From nobody Mon Oct 11 09:15:44 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 912F117F8FF8; Mon, 11 Oct 2021 09:15: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 4HSY743Zrtz3NPW; Mon, 11 Oct 2021 09:15: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 58EC31E901; Mon, 11 Oct 2021 09:15: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 19B9Fij5009380; Mon, 11 Oct 2021 09:15:44 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19B9Fi4g009379; Mon, 11 Oct 2021 09:15:44 GMT (envelope-from git) Date: Mon, 11 Oct 2021 09:15:44 GMT Message-Id: <202110110915.19B9Fi4g009379@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mateusz Guzik Subject: git: e1df0f5dbf59 - stable/13 - vfs: retire VNODE_REFCOUNT_FENCE_* macros List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: e1df0f5dbf591a62b81073cfa523d91477468376 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=e1df0f5dbf591a62b81073cfa523d91477468376 commit e1df0f5dbf591a62b81073cfa523d91477468376 Author: Mateusz Guzik AuthorDate: 2021-09-18 08:14:35 +0000 Commit: Mateusz Guzik CommitDate: 2021-10-11 09:09:35 +0000 vfs: retire VNODE_REFCOUNT_FENCE_* macros They are unused as of last year. (cherry picked from commit 5d8e32a66c1700323c570d25b03672f35f4e0110) --- sys/kern/vfs_subr.c | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index d67936447216..9d0638d1bf38 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -120,22 +120,6 @@ static int v_inval_buf_range_locked(struct vnode *vp, struct bufobj *bo, daddr_t startlbn, daddr_t endlbn); static void vnlru_recalc(void); -/* - * These fences are intended for cases where some synchronization is - * needed between access of v_iflags and lockless vnode refcount (v_holdcnt - * and v_usecount) updates. Access to v_iflags is generally synchronized - * by the interlock, but we have some internal assertions that check vnode - * flags without acquiring the lock. Thus, these fences are INVARIANTS-only - * for now. - */ -#ifdef INVARIANTS -#define VNODE_REFCOUNT_FENCE_ACQ() atomic_thread_fence_acq() -#define VNODE_REFCOUNT_FENCE_REL() atomic_thread_fence_rel() -#else -#define VNODE_REFCOUNT_FENCE_ACQ() -#define VNODE_REFCOUNT_FENCE_REL() -#endif - /* * Number of vnodes in existence. Increased whenever getnewvnode() * allocates a new vnode, decreased in vdropl() for VIRF_DOOMED vnode. From nobody Mon Oct 11 09:15:45 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 36DFA17F9058; Mon, 11 Oct 2021 09:15: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 4HSY754vQmz3Mv3; Mon, 11 Oct 2021 09:15: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 7E1361E4C1; Mon, 11 Oct 2021 09:15: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 19B9Fjd1009404; Mon, 11 Oct 2021 09:15:45 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19B9Fj3B009403; Mon, 11 Oct 2021 09:15:45 GMT (envelope-from git) Date: Mon, 11 Oct 2021 09:15:45 GMT Message-Id: <202110110915.19B9Fj3B009403@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mateusz Guzik Subject: git: 93b14ce63d0a - stable/13 - cache: count vnodes in cache_purgevfs List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 93b14ce63d0a6dc926e8e5fe9394df23e490c3e0 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=93b14ce63d0a6dc926e8e5fe9394df23e490c3e0 commit 93b14ce63d0a6dc926e8e5fe9394df23e490c3e0 Author: Mateusz Guzik AuthorDate: 2021-09-18 08:30:15 +0000 Commit: Mateusz Guzik CommitDate: 2021-10-11 09:09:47 +0000 cache: count vnodes in cache_purgevfs (cherry picked from commit a2cb65b8fe975a8f228258e3057b62e068dbf8e2) --- sys/kern/vfs_cache.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/sys/kern/vfs_cache.c b/sys/kern/vfs_cache.c index 09f926d0cd31..54a87ced2218 100644 --- a/sys/kern/vfs_cache.c +++ b/sys/kern/vfs_cache.c @@ -237,7 +237,7 @@ SDT_PROBE_DEFINE2(vfs, namecache, removecnp, hit, "struct vnode *", "struct componentname *"); SDT_PROBE_DEFINE2(vfs, namecache, removecnp, miss, "struct vnode *", "struct componentname *"); -SDT_PROBE_DEFINE1(vfs, namecache, purge, done, "struct vnode *"); +SDT_PROBE_DEFINE3(vfs, namecache, purge, done, "struct vnode *", "size_t", "size_t"); SDT_PROBE_DEFINE1(vfs, namecache, purge, batch, "int"); SDT_PROBE_DEFINE1(vfs, namecache, purge_negative, done, "struct vnode *"); SDT_PROBE_DEFINE1(vfs, namecache, purgevfs, done, "struct mount *"); @@ -3014,13 +3014,15 @@ void cache_purgevfs(struct mount *mp) { struct vnode *vp, *mvp; + size_t visited, purged; - SDT_PROBE1(vfs, namecache, purgevfs, done, mp); + visited = purged = 0; /* * Somewhat wasteful iteration over all vnodes. Would be better to * support filtering and avoid the interlock to begin with. */ MNT_VNODE_FOREACH_ALL(vp, mp, mvp) { + visited++; if (!cache_has_entries(vp)) { VI_UNLOCK(vp); continue; @@ -3028,8 +3030,11 @@ cache_purgevfs(struct mount *mp) vholdl(vp); VI_UNLOCK(vp); cache_purge(vp); + purged++; vdrop(vp); } + + SDT_PROBE3(vfs, namecache, purgevfs, done, mp, visited, purged); } /* From nobody Mon Oct 11 09:15:46 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id D660517F9130; Mon, 11 Oct 2021 09:15:47 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HSY766mN8z3NVd; Mon, 11 Oct 2021 09:15:46 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id A1D2A1E75B; Mon, 11 Oct 2021 09:15:46 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19B9Fk0X009428; Mon, 11 Oct 2021 09:15:46 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19B9FkMh009427; Mon, 11 Oct 2021 09:15:46 GMT (envelope-from git) Date: Mon, 11 Oct 2021 09:15:46 GMT Message-Id: <202110110915.19B9FkMh009427@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mateusz Guzik Subject: git: 32c7c1d3945f - stable/13 - lockmgr: fix lock profiling of face adaptive spinning List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 32c7c1d3945f9e4b4c59a0f9bc2bdb054dd5b446 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=32c7c1d3945f9e4b4c59a0f9bc2bdb054dd5b446 commit 32c7c1d3945f9e4b4c59a0f9bc2bdb054dd5b446 Author: Mateusz Guzik AuthorDate: 2021-09-11 18:23:51 +0000 Commit: Mateusz Guzik CommitDate: 2021-10-11 09:09:55 +0000 lockmgr: fix lock profiling of face adaptive spinning (cherry picked from commit f902e4bb04ad717935a97ce1ae59e2dd389d940d) --- sys/kern/kern_lock.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/sys/kern/kern_lock.c b/sys/kern/kern_lock.c index c86dad2218d4..e90c55947676 100644 --- a/sys/kern/kern_lock.c +++ b/sys/kern/kern_lock.c @@ -623,6 +623,9 @@ lockmgr_slock_hard(struct lock *lk, u_int flags, struct lock_object *ilk, if (lockmgr_slock_try(lk, &x, flags, false)) break; + lock_profile_obtain_lock_failed(&lk->lock_object, false, + &contested, &waittime); + if ((flags & (LK_ADAPTIVE | LK_INTERLOCK)) == LK_ADAPTIVE) { if (lockmgr_slock_adaptive(&lda, lk, &x, flags)) continue; @@ -631,8 +634,6 @@ lockmgr_slock_hard(struct lock *lk, u_int flags, struct lock_object *ilk, #ifdef HWPMC_HOOKS PMC_SOFT_CALL( , , lock, failed); #endif - lock_profile_obtain_lock_failed(&lk->lock_object, false, - &contested, &waittime); /* * If the lock is expected to not sleep just give up @@ -837,6 +838,10 @@ lockmgr_xlock_hard(struct lock *lk, u_int flags, struct lock_object *ilk, break; continue; } + + lock_profile_obtain_lock_failed(&lk->lock_object, false, + &contested, &waittime); + if ((flags & (LK_ADAPTIVE | LK_INTERLOCK)) == LK_ADAPTIVE) { if (lockmgr_xlock_adaptive(&lda, lk, &x)) continue; @@ -844,8 +849,6 @@ lockmgr_xlock_hard(struct lock *lk, u_int flags, struct lock_object *ilk, #ifdef HWPMC_HOOKS PMC_SOFT_CALL( , , lock, failed); #endif - lock_profile_obtain_lock_failed(&lk->lock_object, false, - &contested, &waittime); /* * If the lock is expected to not sleep just give up From nobody Mon Oct 11 09:15:47 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 66BFB17F9384; Mon, 11 Oct 2021 09:15: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 4HSY781NHqz3NY8; Mon, 11 Oct 2021 09:15: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 CBA931E887; Mon, 11 Oct 2021 09:15: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 19B9FlAU009454; Mon, 11 Oct 2021 09:15:47 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19B9FlNk009453; Mon, 11 Oct 2021 09:15:47 GMT (envelope-from git) Date: Mon, 11 Oct 2021 09:15:47 GMT Message-Id: <202110110915.19B9FlNk009453@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mateusz Guzik Subject: git: fa7ebd573910 - stable/13 - vfs: add the missing vnode interlock in vfs_mountroot_shuffle List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: fa7ebd573910f180e31fedfbd36a984139de72a7 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=fa7ebd573910f180e31fedfbd36a984139de72a7 commit fa7ebd573910f180e31fedfbd36a984139de72a7 Author: Mateusz Guzik AuthorDate: 2021-09-18 08:12:27 +0000 Commit: Mateusz Guzik CommitDate: 2021-10-11 09:10:13 +0000 vfs: add the missing vnode interlock in vfs_mountroot_shuffle Around v_mountedhere assignment. (cherry picked from commit 0d9e99ce3b1071c76ff5a2d9d4158341c0371c2f) --- sys/kern/vfs_mountroot.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sys/kern/vfs_mountroot.c b/sys/kern/vfs_mountroot.c index 4f80104c311c..7adf63db2dac 100644 --- a/sys/kern/vfs_mountroot.c +++ b/sys/kern/vfs_mountroot.c @@ -367,10 +367,12 @@ vfs_mountroot_shuffle(struct thread *td, struct mount *mpdevfs) error = vinvalbuf(vp, V_SAVE, 0, 0); if (!error) { cache_purge(vp); + VI_LOCK(vp); mporoot->mnt_vnodecovered = vp; vp->v_mountedhere = mporoot; strlcpy(mporoot->mnt_stat.f_mntonname, fspath, MNAMELEN); + VI_UNLOCK(vp); VOP_UNLOCK(vp); } else vput(vp); From nobody Mon Oct 11 09:15:48 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id B51E217F91B8; Mon, 11 Oct 2021 09:15: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 4HSY7915B9z3NT5; Mon, 11 Oct 2021 09:15: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 E9CF81E902; Mon, 11 Oct 2021 09:15: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 19B9FmGF009483; Mon, 11 Oct 2021 09:15:48 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19B9Fmx1009482; Mon, 11 Oct 2021 09:15:48 GMT (envelope-from git) Date: Mon, 11 Oct 2021 09:15:48 GMT Message-Id: <202110110915.19B9Fmx1009482@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mateusz Guzik Subject: git: 3bf887780215 - stable/13 - vfs: add missing VIRF_MOUNTPOINT in vfs_mountroot_shuffle List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 3bf887780215223a4a15a7e8207504aa1112acca Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=3bf887780215223a4a15a7e8207504aa1112acca commit 3bf887780215223a4a15a7e8207504aa1112acca Author: Mateusz Guzik AuthorDate: 2021-09-18 08:13:33 +0000 Commit: Mateusz Guzik CommitDate: 2021-10-11 09:10:20 +0000 vfs: add missing VIRF_MOUNTPOINT in vfs_mountroot_shuffle Reported by: mav (cherry picked from commit 7b2ac8eb9be76c96356b6e9a7c06a8080ea841ae) --- sys/kern/vfs_mountroot.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sys/kern/vfs_mountroot.c b/sys/kern/vfs_mountroot.c index 7adf63db2dac..9a3895b6f830 100644 --- a/sys/kern/vfs_mountroot.c +++ b/sys/kern/vfs_mountroot.c @@ -369,6 +369,7 @@ vfs_mountroot_shuffle(struct thread *td, struct mount *mpdevfs) cache_purge(vp); VI_LOCK(vp); mporoot->mnt_vnodecovered = vp; + vn_irflag_set_locked(vp, VIRF_MOUNTPOINT); vp->v_mountedhere = mporoot; strlcpy(mporoot->mnt_stat.f_mntonname, fspath, MNAMELEN); From nobody Mon Oct 11 09:15:49 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 0CED117F9414; Mon, 11 Oct 2021 09:15: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 4HSY7C2llPz3NHb; Mon, 11 Oct 2021 09:15: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 186841E903; Mon, 11 Oct 2021 09:15: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 19B9Fndu009507; Mon, 11 Oct 2021 09:15:49 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19B9Fnw4009506; Mon, 11 Oct 2021 09:15:49 GMT (envelope-from git) Date: Mon, 11 Oct 2021 09:15:49 GMT Message-Id: <202110110915.19B9Fnw4009506@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mateusz Guzik Subject: git: 1ebe8e0fad40 - stable/13 - ipsec: enter epoch before calling into ipsec_run_hhooks List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 1ebe8e0fad409ec16b34c392e823c25ecd42876f Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=1ebe8e0fad409ec16b34c392e823c25ecd42876f commit 1ebe8e0fad409ec16b34c392e823c25ecd42876f Author: Mateusz Guzik AuthorDate: 2021-09-17 12:00:20 +0000 Commit: Mateusz Guzik CommitDate: 2021-10-11 09:10:31 +0000 ipsec: enter epoch before calling into ipsec_run_hhooks pfil_run_hooks which eventually can get called asserts on it. Reviewed by: ae Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D32007 (cherry picked from commit 590d0715b348d0d8da0c0355cebd9dff18e39831) --- sys/netipsec/ipsec_input.c | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/sys/netipsec/ipsec_input.c b/sys/netipsec/ipsec_input.c index 48acba68a1fe..2e2efe34842b 100644 --- a/sys/netipsec/ipsec_input.c +++ b/sys/netipsec/ipsec_input.c @@ -305,7 +305,7 @@ ipsec4_common_input_cb(struct mbuf *m, struct secasvar *sav, int skip, buf, sizeof(buf)), (u_long) ntohl(sav->spi))); IPSEC_ISTAT(sproto, hdrops); error = ENOBUFS; - goto bad; + goto bad_noepoch; } ip = mtod(m, struct ip *); @@ -325,6 +325,11 @@ ipsec4_common_input_cb(struct mbuf *m, struct secasvar *sav, int skip, (prot == IPPROTO_UDP || prot == IPPROTO_TCP)) udp_ipsec_adjust_cksum(m, sav, prot, skip); + /* + * Needed for ipsec_run_hooks and netisr_queue_src + */ + NET_EPOCH_ENTER(et); + IPSEC_INIT_CTX(&ctx, &m, NULL, sav, AF_INET, IPSEC_ENC_BEFORE); if ((error = ipsec_run_hhooks(&ctx, HHOOK_TYPE_IPSEC_IN)) != 0) goto bad; @@ -424,18 +429,19 @@ ipsec4_common_input_cb(struct mbuf *m, struct secasvar *sav, int skip, if (saidx->mode == IPSEC_MODE_TUNNEL) error = ipsec_if_input(m, sav, af); if (error == 0) { - NET_EPOCH_ENTER(et); error = netisr_queue_src(isr_prot, (uintptr_t)sav->spi, m); - NET_EPOCH_EXIT(et); if (error) { IPSEC_ISTAT(sproto, qfull); DPRINTF(("%s: queue full; proto %u packet dropped\n", __func__, sproto)); } } + NET_EPOCH_EXIT(et); key_freesav(&sav); return (error); bad: + NET_EPOCH_EXIT(et); +bad_noepoch: key_freesav(&sav); if (m != NULL) m_freem(m); @@ -512,6 +518,8 @@ ipsec6_common_input_cb(struct mbuf *m, struct secasvar *sav, int skip, sproto == IPPROTO_IPCOMP, ("unexpected security protocol %u", sproto)); + NET_EPOCH_ENTER(et); + /* Fix IPv6 header */ if (m->m_len < sizeof(struct ip6_hdr) && (m = m_pullup(m, sizeof(struct ip6_hdr))) == NULL) { @@ -623,16 +631,15 @@ ipsec6_common_input_cb(struct mbuf *m, struct secasvar *sav, int skip, if (saidx->mode == IPSEC_MODE_TUNNEL) error = ipsec_if_input(m, sav, af); if (error == 0) { - NET_EPOCH_ENTER(et); error = netisr_queue_src(isr_prot, (uintptr_t)sav->spi, m); - NET_EPOCH_EXIT(et); if (error) { IPSEC_ISTAT(sproto, qfull); DPRINTF(("%s: queue full; proto %u packet" " dropped\n", __func__, sproto)); } } + NET_EPOCH_EXIT(et); key_freesav(&sav); return (error); } @@ -642,12 +649,11 @@ ipsec6_common_input_cb(struct mbuf *m, struct secasvar *sav, int skip, */ nest = 0; nxt = nxt8; - NET_EPOCH_ENTER(et); while (nxt != IPPROTO_DONE) { if (V_ip6_hdrnestlimit && (++nest > V_ip6_hdrnestlimit)) { IP6STAT_INC(ip6s_toomanyhdr); error = EINVAL; - goto bad_epoch; + goto bad; } /* @@ -658,7 +664,7 @@ ipsec6_common_input_cb(struct mbuf *m, struct secasvar *sav, int skip, IP6STAT_INC(ip6s_tooshort); in6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_truncated); error = EINVAL; - goto bad_epoch; + goto bad; } /* * Enforce IPsec policy checking if we are seeing last header. @@ -668,16 +674,15 @@ ipsec6_common_input_cb(struct mbuf *m, struct secasvar *sav, int skip, if ((inet6sw[ip6_protox[nxt]].pr_flags & PR_LASTHDR) != 0 && ipsec6_in_reject(m, NULL)) { error = EINVAL; - goto bad_epoch; + goto bad; } nxt = (*inet6sw[ip6_protox[nxt]].pr_input)(&m, &skip, nxt); } NET_EPOCH_EXIT(et); key_freesav(&sav); return (0); -bad_epoch: - NET_EPOCH_EXIT(et); bad: + NET_EPOCH_EXIT(et); key_freesav(&sav); if (m) m_freem(m); From nobody Mon Oct 11 09:15:51 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 70C3517F917D; Mon, 11 Oct 2021 09:15: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 4HSY7C6PFyz3Nbr; Mon, 11 Oct 2021 09:15:51 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 3DC621E627; Mon, 11 Oct 2021 09:15:51 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19B9Fpr9009531; Mon, 11 Oct 2021 09:15:51 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19B9Fpc5009530; Mon, 11 Oct 2021 09:15:51 GMT (envelope-from git) Date: Mon, 11 Oct 2021 09:15:51 GMT Message-Id: <202110110915.19B9Fpc5009530@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mateusz Guzik Subject: git: f312cc6e5627 - stable/13 - fifo: support flock List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: f312cc6e562736e1942ecb2da50c5b58bbbbd850 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=f312cc6e562736e1942ecb2da50c5b58bbbbd850 commit f312cc6e562736e1942ecb2da50c5b58bbbbd850 Author: Mateusz Guzik AuthorDate: 2021-09-25 12:24:39 +0000 Commit: Mateusz Guzik CommitDate: 2021-10-11 09:12:48 +0000 fifo: support flock This evens it up with Linux. Original patch by: Greg V Differential Revision: https://reviews.freebsd.org/D24255#565302 (cherry picked from commit d71e1a883c92b8b166eea59734850acd54048d72) --- sys/fs/fifofs/fifo_vnops.c | 4 +++- sys/kern/kern_descrip.c | 16 ++++++++++------ sys/kern/vfs_vnops.c | 2 +- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/sys/fs/fifofs/fifo_vnops.c b/sys/fs/fifofs/fifo_vnops.c index 861f1b40a744..1b941620b080 100644 --- a/sys/fs/fifofs/fifo_vnops.c +++ b/sys/fs/fifofs/fifo_vnops.c @@ -376,5 +376,7 @@ fifo_advlock(ap) } */ *ap; { - return (ap->a_flags & F_FLOCK ? EOPNOTSUPP : EINVAL); + if ((ap->a_flags & F_FLOCK) == 0) + return (EINVAL); + return (vop_stdadvlock(ap)); } diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c index ed7fe83cf02f..58c2d1939dba 100644 --- a/sys/kern/kern_descrip.c +++ b/sys/kern/kern_descrip.c @@ -3560,11 +3560,15 @@ sys_flock(struct thread *td, struct flock_args *uap) error = fget(td, uap->fd, &cap_flock_rights, &fp); if (error != 0) return (error); - if (fp->f_type != DTYPE_VNODE || fp->f_ops == &path_fileops) { - fdrop(fp, td); - return (EOPNOTSUPP); + error = EOPNOTSUPP; + if (fp->f_type != DTYPE_VNODE && fp->f_type != DTYPE_FIFO) { + goto done; + } + if (fp->f_ops == &path_fileops) { + goto done; } + error = 0; vp = fp->f_vnode; lf.l_whence = SEEK_SET; lf.l_start = 0; @@ -3573,7 +3577,7 @@ sys_flock(struct thread *td, struct flock_args *uap) lf.l_type = F_UNLCK; atomic_clear_int(&fp->f_flag, FHASLOCK); error = VOP_ADVLOCK(vp, (caddr_t)fp, F_UNLCK, &lf, F_FLOCK); - goto done2; + goto done; } if (uap->how & LOCK_EX) lf.l_type = F_WRLCK; @@ -3581,12 +3585,12 @@ sys_flock(struct thread *td, struct flock_args *uap) lf.l_type = F_RDLCK; else { error = EBADF; - goto done2; + goto done; } atomic_set_int(&fp->f_flag, FHASLOCK); error = VOP_ADVLOCK(vp, (caddr_t)fp, F_SETLK, &lf, (uap->how & LOCK_NB) ? F_FLOCK : F_FLOCK | F_WAIT); -done2: +done: fdrop(fp, td); return (error); } diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c index 8ff78b9d6319..e8d6df5c4193 100644 --- a/sys/kern/vfs_vnops.c +++ b/sys/kern/vfs_vnops.c @@ -1826,7 +1826,7 @@ vn_closefile(struct file *fp, struct thread *td) vp = fp->f_vnode; fp->f_ops = &badfileops; - ref = (fp->f_flag & FHASLOCK) != 0 && fp->f_type == DTYPE_VNODE; + ref = (fp->f_flag & FHASLOCK) != 0; error = vn_close1(vp, fp->f_flag, fp->f_cred, td, ref); From nobody Mon Oct 11 09:15:52 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 96A4117F91E3; Mon, 11 Oct 2021 09:15: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 4HSY7D4z3tz3NHl; Mon, 11 Oct 2021 09:15: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 65F8C1E80A; Mon, 11 Oct 2021 09:15: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 19B9Fqx5009555; Mon, 11 Oct 2021 09:15:52 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19B9FqRK009554; Mon, 11 Oct 2021 09:15:52 GMT (envelope-from git) Date: Mon, 11 Oct 2021 09:15:52 GMT Message-Id: <202110110915.19B9FqRK009554@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mateusz Guzik Subject: git: 7890bcbc152e - stable/13 - mmc: fix 1-byte reallocs (when it should have been sizeof device_t) List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 7890bcbc152e2c9f2d0f99342b6e1cf4197c2a35 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=7890bcbc152e2c9f2d0f99342b6e1cf4197c2a35 commit 7890bcbc152e2c9f2d0f99342b6e1cf4197c2a35 Author: Mateusz Guzik AuthorDate: 2021-09-25 12:49:43 +0000 Commit: Mateusz Guzik CommitDate: 2021-10-11 09:12:55 +0000 mmc: fix 1-byte reallocs (when it should have been sizeof device_t) Reported by KASAN: panic: ASan: Invalid access, 8-byte write at 0xfffffe00f0992610, RedZonePartial(1) panic() at panic+0xb5/frame 0xffffffff86a595b0 __asan_store8_noabort() at __asan_store8_noabort+0x376/frame 0xffffffff86a59670 mmc_go_discovery() at mmc_go_discovery+0x6c61/frame 0xffffffff86a5a790 mmc_delayed_attach() at mmc_delayed_attach+0x35/frame 0xffffffff86a5a7b0 [snip] Sponsored by: Rubicon Communications, LLC ("Netgate") (cherry picked from commit 13c63ae08df43d4e662b73ea3e05137fff88e639) --- sys/dev/mmc/mmc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/dev/mmc/mmc.c b/sys/dev/mmc/mmc.c index 47df562e73fd..6e1d55639284 100644 --- a/sys/dev/mmc/mmc.c +++ b/sys/dev/mmc/mmc.c @@ -1926,7 +1926,7 @@ child_common: if (child != NULL) { device_set_ivars(child, ivar); sc->child_list = realloc(sc->child_list, - sizeof(device_t) * sc->child_count + 1, + sizeof(device_t) * (sc->child_count + 1), M_DEVBUF, M_WAITOK); sc->child_list[sc->child_count++] = child; } else From nobody Mon Oct 11 09:15:55 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 3687A17F92EE; Mon, 11 Oct 2021 09:15: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 4HSY7J1MDwz3Nhf; Mon, 11 Oct 2021 09:15: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 C406D1E904; Mon, 11 Oct 2021 09:15: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 19B9FtdR009633; Mon, 11 Oct 2021 09:15:55 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19B9FtIk009632; Mon, 11 Oct 2021 09:15:55 GMT (envelope-from git) Date: Mon, 11 Oct 2021 09:15:55 GMT Message-Id: <202110110915.19B9FtIk009632@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mateusz Guzik Subject: git: 0e89914326ec - stable/13 - vfs: hoist cn_thread assert in namei List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 0e89914326ec11d4c1685e8ecb14f6349ea8f591 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=0e89914326ec11d4c1685e8ecb14f6349ea8f591 commit 0e89914326ec11d4c1685e8ecb14f6349ea8f591 Author: Mateusz Guzik AuthorDate: 2021-10-01 21:13:38 +0000 Commit: Mateusz Guzik CommitDate: 2021-10-11 09:13:35 +0000 vfs: hoist cn_thread assert in namei Making it condtional on whether ktrace happens to be enabled makes no sense. (cherry picked from commit c9536389d732feecf61afa4632397d67b04b2ab4) --- sys/kern/vfs_lookup.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/kern/vfs_lookup.c b/sys/kern/vfs_lookup.c index a827c87538b8..454a10175e1b 100644 --- a/sys/kern/vfs_lookup.c +++ b/sys/kern/vfs_lookup.c @@ -556,6 +556,8 @@ namei(struct nameidata *ndp) cnp = &ndp->ni_cnd; td = cnp->cn_thread; #ifdef INVARIANTS + KASSERT(cnp->cn_thread == curthread, + ("namei not using curthread")); KASSERT((ndp->ni_debugflags & NAMEI_DBG_CALLED) == 0, ("%s: repeated call to namei without NDREINIT", __func__)); KASSERT(ndp->ni_debugflags == NAMEI_DBG_INITED, @@ -610,8 +612,6 @@ namei(struct nameidata *ndp) #ifdef KTRACE if (KTRPOINT(td, KTR_NAMEI)) { - KASSERT(cnp->cn_thread == curthread, - ("namei not using curthread")); ktrnamei(cnp->cn_pnbuf); } #endif From nobody Mon Oct 11 09:15:54 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 79CD417F9567; Mon, 11 Oct 2021 09:15: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 4HSY7H0SMRz3NTb; Mon, 11 Oct 2021 09:15: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 AC1A61E79F; Mon, 11 Oct 2021 09:15: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 19B9FsVD009609; Mon, 11 Oct 2021 09:15:54 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19B9Fsni009608; Mon, 11 Oct 2021 09:15:54 GMT (envelope-from git) Date: Mon, 11 Oct 2021 09:15:54 GMT Message-Id: <202110110915.19B9Fsni009608@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mateusz Guzik Subject: git: cda5e344e251 - stable/13 - linprocfs: find cwd and root handling List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: cda5e344e2511a8c4119cdfcd3953807ba54bdee Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=cda5e344e2511a8c4119cdfcd3953807ba54bdee commit cda5e344e2511a8c4119cdfcd3953807ba54bdee Author: Mateusz Guzik AuthorDate: 2021-09-30 10:50:18 +0000 Commit: Mateusz Guzik CommitDate: 2021-10-11 09:13:29 +0000 linprocfs: find cwd and root handling The code would incorrectly use curthread instead of the target proc to resolve vnodes. Fixes: 8d03b99b9dafe928 ("fd: move vnodes out of filedesc into a dedicated structure") PR: 258729 Noted by: Damjan Jovanovic (cherry picked from commit 69ab52838655912cf89699e0b2d21d244d3b9b27) --- 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 79ffc4dfd5aa..d29bcda47ec0 100644 --- a/sys/compat/linprocfs/linprocfs.c +++ b/sys/compat/linprocfs/linprocfs.c @@ -1169,7 +1169,7 @@ linprocfs_doproccwd(PFS_FILL_ARGS) char *fullpath = "unknown"; char *freepath = NULL; - pwd = pwd_hold(td); + pwd = pwd_hold_proc(p); vn_fullpath(pwd->pwd_cdir, &fullpath, &freepath); sbuf_printf(sb, "%s", fullpath); if (freepath) @@ -1189,7 +1189,7 @@ linprocfs_doprocroot(PFS_FILL_ARGS) char *fullpath = "unknown"; char *freepath = NULL; - pwd = pwd_hold(td); + pwd = pwd_hold_proc(p); vp = jailed(p->p_ucred) ? pwd->pwd_jdir : pwd->pwd_rdir; vn_fullpath(vp, &fullpath, &freepath); sbuf_printf(sb, "%s", fullpath); From nobody Mon Oct 11 09:15:53 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id BE37317F956C; Mon, 11 Oct 2021 09:15: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 4HSY7G21Gqz3NFw; Mon, 11 Oct 2021 09:15: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 8C0511E79E; Mon, 11 Oct 2021 09:15: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 19B9FrgB009579; Mon, 11 Oct 2021 09:15:53 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19B9FrTl009578; Mon, 11 Oct 2021 09:15:53 GMT (envelope-from git) Date: Mon, 11 Oct 2021 09:15:53 GMT Message-Id: <202110110915.19B9FrTl009578@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mateusz Guzik Subject: git: e6014341647f - stable/13 - fd: add pwd_hold_proc List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: e6014341647f9a45dab9d09f57d475c50137e6b6 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=e6014341647f9a45dab9d09f57d475c50137e6b6 commit e6014341647f9a45dab9d09f57d475c50137e6b6 Author: Mateusz Guzik AuthorDate: 2021-09-30 10:49:51 +0000 Commit: Mateusz Guzik CommitDate: 2021-10-11 09:13:03 +0000 fd: add pwd_hold_proc (cherry picked from commit 85c855d31b18d7a8ab534259f27444c81b6ec797) --- sys/kern/kern_descrip.c | 20 ++++++++++++++++++++ sys/sys/filedesc.h | 1 + 2 files changed, 21 insertions(+) diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c index 58c2d1939dba..755b5df51c6a 100644 --- a/sys/kern/kern_descrip.c +++ b/sys/kern/kern_descrip.c @@ -3791,6 +3791,26 @@ pwd_hold(struct thread *td) return (pwd); } +struct pwd * +pwd_hold_proc(struct proc *p) +{ + struct pwddesc *pdp; + struct pwd *pwd; + + PROC_ASSERT_HELD(p); + PROC_LOCK(p); + pdp = pdhold(p); + MPASS(pdp != NULL); + PROC_UNLOCK(p); + + PWDDESC_XLOCK(pdp); + pwd = pwd_hold_pwddesc(pdp); + MPASS(pwd != NULL); + PWDDESC_XUNLOCK(pdp); + pddrop(pdp); + return (pwd); +} + static struct pwd * pwd_alloc(void) { diff --git a/sys/sys/filedesc.h b/sys/sys/filedesc.h index 7f18d8a2286c..f17fdf601ba1 100644 --- a/sys/sys/filedesc.h +++ b/sys/sys/filedesc.h @@ -341,6 +341,7 @@ void pwd_set_rootvnode(void); struct pwd *pwd_hold_pwddesc(struct pwddesc *pdp); bool pwd_hold_smr(struct pwd *pwd); +struct pwd *pwd_hold_proc(struct proc *p); struct pwd *pwd_hold(struct thread *td); void pwd_drop(struct pwd *pwd); static inline void From nobody Mon Oct 11 12:16:03 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id CEC431340742; Mon, 11 Oct 2021 12:16:03 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HSd77568Zz4Z2B; Mon, 11 Oct 2021 12:16:03 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 8F4A220E40; Mon, 11 Oct 2021 12:16:03 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19BCG3q7049028; Mon, 11 Oct 2021 12:16:03 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19BCG3cV049027; Mon, 11 Oct 2021 12:16:03 GMT (envelope-from git) Date: Mon, 11 Oct 2021 12:16:03 GMT Message-Id: <202110111216.19BCG3cV049027@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Andrew Turner Subject: git: 00c276a25024 - stable/13 - Use a 64 bit read to access GICR_TYPER List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: andrew X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 00c276a2502488f4198dcec4bf1a6d22159e2b62 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by andrew: URL: https://cgit.FreeBSD.org/src/commit/?id=00c276a2502488f4198dcec4bf1a6d22159e2b62 commit 00c276a2502488f4198dcec4bf1a6d22159e2b62 Author: Andrew Turner AuthorDate: 2021-09-15 09:13:41 +0000 Commit: Andrew Turner CommitDate: 2021-10-11 10:50:42 +0000 Use a 64 bit read to access GICR_TYPER The GICv3 ITS only needs to implement 32 bit access to the GICR_TYPER when the CPU implements AArch32. As this may not always be the case use a 64 bit read when checking if the ITS is enabled on the CPU. PR: 258217 Reported by: Olivier Delande Sponsored by: The FreeBSD Foundation (cherry picked from commit 1896a0094317c80d46beff5ad42b68215513c996) --- sys/arm64/arm64/gicv3_its.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/arm64/arm64/gicv3_its.c b/sys/arm64/arm64/gicv3_its.c index 061d5a1dbdb9..9c058dbe7f99 100644 --- a/sys/arm64/arm64/gicv3_its.c +++ b/sys/arm64/arm64/gicv3_its.c @@ -708,7 +708,7 @@ its_init_cpu(device_t dev, struct gicv3_its_softc *sc) return (0); /* Check if the ITS is enabled on this CPU */ - if ((gic_r_read_4(gicv3, GICR_TYPER) & GICR_TYPER_PLPIS) == 0) + if ((gic_r_read_8(gicv3, GICR_TYPER) & GICR_TYPER_PLPIS) == 0) return (ENXIO); rpcpu = gicv3_get_redist(dev); From nobody Mon Oct 11 12:16:04 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id E288B13408CD; Mon, 11 Oct 2021 12:16: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 4HSd7865Wwz4ZLC; Mon, 11 Oct 2021 12:16: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 B1DFF20D17; Mon, 11 Oct 2021 12:16: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 19BCG4hZ049052; Mon, 11 Oct 2021 12:16:04 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19BCG4md049051; Mon, 11 Oct 2021 12:16:04 GMT (envelope-from git) Date: Mon, 11 Oct 2021 12:16:04 GMT Message-Id: <202110111216.19BCG4md049051@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Andrew Turner Subject: git: cebda3bec001 - stable/13 - Add ELF macros found in the aaelf64 spec List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: andrew X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: cebda3bec001ae8182fb2f663af5b4d554f842fe Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by andrew: URL: https://cgit.FreeBSD.org/src/commit/?id=cebda3bec001ae8182fb2f663af5b4d554f842fe commit cebda3bec001ae8182fb2f663af5b4d554f842fe Author: Andrew Turner AuthorDate: 2021-09-20 08:55:44 +0000 Commit: Andrew Turner CommitDate: 2021-10-11 10:50:42 +0000 Add ELF macros found in the aaelf64 spec The arm64 aaelf64 spec [0] has DT_AARCH64_ that could be used with dynamic linking. It also adds GNU_PROPERTY_AARCH64_FEATURE_1_AND used to tell the kernel which CPU features the binary is compatible with, but does not require to execute correctly. Add these values so the kernel and elf tools can make use of them. [0] https://github.com/ARM-software/abi-aa/blob/2021Q1/aaelf64/aaelf64.rst Sponsored by: The FreeBSD Foundation (cherry picked from commit b94d360e4aa66d626ad5a0acde683ae9a9c71729) --- sys/sys/elf_common.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/sys/sys/elf_common.h b/sys/sys/elf_common.h index 76bda8f71f3b..d914ab8d4731 100644 --- a/sys/sys/elf_common.h +++ b/sys/sys/elf_common.h @@ -678,6 +678,10 @@ typedef struct { #define DT_LOPROC 0x70000000 /* First processor-specific type. */ +#define DT_AARCH64_BTI_PLT 0x70000001 +#define DT_AARCH64_PAC_PLT 0x70000003 +#define DT_AARCH64_VARIANT_PCS 0x70000005 + #define DT_ARM_SYMTABSZ 0x70000001 #define DT_ARM_PREEMPTMAP 0x70000002 @@ -829,6 +833,11 @@ typedef struct { #define GNU_PROPERTY_LOPROC 0xc0000000 #define GNU_PROPERTY_HIPROC 0xdfffffff +#define GNU_PROPERTY_AARCH64_FEATURE_1_AND 0xc0000000 + +#define GNU_PROPERTY_AARCH64_FEATURE_1_BTI 0x00000001 +#define GNU_PROPERTY_AARCH64_FEATURE_1_PAC 0x00000002 + #define GNU_PROPERTY_X86_FEATURE_1_AND 0xc0000002 #define GNU_PROPERTY_X86_FEATURE_1_IBT 0x00000001 From nobody Mon Oct 11 12:16:05 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4AC2F13407B4; Mon, 11 Oct 2021 12:16: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 4HSd7B3MnRz4Z2F; Mon, 11 Oct 2021 12:16:06 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id D2F4620F06; Mon, 11 Oct 2021 12:16: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 19BCG5eO049082; Mon, 11 Oct 2021 12:16:05 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19BCG5Ci049081; Mon, 11 Oct 2021 12:16:05 GMT (envelope-from git) Date: Mon, 11 Oct 2021 12:16:05 GMT Message-Id: <202110111216.19BCG5Ci049081@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Andrew Turner Subject: git: 1dac7b4b7ed6 - stable/13 - Fix the arm64 L2_BLOCK_MASK definition List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: andrew X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 1dac7b4b7ed6f30d088ac54f0dbf73d02fcad2c1 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by andrew: URL: https://cgit.FreeBSD.org/src/commit/?id=1dac7b4b7ed6f30d088ac54f0dbf73d02fcad2c1 commit 1dac7b4b7ed6f30d088ac54f0dbf73d02fcad2c1 Author: Andrew Turner AuthorDate: 2021-09-21 13:46:10 +0000 Commit: Andrew Turner CommitDate: 2021-10-11 10:50:42 +0000 Fix the arm64 L2_BLOCK_MASK definition It was missing the top 16 bits. Sponsored by: The FreeBSD Foundation (cherry picked from commit 5a619ca07a2d6614b7b4ecbb7078d0949702dcd2) --- sys/arm64/include/pte.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/arm64/include/pte.h b/sys/arm64/include/pte.h index 5d4412d2c141..b3bec720e9f9 100644 --- a/sys/arm64/include/pte.h +++ b/sys/arm64/include/pte.h @@ -125,7 +125,7 @@ typedef uint64_t pt_entry_t; /* page table entry */ #define L2_BLOCK L1_BLOCK #define L2_TABLE L1_TABLE -#define L2_BLOCK_MASK UINT64_C(0xffffffe00000) +#define L2_BLOCK_MASK UINT64_C(0xffffffffffe00000) /* Level 3 table, 4KiB per entry */ #define L3_SHIFT 12 From nobody Mon Oct 11 13:57:52 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 8733C17E4629; Mon, 11 Oct 2021 13:57:52 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HSgNc3QNNz4mdv; Mon, 11 Oct 2021 13:57:52 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 516D121FE6; Mon, 11 Oct 2021 13:57: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 19BDvq7D081992; Mon, 11 Oct 2021 13:57:52 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19BDvqx1081991; Mon, 11 Oct 2021 13:57:52 GMT (envelope-from git) Date: Mon, 11 Oct 2021 13:57:52 GMT Message-Id: <202110111357.19BDvqx1081991@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Marcin Wojtas Subject: git: 14721190e829 - stable/12 - pci_user: call bus_translate_resource before BAR mmap List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mw X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 14721190e8298199a6cfbb6d2568ea1d17e7a107 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by mw: URL: https://cgit.FreeBSD.org/src/commit/?id=14721190e8298199a6cfbb6d2568ea1d17e7a107 commit 14721190e8298199a6cfbb6d2568ea1d17e7a107 Author: Marcin Wojtas AuthorDate: 2021-04-06 15:10:04 +0000 Commit: Marcin Wojtas CommitDate: 2021-10-11 13:40:11 +0000 pci_user: call bus_translate_resource before BAR mmap On some armv8 machines it is possible that the mapping between CPU and PCI bus BAR base addresses is not 1:1. In case a BAR is allocated in kernel using bus_alloc_resource_any this translation is handled in ofw_pci_activate_resource. Do the same in pci_user.c by calling bus_translate_resource devmethod. This fixes mmaping BARs to userspace on Marvell SoCs (Armada 7k8k/CN913x) and possibly many other platforms. Submitted by: Kornel Duleba Reviewed by: kib Obtained from: Semihalf Sponsored by: Marvell MFC after: 2 weeks Differential revision: https://reviews.freebsd.org/D29604 (cherry picked from commit f2f1ab39c04088ce53287528549e652cf68cee09) pci_user: fix build for 32-bit platforms Commit: f2f1ab39c040 ("pci_user: call bus_translate_resource before BAR mmap") broke build for 32-bit platforms due to rman_res_t and vm_paddr_t incompatible types. Fix that. (cherry picked from commit 9857e00a528bb230c8935ded5f118a7374bf808b) --- sys/dev/pci/pci_user.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/sys/dev/pci/pci_user.c b/sys/dev/pci/pci_user.c index 9e3842acf889..54ddb5796cc8 100644 --- a/sys/dev/pci/pci_user.c +++ b/sys/dev/pci/pci_user.c @@ -855,7 +855,7 @@ pci_bar_mmap(device_t pcidev, struct pci_bar_mmap *pbm) struct thread *td; struct sglist *sg; struct pci_map *pm; - vm_paddr_t membase; + rman_res_t membase; vm_paddr_t pbase; vm_size_t plen; vm_offset_t addr; @@ -878,7 +878,11 @@ pci_bar_mmap(device_t pcidev, struct pci_bar_mmap *pbm) return (EBUSY); /* XXXKIB enable if _ACTIVATE */ if (!PCI_BAR_MEM(pm->pm_value)) return (EIO); - membase = pm->pm_value & PCIM_BAR_MEM_BASE; + error = BUS_TRANSLATE_RESOURCE(pcidev, SYS_RES_MEMORY, + pm->pm_value & PCIM_BAR_MEM_BASE, &membase); + if (error != 0) + return (error); + pbase = trunc_page(membase); plen = round_page(membase + ((pci_addr_t)1 << pm->pm_size)) - pbase; From nobody Mon Oct 11 14:32:42 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 924A717E82EE; Mon, 11 Oct 2021 14:32:42 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HSh8p3dPCz4q3y; Mon, 11 Oct 2021 14:32:42 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 5C18822A96; Mon, 11 Oct 2021 14:32:42 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19BEWg1P035380; Mon, 11 Oct 2021 14:32:42 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19BEWgXb035379; Mon, 11 Oct 2021 14:32:42 GMT (envelope-from git) Date: Mon, 11 Oct 2021 14:32:42 GMT Message-Id: <202110111432.19BEWgXb035379@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Marcin Wojtas Subject: git: d09aeecae080 - stable/12 - Upgrade ENA to v2.4.0 List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mw X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: d09aeecae080c05ac277ac6c938e43b4cb198f05 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by mw: URL: https://cgit.FreeBSD.org/src/commit/?id=d09aeecae080c05ac277ac6c938e43b4cb198f05 commit d09aeecae080c05ac277ac6c938e43b4cb198f05 Author: Marcin Wojtas AuthorDate: 2021-06-14 08:57:45 +0000 Commit: Marcin Wojtas CommitDate: 2021-10-11 14:31:50 +0000 Upgrade ENA to v2.4.0 Approved by: re ena: change ENA C++-style comment into C-style According to man style(9), only C-style comments should be used. Submitted by: Michal Krawczyk Obtained from: Semihalf MFC after: 2 weeks Sponsored by: Amazon, Inc. (cherry picked from commit 438c9e3cf89403628ec237cfecdd0538f208087b) ena: add support for the large LLQ headers in ENA Default LLQ (Low-latency queue) maximum header size is 96 bytes and can be too small for some types of packets - like IPv6 packets with multiple extension. This can be fixed, by using large LLQ headers. If the device supports larger LLQ headers, the user can activate this feature by setting sysctl tunable 'hw.ena.force_large_llq_header' to '1' in the /boot/loader.conf file. In case the device isn't supporting this feature, the default value (96B) will be used. Submitted by: Michal Krawczyk Obtained from: Semihalf MFC after: 2 weeks Sponsored by: Amazon, Inc. (cherry picked from commit beaadec9eaec8e6b266faff3b0880a141728fcef) ena: remove surplus NULL checks when freeing ENA resources Calling free on a NULL pointer is valid, as appropriate check is already done internally: /* free(NULL, ...) does nothing */ if (addr == NULL) return; Submitted by: Artur Rojek Obtained from: Semihalf MFC after: 2 weeks Sponsored by: Amazon, Inc. (cherry picked from commit ddec69e6a796283497ebada0569f34bd41bbdf37) ena: hide sysctl nodes for unused ENA queues IO queue related attributes are registered statically at driver attach with the rest of the ENA specific sysctl nodes. However, the number of queues can be changed at runtime via the `ena_sysctl_io_queues_nb` request, leading to a potential exposure of attributes for non-existing queues. Introduce a new `ena_sysctl_update_queue_node_nb` function, which updates the sysctl nodes after the number of queues is altered. This happens by either registering or unregistering node specific oids, based on a delta between the previous and current queue count. NOTE: All unregistered oids must be registered again before the driver detach, e.g. by another call to this function. Submitted by: Artur Rojek Obtained from: Semihalf MFC after: 2 weeks Sponsored by: Amazon, Inc. (cherry picked from commit 0e7d31f63b9db869c91228d8ed1e984bdee2b931) Merge tag 'vendor/ena-com/2.4.0' Update the driver in order not to break its compilation and make use of the new ENA logging system Migrate platform code to the new logging system provided by ena_com layer. Make ENA_INFO the new default log level. Remove all explicit use of `device_printf`, all new logs requiring one of the log macros to be used. (cherry picked from commit 3fc5d816f8831d6fc2816ac97bd78dc486cd080c) Update ENA driver man page Bring the obsolete man page up to date: * update diagnostic error messages * add documentation of loader tunables * document netmap support * add a driver history section * update the contact information Submitted by: Artur Rojek Submitted by: Michal Krawczyk Obtained from: Semihalf MFC after: 2 weeks Sponsored by: Amazon, Inc. (cherry picked from commit e34856a2c44a45512463aed0d1794f34258c66ee) Update ENA version to v2.4.0 Some of the changes in this release: * Large LLQ headers, * Bug/stability fixes, * Change of the README/Documentation. Submitted by: Michal Krawczyk Obtained from: Semihalf MFC after: 2 weeks Sponsored by: Amazon, Inc. (cherry picked from commit 93f0df457bf1d0e5f71839ab969c94d1f95813fb) --- share/man/man4/ena.4 | 272 +++++++++++++++--- sys/contrib/ena-com/ena_com.c | 37 +-- sys/contrib/ena-com/ena_com.h | 6 +- sys/contrib/ena-com/ena_defs/ena_admin_defs.h | 23 +- sys/contrib/ena-com/ena_defs/ena_gen_info.h | 6 +- sys/contrib/ena-com/ena_eth_com.c | 4 +- sys/contrib/ena-com/ena_fbsd_log.h | 74 +++++ sys/contrib/ena-com/ena_plat.h | 37 +-- sys/dev/ena/ena.c | 392 ++++++++++++++------------ sys/dev/ena/ena.h | 5 +- sys/dev/ena/ena_datapath.c | 85 +++--- sys/dev/ena/ena_netmap.c | 73 ++--- sys/dev/ena/ena_sysctl.c | 91 ++++-- sys/dev/ena/ena_sysctl.h | 7 +- 14 files changed, 744 insertions(+), 368 deletions(-) diff --git a/share/man/man4/ena.4 b/share/man/man4/ena.4 index d73413f9a7b0..bc1927608b04 100644 --- a/share/man/man4/ena.4 +++ b/share/man/man4/ena.4 @@ -29,7 +29,7 @@ .\" .\" $FreeBSD$ .\" -.Dd August 16, 2017 +.Dd June 4, 2021 .Dt ENA 4 .Os .Sh NAME @@ -86,7 +86,13 @@ debug logs. .Pp Some of the ENA devices support a working mode called Low-latency Queue (LLQ), which saves several more microseconds. -This feature will be implemented for driver in future releases. +.Pp +Support for the +.Xr netmap 4 +framework is provided by the +.Nm +driver. +Kernel must be built with the DEV_NETMAP option to be able to use this feature. .Sh HARDWARE Supported PCI vendor ID/device IDs: .Pp @@ -100,8 +106,172 @@ Supported PCI vendor ID/device IDs: .It 1d0f:ec21 - ENA VF with LLQ support .El +.Sh LOADER TUNABLES +The +.Nm +driver's behavior can be changed using run-time or boot-time sysctl +arguments. +The boot-time arguments can be set at the +.Xr loader 8 +prompt before booting the kernel, or stored in the +.Xr loader.conf 5 . +The run-time arguments can be set using the +.Xr sysctl 8 +command. +.Pp +Boot-time tunables: +.Bl -tag -width indent +.It Va hw.ena.enable_9k_mbufs +Use 9k mbufs for the Rx descriptors. +The default is 0. +If the node value is set to 1, 9k mbufs will be used for the Rx buffers. +If set to 0, page size mbufs will be used instead. +.Pp +Using 9k buffers for Rx can improve Rx throughput, but in low memory conditions +it might increase allocation time, as the system has to look for 3 contiguous +pages. +This can further lead to OS instability, together with ENA driver reset and NVMe +timeouts. +If network performance is critical and memory capacity is sufficient, the 9k +mbufs can be used. +.It Va hw.ena.force_large_llq_headers +Force the driver to use large LLQ headers (224 bytes). +The default is 0. +If the node value is set to 0, the regular size LLQ header will be used, which +is 96B. +In some cases, the packet header can be bigger than this (for example - +IPv6 with multiple extensions). +In such a situation, the large LLQ headers should be used by setting this node +value to 1. +This will take effect only if the device supports both LLQ and large LLQ +headers. +Otherwise, it will fallback to the no LLQ mode or regular header size. +.Pp +Increasing LLQ header size reduces the size of the Tx queue by half, so it may +affect the number of dropped Tx packets. +.El +.Pp +Run-time tunables: +.Bl -tag -width indent +.It Va hw.ena.log_level +Controls extra logging verbosity of the driver. +The default is 2. +The higher the logging level, the more logs will be printed out. 0 means all +extra logs are disabled and only error logs will be printed out. +Default value (2) reports errors, warnings and is verbose about driver +operation. +.Pp +The possible flags are: +.Pp +.Bl -bullet -compact +.It +0 - ENA_ERR - Enable driver error messages and ena_com error logs. +.It +1 - ENA_WARN - Enable logs for non-critical errors. +.It +2 - ENA_INFO - Make the driver more verbose about its actions. +.It +3 - ENA_DBG - Enable debug logs. +.El +.Pp +NOTE: In order to enable logging on the Tx/Rx data path, driver must be compiled +with ENA_LOG_IO_ENABLE compilation flag. +.Pp +Example: +To enable logs for errors and warnings, the following command should be used: +.Bd -literal -offset indent +sysctl hw.ena.log_level=1 +.Ed +.It Va dev.ena.X.io_queues_nb +Number of the currently allocated and used IO queues. +The default is max_num_io_queues. +Controls the number of IO queue pairs (Tx/Rx). As this call has to reallocate +the queues, it will reset the interface and restart all the queues - this means +that everything, which was currently held in the queue, will be lost, leading to +potential packet drops. +.Pp +This call can fail if the system isn't able to provide the driver with enough +resources. +In that situation, the driver will try to revert the previous number of the IO +queues. +If this also fails, the device reset will be triggered. +.Pp +Example: +To use only 2 Tx and Rx queues for the device ena1, the following command should +be used: +.Bd -literal -offset indent +sysctl dev.ena.1.io_queues_nb=2 +.Ed +.It Va dev.ena.X.rx_queue_size +Size of the Rx queue. +The default is 1024. +Controls the number of IO descriptors for each Rx queue. +The user may want to increase the Rx queue size if they observe a high number of +Rx drops in the driver's statistics. +For performance reasons, the Rx queue size must be a power of 2. +.Pp +This call can fail if the system isn't able to provide the driver with enough +resources. +In that situation, the driver will try to revert to the previous number of the +descriptors. +If this also fails, the device reset will be triggered. +.Pp +Example: +To increase Rx ring size to 8K descriptors for the device ena0, the following +command should be used: +.Bd -literal -offset indent +sysctl dev.ena.0.rx_queue_size=8192 +.Ed +.It Va dev.ena.X.buf_ring_size +Size of the Tx buffer ring (drbr). +The default is 4096. +Input must be a power of 2. +Controls the number of mbufs that can be held in the Tx buffer ring. +The drbr is used as a multiple-producer, single-consumer lockless ring for +buffering extra mbufs coming from the stack in case the Tx procedure is busy +sending the packets, or the Tx ring is full. +Increasing the size of the buffer ring may reduce the number of Tx packets being +dropped in case of a big Tx burst, which cannot be handled by the IO queue +immediately. +Each Tx queue has its own drbr. +.Pp +It is recommended to keep the drbr with at least the default value, but in case +the system lacks the resources, it can be reduced. +This call can fail if the system is not able to provide the driver with enough +resources. +In that situation, the driver will try to revert to the previous number of the +drbr and trigger the device reset. +.Pp +Example: +To set drbr size for interface ena0 to 2048, the following command should +be used: +.Bd -literal -offset indent +sysctl dev.ena.0.buf_ring_size=2048 +.Ed +.It Va dev.ena.X.eni_metrics.sample_interval +Interval in seconds for updating ENI metrics. +The default is 0. +Determines how often (if ever) the ENI metrics should be updated. +The ENI metrics are being updated asynchronously in a timer service in order to +avoid admin queue overload by sysctl node reading. +The value in this node controls the interval between issuing admin commands to +the device, which will update the ENI metrics values. +.Pp +If some application is periodically monitoring the eni_metrics, then the ENI +metrics interval can be adjusted accordingly. +Value 0 turns off the update completely. +Value 1 is the minimum interval and is equal to 1 second. +The maximum allowed update interval is 1 hour. +.Pp +Example: +To update ENI metrics for the device ena1 every 10 seconds, the following +command should be used: +.Bd -literal -offset indent +sysctl dev.ena.1.eni_metrics.sample_interval=10 +.Ed +.El .Sh DIAGNOSTICS -.Ss Device initialization phase: +.Ss Device initialization phase .Bl -diag .It ena%d: failed to init mmio read less .Pp @@ -116,7 +286,7 @@ Device may not be responding or is already during reset. Version of the controller is too old and it is not supported by the driver. .It ena%d: Invalid dma width value %d .Pp -The controller is able to request dma transaction width. +The controller is unable to request dma transaction width. .br Device stopped responding or it demanded invalid value. .It ena%d: Can not initialize ena admin queue with device @@ -132,33 +302,30 @@ Failed to get attributes of the device from the controller. .Pp Errors occurred when trying to configure AENQ groups. .El -.Ss Driver initialisation/shutdown phase: +.Ss Driver initialization/shutdown phase .Bl -diag .It ena%d: PCI resource allocation failed! -.It ena%d: allocating ena_dev failed .It ena%d: failed to pmap registers bar -.It ena%d: Error while setting up bufring -.It ena%d: Error with initialization of IO rings .It ena%d: can not allocate ifnet structure .It ena%d: Error with network interface setup .It ena%d: Failed to enable and set the admin interrupts -.It ena%d: Failed to allocate %d, vectors %d +.It ena%d: Error, MSI-X is already enabled .It ena%d: Failed to enable MSIX, vectors %d rc %d +.It ena%d: Not enough number of MSI-X allocated: %d .It ena%d: Error with MSI-X enablement .It ena%d: could not allocate irq vector: %d -.It ena%d: Unable to allocate bus resource: registers +.It ena%d: unable to allocate bus resource: registers! +.It ena%d: unable to allocate bus resource: msix! .Pp Resource allocation failed when initializing the device. .br Driver will not be attached. .It ena%d: ENA device init failed (err: %d) +.It ena%d: Cannot initialize device .Pp Device initialization failed. .br Driver will not be attached. -.It ena%d: could not activate irq vector: %d -.Pp -Error occurred when trying to activate interrupt vectors for Admin Queue. .It ena%d: failed to register interrupt handler for irq %ju: %d .Pp Error occurred when trying to register Admin Queue interrupt handler. @@ -181,8 +348,7 @@ VLANs must be detached first and then detach routine have to be called again. .It ena%d: Unmapped TX DMA tag associations .Pp Error occurred when trying to destroy RX/TX DMA tag. -.It ena%d: Cannot init RSS -.It ena%d: Cannot fill indirect table +.It ena%d: Cannot init indirect table .It ena%d: Cannot fill indirect table .It ena%d: Cannot fill hash function .It ena%d: Cannot fill hash control @@ -192,20 +358,30 @@ Error occurred during initialization of one of RSS resources. .br The device will work with reduced performance because all RX packets will be passed to queue 0 and there will be no hash information. +.It ena%d: LLQ is not supported. Fallback to host mode policy. +.It ena%d: Failed to configure the device mode. Fallback to host mode policy. +.It ena%d: unable to allocate LLQ bar resource. Fallback to host mode policy. +.Pp +Error occured during Low-latency Queue mode setup. +.br +The device will work, but without the LLQ performance gain. +.It ena%d: failed to enable write combining. +.Pp +Error occured while setting the Write Combining mode, required for the LLQ. .It ena%d: failed to tear down irq: %d .It ena%d: dev has no parent while releasing res for irq: %d Release of the interrupts failed. .El -.Ss Additional diagnostic: +.Ss Additional diagnostic .Bl -diag -.It ena%d: Cannot get attribute for ena device -.Pp -This message appears when trying to change MTU and driver is unable to get -attributes from the device. -.It ena%d: Invalid MTU setting. new_mtu: %d +.It ena%d: Invalid MTU setting. new_mtu: %d max_mtu: %d min mtu: %d .Pp Requested MTU value is not supported and will not be set. -.It ena%d: keep alive watchdog timeout +.It ena%d: Failed to set MTU to %d +.Pp +This message appears when either MTU change feature is not supported, or device +communication error has occured. +.It ena%d: Keep alive watchdog timeout. .Pp Device stopped responding and will be reset. .It ena%d: Found a Tx that wasn't completed on time, qid %d, index %d. @@ -215,18 +391,35 @@ Packet was pushed to the NIC but not sent within given time limit. It may be caused by hang of the IO queue. .It ena%d: The number of lost tx completion is aboce the threshold (%d > %d). Reset the device .Pp -If too many Tx wasn't completed on time the device is going to be reset. +If too many Tx weren't completed on time the device is going to be reset. .br It may be caused by hanged queue or device. -.It ena%d: trigger reset is on +.It ena%d: Trigger reset is on .Pp Device will be reset. .br Reset is triggered either by watchdog or if too many TX packets were not completed on time. -.It ena%d: invalid value recvd +.It ena%d: device reset scheduled but trigger_reset is off .Pp -Link status received from the device in the AENQ handler is invalid. +Reset task has been triggered, but the driver did not request it. +.br +Device reset will not be performed. +.It ena%d: Device reset failed +.Pp +Error occured while trying to reset the device. +.It ena%d: Cannot initialize device +.It ena%d: Error, mac address are different +.It ena%d: Error, device max mtu is smaller than ifp MTU +.It ena%d: Validation of device parameters failed +.It ena%d: Enable MSI-X failed +.It ena%d: Failed to create I/O queues +.It ena%d: Reset attempt failed. Can not reset the device +.Pp +Error occured while trying to restore the device after reset. +.It ena%d: Device reset completed successfully, Driver info: %s +.Pp +Device has been correctly restored after reset and is ready to use. .It ena%d: Allocation for Tx Queue %u failed .It ena%d: Allocation for Rx Queue %u failed .It ena%d: Unable to create Rx DMA map for buffer %d @@ -234,7 +427,6 @@ Link status received from the device in the AENQ handler is invalid. .It ena%d: Failed to get TX queue handlers. TX queue num %d rc: %d .It ena%d: Failed to create io RX queue[%d] rc: %d .It ena%d: Failed to get RX queue handlers. RX queue num %d rc: %d -.It ena%d: failed to request irq .It ena%d: could not allocate irq vector: %d .It ena%d: failed to register interrupt handler for irq %ju: %d .Pp @@ -246,12 +438,20 @@ Interface will not be brought up. Initialization of the LRO for the RX ring failed. .It ena%d: failed to alloc buffer for rx queue .It ena%d: failed to add buffer for rx queue %d -.It ena%d: refilled rx queue %d with %d pages only +.It ena%d: refilled rx qid %d with only %d mbufs (from %d) .Pp Allocation of resources used on RX path failed. .br If happened during initialization of the IO queue, the interface will not be brought up. +.It ena%d: NULL mbuf in rx_info +.Pp +Error occured while assembling mbuf from descriptors. +.It ena%d: tx_info doesn't have valid mbuf +.It ena%d: Invalid req_id: %hu +.It ena%d: failed to prepare tx bufs +.Pp +Error occured while preparing a packet for transmission. .It ena%d: ioctl promisc/allmulti .Pp IOCTL request for the device to work in promiscuous/allmulti mode. @@ -259,21 +459,23 @@ IOCTL request for the device to work in promiscuous/allmulti mode. See .Xr ifconfig 8 for more details. -.It ena%d: too many fragments. Last fragment: %d! -.Pp -Packet with unsupported number of segments was queued for sending to the -device. -.br -Packet will be dropped. +.El .Sh SUPPORT If an issue is identified with the released source code with a supported adapter, please email the specific information related to the issue to -.Aq Mt mk@semihalf.com +.Aq Mt mk@semihalf.com , +.Aq Mt ar@semihalf.com and .Aq Mt mw@semihalf.com . .Sh SEE ALSO +.Xr netmap 4 , .Xr vlan 4 , .Xr ifconfig 8 +.Sh HISTORY +The +.Nm +driver first appeared in +.Fx 11.1 . .Sh AUTHORS The .Nm diff --git a/sys/contrib/ena-com/ena_com.c b/sys/contrib/ena-com/ena_com.c index 8c63c1a03f76..3af3b14eca44 100644 --- a/sys/contrib/ena-com/ena_com.c +++ b/sys/contrib/ena-com/ena_com.c @@ -1,7 +1,7 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * - * Copyright (c) 2015-2020 Amazon.com, Inc. or its affiliates. + * Copyright (c) 2015-2021 Amazon.com, Inc. or its affiliates. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -694,7 +694,7 @@ static int ena_com_config_llq_info(struct ena_com_dev *ena_dev, } else { ena_trc_err(ena_dev, "Invalid header location control, supported: 0x%x\n", supported_feat); - return -EINVAL; + return ENA_COM_INVAL; } if (likely(llq_info->header_location_ctrl == ENA_ADMIN_INLINE_HEADER)) { @@ -709,7 +709,7 @@ static int ena_com_config_llq_info(struct ena_com_dev *ena_dev, } else { ena_trc_err(ena_dev, "Invalid desc_stride_ctrl, supported: 0x%x\n", supported_feat); - return -EINVAL; + return ENA_COM_INVAL; } ena_trc_err(ena_dev, "Default llq stride ctrl is not supported, performing fallback, default: 0x%x, supported: 0x%x, used: 0x%x\n", @@ -738,7 +738,7 @@ static int ena_com_config_llq_info(struct ena_com_dev *ena_dev, } else { ena_trc_err(ena_dev, "Invalid entry_size_ctrl, supported: 0x%x\n", supported_feat); - return -EINVAL; + return ENA_COM_INVAL; } ena_trc_err(ena_dev, "Default llq ring entry size is not supported, performing fallback, default: 0x%x, supported: 0x%x, used: 0x%x\n", @@ -752,7 +752,7 @@ static int ena_com_config_llq_info(struct ena_com_dev *ena_dev, */ ena_trc_err(ena_dev, "Illegal entry size %d\n", llq_info->desc_list_entry_size); - return -EINVAL; + return ENA_COM_INVAL; } if (llq_info->desc_stride_ctrl == ENA_ADMIN_MULTIPLE_DESCS_PER_ENTRY) @@ -776,7 +776,7 @@ static int ena_com_config_llq_info(struct ena_com_dev *ena_dev, } else { ena_trc_err(ena_dev, "Invalid descs_num_before_header, supported: 0x%x\n", supported_feat); - return -EINVAL; + return ENA_COM_INVAL; } ena_trc_err(ena_dev, "Default llq num descs before header is not supported, performing fallback, default: 0x%x, supported: 0x%x, used: 0x%x\n", @@ -1409,16 +1409,17 @@ int ena_com_execute_admin_command(struct ena_com_admin_queue *admin_queue, comp_ctx = ena_com_submit_admin_cmd(admin_queue, cmd, cmd_size, comp, comp_size); if (IS_ERR(comp_ctx)) { - if (comp_ctx == ERR_PTR(ENA_COM_NO_DEVICE)) + ret = PTR_ERR(comp_ctx); + if (ret == ENA_COM_NO_DEVICE) ena_trc_dbg(admin_queue->ena_dev, - "Failed to submit command [%ld]\n", - PTR_ERR(comp_ctx)); + "Failed to submit command [%d]\n", + ret); else ena_trc_err(admin_queue->ena_dev, - "Failed to submit command [%ld]\n", - PTR_ERR(comp_ctx)); + "Failed to submit command [%d]\n", + ret); - return (int)PTR_ERR(comp_ctx); + return ret; } ret = ena_com_wait_and_process_admin_cq(comp_ctx, admin_queue); @@ -2034,7 +2035,7 @@ int ena_com_get_dev_attr_feat(struct ena_com_dev *ena_dev, return rc; if (get_resp.u.max_queue_ext.version != ENA_FEATURE_MAX_QUEUE_EXT_VER) - return -EINVAL; + return ENA_COM_INVAL; memcpy(&get_feat_ctx->max_queue_ext, &get_resp.u.max_queue_ext, sizeof(get_resp.u.max_queue_ext)); @@ -2363,7 +2364,7 @@ done: } #endif -int ena_com_set_dev_mtu(struct ena_com_dev *ena_dev, int mtu) +int ena_com_set_dev_mtu(struct ena_com_dev *ena_dev, u32 mtu) { struct ena_com_admin_queue *admin_queue; struct ena_admin_set_feat_cmd cmd; @@ -2381,7 +2382,7 @@ int ena_com_set_dev_mtu(struct ena_com_dev *ena_dev, int mtu) cmd.aq_common_descriptor.opcode = ENA_ADMIN_SET_FEATURE; cmd.aq_common_descriptor.flags = 0; cmd.feat_common.feature_id = ENA_ADMIN_MTU; - cmd.u.mtu.mtu = (u32)mtu; + cmd.u.mtu.mtu = mtu; ret = ena_com_execute_admin_command(admin_queue, (struct ena_admin_aq_entry *)&cmd, @@ -2792,7 +2793,7 @@ int ena_com_indirect_table_set(struct ena_com_dev *ena_dev) return ret; } - cmd.control_buffer.length = (u32)(1ULL << rss->tbl_log_size) * + cmd.control_buffer.length = (1ULL << rss->tbl_log_size) * sizeof(struct ena_admin_rss_ind_table_entry); ret = ena_com_execute_admin_command(admin_queue, @@ -2814,7 +2815,7 @@ int ena_com_indirect_table_get(struct ena_com_dev *ena_dev, u32 *ind_tbl) u32 tbl_size; int i, rc; - tbl_size = (u32)(1ULL << rss->tbl_log_size) * + tbl_size = (1ULL << rss->tbl_log_size) * sizeof(struct ena_admin_rss_ind_table_entry); rc = ena_com_get_feature_ex(ena_dev, &get_resp, @@ -3098,7 +3099,7 @@ int ena_com_config_dev_mode(struct ena_com_dev *ena_dev, if (unlikely(ena_dev->tx_max_header_size == 0)) { ena_trc_err(ena_dev, "The size of the LLQ entry is smaller than needed\n"); - return -EINVAL; + return ENA_COM_INVAL; } ena_dev->tx_mem_queue_type = ENA_ADMIN_PLACEMENT_POLICY_DEV; diff --git a/sys/contrib/ena-com/ena_com.h b/sys/contrib/ena-com/ena_com.h index 414301bdaf91..7ff0e00c1f17 100644 --- a/sys/contrib/ena-com/ena_com.h +++ b/sys/contrib/ena-com/ena_com.h @@ -1,7 +1,7 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * - * Copyright (c) 2015-2020 Amazon.com, Inc. or its affiliates. + * Copyright (c) 2015-2021 Amazon.com, Inc. or its affiliates. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -51,8 +51,6 @@ #define ADMIN_CQ_SIZE(depth) ((depth) * sizeof(struct ena_admin_acq_entry)) #define ADMIN_AENQ_SIZE(depth) ((depth) * sizeof(struct ena_admin_aenq_entry)) -#define ENA_CDESC_RING_SIZE_ALIGNMENT (1 << 12) /* 4K */ - /*****************************************************************************/ /*****************************************************************************/ /* ENA adaptive interrupt moderation settings */ @@ -645,7 +643,7 @@ int ena_com_get_eni_stats(struct ena_com_dev *ena_dev, * * @return: 0 on Success and negative value otherwise. */ -int ena_com_set_dev_mtu(struct ena_com_dev *ena_dev, int mtu); +int ena_com_set_dev_mtu(struct ena_com_dev *ena_dev, u32 mtu); /* ena_com_get_offload_settings - Retrieve the device offloads capabilities * @ena_dev: ENA communication layer struct diff --git a/sys/contrib/ena-com/ena_defs/ena_admin_defs.h b/sys/contrib/ena-com/ena_defs/ena_admin_defs.h index edfdad3473d7..33010bd1a2e8 100644 --- a/sys/contrib/ena-com/ena_defs/ena_admin_defs.h +++ b/sys/contrib/ena-com/ena_defs/ena_admin_defs.h @@ -1,7 +1,7 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * - * Copyright (c) 2015-2020 Amazon.com, Inc. or its affiliates. + * Copyright (c) 2015-2021 Amazon.com, Inc. or its affiliates. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -853,7 +853,8 @@ enum ena_admin_os_type { ENA_ADMIN_OS_FREEBSD = 4, ENA_ADMIN_OS_IPXE = 5, ENA_ADMIN_OS_ESXI = 6, - ENA_ADMIN_OS_GROUPS_NUM = 6, + ENA_ADMIN_OS_MACOS = 7, + ENA_ADMIN_OS_GROUPS_NUM = 7, }; struct ena_admin_host_info { @@ -902,7 +903,9 @@ struct ena_admin_host_info { * 2 : interrupt_moderation * 3 : rx_buf_mirroring * 4 : rss_configurable_function_key - * 31:5 : reserved + * 5 : reserved + * 6 : rx_page_reuse + * 31:7 : reserved */ uint32_t driver_supported_features; }; @@ -1092,8 +1095,6 @@ enum ena_admin_aenq_group { }; enum ena_admin_aenq_notification_syndrome { - ENA_ADMIN_SUSPEND = 0, - ENA_ADMIN_RESUME = 1, ENA_ADMIN_UPDATE_HINTS = 2, }; @@ -1228,6 +1229,8 @@ struct ena_admin_ena_mmio_req_read_less_resp { #define ENA_ADMIN_HOST_INFO_RX_BUF_MIRRORING_MASK BIT(3) #define ENA_ADMIN_HOST_INFO_RSS_CONFIGURABLE_FUNCTION_KEY_SHIFT 4 #define ENA_ADMIN_HOST_INFO_RSS_CONFIGURABLE_FUNCTION_KEY_MASK BIT(4) +#define ENA_ADMIN_HOST_INFO_RX_PAGE_REUSE_SHIFT 6 +#define ENA_ADMIN_HOST_INFO_RX_PAGE_REUSE_MASK BIT(6) /* feature_rss_ind_table */ #define ENA_ADMIN_FEATURE_RSS_IND_TABLE_ONE_ENTRY_UPDATE_MASK BIT(0) @@ -1689,6 +1692,16 @@ static inline void set_ena_admin_host_info_rss_configurable_function_key(struct p->driver_supported_features |= (val << ENA_ADMIN_HOST_INFO_RSS_CONFIGURABLE_FUNCTION_KEY_SHIFT) & ENA_ADMIN_HOST_INFO_RSS_CONFIGURABLE_FUNCTION_KEY_MASK; } +static inline uint32_t get_ena_admin_host_info_rx_page_reuse(const struct ena_admin_host_info *p) +{ + return (p->driver_supported_features & ENA_ADMIN_HOST_INFO_RX_PAGE_REUSE_MASK) >> ENA_ADMIN_HOST_INFO_RX_PAGE_REUSE_SHIFT; +} + +static inline void set_ena_admin_host_info_rx_page_reuse(struct ena_admin_host_info *p, uint32_t val) +{ + p->driver_supported_features |= (val << ENA_ADMIN_HOST_INFO_RX_PAGE_REUSE_SHIFT) & ENA_ADMIN_HOST_INFO_RX_PAGE_REUSE_MASK; +} + static inline uint8_t get_ena_admin_feature_rss_ind_table_one_entry_update(const struct ena_admin_feature_rss_ind_table *p) { return p->flags & ENA_ADMIN_FEATURE_RSS_IND_TABLE_ONE_ENTRY_UPDATE_MASK; diff --git a/sys/contrib/ena-com/ena_defs/ena_gen_info.h b/sys/contrib/ena-com/ena_defs/ena_gen_info.h index 726750a67d4e..2797239f24ef 100644 --- a/sys/contrib/ena-com/ena_defs/ena_gen_info.h +++ b/sys/contrib/ena-com/ena_defs/ena_gen_info.h @@ -1,7 +1,7 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * - * Copyright (c) 2015-2020 Amazon.com, Inc. or its affiliates. + * Copyright (c) 2015-2021 Amazon.com, Inc. or its affiliates. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -30,5 +30,5 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#define ENA_GEN_DATE "Fri Sep 18 17:09:00 IDT 2020" -#define ENA_GEN_COMMIT "0f80d82" +#define ENA_GEN_DATE "Tue Jan 19 12:45:09 STD 2021" +#define ENA_GEN_COMMIT "f023ae8f" diff --git a/sys/contrib/ena-com/ena_eth_com.c b/sys/contrib/ena-com/ena_eth_com.c index 47ca4e4afdb6..2d66c34c0aa7 100644 --- a/sys/contrib/ena-com/ena_eth_com.c +++ b/sys/contrib/ena-com/ena_eth_com.c @@ -1,7 +1,7 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * - * Copyright (c) 2015-2020 Amazon.com, Inc. or its affiliates. + * Copyright (c) 2015-2021 Amazon.com, Inc. or its affiliates. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -178,7 +178,7 @@ static int ena_com_close_bounce_buffer(struct ena_com_io_sq *io_sq) return ENA_COM_OK; /* bounce buffer was used, so write it and get a new one */ - if (pkt_ctrl->idx) { + if (likely(pkt_ctrl->idx)) { rc = ena_com_write_bounce_buffer_to_dev(io_sq, pkt_ctrl->curr_bounce_buf); if (unlikely(rc)) { diff --git a/sys/contrib/ena-com/ena_fbsd_log.h b/sys/contrib/ena-com/ena_fbsd_log.h new file mode 100644 index 000000000000..311e2f0f280a --- /dev/null +++ b/sys/contrib/ena-com/ena_fbsd_log.h @@ -0,0 +1,74 @@ +/*- + * SPDX-License-Identifier: BSD-3-Clause + * + * Copyright (c) 2015-2021 Amazon.com, Inc. or its affiliates. + * 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. + * * Neither the name of copyright holder nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef ENA_FBSD_LOG_H +#define ENA_FBSD_LOG_H + +enum ena_log_t { + ENA_ERR = 0, + ENA_WARN, + ENA_INFO, + ENA_DBG, +}; + +extern int ena_log_level; + +#define ena_log(dev, level, fmt, args...) \ + do { \ + if (ENA_ ## level <= ena_log_level) \ + device_printf((dev), fmt, ##args); \ + } while (0) + +#define ena_log_raw(level, fmt, args...) \ + do { \ + if (ENA_ ## level <= ena_log_level) \ + printf(fmt, ##args); \ + } while (0) + +#define ena_log_unused(dev, level, fmt, args...) \ + do { \ + (void)(dev); \ + } while (0) + +#ifdef ENA_LOG_IO_ENABLE +#define ena_log_io(dev, level, fmt, args...) \ + ena_log((dev), level, fmt, ##args) +#else +#define ena_log_io(dev, level, fmt, args...) \ + ena_log_unused((dev), level, fmt, ##args) +#endif + +#define ena_log_nm(dev, level, fmt, args...) \ + ena_log((dev), level, "[nm] " fmt, ##args) + +#endif /* !(ENA_FBSD_LOG_H) */ diff --git a/sys/contrib/ena-com/ena_plat.h b/sys/contrib/ena-com/ena_plat.h index 8fe1ec9aa731..b31821248398 100644 --- a/sys/contrib/ena-com/ena_plat.h +++ b/sys/contrib/ena-com/ena_plat.h @@ -1,7 +1,7 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * - * Copyright (c) 2015-2020 Amazon.com, Inc. or its affiliates. + * Copyright (c) 2015-2021 Amazon.com, Inc. or its affiliates. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -91,22 +91,12 @@ __FBSDID("$FreeBSD$"); #include #include -extern struct ena_bus_space ebs; +#include "ena_fbsd_log.h" -/* Levels */ -#define ENA_ALERT (1 << 0) /* Alerts are providing more error info. */ -#define ENA_WARNING (1 << 1) /* Driver output is more error sensitive. */ -#define ENA_INFO (1 << 2) /* Provides additional driver info. */ -#define ENA_DBG (1 << 3) /* Driver output for debugging. */ -/* Detailed info that will be printed with ENA_INFO or ENA_DEBUG flag. */ -#define ENA_TXPTH (1 << 4) /* Allows TX path tracing. */ -#define ENA_RXPTH (1 << 5) /* Allows RX path tracing. */ -#define ENA_RSC (1 << 6) /* Goes with TXPTH or RXPTH, free/alloc res. */ -#define ENA_IOQ (1 << 7) /* Detailed info about IO queues. */ -#define ENA_ADMQ (1 << 8) /* Detailed info about admin queue. */ -#define ENA_NETMAP (1 << 9) /* Detailed info about netmap. */ +extern struct ena_bus_space ebs; #define DEFAULT_ALLOC_ALIGNMENT 8 +#define ENA_CDESC_RING_SIZE_ALIGNMENT (1 << 12) /* 4K */ extern int ena_log_level; @@ -116,27 +106,18 @@ extern int ena_log_level; (type *)((uintptr_t)__p - offsetof(type, member)); \ }) -#define ena_trace_raw(ctx, level, fmt, args...) \ - do { \ - ((void)(ctx)); \ - if (((level) & ena_log_level) != (level)) \ - break; \ - printf(fmt, ##args); \ - } while (0) - #define ena_trace(ctx, level, fmt, args...) \ - ena_trace_raw(ctx, level, "%s() [TID:%d]: " \ + ena_log((ctx)->dmadev, level, "%s() [TID:%d]: " \ fmt, __func__, curthread->td_tid, ##args) - #define ena_trc_dbg(ctx, format, arg...) \ - ena_trace(ctx, ENA_DBG, format, ##arg) + ena_trace(ctx, DBG, format, ##arg) #define ena_trc_info(ctx, format, arg...) \ - ena_trace(ctx, ENA_INFO, format, ##arg) + ena_trace(ctx, INFO, format, ##arg) #define ena_trc_warn(ctx, format, arg...) \ - ena_trace(ctx, ENA_WARNING, format, ##arg) + ena_trace(ctx, WARN, format, ##arg) #define ena_trc_err(ctx, format, arg...) \ - ena_trace(ctx, ENA_ALERT, format, ##arg) + ena_trace(ctx, ERR, format, ##arg) #define unlikely(x) __predict_false(!!(x)) #define likely(x) __predict_true(!!(x)) diff --git a/sys/dev/ena/ena.c b/sys/dev/ena/ena.c index 0079f5354c33..6425ddddee9a 100644 --- a/sys/dev/ena/ena.c +++ b/sys/dev/ena/ena.c @@ -1,7 +1,7 @@ /*- * SPDX-License-Identifier: BSD-2-Clause * - * Copyright (c) 2015-2020 Amazon.com, Inc. or its affiliates. + * Copyright (c) 2015-2021 Amazon.com, Inc. or its affiliates. *** 2304 LINES SKIPPED *** From nobody Mon Oct 11 14:32:43 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id C7D4017E80D3; Mon, 11 Oct 2021 14:32:43 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HSh8q4NwZz4qC9; Mon, 11 Oct 2021 14:32:43 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 7441822B19; Mon, 11 Oct 2021 14:32:43 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19BEWhlM035404; Mon, 11 Oct 2021 14:32:43 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19BEWh82035403; Mon, 11 Oct 2021 14:32:43 GMT (envelope-from git) Date: Mon, 11 Oct 2021 14:32:43 GMT Message-Id: <202110111432.19BEWh82035403@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Marcin Wojtas Subject: git: 7dbcef9536b4 - stable/12 - Upgrade ENA to v2.4.1 List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mw X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 7dbcef9536b410426e8b391e721e5800f5d503b5 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by mw: URL: https://cgit.FreeBSD.org/src/commit/?id=7dbcef9536b410426e8b391e721e5800f5d503b5 commit 7dbcef9536b410426e8b391e721e5800f5d503b5 Author: Marcin Wojtas AuthorDate: 2021-07-23 22:31:32 +0000 Commit: Marcin Wojtas CommitDate: 2021-10-11 14:32:14 +0000 Upgrade ENA to v2.4.1 Approved by: re ena: Remove redundant declaration of ena_log_level. GCC6 raises a -Wredundant-decl error due to duplicate declarations in ena_fbsd_log.h and ena_plat.h. Submitted by: jhb Sponsored by: Chelsio Communications (cherry picked from commit 8843787aa1bdbd10de6ba47a04489179ec2d2d3c) ena: Avoid unnecessary mbuf collapses for LLQ condition In case of Low-latency Queue, one small enough descriptor can be pushed directly to the ENA hw, thus saving one fragment. Check for this condition before performing collapse. Submitted by: Artur Rojek Obtained from: Semihalf MFC after: 2 weeks Sponsored by: Amazon, Inc. (cherry picked from commit c81f8c26115a64b9a97ecdb2a64e824dd839ee73) ena: Trigger reset on ena_com_prepare_tx failure All ena_com_prepare_tx errors other than ENA_COM_NO_MEM are fatal and require device reset. Submitted by: Artur Rojek Obtained from: Semihalf MFC after: 2 weeks Sponsored by: Amazon, Inc. (cherry picked from commit 36130d2979d695dd439bc607feb00dcdb9a1937b) ena: Prevent reset after device destruction Check for ENA_FLAG_TRIGGER_RESET inside a locked context in order to avoid potential race conditions with ena_destroy_device. This aligns the reset task logic with the Linux driver. Submitted by: Artur Rojek Obtained from: Semihalf MFC after: 2 weeks Sponsored by: Amazon, Inc. (cherry picked from commit 433ab9b6987b42b3e5b25b8b5dc7e5178c7ef9bb) ena: Add extra log messages Stay aligned with the Linux driver by adding the following logs: * inform the user about retrying queue creation * warn on non-empty ena_tx_buffer.mbuf prior to ena_tx_map_mbuf Submitted by: Artur Rojek Obtained from: Semihalf MFC after: 2 weeks Sponsored by: Amazon, Inc. (cherry picked from commit 77160654a162b5faa8ad7a02e18d2bef2589f868) ena: Add locking assertions ENA silently assumed that ena_up, ena_down and ena_start_xmit routines should be called within locked context. Driver's logic heavily assumes on concurrent access to those routines, so for safety and better documentation about this assumption, the locking assertions were added to the above functions. The assertion was added only for the main steps (skipping the helper functions) which can be called from multiple places including the kernel and the driver itself. Submitted by: Artur Rojek Obtained from: Semihalf MFC after: 2 weeks Sponsored by: Amazon, Inc. (cherry picked from commit cb98c439d66c303353a9f4abbbe9ddb51559c638) ena: Move RSS logic into its own source files Delegate RSS related functionality into separate .c/.h files in preparation for the full RSS support. While at it, reorder functions and remove prototypes for ones with internal linkage. Submitted by: Artur Rojek Obtained from: Semihalf MFC after: 2 weeks Sponsored by: Amazon, Inc. (cherry picked from commit 986e7b9227668caf9620f207e3c1d708c87b634d) ena: Disable meta descriptor caching for netmap If LLQ is being used, `ena_tx_ctx.meta_valid` must stay enabled. This fixes netmap support on latest generation ENA HW and aligns it with the core driver behavior. As netmap doesn't support any csum offloads, the `adapter->disable_meta_caching` value can be simply passed to the HW. Submitted by: Artur Rojek Obtained from: Semihalf MFC after: 2 weeks Sponsored by: Amazon, Inc. (cherry picked from commit a831466830de6ab55fc03170290b313157196e81) ena: Share ena_global_lock between driver instances In order to use `ena_global_lock` in sysctl context, it must be kept outside the driver instance's software context, as sysctls can be called before attach and after detach, leading to lock use before sx_init and after sx_destroy otherwise. Solve this issue by turning `ena_global_lock` into a file scope variable, shared between all instances of the driver and associated sysctl context, and in turn initialized/destroyed in dedicated SYSINIT/SYSUNINIT functions. As a side effect, this change also fixes existing race in the reset routine, when simultaneously accessing sysctl exposed properties. Submitted by: Artur Rojek Obtained from: Semihalf MFC after: 2 weeks Sponsored by: Amazon, Inc. (cherry picked from commit 07aff471c0de2de9a1dc5c7749c46b525bdd0201) ena: Add missing statistics Provide the following sysctl statistics in order to stay aligned with the Linux driver: * rx_ring.csum_good * tx_ring.unmask_interrupt_num Also rename the 'bad_csum' statistic name to 'csum_bad' for alignment. Submitted by: Artur Rojek Obtained from: Semihalf MFC after: 2 weeks Sponsored by: Amazon, Inc. (cherry picked from commit 223c8cb12e951c63807300a0cbdc4a1569520b4b) ena: Implement full RSS reconfiguration Bind RX/TX queues and MSI-X vectors to matching CPUs based on the RSS bucket entries. Introduce sysctls for the following RSS functionality: - rss.indir_table: indirection table mapping - rss.indir_table_size: indirection table size - rss.key: RSS hash key (if Toeplitz used) Said sysctls are only available when compiled without `option RSS`, as kernel-side RSS support currently doesn't offer RSS reconfiguration. Migrate the hash algorithm from CRC32 to Toeplitz and change the initial hash value to 0x0 in order to match the standard Toeplitz implementation. Provide helpers for hash key inversion required for HW operations. Submitted by: Artur Rojek Obtained from: Semihalf MFC after: 2 weeks Sponsored by: Amazon, Inc. (cherry picked from commit 6d1ef2abd330fac4057f092abbbdc28a568b4327) ena: fix building in-kernel driver When building ENA as compiled into the kernel, the driver would fail to build. Resolve the problem by introducing the following changes: 1. Add missing `ena_rss.c` entry in `sys/conf/files`. 2. Prevent SYSCTL_ADD_INT from throwing an assert due to an extra CTLTYPE_INT flag. Fixes: 986e7b92276 ("ena: Move RSS logic into its own source files") Fixes: 6d1ef2abd33 ("ena: Implement full RSS reconfiguration") Submitted by: Artur Rojek Obtained from: Semihalf Sponsored by: Amazon, Inc. MFC after: 1 week (cherry picked from commit a3f0d18237bdcf272461d3b4b682de384c572144) ena: Update driver version to v2.4.1 Some of the changes in this release: * Hardware RSS hash key reconfiguration and indirection table reconfiguration support. * Full kernel RSS support. * Extra statistic counters. * Netmap support for ENAv3. * Locking assertions. * Extra log messages. * Reset handling fixes. Submitted by: Michal Krawczyk Obtained from: Semihalf MFC after: 2 weeks Sponsored by: Amazon, Inc. (cherry picked from commit 42c7760be3ea420668f625f2064ae347aa7e818e) --- share/man/man4/ena.4 | 51 +++++++ sys/conf/files | 2 + sys/contrib/ena-com/ena_plat.h | 2 - sys/dev/ena/ena.c | 302 +++++++++++++------------------------ sys/dev/ena/ena.h | 34 +++-- sys/dev/ena/ena_datapath.c | 32 +++- sys/dev/ena/ena_netmap.c | 7 +- sys/dev/ena/ena_rss.c | 300 +++++++++++++++++++++++++++++++++++++ sys/dev/ena/ena_rss.h | 73 +++++++++ sys/dev/ena/ena_sysctl.c | 329 +++++++++++++++++++++++++++++++++++++++-- sys/modules/ena/Makefile | 2 +- 11 files changed, 900 insertions(+), 234 deletions(-) diff --git a/share/man/man4/ena.4 b/share/man/man4/ena.4 index bc1927608b04..71bdf4babca6 100644 --- a/share/man/man4/ena.4 +++ b/share/man/man4/ena.4 @@ -269,6 +269,57 @@ command should be used: .Bd -literal -offset indent sysctl dev.ena.1.eni_metrics.sample_interval=10 .Ed +.It Va dev.ena.X.rss.indir_table_size +RSS indirection table size. +The default is 128. +Returns the number of entries in the RSS indirection table. +.Pp +Example: +To read the RSS indirection table size, the following command should be used: +.Bd -literal -offset indent +sysctl dev.ena.0.rss.indir_table_size +.Ed +.It Va dev.ena.X.rss.indir_table +RSS indirection table mapping. +The default is x:y key-pairs of indir_table_size length. +Updates selected indices of the RSS indirection table. +.Pp +The entry string consists of one or more x:y keypairs, where x stands for +the table index and y for its new value. Table indices that don't need to be +updated can be omitted from the string and will retain their existing values. +.Pp +If an index is entered more than once, the last value is used. +.Pp +Example: +To update two selected indices in the RSS indirection table, e.g. setting index +0 to queue 5 and then index 5 to queue 0, the following command should be used: +.Bd -literal -offset indent +sysctl dev.ena.0.rss.indir_table="0:5 5:0" +.Ed +.It Va dev.ena.X.rss.key +RSS hash key. +The default is 40 bytes long randomly generated hash key. +Controls the RSS Toeplitz hash algorithm key value. +.Pp +Only available when driver compiled without the kernel side RSS support. +.Pp +Example: +To change the RSS hash key value to +.Pp +0x6d, 0x5a, 0x56, 0xda, 0x25, 0x5b, 0x0e, 0xc2, +.br +0x41, 0x67, 0x25, 0x3d, 0x43, 0xa3, 0x8f, 0xb0, +.br +0xd0, 0xca, 0x2b, 0xcb, 0xae, 0x7b, 0x30, 0xb4, +.br +0x77, 0xcb, 0x2d, 0xa3, 0x80, 0x30, 0xf2, 0x0c, +.br +0x6a, 0x42, 0xb7, 0x3b, 0xbe, 0xac, 0x01, 0xfa +.Pp +the following command should be used: +.Bd -literal -offset indent +sysctl dev.ena.0.rss.key=6d5a56da255b0ec24167253d43a38fb0d0ca2bcbae7b30b477cb2da38030f20c6a42b73bbeac01fa +.Ed .El .Sh DIAGNOSTICS .Ss Device initialization phase diff --git a/sys/conf/files b/sys/conf/files index ec54a06e84f1..34e1fffc4165 100644 --- a/sys/conf/files +++ b/sys/conf/files @@ -1714,6 +1714,8 @@ dev/ena/ena_datapath.c optional ena \ compile-with "${NORMAL_C} -I$S/contrib" dev/ena/ena_netmap.c optional ena \ compile-with "${NORMAL_C} -I$S/contrib" +dev/ena/ena_rss.c optional ena \ + compile-with "${NORMAL_C} -I$S/contrib" dev/ena/ena_sysctl.c optional ena \ compile-with "${NORMAL_C} -I$S/contrib" contrib/ena-com/ena_com.c optional ena diff --git a/sys/contrib/ena-com/ena_plat.h b/sys/contrib/ena-com/ena_plat.h index b31821248398..274f795950c0 100644 --- a/sys/contrib/ena-com/ena_plat.h +++ b/sys/contrib/ena-com/ena_plat.h @@ -98,8 +98,6 @@ extern struct ena_bus_space ebs; #define DEFAULT_ALLOC_ALIGNMENT 8 #define ENA_CDESC_RING_SIZE_ALIGNMENT (1 << 12) /* 4K */ -extern int ena_log_level; - #define container_of(ptr, type, member) \ ({ \ const __typeof(((type *)0)->member) *__p = (ptr); \ diff --git a/sys/dev/ena/ena.c b/sys/dev/ena/ena.c index 6425ddddee9a..5b5a7f6593f4 100644 --- a/sys/dev/ena/ena.c +++ b/sys/dev/ena/ena.c @@ -63,9 +63,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#ifdef RSS -#include -#endif #include #include @@ -84,6 +81,7 @@ __FBSDID("$FreeBSD$"); #include "ena_datapath.h" #include "ena.h" #include "ena_sysctl.h" +#include "ena_rss.h" #ifdef DEV_NETMAP #include "ena_netmap.h" @@ -143,7 +141,6 @@ static void ena_free_io_irq(struct ena_adapter *); static void ena_free_irqs(struct ena_adapter*); static void ena_disable_msix(struct ena_adapter *); static void ena_unmask_all_io_irqs(struct ena_adapter *); -static int ena_rss_configure(struct ena_adapter *); static int ena_up_complete(struct ena_adapter *); static uint64_t ena_get_counter(if_t, ift_counter); static int ena_media_change(if_t); @@ -161,8 +158,6 @@ static int ena_set_queues_placement_policy(device_t, struct ena_com_dev *, static uint32_t ena_calc_max_io_queue_num(device_t, struct ena_com_dev *, struct ena_com_dev_get_features_ctx *); static int ena_calc_io_queue_size(struct ena_calc_queue_size_ctx *); -static int ena_rss_init_default(struct ena_adapter *); -static void ena_rss_init_default_deferred(void *); static void ena_config_host_info(struct ena_com_dev *, device_t); static int ena_attach(device_t); static int ena_detach(device_t); @@ -186,6 +181,8 @@ static ena_vendor_info_t ena_vendor_info_array[] = { { 0, 0, 0 } }; +struct sx ena_global_lock; + /* * Contains pointers to event handlers, e.g. link state chage. */ @@ -265,27 +262,6 @@ fail_tag: return (error); } -/* - * This function should generate unique key for the whole driver. - * If the key was already genereated in the previous call (for example - * for another adapter), then it should be returned instead. - */ -void -ena_rss_key_fill(void *key, size_t size) -{ - static bool key_generated; - static uint8_t default_key[ENA_HASH_KEY_SIZE]; - - KASSERT(size <= ENA_HASH_KEY_SIZE, ("Requested more bytes than ENA RSS key can hold")); - - if (!key_generated) { - arc4random_buf(default_key, ENA_HASH_KEY_SIZE); - key_generated = true; - } - - memcpy(key, default_key, size); -} - static void ena_free_pci_resources(struct ena_adapter *adapter) { @@ -625,8 +601,10 @@ static int ena_setup_tx_resources(struct ena_adapter *adapter, int qid) { device_t pdev = adapter->pdev; + char thread_name[MAXCOMLEN + 1]; struct ena_que *que = &adapter->que[qid]; struct ena_ring *tx_ring = que->tx_ring; + cpuset_t *cpu_mask = NULL; int size, i, err; #ifdef DEV_NETMAP bus_dmamap_t *map; @@ -710,8 +688,16 @@ ena_setup_tx_resources(struct ena_adapter *adapter, int qid) tx_ring->running = true; - taskqueue_start_threads(&tx_ring->enqueue_tq, 1, PI_NET, - "%s txeq %d", device_get_nameunit(adapter->pdev), que->cpu); +#ifdef RSS + cpu_mask = &que->cpu_mask; + snprintf(thread_name, sizeof(thread_name), "%s txeq %d", + device_get_nameunit(adapter->pdev), que->cpu); +#else + snprintf(thread_name, sizeof(thread_name), "%s txeq %d", + device_get_nameunit(adapter->pdev), que->id); +#endif + taskqueue_start_threads_cpuset(&tx_ring->enqueue_tq, 1, PI_NET, + cpu_mask, "%s", thread_name); return (0); @@ -1153,8 +1139,6 @@ ena_update_buf_ring_size(struct ena_adapter *adapter, int rc = 0; bool dev_was_up; - ENA_LOCK_LOCK(adapter); - old_buf_ring_size = adapter->buf_ring_size; adapter->buf_ring_size = new_buf_ring_size; @@ -1189,8 +1173,6 @@ ena_update_buf_ring_size(struct ena_adapter *adapter, } } - ENA_LOCK_UNLOCK(adapter); - return (rc); } @@ -1202,8 +1184,6 @@ ena_update_queue_size(struct ena_adapter *adapter, uint32_t new_tx_size, int rc = 0; bool dev_was_up; - ENA_LOCK_LOCK(adapter); - old_tx_size = adapter->requested_tx_ring_size; old_rx_size = adapter->requested_rx_ring_size; adapter->requested_tx_ring_size = new_tx_size; @@ -1244,8 +1224,6 @@ ena_update_queue_size(struct ena_adapter *adapter, uint32_t new_tx_size, } } - ENA_LOCK_UNLOCK(adapter); - return (rc); } @@ -1268,8 +1246,6 @@ ena_update_io_queue_nb(struct ena_adapter *adapter, uint32_t new_num) int rc = 0; bool dev_was_up; - ENA_LOCK_LOCK(adapter); - dev_was_up = ENA_FLAG_ISSET(ENA_FLAG_DEV_UP, adapter); old_num = adapter->num_io_queues; ena_down(adapter); @@ -1299,8 +1275,6 @@ ena_update_io_queue_nb(struct ena_adapter *adapter, uint32_t new_num) } } - ENA_LOCK_UNLOCK(adapter); - return (rc); } @@ -1459,6 +1433,7 @@ ena_create_io_queues(struct ena_adapter *adapter) struct ena_que *queue; uint16_t ena_qid; uint32_t msix_vector; + cpuset_t *cpu_mask = NULL; int rc, i; /* Create TX queues */ @@ -1525,7 +1500,11 @@ ena_create_io_queues(struct ena_adapter *adapter) queue->cleanup_tq = taskqueue_create_fast("ena cleanup", M_WAITOK, taskqueue_thread_enqueue, &queue->cleanup_tq); - taskqueue_start_threads(&queue->cleanup_tq, 1, PI_NET, +#ifdef RSS + cpu_mask = &queue->cpu_mask; +#endif + taskqueue_start_threads_cpuset(&queue->cleanup_tq, 1, PI_NET, + cpu_mask, "%s queue %d cleanup", device_get_nameunit(adapter->pdev), i); } @@ -1664,7 +1643,10 @@ ena_setup_mgmnt_intr(struct ena_adapter *adapter) static int ena_setup_io_intr(struct ena_adapter *adapter) { - static int last_bind_cpu = -1; +#ifdef RSS + int num_buckets = rss_getnumbuckets(); + static int last_bind = 0; +#endif int irq_idx; if (adapter->msix_entries == NULL) @@ -1682,15 +1664,12 @@ ena_setup_io_intr(struct ena_adapter *adapter) ena_log(adapter->pdev, DBG, "ena_setup_io_intr vector: %d\n", adapter->msix_entries[irq_idx].vector); - /* - * We want to bind rings to the corresponding cpu - * using something similar to the RSS round-robin technique. - */ - if (unlikely(last_bind_cpu < 0)) - last_bind_cpu = CPU_FIRST(); +#ifdef RSS adapter->que[i].cpu = adapter->irq_tbl[irq_idx].cpu = - last_bind_cpu; - last_bind_cpu = CPU_NEXT(last_bind_cpu); + rss_getcpu(last_bind); + last_bind = (last_bind + 1) % num_buckets; + CPU_SETOF(adapter->que[i].cpu, &adapter->que[i].cpu_mask); +#endif } return (0); @@ -1782,6 +1761,19 @@ ena_request_io_irq(struct ena_adapter *adapter) goto err; } irq->requested = true; + +#ifdef RSS + rc = bus_bind_intr(adapter->pdev, irq->res, irq->cpu); + if (unlikely(rc != 0)) { + ena_log(pdev, ERR, "failed to bind " + "interrupt handler for irq %ju to cpu %d: %d\n", + rman_get_start(irq->res), irq->cpu, rc); + goto err; + } + + ena_log(pdev, INFO, "queue %d - cpu %d\n", + i - ENA_IO_IRQ_FIRST_IDX, irq->cpu); +#endif } return (rc); @@ -1910,6 +1902,7 @@ ena_unmask_all_io_irqs(struct ena_adapter *adapter) { struct ena_com_io_cq* io_cq; struct ena_eth_io_intr_reg intr_reg; + struct ena_ring *tx_ring; uint16_t ena_qid; int i; @@ -1918,47 +1911,12 @@ ena_unmask_all_io_irqs(struct ena_adapter *adapter) ena_qid = ENA_IO_TXQ_IDX(i); io_cq = &adapter->ena_dev->io_cq_queues[ena_qid]; ena_com_update_intr_reg(&intr_reg, 0, 0, true); + tx_ring = &adapter->tx_ring[i]; + counter_u64_add(tx_ring->tx_stats.unmask_interrupt_num, 1); ena_com_unmask_intr(io_cq, &intr_reg); } } -/* Configure the Rx forwarding */ -static int -ena_rss_configure(struct ena_adapter *adapter) -{ - struct ena_com_dev *ena_dev = adapter->ena_dev; - int rc; - - /* In case the RSS table was destroyed */ - if (!ena_dev->rss.tbl_log_size) { - rc = ena_rss_init_default(adapter); - if (unlikely((rc != 0) && (rc != EOPNOTSUPP))) { - ena_log(adapter->pdev, ERR, - "WARNING: RSS was not properly re-initialized," - " it will affect bandwidth\n"); - ENA_FLAG_CLEAR_ATOMIC(ENA_FLAG_RSS_ACTIVE, adapter); - return (rc); - } - } - - /* Set indirect table */ - rc = ena_com_indirect_table_set(ena_dev); - if (unlikely((rc != 0) && (rc != EOPNOTSUPP))) - return (rc); - - /* Configure hash function (if supported) */ - rc = ena_com_set_hash_function(ena_dev); - if (unlikely((rc != 0) && (rc != EOPNOTSUPP))) - return (rc); - - /* Configure hash inputs (if supported) */ - rc = ena_com_set_hash_ctrl(ena_dev); - if (unlikely((rc != 0) && (rc != EOPNOTSUPP))) - return (rc); - - return (0); -} - static int ena_up_complete(struct ena_adapter *adapter) { @@ -2079,6 +2037,10 @@ err_setup_tx: return (rc); } + ena_log(pdev, INFO, + "Retrying queue creation with sizes TX=%d, RX=%d\n", + new_tx_ring_size, new_rx_ring_size); + set_io_rings_size(adapter, new_tx_ring_size, new_rx_ring_size); } } @@ -2088,6 +2050,8 @@ ena_up(struct ena_adapter *adapter) { int rc = 0; + ENA_LOCK_ASSERT(); + if (unlikely(device_is_attached(adapter->pdev) == 0)) { ena_log(adapter->pdev, ERR, "device is not attached!\n"); return (ENXIO); @@ -2205,13 +2169,13 @@ ena_media_status(if_t ifp, struct ifmediareq *ifmr) struct ena_adapter *adapter = if_getsoftc(ifp); ena_log(adapter->pdev, DBG, "Media status update\n"); - ENA_LOCK_LOCK(adapter); + ENA_LOCK_LOCK(); ifmr->ifm_status = IFM_AVALID; ifmr->ifm_active = IFM_ETHER; if (!ENA_FLAG_ISSET(ENA_FLAG_LINK_UP, adapter)) { - ENA_LOCK_UNLOCK(adapter); + ENA_LOCK_UNLOCK(); ena_log(adapter->pdev, INFO, "Link is down\n"); return; } @@ -2219,7 +2183,7 @@ ena_media_status(if_t ifp, struct ifmediareq *ifmr) ifmr->ifm_status |= IFM_ACTIVE; ifmr->ifm_active |= IFM_UNKNOWN | IFM_FDX; - ENA_LOCK_UNLOCK(adapter); + ENA_LOCK_UNLOCK(); } static void @@ -2228,9 +2192,9 @@ ena_init(void *arg) struct ena_adapter *adapter = (struct ena_adapter *)arg; if (!ENA_FLAG_ISSET(ENA_FLAG_DEV_UP, adapter)) { - ENA_LOCK_LOCK(adapter); + ENA_LOCK_LOCK(); ena_up(adapter); - ENA_LOCK_UNLOCK(adapter); + ENA_LOCK_UNLOCK(); } } @@ -2252,13 +2216,13 @@ ena_ioctl(if_t ifp, u_long command, caddr_t data) case SIOCSIFMTU: if (ifp->if_mtu == ifr->ifr_mtu) break; - ENA_LOCK_LOCK(adapter); + ENA_LOCK_LOCK(); ena_down(adapter); ena_change_mtu(ifp, ifr->ifr_mtu); rc = ena_up(adapter); - ENA_LOCK_UNLOCK(adapter); + ENA_LOCK_UNLOCK(); break; case SIOCSIFFLAGS: @@ -2270,15 +2234,15 @@ ena_ioctl(if_t ifp, u_long command, caddr_t data) "ioctl promisc/allmulti\n"); } } else { - ENA_LOCK_LOCK(adapter); + ENA_LOCK_LOCK(); rc = ena_up(adapter); - ENA_LOCK_UNLOCK(adapter); + ENA_LOCK_UNLOCK(); } } else { if ((if_getdrvflags(ifp) & IFF_DRV_RUNNING) != 0) { - ENA_LOCK_LOCK(adapter); + ENA_LOCK_LOCK(); ena_down(adapter); - ENA_LOCK_UNLOCK(adapter); + ENA_LOCK_UNLOCK(); } } break; @@ -2303,10 +2267,10 @@ ena_ioctl(if_t ifp, u_long command, caddr_t data) if ((reinit != 0) && ((if_getdrvflags(ifp) & IFF_DRV_RUNNING) != 0)) { - ENA_LOCK_LOCK(adapter); + ENA_LOCK_LOCK(); ena_down(adapter); rc = ena_up(adapter); - ENA_LOCK_UNLOCK(adapter); + ENA_LOCK_UNLOCK(); } } @@ -2460,6 +2424,8 @@ ena_down(struct ena_adapter *adapter) { int rc; + ENA_LOCK_ASSERT(); + if (!ENA_FLAG_ISSET(ENA_FLAG_DEV_UP, adapter)) return; @@ -2525,6 +2491,10 @@ ena_calc_max_io_queue_num(device_t pdev, struct ena_com_dev *ena_dev, /* 1 IRQ for for mgmnt and 1 IRQ for each TX/RX pair */ max_num_io_queues = min_t(uint32_t, max_num_io_queues, pci_msix_count(pdev) - 1); +#ifdef RSS + max_num_io_queues = min_t(uint32_t, max_num_io_queues, + rss_getnumbuckets()); +#endif return (max_num_io_queues); } @@ -2726,90 +2696,6 @@ ena_calc_io_queue_size(struct ena_calc_queue_size_ctx *ctx) return (0); } -static int -ena_rss_init_default(struct ena_adapter *adapter) -{ - struct ena_com_dev *ena_dev = adapter->ena_dev; - device_t dev = adapter->pdev; - int qid, rc, i; - - rc = ena_com_rss_init(ena_dev, ENA_RX_RSS_TABLE_LOG_SIZE); - if (unlikely(rc != 0)) { - ena_log(dev, ERR, "Cannot init indirect table\n"); - return (rc); - } - - for (i = 0; i < ENA_RX_RSS_TABLE_SIZE; i++) { - qid = i % adapter->num_io_queues; - rc = ena_com_indirect_table_fill_entry(ena_dev, i, - ENA_IO_RXQ_IDX(qid)); - if (unlikely((rc != 0) && (rc != EOPNOTSUPP))) { - ena_log(dev, ERR, "Cannot fill indirect table\n"); - goto err_rss_destroy; - } - } - -#ifdef RSS - uint8_t rss_algo = rss_gethashalgo(); - if (rss_algo == RSS_HASH_TOEPLITZ) { - uint8_t hash_key[RSS_KEYSIZE]; - - rss_getkey(hash_key); - rc = ena_com_fill_hash_function(ena_dev, ENA_ADMIN_TOEPLITZ, - hash_key, RSS_KEYSIZE, 0xFFFFFFFF); - } else -#endif - rc = ena_com_fill_hash_function(ena_dev, ENA_ADMIN_CRC32, NULL, - ENA_HASH_KEY_SIZE, 0xFFFFFFFF); - if (unlikely((rc != 0) && (rc != EOPNOTSUPP))) { - ena_log(dev, ERR, "Cannot fill hash function\n"); - goto err_rss_destroy; - } - - rc = ena_com_set_default_hash_ctrl(ena_dev); - if (unlikely((rc != 0) && (rc != EOPNOTSUPP))) { - ena_log(dev, ERR, "Cannot fill hash control\n"); - goto err_rss_destroy; - } - - return (0); - -err_rss_destroy: - ena_com_rss_destroy(ena_dev); - return (rc); -} - -static void -ena_rss_init_default_deferred(void *arg) -{ - struct ena_adapter *adapter; - devclass_t dc; - int max; - int rc; - - dc = devclass_find("ena"); - if (unlikely(dc == NULL)) { - ena_log_raw(ERR, "SYSINIT: %s: No devclass ena\n", __func__); - return; - } - - max = devclass_get_maxunit(dc); - while (max-- >= 0) { - adapter = devclass_get_softc(dc, max); - if (adapter != NULL) { - rc = ena_rss_init_default(adapter); - ENA_FLAG_SET_ATOMIC(ENA_FLAG_RSS_ACTIVE, adapter); - if (unlikely(rc != 0)) { - ena_log(adapter->pdev, WARN, - "WARNING: RSS was not properly initialized," - " it will affect bandwidth\n"); - ENA_FLAG_CLEAR_ATOMIC(ENA_FLAG_RSS_ACTIVE, adapter); - } - } - } -} -SYSINIT(ena_rss_init, SI_SUB_KICK_SCHEDULER, SI_ORDER_SECOND, ena_rss_init_default_deferred, NULL); - static void ena_config_host_info(struct ena_com_dev *ena_dev, device_t dev) { @@ -2842,7 +2728,8 @@ ena_config_host_info(struct ena_com_dev *ena_dev, device_t dev) (DRV_MODULE_VER_SUBMINOR << ENA_ADMIN_HOST_INFO_SUB_MINOR_SHIFT); host_info->num_cpus = mp_ncpus; host_info->driver_supported_features = - ENA_ADMIN_HOST_INFO_RX_OFFSET_MASK; + ENA_ADMIN_HOST_INFO_RX_OFFSET_MASK | + ENA_ADMIN_HOST_INFO_RSS_CONFIGURABLE_FUNCTION_KEY_MASK; rc = ena_com_set_host_attributes(ena_dev); if (unlikely(rc != 0)) { @@ -3543,16 +3430,12 @@ ena_reset_task(void *arg, int pending) { struct ena_adapter *adapter = (struct ena_adapter *)arg; - if (unlikely(!ENA_FLAG_ISSET(ENA_FLAG_TRIGGER_RESET, adapter))) { - ena_log(adapter->pdev, WARN, - "device reset scheduled but trigger_reset is off\n"); - return; + ENA_LOCK_LOCK(); + if (likely(ENA_FLAG_ISSET(ENA_FLAG_TRIGGER_RESET, adapter))) { + ena_destroy_device(adapter, false); + ena_restore_device(adapter); } - - ENA_LOCK_LOCK(adapter); - ena_destroy_device(adapter, false); - ena_restore_device(adapter); - ENA_LOCK_UNLOCK(adapter); + ENA_LOCK_UNLOCK(); } /** @@ -3581,8 +3464,6 @@ ena_attach(device_t pdev) adapter = device_get_softc(pdev); adapter->pdev = pdev; - ENA_LOCK_INIT(adapter); - /* * Set up the timer service - driver is responsible for avoiding * concurrency, as the callout won't be using any locking inside. @@ -3824,19 +3705,19 @@ ena_detach(device_t pdev) ether_ifdetach(adapter->ifp); /* Stop timer service */ - ENA_LOCK_LOCK(adapter); + ENA_LOCK_LOCK(); callout_drain(&adapter->timer_service); - ENA_LOCK_UNLOCK(adapter); + ENA_LOCK_UNLOCK(); /* Release reset task */ while (taskqueue_cancel(adapter->reset_tq, &adapter->reset_task, NULL)) taskqueue_drain(adapter->reset_tq, &adapter->reset_task); taskqueue_free(adapter->reset_tq); - ENA_LOCK_LOCK(adapter); + ENA_LOCK_LOCK(); ena_down(adapter); ena_destroy_device(adapter, true); - ENA_LOCK_UNLOCK(adapter); + ENA_LOCK_UNLOCK(); /* Restore unregistered sysctl queue nodes. */ ena_sysctl_update_queue_node_nb(adapter, adapter->num_io_queues, @@ -3865,13 +3746,14 @@ ena_detach(device_t pdev) ena_free_pci_resources(adapter); + if (adapter->rss_indir != NULL) + free(adapter->rss_indir, M_DEVBUF); + if (likely(ENA_FLAG_ISSET(ENA_FLAG_RSS_ACTIVE, adapter))) ena_com_rss_destroy(ena_dev); ena_com_delete_host_info(ena_dev); - ENA_LOCK_DESTROY(adapter); - if_free(adapter->ifp); free(ena_dev->bus, M_DEVBUF); @@ -3937,6 +3819,20 @@ static void ena_notification(void *adapter_data, } } +static void +ena_lock_init(void *arg) +{ + ENA_LOCK_INIT(); +} +SYSINIT(ena_lock_init, SI_SUB_LOCK, SI_ORDER_FIRST, ena_lock_init, NULL); + +static void +ena_lock_uninit(void *arg) +{ + ENA_LOCK_DESTROY(); +} +SYSUNINIT(ena_lock_uninit, SI_SUB_LOCK, SI_ORDER_FIRST, ena_lock_uninit, NULL); + /** * This handler will called for unknown event group or unimplemented handlers **/ diff --git a/sys/dev/ena/ena.h b/sys/dev/ena/ena.h index ff18b335ca1a..b580bca1159c 100644 --- a/sys/dev/ena/ena.h +++ b/sys/dev/ena/ena.h @@ -34,14 +34,14 @@ #ifndef ENA_H #define ENA_H -#include +#include "opt_rss.h" #include "ena-com/ena_com.h" #include "ena-com/ena_eth_com.h" #define DRV_MODULE_VER_MAJOR 2 #define DRV_MODULE_VER_MINOR 4 -#define DRV_MODULE_VER_SUBMINOR 0 +#define DRV_MODULE_VER_SUBMINOR 1 #define DRV_MODULE_NAME "ena" @@ -123,6 +123,8 @@ #define ENA_IO_TXQ_IDX(q) (2 * (q)) #define ENA_IO_RXQ_IDX(q) (2 * (q) + 1) +#define ENA_IO_TXQ_IDX_TO_COMBINED_IDX(q) ((q) / 2) +#define ENA_IO_RXQ_IDX_TO_COMBINED_IDX(q) (((q) - 1) / 2) #define ENA_MGMNT_IRQ_IDX 0 #define ENA_IO_IRQ_FIRST_IDX 1 @@ -201,7 +203,9 @@ struct ena_irq { void *cookie; unsigned int vector; bool requested; +#ifdef RSS int cpu; +#endif char name[ENA_IRQNAME_SIZE]; }; @@ -214,7 +218,10 @@ struct ena_que { struct taskqueue *cleanup_tq; uint32_t id; +#ifdef RSS int cpu; + cpuset_t cpu_mask; +#endif struct sysctl_oid *oid; }; @@ -281,19 +288,21 @@ struct ena_stats_tx { *** 1123 LINES SKIPPED *** From nobody Mon Oct 11 17:39:01 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 94DE717F808B; Mon, 11 Oct 2021 17:39: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 4HSmHn3m7Tz4n9P; Mon, 11 Oct 2021 17:39: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 529382529C; Mon, 11 Oct 2021 17:39: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 19BHd1S3076990; Mon, 11 Oct 2021 17:39:01 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19BHd1AH076989; Mon, 11 Oct 2021 17:39:01 GMT (envelope-from git) Date: Mon, 11 Oct 2021 17:39:01 GMT Message-Id: <202110111739.19BHd1AH076989@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: David Bright Subject: git: 7ee00acd40bf - stable/13 - RPCBIND: skip ipv6 link local when request is not from link local address List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dab X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 7ee00acd40bf735dd5ff6ca21fa2fd0954a3fcef Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by dab: URL: https://cgit.FreeBSD.org/src/commit/?id=7ee00acd40bf735dd5ff6ca21fa2fd0954a3fcef commit 7ee00acd40bf735dd5ff6ca21fa2fd0954a3fcef Author: David Bright AuthorDate: 2021-10-04 15:43:41 +0000 Commit: David Bright CommitDate: 2021-10-11 16:19:15 +0000 RPCBIND: skip ipv6 link local when request is not from link local address RPCINFO on macOS behaves different compared to other linux clients and doesn't provide request address in rpcb structure of the RPCBPROC_GETADDRLIST call which doesn't seem to be forbidden. In this case RPCBIND uses RPC call's source address and picks a closest corresponding local address. If there are no addresses in the same subnet as the source address, return of RPCBIND may vary depending on the order of addresses returned in getifaddrs. If a link local precedes global address it may be returned even if the request comes from neither a link local nor from link local in a different scope, which will prevent services like nfs from working in tpc6 scenario on macOS clients. Issue can be seen only on FreeBSD rpcbind port due to changes in workflow of addrmerge call. Submitted by: Dmitry Ovsyannikov (Dmitry.Ovsyannikov@dell.com) Sponsored by: Dell EMC (cherry picked from commit d18c9a91979543adc182c7b28819691b64fda388) --- usr.sbin/rpcbind/tests/addrmerge_test.c | 34 +++++++++++++++++++++++++++++++++ usr.sbin/rpcbind/util.c | 12 +++++++----- 2 files changed, 41 insertions(+), 5 deletions(-) diff --git a/usr.sbin/rpcbind/tests/addrmerge_test.c b/usr.sbin/rpcbind/tests/addrmerge_test.c index e1600f1a4837..a29dc30fdde8 100644 --- a/usr.sbin/rpcbind/tests/addrmerge_test.c +++ b/usr.sbin/rpcbind/tests/addrmerge_test.c @@ -257,6 +257,22 @@ mock_tun0(void) IFF_UP | IFF_RUNNING | IFF_POINTOPOINT | IFF_MULTICAST, 0, false); } +static void +mock_mlxen0(void) +{ + mock_ifaddr4("mlxen0", "192.0.3.1", "255.255.255.128", "192.0.3.127", + IFF_UP | IFF_BROADCAST | IFF_RUNNING | IFF_SIMPLEX | IFF_MULTICAST, + false); + /* Setting link local address before ipv6 address*/ + mock_ifaddr6("mlxen0", "fe80::4", "ffff:ffff:ffff:ffff::", + "fe80::ffff:ffff:ffff:ffff", + IFF_UP | IFF_BROADCAST | IFF_RUNNING | IFF_SIMPLEX | IFF_MULTICAST, + 3, false); + mock_ifaddr6("mlxen0", "2001:db8::7", "ffff:ffff:ffff:ffff::", + "2001:db8::ffff:ffff:ffff:ffff", + IFF_UP | IFF_BROADCAST | IFF_RUNNING | IFF_SIMPLEX | IFF_MULTICAST, + 0, false); +} /* Stub rpcbind functions */ int @@ -835,6 +851,23 @@ ATF_TC_BODY(addrmerge_recvdstaddr6_rev, tc) ATF_CHECK_STREQ("2001:db8::2.3.46", maddr); free(maddr); } + +ATF_TC_WITHOUT_HEAD(addrmerge_ipv6_other_subnet); +ATF_TC_BODY(addrmerge_ipv6_other_subnet, tc) +{ + char *maddr; + + /* getifaddrs will return link local before normal ipv6 */ + mock_lo0(); + mock_mlxen0(); + + maddr = do_addrmerge6("2001:db8:1::1.3.46"); + + /* We must return the closest ipv6 address*/ + ATF_REQUIRE(maddr != NULL); + ATF_CHECK_STREQ("2001:db8::7.3.46", maddr); + free(maddr); +} #endif /* INET6 */ @@ -864,6 +897,7 @@ ATF_TP_ADD_TCS(tp) ATF_TP_ADD_TC(tp, addrmerge_ipv6_linklocal_rev); ATF_TP_ADD_TC(tp, addrmerge_recvdstaddr6); ATF_TP_ADD_TC(tp, addrmerge_recvdstaddr6_rev); + ATF_TP_ADD_TC(tp, addrmerge_ipv6_other_subnet); #endif return (atf_no_error()); diff --git a/usr.sbin/rpcbind/util.c b/usr.sbin/rpcbind/util.c index 455578b657fb..e497e9227690 100644 --- a/usr.sbin/rpcbind/util.c +++ b/usr.sbin/rpcbind/util.c @@ -229,17 +229,19 @@ addrmerge(struct netbuf *caller, const char *serv_uaddr, const char *clnt_uaddr, * a link-local address then use the scope id to see * which one. */ - if (IN6_IS_ADDR_LINKLOCAL(&SA2SIN6ADDR(ifsa)) && - IN6_IS_ADDR_LINKLOCAL(&SA2SIN6ADDR(caller_sa)) && - IN6_IS_ADDR_LINKLOCAL(&SA2SIN6ADDR(hint_sa))) { - if (SA2SIN6(ifsa)->sin6_scope_id == - SA2SIN6(caller_sa)->sin6_scope_id) { + if (IN6_IS_ADDR_LINKLOCAL(&SA2SIN6ADDR(ifsa))) { + if (IN6_IS_ADDR_LINKLOCAL(&SA2SIN6ADDR(caller_sa)) && + IN6_IS_ADDR_LINKLOCAL(&SA2SIN6ADDR(hint_sa)) && + (SA2SIN6(ifsa)->sin6_scope_id == + SA2SIN6(caller_sa)->sin6_scope_id)) { const int goodness = 3; if (bestif_goodness < goodness) { bestif = ifap; bestif_goodness = goodness; } + } else { + continue; } } } From nobody Mon Oct 11 19:06:24 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 6E0F218019FE; Mon, 11 Oct 2021 19:06:24 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HSpDc2grTz3rmt; Mon, 11 Oct 2021 19:06:24 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 3C6C8266A0; Mon, 11 Oct 2021 19:06: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 19BJ6O2d097570; Mon, 11 Oct 2021 19:06:24 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19BJ6ORq097569; Mon, 11 Oct 2021 19:06:24 GMT (envelope-from git) Date: Mon, 11 Oct 2021 19:06:24 GMT Message-Id: <202110111906.19BJ6ORq097569@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: David Bright Subject: git: e72fce241f88 - stable/12 - RPCBIND: skip ipv6 link local when request is not from link local address List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dab X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: e72fce241f88737592219049648d93d58f0e63eb Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by dab: URL: https://cgit.FreeBSD.org/src/commit/?id=e72fce241f88737592219049648d93d58f0e63eb commit e72fce241f88737592219049648d93d58f0e63eb Author: David Bright AuthorDate: 2021-10-04 15:43:41 +0000 Commit: David Bright CommitDate: 2021-10-11 16:21:00 +0000 RPCBIND: skip ipv6 link local when request is not from link local address RPCINFO on macOS behaves different compared to other linux clients and doesn't provide request address in rpcb structure of the RPCBPROC_GETADDRLIST call which doesn't seem to be forbidden. In this case RPCBIND uses RPC call's source address and picks a closest corresponding local address. If there are no addresses in the same subnet as the source address, return of RPCBIND may vary depending on the order of addresses returned in getifaddrs. If a link local precedes global address it may be returned even if the request comes from neither a link local nor from link local in a different scope, which will prevent services like nfs from working in tpc6 scenario on macOS clients. Issue can be seen only on FreeBSD rpcbind port due to changes in workflow of addrmerge call. Submitted by: Dmitry Ovsyannikov (Dmitry.Ovsyannikov@dell.com) Sponsored by: Dell EMC (cherry picked from commit d18c9a91979543adc182c7b28819691b64fda388) --- usr.sbin/rpcbind/tests/addrmerge_test.c | 34 +++++++++++++++++++++++++++++++++ usr.sbin/rpcbind/util.c | 12 +++++++----- 2 files changed, 41 insertions(+), 5 deletions(-) diff --git a/usr.sbin/rpcbind/tests/addrmerge_test.c b/usr.sbin/rpcbind/tests/addrmerge_test.c index e1600f1a4837..a29dc30fdde8 100644 --- a/usr.sbin/rpcbind/tests/addrmerge_test.c +++ b/usr.sbin/rpcbind/tests/addrmerge_test.c @@ -257,6 +257,22 @@ mock_tun0(void) IFF_UP | IFF_RUNNING | IFF_POINTOPOINT | IFF_MULTICAST, 0, false); } +static void +mock_mlxen0(void) +{ + mock_ifaddr4("mlxen0", "192.0.3.1", "255.255.255.128", "192.0.3.127", + IFF_UP | IFF_BROADCAST | IFF_RUNNING | IFF_SIMPLEX | IFF_MULTICAST, + false); + /* Setting link local address before ipv6 address*/ + mock_ifaddr6("mlxen0", "fe80::4", "ffff:ffff:ffff:ffff::", + "fe80::ffff:ffff:ffff:ffff", + IFF_UP | IFF_BROADCAST | IFF_RUNNING | IFF_SIMPLEX | IFF_MULTICAST, + 3, false); + mock_ifaddr6("mlxen0", "2001:db8::7", "ffff:ffff:ffff:ffff::", + "2001:db8::ffff:ffff:ffff:ffff", + IFF_UP | IFF_BROADCAST | IFF_RUNNING | IFF_SIMPLEX | IFF_MULTICAST, + 0, false); +} /* Stub rpcbind functions */ int @@ -835,6 +851,23 @@ ATF_TC_BODY(addrmerge_recvdstaddr6_rev, tc) ATF_CHECK_STREQ("2001:db8::2.3.46", maddr); free(maddr); } + +ATF_TC_WITHOUT_HEAD(addrmerge_ipv6_other_subnet); +ATF_TC_BODY(addrmerge_ipv6_other_subnet, tc) +{ + char *maddr; + + /* getifaddrs will return link local before normal ipv6 */ + mock_lo0(); + mock_mlxen0(); + + maddr = do_addrmerge6("2001:db8:1::1.3.46"); + + /* We must return the closest ipv6 address*/ + ATF_REQUIRE(maddr != NULL); + ATF_CHECK_STREQ("2001:db8::7.3.46", maddr); + free(maddr); +} #endif /* INET6 */ @@ -864,6 +897,7 @@ ATF_TP_ADD_TCS(tp) ATF_TP_ADD_TC(tp, addrmerge_ipv6_linklocal_rev); ATF_TP_ADD_TC(tp, addrmerge_recvdstaddr6); ATF_TP_ADD_TC(tp, addrmerge_recvdstaddr6_rev); + ATF_TP_ADD_TC(tp, addrmerge_ipv6_other_subnet); #endif return (atf_no_error()); diff --git a/usr.sbin/rpcbind/util.c b/usr.sbin/rpcbind/util.c index 455578b657fb..e497e9227690 100644 --- a/usr.sbin/rpcbind/util.c +++ b/usr.sbin/rpcbind/util.c @@ -229,17 +229,19 @@ addrmerge(struct netbuf *caller, const char *serv_uaddr, const char *clnt_uaddr, * a link-local address then use the scope id to see * which one. */ - if (IN6_IS_ADDR_LINKLOCAL(&SA2SIN6ADDR(ifsa)) && - IN6_IS_ADDR_LINKLOCAL(&SA2SIN6ADDR(caller_sa)) && - IN6_IS_ADDR_LINKLOCAL(&SA2SIN6ADDR(hint_sa))) { - if (SA2SIN6(ifsa)->sin6_scope_id == - SA2SIN6(caller_sa)->sin6_scope_id) { + if (IN6_IS_ADDR_LINKLOCAL(&SA2SIN6ADDR(ifsa))) { + if (IN6_IS_ADDR_LINKLOCAL(&SA2SIN6ADDR(caller_sa)) && + IN6_IS_ADDR_LINKLOCAL(&SA2SIN6ADDR(hint_sa)) && + (SA2SIN6(ifsa)->sin6_scope_id == + SA2SIN6(caller_sa)->sin6_scope_id)) { const int goodness = 3; if (bestif_goodness < goodness) { bestif = ifap; bestif_goodness = goodness; } + } else { + continue; } } } From nobody Tue Oct 12 00:38:28 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 5FE4F18080FE; Tue, 12 Oct 2021 00:38: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 4HSxbm2Cx3z4vrW; Tue, 12 Oct 2021 00:38: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 2D40A2C3E; Tue, 12 Oct 2021 00:38: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 19C0cSot037214; Tue, 12 Oct 2021 00:38:28 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19C0cSJZ037213; Tue, 12 Oct 2021 00:38:28 GMT (envelope-from git) Date: Tue, 12 Oct 2021 00:38:28 GMT Message-Id: <202110120038.19C0cSJZ037213@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Ed Maste Subject: git: 0cd2f8f6ab70 - stable/13 - Remove obsolete amd(8) rc.conf configuration List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: emaste X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 0cd2f8f6ab700f487a78f7383465f127b24829c7 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=0cd2f8f6ab700f487a78f7383465f127b24829c7 commit 0cd2f8f6ab700f487a78f7383465f127b24829c7 Author: Tom Hukins AuthorDate: 2021-10-05 14:34:52 +0000 Commit: Ed Maste CommitDate: 2021-10-12 00:38:06 +0000 Remove obsolete amd(8) rc.conf configuration The script that used these was removed in 13f7dbe822d5f along with amd itself. Fixes: 13f7dbe822d5 ("retire amd(8)") MFC after: 1 week Pull Request: https://github.com/freebsd/freebsd-src/pull/548 (cherry picked from commit 70ffa69e1bc7d6acbe061315743b1407b7d722d8) --- libexec/rc/rc.conf | 4 ---- share/man/man5/rc.conf.5 | 36 +----------------------------------- 2 files changed, 1 insertion(+), 39 deletions(-) diff --git a/libexec/rc/rc.conf b/libexec/rc/rc.conf index 89bb8e65d7b8..e4fc9a1d75fe 100644 --- a/libexec/rc/rc.conf +++ b/libexec/rc/rc.conf @@ -351,10 +351,6 @@ ftpd_program="/usr/libexec/ftpd" # Path to ftpd, if you want a different one. ftpd_flags="" # Additional flags to stand-alone ftpd. ### Network daemon (NFS): All need rpcbind_enable="YES" ### -amd_enable="NO" # Run amd service with $amd_flags (or NO). -amd_program="/usr/sbin/amd" # path to amd, if you want a different one. -amd_flags="-a /.amd_mnt -l syslog /host /etc/amd.map /net /etc/amd.map" -amd_map_program="NO" # Can be set to "ypcat -k amd.master" autofs_enable="NO" # Run autofs daemons. automount_flags="" # Flags to automount(8) (if autofs enabled). automountd_flags="" # Flags to automountd(8) (if autofs enabled). diff --git a/share/man/man5/rc.conf.5 b/share/man/man5/rc.conf.5 index 5f0022ca1a78..96db269407cd 100644 --- a/share/man/man5/rc.conf.5 +++ b/share/man/man5/rc.conf.5 @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd July 8, 2021 +.Dd October 5, 2021 .Dt RC.CONF 5 .Os .Sh NAME @@ -2320,39 +2320,6 @@ If is set to .Dq Li YES , these are the flags to pass to it. -.It Va amd_enable -.Pq Vt bool -If set to -.Dq Li YES , -run the -.Xr amd 8 -daemon at boot time. -.It Va amd_flags -.Pq Vt str -If -.Va amd_enable -is set to -.Dq Li YES , -these are the flags to pass to it. -See the -.Xr amd 8 -manpage for more information. -.It Va amd_map_program -.Pq Vt str -If set, -the specified program is run to get the list of -.Xr amd 8 -maps. -For example, if the -.Xr amd 8 -maps are stored in NIS, one can set this to -run -.Xr ypcat 1 -to get a list of -.Xr amd 8 -maps from the -.Pa amd.master -NIS map. .It Va update_motd .Pq Vt bool If set to @@ -4638,7 +4605,6 @@ it will be made permanently active. .Xr pf.conf 5 , .Xr security 7 , .Xr accton 8 , -.Xr amd 8 , .Xr apm 8 , .Xr bsdinstall 8 , .Xr bthidd 8 , From nobody Tue Oct 12 05:13:08 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 44D9D17DB847; Tue, 12 Oct 2021 05:13: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 4HT3hh6BWmz3hyJ; Tue, 12 Oct 2021 05:13: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 8ECD66B16; Tue, 12 Oct 2021 05:13: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 19C5D8Hp008877; Tue, 12 Oct 2021 05:13:08 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19C5D8Z9008876; Tue, 12 Oct 2021 05:13:08 GMT (envelope-from git) Date: Tue, 12 Oct 2021 05:13:08 GMT Message-Id: <202110120513.19C5D8Z9008876@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Alan Somers Subject: git: 076040aacb5d - stable/12 - fusefs: quiet some cache-related warnings List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: asomers X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 076040aacb5d58dd924853350136f08d7f37b969 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by asomers: URL: https://cgit.FreeBSD.org/src/commit/?id=076040aacb5d58dd924853350136f08d7f37b969 commit 076040aacb5d58dd924853350136f08d7f37b969 Author: Alan Somers AuthorDate: 2021-10-03 16:59:04 +0000 Commit: Alan Somers CommitDate: 2021-10-12 00:29:45 +0000 fusefs: quiet some cache-related warnings If the FUSE server does something that would make our cache incoherent, we should print a warning to the user. However, we previously warned in some situations when we shouldn't, such as if the file's size changed on the server _after_ our own attribute cache had expired. This change suppresses the warning in cases like that. It also moves the warning logic to a single place within the code. PR: 256936 Reported by: Agata Tested by: Agata , jSML4ThWwBID69YC@protonmail.com (cherry picked from commit 5d94aaacb5180798b2f698e33937f068386004eb) --- sys/fs/fuse/fuse_internal.c | 74 +++++++++++++++++++++++++++++++-------------- sys/fs/fuse/fuse_internal.h | 3 +- sys/fs/fuse/fuse_io.c | 4 +-- sys/fs/fuse/fuse_node.c | 19 ++++++++++-- sys/fs/fuse/fuse_node.h | 2 +- sys/fs/fuse/fuse_vfsops.c | 40 +----------------------- sys/fs/fuse/fuse_vnops.c | 41 ++----------------------- 7 files changed, 76 insertions(+), 107 deletions(-) diff --git a/sys/fs/fuse/fuse_internal.c b/sys/fs/fuse/fuse_internal.c index f70533b54028..90383759f1bd 100644 --- a/sys/fs/fuse/fuse_internal.c +++ b/sys/fs/fuse/fuse_internal.c @@ -255,7 +255,8 @@ fuse_internal_access(struct vnode *vp, */ void fuse_internal_cache_attrs(struct vnode *vp, struct fuse_attr *attr, - uint64_t attr_valid, uint32_t attr_valid_nsec, struct vattr *vap) + uint64_t attr_valid, uint32_t attr_valid_nsec, struct vattr *vap, + bool from_server) { struct mount *mp; struct fuse_vnode_data *fvdat; @@ -271,9 +272,54 @@ fuse_internal_cache_attrs(struct vnode *vp, struct fuse_attr *attr, fuse_validity_2_bintime(attr_valid, attr_valid_nsec, &fvdat->attr_cache_timeout); + if (vnode_isreg(vp) && + fvdat->cached_attrs.va_size != VNOVAL && + attr->size != fvdat->cached_attrs.va_size) + { + if ( data->cache_mode == FUSE_CACHE_WB && + fvdat->flag & FN_SIZECHANGE) + { + const char *msg; + + /* + * The server changed the file's size even though we're + * using writeback cacheing and and we have outstanding + * dirty writes! That's a server bug. + */ + if (fuse_libabi_geq(data, 7, 23)) { + msg = "writeback cache incoherent!." + "To prevent data corruption, disable " + "the writeback cache according to your " + "FUSE server's documentation."; + } else { + msg = "writeback cache incoherent!." + "To prevent data corruption, disable " + "the writeback cache by setting " + "vfs.fusefs.data_cache_mode to 0 or 1."; + } + fuse_warn(data, FSESS_WARN_WB_CACHE_INCOHERENT, msg); + } + if (fuse_vnode_attr_cache_valid(vp) && + data->cache_mode != FUSE_CACHE_UC) + { + /* + * The server changed the file's size even though we + * have it cached and our cache has not yet expired. + * That's a bug. + */ + fuse_warn(data, FSESS_WARN_CACHE_INCOHERENT, + "cache incoherent! " + "To prevent " + "data corruption, disable the data cache " + "by mounting with -o direct_io, or as " + "directed otherwise by your FUSE server's " + "documentation."); + } + } + /* Fix our buffers if the filesize changed without us knowing */ if (vnode_isreg(vp) && attr->size != fvdat->cached_attrs.va_size) { - (void)fuse_vnode_setsize(vp, attr->size); + (void)fuse_vnode_setsize(vp, attr->size, from_server); fvdat->cached_attrs.va_size = attr->size; } @@ -807,7 +853,7 @@ fuse_internal_newentry_core(struct vnode *dvp, fuse_vnode_clear_attr_cache(dvp); fuse_internal_cache_attrs(*vpp, &feo->attr, feo->attr_valid, - feo->attr_valid_nsec, NULL); + feo->attr_valid_nsec, NULL, true); return err; } @@ -913,26 +959,8 @@ fuse_internal_do_getattr(struct vnode *vp, struct vattr *vap, fao->attr.mtime = old_mtime.tv_sec; fao->attr.mtimensec = old_mtime.tv_nsec; } - if (vnode_isreg(vp) && - fvdat->cached_attrs.va_size != VNOVAL && - fao->attr.size != fvdat->cached_attrs.va_size) { - /* - * The server changed the file's size even though we had it - * cached! That's a server bug. - */ - struct mount *mp = vnode_mount(vp); - struct fuse_data *data = fuse_get_mpdata(mp); - - fuse_warn(data, FSESS_WARN_CACHE_INCOHERENT, - "cache incoherent! " - "To prevent data corruption, disable the data cache " - "by mounting with -o direct_io, or as directed " - "otherwise by your FUSE server's documentation."); - int iosize = fuse_iosize(vp); - v_inval_buf_range(vp, 0, INT64_MAX, iosize); - } fuse_internal_cache_attrs(vp, &fao->attr, fao->attr_valid, - fao->attr_valid_nsec, vap); + fao->attr_valid_nsec, vap, true); if (vtyp != vnode_vtype(vp)) { fuse_internal_vnode_disappear(vp); err = ENOENT; @@ -1216,7 +1244,7 @@ int fuse_internal_setattr(struct vnode *vp, struct vattr *vap, struct fuse_attr_out *fao = (struct fuse_attr_out*)fdi.answ; fuse_vnode_undirty_cached_timestamps(vp); fuse_internal_cache_attrs(vp, &fao->attr, fao->attr_valid, - fao->attr_valid_nsec, NULL); + fao->attr_valid_nsec, NULL, false); } out: diff --git a/sys/fs/fuse/fuse_internal.h b/sys/fs/fuse/fuse_internal.h index 85581f3c29c5..295d01b49795 100644 --- a/sys/fs/fuse/fuse_internal.h +++ b/sys/fs/fuse/fuse_internal.h @@ -224,7 +224,8 @@ int fuse_internal_access(struct vnode *vp, accmode_t mode, /* attributes */ void fuse_internal_cache_attrs(struct vnode *vp, struct fuse_attr *attr, - uint64_t attr_valid, uint32_t attr_valid_nsec, struct vattr *vap); + uint64_t attr_valid, uint32_t attr_valid_nsec, struct vattr *vap, + bool from_server); /* fsync */ diff --git a/sys/fs/fuse/fuse_io.c b/sys/fs/fuse/fuse_io.c index 5769ac8eccd1..96ee2496fd54 100644 --- a/sys/fs/fuse/fuse_io.c +++ b/sys/fs/fuse/fuse_io.c @@ -611,7 +611,7 @@ retry: as_written_offset = uio->uio_offset - diff; if (as_written_offset - diff > filesize) - fuse_vnode_setsize(vp, as_written_offset); + fuse_vnode_setsize(vp, as_written_offset, false); if (as_written_offset - diff >= filesize) fvdat->flag &= ~FN_SIZECHANGE; @@ -755,7 +755,7 @@ again: * Extend file _after_ locking buffer so we won't race * with other readers */ - err = fuse_vnode_setsize(vp, uio->uio_offset + n); + err = fuse_vnode_setsize(vp, uio->uio_offset + n, false); filesize = uio->uio_offset + n; fvdat->flag |= FN_SIZECHANGE; if (err) { diff --git a/sys/fs/fuse/fuse_node.c b/sys/fs/fuse/fuse_node.c index fe21dc2881b0..d616d834de28 100644 --- a/sys/fs/fuse/fuse_node.c +++ b/sys/fs/fuse/fuse_node.c @@ -387,11 +387,14 @@ fuse_vnode_savesize(struct vnode *vp, struct ucred *cred, pid_t pid) } /* - * Adjust the vnode's size to a new value, such as that provided by - * FUSE_GETATTR. + * Adjust the vnode's size to a new value. + * + * If the new value came from the server, such as from a FUSE_GETATTR + * operation, set `from_server` true. But if it came from a local operation, + * such as write(2) or truncate(2), set `from_server` false. */ int -fuse_vnode_setsize(struct vnode *vp, off_t newsize) +fuse_vnode_setsize(struct vnode *vp, off_t newsize, bool from_server) { struct fuse_vnode_data *fvdat = VTOFUD(vp); struct vattr *attrs; @@ -432,6 +435,16 @@ fuse_vnode_setsize(struct vnode *vp, off_t newsize) MPASS(bp->b_flags & B_VMIO); vfs_bio_clrbuf(bp); bp->b_dirtyend = MIN(bp->b_dirtyend, newsize - lbn * iosize); + } else if (from_server && newsize > oldsize && oldsize != VNOVAL) { + /* + * The FUSE server changed the file size behind our back. We + * should invalidate the entire cache. + */ + daddr_t left_lbn, end_lbn; + + left_lbn = oldsize / iosize; + end_lbn = howmany(newsize, iosize); + v_inval_buf_range(vp, 0, end_lbn, iosize); } out: if (bp) diff --git a/sys/fs/fuse/fuse_node.h b/sys/fs/fuse/fuse_node.h index c92874334aa1..8f69ef9a08f3 100644 --- a/sys/fs/fuse/fuse_node.h +++ b/sys/fs/fuse/fuse_node.h @@ -199,7 +199,7 @@ void fuse_vnode_open(struct vnode *vp, int32_t fuse_open_flags, int fuse_vnode_savesize(struct vnode *vp, struct ucred *cred, pid_t pid); -int fuse_vnode_setsize(struct vnode *vp, off_t newsize); +int fuse_vnode_setsize(struct vnode *vp, off_t newsize, bool from_server); void fuse_vnode_undirty_cached_timestamps(struct vnode *vp); diff --git a/sys/fs/fuse/fuse_vfsops.c b/sys/fs/fuse/fuse_vfsops.c index a4a0ce3b86d0..a07fa88a7496 100644 --- a/sys/fs/fuse/fuse_vfsops.c +++ b/sys/fs/fuse/fuse_vfsops.c @@ -537,7 +537,6 @@ fuse_vfsop_vget(struct mount *mp, ino_t ino, int flags, struct vnode **vpp) struct fuse_entry_out *feo; struct fuse_vnode_data *fvdat; const char dot[] = "."; - off_t filesize; enum vtype vtyp; int error; @@ -574,47 +573,10 @@ fuse_vfsop_vget(struct mount *mp, ino_t ino, int flags, struct vnode **vpp) error = fuse_vnode_get(mp, feo, nodeid, NULL, vpp, NULL, vtyp); if (error) goto out; - filesize = feo->attr.size; - - /* - * In the case where we are looking up a FUSE node represented by an - * existing cached vnode, and the true size reported by FUSE_LOOKUP - * doesn't match the vnode's cached size, then any cached writes beyond - * the file's current size are lost. - * - * We can get here: - * * following attribute cache expiration, or - * * due a bug in the daemon, or - */ fvdat = VTOFUD(*vpp); - if (vnode_isreg(*vpp) && - filesize != fvdat->cached_attrs.va_size && - fvdat->flag & FN_SIZECHANGE) { - if (data->cache_mode == fuse_data_cache_mode) { - const char *msg; - - if (fuse_libabi_geq(data, 7, 23)) { - msg = "writeback cache incoherent!." - "To prevent data corruption, disable " - "the writeback cache according to your " - "FUSE server's documentation."; - } else { - msg = "writeback cache incoherent!." - "To prevent data corruption, disable " - "the writeback cache by setting " - "vfs.fusefs.data_cache_mode to 0 or 1."; - } - fuse_warn(data, FSESS_WARN_WB_CACHE_INCOHERENT, msg); - } else { - /* If we get here, it's likely a fusefs kernel bug */ - printf("%s: WB cache incoherent on %s!\n", __func__, - vnode_mount(*vpp)->mnt_stat.f_mntonname); - } - fvdat->flag &= ~FN_SIZECHANGE; - } fuse_internal_cache_attrs(*vpp, &feo->attr, feo->attr_valid, - feo->attr_valid_nsec, NULL); + feo->attr_valid_nsec, NULL, true); fuse_validity_2_bintime(feo->entry_valid, feo->entry_valid_nsec, &fvdat->entry_cache_timeout); out: diff --git a/sys/fs/fuse/fuse_vnops.c b/sys/fs/fuse/fuse_vnops.c index d13ae257e0a8..a441a004dd05 100644 --- a/sys/fs/fuse/fuse_vnops.c +++ b/sys/fs/fuse/fuse_vnops.c @@ -734,7 +734,7 @@ fuse_vnop_create(struct vop_create_args *ap) } ASSERT_VOP_ELOCKED(*vpp, "fuse_vnop_create"); fuse_internal_cache_attrs(*vpp, &feo->attr, feo->attr_valid, - feo->attr_valid_nsec, NULL); + feo->attr_valid_nsec, NULL, true); fuse_filehandle_init(*vpp, FUFH_RDWR, NULL, td, cred, foo); fuse_vnode_open(*vpp, foo->open_flags, td); @@ -941,7 +941,7 @@ fuse_vnop_link(struct vop_link_args *ap) */ fuse_vnode_clear_attr_cache(tdvp); fuse_internal_cache_attrs(vp, &feo->attr, feo->attr_valid, - feo->attr_valid_nsec, NULL); + feo->attr_valid_nsec, NULL, true); } out: fdisp_destroy(&fdi); @@ -1149,52 +1149,17 @@ fuse_vnop_lookup(struct vop_lookup_args *ap) *vpp = dvp; } else { struct fuse_vnode_data *fvdat; - struct vattr *vap; err = fuse_vnode_get(vnode_mount(dvp), feo, nid, dvp, &vp, cnp, vtyp); if (err) goto out; *vpp = vp; - - /* - * In the case where we are looking up a FUSE node - * represented by an existing cached vnode, and the - * true size reported by FUSE_LOOKUP doesn't match - * the vnode's cached size, then any cached writes - * beyond the file's current size are lost. - * - * We can get here: - * * following attribute cache expiration, or - * * due a bug in the daemon, or - */ fvdat = VTOFUD(vp); - if (vnode_isreg(vp) && - ((filesize != fvdat->cached_attrs.va_size && - fvdat->flag & FN_SIZECHANGE) || - ((vap = VTOVA(vp)) && - filesize != vap->va_size))) - { - fvdat->flag &= ~FN_SIZECHANGE; - /* - * The server changed the file's size even - * though we had it cached, or had dirty writes - * in the WB cache! - */ - fuse_warn(data, FSESS_WARN_CACHE_INCOHERENT, - "cache incoherent! " - "To prevent " - "data corruption, disable the data cache " - "by mounting with -o direct_io, or as " - "directed otherwise by your FUSE server's " - "documentation."); - int iosize = fuse_iosize(vp); - v_inval_buf_range(vp, 0, INT64_MAX, iosize); - } MPASS(feo != NULL); fuse_internal_cache_attrs(*vpp, &feo->attr, - feo->attr_valid, feo->attr_valid_nsec, NULL); + feo->attr_valid, feo->attr_valid_nsec, NULL, true); fuse_validity_2_bintime(feo->entry_valid, feo->entry_valid_nsec, &fvdat->entry_cache_timeout); From nobody Tue Oct 12 05:38:06 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4CD3E12D8C2A; Tue, 12 Oct 2021 05:38: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 4HT4FW0vQ3z3rkk; Tue, 12 Oct 2021 05:38: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 E9FD16BEB; Tue, 12 Oct 2021 05:38: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 19C5c6Wo036017; Tue, 12 Oct 2021 05:38:06 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19C5c68r036016; Tue, 12 Oct 2021 05:38:06 GMT (envelope-from git) Date: Tue, 12 Oct 2021 05:38:06 GMT Message-Id: <202110120538.19C5c68r036016@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Alan Somers Subject: git: 2ccb87689fdf - stable/12 - fusefs: fix a recurse-on-non-recursive lockmgr panic List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: asomers X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 2ccb87689fdf15b62e1a7d078ccd21db53a07e9f Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by asomers: URL: https://cgit.FreeBSD.org/src/commit/?id=2ccb87689fdf15b62e1a7d078ccd21db53a07e9f commit 2ccb87689fdf15b62e1a7d078ccd21db53a07e9f Author: Alan Somers AuthorDate: 2021-10-02 18:17:36 +0000 Commit: Alan Somers CommitDate: 2021-10-12 05:13:58 +0000 fusefs: fix a recurse-on-non-recursive lockmgr panic fuse_vnop_bmap needs to know the file's size in order to calculate the optimum amount of readahead. If the file's size is unknown, it must ask the FUSE server. But if the file's data was previously cached and the server reports that its size has shrunk, fusefs must invalidate the cached data. That's not possible during VOP_BMAP because the buffer object is already locked. Fix the panic by not querying the FUSE server for the file's size during VOP_BMAP if we don't need it. That's also a a slight performance optimization. PR: 256937 Reported by: Agata Tested by: Agata (cherry picked from commit 7430017b9978cae054ed99e5160f739e5ca021d5) --- sys/fs/fuse/fuse_vnops.c | 20 ++++++++--- tests/sys/fs/fusefs/bmap.cc | 86 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 102 insertions(+), 4 deletions(-) diff --git a/sys/fs/fuse/fuse_vnops.c b/sys/fs/fuse/fuse_vnops.c index a441a004dd05..3c0b3372a76b 100644 --- a/sys/fs/fuse/fuse_vnops.c +++ b/sys/fs/fuse/fuse_vnops.c @@ -475,8 +475,9 @@ fuse_vnop_bmap(struct vop_bmap_args *ap) struct fuse_bmap_in *fbi; struct fuse_bmap_out *fbo; struct fuse_data *data; + struct fuse_vnode_data *fvdat = VTOFUD(vp); uint64_t biosize; - off_t filesize; + off_t fsize; daddr_t lbn = ap->a_bn; daddr_t *pbn = ap->a_bnp; int *runp = ap->a_runp; @@ -509,10 +510,21 @@ fuse_vnop_bmap(struct vop_bmap_args *ap) */ if (runb != NULL) *runb = MIN(lbn, maxrun); - if (runp != NULL) { - error = fuse_vnode_size(vp, &filesize, td->td_ucred, td); + if (runp != NULL && maxrun == 0) + *runp = 0; + else if (runp != NULL) { + /* + * If the file's size is cached, use that value to calculate + * runp, even if the cache is expired. runp is only advisory, + * and the risk of getting it wrong is not worth the cost of + * another upcall. + */ + if (fvdat->cached_attrs.va_size != VNOVAL) + fsize = fvdat->cached_attrs.va_size; + else + error = fuse_vnode_size(vp, &fsize, td->td_ucred, td); if (error == 0) - *runp = MIN(MAX(0, filesize / (off_t)biosize - lbn - 1), + *runp = MIN(MAX(0, fsize / (off_t)biosize - lbn - 1), maxrun); else *runp = 0; diff --git a/tests/sys/fs/fusefs/bmap.cc b/tests/sys/fs/fusefs/bmap.cc index b41aeb4f08dd..85b38937ef77 100644 --- a/tests/sys/fs/fusefs/bmap.cc +++ b/tests/sys/fs/fusefs/bmap.cc @@ -75,6 +75,8 @@ void expect_lookup(const char *relpath, uint64_t ino, off_t size) } }; +class BmapEof: public Bmap, public WithParamInterface {}; + /* * Test FUSE_BMAP * XXX The FUSE protocol does not include the runp and runb variables, so those @@ -161,3 +163,87 @@ TEST_F(Bmap, default_) leak(fd); } + +/* + * VOP_BMAP should not query the server for the file's size, even if its cached + * attributes have expired. + * Regression test for https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=256937 + */ +TEST_P(BmapEof, eof) +{ + /* + * Outline: + * 1) lookup the file, setting attr_valid=0 + * 2) Read more than one block, causing the kernel to issue VOP_BMAP to + * plan readahead. + * 3) Nothing should panic + * 4) Repeat the tests, truncating the file after different numbers of + * GETATTR operations. + */ + Sequence seq; + const off_t filesize = 2 * m_maxbcachebuf; + const ino_t ino = 42; + mode_t mode = S_IFREG | 0644; + void *contents, *buf; + int fd; + int ngetattrs; + + ngetattrs = GetParam(); + contents = calloc(1, filesize); + FuseTest::expect_lookup(RELPATH, ino, mode, filesize, 1, 0); + expect_open(ino, 0, 1); + // Depending on ngetattrs, FUSE_READ could be called with either + // filesize or filesize / 2 . + EXPECT_CALL(*m_mock, process( + ResultOf([=](auto in) { + return (in.header.opcode == FUSE_READ && + in.header.nodeid == ino && + in.body.read.offset == 0 && + ( in.body.read.size == filesize || + in.body.read.size == filesize / 2)); + }, Eq(true)), + _) + ).WillOnce(Invoke(ReturnImmediate([=](auto in, auto& out) { + size_t osize = in.body.read.size; + out.header.len = sizeof(struct fuse_out_header) + osize; + bzero(out.body.bytes, osize); + }))); + EXPECT_CALL(*m_mock, process( + ResultOf([](auto in) { + return (in.header.opcode == FUSE_GETATTR && + in.header.nodeid == ino); + }, Eq(true)), + _) + ).Times(Between(ngetattrs - 1, ngetattrs)) + .InSequence(seq) + .WillRepeatedly(Invoke(ReturnImmediate([=](auto i __unused, auto& out) { + SET_OUT_HEADER_LEN(out, attr); + out.body.attr.attr_valid = 0; + out.body.attr.attr.ino = ino; + out.body.attr.attr.mode = S_IFREG | 0644; + out.body.attr.attr.size = filesize; + }))); + EXPECT_CALL(*m_mock, process( + ResultOf([](auto in) { + return (in.header.opcode == FUSE_GETATTR && + in.header.nodeid == ino); + }, Eq(true)), + _) + ).InSequence(seq) + .WillRepeatedly(Invoke(ReturnImmediate([=](auto i __unused, auto& out) { + SET_OUT_HEADER_LEN(out, attr); + out.body.attr.attr_valid = 0; + out.body.attr.attr.ino = ino; + out.body.attr.attr.mode = S_IFREG | 0644; + out.body.attr.attr.size = filesize / 2; + }))); + + buf = calloc(1, filesize); + fd = open(FULLPATH, O_RDWR); + ASSERT_LE(0, fd) << strerror(errno); + read(fd, buf, filesize); +} + +INSTANTIATE_TEST_CASE_P(BE, BmapEof, + Values(1, 2, 3) +); From nobody Tue Oct 12 05:57:20 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id DB43017DC634; Tue, 12 Oct 2021 05:57: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 4HT4gh2fPRz4V3Q; Tue, 12 Oct 2021 05:57: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 3C1F073DE; Tue, 12 Oct 2021 05:57: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 19C5vKen061836; Tue, 12 Oct 2021 05:57:20 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19C5vKYB061835; Tue, 12 Oct 2021 05:57:20 GMT (envelope-from git) Date: Tue, 12 Oct 2021 05:57:20 GMT Message-Id: <202110120557.19C5vKYB061835@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Alan Somers Subject: git: 955a418bd303 - stable/12 - fusefs: Fix a bug during VOP_STRATEGY when the server changes file size List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: asomers X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 955a418bd3036dc055d97cf98faec0be137b3b11 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by asomers: URL: https://cgit.FreeBSD.org/src/commit/?id=955a418bd3036dc055d97cf98faec0be137b3b11 commit 955a418bd3036dc055d97cf98faec0be137b3b11 Author: Alan Somers AuthorDate: 2021-10-03 17:51:14 +0000 Commit: Alan Somers CommitDate: 2021-10-12 05:41:25 +0000 fusefs: Fix a bug during VOP_STRATEGY when the server changes file size If the FUSE server tells the kernel that a file's size has changed, then the kernel must invalidate any portion of that file in cache. But the kernel can't do that during VOP_STRATEGY, because the file's buffers are already locked. Instead, proceed with the write. PR: 256937 Reported by: Agata Tested by: Agata Reviewed by: pfg Differential Revision: https://reviews.freebsd.org/D32332 (cherry picked from commit 032a5bd55b3a003d3560435422a95f27f91685fe) --- sys/fs/fuse/fuse_io.c | 19 ++++++---- tests/sys/fs/fusefs/write.cc | 82 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 94 insertions(+), 7 deletions(-) diff --git a/sys/fs/fuse/fuse_io.c b/sys/fs/fuse/fuse_io.c index 96ee2496fd54..e163ddedb482 100644 --- a/sys/fs/fuse/fuse_io.c +++ b/sys/fs/fuse/fuse_io.c @@ -1047,13 +1047,18 @@ fuse_io_strategy(struct vnode *vp, struct buf *bp) /* * Setup for actual write */ - error = fuse_vnode_size(vp, &filesize, cred, curthread); - if (error) { - bp->b_ioflags |= BIO_ERROR; - bp->b_error = error; - bufdone(bp); - return (error); - } + /* + * If the file's size is cached, use that value, even if the + * cache is expired. At this point we're already committed to + * writing something. If the FUSE server has changed the + * file's size behind our back, it's too late for us to do + * anything about it. In particular, we can't invalidate any + * part of the file's buffers because VOP_STRATEGY is called + * with them already locked. + */ + filesize = fvdat->cached_attrs.va_size; + /* filesize must've been cached by fuse_vnop_open. */ + KASSERT(filesize != VNOVAL, ("filesize should've been cached")); if ((off_t)bp->b_lblkno * biosize + bp->b_dirtyend > filesize) bp->b_dirtyend = filesize - diff --git a/tests/sys/fs/fusefs/write.cc b/tests/sys/fs/fusefs/write.cc index e3fbbf072911..3654a063b765 100644 --- a/tests/sys/fs/fusefs/write.cc +++ b/tests/sys/fs/fusefs/write.cc @@ -194,6 +194,10 @@ virtual void SetUp() { } }; + +class WriteEofDuringVnopStrategy: public Write, public WithParamInterface +{}; + void sigxfsz_handler(int __unused sig) { Write::s_sigxfsz = 1; } @@ -515,6 +519,84 @@ TEST_F(Write, eof_during_rmw) leak(fd); } +/* + * VOP_STRATEGY should not query the server for the file's size, even if its + * cached attributes have expired. + * Regression test for https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=256937 + */ +TEST_P(WriteEofDuringVnopStrategy, eof_during_vop_strategy) +{ + const char FULLPATH[] = "mountpoint/some_file.txt"; + const char RELPATH[] = "some_file.txt"; + Sequence seq; + const off_t filesize = 2 * m_maxbcachebuf; + void *contents; + uint64_t ino = 42; + uint64_t attr_valid = 0; + uint64_t attr_valid_nsec = 0; + mode_t mode = S_IFREG | 0644; + int fd; + int ngetattrs; + + ngetattrs = GetParam(); + contents = calloc(1, filesize); + + EXPECT_LOOKUP(FUSE_ROOT_ID, RELPATH) + .WillRepeatedly(Invoke( + ReturnImmediate([=](auto in __unused, auto& out) { + SET_OUT_HEADER_LEN(out, entry); + out.body.entry.attr.mode = mode; + out.body.entry.nodeid = ino; + out.body.entry.attr.nlink = 1; + out.body.entry.attr.size = filesize; + out.body.entry.attr_valid = attr_valid; + out.body.entry.attr_valid_nsec = attr_valid_nsec; + }))); + expect_open(ino, 0, 1); + EXPECT_CALL(*m_mock, process( + ResultOf([=](auto in) { + return (in.header.opcode == FUSE_GETATTR && + in.header.nodeid == ino); + }, Eq(true)), + _) + ).Times(Between(ngetattrs - 1, ngetattrs)) + .InSequence(seq) + .WillRepeatedly(Invoke(ReturnImmediate([=](auto i __unused, auto& out) { + SET_OUT_HEADER_LEN(out, attr); + out.body.attr.attr.ino = ino; + out.body.attr.attr.mode = mode; + out.body.attr.attr_valid = attr_valid; + out.body.attr.attr_valid_nsec = attr_valid_nsec; + out.body.attr.attr.size = filesize; + }))); + EXPECT_CALL(*m_mock, process( + ResultOf([=](auto in) { + return (in.header.opcode == FUSE_GETATTR && + in.header.nodeid == ino); + }, Eq(true)), + _) + ).InSequence(seq) + .WillRepeatedly(Invoke(ReturnImmediate([=](auto i __unused, auto& out) { + SET_OUT_HEADER_LEN(out, attr); + out.body.attr.attr.ino = ino; + out.body.attr.attr.mode = mode; + out.body.attr.attr_valid = attr_valid; + out.body.attr.attr_valid_nsec = attr_valid_nsec; + out.body.attr.attr.size = filesize / 2; + }))); + expect_write(ino, 0, filesize / 2, filesize / 2, contents); + + fd = open(FULLPATH, O_RDWR); + ASSERT_LE(0, fd) << strerror(errno); + ASSERT_EQ(filesize / 2, write(fd, contents, filesize / 2)) + << strerror(errno); + +} + +INSTANTIATE_TEST_CASE_P(W, WriteEofDuringVnopStrategy, + Values(1, 2, 3) +); + /* * If the kernel cannot be sure which uid, gid, or pid was responsible for a * write, then it must set the FUSE_WRITE_CACHE bit From nobody Tue Oct 12 06:01:06 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 5D29B17E0C0F; Tue, 12 Oct 2021 06:01:07 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HT4m30nt0z4XS8; Tue, 12 Oct 2021 06:01: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 F09B87581; Tue, 12 Oct 2021 06:01:06 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19C616bB071247; Tue, 12 Oct 2021 06:01:06 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19C616BM071246; Tue, 12 Oct 2021 06:01:06 GMT (envelope-from git) Date: Tue, 12 Oct 2021 06:01:06 GMT Message-Id: <202110120601.19C616BM071246@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Alan Somers Subject: git: 9381a9d89260 - stable/12 - fusefs: fix intermittency in the dev_fuse_poll test List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: asomers X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 9381a9d8926005ef57a3e8add7fb21e42e01d08c Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by asomers: URL: https://cgit.FreeBSD.org/src/commit/?id=9381a9d8926005ef57a3e8add7fb21e42e01d08c commit 9381a9d8926005ef57a3e8add7fb21e42e01d08c Author: Alan Somers AuthorDate: 2021-09-25 16:16:20 +0000 Commit: Alan Somers CommitDate: 2021-10-12 05:57:38 +0000 fusefs: fix intermittency in the dev_fuse_poll test The DevFusePoll::access/select test would occasionally segfault. The cause was a file descriptor that was shared between two threads. The first thread would kill the second and close the file descriptor. But it was possible that the second would read the file descriptor before it shut down. That did not cause problems for kqueue, poll, or blocking operation, but it triggered segfaults in select's macros. Differential Revision: https://reviews.freebsd.org/D32142 (cherry picked from commit f44a448709d3b77508fd59ee28201ae1666387c2) --- tests/sys/fs/fusefs/mockfs.cc | 10 +++++++--- tests/sys/fs/fusefs/mockfs.hh | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/tests/sys/fs/fusefs/mockfs.cc b/tests/sys/fs/fusefs/mockfs.cc index 4effecc1cd82..4266d6be214c 100644 --- a/tests/sys/fs/fusefs/mockfs.cc +++ b/tests/sys/fs/fusefs/mockfs.cc @@ -823,6 +823,7 @@ void MockFS::read_request(mockfs_buf_in &in, ssize_t &res) { struct timeval timeout_tv; const int timeout_ms = 999; int timeout_int, nfds; + int fuse_fd; switch (m_pm) { case BLOCKING: @@ -859,19 +860,22 @@ void MockFS::read_request(mockfs_buf_in &in, ssize_t &res) { ASSERT_TRUE(fds[0].revents & POLLIN); break; case SELECT: + fuse_fd = m_fuse_fd; + if (fuse_fd < 0) + break; timeout_tv.tv_sec = 0; timeout_tv.tv_usec = timeout_ms * 1'000; - nfds = m_fuse_fd + 1; + nfds = fuse_fd + 1; while (nready == 0) { FD_ZERO(&readfds); - FD_SET(m_fuse_fd, &readfds); + FD_SET(fuse_fd, &readfds); nready = select(nfds, &readfds, NULL, NULL, &timeout_tv); if (m_quit) return; } ASSERT_LE(0, nready) << strerror(errno); - ASSERT_TRUE(FD_ISSET(m_fuse_fd, &readfds)); + ASSERT_TRUE(FD_ISSET(fuse_fd, &readfds)); break; default: FAIL() << "not yet implemented"; diff --git a/tests/sys/fs/fusefs/mockfs.hh b/tests/sys/fs/fusefs/mockfs.hh index be8a05c344fa..391606704371 100644 --- a/tests/sys/fs/fusefs/mockfs.hh +++ b/tests/sys/fs/fusefs/mockfs.hh @@ -264,7 +264,7 @@ class MockFS { pthread_t m_daemon_id; /* file descriptor of /dev/fuse control device */ - int m_fuse_fd; + volatile int m_fuse_fd; /* The minor version of the kernel API that this mock daemon targets */ uint32_t m_kernel_minor_version; From nobody Tue Oct 12 07:00:48 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 2F24D17FD181; Tue, 12 Oct 2021 07:00: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 4HT64x0wHnz4rXl; Tue, 12 Oct 2021 07:00: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 0023C7CFB; Tue, 12 Oct 2021 07:00: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 19C70mwq051541; Tue, 12 Oct 2021 07:00:48 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19C70mA7051540; Tue, 12 Oct 2021 07:00:48 GMT (envelope-from git) Date: Tue, 12 Oct 2021 07:00:48 GMT Message-Id: <202110120700.19C70mA7051540@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: 9a1f5e104ee5 - stable/13 - mlx5_en: fix use of CALLOUT_DIRECT List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 9a1f5e104ee5f967c67bc258abd37d81f7a5df31 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=9a1f5e104ee5f967c67bc258abd37d81f7a5df31 commit 9a1f5e104ee5f967c67bc258abd37d81f7a5df31 Author: Konstantin Belousov AuthorDate: 2021-09-08 15:37:20 +0000 Commit: Konstantin Belousov CommitDate: 2021-10-12 07:00:10 +0000 mlx5_en: fix use of CALLOUT_DIRECT (cherry picked from commit 0eb2dcd32ea6fb59661d709872e02ea6b3e7b9e2) --- sys/dev/mlx5/mlx5_en/mlx5_en_main.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sys/dev/mlx5/mlx5_en/mlx5_en_main.c b/sys/dev/mlx5/mlx5_en/mlx5_en_main.c index cebba31b36e1..655e531fb8b8 100644 --- a/sys/dev/mlx5/mlx5_en/mlx5_en_main.c +++ b/sys/dev/mlx5/mlx5_en/mlx5_en_main.c @@ -1118,10 +1118,10 @@ mlx5e_reset_calibration_callout(struct mlx5e_priv *priv) if (priv->clbr_done == 0) mlx5e_calibration_callout(priv); else - callout_reset_curcpu(&priv->tstmp_clbr, (priv->clbr_done < + callout_reset_sbt_curcpu(&priv->tstmp_clbr, (priv->clbr_done < mlx5e_calibration_duration ? mlx5e_fast_calibration : - mlx5e_normal_calibration) * hz, mlx5e_calibration_callout, - priv); + mlx5e_normal_calibration) * SBT_1S, 0, + mlx5e_calibration_callout, priv, C_DIRECT_EXEC); } static uint64_t @@ -4683,7 +4683,7 @@ mlx5e_create_ifp(struct mlx5_core_dev *mdev) OID_AUTO, "rx_clbr_done", CTLFLAG_RD, &priv->clbr_done, 0, "RX timestamps calibration state"); - callout_init(&priv->tstmp_clbr, CALLOUT_DIRECT); + callout_init(&priv->tstmp_clbr, 1); mlx5e_reset_calibration_callout(priv); pa.pa_version = PFIL_VERSION; From nobody Tue Oct 12 07:00:50 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 5A14517FCFCF; Tue, 12 Oct 2021 07:00: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 4HT64y1rwDz4rtf; Tue, 12 Oct 2021 07:00: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 1EF427B73; Tue, 12 Oct 2021 07:00: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 19C70oFM052425; Tue, 12 Oct 2021 07:00:50 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19C70oE4052410; Tue, 12 Oct 2021 07:00:50 GMT (envelope-from git) Date: Tue, 12 Oct 2021 07:00:50 GMT Message-Id: <202110120700.19C70oE4052410@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: 39a1ff43ad78 - stable/13 - ObsoleteFiles.inc: stop removing pthread_mutexattr_get/setpshared.3 List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 39a1ff43ad78c1c466a5b3300f8ac24ff0a0a84a Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=39a1ff43ad78c1c466a5b3300f8ac24ff0a0a84a commit 39a1ff43ad78c1c466a5b3300f8ac24ff0a0a84a Author: Konstantin Belousov AuthorDate: 2021-10-10 14:38:20 +0000 Commit: Konstantin Belousov CommitDate: 2021-10-12 07:00:10 +0000 ObsoleteFiles.inc: stop removing pthread_mutexattr_get/setpshared.3 (cherry picked from commit 24b51c7295db6b316250f0288aaf05660a81063e) --- ObsoleteFiles.inc | 2 -- 1 file changed, 2 deletions(-) diff --git a/ObsoleteFiles.inc b/ObsoleteFiles.inc index a721f5596031..ac85e8b55e26 100644 --- a/ObsoleteFiles.inc +++ b/ObsoleteFiles.inc @@ -11702,8 +11702,6 @@ OLD_FILES+=usr/share/man/man3/isnanf.3.gz OLD_FILES+=usr/share/man/man3/libautofs.3.gz OLD_FILES+=usr/share/man/man3/pthread_attr_setsstack.3.gz OLD_FILES+=usr/share/man/man3/pthread_getcancelstate.3.gz -OLD_FILES+=usr/share/man/man3/pthread_mutexattr_getpshared.3.gz -OLD_FILES+=usr/share/man/man3/pthread_mutexattr_setpshared.3.gz OLD_FILES+=usr/share/man/man3/set_assertion_failure_callback.3.gz OLD_FILES+=usr/share/man/man3/setkey.3.gz OLD_FILES+=usr/share/man/man3/setvfsent.3.gz From nobody Tue Oct 12 07:17:23 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id B69AA1802BD0; Tue, 12 Oct 2021 07:17: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 4HT6S34gm2z4wZ0; Tue, 12 Oct 2021 07:17: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 80B63104FC; Tue, 12 Oct 2021 07:17: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 19C7HNj5069965; Tue, 12 Oct 2021 07:17:23 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19C7HNT4069964; Tue, 12 Oct 2021 07:17:23 GMT (envelope-from git) Date: Tue, 12 Oct 2021 07:17:23 GMT Message-Id: <202110120717.19C7HNT4069964@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: a8a9dbed5251 - stable/12 - mlx5_en: fix use of CALLOUT_DIRECT List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: a8a9dbed52515b7288d27a2f5f646b414c114be5 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=a8a9dbed52515b7288d27a2f5f646b414c114be5 commit a8a9dbed52515b7288d27a2f5f646b414c114be5 Author: Konstantin Belousov AuthorDate: 2021-09-08 15:37:20 +0000 Commit: Konstantin Belousov CommitDate: 2021-10-12 07:01:11 +0000 mlx5_en: fix use of CALLOUT_DIRECT (cherry picked from commit 0eb2dcd32ea6fb59661d709872e02ea6b3e7b9e2) --- sys/dev/mlx5/mlx5_en/mlx5_en_main.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sys/dev/mlx5/mlx5_en/mlx5_en_main.c b/sys/dev/mlx5/mlx5_en/mlx5_en_main.c index 1596ca0fb21a..126ca1484705 100644 --- a/sys/dev/mlx5/mlx5_en/mlx5_en_main.c +++ b/sys/dev/mlx5/mlx5_en/mlx5_en_main.c @@ -1162,10 +1162,10 @@ mlx5e_reset_calibration_callout(struct mlx5e_priv *priv) if (priv->clbr_done == 0) mlx5e_calibration_callout(priv); else - callout_reset_curcpu(&priv->tstmp_clbr, (priv->clbr_done < + callout_reset_sbt_curcpu(&priv->tstmp_clbr, (priv->clbr_done < mlx5e_calibration_duration ? mlx5e_fast_calibration : - mlx5e_normal_calibration) * hz, mlx5e_calibration_callout, - priv); + mlx5e_normal_calibration) * SBT_1S, 0, + mlx5e_calibration_callout, priv, C_DIRECT_EXEC); } static uint64_t @@ -4457,7 +4457,7 @@ mlx5e_create_ifp(struct mlx5_core_dev *mdev) OID_AUTO, "rx_clbr_done", CTLFLAG_RD, &priv->clbr_done, 0, "RX timestamps calibration state"); - callout_init(&priv->tstmp_clbr, CALLOUT_DIRECT); + callout_init(&priv->tstmp_clbr, 1); mlx5e_reset_calibration_callout(priv); return (priv); From nobody Tue Oct 12 07:17:24 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id F2E161802CBC; Tue, 12 Oct 2021 07:17: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 4HT6S45s0fz4wXG; Tue, 12 Oct 2021 07:17: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 A539B7F6C; Tue, 12 Oct 2021 07:17: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 19C7HONF069989; Tue, 12 Oct 2021 07:17:24 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19C7HOTs069988; Tue, 12 Oct 2021 07:17:24 GMT (envelope-from git) Date: Tue, 12 Oct 2021 07:17:24 GMT Message-Id: <202110120717.19C7HOTs069988@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: 493e98e6c71a - stable/12 - ObsoleteFiles.inc: stop removing pthread_mutexattr_get/setpshared.3 List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 493e98e6c71a23d55b4004189cf154a450ec8638 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=493e98e6c71a23d55b4004189cf154a450ec8638 commit 493e98e6c71a23d55b4004189cf154a450ec8638 Author: Konstantin Belousov AuthorDate: 2021-10-10 14:38:20 +0000 Commit: Konstantin Belousov CommitDate: 2021-10-12 07:02:04 +0000 ObsoleteFiles.inc: stop removing pthread_mutexattr_get/setpshared.3 (cherry picked from commit 24b51c7295db6b316250f0288aaf05660a81063e) --- ObsoleteFiles.inc | 2 -- 1 file changed, 2 deletions(-) diff --git a/ObsoleteFiles.inc b/ObsoleteFiles.inc index 14c313c55377..71f7a17cf730 100644 --- a/ObsoleteFiles.inc +++ b/ObsoleteFiles.inc @@ -11055,8 +11055,6 @@ OLD_FILES+=usr/share/man/man3/isnanf.3.gz OLD_FILES+=usr/share/man/man3/libautofs.3.gz OLD_FILES+=usr/share/man/man3/pthread_attr_setsstack.3.gz OLD_FILES+=usr/share/man/man3/pthread_getcancelstate.3.gz -OLD_FILES+=usr/share/man/man3/pthread_mutexattr_getpshared.3.gz -OLD_FILES+=usr/share/man/man3/pthread_mutexattr_setpshared.3.gz OLD_FILES+=usr/share/man/man3/set_assertion_failure_callback.3.gz OLD_FILES+=usr/share/man/man3/setkey.3.gz OLD_FILES+=usr/share/man/man3/setvfsent.3.gz From nobody Tue Oct 12 12:13:34 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id E09881803498; Tue, 12 Oct 2021 12:13: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 4HTF1p5ygfz3QDC; Tue, 12 Oct 2021 12:13: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 AD41013EFE; Tue, 12 Oct 2021 12:13: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 19CCDYxS068787; Tue, 12 Oct 2021 12: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 19CCDYWW068786; Tue, 12 Oct 2021 12:13:34 GMT (envelope-from git) Date: Tue, 12 Oct 2021 12:13:34 GMT Message-Id: <202110121213.19CCDYWW068786@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Hans Petter Selasky Subject: git: 1f1aa1aa9651 - stable/13 - sound(4): Implement mixer mute control for feeder channels. List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: hselasky X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 1f1aa1aa96513b7385ff89f6b6f3e1501d9cea87 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by hselasky: URL: https://cgit.FreeBSD.org/src/commit/?id=1f1aa1aa96513b7385ff89f6b6f3e1501d9cea87 commit 1f1aa1aa96513b7385ff89f6b6f3e1501d9cea87 Author: Hans Petter Selasky AuthorDate: 2021-09-28 07:41:18 +0000 Commit: Hans Petter Selasky CommitDate: 2021-10-12 12:10:59 +0000 sound(4): Implement mixer mute control for feeder channels. PR: 258711 Differential Revision: https://reviews.freebsd.org/D31636 Sponsored by: NVIDIA Networking (cherry picked from commit 4a83ca1078e3ec70159741b51a6b48e844ada9f5) --- sys/dev/sound/pcm/channel.c | 71 ++++++++++++++++++++++ sys/dev/sound/pcm/channel.h | 8 ++- sys/dev/sound/pcm/dsp.c | 121 +++++++++++++++++++++++--------------- sys/dev/sound/pcm/feeder_volume.c | 19 ++++-- 4 files changed, 167 insertions(+), 52 deletions(-) diff --git a/sys/dev/sound/pcm/channel.c b/sys/dev/sound/pcm/channel.c index 38c578ba8282..4d56eee6847e 100644 --- a/sys/dev/sound/pcm/channel.c +++ b/sys/dev/sound/pcm/channel.c @@ -1223,6 +1223,8 @@ chn_init(struct pcm_channel *c, void *devinfo, int dir, int direction) c->volume[SND_VOL_C_MASTER][SND_CHN_T_VOL_0DB] = SND_VOL_0DB_MASTER; c->volume[SND_VOL_C_PCM][SND_CHN_T_VOL_0DB] = chn_vol_0db_pcm; + memset(c->muted, 0, sizeof(c->muted)); + chn_vpc_reset(c, SND_VOL_C_PCM, 1); ret = ENODEV; @@ -1394,6 +1396,75 @@ chn_getvolume_matrix(struct pcm_channel *c, int vc, int vt) return (c->volume[vc][vt]); } +int +chn_setmute_multi(struct pcm_channel *c, int vc, int mute) +{ + int i, ret; + + ret = 0; + + for (i = 0; i < SND_CHN_T_MAX; i++) { + if ((1 << i) & SND_CHN_LEFT_MASK) + ret |= chn_setmute_matrix(c, vc, i, mute); + else if ((1 << i) & SND_CHN_RIGHT_MASK) + ret |= chn_setmute_matrix(c, vc, i, mute) << 8; + else + ret |= chn_setmute_matrix(c, vc, i, mute) << 16; + } + return (ret); +} + +int +chn_setmute_matrix(struct pcm_channel *c, int vc, int vt, int mute) +{ + int i; + + KASSERT(c != NULL && vc >= SND_VOL_C_MASTER && vc < SND_VOL_C_MAX && + (vc == SND_VOL_C_MASTER || (vc & 1)) && + (vt == SND_CHN_T_VOL_0DB || (vt >= SND_CHN_T_BEGIN && vt <= SND_CHN_T_END)), + ("%s(): invalid mute matrix c=%p vc=%d vt=%d mute=%d", + __func__, c, vc, vt, mute)); + + CHN_LOCKASSERT(c); + + mute = (mute != 0); + + c->muted[vc][vt] = mute; + + /* + * Do relative calculation here and store it into class + 1 + * to ease the job of feeder_volume. + */ + if (vc == SND_VOL_C_MASTER) { + for (vc = SND_VOL_C_BEGIN; vc <= SND_VOL_C_END; + vc += SND_VOL_C_STEP) + c->muted[SND_VOL_C_VAL(vc)][vt] = mute; + } else if (vc & 1) { + if (vt == SND_CHN_T_VOL_0DB) { + for (i = SND_CHN_T_BEGIN; i <= SND_CHN_T_END; + i += SND_CHN_T_STEP) { + c->muted[SND_VOL_C_VAL(vc)][i] = mute; + } + } else { + c->muted[SND_VOL_C_VAL(vc)][vt] = mute; + } + } + return (mute); +} + +int +chn_getmute_matrix(struct pcm_channel *c, int vc, int vt) +{ + KASSERT(c != NULL && vc >= SND_VOL_C_MASTER && vc < SND_VOL_C_MAX && + (vt == SND_CHN_T_VOL_0DB || + (vt >= SND_CHN_T_BEGIN && vt <= SND_CHN_T_END)), + ("%s(): invalid mute matrix c=%p vc=%d vt=%d", + __func__, c, vc, vt)); + CHN_LOCKASSERT(c); + + return (c->muted[vc][vt]); +} + struct pcmchan_matrix * chn_getmatrix(struct pcm_channel *c) { diff --git a/sys/dev/sound/pcm/channel.h b/sys/dev/sound/pcm/channel.h index 34d62f4e15c2..60b7b3416cc3 100644 --- a/sys/dev/sound/pcm/channel.h +++ b/sys/dev/sound/pcm/channel.h @@ -166,7 +166,8 @@ struct pcm_channel { struct pcmchan_matrix matrix; struct pcmchan_matrix matrix_scratch; - int volume[SND_VOL_C_MAX][SND_CHN_T_VOL_MAX]; + int16_t volume[SND_VOL_C_MAX][SND_CHN_T_VOL_MAX]; + int8_t muted[SND_VOL_C_MAX][SND_CHN_T_VOL_MAX]; void *data1, *data2; }; @@ -271,6 +272,9 @@ int chn_setvolume_multi(struct pcm_channel *c, int vc, int left, int right, int center); int chn_setvolume_matrix(struct pcm_channel *c, int vc, int vt, int val); int chn_getvolume_matrix(struct pcm_channel *c, int vc, int vt); +int chn_setmute_multi(struct pcm_channel *c, int vc, int mute); +int chn_setmute_matrix(struct pcm_channel *c, int vc, int vt, int mute); +int chn_getmute_matrix(struct pcm_channel *c, int vc, int vt); void chn_vpc_reset(struct pcm_channel *c, int vc, int force); int chn_setparam(struct pcm_channel *c, uint32_t format, uint32_t speed); int chn_setspeed(struct pcm_channel *c, uint32_t speed); @@ -307,6 +311,8 @@ int chn_syncdestroy(struct pcm_channel *c); #define CHN_GETVOLUME(x, y, z) ((x)->volume[y][z]) #endif +#define CHN_GETMUTE(x, y, z) ((x)->muted[y][z]) + #ifdef OSSV4_EXPERIMENT int chn_getpeaks(struct pcm_channel *c, int *lpeak, int *rpeak); #endif diff --git a/sys/dev/sound/pcm/dsp.c b/sys/dev/sound/pcm/dsp.c index cce05f4ecf37..15f437b8627c 100644 --- a/sys/dev/sound/pcm/dsp.c +++ b/sys/dev/sound/pcm/dsp.c @@ -965,6 +965,7 @@ dsp_ioctl_channel(struct cdev *dev, struct pcm_channel *volch, u_long cmd, struct snddev_info *d; struct pcm_channel *rdch, *wrch; int j, devtype, ret; + int left, right, center, mute; d = dsp_get_info(dev); if (!PCM_REGISTERED(d) || !(dsp_get_flags(dev) & SD_F_VPC)) @@ -1003,67 +1004,95 @@ dsp_ioctl_channel(struct cdev *dev, struct pcm_channel *volch, u_long cmd, } /* Final validation */ - if (volch != NULL) { - CHN_LOCK(volch); - if (!(volch->feederflags & (1 << FEEDER_VOLUME))) { - CHN_UNLOCK(volch); - return (-1); - } - if (volch->direction == PCMDIR_PLAY) - wrch = volch; - else - rdch = volch; - } - - ret = EINVAL; + if (volch == NULL) + return (EINVAL); - if (volch != NULL && - ((j == SOUND_MIXER_PCM && volch->direction == PCMDIR_PLAY) || - (j == SOUND_MIXER_RECLEV && volch->direction == PCMDIR_REC))) { - if ((cmd & ~0xff) == MIXER_WRITE(0)) { - int left, right, center; + CHN_LOCK(volch); + if (!(volch->feederflags & (1 << FEEDER_VOLUME))) { + CHN_UNLOCK(volch); + return (EINVAL); + } + switch (cmd & ~0xff) { + case MIXER_WRITE(0): + switch (j) { + case SOUND_MIXER_MUTE: + if (volch->direction == PCMDIR_REC) { + chn_setmute_multi(volch, SND_VOL_C_PCM, (*(int *)arg & SOUND_MASK_RECLEV) != 0); + } else { + chn_setmute_multi(volch, SND_VOL_C_PCM, (*(int *)arg & SOUND_MASK_PCM) != 0); + } + break; + case SOUND_MIXER_PCM: + if (volch->direction != PCMDIR_PLAY) + break; left = *(int *)arg & 0x7f; right = ((*(int *)arg) >> 8) & 0x7f; center = (left + right) >> 1; - chn_setvolume_multi(volch, SND_VOL_C_PCM, left, right, - center); - } else if ((cmd & ~0xff) == MIXER_READ(0)) { - *(int *)arg = CHN_GETVOLUME(volch, - SND_VOL_C_PCM, SND_CHN_T_FL); - *(int *)arg |= CHN_GETVOLUME(volch, - SND_VOL_C_PCM, SND_CHN_T_FR) << 8; + chn_setvolume_multi(volch, SND_VOL_C_PCM, + left, right, center); + break; + case SOUND_MIXER_RECLEV: + if (volch->direction != PCMDIR_REC) + break; + left = *(int *)arg & 0x7f; + right = ((*(int *)arg) >> 8) & 0x7f; + center = (left + right) >> 1; + chn_setvolume_multi(volch, SND_VOL_C_PCM, + left, right, center); + break; + default: + /* ignore all other mixer writes */ + break; } - ret = 0; - } else if (rdch != NULL || wrch != NULL) { + break; + + case MIXER_READ(0): switch (j) { + case SOUND_MIXER_MUTE: + mute = CHN_GETMUTE(volch, SND_VOL_C_PCM, SND_CHN_T_FL) || + CHN_GETMUTE(volch, SND_VOL_C_PCM, SND_CHN_T_FR); + if (volch->direction == PCMDIR_REC) { + *(int *)arg = mute << SOUND_MIXER_RECLEV; + } else { + *(int *)arg = mute << SOUND_MIXER_PCM; + } + break; + case SOUND_MIXER_PCM: + if (volch->direction != PCMDIR_PLAY) + break; + *(int *)arg = CHN_GETVOLUME(volch, + SND_VOL_C_PCM, SND_CHN_T_FL); + *(int *)arg |= CHN_GETVOLUME(volch, + SND_VOL_C_PCM, SND_CHN_T_FR) << 8; + break; + case SOUND_MIXER_RECLEV: + if (volch->direction != PCMDIR_REC) + break; + *(int *)arg = CHN_GETVOLUME(volch, + SND_VOL_C_PCM, SND_CHN_T_FL); + *(int *)arg |= CHN_GETVOLUME(volch, + SND_VOL_C_PCM, SND_CHN_T_FR) << 8; + break; case SOUND_MIXER_DEVMASK: case SOUND_MIXER_CAPS: case SOUND_MIXER_STEREODEVS: - if ((cmd & ~0xff) == MIXER_READ(0)) { - *(int *)arg = 0; - if (rdch != NULL) - *(int *)arg |= SOUND_MASK_RECLEV; - if (wrch != NULL) - *(int *)arg |= SOUND_MASK_PCM; - } - ret = 0; - break; - case SOUND_MIXER_RECMASK: - case SOUND_MIXER_RECSRC: - if ((cmd & ~0xff) == MIXER_READ(0)) - *(int *)arg = 0; - ret = 0; + if (volch->direction == PCMDIR_REC) + *(int *)arg = SOUND_MASK_RECLEV; + else + *(int *)arg = SOUND_MASK_PCM; break; default: + *(int *)arg = 0; break; } - } - - if (volch != NULL) - CHN_UNLOCK(volch); + break; - return (ret); + default: + break; + } + CHN_UNLOCK(volch); + return (0); } static int diff --git a/sys/dev/sound/pcm/feeder_volume.c b/sys/dev/sound/pcm/feeder_volume.c index 322d7f6b2c84..2312bd89c9d4 100644 --- a/sys/dev/sound/pcm/feeder_volume.c +++ b/sys/dev/sound/pcm/feeder_volume.c @@ -237,10 +237,13 @@ static int feed_volume_feed(struct pcm_feeder *f, struct pcm_channel *c, uint8_t *b, uint32_t count, void *source) { + int temp_vol[SND_CHN_T_VOL_MAX]; struct feed_volume_info *info; uint32_t j, align; - int i, *vol, *matrix; + int i, *matrix; uint8_t *dst; + const int16_t *vol; + const int8_t *muted; /* * Fetch filter data operation. @@ -251,6 +254,7 @@ feed_volume_feed(struct pcm_feeder *f, struct pcm_channel *c, uint8_t *b, return (FEEDER_FEED(f->source, c, b, count, source)); vol = c->volume[SND_VOL_C_VAL(info->volume_class)]; + muted = c->muted[SND_VOL_C_VAL(info->volume_class)]; matrix = info->matrix; /* @@ -258,17 +262,22 @@ feed_volume_feed(struct pcm_feeder *f, struct pcm_channel *c, uint8_t *b, */ j = 0; i = info->channels; - do { - if (vol[matrix[--i]] != SND_VOL_FLAT) { + while (i--) { + if (vol[matrix[i]] != SND_VOL_FLAT || + muted[matrix[i]] != 0) { j = 1; break; } - } while (i != 0); + } /* Nope, just bypass entirely. */ if (j == 0) return (FEEDER_FEED(f->source, c, b, count, source)); + /* Check if any controls are muted. */ + for (j = 0; j != SND_CHN_T_VOL_MAX; j++) + temp_vol[j] = muted[j] ? 0 : vol[j]; + dst = b; align = info->bps * info->channels; @@ -281,7 +290,7 @@ feed_volume_feed(struct pcm_feeder *f, struct pcm_channel *c, uint8_t *b, if (j == 0) break; - info->apply(vol, matrix, info->channels, dst, j); + info->apply(temp_vol, matrix, info->channels, dst, j); j *= align; dst += j; From nobody Tue Oct 12 12:13:35 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 394D71803582; Tue, 12 Oct 2021 12:13:36 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HTF1r0TnZz3QWd; Tue, 12 Oct 2021 12:13: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 D8A4D14342; Tue, 12 Oct 2021 12: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 19CCDZR4068811; Tue, 12 Oct 2021 12:13:35 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19CCDZu1068810; Tue, 12 Oct 2021 12:13:35 GMT (envelope-from git) Date: Tue, 12 Oct 2021 12:13:35 GMT Message-Id: <202110121213.19CCDZu1068810@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Hans Petter Selasky Subject: git: fe5ee07a11ce - stable/13 - mlx4en(4): Fix wrong mbuf cluster size in mlx4_en_debugnet_init() List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: hselasky X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: fe5ee07a11ced27eab9c6a6bd0f3e27d99423ba8 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by hselasky: URL: https://cgit.FreeBSD.org/src/commit/?id=fe5ee07a11ced27eab9c6a6bd0f3e27d99423ba8 commit fe5ee07a11ced27eab9c6a6bd0f3e27d99423ba8 Author: Hans Petter Selasky AuthorDate: 2021-10-05 08:46:56 +0000 Commit: Hans Petter Selasky CommitDate: 2021-10-12 12:12:00 +0000 mlx4en(4): Fix wrong mbuf cluster size in mlx4_en_debugnet_init() This fixes an "invalid cluster size" panic when debugnet is activated. panic() m_getzone() debugnet_mbuf_reinit() debugnet_any_ifnet_update() ifhwioctl() ifioctl() Submitted by: ae@ PR: 258923 Sponsored by: NVIDIA Networking (cherry picked from commit 5a7de2b42caf6241e87b417a0521e9ab303989d7) --- sys/dev/mlx4/mlx4_en/mlx4_en_netdev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/dev/mlx4/mlx4_en/mlx4_en_netdev.c b/sys/dev/mlx4/mlx4_en/mlx4_en_netdev.c index eec620f5b90e..672affcce623 100644 --- a/sys/dev/mlx4/mlx4_en/mlx4_en_netdev.c +++ b/sys/dev/mlx4/mlx4_en/mlx4_en_netdev.c @@ -2904,7 +2904,7 @@ mlx4_en_debugnet_init(struct ifnet *dev, int *nrxr, int *ncl, int *clsize) mutex_lock(&priv->mdev->state_lock); *nrxr = priv->rx_ring_num; *ncl = DEBUGNET_MAX_IN_FLIGHT; - *clsize = priv->rx_mb_size; + *clsize = MCLBYTES; mutex_unlock(&priv->mdev->state_lock); } From nobody Tue Oct 12 12:17:49 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 1DB251806890; Tue, 12 Oct 2021 12:17: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 4HTF6k071Vz3jBM; Tue, 12 Oct 2021 12:17: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 D813C143B5; Tue, 12 Oct 2021 12:17: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 19CCHnRN069242; Tue, 12 Oct 2021 12:17:49 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19CCHnR3069241; Tue, 12 Oct 2021 12:17:49 GMT (envelope-from git) Date: Tue, 12 Oct 2021 12:17:49 GMT Message-Id: <202110121217.19CCHnR3069241@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Hans Petter Selasky Subject: git: 8d804809630f - stable/12 - mlx4en(4): Fix wrong mbuf cluster size in mlx4_en_debugnet_init() List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: hselasky X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 8d804809630fd145683de92ba502a9ed34b94115 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by hselasky: URL: https://cgit.FreeBSD.org/src/commit/?id=8d804809630fd145683de92ba502a9ed34b94115 commit 8d804809630fd145683de92ba502a9ed34b94115 Author: Hans Petter Selasky AuthorDate: 2021-10-05 08:46:56 +0000 Commit: Hans Petter Selasky CommitDate: 2021-10-12 12:17:02 +0000 mlx4en(4): Fix wrong mbuf cluster size in mlx4_en_debugnet_init() This fixes an "invalid cluster size" panic when debugnet is activated. panic() m_getzone() debugnet_mbuf_reinit() debugnet_any_ifnet_update() ifhwioctl() ifioctl() Submitted by: ae@ PR: 258923 Sponsored by: NVIDIA Networking (cherry picked from commit 5a7de2b42caf6241e87b417a0521e9ab303989d7) --- sys/dev/mlx4/mlx4_en/mlx4_en_netdev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/dev/mlx4/mlx4_en/mlx4_en_netdev.c b/sys/dev/mlx4/mlx4_en/mlx4_en_netdev.c index f128aa3c1bd0..85e323b9a882 100644 --- a/sys/dev/mlx4/mlx4_en/mlx4_en_netdev.c +++ b/sys/dev/mlx4/mlx4_en/mlx4_en_netdev.c @@ -2904,7 +2904,7 @@ mlx4_en_netdump_init(struct ifnet *dev, int *nrxr, int *ncl, int *clsize) mutex_lock(&priv->mdev->state_lock); *nrxr = priv->rx_ring_num; *ncl = NETDUMP_MAX_IN_FLIGHT; - *clsize = priv->rx_mb_size; + *clsize = MCLBYTES; mutex_unlock(&priv->mdev->state_lock); } From nobody Tue Oct 12 14:21:57 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 3B04317F6D3C; Tue, 12 Oct 2021 14:21:59 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HTHsz10dbz4qsL; Tue, 12 Oct 2021 14:21:59 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 0207115EEC; Tue, 12 Oct 2021 14:21:59 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19CELwcF042600; Tue, 12 Oct 2021 14:21:58 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19CELvq8042599; Tue, 12 Oct 2021 14:21:57 GMT (envelope-from git) Date: Tue, 12 Oct 2021 14:21:57 GMT Message-Id: <202110121421.19CELvq8042599@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: =?utf-8?Q?Stefan E=C3=9Fer?= Subject: git: e84a97439b4b - stable/13 - usr.bin/gh-bc, contrib/bc: update to version 5.0.0 List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: se X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: e84a97439b4bcc11e04837b2f130dfff4c755c5f Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by se: URL: https://cgit.FreeBSD.org/src/commit/?id=e84a97439b4bcc11e04837b2f130dfff4c755c5f commit e84a97439b4bcc11e04837b2f130dfff4c755c5f Author: Stefan Eßer AuthorDate: 2021-08-10 08:42:54 +0000 Commit: Stefan Eßer CommitDate: 2021-10-12 14:18:26 +0000 usr.bin/gh-bc, contrib/bc: update to version 5.0.0 Merge commit 2f57ecae4b98e76e5d675563785a7e6c59c868c4 This is a new major release with a number of changes and extensions: - Limited the number of temporary numbers and made the space for them static so that allocating more space for them cannot fail. - Allowed integers with non-zero scale to be used with power, places, and shift operators. - Added greatest common divisor and least common multiple to lib2.bc. - Made bc and dc UTF-8 capable. - Added the ability for users to have bc and dc quit on SIGINT. - Added the ability for users to disable prompt and TTY mode by environment variables. - Added the ability for users to redefine keywords. - Added dc's modular exponentiation and divmod to bc. - Added the ability to assign strings to variables and array elements and pass them to functions in bc. - Added dc's asciify command and stream printing to bc. - Added bitwise and, or, xor, left shift, right shift, reverse, left rotate, right rotate, and mod functions to lib2.bc. - Added the functions s2u(x) and s2un(x,n), to lib2.bc. MFC after: 1 week (cherry picked from commit 44d4804d1945435745518cd09eb8ae6ab22ecef4) vendor/bc: update to upstream version 5.0.2 (cherry picked from commit a60ef1802a36f2f2a5611564191440ea1c1e2f17) (cherry picked from commit 662087dfd0668dee82ed20d00ced662aa3595059) contrib/bc: remove files ommitted from the release A number of files have been removed from the release distribution of this bc implementation. They were mostly relevant for pre release testing and benchmarking to identify regressions. The Markdown sources of the man pages are only relevant for combinations of build options not used in FreeBSD and need non-default conversion tools (available as ports in FreeBSD). All the omitted files can be found in the upstream git repository, and they are fetched when building this software as a port. But they have never been used in the FreeBSD base system. (cherry picked from commit ea31d1a5c490193348e0b71fdda6d08a2c80a2eb) Remove files that were checked in with wrong .gitattributes These files will be added back in updated form, but are only relevant for the Windows platform, anyway. (cherry picked from commit d6c323eda215d05091f56d02a8274eb50c244a6f) contrib/bc: merge version 5.1.0 from vendor branch This version adds options and functions that allow to print numbers in the open interval (-1 .. 1) with or without a leading 0 digit. Additionally, an option has been added to prevent line wrap and allows to print arbitrarily long results on a single line. Merge commit '5d58a51571721190681c50d4bd3a1f45e6282d72' (cherry picked from commit d43fa8ef534ac87a16843d45264f56cf11e0fcbc) contrib/bc: update to version 5.1.1 Merge commit '6f49f5cdde1c62c4e5a743e895f3afe592b5c0e5' (cherry picked from commit a30efc5ca7272e446abb71f0d72c76539f267bb6) contrib/bc: temporarily disconnect the tests for 5.0.2 The tests that come with version 5.0.2 have been extended to cover the line editing functions. It has been found that these tests generate false negative results in FreeBSD, most likely due to an issue in the pexpect functionality used. These history tests are skipped on systems that do not have python and py-pexpect installed (and thus are unlikely to cause CI test failures), but in order to not cause irritating failures on systems were these packages are in fact installed, I temporarily disconnect them. I had planned to skip this version due to the issue with the history tests, but some committer has asked me to go ahead since the currently used version 5.0.0 contains a macro name that collides with a project he is working on. No MFC of this version is planned. A version 5.0.3 is expected to be released soon, and that version will allow to reconnect the tests and will be MFCed. (cherry picked from commit f774652b0e837be415abd20935eae3466ea34a20) Add back Windows only VCXProj files (cherry picked from commit ded0d3d486eba766f613070de0ed12029a9a3816) contrib/bc: re-enable tests after the import of version 5.1.0 The tests have been fixed to not write any data outside of the temporary work directory provided by the test framework. MFC after: 3 days (cherry picked from commit b8d895faf47afb8f3b31055e2ec2db8d0df5db23) Revert erroneous commit ded0d3d486eba These files came from a prior commit to contrib/bc and seem to have been placed in the top of the source tree by a failed git rebase. Reported by: markj (cherry picked from commit f902ca97bdbceccf62b4b02b0321af91ea398925) --- contrib/bc/.gitattributes | 2 +- contrib/bc/.gitignore | 8 +- contrib/bc/LICENSE.md | 14 +- contrib/bc/Makefile.in | 233 +- contrib/bc/NEWS.md | 117 +- contrib/bc/README.md | 50 +- contrib/bc/RELEASE.md | 54 - contrib/bc/bc.vcxproj | 278 - contrib/bc/bc.vcxproj.filters | 182 - contrib/bc/bcl.sln | 31 - contrib/bc/bcl.vcxproj | 161 - contrib/bc/bcl.vcxproj.filters | 96 - contrib/bc/configure | 1322 +---- contrib/bc/configure.sh | 467 +- contrib/bc/gen/bc_help.txt | 60 + contrib/bc/gen/dc_help.txt | 38 + contrib/bc/gen/lib.bc | 2 +- contrib/bc/gen/lib2.bc | 283 +- contrib/bc/gen/strgen.c | 112 +- contrib/bc/gen/strgen.sh | 3 + contrib/bc/include/args.h | 11 +- contrib/bc/include/bc.h | 313 +- contrib/bc/include/bcl.h | 142 +- contrib/bc/include/dc.h | 42 +- contrib/bc/include/file.h | 88 + contrib/bc/include/history.h | 108 +- contrib/bc/include/lang.h | 445 +- contrib/bc/include/lex.h | 375 +- contrib/bc/include/library.h | 90 +- contrib/bc/include/num.h | 646 ++- contrib/bc/include/opt.h | 61 + contrib/bc/include/parse.h | 182 +- contrib/bc/include/program.h | 828 ++- contrib/bc/include/rand.h | 326 +- contrib/bc/include/read.h | 42 +- contrib/bc/include/status.h | 646 ++- contrib/bc/include/vector.h | 378 +- contrib/bc/include/version.h | 5 +- contrib/bc/include/vm.h | 693 ++- contrib/bc/locales/de_DE.ISO8859-1.msg | 13 +- contrib/bc/locales/de_DE.UTF-8.msg | 13 +- contrib/bc/locales/en_US.msg | 13 +- contrib/bc/locales/es_ES.ISO8859-1.msg | 13 +- contrib/bc/locales/es_ES.UTF-8.msg | 13 +- contrib/bc/locales/fr_FR.ISO8859-1.msg | 13 +- contrib/bc/locales/fr_FR.UTF-8.msg | 13 +- contrib/bc/locales/ja_JP.UTF-8.msg | 32 +- contrib/bc/locales/ja_JP.eucJP.msg | 32 +- contrib/bc/locales/nl_NL.ISO8859-1.msg | 22 +- contrib/bc/locales/nl_NL.UTF-8.msg | 22 +- contrib/bc/locales/pl_PL.ISO8859-2.msg | 22 +- contrib/bc/locales/pl_PL.UTF-8.msg | 22 +- contrib/bc/locales/pt_PT.ISO8859-1.msg | 13 +- contrib/bc/locales/pt_PT.UTF-8.msg | 13 +- contrib/bc/locales/ru_RU.CP1251.msg | 22 +- contrib/bc/locales/ru_RU.CP866.msg | 22 +- contrib/bc/locales/ru_RU.ISO8859-5.msg | 22 +- contrib/bc/locales/ru_RU.KOI8-R.msg | 15 +- contrib/bc/locales/ru_RU.UTF-8.msg | 22 +- contrib/bc/locales/zh_CN.GB18030.msg | 17 +- contrib/bc/locales/zh_CN.GB2312.msg | 17 +- contrib/bc/locales/zh_CN.GBK.msg | 17 +- contrib/bc/locales/zh_CN.UTF-8.msg | 15 +- contrib/bc/locales/zh_CN.eucCN.msg | 17 +- contrib/bc/manpage.sh | 131 - contrib/bc/manuals/algorithms.md | 162 +- contrib/bc/manuals/bc.1.md.in | 1840 ------- contrib/bc/manuals/bc/A.1 | 2660 ++++++---- contrib/bc/manuals/bc/A.1.md | 725 ++- contrib/bc/manuals/bc/E.1 | 1332 +++-- contrib/bc/manuals/bc/E.1.md | 354 +- contrib/bc/manuals/bc/EH.1 | 1303 +++-- contrib/bc/manuals/bc/EH.1.md | 326 +- contrib/bc/manuals/bc/EHN.1 | 1303 +++-- contrib/bc/manuals/bc/EHN.1.md | 326 +- contrib/bc/manuals/bc/EHNP.1 | 1375 ----- contrib/bc/manuals/bc/EHNP.1.md | 1069 ---- contrib/bc/manuals/bc/EHP.1 | 1382 ----- contrib/bc/manuals/bc/EHP.1.md | 1077 ---- contrib/bc/manuals/bc/EN.1 | 1332 +++-- contrib/bc/manuals/bc/EN.1.md | 354 +- contrib/bc/manuals/bc/ENP.1 | 1393 ----- contrib/bc/manuals/bc/ENP.1.md | 1085 ---- contrib/bc/manuals/bc/EP.1 | 1400 ----- contrib/bc/manuals/bc/EP.1.md | 1093 ---- contrib/bc/manuals/bc/H.1 | 2633 ++++++---- contrib/bc/manuals/bc/H.1.md | 702 ++- contrib/bc/manuals/bc/HN.1 | 2633 ++++++---- contrib/bc/manuals/bc/HN.1.md | 702 ++- contrib/bc/manuals/bc/HNP.1 | 2223 -------- contrib/bc/manuals/bc/HNP.1.md | 1679 ------ contrib/bc/manuals/bc/HP.1 | 2230 -------- contrib/bc/manuals/bc/HP.1.md | 1687 ------ contrib/bc/manuals/bc/N.1 | 2660 ++++++---- contrib/bc/manuals/bc/N.1.md | 725 ++- contrib/bc/manuals/bc/NP.1 | 2243 -------- contrib/bc/manuals/bc/NP.1.md | 1696 ------ contrib/bc/manuals/bc/P.1 | 2250 -------- contrib/bc/manuals/bc/P.1.md | 1704 ------ contrib/bc/manuals/bcl.3 | 1780 ++++--- contrib/bc/manuals/bcl.3.md | 275 +- contrib/bc/manuals/benchmarks.md | 673 --- contrib/bc/manuals/build.md | 213 +- contrib/bc/manuals/dc.1.md.in | 1289 ----- contrib/bc/manuals/dc/A.1 | 1651 +++--- contrib/bc/manuals/dc/A.1.md | 277 +- contrib/bc/manuals/dc/E.1 | 1463 +++--- contrib/bc/manuals/dc/E.1.md | 277 +- contrib/bc/manuals/dc/EH.1 | 1432 +++--- contrib/bc/manuals/dc/EH.1.md | 253 +- contrib/bc/manuals/dc/EHN.1 | 1432 +++--- contrib/bc/manuals/dc/EHN.1.md | 251 +- contrib/bc/manuals/dc/EHNP.1 | 1307 ----- contrib/bc/manuals/dc/EHNP.1.md | 1023 ---- contrib/bc/manuals/dc/EHP.1 | 1311 ----- contrib/bc/manuals/dc/EHP.1.md | 1028 ---- contrib/bc/manuals/dc/EN.1 | 1461 +++--- contrib/bc/manuals/dc/EN.1.md | 275 +- contrib/bc/manuals/dc/ENP.1 | 1322 ----- contrib/bc/manuals/dc/ENP.1.md | 1036 ---- contrib/bc/manuals/dc/EP.1 | 1326 ----- contrib/bc/manuals/dc/EP.1.md | 1041 ---- contrib/bc/manuals/dc/H.1 | 1620 +++--- contrib/bc/manuals/dc/H.1.md | 253 +- contrib/bc/manuals/dc/HN.1 | 1620 +++--- contrib/bc/manuals/dc/HN.1.md | 251 +- contrib/bc/manuals/dc/HNP.1 | 1536 ------ contrib/bc/manuals/dc/HNP.1.md | 1190 ----- contrib/bc/manuals/dc/HP.1 | 1540 ------ contrib/bc/manuals/dc/HP.1.md | 1195 ----- contrib/bc/manuals/dc/N.1 | 1649 +++--- contrib/bc/manuals/dc/N.1.md | 275 +- contrib/bc/manuals/dc/NP.1 | 1551 ------ contrib/bc/manuals/dc/NP.1.md | 1203 ----- contrib/bc/manuals/dc/P.1 | 1555 ------ contrib/bc/manuals/dc/P.1.md | 1208 ----- contrib/bc/manuals/header.txt | 27 - contrib/bc/manuals/header_bc.txt | 1 - contrib/bc/manuals/header_bcl.txt | 1 - contrib/bc/manuals/header_dc.txt | 1 - contrib/bc/release.sh | 601 --- contrib/bc/{ => scripts}/exec-install.sh | 6 +- contrib/bc/{ => scripts}/functions.sh | 74 +- contrib/bc/{ => scripts}/karatsuba.py | 29 +- contrib/bc/{ => scripts}/link.sh | 5 +- contrib/bc/{ => scripts}/locale_install.sh | 53 +- contrib/bc/{ => scripts}/locale_uninstall.sh | 1 + contrib/bc/{ => scripts}/safe-install.sh | 0 contrib/bc/src/args.c | 132 +- contrib/bc/src/bc.c | 11 +- contrib/bc/src/bc_lex.c | 84 +- contrib/bc/src/bc_parse.c | 917 +++- contrib/bc/src/data.c | 455 +- contrib/bc/src/dc.c | 11 +- contrib/bc/src/dc_lex.c | 104 +- contrib/bc/src/dc_parse.c | 93 +- contrib/bc/src/file.c | 63 +- contrib/bc/src/history.c | 677 ++- contrib/bc/src/lang.c | 131 +- contrib/bc/src/lex.c | 123 +- contrib/bc/src/library.c | 180 +- contrib/bc/src/main.c | 13 +- contrib/bc/src/num.c | 1593 ++++-- contrib/bc/src/opt.c | 129 +- contrib/bc/src/parse.c | 83 +- contrib/bc/src/program.c | 1967 +++++-- contrib/bc/src/rand.c | 185 +- contrib/bc/src/read.c | 99 +- contrib/bc/src/vector.c | 302 +- contrib/bc/src/vm.c | 700 ++- contrib/bc/tests/afl.py | 188 - contrib/bc/tests/all.sh | 124 +- contrib/bc/tests/bc/all.txt | 10 +- contrib/bc/tests/bc/bitfuncs.txt | 5400 ++++++++++++++++++++ contrib/bc/tests/bc/bitfuncs_results.txt | 5400 ++++++++++++++++++++ contrib/bc/tests/bc/decimal.txt | 4 + contrib/bc/tests/bc/decimal_results.txt | 9 +- contrib/bc/tests/bc/divmod.txt | 64 + contrib/bc/tests/bc/divmod_results.txt | 126 + contrib/bc/tests/bc/errors.txt | 48 +- contrib/bc/tests/bc/errors/25.txt | 4 + contrib/bc/tests/bc/errors/26.txt | Bin 0 -> 317 bytes contrib/bc/tests/bc/errors/27.txt | 1 + contrib/bc/tests/bc/errors/28.txt | 2 + contrib/bc/tests/bc/errors/29.txt | 20 + contrib/bc/tests/bc/errors/30.txt | 3 + contrib/bc/tests/bc/errors/31.txt | 3 + contrib/bc/tests/bc/errors/32.txt | Bin 0 -> 1701 bytes contrib/bc/tests/bc/leadingzero.txt | 12 + contrib/bc/tests/bc/leadingzero_results.txt | 12 + contrib/bc/tests/bc/lib2.txt | 7 + contrib/bc/tests/bc/lib2_results.txt | 7 + contrib/bc/tests/bc/modexp.txt | 103 + contrib/bc/tests/bc/modexp_results.txt | 103 + contrib/bc/tests/bc/pi_results.txt | 3 +- contrib/bc/tests/bc/posix_errors.txt | 1 + contrib/bc/tests/bc/power.txt | 43 + contrib/bc/tests/bc/power_results.txt | 72 + contrib/bc/tests/bc/recursive_arrays.txt | 353 ++ contrib/bc/tests/bc/recursive_arrays_results.txt | 1 + contrib/bc/tests/bc/scripts/add.bc | 2 +- contrib/bc/tests/bc/scripts/all.txt | 11 +- contrib/bc/tests/bc/scripts/array.bc | 0 contrib/bc/tests/bc/scripts/atan.bc | 0 contrib/bc/tests/bc/scripts/bessel.bc | 0 contrib/bc/tests/bc/scripts/divide.bc | 1 + contrib/bc/tests/bc/scripts/globals.bc | 4 + contrib/bc/tests/bc/scripts/ifs.bc | 49 + contrib/bc/tests/bc/scripts/ifs.txt | 18 + contrib/bc/tests/bc/scripts/ifs2.bc | 33 + contrib/bc/tests/bc/scripts/ifs2.txt | 34 + contrib/bc/tests/bc/scripts/multiply.bc | 1 + contrib/bc/tests/bc/scripts/parse.bc | 0 contrib/bc/tests/bc/scripts/print.bc | 0 contrib/bc/tests/bc/scripts/references.bc | 0 contrib/bc/tests/bc/scripts/screen.bc | 0 contrib/bc/tests/bc/scripts/strings2.bc | 7 + contrib/bc/tests/bc/scripts/subtract.bc | 2 +- contrib/bc/tests/bc/stdin2.txt | 3 + contrib/bc/tests/bc/stdin2_results.txt | 21 + contrib/bc/tests/bc/strings.txt | 61 + contrib/bc/tests/bc/strings_results.txt | 45 + contrib/bc/tests/bc/timeconst.sh | 24 +- contrib/bc/tests/bc/vars_results.txt | 3 +- contrib/bc/tests/bcl.c | 154 +- contrib/bc/tests/dc/all.txt | 2 + contrib/bc/tests/dc/decimal.txt | 5 + contrib/bc/tests/dc/decimal_results.txt | 11 +- contrib/bc/tests/dc/errors.txt | 7 + .../{fuzzing/dc_inputs/17.txt => dc/errors/32.txt} | 2 +- contrib/bc/tests/dc/errors/33.txt | Bin 0 -> 323 bytes .../{fuzzing/dc_inputs/26.txt => dc/errors/34.txt} | 104 +- contrib/bc/tests/dc/exec_stack_len.txt | 6 + contrib/bc/tests/dc/exec_stack_len_results.txt | 8 + contrib/bc/tests/dc/length.txt | 2 + contrib/bc/tests/dc/length_results.txt | 2 + contrib/bc/tests/dc/scientific.txt | 4 + contrib/bc/tests/dc/scientific_results.txt | 4 + contrib/bc/tests/dc/scripts/array.dc | 0 contrib/bc/tests/dc/scripts/asciify.dc | 0 contrib/bc/tests/dc/scripts/easter.sh | 4 +- contrib/bc/tests/dc/scripts/else.dc | 0 contrib/bc/tests/dc/scripts/factorial.dc | 0 contrib/bc/tests/dc/scripts/loop.dc | 0 contrib/bc/tests/dc/scripts/prime.dc | 0 contrib/bc/tests/dc/scripts/quit.dc | 0 contrib/bc/tests/dc/scripts/stream.dc | 2 +- contrib/bc/tests/dc/scripts/stream.txt | Bin 0 -> 130834 bytes contrib/bc/tests/dc/scripts/weird.dc | 0 contrib/bc/tests/dc/stack_len.txt | 15 + contrib/bc/tests/dc/stack_len_results.txt | 10 + contrib/bc/tests/dc/strings.txt | 1 + contrib/bc/tests/dc/strings_results.txt | 1 + contrib/bc/tests/{diff.sh => error.sh} | 74 +- contrib/bc/tests/errors.sh | 55 +- contrib/bc/tests/extra_required.txt | 2 + contrib/bc/tests/fuzzing/bc_inputs1/abs.txt | 7 - contrib/bc/tests/fuzzing/bc_inputs1/add.txt | 146 - contrib/bc/tests/fuzzing/bc_inputs1/arctangent.txt | 26 - contrib/bc/tests/fuzzing/bc_inputs1/array.bc | 60 - contrib/bc/tests/fuzzing/bc_inputs1/arrays.txt | 10 - .../bc/tests/fuzzing/bc_inputs1/assignments.txt | 122 - contrib/bc/tests/fuzzing/bc_inputs1/basic.txt | 7 - contrib/bc/tests/fuzzing/bc_inputs1/boolean.txt | 184 - contrib/bc/tests/fuzzing/bc_inputs1/cosine.txt | 44 - contrib/bc/tests/fuzzing/bc_inputs1/decimal.txt | 35 - contrib/bc/tests/fuzzing/bc_inputs1/divide.txt | 31 - .../bc/tests/fuzzing/bc_inputs1/engineering.txt | 19 - contrib/bc/tests/fuzzing/bc_inputs1/exponent.txt | 22 - contrib/bc/tests/fuzzing/bc_inputs1/functions.bc | 7 - contrib/bc/tests/fuzzing/bc_inputs1/functions.txt | 13 - contrib/bc/tests/fuzzing/bc_inputs1/globals.txt | 21 - contrib/bc/tests/fuzzing/bc_inputs1/len.bc | 48 - contrib/bc/tests/fuzzing/bc_inputs1/length.txt | 59 - contrib/bc/tests/fuzzing/bc_inputs1/lib10.txt | 4 - contrib/bc/tests/fuzzing/bc_inputs1/lib11.txt | 4 - contrib/bc/tests/fuzzing/bc_inputs1/lib12.txt | 1 - contrib/bc/tests/fuzzing/bc_inputs1/lib2.txt | 15 - contrib/bc/tests/fuzzing/bc_inputs1/lib3.txt | 6 - contrib/bc/tests/fuzzing/bc_inputs1/lib4.txt | 10 - contrib/bc/tests/fuzzing/bc_inputs1/lib5.txt | 2 - contrib/bc/tests/fuzzing/bc_inputs1/lib6.txt | 5 - contrib/bc/tests/fuzzing/bc_inputs1/lib7.txt | 12 - contrib/bc/tests/fuzzing/bc_inputs1/lib8.txt | 3 - contrib/bc/tests/fuzzing/bc_inputs2/lib13.txt | 1 - contrib/bc/tests/fuzzing/bc_inputs2/lib14.txt | 1 - contrib/bc/tests/fuzzing/bc_inputs2/lib15.txt | 1 - contrib/bc/tests/fuzzing/bc_inputs2/lib16.txt | 1 - contrib/bc/tests/fuzzing/bc_inputs2/lib19.txt | 1 - contrib/bc/tests/fuzzing/bc_inputs2/lib20.txt | 1 - contrib/bc/tests/fuzzing/bc_inputs2/lib21.txt | 1 - contrib/bc/tests/fuzzing/bc_inputs2/lib22.txt | 1 - contrib/bc/tests/fuzzing/bc_inputs2/lib23.txt | 1 - contrib/bc/tests/fuzzing/bc_inputs2/lib24.txt | 1 - contrib/bc/tests/fuzzing/bc_inputs2/log.txt | 22 - contrib/bc/tests/fuzzing/bc_inputs2/misc.txt | 13 - contrib/bc/tests/fuzzing/bc_inputs2/misc1.txt | 76 - contrib/bc/tests/fuzzing/bc_inputs2/misc2.txt | 110 - contrib/bc/tests/fuzzing/bc_inputs2/misc3.txt | 12 - contrib/bc/tests/fuzzing/bc_inputs2/modulus.txt | 69 - contrib/bc/tests/fuzzing/bc_inputs2/multiply.txt | 40 - contrib/bc/tests/fuzzing/bc_inputs2/pi.txt | 4 - contrib/bc/tests/fuzzing/bc_inputs2/places.txt | 19 - contrib/bc/tests/fuzzing/bc_inputs2/power.txt | 44 - contrib/bc/tests/fuzzing/bc_inputs2/print2.txt | 194 - contrib/bc/tests/fuzzing/bc_inputs2/references.bc | 408 -- contrib/bc/tests/fuzzing/bc_inputs2/scale.txt | 57 - contrib/bc/tests/fuzzing/bc_inputs2/scientific.txt | 51 - contrib/bc/tests/fuzzing/bc_inputs2/shift.txt | 281 - contrib/bc/tests/fuzzing/bc_inputs2/sine.txt | 207 - contrib/bc/tests/fuzzing/bc_inputs3/01.txt | 339 -- contrib/bc/tests/fuzzing/bc_inputs3/02.txt | 1 - contrib/bc/tests/fuzzing/bc_inputs3/03.txt | 2 - contrib/bc/tests/fuzzing/bc_inputs3/04.txt | 1 - contrib/bc/tests/fuzzing/bc_inputs3/05.txt | 1 - contrib/bc/tests/fuzzing/bc_inputs3/06.txt | 1 - contrib/bc/tests/fuzzing/bc_inputs3/07.txt | 8 - contrib/bc/tests/fuzzing/bc_inputs3/08.txt | 3 - contrib/bc/tests/fuzzing/bc_inputs3/09.txt | 11 - contrib/bc/tests/fuzzing/bc_inputs3/10.txt | 1 - contrib/bc/tests/fuzzing/bc_inputs3/11.txt | 99 - contrib/bc/tests/fuzzing/bc_inputs3/12.txt | 2 - contrib/bc/tests/fuzzing/bc_inputs3/13.txt | 56 - contrib/bc/tests/fuzzing/bc_inputs3/14.txt | 1 - contrib/bc/tests/fuzzing/bc_inputs3/15.txt | 3 - contrib/bc/tests/fuzzing/bc_inputs3/16.txt | 1 - contrib/bc/tests/fuzzing/bc_inputs3/17.txt | 11 - contrib/bc/tests/fuzzing/bc_inputs3/18.txt | 3 - contrib/bc/tests/fuzzing/bc_inputs3/19.txt | 5 - contrib/bc/tests/fuzzing/bc_inputs3/20.txt | 51 - contrib/bc/tests/fuzzing/bc_inputs3/21.txt | 10 - contrib/bc/tests/fuzzing/bc_inputs3/22.txt | 2 - contrib/bc/tests/fuzzing/bc_inputs3/23.txt | Bin 1024 -> 0 bytes contrib/bc/tests/fuzzing/bc_inputs3/24.txt | 4 - contrib/bc/tests/fuzzing/bc_inputs3/sqrt.txt | 14 - contrib/bc/tests/fuzzing/bc_inputs3/strings.txt | 12 - contrib/bc/tests/fuzzing/bc_inputs3/subtract.txt | 153 - contrib/bc/tests/fuzzing/bc_inputs3/trunc.txt | 15 - contrib/bc/tests/fuzzing/bc_inputs3/void.txt | 20 - contrib/bc/tests/fuzzing/dc_inputs/01.txt | 2 - contrib/bc/tests/fuzzing/dc_inputs/02.txt | 5 - contrib/bc/tests/fuzzing/dc_inputs/03.txt | 2 - contrib/bc/tests/fuzzing/dc_inputs/04.txt | 9 - contrib/bc/tests/fuzzing/dc_inputs/05.txt | 3 - contrib/bc/tests/fuzzing/dc_inputs/06.txt | 1 - contrib/bc/tests/fuzzing/dc_inputs/07.txt | 3 - contrib/bc/tests/fuzzing/dc_inputs/08.txt | 1 - contrib/bc/tests/fuzzing/dc_inputs/09.txt | 9 - contrib/bc/tests/fuzzing/dc_inputs/10.txt | 11 - contrib/bc/tests/fuzzing/dc_inputs/11.txt | 4 - contrib/bc/tests/fuzzing/dc_inputs/12.txt | 2 - contrib/bc/tests/fuzzing/dc_inputs/13.txt | 7 - contrib/bc/tests/fuzzing/dc_inputs/14.txt | 7 - contrib/bc/tests/fuzzing/dc_inputs/15.txt | 11 - contrib/bc/tests/fuzzing/dc_inputs/16.txt | 1 - contrib/bc/tests/fuzzing/dc_inputs/18.txt | 3 - contrib/bc/tests/fuzzing/dc_inputs/19.txt | 1 - contrib/bc/tests/fuzzing/dc_inputs/20.txt | 3 - contrib/bc/tests/fuzzing/dc_inputs/21.txt | 5 - contrib/bc/tests/fuzzing/dc_inputs/22.txt | 36 - contrib/bc/tests/fuzzing/dc_inputs/23.txt | 2 - contrib/bc/tests/fuzzing/dc_inputs/24.txt | 1 - contrib/bc/tests/fuzzing/dc_inputs/25.txt | 6 - contrib/bc/tests/fuzzing/dc_inputs/27.txt | 2 - contrib/bc/tests/fuzzing/dc_inputs/28.txt | 1 - contrib/bc/tests/fuzzing/dc_inputs/29.txt | 13 - contrib/bc/tests/fuzzing/dc_inputs/30.txt | 1 - contrib/bc/tests/fuzzing/dc_inputs/31.txt | 1 - contrib/bc/tests/fuzzing/dc_inputs/abs.txt | 7 - contrib/bc/tests/fuzzing/dc_inputs/add.txt | 33 - contrib/bc/tests/fuzzing/dc_inputs/array.dc | 2 - contrib/bc/tests/fuzzing/dc_inputs/boolean.txt | 80 - contrib/bc/tests/fuzzing/dc_inputs/decimal.txt | 36 - contrib/bc/tests/fuzzing/dc_inputs/divide.txt | 33 - contrib/bc/tests/fuzzing/dc_inputs/divmod.txt | 64 - contrib/bc/tests/fuzzing/dc_inputs/else.dc | 4 - contrib/bc/tests/fuzzing/dc_inputs/engineering.txt | 19 - contrib/bc/tests/fuzzing/dc_inputs/loop.dc | 3 - contrib/bc/tests/fuzzing/dc_inputs/misc.txt | 1 - contrib/bc/tests/fuzzing/dc_inputs/modexp.txt | 103 - contrib/bc/tests/fuzzing/dc_inputs/modulus.txt | 70 - contrib/bc/tests/fuzzing/dc_inputs/multiply.txt | 42 - contrib/bc/tests/fuzzing/dc_inputs/places.txt | 14 - contrib/bc/tests/fuzzing/dc_inputs/power.txt | 36 - contrib/bc/tests/fuzzing/dc_inputs/quit.dc | 2 - contrib/bc/tests/fuzzing/dc_inputs/scientific.txt | 51 - contrib/bc/tests/fuzzing/dc_inputs/shift.txt | 42 - contrib/bc/tests/fuzzing/dc_inputs/sqrt.txt | 14 - contrib/bc/tests/fuzzing/dc_inputs/stdin.txt | 205 - contrib/bc/tests/fuzzing/dc_inputs/stream.dc | 2 - contrib/bc/tests/fuzzing/dc_inputs/strings.txt | 50 - contrib/bc/tests/fuzzing/dc_inputs/subtract.txt | 33 - contrib/bc/tests/fuzzing/dc_inputs/trunc.txt | 11 - contrib/bc/tests/fuzzing/dc_inputs/vars.txt | 2 - contrib/bc/tests/fuzzing/dc_inputs/weird.dc | 2 - contrib/bc/tests/history.py | 1153 +++++ contrib/bc/tests/{fuzzing/bc.dict => history.sh} | 122 +- contrib/bc/tests/other.sh | 142 +- contrib/bc/tests/radamsa.sh | 120 - contrib/bc/tests/radamsa.txt | 17 - contrib/bc/tests/randmath.py | 306 -- contrib/bc/tests/read.sh | 25 +- contrib/bc/tests/script.sed | 9 + contrib/bc/tests/script.sh | 22 +- contrib/bc/tests/scripts.sh | 53 +- contrib/bc/tests/stdin.sh | 23 +- contrib/bc/tests/test.sh | 17 +- contrib/bc/{ => vs}/bc.sln | 22 +- contrib/bc/vs/bc.vcxproj | 297 ++ contrib/bc/vs/bc.vcxproj.filters | 173 + contrib/bc/vs/bcl.sln | 37 + contrib/bc/vs/bcl.vcxproj | 259 + contrib/bc/vs/bcl.vcxproj.filters | 90 + contrib/bc/vs/tests/tests_bc.bat | 104 + contrib/bc/vs/tests/tests_dc.bat | 61 + usr.bin/gh-bc/Makefile | 20 +- usr.bin/gh-bc/tests/Makefile | 4 +- 417 files changed, 50523 insertions(+), 75025 deletions(-) diff --git a/contrib/bc/.gitattributes b/contrib/bc/.gitattributes index 22d6e60bce68..1e2c56dde215 100644 --- a/contrib/bc/.gitattributes +++ b/contrib/bc/.gitattributes @@ -1,3 +1,3 @@ *.vcxproj eol=crlf *.vcxproj.filters eol=crlf -*.sln eol= crlf +*.sln eol=crlf diff --git a/contrib/bc/.gitignore b/contrib/bc/.gitignore index b131d5813764..31e43aa61efc 100644 --- a/contrib/bc/.gitignore +++ b/contrib/bc/.gitignore @@ -51,11 +51,17 @@ print_results.txt bessel.txt bessel_results.txt prime.txt -stream.txt +strings2.txt +strings2_results.txt tests/bc/scripts/add.txt tests/bc/scripts/divide.txt tests/bc/scripts/multiply.txt tests/bc/scripts/subtract.txt +tests/bc/scripts/strings2.txt +benchmarks/bc/*.txt +benchmarks/dc/*.txt +scripts/ministat +scripts/bitgen perf.data perf.data.old *.gcda diff --git a/contrib/bc/LICENSE.md b/contrib/bc/LICENSE.md index 269e131cc81d..8ab2e6069881 100644 --- a/contrib/bc/LICENSE.md +++ b/contrib/bc/LICENSE.md @@ -79,9 +79,9 @@ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -## `safe-install.sh` +## `scripts/safe-install.sh` -The file `safe-install.sh` is under the following copyright and license: +The file `scripts/safe-install.sh` is under the following copyright and license: Copyright (c) 2021 Rich Felker @@ -101,3 +101,13 @@ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +## `scripts/ministat.c` + +The file `scripts/ministat.c` is under the following license: + +"THE BEER-WARE LICENSE" (Revision 42): + + wrote this file. As long as you retain this notice you +can do whatever you want with this stuff. If we meet some day, and you think +this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp diff --git a/contrib/bc/Makefile.in b/contrib/bc/Makefile.in index 2b50476a79fe..3d6780d6ac95 100644 --- a/contrib/bc/Makefile.in +++ b/contrib/bc/Makefile.in @@ -134,39 +134,64 @@ BC_ENABLE_HISTORY = %%HISTORY%% BC_ENABLE_EXTRA_MATH_NAME = BC_ENABLE_EXTRA_MATH BC_ENABLE_EXTRA_MATH = %%EXTRA_MATH%% BC_ENABLE_NLS = %%NLS%% -BC_ENABLE_PROMPT = %%PROMPT%% BC_LONG_BIT = %%LONG_BIT%% BC_ENABLE_AFL = %%FUZZ%% BC_ENABLE_MEMCHECK = %%MEMCHECK%% +BC_DEFAULT_BANNER = %%BC_DEFAULT_BANNER%% +BC_DEFAULT_SIGINT_RESET = %%BC_DEFAULT_SIGINT_RESET%% +DC_DEFAULT_SIGINT_RESET = %%DC_DEFAULT_SIGINT_RESET%% +BC_DEFAULT_TTY_MODE = %%BC_DEFAULT_TTY_MODE%% +DC_DEFAULT_TTY_MODE = %%DC_DEFAULT_TTY_MODE%% +BC_DEFAULT_PROMPT = %%BC_DEFAULT_PROMPT%% +DC_DEFAULT_PROMPT = %%DC_DEFAULT_PROMPT%% + RM = rm MKDIR = mkdir -INSTALL = ./exec-install.sh -SAFE_INSTALL = ./safe-install.sh -LINK = ./link.sh -MANPAGE = ./manpage.sh -KARATSUBA = ./karatsuba.py -LOCALE_INSTALL = ./locale_install.sh -LOCALE_UNINSTALL = ./locale_uninstall.sh +SCRIPTS = ./scripts + +MINISTAT = ministat +MINISTAT_EXEC = $(SCRIPTS)/$(MINISTAT) + +BITFUNCGEN = bitfuncgen +BITFUNCGEN_EXEC = $(SCRIPTS)/$(BITFUNCGEN) + +INSTALL = $(SCRIPTS)/exec-install.sh +SAFE_INSTALL = $(SCRIPTS)/safe-install.sh +LINK = $(SCRIPTS)/link.sh +MANPAGE = $(SCRIPTS)/manpage.sh +KARATSUBA = $(SCRIPTS)/karatsuba.py +LOCALE_INSTALL = $(SCRIPTS)/locale_install.sh +LOCALE_UNINSTALL = $(SCRIPTS)/locale_uninstall.sh VALGRIND_ARGS = --error-exitcode=100 --leak-check=full --show-leak-kinds=all --errors-for-leak-kinds=all -TEST_STARS = "***********************************************************************" +TEST_STARS = *********************************************************************** BC_NUM_KARATSUBA_LEN = %%KARATSUBA_LEN%% +BC_DEFS0 = -DBC_DEFAULT_BANNER=$(BC_DEFAULT_BANNER) +BC_DEFS1 = -DBC_DEFAULT_SIGINT_RESET=$(BC_DEFAULT_SIGINT_RESET) +BC_DEFS2 = -DBC_DEFAULT_TTY_MODE=$(BC_DEFAULT_TTY_MODE) +BC_DEFS3 = -DBC_DEFAULT_PROMPT=$(BC_DEFAULT_PROMPT) +BC_DEFS = $(BC_DEFS0) $(BC_DEFS1) $(BC_DEFS2) $(BC_DEFS3) +DC_DEFS1 = -DDC_DEFAULT_SIGINT_RESET=$(DC_DEFAULT_SIGINT_RESET) +DC_DEFS2 = -DDC_DEFAULT_TTY_MODE=$(DC_DEFAULT_TTY_MODE) +DC_DEFS3 = -DDC_DEFAULT_PROMPT=$(DC_DEFAULT_PROMPT) +DC_DEFS = $(DC_DEFS1) $(DC_DEFS2) $(DC_DEFS3) + CPPFLAGS1 = -D$(BC_ENABLED_NAME)=$(BC_ENABLED) -D$(DC_ENABLED_NAME)=$(DC_ENABLED) CPPFLAGS2 = $(CPPFLAGS1) -I./include/ -DBUILD_TYPE=$(BC_BUILD_TYPE) %%LONG_BIT_DEFINE%% CPPFLAGS3 = $(CPPFLAGS2) -DEXECPREFIX=$(EXEC_PREFIX) -DMAINEXEC=$(MAIN_EXEC) -CPPFLAGS4 = $(CPPFLAGS3) -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700 +CPPFLAGS4 = $(CPPFLAGS3) -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700 %%BSD%% CPPFLAGS5 = $(CPPFLAGS4) -DBC_NUM_KARATSUBA_LEN=$(BC_NUM_KARATSUBA_LEN) -CPPFLAGS6 = $(CPPFLAGS5) -DBC_ENABLE_NLS=$(BC_ENABLE_NLS) -DBC_ENABLE_PROMPT=$(BC_ENABLE_PROMPT) +CPPFLAGS6 = $(CPPFLAGS5) -DBC_ENABLE_NLS=$(BC_ENABLE_NLS) CPPFLAGS7 = $(CPPFLAGS6) -D$(BC_ENABLE_EXTRA_MATH_NAME)=$(BC_ENABLE_EXTRA_MATH) CPPFLAGS8 = $(CPPFLAGS7) -DBC_ENABLE_HISTORY=$(BC_ENABLE_HISTORY) -DBC_ENABLE_LIBRARY=$(BC_ENABLE_LIBRARY) CPPFLAGS = $(CPPFLAGS8) -DBC_ENABLE_MEMCHECK=$(BC_ENABLE_MEMCHECK) -DBC_ENABLE_AFL=$(BC_ENABLE_AFL) -CFLAGS = $(CPPFLAGS) %%CPPFLAGS%% %%CFLAGS%% +CFLAGS = $(CPPFLAGS) $(BC_DEFS) $(DC_DEFS) %%CPPFLAGS%% %%CFLAGS%% LDFLAGS = %%LDFLAGS%% HOSTCFLAGS = %%HOSTCFLAGS%% @@ -219,6 +244,12 @@ $(BIN): headers: %%HEADERS%% +$(MINISTAT): + $(HOSTCC) $(HOSTCFLAGS) -lm -o $(MINISTAT_EXEC) scripts/ministat.c + +$(BITFUNCGEN): + $(HOSTCC) $(HOSTCFLAGS) -lm -o $(BITFUNCGEN_EXEC) scripts/bitfuncgen.c + help: @printf 'available targets:\n' @printf '\n' @@ -249,16 +280,33 @@ help: @printf ' valgrind_dc runs the dc test suite, if dc has been built,\n' @printf ' through valgrind\n' -run_all_tests: +run_all_tests: bc_all_tests timeconst_all_tests dc_all_tests + +run_all_tests_np: bc_all_tests_np timeconst_all_tests dc_all_tests_np + +bc_all_tests: %%BC_ALL_TESTS%% + +bc_all_tests_np: + %%BC_ALL_TESTS_NP%% + +timeconst_all_tests: %%TIMECONST_ALL_TESTS%% + +dc_all_tests: %%DC_ALL_TESTS%% +dc_all_tests_np: + %%DC_ALL_TESTS_NP%% + +history_all_tests: + %%HISTORY_TESTS%% + check: test test: %%TESTS%% -test_bc: test_bc_header test_bc_tests test_bc_scripts test_bc_stdin test_bc_read test_bc_errors test_bc_other +test_bc: test_bc_header test_bc_tests test_bc_scripts test_bc_errors test_bc_stdin test_bc_read test_bc_other @printf '\nAll bc tests passed.\n\n$(TEST_STARS)\n' test_bc_tests:%%BC_TESTS%% @@ -271,16 +319,18 @@ test_bc_stdin: test_bc_read: @sh tests/read.sh bc %%BC_TEST_EXEC%% -test_bc_errors: +test_bc_errors: test_bc_error_lines%%BC_ERROR_TESTS%% + +test_bc_error_lines: @sh tests/errors.sh bc %%BC_TEST_EXEC%% test_bc_other: - @sh tests/other.sh bc %%BC_TEST_EXEC%% + @sh tests/other.sh bc $(BC_ENABLE_EXTRA_MATH) %%BC_TEST_EXEC%% test_bc_header: @printf '$(TEST_STARS)\n\nRunning bc tests...\n\n' -test_dc: test_dc_header test_dc_tests test_dc_scripts test_dc_stdin test_dc_read test_dc_errors test_dc_other +test_dc: test_dc_header test_dc_tests test_dc_scripts test_dc_errors test_dc_stdin test_dc_read test_dc_other @printf '\nAll dc tests passed.\n\n$(TEST_STARS)\n' test_dc_tests:%%DC_TESTS%% @@ -293,11 +343,13 @@ test_dc_stdin: test_dc_read: @sh tests/read.sh dc %%DC_TEST_EXEC%% -test_dc_errors: +test_dc_errors: test_dc_error_lines%%DC_ERROR_TESTS%% + +test_dc_error_lines: @sh tests/errors.sh dc %%DC_TEST_EXEC%% test_dc_other: - @sh tests/other.sh dc %%DC_TEST_EXEC%% + @sh tests/other.sh dc $(BC_ENABLE_EXTRA_MATH) %%DC_TEST_EXEC%% test_dc_header: @printf '$(TEST_STARS)\n\nRunning dc tests...\n\n' @@ -305,6 +357,122 @@ test_dc_header: timeconst: %%TIMECONST%% +test_history: test_history_header test_bc_history test_dc_history + @printf '\nAll history tests passed.\n\n$(TEST_STARS)\n' + +test_bc_history:%%BC_HISTORY_TEST_PREREQS%% + +test_bc_history_all: test_bc_history0 test_bc_history1 test_bc_history2 test_bc_history3 test_bc_history4 test_bc_history5 test_bc_history6 test_bc_history7 test_bc_history8 test_bc_history9 test_bc_history10 test_bc_history11 test_bc_history12 test_bc_history13 test_bc_history14 test_bc_history15 test_bc_history16 test_bc_history17 test_bc_history18 test_bc_history19 test_bc_history20 test_bc_history21 + +test_bc_history_skip: + @printf 'No bc history tests to run\n' + +test_bc_history0: + @sh tests/history.sh bc 0 %%BC_TEST_EXEC%% + +test_bc_history1: + @sh tests/history.sh bc 1 %%BC_TEST_EXEC%% + +test_bc_history2: + @sh tests/history.sh bc 2 %%BC_TEST_EXEC%% + +test_bc_history3: + @sh tests/history.sh bc 3 %%BC_TEST_EXEC%% + +test_bc_history4: + @sh tests/history.sh bc 4 %%BC_TEST_EXEC%% + +test_bc_history5: + @sh tests/history.sh bc 5 %%BC_TEST_EXEC%% + +test_bc_history6: + @sh tests/history.sh bc 6 %%BC_TEST_EXEC%% + +test_bc_history7: + @sh tests/history.sh bc 7 %%BC_TEST_EXEC%% + +test_bc_history8: + @sh tests/history.sh bc 8 %%BC_TEST_EXEC%% + +test_bc_history9: + @sh tests/history.sh bc 9 %%BC_TEST_EXEC%% + +test_bc_history10: + @sh tests/history.sh bc 10 %%BC_TEST_EXEC%% + +test_bc_history11: + @sh tests/history.sh bc 11 %%BC_TEST_EXEC%% + +test_bc_history12: + @sh tests/history.sh bc 12 %%BC_TEST_EXEC%% + +test_bc_history13: + @sh tests/history.sh bc 13 %%BC_TEST_EXEC%% + +test_bc_history14: + @sh tests/history.sh bc 14 %%BC_TEST_EXEC%% + +test_bc_history15: + @sh tests/history.sh bc 15 %%BC_TEST_EXEC%% + +test_bc_history16: + @sh tests/history.sh bc 16 %%BC_TEST_EXEC%% + +test_bc_history17: + @sh tests/history.sh bc 17 %%BC_TEST_EXEC%% + +test_bc_history18: + @sh tests/history.sh bc 18 %%BC_TEST_EXEC%% + +test_bc_history19: + @sh tests/history.sh bc 19 %%BC_TEST_EXEC%% + +test_bc_history20: + @sh tests/history.sh bc 20 %%BC_TEST_EXEC%% + +test_bc_history21: + @sh tests/history.sh bc 21 %%BC_TEST_EXEC%% + +test_dc_history:%%DC_HISTORY_TEST_PREREQS%% + +test_dc_history_all: test_dc_history0 test_dc_history1 test_dc_history2 test_dc_history3 test_dc_history4 test_dc_history5 test_dc_history6 test_dc_history7 test_dc_history8 test_dc_history9 + +test_dc_history_skip: + @printf 'No dc history tests to run\n' + +test_dc_history0: + @sh tests/history.sh dc 0 %%DC_TEST_EXEC%% + +test_dc_history1: + @sh tests/history.sh dc 1 %%DC_TEST_EXEC%% + +test_dc_history2: + @sh tests/history.sh dc 2 %%DC_TEST_EXEC%% + +test_dc_history3: + @sh tests/history.sh dc 3 %%DC_TEST_EXEC%% + +test_dc_history4: + @sh tests/history.sh dc 4 %%DC_TEST_EXEC%% + +test_dc_history5: + @sh tests/history.sh dc 5 %%DC_TEST_EXEC%% + +test_dc_history6: + @sh tests/history.sh dc 6 %%DC_TEST_EXEC%% + +test_dc_history7: + @sh tests/history.sh dc 7 %%DC_TEST_EXEC%% + +test_dc_history8: + @sh tests/history.sh dc 8 %%DC_TEST_EXEC%% + +test_dc_history9: + @sh tests/history.sh dc 9 %%DC_TEST_EXEC%% + +test_history_header: + @printf '$(TEST_STARS)\n\nRunning history tests...\n\n' + library_test: $(LIBBC) $(CC) $(CFLAGS) $(BCL_TEST_C) $(LIBBC) -o $(BCL_TEST) @@ -322,12 +490,6 @@ coverage_output: coverage:%%COVERAGE_PREREQS%% -libcname: - @printf '%s' "$(BC_LIB_C)" - -extra_math: - @printf '%s' "$(BC_ENABLE_EXTRA_MATH)" - manpages: $(MANPAGE) bc $(MANPAGE) dc @@ -348,15 +510,19 @@ clean:%%CLEAN_PREREQS%% @$(RM) -f $(BC_LIB2_C) $(BC_LIB2_O) @$(RM) -f $(BC_HELP_C) $(BC_HELP_O) @$(RM) -f $(DC_HELP_C) $(DC_HELP_O) - @$(RM) -fr $(BC_TEST_OUTPUTS) $(DC_TEST_OUTPUTS) - @$(RM) -fr $(BC_FUZZ_OUTPUTS) $(DC_FUZZ_OUTPUTS) @$(RM) -fr Debug/ Release/ -clean_config: clean +clean_benchmarks: + @printf 'Cleaning benchmarks...\n' + @$(RM) -f $(MINISTAT_EXEC) + @$(RM) -f benchmarks/bc/*.txt + @$(RM) -f benchmarks/dc/*.txt + +clean_config: clean clean_benchmarks @printf 'Cleaning config...\n' @$(RM) -f Makefile - @$(RM) -f $(BC_MD) $(DC_MD) - @$(RM) -f $(BC_MANPAGE) $(DC_MANPAGE) + @$(RM) -f $(BC_MD) $(BC_MANPAGE) + @$(RM) -f $(DC_MD) $(DC_MANPAGE) clean_coverage: @printf 'Cleaning coverage files...\n' @@ -376,9 +542,12 @@ clean_coverage: clean_tests: clean clean_config clean_coverage @printf 'Cleaning test files...\n' + @$(RM) -fr $(BC_TEST_OUTPUTS) $(DC_TEST_OUTPUTS) + @$(RM) -fr $(BC_FUZZ_OUTPUTS) $(DC_FUZZ_OUTPUTS) @$(RM) -f tests/bc/parse.txt tests/bc/parse_results.txt @$(RM) -f tests/bc/print.txt tests/bc/print_results.txt @$(RM) -f tests/bc/bessel.txt tests/bc/bessel_results.txt + @$(RM) -f tests/bc/strings2.txt tests/bc/strings2_results.txt @$(RM) -f tests/bc/scripts/bessel.txt @$(RM) -f tests/bc/scripts/parse.txt @$(RM) -f tests/bc/scripts/print.txt @@ -386,13 +555,15 @@ clean_tests: clean clean_config clean_coverage @$(RM) -f tests/bc/scripts/divide.txt @$(RM) -f tests/bc/scripts/multiply.txt @$(RM) -f tests/bc/scripts/subtract.txt - @$(RM) -f tests/dc/scripts/prime.txt tests/dc/scripts/stream.txt + @$(RM) -f tests/bc/scripts/strings2.txt + @$(RM) -f tests/dc/scripts/prime.txt @$(RM) -f .log_*.txt @$(RM) -f .math.txt .results.txt .ops.txt @$(RM) -f .test.txt @$(RM) -f tags .gdbbreakpoints .gdb_history .gdbsetup @$(RM) -f cscope.* @$(RM) -f bc.old + @$(RM) -f $(BITFUNCGEN_EXEC) install_locales: %%INSTALL_LOCALES%% diff --git a/contrib/bc/NEWS.md b/contrib/bc/NEWS.md index c78bddd27e76..5251096d9f2a 100644 --- a/contrib/bc/NEWS.md +++ b/contrib/bc/NEWS.md @@ -1,5 +1,111 @@ # News +## 5.1.1 + +This is a production release that completes a bug fix from `5.1.0`. The bug +exists in all versions of `bc`. + +The bug was that `if` statements without `else` statements would not be handled +correctly at the end of files or right before a function definition. + +## 5.1.0 + +This is a production release with some fixes and new features. + *** 152081 LINES SKIPPED *** From nobody Tue Oct 12 14:43:39 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 23CBA17FE8E4; Tue, 12 Oct 2021 14:43: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 4HTJM10QD2z3C0D; Tue, 12 Oct 2021 14:43: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 E1E2F16547; Tue, 12 Oct 2021 14:43: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 19CEhegC068625; Tue, 12 Oct 2021 14:43:40 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19CEhdR5068624; Tue, 12 Oct 2021 14:43:39 GMT (envelope-from git) Date: Tue, 12 Oct 2021 14:43:39 GMT Message-Id: <202110121443.19CEhdR5068624@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: =?utf-8?Q?Stefan E=C3=9Fer?= Subject: git: e32b8140f4e7 - stable/12 - contrib/bc, usr.bin/gh-bc: merge update to version 5.1.1 List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: se X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: e32b8140f4e7de93eb7d571e7fcb2bf9db6c97a3 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by se: URL: https://cgit.FreeBSD.org/src/commit/?id=e32b8140f4e7de93eb7d571e7fcb2bf9db6c97a3 commit e32b8140f4e7de93eb7d571e7fcb2bf9db6c97a3 Author: Stefan Eßer AuthorDate: 2021-05-12 05:49:19 +0000 Commit: Stefan Eßer CommitDate: 2021-10-12 14:37:47 +0000 contrib/bc, usr.bin/gh-bc: merge update to version 5.1.1 This version of bc and dc is used by default on FreeBSD-13 and newer, but remains optional on FreeBSD-12.x. It is enabled by building and installing the world with WITH_GH_BC=yes defined in /etc/src.conf. contrib/bc: update to version 4.0.2 Merge commit '2858419a0ee2b8f5827de72c00618bcd69ebc5fc' This update fixes the initialization of "scale" to 20 if started with -l and the initial statement leads to an error (e.g. contains a syntax error). Scale was initialized to 0 in that case. Another change is the support of job control in interactive mode with line editing enabled. The control characters have been interpreted as editing commands only, prior to this version. (cherry picked from commit 8c39e25220bb88cd027d0c3b0fe86e52f6abd150) (cherry picked from commit 3d5f931a771ce8937c0572a4fc11bf7a09323125) usr.bin/gh-bc, contrib/bc: update to version 5.0.0 Merge commit 2f57ecae4b98e76e5d675563785a7e6c59c868c4 This is a new major release with a number of changes and extensions: - Limited the number of temporary numbers and made the space for them static so that allocating more space for them cannot fail. - Allowed integers with non-zero scale to be used with power, places, and shift operators. - Added greatest common divisor and least common multiple to lib2.bc. - Made bc and dc UTF-8 capable. - Added the ability for users to have bc and dc quit on SIGINT. - Added the ability for users to disable prompt and TTY mode by environment variables. - Added the ability for users to redefine keywords. - Added dc's modular exponentiation and divmod to bc. - Added the ability to assign strings to variables and array elements and pass them to functions in bc. - Added dc's asciify command and stream printing to bc. - Added bitwise and, or, xor, left shift, right shift, reverse, left rotate, right rotate, and mod functions to lib2.bc. - Added the functions s2u(x) and s2un(x,n), to lib2.bc. MFC after: 1 week (cherry picked from commit 44d4804d1945435745518cd09eb8ae6ab22ecef4) vendor/bc: update to upstream version 5.0.2 (cherry picked from commit a60ef1802a36f2f2a5611564191440ea1c1e2f17) (cherry picked from commit 662087dfd0668dee82ed20d00ced662aa3595059) contrib/bc: remove files ommitted from the release A number of files have been removed from the release distribution of this bc implementation. They were mostly relevant for pre release testing and benchmarking to identify regressions. The Markdown sources of the man pages are only relevant for combinations of build options not used in FreeBSD and need non-default conversion tools (available as ports in FreeBSD). All the omitted files can be found in the upstream git repository, and they are fetched when building this software as a port. But they have never been used in the FreeBSD base system. (cherry picked from commit ea31d1a5c490193348e0b71fdda6d08a2c80a2eb) Remove files that were checked in with wrong .gitattributes These files will be added back in updated form, but are only relevant for the Windows platform, anyway. (cherry picked from commit d6c323eda215d05091f56d02a8274eb50c244a6f) contrib/bc: merge version 5.1.0 from vendor branch This version adds options and functions that allow to print numbers in the open interval (-1 .. 1) with or without a leading 0 digit. Additionally, an option has been added to prevent line wrap and allows to print arbitrarily long results on a single line. Merge commit '5d58a51571721190681c50d4bd3a1f45e6282d72' (cherry picked from commit d43fa8ef534ac87a16843d45264f56cf11e0fcbc) contrib/bc: update to version 5.1.1 Merge commit '6f49f5cdde1c62c4e5a743e895f3afe592b5c0e5' (cherry picked from commit a30efc5ca7272e446abb71f0d72c76539f267bb6) contrib/bc: temporarily disconnect the tests for 5.0.2 The tests that come with version 5.0.2 have been extended to cover the line editing functions. It has been found that these tests generate false negative results in FreeBSD, most likely due to an issue in the pexpect functionality used. These history tests are skipped on systems that do not have python and py-pexpect installed (and thus are unlikely to cause CI test failures), but in order to not cause irritating failures on systems were these packages are in fact installed, I temporarily disconnect them. I had planned to skip this version due to the issue with the history tests, but some committer has asked me to go ahead since the currently used version 5.0.0 contains a macro name that collides with a project he is working on. No MFC of this version is planned. A version 5.0.3 is expected to be released soon, and that version will allow to reconnect the tests and will be MFCed. (cherry picked from commit f774652b0e837be415abd20935eae3466ea34a20) Add back Windows only VCXProj files (cherry picked from commit ded0d3d486eba766f613070de0ed12029a9a3816) contrib/bc: re-enable tests after the import of version 5.1.0 The tests have been fixed to not write any data outside of the temporary work directory provided by the test framework. MFC after: 3 days (cherry picked from commit b8d895faf47afb8f3b31055e2ec2db8d0df5db23) Revert erroneous commit ded0d3d486eba These files came from a prior commit to contrib/bc and seem to have been placed in the top of the source tree by a failed git rebase. Reported by: markj (cherry picked from commit f902ca97bdbceccf62b4b02b0321af91ea398925) (cherry picked from commit e84a97439b4bcc11e04837b2f130dfff4c755c5f) --- contrib/bc/.gitattributes | 2 +- contrib/bc/.gitignore | 8 +- contrib/bc/LICENSE.md | 14 +- contrib/bc/Makefile.in | 233 +- contrib/bc/NEWS.md | 126 +- contrib/bc/README.md | 50 +- contrib/bc/RELEASE.md | 54 - contrib/bc/bc.vcxproj | 278 - contrib/bc/bc.vcxproj.filters | 182 - contrib/bc/bcl.sln | 31 - contrib/bc/bcl.vcxproj | 161 - contrib/bc/bcl.vcxproj.filters | 96 - contrib/bc/configure | 1322 +---- contrib/bc/configure.sh | 467 +- contrib/bc/gen/bc_help.txt | 60 + contrib/bc/gen/dc_help.txt | 38 + contrib/bc/gen/lib.bc | 2 +- contrib/bc/gen/lib2.bc | 283 +- contrib/bc/gen/strgen.c | 112 +- contrib/bc/gen/strgen.sh | 3 + contrib/bc/include/args.h | 11 +- contrib/bc/include/bc.h | 313 +- contrib/bc/include/bcl.h | 142 +- contrib/bc/include/dc.h | 42 +- contrib/bc/include/file.h | 88 + contrib/bc/include/history.h | 109 +- contrib/bc/include/lang.h | 445 +- contrib/bc/include/lex.h | 375 +- contrib/bc/include/library.h | 90 +- contrib/bc/include/num.h | 646 ++- contrib/bc/include/opt.h | 61 + contrib/bc/include/parse.h | 182 +- contrib/bc/include/program.h | 828 ++- contrib/bc/include/rand.h | 326 +- contrib/bc/include/read.h | 42 +- contrib/bc/include/status.h | 646 ++- contrib/bc/include/vector.h | 378 +- contrib/bc/include/version.h | 5 +- contrib/bc/include/vm.h | 693 ++- contrib/bc/locales/de_DE.ISO8859-1.msg | 13 +- contrib/bc/locales/de_DE.UTF-8.msg | 13 +- contrib/bc/locales/en_US.msg | 13 +- contrib/bc/locales/es_ES.ISO8859-1.msg | 13 +- contrib/bc/locales/es_ES.UTF-8.msg | 13 +- contrib/bc/locales/fr_FR.ISO8859-1.msg | 13 +- contrib/bc/locales/fr_FR.UTF-8.msg | 13 +- contrib/bc/locales/ja_JP.UTF-8.msg | 32 +- contrib/bc/locales/ja_JP.eucJP.msg | 32 +- contrib/bc/locales/nl_NL.ISO8859-1.msg | 22 +- contrib/bc/locales/nl_NL.UTF-8.msg | 22 +- contrib/bc/locales/pl_PL.ISO8859-2.msg | 22 +- contrib/bc/locales/pl_PL.UTF-8.msg | 22 +- contrib/bc/locales/pt_PT.ISO8859-1.msg | 13 +- contrib/bc/locales/pt_PT.UTF-8.msg | 13 +- contrib/bc/locales/ru_RU.CP1251.msg | 22 +- contrib/bc/locales/ru_RU.CP866.msg | 22 +- contrib/bc/locales/ru_RU.ISO8859-5.msg | 22 +- contrib/bc/locales/ru_RU.KOI8-R.msg | 15 +- contrib/bc/locales/ru_RU.UTF-8.msg | 22 +- contrib/bc/locales/zh_CN.GB18030.msg | 17 +- contrib/bc/locales/zh_CN.GB2312.msg | 17 +- contrib/bc/locales/zh_CN.GBK.msg | 17 +- contrib/bc/locales/zh_CN.UTF-8.msg | 15 +- contrib/bc/locales/zh_CN.eucCN.msg | 17 +- contrib/bc/manpage.sh | 131 - contrib/bc/manuals/algorithms.md | 162 +- contrib/bc/manuals/bc.1.md.in | 1840 ------- contrib/bc/manuals/bc/A.1 | 2660 ++++++---- contrib/bc/manuals/bc/A.1.md | 725 ++- contrib/bc/manuals/bc/E.1 | 1332 +++-- contrib/bc/manuals/bc/E.1.md | 354 +- contrib/bc/manuals/bc/EH.1 | 1303 +++-- contrib/bc/manuals/bc/EH.1.md | 326 +- contrib/bc/manuals/bc/EHN.1 | 1303 +++-- contrib/bc/manuals/bc/EHN.1.md | 326 +- contrib/bc/manuals/bc/EHNP.1 | 1375 ----- contrib/bc/manuals/bc/EHNP.1.md | 1069 ---- contrib/bc/manuals/bc/EHP.1 | 1382 ----- contrib/bc/manuals/bc/EHP.1.md | 1077 ---- contrib/bc/manuals/bc/EN.1 | 1332 +++-- contrib/bc/manuals/bc/EN.1.md | 354 +- contrib/bc/manuals/bc/ENP.1 | 1393 ----- contrib/bc/manuals/bc/ENP.1.md | 1085 ---- contrib/bc/manuals/bc/EP.1 | 1400 ----- contrib/bc/manuals/bc/EP.1.md | 1093 ---- contrib/bc/manuals/bc/H.1 | 2633 ++++++---- contrib/bc/manuals/bc/H.1.md | 702 ++- contrib/bc/manuals/bc/HN.1 | 2633 ++++++---- contrib/bc/manuals/bc/HN.1.md | 702 ++- contrib/bc/manuals/bc/HNP.1 | 2223 -------- contrib/bc/manuals/bc/HNP.1.md | 1679 ------ contrib/bc/manuals/bc/HP.1 | 2230 -------- contrib/bc/manuals/bc/HP.1.md | 1687 ------ contrib/bc/manuals/bc/N.1 | 2660 ++++++---- contrib/bc/manuals/bc/N.1.md | 725 ++- contrib/bc/manuals/bc/NP.1 | 2243 -------- contrib/bc/manuals/bc/NP.1.md | 1696 ------ contrib/bc/manuals/bc/P.1 | 2250 -------- contrib/bc/manuals/bc/P.1.md | 1704 ------ contrib/bc/manuals/bcl.3 | 1780 ++++--- contrib/bc/manuals/bcl.3.md | 275 +- contrib/bc/manuals/benchmarks.md | 673 --- contrib/bc/manuals/build.md | 213 +- contrib/bc/manuals/dc.1.md.in | 1289 ----- contrib/bc/manuals/dc/A.1 | 1651 +++--- contrib/bc/manuals/dc/A.1.md | 277 +- contrib/bc/manuals/dc/E.1 | 1463 +++--- contrib/bc/manuals/dc/E.1.md | 277 +- contrib/bc/manuals/dc/EH.1 | 1432 +++--- contrib/bc/manuals/dc/EH.1.md | 253 +- contrib/bc/manuals/dc/EHN.1 | 1432 +++--- contrib/bc/manuals/dc/EHN.1.md | 251 +- contrib/bc/manuals/dc/EHNP.1 | 1307 ----- contrib/bc/manuals/dc/EHNP.1.md | 1023 ---- contrib/bc/manuals/dc/EHP.1 | 1311 ----- contrib/bc/manuals/dc/EHP.1.md | 1028 ---- contrib/bc/manuals/dc/EN.1 | 1461 +++--- contrib/bc/manuals/dc/EN.1.md | 275 +- contrib/bc/manuals/dc/ENP.1 | 1322 ----- contrib/bc/manuals/dc/ENP.1.md | 1036 ---- contrib/bc/manuals/dc/EP.1 | 1326 ----- contrib/bc/manuals/dc/EP.1.md | 1041 ---- contrib/bc/manuals/dc/H.1 | 1620 +++--- contrib/bc/manuals/dc/H.1.md | 253 +- contrib/bc/manuals/dc/HN.1 | 1620 +++--- contrib/bc/manuals/dc/HN.1.md | 251 +- contrib/bc/manuals/dc/HNP.1 | 1536 ------ contrib/bc/manuals/dc/HNP.1.md | 1190 ----- contrib/bc/manuals/dc/HP.1 | 1540 ------ contrib/bc/manuals/dc/HP.1.md | 1195 ----- contrib/bc/manuals/dc/N.1 | 1649 +++--- contrib/bc/manuals/dc/N.1.md | 275 +- contrib/bc/manuals/dc/NP.1 | 1551 ------ contrib/bc/manuals/dc/NP.1.md | 1203 ----- contrib/bc/manuals/dc/P.1 | 1555 ------ contrib/bc/manuals/dc/P.1.md | 1208 ----- contrib/bc/manuals/header.txt | 27 - contrib/bc/manuals/header_bc.txt | 1 - contrib/bc/manuals/header_bcl.txt | 1 - contrib/bc/manuals/header_dc.txt | 1 - contrib/bc/release.sh | 601 --- contrib/bc/{ => scripts}/exec-install.sh | 6 +- contrib/bc/{ => scripts}/functions.sh | 74 +- contrib/bc/{ => scripts}/karatsuba.py | 29 +- contrib/bc/{ => scripts}/link.sh | 5 +- contrib/bc/{ => scripts}/locale_install.sh | 53 +- contrib/bc/{ => scripts}/locale_uninstall.sh | 1 + contrib/bc/{ => scripts}/safe-install.sh | 0 contrib/bc/src/args.c | 132 +- contrib/bc/src/bc.c | 11 +- contrib/bc/src/bc_lex.c | 84 +- contrib/bc/src/bc_parse.c | 917 +++- contrib/bc/src/data.c | 455 +- contrib/bc/src/dc.c | 11 +- contrib/bc/src/dc_lex.c | 104 +- contrib/bc/src/dc_parse.c | 93 +- contrib/bc/src/file.c | 63 +- contrib/bc/src/history.c | 676 ++- contrib/bc/src/lang.c | 131 +- contrib/bc/src/lex.c | 123 +- contrib/bc/src/library.c | 180 +- contrib/bc/src/main.c | 13 +- contrib/bc/src/num.c | 1593 ++++-- contrib/bc/src/opt.c | 129 +- contrib/bc/src/parse.c | 83 +- contrib/bc/src/program.c | 1967 +++++-- contrib/bc/src/rand.c | 185 +- contrib/bc/src/read.c | 99 +- contrib/bc/src/vector.c | 302 +- contrib/bc/src/vm.c | 702 ++- contrib/bc/tests/afl.py | 188 - contrib/bc/tests/all.sh | 124 +- contrib/bc/tests/bc/all.txt | 10 +- contrib/bc/tests/bc/bitfuncs.txt | 5400 ++++++++++++++++++++ contrib/bc/tests/bc/bitfuncs_results.txt | 5400 ++++++++++++++++++++ contrib/bc/tests/bc/decimal.txt | 4 + contrib/bc/tests/bc/decimal_results.txt | 9 +- contrib/bc/tests/bc/divmod.txt | 64 + contrib/bc/tests/bc/divmod_results.txt | 126 + contrib/bc/tests/bc/errors.txt | 48 +- contrib/bc/tests/bc/errors/25.txt | 4 + contrib/bc/tests/bc/errors/26.txt | Bin 0 -> 317 bytes contrib/bc/tests/bc/errors/27.txt | 1 + contrib/bc/tests/bc/errors/28.txt | 2 + contrib/bc/tests/bc/errors/29.txt | 20 + contrib/bc/tests/bc/errors/30.txt | 3 + contrib/bc/tests/bc/errors/31.txt | 3 + contrib/bc/tests/bc/errors/32.txt | Bin 0 -> 1701 bytes contrib/bc/tests/bc/leadingzero.txt | 12 + contrib/bc/tests/bc/leadingzero_results.txt | 12 + contrib/bc/tests/bc/lib2.txt | 7 + contrib/bc/tests/bc/lib2_results.txt | 7 + contrib/bc/tests/bc/modexp.txt | 103 + contrib/bc/tests/bc/modexp_results.txt | 103 + contrib/bc/tests/bc/pi_results.txt | 3 +- contrib/bc/tests/bc/posix_errors.txt | 1 + contrib/bc/tests/bc/power.txt | 43 + contrib/bc/tests/bc/power_results.txt | 72 + contrib/bc/tests/bc/recursive_arrays.txt | 353 ++ contrib/bc/tests/bc/recursive_arrays_results.txt | 1 + contrib/bc/tests/bc/scripts/add.bc | 2 +- contrib/bc/tests/bc/scripts/all.txt | 11 +- contrib/bc/tests/bc/scripts/array.bc | 0 contrib/bc/tests/bc/scripts/atan.bc | 0 contrib/bc/tests/bc/scripts/bessel.bc | 0 contrib/bc/tests/bc/scripts/divide.bc | 1 + contrib/bc/tests/bc/scripts/globals.bc | 4 + contrib/bc/tests/bc/scripts/ifs.bc | 49 + contrib/bc/tests/bc/scripts/ifs.txt | 18 + contrib/bc/tests/bc/scripts/ifs2.bc | 33 + contrib/bc/tests/bc/scripts/ifs2.txt | 34 + contrib/bc/tests/bc/scripts/multiply.bc | 1 + contrib/bc/tests/bc/scripts/parse.bc | 0 contrib/bc/tests/bc/scripts/print.bc | 0 contrib/bc/tests/bc/scripts/references.bc | 0 contrib/bc/tests/bc/scripts/screen.bc | 0 contrib/bc/tests/bc/scripts/strings2.bc | 7 + contrib/bc/tests/bc/scripts/subtract.bc | 2 +- contrib/bc/tests/bc/stdin2.txt | 3 + contrib/bc/tests/bc/stdin2_results.txt | 21 + contrib/bc/tests/bc/strings.txt | 61 + contrib/bc/tests/bc/strings_results.txt | 45 + contrib/bc/tests/bc/timeconst.sh | 24 +- contrib/bc/tests/bc/vars_results.txt | 3 +- contrib/bc/tests/bcl.c | 154 +- contrib/bc/tests/dc/all.txt | 2 + contrib/bc/tests/dc/decimal.txt | 5 + contrib/bc/tests/dc/decimal_results.txt | 11 +- contrib/bc/tests/dc/errors.txt | 7 + .../{fuzzing/dc_inputs/17.txt => dc/errors/32.txt} | 2 +- contrib/bc/tests/dc/errors/33.txt | Bin 0 -> 323 bytes .../{fuzzing/dc_inputs/26.txt => dc/errors/34.txt} | 104 +- contrib/bc/tests/dc/exec_stack_len.txt | 6 + contrib/bc/tests/dc/exec_stack_len_results.txt | 8 + contrib/bc/tests/dc/length.txt | 2 + contrib/bc/tests/dc/length_results.txt | 2 + contrib/bc/tests/dc/scientific.txt | 4 + contrib/bc/tests/dc/scientific_results.txt | 4 + contrib/bc/tests/dc/scripts/array.dc | 0 contrib/bc/tests/dc/scripts/asciify.dc | 0 contrib/bc/tests/dc/scripts/easter.sh | 4 +- contrib/bc/tests/dc/scripts/else.dc | 0 contrib/bc/tests/dc/scripts/factorial.dc | 0 contrib/bc/tests/dc/scripts/loop.dc | 0 contrib/bc/tests/dc/scripts/prime.dc | 0 contrib/bc/tests/dc/scripts/quit.dc | 0 contrib/bc/tests/dc/scripts/stream.dc | 2 +- contrib/bc/tests/dc/scripts/stream.txt | Bin 0 -> 130834 bytes contrib/bc/tests/dc/scripts/weird.dc | 0 contrib/bc/tests/dc/stack_len.txt | 15 + contrib/bc/tests/dc/stack_len_results.txt | 10 + contrib/bc/tests/dc/strings.txt | 1 + contrib/bc/tests/dc/strings_results.txt | 1 + contrib/bc/tests/{diff.sh => error.sh} | 74 +- contrib/bc/tests/errors.sh | 55 +- contrib/bc/tests/extra_required.txt | 2 + contrib/bc/tests/fuzzing/bc_inputs1/abs.txt | 7 - contrib/bc/tests/fuzzing/bc_inputs1/add.txt | 146 - contrib/bc/tests/fuzzing/bc_inputs1/arctangent.txt | 26 - contrib/bc/tests/fuzzing/bc_inputs1/array.bc | 60 - contrib/bc/tests/fuzzing/bc_inputs1/arrays.txt | 10 - .../bc/tests/fuzzing/bc_inputs1/assignments.txt | 122 - contrib/bc/tests/fuzzing/bc_inputs1/basic.txt | 7 - contrib/bc/tests/fuzzing/bc_inputs1/boolean.txt | 184 - contrib/bc/tests/fuzzing/bc_inputs1/cosine.txt | 44 - contrib/bc/tests/fuzzing/bc_inputs1/decimal.txt | 35 - contrib/bc/tests/fuzzing/bc_inputs1/divide.txt | 31 - .../bc/tests/fuzzing/bc_inputs1/engineering.txt | 19 - contrib/bc/tests/fuzzing/bc_inputs1/exponent.txt | 22 - contrib/bc/tests/fuzzing/bc_inputs1/functions.bc | 7 - contrib/bc/tests/fuzzing/bc_inputs1/functions.txt | 13 - contrib/bc/tests/fuzzing/bc_inputs1/globals.txt | 21 - contrib/bc/tests/fuzzing/bc_inputs1/len.bc | 48 - contrib/bc/tests/fuzzing/bc_inputs1/length.txt | 59 - contrib/bc/tests/fuzzing/bc_inputs1/lib10.txt | 4 - contrib/bc/tests/fuzzing/bc_inputs1/lib11.txt | 4 - contrib/bc/tests/fuzzing/bc_inputs1/lib12.txt | 1 - contrib/bc/tests/fuzzing/bc_inputs1/lib2.txt | 15 - contrib/bc/tests/fuzzing/bc_inputs1/lib3.txt | 6 - contrib/bc/tests/fuzzing/bc_inputs1/lib4.txt | 10 - contrib/bc/tests/fuzzing/bc_inputs1/lib5.txt | 2 - contrib/bc/tests/fuzzing/bc_inputs1/lib6.txt | 5 - contrib/bc/tests/fuzzing/bc_inputs1/lib7.txt | 12 - contrib/bc/tests/fuzzing/bc_inputs1/lib8.txt | 3 - contrib/bc/tests/fuzzing/bc_inputs2/lib13.txt | 1 - contrib/bc/tests/fuzzing/bc_inputs2/lib14.txt | 1 - contrib/bc/tests/fuzzing/bc_inputs2/lib15.txt | 1 - contrib/bc/tests/fuzzing/bc_inputs2/lib16.txt | 1 - contrib/bc/tests/fuzzing/bc_inputs2/lib19.txt | 1 - contrib/bc/tests/fuzzing/bc_inputs2/lib20.txt | 1 - contrib/bc/tests/fuzzing/bc_inputs2/lib21.txt | 1 - contrib/bc/tests/fuzzing/bc_inputs2/lib22.txt | 1 - contrib/bc/tests/fuzzing/bc_inputs2/lib23.txt | 1 - contrib/bc/tests/fuzzing/bc_inputs2/lib24.txt | 1 - contrib/bc/tests/fuzzing/bc_inputs2/log.txt | 22 - contrib/bc/tests/fuzzing/bc_inputs2/misc.txt | 13 - contrib/bc/tests/fuzzing/bc_inputs2/misc1.txt | 76 - contrib/bc/tests/fuzzing/bc_inputs2/misc2.txt | 110 - contrib/bc/tests/fuzzing/bc_inputs2/misc3.txt | 12 - contrib/bc/tests/fuzzing/bc_inputs2/modulus.txt | 69 - contrib/bc/tests/fuzzing/bc_inputs2/multiply.txt | 40 - contrib/bc/tests/fuzzing/bc_inputs2/pi.txt | 4 - contrib/bc/tests/fuzzing/bc_inputs2/places.txt | 19 - contrib/bc/tests/fuzzing/bc_inputs2/power.txt | 44 - contrib/bc/tests/fuzzing/bc_inputs2/print2.txt | 194 - contrib/bc/tests/fuzzing/bc_inputs2/references.bc | 408 -- contrib/bc/tests/fuzzing/bc_inputs2/scale.txt | 57 - contrib/bc/tests/fuzzing/bc_inputs2/scientific.txt | 51 - contrib/bc/tests/fuzzing/bc_inputs2/shift.txt | 281 - contrib/bc/tests/fuzzing/bc_inputs2/sine.txt | 207 - contrib/bc/tests/fuzzing/bc_inputs3/01.txt | 339 -- contrib/bc/tests/fuzzing/bc_inputs3/02.txt | 1 - contrib/bc/tests/fuzzing/bc_inputs3/03.txt | 2 - contrib/bc/tests/fuzzing/bc_inputs3/04.txt | 1 - contrib/bc/tests/fuzzing/bc_inputs3/05.txt | 1 - contrib/bc/tests/fuzzing/bc_inputs3/06.txt | 1 - contrib/bc/tests/fuzzing/bc_inputs3/07.txt | 8 - contrib/bc/tests/fuzzing/bc_inputs3/08.txt | 3 - contrib/bc/tests/fuzzing/bc_inputs3/09.txt | 11 - contrib/bc/tests/fuzzing/bc_inputs3/10.txt | 1 - contrib/bc/tests/fuzzing/bc_inputs3/11.txt | 99 - contrib/bc/tests/fuzzing/bc_inputs3/12.txt | 2 - contrib/bc/tests/fuzzing/bc_inputs3/13.txt | 56 - contrib/bc/tests/fuzzing/bc_inputs3/14.txt | 1 - contrib/bc/tests/fuzzing/bc_inputs3/15.txt | 3 - contrib/bc/tests/fuzzing/bc_inputs3/16.txt | 1 - contrib/bc/tests/fuzzing/bc_inputs3/17.txt | 11 - contrib/bc/tests/fuzzing/bc_inputs3/18.txt | 3 - contrib/bc/tests/fuzzing/bc_inputs3/19.txt | 5 - contrib/bc/tests/fuzzing/bc_inputs3/20.txt | 51 - contrib/bc/tests/fuzzing/bc_inputs3/21.txt | 10 - contrib/bc/tests/fuzzing/bc_inputs3/22.txt | 2 - contrib/bc/tests/fuzzing/bc_inputs3/23.txt | Bin 1024 -> 0 bytes contrib/bc/tests/fuzzing/bc_inputs3/24.txt | 4 - contrib/bc/tests/fuzzing/bc_inputs3/sqrt.txt | 14 - contrib/bc/tests/fuzzing/bc_inputs3/strings.txt | 12 - contrib/bc/tests/fuzzing/bc_inputs3/subtract.txt | 153 - contrib/bc/tests/fuzzing/bc_inputs3/trunc.txt | 15 - contrib/bc/tests/fuzzing/bc_inputs3/void.txt | 20 - contrib/bc/tests/fuzzing/dc_inputs/01.txt | 2 - contrib/bc/tests/fuzzing/dc_inputs/02.txt | 5 - contrib/bc/tests/fuzzing/dc_inputs/03.txt | 2 - contrib/bc/tests/fuzzing/dc_inputs/04.txt | 9 - contrib/bc/tests/fuzzing/dc_inputs/05.txt | 3 - contrib/bc/tests/fuzzing/dc_inputs/06.txt | 1 - contrib/bc/tests/fuzzing/dc_inputs/07.txt | 3 - contrib/bc/tests/fuzzing/dc_inputs/08.txt | 1 - contrib/bc/tests/fuzzing/dc_inputs/09.txt | 9 - contrib/bc/tests/fuzzing/dc_inputs/10.txt | 11 - contrib/bc/tests/fuzzing/dc_inputs/11.txt | 4 - contrib/bc/tests/fuzzing/dc_inputs/12.txt | 2 - contrib/bc/tests/fuzzing/dc_inputs/13.txt | 7 - contrib/bc/tests/fuzzing/dc_inputs/14.txt | 7 - contrib/bc/tests/fuzzing/dc_inputs/15.txt | 11 - contrib/bc/tests/fuzzing/dc_inputs/16.txt | 1 - contrib/bc/tests/fuzzing/dc_inputs/18.txt | 3 - contrib/bc/tests/fuzzing/dc_inputs/19.txt | 1 - contrib/bc/tests/fuzzing/dc_inputs/20.txt | 3 - contrib/bc/tests/fuzzing/dc_inputs/21.txt | 5 - contrib/bc/tests/fuzzing/dc_inputs/22.txt | 36 - contrib/bc/tests/fuzzing/dc_inputs/23.txt | 2 - contrib/bc/tests/fuzzing/dc_inputs/24.txt | 1 - contrib/bc/tests/fuzzing/dc_inputs/25.txt | 6 - contrib/bc/tests/fuzzing/dc_inputs/27.txt | 2 - contrib/bc/tests/fuzzing/dc_inputs/28.txt | 1 - contrib/bc/tests/fuzzing/dc_inputs/29.txt | 13 - contrib/bc/tests/fuzzing/dc_inputs/30.txt | 1 - contrib/bc/tests/fuzzing/dc_inputs/31.txt | 1 - contrib/bc/tests/fuzzing/dc_inputs/abs.txt | 7 - contrib/bc/tests/fuzzing/dc_inputs/add.txt | 33 - contrib/bc/tests/fuzzing/dc_inputs/array.dc | 2 - contrib/bc/tests/fuzzing/dc_inputs/boolean.txt | 80 - contrib/bc/tests/fuzzing/dc_inputs/decimal.txt | 36 - contrib/bc/tests/fuzzing/dc_inputs/divide.txt | 33 - contrib/bc/tests/fuzzing/dc_inputs/divmod.txt | 64 - contrib/bc/tests/fuzzing/dc_inputs/else.dc | 4 - contrib/bc/tests/fuzzing/dc_inputs/engineering.txt | 19 - contrib/bc/tests/fuzzing/dc_inputs/loop.dc | 3 - contrib/bc/tests/fuzzing/dc_inputs/misc.txt | 1 - contrib/bc/tests/fuzzing/dc_inputs/modexp.txt | 103 - contrib/bc/tests/fuzzing/dc_inputs/modulus.txt | 70 - contrib/bc/tests/fuzzing/dc_inputs/multiply.txt | 42 - contrib/bc/tests/fuzzing/dc_inputs/places.txt | 14 - contrib/bc/tests/fuzzing/dc_inputs/power.txt | 36 - contrib/bc/tests/fuzzing/dc_inputs/quit.dc | 2 - contrib/bc/tests/fuzzing/dc_inputs/scientific.txt | 51 - contrib/bc/tests/fuzzing/dc_inputs/shift.txt | 42 - contrib/bc/tests/fuzzing/dc_inputs/sqrt.txt | 14 - contrib/bc/tests/fuzzing/dc_inputs/stdin.txt | 205 - contrib/bc/tests/fuzzing/dc_inputs/stream.dc | 2 - contrib/bc/tests/fuzzing/dc_inputs/strings.txt | 50 - contrib/bc/tests/fuzzing/dc_inputs/subtract.txt | 33 - contrib/bc/tests/fuzzing/dc_inputs/trunc.txt | 11 - contrib/bc/tests/fuzzing/dc_inputs/vars.txt | 2 - contrib/bc/tests/fuzzing/dc_inputs/weird.dc | 2 - contrib/bc/tests/history.py | 1153 +++++ contrib/bc/tests/{fuzzing/bc.dict => history.sh} | 122 +- contrib/bc/tests/other.sh | 145 +- contrib/bc/tests/radamsa.sh | 120 - contrib/bc/tests/radamsa.txt | 17 - contrib/bc/tests/randmath.py | 306 -- contrib/bc/tests/read.sh | 25 +- contrib/bc/tests/script.sed | 9 + contrib/bc/tests/script.sh | 22 +- contrib/bc/tests/scripts.sh | 53 +- contrib/bc/tests/stdin.sh | 23 +- contrib/bc/tests/test.sh | 17 +- contrib/bc/{ => vs}/bc.sln | 22 +- contrib/bc/vs/bc.vcxproj | 297 ++ contrib/bc/vs/bc.vcxproj.filters | 173 + contrib/bc/vs/bcl.sln | 37 + contrib/bc/vs/bcl.vcxproj | 259 + contrib/bc/vs/bcl.vcxproj.filters | 90 + contrib/bc/vs/tests/tests_bc.bat | 104 + contrib/bc/vs/tests/tests_dc.bat | 61 + usr.bin/gh-bc/Makefile | 20 +- usr.bin/gh-bc/tests/Makefile | 4 +- 417 files changed, 50537 insertions(+), 75025 deletions(-) diff --git a/contrib/bc/.gitattributes b/contrib/bc/.gitattributes index 22d6e60bce68..1e2c56dde215 100644 --- a/contrib/bc/.gitattributes +++ b/contrib/bc/.gitattributes @@ -1,3 +1,3 @@ *.vcxproj eol=crlf *.vcxproj.filters eol=crlf -*.sln eol= crlf +*.sln eol=crlf diff --git a/contrib/bc/.gitignore b/contrib/bc/.gitignore index b131d5813764..31e43aa61efc 100644 --- a/contrib/bc/.gitignore +++ b/contrib/bc/.gitignore @@ -51,11 +51,17 @@ print_results.txt bessel.txt bessel_results.txt prime.txt -stream.txt +strings2.txt +strings2_results.txt tests/bc/scripts/add.txt tests/bc/scripts/divide.txt tests/bc/scripts/multiply.txt tests/bc/scripts/subtract.txt +tests/bc/scripts/strings2.txt +benchmarks/bc/*.txt +benchmarks/dc/*.txt +scripts/ministat +scripts/bitgen perf.data perf.data.old *.gcda diff --git a/contrib/bc/LICENSE.md b/contrib/bc/LICENSE.md index 269e131cc81d..8ab2e6069881 100644 --- a/contrib/bc/LICENSE.md +++ b/contrib/bc/LICENSE.md @@ -79,9 +79,9 @@ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -## `safe-install.sh` +## `scripts/safe-install.sh` -The file `safe-install.sh` is under the following copyright and license: +The file `scripts/safe-install.sh` is under the following copyright and license: Copyright (c) 2021 Rich Felker @@ -101,3 +101,13 @@ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +## `scripts/ministat.c` + +The file `scripts/ministat.c` is under the following license: + +"THE BEER-WARE LICENSE" (Revision 42): + + wrote this file. As long as you retain this notice you +can do whatever you want with this stuff. If we meet some day, and you think +this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp diff --git a/contrib/bc/Makefile.in b/contrib/bc/Makefile.in index 2b50476a79fe..3d6780d6ac95 100644 --- a/contrib/bc/Makefile.in +++ b/contrib/bc/Makefile.in @@ -134,39 +134,64 @@ BC_ENABLE_HISTORY = %%HISTORY%% BC_ENABLE_EXTRA_MATH_NAME = BC_ENABLE_EXTRA_MATH BC_ENABLE_EXTRA_MATH = %%EXTRA_MATH%% BC_ENABLE_NLS = %%NLS%% -BC_ENABLE_PROMPT = %%PROMPT%% BC_LONG_BIT = %%LONG_BIT%% BC_ENABLE_AFL = %%FUZZ%% BC_ENABLE_MEMCHECK = %%MEMCHECK%% +BC_DEFAULT_BANNER = %%BC_DEFAULT_BANNER%% +BC_DEFAULT_SIGINT_RESET = %%BC_DEFAULT_SIGINT_RESET%% +DC_DEFAULT_SIGINT_RESET = %%DC_DEFAULT_SIGINT_RESET%% +BC_DEFAULT_TTY_MODE = %%BC_DEFAULT_TTY_MODE%% +DC_DEFAULT_TTY_MODE = %%DC_DEFAULT_TTY_MODE%% +BC_DEFAULT_PROMPT = %%BC_DEFAULT_PROMPT%% +DC_DEFAULT_PROMPT = %%DC_DEFAULT_PROMPT%% + RM = rm MKDIR = mkdir -INSTALL = ./exec-install.sh -SAFE_INSTALL = ./safe-install.sh -LINK = ./link.sh -MANPAGE = ./manpage.sh -KARATSUBA = ./karatsuba.py -LOCALE_INSTALL = ./locale_install.sh -LOCALE_UNINSTALL = ./locale_uninstall.sh +SCRIPTS = ./scripts + +MINISTAT = ministat +MINISTAT_EXEC = $(SCRIPTS)/$(MINISTAT) + +BITFUNCGEN = bitfuncgen +BITFUNCGEN_EXEC = $(SCRIPTS)/$(BITFUNCGEN) + +INSTALL = $(SCRIPTS)/exec-install.sh +SAFE_INSTALL = $(SCRIPTS)/safe-install.sh +LINK = $(SCRIPTS)/link.sh +MANPAGE = $(SCRIPTS)/manpage.sh +KARATSUBA = $(SCRIPTS)/karatsuba.py +LOCALE_INSTALL = $(SCRIPTS)/locale_install.sh +LOCALE_UNINSTALL = $(SCRIPTS)/locale_uninstall.sh VALGRIND_ARGS = --error-exitcode=100 --leak-check=full --show-leak-kinds=all --errors-for-leak-kinds=all -TEST_STARS = "***********************************************************************" +TEST_STARS = *********************************************************************** BC_NUM_KARATSUBA_LEN = %%KARATSUBA_LEN%% +BC_DEFS0 = -DBC_DEFAULT_BANNER=$(BC_DEFAULT_BANNER) +BC_DEFS1 = -DBC_DEFAULT_SIGINT_RESET=$(BC_DEFAULT_SIGINT_RESET) +BC_DEFS2 = -DBC_DEFAULT_TTY_MODE=$(BC_DEFAULT_TTY_MODE) +BC_DEFS3 = -DBC_DEFAULT_PROMPT=$(BC_DEFAULT_PROMPT) +BC_DEFS = $(BC_DEFS0) $(BC_DEFS1) $(BC_DEFS2) $(BC_DEFS3) +DC_DEFS1 = -DDC_DEFAULT_SIGINT_RESET=$(DC_DEFAULT_SIGINT_RESET) +DC_DEFS2 = -DDC_DEFAULT_TTY_MODE=$(DC_DEFAULT_TTY_MODE) +DC_DEFS3 = -DDC_DEFAULT_PROMPT=$(DC_DEFAULT_PROMPT) +DC_DEFS = $(DC_DEFS1) $(DC_DEFS2) $(DC_DEFS3) + CPPFLAGS1 = -D$(BC_ENABLED_NAME)=$(BC_ENABLED) -D$(DC_ENABLED_NAME)=$(DC_ENABLED) CPPFLAGS2 = $(CPPFLAGS1) -I./include/ -DBUILD_TYPE=$(BC_BUILD_TYPE) %%LONG_BIT_DEFINE%% CPPFLAGS3 = $(CPPFLAGS2) -DEXECPREFIX=$(EXEC_PREFIX) -DMAINEXEC=$(MAIN_EXEC) -CPPFLAGS4 = $(CPPFLAGS3) -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700 +CPPFLAGS4 = $(CPPFLAGS3) -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700 %%BSD%% CPPFLAGS5 = $(CPPFLAGS4) -DBC_NUM_KARATSUBA_LEN=$(BC_NUM_KARATSUBA_LEN) -CPPFLAGS6 = $(CPPFLAGS5) -DBC_ENABLE_NLS=$(BC_ENABLE_NLS) -DBC_ENABLE_PROMPT=$(BC_ENABLE_PROMPT) +CPPFLAGS6 = $(CPPFLAGS5) -DBC_ENABLE_NLS=$(BC_ENABLE_NLS) CPPFLAGS7 = $(CPPFLAGS6) -D$(BC_ENABLE_EXTRA_MATH_NAME)=$(BC_ENABLE_EXTRA_MATH) CPPFLAGS8 = $(CPPFLAGS7) -DBC_ENABLE_HISTORY=$(BC_ENABLE_HISTORY) -DBC_ENABLE_LIBRARY=$(BC_ENABLE_LIBRARY) CPPFLAGS = $(CPPFLAGS8) -DBC_ENABLE_MEMCHECK=$(BC_ENABLE_MEMCHECK) -DBC_ENABLE_AFL=$(BC_ENABLE_AFL) -CFLAGS = $(CPPFLAGS) %%CPPFLAGS%% %%CFLAGS%% +CFLAGS = $(CPPFLAGS) $(BC_DEFS) $(DC_DEFS) %%CPPFLAGS%% %%CFLAGS%% LDFLAGS = %%LDFLAGS%% HOSTCFLAGS = %%HOSTCFLAGS%% @@ -219,6 +244,12 @@ $(BIN): headers: %%HEADERS%% +$(MINISTAT): + $(HOSTCC) $(HOSTCFLAGS) -lm -o $(MINISTAT_EXEC) scripts/ministat.c + +$(BITFUNCGEN): + $(HOSTCC) $(HOSTCFLAGS) -lm -o $(BITFUNCGEN_EXEC) scripts/bitfuncgen.c + help: @printf 'available targets:\n' @printf '\n' @@ -249,16 +280,33 @@ help: @printf ' valgrind_dc runs the dc test suite, if dc has been built,\n' @printf ' through valgrind\n' -run_all_tests: +run_all_tests: bc_all_tests timeconst_all_tests dc_all_tests + +run_all_tests_np: bc_all_tests_np timeconst_all_tests dc_all_tests_np + +bc_all_tests: %%BC_ALL_TESTS%% + +bc_all_tests_np: + %%BC_ALL_TESTS_NP%% + +timeconst_all_tests: %%TIMECONST_ALL_TESTS%% + +dc_all_tests: %%DC_ALL_TESTS%% +dc_all_tests_np: + %%DC_ALL_TESTS_NP%% + +history_all_tests: + %%HISTORY_TESTS%% + check: test test: %%TESTS%% -test_bc: test_bc_header test_bc_tests test_bc_scripts test_bc_stdin test_bc_read test_bc_errors test_bc_other +test_bc: test_bc_header test_bc_tests test_bc_scripts test_bc_errors test_bc_stdin test_bc_read test_bc_other @printf '\nAll bc tests passed.\n\n$(TEST_STARS)\n' test_bc_tests:%%BC_TESTS%% @@ -271,16 +319,18 @@ test_bc_stdin: test_bc_read: @sh tests/read.sh bc %%BC_TEST_EXEC%% -test_bc_errors: +test_bc_errors: test_bc_error_lines%%BC_ERROR_TESTS%% + +test_bc_error_lines: @sh tests/errors.sh bc %%BC_TEST_EXEC%% test_bc_other: - @sh tests/other.sh bc %%BC_TEST_EXEC%% + @sh tests/other.sh bc $(BC_ENABLE_EXTRA_MATH) %%BC_TEST_EXEC%% test_bc_header: @printf '$(TEST_STARS)\n\nRunning bc tests...\n\n' -test_dc: test_dc_header test_dc_tests test_dc_scripts test_dc_stdin test_dc_read test_dc_errors test_dc_other +test_dc: test_dc_header test_dc_tests test_dc_scripts test_dc_errors test_dc_stdin test_dc_read test_dc_other @printf '\nAll dc tests passed.\n\n$(TEST_STARS)\n' test_dc_tests:%%DC_TESTS%% @@ -293,11 +343,13 @@ test_dc_stdin: test_dc_read: @sh tests/read.sh dc %%DC_TEST_EXEC%% -test_dc_errors: +test_dc_errors: test_dc_error_lines%%DC_ERROR_TESTS%% + +test_dc_error_lines: @sh tests/errors.sh dc %%DC_TEST_EXEC%% test_dc_other: - @sh tests/other.sh dc %%DC_TEST_EXEC%% + @sh tests/other.sh dc $(BC_ENABLE_EXTRA_MATH) %%DC_TEST_EXEC%% test_dc_header: @printf '$(TEST_STARS)\n\nRunning dc tests...\n\n' @@ -305,6 +357,122 @@ test_dc_header: timeconst: %%TIMECONST%% +test_history: test_history_header test_bc_history test_dc_history + @printf '\nAll history tests passed.\n\n$(TEST_STARS)\n' + +test_bc_history:%%BC_HISTORY_TEST_PREREQS%% + +test_bc_history_all: test_bc_history0 test_bc_history1 test_bc_history2 test_bc_history3 test_bc_history4 test_bc_history5 test_bc_history6 test_bc_history7 test_bc_history8 test_bc_history9 test_bc_history10 test_bc_history11 test_bc_history12 test_bc_history13 test_bc_history14 test_bc_history15 test_bc_history16 test_bc_history17 test_bc_history18 test_bc_history19 test_bc_history20 test_bc_history21 + +test_bc_history_skip: + @printf 'No bc history tests to run\n' + +test_bc_history0: + @sh tests/history.sh bc 0 %%BC_TEST_EXEC%% + +test_bc_history1: + @sh tests/history.sh bc 1 %%BC_TEST_EXEC%% + +test_bc_history2: + @sh tests/history.sh bc 2 %%BC_TEST_EXEC%% + +test_bc_history3: + @sh tests/history.sh bc 3 %%BC_TEST_EXEC%% + +test_bc_history4: + @sh tests/history.sh bc 4 %%BC_TEST_EXEC%% + +test_bc_history5: + @sh tests/history.sh bc 5 %%BC_TEST_EXEC%% + +test_bc_history6: + @sh tests/history.sh bc 6 %%BC_TEST_EXEC%% + +test_bc_history7: + @sh tests/history.sh bc 7 %%BC_TEST_EXEC%% + +test_bc_history8: + @sh tests/history.sh bc 8 %%BC_TEST_EXEC%% + +test_bc_history9: + @sh tests/history.sh bc 9 %%BC_TEST_EXEC%% + +test_bc_history10: + @sh tests/history.sh bc 10 %%BC_TEST_EXEC%% + +test_bc_history11: + @sh tests/history.sh bc 11 %%BC_TEST_EXEC%% + +test_bc_history12: + @sh tests/history.sh bc 12 %%BC_TEST_EXEC%% + +test_bc_history13: + @sh tests/history.sh bc 13 %%BC_TEST_EXEC%% + +test_bc_history14: + @sh tests/history.sh bc 14 %%BC_TEST_EXEC%% + +test_bc_history15: + @sh tests/history.sh bc 15 %%BC_TEST_EXEC%% + +test_bc_history16: + @sh tests/history.sh bc 16 %%BC_TEST_EXEC%% + +test_bc_history17: + @sh tests/history.sh bc 17 %%BC_TEST_EXEC%% + +test_bc_history18: + @sh tests/history.sh bc 18 %%BC_TEST_EXEC%% + +test_bc_history19: + @sh tests/history.sh bc 19 %%BC_TEST_EXEC%% + +test_bc_history20: + @sh tests/history.sh bc 20 %%BC_TEST_EXEC%% + +test_bc_history21: + @sh tests/history.sh bc 21 %%BC_TEST_EXEC%% + +test_dc_history:%%DC_HISTORY_TEST_PREREQS%% + +test_dc_history_all: test_dc_history0 test_dc_history1 test_dc_history2 test_dc_history3 test_dc_history4 test_dc_history5 test_dc_history6 test_dc_history7 test_dc_history8 test_dc_history9 + +test_dc_history_skip: + @printf 'No dc history tests to run\n' + +test_dc_history0: + @sh tests/history.sh dc 0 %%DC_TEST_EXEC%% + +test_dc_history1: + @sh tests/history.sh dc 1 %%DC_TEST_EXEC%% + +test_dc_history2: + @sh tests/history.sh dc 2 %%DC_TEST_EXEC%% + +test_dc_history3: + @sh tests/history.sh dc 3 %%DC_TEST_EXEC%% + +test_dc_history4: + @sh tests/history.sh dc 4 %%DC_TEST_EXEC%% + +test_dc_history5: + @sh tests/history.sh dc 5 %%DC_TEST_EXEC%% + +test_dc_history6: + @sh tests/history.sh dc 6 %%DC_TEST_EXEC%% + +test_dc_history7: + @sh tests/history.sh dc 7 %%DC_TEST_EXEC%% + +test_dc_history8: + @sh tests/history.sh dc 8 %%DC_TEST_EXEC%% + +test_dc_history9: + @sh tests/history.sh dc 9 %%DC_TEST_EXEC%% + +test_history_header: + @printf '$(TEST_STARS)\n\nRunning history tests...\n\n' + library_test: $(LIBBC) $(CC) $(CFLAGS) $(BCL_TEST_C) $(LIBBC) -o $(BCL_TEST) @@ -322,12 +490,6 @@ coverage_output: coverage:%%COVERAGE_PREREQS%% -libcname: - @printf '%s' "$(BC_LIB_C)" - -extra_math: - @printf '%s' "$(BC_ENABLE_EXTRA_MATH)" - manpages: $(MANPAGE) bc $(MANPAGE) dc @@ -348,15 +510,19 @@ clean:%%CLEAN_PREREQS%% @$(RM) -f $(BC_LIB2_C) $(BC_LIB2_O) @$(RM) -f $(BC_HELP_C) $(BC_HELP_O) @$(RM) -f $(DC_HELP_C) $(DC_HELP_O) - @$(RM) -fr $(BC_TEST_OUTPUTS) $(DC_TEST_OUTPUTS) - @$(RM) -fr $(BC_FUZZ_OUTPUTS) $(DC_FUZZ_OUTPUTS) @$(RM) -fr Debug/ Release/ -clean_config: clean +clean_benchmarks: + @printf 'Cleaning benchmarks...\n' + @$(RM) -f $(MINISTAT_EXEC) + @$(RM) -f benchmarks/bc/*.txt + @$(RM) -f benchmarks/dc/*.txt + +clean_config: clean clean_benchmarks @printf 'Cleaning config...\n' @$(RM) -f Makefile - @$(RM) -f $(BC_MD) $(DC_MD) - @$(RM) -f $(BC_MANPAGE) $(DC_MANPAGE) + @$(RM) -f $(BC_MD) $(BC_MANPAGE) + @$(RM) -f $(DC_MD) $(DC_MANPAGE) clean_coverage: @printf 'Cleaning coverage files...\n' @@ -376,9 +542,12 @@ clean_coverage: clean_tests: clean clean_config clean_coverage @printf 'Cleaning test files...\n' + @$(RM) -fr $(BC_TEST_OUTPUTS) $(DC_TEST_OUTPUTS) + @$(RM) -fr $(BC_FUZZ_OUTPUTS) $(DC_FUZZ_OUTPUTS) @$(RM) -f tests/bc/parse.txt tests/bc/parse_results.txt @$(RM) -f tests/bc/print.txt tests/bc/print_results.txt @$(RM) -f tests/bc/bessel.txt tests/bc/bessel_results.txt + @$(RM) -f tests/bc/strings2.txt tests/bc/strings2_results.txt @$(RM) -f tests/bc/scripts/bessel.txt @$(RM) -f tests/bc/scripts/parse.txt @$(RM) -f tests/bc/scripts/print.txt @@ -386,13 +555,15 @@ clean_tests: clean clean_config clean_coverage @$(RM) -f tests/bc/scripts/divide.txt @$(RM) -f tests/bc/scripts/multiply.txt @$(RM) -f tests/bc/scripts/subtract.txt - @$(RM) -f tests/dc/scripts/prime.txt tests/dc/scripts/stream.txt + @$(RM) -f tests/bc/scripts/strings2.txt + @$(RM) -f tests/dc/scripts/prime.txt @$(RM) -f .log_*.txt @$(RM) -f .math.txt .results.txt .ops.txt @$(RM) -f .test.txt @$(RM) -f tags .gdbbreakpoints .gdb_history .gdbsetup @$(RM) -f cscope.* @$(RM) -f bc.old + @$(RM) -f $(BITFUNCGEN_EXEC) *** 152118 LINES SKIPPED *** From nobody Tue Oct 12 14:48:58 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 7718A18030B6; Tue, 12 Oct 2021 14:48: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 4HTJT71X1Lz3H0S; Tue, 12 Oct 2021 14:48: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 1085E163B3; Tue, 12 Oct 2021 14:48: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 19CEmxB0069399; Tue, 12 Oct 2021 14:48:59 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19CEmw8k069398; Tue, 12 Oct 2021 14:48:58 GMT (envelope-from git) Date: Tue, 12 Oct 2021 14:48:58 GMT Message-Id: <202110121448.19CEmw8k069398@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Marcin Wojtas Subject: git: 5b8f3948f166 - stable/11 - Upgrade ENA to v2.4.0 List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mw X-Git-Repository: src X-Git-Refname: refs/heads/stable/11 X-Git-Reftype: branch X-Git-Commit: 5b8f3948f1669a05fc453b38055dedf5c9fad430 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/11 has been updated by mw: URL: https://cgit.FreeBSD.org/src/commit/?id=5b8f3948f1669a05fc453b38055dedf5c9fad430 commit 5b8f3948f1669a05fc453b38055dedf5c9fad430 Author: Marcin Wojtas AuthorDate: 2020-06-23 04:58:36 +0000 Commit: Marcin Wojtas CommitDate: 2021-10-12 14:47:18 +0000 Upgrade ENA to v2.4.0 teach ena driver about RSS kernel option Networking is broken if the driver configures its (virtual) hardware to use a hash algorithm (or a key) different from the one that the network stack (software RSS) uses. This can be seen with connections initiated from the host. The PCB will be placed into the hash table based on the hash value calculated by the software. The hardware-calculated hash value in reponse packets will be different, so the PCB won't be found. Tested with a kernel compiled with 'options RSS' on an instance with ena driver. Reviewed by: mw, adrian MFC after: 2 weeks Sponsored by: Panzura Differential Revision: https://reviews.freebsd.org/D24733 (cherry picked from commit b40dd828bdc96959cf5fa90d02fc00d96c54fbe4) ena: change ENA C++-style comment into C-style According to man style(9), only C-style comments should be used. Submitted by: Michal Krawczyk Obtained from: Semihalf MFC after: 2 weeks Sponsored by: Amazon, Inc. (cherry picked from commit 438c9e3cf89403628ec237cfecdd0538f208087b) ena: add support for the large LLQ headers in ENA Default LLQ (Low-latency queue) maximum header size is 96 bytes and can be too small for some types of packets - like IPv6 packets with multiple extension. This can be fixed, by using large LLQ headers. If the device supports larger LLQ headers, the user can activate this feature by setting sysctl tunable 'hw.ena.force_large_llq_header' to '1' in the /boot/loader.conf file. In case the device isn't supporting this feature, the default value (96B) will be used. Submitted by: Michal Krawczyk Obtained from: Semihalf MFC after: 2 weeks Sponsored by: Amazon, Inc. (cherry picked from commit beaadec9eaec8e6b266faff3b0880a141728fcef) ena: remove surplus NULL checks when freeing ENA resources Calling free on a NULL pointer is valid, as appropriate check is already done internally: /* free(NULL, ...) does nothing */ if (addr == NULL) return; Submitted by: Artur Rojek Obtained from: Semihalf MFC after: 2 weeks Sponsored by: Amazon, Inc. (cherry picked from commit ddec69e6a796283497ebada0569f34bd41bbdf37) ena: hide sysctl nodes for unused ENA queues IO queue related attributes are registered statically at driver attach with the rest of the ENA specific sysctl nodes. However, the number of queues can be changed at runtime via the `ena_sysctl_io_queues_nb` request, leading to a potential exposure of attributes for non-existing queues. Introduce a new `ena_sysctl_update_queue_node_nb` function, which updates the sysctl nodes after the number of queues is altered. This happens by either registering or unregistering node specific oids, based on a delta between the previous and current queue count. NOTE: All unregistered oids must be registered again before the driver detach, e.g. by another call to this function. Submitted by: Artur Rojek Obtained from: Semihalf MFC after: 2 weeks Sponsored by: Amazon, Inc. (cherry picked from commit 0e7d31f63b9db869c91228d8ed1e984bdee2b931) Merge tag 'vendor/ena-com/2.4.0' Update the driver in order not to break its compilation and make use of the new ENA logging system Migrate platform code to the new logging system provided by ena_com layer. Make ENA_INFO the new default log level. Remove all explicit use of `device_printf`, all new logs requiring one of the log macros to be used. (cherry picked from commit 3fc5d816f8831d6fc2816ac97bd78dc486cd080c) Update ENA driver man page Bring the obsolete man page up to date: * update diagnostic error messages * add documentation of loader tunables * document netmap support * add a driver history section * update the contact information Submitted by: Artur Rojek Submitted by: Michal Krawczyk Obtained from: Semihalf MFC after: 2 weeks Sponsored by: Amazon, Inc. (cherry picked from commit e34856a2c44a45512463aed0d1794f34258c66ee) Update ENA version to v2.4.0 Some of the changes in this release: * Large LLQ headers, * Bug/stability fixes, * Change of the README/Documentation. Submitted by: Michal Krawczyk Obtained from: Semihalf MFC after: 2 weeks Sponsored by: Amazon, Inc. (cherry picked from commit 93f0df457bf1d0e5f71839ab969c94d1f95813fb) --- share/man/man4/ena.4 | 272 ++++++++++++++--- sys/contrib/ena-com/ena_com.c | 37 +-- sys/contrib/ena-com/ena_com.h | 6 +- sys/contrib/ena-com/ena_defs/ena_admin_defs.h | 23 +- sys/contrib/ena-com/ena_defs/ena_gen_info.h | 6 +- sys/contrib/ena-com/ena_eth_com.c | 4 +- sys/contrib/ena-com/ena_fbsd_log.h | 74 +++++ sys/contrib/ena-com/ena_plat.h | 37 +-- sys/dev/ena/ena.c | 407 +++++++++++++++----------- sys/dev/ena/ena.h | 5 +- sys/dev/ena/ena_datapath.c | 99 ++++--- sys/dev/ena/ena_netmap.c | 73 ++--- sys/dev/ena/ena_sysctl.c | 91 ++++-- sys/dev/ena/ena_sysctl.h | 7 +- 14 files changed, 773 insertions(+), 368 deletions(-) diff --git a/share/man/man4/ena.4 b/share/man/man4/ena.4 index d73413f9a7b0..bc1927608b04 100644 --- a/share/man/man4/ena.4 +++ b/share/man/man4/ena.4 @@ -29,7 +29,7 @@ .\" .\" $FreeBSD$ .\" -.Dd August 16, 2017 +.Dd June 4, 2021 .Dt ENA 4 .Os .Sh NAME @@ -86,7 +86,13 @@ debug logs. .Pp Some of the ENA devices support a working mode called Low-latency Queue (LLQ), which saves several more microseconds. -This feature will be implemented for driver in future releases. +.Pp +Support for the +.Xr netmap 4 +framework is provided by the +.Nm +driver. +Kernel must be built with the DEV_NETMAP option to be able to use this feature. .Sh HARDWARE Supported PCI vendor ID/device IDs: .Pp @@ -100,8 +106,172 @@ Supported PCI vendor ID/device IDs: .It 1d0f:ec21 - ENA VF with LLQ support .El +.Sh LOADER TUNABLES +The +.Nm +driver's behavior can be changed using run-time or boot-time sysctl +arguments. +The boot-time arguments can be set at the +.Xr loader 8 +prompt before booting the kernel, or stored in the +.Xr loader.conf 5 . +The run-time arguments can be set using the +.Xr sysctl 8 +command. +.Pp +Boot-time tunables: +.Bl -tag -width indent +.It Va hw.ena.enable_9k_mbufs +Use 9k mbufs for the Rx descriptors. +The default is 0. +If the node value is set to 1, 9k mbufs will be used for the Rx buffers. +If set to 0, page size mbufs will be used instead. +.Pp +Using 9k buffers for Rx can improve Rx throughput, but in low memory conditions +it might increase allocation time, as the system has to look for 3 contiguous +pages. +This can further lead to OS instability, together with ENA driver reset and NVMe +timeouts. +If network performance is critical and memory capacity is sufficient, the 9k +mbufs can be used. +.It Va hw.ena.force_large_llq_headers +Force the driver to use large LLQ headers (224 bytes). +The default is 0. +If the node value is set to 0, the regular size LLQ header will be used, which +is 96B. +In some cases, the packet header can be bigger than this (for example - +IPv6 with multiple extensions). +In such a situation, the large LLQ headers should be used by setting this node +value to 1. +This will take effect only if the device supports both LLQ and large LLQ +headers. +Otherwise, it will fallback to the no LLQ mode or regular header size. +.Pp +Increasing LLQ header size reduces the size of the Tx queue by half, so it may +affect the number of dropped Tx packets. +.El +.Pp +Run-time tunables: +.Bl -tag -width indent +.It Va hw.ena.log_level +Controls extra logging verbosity of the driver. +The default is 2. +The higher the logging level, the more logs will be printed out. 0 means all +extra logs are disabled and only error logs will be printed out. +Default value (2) reports errors, warnings and is verbose about driver +operation. +.Pp +The possible flags are: +.Pp +.Bl -bullet -compact +.It +0 - ENA_ERR - Enable driver error messages and ena_com error logs. +.It +1 - ENA_WARN - Enable logs for non-critical errors. +.It +2 - ENA_INFO - Make the driver more verbose about its actions. +.It +3 - ENA_DBG - Enable debug logs. +.El +.Pp +NOTE: In order to enable logging on the Tx/Rx data path, driver must be compiled +with ENA_LOG_IO_ENABLE compilation flag. +.Pp +Example: +To enable logs for errors and warnings, the following command should be used: +.Bd -literal -offset indent +sysctl hw.ena.log_level=1 +.Ed +.It Va dev.ena.X.io_queues_nb +Number of the currently allocated and used IO queues. +The default is max_num_io_queues. +Controls the number of IO queue pairs (Tx/Rx). As this call has to reallocate +the queues, it will reset the interface and restart all the queues - this means +that everything, which was currently held in the queue, will be lost, leading to +potential packet drops. +.Pp +This call can fail if the system isn't able to provide the driver with enough +resources. +In that situation, the driver will try to revert the previous number of the IO +queues. +If this also fails, the device reset will be triggered. +.Pp +Example: +To use only 2 Tx and Rx queues for the device ena1, the following command should +be used: +.Bd -literal -offset indent +sysctl dev.ena.1.io_queues_nb=2 +.Ed +.It Va dev.ena.X.rx_queue_size +Size of the Rx queue. +The default is 1024. +Controls the number of IO descriptors for each Rx queue. +The user may want to increase the Rx queue size if they observe a high number of +Rx drops in the driver's statistics. +For performance reasons, the Rx queue size must be a power of 2. +.Pp +This call can fail if the system isn't able to provide the driver with enough +resources. +In that situation, the driver will try to revert to the previous number of the +descriptors. +If this also fails, the device reset will be triggered. +.Pp +Example: +To increase Rx ring size to 8K descriptors for the device ena0, the following +command should be used: +.Bd -literal -offset indent +sysctl dev.ena.0.rx_queue_size=8192 +.Ed +.It Va dev.ena.X.buf_ring_size +Size of the Tx buffer ring (drbr). +The default is 4096. +Input must be a power of 2. +Controls the number of mbufs that can be held in the Tx buffer ring. +The drbr is used as a multiple-producer, single-consumer lockless ring for +buffering extra mbufs coming from the stack in case the Tx procedure is busy +sending the packets, or the Tx ring is full. +Increasing the size of the buffer ring may reduce the number of Tx packets being +dropped in case of a big Tx burst, which cannot be handled by the IO queue +immediately. +Each Tx queue has its own drbr. +.Pp +It is recommended to keep the drbr with at least the default value, but in case +the system lacks the resources, it can be reduced. +This call can fail if the system is not able to provide the driver with enough +resources. +In that situation, the driver will try to revert to the previous number of the +drbr and trigger the device reset. +.Pp +Example: +To set drbr size for interface ena0 to 2048, the following command should +be used: +.Bd -literal -offset indent +sysctl dev.ena.0.buf_ring_size=2048 +.Ed +.It Va dev.ena.X.eni_metrics.sample_interval +Interval in seconds for updating ENI metrics. +The default is 0. +Determines how often (if ever) the ENI metrics should be updated. +The ENI metrics are being updated asynchronously in a timer service in order to +avoid admin queue overload by sysctl node reading. +The value in this node controls the interval between issuing admin commands to +the device, which will update the ENI metrics values. +.Pp +If some application is periodically monitoring the eni_metrics, then the ENI +metrics interval can be adjusted accordingly. +Value 0 turns off the update completely. +Value 1 is the minimum interval and is equal to 1 second. +The maximum allowed update interval is 1 hour. +.Pp +Example: +To update ENI metrics for the device ena1 every 10 seconds, the following +command should be used: +.Bd -literal -offset indent +sysctl dev.ena.1.eni_metrics.sample_interval=10 +.Ed +.El .Sh DIAGNOSTICS -.Ss Device initialization phase: +.Ss Device initialization phase .Bl -diag .It ena%d: failed to init mmio read less .Pp @@ -116,7 +286,7 @@ Device may not be responding or is already during reset. Version of the controller is too old and it is not supported by the driver. .It ena%d: Invalid dma width value %d .Pp -The controller is able to request dma transaction width. +The controller is unable to request dma transaction width. .br Device stopped responding or it demanded invalid value. .It ena%d: Can not initialize ena admin queue with device @@ -132,33 +302,30 @@ Failed to get attributes of the device from the controller. .Pp Errors occurred when trying to configure AENQ groups. .El -.Ss Driver initialisation/shutdown phase: +.Ss Driver initialization/shutdown phase .Bl -diag .It ena%d: PCI resource allocation failed! -.It ena%d: allocating ena_dev failed .It ena%d: failed to pmap registers bar -.It ena%d: Error while setting up bufring -.It ena%d: Error with initialization of IO rings .It ena%d: can not allocate ifnet structure .It ena%d: Error with network interface setup .It ena%d: Failed to enable and set the admin interrupts -.It ena%d: Failed to allocate %d, vectors %d +.It ena%d: Error, MSI-X is already enabled .It ena%d: Failed to enable MSIX, vectors %d rc %d +.It ena%d: Not enough number of MSI-X allocated: %d .It ena%d: Error with MSI-X enablement .It ena%d: could not allocate irq vector: %d -.It ena%d: Unable to allocate bus resource: registers +.It ena%d: unable to allocate bus resource: registers! +.It ena%d: unable to allocate bus resource: msix! .Pp Resource allocation failed when initializing the device. .br Driver will not be attached. .It ena%d: ENA device init failed (err: %d) +.It ena%d: Cannot initialize device .Pp Device initialization failed. .br Driver will not be attached. -.It ena%d: could not activate irq vector: %d -.Pp -Error occurred when trying to activate interrupt vectors for Admin Queue. .It ena%d: failed to register interrupt handler for irq %ju: %d .Pp Error occurred when trying to register Admin Queue interrupt handler. @@ -181,8 +348,7 @@ VLANs must be detached first and then detach routine have to be called again. .It ena%d: Unmapped TX DMA tag associations .Pp Error occurred when trying to destroy RX/TX DMA tag. -.It ena%d: Cannot init RSS -.It ena%d: Cannot fill indirect table +.It ena%d: Cannot init indirect table .It ena%d: Cannot fill indirect table .It ena%d: Cannot fill hash function .It ena%d: Cannot fill hash control @@ -192,20 +358,30 @@ Error occurred during initialization of one of RSS resources. .br The device will work with reduced performance because all RX packets will be passed to queue 0 and there will be no hash information. +.It ena%d: LLQ is not supported. Fallback to host mode policy. +.It ena%d: Failed to configure the device mode. Fallback to host mode policy. +.It ena%d: unable to allocate LLQ bar resource. Fallback to host mode policy. +.Pp +Error occured during Low-latency Queue mode setup. +.br +The device will work, but without the LLQ performance gain. +.It ena%d: failed to enable write combining. +.Pp +Error occured while setting the Write Combining mode, required for the LLQ. .It ena%d: failed to tear down irq: %d .It ena%d: dev has no parent while releasing res for irq: %d Release of the interrupts failed. .El -.Ss Additional diagnostic: +.Ss Additional diagnostic .Bl -diag -.It ena%d: Cannot get attribute for ena device -.Pp -This message appears when trying to change MTU and driver is unable to get -attributes from the device. -.It ena%d: Invalid MTU setting. new_mtu: %d +.It ena%d: Invalid MTU setting. new_mtu: %d max_mtu: %d min mtu: %d .Pp Requested MTU value is not supported and will not be set. -.It ena%d: keep alive watchdog timeout +.It ena%d: Failed to set MTU to %d +.Pp +This message appears when either MTU change feature is not supported, or device +communication error has occured. +.It ena%d: Keep alive watchdog timeout. .Pp Device stopped responding and will be reset. .It ena%d: Found a Tx that wasn't completed on time, qid %d, index %d. @@ -215,18 +391,35 @@ Packet was pushed to the NIC but not sent within given time limit. It may be caused by hang of the IO queue. .It ena%d: The number of lost tx completion is aboce the threshold (%d > %d). Reset the device .Pp -If too many Tx wasn't completed on time the device is going to be reset. +If too many Tx weren't completed on time the device is going to be reset. .br It may be caused by hanged queue or device. -.It ena%d: trigger reset is on +.It ena%d: Trigger reset is on .Pp Device will be reset. .br Reset is triggered either by watchdog or if too many TX packets were not completed on time. -.It ena%d: invalid value recvd +.It ena%d: device reset scheduled but trigger_reset is off .Pp -Link status received from the device in the AENQ handler is invalid. +Reset task has been triggered, but the driver did not request it. +.br +Device reset will not be performed. +.It ena%d: Device reset failed +.Pp +Error occured while trying to reset the device. +.It ena%d: Cannot initialize device +.It ena%d: Error, mac address are different +.It ena%d: Error, device max mtu is smaller than ifp MTU +.It ena%d: Validation of device parameters failed +.It ena%d: Enable MSI-X failed +.It ena%d: Failed to create I/O queues +.It ena%d: Reset attempt failed. Can not reset the device +.Pp +Error occured while trying to restore the device after reset. +.It ena%d: Device reset completed successfully, Driver info: %s +.Pp +Device has been correctly restored after reset and is ready to use. .It ena%d: Allocation for Tx Queue %u failed .It ena%d: Allocation for Rx Queue %u failed .It ena%d: Unable to create Rx DMA map for buffer %d @@ -234,7 +427,6 @@ Link status received from the device in the AENQ handler is invalid. .It ena%d: Failed to get TX queue handlers. TX queue num %d rc: %d .It ena%d: Failed to create io RX queue[%d] rc: %d .It ena%d: Failed to get RX queue handlers. RX queue num %d rc: %d -.It ena%d: failed to request irq .It ena%d: could not allocate irq vector: %d .It ena%d: failed to register interrupt handler for irq %ju: %d .Pp @@ -246,12 +438,20 @@ Interface will not be brought up. Initialization of the LRO for the RX ring failed. .It ena%d: failed to alloc buffer for rx queue .It ena%d: failed to add buffer for rx queue %d -.It ena%d: refilled rx queue %d with %d pages only +.It ena%d: refilled rx qid %d with only %d mbufs (from %d) .Pp Allocation of resources used on RX path failed. .br If happened during initialization of the IO queue, the interface will not be brought up. +.It ena%d: NULL mbuf in rx_info +.Pp +Error occured while assembling mbuf from descriptors. +.It ena%d: tx_info doesn't have valid mbuf +.It ena%d: Invalid req_id: %hu +.It ena%d: failed to prepare tx bufs +.Pp +Error occured while preparing a packet for transmission. .It ena%d: ioctl promisc/allmulti .Pp IOCTL request for the device to work in promiscuous/allmulti mode. @@ -259,21 +459,23 @@ IOCTL request for the device to work in promiscuous/allmulti mode. See .Xr ifconfig 8 for more details. -.It ena%d: too many fragments. Last fragment: %d! -.Pp -Packet with unsupported number of segments was queued for sending to the -device. -.br -Packet will be dropped. +.El .Sh SUPPORT If an issue is identified with the released source code with a supported adapter, please email the specific information related to the issue to -.Aq Mt mk@semihalf.com +.Aq Mt mk@semihalf.com , +.Aq Mt ar@semihalf.com and .Aq Mt mw@semihalf.com . .Sh SEE ALSO +.Xr netmap 4 , .Xr vlan 4 , .Xr ifconfig 8 +.Sh HISTORY +The +.Nm +driver first appeared in +.Fx 11.1 . .Sh AUTHORS The .Nm diff --git a/sys/contrib/ena-com/ena_com.c b/sys/contrib/ena-com/ena_com.c index 8c63c1a03f76..3af3b14eca44 100644 --- a/sys/contrib/ena-com/ena_com.c +++ b/sys/contrib/ena-com/ena_com.c @@ -1,7 +1,7 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * - * Copyright (c) 2015-2020 Amazon.com, Inc. or its affiliates. + * Copyright (c) 2015-2021 Amazon.com, Inc. or its affiliates. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -694,7 +694,7 @@ static int ena_com_config_llq_info(struct ena_com_dev *ena_dev, } else { ena_trc_err(ena_dev, "Invalid header location control, supported: 0x%x\n", supported_feat); - return -EINVAL; + return ENA_COM_INVAL; } if (likely(llq_info->header_location_ctrl == ENA_ADMIN_INLINE_HEADER)) { @@ -709,7 +709,7 @@ static int ena_com_config_llq_info(struct ena_com_dev *ena_dev, } else { ena_trc_err(ena_dev, "Invalid desc_stride_ctrl, supported: 0x%x\n", supported_feat); - return -EINVAL; + return ENA_COM_INVAL; } ena_trc_err(ena_dev, "Default llq stride ctrl is not supported, performing fallback, default: 0x%x, supported: 0x%x, used: 0x%x\n", @@ -738,7 +738,7 @@ static int ena_com_config_llq_info(struct ena_com_dev *ena_dev, } else { ena_trc_err(ena_dev, "Invalid entry_size_ctrl, supported: 0x%x\n", supported_feat); - return -EINVAL; + return ENA_COM_INVAL; } ena_trc_err(ena_dev, "Default llq ring entry size is not supported, performing fallback, default: 0x%x, supported: 0x%x, used: 0x%x\n", @@ -752,7 +752,7 @@ static int ena_com_config_llq_info(struct ena_com_dev *ena_dev, */ ena_trc_err(ena_dev, "Illegal entry size %d\n", llq_info->desc_list_entry_size); - return -EINVAL; + return ENA_COM_INVAL; } if (llq_info->desc_stride_ctrl == ENA_ADMIN_MULTIPLE_DESCS_PER_ENTRY) @@ -776,7 +776,7 @@ static int ena_com_config_llq_info(struct ena_com_dev *ena_dev, } else { ena_trc_err(ena_dev, "Invalid descs_num_before_header, supported: 0x%x\n", supported_feat); - return -EINVAL; + return ENA_COM_INVAL; } ena_trc_err(ena_dev, "Default llq num descs before header is not supported, performing fallback, default: 0x%x, supported: 0x%x, used: 0x%x\n", @@ -1409,16 +1409,17 @@ int ena_com_execute_admin_command(struct ena_com_admin_queue *admin_queue, comp_ctx = ena_com_submit_admin_cmd(admin_queue, cmd, cmd_size, comp, comp_size); if (IS_ERR(comp_ctx)) { - if (comp_ctx == ERR_PTR(ENA_COM_NO_DEVICE)) + ret = PTR_ERR(comp_ctx); + if (ret == ENA_COM_NO_DEVICE) ena_trc_dbg(admin_queue->ena_dev, - "Failed to submit command [%ld]\n", - PTR_ERR(comp_ctx)); + "Failed to submit command [%d]\n", + ret); else ena_trc_err(admin_queue->ena_dev, - "Failed to submit command [%ld]\n", - PTR_ERR(comp_ctx)); + "Failed to submit command [%d]\n", + ret); - return (int)PTR_ERR(comp_ctx); + return ret; } ret = ena_com_wait_and_process_admin_cq(comp_ctx, admin_queue); @@ -2034,7 +2035,7 @@ int ena_com_get_dev_attr_feat(struct ena_com_dev *ena_dev, return rc; if (get_resp.u.max_queue_ext.version != ENA_FEATURE_MAX_QUEUE_EXT_VER) - return -EINVAL; + return ENA_COM_INVAL; memcpy(&get_feat_ctx->max_queue_ext, &get_resp.u.max_queue_ext, sizeof(get_resp.u.max_queue_ext)); @@ -2363,7 +2364,7 @@ done: } #endif -int ena_com_set_dev_mtu(struct ena_com_dev *ena_dev, int mtu) +int ena_com_set_dev_mtu(struct ena_com_dev *ena_dev, u32 mtu) { struct ena_com_admin_queue *admin_queue; struct ena_admin_set_feat_cmd cmd; @@ -2381,7 +2382,7 @@ int ena_com_set_dev_mtu(struct ena_com_dev *ena_dev, int mtu) cmd.aq_common_descriptor.opcode = ENA_ADMIN_SET_FEATURE; cmd.aq_common_descriptor.flags = 0; cmd.feat_common.feature_id = ENA_ADMIN_MTU; - cmd.u.mtu.mtu = (u32)mtu; + cmd.u.mtu.mtu = mtu; ret = ena_com_execute_admin_command(admin_queue, (struct ena_admin_aq_entry *)&cmd, @@ -2792,7 +2793,7 @@ int ena_com_indirect_table_set(struct ena_com_dev *ena_dev) return ret; } - cmd.control_buffer.length = (u32)(1ULL << rss->tbl_log_size) * + cmd.control_buffer.length = (1ULL << rss->tbl_log_size) * sizeof(struct ena_admin_rss_ind_table_entry); ret = ena_com_execute_admin_command(admin_queue, @@ -2814,7 +2815,7 @@ int ena_com_indirect_table_get(struct ena_com_dev *ena_dev, u32 *ind_tbl) u32 tbl_size; int i, rc; - tbl_size = (u32)(1ULL << rss->tbl_log_size) * + tbl_size = (1ULL << rss->tbl_log_size) * sizeof(struct ena_admin_rss_ind_table_entry); rc = ena_com_get_feature_ex(ena_dev, &get_resp, @@ -3098,7 +3099,7 @@ int ena_com_config_dev_mode(struct ena_com_dev *ena_dev, if (unlikely(ena_dev->tx_max_header_size == 0)) { ena_trc_err(ena_dev, "The size of the LLQ entry is smaller than needed\n"); - return -EINVAL; + return ENA_COM_INVAL; } ena_dev->tx_mem_queue_type = ENA_ADMIN_PLACEMENT_POLICY_DEV; diff --git a/sys/contrib/ena-com/ena_com.h b/sys/contrib/ena-com/ena_com.h index 414301bdaf91..7ff0e00c1f17 100644 --- a/sys/contrib/ena-com/ena_com.h +++ b/sys/contrib/ena-com/ena_com.h @@ -1,7 +1,7 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * - * Copyright (c) 2015-2020 Amazon.com, Inc. or its affiliates. + * Copyright (c) 2015-2021 Amazon.com, Inc. or its affiliates. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -51,8 +51,6 @@ #define ADMIN_CQ_SIZE(depth) ((depth) * sizeof(struct ena_admin_acq_entry)) #define ADMIN_AENQ_SIZE(depth) ((depth) * sizeof(struct ena_admin_aenq_entry)) -#define ENA_CDESC_RING_SIZE_ALIGNMENT (1 << 12) /* 4K */ - /*****************************************************************************/ /*****************************************************************************/ /* ENA adaptive interrupt moderation settings */ @@ -645,7 +643,7 @@ int ena_com_get_eni_stats(struct ena_com_dev *ena_dev, * * @return: 0 on Success and negative value otherwise. */ -int ena_com_set_dev_mtu(struct ena_com_dev *ena_dev, int mtu); +int ena_com_set_dev_mtu(struct ena_com_dev *ena_dev, u32 mtu); /* ena_com_get_offload_settings - Retrieve the device offloads capabilities * @ena_dev: ENA communication layer struct diff --git a/sys/contrib/ena-com/ena_defs/ena_admin_defs.h b/sys/contrib/ena-com/ena_defs/ena_admin_defs.h index edfdad3473d7..33010bd1a2e8 100644 --- a/sys/contrib/ena-com/ena_defs/ena_admin_defs.h +++ b/sys/contrib/ena-com/ena_defs/ena_admin_defs.h @@ -1,7 +1,7 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * - * Copyright (c) 2015-2020 Amazon.com, Inc. or its affiliates. + * Copyright (c) 2015-2021 Amazon.com, Inc. or its affiliates. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -853,7 +853,8 @@ enum ena_admin_os_type { ENA_ADMIN_OS_FREEBSD = 4, ENA_ADMIN_OS_IPXE = 5, ENA_ADMIN_OS_ESXI = 6, - ENA_ADMIN_OS_GROUPS_NUM = 6, + ENA_ADMIN_OS_MACOS = 7, + ENA_ADMIN_OS_GROUPS_NUM = 7, }; struct ena_admin_host_info { @@ -902,7 +903,9 @@ struct ena_admin_host_info { * 2 : interrupt_moderation * 3 : rx_buf_mirroring * 4 : rss_configurable_function_key - * 31:5 : reserved + * 5 : reserved + * 6 : rx_page_reuse + * 31:7 : reserved */ uint32_t driver_supported_features; }; @@ -1092,8 +1095,6 @@ enum ena_admin_aenq_group { }; enum ena_admin_aenq_notification_syndrome { - ENA_ADMIN_SUSPEND = 0, - ENA_ADMIN_RESUME = 1, ENA_ADMIN_UPDATE_HINTS = 2, }; @@ -1228,6 +1229,8 @@ struct ena_admin_ena_mmio_req_read_less_resp { #define ENA_ADMIN_HOST_INFO_RX_BUF_MIRRORING_MASK BIT(3) #define ENA_ADMIN_HOST_INFO_RSS_CONFIGURABLE_FUNCTION_KEY_SHIFT 4 #define ENA_ADMIN_HOST_INFO_RSS_CONFIGURABLE_FUNCTION_KEY_MASK BIT(4) +#define ENA_ADMIN_HOST_INFO_RX_PAGE_REUSE_SHIFT 6 +#define ENA_ADMIN_HOST_INFO_RX_PAGE_REUSE_MASK BIT(6) /* feature_rss_ind_table */ #define ENA_ADMIN_FEATURE_RSS_IND_TABLE_ONE_ENTRY_UPDATE_MASK BIT(0) @@ -1689,6 +1692,16 @@ static inline void set_ena_admin_host_info_rss_configurable_function_key(struct p->driver_supported_features |= (val << ENA_ADMIN_HOST_INFO_RSS_CONFIGURABLE_FUNCTION_KEY_SHIFT) & ENA_ADMIN_HOST_INFO_RSS_CONFIGURABLE_FUNCTION_KEY_MASK; } +static inline uint32_t get_ena_admin_host_info_rx_page_reuse(const struct ena_admin_host_info *p) +{ + return (p->driver_supported_features & ENA_ADMIN_HOST_INFO_RX_PAGE_REUSE_MASK) >> ENA_ADMIN_HOST_INFO_RX_PAGE_REUSE_SHIFT; +} + +static inline void set_ena_admin_host_info_rx_page_reuse(struct ena_admin_host_info *p, uint32_t val) +{ + p->driver_supported_features |= (val << ENA_ADMIN_HOST_INFO_RX_PAGE_REUSE_SHIFT) & ENA_ADMIN_HOST_INFO_RX_PAGE_REUSE_MASK; +} + static inline uint8_t get_ena_admin_feature_rss_ind_table_one_entry_update(const struct ena_admin_feature_rss_ind_table *p) { return p->flags & ENA_ADMIN_FEATURE_RSS_IND_TABLE_ONE_ENTRY_UPDATE_MASK; diff --git a/sys/contrib/ena-com/ena_defs/ena_gen_info.h b/sys/contrib/ena-com/ena_defs/ena_gen_info.h index 726750a67d4e..2797239f24ef 100644 --- a/sys/contrib/ena-com/ena_defs/ena_gen_info.h +++ b/sys/contrib/ena-com/ena_defs/ena_gen_info.h @@ -1,7 +1,7 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * - * Copyright (c) 2015-2020 Amazon.com, Inc. or its affiliates. + * Copyright (c) 2015-2021 Amazon.com, Inc. or its affiliates. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -30,5 +30,5 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#define ENA_GEN_DATE "Fri Sep 18 17:09:00 IDT 2020" -#define ENA_GEN_COMMIT "0f80d82" +#define ENA_GEN_DATE "Tue Jan 19 12:45:09 STD 2021" +#define ENA_GEN_COMMIT "f023ae8f" diff --git a/sys/contrib/ena-com/ena_eth_com.c b/sys/contrib/ena-com/ena_eth_com.c index 47ca4e4afdb6..2d66c34c0aa7 100644 --- a/sys/contrib/ena-com/ena_eth_com.c +++ b/sys/contrib/ena-com/ena_eth_com.c @@ -1,7 +1,7 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * - * Copyright (c) 2015-2020 Amazon.com, Inc. or its affiliates. + * Copyright (c) 2015-2021 Amazon.com, Inc. or its affiliates. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -178,7 +178,7 @@ static int ena_com_close_bounce_buffer(struct ena_com_io_sq *io_sq) return ENA_COM_OK; /* bounce buffer was used, so write it and get a new one */ - if (pkt_ctrl->idx) { + if (likely(pkt_ctrl->idx)) { rc = ena_com_write_bounce_buffer_to_dev(io_sq, pkt_ctrl->curr_bounce_buf); if (unlikely(rc)) { diff --git a/sys/contrib/ena-com/ena_fbsd_log.h b/sys/contrib/ena-com/ena_fbsd_log.h new file mode 100644 index 000000000000..311e2f0f280a --- /dev/null +++ b/sys/contrib/ena-com/ena_fbsd_log.h @@ -0,0 +1,74 @@ +/*- + * SPDX-License-Identifier: BSD-3-Clause + * + * Copyright (c) 2015-2021 Amazon.com, Inc. or its affiliates. + * 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. + * * Neither the name of copyright holder nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef ENA_FBSD_LOG_H +#define ENA_FBSD_LOG_H + +enum ena_log_t { + ENA_ERR = 0, + ENA_WARN, + ENA_INFO, + ENA_DBG, +}; + +extern int ena_log_level; + +#define ena_log(dev, level, fmt, args...) \ + do { \ + if (ENA_ ## level <= ena_log_level) \ + device_printf((dev), fmt, ##args); \ + } while (0) + +#define ena_log_raw(level, fmt, args...) \ + do { \ + if (ENA_ ## level <= ena_log_level) \ + printf(fmt, ##args); \ + } while (0) + +#define ena_log_unused(dev, level, fmt, args...) \ + do { \ + (void)(dev); \ + } while (0) + +#ifdef ENA_LOG_IO_ENABLE +#define ena_log_io(dev, level, fmt, args...) \ + ena_log((dev), level, fmt, ##args) +#else +#define ena_log_io(dev, level, fmt, args...) \ + ena_log_unused((dev), level, fmt, ##args) +#endif + +#define ena_log_nm(dev, level, fmt, args...) \ + ena_log((dev), level, "[nm] " fmt, ##args) + +#endif /* !(ENA_FBSD_LOG_H) */ diff --git a/sys/contrib/ena-com/ena_plat.h b/sys/contrib/ena-com/ena_plat.h index 8fe1ec9aa731..b31821248398 100644 --- a/sys/contrib/ena-com/ena_plat.h +++ b/sys/contrib/ena-com/ena_plat.h @@ -1,7 +1,7 @@ /*- * SPDX-License-Identifier: BSD-3-Clause * - * Copyright (c) 2015-2020 Amazon.com, Inc. or its affiliates. + * Copyright (c) 2015-2021 Amazon.com, Inc. or its affiliates. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -91,22 +91,12 @@ __FBSDID("$FreeBSD$"); #include #include -extern struct ena_bus_space ebs; +#include "ena_fbsd_log.h" -/* Levels */ -#define ENA_ALERT (1 << 0) /* Alerts are providing more error info. */ -#define ENA_WARNING (1 << 1) /* Driver output is more error sensitive. */ -#define ENA_INFO (1 << 2) /* Provides additional driver info. */ -#define ENA_DBG (1 << 3) /* Driver output for debugging. */ -/* Detailed info that will be printed with ENA_INFO or ENA_DEBUG flag. */ -#define ENA_TXPTH (1 << 4) /* Allows TX path tracing. */ -#define ENA_RXPTH (1 << 5) /* Allows RX path tracing. */ -#define ENA_RSC (1 << 6) /* Goes with TXPTH or RXPTH, free/alloc res. */ -#define ENA_IOQ (1 << 7) /* Detailed info about IO queues. */ -#define ENA_ADMQ (1 << 8) /* Detailed info about admin queue. */ -#define ENA_NETMAP (1 << 9) /* Detailed info about netmap. */ +extern struct ena_bus_space ebs; #define DEFAULT_ALLOC_ALIGNMENT 8 +#define ENA_CDESC_RING_SIZE_ALIGNMENT (1 << 12) /* 4K */ extern int ena_log_level; @@ -116,27 +106,18 @@ extern int ena_log_level; (type *)((uintptr_t)__p - offsetof(type, member)); \ }) -#define ena_trace_raw(ctx, level, fmt, args...) \ - do { \ - ((void)(ctx)); \ - if (((level) & ena_log_level) != (level)) \ - break; \ - printf(fmt, ##args); \ - } while (0) - #define ena_trace(ctx, level, fmt, args...) \ - ena_trace_raw(ctx, level, "%s() [TID:%d]: " \ + ena_log((ctx)->dmadev, level, "%s() [TID:%d]: " \ fmt, __func__, curthread->td_tid, ##args) - #define ena_trc_dbg(ctx, format, arg...) \ - ena_trace(ctx, ENA_DBG, format, ##arg) + ena_trace(ctx, DBG, format, ##arg) #define ena_trc_info(ctx, format, arg...) \ - ena_trace(ctx, ENA_INFO, format, ##arg) + ena_trace(ctx, INFO, format, ##arg) #define ena_trc_warn(ctx, format, arg...) \ - ena_trace(ctx, ENA_WARNING, format, ##arg) *** 2381 LINES SKIPPED *** From nobody Tue Oct 12 14:49:00 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 5E1E3180303C; Tue, 12 Oct 2021 14:49: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 4HTJT84MVzz3Gv2; Tue, 12 Oct 2021 14:49:00 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 2DD691654A; Tue, 12 Oct 2021 14:49:00 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19CEn0SM069429; Tue, 12 Oct 2021 14:49:00 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19CEn0Ll069427; Tue, 12 Oct 2021 14:49:00 GMT (envelope-from git) Date: Tue, 12 Oct 2021 14:49:00 GMT Message-Id: <202110121449.19CEn0Ll069427@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Marcin Wojtas Subject: git: e579f3af96d5 - stable/11 - Upgrade ENA to v2.4.1 List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mw X-Git-Repository: src X-Git-Refname: refs/heads/stable/11 X-Git-Reftype: branch X-Git-Commit: e579f3af96d5e431d8dad48d35826aa09d5a77f8 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/11 has been updated by mw: URL: https://cgit.FreeBSD.org/src/commit/?id=e579f3af96d5e431d8dad48d35826aa09d5a77f8 commit e579f3af96d5e431d8dad48d35826aa09d5a77f8 Author: Marcin Wojtas AuthorDate: 2021-07-23 22:31:32 +0000 Commit: Marcin Wojtas CommitDate: 2021-10-12 14:47:32 +0000 Upgrade ENA to v2.4.1 ena: Remove redundant declaration of ena_log_level. GCC6 raises a -Wredundant-decl error due to duplicate declarations in ena_fbsd_log.h and ena_plat.h. Submitted by: jhb Sponsored by: Chelsio Communications (cherry picked from commit 8843787aa1bdbd10de6ba47a04489179ec2d2d3c) ena: Avoid unnecessary mbuf collapses for LLQ condition In case of Low-latency Queue, one small enough descriptor can be pushed directly to the ENA hw, thus saving one fragment. Check for this condition before performing collapse. Submitted by: Artur Rojek Obtained from: Semihalf MFC after: 2 weeks Sponsored by: Amazon, Inc. (cherry picked from commit c81f8c26115a64b9a97ecdb2a64e824dd839ee73) ena: Trigger reset on ena_com_prepare_tx failure All ena_com_prepare_tx errors other than ENA_COM_NO_MEM are fatal and require device reset. Submitted by: Artur Rojek Obtained from: Semihalf MFC after: 2 weeks Sponsored by: Amazon, Inc. (cherry picked from commit 36130d2979d695dd439bc607feb00dcdb9a1937b) ena: Prevent reset after device destruction Check for ENA_FLAG_TRIGGER_RESET inside a locked context in order to avoid potential race conditions with ena_destroy_device. This aligns the reset task logic with the Linux driver. Submitted by: Artur Rojek Obtained from: Semihalf MFC after: 2 weeks Sponsored by: Amazon, Inc. (cherry picked from commit 433ab9b6987b42b3e5b25b8b5dc7e5178c7ef9bb) ena: Add extra log messages Stay aligned with the Linux driver by adding the following logs: * inform the user about retrying queue creation * warn on non-empty ena_tx_buffer.mbuf prior to ena_tx_map_mbuf Submitted by: Artur Rojek Obtained from: Semihalf MFC after: 2 weeks Sponsored by: Amazon, Inc. (cherry picked from commit 77160654a162b5faa8ad7a02e18d2bef2589f868) ena: Add locking assertions ENA silently assumed that ena_up, ena_down and ena_start_xmit routines should be called within locked context. Driver's logic heavily assumes on concurrent access to those routines, so for safety and better documentation about this assumption, the locking assertions were added to the above functions. The assertion was added only for the main steps (skipping the helper functions) which can be called from multiple places including the kernel and the driver itself. Submitted by: Artur Rojek Obtained from: Semihalf MFC after: 2 weeks Sponsored by: Amazon, Inc. (cherry picked from commit cb98c439d66c303353a9f4abbbe9ddb51559c638) ena: Move RSS logic into its own source files Delegate RSS related functionality into separate .c/.h files in preparation for the full RSS support. While at it, reorder functions and remove prototypes for ones with internal linkage. Submitted by: Artur Rojek Obtained from: Semihalf MFC after: 2 weeks Sponsored by: Amazon, Inc. (cherry picked from commit 986e7b9227668caf9620f207e3c1d708c87b634d) ena: Disable meta descriptor caching for netmap If LLQ is being used, `ena_tx_ctx.meta_valid` must stay enabled. This fixes netmap support on latest generation ENA HW and aligns it with the core driver behavior. As netmap doesn't support any csum offloads, the `adapter->disable_meta_caching` value can be simply passed to the HW. Submitted by: Artur Rojek Obtained from: Semihalf MFC after: 2 weeks Sponsored by: Amazon, Inc. (cherry picked from commit a831466830de6ab55fc03170290b313157196e81) ena: Share ena_global_lock between driver instances In order to use `ena_global_lock` in sysctl context, it must be kept outside the driver instance's software context, as sysctls can be called before attach and after detach, leading to lock use before sx_init and after sx_destroy otherwise. Solve this issue by turning `ena_global_lock` into a file scope variable, shared between all instances of the driver and associated sysctl context, and in turn initialized/destroyed in dedicated SYSINIT/SYSUNINIT functions. As a side effect, this change also fixes existing race in the reset routine, when simultaneously accessing sysctl exposed properties. Submitted by: Artur Rojek Obtained from: Semihalf MFC after: 2 weeks Sponsored by: Amazon, Inc. (cherry picked from commit 07aff471c0de2de9a1dc5c7749c46b525bdd0201) ena: Add missing statistics Provide the following sysctl statistics in order to stay aligned with the Linux driver: * rx_ring.csum_good * tx_ring.unmask_interrupt_num Also rename the 'bad_csum' statistic name to 'csum_bad' for alignment. Submitted by: Artur Rojek Obtained from: Semihalf MFC after: 2 weeks Sponsored by: Amazon, Inc. (cherry picked from commit 223c8cb12e951c63807300a0cbdc4a1569520b4b) ena: Implement full RSS reconfiguration Bind RX/TX queues and MSI-X vectors to matching CPUs based on the RSS bucket entries. Introduce sysctls for the following RSS functionality: - rss.indir_table: indirection table mapping - rss.indir_table_size: indirection table size - rss.key: RSS hash key (if Toeplitz used) Said sysctls are only available when compiled without `option RSS`, as kernel-side RSS support currently doesn't offer RSS reconfiguration. Migrate the hash algorithm from CRC32 to Toeplitz and change the initial hash value to 0x0 in order to match the standard Toeplitz implementation. Provide helpers for hash key inversion required for HW operations. Submitted by: Artur Rojek Obtained from: Semihalf MFC after: 2 weeks Sponsored by: Amazon, Inc. (cherry picked from commit 6d1ef2abd330fac4057f092abbbdc28a568b4327) ena: fix building in-kernel driver When building ENA as compiled into the kernel, the driver would fail to build. Resolve the problem by introducing the following changes: 1. Add missing `ena_rss.c` entry in `sys/conf/files`. 2. Prevent SYSCTL_ADD_INT from throwing an assert due to an extra CTLTYPE_INT flag. Fixes: 986e7b92276 ("ena: Move RSS logic into its own source files") Fixes: 6d1ef2abd33 ("ena: Implement full RSS reconfiguration") Submitted by: Artur Rojek Obtained from: Semihalf Sponsored by: Amazon, Inc. MFC after: 1 week (cherry picked from commit a3f0d18237bdcf272461d3b4b682de384c572144) ena: Update driver version to v2.4.1 Some of the changes in this release: * Hardware RSS hash key reconfiguration and indirection table reconfiguration support. * Full kernel RSS support. * Extra statistic counters. * Netmap support for ENAv3. * Locking assertions. * Extra log messages. * Reset handling fixes. Submitted by: Michal Krawczyk Obtained from: Semihalf MFC after: 2 weeks Sponsored by: Amazon, Inc. (cherry picked from commit 42c7760be3ea420668f625f2064ae347aa7e818e) --- share/man/man4/ena.4 | 51 +++++++ sys/conf/files | 2 + sys/contrib/ena-com/ena_plat.h | 2 - sys/dev/ena/ena.c | 302 +++++++++++++------------------------ sys/dev/ena/ena.h | 34 +++-- sys/dev/ena/ena_datapath.c | 32 +++- sys/dev/ena/ena_netmap.c | 7 +- sys/dev/ena/ena_rss.c | 300 +++++++++++++++++++++++++++++++++++++ sys/dev/ena/ena_rss.h | 73 +++++++++ sys/dev/ena/ena_sysctl.c | 329 +++++++++++++++++++++++++++++++++++++++-- sys/modules/ena/Makefile | 2 +- 11 files changed, 900 insertions(+), 234 deletions(-) diff --git a/share/man/man4/ena.4 b/share/man/man4/ena.4 index bc1927608b04..71bdf4babca6 100644 --- a/share/man/man4/ena.4 +++ b/share/man/man4/ena.4 @@ -269,6 +269,57 @@ command should be used: .Bd -literal -offset indent sysctl dev.ena.1.eni_metrics.sample_interval=10 .Ed +.It Va dev.ena.X.rss.indir_table_size +RSS indirection table size. +The default is 128. +Returns the number of entries in the RSS indirection table. +.Pp +Example: +To read the RSS indirection table size, the following command should be used: +.Bd -literal -offset indent +sysctl dev.ena.0.rss.indir_table_size +.Ed +.It Va dev.ena.X.rss.indir_table +RSS indirection table mapping. +The default is x:y key-pairs of indir_table_size length. +Updates selected indices of the RSS indirection table. +.Pp +The entry string consists of one or more x:y keypairs, where x stands for +the table index and y for its new value. Table indices that don't need to be +updated can be omitted from the string and will retain their existing values. +.Pp +If an index is entered more than once, the last value is used. +.Pp +Example: +To update two selected indices in the RSS indirection table, e.g. setting index +0 to queue 5 and then index 5 to queue 0, the following command should be used: +.Bd -literal -offset indent +sysctl dev.ena.0.rss.indir_table="0:5 5:0" +.Ed +.It Va dev.ena.X.rss.key +RSS hash key. +The default is 40 bytes long randomly generated hash key. +Controls the RSS Toeplitz hash algorithm key value. +.Pp +Only available when driver compiled without the kernel side RSS support. +.Pp +Example: +To change the RSS hash key value to +.Pp +0x6d, 0x5a, 0x56, 0xda, 0x25, 0x5b, 0x0e, 0xc2, +.br +0x41, 0x67, 0x25, 0x3d, 0x43, 0xa3, 0x8f, 0xb0, +.br +0xd0, 0xca, 0x2b, 0xcb, 0xae, 0x7b, 0x30, 0xb4, +.br +0x77, 0xcb, 0x2d, 0xa3, 0x80, 0x30, 0xf2, 0x0c, +.br +0x6a, 0x42, 0xb7, 0x3b, 0xbe, 0xac, 0x01, 0xfa +.Pp +the following command should be used: +.Bd -literal -offset indent +sysctl dev.ena.0.rss.key=6d5a56da255b0ec24167253d43a38fb0d0ca2bcbae7b30b477cb2da38030f20c6a42b73bbeac01fa +.Ed .El .Sh DIAGNOSTICS .Ss Device initialization phase diff --git a/sys/conf/files b/sys/conf/files index 0356ac8fd471..f7edc87469eb 100644 --- a/sys/conf/files +++ b/sys/conf/files @@ -1665,6 +1665,8 @@ dev/ena/ena_datapath.c optional ena \ compile-with "${NORMAL_C} -I$S/contrib" dev/ena/ena_netmap.c optional ena \ compile-with "${NORMAL_C} -I$S/contrib" +dev/ena/ena_rss.c optional ena \ + compile-with "${NORMAL_C} -I$S/contrib" dev/ena/ena_sysctl.c optional ena \ compile-with "${NORMAL_C} -I$S/contrib" contrib/ena-com/ena_com.c optional ena diff --git a/sys/contrib/ena-com/ena_plat.h b/sys/contrib/ena-com/ena_plat.h index b31821248398..274f795950c0 100644 --- a/sys/contrib/ena-com/ena_plat.h +++ b/sys/contrib/ena-com/ena_plat.h @@ -98,8 +98,6 @@ extern struct ena_bus_space ebs; #define DEFAULT_ALLOC_ALIGNMENT 8 #define ENA_CDESC_RING_SIZE_ALIGNMENT (1 << 12) /* 4K */ -extern int ena_log_level; - #define container_of(ptr, type, member) \ ({ \ const __typeof(((type *)0)->member) *__p = (ptr); \ diff --git a/sys/dev/ena/ena.c b/sys/dev/ena/ena.c index 8ca5200d82d8..a25be8423139 100644 --- a/sys/dev/ena/ena.c +++ b/sys/dev/ena/ena.c @@ -63,9 +63,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#ifdef RSS -#include -#endif #include #include @@ -84,6 +81,7 @@ __FBSDID("$FreeBSD$"); #include "ena_datapath.h" #include "ena.h" #include "ena_sysctl.h" +#include "ena_rss.h" #ifdef DEV_NETMAP #include "ena_netmap.h" @@ -143,7 +141,6 @@ static void ena_free_io_irq(struct ena_adapter *); static void ena_free_irqs(struct ena_adapter*); static void ena_disable_msix(struct ena_adapter *); static void ena_unmask_all_io_irqs(struct ena_adapter *); -static int ena_rss_configure(struct ena_adapter *); static int ena_up_complete(struct ena_adapter *); static uint64_t ena_get_counter(if_t, ift_counter); static int ena_media_change(if_t); @@ -161,8 +158,6 @@ static int ena_set_queues_placement_policy(device_t, struct ena_com_dev *, static uint32_t ena_calc_max_io_queue_num(device_t, struct ena_com_dev *, struct ena_com_dev_get_features_ctx *); static int ena_calc_io_queue_size(struct ena_calc_queue_size_ctx *); -static int ena_rss_init_default(struct ena_adapter *); -static void ena_rss_init_default_deferred(void *); static void ena_config_host_info(struct ena_com_dev *, device_t); static int ena_attach(device_t); static int ena_detach(device_t); @@ -186,6 +181,8 @@ static ena_vendor_info_t ena_vendor_info_array[] = { { 0, 0, 0 } }; +struct sx ena_global_lock; + /* * Contains pointers to event handlers, e.g. link state chage. */ @@ -265,27 +262,6 @@ fail_tag: return (error); } -/* - * This function should generate unique key for the whole driver. - * If the key was already genereated in the previous call (for example - * for another adapter), then it should be returned instead. - */ -void -ena_rss_key_fill(void *key, size_t size) -{ - static bool key_generated; - static uint8_t default_key[ENA_HASH_KEY_SIZE]; - - KASSERT(size <= ENA_HASH_KEY_SIZE, ("Requested more bytes than ENA RSS key can hold")); - - if (!key_generated) { - arc4rand(default_key, ENA_HASH_KEY_SIZE, 0); - key_generated = true; - } - - memcpy(key, default_key, size); -} - static void ena_free_pci_resources(struct ena_adapter *adapter) { @@ -625,8 +601,10 @@ static int ena_setup_tx_resources(struct ena_adapter *adapter, int qid) { device_t pdev = adapter->pdev; + char thread_name[MAXCOMLEN + 1]; struct ena_que *que = &adapter->que[qid]; struct ena_ring *tx_ring = que->tx_ring; + cpuset_t *cpu_mask = NULL; int size, i, err; #ifdef DEV_NETMAP bus_dmamap_t *map; @@ -710,8 +688,16 @@ ena_setup_tx_resources(struct ena_adapter *adapter, int qid) tx_ring->running = true; - taskqueue_start_threads(&tx_ring->enqueue_tq, 1, PI_NET, - "%s txeq %d", device_get_nameunit(adapter->pdev), que->cpu); +#ifdef RSS + cpu_mask = &que->cpu_mask; + snprintf(thread_name, sizeof(thread_name), "%s txeq %d", + device_get_nameunit(adapter->pdev), que->cpu); +#else + snprintf(thread_name, sizeof(thread_name), "%s txeq %d", + device_get_nameunit(adapter->pdev), que->id); +#endif + taskqueue_start_threads_cpuset(&tx_ring->enqueue_tq, 1, PI_NET, + cpu_mask, "%s", thread_name); return (0); @@ -1153,8 +1139,6 @@ ena_update_buf_ring_size(struct ena_adapter *adapter, int rc = 0; bool dev_was_up; - ENA_LOCK_LOCK(adapter); - old_buf_ring_size = adapter->buf_ring_size; adapter->buf_ring_size = new_buf_ring_size; @@ -1189,8 +1173,6 @@ ena_update_buf_ring_size(struct ena_adapter *adapter, } } - ENA_LOCK_UNLOCK(adapter); - return (rc); } @@ -1202,8 +1184,6 @@ ena_update_queue_size(struct ena_adapter *adapter, uint32_t new_tx_size, int rc = 0; bool dev_was_up; - ENA_LOCK_LOCK(adapter); - old_tx_size = adapter->requested_tx_ring_size; old_rx_size = adapter->requested_rx_ring_size; adapter->requested_tx_ring_size = new_tx_size; @@ -1244,8 +1224,6 @@ ena_update_queue_size(struct ena_adapter *adapter, uint32_t new_tx_size, } } - ENA_LOCK_UNLOCK(adapter); - return (rc); } @@ -1268,8 +1246,6 @@ ena_update_io_queue_nb(struct ena_adapter *adapter, uint32_t new_num) int rc = 0; bool dev_was_up; - ENA_LOCK_LOCK(adapter); - dev_was_up = ENA_FLAG_ISSET(ENA_FLAG_DEV_UP, adapter); old_num = adapter->num_io_queues; ena_down(adapter); @@ -1299,8 +1275,6 @@ ena_update_io_queue_nb(struct ena_adapter *adapter, uint32_t new_num) } } - ENA_LOCK_UNLOCK(adapter); - return (rc); } @@ -1459,6 +1433,7 @@ ena_create_io_queues(struct ena_adapter *adapter) struct ena_que *queue; uint16_t ena_qid; uint32_t msix_vector; + cpuset_t *cpu_mask = NULL; int rc, i; /* Create TX queues */ @@ -1525,7 +1500,11 @@ ena_create_io_queues(struct ena_adapter *adapter) queue->cleanup_tq = taskqueue_create_fast("ena cleanup", M_WAITOK, taskqueue_thread_enqueue, &queue->cleanup_tq); - taskqueue_start_threads(&queue->cleanup_tq, 1, PI_NET, +#ifdef RSS + cpu_mask = &queue->cpu_mask; +#endif + taskqueue_start_threads_cpuset(&queue->cleanup_tq, 1, PI_NET, + cpu_mask, "%s queue %d cleanup", device_get_nameunit(adapter->pdev), i); } @@ -1664,7 +1643,10 @@ ena_setup_mgmnt_intr(struct ena_adapter *adapter) static int ena_setup_io_intr(struct ena_adapter *adapter) { - static int last_bind_cpu = -1; +#ifdef RSS + int num_buckets = rss_getnumbuckets(); + static int last_bind = 0; +#endif int irq_idx; if (adapter->msix_entries == NULL) @@ -1682,15 +1664,12 @@ ena_setup_io_intr(struct ena_adapter *adapter) ena_log(adapter->pdev, DBG, "ena_setup_io_intr vector: %d\n", adapter->msix_entries[irq_idx].vector); - /* - * We want to bind rings to the corresponding cpu - * using something similar to the RSS round-robin technique. - */ - if (unlikely(last_bind_cpu < 0)) - last_bind_cpu = CPU_FIRST(); +#ifdef RSS adapter->que[i].cpu = adapter->irq_tbl[irq_idx].cpu = - last_bind_cpu; - last_bind_cpu = CPU_NEXT(last_bind_cpu); + rss_getcpu(last_bind); + last_bind = (last_bind + 1) % num_buckets; + CPU_SETOF(adapter->que[i].cpu, &adapter->que[i].cpu_mask); +#endif } return (0); @@ -1782,6 +1761,19 @@ ena_request_io_irq(struct ena_adapter *adapter) goto err; } irq->requested = true; + +#ifdef RSS + rc = bus_bind_intr(adapter->pdev, irq->res, irq->cpu); + if (unlikely(rc != 0)) { + ena_log(pdev, ERR, "failed to bind " + "interrupt handler for irq %ju to cpu %d: %d\n", + rman_get_start(irq->res), irq->cpu, rc); + goto err; + } + + ena_log(pdev, INFO, "queue %d - cpu %d\n", + i - ENA_IO_IRQ_FIRST_IDX, irq->cpu); +#endif } return (rc); @@ -1910,6 +1902,7 @@ ena_unmask_all_io_irqs(struct ena_adapter *adapter) { struct ena_com_io_cq* io_cq; struct ena_eth_io_intr_reg intr_reg; + struct ena_ring *tx_ring; uint16_t ena_qid; int i; @@ -1918,47 +1911,12 @@ ena_unmask_all_io_irqs(struct ena_adapter *adapter) ena_qid = ENA_IO_TXQ_IDX(i); io_cq = &adapter->ena_dev->io_cq_queues[ena_qid]; ena_com_update_intr_reg(&intr_reg, 0, 0, true); + tx_ring = &adapter->tx_ring[i]; + counter_u64_add(tx_ring->tx_stats.unmask_interrupt_num, 1); ena_com_unmask_intr(io_cq, &intr_reg); } } -/* Configure the Rx forwarding */ -static int -ena_rss_configure(struct ena_adapter *adapter) -{ - struct ena_com_dev *ena_dev = adapter->ena_dev; - int rc; - - /* In case the RSS table was destroyed */ - if (!ena_dev->rss.tbl_log_size) { - rc = ena_rss_init_default(adapter); - if (unlikely((rc != 0) && (rc != EOPNOTSUPP))) { - ena_log(adapter->pdev, ERR, - "WARNING: RSS was not properly re-initialized," - " it will affect bandwidth\n"); - ENA_FLAG_CLEAR_ATOMIC(ENA_FLAG_RSS_ACTIVE, adapter); - return (rc); - } - } - - /* Set indirect table */ - rc = ena_com_indirect_table_set(ena_dev); - if (unlikely((rc != 0) && (rc != EOPNOTSUPP))) - return (rc); - - /* Configure hash function (if supported) */ - rc = ena_com_set_hash_function(ena_dev); - if (unlikely((rc != 0) && (rc != EOPNOTSUPP))) - return (rc); - - /* Configure hash inputs (if supported) */ - rc = ena_com_set_hash_ctrl(ena_dev); - if (unlikely((rc != 0) && (rc != EOPNOTSUPP))) - return (rc); - - return (0); -} - static int ena_up_complete(struct ena_adapter *adapter) { @@ -2079,6 +2037,10 @@ err_setup_tx: return (rc); } + ena_log(pdev, INFO, + "Retrying queue creation with sizes TX=%d, RX=%d\n", + new_tx_ring_size, new_rx_ring_size); + set_io_rings_size(adapter, new_tx_ring_size, new_rx_ring_size); } } @@ -2088,6 +2050,8 @@ ena_up(struct ena_adapter *adapter) { int rc = 0; + ENA_LOCK_ASSERT(); + if (unlikely(device_is_attached(adapter->pdev) == 0)) { ena_log(adapter->pdev, ERR, "device is not attached!\n"); return (ENXIO); @@ -2205,13 +2169,13 @@ ena_media_status(if_t ifp, struct ifmediareq *ifmr) struct ena_adapter *adapter = if_getsoftc(ifp); ena_log(adapter->pdev, DBG, "Media status update\n"); - ENA_LOCK_LOCK(adapter); + ENA_LOCK_LOCK(); ifmr->ifm_status = IFM_AVALID; ifmr->ifm_active = IFM_ETHER; if (!ENA_FLAG_ISSET(ENA_FLAG_LINK_UP, adapter)) { - ENA_LOCK_UNLOCK(adapter); + ENA_LOCK_UNLOCK(); ena_log(adapter->pdev, INFO, "Link is down\n"); return; } @@ -2219,7 +2183,7 @@ ena_media_status(if_t ifp, struct ifmediareq *ifmr) ifmr->ifm_status |= IFM_ACTIVE; ifmr->ifm_active |= IFM_UNKNOWN | IFM_FDX; - ENA_LOCK_UNLOCK(adapter); + ENA_LOCK_UNLOCK(); } static void @@ -2228,9 +2192,9 @@ ena_init(void *arg) struct ena_adapter *adapter = (struct ena_adapter *)arg; if (!ENA_FLAG_ISSET(ENA_FLAG_DEV_UP, adapter)) { - ENA_LOCK_LOCK(adapter); + ENA_LOCK_LOCK(); ena_up(adapter); - ENA_LOCK_UNLOCK(adapter); + ENA_LOCK_UNLOCK(); } } @@ -2252,13 +2216,13 @@ ena_ioctl(if_t ifp, u_long command, caddr_t data) case SIOCSIFMTU: if (ifp->if_mtu == ifr->ifr_mtu) break; - ENA_LOCK_LOCK(adapter); + ENA_LOCK_LOCK(); ena_down(adapter); ena_change_mtu(ifp, ifr->ifr_mtu); rc = ena_up(adapter); - ENA_LOCK_UNLOCK(adapter); + ENA_LOCK_UNLOCK(); break; case SIOCSIFFLAGS: @@ -2270,15 +2234,15 @@ ena_ioctl(if_t ifp, u_long command, caddr_t data) "ioctl promisc/allmulti\n"); } } else { - ENA_LOCK_LOCK(adapter); + ENA_LOCK_LOCK(); rc = ena_up(adapter); - ENA_LOCK_UNLOCK(adapter); + ENA_LOCK_UNLOCK(); } } else { if ((if_getdrvflags(ifp) & IFF_DRV_RUNNING) != 0) { - ENA_LOCK_LOCK(adapter); + ENA_LOCK_LOCK(); ena_down(adapter); - ENA_LOCK_UNLOCK(adapter); + ENA_LOCK_UNLOCK(); } } break; @@ -2303,10 +2267,10 @@ ena_ioctl(if_t ifp, u_long command, caddr_t data) if ((reinit != 0) && ((if_getdrvflags(ifp) & IFF_DRV_RUNNING) != 0)) { - ENA_LOCK_LOCK(adapter); + ENA_LOCK_LOCK(); ena_down(adapter); rc = ena_up(adapter); - ENA_LOCK_UNLOCK(adapter); + ENA_LOCK_UNLOCK(); } } @@ -2460,6 +2424,8 @@ ena_down(struct ena_adapter *adapter) { int rc; + ENA_LOCK_ASSERT(); + if (!ENA_FLAG_ISSET(ENA_FLAG_DEV_UP, adapter)) return; @@ -2525,6 +2491,10 @@ ena_calc_max_io_queue_num(device_t pdev, struct ena_com_dev *ena_dev, /* 1 IRQ for for mgmnt and 1 IRQ for each TX/RX pair */ max_num_io_queues = min_t(uint32_t, max_num_io_queues, pci_msix_count(pdev) - 1); +#ifdef RSS + max_num_io_queues = min_t(uint32_t, max_num_io_queues, + rss_getnumbuckets()); +#endif return (max_num_io_queues); } @@ -2721,90 +2691,6 @@ ena_calc_io_queue_size(struct ena_calc_queue_size_ctx *ctx) return (0); } -static int -ena_rss_init_default(struct ena_adapter *adapter) -{ - struct ena_com_dev *ena_dev = adapter->ena_dev; - device_t dev = adapter->pdev; - int qid, rc, i; - - rc = ena_com_rss_init(ena_dev, ENA_RX_RSS_TABLE_LOG_SIZE); - if (unlikely(rc != 0)) { - ena_log(dev, ERR, "Cannot init indirect table\n"); - return (rc); - } - - for (i = 0; i < ENA_RX_RSS_TABLE_SIZE; i++) { - qid = i % adapter->num_io_queues; - rc = ena_com_indirect_table_fill_entry(ena_dev, i, - ENA_IO_RXQ_IDX(qid)); - if (unlikely((rc != 0) && (rc != EOPNOTSUPP))) { - ena_log(dev, ERR, "Cannot fill indirect table\n"); - goto err_rss_destroy; - } - } - -#ifdef RSS - uint8_t rss_algo = rss_gethashalgo(); - if (rss_algo == RSS_HASH_TOEPLITZ) { - uint8_t hash_key[RSS_KEYSIZE]; - - rss_getkey(hash_key); - rc = ena_com_fill_hash_function(ena_dev, ENA_ADMIN_TOEPLITZ, - hash_key, RSS_KEYSIZE, 0xFFFFFFFF); - } else -#endif - rc = ena_com_fill_hash_function(ena_dev, ENA_ADMIN_CRC32, NULL, - ENA_HASH_KEY_SIZE, 0xFFFFFFFF); - if (unlikely((rc != 0) && (rc != EOPNOTSUPP))) { - ena_log(dev, ERR, "Cannot fill hash function\n"); - goto err_rss_destroy; - } - - rc = ena_com_set_default_hash_ctrl(ena_dev); - if (unlikely((rc != 0) && (rc != EOPNOTSUPP))) { - ena_log(dev, ERR, "Cannot fill hash control\n"); - goto err_rss_destroy; - } - - return (0); - -err_rss_destroy: - ena_com_rss_destroy(ena_dev); - return (rc); -} - -static void -ena_rss_init_default_deferred(void *arg) -{ - struct ena_adapter *adapter; - devclass_t dc; - int max; - int rc; - - dc = devclass_find("ena"); - if (unlikely(dc == NULL)) { - ena_log_raw(ERR, "SYSINIT: %s: No devclass ena\n", __func__); - return; - } - - max = devclass_get_maxunit(dc); - while (max-- >= 0) { - adapter = devclass_get_softc(dc, max); - if (adapter != NULL) { - rc = ena_rss_init_default(adapter); - ENA_FLAG_SET_ATOMIC(ENA_FLAG_RSS_ACTIVE, adapter); - if (unlikely(rc != 0)) { - ena_log(adapter->pdev, WARN, - "WARNING: RSS was not properly initialized," - " it will affect bandwidth\n"); - ENA_FLAG_CLEAR_ATOMIC(ENA_FLAG_RSS_ACTIVE, adapter); - } - } - } -} -SYSINIT(ena_rss_init, SI_SUB_KICK_SCHEDULER, SI_ORDER_SECOND, ena_rss_init_default_deferred, NULL); - static void ena_config_host_info(struct ena_com_dev *ena_dev, device_t dev) { @@ -2837,7 +2723,8 @@ ena_config_host_info(struct ena_com_dev *ena_dev, device_t dev) (DRV_MODULE_VER_SUBMINOR << ENA_ADMIN_HOST_INFO_SUB_MINOR_SHIFT); host_info->num_cpus = mp_ncpus; host_info->driver_supported_features = - ENA_ADMIN_HOST_INFO_RX_OFFSET_MASK; + ENA_ADMIN_HOST_INFO_RX_OFFSET_MASK | + ENA_ADMIN_HOST_INFO_RSS_CONFIGURABLE_FUNCTION_KEY_MASK; rc = ena_com_set_host_attributes(ena_dev); if (unlikely(rc != 0)) { @@ -3538,16 +3425,12 @@ ena_reset_task(void *arg, int pending) { struct ena_adapter *adapter = (struct ena_adapter *)arg; - if (unlikely(!ENA_FLAG_ISSET(ENA_FLAG_TRIGGER_RESET, adapter))) { - ena_log(adapter->pdev, WARN, - "device reset scheduled but trigger_reset is off\n"); - return; + ENA_LOCK_LOCK(); + if (likely(ENA_FLAG_ISSET(ENA_FLAG_TRIGGER_RESET, adapter))) { + ena_destroy_device(adapter, false); + ena_restore_device(adapter); } - - ENA_LOCK_LOCK(adapter); - ena_destroy_device(adapter, false); - ena_restore_device(adapter); - ENA_LOCK_UNLOCK(adapter); + ENA_LOCK_UNLOCK(); } /** @@ -3576,8 +3459,6 @@ ena_attach(device_t pdev) adapter = device_get_softc(pdev); adapter->pdev = pdev; - ENA_LOCK_INIT(adapter); - /* * Set up the timer service - driver is responsible for avoiding * concurrency, as the callout won't be using any locking inside. @@ -3827,19 +3708,19 @@ ena_detach(device_t pdev) ether_ifdetach(adapter->ifp); /* Stop timer service */ - ENA_LOCK_LOCK(adapter); + ENA_LOCK_LOCK(); callout_drain(&adapter->timer_service); - ENA_LOCK_UNLOCK(adapter); + ENA_LOCK_UNLOCK(); /* Release reset task */ while (taskqueue_cancel(adapter->reset_tq, &adapter->reset_task, NULL)) taskqueue_drain(adapter->reset_tq, &adapter->reset_task); taskqueue_free(adapter->reset_tq); - ENA_LOCK_LOCK(adapter); + ENA_LOCK_LOCK(); ena_down(adapter); ena_destroy_device(adapter, true); - ENA_LOCK_UNLOCK(adapter); + ENA_LOCK_UNLOCK(); /* Restore unregistered sysctl queue nodes. */ ena_sysctl_update_queue_node_nb(adapter, adapter->num_io_queues, @@ -3868,13 +3749,14 @@ ena_detach(device_t pdev) ena_free_pci_resources(adapter); + if (adapter->rss_indir != NULL) + free(adapter->rss_indir, M_DEVBUF); + if (likely(ENA_FLAG_ISSET(ENA_FLAG_RSS_ACTIVE, adapter))) ena_com_rss_destroy(ena_dev); ena_com_delete_host_info(ena_dev); - ENA_LOCK_DESTROY(adapter); - if_free(adapter->ifp); free(ena_dev->bus, M_DEVBUF); @@ -3940,6 +3822,20 @@ static void ena_notification(void *adapter_data, } } +static void +ena_lock_init(void *arg) +{ + ENA_LOCK_INIT(); +} +SYSINIT(ena_lock_init, SI_SUB_LOCK, SI_ORDER_FIRST, ena_lock_init, NULL); + +static void +ena_lock_uninit(void *arg) +{ + ENA_LOCK_DESTROY(); +} +SYSUNINIT(ena_lock_uninit, SI_SUB_LOCK, SI_ORDER_FIRST, ena_lock_uninit, NULL); + /** * This handler will called for unknown event group or unimplemented handlers **/ diff --git a/sys/dev/ena/ena.h b/sys/dev/ena/ena.h index 1d06a3cb56de..f559f9127c11 100644 --- a/sys/dev/ena/ena.h +++ b/sys/dev/ena/ena.h @@ -34,14 +34,14 @@ #ifndef ENA_H #define ENA_H -#include +#include "opt_rss.h" #include "ena-com/ena_com.h" #include "ena-com/ena_eth_com.h" #define DRV_MODULE_VER_MAJOR 2 #define DRV_MODULE_VER_MINOR 4 -#define DRV_MODULE_VER_SUBMINOR 0 +#define DRV_MODULE_VER_SUBMINOR 1 #define DRV_MODULE_NAME "ena" @@ -123,6 +123,8 @@ #define ENA_IO_TXQ_IDX(q) (2 * (q)) #define ENA_IO_RXQ_IDX(q) (2 * (q) + 1) +#define ENA_IO_TXQ_IDX_TO_COMBINED_IDX(q) ((q) / 2) +#define ENA_IO_RXQ_IDX_TO_COMBINED_IDX(q) (((q) - 1) / 2) #define ENA_MGMNT_IRQ_IDX 0 #define ENA_IO_IRQ_FIRST_IDX 1 @@ -201,7 +203,9 @@ struct ena_irq { void *cookie; unsigned int vector; bool requested; +#ifdef RSS int cpu; +#endif char name[ENA_IRQNAME_SIZE]; }; @@ -214,7 +218,10 @@ struct ena_que { struct taskqueue *cleanup_tq; uint32_t id; +#ifdef RSS int cpu; + cpuset_t cpu_mask; +#endif struct sysctl_oid *oid; }; @@ -281,19 +288,21 @@ struct ena_stats_tx { counter_u64_t queue_wakeup; counter_u64_t queue_stop; *** 1121 LINES SKIPPED *** From nobody Tue Oct 12 15:39:11 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 6E79617F3744; Tue, 12 Oct 2021 15:39: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 4HTKb32Ymbz3qQx; Tue, 12 Oct 2021 15:39: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 388BE16CD5; Tue, 12 Oct 2021 15:39: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 19CFdBCb037153; Tue, 12 Oct 2021 15:39:11 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19CFdBVW037152; Tue, 12 Oct 2021 15:39:11 GMT (envelope-from git) Date: Tue, 12 Oct 2021 15:39:11 GMT Message-Id: <202110121539.19CFdBVW037152@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Ed Maste Subject: git: be74669a2f62 - stable/13 - OpenSSH: cherry-pick "need initgroups() before setresgid()" List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: emaste X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: be74669a2f62915f84b844bb00dd2767c60539fe Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=be74669a2f62915f84b844bb00dd2767c60539fe commit be74669a2f62915f84b844bb00dd2767c60539fe Author: Ed Maste AuthorDate: 2021-10-12 00:47:39 +0000 Commit: Ed Maste CommitDate: 2021-10-12 15:37:55 +0000 OpenSSH: cherry-pick "need initgroups() before setresgid()" From openssh-portable commits f3cbe43e28fe and bf944e3794ef, backported to OpenSSH 7.9p1 on stable/13. Reviewed by: delphij Security: CVE-2021-41617 Differential Revision: https://reviews.freebsd.org/D32460 (cherry picked from commit 172fa4aa7577915bf5ace5783251821d3774dc05) --- crypto/openssh/auth.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/crypto/openssh/auth.c b/crypto/openssh/auth.c index a2e1fa10ce45..65183d456490 100644 --- a/crypto/openssh/auth.c +++ b/crypto/openssh/auth.c @@ -39,6 +39,7 @@ __RCSID("$FreeBSD$"); # include #endif #include +#include #ifdef HAVE_LOGIN_H #include #endif @@ -983,6 +984,13 @@ subprocess(const char *tag, struct passwd *pw, const char *command, } closefrom(STDERR_FILENO + 1); + if (geteuid() == 0 && + initgroups(pw->pw_name, pw->pw_gid) == -1) { + error("%s: initgroups(%s, %u): %s", tag, + pw->pw_name, (u_int)pw->pw_gid, strerror(errno)); + _exit(1); + } + /* Don't use permanently_set_uid() here to avoid fatal() */ if (setresgid(pw->pw_gid, pw->pw_gid, pw->pw_gid) != 0) { error("%s: setresgid %u: %s", tag, (u_int)pw->pw_gid, From nobody Tue Oct 12 16:01:41 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id D5D2517FE9B1; Tue, 12 Oct 2021 16:01: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 4HTL514HVnz4RyY; Tue, 12 Oct 2021 16:01: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 73658173D3; Tue, 12 Oct 2021 16:01: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 19CG1f7T074132; Tue, 12 Oct 2021 16:01:41 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19CG1fNg074131; Tue, 12 Oct 2021 16:01:41 GMT (envelope-from git) Date: Tue, 12 Oct 2021 16:01:41 GMT Message-Id: <202110121601.19CG1fNg074131@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: e088ad2d0efe - stable/12 - x86: cpufunc: Add rdtscp_aux() List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: e088ad2d0efec94462d5c10c992f2ac0b5aa22fd Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=e088ad2d0efec94462d5c10c992f2ac0b5aa22fd commit e088ad2d0efec94462d5c10c992f2ac0b5aa22fd Author: Adam Fenn AuthorDate: 2021-07-26 19:59:55 +0000 Commit: Konstantin Belousov CommitDate: 2021-10-12 16:01:25 +0000 x86: cpufunc: Add rdtscp_aux() Add a variant of 'rdtscp()' that retains and returns the 'IA32_TSC_AUX' value read by 'rdtscp'. Sponsored By: Juniper Networks, Inc. Sponsored By: Klara, Inc. Reviewed by: markj, kib Differential Revision: https://reviews.freebsd.org/D31415 (cherry picked from commit 908e277230ef1a80589f85687f5b422b0e863e79) --- sys/amd64/include/cpufunc.h | 9 +++++++++ sys/i386/include/cpufunc.h | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/sys/amd64/include/cpufunc.h b/sys/amd64/include/cpufunc.h index 85e6c60a4ffd..93e62c0df73a 100644 --- a/sys/amd64/include/cpufunc.h +++ b/sys/amd64/include/cpufunc.h @@ -403,6 +403,15 @@ rdtscp(void) return (low | ((uint64_t)high << 32)); } +static __inline uint64_t +rdtscp_aux(uint32_t *aux) +{ + uint32_t low, high; + + __asm __volatile("rdtscp" : "=a" (low), "=d" (high), "=c" (*aux)); + return (low | ((uint64_t)high << 32)); +} + static __inline uint32_t rdtsc32(void) { diff --git a/sys/i386/include/cpufunc.h b/sys/i386/include/cpufunc.h index 9646590a6a40..7b99978facc3 100644 --- a/sys/i386/include/cpufunc.h +++ b/sys/i386/include/cpufunc.h @@ -403,6 +403,15 @@ rdtscp(void) return (rv); } +static __inline uint64_t +rdtscp_aux(uint32_t *aux) +{ + uint64_t rv; + + __asm __volatile("rdtscp" : "=A" (rv), "=c" (*aux)); + return (rv); +} + static __inline uint32_t rdtsc32(void) { From nobody Tue Oct 12 16:01:42 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id E7F4617FE96A; Tue, 12 Oct 2021 16:01: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 4HTL5252s3z4SDk; Tue, 12 Oct 2021 16:01: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 8EA8117245; Tue, 12 Oct 2021 16:01: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 19CG1gT1074156; Tue, 12 Oct 2021 16:01:42 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19CG1ggj074155; Tue, 12 Oct 2021 16:01:42 GMT (envelope-from git) Date: Tue, 12 Oct 2021 16:01:42 GMT Message-Id: <202110121601.19CG1ggj074155@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: 946f96d13b01 - stable/12 - x86: cpufunc: Add rdtsc_ordered() List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 946f96d13b013963cc11de1eca2ede4c0658fc61 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=946f96d13b013963cc11de1eca2ede4c0658fc61 commit 946f96d13b013963cc11de1eca2ede4c0658fc61 Author: Adam Fenn AuthorDate: 2021-07-28 17:12:00 +0000 Commit: Konstantin Belousov CommitDate: 2021-10-12 16:01:26 +0000 x86: cpufunc: Add rdtsc_ordered() Add a variant of 'rdtsc()' that performs the ordered version of 'rdtsc' appropriate for the invoking x86 variant. Also, expose the 'lfence'-ed and 'mfence'-ed 'rdtsc()' variants needed by 'rdtsc_ordered()' for general use. Sponsored by: Juniper Networks, Inc. Sponsored by: Klara, Inc. Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D31416 (cherry picked from commit 652ae7b11485d9f991ea66a56aa79d4dd9cd1103) --- sys/amd64/include/cpufunc.h | 14 ++++++++++++++ sys/i386/include/cpufunc.h | 14 ++++++++++++++ sys/x86/include/x86_var.h | 1 + sys/x86/x86/cpu_machdep.c | 16 ++++++++++++++++ 4 files changed, 45 insertions(+) diff --git a/sys/amd64/include/cpufunc.h b/sys/amd64/include/cpufunc.h index 93e62c0df73a..95086469d51d 100644 --- a/sys/amd64/include/cpufunc.h +++ b/sys/amd64/include/cpufunc.h @@ -394,6 +394,20 @@ rdtsc(void) return (low | ((uint64_t)high << 32)); } +static __inline uint64_t +rdtsc_ordered_lfence(void) +{ + lfence(); + return (rdtsc()); +} + +static __inline uint64_t +rdtsc_ordered_mfence(void) +{ + mfence(); + return (rdtsc()); +} + static __inline uint64_t rdtscp(void) { diff --git a/sys/i386/include/cpufunc.h b/sys/i386/include/cpufunc.h index 7b99978facc3..79cdd3004b77 100644 --- a/sys/i386/include/cpufunc.h +++ b/sys/i386/include/cpufunc.h @@ -394,6 +394,20 @@ rdtsc(void) return (rv); } +static __inline uint64_t +rdtsc_ordered_lfence(void) +{ + lfence(); + return (rdtsc()); +} + +static __inline uint64_t +rdtsc_ordered_mfence(void) +{ + mfence(); + return (rdtsc()); +} + static __inline uint64_t rdtscp(void) { diff --git a/sys/x86/include/x86_var.h b/sys/x86/include/x86_var.h index 3e146b44338f..5b8e41bd76d7 100644 --- a/sys/x86/include/x86_var.h +++ b/sys/x86/include/x86_var.h @@ -159,6 +159,7 @@ int pti_get_default(void); int user_dbreg_trap(register_t dr6); int minidumpsys(struct dumperinfo *); struct pcb *get_pcb_td(struct thread *td); +uint64_t rdtsc_ordered(void); #define MSR_OP_ANDNOT 0x00000001 #define MSR_OP_OR 0x00000002 diff --git a/sys/x86/x86/cpu_machdep.c b/sys/x86/x86/cpu_machdep.c index 8bceaee913db..26423228d5dc 100644 --- a/sys/x86/x86/cpu_machdep.c +++ b/sys/x86/x86/cpu_machdep.c @@ -76,6 +76,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include @@ -88,6 +89,7 @@ __FBSDID("$FreeBSD$"); #include #endif #include +#include #include #include @@ -1421,3 +1423,17 @@ acpi_get_fadt_bootflags(uint16_t *flagsp) return (false); #endif } + +DEFINE_IFUNC(, uint64_t, rdtsc_ordered, (void), static) +{ + bool cpu_is_amd = cpu_vendor_id == CPU_VENDOR_AMD || + cpu_vendor_id == CPU_VENDOR_HYGON; + + if ((amd_feature & AMDID_RDTSCP) != 0) + return (rdtscp); + else if ((cpu_feature & CPUID_SSE2) != 0) + return (cpu_is_amd ? rdtsc_ordered_mfence : + rdtsc_ordered_lfence); + else + return (rdtsc); +} From nobody Tue Oct 12 16:01:43 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id C2C4217FE8A2; Tue, 12 Oct 2021 16:01: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 4HTL541fMbz4S3d; Tue, 12 Oct 2021 16:01: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 BEE2F173D4; Tue, 12 Oct 2021 16:01: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 19CG1hPq074180; Tue, 12 Oct 2021 16:01:43 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19CG1hYa074179; Tue, 12 Oct 2021 16:01:43 GMT (envelope-from git) Date: Tue, 12 Oct 2021 16:01:43 GMT Message-Id: <202110121601.19CG1hYa074179@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: 2f1e66f27040 - stable/12 - x86: files: Make sys/x86/x86/pvclock.c optional List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 2f1e66f27040bda7a6fedbbfa6dadcb2c5a7e66c Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=2f1e66f27040bda7a6fedbbfa6dadcb2c5a7e66c commit 2f1e66f27040bda7a6fedbbfa6dadcb2c5a7e66c Author: Adam Fenn AuthorDate: 2021-08-04 15:10:43 +0000 Commit: Konstantin Belousov CommitDate: 2021-10-12 16:01:26 +0000 x86: files: Make sys/x86/x86/pvclock.c optional Make inclusion of `sys/x86/x86/pvclock.c` contingent on that of its dependents. Sponsored by: Juniper Networks, Inc. Sponsored by: Klara, Inc. Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D31417 (cherry picked from commit 346f5a0c483b7c159efd7c8faf4a18f3e3f77158) --- sys/conf/files.amd64 | 2 +- sys/conf/files.i386 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/conf/files.amd64 b/sys/conf/files.amd64 index ee7d8fc2f072..ad698de09fe7 100644 --- a/sys/conf/files.amd64 +++ b/sys/conf/files.amd64 @@ -819,7 +819,7 @@ x86/x86/mp_x86.c optional smp x86/x86/mp_watchdog.c optional mp_watchdog smp x86/x86/msi.c optional pci x86/x86/nexus.c standard -x86/x86/pvclock.c standard +x86/x86/pvclock.c optional xenhvm x86/x86/stack_machdep.c optional ddb | stack x86/x86/tsc.c standard x86/x86/ucode.c standard diff --git a/sys/conf/files.i386 b/sys/conf/files.i386 index ffbb8c314e3e..934c72c87044 100644 --- a/sys/conf/files.i386 +++ b/sys/conf/files.i386 @@ -635,7 +635,7 @@ x86/x86/nexus.c standard x86/x86/stack_machdep.c optional ddb | stack x86/x86/tsc.c standard x86/x86/ucode.c standard -x86/x86/pvclock.c standard +x86/x86/pvclock.c optional xenhvm x86/x86/delay.c standard x86/xen/hvm.c optional xenhvm x86/xen/xen_intr.c optional xenhvm From nobody Tue Oct 12 16:01:44 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 8F07817FE6CF; Tue, 12 Oct 2021 16:01:46 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HTL551QQNz4SBW; Tue, 12 Oct 2021 16:01: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 DA090172C9; Tue, 12 Oct 2021 16:01:44 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19CG1iiK074204; Tue, 12 Oct 2021 16:01:44 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19CG1iV4074203; Tue, 12 Oct 2021 16:01:44 GMT (envelope-from git) Date: Tue, 12 Oct 2021 16:01:44 GMT Message-Id: <202110121601.19CG1iV4074203@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: 249f2478e382 - stable/12 - pvclock: Add 'struct pvclock' API List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 249f2478e38224df653878bc58ab549f1b7c0465 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=249f2478e38224df653878bc58ab549f1b7c0465 commit 249f2478e38224df653878bc58ab549f1b7c0465 Author: Adam Fenn AuthorDate: 2021-08-07 20:01:46 +0000 Commit: Konstantin Belousov CommitDate: 2021-10-12 16:01:26 +0000 pvclock: Add 'struct pvclock' API Consolidate more hypervisor-agnostic functionality behind a new 'struct pvclock' API. This should also make it easier to subsequently add hypervisor-agnostic vDSO timekeeping support. Also, perform some clean-up: - Remove 'pvclock_get_last_cycles()'; do not allow external access to 'pvclock_last_systime' since this is not necessary. - Consolidate/simplify wall and system time reading codepaths. - Ensure correct ordering within wall and system time reading codepaths via 'atomic(9)' and 'rdtsc_ordered()' rather than via 'rmb()'. - Remove some extra newlines. Sponsored by: Juniper Networks, Inc. Sponsored by: Klara, Inc. Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D31418 (cherry picked from commit 0b3382b863f3195d88b99f94d5af7fe4a7b9726a) --- sys/x86/include/pvclock.h | 27 ++++++- sys/x86/x86/pvclock.c | 194 ++++++++++++++++++++++++++++++++-------------- 2 files changed, 160 insertions(+), 61 deletions(-) diff --git a/sys/x86/include/pvclock.h b/sys/x86/include/pvclock.h index 402ffed810ca..399017039dd0 100644 --- a/sys/x86/include/pvclock.h +++ b/sys/x86/include/pvclock.h @@ -29,6 +29,9 @@ #ifndef X86_PVCLOCK #define X86_PVCLOCK +#include +#include + struct pvclock_vcpu_time_info { uint32_t version; uint32_t pad0; @@ -43,17 +46,39 @@ struct pvclock_vcpu_time_info { #define PVCLOCK_FLAG_TSC_STABLE 0x01 #define PVCLOCK_FLAG_GUEST_PASUED 0x02 +typedef struct pvclock_wall_clock *pvclock_get_wallclock_t(void *arg); + struct pvclock_wall_clock { uint32_t version; uint32_t sec; uint32_t nsec; }; +struct pvclock { + /* Public; initialized by the caller of 'pvclock_init()': */ + pvclock_get_wallclock_t *get_wallclock; + void *get_wallclock_arg; + struct pvclock_vcpu_time_info *timeinfos; + bool stable_flag_supported; + + /* Private; initialized by the 'pvclock' API: */ + struct timecounter tc; +}; + +/* + * NOTE: 'pvclock_get_timecount()' and 'pvclock_get_wallclock()' are purely + * transitional; they should be removed after 'dev/xen/timer/timer.c' has been + * migrated to the 'struct pvclock' API. + */ void pvclock_resume(void); -uint64_t pvclock_get_last_cycles(void); uint64_t pvclock_tsc_freq(struct pvclock_vcpu_time_info *ti); uint64_t pvclock_get_timecount(struct pvclock_vcpu_time_info *ti); void pvclock_get_wallclock(struct pvclock_wall_clock *wc, struct timespec *ts); +void pvclock_init(struct pvclock *pvc, device_t dev, + const char *tc_name, int tc_quality, u_int tc_flags); +void pvclock_gettime(struct pvclock *pvc, struct timespec *ts); +int pvclock_destroy(struct pvclock *pvc); + #endif diff --git a/sys/x86/x86/pvclock.c b/sys/x86/x86/pvclock.c index c1e6f83b33bf..e0ad65d906b8 100644 --- a/sys/x86/x86/pvclock.c +++ b/sys/x86/x86/pvclock.c @@ -31,31 +31,34 @@ __FBSDID("$FreeBSD$"); #include #include +#include +#include #include -#include -#include #include +#include #include /* - * Last time; this guarantees a monotonically increasing clock for when - * a stable TSC is not provided. + * Last system time. This is used to guarantee a monotonically non-decreasing + * clock for the kernel codepath and approximate the same for the vDSO codepath. + * In theory, this should be unnecessary absent hypervisor bug(s) and/or what + * should be rare cases where TSC jitter may still be visible despite the + * hypervisor's best efforts. */ -static volatile uint64_t pvclock_last_cycles; +static volatile uint64_t pvclock_last_systime; + +static uint64_t pvclock_getsystime(struct pvclock *pvc); +static void pvclock_read_time_info( + struct pvclock_vcpu_time_info *ti, uint64_t *ns, uint8_t *flags); +static void pvclock_read_wall_clock(struct pvclock_wall_clock *wc, + struct timespec *ts); +static u_int pvclock_tc_get_timecount(struct timecounter *tc); void pvclock_resume(void) { - - atomic_store_rel_64(&pvclock_last_cycles, 0); -} - -uint64_t -pvclock_get_last_cycles(void) -{ - - return (atomic_load_acq_64(&pvclock_last_cycles)); + atomic_store_rel_64(&pvclock_last_systime, 0); } uint64_t @@ -64,12 +67,10 @@ pvclock_tsc_freq(struct pvclock_vcpu_time_info *ti) uint64_t freq; freq = (1000000000ULL << 32) / ti->tsc_to_system_mul; - if (ti->tsc_shift < 0) freq <<= -ti->tsc_shift; else freq >>= ti->tsc_shift; - return (freq); } @@ -86,7 +87,6 @@ pvclock_scale_delta(uint64_t delta, uint32_t mul_frac, int shift) delta >>= -shift; else delta <<= shift; - #if defined(__i386__) { uint32_t tmp1, tmp2; @@ -122,82 +122,156 @@ pvclock_scale_delta(uint64_t delta, uint32_t mul_frac, int shift) #else #error "pvclock: unsupported x86 architecture?" #endif - return (product); } -static uint64_t -pvclock_get_nsec_offset(struct pvclock_vcpu_time_info *ti) -{ - uint64_t delta; - - delta = rdtsc() - ti->tsc_timestamp; - - return (pvclock_scale_delta(delta, ti->tsc_to_system_mul, - ti->tsc_shift)); -} - static void pvclock_read_time_info(struct pvclock_vcpu_time_info *ti, - uint64_t *cycles, uint8_t *flags) + uint64_t *ns, uint8_t *flags) { + uint64_t delta; uint32_t version; do { - version = ti->version; - rmb(); - *cycles = ti->system_time + pvclock_get_nsec_offset(ti); + version = atomic_load_acq_32(&ti->version); + delta = rdtsc_ordered() - ti->tsc_timestamp; + *ns = ti->system_time + pvclock_scale_delta(delta, + ti->tsc_to_system_mul, ti->tsc_shift); *flags = ti->flags; - rmb(); + atomic_thread_fence_acq(); } while ((ti->version & 1) != 0 || ti->version != version); } static void -pvclock_read_wall_clock(struct pvclock_wall_clock *wc, uint32_t *sec, - uint32_t *nsec) +pvclock_read_wall_clock(struct pvclock_wall_clock *wc, struct timespec *ts) { uint32_t version; do { - version = wc->version; - rmb(); - *sec = wc->sec; - *nsec = wc->nsec; - rmb(); + version = atomic_load_acq_32(&wc->version); + ts->tv_sec = wc->sec; + ts->tv_nsec = wc->nsec; + atomic_thread_fence_acq(); } while ((wc->version & 1) != 0 || wc->version != version); } +static uint64_t +pvclock_getsystime(struct pvclock *pvc) +{ + uint64_t now, last, ret; + uint8_t flags; + + critical_enter(); + pvclock_read_time_info(&pvc->timeinfos[curcpu], &now, &flags); + ret = now; + if ((flags & PVCLOCK_FLAG_TSC_STABLE) == 0) { + last = atomic_load_acq_64(&pvclock_last_systime); + do { + if (last > now) { + ret = last; + break; + } + } while (!atomic_fcmpset_rel_64(&pvclock_last_systime, &last, + now)); + } + critical_exit(); + return (ret); +} + +/* + * NOTE: Transitional-only; this should be removed after 'dev/xen/timer/timer.c' + * has been migrated to the 'struct pvclock' API. + */ uint64_t pvclock_get_timecount(struct pvclock_vcpu_time_info *ti) { - uint64_t now, last; + uint64_t now, last, ret; uint8_t flags; pvclock_read_time_info(ti, &now, &flags); + ret = now; + if ((flags & PVCLOCK_FLAG_TSC_STABLE) == 0) { + last = atomic_load_acq_64(&pvclock_last_systime); + do { + if (last > now) { + ret = last; + break; + } + } while (!atomic_fcmpset_rel_64(&pvclock_last_systime, &last, + now)); + } + return (ret); +} - if (flags & PVCLOCK_FLAG_TSC_STABLE) - return (now); +/* + * NOTE: Transitional-only; this should be removed after 'dev/xen/timer/timer.c' + * has been migrated to the 'struct pvclock' API. + */ +void +pvclock_get_wallclock(struct pvclock_wall_clock *wc, struct timespec *ts) +{ + pvclock_read_wall_clock(wc, ts); +} - /* - * Enforce a monotonically increasing clock time across all VCPUs. - * If our time is too old, use the last time and return. Otherwise, - * try to update the last time. - */ - do { - last = atomic_load_acq_64(&pvclock_last_cycles); - if (last > now) - return (last); - } while (!atomic_cmpset_64(&pvclock_last_cycles, last, now)); +static u_int +pvclock_tc_get_timecount(struct timecounter *tc) +{ + struct pvclock *pvc = tc->tc_priv; - return (now); + return (pvclock_getsystime(pvc) & UINT_MAX); } void -pvclock_get_wallclock(struct pvclock_wall_clock *wc, struct timespec *ts) +pvclock_gettime(struct pvclock *pvc, struct timespec *ts) { - uint32_t sec, nsec; + struct timespec system_ts; + uint64_t system_ns; + + pvclock_read_wall_clock(pvc->get_wallclock(pvc->get_wallclock_arg), ts); + system_ns = pvclock_getsystime(pvc); + system_ts.tv_sec = system_ns / 1000000000ULL; + system_ts.tv_nsec = system_ns % 1000000000ULL; + timespecadd(ts, &system_ts, ts); +} - pvclock_read_wall_clock(wc, &sec, &nsec); - ts->tv_sec = sec; - ts->tv_nsec = nsec; +void +pvclock_init(struct pvclock *pvc, device_t dev, const char *tc_name, + int tc_quality, u_int tc_flags) +{ + KASSERT(((uintptr_t)pvc->timeinfos & PAGE_MASK) == 0, + ("Specified time info page(s) address is not page-aligned.")); + + /* Set up timecounter and timecounter-supporting members: */ + pvc->tc.tc_get_timecount = pvclock_tc_get_timecount; + pvc->tc.tc_poll_pps = NULL; + pvc->tc.tc_counter_mask = ~0U; + pvc->tc.tc_frequency = 1000000000ULL; + pvc->tc.tc_name = tc_name; + pvc->tc.tc_quality = tc_quality; + pvc->tc.tc_flags = tc_flags; + pvc->tc.tc_priv = pvc; + pvc->tc.tc_fill_vdso_timehands = NULL; +#ifdef COMPAT_FREEBSD32 + pvc->tc.tc_fill_vdso_timehands32 = NULL; +#endif + + /* Register timecounter: */ + tc_init(&pvc->tc); + + /* + * Register wallclock: + * The RTC registration API expects a resolution in microseconds; + * pvclock's 1ns resolution is rounded up to 1us. + */ + clock_register(dev, 1); +} + +int +pvclock_destroy(struct pvclock *pvc) +{ + /* + * Not currently possible since there is no teardown counterpart of + * 'tc_init()'. + */ + return (EBUSY); } From nobody Tue Oct 12 16:01:45 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 662D917FE8B7; Tue, 12 Oct 2021 16:01:47 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HTL563Vwkz4SHH; Tue, 12 Oct 2021 16:01:46 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 0A19C173D5; Tue, 12 Oct 2021 16:01: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 19CG1jdm074234; Tue, 12 Oct 2021 16:01:45 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19CG1jG7074233; Tue, 12 Oct 2021 16:01:45 GMT (envelope-from git) Date: Tue, 12 Oct 2021 16:01:45 GMT Message-Id: <202110121601.19CG1jG7074233@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: 6fa88a627d5e - stable/12 - kvm_clock: KVM paravirtual clock support List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 6fa88a627d5e9d290022b6f463effc99f3df8ee2 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=6fa88a627d5e9d290022b6f463effc99f3df8ee2 commit 6fa88a627d5e9d290022b6f463effc99f3df8ee2 Author: Adam Fenn AuthorDate: 2021-08-04 15:42:48 +0000 Commit: Konstantin Belousov CommitDate: 2021-10-12 16:01:26 +0000 kvm_clock: KVM paravirtual clock support Add support for the KVM paravirtual clock device. Sponsored by: Juniper Networks, Inc. Sponsored by: Klara, Inc. Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D29733 (cherry picked from commit 6c69c6bb4c7ffde48b130df707799d4eca21ca9f) --- sys/amd64/conf/GENERIC | 3 + sys/amd64/conf/MINIMAL | 3 + sys/amd64/conf/NOTES | 3 + sys/conf/files.amd64 | 3 +- sys/conf/files.i386 | 3 +- sys/dev/kvm_clock/kvm_clock.c | 240 ++++++++++++++++++++++++++++++++++++++++++ sys/i386/conf/GENERIC | 3 + sys/i386/conf/NOTES | 3 + sys/x86/include/kvm.h | 79 ++++++++++++++ 9 files changed, 338 insertions(+), 2 deletions(-) diff --git a/sys/amd64/conf/GENERIC b/sys/amd64/conf/GENERIC index 0784544c9c7d..84912e695262 100644 --- a/sys/amd64/conf/GENERIC +++ b/sys/amd64/conf/GENERIC @@ -362,6 +362,9 @@ device virtio_blk # VirtIO Block device device virtio_scsi # VirtIO SCSI device device virtio_balloon # VirtIO Memory Balloon device +# Linux KVM paravirtualization support +device kvm_clock # KVM paravirtual clock driver + # HyperV drivers and enhancement support device hyperv # HyperV drivers diff --git a/sys/amd64/conf/MINIMAL b/sys/amd64/conf/MINIMAL index 7c035e871e79..97a97aacff77 100644 --- a/sys/amd64/conf/MINIMAL +++ b/sys/amd64/conf/MINIMAL @@ -133,6 +133,9 @@ device gif # IPv6 and IPv4 tunneling # Note that 'bpf' is required for DHCP. device bpf # Berkeley packet filter +# Linux KVM paravirtualization support +device kvm_clock # KVM paravirtual clock driver + # Xen HVM Guest Optimizations # NOTE: XENHVM depends on xenpci. They must be added or removed together. options XENHVM # Xen HVM kernel infrastructure diff --git a/sys/amd64/conf/NOTES b/sys/amd64/conf/NOTES index 0b949acdc4a3..abf4397787cd 100644 --- a/sys/amd64/conf/NOTES +++ b/sys/amd64/conf/NOTES @@ -527,6 +527,9 @@ device virtio_balloon # VirtIO Memory Balloon device device virtio_random # VirtIO Entropy device device virtio_console # VirtIO Console device +# Linux KVM paravirtualization support +device kvm_clock # KVM paravirtual clock driver + # Microsoft Hyper-V enhancement support device hyperv # HyperV drivers diff --git a/sys/conf/files.amd64 b/sys/conf/files.amd64 index ad698de09fe7..425abcd8b4c7 100644 --- a/sys/conf/files.amd64 +++ b/sys/conf/files.amd64 @@ -398,6 +398,7 @@ dev/hyperv/vmbus/vmbus_res.c optional hyperv dev/hyperv/vmbus/vmbus_xact.c optional hyperv dev/hyperv/vmbus/amd64/hyperv_machdep.c optional hyperv dev/hyperv/vmbus/amd64/vmbus_vector.S optional hyperv +dev/kvm_clock/kvm_clock.c optional kvm_clock dev/nctgpio/nctgpio.c optional nctgpio dev/nfe/if_nfe.c optional nfe pci dev/ntb/if_ntb/if_ntb.c optional if_ntb @@ -819,7 +820,7 @@ x86/x86/mp_x86.c optional smp x86/x86/mp_watchdog.c optional mp_watchdog smp x86/x86/msi.c optional pci x86/x86/nexus.c standard -x86/x86/pvclock.c optional xenhvm +x86/x86/pvclock.c optional kvm_clock | xenhvm x86/x86/stack_machdep.c optional ddb | stack x86/x86/tsc.c standard x86/x86/ucode.c standard diff --git a/sys/conf/files.i386 b/sys/conf/files.i386 index 934c72c87044..4bb09402791a 100644 --- a/sys/conf/files.i386 +++ b/sys/conf/files.i386 @@ -285,6 +285,7 @@ dev/ipmi/ipmi_ssif.c optional ipmi smbus dev/ipmi/ipmi_pci.c optional ipmi pci dev/ipmi/ipmi_linux.c optional ipmi compat_linux dev/itwd/itwd.c optional itwd +dev/kvm_clock/kvm_clock.c optional kvm_clock dev/le/if_le_isa.c optional le isa dev/mse/mse.c optional mse dev/mse/mse_isa.c optional mse isa @@ -635,7 +636,7 @@ x86/x86/nexus.c standard x86/x86/stack_machdep.c optional ddb | stack x86/x86/tsc.c standard x86/x86/ucode.c standard -x86/x86/pvclock.c optional xenhvm +x86/x86/pvclock.c optional kvm_clock | xenhvm x86/x86/delay.c standard x86/xen/hvm.c optional xenhvm x86/xen/xen_intr.c optional xenhvm diff --git a/sys/dev/kvm_clock/kvm_clock.c b/sys/dev/kvm_clock/kvm_clock.c new file mode 100644 index 000000000000..1a76432e417d --- /dev/null +++ b/sys/dev/kvm_clock/kvm_clock.c @@ -0,0 +1,240 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2014 Bryan Venteicher + * Copyright (c) 2021 Mathieu Chouquet-Stringer + * Copyright (c) 2021 Juniper Networks, Inc. + * Copyright (c) 2021 Klara, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +/* + * Linux KVM paravirtual clock support + * + * References: + * - [1] https://www.kernel.org/doc/html/latest/virt/kvm/cpuid.html + * - [2] https://www.kernel.org/doc/html/latest/virt/kvm/msr.html + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include + +#include "clock_if.h" + +#define KVM_CLOCK_DEVNAME "kvmclock" +/* + * Note: Chosen to be (1) above HPET's value (always 950), (2) above the TSC's + * default value of 800, and (3) below the TSC's value when it supports the + * "Invariant TSC" feature and is believed to be synchronized across all CPUs. + */ +#define KVM_CLOCK_TC_QUALITY 975 + +struct kvm_clock_softc { + struct pvclock pvc; + struct pvclock_wall_clock wc; + struct pvclock_vcpu_time_info *timeinfos; + u_int msr_tc; + u_int msr_wc; +}; + +static devclass_t kvm_clock_devclass; + +static struct pvclock_wall_clock *kvm_clock_get_wallclock(void *arg); +static void kvm_clock_system_time_enable(struct kvm_clock_softc *sc); +static void kvm_clock_system_time_enable_pcpu(void *arg); + +static struct pvclock_wall_clock * +kvm_clock_get_wallclock(void *arg) +{ + struct kvm_clock_softc *sc = arg; + + wrmsr(sc->msr_wc, vtophys(&sc->wc)); + return (&sc->wc); +} + +static void +kvm_clock_system_time_enable(struct kvm_clock_softc *sc) +{ + smp_rendezvous(NULL, kvm_clock_system_time_enable_pcpu, NULL, sc); +} + +static void +kvm_clock_system_time_enable_pcpu(void *arg) +{ + struct kvm_clock_softc *sc = arg; + + /* + * See [2]; the lsb of this MSR is the system time enable bit. + */ + wrmsr(sc->msr_tc, vtophys(&(sc->timeinfos)[curcpu]) | 1); +} + +static void +kvm_clock_identify(driver_t *driver, device_t parent) +{ + u_int regs[4]; + + kvm_cpuid_get_features(regs); + if ((regs[0] & + (KVM_FEATURE_CLOCKSOURCE2 | KVM_FEATURE_CLOCKSOURCE)) == 0) + return; + if (device_find_child(parent, KVM_CLOCK_DEVNAME, -1)) + return; + BUS_ADD_CHILD(parent, 0, KVM_CLOCK_DEVNAME, 0); +} + +static int +kvm_clock_probe(device_t dev) +{ + device_set_desc(dev, "KVM paravirtual clock"); + return (BUS_PROBE_DEFAULT); +} + +static int +kvm_clock_attach(device_t dev) +{ + u_int regs[4]; + struct kvm_clock_softc *sc = device_get_softc(dev); + bool stable_flag_supported; + + /* Process KVM "features" CPUID leaf content: */ + kvm_cpuid_get_features(regs); + if ((regs[0] & KVM_FEATURE_CLOCKSOURCE2) != 0) { + sc->msr_tc = KVM_MSR_SYSTEM_TIME_NEW; + sc->msr_wc = KVM_MSR_WALL_CLOCK_NEW; + } else { + KASSERT((regs[0] & KVM_FEATURE_CLOCKSOURCE) != 0, + ("Clocksource feature flags disappeared since " + "kvm_clock_identify: regs[0] %#0x.", regs[0])); + sc->msr_tc = KVM_MSR_SYSTEM_TIME; + sc->msr_wc = KVM_MSR_WALL_CLOCK; + } + stable_flag_supported = + (regs[0] & KVM_FEATURE_CLOCKSOURCE_STABLE_BIT) != 0; + + /* Set up 'struct pvclock_vcpu_time_info' page(s): */ + sc->timeinfos = (struct pvclock_vcpu_time_info *)kmem_malloc(mp_ncpus * + sizeof(struct pvclock_vcpu_time_info), M_WAITOK | M_ZERO); + kvm_clock_system_time_enable(sc); + + /* + * Init pvclock; register KVM clock wall clock, register KVM clock + * timecounter, and set up the requisite infrastructure for vDSO access + * to this timecounter. + * Regarding 'tc_flags': Since the KVM MSR documentation does not + * specifically discuss suspend/resume scenarios, conservatively + * leave 'TC_FLAGS_SUSPEND_SAFE' cleared and assume that the system + * time must be re-inited in such cases. + */ + sc->pvc.get_wallclock = kvm_clock_get_wallclock; + sc->pvc.get_wallclock_arg = sc; + sc->pvc.timeinfos = sc->timeinfos; + sc->pvc.stable_flag_supported = stable_flag_supported; + pvclock_init(&sc->pvc, dev, KVM_CLOCK_DEVNAME, KVM_CLOCK_TC_QUALITY, 0); + return (0); +} + +static int +kvm_clock_detach(device_t dev) +{ + struct kvm_clock_softc *sc = device_get_softc(dev); + + return (pvclock_destroy(&sc->pvc)); +} + +static int +kvm_clock_suspend(device_t dev) +{ + return (0); +} + +static int +kvm_clock_resume(device_t dev) +{ + /* + * See note in 'kvm_clock_attach()' regarding 'TC_FLAGS_SUSPEND_SAFE'; + * conservatively assume that the system time must be re-inited in + * suspend/resume scenarios. + */ + kvm_clock_system_time_enable(device_get_softc(dev)); + pvclock_resume(); + inittodr(time_second); + return (0); +} + +static int +kvm_clock_gettime(device_t dev, struct timespec *ts) +{ + struct kvm_clock_softc *sc = device_get_softc(dev); + + pvclock_gettime(&sc->pvc, ts); + return (0); +} + +static int +kvm_clock_settime(device_t dev, struct timespec *ts) +{ + /* + * Even though it is not possible to set the KVM clock's wall clock, to + * avoid the possibility of periodic benign error messages from + * 'settime_task_func()', report success rather than, e.g., 'ENODEV'. + */ + return (0); +} + +static device_method_t kvm_clock_methods[] = { + DEVMETHOD(device_identify, kvm_clock_identify), + DEVMETHOD(device_probe, kvm_clock_probe), + DEVMETHOD(device_attach, kvm_clock_attach), + DEVMETHOD(device_detach, kvm_clock_detach), + DEVMETHOD(device_suspend, kvm_clock_suspend), + DEVMETHOD(device_resume, kvm_clock_resume), + /* clock interface */ + DEVMETHOD(clock_gettime, kvm_clock_gettime), + DEVMETHOD(clock_settime, kvm_clock_settime), + + DEVMETHOD_END +}; + +static driver_t kvm_clock_driver = { + KVM_CLOCK_DEVNAME, + kvm_clock_methods, + sizeof(struct kvm_clock_softc), +}; + +DRIVER_MODULE(kvm_clock, nexus, kvm_clock_driver, kvm_clock_devclass, 0, 0); diff --git a/sys/i386/conf/GENERIC b/sys/i386/conf/GENERIC index ecb7529df250..d9cb9ed0776e 100644 --- a/sys/i386/conf/GENERIC +++ b/sys/i386/conf/GENERIC @@ -353,6 +353,9 @@ device virtio_blk # VirtIO Block device device virtio_scsi # VirtIO SCSI device device virtio_balloon # VirtIO Memory Balloon device +# Linux KVM paravirtualization support +device kvm_clock # KVM paravirtual clock driver + # HyperV drivers and enhancement support device hyperv # HyperV drivers diff --git a/sys/i386/conf/NOTES b/sys/i386/conf/NOTES index 211b3a6fa7e8..34561c548622 100644 --- a/sys/i386/conf/NOTES +++ b/sys/i386/conf/NOTES @@ -771,6 +771,9 @@ device virtio_balloon # VirtIO Memory Balloon device device virtio_random # VirtIO Entropy device device virtio_console # VirtIO Console device +# Linux KVM paravirtualization support +device kvm_clock # KVM paravirtual clock driver + device hyperv # HyperV drivers ##################################################################### diff --git a/sys/x86/include/kvm.h b/sys/x86/include/kvm.h new file mode 100644 index 000000000000..b74d45d07981 --- /dev/null +++ b/sys/x86/include/kvm.h @@ -0,0 +1,79 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2014 Bryan Venteicher + * Copyright (c) 2021 Mathieu Chouquet-Stringer + * Copyright (c) 2021 Juniper Networks, Inc. + * Copyright (c) 2021 Klara, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +/* + * Linux KVM paravirtualization: common definitions + * + * References: + * - [1] https://www.kernel.org/doc/html/latest/virt/kvm/cpuid.html + * - [2] https://www.kernel.org/doc/html/latest/virt/kvm/msr.html + */ + +#ifndef _X86_KVM_H_ +#define _X86_KVM_H_ + +#include +#include + +#include + +#define KVM_CPUID_SIGNATURE 0x40000000 +#define KVM_CPUID_FEATURES_LEAF 0x40000001 + +#define KVM_FEATURE_CLOCKSOURCE 0x00000001 +#define KVM_FEATURE_CLOCKSOURCE2 0x00000008 +#define KVM_FEATURE_CLOCKSOURCE_STABLE_BIT 0x01000000 + +/* Deprecated: for the CLOCKSOURCE feature. */ +#define KVM_MSR_WALL_CLOCK 0x11 +#define KVM_MSR_SYSTEM_TIME 0x12 + +#define KVM_MSR_WALL_CLOCK_NEW 0x4b564d00 +#define KVM_MSR_SYSTEM_TIME_NEW 0x4b564d01 + +static inline bool +kvm_cpuid_features_leaf_supported(void) +{ + return (vm_guest == VM_GUEST_KVM && + KVM_CPUID_FEATURES_LEAF <= hv_high); +} + +static inline void +kvm_cpuid_get_features(u_int *regs) +{ + if (!kvm_cpuid_features_leaf_supported()) + regs[0] = regs[1] = regs[2] = regs[3] = 0; + else + do_cpuid(KVM_CPUID_FEATURES_LEAF, regs); +} + +#endif /* !_X86_KVM_H_ */ From nobody Tue Oct 12 16:01:46 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 7AAC517FEA96; Tue, 12 Oct 2021 16:01:48 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HTL572frvz4SBl; Tue, 12 Oct 2021 16:01:47 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 1F8AD17788; Tue, 12 Oct 2021 16:01:47 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19CG1l84075387; Tue, 12 Oct 2021 16:01:47 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19CG1k0Z075375; Tue, 12 Oct 2021 16:01:46 GMT (envelope-from git) Date: Tue, 12 Oct 2021 16:01:46 GMT Message-Id: <202110121601.19CG1k0Z075375@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: 4b34c91973dd - stable/12 - pvclock: Add vDSO support List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 4b34c91973ddaf594bbb192f84e421598a1b39be Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=4b34c91973ddaf594bbb192f84e421598a1b39be commit 4b34c91973ddaf594bbb192f84e421598a1b39be Author: Adam Fenn AuthorDate: 2021-08-07 20:10:04 +0000 Commit: Konstantin Belousov CommitDate: 2021-10-12 16:01:26 +0000 pvclock: Add vDSO support Add vDSO support for timekeeping devices that support the KVM/XEN paravirtual clock API. Also, expose, in the userspace-accessible '', definitions that will be needed by 'libc' to support 'VDSO_TH_ALGO_X86_PVCLK'. Sponsored by: Juniper Networks, Inc. Sponsored by: Klara, Inc. Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D31418 (cherry picked from commit d4b2d3035a23d5dc468d41151487a8299bf45cdc) --- sys/dev/acpica/acpi_hpet.c | 4 + sys/dev/hyperv/vmbus/amd64/hyperv_machdep.c | 2 + sys/x86/include/pvclock.h | 62 +++++++++++ sys/x86/include/vdso.h | 5 +- sys/x86/x86/pvclock.c | 165 +++++++++++++++++++--------- sys/x86/x86/tsc.c | 4 + 6 files changed, 188 insertions(+), 54 deletions(-) diff --git a/sys/dev/acpica/acpi_hpet.c b/sys/dev/acpica/acpi_hpet.c index fcb5632d896a..897867a59b35 100644 --- a/sys/dev/acpica/acpi_hpet.c +++ b/sys/dev/acpica/acpi_hpet.c @@ -156,6 +156,8 @@ hpet_vdso_timehands(struct vdso_timehands *vdso_th, struct timecounter *tc) vdso_th->th_algo = VDSO_TH_ALGO_X86_HPET; vdso_th->th_x86_shift = 0; vdso_th->th_x86_hpet_idx = device_get_unit(sc->dev); + vdso_th->th_x86_pvc_last_systime = 0; + vdso_th->th_x86_pvc_stable_mask = 0; bzero(vdso_th->th_res, sizeof(vdso_th->th_res)); return (sc->mmap_allow != 0); } @@ -171,6 +173,8 @@ hpet_vdso_timehands32(struct vdso_timehands32 *vdso_th32, vdso_th32->th_algo = VDSO_TH_ALGO_X86_HPET; vdso_th32->th_x86_shift = 0; vdso_th32->th_x86_hpet_idx = device_get_unit(sc->dev); + vdso_th32->th_x86_pvc_last_systime = 0; + vdso_th32->th_x86_pvc_stable_mask = 0; bzero(vdso_th32->th_res, sizeof(vdso_th32->th_res)); return (sc->mmap_allow != 0); } diff --git a/sys/dev/hyperv/vmbus/amd64/hyperv_machdep.c b/sys/dev/hyperv/vmbus/amd64/hyperv_machdep.c index c08098138805..11d549dc18d2 100644 --- a/sys/dev/hyperv/vmbus/amd64/hyperv_machdep.c +++ b/sys/dev/hyperv/vmbus/amd64/hyperv_machdep.c @@ -128,6 +128,8 @@ hyperv_tsc_vdso_timehands(struct vdso_timehands *vdso_th, vdso_th->th_algo = VDSO_TH_ALGO_X86_HVTSC; vdso_th->th_x86_shift = 0; vdso_th->th_x86_hpet_idx = 0; + vdso_th->th_x86_pvc_last_systime = 0; + vdso_th->th_x86_pvc_stable_mask = 0; bzero(vdso_th->th_res, sizeof(vdso_th->th_res)); return (1); } diff --git a/sys/x86/include/pvclock.h b/sys/x86/include/pvclock.h index 399017039dd0..023acdb80d9c 100644 --- a/sys/x86/include/pvclock.h +++ b/sys/x86/include/pvclock.h @@ -30,7 +30,12 @@ #define X86_PVCLOCK #include + +#ifdef _KERNEL #include +#endif /* _KERNEL */ + +#define PVCLOCK_CDEVNAME "pvclock" struct pvclock_vcpu_time_info { uint32_t version; @@ -46,6 +51,59 @@ struct pvclock_vcpu_time_info { #define PVCLOCK_FLAG_TSC_STABLE 0x01 #define PVCLOCK_FLAG_GUEST_PASUED 0x02 +/* + * Scale a 64-bit delta by scaling and multiplying by a 32-bit fraction, + * yielding a 64-bit result. + */ +static inline uint64_t +pvclock_scale_delta(uint64_t delta, uint32_t mul_frac, int shift) +{ + uint64_t product; + + if (shift < 0) + delta >>= -shift; + else + delta <<= shift; +#if defined(__i386__) + { + uint32_t tmp1, tmp2; + + /** + * For i386, the formula looks like: + * + * lower = (mul_frac * (delta & UINT_MAX)) >> 32 + * upper = mul_frac * (delta >> 32) + * product = lower + upper + */ + __asm__ ( + "mul %5 ; " + "mov %4,%%eax ; " + "mov %%edx,%4 ; " + "mul %5 ; " + "xor %5,%5 ; " + "add %4,%%eax ; " + "adc %5,%%edx ; " + : "=A" (product), "=r" (tmp1), "=r" (tmp2) + : "a" ((uint32_t)delta), "1" ((uint32_t)(delta >> 32)), + "2" (mul_frac) ); + } +#elif defined(__amd64__) + { + unsigned long tmp; + + __asm__ ( + "mulq %[mul_frac] ; shrd $32, %[hi], %[lo]" + : [lo]"=a" (product), [hi]"=d" (tmp) + : "0" (delta), [mul_frac]"rm"((uint64_t)mul_frac)); + } +#else +#error "pvclock: unsupported x86 architecture?" +#endif + return (product); +} + +#ifdef _KERNEL + typedef struct pvclock_wall_clock *pvclock_get_wallclock_t(void *arg); struct pvclock_wall_clock { @@ -62,7 +120,9 @@ struct pvclock { bool stable_flag_supported; /* Private; initialized by the 'pvclock' API: */ + bool vdso_force_unstable; struct timecounter tc; + struct cdev *cdev; }; /* @@ -81,4 +141,6 @@ void pvclock_init(struct pvclock *pvc, device_t dev, void pvclock_gettime(struct pvclock *pvc, struct timespec *ts); int pvclock_destroy(struct pvclock *pvc); +#endif /* _KERNEL */ + #endif diff --git a/sys/x86/include/vdso.h b/sys/x86/include/vdso.h index 97972c660dde..ace63cbe9f62 100644 --- a/sys/x86/include/vdso.h +++ b/sys/x86/include/vdso.h @@ -37,11 +37,14 @@ #define VDSO_TIMEHANDS_MD \ uint32_t th_x86_shift; \ uint32_t th_x86_hpet_idx; \ - uint32_t th_res[6]; + uint64_t th_x86_pvc_last_systime;\ + uint8_t th_x86_pvc_stable_mask; \ + uint8_t th_res[15]; #define VDSO_TH_ALGO_X86_TSC VDSO_TH_ALGO_1 #define VDSO_TH_ALGO_X86_HPET VDSO_TH_ALGO_2 #define VDSO_TH_ALGO_X86_HVTSC VDSO_TH_ALGO_3 /* Hyper-V ref. TSC */ +#define VDSO_TH_ALGO_X86_PVCLK VDSO_TH_ALGO_4 /* KVM/XEN paravirtual clock */ #ifdef _KERNEL #ifdef COMPAT_FREEBSD32 diff --git a/sys/x86/x86/pvclock.c b/sys/x86/x86/pvclock.c index e0ad65d906b8..e13366bd4bbd 100644 --- a/sys/x86/x86/pvclock.c +++ b/sys/x86/x86/pvclock.c @@ -31,11 +31,22 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include +#include +#include #include +#include #include +#include +#include +#include + +#include +#include #include +#include #include #include @@ -54,6 +65,22 @@ static void pvclock_read_time_info( static void pvclock_read_wall_clock(struct pvclock_wall_clock *wc, struct timespec *ts); static u_int pvclock_tc_get_timecount(struct timecounter *tc); +static uint32_t pvclock_tc_vdso_timehands( + struct vdso_timehands *vdso_th, struct timecounter *tc); +#ifdef COMPAT_FREEBSD32 +static uint32_t pvclock_tc_vdso_timehands32( + struct vdso_timehands32 *vdso_th, struct timecounter *tc); +#endif + +static d_open_t pvclock_cdev_open; +static d_mmap_t pvclock_cdev_mmap; + +static struct cdevsw pvclock_cdev_cdevsw = { + .d_version = D_VERSION, + .d_name = PVCLOCK_CDEVNAME, + .d_open = pvclock_cdev_open, + .d_mmap = pvclock_cdev_mmap, +}; void pvclock_resume(void) @@ -74,57 +101,6 @@ pvclock_tsc_freq(struct pvclock_vcpu_time_info *ti) return (freq); } -/* - * Scale a 64-bit delta by scaling and multiplying by a 32-bit fraction, - * yielding a 64-bit result. - */ -static inline uint64_t -pvclock_scale_delta(uint64_t delta, uint32_t mul_frac, int shift) -{ - uint64_t product; - - if (shift < 0) - delta >>= -shift; - else - delta <<= shift; -#if defined(__i386__) - { - uint32_t tmp1, tmp2; - - /** - * For i386, the formula looks like: - * - * lower = (mul_frac * (delta & UINT_MAX)) >> 32 - * upper = mul_frac * (delta >> 32) - * product = lower + upper - */ - __asm__ ( - "mul %5 ; " - "mov %4,%%eax ; " - "mov %%edx,%4 ; " - "mul %5 ; " - "xor %5,%5 ; " - "add %4,%%eax ; " - "adc %5,%%edx ; " - : "=A" (product), "=r" (tmp1), "=r" (tmp2) - : "a" ((uint32_t)delta), "1" ((uint32_t)(delta >> 32)), - "2" (mul_frac) ); - } -#elif defined(__amd64__) - { - unsigned long tmp; - - __asm__ ( - "mulq %[mul_frac] ; shrd $32, %[hi], %[lo]" - : [lo]"=a" (product), [hi]"=d" (tmp) - : "0" (delta), [mul_frac]"rm"((uint64_t)mul_frac)); - } -#else -#error "pvclock: unsupported x86 architecture?" -#endif - return (product); -} - static void pvclock_read_time_info(struct pvclock_vcpu_time_info *ti, uint64_t *ns, uint8_t *flags) @@ -213,6 +189,27 @@ pvclock_get_wallclock(struct pvclock_wall_clock *wc, struct timespec *ts) pvclock_read_wall_clock(wc, ts); } +static int +pvclock_cdev_open(struct cdev *dev, int oflags, int devtype, struct thread *td) +{ + if (oflags & FWRITE) + return (EPERM); + return (0); +} + +static int +pvclock_cdev_mmap(struct cdev *dev, vm_ooffset_t offset, vm_paddr_t *paddr, + int nprot, vm_memattr_t *memattr) +{ + if (offset >= mp_ncpus * sizeof(struct pvclock_vcpu_time_info)) + return (EINVAL); + if (nprot != PROT_READ) + return (EACCES); + *paddr = vtophys((uintptr_t)dev->si_drv1 + offset); + *memattr = VM_MEMATTR_DEFAULT; + return (0); +} + static u_int pvclock_tc_get_timecount(struct timecounter *tc) { @@ -221,6 +218,42 @@ pvclock_tc_get_timecount(struct timecounter *tc) return (pvclock_getsystime(pvc) & UINT_MAX); } +static uint32_t +pvclock_tc_vdso_timehands(struct vdso_timehands *vdso_th, + struct timecounter *tc) +{ + struct pvclock *pvc = tc->tc_priv; + + vdso_th->th_algo = VDSO_TH_ALGO_X86_PVCLK; + vdso_th->th_x86_shift = 0; + vdso_th->th_x86_hpet_idx = 0; + vdso_th->th_x86_pvc_last_systime = + atomic_load_acq_64(&pvclock_last_systime); + vdso_th->th_x86_pvc_stable_mask = !pvc->vdso_force_unstable && + pvc->stable_flag_supported ? PVCLOCK_FLAG_TSC_STABLE : 0; + bzero(vdso_th->th_res, sizeof(vdso_th->th_res)); + return (pvc->cdev != NULL && amd_feature & AMDID_RDTSCP); +} + +#ifdef COMPAT_FREEBSD32 +static uint32_t +pvclock_tc_vdso_timehands32(struct vdso_timehands32 *vdso_th, + struct timecounter *tc) +{ + struct pvclock *pvc = tc->tc_priv; + + vdso_th->th_algo = VDSO_TH_ALGO_X86_PVCLK; + vdso_th->th_x86_shift = 0; + vdso_th->th_x86_hpet_idx = 0; + vdso_th->th_x86_pvc_last_systime = + atomic_load_acq_64(&pvclock_last_systime); + vdso_th->th_x86_pvc_stable_mask = !pvc->vdso_force_unstable && + pvc->stable_flag_supported ? PVCLOCK_FLAG_TSC_STABLE : 0; + bzero(vdso_th->th_res, sizeof(vdso_th->th_res)); + return (pvc->cdev != NULL && amd_feature & AMDID_RDTSCP); +} +#endif + void pvclock_gettime(struct pvclock *pvc, struct timespec *ts) { @@ -238,9 +271,19 @@ void pvclock_init(struct pvclock *pvc, device_t dev, const char *tc_name, int tc_quality, u_int tc_flags) { + struct make_dev_args mda; + int err; + KASSERT(((uintptr_t)pvc->timeinfos & PAGE_MASK) == 0, ("Specified time info page(s) address is not page-aligned.")); + /* Set up vDSO stable-flag suppression test facility: */ + pvc->vdso_force_unstable = false; + SYSCTL_ADD_BOOL(device_get_sysctl_ctx(dev), + SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), OID_AUTO, + "vdso_force_unstable", CTLFLAG_RW, &pvc->vdso_force_unstable, 0, + "Forcibly deassert stable flag in vDSO codepath"); + /* Set up timecounter and timecounter-supporting members: */ pvc->tc.tc_get_timecount = pvclock_tc_get_timecount; pvc->tc.tc_poll_pps = NULL; @@ -250,11 +293,27 @@ pvclock_init(struct pvclock *pvc, device_t dev, const char *tc_name, pvc->tc.tc_quality = tc_quality; pvc->tc.tc_flags = tc_flags; pvc->tc.tc_priv = pvc; - pvc->tc.tc_fill_vdso_timehands = NULL; + pvc->tc.tc_fill_vdso_timehands = pvclock_tc_vdso_timehands; #ifdef COMPAT_FREEBSD32 - pvc->tc.tc_fill_vdso_timehands32 = NULL; + pvc->tc.tc_fill_vdso_timehands32 = pvclock_tc_vdso_timehands32; #endif + /* Set up cdev for userspace mmapping of vCPU 0 time info page: */ + make_dev_args_init(&mda); + mda.mda_devsw = &pvclock_cdev_cdevsw; + mda.mda_uid = UID_ROOT; + mda.mda_gid = GID_WHEEL; + mda.mda_mode = 0444; + mda.mda_si_drv1 = pvc->timeinfos; + err = make_dev_s(&mda, &pvc->cdev, PVCLOCK_CDEVNAME); + if (err != 0) { + device_printf(dev, "Could not create /dev/%s, error %d. Fast " + "time of day will be unavailable for this timecounter.\n", + PVCLOCK_CDEVNAME, err); + KASSERT(pvc->cdev == NULL, + ("Failed make_dev_s() unexpectedly inited cdev.")); + } + /* Register timecounter: */ tc_init(&pvc->tc); diff --git a/sys/x86/x86/tsc.c b/sys/x86/x86/tsc.c index f14e0707651c..5b3934e7bb9d 100644 --- a/sys/x86/x86/tsc.c +++ b/sys/x86/x86/tsc.c @@ -864,6 +864,8 @@ x86_tsc_vdso_timehands(struct vdso_timehands *vdso_th, struct timecounter *tc) vdso_th->th_algo = VDSO_TH_ALGO_X86_TSC; vdso_th->th_x86_shift = (int)(intptr_t)tc->tc_priv; vdso_th->th_x86_hpet_idx = 0xffffffff; + vdso_th->th_x86_pvc_last_systime = 0; + vdso_th->th_x86_pvc_stable_mask = 0; bzero(vdso_th->th_res, sizeof(vdso_th->th_res)); return (1); } @@ -877,6 +879,8 @@ x86_tsc_vdso_timehands32(struct vdso_timehands32 *vdso_th32, vdso_th32->th_algo = VDSO_TH_ALGO_X86_TSC; vdso_th32->th_x86_shift = (int)(intptr_t)tc->tc_priv; vdso_th32->th_x86_hpet_idx = 0xffffffff; + vdso_th32->th_x86_pvc_last_systime = 0; + vdso_th32->th_x86_pvc_stable_mask = 0; bzero(vdso_th32->th_res, sizeof(vdso_th32->th_res)); return (1); } From nobody Tue Oct 12 16:01:48 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 24E8E17FEA48; Tue, 12 Oct 2021 16:01:49 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HTL5860v1z4S1t; Tue, 12 Oct 2021 16:01:48 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 3855717802; Tue, 12 Oct 2021 16:01:48 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19CG1m7b076604; Tue, 12 Oct 2021 16:01:48 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19CG1msR076597; Tue, 12 Oct 2021 16:01:48 GMT (envelope-from git) Date: Tue, 12 Oct 2021 16:01:48 GMT Message-Id: <202110121601.19CG1msR076597@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: 2a16b0f333d4 - stable/12 - libc: vDSO timekeeping: Add pvclock support List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 2a16b0f333d47430c9d932aafa7d2af46f475fd4 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=2a16b0f333d47430c9d932aafa7d2af46f475fd4 commit 2a16b0f333d47430c9d932aafa7d2af46f475fd4 Author: Adam Fenn AuthorDate: 2021-08-07 20:11:29 +0000 Commit: Konstantin Belousov CommitDate: 2021-10-12 16:01:26 +0000 libc: vDSO timekeeping: Add pvclock support Add support for 'VDSO_TH_ALGO_X86_PVCLK'; add vDSO-based timekeeping for devices that support the KVM/XEN paravirtual clock API. Sponsored by: Juniper Networks, Inc. Sponsored by: Klara, Inc. Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D31418 (cherry picked from commit a3d932dfef5edc9d1c947b02fb93a64d63a291cb) --- lib/libc/x86/sys/__vdso_gettc.c | 62 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/lib/libc/x86/sys/__vdso_gettc.c b/lib/libc/x86/sys/__vdso_gettc.c index 1f3e8133040f..303b2c4e771c 100644 --- a/lib/libc/x86/sys/__vdso_gettc.c +++ b/lib/libc/x86/sys/__vdso_gettc.c @@ -45,6 +45,7 @@ __FBSDID("$FreeBSD$"); #include "un-namespace.h" #include #include +#include #include #include #ifdef WANT_HYPERV @@ -312,6 +313,61 @@ __vdso_hyperv_tsc(struct hyperv_reftsc *tsc_ref, u_int *tc) #endif /* WANT_HYPERV */ +static struct pvclock_vcpu_time_info *pvclock_timeinfos; + +static int +__vdso_pvclock_gettc(const struct vdso_timehands *th, u_int *tc) +{ + uint64_t delta, ns, tsc; + struct pvclock_vcpu_time_info *ti; + uint32_t cpuid_ti, cpuid_tsc, version; + bool stable; + + do { + ti = &pvclock_timeinfos[0]; + version = atomic_load_acq_32(&ti->version); + stable = (ti->flags & th->th_x86_pvc_stable_mask) != 0; + if (stable) { + tsc = rdtscp(); + } else { + (void)rdtscp_aux(&cpuid_ti); + ti = &pvclock_timeinfos[cpuid_ti]; + version = atomic_load_acq_32(&ti->version); + tsc = rdtscp_aux(&cpuid_tsc); + } + delta = tsc - ti->tsc_timestamp; + ns = ti->system_time + pvclock_scale_delta(delta, + ti->tsc_to_system_mul, ti->tsc_shift); + atomic_thread_fence_acq(); + } while ((ti->version & 1) != 0 || ti->version != version || + (!stable && cpuid_ti != cpuid_tsc)); + *tc = MAX(ns, th->th_x86_pvc_last_systime); + return (0); +} + +static void +__vdso_init_pvclock_timeinfos(void) +{ + struct pvclock_vcpu_time_info *timeinfos; + size_t len; + int fd, ncpus; + unsigned int mode; + + timeinfos = MAP_FAILED; + if (_elf_aux_info(AT_NCPUS, &ncpus, sizeof(ncpus)) != 0 || + (cap_getmode(&mode) == 0 && mode != 0) || + (fd = _open("/dev/" PVCLOCK_CDEVNAME, O_RDONLY | O_CLOEXEC)) < 0) + goto leave; + len = ncpus * sizeof(*pvclock_timeinfos); + timeinfos = mmap(NULL, len, PROT_READ, MAP_SHARED, fd, 0); + _close(fd); +leave: + if (atomic_cmpset_rel_ptr( + (volatile uintptr_t *)&pvclock_timeinfos, (uintptr_t)NULL, + (uintptr_t)timeinfos) == 0 && timeinfos != MAP_FAILED) + (void)munmap((void *)timeinfos, len); +} + #pragma weak __vdso_gettc int __vdso_gettc(const struct vdso_timehands *th, u_int *tc) @@ -347,6 +403,12 @@ __vdso_gettc(const struct vdso_timehands *th, u_int *tc) return (ENOSYS); return (__vdso_hyperv_tsc(hyperv_ref_tsc, tc)); #endif + case VDSO_TH_ALGO_X86_PVCLK: + if (pvclock_timeinfos == NULL) + __vdso_init_pvclock_timeinfos(); + if (pvclock_timeinfos == MAP_FAILED) + return (ENOSYS); + return (__vdso_pvclock_gettc(th, tc)); default: return (ENOSYS); } From nobody Tue Oct 12 16:32:04 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 2024F17F76FE; Tue, 12 Oct 2021 16:32: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 4HTLm464xbz4gg5; Tue, 12 Oct 2021 16:32: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 991F017C94; Tue, 12 Oct 2021 16:32: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 19CGW4tf016848; Tue, 12 Oct 2021 16:32:04 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19CGW44q016847; Tue, 12 Oct 2021 16:32:04 GMT (envelope-from git) Date: Tue, 12 Oct 2021 16:32:04 GMT Message-Id: <202110121632.19CGW44q016847@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Ed Maste Subject: git: 5e6d12734846 - stable/12 - OpenSSH: cherry-pick "need initgroups() before setresgid()" List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: emaste X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 5e6d12734846ae20bd31ec514d3a56672202f1b4 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=5e6d12734846ae20bd31ec514d3a56672202f1b4 commit 5e6d12734846ae20bd31ec514d3a56672202f1b4 Author: Ed Maste AuthorDate: 2021-10-12 00:47:39 +0000 Commit: Ed Maste CommitDate: 2021-10-12 16:31:49 +0000 OpenSSH: cherry-pick "need initgroups() before setresgid()" From openssh-portable commits f3cbe43e28fe and bf944e3794ef, backported to OpenSSH 7.9p1 on stable/13 [and stable/12]. Reviewed by: delphij Security: CVE-2021-41617 Differential Revision: https://reviews.freebsd.org/D32460 (cherry picked from commit 172fa4aa7577915bf5ace5783251821d3774dc05) (cherry picked from commit be74669a2f62915f84b844bb00dd2767c60539fe) --- crypto/openssh/auth.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/crypto/openssh/auth.c b/crypto/openssh/auth.c index a2e1fa10ce45..65183d456490 100644 --- a/crypto/openssh/auth.c +++ b/crypto/openssh/auth.c @@ -39,6 +39,7 @@ __RCSID("$FreeBSD$"); # include #endif #include +#include #ifdef HAVE_LOGIN_H #include #endif @@ -983,6 +984,13 @@ subprocess(const char *tag, struct passwd *pw, const char *command, } closefrom(STDERR_FILENO + 1); + if (geteuid() == 0 && + initgroups(pw->pw_name, pw->pw_gid) == -1) { + error("%s: initgroups(%s, %u): %s", tag, + pw->pw_name, (u_int)pw->pw_gid, strerror(errno)); + _exit(1); + } + /* Don't use permanently_set_uid() here to avoid fatal() */ if (setresgid(pw->pw_gid, pw->pw_gid, pw->pw_gid) != 0) { error("%s: setresgid %u: %s", tag, (u_int)pw->pw_gid, From nobody Tue Oct 12 16:37:33 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 1AD2517F9118; Tue, 12 Oct 2021 16:37: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 4HTLtQ0F5Cz4jDV; Tue, 12 Oct 2021 16:37: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 DC07F17A52; Tue, 12 Oct 2021 16:37: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 19CGbXr4017767; Tue, 12 Oct 2021 16:37:33 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19CGbX2r017766; Tue, 12 Oct 2021 16:37:33 GMT (envelope-from git) Date: Tue, 12 Oct 2021 16:37:33 GMT Message-Id: <202110121637.19CGbX2r017766@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Alan Somers Subject: git: e51bbeaa6fe9 - stable/12 - sbin/mount_fusefs/mount_fusefs.8: Fix typos List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: asomers X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: e51bbeaa6fe9cd0b869e22f9192478da6932e545 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by asomers: URL: https://cgit.FreeBSD.org/src/commit/?id=e51bbeaa6fe9cd0b869e22f9192478da6932e545 commit e51bbeaa6fe9cd0b869e22f9192478da6932e545 Author: Elyes HAOUAS AuthorDate: 2021-10-08 16:44:48 +0000 Commit: Alan Somers CommitDate: 2021-10-12 16:37:04 +0000 sbin/mount_fusefs/mount_fusefs.8: Fix typos "expicitly" --> "explicitly" "uknown" --> "unknown" Signed-off-by: Elyes HAOUAS Pull Request: https://github.com/freebsd/freebsd-src/pull/552 (cherry picked from commit c8a45820e0d94892c1a632d49ccfddd8f559801e) --- sbin/mount_fusefs/mount_fusefs.8 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sbin/mount_fusefs/mount_fusefs.8 b/sbin/mount_fusefs/mount_fusefs.8 index 9f59a25647ce..15542a871905 100644 --- a/sbin/mount_fusefs/mount_fusefs.8 +++ b/sbin/mount_fusefs/mount_fusefs.8 @@ -34,7 +34,7 @@ .\" .\" $FreeBSD$ .\" -.Dd July 31, 2019 +.Dd October 9, 2021 .Dt MOUNT_FUSEFS 8 .Os .Sh NAME @@ -162,7 +162,7 @@ Limit size of read requests to Do not refuse unmounting if there are secondary mounts. .It Cm private Refuse shared mounting of the daemon. -This is the default behaviour, to allow sharing, expicitly use +This is the default behaviour, to allow sharing, explicitly use .Fl o Cm noprivate . .It Cm push_symlinks_in Prefix absolute symlinks with the mountpoint. @@ -293,7 +293,7 @@ option. .It Ev MOUNT_FUSEFS_IGNORE_UNKNOWN If set, .Nm -will ignore uknown mount options. +will ignore unknown mount options. .It Ev MOUNT_FUSEFS_CALL_BY_LIB Adjust behavior to the needs of the FUSE library. Currently it effects help output. From nobody Tue Oct 12 18:18:16 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 8822317FE38C; Tue, 12 Oct 2021 18:18:16 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HTP6c3Q1qz3m2Y; Tue, 12 Oct 2021 18:18:16 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 54DFE192AE; Tue, 12 Oct 2021 18:18:16 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19CIIGq9053278; Tue, 12 Oct 2021 18:18:16 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19CIIGt7053277; Tue, 12 Oct 2021 18:18:16 GMT (envelope-from git) Date: Tue, 12 Oct 2021 18:18:16 GMT Message-Id: <202110121818.19CIIGt7053277@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kevin Bowling Subject: git: 88d064c12188 - stable/13 - ixgbe: Update shared code catchup List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kbowling X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 88d064c121888fecb64ca02995b3375b6eefd28f Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by kbowling (ports committer): URL: https://cgit.FreeBSD.org/src/commit/?id=88d064c121888fecb64ca02995b3375b6eefd28f commit 88d064c121888fecb64ca02995b3375b6eefd28f Author: Kevin Bowling AuthorDate: 2021-10-07 01:43:27 +0000 Commit: Kevin Bowling CommitDate: 2021-10-12 18:18:05 +0000 ixgbe: Update shared code catchup Leftovers from DPDK sync Reviewed by: grehan Obtained from: DPDK MFC after: 5 days Differential Revision: https://reviews.freebsd.org/D31621 (cherry picked from commit 3f66b96d8658f8721e6b1c6f035611bec44675b9) --- sys/dev/ixgbe/ixgbe_82599.c | 5 ++ sys/dev/ixgbe/ixgbe_api.c | 54 ++++++++++++++ sys/dev/ixgbe/ixgbe_api.h | 3 + sys/dev/ixgbe/ixgbe_common.c | 174 ++++++++++++++++++++++++++++++++++++++++++- sys/dev/ixgbe/ixgbe_common.h | 14 +++- sys/dev/ixgbe/ixgbe_dcb.c | 20 ----- sys/dev/ixgbe/ixgbe_mbx.c | 116 ++++++++++++++++++++++++++++- sys/dev/ixgbe/ixgbe_mbx.h | 7 ++ sys/dev/ixgbe/ixgbe_phy.c | 11 ++- sys/dev/ixgbe/ixgbe_phy.h | 2 - sys/dev/ixgbe/ixgbe_type.h | 52 +++++++++++-- sys/dev/ixgbe/ixgbe_vf.c | 4 - sys/dev/ixgbe/ixgbe_x540.c | 2 +- sys/dev/ixgbe/ixgbe_x550.c | 12 ++- 14 files changed, 427 insertions(+), 49 deletions(-) diff --git a/sys/dev/ixgbe/ixgbe_82599.c b/sys/dev/ixgbe/ixgbe_82599.c index 9eb3904a30f9..698602080592 100644 --- a/sys/dev/ixgbe/ixgbe_82599.c +++ b/sys/dev/ixgbe/ixgbe_82599.c @@ -395,6 +395,11 @@ s32 ixgbe_init_ops_82599(struct ixgbe_hw *hw) /* Manageability interface */ mac->ops.set_fw_drv_ver = ixgbe_set_fw_drv_ver_generic; + mac->ops.get_thermal_sensor_data = + ixgbe_get_thermal_sensor_data_generic; + mac->ops.init_thermal_sensor_thresh = + ixgbe_init_thermal_sensor_thresh_generic; + mac->ops.bypass_rw = ixgbe_bypass_rw_generic; mac->ops.bypass_valid_rd = ixgbe_bypass_valid_rd_generic; mac->ops.bypass_set = ixgbe_bypass_set_generic; diff --git a/sys/dev/ixgbe/ixgbe_api.c b/sys/dev/ixgbe/ixgbe_api.c index 5a425f087f1a..87b213a99b0e 100644 --- a/sys/dev/ixgbe/ixgbe_api.c +++ b/sys/dev/ixgbe/ixgbe_api.c @@ -113,6 +113,13 @@ s32 ixgbe_init_shared_code(struct ixgbe_hw *hw) case ixgbe_mac_X550EM_a: status = ixgbe_init_ops_X550EM_a(hw); break; + case ixgbe_mac_82599_vf: + case ixgbe_mac_X540_vf: + case ixgbe_mac_X550_vf: + case ixgbe_mac_X550EM_x_vf: + case ixgbe_mac_X550EM_a_vf: + status = ixgbe_init_ops_vf(hw); + break; default: status = IXGBE_ERR_DEVICE_NOT_SUPPORTED; break; @@ -176,6 +183,15 @@ s32 ixgbe_set_mac_type(struct ixgbe_hw *hw) case IXGBE_DEV_ID_82599_T3_LOM: hw->mac.type = ixgbe_mac_82599EB; break; + case IXGBE_DEV_ID_82599_VF: + case IXGBE_DEV_ID_82599_VF_HV: + hw->mac.type = ixgbe_mac_82599_vf; + break; + case IXGBE_DEV_ID_X540_VF: + case IXGBE_DEV_ID_X540_VF_HV: + hw->mac.type = ixgbe_mac_X540_vf; + hw->mvals = ixgbe_mvals_X540; + break; case IXGBE_DEV_ID_X540T: case IXGBE_DEV_ID_X540T1: case IXGBE_DEV_ID_X540_BYPASS: @@ -210,6 +226,21 @@ s32 ixgbe_set_mac_type(struct ixgbe_hw *hw) hw->mac.type = ixgbe_mac_X550EM_a; hw->mvals = ixgbe_mvals_X550EM_a; break; + case IXGBE_DEV_ID_X550_VF: + case IXGBE_DEV_ID_X550_VF_HV: + hw->mac.type = ixgbe_mac_X550_vf; + hw->mvals = ixgbe_mvals_X550; + break; + case IXGBE_DEV_ID_X550EM_X_VF: + case IXGBE_DEV_ID_X550EM_X_VF_HV: + hw->mac.type = ixgbe_mac_X550EM_x_vf; + hw->mvals = ixgbe_mvals_X550EM_x; + break; + case IXGBE_DEV_ID_X550EM_A_VF: + case IXGBE_DEV_ID_X550EM_A_VF_HV: + hw->mac.type = ixgbe_mac_X550EM_a_vf; + hw->mvals = ixgbe_mvals_X550EM_a; + break; default: ret_val = IXGBE_ERR_DEVICE_NOT_SUPPORTED; ERROR_REPORT2(IXGBE_ERROR_UNSUPPORTED, @@ -1146,6 +1177,29 @@ s32 ixgbe_set_fw_drv_ver(struct ixgbe_hw *hw, u8 maj, u8 min, u8 build, } +/** + * ixgbe_get_thermal_sensor_data - Gathers thermal sensor data + * @hw: pointer to hardware structure + * + * Updates the temperatures in mac.thermal_sensor_data + **/ +s32 ixgbe_get_thermal_sensor_data(struct ixgbe_hw *hw) +{ + return ixgbe_call_func(hw, hw->mac.ops.get_thermal_sensor_data, (hw), + IXGBE_NOT_IMPLEMENTED); +} + +/** + * ixgbe_init_thermal_sensor_thresh - Inits thermal sensor thresholds + * @hw: pointer to hardware structure + * + * Inits the thermal sensor thresholds according to the NVM map + **/ +s32 ixgbe_init_thermal_sensor_thresh(struct ixgbe_hw *hw) +{ + return ixgbe_call_func(hw, hw->mac.ops.init_thermal_sensor_thresh, (hw), + IXGBE_NOT_IMPLEMENTED); +} /** * ixgbe_dmac_config - Configure DMA Coalescing registers. diff --git a/sys/dev/ixgbe/ixgbe_api.h b/sys/dev/ixgbe/ixgbe_api.h index c70f27c6aa2c..7fd300bfe4ee 100644 --- a/sys/dev/ixgbe/ixgbe_api.h +++ b/sys/dev/ixgbe/ixgbe_api.h @@ -49,6 +49,7 @@ extern s32 ixgbe_init_ops_X550(struct ixgbe_hw *hw); extern s32 ixgbe_init_ops_X550EM(struct ixgbe_hw *hw); extern s32 ixgbe_init_ops_X550EM_x(struct ixgbe_hw *hw); extern s32 ixgbe_init_ops_X550EM_a(struct ixgbe_hw *hw); +extern s32 ixgbe_init_ops_vf(struct ixgbe_hw *hw); s32 ixgbe_set_mac_type(struct ixgbe_hw *hw); s32 ixgbe_init_hw(struct ixgbe_hw *hw); @@ -135,6 +136,8 @@ s32 ixgbe_fc_enable(struct ixgbe_hw *hw); s32 ixgbe_setup_fc(struct ixgbe_hw *hw); s32 ixgbe_set_fw_drv_ver(struct ixgbe_hw *hw, u8 maj, u8 min, u8 build, u8 ver, u16 len, char *driver_ver); +s32 ixgbe_get_thermal_sensor_data(struct ixgbe_hw *hw); +s32 ixgbe_init_thermal_sensor_thresh(struct ixgbe_hw *hw); void ixgbe_set_mta(struct ixgbe_hw *hw, u8 *mc_addr); s32 ixgbe_get_phy_firmware_version(struct ixgbe_hw *hw, u16 *firmware_version); diff --git a/sys/dev/ixgbe/ixgbe_common.c b/sys/dev/ixgbe/ixgbe_common.c index 50e18bcba997..0ad538a465ea 100644 --- a/sys/dev/ixgbe/ixgbe_common.c +++ b/sys/dev/ixgbe/ixgbe_common.c @@ -4132,7 +4132,7 @@ s32 ixgbe_clear_vfta_generic(struct ixgbe_hw *hw) for (offset = 0; offset < IXGBE_VLVF_ENTRIES; offset++) { IXGBE_WRITE_REG(hw, IXGBE_VLVF(offset), 0); IXGBE_WRITE_REG(hw, IXGBE_VLVFB(offset * 2), 0); - IXGBE_WRITE_REG(hw, IXGBE_VLVFB((offset * 2) + 1), 0); + IXGBE_WRITE_REG(hw, IXGBE_VLVFB(offset * 2 + 1), 0); } return IXGBE_SUCCESS; @@ -4626,7 +4626,7 @@ s32 ixgbe_host_interface_command(struct ixgbe_hw *hw, u32 *buffer, /* first pull in the header so we know the buffer length */ for (bi = 0; bi < dword_len; bi++) { buffer[bi] = IXGBE_READ_REG_ARRAY(hw, IXGBE_FLEX_MNG, bi); - IXGBE_LE32_TO_CPUS(&buffer[bi]); + IXGBE_LE32_TO_CPUS((uintptr_t)&buffer[bi]); } /* @@ -4662,7 +4662,7 @@ s32 ixgbe_host_interface_command(struct ixgbe_hw *hw, u32 *buffer, /* Pull in the rest of the buffer (bi is where we left off) */ for (; bi <= dword_len; bi++) { buffer[bi] = IXGBE_READ_REG_ARRAY(hw, IXGBE_FLEX_MNG, bi); - IXGBE_LE32_TO_CPUS(&buffer[bi]); + IXGBE_LE32_TO_CPUS((uintptr_t)&buffer[bi]); } rel_out: @@ -4852,6 +4852,174 @@ out: IXGBE_WRITE_REG(hw, IXGBE_HLREG0, hlreg0); } +static const u8 ixgbe_emc_temp_data[4] = { + IXGBE_EMC_INTERNAL_DATA, + IXGBE_EMC_DIODE1_DATA, + IXGBE_EMC_DIODE2_DATA, + IXGBE_EMC_DIODE3_DATA +}; +static const u8 ixgbe_emc_therm_limit[4] = { + IXGBE_EMC_INTERNAL_THERM_LIMIT, + IXGBE_EMC_DIODE1_THERM_LIMIT, + IXGBE_EMC_DIODE2_THERM_LIMIT, + IXGBE_EMC_DIODE3_THERM_LIMIT +}; + +/** + * ixgbe_get_thermal_sensor_data - Gathers thermal sensor data + * @hw: pointer to hardware structure + * + * Returns the thermal sensor data structure + **/ +s32 ixgbe_get_thermal_sensor_data_generic(struct ixgbe_hw *hw) +{ + s32 status = IXGBE_SUCCESS; + u16 ets_offset; + u16 ets_cfg; + u16 ets_sensor; + u8 num_sensors; + u8 sensor_index; + u8 sensor_location; + u8 i; + struct ixgbe_thermal_sensor_data *data = &hw->mac.thermal_sensor_data; + + DEBUGFUNC("ixgbe_get_thermal_sensor_data_generic"); + + /* Only support thermal sensors attached to 82599 physical port 0 */ + if ((hw->mac.type != ixgbe_mac_82599EB) || + (IXGBE_READ_REG(hw, IXGBE_STATUS) & IXGBE_STATUS_LAN_ID_1)) { + status = IXGBE_NOT_IMPLEMENTED; + goto out; + } + + status = hw->eeprom.ops.read(hw, IXGBE_ETS_CFG, &ets_offset); + if (status) + goto out; + + if ((ets_offset == 0x0000) || (ets_offset == 0xFFFF)) { + status = IXGBE_NOT_IMPLEMENTED; + goto out; + } + + status = hw->eeprom.ops.read(hw, ets_offset, &ets_cfg); + if (status) + goto out; + + if (((ets_cfg & IXGBE_ETS_TYPE_MASK) >> IXGBE_ETS_TYPE_SHIFT) + != IXGBE_ETS_TYPE_EMC) { + status = IXGBE_NOT_IMPLEMENTED; + goto out; + } + + num_sensors = (ets_cfg & IXGBE_ETS_NUM_SENSORS_MASK); + if (num_sensors > IXGBE_MAX_SENSORS) + num_sensors = IXGBE_MAX_SENSORS; + + for (i = 0; i < num_sensors; i++) { + status = hw->eeprom.ops.read(hw, (ets_offset + 1 + i), + &ets_sensor); + if (status) + goto out; + + sensor_index = ((ets_sensor & IXGBE_ETS_DATA_INDEX_MASK) >> + IXGBE_ETS_DATA_INDEX_SHIFT); + sensor_location = ((ets_sensor & IXGBE_ETS_DATA_LOC_MASK) >> + IXGBE_ETS_DATA_LOC_SHIFT); + + if (sensor_location != 0) { + status = hw->phy.ops.read_i2c_byte(hw, + ixgbe_emc_temp_data[sensor_index], + IXGBE_I2C_THERMAL_SENSOR_ADDR, + &data->sensor[i].temp); + if (status) + goto out; + } + } +out: + return status; +} + +/** + * ixgbe_init_thermal_sensor_thresh_generic - Inits thermal sensor thresholds + * @hw: pointer to hardware structure + * + * Inits the thermal sensor thresholds according to the NVM map + * and save off the threshold and location values into mac.thermal_sensor_data + **/ +s32 ixgbe_init_thermal_sensor_thresh_generic(struct ixgbe_hw *hw) +{ + s32 status = IXGBE_SUCCESS; + u16 offset; + u16 ets_offset; + u16 ets_cfg; + u16 ets_sensor; + u8 low_thresh_delta; + u8 num_sensors; + u8 sensor_index; + u8 sensor_location; + u8 therm_limit; + u8 i; + struct ixgbe_thermal_sensor_data *data = &hw->mac.thermal_sensor_data; + + DEBUGFUNC("ixgbe_init_thermal_sensor_thresh_generic"); + + memset(data, 0, sizeof(struct ixgbe_thermal_sensor_data)); + + /* Only support thermal sensors attached to 82599 physical port 0 */ + if ((hw->mac.type != ixgbe_mac_82599EB) || + (IXGBE_READ_REG(hw, IXGBE_STATUS) & IXGBE_STATUS_LAN_ID_1)) + return IXGBE_NOT_IMPLEMENTED; + + offset = IXGBE_ETS_CFG; + if (hw->eeprom.ops.read(hw, offset, &ets_offset)) + goto eeprom_err; + if ((ets_offset == 0x0000) || (ets_offset == 0xFFFF)) + return IXGBE_NOT_IMPLEMENTED; + + offset = ets_offset; + if (hw->eeprom.ops.read(hw, offset, &ets_cfg)) + goto eeprom_err; + if (((ets_cfg & IXGBE_ETS_TYPE_MASK) >> IXGBE_ETS_TYPE_SHIFT) + != IXGBE_ETS_TYPE_EMC) + return IXGBE_NOT_IMPLEMENTED; + + low_thresh_delta = ((ets_cfg & IXGBE_ETS_LTHRES_DELTA_MASK) >> + IXGBE_ETS_LTHRES_DELTA_SHIFT); + num_sensors = (ets_cfg & IXGBE_ETS_NUM_SENSORS_MASK); + + for (i = 0; i < num_sensors; i++) { + offset = ets_offset + 1 + i; + if (hw->eeprom.ops.read(hw, offset, &ets_sensor)) { + ERROR_REPORT2(IXGBE_ERROR_INVALID_STATE, + "eeprom read at offset %d failed", + offset); + continue; + } + sensor_index = ((ets_sensor & IXGBE_ETS_DATA_INDEX_MASK) >> + IXGBE_ETS_DATA_INDEX_SHIFT); + sensor_location = ((ets_sensor & IXGBE_ETS_DATA_LOC_MASK) >> + IXGBE_ETS_DATA_LOC_SHIFT); + therm_limit = ets_sensor & IXGBE_ETS_DATA_HTHRESH_MASK; + + hw->phy.ops.write_i2c_byte(hw, + ixgbe_emc_therm_limit[sensor_index], + IXGBE_I2C_THERMAL_SENSOR_ADDR, therm_limit); + + if ((i < IXGBE_MAX_SENSORS) && (sensor_location != 0)) { + data->sensor[i].location = sensor_location; + data->sensor[i].caution_thresh = therm_limit; + data->sensor[i].max_op_thresh = therm_limit - + low_thresh_delta; + } + } + return status; + +eeprom_err: + ERROR_REPORT2(IXGBE_ERROR_INVALID_STATE, + "eeprom read at offset %d failed", offset); + return IXGBE_NOT_IMPLEMENTED; +} + /** * ixgbe_bypass_rw_generic - Bit bang data into by_pass FW * diff --git a/sys/dev/ixgbe/ixgbe_common.h b/sys/dev/ixgbe/ixgbe_common.h index 051af213b628..e5a186f73ea9 100644 --- a/sys/dev/ixgbe/ixgbe_common.h +++ b/sys/dev/ixgbe/ixgbe_common.h @@ -43,12 +43,10 @@ IXGBE_WRITE_REG(hw, reg + 4, (u32) (value >> 32)); \ } while (0) #define IXGBE_REMOVED(a) (0) -#if !defined(NO_READ_PBA_RAW) || !defined(NO_WRITE_PBA_RAW) struct ixgbe_pba { u16 word[2]; u16 *pba_block; }; -#endif void ixgbe_dcb_get_rtrup2tc_generic(struct ixgbe_hw *hw, u8 *map); @@ -180,6 +178,18 @@ extern void ixgbe_stop_mac_link_on_d3_82599(struct ixgbe_hw *hw); bool ixgbe_mng_present(struct ixgbe_hw *hw); bool ixgbe_mng_enabled(struct ixgbe_hw *hw); +#define IXGBE_I2C_THERMAL_SENSOR_ADDR 0xF8 +#define IXGBE_EMC_INTERNAL_DATA 0x00 +#define IXGBE_EMC_INTERNAL_THERM_LIMIT 0x20 +#define IXGBE_EMC_DIODE1_DATA 0x01 +#define IXGBE_EMC_DIODE1_THERM_LIMIT 0x19 +#define IXGBE_EMC_DIODE2_DATA 0x23 +#define IXGBE_EMC_DIODE2_THERM_LIMIT 0x1A +#define IXGBE_EMC_DIODE3_DATA 0x2A +#define IXGBE_EMC_DIODE3_THERM_LIMIT 0x30 + +s32 ixgbe_get_thermal_sensor_data_generic(struct ixgbe_hw *hw); +s32 ixgbe_init_thermal_sensor_thresh_generic(struct ixgbe_hw *hw); void ixgbe_get_etk_id(struct ixgbe_hw *hw, struct ixgbe_nvm_version *nvm_ver); void ixgbe_get_oem_prod_version(struct ixgbe_hw *hw, diff --git a/sys/dev/ixgbe/ixgbe_dcb.c b/sys/dev/ixgbe/ixgbe_dcb.c index d096321b23c1..54102f312dbb 100644 --- a/sys/dev/ixgbe/ixgbe_dcb.c +++ b/sys/dev/ixgbe/ixgbe_dcb.c @@ -409,10 +409,8 @@ s32 ixgbe_dcb_get_tc_stats(struct ixgbe_hw *hw, struct ixgbe_hw_stats *stats, case ixgbe_mac_X550: case ixgbe_mac_X550EM_x: case ixgbe_mac_X550EM_a: -#if !defined(NO_82599_SUPPORT) || !defined(NO_X540_SUPPORT) ret = ixgbe_dcb_get_tc_stats_82599(hw, stats, tc_count); break; -#endif default: break; } @@ -440,10 +438,8 @@ s32 ixgbe_dcb_get_pfc_stats(struct ixgbe_hw *hw, struct ixgbe_hw_stats *stats, case ixgbe_mac_X550: case ixgbe_mac_X550EM_x: case ixgbe_mac_X550EM_a: -#if !defined(NO_82599_SUPPORT) || !defined(NO_X540_SUPPORT) ret = ixgbe_dcb_get_pfc_stats_82599(hw, stats, tc_count); break; -#endif default: break; } @@ -482,11 +478,9 @@ s32 ixgbe_dcb_config_rx_arbiter_cee(struct ixgbe_hw *hw, case ixgbe_mac_X550: case ixgbe_mac_X550EM_x: case ixgbe_mac_X550EM_a: -#if !defined(NO_82599_SUPPORT) || !defined(NO_X540_SUPPORT) ret = ixgbe_dcb_config_rx_arbiter_82599(hw, refill, max, bwgid, tsa, map); break; -#endif default: break; } @@ -524,11 +518,9 @@ s32 ixgbe_dcb_config_tx_desc_arbiter_cee(struct ixgbe_hw *hw, case ixgbe_mac_X550: case ixgbe_mac_X550EM_x: case ixgbe_mac_X550EM_a: -#if !defined(NO_82599_SUPPORT) || !defined(NO_X540_SUPPORT) ret = ixgbe_dcb_config_tx_desc_arbiter_82599(hw, refill, max, bwgid, tsa); break; -#endif default: break; } @@ -568,12 +560,10 @@ s32 ixgbe_dcb_config_tx_data_arbiter_cee(struct ixgbe_hw *hw, case ixgbe_mac_X550: case ixgbe_mac_X550EM_x: case ixgbe_mac_X550EM_a: -#if !defined(NO_82599_SUPPORT) || !defined(NO_X540_SUPPORT) ret = ixgbe_dcb_config_tx_data_arbiter_82599(hw, refill, max, bwgid, tsa, map); break; -#endif default: break; } @@ -606,10 +596,8 @@ s32 ixgbe_dcb_config_pfc_cee(struct ixgbe_hw *hw, case ixgbe_mac_X550: case ixgbe_mac_X550EM_x: case ixgbe_mac_X550EM_a: -#if !defined(NO_82599_SUPPORT) || !defined(NO_X540_SUPPORT) ret = ixgbe_dcb_config_pfc_82599(hw, pfc_en, map); break; -#endif default: break; } @@ -635,10 +623,8 @@ s32 ixgbe_dcb_config_tc_stats(struct ixgbe_hw *hw) case ixgbe_mac_X550: case ixgbe_mac_X550EM_x: case ixgbe_mac_X550EM_a: -#if !defined(NO_82599_SUPPORT) || !defined(NO_X540_SUPPORT) ret = ixgbe_dcb_config_tc_stats_82599(hw, NULL); break; -#endif default: break; } @@ -683,7 +669,6 @@ s32 ixgbe_dcb_hw_config_cee(struct ixgbe_hw *hw, case ixgbe_mac_X550: case ixgbe_mac_X550EM_x: case ixgbe_mac_X550EM_a: -#if !defined(NO_82599_SUPPORT) || !defined(NO_X540_SUPPORT) ixgbe_dcb_config_82599(hw, dcb_config); ret = ixgbe_dcb_hw_config_82599(hw, dcb_config->link_speed, refill, max, bwgid, @@ -691,7 +676,6 @@ s32 ixgbe_dcb_hw_config_cee(struct ixgbe_hw *hw, ixgbe_dcb_config_tc_stats_82599(hw, dcb_config); break; -#endif default: break; } @@ -718,10 +702,8 @@ s32 ixgbe_dcb_config_pfc(struct ixgbe_hw *hw, u8 pfc_en, u8 *map) case ixgbe_mac_X550: case ixgbe_mac_X550EM_x: case ixgbe_mac_X550EM_a: -#if !defined(NO_82599_SUPPORT) || !defined(NO_X540_SUPPORT) ret = ixgbe_dcb_config_pfc_82599(hw, pfc_en, map); break; -#endif default: break; } @@ -744,7 +726,6 @@ s32 ixgbe_dcb_hw_config(struct ixgbe_hw *hw, u16 *refill, u16 *max, case ixgbe_mac_X550: case ixgbe_mac_X550EM_x: case ixgbe_mac_X550EM_a: -#if !defined(NO_82599_SUPPORT) || !defined(NO_X540_SUPPORT) ixgbe_dcb_config_rx_arbiter_82599(hw, refill, max, bwg_id, tsa, map); ixgbe_dcb_config_tx_desc_arbiter_82599(hw, refill, max, bwg_id, @@ -752,7 +733,6 @@ s32 ixgbe_dcb_hw_config(struct ixgbe_hw *hw, u16 *refill, u16 *max, ixgbe_dcb_config_tx_data_arbiter_82599(hw, refill, max, bwg_id, tsa, map); break; -#endif default: break; } diff --git a/sys/dev/ixgbe/ixgbe_mbx.c b/sys/dev/ixgbe/ixgbe_mbx.c index f72bbf34256a..443ebb478993 100644 --- a/sys/dev/ixgbe/ixgbe_mbx.c +++ b/sys/dev/ixgbe/ixgbe_mbx.c @@ -36,6 +36,118 @@ #include "ixgbe_type.h" #include "ixgbe_mbx.h" +/** + * ixgbe_read_mbx - Reads a message from the mailbox + * @hw: pointer to the HW structure + * @msg: The message buffer + * @size: Length of buffer + * @mbx_id: id of mailbox to read + * + * returns SUCCESS if it successfully read message from buffer + **/ +s32 ixgbe_read_mbx(struct ixgbe_hw *hw, u32 *msg, u16 size, u16 mbx_id) +{ + struct ixgbe_mbx_info *mbx = &hw->mbx; + s32 ret_val = IXGBE_ERR_MBX; + + DEBUGFUNC("ixgbe_read_mbx"); + + /* limit read to size of mailbox */ + if (size > mbx->size) + size = mbx->size; + + if (mbx->ops.read) + ret_val = mbx->ops.read(hw, msg, size, mbx_id); + + return ret_val; +} + +/** + * ixgbe_write_mbx - Write a message to the mailbox + * @hw: pointer to the HW structure + * @msg: The message buffer + * @size: Length of buffer + * @mbx_id: id of mailbox to write + * + * returns SUCCESS if it successfully copied message into the buffer + **/ +s32 ixgbe_write_mbx(struct ixgbe_hw *hw, u32 *msg, u16 size, u16 mbx_id) +{ + struct ixgbe_mbx_info *mbx = &hw->mbx; + s32 ret_val = IXGBE_SUCCESS; + + DEBUGFUNC("ixgbe_write_mbx"); + + if (size > mbx->size) { + ret_val = IXGBE_ERR_MBX; + ERROR_REPORT2(IXGBE_ERROR_ARGUMENT, + "Invalid mailbox message size %d", size); + } else if (mbx->ops.write) + ret_val = mbx->ops.write(hw, msg, size, mbx_id); + + return ret_val; +} + +/** + * ixgbe_check_for_msg - checks to see if someone sent us mail + * @hw: pointer to the HW structure + * @mbx_id: id of mailbox to check + * + * returns SUCCESS if the Status bit was found or else ERR_MBX + **/ +s32 ixgbe_check_for_msg(struct ixgbe_hw *hw, u16 mbx_id) +{ + struct ixgbe_mbx_info *mbx = &hw->mbx; + s32 ret_val = IXGBE_ERR_MBX; + + DEBUGFUNC("ixgbe_check_for_msg"); + + if (mbx->ops.check_for_msg) + ret_val = mbx->ops.check_for_msg(hw, mbx_id); + + return ret_val; +} + +/** + * ixgbe_check_for_ack - checks to see if someone sent us ACK + * @hw: pointer to the HW structure + * @mbx_id: id of mailbox to check + * + * returns SUCCESS if the Status bit was found or else ERR_MBX + **/ +s32 ixgbe_check_for_ack(struct ixgbe_hw *hw, u16 mbx_id) +{ + struct ixgbe_mbx_info *mbx = &hw->mbx; + s32 ret_val = IXGBE_ERR_MBX; + + DEBUGFUNC("ixgbe_check_for_ack"); + + if (mbx->ops.check_for_ack) + ret_val = mbx->ops.check_for_ack(hw, mbx_id); + + return ret_val; +} + +/** + * ixgbe_check_for_rst - checks to see if other side has reset + * @hw: pointer to the HW structure + * @mbx_id: id of mailbox to check + * + * returns SUCCESS if the Status bit was found or else ERR_MBX + **/ +s32 ixgbe_check_for_rst(struct ixgbe_hw *hw, u16 mbx_id) +{ + struct ixgbe_mbx_info *mbx = &hw->mbx; + s32 ret_val = IXGBE_ERR_MBX; + + DEBUGFUNC("ixgbe_check_for_rst"); + + if (mbx->ops.check_for_rst) + ret_val = mbx->ops.check_for_rst(hw, mbx_id); + + return ret_val; +} + /** * ixgbe_poll_for_msg - Wait for message notification * @hw: pointer to the HW structure @@ -110,7 +222,7 @@ out: * returns SUCCESS if it successfully received a message notification and * copied it into the receive buffer. **/ -static s32 ixgbe_read_posted_mbx(struct ixgbe_hw *hw, u32 *msg, u16 size, +s32 ixgbe_read_posted_mbx(struct ixgbe_hw *hw, u32 *msg, u16 size, u16 mbx_id) { struct ixgbe_mbx_info *mbx = &hw->mbx; @@ -140,7 +252,7 @@ out: * returns SUCCESS if it successfully copied message into the buffer and * received an ack to that message within delay * timeout period **/ -static s32 ixgbe_write_posted_mbx(struct ixgbe_hw *hw, u32 *msg, u16 size, +s32 ixgbe_write_posted_mbx(struct ixgbe_hw *hw, u32 *msg, u16 size, u16 mbx_id) { struct ixgbe_mbx_info *mbx = &hw->mbx; diff --git a/sys/dev/ixgbe/ixgbe_mbx.h b/sys/dev/ixgbe/ixgbe_mbx.h index 9b3deb28f149..88387ea3f7c2 100644 --- a/sys/dev/ixgbe/ixgbe_mbx.h +++ b/sys/dev/ixgbe/ixgbe_mbx.h @@ -153,6 +153,13 @@ enum ixgbevf_xcast_modes { #define IXGBE_VF_MBX_INIT_TIMEOUT 2000 /* number of retries on mailbox */ #define IXGBE_VF_MBX_INIT_DELAY 500 /* microseconds between retries */ +s32 ixgbe_read_mbx(struct ixgbe_hw *, u32 *, u16, u16); +s32 ixgbe_write_mbx(struct ixgbe_hw *, u32 *, u16, u16); +s32 ixgbe_read_posted_mbx(struct ixgbe_hw *, u32 *, u16, u16); +s32 ixgbe_write_posted_mbx(struct ixgbe_hw *, u32 *, u16, u16); +s32 ixgbe_check_for_msg(struct ixgbe_hw *, u16); +s32 ixgbe_check_for_ack(struct ixgbe_hw *, u16); +s32 ixgbe_check_for_rst(struct ixgbe_hw *, u16); void ixgbe_init_mbx_ops_generic(struct ixgbe_hw *hw); void ixgbe_init_mbx_params_vf(struct ixgbe_hw *); void ixgbe_init_mbx_params_pf(struct ixgbe_hw *); diff --git a/sys/dev/ixgbe/ixgbe_phy.c b/sys/dev/ixgbe/ixgbe_phy.c index 5a2f49e9ebac..eef1d40448d3 100644 --- a/sys/dev/ixgbe/ixgbe_phy.c +++ b/sys/dev/ixgbe/ixgbe_phy.c @@ -1536,7 +1536,10 @@ s32 ixgbe_identify_sfp_module_generic(struct ixgbe_hw *hw) status = IXGBE_SUCCESS; } else { if (hw->allow_unsupported_sfp == true) { - EWARN(hw, "WARNING: Intel (R) Network Connections are quality tested using Intel (R) Ethernet Optics. Using untested modules is not supported and may cause unstable operation or damage to the module or the adapter. Intel Corporation is not responsible for any harm caused by using untested modules.\n"); + EWARN(hw, + "WARNING: Intel (R) Network Connections are quality tested using Intel (R) Ethernet Optics. " + "Using untested modules is not supported and may cause unstable operation or damage to the module or the adapter. " + "Intel Corporation is not responsible for any harm caused by using untested modules.\n"); status = IXGBE_SUCCESS; } else { DEBUGOUT("SFP+ module not supported\n"); @@ -1789,7 +1792,10 @@ s32 ixgbe_identify_qsfp_module_generic(struct ixgbe_hw *hw) status = IXGBE_SUCCESS; } else { if (hw->allow_unsupported_sfp == true) { - EWARN(hw, "WARNING: Intel (R) Network Connections are quality tested using Intel (R) Ethernet Optics. Using untested modules is not supported and may cause unstable operation or damage to the module or the adapter. Intel Corporation is not responsible for any harm caused by using untested modules.\n"); + EWARN(hw, + "WARNING: Intel (R) Network Connections are quality tested using Intel (R) Ethernet Optics. " + "Using untested modules is not supported and may cause unstable operation or damage to the module or the adapter. " + "Intel Corporation is not responsible for any harm caused by using untested modules.\n"); status = IXGBE_SUCCESS; } else { DEBUGOUT("QSFP module not supported\n"); @@ -2571,7 +2577,6 @@ static bool ixgbe_get_i2c_data(struct ixgbe_hw *hw, u32 *i2cctl) { u32 data_oe_bit = IXGBE_I2C_DATA_OE_N_EN_BY_MAC(hw); bool data; - UNREFERENCED_1PARAMETER(hw); DEBUGFUNC("ixgbe_get_i2c_data"); diff --git a/sys/dev/ixgbe/ixgbe_phy.h b/sys/dev/ixgbe/ixgbe_phy.h index 7f51ccc1dd2c..09d7ea4afbc0 100644 --- a/sys/dev/ixgbe/ixgbe_phy.h +++ b/sys/dev/ixgbe/ixgbe_phy.h @@ -147,10 +147,8 @@ #define IXGBE_I2C_T_SU_STO 4 #define IXGBE_I2C_T_BUF 5 -#ifndef IXGBE_SFP_DETECT_RETRIES #define IXGBE_SFP_DETECT_RETRIES 10 -#endif /* IXGBE_SFP_DETECT_RETRIES */ #define IXGBE_TN_LASI_STATUS_REG 0x9005 #define IXGBE_TN_LASI_STATUS_TEMP_ALARM 0x0008 diff --git a/sys/dev/ixgbe/ixgbe_type.h b/sys/dev/ixgbe/ixgbe_type.h index 1c04f09df77c..1eb446184990 100644 --- a/sys/dev/ixgbe/ixgbe_type.h +++ b/sys/dev/ixgbe/ixgbe_type.h @@ -48,8 +48,8 @@ * * - IXGBE_ERROR_POLLING * This category is for errors related to polling/timeout issues and should be - * used in any case where the timeout occurred, or a failure to obtain a lock, or - * failure to receive data within the time limit. + * used in any case where the timeout occurred, or a failure to obtain a lock, + * or failure to receive data within the time limit. * * - IXGBE_ERROR_CAUTION * This category should be used for reporting issues that may be the cause of @@ -157,7 +157,7 @@ #define IXGBE_DEV_ID_X550EM_X_VF 0x15A8 #define IXGBE_DEV_ID_X550EM_X_VF_HV 0x15A9 -#define IXGBE_CAT(r,m) IXGBE_##r##m +#define IXGBE_CAT(r, m) IXGBE_##r##m #define IXGBE_BY_MAC(_hw, r) ((_hw)->mvals[IXGBE_CAT(r, _IDX)]) @@ -284,6 +284,26 @@ #define IXGBE_I2C_CLK_OE_N_EN_BY_MAC(_hw) IXGBE_BY_MAC((_hw), I2C_CLK_OE_N_EN) #define IXGBE_I2C_CLOCK_STRETCHING_TIMEOUT 500 +#define IXGBE_I2C_THERMAL_SENSOR_ADDR 0xF8 +#define IXGBE_EMC_INTERNAL_DATA 0x00 +#define IXGBE_EMC_INTERNAL_THERM_LIMIT 0x20 +#define IXGBE_EMC_DIODE1_DATA 0x01 +#define IXGBE_EMC_DIODE1_THERM_LIMIT 0x19 +#define IXGBE_EMC_DIODE2_DATA 0x23 +#define IXGBE_EMC_DIODE2_THERM_LIMIT 0x1A + +#define IXGBE_MAX_SENSORS 3 + +struct ixgbe_thermal_diode_data { + u8 location; + u8 temp; + u8 caution_thresh; + u8 max_op_thresh; +}; + +struct ixgbe_thermal_sensor_data { + struct ixgbe_thermal_diode_data sensor[IXGBE_MAX_SENSORS]; +}; #define NVM_OROM_OFFSET 0x17 @@ -2358,6 +2378,20 @@ enum { #define IXGBE_ALT_MAC_ADDR_PTR 0x37 #define IXGBE_FREE_SPACE_PTR 0X3E +/* External Thermal Sensor Config */ +#define IXGBE_ETS_CFG 0x26 +#define IXGBE_ETS_LTHRES_DELTA_MASK 0x07C0 +#define IXGBE_ETS_LTHRES_DELTA_SHIFT 6 +#define IXGBE_ETS_TYPE_MASK 0x0038 +#define IXGBE_ETS_TYPE_SHIFT 3 +#define IXGBE_ETS_TYPE_EMC 0x000 +#define IXGBE_ETS_NUM_SENSORS_MASK 0x0007 +#define IXGBE_ETS_DATA_LOC_MASK 0x3C00 +#define IXGBE_ETS_DATA_LOC_SHIFT 10 +#define IXGBE_ETS_DATA_INDEX_MASK 0x0300 +#define IXGBE_ETS_DATA_INDEX_SHIFT 8 +#define IXGBE_ETS_DATA_HTHRESH_MASK 0x00FF + #define IXGBE_SAN_MAC_ADDR_PTR 0x28 #define IXGBE_DEVICE_CAPS 0x2C #define IXGBE_82599_SERIAL_NUMBER_MAC_ADDR 0x11 @@ -2412,9 +2446,7 @@ enum { #define IXGBE_EEPROM_CTRL_2 1 /* EEPROM CTRL word 2 */ #define IXGBE_EEPROM_CCD_BIT 2 -#ifndef IXGBE_EEPROM_GRANT_ATTEMPTS #define IXGBE_EEPROM_GRANT_ATTEMPTS 1000 /* EEPROM attempts to gain grant */ -#endif /* Number of 5 microseconds we wait for EERD read and * EERW write to complete */ @@ -3932,7 +3964,6 @@ struct ixgbe_mac_operations { s32 (*get_fcoe_boot_status)(struct ixgbe_hw *, u16 *); s32 (*stop_adapter)(struct ixgbe_hw *); s32 (*get_bus_info)(struct ixgbe_hw *); - s32 (*negotiate_api_version)(struct ixgbe_hw *, int); void (*set_lan_id)(struct ixgbe_hw *); s32 (*read_analog_reg8)(struct ixgbe_hw*, u32, u8*); s32 (*write_analog_reg8)(struct ixgbe_hw*, u32, u8); @@ -3945,6 +3976,7 @@ struct ixgbe_mac_operations { void (*init_swfw_sync)(struct ixgbe_hw *); s32 (*prot_autoc_read)(struct ixgbe_hw *, bool *, u32 *); s32 (*prot_autoc_write)(struct ixgbe_hw *, u32, bool); + s32 (*negotiate_api_version)(struct ixgbe_hw *hw, int api); /* Link */ void (*disable_tx_laser)(struct ixgbe_hw *); @@ -3980,17 +4012,17 @@ struct ixgbe_mac_operations { ixgbe_mc_addr_itr); s32 (*update_mc_addr_list)(struct ixgbe_hw *, u8 *, u32, ixgbe_mc_addr_itr, bool clear); - s32 (*update_xcast_mode)(struct ixgbe_hw *, int); s32 (*enable_mc)(struct ixgbe_hw *); s32 (*disable_mc)(struct ixgbe_hw *); s32 (*clear_vfta)(struct ixgbe_hw *); s32 (*set_vfta)(struct ixgbe_hw *, u32, u32, bool, bool); s32 (*set_vlvf)(struct ixgbe_hw *, u32, u32, bool, u32 *, u32, bool); - s32 (*set_rlpml)(struct ixgbe_hw *, u16); s32 (*init_uta_tables)(struct ixgbe_hw *); void (*set_mac_anti_spoofing)(struct ixgbe_hw *, bool, int); void (*set_vlan_anti_spoofing)(struct ixgbe_hw *, bool, int); + s32 (*update_xcast_mode)(struct ixgbe_hw *, int); + s32 (*set_rlpml)(struct ixgbe_hw *, u16); /* Flow Control */ s32 (*fc_enable)(struct ixgbe_hw *); @@ -4000,6 +4032,8 @@ struct ixgbe_mac_operations { /* Manageability interface */ s32 (*set_fw_drv_ver)(struct ixgbe_hw *, u8, u8, u8, u8, u16, const char *); + s32 (*get_thermal_sensor_data)(struct ixgbe_hw *); + s32 (*init_thermal_sensor_thresh)(struct ixgbe_hw *hw); s32 (*bypass_rw) (struct ixgbe_hw *hw, u32 cmd, u32 *status); bool (*bypass_valid_rd) (u32 in_reg, u32 out_reg); s32 (*bypass_set) (struct ixgbe_hw *hw, u32 cmd, u32 event, u32 action); @@ -4107,6 +4141,8 @@ struct ixgbe_mac_info { bool orig_link_settings_stored; bool autotry_restart; u8 flags; + struct ixgbe_thermal_sensor_data thermal_sensor_data; + bool thermal_sensor_enabled; struct ixgbe_dmac_config dmac_config; bool set_lben; u32 max_link_up_time; diff --git a/sys/dev/ixgbe/ixgbe_vf.c b/sys/dev/ixgbe/ixgbe_vf.c index 82800b4a3d87..f70f4d667aee 100644 --- a/sys/dev/ixgbe/ixgbe_vf.c +++ b/sys/dev/ixgbe/ixgbe_vf.c @@ -36,12 +36,8 @@ #include "ixgbe.h" -#ifndef IXGBE_VFWRITE_REG #define IXGBE_VFWRITE_REG IXGBE_WRITE_REG -#endif -#ifndef IXGBE_VFREAD_REG #define IXGBE_VFREAD_REG IXGBE_READ_REG -#endif /** * ixgbe_init_ops_vf - Initialize the pointers for vf diff --git a/sys/dev/ixgbe/ixgbe_x540.c b/sys/dev/ixgbe/ixgbe_x540.c index d03b34ee8135..ea45cd31a4c3 100644 --- a/sys/dev/ixgbe/ixgbe_x540.c +++ b/sys/dev/ixgbe/ixgbe_x540.c @@ -819,7 +819,7 @@ s32 ixgbe_acquire_swfw_sync_X540(struct ixgbe_hw *hw, u32 mask) * bits in the SW_FW_SYNC register. */ if (ixgbe_get_swfw_sync_semaphore(hw)) { - DEBUGOUT("Failed to get NVM sempahore and register semaphore while forcefully ignoring FW sempahore bit(s) and setting SW semaphore bit(s), returning IXGBE_ERR_SWFW_SYNC\n"); + DEBUGOUT("Failed to get NVM semaphore and register semaphore while forcefully ignoring FW semaphore bit(s) and setting SW semaphore bit(s), returning IXGBE_ERR_SWFW_SYNC\n"); return IXGBE_ERR_SWFW_SYNC; } swfw_sync = IXGBE_READ_REG(hw, IXGBE_SWFW_SYNC_BY_MAC(hw)); diff --git a/sys/dev/ixgbe/ixgbe_x550.c b/sys/dev/ixgbe/ixgbe_x550.c index 7fc556662b00..3353d91e228e 100644 --- a/sys/dev/ixgbe/ixgbe_x550.c +++ b/sys/dev/ixgbe/ixgbe_x550.c @@ -619,6 +619,10 @@ s32 ixgbe_init_ops_X550EM(struct ixgbe_hw *hw) * the pointers to NULL explicitly here to overwrite * the values being set in the x540 function. */ + /* Thermal sensor not supported in x550EM */ + mac->ops.get_thermal_sensor_data = NULL; + mac->ops.init_thermal_sensor_thresh = NULL; + mac->thermal_sensor_enabled = false; /* Bypass not supported in x550EM */ mac->ops.bypass_rw = NULL; @@ -1135,7 +1139,7 @@ s32 ixgbe_write_iosf_sb_reg_x550(struct ixgbe_hw *hw, u32 reg_addr, u32 device_type, u32 data) { u32 gssr = IXGBE_GSSR_PHY1_SM | IXGBE_GSSR_PHY0_SM; - u32 command, error __unused; + u32 command, error; s32 ret; ret = ixgbe_acquire_swfw_semaphore(hw, gssr); @@ -1181,7 +1185,7 @@ s32 ixgbe_read_iosf_sb_reg_x550(struct ixgbe_hw *hw, u32 reg_addr, u32 device_type, u32 *data) { u32 gssr = IXGBE_GSSR_PHY1_SM | IXGBE_GSSR_PHY0_SM; - u32 command, error __unused; + u32 command, error; s32 ret; ret = ixgbe_acquire_swfw_semaphore(hw, gssr); @@ -2716,7 +2720,7 @@ static s32 ixgbe_setup_sfi_x550a(struct ixgbe_hw *hw, ixgbe_link_speed *speed) * @speed: new link speed * @autoneg_wait_to_complete: unused * - * Configure the the integrated PHY for SFP support. + * Configure the integrated PHY for SFP support. **/ s32 ixgbe_setup_mac_link_sfp_x550a(struct ixgbe_hw *hw, ixgbe_link_speed speed, @@ -3688,7 +3692,7 @@ u64 ixgbe_get_supported_physical_layer_X550em(struct ixgbe_hw *hw) physical_layer = IXGBE_PHYSICAL_LAYER_1000BASE_KX; break; case ixgbe_phy_ext_1g_t: - physical_layer = IXGBE_PHYSICAL_LAYER_1000BASE_T; + physical_layer |= IXGBE_PHYSICAL_LAYER_1000BASE_T; break; default: break; From nobody Tue Oct 12 18:19:40 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 73E7217FE89A; Tue, 12 Oct 2021 18:19: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 4HTP8D1Xlyz3mKf; Tue, 12 Oct 2021 18:19: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 14E6118FEE; Tue, 12 Oct 2021 18:19: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 19CIJecZ053483; Tue, 12 Oct 2021 18:19:40 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19CIJeCc053482; Tue, 12 Oct 2021 18:19:40 GMT (envelope-from git) Date: Tue, 12 Oct 2021 18:19:40 GMT Message-Id: <202110121819.19CIJeCc053482@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kevin Bowling Subject: git: 8d4cf1a63e1d - stable/12 - ixgbe: Update shared code catchup List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kbowling X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 8d4cf1a63e1db1cd3aff8132e3e0e3ea00e3a6a9 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by kbowling (ports committer): URL: https://cgit.FreeBSD.org/src/commit/?id=8d4cf1a63e1db1cd3aff8132e3e0e3ea00e3a6a9 commit 8d4cf1a63e1db1cd3aff8132e3e0e3ea00e3a6a9 Author: Kevin Bowling AuthorDate: 2021-10-07 01:43:27 +0000 Commit: Kevin Bowling CommitDate: 2021-10-12 18:18:49 +0000 ixgbe: Update shared code catchup Leftovers from DPDK sync Reviewed by: grehan Obtained from: DPDK MFC after: 5 days Differential Revision: https://reviews.freebsd.org/D31621 (cherry picked from commit 3f66b96d8658f8721e6b1c6f035611bec44675b9) --- sys/dev/ixgbe/ixgbe_82599.c | 5 ++ sys/dev/ixgbe/ixgbe_api.c | 54 ++++++++++++++ sys/dev/ixgbe/ixgbe_api.h | 3 + sys/dev/ixgbe/ixgbe_common.c | 174 ++++++++++++++++++++++++++++++++++++++++++- sys/dev/ixgbe/ixgbe_common.h | 14 +++- sys/dev/ixgbe/ixgbe_dcb.c | 20 ----- sys/dev/ixgbe/ixgbe_mbx.c | 116 ++++++++++++++++++++++++++++- sys/dev/ixgbe/ixgbe_mbx.h | 7 ++ sys/dev/ixgbe/ixgbe_phy.c | 11 ++- sys/dev/ixgbe/ixgbe_phy.h | 2 - sys/dev/ixgbe/ixgbe_type.h | 52 +++++++++++-- sys/dev/ixgbe/ixgbe_vf.c | 4 - sys/dev/ixgbe/ixgbe_x540.c | 2 +- sys/dev/ixgbe/ixgbe_x550.c | 12 ++- 14 files changed, 427 insertions(+), 49 deletions(-) diff --git a/sys/dev/ixgbe/ixgbe_82599.c b/sys/dev/ixgbe/ixgbe_82599.c index 9eb3904a30f9..698602080592 100644 --- a/sys/dev/ixgbe/ixgbe_82599.c +++ b/sys/dev/ixgbe/ixgbe_82599.c @@ -395,6 +395,11 @@ s32 ixgbe_init_ops_82599(struct ixgbe_hw *hw) /* Manageability interface */ mac->ops.set_fw_drv_ver = ixgbe_set_fw_drv_ver_generic; + mac->ops.get_thermal_sensor_data = + ixgbe_get_thermal_sensor_data_generic; + mac->ops.init_thermal_sensor_thresh = + ixgbe_init_thermal_sensor_thresh_generic; + mac->ops.bypass_rw = ixgbe_bypass_rw_generic; mac->ops.bypass_valid_rd = ixgbe_bypass_valid_rd_generic; mac->ops.bypass_set = ixgbe_bypass_set_generic; diff --git a/sys/dev/ixgbe/ixgbe_api.c b/sys/dev/ixgbe/ixgbe_api.c index 5a425f087f1a..87b213a99b0e 100644 --- a/sys/dev/ixgbe/ixgbe_api.c +++ b/sys/dev/ixgbe/ixgbe_api.c @@ -113,6 +113,13 @@ s32 ixgbe_init_shared_code(struct ixgbe_hw *hw) case ixgbe_mac_X550EM_a: status = ixgbe_init_ops_X550EM_a(hw); break; + case ixgbe_mac_82599_vf: + case ixgbe_mac_X540_vf: + case ixgbe_mac_X550_vf: + case ixgbe_mac_X550EM_x_vf: + case ixgbe_mac_X550EM_a_vf: + status = ixgbe_init_ops_vf(hw); + break; default: status = IXGBE_ERR_DEVICE_NOT_SUPPORTED; break; @@ -176,6 +183,15 @@ s32 ixgbe_set_mac_type(struct ixgbe_hw *hw) case IXGBE_DEV_ID_82599_T3_LOM: hw->mac.type = ixgbe_mac_82599EB; break; + case IXGBE_DEV_ID_82599_VF: + case IXGBE_DEV_ID_82599_VF_HV: + hw->mac.type = ixgbe_mac_82599_vf; + break; + case IXGBE_DEV_ID_X540_VF: + case IXGBE_DEV_ID_X540_VF_HV: + hw->mac.type = ixgbe_mac_X540_vf; + hw->mvals = ixgbe_mvals_X540; + break; case IXGBE_DEV_ID_X540T: case IXGBE_DEV_ID_X540T1: case IXGBE_DEV_ID_X540_BYPASS: @@ -210,6 +226,21 @@ s32 ixgbe_set_mac_type(struct ixgbe_hw *hw) hw->mac.type = ixgbe_mac_X550EM_a; hw->mvals = ixgbe_mvals_X550EM_a; break; + case IXGBE_DEV_ID_X550_VF: + case IXGBE_DEV_ID_X550_VF_HV: + hw->mac.type = ixgbe_mac_X550_vf; + hw->mvals = ixgbe_mvals_X550; + break; + case IXGBE_DEV_ID_X550EM_X_VF: + case IXGBE_DEV_ID_X550EM_X_VF_HV: + hw->mac.type = ixgbe_mac_X550EM_x_vf; + hw->mvals = ixgbe_mvals_X550EM_x; + break; + case IXGBE_DEV_ID_X550EM_A_VF: + case IXGBE_DEV_ID_X550EM_A_VF_HV: + hw->mac.type = ixgbe_mac_X550EM_a_vf; + hw->mvals = ixgbe_mvals_X550EM_a; + break; default: ret_val = IXGBE_ERR_DEVICE_NOT_SUPPORTED; ERROR_REPORT2(IXGBE_ERROR_UNSUPPORTED, @@ -1146,6 +1177,29 @@ s32 ixgbe_set_fw_drv_ver(struct ixgbe_hw *hw, u8 maj, u8 min, u8 build, } +/** + * ixgbe_get_thermal_sensor_data - Gathers thermal sensor data + * @hw: pointer to hardware structure + * + * Updates the temperatures in mac.thermal_sensor_data + **/ +s32 ixgbe_get_thermal_sensor_data(struct ixgbe_hw *hw) +{ + return ixgbe_call_func(hw, hw->mac.ops.get_thermal_sensor_data, (hw), + IXGBE_NOT_IMPLEMENTED); +} + +/** + * ixgbe_init_thermal_sensor_thresh - Inits thermal sensor thresholds + * @hw: pointer to hardware structure + * + * Inits the thermal sensor thresholds according to the NVM map + **/ +s32 ixgbe_init_thermal_sensor_thresh(struct ixgbe_hw *hw) +{ + return ixgbe_call_func(hw, hw->mac.ops.init_thermal_sensor_thresh, (hw), + IXGBE_NOT_IMPLEMENTED); +} /** * ixgbe_dmac_config - Configure DMA Coalescing registers. diff --git a/sys/dev/ixgbe/ixgbe_api.h b/sys/dev/ixgbe/ixgbe_api.h index c70f27c6aa2c..7fd300bfe4ee 100644 --- a/sys/dev/ixgbe/ixgbe_api.h +++ b/sys/dev/ixgbe/ixgbe_api.h @@ -49,6 +49,7 @@ extern s32 ixgbe_init_ops_X550(struct ixgbe_hw *hw); extern s32 ixgbe_init_ops_X550EM(struct ixgbe_hw *hw); extern s32 ixgbe_init_ops_X550EM_x(struct ixgbe_hw *hw); extern s32 ixgbe_init_ops_X550EM_a(struct ixgbe_hw *hw); +extern s32 ixgbe_init_ops_vf(struct ixgbe_hw *hw); s32 ixgbe_set_mac_type(struct ixgbe_hw *hw); s32 ixgbe_init_hw(struct ixgbe_hw *hw); @@ -135,6 +136,8 @@ s32 ixgbe_fc_enable(struct ixgbe_hw *hw); s32 ixgbe_setup_fc(struct ixgbe_hw *hw); s32 ixgbe_set_fw_drv_ver(struct ixgbe_hw *hw, u8 maj, u8 min, u8 build, u8 ver, u16 len, char *driver_ver); +s32 ixgbe_get_thermal_sensor_data(struct ixgbe_hw *hw); +s32 ixgbe_init_thermal_sensor_thresh(struct ixgbe_hw *hw); void ixgbe_set_mta(struct ixgbe_hw *hw, u8 *mc_addr); s32 ixgbe_get_phy_firmware_version(struct ixgbe_hw *hw, u16 *firmware_version); diff --git a/sys/dev/ixgbe/ixgbe_common.c b/sys/dev/ixgbe/ixgbe_common.c index 50e18bcba997..0ad538a465ea 100644 --- a/sys/dev/ixgbe/ixgbe_common.c +++ b/sys/dev/ixgbe/ixgbe_common.c @@ -4132,7 +4132,7 @@ s32 ixgbe_clear_vfta_generic(struct ixgbe_hw *hw) for (offset = 0; offset < IXGBE_VLVF_ENTRIES; offset++) { IXGBE_WRITE_REG(hw, IXGBE_VLVF(offset), 0); IXGBE_WRITE_REG(hw, IXGBE_VLVFB(offset * 2), 0); - IXGBE_WRITE_REG(hw, IXGBE_VLVFB((offset * 2) + 1), 0); + IXGBE_WRITE_REG(hw, IXGBE_VLVFB(offset * 2 + 1), 0); } return IXGBE_SUCCESS; @@ -4626,7 +4626,7 @@ s32 ixgbe_host_interface_command(struct ixgbe_hw *hw, u32 *buffer, /* first pull in the header so we know the buffer length */ for (bi = 0; bi < dword_len; bi++) { buffer[bi] = IXGBE_READ_REG_ARRAY(hw, IXGBE_FLEX_MNG, bi); - IXGBE_LE32_TO_CPUS(&buffer[bi]); + IXGBE_LE32_TO_CPUS((uintptr_t)&buffer[bi]); } /* @@ -4662,7 +4662,7 @@ s32 ixgbe_host_interface_command(struct ixgbe_hw *hw, u32 *buffer, /* Pull in the rest of the buffer (bi is where we left off) */ for (; bi <= dword_len; bi++) { buffer[bi] = IXGBE_READ_REG_ARRAY(hw, IXGBE_FLEX_MNG, bi); - IXGBE_LE32_TO_CPUS(&buffer[bi]); + IXGBE_LE32_TO_CPUS((uintptr_t)&buffer[bi]); } rel_out: @@ -4852,6 +4852,174 @@ out: IXGBE_WRITE_REG(hw, IXGBE_HLREG0, hlreg0); } +static const u8 ixgbe_emc_temp_data[4] = { + IXGBE_EMC_INTERNAL_DATA, + IXGBE_EMC_DIODE1_DATA, + IXGBE_EMC_DIODE2_DATA, + IXGBE_EMC_DIODE3_DATA +}; +static const u8 ixgbe_emc_therm_limit[4] = { + IXGBE_EMC_INTERNAL_THERM_LIMIT, + IXGBE_EMC_DIODE1_THERM_LIMIT, + IXGBE_EMC_DIODE2_THERM_LIMIT, + IXGBE_EMC_DIODE3_THERM_LIMIT +}; + +/** + * ixgbe_get_thermal_sensor_data - Gathers thermal sensor data + * @hw: pointer to hardware structure + * + * Returns the thermal sensor data structure + **/ +s32 ixgbe_get_thermal_sensor_data_generic(struct ixgbe_hw *hw) +{ + s32 status = IXGBE_SUCCESS; + u16 ets_offset; + u16 ets_cfg; + u16 ets_sensor; + u8 num_sensors; + u8 sensor_index; + u8 sensor_location; + u8 i; + struct ixgbe_thermal_sensor_data *data = &hw->mac.thermal_sensor_data; + + DEBUGFUNC("ixgbe_get_thermal_sensor_data_generic"); + + /* Only support thermal sensors attached to 82599 physical port 0 */ + if ((hw->mac.type != ixgbe_mac_82599EB) || + (IXGBE_READ_REG(hw, IXGBE_STATUS) & IXGBE_STATUS_LAN_ID_1)) { + status = IXGBE_NOT_IMPLEMENTED; + goto out; + } + + status = hw->eeprom.ops.read(hw, IXGBE_ETS_CFG, &ets_offset); + if (status) + goto out; + + if ((ets_offset == 0x0000) || (ets_offset == 0xFFFF)) { + status = IXGBE_NOT_IMPLEMENTED; + goto out; + } + + status = hw->eeprom.ops.read(hw, ets_offset, &ets_cfg); + if (status) + goto out; + + if (((ets_cfg & IXGBE_ETS_TYPE_MASK) >> IXGBE_ETS_TYPE_SHIFT) + != IXGBE_ETS_TYPE_EMC) { + status = IXGBE_NOT_IMPLEMENTED; + goto out; + } + + num_sensors = (ets_cfg & IXGBE_ETS_NUM_SENSORS_MASK); + if (num_sensors > IXGBE_MAX_SENSORS) + num_sensors = IXGBE_MAX_SENSORS; + + for (i = 0; i < num_sensors; i++) { + status = hw->eeprom.ops.read(hw, (ets_offset + 1 + i), + &ets_sensor); + if (status) + goto out; + + sensor_index = ((ets_sensor & IXGBE_ETS_DATA_INDEX_MASK) >> + IXGBE_ETS_DATA_INDEX_SHIFT); + sensor_location = ((ets_sensor & IXGBE_ETS_DATA_LOC_MASK) >> + IXGBE_ETS_DATA_LOC_SHIFT); + + if (sensor_location != 0) { + status = hw->phy.ops.read_i2c_byte(hw, + ixgbe_emc_temp_data[sensor_index], + IXGBE_I2C_THERMAL_SENSOR_ADDR, + &data->sensor[i].temp); + if (status) + goto out; + } + } +out: + return status; +} + +/** + * ixgbe_init_thermal_sensor_thresh_generic - Inits thermal sensor thresholds + * @hw: pointer to hardware structure + * + * Inits the thermal sensor thresholds according to the NVM map + * and save off the threshold and location values into mac.thermal_sensor_data + **/ +s32 ixgbe_init_thermal_sensor_thresh_generic(struct ixgbe_hw *hw) +{ + s32 status = IXGBE_SUCCESS; + u16 offset; + u16 ets_offset; + u16 ets_cfg; + u16 ets_sensor; + u8 low_thresh_delta; + u8 num_sensors; + u8 sensor_index; + u8 sensor_location; + u8 therm_limit; + u8 i; + struct ixgbe_thermal_sensor_data *data = &hw->mac.thermal_sensor_data; + + DEBUGFUNC("ixgbe_init_thermal_sensor_thresh_generic"); + + memset(data, 0, sizeof(struct ixgbe_thermal_sensor_data)); + + /* Only support thermal sensors attached to 82599 physical port 0 */ + if ((hw->mac.type != ixgbe_mac_82599EB) || + (IXGBE_READ_REG(hw, IXGBE_STATUS) & IXGBE_STATUS_LAN_ID_1)) + return IXGBE_NOT_IMPLEMENTED; + + offset = IXGBE_ETS_CFG; + if (hw->eeprom.ops.read(hw, offset, &ets_offset)) + goto eeprom_err; + if ((ets_offset == 0x0000) || (ets_offset == 0xFFFF)) + return IXGBE_NOT_IMPLEMENTED; + + offset = ets_offset; + if (hw->eeprom.ops.read(hw, offset, &ets_cfg)) + goto eeprom_err; + if (((ets_cfg & IXGBE_ETS_TYPE_MASK) >> IXGBE_ETS_TYPE_SHIFT) + != IXGBE_ETS_TYPE_EMC) + return IXGBE_NOT_IMPLEMENTED; + + low_thresh_delta = ((ets_cfg & IXGBE_ETS_LTHRES_DELTA_MASK) >> + IXGBE_ETS_LTHRES_DELTA_SHIFT); + num_sensors = (ets_cfg & IXGBE_ETS_NUM_SENSORS_MASK); + + for (i = 0; i < num_sensors; i++) { + offset = ets_offset + 1 + i; + if (hw->eeprom.ops.read(hw, offset, &ets_sensor)) { + ERROR_REPORT2(IXGBE_ERROR_INVALID_STATE, + "eeprom read at offset %d failed", + offset); + continue; + } + sensor_index = ((ets_sensor & IXGBE_ETS_DATA_INDEX_MASK) >> + IXGBE_ETS_DATA_INDEX_SHIFT); + sensor_location = ((ets_sensor & IXGBE_ETS_DATA_LOC_MASK) >> + IXGBE_ETS_DATA_LOC_SHIFT); + therm_limit = ets_sensor & IXGBE_ETS_DATA_HTHRESH_MASK; + + hw->phy.ops.write_i2c_byte(hw, + ixgbe_emc_therm_limit[sensor_index], + IXGBE_I2C_THERMAL_SENSOR_ADDR, therm_limit); + + if ((i < IXGBE_MAX_SENSORS) && (sensor_location != 0)) { + data->sensor[i].location = sensor_location; + data->sensor[i].caution_thresh = therm_limit; + data->sensor[i].max_op_thresh = therm_limit - + low_thresh_delta; + } + } + return status; + +eeprom_err: + ERROR_REPORT2(IXGBE_ERROR_INVALID_STATE, + "eeprom read at offset %d failed", offset); + return IXGBE_NOT_IMPLEMENTED; +} + /** * ixgbe_bypass_rw_generic - Bit bang data into by_pass FW * diff --git a/sys/dev/ixgbe/ixgbe_common.h b/sys/dev/ixgbe/ixgbe_common.h index 051af213b628..e5a186f73ea9 100644 --- a/sys/dev/ixgbe/ixgbe_common.h +++ b/sys/dev/ixgbe/ixgbe_common.h @@ -43,12 +43,10 @@ IXGBE_WRITE_REG(hw, reg + 4, (u32) (value >> 32)); \ } while (0) #define IXGBE_REMOVED(a) (0) -#if !defined(NO_READ_PBA_RAW) || !defined(NO_WRITE_PBA_RAW) struct ixgbe_pba { u16 word[2]; u16 *pba_block; }; -#endif void ixgbe_dcb_get_rtrup2tc_generic(struct ixgbe_hw *hw, u8 *map); @@ -180,6 +178,18 @@ extern void ixgbe_stop_mac_link_on_d3_82599(struct ixgbe_hw *hw); bool ixgbe_mng_present(struct ixgbe_hw *hw); bool ixgbe_mng_enabled(struct ixgbe_hw *hw); +#define IXGBE_I2C_THERMAL_SENSOR_ADDR 0xF8 +#define IXGBE_EMC_INTERNAL_DATA 0x00 +#define IXGBE_EMC_INTERNAL_THERM_LIMIT 0x20 +#define IXGBE_EMC_DIODE1_DATA 0x01 +#define IXGBE_EMC_DIODE1_THERM_LIMIT 0x19 +#define IXGBE_EMC_DIODE2_DATA 0x23 +#define IXGBE_EMC_DIODE2_THERM_LIMIT 0x1A +#define IXGBE_EMC_DIODE3_DATA 0x2A +#define IXGBE_EMC_DIODE3_THERM_LIMIT 0x30 + +s32 ixgbe_get_thermal_sensor_data_generic(struct ixgbe_hw *hw); +s32 ixgbe_init_thermal_sensor_thresh_generic(struct ixgbe_hw *hw); void ixgbe_get_etk_id(struct ixgbe_hw *hw, struct ixgbe_nvm_version *nvm_ver); void ixgbe_get_oem_prod_version(struct ixgbe_hw *hw, diff --git a/sys/dev/ixgbe/ixgbe_dcb.c b/sys/dev/ixgbe/ixgbe_dcb.c index d096321b23c1..54102f312dbb 100644 --- a/sys/dev/ixgbe/ixgbe_dcb.c +++ b/sys/dev/ixgbe/ixgbe_dcb.c @@ -409,10 +409,8 @@ s32 ixgbe_dcb_get_tc_stats(struct ixgbe_hw *hw, struct ixgbe_hw_stats *stats, case ixgbe_mac_X550: case ixgbe_mac_X550EM_x: case ixgbe_mac_X550EM_a: -#if !defined(NO_82599_SUPPORT) || !defined(NO_X540_SUPPORT) ret = ixgbe_dcb_get_tc_stats_82599(hw, stats, tc_count); break; -#endif default: break; } @@ -440,10 +438,8 @@ s32 ixgbe_dcb_get_pfc_stats(struct ixgbe_hw *hw, struct ixgbe_hw_stats *stats, case ixgbe_mac_X550: case ixgbe_mac_X550EM_x: case ixgbe_mac_X550EM_a: -#if !defined(NO_82599_SUPPORT) || !defined(NO_X540_SUPPORT) ret = ixgbe_dcb_get_pfc_stats_82599(hw, stats, tc_count); break; -#endif default: break; } @@ -482,11 +478,9 @@ s32 ixgbe_dcb_config_rx_arbiter_cee(struct ixgbe_hw *hw, case ixgbe_mac_X550: case ixgbe_mac_X550EM_x: case ixgbe_mac_X550EM_a: -#if !defined(NO_82599_SUPPORT) || !defined(NO_X540_SUPPORT) ret = ixgbe_dcb_config_rx_arbiter_82599(hw, refill, max, bwgid, tsa, map); break; -#endif default: break; } @@ -524,11 +518,9 @@ s32 ixgbe_dcb_config_tx_desc_arbiter_cee(struct ixgbe_hw *hw, case ixgbe_mac_X550: case ixgbe_mac_X550EM_x: case ixgbe_mac_X550EM_a: -#if !defined(NO_82599_SUPPORT) || !defined(NO_X540_SUPPORT) ret = ixgbe_dcb_config_tx_desc_arbiter_82599(hw, refill, max, bwgid, tsa); break; -#endif default: break; } @@ -568,12 +560,10 @@ s32 ixgbe_dcb_config_tx_data_arbiter_cee(struct ixgbe_hw *hw, case ixgbe_mac_X550: case ixgbe_mac_X550EM_x: case ixgbe_mac_X550EM_a: -#if !defined(NO_82599_SUPPORT) || !defined(NO_X540_SUPPORT) ret = ixgbe_dcb_config_tx_data_arbiter_82599(hw, refill, max, bwgid, tsa, map); break; -#endif default: break; } @@ -606,10 +596,8 @@ s32 ixgbe_dcb_config_pfc_cee(struct ixgbe_hw *hw, case ixgbe_mac_X550: case ixgbe_mac_X550EM_x: case ixgbe_mac_X550EM_a: -#if !defined(NO_82599_SUPPORT) || !defined(NO_X540_SUPPORT) ret = ixgbe_dcb_config_pfc_82599(hw, pfc_en, map); break; -#endif default: break; } @@ -635,10 +623,8 @@ s32 ixgbe_dcb_config_tc_stats(struct ixgbe_hw *hw) case ixgbe_mac_X550: case ixgbe_mac_X550EM_x: case ixgbe_mac_X550EM_a: -#if !defined(NO_82599_SUPPORT) || !defined(NO_X540_SUPPORT) ret = ixgbe_dcb_config_tc_stats_82599(hw, NULL); break; -#endif default: break; } @@ -683,7 +669,6 @@ s32 ixgbe_dcb_hw_config_cee(struct ixgbe_hw *hw, case ixgbe_mac_X550: case ixgbe_mac_X550EM_x: case ixgbe_mac_X550EM_a: -#if !defined(NO_82599_SUPPORT) || !defined(NO_X540_SUPPORT) ixgbe_dcb_config_82599(hw, dcb_config); ret = ixgbe_dcb_hw_config_82599(hw, dcb_config->link_speed, refill, max, bwgid, @@ -691,7 +676,6 @@ s32 ixgbe_dcb_hw_config_cee(struct ixgbe_hw *hw, ixgbe_dcb_config_tc_stats_82599(hw, dcb_config); break; -#endif default: break; } @@ -718,10 +702,8 @@ s32 ixgbe_dcb_config_pfc(struct ixgbe_hw *hw, u8 pfc_en, u8 *map) case ixgbe_mac_X550: case ixgbe_mac_X550EM_x: case ixgbe_mac_X550EM_a: -#if !defined(NO_82599_SUPPORT) || !defined(NO_X540_SUPPORT) ret = ixgbe_dcb_config_pfc_82599(hw, pfc_en, map); break; -#endif default: break; } @@ -744,7 +726,6 @@ s32 ixgbe_dcb_hw_config(struct ixgbe_hw *hw, u16 *refill, u16 *max, case ixgbe_mac_X550: case ixgbe_mac_X550EM_x: case ixgbe_mac_X550EM_a: -#if !defined(NO_82599_SUPPORT) || !defined(NO_X540_SUPPORT) ixgbe_dcb_config_rx_arbiter_82599(hw, refill, max, bwg_id, tsa, map); ixgbe_dcb_config_tx_desc_arbiter_82599(hw, refill, max, bwg_id, @@ -752,7 +733,6 @@ s32 ixgbe_dcb_hw_config(struct ixgbe_hw *hw, u16 *refill, u16 *max, ixgbe_dcb_config_tx_data_arbiter_82599(hw, refill, max, bwg_id, tsa, map); break; -#endif default: break; } diff --git a/sys/dev/ixgbe/ixgbe_mbx.c b/sys/dev/ixgbe/ixgbe_mbx.c index f72bbf34256a..443ebb478993 100644 --- a/sys/dev/ixgbe/ixgbe_mbx.c +++ b/sys/dev/ixgbe/ixgbe_mbx.c @@ -36,6 +36,118 @@ #include "ixgbe_type.h" #include "ixgbe_mbx.h" +/** + * ixgbe_read_mbx - Reads a message from the mailbox + * @hw: pointer to the HW structure + * @msg: The message buffer + * @size: Length of buffer + * @mbx_id: id of mailbox to read + * + * returns SUCCESS if it successfully read message from buffer + **/ +s32 ixgbe_read_mbx(struct ixgbe_hw *hw, u32 *msg, u16 size, u16 mbx_id) +{ + struct ixgbe_mbx_info *mbx = &hw->mbx; + s32 ret_val = IXGBE_ERR_MBX; + + DEBUGFUNC("ixgbe_read_mbx"); + + /* limit read to size of mailbox */ + if (size > mbx->size) + size = mbx->size; + + if (mbx->ops.read) + ret_val = mbx->ops.read(hw, msg, size, mbx_id); + + return ret_val; +} + +/** + * ixgbe_write_mbx - Write a message to the mailbox + * @hw: pointer to the HW structure + * @msg: The message buffer + * @size: Length of buffer + * @mbx_id: id of mailbox to write + * + * returns SUCCESS if it successfully copied message into the buffer + **/ +s32 ixgbe_write_mbx(struct ixgbe_hw *hw, u32 *msg, u16 size, u16 mbx_id) +{ + struct ixgbe_mbx_info *mbx = &hw->mbx; + s32 ret_val = IXGBE_SUCCESS; + + DEBUGFUNC("ixgbe_write_mbx"); + + if (size > mbx->size) { + ret_val = IXGBE_ERR_MBX; + ERROR_REPORT2(IXGBE_ERROR_ARGUMENT, + "Invalid mailbox message size %d", size); + } else if (mbx->ops.write) + ret_val = mbx->ops.write(hw, msg, size, mbx_id); + + return ret_val; +} + +/** + * ixgbe_check_for_msg - checks to see if someone sent us mail + * @hw: pointer to the HW structure + * @mbx_id: id of mailbox to check + * + * returns SUCCESS if the Status bit was found or else ERR_MBX + **/ +s32 ixgbe_check_for_msg(struct ixgbe_hw *hw, u16 mbx_id) +{ + struct ixgbe_mbx_info *mbx = &hw->mbx; + s32 ret_val = IXGBE_ERR_MBX; + + DEBUGFUNC("ixgbe_check_for_msg"); + + if (mbx->ops.check_for_msg) + ret_val = mbx->ops.check_for_msg(hw, mbx_id); + + return ret_val; +} + +/** + * ixgbe_check_for_ack - checks to see if someone sent us ACK + * @hw: pointer to the HW structure + * @mbx_id: id of mailbox to check + * + * returns SUCCESS if the Status bit was found or else ERR_MBX + **/ +s32 ixgbe_check_for_ack(struct ixgbe_hw *hw, u16 mbx_id) +{ + struct ixgbe_mbx_info *mbx = &hw->mbx; + s32 ret_val = IXGBE_ERR_MBX; + + DEBUGFUNC("ixgbe_check_for_ack"); + + if (mbx->ops.check_for_ack) + ret_val = mbx->ops.check_for_ack(hw, mbx_id); + + return ret_val; +} + +/** + * ixgbe_check_for_rst - checks to see if other side has reset + * @hw: pointer to the HW structure + * @mbx_id: id of mailbox to check + * + * returns SUCCESS if the Status bit was found or else ERR_MBX + **/ +s32 ixgbe_check_for_rst(struct ixgbe_hw *hw, u16 mbx_id) +{ + struct ixgbe_mbx_info *mbx = &hw->mbx; + s32 ret_val = IXGBE_ERR_MBX; + + DEBUGFUNC("ixgbe_check_for_rst"); + + if (mbx->ops.check_for_rst) + ret_val = mbx->ops.check_for_rst(hw, mbx_id); + + return ret_val; +} + /** * ixgbe_poll_for_msg - Wait for message notification * @hw: pointer to the HW structure @@ -110,7 +222,7 @@ out: * returns SUCCESS if it successfully received a message notification and * copied it into the receive buffer. **/ -static s32 ixgbe_read_posted_mbx(struct ixgbe_hw *hw, u32 *msg, u16 size, +s32 ixgbe_read_posted_mbx(struct ixgbe_hw *hw, u32 *msg, u16 size, u16 mbx_id) { struct ixgbe_mbx_info *mbx = &hw->mbx; @@ -140,7 +252,7 @@ out: * returns SUCCESS if it successfully copied message into the buffer and * received an ack to that message within delay * timeout period **/ -static s32 ixgbe_write_posted_mbx(struct ixgbe_hw *hw, u32 *msg, u16 size, +s32 ixgbe_write_posted_mbx(struct ixgbe_hw *hw, u32 *msg, u16 size, u16 mbx_id) { struct ixgbe_mbx_info *mbx = &hw->mbx; diff --git a/sys/dev/ixgbe/ixgbe_mbx.h b/sys/dev/ixgbe/ixgbe_mbx.h index 9b3deb28f149..88387ea3f7c2 100644 --- a/sys/dev/ixgbe/ixgbe_mbx.h +++ b/sys/dev/ixgbe/ixgbe_mbx.h @@ -153,6 +153,13 @@ enum ixgbevf_xcast_modes { #define IXGBE_VF_MBX_INIT_TIMEOUT 2000 /* number of retries on mailbox */ #define IXGBE_VF_MBX_INIT_DELAY 500 /* microseconds between retries */ +s32 ixgbe_read_mbx(struct ixgbe_hw *, u32 *, u16, u16); +s32 ixgbe_write_mbx(struct ixgbe_hw *, u32 *, u16, u16); +s32 ixgbe_read_posted_mbx(struct ixgbe_hw *, u32 *, u16, u16); +s32 ixgbe_write_posted_mbx(struct ixgbe_hw *, u32 *, u16, u16); +s32 ixgbe_check_for_msg(struct ixgbe_hw *, u16); +s32 ixgbe_check_for_ack(struct ixgbe_hw *, u16); +s32 ixgbe_check_for_rst(struct ixgbe_hw *, u16); void ixgbe_init_mbx_ops_generic(struct ixgbe_hw *hw); void ixgbe_init_mbx_params_vf(struct ixgbe_hw *); void ixgbe_init_mbx_params_pf(struct ixgbe_hw *); diff --git a/sys/dev/ixgbe/ixgbe_phy.c b/sys/dev/ixgbe/ixgbe_phy.c index 5a2f49e9ebac..eef1d40448d3 100644 --- a/sys/dev/ixgbe/ixgbe_phy.c +++ b/sys/dev/ixgbe/ixgbe_phy.c @@ -1536,7 +1536,10 @@ s32 ixgbe_identify_sfp_module_generic(struct ixgbe_hw *hw) status = IXGBE_SUCCESS; } else { if (hw->allow_unsupported_sfp == true) { - EWARN(hw, "WARNING: Intel (R) Network Connections are quality tested using Intel (R) Ethernet Optics. Using untested modules is not supported and may cause unstable operation or damage to the module or the adapter. Intel Corporation is not responsible for any harm caused by using untested modules.\n"); + EWARN(hw, + "WARNING: Intel (R) Network Connections are quality tested using Intel (R) Ethernet Optics. " + "Using untested modules is not supported and may cause unstable operation or damage to the module or the adapter. " + "Intel Corporation is not responsible for any harm caused by using untested modules.\n"); status = IXGBE_SUCCESS; } else { DEBUGOUT("SFP+ module not supported\n"); @@ -1789,7 +1792,10 @@ s32 ixgbe_identify_qsfp_module_generic(struct ixgbe_hw *hw) status = IXGBE_SUCCESS; } else { if (hw->allow_unsupported_sfp == true) { - EWARN(hw, "WARNING: Intel (R) Network Connections are quality tested using Intel (R) Ethernet Optics. Using untested modules is not supported and may cause unstable operation or damage to the module or the adapter. Intel Corporation is not responsible for any harm caused by using untested modules.\n"); + EWARN(hw, + "WARNING: Intel (R) Network Connections are quality tested using Intel (R) Ethernet Optics. " + "Using untested modules is not supported and may cause unstable operation or damage to the module or the adapter. " + "Intel Corporation is not responsible for any harm caused by using untested modules.\n"); status = IXGBE_SUCCESS; } else { DEBUGOUT("QSFP module not supported\n"); @@ -2571,7 +2577,6 @@ static bool ixgbe_get_i2c_data(struct ixgbe_hw *hw, u32 *i2cctl) { u32 data_oe_bit = IXGBE_I2C_DATA_OE_N_EN_BY_MAC(hw); bool data; - UNREFERENCED_1PARAMETER(hw); DEBUGFUNC("ixgbe_get_i2c_data"); diff --git a/sys/dev/ixgbe/ixgbe_phy.h b/sys/dev/ixgbe/ixgbe_phy.h index 7f51ccc1dd2c..09d7ea4afbc0 100644 --- a/sys/dev/ixgbe/ixgbe_phy.h +++ b/sys/dev/ixgbe/ixgbe_phy.h @@ -147,10 +147,8 @@ #define IXGBE_I2C_T_SU_STO 4 #define IXGBE_I2C_T_BUF 5 -#ifndef IXGBE_SFP_DETECT_RETRIES #define IXGBE_SFP_DETECT_RETRIES 10 -#endif /* IXGBE_SFP_DETECT_RETRIES */ #define IXGBE_TN_LASI_STATUS_REG 0x9005 #define IXGBE_TN_LASI_STATUS_TEMP_ALARM 0x0008 diff --git a/sys/dev/ixgbe/ixgbe_type.h b/sys/dev/ixgbe/ixgbe_type.h index 1c04f09df77c..1eb446184990 100644 --- a/sys/dev/ixgbe/ixgbe_type.h +++ b/sys/dev/ixgbe/ixgbe_type.h @@ -48,8 +48,8 @@ * * - IXGBE_ERROR_POLLING * This category is for errors related to polling/timeout issues and should be - * used in any case where the timeout occurred, or a failure to obtain a lock, or - * failure to receive data within the time limit. + * used in any case where the timeout occurred, or a failure to obtain a lock, + * or failure to receive data within the time limit. * * - IXGBE_ERROR_CAUTION * This category should be used for reporting issues that may be the cause of @@ -157,7 +157,7 @@ #define IXGBE_DEV_ID_X550EM_X_VF 0x15A8 #define IXGBE_DEV_ID_X550EM_X_VF_HV 0x15A9 -#define IXGBE_CAT(r,m) IXGBE_##r##m +#define IXGBE_CAT(r, m) IXGBE_##r##m #define IXGBE_BY_MAC(_hw, r) ((_hw)->mvals[IXGBE_CAT(r, _IDX)]) @@ -284,6 +284,26 @@ #define IXGBE_I2C_CLK_OE_N_EN_BY_MAC(_hw) IXGBE_BY_MAC((_hw), I2C_CLK_OE_N_EN) #define IXGBE_I2C_CLOCK_STRETCHING_TIMEOUT 500 +#define IXGBE_I2C_THERMAL_SENSOR_ADDR 0xF8 +#define IXGBE_EMC_INTERNAL_DATA 0x00 +#define IXGBE_EMC_INTERNAL_THERM_LIMIT 0x20 +#define IXGBE_EMC_DIODE1_DATA 0x01 +#define IXGBE_EMC_DIODE1_THERM_LIMIT 0x19 +#define IXGBE_EMC_DIODE2_DATA 0x23 +#define IXGBE_EMC_DIODE2_THERM_LIMIT 0x1A + +#define IXGBE_MAX_SENSORS 3 + +struct ixgbe_thermal_diode_data { + u8 location; + u8 temp; + u8 caution_thresh; + u8 max_op_thresh; +}; + +struct ixgbe_thermal_sensor_data { + struct ixgbe_thermal_diode_data sensor[IXGBE_MAX_SENSORS]; +}; #define NVM_OROM_OFFSET 0x17 @@ -2358,6 +2378,20 @@ enum { #define IXGBE_ALT_MAC_ADDR_PTR 0x37 #define IXGBE_FREE_SPACE_PTR 0X3E +/* External Thermal Sensor Config */ +#define IXGBE_ETS_CFG 0x26 +#define IXGBE_ETS_LTHRES_DELTA_MASK 0x07C0 +#define IXGBE_ETS_LTHRES_DELTA_SHIFT 6 +#define IXGBE_ETS_TYPE_MASK 0x0038 +#define IXGBE_ETS_TYPE_SHIFT 3 +#define IXGBE_ETS_TYPE_EMC 0x000 +#define IXGBE_ETS_NUM_SENSORS_MASK 0x0007 +#define IXGBE_ETS_DATA_LOC_MASK 0x3C00 +#define IXGBE_ETS_DATA_LOC_SHIFT 10 +#define IXGBE_ETS_DATA_INDEX_MASK 0x0300 +#define IXGBE_ETS_DATA_INDEX_SHIFT 8 +#define IXGBE_ETS_DATA_HTHRESH_MASK 0x00FF + #define IXGBE_SAN_MAC_ADDR_PTR 0x28 #define IXGBE_DEVICE_CAPS 0x2C #define IXGBE_82599_SERIAL_NUMBER_MAC_ADDR 0x11 @@ -2412,9 +2446,7 @@ enum { #define IXGBE_EEPROM_CTRL_2 1 /* EEPROM CTRL word 2 */ #define IXGBE_EEPROM_CCD_BIT 2 -#ifndef IXGBE_EEPROM_GRANT_ATTEMPTS #define IXGBE_EEPROM_GRANT_ATTEMPTS 1000 /* EEPROM attempts to gain grant */ -#endif /* Number of 5 microseconds we wait for EERD read and * EERW write to complete */ @@ -3932,7 +3964,6 @@ struct ixgbe_mac_operations { s32 (*get_fcoe_boot_status)(struct ixgbe_hw *, u16 *); s32 (*stop_adapter)(struct ixgbe_hw *); s32 (*get_bus_info)(struct ixgbe_hw *); - s32 (*negotiate_api_version)(struct ixgbe_hw *, int); void (*set_lan_id)(struct ixgbe_hw *); s32 (*read_analog_reg8)(struct ixgbe_hw*, u32, u8*); s32 (*write_analog_reg8)(struct ixgbe_hw*, u32, u8); @@ -3945,6 +3976,7 @@ struct ixgbe_mac_operations { void (*init_swfw_sync)(struct ixgbe_hw *); s32 (*prot_autoc_read)(struct ixgbe_hw *, bool *, u32 *); s32 (*prot_autoc_write)(struct ixgbe_hw *, u32, bool); + s32 (*negotiate_api_version)(struct ixgbe_hw *hw, int api); /* Link */ void (*disable_tx_laser)(struct ixgbe_hw *); @@ -3980,17 +4012,17 @@ struct ixgbe_mac_operations { ixgbe_mc_addr_itr); s32 (*update_mc_addr_list)(struct ixgbe_hw *, u8 *, u32, ixgbe_mc_addr_itr, bool clear); - s32 (*update_xcast_mode)(struct ixgbe_hw *, int); s32 (*enable_mc)(struct ixgbe_hw *); s32 (*disable_mc)(struct ixgbe_hw *); s32 (*clear_vfta)(struct ixgbe_hw *); s32 (*set_vfta)(struct ixgbe_hw *, u32, u32, bool, bool); s32 (*set_vlvf)(struct ixgbe_hw *, u32, u32, bool, u32 *, u32, bool); - s32 (*set_rlpml)(struct ixgbe_hw *, u16); s32 (*init_uta_tables)(struct ixgbe_hw *); void (*set_mac_anti_spoofing)(struct ixgbe_hw *, bool, int); void (*set_vlan_anti_spoofing)(struct ixgbe_hw *, bool, int); + s32 (*update_xcast_mode)(struct ixgbe_hw *, int); + s32 (*set_rlpml)(struct ixgbe_hw *, u16); /* Flow Control */ s32 (*fc_enable)(struct ixgbe_hw *); @@ -4000,6 +4032,8 @@ struct ixgbe_mac_operations { /* Manageability interface */ s32 (*set_fw_drv_ver)(struct ixgbe_hw *, u8, u8, u8, u8, u16, const char *); + s32 (*get_thermal_sensor_data)(struct ixgbe_hw *); + s32 (*init_thermal_sensor_thresh)(struct ixgbe_hw *hw); s32 (*bypass_rw) (struct ixgbe_hw *hw, u32 cmd, u32 *status); bool (*bypass_valid_rd) (u32 in_reg, u32 out_reg); s32 (*bypass_set) (struct ixgbe_hw *hw, u32 cmd, u32 event, u32 action); @@ -4107,6 +4141,8 @@ struct ixgbe_mac_info { bool orig_link_settings_stored; bool autotry_restart; u8 flags; + struct ixgbe_thermal_sensor_data thermal_sensor_data; + bool thermal_sensor_enabled; struct ixgbe_dmac_config dmac_config; bool set_lben; u32 max_link_up_time; diff --git a/sys/dev/ixgbe/ixgbe_vf.c b/sys/dev/ixgbe/ixgbe_vf.c index 82800b4a3d87..f70f4d667aee 100644 --- a/sys/dev/ixgbe/ixgbe_vf.c +++ b/sys/dev/ixgbe/ixgbe_vf.c @@ -36,12 +36,8 @@ #include "ixgbe.h" -#ifndef IXGBE_VFWRITE_REG #define IXGBE_VFWRITE_REG IXGBE_WRITE_REG -#endif -#ifndef IXGBE_VFREAD_REG #define IXGBE_VFREAD_REG IXGBE_READ_REG -#endif /** * ixgbe_init_ops_vf - Initialize the pointers for vf diff --git a/sys/dev/ixgbe/ixgbe_x540.c b/sys/dev/ixgbe/ixgbe_x540.c index d03b34ee8135..ea45cd31a4c3 100644 --- a/sys/dev/ixgbe/ixgbe_x540.c +++ b/sys/dev/ixgbe/ixgbe_x540.c @@ -819,7 +819,7 @@ s32 ixgbe_acquire_swfw_sync_X540(struct ixgbe_hw *hw, u32 mask) * bits in the SW_FW_SYNC register. */ if (ixgbe_get_swfw_sync_semaphore(hw)) { - DEBUGOUT("Failed to get NVM sempahore and register semaphore while forcefully ignoring FW sempahore bit(s) and setting SW semaphore bit(s), returning IXGBE_ERR_SWFW_SYNC\n"); + DEBUGOUT("Failed to get NVM semaphore and register semaphore while forcefully ignoring FW semaphore bit(s) and setting SW semaphore bit(s), returning IXGBE_ERR_SWFW_SYNC\n"); return IXGBE_ERR_SWFW_SYNC; } swfw_sync = IXGBE_READ_REG(hw, IXGBE_SWFW_SYNC_BY_MAC(hw)); diff --git a/sys/dev/ixgbe/ixgbe_x550.c b/sys/dev/ixgbe/ixgbe_x550.c index 7fc556662b00..3353d91e228e 100644 --- a/sys/dev/ixgbe/ixgbe_x550.c +++ b/sys/dev/ixgbe/ixgbe_x550.c @@ -619,6 +619,10 @@ s32 ixgbe_init_ops_X550EM(struct ixgbe_hw *hw) * the pointers to NULL explicitly here to overwrite * the values being set in the x540 function. */ + /* Thermal sensor not supported in x550EM */ + mac->ops.get_thermal_sensor_data = NULL; + mac->ops.init_thermal_sensor_thresh = NULL; + mac->thermal_sensor_enabled = false; /* Bypass not supported in x550EM */ mac->ops.bypass_rw = NULL; @@ -1135,7 +1139,7 @@ s32 ixgbe_write_iosf_sb_reg_x550(struct ixgbe_hw *hw, u32 reg_addr, u32 device_type, u32 data) { u32 gssr = IXGBE_GSSR_PHY1_SM | IXGBE_GSSR_PHY0_SM; - u32 command, error __unused; + u32 command, error; s32 ret; ret = ixgbe_acquire_swfw_semaphore(hw, gssr); @@ -1181,7 +1185,7 @@ s32 ixgbe_read_iosf_sb_reg_x550(struct ixgbe_hw *hw, u32 reg_addr, u32 device_type, u32 *data) { u32 gssr = IXGBE_GSSR_PHY1_SM | IXGBE_GSSR_PHY0_SM; - u32 command, error __unused; + u32 command, error; s32 ret; ret = ixgbe_acquire_swfw_semaphore(hw, gssr); @@ -2716,7 +2720,7 @@ static s32 ixgbe_setup_sfi_x550a(struct ixgbe_hw *hw, ixgbe_link_speed *speed) * @speed: new link speed * @autoneg_wait_to_complete: unused * - * Configure the the integrated PHY for SFP support. + * Configure the integrated PHY for SFP support. **/ s32 ixgbe_setup_mac_link_sfp_x550a(struct ixgbe_hw *hw, ixgbe_link_speed speed, @@ -3688,7 +3692,7 @@ u64 ixgbe_get_supported_physical_layer_X550em(struct ixgbe_hw *hw) physical_layer = IXGBE_PHYSICAL_LAYER_1000BASE_KX; break; case ixgbe_phy_ext_1g_t: - physical_layer = IXGBE_PHYSICAL_LAYER_1000BASE_T; + physical_layer |= IXGBE_PHYSICAL_LAYER_1000BASE_T; break; default: break; From nobody Wed Oct 13 00:36:48 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 5D96017EC7BD; Wed, 13 Oct 2021 00:36: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 4HTYWP25lzz3N6n; Wed, 13 Oct 2021 00:36: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 218231DDE8; Wed, 13 Oct 2021 00:36: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 19D0amJF060382; Wed, 13 Oct 2021 00: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 19D0amwp060381; Wed, 13 Oct 2021 00:36:48 GMT (envelope-from git) Date: Wed, 13 Oct 2021 00:36:48 GMT Message-Id: <202110130036.19D0amwp060381@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: 16dfe02e38b9 - stable/13 - syslogd: Fix bug that caused -N to drop SecureMode if specified after -s List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 16dfe02e38b957206ddda0cffd7e938b01fa1302 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=16dfe02e38b957206ddda0cffd7e938b01fa1302 commit 16dfe02e38b957206ddda0cffd7e938b01fa1302 Author: jfranklin13 AuthorDate: 2021-09-28 14:49:15 +0000 Commit: Mark Johnston CommitDate: 2021-10-13 00:36:11 +0000 syslogd: Fix bug that caused -N to drop SecureMode if specified after -s Pull Request: https://github.com/freebsd/freebsd-src/pull/541 (cherry picked from commit 9589362bc980290ff84fe61814e5716dea79e931) --- usr.sbin/syslogd/syslogd.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/usr.sbin/syslogd/syslogd.c b/usr.sbin/syslogd/syslogd.c index 9ed0b8098753..c3b8af4fa8fa 100644 --- a/usr.sbin/syslogd/syslogd.c +++ b/usr.sbin/syslogd/syslogd.c @@ -677,7 +677,8 @@ main(int argc, char *argv[]) break; case 'N': NoBind = 1; - SecureMode = 1; + if (!SecureMode) + SecureMode = 1; break; case 'n': resolve = 0; From nobody Wed Oct 13 00:36:50 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 6A88F17EC669; Wed, 13 Oct 2021 00:36: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 4HTYWQ2VFMz3N0M; Wed, 13 Oct 2021 00:36: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 362CF1E24D; Wed, 13 Oct 2021 00:36: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 19D0aoJo060406; Wed, 13 Oct 2021 00:36:50 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19D0aoXb060405; Wed, 13 Oct 2021 00:36:50 GMT (envelope-from git) Date: Wed, 13 Oct 2021 00:36:50 GMT Message-Id: <202110130036.19D0aoXb060405@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: e49d57eecc8e - stable/13 - linuxkpi: Handle a NULL cache pointer in kmem_cache_destroy() List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: e49d57eecc8e4cb2247fc667928e91f62d392ca0 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=e49d57eecc8e4cb2247fc667928e91f62d392ca0 commit e49d57eecc8e4cb2247fc667928e91f62d392ca0 Author: Mark Johnston AuthorDate: 2021-10-06 18:45:22 +0000 Commit: Mark Johnston CommitDate: 2021-10-13 00:36:18 +0000 linuxkpi: Handle a NULL cache pointer in kmem_cache_destroy() This is compatible with Linux, and some driver error paths depend on it. Reviewed by: bz, emaste Sponsored by: The FreeBSD Foundation (cherry picked from commit a76de17715ab689b0b53a1012e22d8a08470b6e4) --- sys/compat/linuxkpi/common/src/linux_slab.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sys/compat/linuxkpi/common/src/linux_slab.c b/sys/compat/linuxkpi/common/src/linux_slab.c index 35a88fd7cf42..0aa751ec886e 100644 --- a/sys/compat/linuxkpi/common/src/linux_slab.c +++ b/sys/compat/linuxkpi/common/src/linux_slab.c @@ -193,6 +193,9 @@ lkpi_kmem_cache_free(struct linux_kmem_cache *c, void *m) void linux_kmem_cache_destroy(struct linux_kmem_cache *c) { + if (c == NULL) + return; + if (unlikely(c->cache_flags & SLAB_TYPESAFE_BY_RCU)) { /* make sure all free callbacks have been called */ rcu_barrier(); From nobody Wed Oct 13 02:11:52 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 431BE17F8E7F; Wed, 13 Oct 2021 02: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 4HTbd41Pfgz4dpF; Wed, 13 Oct 2021 02: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 112661F5D4; Wed, 13 Oct 2021 02: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 19D2BqGA092604; Wed, 13 Oct 2021 02: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 19D2BqAg092603; Wed, 13 Oct 2021 02:11:52 GMT (envelope-from git) Date: Wed, 13 Oct 2021 02:11:52 GMT Message-Id: <202110130211.19D2BqAg092603@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kevin Bowling Subject: git: 884b89510faa - stable/13 - e1000: Lock nvm print sysctl List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kbowling X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 884b89510faa219c7345dcb3ce67286abba96768 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by kbowling (ports committer): URL: https://cgit.FreeBSD.org/src/commit/?id=884b89510faa219c7345dcb3ce67286abba96768 commit 884b89510faa219c7345dcb3ce67286abba96768 Author: Kevin Bowling AuthorDate: 2021-10-06 23:20:26 +0000 Commit: Kevin Bowling CommitDate: 2021-10-13 02:10:54 +0000 e1000: Lock nvm print sysctl Otherwise results in KASSERT with debug kernels because we rely on the iflib CTX lock to implement the software serialization to the NVM model Reviewed by: gallatin MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D32333 (cherry picked from commit 9b3e252e59c6e63594fb20e3f65188dab9e1eeff) --- sys/dev/e1000/if_em.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/sys/dev/e1000/if_em.c b/sys/dev/e1000/if_em.c index 3153a44000c5..52eff393e848 100644 --- a/sys/dev/e1000/if_em.c +++ b/sys/dev/e1000/if_em.c @@ -4510,20 +4510,27 @@ em_sysctl_nvm_info(SYSCTL_HANDLER_ARGS) static void em_print_nvm_info(struct e1000_softc *sc) { + struct e1000_hw *hw = &sc->hw; + struct sx *iflib_ctx_lock = iflib_ctx_lock_get(sc->ctx); u16 eeprom_data; int i, j, row = 0; /* Its a bit crude, but it gets the job done */ printf("\nInterface EEPROM Dump:\n"); printf("Offset\n0x0000 "); + + /* We rely on the IFLIB_CTX_LOCK as part of NVM locking model */ + sx_xlock(iflib_ctx_lock); + ASSERT_CTX_LOCK_HELD(hw); for (i = 0, j = 0; i < 32; i++, j++) { if (j == 8) { /* Make the offset block */ j = 0; ++row; printf("\n0x00%x0 ",row); } - e1000_read_nvm(&sc->hw, i, 1, &eeprom_data); + e1000_read_nvm(hw, i, 1, &eeprom_data); printf("%04x ", eeprom_data); } + sx_xunlock(iflib_ctx_lock); printf("\n"); } From nobody Wed Oct 13 02:11:53 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id A04C517F91BA; Wed, 13 Oct 2021 02:11: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 4HTbd53CZFz4dpP; Wed, 13 Oct 2021 02:11: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 367CF1F831; Wed, 13 Oct 2021 02:11: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 19D2BrVu092628; Wed, 13 Oct 2021 02:11:53 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19D2BrD6092627; Wed, 13 Oct 2021 02:11:53 GMT (envelope-from git) Date: Wed, 13 Oct 2021 02:11:53 GMT Message-Id: <202110130211.19D2BrD6092627@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kevin Bowling Subject: git: 73922769f0c2 - stable/13 - e1000: print EEPROM/NVM/OROM versions List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kbowling X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 73922769f0c2f70da78f680eed6b3c91911235da Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by kbowling (ports committer): URL: https://cgit.FreeBSD.org/src/commit/?id=73922769f0c2f70da78f680eed6b3c91911235da commit 73922769f0c2f70da78f680eed6b3c91911235da Author: Kevin Bowling AuthorDate: 2021-10-06 23:25:03 +0000 Commit: Kevin Bowling CommitDate: 2021-10-13 02:11:18 +0000 e1000: print EEPROM/NVM/OROM versions This is useful for diagnosing problems. In particular, the errata sheets identify the EEPROM version for many fixes. Reviewed by: gallatin MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D32333 (cherry picked from commit 293663f4da9e8b8aeb106ce3b73a8ed2aa2a8a90) --- sys/dev/e1000/if_em.c | 185 ++++++++++++++++++++++++++++++++++++++++++-------- sys/dev/e1000/if_em.h | 3 + 2 files changed, 158 insertions(+), 30 deletions(-) diff --git a/sys/dev/e1000/if_em.c b/sys/dev/e1000/if_em.c index 52eff393e848..b3775b351c70 100644 --- a/sys/dev/e1000/if_em.c +++ b/sys/dev/e1000/if_em.c @@ -305,6 +305,10 @@ static void em_if_vlan_filter_write(struct e1000_softc *); static void em_setup_vlan_hw_support(struct e1000_softc *); static int em_sysctl_nvm_info(SYSCTL_HANDLER_ARGS); static void em_print_nvm_info(struct e1000_softc *); +static void em_fw_version_locked(if_ctx_t); +static void em_sbuf_fw_version(struct e1000_fw_version *, struct sbuf *); +static void em_print_fw_version(struct e1000_softc *); +static int em_sysctl_print_fw_version(SYSCTL_HANDLER_ARGS); static int em_sysctl_debug_info(SYSCTL_HANDLER_ARGS); static int em_get_rs(SYSCTL_HANDLER_ARGS); static void em_print_debug_info(struct e1000_softc *); @@ -792,6 +796,8 @@ em_if_attach_pre(if_ctx_t ctx) if_softc_ctx_t scctx; device_t dev; struct e1000_hw *hw; + struct sysctl_oid_list *child; + struct sysctl_ctx_list *ctx_list; int error = 0; INIT_DEBUGOUT("em_if_attach_pre: begin"); @@ -806,37 +812,38 @@ em_if_attach_pre(if_ctx_t ctx) sc->tx_process_limit = scctx->isc_ntxd[0]; + /* Determine hardware and mac info */ + em_identify_hardware(ctx); + /* SYSCTL stuff */ - SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev), - SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), - OID_AUTO, "nvm", CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, - sc, 0, em_sysctl_nvm_info, "I", "NVM Information"); - - SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev), - SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), - OID_AUTO, "debug", CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, - sc, 0, em_sysctl_debug_info, "I", "Debug Information"); - - SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev), - SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), - OID_AUTO, "fc", CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, - sc, 0, em_set_flowcntl, "I", "Flow Control"); - - SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev), - SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), - OID_AUTO, "reg_dump", + ctx_list = device_get_sysctl_ctx(dev); + child = SYSCTL_CHILDREN(device_get_sysctl_tree(dev)); + + SYSCTL_ADD_PROC(ctx_list, child, OID_AUTO, "nvm", + CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, sc, 0, + em_sysctl_nvm_info, "I", "NVM Information"); + + SYSCTL_ADD_PROC(ctx_list, child, OID_AUTO, "fw_version", + CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_NEEDGIANT, sc, 0, + em_sysctl_print_fw_version, "A", + "Prints FW/NVM Versions"); + + SYSCTL_ADD_PROC(ctx_list, child, OID_AUTO, "debug", + CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, sc, 0, + em_sysctl_debug_info, "I", "Debug Information"); + + SYSCTL_ADD_PROC(ctx_list, child, OID_AUTO, "fc", + CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, sc, 0, + em_set_flowcntl, "I", "Flow Control"); + + SYSCTL_ADD_PROC(ctx_list, child, OID_AUTO, "reg_dump", CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_NEEDGIANT, sc, 0, em_get_regs, "A", "Dump Registers"); - SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev), - SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), - OID_AUTO, "rs_dump", + SYSCTL_ADD_PROC(ctx_list, child, OID_AUTO, "rs_dump", CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, sc, 0, em_get_rs, "I", "Dump RS indexes"); - /* Determine hardware and mac info */ - em_identify_hardware(ctx); - scctx->isc_tx_nsegments = EM_MAX_SCATTER; scctx->isc_nrxqsets_max = scctx->isc_ntxqsets_max = em_set_num_queues(ctx); if (bootverbose) @@ -1045,12 +1052,9 @@ em_if_attach_pre(if_ctx_t ctx) /* Sysctl for setting Energy Efficient Ethernet */ hw->dev_spec.ich8lan.eee_disable = eee_setting; - SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev), - SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), - OID_AUTO, "eee_control", - CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, - sc, 0, em_sysctl_eee, "I", - "Disable Energy Efficient Ethernet"); + SYSCTL_ADD_PROC(ctx_list, child, OID_AUTO, "eee_control", + CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, sc, 0, + em_sysctl_eee, "I", "Disable Energy Efficient Ethernet"); /* ** Start from a known state, this is @@ -1093,6 +1097,11 @@ em_if_attach_pre(if_ctx_t ctx) } } + /* Save the EEPROM/NVM versions, must be done under IFLIB_CTX_LOCK */ + em_fw_version_locked(ctx); + + em_print_fw_version(sc); + /* Disable ULP support */ e1000_disable_ulp_lpt_lp(hw, true); @@ -4476,6 +4485,122 @@ em_add_hw_stats(struct e1000_softc *sc) "Interrupt Cause Receiver Overrun Count"); } +static void +em_fw_version_locked(if_ctx_t ctx) +{ + struct e1000_softc *sc = iflib_get_softc(ctx); + struct e1000_hw *hw = &sc->hw; + struct e1000_fw_version *fw_ver = &sc->fw_ver; + uint16_t eep = 0; + + /* + * em_fw_version_locked() must run under the IFLIB_CTX_LOCK to meet the + * NVM locking model, so we do it in em_if_attach_pre() and store the + * info in the softc + */ + ASSERT_CTX_LOCK_HELD(hw); + + *fw_ver = (struct e1000_fw_version){0}; + + if (hw->mac.type >= igb_mac_min) { + /* + * Use the Shared Code for igb(4) + */ + e1000_get_fw_version(hw, fw_ver); + } else { + /* + * Otherwise, EEPROM version should be present on (almost?) all + * devices here + */ + if(e1000_read_nvm(hw, NVM_VERSION, 1, &eep)) { + INIT_DEBUGOUT("can't get EEPROM version"); + return; + } + + fw_ver->eep_major = (eep & NVM_MAJOR_MASK) >> NVM_MAJOR_SHIFT; + fw_ver->eep_minor = (eep & NVM_MINOR_MASK) >> NVM_MINOR_SHIFT; + fw_ver->eep_build = (eep & NVM_IMAGE_ID_MASK); + } +} + +static void +em_sbuf_fw_version(struct e1000_fw_version *fw_ver, struct sbuf *buf) +{ + const char *space = ""; + + if (fw_ver->eep_major || fw_ver->eep_minor || fw_ver->eep_build) { + sbuf_printf(buf, "EEPROM V%d.%d-%d", fw_ver->eep_major, + fw_ver->eep_minor, fw_ver->eep_build); + space = " "; + } + + if (fw_ver->invm_major || fw_ver->invm_minor || fw_ver->invm_img_type) { + sbuf_printf(buf, "%sNVM V%d.%d imgtype%d", + space, fw_ver->invm_major, fw_ver->invm_minor, + fw_ver->invm_img_type); + space = " "; + } + + if (fw_ver->or_valid) { + sbuf_printf(buf, "%sOption ROM V%d-b%d-p%d", + space, fw_ver->or_major, fw_ver->or_build, + fw_ver->or_patch); + space = " "; + } + + if (fw_ver->etrack_id) + sbuf_printf(buf, "%seTrack 0x%08x", space, fw_ver->etrack_id); +} + +static void +em_print_fw_version(struct e1000_softc *sc ) +{ + device_t dev = sc->dev; + struct sbuf *buf; + int error = 0; + + buf = sbuf_new_auto(); + if (!buf) { + device_printf(dev, "Could not allocate sbuf for output.\n"); + return; + } + + em_sbuf_fw_version(&sc->fw_ver, buf); + + error = sbuf_finish(buf); + if (error) + device_printf(dev, "Error finishing sbuf: %d\n", error); + else if (sbuf_len(buf)) + device_printf(dev, "%s\n", sbuf_data(buf)); + + sbuf_delete(buf); +} + +static int +em_sysctl_print_fw_version(SYSCTL_HANDLER_ARGS) +{ + struct e1000_softc *sc = (struct e1000_softc *)arg1; + device_t dev = sc->dev; + struct sbuf *buf; + int error = 0; + + buf = sbuf_new_for_sysctl(NULL, NULL, 128, req); + if (!buf) { + device_printf(dev, "Could not allocate sbuf for output.\n"); + return (ENOMEM); + } + + em_sbuf_fw_version(&sc->fw_ver, buf); + + error = sbuf_finish(buf); + if (error) + device_printf(dev, "Error finishing sbuf: %d\n", error); + + sbuf_delete(buf); + + return (0); +} + /********************************************************************** * * This routine provides a way to dump out the adapter eeprom, diff --git a/sys/dev/e1000/if_em.h b/sys/dev/e1000/if_em.h index 41deecb69bf3..33ba22a88552 100644 --- a/sys/dev/e1000/if_em.h +++ b/sys/dev/e1000/if_em.h @@ -510,6 +510,9 @@ struct e1000_softc { u64 que_mask; + /* We need to store this at attach due to e1000 hw/sw locking model */ + struct e1000_fw_version fw_ver; + struct em_int_delay_info tx_int_delay; struct em_int_delay_info tx_abs_int_delay; struct em_int_delay_info rx_int_delay; From nobody Wed Oct 13 02:16:24 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 98D8217FB12A; Wed, 13 Oct 2021 02:16: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 4HTbkJ3yX6z4gJ8; Wed, 13 Oct 2021 02:16: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 69A2E1F7A8; Wed, 13 Oct 2021 02:16: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 19D2GOrn093036; Wed, 13 Oct 2021 02:16:24 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19D2GONw093035; Wed, 13 Oct 2021 02:16:24 GMT (envelope-from git) Date: Wed, 13 Oct 2021 02:16:24 GMT Message-Id: <202110130216.19D2GONw093035@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kevin Bowling Subject: git: 38d7f1c5b391 - stable/12 - e1000: Lock nvm print sysctl List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kbowling X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 38d7f1c5b39145a9ac58678dba59288ffa85fd5e Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by kbowling (ports committer): URL: https://cgit.FreeBSD.org/src/commit/?id=38d7f1c5b39145a9ac58678dba59288ffa85fd5e commit 38d7f1c5b39145a9ac58678dba59288ffa85fd5e Author: Kevin Bowling AuthorDate: 2021-10-06 23:20:26 +0000 Commit: Kevin Bowling CommitDate: 2021-10-13 02:12:21 +0000 e1000: Lock nvm print sysctl Otherwise results in KASSERT with debug kernels because we rely on the iflib CTX lock to implement the software serialization to the NVM model Reviewed by: gallatin MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D32333 (cherry picked from commit 9b3e252e59c6e63594fb20e3f65188dab9e1eeff) --- sys/dev/e1000/if_em.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/sys/dev/e1000/if_em.c b/sys/dev/e1000/if_em.c index cb6cf647a3e8..9e3064a13005 100644 --- a/sys/dev/e1000/if_em.c +++ b/sys/dev/e1000/if_em.c @@ -4499,20 +4499,27 @@ em_sysctl_nvm_info(SYSCTL_HANDLER_ARGS) static void em_print_nvm_info(struct e1000_softc *sc) { + struct e1000_hw *hw = &sc->hw; + struct sx *iflib_ctx_lock = iflib_ctx_lock_get(sc->ctx); u16 eeprom_data; int i, j, row = 0; /* Its a bit crude, but it gets the job done */ printf("\nInterface EEPROM Dump:\n"); printf("Offset\n0x0000 "); + + /* We rely on the IFLIB_CTX_LOCK as part of NVM locking model */ + sx_xlock(iflib_ctx_lock); + ASSERT_CTX_LOCK_HELD(hw); for (i = 0, j = 0; i < 32; i++, j++) { if (j == 8) { /* Make the offset block */ j = 0; ++row; printf("\n0x00%x0 ",row); } - e1000_read_nvm(&sc->hw, i, 1, &eeprom_data); + e1000_read_nvm(hw, i, 1, &eeprom_data); printf("%04x ", eeprom_data); } + sx_xunlock(iflib_ctx_lock); printf("\n"); } From nobody Wed Oct 13 02:16:25 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id E563717FB13D; Wed, 13 Oct 2021 02:16: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 4HTbkK4rz9z4gWr; Wed, 13 Oct 2021 02:16: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 85D691F7A9; Wed, 13 Oct 2021 02:16: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 19D2GPTF093067; Wed, 13 Oct 2021 02:16:25 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19D2GPMH093066; Wed, 13 Oct 2021 02:16:25 GMT (envelope-from git) Date: Wed, 13 Oct 2021 02:16:25 GMT Message-Id: <202110130216.19D2GPMH093066@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kevin Bowling Subject: git: c60b5d477cb4 - stable/12 - e1000: print EEPROM/NVM/OROM versions List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kbowling X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: c60b5d477cb466ed11bc34d3808920298c29f09f Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by kbowling (ports committer): URL: https://cgit.FreeBSD.org/src/commit/?id=c60b5d477cb466ed11bc34d3808920298c29f09f commit c60b5d477cb466ed11bc34d3808920298c29f09f Author: Kevin Bowling AuthorDate: 2021-10-06 23:25:03 +0000 Commit: Kevin Bowling CommitDate: 2021-10-13 02:16:04 +0000 e1000: print EEPROM/NVM/OROM versions This is useful for diagnosing problems. In particular, the errata sheets identify the EEPROM version for many fixes. Reviewed by: gallatin MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D32333 (cherry picked from commit 293663f4da9e8b8aeb106ce3b73a8ed2aa2a8a90) --- sys/dev/e1000/if_em.c | 174 +++++++++++++++++++++++++++++++++++++++++++------- sys/dev/e1000/if_em.h | 3 + 2 files changed, 154 insertions(+), 23 deletions(-) diff --git a/sys/dev/e1000/if_em.c b/sys/dev/e1000/if_em.c index 9e3064a13005..b542860b4a96 100644 --- a/sys/dev/e1000/if_em.c +++ b/sys/dev/e1000/if_em.c @@ -305,6 +305,10 @@ static void em_if_vlan_filter_write(struct e1000_softc *); static void em_setup_vlan_hw_support(struct e1000_softc *); static int em_sysctl_nvm_info(SYSCTL_HANDLER_ARGS); static void em_print_nvm_info(struct e1000_softc *); +static void em_fw_version_locked(if_ctx_t); +static void em_sbuf_fw_version(struct e1000_fw_version *, struct sbuf *); +static void em_print_fw_version(struct e1000_softc *); +static int em_sysctl_print_fw_version(SYSCTL_HANDLER_ARGS); static int em_sysctl_debug_info(SYSCTL_HANDLER_ARGS); static int em_get_rs(SYSCTL_HANDLER_ARGS); static void em_print_debug_info(struct e1000_softc *); @@ -791,6 +795,8 @@ em_if_attach_pre(if_ctx_t ctx) if_softc_ctx_t scctx; device_t dev; struct e1000_hw *hw; + struct sysctl_oid_list *child; + struct sysctl_ctx_list *ctx_list; int error = 0; INIT_DEBUGOUT("em_if_attach_pre: begin"); @@ -805,35 +811,38 @@ em_if_attach_pre(if_ctx_t ctx) sc->tx_process_limit = scctx->isc_ntxd[0]; + /* Determine hardware and mac info */ + em_identify_hardware(ctx); + /* SYSCTL stuff */ - SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev), - SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), - OID_AUTO, "nvm", CTLTYPE_INT|CTLFLAG_RW, sc, 0, + ctx_list = device_get_sysctl_ctx(dev); + child = SYSCTL_CHILDREN(device_get_sysctl_tree(dev)); + + SYSCTL_ADD_PROC(ctx_list, child, OID_AUTO, "nvm", + CTLTYPE_INT | CTLFLAG_RW, sc, 0, em_sysctl_nvm_info, "I", "NVM Information"); - SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev), - SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), - OID_AUTO, "debug", CTLTYPE_INT|CTLFLAG_RW, sc, 0, + SYSCTL_ADD_PROC(ctx_list, child, OID_AUTO, "fw_version", + CTLTYPE_STRING | CTLFLAG_RD, sc, 0, + em_sysctl_print_fw_version, "A", + "Prints FW/NVM Versions"); + + SYSCTL_ADD_PROC(ctx_list, child, OID_AUTO, "debug", + CTLTYPE_INT | CTLFLAG_RW, sc, 0, em_sysctl_debug_info, "I", "Debug Information"); - SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev), - SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), - OID_AUTO, "fc", CTLTYPE_INT|CTLFLAG_RW, sc, 0, + SYSCTL_ADD_PROC(ctx_list, child, OID_AUTO, "fc", + CTLTYPE_INT | CTLFLAG_RW, sc, 0, em_set_flowcntl, "I", "Flow Control"); - SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev), - SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), - OID_AUTO, "reg_dump", CTLTYPE_STRING | CTLFLAG_RD, sc, 0, + SYSCTL_ADD_PROC(ctx_list, child, OID_AUTO, "reg_dump", + CTLTYPE_STRING | CTLFLAG_RD, sc, 0, em_get_regs, "A", "Dump Registers"); - SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev), - SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), - OID_AUTO, "rs_dump", CTLTYPE_INT | CTLFLAG_RW, sc, 0, + SYSCTL_ADD_PROC(ctx_list, child, OID_AUTO, "rs_dump", + CTLTYPE_INT | CTLFLAG_RW, sc, 0, em_get_rs, "I", "Dump RS indexes"); - /* Determine hardware and mac info */ - em_identify_hardware(ctx); - scctx->isc_tx_nsegments = EM_MAX_SCATTER; scctx->isc_nrxqsets_max = scctx->isc_ntxqsets_max = em_set_num_queues(ctx); if (bootverbose) @@ -1044,11 +1053,9 @@ em_if_attach_pre(if_ctx_t ctx) /* Sysctl for setting Energy Efficient Ethernet */ hw->dev_spec.ich8lan.eee_disable = eee_setting; - SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev), - SYSCTL_CHILDREN(device_get_sysctl_tree(dev)), - OID_AUTO, "eee_control", CTLTYPE_INT|CTLFLAG_RW, - sc, 0, em_sysctl_eee, "I", - "Disable Energy Efficient Ethernet"); + SYSCTL_ADD_PROC(ctx_list, child, OID_AUTO, "eee_control", + CTLTYPE_INT | CTLFLAG_RW, sc, 0, + em_sysctl_eee, "I", "Disable Energy Efficient Ethernet"); /* ** Start from a known state, this is @@ -1091,6 +1098,11 @@ em_if_attach_pre(if_ctx_t ctx) } } + /* Save the EEPROM/NVM versions, must be done under IFLIB_CTX_LOCK */ + em_fw_version_locked(ctx); + + em_print_fw_version(sc); + /* Disable ULP support */ e1000_disable_ulp_lpt_lp(hw, true); @@ -4465,6 +4477,122 @@ em_add_hw_stats(struct e1000_softc *sc) "Interrupt Cause Receiver Overrun Count"); } +static void +em_fw_version_locked(if_ctx_t ctx) +{ + struct e1000_softc *sc = iflib_get_softc(ctx); + struct e1000_hw *hw = &sc->hw; + struct e1000_fw_version *fw_ver = &sc->fw_ver; + uint16_t eep = 0; + + /* + * em_fw_version_locked() must run under the IFLIB_CTX_LOCK to meet the + * NVM locking model, so we do it in em_if_attach_pre() and store the + * info in the softc + */ + ASSERT_CTX_LOCK_HELD(hw); + + *fw_ver = (struct e1000_fw_version){0}; + + if (hw->mac.type >= igb_mac_min) { + /* + * Use the Shared Code for igb(4) + */ + e1000_get_fw_version(hw, fw_ver); + } else { + /* + * Otherwise, EEPROM version should be present on (almost?) all + * devices here + */ + if(e1000_read_nvm(hw, NVM_VERSION, 1, &eep)) { + INIT_DEBUGOUT("can't get EEPROM version"); + return; + } + + fw_ver->eep_major = (eep & NVM_MAJOR_MASK) >> NVM_MAJOR_SHIFT; + fw_ver->eep_minor = (eep & NVM_MINOR_MASK) >> NVM_MINOR_SHIFT; + fw_ver->eep_build = (eep & NVM_IMAGE_ID_MASK); + } +} + +static void +em_sbuf_fw_version(struct e1000_fw_version *fw_ver, struct sbuf *buf) +{ + const char *space = ""; + + if (fw_ver->eep_major || fw_ver->eep_minor || fw_ver->eep_build) { + sbuf_printf(buf, "EEPROM V%d.%d-%d", fw_ver->eep_major, + fw_ver->eep_minor, fw_ver->eep_build); + space = " "; + } + + if (fw_ver->invm_major || fw_ver->invm_minor || fw_ver->invm_img_type) { + sbuf_printf(buf, "%sNVM V%d.%d imgtype%d", + space, fw_ver->invm_major, fw_ver->invm_minor, + fw_ver->invm_img_type); + space = " "; + } + + if (fw_ver->or_valid) { + sbuf_printf(buf, "%sOption ROM V%d-b%d-p%d", + space, fw_ver->or_major, fw_ver->or_build, + fw_ver->or_patch); + space = " "; + } + + if (fw_ver->etrack_id) + sbuf_printf(buf, "%seTrack 0x%08x", space, fw_ver->etrack_id); +} + +static void +em_print_fw_version(struct e1000_softc *sc ) +{ + device_t dev = sc->dev; + struct sbuf *buf; + int error = 0; + + buf = sbuf_new_auto(); + if (!buf) { + device_printf(dev, "Could not allocate sbuf for output.\n"); + return; + } + + em_sbuf_fw_version(&sc->fw_ver, buf); + + error = sbuf_finish(buf); + if (error) + device_printf(dev, "Error finishing sbuf: %d\n", error); + else if (sbuf_len(buf)) + device_printf(dev, "%s\n", sbuf_data(buf)); + + sbuf_delete(buf); +} + +static int +em_sysctl_print_fw_version(SYSCTL_HANDLER_ARGS) +{ + struct e1000_softc *sc = (struct e1000_softc *)arg1; + device_t dev = sc->dev; + struct sbuf *buf; + int error = 0; + + buf = sbuf_new_for_sysctl(NULL, NULL, 128, req); + if (!buf) { + device_printf(dev, "Could not allocate sbuf for output.\n"); + return (ENOMEM); + } + + em_sbuf_fw_version(&sc->fw_ver, buf); + + error = sbuf_finish(buf); + if (error) + device_printf(dev, "Error finishing sbuf: %d\n", error); + + sbuf_delete(buf); + + return (0); +} + /********************************************************************** * * This routine provides a way to dump out the adapter eeprom, diff --git a/sys/dev/e1000/if_em.h b/sys/dev/e1000/if_em.h index 48802163a673..9b34075ff2d9 100644 --- a/sys/dev/e1000/if_em.h +++ b/sys/dev/e1000/if_em.h @@ -512,6 +512,9 @@ struct e1000_softc { u64 que_mask; + /* We need to store this at attach due to e1000 hw/sw locking model */ + struct e1000_fw_version fw_ver; + struct em_int_delay_info tx_int_delay; struct em_int_delay_info tx_abs_int_delay; struct em_int_delay_info rx_int_delay; From nobody Wed Oct 13 09:19:07 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id EF851180004F; Wed, 13 Oct 2021 09:19: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 4HTn636KRlz4sN6; Wed, 13 Oct 2021 09:19: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 B594225480; Wed, 13 Oct 2021 09:19: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 19D9J7gp057152; Wed, 13 Oct 2021 09:19:07 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19D9J74m057151; Wed, 13 Oct 2021 09:19:07 GMT (envelope-from git) Date: Wed, 13 Oct 2021 09:19:07 GMT Message-Id: <202110130919.19D9J74m057151@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Vladimir Kondratyev Subject: git: a02996804609 - stable/13 - LinuxKPI: Implement get_file_rcu() List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: wulf X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: a029968046090821d34b22defdbe446ed9a41b7f Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by wulf: URL: https://cgit.FreeBSD.org/src/commit/?id=a029968046090821d34b22defdbe446ed9a41b7f commit a029968046090821d34b22defdbe446ed9a41b7f Author: Vladimir Kondratyev AuthorDate: 2021-09-29 20:12:25 +0000 Commit: Vladimir Kondratyev CommitDate: 2021-10-13 08:57:46 +0000 LinuxKPI: Implement get_file_rcu() get_file_rcu() grabs a file if the file->f_count is not zero. Required by drm-kmod 5.6 Reviewed by: hselasky, manu (previous version) Differential revision: https://reviews.freebsd.org/D31672 (cherry picked from commit a81b36c6d35d74177891860b789dd02b9d1c5851) --- sys/compat/linuxkpi/common/include/linux/fs.h | 9 +++++++++ sys/compat/linuxkpi/common/src/linux_compat.c | 4 +++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/sys/compat/linuxkpi/common/include/linux/fs.h b/sys/compat/linuxkpi/common/include/linux/fs.h index 38911c276216..eaf806b6732c 100644 --- a/sys/compat/linuxkpi/common/include/linux/fs.h +++ b/sys/compat/linuxkpi/common/include/linux/fs.h @@ -108,6 +108,8 @@ struct linux_file { /* pointer to associated character device, if any */ struct linux_cdev *f_cdev; + + struct rcu_head rcu; }; #define file linux_file @@ -254,6 +256,13 @@ get_file(struct linux_file *f) return (f); } +static inline bool +get_file_rcu(struct linux_file *f) +{ + return (refcount_acquire_if_not_zero( + f->_file == NULL ? &f->f_count : &f->_file->f_count)); +} + static inline struct inode * igrab(struct inode *inode) { diff --git a/sys/compat/linuxkpi/common/src/linux_compat.c b/sys/compat/linuxkpi/common/src/linux_compat.c index 217c4081c603..7315a2671ead 100644 --- a/sys/compat/linuxkpi/common/src/linux_compat.c +++ b/sys/compat/linuxkpi/common/src/linux_compat.c @@ -89,6 +89,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #if defined(__i386__) || defined(__amd64__) #include @@ -471,7 +472,7 @@ linux_file_free(struct linux_file *filp) if (filp->_file == NULL) { if (filp->f_shmem != NULL) vm_object_deallocate(filp->f_shmem); - kfree(filp); + kfree_rcu(filp, rcu); } else { /* * The close method of the character device or file @@ -1537,6 +1538,7 @@ linux_file_close(struct file *file, struct thread *td) ldev = filp->f_cdev; if (ldev != NULL) linux_cdev_deref(ldev); + linux_synchronize_rcu(RCU_TYPE_REGULAR); kfree(filp); return (error); From nobody Wed Oct 13 09:19:08 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 3179A17FFFC9; Wed, 13 Oct 2021 09:19:10 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HTn650382z4sB1; Wed, 13 Oct 2021 09:19: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 C608C25481; Wed, 13 Oct 2021 09:19: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 19D9J87f057181; Wed, 13 Oct 2021 09:19:08 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19D9J81m057180; Wed, 13 Oct 2021 09:19:08 GMT (envelope-from git) Date: Wed, 13 Oct 2021 09:19:08 GMT Message-Id: <202110130919.19D9J81m057180@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Vladimir Kondratyev Subject: git: fd6adf784e86 - stable/13 - LinuxKPI: Remove FreeBSD struct resource from all LKPI headers List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: wulf X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: fd6adf784e862d043d1858aab323f3fb136cf706 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by wulf: URL: https://cgit.FreeBSD.org/src/commit/?id=fd6adf784e862d043d1858aab323f3fb136cf706 commit fd6adf784e862d043d1858aab323f3fb136cf706 Author: Vladimir Kondratyev AuthorDate: 2021-09-29 20:12:36 +0000 Commit: Vladimir Kondratyev CommitDate: 2021-10-13 08:58:39 +0000 LinuxKPI: Remove FreeBSD struct resource from all LKPI headers except linux/pci.h to avoid conflicts with Linux version. This allows to #define resource in drm-kmod globally and strip some #ifdef-s Reviewed by: hselasky, manu Differential revision: https://reviews.freebsd.org/D31673 (cherry picked from commit 66ea390652d2ede405b43c168157986bd2b52bb9) --- .../linuxkpi/common/include/linux/interrupt.h | 170 ++------------ sys/compat/linuxkpi/common/src/linux_compat.c | 41 ---- sys/compat/linuxkpi/common/src/linux_interrupt.c | 252 +++++++++++++++++++++ sys/conf/files | 2 + sys/modules/linuxkpi/Makefile | 1 + 5 files changed, 272 insertions(+), 194 deletions(-) diff --git a/sys/compat/linuxkpi/common/include/linux/interrupt.h b/sys/compat/linuxkpi/common/include/linux/interrupt.h index 066157f9b559..4e6c859853a7 100644 --- a/sys/compat/linuxkpi/common/include/linux/interrupt.h +++ b/sys/compat/linuxkpi/common/include/linux/interrupt.h @@ -38,111 +38,31 @@ #include #include -#include -#include #include typedef irqreturn_t (*irq_handler_t)(int, void *); #define IRQF_SHARED RF_SHAREABLE -struct irq_ent { - struct list_head links; - struct device *dev; - struct resource *res; - void *arg; - irqreturn_t (*handler)(int, void *); - void *tag; - unsigned int irq; - - /* XXX All new entries must be after this in stable/13 */ - irqreturn_t (*thread_handler)(int, void *); -}; +struct irq_ent; void linux_irq_handler(void *); void lkpi_devm_irq_release(struct device *, void *); void lkpi_irq_release(struct device *, struct irq_ent *); - -static inline int -linux_irq_rid(struct device *dev, unsigned int irq) -{ - /* check for MSI- or MSIX- interrupt */ - if (irq >= dev->irq_start && irq < dev->irq_end) - return (irq - dev->irq_start + 1); - else - return (0); -} - -static inline struct irq_ent * -linux_irq_ent(struct device *dev, unsigned int irq) -{ - struct irq_ent *irqe; - - list_for_each_entry(irqe, &dev->irqents, links) - if (irqe->irq == irq) - return (irqe); - - return (NULL); -} - -static inline int -_request_irq(struct device *xdev, unsigned int irq, - irq_handler_t handler, irq_handler_t thread_handler, - unsigned long flags, const char *name, void *arg) -{ - struct resource *res; - struct irq_ent *irqe; - struct device *dev; - int error; - int rid; - - dev = linux_pci_find_irq_dev(irq); - if (dev == NULL) - return -ENXIO; - if (xdev != NULL && xdev != dev) - return -ENXIO; - rid = linux_irq_rid(dev, irq); - res = bus_alloc_resource_any(dev->bsddev, SYS_RES_IRQ, &rid, - flags | RF_ACTIVE); - if (res == NULL) - return (-ENXIO); - if (xdev != NULL) - irqe = lkpi_devres_alloc(lkpi_devm_irq_release, sizeof(*irqe), - GFP_KERNEL | __GFP_ZERO); - else - irqe = kzalloc(sizeof(*irqe), GFP_KERNEL); - irqe->dev = dev; - irqe->res = res; - irqe->arg = arg; - irqe->handler = handler; - irqe->thread_handler = thread_handler; - irqe->irq = irq; - - error = bus_setup_intr(dev->bsddev, res, INTR_TYPE_NET | INTR_MPSAFE, - NULL, linux_irq_handler, irqe, &irqe->tag); - if (error) - goto errout; - list_add(&irqe->links, &dev->irqents); - if (xdev != NULL) - devres_add(xdev, irqe); - - return 0; - -errout: - bus_release_resource(dev->bsddev, SYS_RES_IRQ, rid, irqe->res); - if (xdev != NULL) - devres_free(irqe); - else - kfree(irqe); - return (-error); -} +int lkpi_request_irq(struct device *, unsigned int, irq_handler_t, + irq_handler_t, unsigned long, const char *, void *); +int lkpi_enable_irq(unsigned int); +void lkpi_disable_irq(unsigned int); +int lkpi_bind_irq_to_cpu(unsigned int, int); +void lkpi_free_irq(unsigned int, void *); +void lkpi_devm_free_irq(struct device *, unsigned int, void *); static inline int request_irq(unsigned int irq, irq_handler_t handler, unsigned long flags, const char *name, void *arg) { - return (_request_irq(NULL, irq, handler, NULL, flags, name, arg)); + return (lkpi_request_irq(NULL, irq, handler, NULL, flags, name, arg)); } static inline int @@ -151,7 +71,7 @@ request_threaded_irq(int irq, irq_handler_t handler, const char *name, void *arg) { - return (_request_irq(NULL, irq, handler, thread_handler, + return (lkpi_request_irq(NULL, irq, handler, thread_handler, flags, name, arg)); } @@ -161,94 +81,38 @@ devm_request_threaded_irq(struct device *dev, int irq, unsigned long flags, const char *name, void *arg) { - return (_request_irq(dev, irq, handler, thread_handler, + return (lkpi_request_irq(dev, irq, handler, thread_handler, flags, name, arg)); } static inline int enable_irq(unsigned int irq) { - struct irq_ent *irqe; - struct device *dev; - - dev = linux_pci_find_irq_dev(irq); - if (dev == NULL) - return -EINVAL; - irqe = linux_irq_ent(dev, irq); - if (irqe == NULL || irqe->tag != NULL) - return -EINVAL; - return -bus_setup_intr(dev->bsddev, irqe->res, INTR_TYPE_NET | INTR_MPSAFE, - NULL, linux_irq_handler, irqe, &irqe->tag); + return (lkpi_enable_irq(irq)); } static inline void disable_irq(unsigned int irq) { - struct irq_ent *irqe; - struct device *dev; - - dev = linux_pci_find_irq_dev(irq); - if (dev == NULL) - return; - irqe = linux_irq_ent(dev, irq); - if (irqe == NULL) - return; - if (irqe->tag != NULL) - bus_teardown_intr(dev->bsddev, irqe->res, irqe->tag); - irqe->tag = NULL; + lkpi_disable_irq(irq); } static inline int bind_irq_to_cpu(unsigned int irq, int cpu_id) { - struct irq_ent *irqe; - struct device *dev; - - dev = linux_pci_find_irq_dev(irq); - if (dev == NULL) - return (-ENOENT); - - irqe = linux_irq_ent(dev, irq); - if (irqe == NULL) - return (-ENOENT); - - return (-bus_bind_intr(dev->bsddev, irqe->res, cpu_id)); + return (lkpi_bind_irq_to_cpu(irq, cpu_id)); } static inline void -free_irq(unsigned int irq, void *device __unused) +free_irq(unsigned int irq, void *device) { - struct irq_ent *irqe; - struct device *dev; - - dev = linux_pci_find_irq_dev(irq); - if (dev == NULL) - return; - irqe = linux_irq_ent(dev, irq); - if (irqe == NULL) - return; - lkpi_irq_release(dev, irqe); - kfree(irqe); + lkpi_free_irq(irq, device); } static inline void devm_free_irq(struct device *xdev, unsigned int irq, void *p) { - struct device *dev; - struct irq_ent *irqe; - - dev = linux_pci_find_irq_dev(irq); - if (dev == NULL) - return; - if (xdev != dev) - return; - irqe = linux_irq_ent(dev, irq); - if (irqe == NULL) - return; - lkpi_irq_release(dev, irqe); - lkpi_devres_unlink(dev, irqe); - lkpi_devres_free(irqe); - return; + lkpi_devm_free_irq(xdev, irq, p); } static inline int diff --git a/sys/compat/linuxkpi/common/src/linux_compat.c b/sys/compat/linuxkpi/common/src/linux_compat.c index 7315a2671ead..c48d9ac3a281 100644 --- a/sys/compat/linuxkpi/common/src/linux_compat.c +++ b/sys/compat/linuxkpi/common/src/linux_compat.c @@ -2465,47 +2465,6 @@ list_sort(void *priv, struct list_head *head, int (*cmp)(void *priv, free(ar, M_KMALLOC); } -void -lkpi_irq_release(struct device *dev, struct irq_ent *irqe) -{ - - if (irqe->tag != NULL) - bus_teardown_intr(dev->bsddev, irqe->res, irqe->tag); - if (irqe->res != NULL) - bus_release_resource(dev->bsddev, SYS_RES_IRQ, - rman_get_rid(irqe->res), irqe->res); - list_del(&irqe->links); -} - -void -lkpi_devm_irq_release(struct device *dev, void *p) -{ - struct irq_ent *irqe; - - if (dev == NULL || p == NULL) - return; - - irqe = p; - lkpi_irq_release(dev, irqe); -} - -void -linux_irq_handler(void *ent) -{ - struct irq_ent *irqe; - - if (linux_set_current_flags(curthread, M_NOWAIT)) - return; - - irqe = ent; - if (irqe->handler(irqe->irq, irqe->arg) == IRQ_WAKE_THREAD && - irqe->thread_handler != NULL) { - THREAD_SLEEPING_OK(); - irqe->thread_handler(irqe->irq, irqe->arg); - THREAD_NO_SLEEPING(); - } -} - #if defined(__i386__) || defined(__amd64__) int linux_wbinvd_on_all_cpus(void) diff --git a/sys/compat/linuxkpi/common/src/linux_interrupt.c b/sys/compat/linuxkpi/common/src/linux_interrupt.c new file mode 100644 index 000000000000..d8b90094b49b --- /dev/null +++ b/sys/compat/linuxkpi/common/src/linux_interrupt.c @@ -0,0 +1,252 @@ +/*- + * Copyright (c) 2010 Isilon Systems, Inc. + * Copyright (c) 2010 iX Systems, Inc. + * Copyright (c) 2010 Panasas, Inc. + * Copyright (c) 2013-2015 Mellanox Technologies, Ltd. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice unmodified, this list of conditions, and the following + * disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#include +#include +#include + +#include +#include +#include +#include + +struct irq_ent { + struct list_head links; + struct device *dev; + struct resource *res; + void *arg; + irqreturn_t (*handler)(int, void *); + void *tag; + unsigned int irq; + + /* XXX All new entries must be after this in stable/13 */ + irqreturn_t (*thread_handler)(int, void *); +}; + +static inline int +lkpi_irq_rid(struct device *dev, unsigned int irq) +{ + /* check for MSI- or MSIX- interrupt */ + if (irq >= dev->irq_start && irq < dev->irq_end) + return (irq - dev->irq_start + 1); + else + return (0); +} + +static inline struct irq_ent * +lkpi_irq_ent(struct device *dev, unsigned int irq) +{ + struct irq_ent *irqe; + + list_for_each_entry(irqe, &dev->irqents, links) + if (irqe->irq == irq) + return (irqe); + + return (NULL); +} + +void +linux_irq_handler(void *ent) +{ + struct irq_ent *irqe; + + if (linux_set_current_flags(curthread, M_NOWAIT)) + return; + + irqe = ent; + if (irqe->handler(irqe->irq, irqe->arg) == IRQ_WAKE_THREAD && + irqe->thread_handler != NULL) { + THREAD_SLEEPING_OK(); + irqe->thread_handler(irqe->irq, irqe->arg); + THREAD_NO_SLEEPING(); + } +} + +void +lkpi_irq_release(struct device *dev, struct irq_ent *irqe) +{ + if (irqe->tag != NULL) + bus_teardown_intr(dev->bsddev, irqe->res, irqe->tag); + if (irqe->res != NULL) + bus_release_resource(dev->bsddev, SYS_RES_IRQ, + rman_get_rid(irqe->res), irqe->res); + list_del(&irqe->links); +} + +void +lkpi_devm_irq_release(struct device *dev, void *p) +{ + struct irq_ent *irqe; + + if (dev == NULL || p == NULL) + return; + + irqe = p; + lkpi_irq_release(dev, irqe); +} + +int +lkpi_request_irq(struct device *xdev, unsigned int irq, + irq_handler_t handler, irq_handler_t thread_handler, + unsigned long flags, const char *name, void *arg) +{ + struct resource *res; + struct irq_ent *irqe; + struct device *dev; + int error; + int rid; + + dev = linux_pci_find_irq_dev(irq); + if (dev == NULL) + return -ENXIO; + if (xdev != NULL && xdev != dev) + return -ENXIO; + rid = lkpi_irq_rid(dev, irq); + res = bus_alloc_resource_any(dev->bsddev, SYS_RES_IRQ, &rid, + flags | RF_ACTIVE); + if (res == NULL) + return (-ENXIO); + if (xdev != NULL) + irqe = lkpi_devres_alloc(lkpi_devm_irq_release, sizeof(*irqe), + GFP_KERNEL | __GFP_ZERO); + else + irqe = kzalloc(sizeof(*irqe), GFP_KERNEL); + irqe->dev = dev; + irqe->res = res; + irqe->arg = arg; + irqe->handler = handler; + irqe->thread_handler = thread_handler; + irqe->irq = irq; + + error = bus_setup_intr(dev->bsddev, res, INTR_TYPE_NET | INTR_MPSAFE, + NULL, linux_irq_handler, irqe, &irqe->tag); + if (error) + goto errout; + list_add(&irqe->links, &dev->irqents); + if (xdev != NULL) + devres_add(xdev, irqe); + + return 0; + +errout: + bus_release_resource(dev->bsddev, SYS_RES_IRQ, rid, irqe->res); + if (xdev != NULL) + devres_free(irqe); + else + kfree(irqe); + return (-error); +} + +int +lkpi_enable_irq(unsigned int irq) +{ + struct irq_ent *irqe; + struct device *dev; + + dev = linux_pci_find_irq_dev(irq); + if (dev == NULL) + return -EINVAL; + irqe = lkpi_irq_ent(dev, irq); + if (irqe == NULL || irqe->tag != NULL) + return -EINVAL; + return -bus_setup_intr(dev->bsddev, irqe->res, INTR_TYPE_NET | INTR_MPSAFE, + NULL, linux_irq_handler, irqe, &irqe->tag); +} + +void +lkpi_disable_irq(unsigned int irq) +{ + struct irq_ent *irqe; + struct device *dev; + + dev = linux_pci_find_irq_dev(irq); + if (dev == NULL) + return; + irqe = lkpi_irq_ent(dev, irq); + if (irqe == NULL) + return; + if (irqe->tag != NULL) + bus_teardown_intr(dev->bsddev, irqe->res, irqe->tag); + irqe->tag = NULL; +} + +int +lkpi_bind_irq_to_cpu(unsigned int irq, int cpu_id) +{ + struct irq_ent *irqe; + struct device *dev; + + dev = linux_pci_find_irq_dev(irq); + if (dev == NULL) + return (-ENOENT); + + irqe = lkpi_irq_ent(dev, irq); + if (irqe == NULL) + return (-ENOENT); + + return (-bus_bind_intr(dev->bsddev, irqe->res, cpu_id)); +} + +void +lkpi_free_irq(unsigned int irq, void *device __unused) +{ + struct irq_ent *irqe; + struct device *dev; + + dev = linux_pci_find_irq_dev(irq); + if (dev == NULL) + return; + irqe = lkpi_irq_ent(dev, irq); + if (irqe == NULL) + return; + lkpi_irq_release(dev, irqe); + kfree(irqe); +} + +void +lkpi_devm_free_irq(struct device *xdev, unsigned int irq, void *p __unused) +{ + struct device *dev; + struct irq_ent *irqe; + + dev = linux_pci_find_irq_dev(irq); + if (dev == NULL) + return; + if (xdev != dev) + return; + irqe = lkpi_irq_ent(dev, irq); + if (irqe == NULL) + return; + lkpi_irq_release(dev, irqe); + lkpi_devres_unlink(dev, irqe); + lkpi_devres_free(irqe); + return; +} diff --git a/sys/conf/files b/sys/conf/files index 69ebfe39340d..40bba75d4fbc 100644 --- a/sys/conf/files +++ b/sys/conf/files @@ -4586,6 +4586,8 @@ compat/linuxkpi/common/src/linux_firmware.c optional compat_linuxkpi \ compile-with "${LINUXKPI_C}" compat/linuxkpi/common/src/linux_hrtimer.c optional compat_linuxkpi \ compile-with "${LINUXKPI_C}" +compat/linuxkpi/common/src/linux_interrupt.c optional compat_linuxkpi \ + compile-with "${LINUXKPI_C}" compat/linuxkpi/common/src/linux_kthread.c optional compat_linuxkpi \ compile-with "${LINUXKPI_C}" compat/linuxkpi/common/src/linux_lock.c optional compat_linuxkpi \ diff --git a/sys/modules/linuxkpi/Makefile b/sys/modules/linuxkpi/Makefile index 81aa607f1302..514428a82509 100644 --- a/sys/modules/linuxkpi/Makefile +++ b/sys/modules/linuxkpi/Makefile @@ -10,6 +10,7 @@ SRCS= linux_compat.c \ linux_firmware.c \ linux_hrtimer.c \ linux_idr.c \ + linux_interrupt.c \ linux_kmod.c \ linux_kthread.c \ linux_lock.c \ From nobody Wed Oct 13 09:19:09 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 2B31E17FFD79; Wed, 13 Oct 2021 09:19: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 4HTn661bcqz4sXg; Wed, 13 Oct 2021 09:19:10 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id EAA7D251A1; Wed, 13 Oct 2021 09:19: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 19D9J90X057205; Wed, 13 Oct 2021 09:19:09 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19D9J9AK057204; Wed, 13 Oct 2021 09:19:09 GMT (envelope-from git) Date: Wed, 13 Oct 2021 09:19:09 GMT Message-Id: <202110130919.19D9J9AK057204@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Vladimir Kondratyev Subject: git: 2c26756366c4 - stable/13 - LinuxKPI: implement _IOC_TYPE and _IOC_NR macros in linux/ioctl.h List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: wulf X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 2c26756366c407354535b00dc0a2cde6f34e991f Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by wulf: URL: https://cgit.FreeBSD.org/src/commit/?id=2c26756366c407354535b00dc0a2cde6f34e991f commit 2c26756366c407354535b00dc0a2cde6f34e991f Author: Vladimir Kondratyev AuthorDate: 2021-09-29 20:12:47 +0000 Commit: Vladimir Kondratyev CommitDate: 2021-10-13 08:59:25 +0000 LinuxKPI: implement _IOC_TYPE and _IOC_NR macros in linux/ioctl.h They are used by drm-kmod Reviewed by: emaste, hselasky, manu Differential revision: https://reviews.freebsd.org/D31674 (cherry picked from commit b58c916f115d9d40f91397a1b406891f36c39fad) --- sys/compat/linuxkpi/common/include/linux/ioctl.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sys/compat/linuxkpi/common/include/linux/ioctl.h b/sys/compat/linuxkpi/common/include/linux/ioctl.h index fdedf9c4a179..fcdb5c547e73 100644 --- a/sys/compat/linuxkpi/common/include/linux/ioctl.h +++ b/sys/compat/linuxkpi/common/include/linux/ioctl.h @@ -33,6 +33,8 @@ #include -#define _IOC_SIZE(cmd) IOCPARM_LEN(cmd) +#define _IOC_SIZE(cmd) IOCPARM_LEN(cmd) +#define _IOC_TYPE(cmd) IOCGROUP(cmd) +#define _IOC_NR(cmd) ((cmd) & 0xff) #endif /* _LINUX_IOCTL_H_ */ From nobody Wed Oct 13 09:19:10 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id C2B281800067; Wed, 13 Oct 2021 09:19: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 4HTn673BmGz4sVJ; Wed, 13 Oct 2021 09:19: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 1515324C71; Wed, 13 Oct 2021 09:19: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 19D9JADE057229; Wed, 13 Oct 2021 09:19:10 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19D9JAOZ057228; Wed, 13 Oct 2021 09:19:10 GMT (envelope-from git) Date: Wed, 13 Oct 2021 09:19:10 GMT Message-Id: <202110130919.19D9JAOZ057228@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Vladimir Kondratyev Subject: git: c1daa6fa4ca5 - stable/13 - LinuxKPI: allocate current before taking shrinkers lock List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: wulf X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: c1daa6fa4ca53206908777f2f9e17ea7ddd7d295 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by wulf: URL: https://cgit.FreeBSD.org/src/commit/?id=c1daa6fa4ca53206908777f2f9e17ea7ddd7d295 commit c1daa6fa4ca53206908777f2f9e17ea7ddd7d295 Author: Vladimir Kondratyev AuthorDate: 2021-09-29 20:12:58 +0000 Commit: Vladimir Kondratyev CommitDate: 2021-10-13 09:00:17 +0000 LinuxKPI: allocate current before taking shrinkers lock This fixes following warnings when shrinkers are invoked first time: uma_zalloc_debug: zone "lkpicurr" with the following non-sleepable locks held: exclusive sleep mutex lkpi-shrinker (lkpi-shrinker) uma_zalloc_debug: zone "lkpimm" with the following non-sleepable locks held: exclusive sleep mutex lkpi-shrinker (lkpi-shrinker) Reviewed by: hselasky, manu Differential revision: https://reviews.freebsd.org/D32066 (cherry picked from commit 2fe9ea5d3ad69d880138d98b2ae8d2c4309eeafa) --- sys/compat/linuxkpi/common/src/linux_shrinker.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sys/compat/linuxkpi/common/src/linux_shrinker.c b/sys/compat/linuxkpi/common/src/linux_shrinker.c index 0423f4e05804..b66316c22013 100644 --- a/sys/compat/linuxkpi/common/src/linux_shrinker.c +++ b/sys/compat/linuxkpi/common/src/linux_shrinker.c @@ -36,6 +36,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include TAILQ_HEAD(, shrinker) lkpi_shrinkers = TAILQ_HEAD_INITIALIZER(lkpi_shrinkers); @@ -93,6 +94,7 @@ linuxkpi_vm_lowmem(void *arg __unused) { struct shrinker *s; + linux_set_current(curthread); mtx_lock(&mtx_shrinker); TAILQ_FOREACH(s, &lkpi_shrinkers, next) { shrinker_shrink(s); From nobody Wed Oct 13 09:19:12 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4655F1800232; Wed, 13 Oct 2021 09:19: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 4HTn69286zz4sBJ; Wed, 13 Oct 2021 09:19: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 2D3F72530E; Wed, 13 Oct 2021 09:19: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 19D9JCFg057253; Wed, 13 Oct 2021 09:19:12 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19D9JCSJ057252; Wed, 13 Oct 2021 09:19:12 GMT (envelope-from git) Date: Wed, 13 Oct 2021 09:19:12 GMT Message-Id: <202110130919.19D9JCSJ057252@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Vladimir Kondratyev Subject: git: cdae9b8e4377 - stable/13 - LinuxKPI: Invoke release handler when file is destroyed by fput() List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: wulf X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: cdae9b8e4377937f4c79386727a46a414b515f11 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by wulf: URL: https://cgit.FreeBSD.org/src/commit/?id=cdae9b8e4377937f4c79386727a46a414b515f11 commit cdae9b8e4377937f4c79386727a46a414b515f11 Author: Vladimir Kondratyev AuthorDate: 2021-09-29 20:13:27 +0000 Commit: Vladimir Kondratyev CommitDate: 2021-10-13 09:01:06 +0000 LinuxKPI: Invoke release handler when file is destroyed by fput() Required by drm_kmod 5.6 Reviewed by: hselasky, manu MFC after: 2 weeks Differential revision: https://reviews.freebsd.org/D32067 (cherry picked from commit 7d92d4835850fdc5c1ec1fa7c5634826a61ad0a5) --- sys/compat/linuxkpi/common/src/linux_compat.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sys/compat/linuxkpi/common/src/linux_compat.c b/sys/compat/linuxkpi/common/src/linux_compat.c index c48d9ac3a281..247c1f54515e 100644 --- a/sys/compat/linuxkpi/common/src/linux_compat.c +++ b/sys/compat/linuxkpi/common/src/linux_compat.c @@ -470,6 +470,8 @@ void linux_file_free(struct linux_file *filp) { if (filp->_file == NULL) { + if (filp->f_op != NULL && filp->f_op->release != NULL) + filp->f_op->release(filp->f_vnode, filp); if (filp->f_shmem != NULL) vm_object_deallocate(filp->f_shmem); kfree_rcu(filp, rcu); From nobody Wed Oct 13 09:19:13 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id C6B5518002B9; Wed, 13 Oct 2021 09:19: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 4HTn6B4yg3z4sSP; Wed, 13 Oct 2021 09:19:14 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4CF6324C72; Wed, 13 Oct 2021 09:19: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 19D9JD7v057277; Wed, 13 Oct 2021 09:19:13 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19D9JDjk057276; Wed, 13 Oct 2021 09:19:13 GMT (envelope-from git) Date: Wed, 13 Oct 2021 09:19:13 GMT Message-Id: <202110130919.19D9JDjk057276@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Vladimir Kondratyev Subject: git: 847ffc18ddf8 - stable/13 - LinuxKPI: Factor out vmf_insert_pfn_prot() routine List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: wulf X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 847ffc18ddf8183fee8d959c75c62f317270ce88 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by wulf: URL: https://cgit.FreeBSD.org/src/commit/?id=847ffc18ddf8183fee8d959c75c62f317270ce88 commit 847ffc18ddf8183fee8d959c75c62f317270ce88 Author: Vladimir Kondratyev AuthorDate: 2021-09-29 20:13:41 +0000 Commit: Vladimir Kondratyev CommitDate: 2021-10-13 09:01:32 +0000 LinuxKPI: Factor out vmf_insert_pfn_prot() routine from GEM and TTM page fault handlers and move it in to base system. This code is tightly integrated with LKPI mmap support to belong to drm-kmod. As this routine requires associated vm_object to be locked, it got additional _locked suffix. Reviewed by: hselasky, markj Differential revision: https://reviews.freebsd.org/D32068 (cherry picked from commit f6823dac8fa6e9fc2926a866e9a0c4d43e38e236) --- sys/compat/linuxkpi/common/include/linux/mm.h | 23 +++++++++++++++++++ sys/compat/linuxkpi/common/src/linux_page.c | 32 +++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) diff --git a/sys/compat/linuxkpi/common/include/linux/mm.h b/sys/compat/linuxkpi/common/include/linux/mm.h index 74709299ba1a..dc75ae4483c3 100644 --- a/sys/compat/linuxkpi/common/include/linux/mm.h +++ b/sys/compat/linuxkpi/common/include/linux/mm.h @@ -82,6 +82,9 @@ CTASSERT((VM_PROT_ALL & -(1 << 8)) == 0); #define VM_FAULT_RETRY (1 << 9) #define VM_FAULT_FALLBACK (1 << 10) +#define VM_FAULT_ERROR (VM_FAULT_OOM | VM_FAULT_SIGBUS | VM_FAULT_SIGSEGV | \ + VM_FAULT_HWPOISON |VM_FAULT_HWPOISON_LARGE | VM_FAULT_FALLBACK) + #define FAULT_FLAG_WRITE (1 << 0) #define FAULT_FLAG_MKWRITE (1 << 1) #define FAULT_FLAG_ALLOW_RETRY (1 << 2) @@ -183,6 +186,26 @@ io_remap_pfn_range(struct vm_area_struct *vma, return (0); } +vm_fault_t +lkpi_vmf_insert_pfn_prot_locked(struct vm_area_struct *vma, unsigned long addr, + unsigned long pfn, pgprot_t prot); + +static inline vm_fault_t +vmf_insert_pfn_prot(struct vm_area_struct *vma, unsigned long addr, + unsigned long pfn, pgprot_t prot) +{ + vm_fault_t ret; + + VM_OBJECT_WLOCK(vma->vm_obj); + ret = lkpi_vmf_insert_pfn_prot_locked(vma, addr, pfn, prot); + VM_OBJECT_WUNLOCK(vma->vm_obj); + + return (ret); +} +#define vmf_insert_pfn_prot(...) \ + _Static_assert(false, \ +"This function is always called in a loop. Consider using the locked version") + static inline int apply_to_page_range(struct mm_struct *mm, unsigned long address, unsigned long size, pte_fn_t fn, void *data) diff --git a/sys/compat/linuxkpi/common/src/linux_page.c b/sys/compat/linuxkpi/common/src/linux_page.c index ee41366c53a6..cbe6d2530b91 100644 --- a/sys/compat/linuxkpi/common/src/linux_page.c +++ b/sys/compat/linuxkpi/common/src/linux_page.c @@ -275,3 +275,35 @@ is_vmalloc_addr(const void *addr) { return (vtoslab((vm_offset_t)addr & ~UMA_SLAB_MASK) != NULL); } + +vm_fault_t +lkpi_vmf_insert_pfn_prot_locked(struct vm_area_struct *vma, unsigned long addr, + unsigned long pfn, pgprot_t prot) +{ + vm_object_t vm_obj = vma->vm_obj; + vm_page_t page; + vm_pindex_t pindex; + + VM_OBJECT_ASSERT_WLOCKED(vm_obj); + pindex = OFF_TO_IDX(addr - vma->vm_start); + if (vma->vm_pfn_count == 0) + vma->vm_pfn_first = pindex; + MPASS(pindex <= OFF_TO_IDX(vma->vm_end)); + +retry: + page = vm_page_grab(vm_obj, pindex, VM_ALLOC_NOCREAT); + if (page == NULL) { + page = PHYS_TO_VM_PAGE(IDX_TO_OFF(pfn)); + if (!vm_page_busy_acquire(page, VM_ALLOC_WAITFAIL)) + goto retry; + if (vm_page_insert(page, vm_obj, pindex)) { + vm_page_xunbusy(page); + return (VM_FAULT_OOM); + } + vm_page_valid(page); + } + pmap_page_set_memattr(page, pgprot2cachemode(prot)); + vma->vm_pfn_count++; + + return (VM_FAULT_NOPAGE); +} From nobody Wed Oct 13 09:19:15 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id D513B18003E7; Wed, 13 Oct 2021 09:19: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 4HTn6F48FRz4sBV; Wed, 13 Oct 2021 09:19: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 8715C25406; Wed, 13 Oct 2021 09:19:15 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19D9JFdH057331; Wed, 13 Oct 2021 09:19:15 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19D9JFKg057330; Wed, 13 Oct 2021 09:19:15 GMT (envelope-from git) Date: Wed, 13 Oct 2021 09:19:15 GMT Message-Id: <202110130919.19D9JFKg057330@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Vladimir Kondratyev Subject: git: 767e3ba2e633 - stable/13 - LinuxKPI: Allow cdev_pager prefault handler to steal pages List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: wulf X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 767e3ba2e63346953a5dacd0779013ca22f36170 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by wulf: URL: https://cgit.FreeBSD.org/src/commit/?id=767e3ba2e63346953a5dacd0779013ca22f36170 commit 767e3ba2e63346953a5dacd0779013ca22f36170 Author: Vladimir Kondratyev AuthorDate: 2021-09-29 20:14:05 +0000 Commit: Vladimir Kondratyev CommitDate: 2021-10-13 09:02:49 +0000 LinuxKPI: Allow cdev_pager prefault handler to steal pages from other vm_objects. This workarounds "Page already inserted" panic in vm_page_insert routine triggered on attempt to mmap file created with shmem_file_setup call. After introduction of "GTT mmap interface v4" a.k.a. MMAP_OFFSET, vm_objects allocated by these calls may try to own intersected sets of pages that leads to the assertion. Reviewed by: kib Differential revision: https://reviews.freebsd.org/D32090 (cherry picked from commit 62ff0566c93056e00b3c9c3f8d2ac1e7d8e0c098) --- sys/compat/linuxkpi/common/src/linux_page.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/sys/compat/linuxkpi/common/src/linux_page.c b/sys/compat/linuxkpi/common/src/linux_page.c index cbe6d2530b91..c7191fef3429 100644 --- a/sys/compat/linuxkpi/common/src/linux_page.c +++ b/sys/compat/linuxkpi/common/src/linux_page.c @@ -281,6 +281,7 @@ lkpi_vmf_insert_pfn_prot_locked(struct vm_area_struct *vma, unsigned long addr, unsigned long pfn, pgprot_t prot) { vm_object_t vm_obj = vma->vm_obj; + vm_object_t tmp_obj; vm_page_t page; vm_pindex_t pindex; @@ -296,6 +297,32 @@ retry: page = PHYS_TO_VM_PAGE(IDX_TO_OFF(pfn)); if (!vm_page_busy_acquire(page, VM_ALLOC_WAITFAIL)) goto retry; + if (page->object != NULL) { + tmp_obj = page->object; + vm_page_xunbusy(page); + VM_OBJECT_WUNLOCK(vm_obj); + VM_OBJECT_WLOCK(tmp_obj); + if (page->object == tmp_obj && + vm_page_busy_acquire(page, VM_ALLOC_WAITFAIL)) { + KASSERT(page->object == tmp_obj, + ("page has changed identity")); + KASSERT((page->oflags & VPO_UNMANAGED) == 0, + ("page does not belong to shmem")); + vm_pager_page_unswapped(page); + if (pmap_page_is_mapped(page)) { + vm_page_xunbusy(page); + VM_OBJECT_WUNLOCK(tmp_obj); + printf("%s: page rename failed: page " + "is mapped\n", __func__); + VM_OBJECT_WLOCK(vm_obj); + return (VM_FAULT_NOPAGE); + } + vm_page_remove(page); + } + VM_OBJECT_WUNLOCK(tmp_obj); + VM_OBJECT_WLOCK(vm_obj); + goto retry; + } if (vm_page_insert(page, vm_obj, pindex)) { vm_page_xunbusy(page); return (VM_FAULT_OOM); From nobody Wed Oct 13 09:19:14 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 6FD5A1800582; Wed, 13 Oct 2021 09:19: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 4HTn6D3fGyz4sY8; Wed, 13 Oct 2021 09:19:16 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 63B9325052; Wed, 13 Oct 2021 09:19: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 19D9JENL057307; Wed, 13 Oct 2021 09:19:14 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19D9JEbj057306; Wed, 13 Oct 2021 09:19:14 GMT (envelope-from git) Date: Wed, 13 Oct 2021 09:19:14 GMT Message-Id: <202110130919.19D9JEbj057306@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Vladimir Kondratyev Subject: git: 4fba1853b5bd - stable/13 - LinuxKPI: stub anon_inode_getfile List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: wulf X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 4fba1853b5bdb427912acda92357d041d9a13d7e Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by wulf: URL: https://cgit.FreeBSD.org/src/commit/?id=4fba1853b5bdb427912acda92357d041d9a13d7e commit 4fba1853b5bdb427912acda92357d041d9a13d7e Author: Vladimir Kondratyev AuthorDate: 2021-09-29 20:13:53 +0000 Commit: Vladimir Kondratyev CommitDate: 2021-10-13 09:02:17 +0000 LinuxKPI: stub anon_inode_getfile Although drm-kmod contains better implementation which is able to allocate real entries on pseudofs, this feature has never been used. Starting from drm-kmod v5.6 old implementation began to leak entries on each drm device close(). Now just drop pseudofs support instead of fixing it in drm-kmod and provide stub in base. Reviewed by: hselasky, manu Differential revision: https://reviews.freebsd.org/D32069 (cherry picked from commit bd6d55adb4131d7172e0485d30ceca4e5aa12ff5) --- .../linuxkpi/common/include/linux/anon_inodes.h | 48 ++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/sys/compat/linuxkpi/common/include/linux/anon_inodes.h b/sys/compat/linuxkpi/common/include/linux/anon_inodes.h new file mode 100644 index 000000000000..8fa61cd4b45f --- /dev/null +++ b/sys/compat/linuxkpi/common/include/linux/anon_inodes.h @@ -0,0 +1,48 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2021 Vladimir Kondratyev + * + * 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. + */ + +#ifndef _LINUX_ANON_INODES_H_ +#define _LINUX_ANON_INODES_H_ + +#include +#include +#include + +static inline struct file * +anon_inode_getfile(const char *name __unused, + const struct file_operations *fops, void *priv, int flags __unused) +{ + struct file *file; + + file = alloc_file(FMODE_READ, fops); + file->private_data = priv; + + return (file); +} + +#endif /* _LINUX_ANON_INODES_H_ */ From nobody Wed Oct 13 09:19:16 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 7F13718005BE; Wed, 13 Oct 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 4HTn6G2M5Lz4sVp; Wed, 13 Oct 2021 09:19: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 A39AF24C73; Wed, 13 Oct 2021 09:19: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 19D9JGuX057355; Wed, 13 Oct 2021 09:19:16 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19D9JGRu057354; Wed, 13 Oct 2021 09:19:16 GMT (envelope-from git) Date: Wed, 13 Oct 2021 09:19:16 GMT Message-Id: <202110130919.19D9JGRu057354@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Vladimir Kondratyev Subject: git: 7db428f0bb28 - stable/13 - LinuxKPI: Add helper functions to store integers to linux/xarray.h List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: wulf X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 7db428f0bb28defcac0c05b9745d09237a8293d3 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by wulf: URL: https://cgit.FreeBSD.org/src/commit/?id=7db428f0bb28defcac0c05b9745d09237a8293d3 commit 7db428f0bb28defcac0c05b9745d09237a8293d3 Author: Vladimir Kondratyev AuthorDate: 2021-09-29 20:14:23 +0000 Commit: Vladimir Kondratyev CommitDate: 2021-10-13 09:03:29 +0000 LinuxKPI: Add helper functions to store integers to linux/xarray.h Required by drm-kmod. Reviewed by: hselasky Differential revision: https://reviews.freebsd.org/D32091 (cherry picked from commit b59ffedae8f3707bf0079b4fd0cbf8190eed0c5e) --- sys/compat/linuxkpi/common/include/linux/xarray.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/sys/compat/linuxkpi/common/include/linux/xarray.h b/sys/compat/linuxkpi/common/include/linux/xarray.h index afe66c1f2b5f..7427f6e4f9f9 100644 --- a/sys/compat/linuxkpi/common/include/linux/xarray.h +++ b/sys/compat/linuxkpi/common/include/linux/xarray.h @@ -97,4 +97,27 @@ xa_init(struct xarray *xa) xa_init_flags(xa, 0); } +static inline void * +xa_mk_value(unsigned long v) +{ + unsigned long r = (v << 1) | 1; + + return ((void *)r); +} + +static inline bool +xa_is_value(const void *e) +{ + unsigned long v = (unsigned long)e; + + return (v & 1); +} + +static inline unsigned long +xa_to_value(const void *e) +{ + unsigned long v = (unsigned long)e; + + return (v >> 1); +} #endif /* _LINUX_XARRAY_H_ */ From nobody Wed Oct 13 09:19:18 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 5A00E18005E7; Wed, 13 Oct 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 4HTn6J4Xrzz4sgy; Wed, 13 Oct 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 EA1F825407; Wed, 13 Oct 2021 09:19: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 19D9JIJ4057403; Wed, 13 Oct 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 19D9JIhC057402; Wed, 13 Oct 2021 09:19:18 GMT (envelope-from git) Date: Wed, 13 Oct 2021 09:19:18 GMT Message-Id: <202110130919.19D9JIhC057402@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Vladimir Kondratyev Subject: git: 8cf87dd59ff7 - stable/13 - LinuxKPI: Cast offset_in_page() parameter to unsigned long List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: wulf X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 8cf87dd59ff7f58db2a449c05d15f3315244d466 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by wulf: URL: https://cgit.FreeBSD.org/src/commit/?id=8cf87dd59ff7f58db2a449c05d15f3315244d466 commit 8cf87dd59ff7f58db2a449c05d15f3315244d466 Author: Vladimir Kondratyev AuthorDate: 2021-09-29 20:14:47 +0000 Commit: Vladimir Kondratyev CommitDate: 2021-10-13 09:04:58 +0000 LinuxKPI: Cast offset_in_page() parameter to unsigned long to reduce number of patches in drm-kmod Reviewed by: hselasky Differential revision: https://reviews.freebsd.org/D32093 (cherry picked from commit 37eba5b77a5733ac711b119141619c89b8446471) --- sys/compat/linuxkpi/common/include/linux/mm.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/compat/linuxkpi/common/include/linux/mm.h b/sys/compat/linuxkpi/common/include/linux/mm.h index dc75ae4483c3..871d16cb06ff 100644 --- a/sys/compat/linuxkpi/common/include/linux/mm.h +++ b/sys/compat/linuxkpi/common/include/linux/mm.h @@ -229,7 +229,7 @@ vma_pages(struct vm_area_struct *vma) return ((vma->vm_end - vma->vm_start) >> PAGE_SHIFT); } -#define offset_in_page(off) ((off) & (PAGE_SIZE - 1)) +#define offset_in_page(off) ((unsigned long)(off) & (PAGE_SIZE - 1)) static inline void set_page_dirty(struct vm_page *page) From nobody Wed Oct 13 09:19:17 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id DCB4318006B8; Wed, 13 Oct 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 4HTn6J6dbzz4skP; Wed, 13 Oct 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 CE08D25053; Wed, 13 Oct 2021 09:19: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 19D9JH1A057379; Wed, 13 Oct 2021 09:19:17 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19D9JHd1057378; Wed, 13 Oct 2021 09:19:17 GMT (envelope-from git) Date: Wed, 13 Oct 2021 09:19:17 GMT Message-Id: <202110130919.19D9JHd1057378@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Vladimir Kondratyev Subject: git: 0ed3a19a3896 - stable/13 - LinuxKPI: Import linux/poison.h header List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: wulf X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 0ed3a19a3896806cbbb5c2eb3abd6e3c473941bb Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by wulf: URL: https://cgit.FreeBSD.org/src/commit/?id=0ed3a19a3896806cbbb5c2eb3abd6e3c473941bb commit 0ed3a19a3896806cbbb5c2eb3abd6e3c473941bb Author: Vladimir Kondratyev AuthorDate: 2021-09-29 20:14:34 +0000 Commit: Vladimir Kondratyev CommitDate: 2021-10-13 09:04:11 +0000 LinuxKPI: Import linux/poison.h header Required by drm-kmod 5.6 Reviewed by: hselasky, imp, manu Obtained from: OpenBSD Differential revision: https://reviews.freebsd.org/D32092 (cherry picked from commit 6efabdeede7f3aac4b133116a421f5a7a721e24c) --- sys/compat/linuxkpi/common/include/linux/poison.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/sys/compat/linuxkpi/common/include/linux/poison.h b/sys/compat/linuxkpi/common/include/linux/poison.h new file mode 100644 index 000000000000..35ccb5b5499a --- /dev/null +++ b/sys/compat/linuxkpi/common/include/linux/poison.h @@ -0,0 +1,9 @@ +/* Public domain. */ + +#ifndef _LINUX_POISON_H +#define _LINUX_POISON_H + +#define POISON_INUSE 0xdb +#define POISON_FREE 0xdf + +#endif From nobody Wed Oct 13 09:19:20 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 824CD1800891; Wed, 13 Oct 2021 09:19:22 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HTn6L1Hzsz4sYN; Wed, 13 Oct 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 1B58A251A2; Wed, 13 Oct 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 19D9JKLw057433; Wed, 13 Oct 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 19D9JKow057432; Wed, 13 Oct 2021 09:19:20 GMT (envelope-from git) Date: Wed, 13 Oct 2021 09:19:20 GMT Message-Id: <202110130919.19D9JKow057432@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Vladimir Kondratyev Subject: git: f2a3116ab4d6 - stable/13 - LinuxKPI: Add dummy pgprot_decrypted() implementation List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: wulf X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: f2a3116ab4d670389dfea4d3fe997af246f5b330 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by wulf: URL: https://cgit.FreeBSD.org/src/commit/?id=f2a3116ab4d670389dfea4d3fe997af246f5b330 commit f2a3116ab4d670389dfea4d3fe997af246f5b330 Author: Vladimir Kondratyev AuthorDate: 2021-09-29 20:14:58 +0000 Commit: Vladimir Kondratyev CommitDate: 2021-10-13 09:05:38 +0000 LinuxKPI: Add dummy pgprot_decrypted() implementation to reduce number of #ifdefs in drm-kmod Reviewed by: hselasky Differential revision: https://reviews.freebsd.org/D32094 (cherry picked from commit 3d86f8f1d7d1a070dd2e81367a4196a272b3bd07) --- sys/compat/linuxkpi/common/include/asm/pgtable.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sys/compat/linuxkpi/common/include/asm/pgtable.h b/sys/compat/linuxkpi/common/include/asm/pgtable.h index 1df103060368..4831c144888d 100644 --- a/sys/compat/linuxkpi/common/include/asm/pgtable.h +++ b/sys/compat/linuxkpi/common/include/asm/pgtable.h @@ -40,4 +40,6 @@ typedef unsigned long pgdval_t; typedef unsigned long pgprotval_t; typedef struct page *pgtable_t; +#define pgprot_decrypted(prot) (prot) + #endif /* _ASM_PGTABLE_H_ */ From nobody Wed Oct 13 09:19:21 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id DAFE81800745; Wed, 13 Oct 2021 09: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 4HTn6M4qcFz4sbl; Wed, 13 Oct 2021 09: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 4143E25408; Wed, 13 Oct 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 19D9JLXO057457; Wed, 13 Oct 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 19D9JL5n057456; Wed, 13 Oct 2021 09:19:21 GMT (envelope-from git) Date: Wed, 13 Oct 2021 09:19:21 GMT Message-Id: <202110130919.19D9JL5n057456@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Vladimir Kondratyev Subject: git: 9441d948aa3b - stable/13 - LinuxKPI: Implement backlight_enable and backlight_disable functions List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: wulf X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 9441d948aa3bdf4a4d04c15131d385ae951cd9de Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by wulf: URL: https://cgit.FreeBSD.org/src/commit/?id=9441d948aa3bdf4a4d04c15131d385ae951cd9de commit 9441d948aa3bdf4a4d04c15131d385ae951cd9de Author: Vladimir Kondratyev AuthorDate: 2021-09-29 20:15:12 +0000 Commit: Vladimir Kondratyev CommitDate: 2021-10-13 09:06:51 +0000 LinuxKPI: Implement backlight_enable and backlight_disable functions For now, disable backlight if brightness level is set to 0. In the future we may implement separate knob in backlight(8). Required by drm-kmod v5.6 Reviewed by: hselasky, manu Differential revision: https://reviews.freebsd.org/D32165 (cherry picked from commit b52e36384091c5f80b06b79f5889492eac074426) --- .../linuxkpi/common/include/linux/backlight.h | 22 ++++++++++++++++++++-- sys/compat/linuxkpi/common/src/linux_pci.c | 2 ++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/sys/compat/linuxkpi/common/include/linux/backlight.h b/sys/compat/linuxkpi/common/include/linux/backlight.h index 1d2224811124..b3a07c4cdcaa 100644 --- a/sys/compat/linuxkpi/common/include/linux/backlight.h +++ b/sys/compat/linuxkpi/common/include/linux/backlight.h @@ -79,10 +79,10 @@ void linux_backlight_device_unregister(struct backlight_device *bd); linux_backlight_device_register(name, dev, data, ops, props) #define backlight_device_unregister(bd) linux_backlight_device_unregister(bd) -static inline void +static inline int backlight_update_status(struct backlight_device *bd) { - bd->ops->update_status(bd); + return (bd->ops->update_status(bd)); } static inline void @@ -91,4 +91,22 @@ backlight_force_update(struct backlight_device *bd, int reason) bd->props.brightness = bd->ops->get_brightness(bd); } +static inline int +backlight_enable(struct backlight_device *bd) +{ + if (bd == NULL) + return (0); + bd->props.power = 0/* FB_BLANK_UNBLANK */; + return (backlight_update_status(bd)); +} + +static inline int +backlight_disable(struct backlight_device *bd) +{ + if (bd == NULL) + return (0); + bd->props.power = 4/* FB_BLANK_POWERDOWN */; + return (backlight_update_status(bd)); +} + #endif /* _LINUX_BACKLIGHT_H_ */ diff --git a/sys/compat/linuxkpi/common/src/linux_pci.c b/sys/compat/linuxkpi/common/src/linux_pci.c index ae45df9c6514..b5bb87b5f2ae 100644 --- a/sys/compat/linuxkpi/common/src/linux_pci.c +++ b/sys/compat/linuxkpi/common/src/linux_pci.c @@ -1159,6 +1159,8 @@ linux_backlight_update_status(device_t dev, struct backlight_props *props) pdev->dev.bd->props.brightness = pdev->dev.bd->props.max_brightness * props->brightness / 100; + pdev->dev.bd->props.power = props->brightness == 0 ? + 4/* FB_BLANK_POWERDOWN */ : 0/* FB_BLANK_UNBLANK */; return (pdev->dev.bd->ops->update_status(pdev->dev.bd)); } From nobody Wed Oct 13 09:19:22 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 2A5CE180057F; Wed, 13 Oct 2021 09:19: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 4HTn6N3VtMz4sbn; Wed, 13 Oct 2021 09:19: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 699AC25482; Wed, 13 Oct 2021 09: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 19D9JMCt057481; Wed, 13 Oct 2021 09: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 19D9JMoD057480; Wed, 13 Oct 2021 09:19:22 GMT (envelope-from git) Date: Wed, 13 Oct 2021 09:19:22 GMT Message-Id: <202110130919.19D9JMoD057480@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Vladimir Kondratyev Subject: git: c6fb23b29244 - stable/13 - LinuxKPI: Update pte_fn_t definition to match Linux 5.3 List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: wulf X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: c6fb23b29244ab9a9f77560fba43423431f400ed Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by wulf: URL: https://cgit.FreeBSD.org/src/commit/?id=c6fb23b29244ab9a9f77560fba43423431f400ed commit c6fb23b29244ab9a9f77560fba43423431f400ed Author: Vladimir Kondratyev AuthorDate: 2021-09-29 20:15:27 +0000 Commit: Vladimir Kondratyev CommitDate: 2021-10-13 09:07:24 +0000 LinuxKPI: Update pte_fn_t definition to match Linux 5.3 Reviewed by: emaste, hselasky, manu Differential revision: https://reviews.freebsd.org/D32166 (cherry picked from commit 88531adbfbe25c6ae56cc7bbe76c825a3f5dc504) --- sys/compat/linuxkpi/common/include/linux/mm.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/compat/linuxkpi/common/include/linux/mm.h b/sys/compat/linuxkpi/common/include/linux/mm.h index 871d16cb06ff..4301e616f234 100644 --- a/sys/compat/linuxkpi/common/include/linux/mm.h +++ b/sys/compat/linuxkpi/common/include/linux/mm.h @@ -98,7 +98,7 @@ CTASSERT((VM_PROT_ALL & -(1 << 8)) == 0); #define fault_flag_allow_retry_first(flags) \ (((flags) & (FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_TRIED)) == FAULT_FLAG_ALLOW_RETRY) -typedef int (*pte_fn_t)(linux_pte_t *, pgtable_t, unsigned long addr, void *data); +typedef int (*pte_fn_t)(linux_pte_t *, unsigned long addr, void *data); struct vm_area_struct { vm_offset_t vm_start; From nobody Wed Oct 13 09:19:23 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 92A4E1800758; Wed, 13 Oct 2021 09:19: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 4HTn6P58h7z4skq; Wed, 13 Oct 2021 09:19: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 812DC25409; Wed, 13 Oct 2021 09:19: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 19D9JNeb057505; Wed, 13 Oct 2021 09:19:23 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19D9JNWY057504; Wed, 13 Oct 2021 09:19:23 GMT (envelope-from git) Date: Wed, 13 Oct 2021 09:19:23 GMT Message-Id: <202110130919.19D9JNWY057504@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Vladimir Kondratyev Subject: git: e1f5bed753fe - stable/13 - LinuxKPI: Import linux_page.c and some dependent code from drm-kmod List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: wulf X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: e1f5bed753fe6627f38ee3264f450679805e95da Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by wulf: URL: https://cgit.FreeBSD.org/src/commit/?id=e1f5bed753fe6627f38ee3264f450679805e95da commit e1f5bed753fe6627f38ee3264f450679805e95da Author: Vladimir Kondratyev AuthorDate: 2021-09-29 20:15:37 +0000 Commit: Vladimir Kondratyev CommitDate: 2021-10-13 09:07:53 +0000 LinuxKPI: Import linux_page.c and some dependent code from drm-kmod No functional changes intended Reviewed by: hselasky, manu, markj Differential revision: https://reviews.freebsd.org/D32167 (cherry picked from commit c072f6e856bc0348bf6fdd468761041948823f73) --- sys/compat/linuxkpi/common/include/linux/highmem.h | 118 +++++++++++++++++++++ sys/compat/linuxkpi/common/include/linux/mm.h | 4 + sys/compat/linuxkpi/common/include/linux/page.h | 22 ++++ .../linuxkpi/common/include/linux/scatterlist.h | 58 ++++++++++ sys/compat/linuxkpi/common/src/linux_page.c | 34 ++++++ 5 files changed, 236 insertions(+) diff --git a/sys/compat/linuxkpi/common/include/linux/highmem.h b/sys/compat/linuxkpi/common/include/linux/highmem.h new file mode 100644 index 000000000000..9378746ea480 --- /dev/null +++ b/sys/compat/linuxkpi/common/include/linux/highmem.h @@ -0,0 +1,118 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2010 Isilon Systems, Inc. + * Copyright (c) 2016 Matthew Macy (mmacy@mattmacy.io) + * Copyright (c) 2017 Mellanox Technologies, Ltd. + * Copyright (c) 2021 Vladimir Kondratyev + * + * 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. + */ + +#ifndef _LINUX_HIGHMEM_H_ +#define _LINUX_HIGHMEM_H_ + +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include + +#define PageHighMem(p) (0) + +static inline vm_page_t +kmap_to_page(void *addr) +{ + return (virt_to_page(addr)); +} + +static inline void * +kmap(vm_page_t page) +{ + struct sf_buf *sf; + + if (PMAP_HAS_DMAP) { + return ((void *)PHYS_TO_DMAP(VM_PAGE_TO_PHYS(page))); + } else { + sched_pin(); + sf = sf_buf_alloc(page, SFB_NOWAIT | SFB_CPUPRIVATE); + if (sf == NULL) { + sched_unpin(); + return (NULL); + } + return ((void *)sf_buf_kva(sf)); + } +} + +static inline void * +kmap_atomic_prot(vm_page_t page, pgprot_t prot) +{ + vm_memattr_t attr = pgprot2cachemode(prot); + + if (attr != VM_MEMATTR_DEFAULT) { + vm_page_lock(page); + page->flags |= PG_FICTITIOUS; + vm_page_unlock(page); + pmap_page_set_memattr(page, attr); + } + return (kmap(page)); +} + +static inline void * +kmap_atomic(vm_page_t page) +{ + return (kmap_atomic_prot(page, VM_PROT_ALL)); +} + +static inline void +kunmap(vm_page_t page) +{ + struct sf_buf *sf; + + if (!PMAP_HAS_DMAP) { + /* lookup SF buffer in list */ + sf = sf_buf_alloc(page, SFB_NOWAIT | SFB_CPUPRIVATE); + + /* double-free */ + sf_buf_free(sf); + sf_buf_free(sf); + + sched_unpin(); + } +} + +static inline void +kunmap_atomic(void *vaddr) +{ + if (!PMAP_HAS_DMAP) + kunmap(virt_to_page(vaddr)); +} + +#endif /* _LINUX_HIGHMEM_H_ */ diff --git a/sys/compat/linuxkpi/common/include/linux/mm.h b/sys/compat/linuxkpi/common/include/linux/mm.h index 4301e616f234..0ee9dd58616a 100644 --- a/sys/compat/linuxkpi/common/include/linux/mm.h +++ b/sys/compat/linuxkpi/common/include/linux/mm.h @@ -290,4 +290,8 @@ vmalloc_to_page(const void *addr) extern int is_vmalloc_addr(const void *addr); void si_meminfo(struct sysinfo *si); +#define unmap_mapping_range(...) lkpi_unmap_mapping_range(__VA_ARGS__) +void lkpi_unmap_mapping_range(void *obj, loff_t const holebegin __unused, + loff_t const holelen, int even_cows __unused); + #endif /* _LINUX_MM_H_ */ diff --git a/sys/compat/linuxkpi/common/include/linux/page.h b/sys/compat/linuxkpi/common/include/linux/page.h index a09ae439266e..0c3d456d6ec0 100644 --- a/sys/compat/linuxkpi/common/include/linux/page.h +++ b/sys/compat/linuxkpi/common/include/linux/page.h @@ -41,6 +41,10 @@ #include #include +#if defined(__i386__) || defined(__amd64__) +#include +#endif + typedef unsigned long linux_pte_t; typedef unsigned long linux_pmd_t; typedef unsigned long linux_pgd_t; @@ -53,6 +57,8 @@ typedef unsigned long pgprot_t; CTASSERT((VM_PROT_ALL & -LINUXKPI_PROT_VALID) == 0); +#define PAGE_KERNEL_IO 0x0000 + static inline pgprot_t cachemode2protval(vm_memattr_t attr) { @@ -72,6 +78,7 @@ pgprot2cachemode(pgprot_t prot) #define page_to_pfn(pp) (VM_PAGE_TO_PHYS(pp) >> PAGE_SHIFT) #define pfn_to_page(pfn) (PHYS_TO_VM_PAGE((pfn) << PAGE_SHIFT)) #define nth_page(page,n) pfn_to_page(page_to_pfn(page) + (n)) +#define page_to_phys(page) VM_PAGE_TO_PHYS(page) #define clear_page(page) memset(page, 0, PAGE_SIZE) #define pgprot_noncached(prot) \ @@ -97,4 +104,19 @@ pgprot2cachemode(pgprot_t prot) #undef trunc_page #define trunc_page(x) ((uintptr_t)(x) & ~(PAGE_SIZE - 1)) +#if defined(__i386__) || defined(__amd64__) +#undef clflushopt +static inline void +lkpi_clflushopt(unsigned long addr) +{ + if (cpu_stdext_feature & CPUID_STDEXT_CLFLUSHOPT) + clflushopt(addr); + else if (cpu_feature & CPUID_CLFSH) + clflush(addr); + else + pmap_invalidate_cache(); +} +#define clflushopt(x) lkpi_clflushopt((unsigned long)(x)) +#endif + #endif /* _LINUX_PAGE_H_ */ diff --git a/sys/compat/linuxkpi/common/include/linux/scatterlist.h b/sys/compat/linuxkpi/common/include/linux/scatterlist.h index 5e42876facd0..13ee34cf9448 100644 --- a/sys/compat/linuxkpi/common/include/linux/scatterlist.h +++ b/sys/compat/linuxkpi/common/include/linux/scatterlist.h @@ -4,6 +4,7 @@ * Copyright (c) 2010 Panasas, Inc. * Copyright (c) 2013-2017 Mellanox Technologies, Ltd. * Copyright (c) 2015 Matthew Dillon + * Copyright (c) 2016 Matthew Macy * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -534,4 +535,61 @@ sg_pcopy_from_buffer(struct scatterlist *sgl, unsigned int nents, return (copied); } +static inline size_t +sg_copy_from_buffer(struct scatterlist *sgl, unsigned int nents, + const void *buf, size_t buflen) +{ + return (sg_pcopy_from_buffer(sgl, nents, buf, buflen, 0)); +} + +static inline size_t +sg_pcopy_to_buffer(struct scatterlist *sgl, unsigned int nents, + void *buf, size_t buflen, off_t offset) +{ + struct sg_page_iter iter; + struct scatterlist *sg; + struct page *page; + struct sf_buf *sf; + char *vaddr; + size_t total = 0; + size_t len; + + if (!PMAP_HAS_DMAP) + sched_pin(); + for_each_sg_page(sgl, &iter, nents, 0) { + sg = iter.sg; + + if (offset >= sg->length) { + offset -= sg->length; + continue; + } + len = ulmin(buflen, sg->length - offset); + if (len == 0) + break; + + page = sg_page_iter_page(&iter); + if (!PMAP_HAS_DMAP) { + sf = sf_buf_alloc(page, SFB_CPUPRIVATE | SFB_NOWAIT); + if (sf == NULL) + break; + vaddr = (char *)sf_buf_kva(sf); + } else + vaddr = (char *)PHYS_TO_DMAP(VM_PAGE_TO_PHYS(page)); + memcpy(buf, vaddr + sg->offset + offset, len); + if (!PMAP_HAS_DMAP) + sf_buf_free(sf); + + /* start at beginning of next page */ + offset = 0; + + /* advance buffer */ + buf = (char *)buf + len; + buflen -= len; + total += len; + } + if (!PMAP_HAS_DMAP) + sched_unpin(); + return (total); +} + #endif /* _LINUX_SCATTERLIST_H_ */ diff --git a/sys/compat/linuxkpi/common/src/linux_page.c b/sys/compat/linuxkpi/common/src/linux_page.c index c7191fef3429..8da4736ab7d5 100644 --- a/sys/compat/linuxkpi/common/src/linux_page.c +++ b/sys/compat/linuxkpi/common/src/linux_page.c @@ -334,3 +334,37 @@ retry: return (VM_FAULT_NOPAGE); } + +/* + * Although FreeBSD version of unmap_mapping_range has semantics and types of + * parameters compatible with Linux version, the values passed in are different + * @obj should match to vm_private_data field of vm_area_struct returned by + * mmap file operation handler, see linux_file_mmap_single() sources + * @holelen should match to size of area to be munmapped. + */ +void +lkpi_unmap_mapping_range(void *obj, loff_t const holebegin __unused, + loff_t const holelen, int even_cows __unused) +{ + vm_object_t devobj; + vm_page_t page; + int i, page_count; + + devobj = cdev_pager_lookup(obj); + if (devobj != NULL) { + page_count = OFF_TO_IDX(holelen); + + VM_OBJECT_WLOCK(devobj); +retry: + for (i = 0; i < page_count; i++) { + page = vm_page_lookup(devobj, i); + if (page == NULL) + continue; + if (!vm_page_busy_acquire(page, VM_ALLOC_WAITFAIL)) + goto retry; + cdev_pager_free_page(devobj, page); + } + VM_OBJECT_WUNLOCK(devobj); + vm_object_deallocate(devobj); + } +} From nobody Wed Oct 13 09:19:24 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 9A47018007FB; Wed, 13 Oct 2021 09:19: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 4HTn6R1BFGz4sTG; Wed, 13 Oct 2021 09:19: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 A2318251A3; Wed, 13 Oct 2021 09:19: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 19D9JOTV057529; Wed, 13 Oct 2021 09:19:24 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19D9JOIL057528; Wed, 13 Oct 2021 09:19:24 GMT (envelope-from git) Date: Wed, 13 Oct 2021 09:19:24 GMT Message-Id: <202110130919.19D9JOIL057528@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Vladimir Kondratyev Subject: git: dc9094140c92 - stable/13 - Bump __FreeBSD_version to 1300517 for LinuxKPI changes List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: wulf X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: dc9094140c9263857911eb2610c69011abb1b970 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by wulf: URL: https://cgit.FreeBSD.org/src/commit/?id=dc9094140c9263857911eb2610c69011abb1b970 commit dc9094140c9263857911eb2610c69011abb1b970 Author: Vladimir Kondratyev AuthorDate: 2021-10-12 13:22:37 +0000 Commit: Vladimir Kondratyev CommitDate: 2021-10-13 09:08:17 +0000 Bump __FreeBSD_version to 1300517 for LinuxKPI changes --- 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 67c663de8b76..799ba1a9af42 100644 --- a/sys/sys/param.h +++ b/sys/sys/param.h @@ -60,7 +60,7 @@ * in the range 5 to 9. */ #undef __FreeBSD_version -#define __FreeBSD_version 1300516 /* Master, propagated to newvers */ +#define __FreeBSD_version 1300517 /* Master, propagated to newvers */ /* * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD, From nobody Wed Oct 13 20:10:05 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4AA531810974; Wed, 13 Oct 2021 20:10:06 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HV3YB1jHbz3vkv; Wed, 13 Oct 2021 20:10:06 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 0DB542DEDE; Wed, 13 Oct 2021 20:10:06 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19DKA54Z036445; Wed, 13 Oct 2021 20:10:05 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19DKA5Dk036442; Wed, 13 Oct 2021 20:10:05 GMT (envelope-from git) Date: Wed, 13 Oct 2021 20:10:05 GMT Message-Id: <202110132010.19DKA5Dk036442@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Marko Zec Subject: git: 0eeef61aec4b - stable/13 - [fib_algo][dxr] Improve incremental updating strategy List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: zec X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 0eeef61aec4b996e88547f31a8e7fef677180e98 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by zec: URL: https://cgit.FreeBSD.org/src/commit/?id=0eeef61aec4b996e88547f31a8e7fef677180e98 commit 0eeef61aec4b996e88547f31a8e7fef677180e98 Author: Marko Zec AuthorDate: 2021-10-09 11:22:27 +0000 Commit: Marko Zec CommitDate: 2021-10-13 20:06:10 +0000 [fib_algo][dxr] Improve incremental updating strategy Tracking the number of unused holes in the trie and the range table was a bad metric based on which full trie and / or range rebuilds were triggered, which would happen in vain by far too frequently, particularly with live BGP feeds. Instead, track the total unused space inside the trie and range table structures, and trigger rebuilds if the percentage of unused space exceeds a sysctl-tunable threshold. MFC after: 3 days PR: 257965 --- sys/netinet/in_fib_dxr.c | 103 ++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 84 insertions(+), 19 deletions(-) diff --git a/sys/netinet/in_fib_dxr.c b/sys/netinet/in_fib_dxr.c index 6a9f414c3ab0..d832a66ee2cc 100644 --- a/sys/netinet/in_fib_dxr.c +++ b/sys/netinet/in_fib_dxr.c @@ -49,6 +49,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include @@ -195,6 +196,7 @@ struct dxr_aux { uint32_t updates_high; uint32_t all_chunks_cnt; uint32_t unused_chunks_cnt; + uint32_t unused_chunks_size; uint32_t xtbl_size; uint32_t all_trie_cnt; uint32_t unused_trie_cnt; @@ -232,21 +234,48 @@ static MALLOC_DEFINE(M_DXRAUX, "dxr aux", "DXR auxiliary"); uma_zone_t chunk_zone; uma_zone_t trie_zone; +VNET_DEFINE_STATIC(int, frag_limit) = 100; +#define V_frag_limit VNET(frag_limit) + SYSCTL_DECL(_net_route_algo); SYSCTL_NODE(_net_route_algo, OID_AUTO, dxr, CTLFLAG_RW | CTLFLAG_MPSAFE, 0, "DXR tunables"); -VNET_DEFINE_STATIC(int, max_trie_holes) = 8; -#define V_max_trie_holes VNET(max_trie_holes) -SYSCTL_INT(_net_route_algo_dxr, OID_AUTO, max_trie_holes, - CTLFLAG_RW | CTLFLAG_VNET, &VNET_NAME(max_trie_holes), 0, - "Trie fragmentation threshold before triggering a full rebuild"); +static int +sysctl_dxr_frag_limit(SYSCTL_HANDLER_ARGS) +{ + char buf[8]; + int error, new, i; + + snprintf(buf, sizeof(buf), "%d.%02d%%", V_frag_limit / 100, + V_frag_limit % 100); + error = sysctl_handle_string(oidp, buf, sizeof(buf), req); + if (error != 0 || req->newptr == NULL) + return (error); + if (!isdigit(*buf) && *buf != '.') + return (EINVAL); + for (i = 0, new = 0; isdigit(buf[i]) && i < sizeof(buf); i++) + new = new * 10 + buf[i] - '0'; + new *= 100; + if (buf[i++] == '.') { + if (!isdigit(buf[i])) + return (EINVAL); + new += (buf[i++] - '0') * 10; + if (isdigit(buf[i])) + new += buf[i++] - '0'; + } + if (new > 1000) + return (EINVAL); + V_frag_limit = new; + snprintf(buf, sizeof(buf), "%d.%02d%%", V_frag_limit / 100, + V_frag_limit % 100); + return (0); +} -VNET_DEFINE_STATIC(int, max_range_holes) = 16; -#define V_max_range_holes VNET(max_range_holes) -SYSCTL_INT(_net_route_algo_dxr, OID_AUTO, max_range_holes, - CTLFLAG_RW | CTLFLAG_VNET, &VNET_NAME(max_range_holes), 0, - "Range table fragmentation threshold before triggering a full rebuild"); +SYSCTL_PROC(_net_route_algo_dxr, OID_AUTO, frag_limit, + CTLTYPE_STRING | CTLFLAG_RW | CTLFLAG_VNET, + 0, 0, sysctl_dxr_frag_limit, "A", + "Fragmentation threshold to full rebuild"); /* Binary search for a matching address range */ #define DXR_LOOKUP_STAGE \ @@ -424,6 +453,7 @@ chunk_ref(struct dxr_aux *da, uint32_t chunk) fdesc->base = cdp->cd_base; da->rtbl_top -= size; da->unused_chunks_cnt--; + da->unused_chunks_size -= cdp->cd_max_size; if (cdp->cd_max_size > size) { /* Split the range in two, need a new descriptor */ empty_cdp = uma_zalloc(chunk_zone, M_NOWAIT); @@ -442,6 +472,7 @@ chunk_ref(struct dxr_aux *da, uint32_t chunk) da->all_chunks_cnt++; da->unused_chunks_cnt++; + da->unused_chunks_size += empty_cdp->cd_max_size; cdp->cd_max_size = size; } LIST_REMOVE(cdp, cd_hash_le); @@ -471,9 +502,9 @@ chunk_ref(struct dxr_aux *da, uint32_t chunk) return (1); } da->rtbl_size += RTBL_SIZE_INCR; - if (da->rtbl_top >= BASE_MAX / 4) - FIB_PRINTF(LOG_WARNING, da->fd, "range table at %d%%", - da->rtbl_top * 100 / BASE_MAX); + i = (BASE_MAX - da->rtbl_top) * LOG_DEBUG / BASE_MAX; + FIB_PRINTF(i, da->fd, "range table at %d%% structural limit", + da->rtbl_top * 100 / BASE_MAX); da->range_tbl = realloc(da->range_tbl, sizeof(*da->range_tbl) * da->rtbl_size + FRAGS_PREF_SHORT, M_DXRAUX, M_NOWAIT); @@ -508,6 +539,7 @@ chunk_unref(struct dxr_aux *da, uint32_t chunk) LIST_REMOVE(cdp, cd_hash_le); da->unused_chunks_cnt++; + da->unused_chunks_size += cdp->cd_max_size; cdp->cd_cur_size = 0; /* Attempt to merge with the preceding chunk, if empty */ @@ -546,6 +578,7 @@ chunk_unref(struct dxr_aux *da, uint32_t chunk) da->all_chunks_cnt--; da->unused_chunks_cnt--; da->rtbl_top -= cdp->cd_max_size; + da->unused_chunks_size -= cdp->cd_max_size; LIST_REMOVE(cdp, cd_all_le); uma_zfree(chunk_zone, cdp); return; @@ -846,10 +879,12 @@ dxr_build(struct dxr *dxr) struct timeval t0, t1, t2, t3; uint32_t r_size, dxr_tot_size; uint32_t i, m, range_rebuild = 0; + uint32_t range_frag; #ifdef DXR2 struct trie_desc *tp; uint32_t d_tbl_size, dxr_x, d_size, x_size; uint32_t ti, trie_rebuild = 0, prev_size = 0; + uint32_t trie_frag; #endif KASSERT(dxr->d == NULL, ("dxr: d not free")); @@ -897,9 +932,10 @@ dxr_build(struct dxr *dxr) dxr->nh_tbl = fib_get_nhop_array(da->fd); fib_get_rtable_info(fib_get_rh(da->fd), &rinfo); - if (da->updates_low > da->updates_high || - da->unused_chunks_cnt > V_max_range_holes) + if (da->updates_low > da->updates_high) range_rebuild = 1; + +range_build: if (range_rebuild) { /* Bulk cleanup */ bzero(da->chunk_hashtbl, sizeof(da->chunk_hashtbl)); @@ -910,6 +946,7 @@ dxr_build(struct dxr *dxr) for (i = 0; i < UNUSED_BUCKETS; i++) LIST_INIT(&da->unused_chunks[i]); da->all_chunks_cnt = da->unused_chunks_cnt = 0; + da->unused_chunks_size = 0; da->rtbl_top = 0; da->updates_low = 0; da->updates_high = DIRECT_TBL_SIZE - 1; @@ -929,18 +966,32 @@ dxr_build(struct dxr *dxr) else if (m & 1 && update_chunk(da, i) != 0) return; } + + range_frag = 0; + if (da->rtbl_top) + range_frag = da->unused_chunks_size * 10000ULL / da->rtbl_top; + if (range_frag > V_frag_limit) { + range_rebuild = 1; + goto range_build; + } + r_size = sizeof(*da->range_tbl) * da->rtbl_top; microuptime(&t1); #ifdef DXR2 - if (range_rebuild || da->unused_trie_cnt > V_max_trie_holes || + if (range_rebuild || abs(fls(da->prefixes) - fls(da->trie_rebuilt_prefixes)) > 1) trie_rebuild = 1; + +trie_build: if (trie_rebuild) { da->trie_rebuilt_prefixes = da->prefixes; da->d_bits = DXR_D; da->updates_low = 0; da->updates_high = DIRECT_TBL_SIZE - 1; + if (!range_rebuild) + memset(da->updates_mask, 0xff, + sizeof(da->updates_mask)); } dxr2_try_squeeze: @@ -976,6 +1027,14 @@ dxr2_try_squeeze: da->d_tbl[i] = ti; } + trie_frag = 0; + if (da->all_trie_cnt) + trie_frag = da->unused_trie_cnt * 10000ULL / da->all_trie_cnt; + if (trie_frag > V_frag_limit) { + trie_rebuild = 1; + goto trie_build; + } + d_size = sizeof(*da->d_tbl) * d_tbl_size; x_size = sizeof(*da->x_tbl) * DIRECT_TBL_SIZE / d_tbl_size * da->all_trie_cnt; @@ -1035,6 +1094,15 @@ dxr2_try_squeeze: FIB_PRINTF(LOG_INFO, da->fd, "%d.%02d KBytes, %d.%02d Bytes/prefix", dxr_tot_size / 1024, dxr_tot_size * 100 / 1024 % 100, i / 100, i % 100); +#ifdef DXR2 + FIB_PRINTF(LOG_INFO, da->fd, + "%d.%02d%% trie, %d.%02d%% range fragmentation", + trie_frag / 100, trie_frag % 100, + range_frag / 100, range_frag % 100); +#else + FIB_PRINTF(LOG_INFO, da->fd, "%d.%01d%% range fragmentation", + range_frag / 100, range_frag % 100); +#endif i = (t1.tv_sec - t0.tv_sec) * 1000000 + t1.tv_usec - t0.tv_usec; FIB_PRINTF(LOG_INFO, da->fd, "range table %s in %u.%03u ms", range_rebuild ? "rebuilt" : "updated", i / 1000, i % 1000); @@ -1046,9 +1114,6 @@ dxr2_try_squeeze: i = (t3.tv_sec - t2.tv_sec) * 1000000 + t3.tv_usec - t2.tv_usec; FIB_PRINTF(LOG_INFO, da->fd, "snapshot forked in %u.%03u ms", i / 1000, i % 1000); - FIB_PRINTF(LOG_INFO, da->fd, "range table: %d%%, %d chunks, %d holes", - da->rtbl_top * 100 / BASE_MAX, da->all_chunks_cnt, - da->unused_chunks_cnt); } /* From nobody Wed Oct 13 20:10:06 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id B1AEA1810977; Wed, 13 Oct 2021 20:10:07 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HV3YC31gwz3vnD; Wed, 13 Oct 2021 20:10:07 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 18D6E2E145; Wed, 13 Oct 2021 20:10: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 19DKA7os036658; Wed, 13 Oct 2021 20:10:07 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19DKA6MD036656; Wed, 13 Oct 2021 20:10:06 GMT (envelope-from git) Date: Wed, 13 Oct 2021 20:10:06 GMT Message-Id: <202110132010.19DKA6MD036656@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Marko Zec Subject: git: 602f81ea50d5 - stable/13 - [fib_algo][dxr] Retire counters which are no longer used List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: zec X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 602f81ea50d5456389fef22d4eb48192ac4e3050 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by zec: URL: https://cgit.FreeBSD.org/src/commit/?id=602f81ea50d5456389fef22d4eb48192ac4e3050 commit 602f81ea50d5456389fef22d4eb48192ac4e3050 Author: Marko Zec AuthorDate: 2021-10-09 11:47:10 +0000 Commit: Marko Zec CommitDate: 2021-10-13 20:06:49 +0000 [fib_algo][dxr] Retire counters which are no longer used The number of chunks can still be tracked via vmstat -z|fgrep dxr. MFC after: 3 days --- sys/netinet/in_fib_dxr.c | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/sys/netinet/in_fib_dxr.c b/sys/netinet/in_fib_dxr.c index d832a66ee2cc..f23db925444f 100644 --- a/sys/netinet/in_fib_dxr.c +++ b/sys/netinet/in_fib_dxr.c @@ -194,8 +194,6 @@ struct dxr_aux { uint32_t prefixes; uint32_t updates_low; uint32_t updates_high; - uint32_t all_chunks_cnt; - uint32_t unused_chunks_cnt; uint32_t unused_chunks_size; uint32_t xtbl_size; uint32_t all_trie_cnt; @@ -452,7 +450,6 @@ chunk_ref(struct dxr_aux *da, uint32_t chunk) size * sizeof(struct range_entry_long)); fdesc->base = cdp->cd_base; da->rtbl_top -= size; - da->unused_chunks_cnt--; da->unused_chunks_size -= cdp->cd_max_size; if (cdp->cd_max_size > size) { /* Split the range in two, need a new descriptor */ @@ -470,8 +467,6 @@ chunk_ref(struct dxr_aux *da, uint32_t chunk) LIST_INSERT_HEAD(&da->unused_chunks[i], empty_cdp, cd_hash_le); - da->all_chunks_cnt++; - da->unused_chunks_cnt++; da->unused_chunks_size += empty_cdp->cd_max_size; cdp->cd_max_size = size; } @@ -484,7 +479,6 @@ chunk_ref(struct dxr_aux *da, uint32_t chunk) cdp->cd_max_size = size; cdp->cd_base = fdesc->base; LIST_INSERT_HEAD(&da->all_chunks, cdp, cd_all_le); - da->all_chunks_cnt++; KASSERT(cdp->cd_base + cdp->cd_max_size == da->rtbl_top, ("dxr: %s %d", __FUNCTION__, __LINE__)); } @@ -538,7 +532,6 @@ chunk_unref(struct dxr_aux *da, uint32_t chunk) return; LIST_REMOVE(cdp, cd_hash_le); - da->unused_chunks_cnt++; da->unused_chunks_size += cdp->cd_max_size; cdp->cd_cur_size = 0; @@ -548,9 +541,7 @@ chunk_unref(struct dxr_aux *da, uint32_t chunk) KASSERT(cdp2->cd_base + cdp2->cd_max_size == cdp->cd_base, ("dxr: %s %d", __FUNCTION__, __LINE__)); LIST_REMOVE(cdp, cd_all_le); - da->all_chunks_cnt--; LIST_REMOVE(cdp2, cd_hash_le); - da->unused_chunks_cnt--; cdp2->cd_max_size += cdp->cd_max_size; uma_zfree(chunk_zone, cdp); cdp = cdp2; @@ -562,9 +553,7 @@ chunk_unref(struct dxr_aux *da, uint32_t chunk) KASSERT(cdp->cd_base + cdp->cd_max_size == cdp2->cd_base, ("dxr: %s %d", __FUNCTION__, __LINE__)); LIST_REMOVE(cdp, cd_all_le); - da->all_chunks_cnt--; LIST_REMOVE(cdp2, cd_hash_le); - da->unused_chunks_cnt--; cdp2->cd_max_size += cdp->cd_max_size; cdp2->cd_base = cdp->cd_base; uma_zfree(chunk_zone, cdp); @@ -575,8 +564,6 @@ chunk_unref(struct dxr_aux *da, uint32_t chunk) /* Free the chunk on the top of the range heap, trim the heap */ KASSERT(cdp == LIST_FIRST(&da->all_chunks), ("dxr: %s %d", __FUNCTION__, __LINE__)); - da->all_chunks_cnt--; - da->unused_chunks_cnt--; da->rtbl_top -= cdp->cd_max_size; da->unused_chunks_size -= cdp->cd_max_size; LIST_REMOVE(cdp, cd_all_le); @@ -945,7 +932,6 @@ range_build: } for (i = 0; i < UNUSED_BUCKETS; i++) LIST_INIT(&da->unused_chunks[i]); - da->all_chunks_cnt = da->unused_chunks_cnt = 0; da->unused_chunks_size = 0; da->rtbl_top = 0; da->updates_low = 0; From nobody Thu Oct 14 10:50:51 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id BCF6117F9EA6; Thu, 14 Oct 2021 10:50: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 4HVR5R51zvz3skN; Thu, 14 Oct 2021 10:50: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 8CE2412026; Thu, 14 Oct 2021 10:50: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 19EAopOu015120; Thu, 14 Oct 2021 10:50:51 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19EAop7E015119; Thu, 14 Oct 2021 10:50:51 GMT (envelope-from git) Date: Thu, 14 Oct 2021 10:50:51 GMT Message-Id: <202110141050.19EAop7E015119@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Alexander Motin Subject: git: bcc00cabdbb9 - stable/13 - mps/mpr(4): Move xpt_register_async() out of lock. List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mav X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: bcc00cabdbb9e8255e347f4824838d0303afdd54 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by mav: URL: https://cgit.FreeBSD.org/src/commit/?id=bcc00cabdbb9e8255e347f4824838d0303afdd54 commit bcc00cabdbb9e8255e347f4824838d0303afdd54 Author: Alexander Motin AuthorDate: 2021-09-14 21:37:02 +0000 Commit: Alexander Motin CommitDate: 2021-10-14 10:50:12 +0000 mps/mpr(4): Move xpt_register_async() out of lock. It fixes lock ordere reversal between SIM and device locks. Also remove registration for AC_FOUND_DEVICE, unused for a while now. MFC after: 1 month (cherry picked from commit 02d8194012a9a0e367a92c7f89567b808bf0e9a8) --- sys/dev/mpr/mpr_sas.c | 21 +++++++++++---------- sys/dev/mps/mps_sas.c | 18 ++++++++++-------- 2 files changed, 21 insertions(+), 18 deletions(-) diff --git a/sys/dev/mpr/mpr_sas.c b/sys/dev/mpr/mpr_sas.c index 043d24e82f44..09fa6ac4bc92 100644 --- a/sys/dev/mpr/mpr_sas.c +++ b/sys/dev/mpr/mpr_sas.c @@ -821,6 +821,8 @@ mpr_attach_sas(struct mpr_softc *sc) callout_init(&sassc->discovery_callout, 1 /*mpsafe*/); + mpr_unlock(sc); + /* * Register for async events so we can determine the EEDP * capabilities of devices. @@ -835,7 +837,7 @@ mpr_attach_sas(struct mpr_softc *sc) } else { int event; - event = AC_ADVINFO_CHANGED | AC_FOUND_DEVICE; + event = AC_ADVINFO_CHANGED; status = xpt_register_async(event, mprsas_async, sc, sassc->path); @@ -855,8 +857,6 @@ mpr_attach_sas(struct mpr_softc *sc) mpr_printf(sc, "EEDP capabilities disabled.\n"); } - mpr_unlock(sc); - mprsas_register_events(sc); out: if (error) @@ -890,12 +890,6 @@ mpr_detach_sas(struct mpr_softc *sc) if (sassc->ev_tq != NULL) taskqueue_free(sassc->ev_tq); - /* Make sure CAM doesn't wedge if we had to bail out early. */ - mpr_lock(sc); - - while (sassc->startup_refcount != 0) - mprsas_startup_decrement(sassc); - /* Deregister our async handler */ if (sassc->path != NULL) { xpt_register_async(0, mprsas_async, sc, sassc->path); @@ -903,6 +897,12 @@ mpr_detach_sas(struct mpr_softc *sc) sassc->path = NULL; } + /* Make sure CAM doesn't wedge if we had to bail out early. */ + mpr_lock(sc); + + while (sassc->startup_refcount != 0) + mprsas_startup_decrement(sassc); + if (sassc->flags & MPRSAS_IN_STARTUP) xpt_release_simq(sassc->sim, 1); @@ -3326,6 +3326,7 @@ mprsas_async(void *callback_arg, uint32_t code, struct cam_path *path, sc = (struct mpr_softc *)callback_arg; + mpr_lock(sc); switch (code) { case AC_ADVINFO_CHANGED: { struct mprsas_target *target; @@ -3412,10 +3413,10 @@ mprsas_async(void *callback_arg, uint32_t code, struct cam_path *path, } break; } - case AC_FOUND_DEVICE: default: break; } + mpr_unlock(sc); } /* diff --git a/sys/dev/mps/mps_sas.c b/sys/dev/mps/mps_sas.c index 3124384b6cbb..136e3586ef20 100644 --- a/sys/dev/mps/mps_sas.c +++ b/sys/dev/mps/mps_sas.c @@ -779,6 +779,8 @@ mps_attach_sas(struct mps_softc *sc) callout_init(&sassc->discovery_callout, 1 /*mpsafe*/); + mps_unlock(sc); + /* * Register for async events so we can determine the EEDP * capabilities of devices. @@ -812,8 +814,6 @@ mps_attach_sas(struct mps_softc *sc) mps_printf(sc, "EEDP capabilities disabled.\n"); } - mps_unlock(sc); - mpssas_register_events(sc); out: if (error) @@ -847,12 +847,6 @@ mps_detach_sas(struct mps_softc *sc) if (sassc->ev_tq != NULL) taskqueue_free(sassc->ev_tq); - /* Make sure CAM doesn't wedge if we had to bail out early. */ - mps_lock(sc); - - while (sassc->startup_refcount != 0) - mpssas_startup_decrement(sassc); - /* Deregister our async handler */ if (sassc->path != NULL) { xpt_register_async(0, mpssas_async, sc, sassc->path); @@ -860,6 +854,12 @@ mps_detach_sas(struct mps_softc *sc) sassc->path = NULL; } + /* Make sure CAM doesn't wedge if we had to bail out early. */ + mps_lock(sc); + + while (sassc->startup_refcount != 0) + mpssas_startup_decrement(sassc); + if (sassc->flags & MPSSAS_IN_STARTUP) xpt_release_simq(sassc->sim, 1); @@ -3150,6 +3150,7 @@ mpssas_async(void *callback_arg, uint32_t code, struct cam_path *path, sc = (struct mps_softc *)callback_arg; + mps_lock(sc); switch (code) { case AC_ADVINFO_CHANGED: { struct mpssas_target *target; @@ -3240,6 +3241,7 @@ mpssas_async(void *callback_arg, uint32_t code, struct cam_path *path, default: break; } + mps_unlock(sc); } /* From nobody Thu Oct 14 14:05:31 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 6D853180215A; Thu, 14 Oct 2021 14:05: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 4HVWQ32MjVz3q4s; Thu, 14 Oct 2021 14:05: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 317C8146CE; Thu, 14 Oct 2021 14:05: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 19EE5V0U074695; Thu, 14 Oct 2021 14:05:31 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19EE5VUJ074694; Thu, 14 Oct 2021 14:05:31 GMT (envelope-from git) Date: Thu, 14 Oct 2021 14:05:31 GMT Message-Id: <202110141405.19EE5VUJ074694@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Ed Maste Subject: git: 70db230dcbd9 - stable/13 - ntp.conf.5: Fix typos List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: emaste X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 70db230dcbd958044d4ead05c6cc68f355204e94 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=70db230dcbd958044d4ead05c6cc68f355204e94 commit 70db230dcbd958044d4ead05c6cc68f355204e94 Author: Elyes HAOUAS AuthorDate: 2021-10-06 05:38:06 +0000 Commit: Ed Maste CommitDate: 2021-10-14 14:04:34 +0000 ntp.conf.5: Fix typos "certian" --> "certain" "compatability" --> "compatibility" "noticable" --> "noticeable" "limite" --> "limit" "acutal" --> "actual" "ba" --> "be" MFC after: 1 week Pull Request: https://github.com/freebsd/freebsd-src/pull/550 Signed-off-by: Elyes HAOUAS (cherry picked from commit da3278ded3b2647d26da26788bab8363e502a144) --- usr.sbin/ntp/doc/ntp.conf.5 | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/usr.sbin/ntp/doc/ntp.conf.5 b/usr.sbin/ntp/doc/ntp.conf.5 index 0f3d29341d17..3494a09c2bc7 100644 --- a/usr.sbin/ntp/doc/ntp.conf.5 +++ b/usr.sbin/ntp/doc/ntp.conf.5 @@ -843,7 +843,7 @@ The remaining files are necessary only for the Autokey protocol. .Pp Certificates imported from OpenSSL or public certificate -authorities have certian limitations. +authorities have certain limitations. The certificate should be in ASN.1 syntax, X.509 Version 3 format and encoded in PEM, which is the same format used by OpenSSL. @@ -1627,7 +1627,7 @@ one or more IPs or subnets via the third field of the .Pa ntp.keys file. This restriction is not enabled by default, -to maintain backward compatability. +to maintain backward compatibility. Expect .Cm noepeer to become the default in ntp\-4.4. @@ -2574,7 +2574,7 @@ While this is generally a feature as it allows for quick recovery if a server key has changed, a properly forged and appropriately delivered crypto\-NAK packet can be used in a DoS attack. -If you have active noticable problems with this type of DoS attack +If you have active noticeable problems with this type of DoS attack then you should consider disabling this option. You can check your @@ -2622,7 +2622,7 @@ While this is generally a feature as it allows for quick recovery if a server key has changed, a properly forged and appropriately delivered crypto\-NAK packet can be used in a DoS attack. -If you have active noticable problems with this type of DoS attack +If you have active noticeable problems with this type of DoS attack then you should consider disabling this option. You can check your @@ -2642,7 +2642,7 @@ While this is generally a feature as it allows for quick recovery, if this type of packet is carefully forged and sent during an appropriate window it can be used for a DoS attack. -If you have active noticable problems with this type of DoS attack +If you have active noticeable problems with this type of DoS attack then you should consider disabling this option. You can check your @@ -2848,7 +2848,7 @@ command line option. .Cm incalloc Ar count | Cm incmem Ar kilobytes .Oc .Xc -Controls size limite of the monitoring facility's Most Recently Used +Controls size limit of the monitoring facility's Most Recently Used (MRU) list of client addresses, which is also used by the rate control facility. @@ -2856,7 +2856,7 @@ rate control facility. .It Ic maxdepth Ar count .It Ic maxmem Ar kilobytes Equivalent upper limits on the size of the MRU list, in terms of entries or kilobytes. -The acutal limit will be up to +The actual limit will be up to .Cm incalloc entries or .Cm incmem @@ -2878,7 +2878,7 @@ The default is 600 entries. .It Cm maxage Ar seconds Once the MRU list has .Cm mindepth -entries and an additional client is to ba added to the list, +entries and an additional client is to be added to the list, if the oldest entry was updated more than .Cm maxage seconds ago, that entry is removed and its storage is reused. From nobody Thu Oct 14 14:06:00 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 890AB18026D4; Thu, 14 Oct 2021 14:06:00 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HVWQc3VQsz3qbs; Thu, 14 Oct 2021 14:06:00 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 59997149FD; Thu, 14 Oct 2021 14:06:00 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19EE60ea074859; Thu, 14 Oct 2021 14:06:00 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19EE60gS074858; Thu, 14 Oct 2021 14:06:00 GMT (envelope-from git) Date: Thu, 14 Oct 2021 14:06:00 GMT Message-Id: <202110141406.19EE60gS074858@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Ed Maste Subject: git: cdc3dfd02544 - stable/12 - ntp.conf.5: Fix typos List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: emaste X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: cdc3dfd02544117b3fc13c629cf7a8a70769687b Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=cdc3dfd02544117b3fc13c629cf7a8a70769687b commit cdc3dfd02544117b3fc13c629cf7a8a70769687b Author: Elyes HAOUAS AuthorDate: 2021-10-06 05:38:06 +0000 Commit: Ed Maste CommitDate: 2021-10-14 14:05:32 +0000 ntp.conf.5: Fix typos "certian" --> "certain" "compatability" --> "compatibility" "noticable" --> "noticeable" "limite" --> "limit" "acutal" --> "actual" "ba" --> "be" MFC after: 1 week Pull Request: https://github.com/freebsd/freebsd-src/pull/550 Signed-off-by: Elyes HAOUAS (cherry picked from commit da3278ded3b2647d26da26788bab8363e502a144) --- usr.sbin/ntp/doc/ntp.conf.5 | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/usr.sbin/ntp/doc/ntp.conf.5 b/usr.sbin/ntp/doc/ntp.conf.5 index 0f3d29341d17..3494a09c2bc7 100644 --- a/usr.sbin/ntp/doc/ntp.conf.5 +++ b/usr.sbin/ntp/doc/ntp.conf.5 @@ -843,7 +843,7 @@ The remaining files are necessary only for the Autokey protocol. .Pp Certificates imported from OpenSSL or public certificate -authorities have certian limitations. +authorities have certain limitations. The certificate should be in ASN.1 syntax, X.509 Version 3 format and encoded in PEM, which is the same format used by OpenSSL. @@ -1627,7 +1627,7 @@ one or more IPs or subnets via the third field of the .Pa ntp.keys file. This restriction is not enabled by default, -to maintain backward compatability. +to maintain backward compatibility. Expect .Cm noepeer to become the default in ntp\-4.4. @@ -2574,7 +2574,7 @@ While this is generally a feature as it allows for quick recovery if a server key has changed, a properly forged and appropriately delivered crypto\-NAK packet can be used in a DoS attack. -If you have active noticable problems with this type of DoS attack +If you have active noticeable problems with this type of DoS attack then you should consider disabling this option. You can check your @@ -2622,7 +2622,7 @@ While this is generally a feature as it allows for quick recovery if a server key has changed, a properly forged and appropriately delivered crypto\-NAK packet can be used in a DoS attack. -If you have active noticable problems with this type of DoS attack +If you have active noticeable problems with this type of DoS attack then you should consider disabling this option. You can check your @@ -2642,7 +2642,7 @@ While this is generally a feature as it allows for quick recovery, if this type of packet is carefully forged and sent during an appropriate window it can be used for a DoS attack. -If you have active noticable problems with this type of DoS attack +If you have active noticeable problems with this type of DoS attack then you should consider disabling this option. You can check your @@ -2848,7 +2848,7 @@ command line option. .Cm incalloc Ar count | Cm incmem Ar kilobytes .Oc .Xc -Controls size limite of the monitoring facility's Most Recently Used +Controls size limit of the monitoring facility's Most Recently Used (MRU) list of client addresses, which is also used by the rate control facility. @@ -2856,7 +2856,7 @@ rate control facility. .It Ic maxdepth Ar count .It Ic maxmem Ar kilobytes Equivalent upper limits on the size of the MRU list, in terms of entries or kilobytes. -The acutal limit will be up to +The actual limit will be up to .Cm incalloc entries or .Cm incmem @@ -2878,7 +2878,7 @@ The default is 600 entries. .It Cm maxage Ar seconds Once the MRU list has .Cm mindepth -entries and an additional client is to ba added to the list, +entries and an additional client is to be added to the list, if the oldest entry was updated more than .Cm maxage seconds ago, that entry is removed and its storage is reused. From nobody Thu Oct 14 16:20:15 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id A08AD17F19F0; Thu, 14 Oct 2021 16:20: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 4HVZPW47sPz3FYv; Thu, 14 Oct 2021 16:20: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 6FD8A165B6; Thu, 14 Oct 2021 16:20: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 19EGKFVn053332; Thu, 14 Oct 2021 16:20:15 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19EGKFaR053325; Thu, 14 Oct 2021 16:20:15 GMT (envelope-from git) Date: Thu, 14 Oct 2021 16:20:15 GMT Message-Id: <202110141620.19EGKFaR053325@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Marcin Wojtas Subject: git: 8f2e39b9d3ec - stable/12 - pci_dw: Trim ATU windows bigger than 4GB List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mw X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 8f2e39b9d3ecbd9653f859d9261745059f2b9071 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by mw: URL: https://cgit.FreeBSD.org/src/commit/?id=8f2e39b9d3ecbd9653f859d9261745059f2b9071 commit 8f2e39b9d3ecbd9653f859d9261745059f2b9071 Author: Wojciech Macek AuthorDate: 2021-04-09 07:28:44 +0000 Commit: Marcin Wojtas CommitDate: 2021-10-14 16:09:44 +0000 pci_dw: Trim ATU windows bigger than 4GB The size of the ATU MEM/IO windows is implicitly casted to uint32_t. Because of that some window sizes were silently demoted to 0 and ignored. Check the size if its too large, trim it to 4GB and print a warning message. Submitted by: Kornel Duleba Reviewed by: mw Obtained from: Semihalf Sponsored by: Marvell Differential revision: https://reviews.freebsd.org/D29625 (cherry picked from commit 243000b19f8b4ab104b584b2d16bc6aa9131c9b5) --- sys/dev/pci/pci_dw.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/sys/dev/pci/pci_dw.c b/sys/dev/pci/pci_dw.c index 904e36caff20..973a56239473 100644 --- a/sys/dev/pci/pci_dw.c +++ b/sys/dev/pci/pci_dw.c @@ -350,6 +350,18 @@ pci_dw_decode_ranges(struct pci_dw_softc *sc, struct ofw_pci_range *ranges, " Not all required ranges are found in DT\n"); return (ENXIO); } + if (sc->io_range.size > UINT32_MAX) { + device_printf(sc->dev, + "ATU IO window size is too large. Up to 4GB windows " + "are supported, trimming window size to 4GB\n"); + sc->io_range.size = UINT32_MAX; + } + if (sc->mem_range.size > UINT32_MAX) { + device_printf(sc->dev, + "ATU MEM window size is too large. Up to 4GB windows " + "are supported, trimming window size to 4GB\n"); + sc->mem_range.size = UINT32_MAX; + } return (0); } From nobody Thu Oct 14 16:20:16 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 7276317F1C32; Thu, 14 Oct 2021 16:20: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 4HVZPX6bVGz3FWV; Thu, 14 Oct 2021 16:20:16 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 9AB1C16726; Thu, 14 Oct 2021 16:20: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 19EGKG1n053824; Thu, 14 Oct 2021 16:20:16 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19EGKGQp053822; Thu, 14 Oct 2021 16:20:16 GMT (envelope-from git) Date: Thu, 14 Oct 2021 16:20:16 GMT Message-Id: <202110141620.19EGKGQp053822@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Marcin Wojtas Subject: git: d12f56486571 - stable/12 - pci_dw: fix outbound I/O window configuration List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mw X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: d12f564865718e213e9d41aa493a3b6aa7faca60 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by mw: URL: https://cgit.FreeBSD.org/src/commit/?id=d12f564865718e213e9d41aa493a3b6aa7faca60 commit d12f564865718e213e9d41aa493a3b6aa7faca60 Author: Marcin Wojtas AuthorDate: 2021-04-06 12:31:39 +0000 Commit: Marcin Wojtas CommitDate: 2021-10-14 16:16:33 +0000 pci_dw: fix outbound I/O window configuration Use viewport "2" instead of "0" and change window type from MEM to IO. Without these changes the MEM ATU window can be overwritten with the IO one. Submitted by: Kornel Duleba Obtained from: Semihalf Sponsored by: Marvell Differential revision: https://reviews.freebsd.org/D29516 (cherry picked from commit 57dbb3c25936f0d61fef152eb224ca86a73af0e9) --- sys/dev/pci/pci_dw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/dev/pci/pci_dw.c b/sys/dev/pci/pci_dw.c index 973a56239473..5baa2729493e 100644 --- a/sys/dev/pci/pci_dw.c +++ b/sys/dev/pci/pci_dw.c @@ -236,7 +236,7 @@ pci_dw_setup_hw(struct pci_dw_softc *sc) /* If we have enouht viewports ..*/ if (sc->num_viewport >= 3 && sc->io_range.size != 0) { /* Setup outbound I/O window */ - rv = pci_dw_map_out_atu(sc, 0, IATU_CTRL1_TYPE_MEM, + rv = pci_dw_map_out_atu(sc, 2, IATU_CTRL1_TYPE_IO, sc->io_range.host, sc->io_range.pci, sc->io_range.size); if (rv != 0) return (rv); From nobody Fri Oct 15 13:15:19 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4695A18014E6; Fri, 15 Oct 2021 13:15: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 4HW6Fh1Qrpz4mfr; Fri, 15 Oct 2021 13:15: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 10B9926DD8; Fri, 15 Oct 2021 13:15: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 19FDFJbj033919; Fri, 15 Oct 2021 13:15:19 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19FDFJSR033918; Fri, 15 Oct 2021 13:15:19 GMT (envelope-from git) Date: Fri, 15 Oct 2021 13:15:19 GMT Message-Id: <202110151315.19FDFJSR033918@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mateusz Piotrowski <0mp@FreeBSD.org> Subject: git: a9077f3e0c11 - stable/13 - login.conf.5: Mark passwordtime as implemented List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: 0mp X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: a9077f3e0c11a878bd4a8a729e1e9c3147c135e5 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by 0mp (doc, ports committer): URL: https://cgit.FreeBSD.org/src/commit/?id=a9077f3e0c11a878bd4a8a729e1e9c3147c135e5 commit a9077f3e0c11a878bd4a8a729e1e9c3147c135e5 Author: Felix Johnson AuthorDate: 2021-10-06 20:47:02 +0000 Commit: Mateusz Piotrowski <0mp@FreeBSD.org> CommitDate: 2021-10-15 13:14:53 +0000 login.conf.5: Mark passwordtime as implemented login.conf.5 listed passwordtime in RESERVED CAPABILITIES, which is a section for capabilities not implemented in the base system. However, passwordtime has been implemented in the base for several years now. PR: 246099 Reported by: avg Reviewed by: 0mp MFC after: 3 days (cherry picked from commit e7f8f3b95e1ff76765f1d2f4412b95f6ff5abe25) --- lib/libutil/login.conf.5 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/libutil/login.conf.5 b/lib/libutil/login.conf.5 index aafec9050b5c..7276863f53a9 100644 --- a/lib/libutil/login.conf.5 +++ b/lib/libutil/login.conf.5 @@ -19,7 +19,7 @@ .\" .\" $FreeBSD$ .\" -.Dd May 10, 2020 +.Dd October 6, 2021 .Dt LOGIN.CONF 5 .Os .Sh NAME @@ -287,6 +287,9 @@ NIS clients using a NIS server should probably use "des". .It "passwd_prompt string The password prompt presented by" .Xr login 1 +.It "passwordtime time Used by" +.Xr passwd 1 +to set next password expiry date. .It "times.allow list List of time periods during which" logins are allowed. .It "times.deny list List of time periods during which logins are" @@ -427,9 +430,6 @@ password may be. .Xr passwd 1 will warn the user if an all lower case password is entered. .It "monthtime time Maximum login time per month." -.It "passwordtime time Used by" -.Xr passwd 1 -to set next password expiry date. .It "refreshtime time New time allowed on account refresh." .It "refreshperiod str How often account time is refreshed." .It "sessiontime time Maximum login time per session." From nobody Fri Oct 15 13:16:33 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4CC101801FE9; Fri, 15 Oct 2021 13:16:34 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HW6H61Q89z4n2V; Fri, 15 Oct 2021 13:16:34 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 106FB26FDE; Fri, 15 Oct 2021 13:16:34 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19FDGXcX034144; Fri, 15 Oct 2021 13:16:33 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19FDGXul034143; Fri, 15 Oct 2021 13:16:33 GMT (envelope-from git) Date: Fri, 15 Oct 2021 13:16:33 GMT Message-Id: <202110151316.19FDGXul034143@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mateusz Piotrowski <0mp@FreeBSD.org> Subject: git: 75bb69738e42 - stable/12 - login.conf.5: Mark passwordtime as implemented List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: 0mp X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 75bb69738e427fd34fe2695d71b5381c2cc35066 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by 0mp (doc, ports committer): URL: https://cgit.FreeBSD.org/src/commit/?id=75bb69738e427fd34fe2695d71b5381c2cc35066 commit 75bb69738e427fd34fe2695d71b5381c2cc35066 Author: Felix Johnson AuthorDate: 2021-10-06 20:47:02 +0000 Commit: Mateusz Piotrowski <0mp@FreeBSD.org> CommitDate: 2021-10-15 13:16:00 +0000 login.conf.5: Mark passwordtime as implemented login.conf.5 listed passwordtime in RESERVED CAPABILITIES, which is a section for capabilities not implemented in the base system. However, passwordtime has been implemented in the base for several years now. PR: 246099 Reported by: avg Reviewed by: 0mp MFC after: 3 days (cherry picked from commit e7f8f3b95e1ff76765f1d2f4412b95f6ff5abe25) --- lib/libutil/login.conf.5 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/libutil/login.conf.5 b/lib/libutil/login.conf.5 index aafec9050b5c..7276863f53a9 100644 --- a/lib/libutil/login.conf.5 +++ b/lib/libutil/login.conf.5 @@ -19,7 +19,7 @@ .\" .\" $FreeBSD$ .\" -.Dd May 10, 2020 +.Dd October 6, 2021 .Dt LOGIN.CONF 5 .Os .Sh NAME @@ -287,6 +287,9 @@ NIS clients using a NIS server should probably use "des". .It "passwd_prompt string The password prompt presented by" .Xr login 1 +.It "passwordtime time Used by" +.Xr passwd 1 +to set next password expiry date. .It "times.allow list List of time periods during which" logins are allowed. .It "times.deny list List of time periods during which logins are" @@ -427,9 +430,6 @@ password may be. .Xr passwd 1 will warn the user if an all lower case password is entered. .It "monthtime time Maximum login time per month." -.It "passwordtime time Used by" -.Xr passwd 1 -to set next password expiry date. .It "refreshtime time New time allowed on account refresh." .It "refreshperiod str How often account time is refreshed." .It "sessiontime time Maximum login time per session." From nobody Fri Oct 15 15:26:11 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id D8D031816B71; Fri, 15 Oct 2021 15:26: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 4HW98g4DrVz3PN8; Fri, 15 Oct 2021 15:26: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 70FE69DC; Fri, 15 Oct 2021 15:26: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 19FFQBkN007289; Fri, 15 Oct 2021 15:26:11 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19FFQBd2007288; Fri, 15 Oct 2021 15:26:11 GMT (envelope-from git) Date: Fri, 15 Oct 2021 15:26:11 GMT Message-Id: <202110151526.19FFQBd2007288@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mitchell Horne Subject: git: 5794f8c75ef1 - stable/13 - minidump: De-duplicate is_dumpable() List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mhorne X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 5794f8c75ef15047e22c14fe81c7793d0d2c35e7 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by mhorne: URL: https://cgit.FreeBSD.org/src/commit/?id=5794f8c75ef15047e22c14fe81c7793d0d2c35e7 commit 5794f8c75ef15047e22c14fe81c7793d0d2c35e7 Author: Mitchell Horne AuthorDate: 2021-09-29 17:30:11 +0000 Commit: Mitchell Horne CommitDate: 2021-10-15 15:20:48 +0000 minidump: De-duplicate is_dumpable() The function is identical in each minidump implementation, so move it to vm_phys.c. The only slight exception is powerpc where the function was public, for use in moea64_scan_pmap(). Reviewed by: kib, markj, imp (earlier version) MFC after: 2 weeks Sponsored by: Juniper Networks, Inc. Sponsored by: Klara, Inc. Differential Revision: https://reviews.freebsd.org/D31884 (cherry picked from commit 31991a5a45857e88c29dec422e0b8d6f68f8877b) --- sys/amd64/amd64/minidump_machdep.c | 25 +++++-------------------- sys/amd64/amd64/uma_machdep.c | 1 + sys/arm/arm/minidump_machdep.c | 19 ++----------------- sys/arm64/arm64/minidump_machdep.c | 23 ++++------------------- sys/arm64/arm64/uma_machdep.c | 1 + sys/i386/i386/minidump_machdep_base.c | 21 +++------------------ sys/mips/mips/minidump_machdep.c | 21 +++------------------ sys/mips/mips/uma_machdep.c | 1 + sys/powerpc/aim/mmu_oea64.c | 4 ++-- sys/powerpc/include/md_var.h | 1 - sys/powerpc/powerpc/minidump_machdep.c | 17 +---------------- sys/powerpc/powerpc/uma_machdep.c | 1 + sys/riscv/riscv/minidump_machdep.c | 22 +++------------------- sys/riscv/riscv/uma_machdep.c | 1 + sys/vm/vm_phys.c | 19 +++++++++++++++++++ sys/vm/vm_phys.h | 1 + 16 files changed, 48 insertions(+), 130 deletions(-) diff --git a/sys/amd64/amd64/minidump_machdep.c b/sys/amd64/amd64/minidump_machdep.c index ea8220157083..7c54c423bbaf 100644 --- a/sys/amd64/amd64/minidump_machdep.c +++ b/sys/amd64/amd64/minidump_machdep.c @@ -66,21 +66,6 @@ static int dump_retry_count = 5; SYSCTL_INT(_machdep, OID_AUTO, dump_retry_count, CTLFLAG_RWTUN, &dump_retry_count, 0, "Number of times dump has to retry before bailing out"); -static int -is_dumpable(vm_paddr_t pa) -{ - vm_page_t m; - int i; - - if ((m = vm_phys_paddr_to_vm_page(pa)) != NULL) - return ((m->flags & PG_NODUMP) == 0); - for (i = 0; dump_avail[i] != 0 || dump_avail[i + 1] != 0; i += 2) { - if (pa >= dump_avail[i] && pa < dump_avail[i + 1]) - return (1); - } - return (0); -} - #define PG2MB(pgs) (((pgs) + (1 << 8) - 1) >> 8) static int @@ -256,7 +241,7 @@ minidumpsys(struct dumperinfo *di) va += NBPDP; pa = pdp[i] & PG_PS_FRAME; for (n = 0; n < NPDEPG * NPTEPG; n++) { - if (is_dumpable(pa)) + if (vm_phys_is_dumpable(pa)) dump_add_page(pa); pa += PAGE_SIZE; } @@ -274,7 +259,7 @@ minidumpsys(struct dumperinfo *di) /* This is an entire 2M page. */ pa = pd[j] & PG_PS_FRAME; for (k = 0; k < NPTEPG; k++) { - if (is_dumpable(pa)) + if (vm_phys_is_dumpable(pa)) dump_add_page(pa); pa += PAGE_SIZE; } @@ -283,7 +268,7 @@ minidumpsys(struct dumperinfo *di) pa = pd[j] & PG_FRAME; /* set bit for this PTE page */ - if (is_dumpable(pa)) + if (vm_phys_is_dumpable(pa)) dump_add_page(pa); /* and for each valid page in this 2MB block */ pt = (uint64_t *)PHYS_TO_DMAP(pd[j] & PG_FRAME); @@ -291,7 +276,7 @@ minidumpsys(struct dumperinfo *di) if ((pt[k] & PG_V) == 0) continue; pa = pt[k] & PG_FRAME; - if (is_dumpable(pa)) + if (vm_phys_is_dumpable(pa)) dump_add_page(pa); } } @@ -304,7 +289,7 @@ minidumpsys(struct dumperinfo *di) dumpsize += round_page(BITSET_SIZE(vm_page_dump_pages)); VM_PAGE_DUMP_FOREACH(pa) { /* Clear out undumpable pages now if needed */ - if (is_dumpable(pa)) { + if (vm_phys_is_dumpable(pa)) { dumpsize += PAGE_SIZE; } else { dump_drop_page(pa); diff --git a/sys/amd64/amd64/uma_machdep.c b/sys/amd64/amd64/uma_machdep.c index d080abeefdcc..2fc981f23c83 100644 --- a/sys/amd64/amd64/uma_machdep.c +++ b/sys/amd64/amd64/uma_machdep.c @@ -34,6 +34,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include diff --git a/sys/arm/arm/minidump_machdep.c b/sys/arm/arm/minidump_machdep.c index c5f9cb58302e..f760d774bfbb 100644 --- a/sys/arm/arm/minidump_machdep.c +++ b/sys/arm/arm/minidump_machdep.c @@ -65,21 +65,6 @@ static size_t fragsz; static void *dump_va; static uint64_t counter, progress; -static int -is_dumpable(vm_paddr_t pa) -{ - vm_page_t m; - int i; - - if ((m = vm_phys_paddr_to_vm_page(pa)) != NULL) - return ((m->flags & PG_NODUMP) == 0); - for (i = 0; dump_avail[i] != 0 || dump_avail[i + 1] != 0; i += 2) { - if (pa >= dump_avail[i] && pa < dump_avail[i + 1]) - return (1); - } - return (0); -} - #define PG2MB(pgs) (((pgs) + (1 << 8) - 1) >> 8) static int @@ -202,7 +187,7 @@ minidumpsys(struct dumperinfo *di) ptesize = 0; for (va = KERNBASE; va < kernel_vm_end; va += PAGE_SIZE) { pa = pmap_dump_kextract(va, NULL); - if (pa != 0 && is_dumpable(pa)) + if (pa != 0 && vm_phys_is_dumpable(pa)) dump_add_page(pa); ptesize += sizeof(pt2_entry_t); } @@ -214,7 +199,7 @@ minidumpsys(struct dumperinfo *di) dumpsize += round_page(BITSET_SIZE(vm_page_dump_pages)); VM_PAGE_DUMP_FOREACH(pa) { /* Clear out undumpable pages now if needed */ - if (is_dumpable(pa)) + if (vm_phys_is_dumpable(pa)) dumpsize += PAGE_SIZE; else dump_drop_page(pa); diff --git a/sys/arm64/arm64/minidump_machdep.c b/sys/arm64/arm64/minidump_machdep.c index 1dd40806669b..98d0b50be4c6 100644 --- a/sys/arm64/arm64/minidump_machdep.c +++ b/sys/arm64/arm64/minidump_machdep.c @@ -66,21 +66,6 @@ static size_t counter, progress, dumpsize; static uint64_t tmpbuffer[Ln_ENTRIES]; -static int -is_dumpable(vm_paddr_t pa) -{ - vm_page_t m; - int i; - - if ((m = vm_phys_paddr_to_vm_page(pa)) != NULL) - return ((m->flags & PG_NODUMP) == 0); - for (i = 0; dump_avail[i] != 0 || dump_avail[i + 1] != 0; i += 2) { - if (pa >= dump_avail[i] && pa < dump_avail[i + 1]) - return (1); - } - return (0); -} - static int blk_flush(struct dumperinfo *di) { @@ -226,14 +211,14 @@ minidumpsys(struct dumperinfo *di) pa = *l1 & ~ATTR_MASK; for (i = 0; i < Ln_ENTRIES * Ln_ENTRIES; i++, pa += PAGE_SIZE) - if (is_dumpable(pa)) + if (vm_phys_is_dumpable(pa)) dump_add_page(pa); pmapsize += (Ln_ENTRIES - 1) * PAGE_SIZE; va += L1_SIZE - L2_SIZE; } else if ((*l2 & ATTR_DESCR_MASK) == L2_BLOCK) { pa = *l2 & ~ATTR_MASK; for (i = 0; i < Ln_ENTRIES; i++, pa += PAGE_SIZE) { - if (is_dumpable(pa)) + if (vm_phys_is_dumpable(pa)) dump_add_page(pa); } } else if ((*l2 & ATTR_DESCR_MASK) == L2_TABLE) { @@ -241,7 +226,7 @@ minidumpsys(struct dumperinfo *di) if ((l3[i] & ATTR_DESCR_MASK) != L3_PAGE) continue; pa = l3[i] & ~ATTR_MASK; - if (is_dumpable(pa)) + if (vm_phys_is_dumpable(pa)) dump_add_page(pa); } } @@ -253,7 +238,7 @@ minidumpsys(struct dumperinfo *di) dumpsize += round_page(sizeof(dump_avail)); dumpsize += round_page(BITSET_SIZE(vm_page_dump_pages)); VM_PAGE_DUMP_FOREACH(pa) { - if (is_dumpable(pa)) + if (vm_phys_is_dumpable(pa)) dumpsize += PAGE_SIZE; else dump_drop_page(pa); diff --git a/sys/arm64/arm64/uma_machdep.c b/sys/arm64/arm64/uma_machdep.c index c848edbe32be..3ef3dd3cc9e9 100644 --- a/sys/arm64/arm64/uma_machdep.c +++ b/sys/arm64/arm64/uma_machdep.c @@ -32,6 +32,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include diff --git a/sys/i386/i386/minidump_machdep_base.c b/sys/i386/i386/minidump_machdep_base.c index e2b4234eba11..b8e9e4884552 100644 --- a/sys/i386/i386/minidump_machdep_base.c +++ b/sys/i386/i386/minidump_machdep_base.c @@ -62,21 +62,6 @@ static size_t fragsz; static void *dump_va; static uint64_t counter, progress; -static int -is_dumpable(vm_paddr_t pa) -{ - vm_page_t m; - int i; - - if ((m = vm_phys_paddr_to_vm_page(pa)) != NULL) - return ((m->flags & PG_NODUMP) == 0); - for (i = 0; dump_avail[i] != 0 || dump_avail[i + 1] != 0; i += 2) { - if (pa >= dump_avail[i] && pa < dump_avail[i + 1]) - return (1); - } - return (0); -} - #define PG2MB(pgs) (((pgs) + (1 << 8) - 1) >> 8) static int @@ -203,7 +188,7 @@ minidumpsys(struct dumperinfo *di) /* This is an entire 2M page. */ pa = pd[j] & PG_PS_FRAME; for (k = 0; k < NPTEPG; k++) { - if (is_dumpable(pa)) + if (vm_phys_is_dumpable(pa)) dump_add_page(pa); pa += PAGE_SIZE; } @@ -215,7 +200,7 @@ minidumpsys(struct dumperinfo *di) for (k = 0; k < NPTEPG; k++) { if ((pt[k] & PG_V) == PG_V) { pa = pt[k] & PG_FRAME; - if (is_dumpable(pa)) + if (vm_phys_is_dumpable(pa)) dump_add_page(pa); } } @@ -231,7 +216,7 @@ minidumpsys(struct dumperinfo *di) dumpsize += round_page(BITSET_SIZE(vm_page_dump_pages)); VM_PAGE_DUMP_FOREACH(pa) { /* Clear out undumpable pages now if needed */ - if (is_dumpable(pa)) { + if (vm_phys_is_dumpable(pa)) { dumpsize += PAGE_SIZE; } else { dump_drop_page(pa); diff --git a/sys/mips/mips/minidump_machdep.c b/sys/mips/mips/minidump_machdep.c index e1edfa9ad5d3..d35b1fd53068 100644 --- a/sys/mips/mips/minidump_machdep.c +++ b/sys/mips/mips/minidump_machdep.c @@ -64,21 +64,6 @@ static char tmpbuffer[PAGE_SIZE] __aligned(sizeof(uint64_t)); extern pd_entry_t *kernel_segmap; -static int -is_dumpable(vm_paddr_t pa) -{ - vm_page_t m; - int i; - - if ((m = vm_phys_paddr_to_vm_page(pa)) != NULL) - return ((m->flags & PG_NODUMP) == 0); - for (i = 0; dump_avail[i] != 0 || dump_avail[i + 1] != 0; i += 2) { - if (pa >= dump_avail[i] && pa < dump_avail[i + 1]) - return (1); - } - return (0); -} - static struct { int min_per; int max_per; @@ -189,7 +174,7 @@ minidumpsys(struct dumperinfo *di) for (i = 0; i < NPTEPG; i++) { if (pte_test(&pte[i], PTE_V)) { pa = TLBLO_PTE_TO_PA(pte[i]); - if (is_dumpable(pa)) + if (vm_phys_is_dumpable(pa)) dump_add_page(pa); } } @@ -200,7 +185,7 @@ minidumpsys(struct dumperinfo *di) * and pages allocated by pmap_steal reside */ for (pa = 0; pa < phys_avail[0]; pa += PAGE_SIZE) { - if (is_dumpable(pa)) + if (vm_phys_is_dumpable(pa)) dump_add_page(pa); } @@ -211,7 +196,7 @@ minidumpsys(struct dumperinfo *di) dumpsize += round_page(BITSET_SIZE(vm_page_dump_pages)); VM_PAGE_DUMP_FOREACH(pa) { /* Clear out undumpable pages now if needed */ - if (is_dumpable(pa)) + if (vm_phys_is_dumpable(pa)) dumpsize += PAGE_SIZE; else dump_drop_page(pa); diff --git a/sys/mips/mips/uma_machdep.c b/sys/mips/mips/uma_machdep.c index faf70b20b748..5b57447edd6a 100644 --- a/sys/mips/mips/uma_machdep.c +++ b/sys/mips/mips/uma_machdep.c @@ -35,6 +35,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include diff --git a/sys/powerpc/aim/mmu_oea64.c b/sys/powerpc/aim/mmu_oea64.c index 0e9b15661758..3faa3d0752b8 100644 --- a/sys/powerpc/aim/mmu_oea64.c +++ b/sys/powerpc/aim/mmu_oea64.c @@ -3369,11 +3369,11 @@ moea64_scan_pmap() if (va & PVO_LARGE) { pa_end = pa + lpsize; for (; pa < pa_end; pa += PAGE_SIZE) { - if (is_dumpable(pa)) + if (vm_phys_is_dumpable(pa)) dump_add_page(pa); } } else { - if (is_dumpable(pa)) + if (vm_phys_is_dumpable(pa)) dump_add_page(pa); } } diff --git a/sys/powerpc/include/md_var.h b/sys/powerpc/include/md_var.h index da9232313ffb..ab5f9e33a5bb 100644 --- a/sys/powerpc/include/md_var.h +++ b/sys/powerpc/include/md_var.h @@ -44,7 +44,6 @@ extern int szsigcode64, szsigcode64_elfv2; struct dumperinfo; int minidumpsys(struct dumperinfo *); -int is_dumpable(vm_paddr_t); #endif extern long Maxmem; diff --git a/sys/powerpc/powerpc/minidump_machdep.c b/sys/powerpc/powerpc/minidump_machdep.c index e049f2debcfa..e4d85fe95ed6 100644 --- a/sys/powerpc/powerpc/minidump_machdep.c +++ b/sys/powerpc/powerpc/minidump_machdep.c @@ -91,21 +91,6 @@ static size_t counter, dumpsize, progress; /* Handle chunked writes. */ static size_t fragsz; -int -is_dumpable(vm_paddr_t pa) -{ - vm_page_t m; - int i; - - if ((m = vm_phys_paddr_to_vm_page(pa)) != NULL) - return ((m->flags & PG_NODUMP) == 0); - for (i = 0; dump_avail[i] != 0 || dump_avail[i + 1] != 0; i += 2) { - if (pa >= dump_avail[i] && pa < dump_avail[i + 1]) - return (1); - } - return (0); -} - static void pmap_kenter_temporary(vm_offset_t va, vm_paddr_t pa) { @@ -276,7 +261,7 @@ retry: dumpsize += pmapsize; VM_PAGE_DUMP_FOREACH(pa) { /* Clear out undumpable pages now if needed */ - if (is_dumpable(pa)) + if (vm_phys_is_dumpable(pa)) dumpsize += PAGE_SIZE; else dump_drop_page(pa); diff --git a/sys/powerpc/powerpc/uma_machdep.c b/sys/powerpc/powerpc/uma_machdep.c index 43e2a86456fe..a1769f61d671 100644 --- a/sys/powerpc/powerpc/uma_machdep.c +++ b/sys/powerpc/powerpc/uma_machdep.c @@ -35,6 +35,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include diff --git a/sys/riscv/riscv/minidump_machdep.c b/sys/riscv/riscv/minidump_machdep.c index 2c5e27b6274f..bcedfbdf2fb2 100644 --- a/sys/riscv/riscv/minidump_machdep.c +++ b/sys/riscv/riscv/minidump_machdep.c @@ -99,22 +99,6 @@ report_progress(size_t progress, size_t dumpsize) } } -static bool -is_dumpable(vm_paddr_t pa) -{ - vm_page_t m; - int i; - - if ((m = vm_phys_paddr_to_vm_page(pa)) != NULL) - return ((m->flags & PG_NODUMP) == 0); - - for (i = 0; dump_avail[i] != 0 || dump_avail[i + 1] != 0; i += 2) { - if (pa >= dump_avail[i] && pa < dump_avail[i + 1]) - return (true); - } - return (false); -} - static int blk_flush(struct dumperinfo *di) { @@ -241,7 +225,7 @@ retry: if ((*l2 & PTE_RWX) != 0) { pa = (*l2 >> PTE_PPN1_S) << L2_SHIFT; for (i = 0; i < Ln_ENTRIES; i++, pa += PAGE_SIZE) { - if (is_dumpable(pa)) + if (vm_phys_is_dumpable(pa)) dump_add_page(pa); } } else { @@ -249,7 +233,7 @@ retry: if ((l3[i] & PTE_V) == 0) continue; pa = (l3[i] >> PTE_PPN0_S) * PAGE_SIZE; - if (is_dumpable(pa)) + if (vm_phys_is_dumpable(pa)) dump_add_page(pa); } } @@ -262,7 +246,7 @@ retry: dumpsize += round_page(BITSET_SIZE(vm_page_dump_pages)); VM_PAGE_DUMP_FOREACH(pa) { /* Clear out undumpable pages now if needed */ - if (is_dumpable(pa)) + if (vm_phys_is_dumpable(pa)) dumpsize += PAGE_SIZE; else dump_drop_page(pa); diff --git a/sys/riscv/riscv/uma_machdep.c b/sys/riscv/riscv/uma_machdep.c index 6b563ea8ab0c..f1725fde4699 100644 --- a/sys/riscv/riscv/uma_machdep.c +++ b/sys/riscv/riscv/uma_machdep.c @@ -32,6 +32,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include diff --git a/sys/vm/vm_phys.c b/sys/vm/vm_phys.c index c8f98a0b4695..b0aaa822211f 100644 --- a/sys/vm/vm_phys.c +++ b/sys/vm/vm_phys.c @@ -1593,6 +1593,25 @@ vm_phys_avail_split(vm_paddr_t pa, int i) return (0); } +/* + * Check if a given physical address can be included as part of a crash dump. + */ +bool +vm_phys_is_dumpable(vm_paddr_t pa) +{ + vm_page_t m; + int i; + + if ((m = vm_phys_paddr_to_vm_page(pa)) != NULL) + return ((m->flags & PG_NODUMP) == 0); + + for (i = 0; dump_avail[i] != 0 || dump_avail[i + 1] != 0; i += 2) { + if (pa >= dump_avail[i] && pa < dump_avail[i + 1]) + return (true); + } + return (false); +} + void vm_phys_early_add_seg(vm_paddr_t start, vm_paddr_t end) { diff --git a/sys/vm/vm_phys.h b/sys/vm/vm_phys.h index a650d7dbc380..d10eb96f938f 100644 --- a/sys/vm/vm_phys.h +++ b/sys/vm/vm_phys.h @@ -87,6 +87,7 @@ vm_paddr_t vm_phys_early_alloc(int domain, size_t alloc_size); void vm_phys_early_startup(void); int vm_phys_avail_largest(void); vm_paddr_t vm_phys_avail_size(int i); +bool vm_phys_is_dumpable(vm_paddr_t pa); static inline int vm_phys_domain(vm_paddr_t pa) From nobody Fri Oct 15 15:26:12 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id D7CBC1816DC0; Fri, 15 Oct 2021 15:26:12 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HW98h5F2Kz3PVB; Fri, 15 Oct 2021 15:26:12 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 89E6D9DD; Fri, 15 Oct 2021 15:26:12 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19FFQCjk007316; Fri, 15 Oct 2021 15:26:12 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19FFQCEj007315; Fri, 15 Oct 2021 15:26:12 GMT (envelope-from git) Date: Fri, 15 Oct 2021 15:26:12 GMT Message-Id: <202110151526.19FFQCEj007315@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mitchell Horne Subject: git: fc7febf483a4 - stable/13 - minidump: De-duplicate the progress bar List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mhorne X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: fc7febf483a4910b024b34ab8620e6ac14590c08 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by mhorne: URL: https://cgit.FreeBSD.org/src/commit/?id=fc7febf483a4910b024b34ab8620e6ac14590c08 commit fc7febf483a4910b024b34ab8620e6ac14590c08 Author: Mitchell Horne AuthorDate: 2021-09-29 17:44:27 +0000 Commit: Mitchell Horne CommitDate: 2021-10-15 15:20:48 +0000 minidump: De-duplicate the progress bar The implementation of the progress bar is simple, but duplicated for most minidump implementations. Extract the common bits to kern_dump.c. Ensure that the bar is reset with each subsequent dump; this was only done on some platforms previously. Reviewed by: markj MFC after: 2 weeks Sponsored by: Juniper Networks, Inc. Sponsored by: Klara, Inc. Differential Revision: https://reviews.freebsd.org/D31885 (cherry picked from commit ab4ed843a303ea3e585f8ed3f79873e46d3b3ae3) --- sys/amd64/amd64/minidump_machdep.c | 51 +++---------------------- sys/arm/arm/minidump_machdep.c | 13 +------ sys/arm/include/dump.h | 3 ++ sys/arm64/arm64/minidump_machdep.c | 46 ++--------------------- sys/arm64/include/dump.h | 3 ++ sys/i386/i386/minidump_machdep_base.c | 13 +------ sys/kern/kern_dump.c | 69 ++++++++++++++++++++++++++++++++++ sys/mips/include/dump.h | 3 ++ sys/mips/mips/minidump_machdep.c | 48 ++--------------------- sys/powerpc/include/dump.h | 3 ++ sys/powerpc/powerpc/minidump_machdep.c | 54 +++----------------------- sys/riscv/include/dump.h | 3 ++ sys/riscv/riscv/minidump_machdep.c | 46 ++--------------------- sys/sys/kerneldump.h | 3 ++ sys/x86/include/dump.h | 3 ++ 15 files changed, 113 insertions(+), 248 deletions(-) diff --git a/sys/amd64/amd64/minidump_machdep.c b/sys/amd64/amd64/minidump_machdep.c index 7c54c423bbaf..d6bdbfb7e633 100644 --- a/sys/amd64/amd64/minidump_machdep.c +++ b/sys/amd64/amd64/minidump_machdep.c @@ -60,14 +60,12 @@ static struct kerneldumpheader kdh; /* Handle chunked writes. */ static size_t fragsz; static void *dump_va; -static size_t counter, progress, dumpsize, wdog_next; +static size_t progress, dumpsize, wdog_next; static int dump_retry_count = 5; SYSCTL_INT(_machdep, OID_AUTO, dump_retry_count, CTLFLAG_RWTUN, &dump_retry_count, 0, "Number of times dump has to retry before bailing out"); -#define PG2MB(pgs) (((pgs) + (1 << 8) - 1) >> 8) - static int blk_flush(struct dumperinfo *di) { @@ -81,41 +79,6 @@ blk_flush(struct dumperinfo *di) return (error); } -static struct { - int min_per; - int max_per; - int visited; -} progress_track[10] = { - { 0, 10, 0}, - { 10, 20, 0}, - { 20, 30, 0}, - { 30, 40, 0}, - { 40, 50, 0}, - { 50, 60, 0}, - { 60, 70, 0}, - { 70, 80, 0}, - { 80, 90, 0}, - { 90, 100, 0} -}; - -static void -report_progress(size_t progress, size_t dumpsize) -{ - int sofar, i; - - sofar = 100 - ((progress * 100) / dumpsize); - for (i = 0; i < nitems(progress_track); i++) { - if (sofar < progress_track[i].min_per || - sofar > progress_track[i].max_per) - continue; - if (progress_track[i].visited) - return; - progress_track[i].visited = 1; - printf("..%d%%", sofar); - return; - } -} - /* Pat the watchdog approximately every 128MB of the dump. */ #define WDOG_DUMP_INTERVAL (128 * 1024 * 1024) @@ -152,12 +115,9 @@ blk_write(struct dumperinfo *di, char *ptr, vm_paddr_t pa, size_t sz) len = maxdumpsz - fragsz; if (len > sz) len = sz; - counter += len; progress -= len; - if (counter >> 24) { - report_progress(progress, dumpsize); - counter &= (1<<24) - 1; - } + + dumpsys_pb_progress(len); if (progress <= wdog_next) { wdog_kern_pat(WD_LASTVAL); if (wdog_next > WDOG_DUMP_INTERVAL) @@ -213,9 +173,7 @@ minidumpsys(struct dumperinfo *di) retry_count = 0; retry: retry_count++; - counter = 0; - for (i = 0; i < nitems(progress_track); i++) - progress_track[i].visited = 0; + /* Walk page table pages, set bits in vm_page_dump */ pmapsize = 0; for (va = VM_MIN_KERNEL_ADDRESS; va < MAX(KERNBASE + nkpt * NBPDR, @@ -298,6 +256,7 @@ minidumpsys(struct dumperinfo *di) dumpsize += PAGE_SIZE; wdog_next = progress = dumpsize; + dumpsys_pb_init(dumpsize); /* Initialize mdhdr */ bzero(&mdhdr, sizeof(mdhdr)); diff --git a/sys/arm/arm/minidump_machdep.c b/sys/arm/arm/minidump_machdep.c index f760d774bfbb..83c607c839ee 100644 --- a/sys/arm/arm/minidump_machdep.c +++ b/sys/arm/arm/minidump_machdep.c @@ -63,9 +63,6 @@ static struct kerneldumpheader kdh; /* Handle chunked writes. */ static size_t fragsz; static void *dump_va; -static uint64_t counter, progress; - -#define PG2MB(pgs) (((pgs) + (1 << 8) - 1) >> 8) static int blk_flush(struct dumperinfo *di) @@ -115,13 +112,8 @@ blk_write(struct dumperinfo *di, char *ptr, vm_paddr_t pa, size_t sz) len = maxdumpsz - fragsz; if (len > sz) len = sz; - counter += len; - progress -= len; - if (counter >> 22) { - printf(" %lld", PG2MB(progress >> PAGE_SHIFT)); - counter &= (1<<22) - 1; - } + dumpsys_pb_progress(len); #ifdef SW_WATCHDOG wdog_kern_pat(WD_LASTVAL); #endif @@ -182,7 +174,6 @@ minidumpsys(struct dumperinfo *di) */ dcache_wbinv_poc_all(); - counter = 0; /* Walk page table pages, set bits in vm_page_dump */ ptesize = 0; for (va = KERNBASE; va < kernel_vm_end; va += PAGE_SIZE) { @@ -206,7 +197,7 @@ minidumpsys(struct dumperinfo *di) } dumpsize += PAGE_SIZE; - progress = dumpsize; + dumpsys_pb_init(dumpsize); /* Initialize mdhdr */ bzero(&mdhdr, sizeof(mdhdr)); diff --git a/sys/arm/include/dump.h b/sys/arm/include/dump.h index 3a7432fd49d3..97db0a819701 100644 --- a/sys/arm/include/dump.h +++ b/sys/arm/include/dump.h @@ -36,6 +36,9 @@ #define DUMPSYS_MD_PA_NPAIRS 20 #define DUMPSYS_NUM_AUX_HDRS 1 +/* How often to check the dump progress bar? */ +#define DUMPSYS_PB_CHECK_BITS 22 /* Every 4MB */ + void dumpsys_wbinv_all(void); int dumpsys_write_aux_headers(struct dumperinfo *di); diff --git a/sys/arm64/arm64/minidump_machdep.c b/sys/arm64/arm64/minidump_machdep.c index 98d0b50be4c6..92b172260ae0 100644 --- a/sys/arm64/arm64/minidump_machdep.c +++ b/sys/arm64/arm64/minidump_machdep.c @@ -62,7 +62,7 @@ static struct kerneldumpheader kdh; /* Handle chunked writes. */ static size_t fragsz; static void *dump_va; -static size_t counter, progress, dumpsize; +static size_t dumpsize; static uint64_t tmpbuffer[Ln_ENTRIES]; @@ -79,41 +79,6 @@ blk_flush(struct dumperinfo *di) return (error); } -static struct { - int min_per; - int max_per; - int visited; -} progress_track[10] = { - { 0, 10, 0}, - { 10, 20, 0}, - { 20, 30, 0}, - { 30, 40, 0}, - { 40, 50, 0}, - { 50, 60, 0}, - { 60, 70, 0}, - { 70, 80, 0}, - { 80, 90, 0}, - { 90, 100, 0} -}; - -static void -report_progress(size_t progress, size_t dumpsize) -{ - int sofar, i; - - sofar = 100 - ((progress * 100) / dumpsize); - for (i = 0; i < nitems(progress_track); i++) { - if (sofar < progress_track[i].min_per || - sofar > progress_track[i].max_per) - continue; - if (progress_track[i].visited) - return; - progress_track[i].visited = 1; - printf("..%d%%", sofar); - return; - } -} - static int blk_write(struct dumperinfo *di, char *ptr, vm_paddr_t pa, size_t sz) { @@ -150,13 +115,8 @@ blk_write(struct dumperinfo *di, char *ptr, vm_paddr_t pa, size_t sz) len = maxdumpsz - fragsz; if (len > sz) len = sz; - counter += len; - progress -= len; - if (counter >> 22) { - report_progress(progress, dumpsize); - counter &= (1 << 22) - 1; - } + dumpsys_pb_progress(len); wdog_kern_pat(WD_LASTVAL); if (ptr) { @@ -245,7 +205,7 @@ minidumpsys(struct dumperinfo *di) } dumpsize += PAGE_SIZE; - progress = dumpsize; + dumpsys_pb_init(dumpsize); /* Initialize mdhdr */ bzero(&mdhdr, sizeof(mdhdr)); diff --git a/sys/arm64/include/dump.h b/sys/arm64/include/dump.h index 6f2537550c42..600cc5415970 100644 --- a/sys/arm64/include/dump.h +++ b/sys/arm64/include/dump.h @@ -40,6 +40,9 @@ #define DUMPSYS_MD_PA_NPAIRS 20 #define DUMPSYS_NUM_AUX_HDRS 1 +/* How often to check the dump progress bar? */ +#define DUMPSYS_PB_CHECK_BITS 22 /* Every 4MB */ + void dumpsys_wbinv_all(void); int dumpsys_write_aux_headers(struct dumperinfo *di); diff --git a/sys/i386/i386/minidump_machdep_base.c b/sys/i386/i386/minidump_machdep_base.c index b8e9e4884552..e3e211bf9a46 100644 --- a/sys/i386/i386/minidump_machdep_base.c +++ b/sys/i386/i386/minidump_machdep_base.c @@ -60,9 +60,6 @@ static struct kerneldumpheader kdh; /* Handle chunked writes. */ static size_t fragsz; static void *dump_va; -static uint64_t counter, progress; - -#define PG2MB(pgs) (((pgs) + (1 << 8) - 1) >> 8) static int blk_flush(struct dumperinfo *di) @@ -110,13 +107,8 @@ blk_write(struct dumperinfo *di, char *ptr, vm_paddr_t pa, size_t sz) len = maxdumpsz - fragsz; if (len > sz) len = sz; - counter += len; - progress -= len; - if (counter >> 24) { - printf(" %lld", PG2MB(progress >> PAGE_SHIFT)); - counter &= (1<<24) - 1; - } + dumpsys_pb_progress(len); wdog_kern_pat(WD_LASTVAL); if (ptr) { @@ -173,7 +165,6 @@ minidumpsys(struct dumperinfo *di) int j, k; struct minidumphdr mdhdr; - counter = 0; /* Walk page table pages, set bits in vm_page_dump */ ptesize = 0; for (va = KERNBASE; va < kernel_vm_end; va += NBPDR) { @@ -224,7 +215,7 @@ minidumpsys(struct dumperinfo *di) } dumpsize += PAGE_SIZE; - progress = dumpsize; + dumpsys_pb_init(dumpsize); /* Initialize mdhdr */ bzero(&mdhdr, sizeof(mdhdr)); diff --git a/sys/kern/kern_dump.c b/sys/kern/kern_dump.c index 7ba6847e405d..4c592f446f45 100644 --- a/sys/kern/kern_dump.c +++ b/sys/kern/kern_dump.c @@ -385,3 +385,72 @@ dumpsys_generic(struct dumperinfo *di) printf("\n** DUMP FAILED (ERROR %d) **\n", error); return (error); } + +/* Minidump progress bar */ +static struct { + const int min_per; + const int max_per; + bool visited; +} progress_track[10] = { + { 0, 10, false}, + { 10, 20, false}, + { 20, 30, false}, + { 30, 40, false}, + { 40, 50, false}, + { 50, 60, false}, + { 60, 70, false}, + { 70, 80, false}, + { 80, 90, false}, + { 90, 100, false} +}; + +static uint64_t dumpsys_pb_size; +static uint64_t dumpsys_pb_remaining; +static uint64_t dumpsys_pb_check; + +/* Reset the progress bar for a dump of dumpsize. */ +void +dumpsys_pb_init(uint64_t dumpsize) +{ + int i; + + dumpsys_pb_size = dumpsys_pb_remaining = dumpsize; + dumpsys_pb_check = 0; + + for (i = 0; i < nitems(progress_track); i++) + progress_track[i].visited = false; +} + +/* + * Update the progress according to the delta bytes that were written out. + * Check and print the progress percentage. + */ +void +dumpsys_pb_progress(size_t delta) +{ + int sofar, i; + + dumpsys_pb_remaining -= delta; + dumpsys_pb_check += delta; + + /* + * To save time while dumping, only loop through progress_track + * occasionally. + */ + if ((dumpsys_pb_check >> DUMPSYS_PB_CHECK_BITS) == 0) + return; + else + dumpsys_pb_check &= (1 << DUMPSYS_PB_CHECK_BITS) - 1; + + sofar = 100 - ((dumpsys_pb_remaining * 100) / dumpsys_pb_size); + for (i = 0; i < nitems(progress_track); i++) { + if (sofar < progress_track[i].min_per || + sofar > progress_track[i].max_per) + continue; + if (!progress_track[i].visited) { + progress_track[i].visited = true; + printf("..%d%%", sofar); + } + break; + } +} diff --git a/sys/mips/include/dump.h b/sys/mips/include/dump.h index 2224b6eea4b9..4e434861dfcc 100644 --- a/sys/mips/include/dump.h +++ b/sys/mips/include/dump.h @@ -36,6 +36,9 @@ #define DUMPSYS_MD_PA_NPAIRS 20 #define DUMPSYS_NUM_AUX_HDRS 0 +/* How often to check the dump progress bar? */ +#define DUMPSYS_PB_CHECK_BITS 22 /* Every 4MB */ + void dumpsys_wbinv_all(void); static inline void diff --git a/sys/mips/mips/minidump_machdep.c b/sys/mips/mips/minidump_machdep.c index d35b1fd53068..691e1208e684 100644 --- a/sys/mips/mips/minidump_machdep.c +++ b/sys/mips/mips/minidump_machdep.c @@ -58,47 +58,12 @@ CTASSERT(sizeof(struct kerneldumpheader) == 512); static struct kerneldumpheader kdh; /* Handle chunked writes. */ -static uint64_t counter, progress, dumpsize; +static uint64_t dumpsize; /* Just auxiliary bufffer */ static char tmpbuffer[PAGE_SIZE] __aligned(sizeof(uint64_t)); extern pd_entry_t *kernel_segmap; -static struct { - int min_per; - int max_per; - int visited; -} progress_track[10] = { - { 0, 10, 0}, - { 10, 20, 0}, - { 20, 30, 0}, - { 30, 40, 0}, - { 40, 50, 0}, - { 50, 60, 0}, - { 60, 70, 0}, - { 70, 80, 0}, - { 80, 90, 0}, - { 90, 100, 0} -}; - -static void -report_progress(uint64_t progress, uint64_t dumpsize) -{ - int sofar, i; - - sofar = 100 - ((progress * 100) / dumpsize); - for (i = 0; i < nitems(progress_track); i++) { - if (sofar < progress_track[i].min_per || - sofar > progress_track[i].max_per) - continue; - if (progress_track[i].visited) - return; - progress_track[i].visited = 1; - printf("..%d%%", sofar); - return; - } -} - static int write_buffer(struct dumperinfo *di, char *ptr, size_t sz) { @@ -115,14 +80,8 @@ write_buffer(struct dumperinfo *di, char *ptr, size_t sz) while (sz) { len = min(maxdumpsz, sz); - counter += len; - progress -= len; - - if (counter >> 22) { - report_progress(progress, dumpsize); - counter &= (1<<22) - 1; - } + dumpsys_pb_progress(len); wdog_kern_pat(WD_LASTVAL); if (ptr) { @@ -163,7 +122,6 @@ minidumpsys(struct dumperinfo *di) /* Flush cache */ mips_dcache_wbinv_all(); - counter = 0; /* Walk page table pages, set bits in vm_page_dump */ ptesize = 0; @@ -203,7 +161,7 @@ minidumpsys(struct dumperinfo *di) } dumpsize += PAGE_SIZE; - progress = dumpsize; + dumpsys_pb_init(dumpsize); /* Initialize mdhdr */ bzero(&mdhdr, sizeof(mdhdr)); diff --git a/sys/powerpc/include/dump.h b/sys/powerpc/include/dump.h index f6ccb003c89b..3debbfbe25f9 100644 --- a/sys/powerpc/include/dump.h +++ b/sys/powerpc/include/dump.h @@ -35,6 +35,9 @@ #define DUMPSYS_MD_PA_NPAIRS (PHYS_AVAIL_SZ + 1) #define DUMPSYS_NUM_AUX_HDRS 0 +/* How often to check the dump progress bar? */ +#define DUMPSYS_PB_CHECK_BITS 20 /* Every 1MB */ + void dumpsys_pa_init(void); void dumpsys_unmap_chunk(vm_paddr_t, size_t, void *); size_t dumpsys_scan_pmap(void); diff --git a/sys/powerpc/powerpc/minidump_machdep.c b/sys/powerpc/powerpc/minidump_machdep.c index e4d85fe95ed6..908e6f7a3fc7 100644 --- a/sys/powerpc/powerpc/minidump_machdep.c +++ b/sys/powerpc/powerpc/minidump_machdep.c @@ -69,24 +69,7 @@ SYSCTL_INT(_machdep, OID_AUTO, dump_retry_count, CTLFLAG_RWTUN, static struct kerneldumpheader kdh; static char pgbuf[PAGE_SIZE]; -static struct { - int min_per; - int max_per; - int visited; -} progress_track[10] = { - { 0, 10, 0}, - { 10, 20, 0}, - { 20, 30, 0}, - { 30, 40, 0}, - { 40, 50, 0}, - { 50, 60, 0}, - { 60, 70, 0}, - { 70, 80, 0}, - { 80, 90, 0}, - { 90, 100, 0} -}; - -static size_t counter, dumpsize, progress; +static size_t dumpsize; /* Handle chunked writes. */ static size_t fragsz; @@ -98,24 +81,6 @@ pmap_kenter_temporary(vm_offset_t va, vm_paddr_t pa) pmap_kenter(va, pa); } -static void -report_progress(void) -{ - int sofar, i; - - sofar = 100 - ((progress * 100) / dumpsize); - for (i = 0; i < nitems(progress_track); i++) { - if (sofar < progress_track[i].min_per || - sofar > progress_track[i].max_per) - continue; - if (progress_track[i].visited) - return; - progress_track[i].visited = 1; - printf("..%d%%", sofar); - return; - } -} - static int blk_flush(struct dumperinfo *di) { @@ -165,12 +130,8 @@ blk_write(struct dumperinfo *di, char *ptr, vm_paddr_t pa, size_t sz) len = maxdumpsz - fragsz; if (len > sz) len = sz; - counter += len; - progress -= len; - if (counter >> 20) { - report_progress(); - counter &= (1<<20) - 1; - } + + dumpsys_pb_progress(len); if (ptr) { error = dump_append(di, ptr, 0, len); @@ -231,7 +192,7 @@ int minidumpsys(struct dumperinfo *di) { vm_paddr_t pa; - int error, i, retry_count; + int error, retry_count; uint32_t pmapsize; struct minidumphdr mdhdr; @@ -241,11 +202,6 @@ retry: fragsz = 0; DBG(total = dumptotal = 0;) - /* Reset progress */ - counter = 0; - for (i = 0; i < nitems(progress_track); i++) - progress_track[i].visited = 0; - /* Build set of dumpable pages from kernel pmap */ pmapsize = dumpsys_scan_pmap(); if (pmapsize % PAGE_SIZE != 0) { @@ -266,7 +222,7 @@ retry: else dump_drop_page(pa); } - progress = dumpsize; + dumpsys_pb_init(dumpsize); /* Initialize mdhdr */ bzero(&mdhdr, sizeof(mdhdr)); diff --git a/sys/riscv/include/dump.h b/sys/riscv/include/dump.h index 182a89eb8f98..3c3152f150e9 100644 --- a/sys/riscv/include/dump.h +++ b/sys/riscv/include/dump.h @@ -37,6 +37,9 @@ #define DUMPSYS_MD_PA_NPAIRS 10 #define DUMPSYS_NUM_AUX_HDRS 0 +/* How often to check the dump progress bar? */ +#define DUMPSYS_PB_CHECK_BITS 22 /* Every 4MB */ + static inline void dumpsys_pa_init(void) { diff --git a/sys/riscv/riscv/minidump_machdep.c b/sys/riscv/riscv/minidump_machdep.c index bcedfbdf2fb2..992ab097e1b3 100644 --- a/sys/riscv/riscv/minidump_machdep.c +++ b/sys/riscv/riscv/minidump_machdep.c @@ -60,45 +60,10 @@ static struct kerneldumpheader kdh; /* Handle chunked writes. */ static size_t fragsz; static void *dump_va; -static size_t counter, progress, dumpsize; +static size_t dumpsize; static uint64_t tmpbuffer[PAGE_SIZE / sizeof(uint64_t)]; -static struct { - int min_per; - int max_per; - int visited; -} progress_track[10] = { - { 0, 10, 0}, - { 10, 20, 0}, - { 20, 30, 0}, - { 30, 40, 0}, - { 40, 50, 0}, - { 50, 60, 0}, - { 60, 70, 0}, - { 70, 80, 0}, - { 80, 90, 0}, - { 90, 100, 0} -}; - -static void -report_progress(size_t progress, size_t dumpsize) -{ - int sofar, i; - - sofar = 100 - ((progress * 100) / dumpsize); - for (i = 0; i < nitems(progress_track); i++) { - if (sofar < progress_track[i].min_per || - sofar > progress_track[i].max_per) - continue; - if (progress_track[i].visited) - return; - progress_track[i].visited = 1; - printf("..%d%%", sofar); - return; - } -} - static int blk_flush(struct dumperinfo *di) { @@ -156,13 +121,8 @@ blk_write(struct dumperinfo *di, char *ptr, vm_paddr_t pa, size_t sz) len = maxdumpsz - fragsz; if (len > sz) len = sz; - counter += len; - progress -= len; - if (counter >> 22) { - report_progress(progress, dumpsize); - counter &= (1 << 22) - 1; - } + dumpsys_pb_progress(len); wdog_kern_pat(WD_LASTVAL); if (ptr) { @@ -253,7 +213,7 @@ retry: } dumpsize += PAGE_SIZE; - progress = dumpsize; + dumpsys_pb_init(dumpsize); /* Initialize mdhdr */ bzero(&mdhdr, sizeof(mdhdr)); diff --git a/sys/sys/kerneldump.h b/sys/sys/kerneldump.h index 8ce6a7a47127..c4ce9d2f13ec 100644 --- a/sys/sys/kerneldump.h +++ b/sys/sys/kerneldump.h @@ -151,6 +151,9 @@ void dumpsys_gen_wbinv_all(void); void dumpsys_gen_unmap_chunk(vm_paddr_t, size_t, void *); int dumpsys_gen_write_aux_headers(struct dumperinfo *); +void dumpsys_pb_init(uint64_t); +void dumpsys_pb_progress(size_t); + extern int do_minidump; #endif diff --git a/sys/x86/include/dump.h b/sys/x86/include/dump.h index 91c72acb4e5b..b8da0d50a6a4 100644 --- a/sys/x86/include/dump.h +++ b/sys/x86/include/dump.h @@ -42,6 +42,9 @@ #define DUMPSYS_MD_PA_NPAIRS 10 #define DUMPSYS_NUM_AUX_HDRS 0 +/* How often to check the dump progress bar? */ +#define DUMPSYS_PB_CHECK_BITS 24 /* Every 16MB */ + static inline void dumpsys_pa_init(void) { From nobody Fri Oct 15 15:26:13 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 6192C1816E2E; Fri, 15 Oct 2021 15:26:14 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HW98k0Rqtz3PbJ; Fri, 15 Oct 2021 15:26:14 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id BEC3CD81; Fri, 15 Oct 2021 15:26:13 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19FFQDEJ007340; Fri, 15 Oct 2021 15:26:13 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19FFQD3Z007339; Fri, 15 Oct 2021 15:26:13 GMT (envelope-from git) Date: Fri, 15 Oct 2021 15:26:13 GMT Message-Id: <202110151526.19FFQD3Z007339@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mitchell Horne Subject: git: 89f1b82a859f - stable/13 - libpmc: fix the 'cycles' event alias on x86 List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mhorne X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 89f1b82a859fe4b9d4a59e9089a634ec24f127dd Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by mhorne: URL: https://cgit.FreeBSD.org/src/commit/?id=89f1b82a859fe4b9d4a59e9089a634ec24f127dd commit 89f1b82a859fe4b9d4a59e9089a634ec24f127dd Author: Mitchell Horne AuthorDate: 2021-09-30 14:11:36 +0000 Commit: Mitchell Horne CommitDate: 2021-10-15 15:21:35 +0000 libpmc: fix the 'cycles' event alias on x86 Looking for "tsc-tsc" in the pmu tables will fail every time. Instead, make this an alias for the static TSC event defined in pmc_events.h. This fixes 'pmcstat -s cycles' on Intel and AMD. Reviewed by: emaste MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D32197 (cherry picked from commit 937539e0a32ce1da46223664ca1cf3b252e02ece) --- lib/libpmc/libpmc.c | 2 +- lib/libpmc/libpmc_pmu_util.c | 1 - sys/dev/hwpmc/pmc_events.h | 3 +++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/libpmc/libpmc.c b/lib/libpmc/libpmc.c index e2422f167267..78fde0ed1f2c 100644 --- a/lib/libpmc/libpmc.c +++ b/lib/libpmc/libpmc.c @@ -179,7 +179,7 @@ static const struct pmc_event_descr cortex_a76_event_table[] = static const struct pmc_event_descr tsc_event_table[] = { - __PMC_EV_TSC() + __PMC_EV_ALIAS_TSC() }; #undef PMC_CLASS_TABLE_DESC diff --git a/lib/libpmc/libpmc_pmu_util.c b/lib/libpmc/libpmc_pmu_util.c index e6f74e6abe81..b72f45e85a72 100644 --- a/lib/libpmc/libpmc_pmu_util.c +++ b/lib/libpmc/libpmc_pmu_util.c @@ -74,7 +74,6 @@ static struct pmu_alias pmu_intel_alias_table[] = { {"BRANCH-INSTRUCTION-RETIRED", "BR_INST_RETIRED.ALL_BRANCHES"}, {"BRANCH_MISSES_RETIRED", "BR_MISP_RETIRED.ALL_BRANCHES"}, {"BRANCH-MISSES-RETIRED", "BR_MISP_RETIRED.ALL_BRANCHES"}, - {"cycles", "tsc-tsc"}, {"unhalted-cycles", "CPU_CLK_UNHALTED.THREAD_P_ANY"}, {"instructions", "inst_retired.any_p"}, {"branch-mispredicts", "br_misp_retired.all_branches"}, diff --git a/sys/dev/hwpmc/pmc_events.h b/sys/dev/hwpmc/pmc_events.h index df56d728907a..6a727c6e7f25 100644 --- a/sys/dev/hwpmc/pmc_events.h +++ b/sys/dev/hwpmc/pmc_events.h @@ -54,6 +54,9 @@ #define PMC_EV_TSC_FIRST PMC_EV_TSC_TSC #define PMC_EV_TSC_LAST PMC_EV_TSC_TSC +#define __PMC_EV_ALIAS_TSC() \ +__PMC_EV_ALIAS("cycles", TSC_TSC) + /* * Software events are dynamically defined. */ From nobody Fri Oct 15 15:26:15 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 7DAE51816BFC; Fri, 15 Oct 2021 15:26:16 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HW98m1qVVz3PKf; Fri, 15 Oct 2021 15:26:16 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id ED066D0F; Fri, 15 Oct 2021 15:26: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 19FFQFcA007388; Fri, 15 Oct 2021 15:26:15 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19FFQFmH007387; Fri, 15 Oct 2021 15:26:15 GMT (envelope-from git) Date: Fri, 15 Oct 2021 15:26:15 GMT Message-Id: <202110151526.19FFQFmH007387@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mitchell Horne Subject: git: 43f5da70cc96 - stable/13 - riscv: handle page faults in the unmappable region List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mhorne X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 43f5da70cc96161c6f738b4e3a91fbdc44679760 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by mhorne: URL: https://cgit.FreeBSD.org/src/commit/?id=43f5da70cc96161c6f738b4e3a91fbdc44679760 commit 43f5da70cc96161c6f738b4e3a91fbdc44679760 Author: Mitchell Horne AuthorDate: 2021-10-07 21:05:38 +0000 Commit: Mitchell Horne CommitDate: 2021-10-15 15:22:13 +0000 riscv: handle page faults in the unmappable region When handling a kernel page fault, check explicitly that stval resides in either the user or kernel address spaces, and make the page fault fatal if not. Otherwise, a properly crafted address may appear to pmap_fault() as a valid and present page in the kernel map, causing the page fault to be retried continuously. This is mainly due to the fact that the upper bits of virtual addresses are not validated by most of the pmap code. Faults of this nature should only occur due to some kind of bug in the kernel, but it is best to handle them gracefully when they do. Handle user page faults in the same way, sending a SIGSEGV immediately when a malformed address is encountered. Add an assertion to pmap_l1(), which should help catch other bugs of this kind that make it this far. Reviewed by: jrtc27, markj MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D31208 (cherry picked from commit 4a9f2f8b07c2d1a1c12f4aabdccd36f56b20cfda) --- sys/riscv/include/vmparam.h | 4 ++++ sys/riscv/riscv/pmap.c | 2 ++ sys/riscv/riscv/trap.c | 8 ++++++++ 3 files changed, 14 insertions(+) diff --git a/sys/riscv/include/vmparam.h b/sys/riscv/include/vmparam.h index 94782da779f7..4ed95def2caa 100644 --- a/sys/riscv/include/vmparam.h +++ b/sys/riscv/include/vmparam.h @@ -186,6 +186,10 @@ #define VM_MINUSER_ADDRESS (VM_MIN_USER_ADDRESS) #define VM_MAXUSER_ADDRESS (VM_MAX_USER_ADDRESS) +/* Check if an address resides in a mappable region. */ +#define VIRT_IS_VALID(va) \ + (((va) < VM_MAX_USER_ADDRESS) || ((va) >= VM_MIN_KERNEL_ADDRESS)) + #define KERNBASE (VM_MIN_KERNEL_ADDRESS) #define SHAREDPAGE (VM_MAXUSER_ADDRESS - PAGE_SIZE) #define USRSTACK SHAREDPAGE diff --git a/sys/riscv/riscv/pmap.c b/sys/riscv/riscv/pmap.c index c596ce15bde5..eab61032fbcb 100644 --- a/sys/riscv/riscv/pmap.c +++ b/sys/riscv/riscv/pmap.c @@ -351,6 +351,8 @@ static __inline pd_entry_t * pmap_l1(pmap_t pmap, vm_offset_t va) { + KASSERT(VIRT_IS_VALID(va), + ("%s: malformed virtual address %#lx", __func__, va)); return (&pmap->pm_l1[pmap_l1_index(va)]); } diff --git a/sys/riscv/riscv/trap.c b/sys/riscv/riscv/trap.c index 69b43f598efd..abf527b2ef13 100644 --- a/sys/riscv/riscv/trap.c +++ b/sys/riscv/riscv/trap.c @@ -199,6 +199,11 @@ page_fault_handler(struct trapframe *frame, int usermode) goto fatal; if (usermode) { + if (!VIRT_IS_VALID(stval)) { + call_trapsignal(td, SIGSEGV, SEGV_MAPERR, (void *)stval, + frame->tf_scause & SCAUSE_CODE); + goto done; + } map = &td->td_proc->p_vmspace->vm_map; } else { /* @@ -207,6 +212,9 @@ page_fault_handler(struct trapframe *frame, int usermode) */ intr_enable(); + if (!VIRT_IS_VALID(stval)) + goto fatal; + if (stval >= VM_MAX_USER_ADDRESS) { map = kernel_map; } else { From nobody Fri Oct 15 15:26:14 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 474B81816ED6; Fri, 15 Oct 2021 15:26:17 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HW98l3ZPBz3PNQ; Fri, 15 Oct 2021 15:26:15 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id CEEF6CFB; Fri, 15 Oct 2021 15:26:14 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19FFQE8B007364; Fri, 15 Oct 2021 15:26:14 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19FFQEPn007363; Fri, 15 Oct 2021 15:26:14 GMT (envelope-from git) Date: Fri, 15 Oct 2021 15:26:14 GMT Message-Id: <202110151526.19FFQEPn007363@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mitchell Horne Subject: git: 3c01f7415067 - stable/13 - libpmc: add some AMD pmu counter aliases List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mhorne X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 3c01f7415067d8a4da0737eb74c2709f0d5afed8 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by mhorne: URL: https://cgit.FreeBSD.org/src/commit/?id=3c01f7415067d8a4da0737eb74c2709f0d5afed8 commit 3c01f7415067d8a4da0737eb74c2709f0d5afed8 Author: Mitchell Horne AuthorDate: 2021-09-30 14:13:37 +0000 Commit: Mitchell Horne CommitDate: 2021-10-15 15:21:36 +0000 libpmc: add some AMD pmu counter aliases Make it mostly compatible with what's defined for Intel. Except where noted, these are defined for all of amdzen(1|2|3). Reviewed by: emaste MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D32162 (cherry picked from commit a20c10893eb17e281f119d1b9b39c175dbf4d7bd) --- lib/libpmc/libpmc_pmu_util.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lib/libpmc/libpmc_pmu_util.c b/lib/libpmc/libpmc_pmu_util.c index b72f45e85a72..363f93c591f8 100644 --- a/lib/libpmc/libpmc_pmu_util.c +++ b/lib/libpmc/libpmc_pmu_util.c @@ -86,6 +86,19 @@ static struct pmu_alias pmu_intel_alias_table[] = { static struct pmu_alias pmu_amd_alias_table[] = { {"UNHALTED_CORE_CYCLES", "ls_not_halted_cyc"}, {"UNHALTED-CORE-CYCLES", "ls_not_halted_cyc"}, + {"LLC_MISSES", "l3_comb_clstr_state.request_miss"}, + {"LLC-MISSES", "l3_comb_clstr_state.request_miss"}, + {"LLC_REFERENCE", "l3_request_g1.caching_l3_cache_accesses"}, + {"LLC-REFERENCE", "l3_request_g1.caching_l3_cache_accesses"}, + {"BRANCH_INSTRUCTION_RETIRED", "ex_ret_brn"}, + {"BRANCH-INSTRUCTION-RETIRED", "ex_ret_brn"}, + {"BRANCH_MISSES_RETIRED", "ex_ret_brn_misp"}, + {"BRANCH-MISSES-RETIRED", "ex_ret_brn_misp"}, + {"unhalted-cycles", "ls_not_halted_cyc"}, + {"instructions", "ex_ret_instr",}, + {"branch-mispredicts", "ex_ret_brn_misp"}, + {"branches", "ex_ret_brn"}, + {"interrupts", "ls_int_taken"}, /* Not on amdzen1 */ {NULL, NULL}, }; From nobody Fri Oct 15 15:26:16 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id BCD6E181708B; Fri, 15 Oct 2021 15:26: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 4HW98n21qPz3PbW; Fri, 15 Oct 2021 15:26:17 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 1DCC3D82; Fri, 15 Oct 2021 15:26:17 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19FFQHq4007412; Fri, 15 Oct 2021 15:26:17 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19FFQGiP007411; Fri, 15 Oct 2021 15:26:16 GMT (envelope-from git) Date: Fri, 15 Oct 2021 15:26:16 GMT Message-Id: <202110151526.19FFQGiP007411@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mitchell Horne Subject: git: d925085dcdbd - stable/13 - riscv: fix VM_MAXUSER_ADDRESS checks in asm routines List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mhorne X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: d925085dcdbd9dd3953dc1a1c726df8d359705b2 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by mhorne: URL: https://cgit.FreeBSD.org/src/commit/?id=d925085dcdbd9dd3953dc1a1c726df8d359705b2 commit d925085dcdbd9dd3953dc1a1c726df8d359705b2 Author: Mitchell Horne AuthorDate: 2021-10-07 21:12:30 +0000 Commit: Mitchell Horne CommitDate: 2021-10-15 15:22:13 +0000 riscv: fix VM_MAXUSER_ADDRESS checks in asm routines There are two issues with the checks against VM_MAXUSER_ADDRESS. First, the comparison should consider the values as unsigned, otherwise addresses with the high bit set will fail to branch. Second, the value of VM_MAXUSER_ADDRESS is, by convention, one larger than the maximum mappable user address and invalid itself. Thus, use the bgeu instruction for these comparisons. Add a regression test case for copyin(9). PR: 257193 Reported by: Robert Morris Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D31209 (cherry picked from commit 8babb5582eed2250309084d76898798409a2aae0) --- sys/riscv/riscv/copyinout.S | 6 +++--- sys/riscv/riscv/support.S | 20 ++++++++++---------- tests/sys/kern/kern_copyin.c | 24 ++++++++++++++++++++++++ 3 files changed, 37 insertions(+), 13 deletions(-) diff --git a/sys/riscv/riscv/copyinout.S b/sys/riscv/riscv/copyinout.S index 1f2a44121ecd..5a171f5a5e17 100644 --- a/sys/riscv/riscv/copyinout.S +++ b/sys/riscv/riscv/copyinout.S @@ -118,7 +118,7 @@ ENTRY(copyout) beqz a2, copyout_end /* If len == 0 then skip loop */ add a3, a1, a2 li a4, VM_MAXUSER_ADDRESS - bgt a3, a4, copyio_fault_nopcb + bgeu a3, a4, copyio_fault_nopcb copycommon @@ -136,7 +136,7 @@ ENTRY(copyin) beqz a2, copyin_end /* If len == 0 then skip loop */ add a3, a0, a2 li a4, VM_MAXUSER_ADDRESS - bgt a3, a4, copyio_fault_nopcb + bgeu a3, a4, copyio_fault_nopcb copycommon @@ -159,7 +159,7 @@ ENTRY(copyinstr) ENTER_USER_ACCESS(a7) li a7, VM_MAXUSER_ADDRESS -1: bgt a0, a7, copyio_fault +1: bgeu a0, a7, copyio_fault lb a4, 0(a0) /* Load from uaddr */ addi a0, a0, 1 sb a4, 0(a1) /* Store in kaddr */ diff --git a/sys/riscv/riscv/support.S b/sys/riscv/riscv/support.S index 3f0ec08ac768..7fcd6af283b7 100644 --- a/sys/riscv/riscv/support.S +++ b/sys/riscv/riscv/support.S @@ -56,7 +56,7 @@ END(fsu_fault) */ ENTRY(casueword32) li a4, (VM_MAXUSER_ADDRESS-3) - bgt a0, a4, fsu_fault_nopcb + bgeu a0, a4, fsu_fault_nopcb la a6, fsu_fault /* Load the fault handler */ SET_FAULT_HANDLER(a6, a4) /* And set it */ ENTER_USER_ACCESS(a4) @@ -77,7 +77,7 @@ END(casueword32) */ ENTRY(casueword) li a4, (VM_MAXUSER_ADDRESS-7) - bgt a0, a4, fsu_fault_nopcb + bgeu a0, a4, fsu_fault_nopcb la a6, fsu_fault /* Load the fault handler */ SET_FAULT_HANDLER(a6, a4) /* And set it */ ENTER_USER_ACCESS(a4) @@ -98,7 +98,7 @@ END(casueword) */ ENTRY(fubyte) li a1, VM_MAXUSER_ADDRESS - bgt a0, a1, fsu_fault_nopcb + bgeu a0, a1, fsu_fault_nopcb la a6, fsu_fault /* Load the fault handler */ SET_FAULT_HANDLER(a6, a1) /* And set it */ ENTER_USER_ACCESS(a1) @@ -113,7 +113,7 @@ END(fubyte) */ ENTRY(fuword16) li a1, (VM_MAXUSER_ADDRESS-1) - bgt a0, a1, fsu_fault_nopcb + bgeu a0, a1, fsu_fault_nopcb la a6, fsu_fault /* Load the fault handler */ SET_FAULT_HANDLER(a6, a1) /* And set it */ ENTER_USER_ACCESS(a1) @@ -128,7 +128,7 @@ END(fuword16) */ ENTRY(fueword32) li a2, (VM_MAXUSER_ADDRESS-3) - bgt a0, a2, fsu_fault_nopcb + bgeu a0, a2, fsu_fault_nopcb la a6, fsu_fault /* Load the fault handler */ SET_FAULT_HANDLER(a6, a2) /* And set it */ ENTER_USER_ACCESS(a2) @@ -147,7 +147,7 @@ END(fueword32) ENTRY(fueword) EENTRY(fueword64) li a2, (VM_MAXUSER_ADDRESS-7) - bgt a0, a2, fsu_fault_nopcb + bgeu a0, a2, fsu_fault_nopcb la a6, fsu_fault /* Load the fault handler */ SET_FAULT_HANDLER(a6, a2) /* And set it */ ENTER_USER_ACCESS(a2) @@ -165,7 +165,7 @@ END(fueword) */ ENTRY(subyte) li a2, VM_MAXUSER_ADDRESS - bgt a0, a2, fsu_fault_nopcb + bgeu a0, a2, fsu_fault_nopcb la a6, fsu_fault /* Load the fault handler */ SET_FAULT_HANDLER(a6, a2) /* And set it */ ENTER_USER_ACCESS(a2) @@ -181,7 +181,7 @@ END(subyte) */ ENTRY(suword16) li a2, (VM_MAXUSER_ADDRESS-1) - bgt a0, a2, fsu_fault_nopcb + bgeu a0, a2, fsu_fault_nopcb la a6, fsu_fault /* Load the fault handler */ SET_FAULT_HANDLER(a6, a2) /* And set it */ ENTER_USER_ACCESS(a2) @@ -197,7 +197,7 @@ END(suword16) */ ENTRY(suword32) li a2, (VM_MAXUSER_ADDRESS-3) - bgt a0, a2, fsu_fault_nopcb + bgeu a0, a2, fsu_fault_nopcb la a6, fsu_fault /* Load the fault handler */ SET_FAULT_HANDLER(a6, a2) /* And set it */ ENTER_USER_ACCESS(a2) @@ -214,7 +214,7 @@ END(suword32) ENTRY(suword) EENTRY(suword64) li a2, (VM_MAXUSER_ADDRESS-7) - bgt a0, a2, fsu_fault_nopcb + bgeu a0, a2, fsu_fault_nopcb la a6, fsu_fault /* Load the fault handler */ SET_FAULT_HANDLER(a6, a2) /* And set it */ ENTER_USER_ACCESS(a2) diff --git a/tests/sys/kern/kern_copyin.c b/tests/sys/kern/kern_copyin.c index b77360e928fd..eb1fea315b5a 100644 --- a/tests/sys/kern/kern_copyin.c +++ b/tests/sys/kern/kern_copyin.c @@ -34,6 +34,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -54,6 +55,21 @@ copyin_checker(uintptr_t uaddr, size_t len) return (ret == -1 ? errno : 0); } +#if __SIZEOF_POINTER__ == 8 +/* + * A slightly more direct path to calling copyin(), but without the ability + * to specify a length. + */ +static int +copyin_checker2(uintptr_t uaddr) +{ + int ret; + + ret = fcntl(scratch_file, F_GETLK, (const void *)uaddr); + return (ret == -1 ? errno : 0); +} +#endif + #ifdef __amd64__ static uintptr_t get_maxuser_address(void) @@ -83,6 +99,10 @@ get_maxuser_address(void) #endif #define FMAX ULONG_MAX +#if __SIZEOF_POINTER__ == 8 +/* PR 257193 */ +#define ADDR_SIGNED 0x800000c000000000 +#endif ATF_TC_WITHOUT_HEAD(kern_copyin); ATF_TC_BODY(kern_copyin, tc) @@ -122,6 +142,10 @@ ATF_TC_BODY(kern_copyin, tc) ATF_CHECK(copyin_checker(FMAX - 10, 9) == EFAULT); ATF_CHECK(copyin_checker(FMAX - 10, 10) == EFAULT); ATF_CHECK(copyin_checker(FMAX - 10, 11) == EFAULT); +#if __SIZEOF_POINTER__ == 8 + ATF_CHECK(copyin_checker(ADDR_SIGNED, 1) == EFAULT); + ATF_CHECK(copyin_checker2(ADDR_SIGNED) == EFAULT); +#endif } ATF_TP_ADD_TCS(tp) From nobody Fri Oct 15 15:26:18 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 7831D1817097; Fri, 15 Oct 2021 15:26:19 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HW98p3lcYz3PNj; Fri, 15 Oct 2021 15:26:18 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 41B3BD83; Fri, 15 Oct 2021 15:26:18 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19FFQIBa007442; Fri, 15 Oct 2021 15:26:18 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19FFQII8007441; Fri, 15 Oct 2021 15:26:18 GMT (envelope-from git) Date: Fri, 15 Oct 2021 15:26:18 GMT Message-Id: <202110151526.19FFQII8007441@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mitchell Horne Subject: git: aa794b82ef88 - stable/13 - arm, arm64, riscv: adjust top-level nexus comment List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mhorne X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: aa794b82ef88001cbb2f335fda126935c231511f Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by mhorne: URL: https://cgit.FreeBSD.org/src/commit/?id=aa794b82ef88001cbb2f335fda126935c231511f commit aa794b82ef88001cbb2f335fda126935c231511f Author: Mitchell Horne AuthorDate: 2021-10-07 18:02:02 +0000 Commit: Mitchell Horne CommitDate: 2021-10-15 15:22:14 +0000 arm, arm64, riscv: adjust top-level nexus comment These platforms don't manage resources for DMA request lines or I/O ports, this is specific to x86. Remove the references from the comments. Reviewed by: imp, jhb MFC after: 3 days Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D32358 (cherry picked from commit 17f790f49f5879ae9888b99fdbf857010ec13f9c) --- sys/arm/arm/nexus.c | 4 +--- sys/arm64/arm64/nexus.c | 4 +--- sys/riscv/riscv/nexus.c | 4 +--- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/sys/arm/arm/nexus.c b/sys/arm/arm/nexus.c index f9e9fec7ad25..be84ab82d43f 100644 --- a/sys/arm/arm/nexus.c +++ b/sys/arm/arm/nexus.c @@ -34,9 +34,7 @@ * attachment point for both processors and buses, and to manage * resources which are common to all of them. In particular, * this code implements the core resource managers for interrupt - * requests, DMA requests (which rightfully should be a part of the - * ISA code but it's easier to do it here for now), I/O port addresses, - * and I/O memory address space. + * requests and I/O memory address space. */ #include "opt_platform.h" diff --git a/sys/arm64/arm64/nexus.c b/sys/arm64/arm64/nexus.c index cc28d87f002b..0775cc820a8c 100644 --- a/sys/arm64/arm64/nexus.c +++ b/sys/arm64/arm64/nexus.c @@ -34,9 +34,7 @@ * attachment point for both processors and buses, and to manage * resources which are common to all of them. In particular, * this code implements the core resource managers for interrupt - * requests, DMA requests (which rightfully should be a part of the - * ISA code but it's easier to do it here for now), I/O port addresses, - * and I/O memory address space. + * requests and I/O memory address space. */ #include "opt_acpi.h" diff --git a/sys/riscv/riscv/nexus.c b/sys/riscv/riscv/nexus.c index b56cf29aa3ee..16fe971b6521 100644 --- a/sys/riscv/riscv/nexus.c +++ b/sys/riscv/riscv/nexus.c @@ -34,9 +34,7 @@ * attachment point for both processors and buses, and to manage * resources which are common to all of them. In particular, * this code implements the core resource managers for interrupt - * requests, DMA requests (which rightfully should be a part of the - * ISA code but it's easier to do it here for now), I/O port addresses, - * and I/O memory address space. + * requests and I/O memory address space. */ #include "opt_platform.h" From nobody Sat Oct 16 13:02:48 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id AACD2180C547; Sat, 16 Oct 2021 13: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 4HWjwm4V2Xz3DmN; Sat, 16 Oct 2021 13: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 7A03E1A68F; Sat, 16 Oct 2021 13: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 19GD2m32037058; Sat, 16 Oct 2021 13: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 19GD2mEO037057; Sat, 16 Oct 2021 13:02:48 GMT (envelope-from git) Date: Sat, 16 Oct 2021 13:02:48 GMT Message-Id: <202110161302.19GD2mEO037057@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: f824a0d0909f - stable/13 - Style List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: f824a0d0909f1238644e282dad85de76b32295c4 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=f824a0d0909f1238644e282dad85de76b32295c4 commit f824a0d0909f1238644e282dad85de76b32295c4 Author: Konstantin Belousov AuthorDate: 2021-10-14 19:30:18 +0000 Commit: Konstantin Belousov CommitDate: 2021-10-15 20:39:07 +0000 Style (cherry picked from commit 1adebca1fc9f6def501f7a5c2b2bde5fe9049477) --- sys/kern/kern_sig.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c index 7a1fd0bab917..af5c70ada3e6 100644 --- a/sys/kern/kern_sig.c +++ b/sys/kern/kern_sig.c @@ -2050,7 +2050,7 @@ trapsignal(struct thread *td, ksiginfo_t *ksi) &td->td_sigmask, code); #endif (*p->p_sysent->sv_sendsig)(ps->ps_sigact[_SIG_IDX(sig)], - ksi, &td->td_sigmask); + ksi, &td->td_sigmask); postsig_done(sig, td, ps); mtx_unlock(&ps->ps_mtx); } else { From nobody Sat Oct 16 13:02:49 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 071E2180C4D1; Sat, 16 Oct 2021 13: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 4HWjwn6L2Nz3DjS; Sat, 16 Oct 2021 13:02: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 A87B11A2DE; Sat, 16 Oct 2021 13:02: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 19GD2nHI037082; Sat, 16 Oct 2021 13:02:49 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19GD2nr6037081; Sat, 16 Oct 2021 13:02:49 GMT (envelope-from git) Date: Sat, 16 Oct 2021 13:02:49 GMT Message-Id: <202110161302.19GD2nr6037081@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: 4943c24be3de - stable/13 - Fix typo in comment List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 4943c24be3de1fe66c68e96a888fb5673439166c Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=4943c24be3de1fe66c68e96a888fb5673439166c commit 4943c24be3de1fe66c68e96a888fb5673439166c Author: Konstantin Belousov AuthorDate: 2021-10-14 20:03:36 +0000 Commit: Konstantin Belousov CommitDate: 2021-10-15 20:39:08 +0000 Fix typo in comment (cherry picked from commit 86929782cfab2664010a31979e9e3c0626721ebb) --- sys/sys/proc.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/sys/proc.h b/sys/sys/proc.h index 67dc32dbaa03..b647cb1c33ef 100644 --- a/sys/sys/proc.h +++ b/sys/sys/proc.h @@ -305,7 +305,7 @@ struct thread { struct osd td_osd; /* (k) Object specific data. */ struct vm_map_entry *td_map_def_user; /* (k) Deferred entries. */ pid_t td_dbg_forked; /* (c) Child pid for debugger. */ - struct vnode *td_vp_reserved;/* (k) Prealloated vnode. */ + struct vnode *td_vp_reserved;/* (k) Preallocated vnode. */ u_int td_no_sleeping; /* (k) Sleeping disabled count. */ void *td_su; /* (k) FFS SU private */ sbintime_t td_sleeptimo; /* (t) Sleep timeout. */ From nobody Sat Oct 16 13:02:50 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id E92D7180C55C; Sat, 16 Oct 2021 13:02: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 4HWjwp6sZ3z3Dp0; Sat, 16 Oct 2021 13: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 C069E1A370; Sat, 16 Oct 2021 13: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 19GD2o3Q037106; Sat, 16 Oct 2021 13: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 19GD2ocF037105; Sat, 16 Oct 2021 13:02:50 GMT (envelope-from git) Date: Sat, 16 Oct 2021 13:02:50 GMT Message-Id: <202110161302.19GD2ocF037105@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: 1625e2db222c - stable/13 - O_PATH: allow vfs_extattr syscalls List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 1625e2db222cad581593d4079385707e2e15cdbe Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=1625e2db222cad581593d4079385707e2e15cdbe commit 1625e2db222cad581593d4079385707e2e15cdbe Author: Greg V AuthorDate: 2021-10-10 12:45:31 +0000 Commit: Konstantin Belousov CommitDate: 2021-10-16 13:01:47 +0000 O_PATH: allow vfs_extattr syscalls (cherry picked from commit 98dae405de7f8b3506dd94dcd3e9f51d3fb15962) --- lib/libc/sys/extattr_get_file.2 | 7 ++++++- sys/kern/vfs_extattr.c | 8 ++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/libc/sys/extattr_get_file.2 b/lib/libc/sys/extattr_get_file.2 index 5134c8d8ac0f..c38b27e17423 100644 --- a/lib/libc/sys/extattr_get_file.2 +++ b/lib/libc/sys/extattr_get_file.2 @@ -26,7 +26,7 @@ .\" .\" $FreeBSD$ .\" -.Dd December 7, 2020 +.Dd October 11, 2021 .Dt EXTATTR 2 .Os .Sh NAME @@ -149,6 +149,11 @@ functions take a file descriptor, while the functions take a path. Both arguments describe a file associated with the extended attribute that should be manipulated. +The +.Qq Li _fd +functions can be used with file descriptors opened with the +.Dv O_PATH +flag. .Pp The following arguments are common to all the system calls described here: .Bl -tag -width attrnamespace diff --git a/sys/kern/vfs_extattr.c b/sys/kern/vfs_extattr.c index adb882288f6c..43b000c78110 100644 --- a/sys/kern/vfs_extattr.c +++ b/sys/kern/vfs_extattr.c @@ -242,7 +242,7 @@ sys_extattr_set_fd(struct thread *td, struct extattr_set_fd_args *uap) return (error); AUDIT_ARG_TEXT(attrname); - error = getvnode(td, uap->fd, + error = getvnode_path(td, uap->fd, cap_rights_init_one(&rights, CAP_EXTATTR_SET), &fp); if (error) return (error); @@ -409,7 +409,7 @@ sys_extattr_get_fd(struct thread *td, struct extattr_get_fd_args *uap) return (error); AUDIT_ARG_TEXT(attrname); - error = getvnode(td, uap->fd, + error = getvnode_path(td, uap->fd, cap_rights_init_one(&rights, CAP_EXTATTR_GET), &fp); if (error) return (error); @@ -544,7 +544,7 @@ sys_extattr_delete_fd(struct thread *td, struct extattr_delete_fd_args *uap) return (error); AUDIT_ARG_TEXT(attrname); - error = getvnode(td, uap->fd, + error = getvnode_path(td, uap->fd, cap_rights_init_one(&rights, CAP_EXTATTR_DELETE), &fp); if (error) return (error); @@ -690,7 +690,7 @@ sys_extattr_list_fd(struct thread *td, struct extattr_list_fd_args *uap) AUDIT_ARG_FD(uap->fd); AUDIT_ARG_VALUE(uap->attrnamespace); - error = getvnode(td, uap->fd, + error = getvnode_path(td, uap->fd, cap_rights_init_one(&rights, CAP_EXTATTR_LIST), &fp); if (error) return (error); From nobody Sat Oct 16 13:02:51 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id E58CF180C4E2; Sat, 16 Oct 2021 13: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 4HWjwr49zHz3Dwf; Sat, 16 Oct 2021 13: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 E2F271A2DF; Sat, 16 Oct 2021 13: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 19GD2pM9037137; Sat, 16 Oct 2021 13: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 19GD2pAD037136; Sat, 16 Oct 2021 13:02:51 GMT (envelope-from git) Date: Sat, 16 Oct 2021 13:02:51 GMT Message-Id: <202110161302.19GD2pAD037136@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: 3f602aa87312 - stable/13 - i386: move signal delivery code to exec_machdep.c List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 3f602aa873122e8c3771135e6d0ed2610ea229b1 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=3f602aa873122e8c3771135e6d0ed2610ea229b1 commit 3f602aa873122e8c3771135e6d0ed2610ea229b1 Author: Konstantin Belousov AuthorDate: 2021-10-04 01:29:26 +0000 Commit: Konstantin Belousov CommitDate: 2021-10-16 13:01:47 +0000 i386: move signal delivery code to exec_machdep.c (cherry picked from commit 4c5bf591522c5449d017b7ea496488c42f847963) --- sys/conf/files.i386 | 1 + sys/i386/i386/exec_machdep.c | 1443 ++++++++++++++++++++++++++++++++++++++++ sys/i386/i386/machdep.c | 1391 -------------------------------------- sys/i386/i386/ptrace_machdep.c | 32 + 4 files changed, 1476 insertions(+), 1391 deletions(-) diff --git a/sys/conf/files.i386 b/sys/conf/files.i386 index 5c65ad53cea4..6a0ca49c0432 100644 --- a/sys/conf/files.i386 +++ b/sys/conf/files.i386 @@ -165,6 +165,7 @@ i386/i386/copyout.c standard i386/i386/db_disasm.c optional ddb i386/i386/db_interface.c optional ddb i386/i386/db_trace.c optional ddb +i386/i386/exec_machdep.c standard i386/i386/elan-mmcr.c optional cpu_elan | cpu_soekris i386/i386/elf_machdep.c standard i386/i386/exception.s standard diff --git a/sys/i386/i386/exec_machdep.c b/sys/i386/i386/exec_machdep.c new file mode 100644 index 000000000000..13628aba7ab1 --- /dev/null +++ b/sys/i386/i386/exec_machdep.c @@ -0,0 +1,1443 @@ +/*- + * SPDX-License-Identifier: BSD-4-Clause + * + * Copyright (c) 2018 The FreeBSD Foundation + * Copyright (c) 1992 Terrence R. Lambert. + * Copyright (c) 1982, 1987, 1990 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * William Jolitz. + * + * Portions of this software were developed by A. Joseph Koshy under + * sponsorship from the FreeBSD Foundation and Google, 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. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * from: @(#)machdep.c 7.4 (Berkeley) 6/3/91 + */ + +#include +__FBSDID("$FreeBSD$"); + +#include "opt_cpu.h" +#include "opt_ddb.h" +#include "opt_kstack_pages.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#ifdef DDB +#ifndef KDB +#error KDB must be enabled in order for DDB to work! +#endif +#include +#include +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static void fpstate_drop(struct thread *td); +static void get_fpcontext(struct thread *td, mcontext_t *mcp, + char *xfpusave, size_t xfpusave_len); +static int set_fpcontext(struct thread *td, mcontext_t *mcp, + char *xfpustate, size_t xfpustate_len); +#ifdef COMPAT_43 +static void osendsig(sig_t catcher, ksiginfo_t *, sigset_t *mask); +#endif +#ifdef COMPAT_FREEBSD4 +static void freebsd4_sendsig(sig_t catcher, ksiginfo_t *, sigset_t *mask); +#endif + +extern struct sysentvec elf32_freebsd_sysvec; + +/* + * Send an interrupt to process. + * + * Stack is set up to allow sigcode stored at top to call routine, + * followed by call to sigreturn routine below. After sigreturn + * resets the signal mask, the stack, and the frame pointer, it + * returns to the user specified pc, psl. + */ +#ifdef COMPAT_43 +static void +osendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask) +{ + struct osigframe sf, *fp; + struct proc *p; + struct thread *td; + struct sigacts *psp; + struct trapframe *regs; + int sig; + int oonstack; + + td = curthread; + p = td->td_proc; + PROC_LOCK_ASSERT(p, MA_OWNED); + sig = ksi->ksi_signo; + psp = p->p_sigacts; + mtx_assert(&psp->ps_mtx, MA_OWNED); + regs = td->td_frame; + oonstack = sigonstack(regs->tf_esp); + + /* Allocate space for the signal handler context. */ + if ((td->td_pflags & TDP_ALTSTACK) && !oonstack && + SIGISMEMBER(psp->ps_sigonstack, sig)) { + fp = (struct osigframe *)((uintptr_t)td->td_sigstk.ss_sp + + td->td_sigstk.ss_size - sizeof(struct osigframe)); +#if defined(COMPAT_43) + td->td_sigstk.ss_flags |= SS_ONSTACK; +#endif + } else + fp = (struct osigframe *)regs->tf_esp - 1; + + /* Build the argument list for the signal handler. */ + sf.sf_signum = sig; + sf.sf_scp = (register_t)&fp->sf_siginfo.si_sc; + bzero(&sf.sf_siginfo, sizeof(sf.sf_siginfo)); + if (SIGISMEMBER(psp->ps_siginfo, sig)) { + /* Signal handler installed with SA_SIGINFO. */ + sf.sf_arg2 = (register_t)&fp->sf_siginfo; + sf.sf_siginfo.si_signo = sig; + sf.sf_siginfo.si_code = ksi->ksi_code; + sf.sf_ahu.sf_action = (__osiginfohandler_t *)catcher; + sf.sf_addr = 0; + } else { + /* Old FreeBSD-style arguments. */ + sf.sf_arg2 = ksi->ksi_code; + sf.sf_addr = (register_t)ksi->ksi_addr; + sf.sf_ahu.sf_handler = catcher; + } + mtx_unlock(&psp->ps_mtx); + PROC_UNLOCK(p); + + /* Save most if not all of trap frame. */ + sf.sf_siginfo.si_sc.sc_eax = regs->tf_eax; + sf.sf_siginfo.si_sc.sc_ebx = regs->tf_ebx; + sf.sf_siginfo.si_sc.sc_ecx = regs->tf_ecx; + sf.sf_siginfo.si_sc.sc_edx = regs->tf_edx; + sf.sf_siginfo.si_sc.sc_esi = regs->tf_esi; + sf.sf_siginfo.si_sc.sc_edi = regs->tf_edi; + sf.sf_siginfo.si_sc.sc_cs = regs->tf_cs; + sf.sf_siginfo.si_sc.sc_ds = regs->tf_ds; + sf.sf_siginfo.si_sc.sc_ss = regs->tf_ss; + sf.sf_siginfo.si_sc.sc_es = regs->tf_es; + sf.sf_siginfo.si_sc.sc_fs = regs->tf_fs; + sf.sf_siginfo.si_sc.sc_gs = rgs(); + sf.sf_siginfo.si_sc.sc_isp = regs->tf_isp; + + /* Build the signal context to be used by osigreturn(). */ + sf.sf_siginfo.si_sc.sc_onstack = (oonstack) ? 1 : 0; + SIG2OSIG(*mask, sf.sf_siginfo.si_sc.sc_mask); + sf.sf_siginfo.si_sc.sc_sp = regs->tf_esp; + sf.sf_siginfo.si_sc.sc_fp = regs->tf_ebp; + sf.sf_siginfo.si_sc.sc_pc = regs->tf_eip; + sf.sf_siginfo.si_sc.sc_ps = regs->tf_eflags; + sf.sf_siginfo.si_sc.sc_trapno = regs->tf_trapno; + sf.sf_siginfo.si_sc.sc_err = regs->tf_err; + + /* + * If we're a vm86 process, we want to save the segment registers. + * We also change eflags to be our emulated eflags, not the actual + * eflags. + */ + if (regs->tf_eflags & PSL_VM) { + /* XXX confusing names: `tf' isn't a trapframe; `regs' is. */ + struct trapframe_vm86 *tf = (struct trapframe_vm86 *)regs; + struct vm86_kernel *vm86 = &td->td_pcb->pcb_ext->ext_vm86; + + sf.sf_siginfo.si_sc.sc_gs = tf->tf_vm86_gs; + sf.sf_siginfo.si_sc.sc_fs = tf->tf_vm86_fs; + sf.sf_siginfo.si_sc.sc_es = tf->tf_vm86_es; + sf.sf_siginfo.si_sc.sc_ds = tf->tf_vm86_ds; + + if (vm86->vm86_has_vme == 0) + sf.sf_siginfo.si_sc.sc_ps = + (tf->tf_eflags & ~(PSL_VIF | PSL_VIP)) | + (vm86->vm86_eflags & (PSL_VIF | PSL_VIP)); + + /* See sendsig() for comments. */ + tf->tf_eflags &= ~(PSL_VM | PSL_NT | PSL_VIF | PSL_VIP); + } + + /* + * Copy the sigframe out to the user's stack. + */ + if (copyout(&sf, fp, sizeof(*fp)) != 0) { + PROC_LOCK(p); + sigexit(td, SIGILL); + } + + regs->tf_esp = (int)fp; + if (p->p_sysent->sv_sigcode_base != 0) { + regs->tf_eip = p->p_sysent->sv_sigcode_base + szsigcode - + szosigcode; + } else { + /* a.out sysentvec does not use shared page */ + regs->tf_eip = p->p_sysent->sv_psstrings - szosigcode; + } + regs->tf_eflags &= ~(PSL_T | PSL_D); + regs->tf_cs = _ucodesel; + regs->tf_ds = _udatasel; + regs->tf_es = _udatasel; + regs->tf_fs = _udatasel; + load_gs(_udatasel); + regs->tf_ss = _udatasel; + PROC_LOCK(p); + mtx_lock(&psp->ps_mtx); +} +#endif /* COMPAT_43 */ + +#ifdef COMPAT_FREEBSD4 +static void +freebsd4_sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask) +{ + struct sigframe4 sf, *sfp; + struct proc *p; + struct thread *td; + struct sigacts *psp; + struct trapframe *regs; + int sig; + int oonstack; + + td = curthread; + p = td->td_proc; + PROC_LOCK_ASSERT(p, MA_OWNED); + sig = ksi->ksi_signo; + psp = p->p_sigacts; + mtx_assert(&psp->ps_mtx, MA_OWNED); + regs = td->td_frame; + oonstack = sigonstack(regs->tf_esp); + + /* Save user context. */ + bzero(&sf, sizeof(sf)); + sf.sf_uc.uc_sigmask = *mask; + sf.sf_uc.uc_stack = td->td_sigstk; + sf.sf_uc.uc_stack.ss_flags = (td->td_pflags & TDP_ALTSTACK) + ? ((oonstack) ? SS_ONSTACK : 0) : SS_DISABLE; + sf.sf_uc.uc_mcontext.mc_onstack = (oonstack) ? 1 : 0; + sf.sf_uc.uc_mcontext.mc_gs = rgs(); + bcopy(regs, &sf.sf_uc.uc_mcontext.mc_fs, sizeof(*regs)); + bzero(sf.sf_uc.uc_mcontext.mc_fpregs, + sizeof(sf.sf_uc.uc_mcontext.mc_fpregs)); + bzero(sf.sf_uc.uc_mcontext.__spare__, + sizeof(sf.sf_uc.uc_mcontext.__spare__)); + bzero(sf.sf_uc.__spare__, sizeof(sf.sf_uc.__spare__)); + + /* Allocate space for the signal handler context. */ + if ((td->td_pflags & TDP_ALTSTACK) != 0 && !oonstack && + SIGISMEMBER(psp->ps_sigonstack, sig)) { + sfp = (struct sigframe4 *)((uintptr_t)td->td_sigstk.ss_sp + + td->td_sigstk.ss_size - sizeof(struct sigframe4)); +#if defined(COMPAT_43) + td->td_sigstk.ss_flags |= SS_ONSTACK; +#endif + } else + sfp = (struct sigframe4 *)regs->tf_esp - 1; + + /* Build the argument list for the signal handler. */ + sf.sf_signum = sig; + sf.sf_ucontext = (register_t)&sfp->sf_uc; + bzero(&sf.sf_si, sizeof(sf.sf_si)); + if (SIGISMEMBER(psp->ps_siginfo, sig)) { + /* Signal handler installed with SA_SIGINFO. */ + sf.sf_siginfo = (register_t)&sfp->sf_si; + sf.sf_ahu.sf_action = (__siginfohandler_t *)catcher; + + /* Fill in POSIX parts */ + sf.sf_si.si_signo = sig; + sf.sf_si.si_code = ksi->ksi_code; + sf.sf_si.si_addr = ksi->ksi_addr; + } else { + /* Old FreeBSD-style arguments. */ + sf.sf_siginfo = ksi->ksi_code; + sf.sf_addr = (register_t)ksi->ksi_addr; + sf.sf_ahu.sf_handler = catcher; + } + mtx_unlock(&psp->ps_mtx); + PROC_UNLOCK(p); + + /* + * If we're a vm86 process, we want to save the segment registers. + * We also change eflags to be our emulated eflags, not the actual + * eflags. + */ + if (regs->tf_eflags & PSL_VM) { + struct trapframe_vm86 *tf = (struct trapframe_vm86 *)regs; + struct vm86_kernel *vm86 = &td->td_pcb->pcb_ext->ext_vm86; + + sf.sf_uc.uc_mcontext.mc_gs = tf->tf_vm86_gs; + sf.sf_uc.uc_mcontext.mc_fs = tf->tf_vm86_fs; + sf.sf_uc.uc_mcontext.mc_es = tf->tf_vm86_es; + sf.sf_uc.uc_mcontext.mc_ds = tf->tf_vm86_ds; + + if (vm86->vm86_has_vme == 0) + sf.sf_uc.uc_mcontext.mc_eflags = + (tf->tf_eflags & ~(PSL_VIF | PSL_VIP)) | + (vm86->vm86_eflags & (PSL_VIF | PSL_VIP)); + + /* + * Clear PSL_NT to inhibit T_TSSFLT faults on return from + * syscalls made by the signal handler. This just avoids + * wasting time for our lazy fixup of such faults. PSL_NT + * does nothing in vm86 mode, but vm86 programs can set it + * almost legitimately in probes for old cpu types. + */ + tf->tf_eflags &= ~(PSL_VM | PSL_NT | PSL_VIF | PSL_VIP); + } + + /* + * Copy the sigframe out to the user's stack. + */ + if (copyout(&sf, sfp, sizeof(*sfp)) != 0) { + PROC_LOCK(p); + sigexit(td, SIGILL); + } + + regs->tf_esp = (int)sfp; + regs->tf_eip = p->p_sysent->sv_sigcode_base + szsigcode - + szfreebsd4_sigcode; + regs->tf_eflags &= ~(PSL_T | PSL_D); + regs->tf_cs = _ucodesel; + regs->tf_ds = _udatasel; + regs->tf_es = _udatasel; + regs->tf_fs = _udatasel; + regs->tf_ss = _udatasel; + PROC_LOCK(p); + mtx_lock(&psp->ps_mtx); +} +#endif /* COMPAT_FREEBSD4 */ + +void +sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask) +{ + struct sigframe sf, *sfp; + struct proc *p; + struct thread *td; + struct sigacts *psp; + char *sp; + struct trapframe *regs; + struct segment_descriptor *sdp; + char *xfpusave; + size_t xfpusave_len; + int sig; + int oonstack; + + td = curthread; + p = td->td_proc; + PROC_LOCK_ASSERT(p, MA_OWNED); + sig = ksi->ksi_signo; + psp = p->p_sigacts; + mtx_assert(&psp->ps_mtx, MA_OWNED); +#ifdef COMPAT_FREEBSD4 + if (SIGISMEMBER(psp->ps_freebsd4, sig)) { + freebsd4_sendsig(catcher, ksi, mask); + return; + } +#endif +#ifdef COMPAT_43 + if (SIGISMEMBER(psp->ps_osigset, sig)) { + osendsig(catcher, ksi, mask); + return; + } +#endif + regs = td->td_frame; + oonstack = sigonstack(regs->tf_esp); + + if (cpu_max_ext_state_size > sizeof(union savefpu) && use_xsave) { + xfpusave_len = cpu_max_ext_state_size - sizeof(union savefpu); + xfpusave = __builtin_alloca(xfpusave_len); + } else { + xfpusave_len = 0; + xfpusave = NULL; + } + + /* Save user context. */ + bzero(&sf, sizeof(sf)); + sf.sf_uc.uc_sigmask = *mask; + sf.sf_uc.uc_stack = td->td_sigstk; + sf.sf_uc.uc_stack.ss_flags = (td->td_pflags & TDP_ALTSTACK) + ? ((oonstack) ? SS_ONSTACK : 0) : SS_DISABLE; + sf.sf_uc.uc_mcontext.mc_onstack = (oonstack) ? 1 : 0; + sf.sf_uc.uc_mcontext.mc_gs = rgs(); + bcopy(regs, &sf.sf_uc.uc_mcontext.mc_fs, sizeof(*regs)); + sf.sf_uc.uc_mcontext.mc_len = sizeof(sf.sf_uc.uc_mcontext); /* magic */ + get_fpcontext(td, &sf.sf_uc.uc_mcontext, xfpusave, xfpusave_len); + fpstate_drop(td); + /* + * Unconditionally fill the fsbase and gsbase into the mcontext. + */ + sdp = &td->td_pcb->pcb_fsd; + sf.sf_uc.uc_mcontext.mc_fsbase = sdp->sd_hibase << 24 | + sdp->sd_lobase; + sdp = &td->td_pcb->pcb_gsd; + sf.sf_uc.uc_mcontext.mc_gsbase = sdp->sd_hibase << 24 | + sdp->sd_lobase; + bzero(sf.sf_uc.uc_mcontext.mc_spare2, + sizeof(sf.sf_uc.uc_mcontext.mc_spare2)); + + /* Allocate space for the signal handler context. */ + if ((td->td_pflags & TDP_ALTSTACK) != 0 && !oonstack && + SIGISMEMBER(psp->ps_sigonstack, sig)) { + sp = (char *)td->td_sigstk.ss_sp + td->td_sigstk.ss_size; +#if defined(COMPAT_43) + td->td_sigstk.ss_flags |= SS_ONSTACK; +#endif + } else + sp = (char *)regs->tf_esp - 128; + if (xfpusave != NULL) { + sp -= xfpusave_len; + sp = (char *)((unsigned int)sp & ~0x3F); + sf.sf_uc.uc_mcontext.mc_xfpustate = (register_t)sp; + } + sp -= sizeof(struct sigframe); + + /* Align to 16 bytes. */ + sfp = (struct sigframe *)((unsigned int)sp & ~0xF); + + /* Build the argument list for the signal handler. */ + sf.sf_signum = sig; + sf.sf_ucontext = (register_t)&sfp->sf_uc; + bzero(&sf.sf_si, sizeof(sf.sf_si)); + if (SIGISMEMBER(psp->ps_siginfo, sig)) { + /* Signal handler installed with SA_SIGINFO. */ + sf.sf_siginfo = (register_t)&sfp->sf_si; + sf.sf_ahu.sf_action = (__siginfohandler_t *)catcher; + + /* Fill in POSIX parts */ + sf.sf_si = ksi->ksi_info; + sf.sf_si.si_signo = sig; /* maybe a translated signal */ + } else { + /* Old FreeBSD-style arguments. */ + sf.sf_siginfo = ksi->ksi_code; + sf.sf_addr = (register_t)ksi->ksi_addr; + sf.sf_ahu.sf_handler = catcher; + } + mtx_unlock(&psp->ps_mtx); + PROC_UNLOCK(p); + + /* + * If we're a vm86 process, we want to save the segment registers. + * We also change eflags to be our emulated eflags, not the actual + * eflags. + */ + if (regs->tf_eflags & PSL_VM) { + struct trapframe_vm86 *tf = (struct trapframe_vm86 *)regs; + struct vm86_kernel *vm86 = &td->td_pcb->pcb_ext->ext_vm86; + + sf.sf_uc.uc_mcontext.mc_gs = tf->tf_vm86_gs; + sf.sf_uc.uc_mcontext.mc_fs = tf->tf_vm86_fs; + sf.sf_uc.uc_mcontext.mc_es = tf->tf_vm86_es; + sf.sf_uc.uc_mcontext.mc_ds = tf->tf_vm86_ds; + + if (vm86->vm86_has_vme == 0) + sf.sf_uc.uc_mcontext.mc_eflags = + (tf->tf_eflags & ~(PSL_VIF | PSL_VIP)) | + (vm86->vm86_eflags & (PSL_VIF | PSL_VIP)); + + /* + * Clear PSL_NT to inhibit T_TSSFLT faults on return from + * syscalls made by the signal handler. This just avoids + * wasting time for our lazy fixup of such faults. PSL_NT + * does nothing in vm86 mode, but vm86 programs can set it + * almost legitimately in probes for old cpu types. + */ + tf->tf_eflags &= ~(PSL_VM | PSL_NT | PSL_VIF | PSL_VIP); + } + + /* + * Copy the sigframe out to the user's stack. + */ + if (copyout(&sf, sfp, sizeof(*sfp)) != 0 || + (xfpusave != NULL && copyout(xfpusave, + (void *)sf.sf_uc.uc_mcontext.mc_xfpustate, xfpusave_len) + != 0)) { + PROC_LOCK(p); + sigexit(td, SIGILL); + } + + regs->tf_esp = (int)sfp; + regs->tf_eip = p->p_sysent->sv_sigcode_base; + if (regs->tf_eip == 0) + regs->tf_eip = p->p_sysent->sv_psstrings - szsigcode; + regs->tf_eflags &= ~(PSL_T | PSL_D); + regs->tf_cs = _ucodesel; + regs->tf_ds = _udatasel; + regs->tf_es = _udatasel; + regs->tf_fs = _udatasel; + regs->tf_ss = _udatasel; + PROC_LOCK(p); + mtx_lock(&psp->ps_mtx); +} + +/* + * System call to cleanup state after a signal has been taken. Reset + * signal mask and stack state from context left by sendsig (above). + * Return to previous pc and psl as specified by context left by + * sendsig. Check carefully to make sure that the user has not + * modified the state to gain improper privileges. + */ +#ifdef COMPAT_43 +int +osigreturn(struct thread *td, struct osigreturn_args *uap) +{ + struct osigcontext sc; + struct trapframe *regs; + struct osigcontext *scp; + int eflags, error; + ksiginfo_t ksi; + + regs = td->td_frame; + error = copyin(uap->sigcntxp, &sc, sizeof(sc)); + if (error != 0) + return (error); + scp = ≻ + eflags = scp->sc_ps; + if (eflags & PSL_VM) { + struct trapframe_vm86 *tf = (struct trapframe_vm86 *)regs; + struct vm86_kernel *vm86; + + /* + * if pcb_ext == 0 or vm86_inited == 0, the user hasn't + * set up the vm86 area, and we can't enter vm86 mode. + */ + if (td->td_pcb->pcb_ext == 0) + return (EINVAL); + vm86 = &td->td_pcb->pcb_ext->ext_vm86; + if (vm86->vm86_inited == 0) + return (EINVAL); + + /* Go back to user mode if both flags are set. */ + if ((eflags & PSL_VIP) && (eflags & PSL_VIF)) { + ksiginfo_init_trap(&ksi); + ksi.ksi_signo = SIGBUS; + ksi.ksi_code = BUS_OBJERR; + ksi.ksi_addr = (void *)regs->tf_eip; + trapsignal(td, &ksi); + } + + if (vm86->vm86_has_vme) { + eflags = (tf->tf_eflags & ~VME_USERCHANGE) | + (eflags & VME_USERCHANGE) | PSL_VM; + } else { + vm86->vm86_eflags = eflags; /* save VIF, VIP */ + eflags = (tf->tf_eflags & ~VM_USERCHANGE) | + (eflags & VM_USERCHANGE) | PSL_VM; + } + tf->tf_vm86_ds = scp->sc_ds; + tf->tf_vm86_es = scp->sc_es; + tf->tf_vm86_fs = scp->sc_fs; + tf->tf_vm86_gs = scp->sc_gs; + tf->tf_ds = _udatasel; + tf->tf_es = _udatasel; + tf->tf_fs = _udatasel; + } else { + /* + * Don't allow users to change privileged or reserved flags. + */ + if (!EFL_SECURE(eflags, regs->tf_eflags)) { + return (EINVAL); + } + + /* + * Don't allow users to load a valid privileged %cs. Let the + * hardware check for invalid selectors, excess privilege in + * other selectors, invalid %eip's and invalid %esp's. + */ + if (!CS_SECURE(scp->sc_cs)) { + ksiginfo_init_trap(&ksi); + ksi.ksi_signo = SIGBUS; + ksi.ksi_code = BUS_OBJERR; + ksi.ksi_trapno = T_PROTFLT; + ksi.ksi_addr = (void *)regs->tf_eip; + trapsignal(td, &ksi); + return (EINVAL); + } + regs->tf_ds = scp->sc_ds; + regs->tf_es = scp->sc_es; + regs->tf_fs = scp->sc_fs; + } + + /* Restore remaining registers. */ + regs->tf_eax = scp->sc_eax; + regs->tf_ebx = scp->sc_ebx; + regs->tf_ecx = scp->sc_ecx; + regs->tf_edx = scp->sc_edx; + regs->tf_esi = scp->sc_esi; + regs->tf_edi = scp->sc_edi; + regs->tf_cs = scp->sc_cs; + regs->tf_ss = scp->sc_ss; + regs->tf_isp = scp->sc_isp; + regs->tf_ebp = scp->sc_fp; + regs->tf_esp = scp->sc_sp; + regs->tf_eip = scp->sc_pc; + regs->tf_eflags = eflags; + +#if defined(COMPAT_43) + if (scp->sc_onstack & 1) + td->td_sigstk.ss_flags |= SS_ONSTACK; + else + td->td_sigstk.ss_flags &= ~SS_ONSTACK; +#endif + kern_sigprocmask(td, SIG_SETMASK, (sigset_t *)&scp->sc_mask, NULL, + SIGPROCMASK_OLD); + return (EJUSTRETURN); +} +#endif /* COMPAT_43 */ + +#ifdef COMPAT_FREEBSD4 +int +freebsd4_sigreturn(struct thread *td, struct freebsd4_sigreturn_args *uap) +{ + struct ucontext4 uc; + struct trapframe *regs; + struct ucontext4 *ucp; + int cs, eflags, error; + ksiginfo_t ksi; + + error = copyin(uap->sigcntxp, &uc, sizeof(uc)); + if (error != 0) + return (error); + ucp = &uc; + regs = td->td_frame; + eflags = ucp->uc_mcontext.mc_eflags; + if (eflags & PSL_VM) { + struct trapframe_vm86 *tf = (struct trapframe_vm86 *)regs; + struct vm86_kernel *vm86; + + /* + * if pcb_ext == 0 or vm86_inited == 0, the user hasn't + * set up the vm86 area, and we can't enter vm86 mode. + */ + if (td->td_pcb->pcb_ext == 0) + return (EINVAL); + vm86 = &td->td_pcb->pcb_ext->ext_vm86; + if (vm86->vm86_inited == 0) + return (EINVAL); + + /* Go back to user mode if both flags are set. */ + if ((eflags & PSL_VIP) && (eflags & PSL_VIF)) { + ksiginfo_init_trap(&ksi); + ksi.ksi_signo = SIGBUS; + ksi.ksi_code = BUS_OBJERR; + ksi.ksi_addr = (void *)regs->tf_eip; + trapsignal(td, &ksi); + } + if (vm86->vm86_has_vme) { + eflags = (tf->tf_eflags & ~VME_USERCHANGE) | + (eflags & VME_USERCHANGE) | PSL_VM; + } else { + vm86->vm86_eflags = eflags; /* save VIF, VIP */ + eflags = (tf->tf_eflags & ~VM_USERCHANGE) | + (eflags & VM_USERCHANGE) | PSL_VM; + } + bcopy(&ucp->uc_mcontext.mc_fs, tf, sizeof(struct trapframe)); + tf->tf_eflags = eflags; + tf->tf_vm86_ds = tf->tf_ds; + tf->tf_vm86_es = tf->tf_es; + tf->tf_vm86_fs = tf->tf_fs; + tf->tf_vm86_gs = ucp->uc_mcontext.mc_gs; + tf->tf_ds = _udatasel; + tf->tf_es = _udatasel; + tf->tf_fs = _udatasel; + } else { + /* + * Don't allow users to change privileged or reserved flags. + */ + if (!EFL_SECURE(eflags, regs->tf_eflags)) { + uprintf( + "pid %d (%s): freebsd4_sigreturn eflags = 0x%x\n", + td->td_proc->p_pid, td->td_name, eflags); + return (EINVAL); + } + + /* + * Don't allow users to load a valid privileged %cs. Let the + * hardware check for invalid selectors, excess privilege in + * other selectors, invalid %eip's and invalid %esp's. + */ + cs = ucp->uc_mcontext.mc_cs; + if (!CS_SECURE(cs)) { + uprintf("pid %d (%s): freebsd4_sigreturn cs = 0x%x\n", + td->td_proc->p_pid, td->td_name, cs); + ksiginfo_init_trap(&ksi); + ksi.ksi_signo = SIGBUS; + ksi.ksi_code = BUS_OBJERR; + ksi.ksi_trapno = T_PROTFLT; + ksi.ksi_addr = (void *)regs->tf_eip; + trapsignal(td, &ksi); + return (EINVAL); + } + + bcopy(&ucp->uc_mcontext.mc_fs, regs, sizeof(*regs)); + } + +#if defined(COMPAT_43) + if (ucp->uc_mcontext.mc_onstack & 1) + td->td_sigstk.ss_flags |= SS_ONSTACK; + else + td->td_sigstk.ss_flags &= ~SS_ONSTACK; +#endif + kern_sigprocmask(td, SIG_SETMASK, &ucp->uc_sigmask, NULL, 0); + return (EJUSTRETURN); +} +#endif /* COMPAT_FREEBSD4 */ + +int +sys_sigreturn(struct thread *td, struct sigreturn_args *uap) +{ + ucontext_t uc; + struct proc *p; + struct trapframe *regs; + ucontext_t *ucp; + char *xfpustate; + size_t xfpustate_len; + int cs, eflags, error, ret; + ksiginfo_t ksi; + + p = td->td_proc; + + error = copyin(uap->sigcntxp, &uc, sizeof(uc)); + if (error != 0) + return (error); + ucp = &uc; + if ((ucp->uc_mcontext.mc_flags & ~_MC_FLAG_MASK) != 0) { + uprintf("pid %d (%s): sigreturn mc_flags %x\n", p->p_pid, + td->td_name, ucp->uc_mcontext.mc_flags); + return (EINVAL); + } + regs = td->td_frame; + eflags = ucp->uc_mcontext.mc_eflags; + if (eflags & PSL_VM) { + struct trapframe_vm86 *tf = (struct trapframe_vm86 *)regs; + struct vm86_kernel *vm86; + + /* + * if pcb_ext == 0 or vm86_inited == 0, the user hasn't + * set up the vm86 area, and we can't enter vm86 mode. + */ + if (td->td_pcb->pcb_ext == 0) + return (EINVAL); + vm86 = &td->td_pcb->pcb_ext->ext_vm86; + if (vm86->vm86_inited == 0) + return (EINVAL); + + /* Go back to user mode if both flags are set. */ + if ((eflags & PSL_VIP) && (eflags & PSL_VIF)) { + ksiginfo_init_trap(&ksi); + ksi.ksi_signo = SIGBUS; + ksi.ksi_code = BUS_OBJERR; + ksi.ksi_addr = (void *)regs->tf_eip; + trapsignal(td, &ksi); + } + + if (vm86->vm86_has_vme) { + eflags = (tf->tf_eflags & ~VME_USERCHANGE) | + (eflags & VME_USERCHANGE) | PSL_VM; + } else { + vm86->vm86_eflags = eflags; /* save VIF, VIP */ + eflags = (tf->tf_eflags & ~VM_USERCHANGE) | + (eflags & VM_USERCHANGE) | PSL_VM; + } + bcopy(&ucp->uc_mcontext.mc_fs, tf, sizeof(struct trapframe)); + tf->tf_eflags = eflags; + tf->tf_vm86_ds = tf->tf_ds; + tf->tf_vm86_es = tf->tf_es; + tf->tf_vm86_fs = tf->tf_fs; + tf->tf_vm86_gs = ucp->uc_mcontext.mc_gs; + tf->tf_ds = _udatasel; + tf->tf_es = _udatasel; + tf->tf_fs = _udatasel; + } else { + /* + * Don't allow users to change privileged or reserved flags. + */ + if (!EFL_SECURE(eflags, regs->tf_eflags)) { + uprintf("pid %d (%s): sigreturn eflags = 0x%x\n", + td->td_proc->p_pid, td->td_name, eflags); + return (EINVAL); + } + + /* + * Don't allow users to load a valid privileged %cs. Let the + * hardware check for invalid selectors, excess privilege in + * other selectors, invalid %eip's and invalid %esp's. + */ + cs = ucp->uc_mcontext.mc_cs; + if (!CS_SECURE(cs)) { + uprintf("pid %d (%s): sigreturn cs = 0x%x\n", + td->td_proc->p_pid, td->td_name, cs); + ksiginfo_init_trap(&ksi); + ksi.ksi_signo = SIGBUS; + ksi.ksi_code = BUS_OBJERR; + ksi.ksi_trapno = T_PROTFLT; + ksi.ksi_addr = (void *)regs->tf_eip; + trapsignal(td, &ksi); + return (EINVAL); + } + + if ((uc.uc_mcontext.mc_flags & _MC_HASFPXSTATE) != 0) { + xfpustate_len = uc.uc_mcontext.mc_xfpustate_len; + if (xfpustate_len > cpu_max_ext_state_size - + sizeof(union savefpu)) { + uprintf( + "pid %d (%s): sigreturn xfpusave_len = 0x%zx\n", + p->p_pid, td->td_name, xfpustate_len); + return (EINVAL); + } + xfpustate = __builtin_alloca(xfpustate_len); + error = copyin( + (const void *)uc.uc_mcontext.mc_xfpustate, + xfpustate, xfpustate_len); + if (error != 0) { + uprintf( + "pid %d (%s): sigreturn copying xfpustate failed\n", + p->p_pid, td->td_name); + return (error); + } + } else { + xfpustate = NULL; + xfpustate_len = 0; + } + ret = set_fpcontext(td, &ucp->uc_mcontext, xfpustate, + xfpustate_len); + if (ret != 0) + return (ret); + bcopy(&ucp->uc_mcontext.mc_fs, regs, sizeof(*regs)); + } + +#if defined(COMPAT_43) + if (ucp->uc_mcontext.mc_onstack & 1) + td->td_sigstk.ss_flags |= SS_ONSTACK; + else + td->td_sigstk.ss_flags &= ~SS_ONSTACK; +#endif + + kern_sigprocmask(td, SIG_SETMASK, &ucp->uc_sigmask, NULL, 0); + return (EJUSTRETURN); +} + +/* + * Reset the hardware debug registers if they were in use. + * They won't have any meaning for the newly exec'd process. + */ +void +x86_clear_dbregs(struct pcb *pcb) +{ + if ((pcb->pcb_flags & PCB_DBREGS) == 0) + return; + + pcb->pcb_dr0 = 0; + pcb->pcb_dr1 = 0; + pcb->pcb_dr2 = 0; + pcb->pcb_dr3 = 0; + pcb->pcb_dr6 = 0; + pcb->pcb_dr7 = 0; + + if (pcb == curpcb) { + /* + * Clear the debug registers on the running CPU, + * otherwise they will end up affecting the next + * process we switch to. + */ + reset_dbregs(); + } + pcb->pcb_flags &= ~PCB_DBREGS; +} + +#ifdef COMPAT_43 +static void +setup_priv_lcall_gate(struct proc *p) +{ + struct i386_ldt_args uap; + union descriptor desc; + u_int lcall_addr; + + bzero(&uap, sizeof(uap)); + uap.start = 0; + uap.num = 1; + lcall_addr = p->p_sysent->sv_psstrings - sz_lcall_tramp; + bzero(&desc, sizeof(desc)); + desc.sd.sd_type = SDT_MEMERA; + desc.sd.sd_dpl = SEL_UPL; + desc.sd.sd_p = 1; + desc.sd.sd_def32 = 1; + desc.sd.sd_gran = 1; + desc.sd.sd_lolimit = 0xffff; + desc.sd.sd_hilimit = 0xf; + desc.sd.sd_lobase = lcall_addr; + desc.sd.sd_hibase = lcall_addr >> 24; + i386_set_ldt(curthread, &uap, &desc); +} +#endif + +/* + * Reset registers to default values on exec. + */ +void +exec_setregs(struct thread *td, struct image_params *imgp, uintptr_t stack) +{ + struct trapframe *regs; + struct pcb *pcb; + register_t saved_eflags; + + regs = td->td_frame; + pcb = td->td_pcb; *** 1965 LINES SKIPPED *** From nobody Sat Oct 16 13:02:52 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id C9ABB180C7A4; Sat, 16 Oct 2021 13:02: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 4HWjws1ZsKz3Dwr; Sat, 16 Oct 2021 13: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 1044D1A713; Sat, 16 Oct 2021 13: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 19GD2qDV037161; Sat, 16 Oct 2021 13: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 19GD2qYF037160; Sat, 16 Oct 2021 13:02:52 GMT (envelope-from git) Date: Sat, 16 Oct 2021 13:02:52 GMT Message-Id: <202110161302.19GD2qYF037160@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: d89b4788767f - stable/13 - arm64: move signal delivery code to exec_machdep.c List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: d89b4788767f57fc07b6e7881bc6103a0ab78b7c Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=d89b4788767f57fc07b6e7881bc6103a0ab78b7c commit d89b4788767f57fc07b6e7881bc6103a0ab78b7c Author: Konstantin Belousov AuthorDate: 2021-10-04 06:55:51 +0000 Commit: Konstantin Belousov CommitDate: 2021-10-16 13:01:47 +0000 arm64: move signal delivery code to exec_machdep.c (cherry picked from commit b4ae6b166066a789641e4a579020ca6b10b40cfa) --- sys/arm64/arm64/exec_machdep.c | 617 +++++++++++++++++++++++++++++++++++++++ sys/arm64/arm64/machdep.c | 588 ------------------------------------- sys/arm64/arm64/ptrace_machdep.c | 74 +++++ sys/conf/files.arm64 | 2 + 4 files changed, 693 insertions(+), 588 deletions(-) diff --git a/sys/arm64/arm64/exec_machdep.c b/sys/arm64/arm64/exec_machdep.c new file mode 100644 index 000000000000..cfc288e2b5aa --- /dev/null +++ b/sys/arm64/arm64/exec_machdep.c @@ -0,0 +1,617 @@ +/*- + * Copyright (c) 2014 Andrew Turner + * 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include +#include + +#ifdef VFP +#include +#endif + +static void get_fpcontext(struct thread *td, mcontext_t *mcp); +static void set_fpcontext(struct thread *td, mcontext_t *mcp); + +int +fill_regs(struct thread *td, struct reg *regs) +{ + struct trapframe *frame; + + frame = td->td_frame; + regs->sp = frame->tf_sp; + regs->lr = frame->tf_lr; + regs->elr = frame->tf_elr; + regs->spsr = frame->tf_spsr; + + memcpy(regs->x, frame->tf_x, sizeof(regs->x)); + +#ifdef COMPAT_FREEBSD32 + /* + * We may be called here for a 32bits process, if we're using a + * 64bits debugger. If so, put PC and SPSR where it expects it. + */ + if (SV_PROC_FLAG(td->td_proc, SV_ILP32)) { + regs->x[15] = frame->tf_elr; + regs->x[16] = frame->tf_spsr; + } +#endif + return (0); +} + +int +set_regs(struct thread *td, struct reg *regs) +{ + struct trapframe *frame; + + frame = td->td_frame; + frame->tf_sp = regs->sp; + frame->tf_lr = regs->lr; + frame->tf_spsr &= ~PSR_FLAGS; + + memcpy(frame->tf_x, regs->x, sizeof(frame->tf_x)); + +#ifdef COMPAT_FREEBSD32 + if (SV_PROC_FLAG(td->td_proc, SV_ILP32)) { + /* + * We may be called for a 32bits process if we're using + * a 64bits debugger. If so, get PC and SPSR from where + * it put it. + */ + frame->tf_elr = regs->x[15]; + frame->tf_spsr |= regs->x[16] & PSR_FLAGS; + } else +#endif + { + frame->tf_elr = regs->elr; + frame->tf_spsr |= regs->spsr & PSR_FLAGS; + } + return (0); +} + +int +fill_fpregs(struct thread *td, struct fpreg *regs) +{ +#ifdef VFP + struct pcb *pcb; + + pcb = td->td_pcb; + if ((pcb->pcb_fpflags & PCB_FP_STARTED) != 0) { + /* + * If we have just been running VFP instructions we will + * need to save the state to memcpy it below. + */ + if (td == curthread) + vfp_save_state(td, pcb); + + KASSERT(pcb->pcb_fpusaved == &pcb->pcb_fpustate, + ("Called fill_fpregs while the kernel is using the VFP")); + memcpy(regs->fp_q, pcb->pcb_fpustate.vfp_regs, + sizeof(regs->fp_q)); + regs->fp_cr = pcb->pcb_fpustate.vfp_fpcr; + regs->fp_sr = pcb->pcb_fpustate.vfp_fpsr; + } else +#endif + memset(regs, 0, sizeof(*regs)); + return (0); +} + +int +set_fpregs(struct thread *td, struct fpreg *regs) +{ +#ifdef VFP + struct pcb *pcb; + + pcb = td->td_pcb; + KASSERT(pcb->pcb_fpusaved == &pcb->pcb_fpustate, + ("Called set_fpregs while the kernel is using the VFP")); + memcpy(pcb->pcb_fpustate.vfp_regs, regs->fp_q, sizeof(regs->fp_q)); + pcb->pcb_fpustate.vfp_fpcr = regs->fp_cr; + pcb->pcb_fpustate.vfp_fpsr = regs->fp_sr; +#endif + return (0); +} + +int +fill_dbregs(struct thread *td, struct dbreg *regs) +{ + struct debug_monitor_state *monitor; + int i; + uint8_t debug_ver, nbkpts, nwtpts; + + memset(regs, 0, sizeof(*regs)); + + extract_user_id_field(ID_AA64DFR0_EL1, ID_AA64DFR0_DebugVer_SHIFT, + &debug_ver); + extract_user_id_field(ID_AA64DFR0_EL1, ID_AA64DFR0_BRPs_SHIFT, + &nbkpts); + extract_user_id_field(ID_AA64DFR0_EL1, ID_AA64DFR0_WRPs_SHIFT, + &nwtpts); + + /* + * The BRPs field contains the number of breakpoints - 1. Armv8-A + * allows the hardware to provide 2-16 breakpoints so this won't + * overflow an 8 bit value. The same applies to the WRPs field. + */ + nbkpts++; + nwtpts++; + + regs->db_debug_ver = debug_ver; + regs->db_nbkpts = nbkpts; + regs->db_nwtpts = nwtpts; + + monitor = &td->td_pcb->pcb_dbg_regs; + if ((monitor->dbg_flags & DBGMON_ENABLED) != 0) { + for (i = 0; i < nbkpts; i++) { + regs->db_breakregs[i].dbr_addr = monitor->dbg_bvr[i]; + regs->db_breakregs[i].dbr_ctrl = monitor->dbg_bcr[i]; + } + for (i = 0; i < nwtpts; i++) { + regs->db_watchregs[i].dbw_addr = monitor->dbg_wvr[i]; + regs->db_watchregs[i].dbw_ctrl = monitor->dbg_wcr[i]; + } + } + + return (0); +} + +int +set_dbregs(struct thread *td, struct dbreg *regs) +{ + struct debug_monitor_state *monitor; + uint64_t addr; + uint32_t ctrl; + int count; + int i; + + monitor = &td->td_pcb->pcb_dbg_regs; + count = 0; + monitor->dbg_enable_count = 0; + + for (i = 0; i < DBG_BRP_MAX; i++) { + addr = regs->db_breakregs[i].dbr_addr; + ctrl = regs->db_breakregs[i].dbr_ctrl; + + /* + * Don't let the user set a breakpoint on a kernel or + * non-canonical user address. + */ + if (addr >= VM_MAXUSER_ADDRESS) + return (EINVAL); + + /* + * The lowest 2 bits are ignored, so record the effective + * address. + */ + addr = rounddown2(addr, 4); + + /* + * Some control fields are ignored, and other bits reserved. + * Only unlinked, address-matching breakpoints are supported. + * + * XXX: fields that appear unvalidated, such as BAS, have + * constrained undefined behaviour. If the user mis-programs + * these, there is no risk to the system. + */ + ctrl &= DBG_BCR_EN | DBG_BCR_PMC | DBG_BCR_BAS; + if ((ctrl & DBG_BCR_EN) != 0) { + /* Only target EL0. */ + if ((ctrl & DBG_BCR_PMC) != DBG_BCR_PMC_EL0) + return (EINVAL); + + monitor->dbg_enable_count++; + } + + monitor->dbg_bvr[i] = addr; + monitor->dbg_bcr[i] = ctrl; + } + + for (i = 0; i < DBG_WRP_MAX; i++) { + addr = regs->db_watchregs[i].dbw_addr; + ctrl = regs->db_watchregs[i].dbw_ctrl; + + /* + * Don't let the user set a watchpoint on a kernel or + * non-canonical user address. + */ + if (addr >= VM_MAXUSER_ADDRESS) + return (EINVAL); + + /* + * Some control fields are ignored, and other bits reserved. + * Only unlinked watchpoints are supported. + */ + ctrl &= DBG_WCR_EN | DBG_WCR_PAC | DBG_WCR_LSC | DBG_WCR_BAS | + DBG_WCR_MASK; + + if ((ctrl & DBG_WCR_EN) != 0) { + /* Only target EL0. */ + if ((ctrl & DBG_WCR_PAC) != DBG_WCR_PAC_EL0) + return (EINVAL); + + /* Must set at least one of the load/store bits. */ + if ((ctrl & DBG_WCR_LSC) == 0) + return (EINVAL); + + /* + * When specifying the address range with BAS, the MASK + * field must be zero. + */ + if ((ctrl & DBG_WCR_BAS) != DBG_WCR_BAS_MASK && + (ctrl & DBG_WCR_MASK) != 0) + return (EINVAL); + + monitor->dbg_enable_count++; + } + monitor->dbg_wvr[i] = addr; + monitor->dbg_wcr[i] = ctrl; + } + + if (monitor->dbg_enable_count > 0) + monitor->dbg_flags |= DBGMON_ENABLED; + + return (0); +} + +#ifdef COMPAT_FREEBSD32 +int +fill_regs32(struct thread *td, struct reg32 *regs) +{ + int i; + struct trapframe *tf; + + tf = td->td_frame; + for (i = 0; i < 13; i++) + regs->r[i] = tf->tf_x[i]; + /* For arm32, SP is r13 and LR is r14 */ + regs->r_sp = tf->tf_x[13]; + regs->r_lr = tf->tf_x[14]; + regs->r_pc = tf->tf_elr; + regs->r_cpsr = tf->tf_spsr; + + return (0); +} + +int +set_regs32(struct thread *td, struct reg32 *regs) +{ + int i; + struct trapframe *tf; + + tf = td->td_frame; + for (i = 0; i < 13; i++) + tf->tf_x[i] = regs->r[i]; + /* For arm 32, SP is r13 an LR is r14 */ + tf->tf_x[13] = regs->r_sp; + tf->tf_x[14] = regs->r_lr; + tf->tf_elr = regs->r_pc; + tf->tf_spsr &= ~PSR_FLAGS; + tf->tf_spsr |= regs->r_cpsr & PSR_FLAGS; + + return (0); +} + +/* XXX fill/set dbregs/fpregs are stubbed on 32-bit arm. */ +int +fill_fpregs32(struct thread *td, struct fpreg32 *regs) +{ + + memset(regs, 0, sizeof(*regs)); + return (0); +} + +int +set_fpregs32(struct thread *td, struct fpreg32 *regs) +{ + + return (0); +} + +int +fill_dbregs32(struct thread *td, struct dbreg32 *regs) +{ + + memset(regs, 0, sizeof(*regs)); + return (0); +} + +int +set_dbregs32(struct thread *td, struct dbreg32 *regs) +{ + + return (0); +} +#endif + +void +exec_setregs(struct thread *td, struct image_params *imgp, uintptr_t stack) +{ + struct trapframe *tf = td->td_frame; + struct pcb *pcb = td->td_pcb; + + memset(tf, 0, sizeof(struct trapframe)); + + tf->tf_x[0] = stack; + tf->tf_sp = STACKALIGN(stack); + tf->tf_lr = imgp->entry_addr; + tf->tf_elr = imgp->entry_addr; + + td->td_pcb->pcb_tpidr_el0 = 0; + td->td_pcb->pcb_tpidrro_el0 = 0; + WRITE_SPECIALREG(tpidrro_el0, 0); + WRITE_SPECIALREG(tpidr_el0, 0); + +#ifdef VFP + vfp_reset_state(td, pcb); +#endif + + /* + * Clear debug register state. It is not applicable to the new process. + */ + bzero(&pcb->pcb_dbg_regs, sizeof(pcb->pcb_dbg_regs)); +} + +/* Sanity check these are the same size, they will be memcpy'd to and from */ +CTASSERT(sizeof(((struct trapframe *)0)->tf_x) == + sizeof((struct gpregs *)0)->gp_x); +CTASSERT(sizeof(((struct trapframe *)0)->tf_x) == + sizeof((struct reg *)0)->x); + +int +get_mcontext(struct thread *td, mcontext_t *mcp, int clear_ret) +{ + struct trapframe *tf = td->td_frame; + + if (clear_ret & GET_MC_CLEAR_RET) { + mcp->mc_gpregs.gp_x[0] = 0; + mcp->mc_gpregs.gp_spsr = tf->tf_spsr & ~PSR_C; + } else { + mcp->mc_gpregs.gp_x[0] = tf->tf_x[0]; + mcp->mc_gpregs.gp_spsr = tf->tf_spsr; + } + + memcpy(&mcp->mc_gpregs.gp_x[1], &tf->tf_x[1], + sizeof(mcp->mc_gpregs.gp_x[1]) * (nitems(mcp->mc_gpregs.gp_x) - 1)); + + mcp->mc_gpregs.gp_sp = tf->tf_sp; + mcp->mc_gpregs.gp_lr = tf->tf_lr; + mcp->mc_gpregs.gp_elr = tf->tf_elr; + get_fpcontext(td, mcp); + + return (0); +} + +int +set_mcontext(struct thread *td, mcontext_t *mcp) +{ + struct trapframe *tf = td->td_frame; + uint32_t spsr; + + spsr = mcp->mc_gpregs.gp_spsr; + if ((spsr & PSR_M_MASK) != PSR_M_EL0t || + (spsr & PSR_AARCH32) != 0 || + (spsr & PSR_DAIF) != (td->td_frame->tf_spsr & PSR_DAIF)) + return (EINVAL); + + memcpy(tf->tf_x, mcp->mc_gpregs.gp_x, sizeof(tf->tf_x)); + + tf->tf_sp = mcp->mc_gpregs.gp_sp; + tf->tf_lr = mcp->mc_gpregs.gp_lr; + tf->tf_elr = mcp->mc_gpregs.gp_elr; + tf->tf_spsr = mcp->mc_gpregs.gp_spsr; + set_fpcontext(td, mcp); + + return (0); +} + +static void +get_fpcontext(struct thread *td, mcontext_t *mcp) +{ +#ifdef VFP + struct pcb *curpcb; + + critical_enter(); + + curpcb = curthread->td_pcb; + + if ((curpcb->pcb_fpflags & PCB_FP_STARTED) != 0) { + /* + * If we have just been running VFP instructions we will + * need to save the state to memcpy it below. + */ + vfp_save_state(td, curpcb); + + KASSERT(curpcb->pcb_fpusaved == &curpcb->pcb_fpustate, + ("Called get_fpcontext while the kernel is using the VFP")); + KASSERT((curpcb->pcb_fpflags & ~PCB_FP_USERMASK) == 0, + ("Non-userspace FPU flags set in get_fpcontext")); + memcpy(mcp->mc_fpregs.fp_q, curpcb->pcb_fpustate.vfp_regs, + sizeof(mcp->mc_fpregs.fp_q)); + mcp->mc_fpregs.fp_cr = curpcb->pcb_fpustate.vfp_fpcr; + mcp->mc_fpregs.fp_sr = curpcb->pcb_fpustate.vfp_fpsr; + mcp->mc_fpregs.fp_flags = curpcb->pcb_fpflags; + mcp->mc_flags |= _MC_FP_VALID; + } + + critical_exit(); +#endif +} + +static void +set_fpcontext(struct thread *td, mcontext_t *mcp) +{ +#ifdef VFP + struct pcb *curpcb; + + critical_enter(); + + if ((mcp->mc_flags & _MC_FP_VALID) != 0) { + curpcb = curthread->td_pcb; + + /* + * Discard any vfp state for the current thread, we + * are about to override it. + */ + vfp_discard(td); + + KASSERT(curpcb->pcb_fpusaved == &curpcb->pcb_fpustate, + ("Called set_fpcontext while the kernel is using the VFP")); + memcpy(curpcb->pcb_fpustate.vfp_regs, mcp->mc_fpregs.fp_q, + sizeof(mcp->mc_fpregs.fp_q)); + curpcb->pcb_fpustate.vfp_fpcr = mcp->mc_fpregs.fp_cr; + curpcb->pcb_fpustate.vfp_fpsr = mcp->mc_fpregs.fp_sr; + curpcb->pcb_fpflags = mcp->mc_fpregs.fp_flags & PCB_FP_USERMASK; + } + + critical_exit(); +#endif +} + +int +sys_sigreturn(struct thread *td, struct sigreturn_args *uap) +{ + ucontext_t uc; + int error; + + if (copyin(uap->sigcntxp, &uc, sizeof(uc))) + return (EFAULT); + + error = set_mcontext(td, &uc.uc_mcontext); + if (error != 0) + return (error); + + /* Restore signal mask. */ + kern_sigprocmask(td, SIG_SETMASK, &uc.uc_sigmask, NULL, 0); + + return (EJUSTRETURN); +} + +void +sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask) +{ + struct thread *td; + struct proc *p; + struct trapframe *tf; + struct sigframe *fp, frame; + struct sigacts *psp; + struct sysentvec *sysent; + int onstack, sig; + + td = curthread; + p = td->td_proc; + PROC_LOCK_ASSERT(p, MA_OWNED); + + sig = ksi->ksi_signo; + psp = p->p_sigacts; + mtx_assert(&psp->ps_mtx, MA_OWNED); + + tf = td->td_frame; + onstack = sigonstack(tf->tf_sp); + + CTR4(KTR_SIG, "sendsig: td=%p (%s) catcher=%p sig=%d", td, p->p_comm, + catcher, sig); + + /* Allocate and validate space for the signal handler context. */ + if ((td->td_pflags & TDP_ALTSTACK) != 0 && !onstack && + SIGISMEMBER(psp->ps_sigonstack, sig)) { + fp = (struct sigframe *)((uintptr_t)td->td_sigstk.ss_sp + + td->td_sigstk.ss_size); +#if defined(COMPAT_43) + td->td_sigstk.ss_flags |= SS_ONSTACK; +#endif + } else { + fp = (struct sigframe *)td->td_frame->tf_sp; + } + + /* Make room, keeping the stack aligned */ + fp--; + fp = (struct sigframe *)STACKALIGN(fp); + + /* Fill in the frame to copy out */ + bzero(&frame, sizeof(frame)); + get_mcontext(td, &frame.sf_uc.uc_mcontext, 0); + frame.sf_si = ksi->ksi_info; + frame.sf_uc.uc_sigmask = *mask; + frame.sf_uc.uc_stack = td->td_sigstk; + frame.sf_uc.uc_stack.ss_flags = (td->td_pflags & TDP_ALTSTACK) != 0 ? + (onstack ? SS_ONSTACK : 0) : SS_DISABLE; + mtx_unlock(&psp->ps_mtx); + PROC_UNLOCK(td->td_proc); + + /* Copy the sigframe out to the user's stack. */ + if (copyout(&frame, fp, sizeof(*fp)) != 0) { + /* Process has trashed its stack. Kill it. */ + CTR2(KTR_SIG, "sendsig: sigexit td=%p fp=%p", td, fp); + PROC_LOCK(p); + sigexit(td, SIGILL); + } + + tf->tf_x[0]= sig; + tf->tf_x[1] = (register_t)&fp->sf_si; + tf->tf_x[2] = (register_t)&fp->sf_uc; + + tf->tf_elr = (register_t)catcher; + tf->tf_sp = (register_t)fp; + sysent = p->p_sysent; + if (sysent->sv_sigcode_base != 0) + tf->tf_lr = (register_t)sysent->sv_sigcode_base; + else + tf->tf_lr = (register_t)(sysent->sv_psstrings - + *(sysent->sv_szsigcode)); + + CTR3(KTR_SIG, "sendsig: return td=%p pc=%#x sp=%#x", td, tf->tf_elr, + tf->tf_sp); + + PROC_LOCK(p); + mtx_lock(&psp->ps_mtx); +} diff --git a/sys/arm64/arm64/machdep.c b/sys/arm64/arm64/machdep.c index eedde49e5de9..529b17772d17 100644 --- a/sys/arm64/arm64/machdep.c +++ b/sys/arm64/arm64/machdep.c @@ -100,9 +100,6 @@ __FBSDID("$FreeBSD$"); #include #endif -static void get_fpcontext(struct thread *td, mcontext_t *mcp); -static void set_fpcontext(struct thread *td, mcontext_t *mcp); - enum arm64_bus arm64_bus_method = ARM64_BUS_NONE; struct pcpu __pcpu[MAXCPU]; @@ -220,486 +217,6 @@ cpu_idle_wakeup(int cpu) return (0); } -int -fill_regs(struct thread *td, struct reg *regs) -{ - struct trapframe *frame; - - frame = td->td_frame; - regs->sp = frame->tf_sp; - regs->lr = frame->tf_lr; - regs->elr = frame->tf_elr; - regs->spsr = frame->tf_spsr; - - memcpy(regs->x, frame->tf_x, sizeof(regs->x)); - -#ifdef COMPAT_FREEBSD32 - /* - * We may be called here for a 32bits process, if we're using a - * 64bits debugger. If so, put PC and SPSR where it expects it. - */ - if (SV_PROC_FLAG(td->td_proc, SV_ILP32)) { - regs->x[15] = frame->tf_elr; - regs->x[16] = frame->tf_spsr; - } -#endif - return (0); -} - -int -set_regs(struct thread *td, struct reg *regs) -{ - struct trapframe *frame; - - frame = td->td_frame; - frame->tf_sp = regs->sp; - frame->tf_lr = regs->lr; - frame->tf_spsr &= ~PSR_FLAGS; - - memcpy(frame->tf_x, regs->x, sizeof(frame->tf_x)); - -#ifdef COMPAT_FREEBSD32 - if (SV_PROC_FLAG(td->td_proc, SV_ILP32)) { - /* - * We may be called for a 32bits process if we're using - * a 64bits debugger. If so, get PC and SPSR from where - * it put it. - */ - frame->tf_elr = regs->x[15]; - frame->tf_spsr |= regs->x[16] & PSR_FLAGS; - } else -#endif - { - frame->tf_elr = regs->elr; - frame->tf_spsr |= regs->spsr & PSR_FLAGS; - } - return (0); -} - -int -fill_fpregs(struct thread *td, struct fpreg *regs) -{ -#ifdef VFP - struct pcb *pcb; - - pcb = td->td_pcb; - if ((pcb->pcb_fpflags & PCB_FP_STARTED) != 0) { - /* - * If we have just been running VFP instructions we will - * need to save the state to memcpy it below. - */ - if (td == curthread) - vfp_save_state(td, pcb); - - KASSERT(pcb->pcb_fpusaved == &pcb->pcb_fpustate, - ("Called fill_fpregs while the kernel is using the VFP")); - memcpy(regs->fp_q, pcb->pcb_fpustate.vfp_regs, - sizeof(regs->fp_q)); - regs->fp_cr = pcb->pcb_fpustate.vfp_fpcr; - regs->fp_sr = pcb->pcb_fpustate.vfp_fpsr; - } else -#endif - memset(regs, 0, sizeof(*regs)); - return (0); -} - -int -set_fpregs(struct thread *td, struct fpreg *regs) -{ -#ifdef VFP - struct pcb *pcb; - - pcb = td->td_pcb; - KASSERT(pcb->pcb_fpusaved == &pcb->pcb_fpustate, - ("Called set_fpregs while the kernel is using the VFP")); - memcpy(pcb->pcb_fpustate.vfp_regs, regs->fp_q, sizeof(regs->fp_q)); - pcb->pcb_fpustate.vfp_fpcr = regs->fp_cr; - pcb->pcb_fpustate.vfp_fpsr = regs->fp_sr; -#endif - return (0); -} - -int -fill_dbregs(struct thread *td, struct dbreg *regs) -{ - struct debug_monitor_state *monitor; - int i; - uint8_t debug_ver, nbkpts, nwtpts; - - memset(regs, 0, sizeof(*regs)); - - extract_user_id_field(ID_AA64DFR0_EL1, ID_AA64DFR0_DebugVer_SHIFT, - &debug_ver); - extract_user_id_field(ID_AA64DFR0_EL1, ID_AA64DFR0_BRPs_SHIFT, - &nbkpts); - extract_user_id_field(ID_AA64DFR0_EL1, ID_AA64DFR0_WRPs_SHIFT, - &nwtpts); - - /* - * The BRPs field contains the number of breakpoints - 1. Armv8-A - * allows the hardware to provide 2-16 breakpoints so this won't - * overflow an 8 bit value. The same applies to the WRPs field. - */ - nbkpts++; - nwtpts++; - - regs->db_debug_ver = debug_ver; - regs->db_nbkpts = nbkpts; - regs->db_nwtpts = nwtpts; - - monitor = &td->td_pcb->pcb_dbg_regs; - if ((monitor->dbg_flags & DBGMON_ENABLED) != 0) { - for (i = 0; i < nbkpts; i++) { - regs->db_breakregs[i].dbr_addr = monitor->dbg_bvr[i]; - regs->db_breakregs[i].dbr_ctrl = monitor->dbg_bcr[i]; - } - for (i = 0; i < nwtpts; i++) { - regs->db_watchregs[i].dbw_addr = monitor->dbg_wvr[i]; - regs->db_watchregs[i].dbw_ctrl = monitor->dbg_wcr[i]; - } - } - - return (0); -} - -int -set_dbregs(struct thread *td, struct dbreg *regs) -{ - struct debug_monitor_state *monitor; - uint64_t addr; - uint32_t ctrl; - int count; - int i; - - monitor = &td->td_pcb->pcb_dbg_regs; - count = 0; - monitor->dbg_enable_count = 0; - - for (i = 0; i < DBG_BRP_MAX; i++) { - addr = regs->db_breakregs[i].dbr_addr; - ctrl = regs->db_breakregs[i].dbr_ctrl; - - /* - * Don't let the user set a breakpoint on a kernel or - * non-canonical user address. - */ - if (addr >= VM_MAXUSER_ADDRESS) - return (EINVAL); - - /* - * The lowest 2 bits are ignored, so record the effective - * address. - */ - addr = rounddown2(addr, 4); - - /* - * Some control fields are ignored, and other bits reserved. - * Only unlinked, address-matching breakpoints are supported. - * - * XXX: fields that appear unvalidated, such as BAS, have - * constrained undefined behaviour. If the user mis-programs - * these, there is no risk to the system. - */ - ctrl &= DBG_BCR_EN | DBG_BCR_PMC | DBG_BCR_BAS; - if ((ctrl & DBG_BCR_EN) != 0) { - /* Only target EL0. */ - if ((ctrl & DBG_BCR_PMC) != DBG_BCR_PMC_EL0) - return (EINVAL); - - monitor->dbg_enable_count++; - } - - monitor->dbg_bvr[i] = addr; - monitor->dbg_bcr[i] = ctrl; - } - - for (i = 0; i < DBG_WRP_MAX; i++) { - addr = regs->db_watchregs[i].dbw_addr; - ctrl = regs->db_watchregs[i].dbw_ctrl; - - /* - * Don't let the user set a watchpoint on a kernel or - * non-canonical user address. - */ - if (addr >= VM_MAXUSER_ADDRESS) - return (EINVAL); - - /* - * Some control fields are ignored, and other bits reserved. - * Only unlinked watchpoints are supported. - */ - ctrl &= DBG_WCR_EN | DBG_WCR_PAC | DBG_WCR_LSC | DBG_WCR_BAS | - DBG_WCR_MASK; - - if ((ctrl & DBG_WCR_EN) != 0) { - /* Only target EL0. */ - if ((ctrl & DBG_WCR_PAC) != DBG_WCR_PAC_EL0) - return (EINVAL); - - /* Must set at least one of the load/store bits. */ - if ((ctrl & DBG_WCR_LSC) == 0) - return (EINVAL); - - /* - * When specifying the address range with BAS, the MASK - * field must be zero. - */ - if ((ctrl & DBG_WCR_BAS) != DBG_WCR_BAS_MASK && - (ctrl & DBG_WCR_MASK) != 0) - return (EINVAL); - - monitor->dbg_enable_count++; - } - monitor->dbg_wvr[i] = addr; - monitor->dbg_wcr[i] = ctrl; - } - - if (monitor->dbg_enable_count > 0) - monitor->dbg_flags |= DBGMON_ENABLED; - - return (0); -} - -#ifdef COMPAT_FREEBSD32 -int -fill_regs32(struct thread *td, struct reg32 *regs) -{ - int i; - struct trapframe *tf; - - tf = td->td_frame; - for (i = 0; i < 13; i++) - regs->r[i] = tf->tf_x[i]; - /* For arm32, SP is r13 and LR is r14 */ - regs->r_sp = tf->tf_x[13]; - regs->r_lr = tf->tf_x[14]; - regs->r_pc = tf->tf_elr; - regs->r_cpsr = tf->tf_spsr; - - return (0); -} - -int -set_regs32(struct thread *td, struct reg32 *regs) -{ - int i; - struct trapframe *tf; - - tf = td->td_frame; - for (i = 0; i < 13; i++) - tf->tf_x[i] = regs->r[i]; - /* For arm 32, SP is r13 an LR is r14 */ - tf->tf_x[13] = regs->r_sp; - tf->tf_x[14] = regs->r_lr; - tf->tf_elr = regs->r_pc; - tf->tf_spsr &= ~PSR_FLAGS; - tf->tf_spsr |= regs->r_cpsr & PSR_FLAGS; - - return (0); -} - -/* XXX fill/set dbregs/fpregs are stubbed on 32-bit arm. */ -int -fill_fpregs32(struct thread *td, struct fpreg32 *regs) -{ - - memset(regs, 0, sizeof(*regs)); - return (0); -} - -int -set_fpregs32(struct thread *td, struct fpreg32 *regs) -{ - - return (0); -} - -int -fill_dbregs32(struct thread *td, struct dbreg32 *regs) -{ - - memset(regs, 0, sizeof(*regs)); - return (0); -} - -int -set_dbregs32(struct thread *td, struct dbreg32 *regs) -{ - - return (0); -} -#endif - -int -ptrace_set_pc(struct thread *td, u_long addr) -{ - - td->td_frame->tf_elr = addr; - return (0); -} - -int -ptrace_single_step(struct thread *td) -{ - - td->td_frame->tf_spsr |= PSR_SS; - td->td_pcb->pcb_flags |= PCB_SINGLE_STEP; - return (0); -} *** 376 LINES SKIPPED *** From nobody Sat Oct 16 13:02:54 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 0EA53180C677; Sat, 16 Oct 2021 13: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 4HWjwt4Ycjz3DpJ; Sat, 16 Oct 2021 13:02: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 28B9D1A788; Sat, 16 Oct 2021 13: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 19GD2sAm037185; Sat, 16 Oct 2021 13: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 19GD2sVW037184; Sat, 16 Oct 2021 13:02:54 GMT (envelope-from git) Date: Sat, 16 Oct 2021 13:02:54 GMT Message-Id: <202110161302.19GD2sVW037184@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: 6a54fd55de06 - stable/13 - arm: move signal delivery code to exec_machdep.c List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 6a54fd55de060fbde2cff17188c2a926f542d745 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=6a54fd55de060fbde2cff17188c2a926f542d745 commit 6a54fd55de060fbde2cff17188c2a926f542d745 Author: Konstantin Belousov AuthorDate: 2021-10-04 11:39:11 +0000 Commit: Konstantin Belousov CommitDate: 2021-10-16 13:01:48 +0000 arm: move signal delivery code to exec_machdep.c (cherry picked from commit dfaf65023ef0d9f68da856f3795448596751a69d) --- sys/arm/arm/exec_machdep.c | 379 +++++++++++++++++++++++++++++++++++++++++++++ sys/arm/arm/machdep.c | 322 -------------------------------------- sys/conf/files.arm | 1 + 3 files changed, 380 insertions(+), 322 deletions(-) diff --git a/sys/arm/arm/exec_machdep.c b/sys/arm/arm/exec_machdep.c new file mode 100644 index 000000000000..3b952463b1ad --- /dev/null +++ b/sys/arm/arm/exec_machdep.c @@ -0,0 +1,379 @@ +/* $NetBSD: arm32_machdep.c,v 1.44 2004/03/24 15:34:47 atatat Exp $ */ + +/*- + * SPDX-License-Identifier: BSD-4-Clause + * + * Copyright (c) 2004 Olivier Houchard + * Copyright (c) 1994-1998 Mark Brinicombe. + * Copyright (c) 1994 Brini. + * All rights reserved. + * + * This code is derived from software written for Brini by Mark Brinicombe + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Mark Brinicombe + * for the NetBSD Project. + * 4. The name of the company nor the name of the author may be used to + * endorse or promote products derived from this software without specific + * prior written permission. + * + * 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 OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +/* + * Clear registers on exec + */ +void +exec_setregs(struct thread *td, struct image_params *imgp, uintptr_t stack) +{ + struct trapframe *tf = td->td_frame; + + memset(tf, 0, sizeof(*tf)); + tf->tf_usr_sp = stack; + tf->tf_usr_lr = imgp->entry_addr; + tf->tf_svc_lr = 0x77777777; + tf->tf_pc = imgp->entry_addr; + tf->tf_spsr = PSR_USR32_MODE; + if ((register_t)imgp->entry_addr & 1) + tf->tf_spsr |= PSR_T; +} + +#ifdef VFP +/* + * Get machine VFP context. + */ +void +get_vfpcontext(struct thread *td, mcontext_vfp_t *vfp) +{ + struct pcb *pcb; + + pcb = td->td_pcb; + if (td == curthread) { + critical_enter(); + vfp_store(&pcb->pcb_vfpstate, false); + critical_exit(); + } else + MPASS(TD_IS_SUSPENDED(td)); + memcpy(vfp->mcv_reg, pcb->pcb_vfpstate.reg, + sizeof(vfp->mcv_reg)); + vfp->mcv_fpscr = pcb->pcb_vfpstate.fpscr; +} + +/* + * Set machine VFP context. + */ +void +set_vfpcontext(struct thread *td, mcontext_vfp_t *vfp) +{ + struct pcb *pcb; + + pcb = td->td_pcb; + if (td == curthread) { + critical_enter(); + vfp_discard(td); + critical_exit(); + } else + MPASS(TD_IS_SUSPENDED(td)); + memcpy(pcb->pcb_vfpstate.reg, vfp->mcv_reg, + sizeof(pcb->pcb_vfpstate.reg)); + pcb->pcb_vfpstate.fpscr = vfp->mcv_fpscr; +} +#endif + +int +arm_get_vfpstate(struct thread *td, void *args) +{ + int rv; + struct arm_get_vfpstate_args ua; + mcontext_vfp_t mcontext_vfp; + + rv = copyin(args, &ua, sizeof(ua)); + if (rv != 0) + return (rv); + if (ua.mc_vfp_size != sizeof(mcontext_vfp_t)) + return (EINVAL); +#ifdef VFP + get_vfpcontext(td, &mcontext_vfp); +#else + bzero(&mcontext_vfp, sizeof(mcontext_vfp)); +#endif + + rv = copyout(&mcontext_vfp, ua.mc_vfp, sizeof(mcontext_vfp)); + if (rv != 0) + return (rv); + return (0); +} + +/* + * Get machine context. + */ +int +get_mcontext(struct thread *td, mcontext_t *mcp, int clear_ret) +{ + struct trapframe *tf = td->td_frame; + __greg_t *gr = mcp->__gregs; + + if (clear_ret & GET_MC_CLEAR_RET) { + gr[_REG_R0] = 0; + gr[_REG_CPSR] = tf->tf_spsr & ~PSR_C; + } else { + gr[_REG_R0] = tf->tf_r0; + gr[_REG_CPSR] = tf->tf_spsr; + } + gr[_REG_R1] = tf->tf_r1; + gr[_REG_R2] = tf->tf_r2; + gr[_REG_R3] = tf->tf_r3; + gr[_REG_R4] = tf->tf_r4; + gr[_REG_R5] = tf->tf_r5; + gr[_REG_R6] = tf->tf_r6; + gr[_REG_R7] = tf->tf_r7; + gr[_REG_R8] = tf->tf_r8; + gr[_REG_R9] = tf->tf_r9; + gr[_REG_R10] = tf->tf_r10; + gr[_REG_R11] = tf->tf_r11; + gr[_REG_R12] = tf->tf_r12; + gr[_REG_SP] = tf->tf_usr_sp; + gr[_REG_LR] = tf->tf_usr_lr; + gr[_REG_PC] = tf->tf_pc; + + mcp->mc_vfp_size = 0; + mcp->mc_vfp_ptr = NULL; + memset(&mcp->mc_spare, 0, sizeof(mcp->mc_spare)); + + return (0); +} + +/* + * Set machine context. + * + * However, we don't set any but the user modifiable flags, and we won't + * touch the cs selector. + */ +int +set_mcontext(struct thread *td, mcontext_t *mcp) +{ + mcontext_vfp_t mc_vfp, *vfp; + struct trapframe *tf = td->td_frame; + const __greg_t *gr = mcp->__gregs; + int spsr; + + /* + * Make sure the processor mode has not been tampered with and + * interrupts have not been disabled. + */ + spsr = gr[_REG_CPSR]; + if ((spsr & PSR_MODE) != PSR_USR32_MODE || + (spsr & (PSR_I | PSR_F)) != 0) + return (EINVAL); + +#ifdef WITNESS + if (mcp->mc_vfp_size != 0 && mcp->mc_vfp_size != sizeof(mc_vfp)) { + printf("%s: %s: Malformed mc_vfp_size: %d (0x%08X)\n", + td->td_proc->p_comm, __func__, + mcp->mc_vfp_size, mcp->mc_vfp_size); + } else if (mcp->mc_vfp_size != 0 && mcp->mc_vfp_ptr == NULL) { + printf("%s: %s: c_vfp_size != 0 but mc_vfp_ptr == NULL\n", + td->td_proc->p_comm, __func__); + } +#endif + + if (mcp->mc_vfp_size == sizeof(mc_vfp) && mcp->mc_vfp_ptr != NULL) { + if (copyin(mcp->mc_vfp_ptr, &mc_vfp, sizeof(mc_vfp)) != 0) + return (EFAULT); + vfp = &mc_vfp; + } else { + vfp = NULL; + } + + tf->tf_r0 = gr[_REG_R0]; + tf->tf_r1 = gr[_REG_R1]; + tf->tf_r2 = gr[_REG_R2]; + tf->tf_r3 = gr[_REG_R3]; + tf->tf_r4 = gr[_REG_R4]; + tf->tf_r5 = gr[_REG_R5]; + tf->tf_r6 = gr[_REG_R6]; + tf->tf_r7 = gr[_REG_R7]; + tf->tf_r8 = gr[_REG_R8]; + tf->tf_r9 = gr[_REG_R9]; + tf->tf_r10 = gr[_REG_R10]; + tf->tf_r11 = gr[_REG_R11]; + tf->tf_r12 = gr[_REG_R12]; + tf->tf_usr_sp = gr[_REG_SP]; + tf->tf_usr_lr = gr[_REG_LR]; + tf->tf_pc = gr[_REG_PC]; + tf->tf_spsr = gr[_REG_CPSR]; +#ifdef VFP + if (vfp != NULL) + set_vfpcontext(td, vfp); +#endif + return (0); +} + +void +sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask) +{ + struct thread *td; + struct proc *p; + struct trapframe *tf; + struct sigframe *fp, frame; + struct sigacts *psp; + struct sysentvec *sysent; + int onstack; + int sig; + int code; + + td = curthread; + p = td->td_proc; + PROC_LOCK_ASSERT(p, MA_OWNED); + sig = ksi->ksi_signo; + code = ksi->ksi_code; + psp = p->p_sigacts; + mtx_assert(&psp->ps_mtx, MA_OWNED); + tf = td->td_frame; + onstack = sigonstack(tf->tf_usr_sp); + + CTR4(KTR_SIG, "sendsig: td=%p (%s) catcher=%p sig=%d", td, p->p_comm, + catcher, sig); + + /* Allocate and validate space for the signal handler context. */ + if ((td->td_pflags & TDP_ALTSTACK) != 0 && !(onstack) && + SIGISMEMBER(psp->ps_sigonstack, sig)) { + fp = (struct sigframe *)((uintptr_t)td->td_sigstk.ss_sp + + td->td_sigstk.ss_size); +#if defined(COMPAT_43) + td->td_sigstk.ss_flags |= SS_ONSTACK; +#endif + } else + fp = (struct sigframe *)td->td_frame->tf_usr_sp; + + /* make room on the stack */ + fp--; + + /* make the stack aligned */ + fp = (struct sigframe *)STACKALIGN(fp); + /* Populate the siginfo frame. */ + bzero(&frame, sizeof(frame)); + get_mcontext(td, &frame.sf_uc.uc_mcontext, 0); +#ifdef VFP + get_vfpcontext(td, &frame.sf_vfp); + frame.sf_uc.uc_mcontext.mc_vfp_size = sizeof(fp->sf_vfp); + frame.sf_uc.uc_mcontext.mc_vfp_ptr = &fp->sf_vfp; +#else + frame.sf_uc.uc_mcontext.mc_vfp_size = 0; + frame.sf_uc.uc_mcontext.mc_vfp_ptr = NULL; +#endif + frame.sf_si = ksi->ksi_info; + frame.sf_uc.uc_sigmask = *mask; + frame.sf_uc.uc_stack = td->td_sigstk; + frame.sf_uc.uc_stack.ss_flags = (td->td_pflags & TDP_ALTSTACK) != 0 ? + (onstack ? SS_ONSTACK : 0) : SS_DISABLE; + mtx_unlock(&psp->ps_mtx); + PROC_UNLOCK(td->td_proc); + + /* Copy the sigframe out to the user's stack. */ + if (copyout(&frame, fp, sizeof(*fp)) != 0) { + /* Process has trashed its stack. Kill it. */ + CTR2(KTR_SIG, "sendsig: sigexit td=%p fp=%p", td, fp); + PROC_LOCK(p); + sigexit(td, SIGILL); + } + + /* + * Build context to run handler in. We invoke the handler + * directly, only returning via the trampoline. Note the + * trampoline version numbers are coordinated with machine- + * dependent code in libc. + */ + + tf->tf_r0 = sig; + tf->tf_r1 = (register_t)&fp->sf_si; + tf->tf_r2 = (register_t)&fp->sf_uc; + + /* the trampoline uses r5 as the uc address */ + tf->tf_r5 = (register_t)&fp->sf_uc; + tf->tf_pc = (register_t)catcher; + tf->tf_usr_sp = (register_t)fp; + sysent = p->p_sysent; + if (sysent->sv_sigcode_base != 0) + tf->tf_usr_lr = (register_t)sysent->sv_sigcode_base; + else + tf->tf_usr_lr = (register_t)(sysent->sv_psstrings - + *(sysent->sv_szsigcode)); + /* Set the mode to enter in the signal handler */ +#if __ARM_ARCH >= 7 + if ((register_t)catcher & 1) + tf->tf_spsr |= PSR_T; + else + tf->tf_spsr &= ~PSR_T; +#endif + + CTR3(KTR_SIG, "sendsig: return td=%p pc=%#x sp=%#x", td, tf->tf_usr_lr, + tf->tf_usr_sp); + + PROC_LOCK(p); + mtx_lock(&psp->ps_mtx); +} + +int +sys_sigreturn(struct thread *td, struct sigreturn_args *uap) +{ + ucontext_t uc; + int error; + + if (uap == NULL) + return (EFAULT); + if (copyin(uap->sigcntxp, &uc, sizeof(uc))) + return (EFAULT); + /* Restore register context. */ + error = set_mcontext(td, &uc.uc_mcontext); + if (error != 0) + return (error); + + /* Restore signal mask. */ + kern_sigprocmask(td, SIG_SETMASK, &uc.uc_sigmask, NULL, 0); + + return (EJUSTRETURN); +} diff --git a/sys/arm/arm/machdep.c b/sys/arm/arm/machdep.c index ea5b5a0de251..c2e5a29bd244 100644 --- a/sys/arm/arm/machdep.c +++ b/sys/arm/arm/machdep.c @@ -337,328 +337,6 @@ spinlock_exit(void) } } -/* - * Clear registers on exec - */ -void -exec_setregs(struct thread *td, struct image_params *imgp, uintptr_t stack) -{ - struct trapframe *tf = td->td_frame; - - memset(tf, 0, sizeof(*tf)); - tf->tf_usr_sp = stack; - tf->tf_usr_lr = imgp->entry_addr; - tf->tf_svc_lr = 0x77777777; - tf->tf_pc = imgp->entry_addr; - tf->tf_spsr = PSR_USR32_MODE; - if ((register_t)imgp->entry_addr & 1) - tf->tf_spsr |= PSR_T; -} - -#ifdef VFP -/* - * Get machine VFP context. - */ -void -get_vfpcontext(struct thread *td, mcontext_vfp_t *vfp) -{ - struct pcb *pcb; - - pcb = td->td_pcb; - if (td == curthread) { - critical_enter(); - vfp_store(&pcb->pcb_vfpstate, false); - critical_exit(); - } else - MPASS(TD_IS_SUSPENDED(td)); - memcpy(vfp->mcv_reg, pcb->pcb_vfpstate.reg, - sizeof(vfp->mcv_reg)); - vfp->mcv_fpscr = pcb->pcb_vfpstate.fpscr; -} - -/* - * Set machine VFP context. - */ -void -set_vfpcontext(struct thread *td, mcontext_vfp_t *vfp) -{ - struct pcb *pcb; - - pcb = td->td_pcb; - if (td == curthread) { - critical_enter(); - vfp_discard(td); - critical_exit(); - } else - MPASS(TD_IS_SUSPENDED(td)); - memcpy(pcb->pcb_vfpstate.reg, vfp->mcv_reg, - sizeof(pcb->pcb_vfpstate.reg)); - pcb->pcb_vfpstate.fpscr = vfp->mcv_fpscr; -} -#endif - -int -arm_get_vfpstate(struct thread *td, void *args) -{ - int rv; - struct arm_get_vfpstate_args ua; - mcontext_vfp_t mcontext_vfp; - - rv = copyin(args, &ua, sizeof(ua)); - if (rv != 0) - return (rv); - if (ua.mc_vfp_size != sizeof(mcontext_vfp_t)) - return (EINVAL); -#ifdef VFP - get_vfpcontext(td, &mcontext_vfp); -#else - bzero(&mcontext_vfp, sizeof(mcontext_vfp)); -#endif - - rv = copyout(&mcontext_vfp, ua.mc_vfp, sizeof(mcontext_vfp)); - if (rv != 0) - return (rv); - return (0); -} - -/* - * Get machine context. - */ -int -get_mcontext(struct thread *td, mcontext_t *mcp, int clear_ret) -{ - struct trapframe *tf = td->td_frame; - __greg_t *gr = mcp->__gregs; - - if (clear_ret & GET_MC_CLEAR_RET) { - gr[_REG_R0] = 0; - gr[_REG_CPSR] = tf->tf_spsr & ~PSR_C; - } else { - gr[_REG_R0] = tf->tf_r0; - gr[_REG_CPSR] = tf->tf_spsr; - } - gr[_REG_R1] = tf->tf_r1; - gr[_REG_R2] = tf->tf_r2; - gr[_REG_R3] = tf->tf_r3; - gr[_REG_R4] = tf->tf_r4; - gr[_REG_R5] = tf->tf_r5; - gr[_REG_R6] = tf->tf_r6; - gr[_REG_R7] = tf->tf_r7; - gr[_REG_R8] = tf->tf_r8; - gr[_REG_R9] = tf->tf_r9; - gr[_REG_R10] = tf->tf_r10; - gr[_REG_R11] = tf->tf_r11; - gr[_REG_R12] = tf->tf_r12; - gr[_REG_SP] = tf->tf_usr_sp; - gr[_REG_LR] = tf->tf_usr_lr; - gr[_REG_PC] = tf->tf_pc; - - mcp->mc_vfp_size = 0; - mcp->mc_vfp_ptr = NULL; - memset(&mcp->mc_spare, 0, sizeof(mcp->mc_spare)); - - return (0); -} - -/* - * Set machine context. - * - * However, we don't set any but the user modifiable flags, and we won't - * touch the cs selector. - */ -int -set_mcontext(struct thread *td, mcontext_t *mcp) -{ - mcontext_vfp_t mc_vfp, *vfp; - struct trapframe *tf = td->td_frame; - const __greg_t *gr = mcp->__gregs; - int spsr; - - /* - * Make sure the processor mode has not been tampered with and - * interrupts have not been disabled. - */ - spsr = gr[_REG_CPSR]; - if ((spsr & PSR_MODE) != PSR_USR32_MODE || - (spsr & (PSR_I | PSR_F)) != 0) - return (EINVAL); - -#ifdef WITNESS - if (mcp->mc_vfp_size != 0 && mcp->mc_vfp_size != sizeof(mc_vfp)) { - printf("%s: %s: Malformed mc_vfp_size: %d (0x%08X)\n", - td->td_proc->p_comm, __func__, - mcp->mc_vfp_size, mcp->mc_vfp_size); - } else if (mcp->mc_vfp_size != 0 && mcp->mc_vfp_ptr == NULL) { - printf("%s: %s: c_vfp_size != 0 but mc_vfp_ptr == NULL\n", - td->td_proc->p_comm, __func__); - } -#endif - - if (mcp->mc_vfp_size == sizeof(mc_vfp) && mcp->mc_vfp_ptr != NULL) { - if (copyin(mcp->mc_vfp_ptr, &mc_vfp, sizeof(mc_vfp)) != 0) - return (EFAULT); - vfp = &mc_vfp; - } else { - vfp = NULL; - } - - tf->tf_r0 = gr[_REG_R0]; - tf->tf_r1 = gr[_REG_R1]; - tf->tf_r2 = gr[_REG_R2]; - tf->tf_r3 = gr[_REG_R3]; - tf->tf_r4 = gr[_REG_R4]; - tf->tf_r5 = gr[_REG_R5]; - tf->tf_r6 = gr[_REG_R6]; - tf->tf_r7 = gr[_REG_R7]; - tf->tf_r8 = gr[_REG_R8]; - tf->tf_r9 = gr[_REG_R9]; - tf->tf_r10 = gr[_REG_R10]; - tf->tf_r11 = gr[_REG_R11]; - tf->tf_r12 = gr[_REG_R12]; - tf->tf_usr_sp = gr[_REG_SP]; - tf->tf_usr_lr = gr[_REG_LR]; - tf->tf_pc = gr[_REG_PC]; - tf->tf_spsr = gr[_REG_CPSR]; -#ifdef VFP - if (vfp != NULL) - set_vfpcontext(td, vfp); -#endif - return (0); -} - -void -sendsig(catcher, ksi, mask) - sig_t catcher; - ksiginfo_t *ksi; - sigset_t *mask; -{ - struct thread *td; - struct proc *p; - struct trapframe *tf; - struct sigframe *fp, frame; - struct sigacts *psp; - struct sysentvec *sysent; - int onstack; - int sig; - int code; - - td = curthread; - p = td->td_proc; - PROC_LOCK_ASSERT(p, MA_OWNED); - sig = ksi->ksi_signo; - code = ksi->ksi_code; - psp = p->p_sigacts; - mtx_assert(&psp->ps_mtx, MA_OWNED); - tf = td->td_frame; - onstack = sigonstack(tf->tf_usr_sp); - - CTR4(KTR_SIG, "sendsig: td=%p (%s) catcher=%p sig=%d", td, p->p_comm, - catcher, sig); - - /* Allocate and validate space for the signal handler context. */ - if ((td->td_pflags & TDP_ALTSTACK) != 0 && !(onstack) && - SIGISMEMBER(psp->ps_sigonstack, sig)) { - fp = (struct sigframe *)((uintptr_t)td->td_sigstk.ss_sp + - td->td_sigstk.ss_size); -#if defined(COMPAT_43) - td->td_sigstk.ss_flags |= SS_ONSTACK; -#endif - } else - fp = (struct sigframe *)td->td_frame->tf_usr_sp; - - /* make room on the stack */ - fp--; - - /* make the stack aligned */ - fp = (struct sigframe *)STACKALIGN(fp); - /* Populate the siginfo frame. */ - bzero(&frame, sizeof(frame)); - get_mcontext(td, &frame.sf_uc.uc_mcontext, 0); -#ifdef VFP - get_vfpcontext(td, &frame.sf_vfp); - frame.sf_uc.uc_mcontext.mc_vfp_size = sizeof(fp->sf_vfp); - frame.sf_uc.uc_mcontext.mc_vfp_ptr = &fp->sf_vfp; -#else - frame.sf_uc.uc_mcontext.mc_vfp_size = 0; - frame.sf_uc.uc_mcontext.mc_vfp_ptr = NULL; -#endif - frame.sf_si = ksi->ksi_info; - frame.sf_uc.uc_sigmask = *mask; - frame.sf_uc.uc_stack = td->td_sigstk; - frame.sf_uc.uc_stack.ss_flags = (td->td_pflags & TDP_ALTSTACK) != 0 ? - (onstack ? SS_ONSTACK : 0) : SS_DISABLE; - mtx_unlock(&psp->ps_mtx); - PROC_UNLOCK(td->td_proc); - - /* Copy the sigframe out to the user's stack. */ - if (copyout(&frame, fp, sizeof(*fp)) != 0) { - /* Process has trashed its stack. Kill it. */ - CTR2(KTR_SIG, "sendsig: sigexit td=%p fp=%p", td, fp); - PROC_LOCK(p); - sigexit(td, SIGILL); - } - - /* - * Build context to run handler in. We invoke the handler - * directly, only returning via the trampoline. Note the - * trampoline version numbers are coordinated with machine- - * dependent code in libc. - */ - - tf->tf_r0 = sig; - tf->tf_r1 = (register_t)&fp->sf_si; - tf->tf_r2 = (register_t)&fp->sf_uc; - - /* the trampoline uses r5 as the uc address */ - tf->tf_r5 = (register_t)&fp->sf_uc; - tf->tf_pc = (register_t)catcher; - tf->tf_usr_sp = (register_t)fp; - sysent = p->p_sysent; - if (sysent->sv_sigcode_base != 0) - tf->tf_usr_lr = (register_t)sysent->sv_sigcode_base; - else - tf->tf_usr_lr = (register_t)(sysent->sv_psstrings - - *(sysent->sv_szsigcode)); - /* Set the mode to enter in the signal handler */ -#if __ARM_ARCH >= 7 - if ((register_t)catcher & 1) - tf->tf_spsr |= PSR_T; - else - tf->tf_spsr &= ~PSR_T; -#endif - - CTR3(KTR_SIG, "sendsig: return td=%p pc=%#x sp=%#x", td, tf->tf_usr_lr, - tf->tf_usr_sp); - - PROC_LOCK(p); - mtx_lock(&psp->ps_mtx); -} - -int -sys_sigreturn(td, uap) - struct thread *td; - struct sigreturn_args /* { - const struct __ucontext *sigcntxp; - } */ *uap; -{ - ucontext_t uc; - int error; - - if (uap == NULL) - return (EFAULT); - if (copyin(uap->sigcntxp, &uc, sizeof(uc))) - return (EFAULT); - /* Restore register context. */ - error = set_mcontext(td, &uc.uc_mcontext); - if (error != 0) - return (error); - - /* Restore signal mask. */ - kern_sigprocmask(td, SIG_SETMASK, &uc.uc_sigmask, NULL, 0); - - return (EJUSTRETURN); -} - /* * Construct a PCB from a trapframe. This is called from kdb_trap() where * we want to start a backtrace from the function that caused us to enter diff --git a/sys/conf/files.arm b/sys/conf/files.arm index 44402b5aa433..69437d21e880 100644 --- a/sys/conf/files.arm +++ b/sys/conf/files.arm @@ -25,6 +25,7 @@ arm/arm/dump_machdep.c standard arm/arm/elf_machdep.c standard arm/arm/elf_note.S standard arm/arm/exception.S standard +arm/arm/exec_machdep.c standard arm/arm/fiq.c standard arm/arm/fiq_subr.S standard arm/arm/fusu.S standard From nobody Sat Oct 16 13:02:55 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id C87FB180C85E; Sat, 16 Oct 2021 13:02: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 4HWjwv4wypz3F2Z; Sat, 16 Oct 2021 13: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 30E7B1A233; Sat, 16 Oct 2021 13: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 19GD2thW037209; Sat, 16 Oct 2021 13: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 19GD2tue037208; Sat, 16 Oct 2021 13:02:55 GMT (envelope-from git) Date: Sat, 16 Oct 2021 13:02:55 GMT Message-Id: <202110161302.19GD2tue037208@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: 185bb1ae2d97 - stable/13 - riscv: move signal delivery code to exec_machdep.c List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 185bb1ae2d973ca697799895db11075e5f96a997 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=185bb1ae2d973ca697799895db11075e5f96a997 commit 185bb1ae2d973ca697799895db11075e5f96a997 Author: Konstantin Belousov AuthorDate: 2021-10-04 15:15:17 +0000 Commit: Konstantin Belousov CommitDate: 2021-10-16 13:01:48 +0000 riscv: move signal delivery code to exec_machdep.c (cherry picked from commit aba66031f27cec0bf9f6c6bc5d857e03eaf97d4f) --- sys/conf/files.riscv | 2 + sys/riscv/riscv/exec_machdep.c | 420 +++++++++++++++++++++++++++++++++++++++ sys/riscv/riscv/machdep.c | 386 +---------------------------------- sys/riscv/riscv/ptrace_machdep.c | 89 +++++++++ 4 files changed, 514 insertions(+), 383 deletions(-) diff --git a/sys/conf/files.riscv b/sys/conf/files.riscv index c6adc92d8a3a..222a00956c17 100644 --- a/sys/conf/files.riscv +++ b/sys/conf/files.riscv @@ -46,6 +46,7 @@ riscv/riscv/db_trace.c optional ddb riscv/riscv/dump_machdep.c standard riscv/riscv/elf_machdep.c standard riscv/riscv/exception.S standard +riscv/riscv/exec_machdep.c standard riscv/riscv/intr_machdep.c standard riscv/riscv/in_cksum.c optional inet | inet6 riscv/riscv/identcpu.c standard @@ -58,6 +59,7 @@ riscv/riscv/nexus.c standard riscv/riscv/ofw_machdep.c optional fdt riscv/riscv/plic.c standard riscv/riscv/pmap.c standard +riscv/riscv/ptrace_machdep.c standard riscv/riscv/riscv_console.c optional rcons riscv/riscv/riscv_syscon.c optional ext_resources syscon riscv_syscon fdt riscv/riscv/sbi.c standard diff --git a/sys/riscv/riscv/exec_machdep.c b/sys/riscv/riscv/exec_machdep.c new file mode 100644 index 000000000000..e06cc97eca9a --- /dev/null +++ b/sys/riscv/riscv/exec_machdep.c @@ -0,0 +1,420 @@ +/*- + * Copyright (c) 2014 Andrew Turner + * Copyright (c) 2015-2017 Ruslan Bukin + * All rights reserved. + * + * Portions of this software were developed by SRI International and the + * University of Cambridge Computer Laboratory under DARPA/AFRL contract + * FA8750-10-C-0237 ("CTSRD"), as part of the DARPA CRASH research programme. + * + * Portions of this software were developed by the University of Cambridge + * Computer Laboratory as part of the CTSRD Project, with support from the + * UK Higher Education Innovation Fund (HEIF). + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef FPE +#include +#endif + +static void get_fpcontext(struct thread *td, mcontext_t *mcp); +static void set_fpcontext(struct thread *td, mcontext_t *mcp); + +int +fill_regs(struct thread *td, struct reg *regs) +{ + struct trapframe *frame; + + frame = td->td_frame; + regs->sepc = frame->tf_sepc; + regs->sstatus = frame->tf_sstatus; + regs->ra = frame->tf_ra; + regs->sp = frame->tf_sp; + regs->gp = frame->tf_gp; + regs->tp = frame->tf_tp; + + memcpy(regs->t, frame->tf_t, sizeof(regs->t)); + memcpy(regs->s, frame->tf_s, sizeof(regs->s)); + memcpy(regs->a, frame->tf_a, sizeof(regs->a)); + + return (0); +} + +int +set_regs(struct thread *td, struct reg *regs) +{ + struct trapframe *frame; + + frame = td->td_frame; + frame->tf_sepc = regs->sepc; + frame->tf_ra = regs->ra; + frame->tf_sp = regs->sp; + frame->tf_gp = regs->gp; + frame->tf_tp = regs->tp; + + memcpy(frame->tf_t, regs->t, sizeof(frame->tf_t)); + memcpy(frame->tf_s, regs->s, sizeof(frame->tf_s)); + memcpy(frame->tf_a, regs->a, sizeof(frame->tf_a)); + + return (0); +} + +int +fill_fpregs(struct thread *td, struct fpreg *regs) +{ +#ifdef FPE + struct pcb *pcb; + + pcb = td->td_pcb; + + if ((pcb->pcb_fpflags & PCB_FP_STARTED) != 0) { + /* + * If we have just been running FPE instructions we will + * need to save the state to memcpy it below. + */ + if (td == curthread) + fpe_state_save(td); + + memcpy(regs->fp_x, pcb->pcb_x, sizeof(regs->fp_x)); + regs->fp_fcsr = pcb->pcb_fcsr; + } else +#endif + memset(regs, 0, sizeof(*regs)); + + return (0); +} + +int +set_fpregs(struct thread *td, struct fpreg *regs) +{ +#ifdef FPE + struct trapframe *frame; + struct pcb *pcb; + + frame = td->td_frame; + pcb = td->td_pcb; + + memcpy(pcb->pcb_x, regs->fp_x, sizeof(regs->fp_x)); + pcb->pcb_fcsr = regs->fp_fcsr; + pcb->pcb_fpflags |= PCB_FP_STARTED; + frame->tf_sstatus &= ~SSTATUS_FS_MASK; + frame->tf_sstatus |= SSTATUS_FS_CLEAN; +#endif + + return (0); +} + +int +fill_dbregs(struct thread *td, struct dbreg *regs) +{ + + panic("fill_dbregs"); +} + +int +set_dbregs(struct thread *td, struct dbreg *regs) +{ + + panic("set_dbregs"); +} + +void +exec_setregs(struct thread *td, struct image_params *imgp, uintptr_t stack) +{ + struct trapframe *tf; + struct pcb *pcb; + + tf = td->td_frame; + pcb = td->td_pcb; + + memset(tf, 0, sizeof(struct trapframe)); + + tf->tf_a[0] = stack; + tf->tf_sp = STACKALIGN(stack); + tf->tf_ra = imgp->entry_addr; + tf->tf_sepc = imgp->entry_addr; + + pcb->pcb_fpflags &= ~PCB_FP_STARTED; +} + +/* Sanity check these are the same size, they will be memcpy'd to and from */ +CTASSERT(sizeof(((struct trapframe *)0)->tf_a) == + sizeof((struct gpregs *)0)->gp_a); +CTASSERT(sizeof(((struct trapframe *)0)->tf_s) == + sizeof((struct gpregs *)0)->gp_s); +CTASSERT(sizeof(((struct trapframe *)0)->tf_t) == + sizeof((struct gpregs *)0)->gp_t); +CTASSERT(sizeof(((struct trapframe *)0)->tf_a) == + sizeof((struct reg *)0)->a); +CTASSERT(sizeof(((struct trapframe *)0)->tf_s) == + sizeof((struct reg *)0)->s); +CTASSERT(sizeof(((struct trapframe *)0)->tf_t) == + sizeof((struct reg *)0)->t); + +int +get_mcontext(struct thread *td, mcontext_t *mcp, int clear_ret) +{ + struct trapframe *tf = td->td_frame; + + memcpy(mcp->mc_gpregs.gp_t, tf->tf_t, sizeof(mcp->mc_gpregs.gp_t)); + memcpy(mcp->mc_gpregs.gp_s, tf->tf_s, sizeof(mcp->mc_gpregs.gp_s)); + memcpy(mcp->mc_gpregs.gp_a, tf->tf_a, sizeof(mcp->mc_gpregs.gp_a)); + + if (clear_ret & GET_MC_CLEAR_RET) { + mcp->mc_gpregs.gp_a[0] = 0; + mcp->mc_gpregs.gp_t[0] = 0; /* clear syscall error */ + } + + mcp->mc_gpregs.gp_ra = tf->tf_ra; + mcp->mc_gpregs.gp_sp = tf->tf_sp; + mcp->mc_gpregs.gp_gp = tf->tf_gp; + mcp->mc_gpregs.gp_tp = tf->tf_tp; + mcp->mc_gpregs.gp_sepc = tf->tf_sepc; + mcp->mc_gpregs.gp_sstatus = tf->tf_sstatus; + get_fpcontext(td, mcp); + + return (0); +} + +int +set_mcontext(struct thread *td, mcontext_t *mcp) +{ + struct trapframe *tf; + + tf = td->td_frame; + + /* + * Permit changes to the USTATUS bits of SSTATUS. + * + * Ignore writes to read-only bits (SD, XS). + * + * Ignore writes to the FS field as set_fpcontext() will set + * it explicitly. + */ + if (((mcp->mc_gpregs.gp_sstatus ^ tf->tf_sstatus) & + ~(SSTATUS_SD | SSTATUS_XS_MASK | SSTATUS_FS_MASK | SSTATUS_UPIE | + SSTATUS_UIE)) != 0) + return (EINVAL); + + memcpy(tf->tf_t, mcp->mc_gpregs.gp_t, sizeof(tf->tf_t)); + memcpy(tf->tf_s, mcp->mc_gpregs.gp_s, sizeof(tf->tf_s)); + memcpy(tf->tf_a, mcp->mc_gpregs.gp_a, sizeof(tf->tf_a)); + + tf->tf_ra = mcp->mc_gpregs.gp_ra; + tf->tf_sp = mcp->mc_gpregs.gp_sp; + tf->tf_gp = mcp->mc_gpregs.gp_gp; + tf->tf_sepc = mcp->mc_gpregs.gp_sepc; + tf->tf_sstatus = mcp->mc_gpregs.gp_sstatus; + set_fpcontext(td, mcp); + + return (0); +} + +static void +get_fpcontext(struct thread *td, mcontext_t *mcp) +{ +#ifdef FPE + struct pcb *curpcb; + + critical_enter(); + + curpcb = curthread->td_pcb; + + KASSERT(td->td_pcb == curpcb, ("Invalid fpe pcb")); + + if ((curpcb->pcb_fpflags & PCB_FP_STARTED) != 0) { + /* + * If we have just been running FPE instructions we will + * need to save the state to memcpy it below. + */ + fpe_state_save(td); + + KASSERT((curpcb->pcb_fpflags & ~PCB_FP_USERMASK) == 0, + ("Non-userspace FPE flags set in get_fpcontext")); + memcpy(mcp->mc_fpregs.fp_x, curpcb->pcb_x, + sizeof(mcp->mc_fpregs.fp_x)); + mcp->mc_fpregs.fp_fcsr = curpcb->pcb_fcsr; + mcp->mc_fpregs.fp_flags = curpcb->pcb_fpflags; + mcp->mc_flags |= _MC_FP_VALID; + } + + critical_exit(); +#endif +} + +static void +set_fpcontext(struct thread *td, mcontext_t *mcp) +{ +#ifdef FPE + struct pcb *curpcb; +#endif + + td->td_frame->tf_sstatus &= ~SSTATUS_FS_MASK; + td->td_frame->tf_sstatus |= SSTATUS_FS_OFF; + +#ifdef FPE + critical_enter(); + + if ((mcp->mc_flags & _MC_FP_VALID) != 0) { + curpcb = curthread->td_pcb; + /* FPE usage is enabled, override registers. */ + memcpy(curpcb->pcb_x, mcp->mc_fpregs.fp_x, + sizeof(mcp->mc_fpregs.fp_x)); + curpcb->pcb_fcsr = mcp->mc_fpregs.fp_fcsr; + curpcb->pcb_fpflags = mcp->mc_fpregs.fp_flags & PCB_FP_USERMASK; + td->td_frame->tf_sstatus |= SSTATUS_FS_CLEAN; + } + + critical_exit(); +#endif +} + +int +sys_sigreturn(struct thread *td, struct sigreturn_args *uap) +{ + ucontext_t uc; + int error; + + if (copyin(uap->sigcntxp, &uc, sizeof(uc))) + return (EFAULT); + + error = set_mcontext(td, &uc.uc_mcontext); + if (error != 0) + return (error); + + /* Restore signal mask. */ + kern_sigprocmask(td, SIG_SETMASK, &uc.uc_sigmask, NULL, 0); + + return (EJUSTRETURN); +} + +void +sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask) +{ + struct sigframe *fp, frame; + struct sysentvec *sysent; + struct trapframe *tf; + struct sigacts *psp; + struct thread *td; + struct proc *p; + int onstack; + int sig; + + td = curthread; + p = td->td_proc; + PROC_LOCK_ASSERT(p, MA_OWNED); + + sig = ksi->ksi_signo; + psp = p->p_sigacts; + mtx_assert(&psp->ps_mtx, MA_OWNED); + + tf = td->td_frame; + onstack = sigonstack(tf->tf_sp); + + CTR4(KTR_SIG, "sendsig: td=%p (%s) catcher=%p sig=%d", td, p->p_comm, + catcher, sig); + + /* Allocate and validate space for the signal handler context. */ + if ((td->td_pflags & TDP_ALTSTACK) != 0 && !onstack && + SIGISMEMBER(psp->ps_sigonstack, sig)) { + fp = (struct sigframe *)((uintptr_t)td->td_sigstk.ss_sp + + td->td_sigstk.ss_size); + } else { + fp = (struct sigframe *)td->td_frame->tf_sp; + } + + /* Make room, keeping the stack aligned */ + fp--; + fp = (struct sigframe *)STACKALIGN(fp); + + /* Fill in the frame to copy out */ + bzero(&frame, sizeof(frame)); + get_mcontext(td, &frame.sf_uc.uc_mcontext, 0); + frame.sf_si = ksi->ksi_info; + frame.sf_uc.uc_sigmask = *mask; + frame.sf_uc.uc_stack = td->td_sigstk; + frame.sf_uc.uc_stack.ss_flags = (td->td_pflags & TDP_ALTSTACK) != 0 ? + (onstack ? SS_ONSTACK : 0) : SS_DISABLE; + mtx_unlock(&psp->ps_mtx); + PROC_UNLOCK(td->td_proc); + + /* Copy the sigframe out to the user's stack. */ + if (copyout(&frame, fp, sizeof(*fp)) != 0) { + /* Process has trashed its stack. Kill it. */ + CTR2(KTR_SIG, "sendsig: sigexit td=%p fp=%p", td, fp); + PROC_LOCK(p); + sigexit(td, SIGILL); + } + + tf->tf_a[0] = sig; + tf->tf_a[1] = (register_t)&fp->sf_si; + tf->tf_a[2] = (register_t)&fp->sf_uc; + + tf->tf_sepc = (register_t)catcher; + tf->tf_sp = (register_t)fp; + + sysent = p->p_sysent; + if (sysent->sv_sigcode_base != 0) + tf->tf_ra = (register_t)sysent->sv_sigcode_base; + else + tf->tf_ra = (register_t)(sysent->sv_psstrings - + *(sysent->sv_szsigcode)); + + CTR3(KTR_SIG, "sendsig: return td=%p pc=%#x sp=%#x", td, tf->tf_sepc, + tf->tf_sp); + + PROC_LOCK(p); + mtx_lock(&psp->ps_mtx); +} diff --git a/sys/riscv/riscv/machdep.c b/sys/riscv/riscv/machdep.c index 841bfeda891e..c6b219849e79 100644 --- a/sys/riscv/riscv/machdep.c +++ b/sys/riscv/riscv/machdep.c @@ -102,9 +102,6 @@ __FBSDID("$FreeBSD$"); #include #endif -static void get_fpcontext(struct thread *td, mcontext_t *mcp); -static void set_fpcontext(struct thread *td, mcontext_t *mcp); - struct pcpu __pcpu[MAXCPU]; static struct trapframe proc0_tf; @@ -182,282 +179,6 @@ cpu_idle_wakeup(int cpu) return (0); } -int -fill_regs(struct thread *td, struct reg *regs) -{ - struct trapframe *frame; - - frame = td->td_frame; - regs->sepc = frame->tf_sepc; - regs->sstatus = frame->tf_sstatus; - regs->ra = frame->tf_ra; - regs->sp = frame->tf_sp; - regs->gp = frame->tf_gp; - regs->tp = frame->tf_tp; - - memcpy(regs->t, frame->tf_t, sizeof(regs->t)); - memcpy(regs->s, frame->tf_s, sizeof(regs->s)); - memcpy(regs->a, frame->tf_a, sizeof(regs->a)); - - return (0); -} - -int -set_regs(struct thread *td, struct reg *regs) -{ - struct trapframe *frame; - - frame = td->td_frame; - frame->tf_sepc = regs->sepc; - frame->tf_ra = regs->ra; - frame->tf_sp = regs->sp; - frame->tf_gp = regs->gp; - frame->tf_tp = regs->tp; - - memcpy(frame->tf_t, regs->t, sizeof(frame->tf_t)); - memcpy(frame->tf_s, regs->s, sizeof(frame->tf_s)); - memcpy(frame->tf_a, regs->a, sizeof(frame->tf_a)); - - return (0); -} - -int -fill_fpregs(struct thread *td, struct fpreg *regs) -{ -#ifdef FPE - struct pcb *pcb; - - pcb = td->td_pcb; - - if ((pcb->pcb_fpflags & PCB_FP_STARTED) != 0) { - /* - * If we have just been running FPE instructions we will - * need to save the state to memcpy it below. - */ - if (td == curthread) - fpe_state_save(td); - - memcpy(regs->fp_x, pcb->pcb_x, sizeof(regs->fp_x)); - regs->fp_fcsr = pcb->pcb_fcsr; - } else -#endif - memset(regs, 0, sizeof(*regs)); - - return (0); -} - -int -set_fpregs(struct thread *td, struct fpreg *regs) -{ -#ifdef FPE - struct trapframe *frame; - struct pcb *pcb; - - frame = td->td_frame; - pcb = td->td_pcb; - - memcpy(pcb->pcb_x, regs->fp_x, sizeof(regs->fp_x)); - pcb->pcb_fcsr = regs->fp_fcsr; - pcb->pcb_fpflags |= PCB_FP_STARTED; - frame->tf_sstatus &= ~SSTATUS_FS_MASK; - frame->tf_sstatus |= SSTATUS_FS_CLEAN; -#endif - - return (0); -} - -int -fill_dbregs(struct thread *td, struct dbreg *regs) -{ - - panic("fill_dbregs"); -} - -int -set_dbregs(struct thread *td, struct dbreg *regs) -{ - - panic("set_dbregs"); -} - -int -ptrace_set_pc(struct thread *td, u_long addr) -{ - - td->td_frame->tf_sepc = addr; - return (0); -} - -int -ptrace_single_step(struct thread *td) -{ - - /* TODO; */ - return (EOPNOTSUPP); -} - -int -ptrace_clear_single_step(struct thread *td) -{ - - /* TODO; */ - return (EOPNOTSUPP); -} - -void -exec_setregs(struct thread *td, struct image_params *imgp, uintptr_t stack) -{ - struct trapframe *tf; - struct pcb *pcb; - - tf = td->td_frame; - pcb = td->td_pcb; - - memset(tf, 0, sizeof(struct trapframe)); - - tf->tf_a[0] = stack; - tf->tf_sp = STACKALIGN(stack); - tf->tf_ra = imgp->entry_addr; - tf->tf_sepc = imgp->entry_addr; - - pcb->pcb_fpflags &= ~PCB_FP_STARTED; -} - -/* Sanity check these are the same size, they will be memcpy'd to and fro */ -CTASSERT(sizeof(((struct trapframe *)0)->tf_a) == - sizeof((struct gpregs *)0)->gp_a); -CTASSERT(sizeof(((struct trapframe *)0)->tf_s) == - sizeof((struct gpregs *)0)->gp_s); -CTASSERT(sizeof(((struct trapframe *)0)->tf_t) == - sizeof((struct gpregs *)0)->gp_t); -CTASSERT(sizeof(((struct trapframe *)0)->tf_a) == - sizeof((struct reg *)0)->a); -CTASSERT(sizeof(((struct trapframe *)0)->tf_s) == - sizeof((struct reg *)0)->s); -CTASSERT(sizeof(((struct trapframe *)0)->tf_t) == - sizeof((struct reg *)0)->t); - -/* Support for FDT configurations only. */ -CTASSERT(FDT); - -int -get_mcontext(struct thread *td, mcontext_t *mcp, int clear_ret) -{ - struct trapframe *tf = td->td_frame; - - memcpy(mcp->mc_gpregs.gp_t, tf->tf_t, sizeof(mcp->mc_gpregs.gp_t)); - memcpy(mcp->mc_gpregs.gp_s, tf->tf_s, sizeof(mcp->mc_gpregs.gp_s)); - memcpy(mcp->mc_gpregs.gp_a, tf->tf_a, sizeof(mcp->mc_gpregs.gp_a)); - - if (clear_ret & GET_MC_CLEAR_RET) { - mcp->mc_gpregs.gp_a[0] = 0; - mcp->mc_gpregs.gp_t[0] = 0; /* clear syscall error */ - } - - mcp->mc_gpregs.gp_ra = tf->tf_ra; - mcp->mc_gpregs.gp_sp = tf->tf_sp; - mcp->mc_gpregs.gp_gp = tf->tf_gp; - mcp->mc_gpregs.gp_tp = tf->tf_tp; - mcp->mc_gpregs.gp_sepc = tf->tf_sepc; - mcp->mc_gpregs.gp_sstatus = tf->tf_sstatus; - get_fpcontext(td, mcp); - - return (0); -} - -int -set_mcontext(struct thread *td, mcontext_t *mcp) -{ - struct trapframe *tf; - - tf = td->td_frame; - - /* - * Permit changes to the USTATUS bits of SSTATUS. - * - * Ignore writes to read-only bits (SD, XS). - * - * Ignore writes to the FS field as set_fpcontext() will set - * it explicitly. - */ - if (((mcp->mc_gpregs.gp_sstatus ^ tf->tf_sstatus) & - ~(SSTATUS_SD | SSTATUS_XS_MASK | SSTATUS_FS_MASK | SSTATUS_UPIE | - SSTATUS_UIE)) != 0) - return (EINVAL); - - memcpy(tf->tf_t, mcp->mc_gpregs.gp_t, sizeof(tf->tf_t)); - memcpy(tf->tf_s, mcp->mc_gpregs.gp_s, sizeof(tf->tf_s)); - memcpy(tf->tf_a, mcp->mc_gpregs.gp_a, sizeof(tf->tf_a)); - - tf->tf_ra = mcp->mc_gpregs.gp_ra; - tf->tf_sp = mcp->mc_gpregs.gp_sp; - tf->tf_gp = mcp->mc_gpregs.gp_gp; - tf->tf_sepc = mcp->mc_gpregs.gp_sepc; - tf->tf_sstatus = mcp->mc_gpregs.gp_sstatus; - set_fpcontext(td, mcp); - - return (0); -} - -static void -get_fpcontext(struct thread *td, mcontext_t *mcp) -{ -#ifdef FPE - struct pcb *curpcb; - - critical_enter(); - - curpcb = curthread->td_pcb; - - KASSERT(td->td_pcb == curpcb, ("Invalid fpe pcb")); - - if ((curpcb->pcb_fpflags & PCB_FP_STARTED) != 0) { - /* - * If we have just been running FPE instructions we will - * need to save the state to memcpy it below. - */ - fpe_state_save(td); - - KASSERT((curpcb->pcb_fpflags & ~PCB_FP_USERMASK) == 0, - ("Non-userspace FPE flags set in get_fpcontext")); - memcpy(mcp->mc_fpregs.fp_x, curpcb->pcb_x, - sizeof(mcp->mc_fpregs.fp_x)); - mcp->mc_fpregs.fp_fcsr = curpcb->pcb_fcsr; - mcp->mc_fpregs.fp_flags = curpcb->pcb_fpflags; - mcp->mc_flags |= _MC_FP_VALID; - } - - critical_exit(); -#endif -} - -static void -set_fpcontext(struct thread *td, mcontext_t *mcp) -{ -#ifdef FPE - struct pcb *curpcb; -#endif - - td->td_frame->tf_sstatus &= ~SSTATUS_FS_MASK; - td->td_frame->tf_sstatus |= SSTATUS_FS_OFF; - -#ifdef FPE - critical_enter(); - - if ((mcp->mc_flags & _MC_FP_VALID) != 0) { - curpcb = curthread->td_pcb; - /* FPE usage is enabled, override registers. */ - memcpy(curpcb->pcb_x, mcp->mc_fpregs.fp_x, - sizeof(mcp->mc_fpregs.fp_x)); - curpcb->pcb_fcsr = mcp->mc_fpregs.fp_fcsr; - curpcb->pcb_fpflags = mcp->mc_fpregs.fp_flags & PCB_FP_USERMASK; - td->td_frame->tf_sstatus |= SSTATUS_FS_CLEAN; - } - - critical_exit(); -#endif -} - void cpu_idle(int busy) { @@ -545,31 +266,6 @@ spinlock_exit(void) } } -#ifndef _SYS_SYSPROTO_H_ -struct sigreturn_args { - ucontext_t *ucp; -}; -#endif - -int -sys_sigreturn(struct thread *td, struct sigreturn_args *uap) -{ - ucontext_t uc; - int error; - - if (copyin(uap->sigcntxp, &uc, sizeof(uc))) - return (EFAULT); - - error = set_mcontext(td, &uc.uc_mcontext); - if (error != 0) - return (error); - - /* Restore signal mask. */ - kern_sigprocmask(td, SIG_SETMASK, &uc.uc_sigmask, NULL, 0); - - return (EJUSTRETURN); -} - /* * Construct a PCB from a trapframe. This is called from kdb_trap() where * we want to start a backtrace from the function that caused us to enter @@ -589,85 +285,6 @@ makectx(struct trapframe *tf, struct pcb *pcb) pcb->pcb_tp = tf->tf_tp; } -void -sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask) -{ - struct sigframe *fp, frame; - struct sysentvec *sysent; - struct trapframe *tf; - struct sigacts *psp; - struct thread *td; - struct proc *p; - int onstack; - int sig; - - td = curthread; - p = td->td_proc; - PROC_LOCK_ASSERT(p, MA_OWNED); - - sig = ksi->ksi_signo; - psp = p->p_sigacts; - mtx_assert(&psp->ps_mtx, MA_OWNED); - - tf = td->td_frame; - onstack = sigonstack(tf->tf_sp); - - CTR4(KTR_SIG, "sendsig: td=%p (%s) catcher=%p sig=%d", td, p->p_comm, - catcher, sig); - - /* Allocate and validate space for the signal handler context. */ - if ((td->td_pflags & TDP_ALTSTACK) != 0 && !onstack && - SIGISMEMBER(psp->ps_sigonstack, sig)) { - fp = (struct sigframe *)((uintptr_t)td->td_sigstk.ss_sp + - td->td_sigstk.ss_size); - } else { - fp = (struct sigframe *)td->td_frame->tf_sp; - } - - /* Make room, keeping the stack aligned */ - fp--; - fp = (struct sigframe *)STACKALIGN(fp); - - /* Fill in the frame to copy out */ - bzero(&frame, sizeof(frame)); - get_mcontext(td, &frame.sf_uc.uc_mcontext, 0); - frame.sf_si = ksi->ksi_info; - frame.sf_uc.uc_sigmask = *mask; - frame.sf_uc.uc_stack = td->td_sigstk; - frame.sf_uc.uc_stack.ss_flags = (td->td_pflags & TDP_ALTSTACK) != 0 ? - (onstack ? SS_ONSTACK : 0) : SS_DISABLE; - mtx_unlock(&psp->ps_mtx); - PROC_UNLOCK(td->td_proc); - - /* Copy the sigframe out to the user's stack. */ - if (copyout(&frame, fp, sizeof(*fp)) != 0) { - /* Process has trashed its stack. Kill it. */ - CTR2(KTR_SIG, "sendsig: sigexit td=%p fp=%p", td, fp); - PROC_LOCK(p); - sigexit(td, SIGILL); - } - - tf->tf_a[0] = sig; - tf->tf_a[1] = (register_t)&fp->sf_si; - tf->tf_a[2] = (register_t)&fp->sf_uc; - - tf->tf_sepc = (register_t)catcher; - tf->tf_sp = (register_t)fp; - - sysent = p->p_sysent; - if (sysent->sv_sigcode_base != 0) - tf->tf_ra = (register_t)sysent->sv_sigcode_base; - else - tf->tf_ra = (register_t)(sysent->sv_psstrings - - *(sysent->sv_szsigcode)); - - CTR3(KTR_SIG, "sendsig: return td=%p pc=%#x sp=%#x", td, tf->tf_sepc, - tf->tf_sp); - - PROC_LOCK(p); - mtx_lock(&psp->ps_mtx); -} - static void init_proc0(vm_offset_t kstack) { @@ -803,6 +420,9 @@ fake_preload_metadata(struct riscv_bootparams *rvbp) rvbp->kern_phys, rvbp->kern_phys + (lastaddr - KERNBASE)); } +/* Support for FDT configurations only. */ +CTASSERT(FDT); + #ifdef FDT static void parse_fdt_bootargs(void) diff --git a/sys/riscv/riscv/ptrace_machdep.c b/sys/riscv/riscv/ptrace_machdep.c new file mode 100644 index 000000000000..d9fc97d7a113 --- /dev/null +++ b/sys/riscv/riscv/ptrace_machdep.c @@ -0,0 +1,89 @@ +/*- + * Copyright (c) 2014 Andrew Turner + * Copyright (c) 2015-2017 Ruslan Bukin + * All rights reserved. + * + * Portions of this software were developed by SRI International and the + * University of Cambridge Computer Laboratory under DARPA/AFRL contract + * FA8750-10-C-0237 ("CTSRD"), as part of the DARPA CRASH research programme. + * + * Portions of this software were developed by the University of Cambridge + * Computer Laboratory as part of the CTSRD Project, with support from the + * UK Higher Education Innovation Fund (HEIF). + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +int +ptrace_set_pc(struct thread *td, u_long addr) +{ + + td->td_frame->tf_sepc = addr; + return (0); +} + +int +ptrace_single_step(struct thread *td) +{ + + /* TODO; */ + return (EOPNOTSUPP); +} + +int +ptrace_clear_single_step(struct thread *td) +{ + + /* TODO; */ + return (EOPNOTSUPP); +} + From nobody Sat Oct 16 13:31:34 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4367F17F0F6B; Sat, 16 Oct 2021 13:31:35 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HWkYz16C9z3QJS; Sat, 16 Oct 2021 13:31:35 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 067BF1AD80; Sat, 16 Oct 2021 13:31:35 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19GDVYui074028; Sat, 16 Oct 2021 13:31:34 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19GDVY3j074027; Sat, 16 Oct 2021 13:31:34 GMT (envelope-from git) Date: Sat, 16 Oct 2021 13:31:34 GMT Message-Id: <202110161331.19GDVY3j074027@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: 66f5f958646c - stable/13 - timecounter: Let kern.timecounter.stepwarnings be set as a tunable List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 66f5f958646c780676c23bd581cf5b3e26eff551 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=66f5f958646c780676c23bd581cf5b3e26eff551 commit 66f5f958646c780676c23bd581cf5b3e26eff551 Author: Mark Johnston AuthorDate: 2021-10-09 16:34:06 +0000 Commit: Mark Johnston CommitDate: 2021-10-16 13:31:19 +0000 timecounter: Let kern.timecounter.stepwarnings be set as a tunable (cherry picked from commit fa9da1f590caba94b98717c33633efcf719da151) --- sys/kern/kern_tc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/kern/kern_tc.c b/sys/kern/kern_tc.c index b1dcb18e31be..4ae0169b7d8d 100644 --- a/sys/kern/kern_tc.c +++ b/sys/kern/kern_tc.c @@ -116,7 +116,7 @@ static SYSCTL_NODE(_kern_timecounter, OID_AUTO, tc, ""); static int timestepwarnings; -SYSCTL_INT(_kern_timecounter, OID_AUTO, stepwarnings, CTLFLAG_RW, +SYSCTL_INT(_kern_timecounter, OID_AUTO, stepwarnings, CTLFLAG_RWTUN, ×tepwarnings, 0, "Log time steps"); static int timehands_count = 2; From nobody Sat Oct 16 22:30:01 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 5344517FD11C; Sat, 16 Oct 2021 22:30: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 4HWyWG1txFz3qRk; Sat, 16 Oct 2021 22:30: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 1654E21C1F; Sat, 16 Oct 2021 22:30: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 19GMU1Bi083799; Sat, 16 Oct 2021 22:30:01 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19GMU1G0083796; Sat, 16 Oct 2021 22:30:01 GMT (envelope-from git) Date: Sat, 16 Oct 2021 22:30:01 GMT Message-Id: <202110162230.19GMU1G0083796@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Peek Subject: git: 4e5c1be4202a - stable/13 - vmci: fix panic due to freeing unallocated resources List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mp X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 4e5c1be4202a141b7a15c505848abcbea535912f Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by mp: URL: https://cgit.FreeBSD.org/src/commit/?id=4e5c1be4202a141b7a15c505848abcbea535912f commit 4e5c1be4202a141b7a15c505848abcbea535912f Author: Mark Peek AuthorDate: 2021-10-09 21:21:16 +0000 Commit: Mark Peek CommitDate: 2021-10-16 18:22:43 +0000 vmci: fix panic due to freeing unallocated resources Summary: An error mapping PCI resources results in a panic due to unallocated resources being freed up. This change puts the appropriate checks in place to prevent the panic. PR: 252445 Reported by: Marek Zarychta Tested by: marcus MFC after: 1 week Sponsored by: VMware Test Plan: Along with user testing, also simulated error by inserting a ENXIO return in vmci_map_bars(). Reviewed by: marcus Subscribers: imp Differential Revision: https://reviews.freebsd.org/D32016 (cherry picked from commit 0f14bcbe384091c729464cb770372aeb79061070) --- sys/dev/vmware/vmci/vmci.c | 9 ++++--- sys/dev/vmware/vmci/vmci_event.c | 3 +++ sys/dev/vmware/vmci/vmci_kernel_if.c | 48 ++++++++++++++++++++++++++++++++++- sys/dev/vmware/vmci/vmci_kernel_if.h | 2 ++ sys/dev/vmware/vmci/vmci_queue_pair.c | 3 +++ 5 files changed, 61 insertions(+), 4 deletions(-) diff --git a/sys/dev/vmware/vmci/vmci.c b/sys/dev/vmware/vmci/vmci.c index bbf17bbe7e41..8adcb7f532b7 100644 --- a/sys/dev/vmware/vmci/vmci.c +++ b/sys/dev/vmware/vmci/vmci.c @@ -242,8 +242,10 @@ vmci_detach(device_t dev) vmci_components_cleanup(); - taskqueue_drain(taskqueue_thread, &sc->vmci_delayed_work_task); - mtx_destroy(&sc->vmci_delayed_work_lock); + if mtx_initialized(&sc->vmci_spinlock) { + taskqueue_drain(taskqueue_thread, &sc->vmci_delayed_work_task); + mtx_destroy(&sc->vmci_delayed_work_lock); + } if (sc->vmci_res0 != NULL) bus_space_write_4(sc->vmci_iot0, sc->vmci_ioh0, @@ -254,7 +256,8 @@ vmci_detach(device_t dev) vmci_unmap_bars(sc); - mtx_destroy(&sc->vmci_spinlock); + if mtx_initialized(&sc->vmci_spinlock) + mtx_destroy(&sc->vmci_spinlock); pci_disable_busmaster(dev); diff --git a/sys/dev/vmware/vmci/vmci_event.c b/sys/dev/vmware/vmci/vmci_event.c index 7f3bf9039e12..192828cc6f6a 100644 --- a/sys/dev/vmware/vmci/vmci_event.c +++ b/sys/dev/vmware/vmci/vmci_event.c @@ -593,6 +593,9 @@ vmci_event_unregister_subscription(vmci_id sub_id) { struct vmci_subscription *s; + if (!vmci_initialized_lock(&subscriber_lock)) + return NULL; + vmci_grab_lock_bh(&subscriber_lock); s = vmci_event_find(sub_id); if (s != NULL) { diff --git a/sys/dev/vmware/vmci/vmci_kernel_if.c b/sys/dev/vmware/vmci/vmci_kernel_if.c index e845650873b5..de54a8d1ca4f 100644 --- a/sys/dev/vmware/vmci/vmci_kernel_if.c +++ b/sys/dev/vmware/vmci/vmci_kernel_if.c @@ -70,7 +70,8 @@ void vmci_cleanup_lock(vmci_lock *lock) { - mtx_destroy(lock); + if mtx_initialized(lock) + mtx_destroy(lock); } /* @@ -165,6 +166,29 @@ vmci_release_lock_bh(vmci_lock *lock) mtx_unlock(lock); } +/* + *------------------------------------------------------------------------------ + * + * vmci_initialized_lock + * + * Returns whether a lock has been initialized. + * + * Results: + * Return 1 if initialized or 0 if unininitialized. + * + * Side effects: + * None + * + *------------------------------------------------------------------------------ + */ + +int +vmci_initialized_lock(vmci_lock *lock) +{ + + return mtx_initialized(lock); +} + /* *------------------------------------------------------------------------------ * @@ -446,6 +470,28 @@ vmci_mutex_release(vmci_mutex *mutex) mtx_unlock(mutex); } +/* + *------------------------------------------------------------------------------ + * + * vmci_mutex_initialized + * + * Returns whether a mutex has been initialized. + * + * Results: + * Return 1 if initialized or 0 if unininitialized. + * + * Side effects: + * None + * + *------------------------------------------------------------------------------ + */ + +int +vmci_mutex_initialized(vmci_mutex *mutex) +{ + + return mtx_initialized(mutex); +} /* *------------------------------------------------------------------------------ * diff --git a/sys/dev/vmware/vmci/vmci_kernel_if.h b/sys/dev/vmware/vmci/vmci_kernel_if.h index fc23eefe98e0..048e480b0698 100644 --- a/sys/dev/vmware/vmci/vmci_kernel_if.h +++ b/sys/dev/vmware/vmci/vmci_kernel_if.h @@ -48,6 +48,7 @@ void vmci_grab_lock(vmci_lock *lock); void vmci_release_lock(vmci_lock *lock); void vmci_grab_lock_bh(vmci_lock *lock); void vmci_release_lock_bh(vmci_lock *lock); +int vmci_initialized_lock(vmci_lock *lock); void *vmci_alloc_kernel_mem(size_t size, int flags); void vmci_free_kernel_mem(void *ptr, size_t size); @@ -72,6 +73,7 @@ int vmci_mutex_init(vmci_mutex *mutex, char *name); void vmci_mutex_destroy(vmci_mutex *mutex); void vmci_mutex_acquire(vmci_mutex *mutex); void vmci_mutex_release(vmci_mutex *mutex); +int vmci_mutex_initialized(vmci_mutex *mutex); void *vmci_alloc_queue(uint64_t size, uint32_t flags); void vmci_free_queue(void *q, uint64_t size); diff --git a/sys/dev/vmware/vmci/vmci_queue_pair.c b/sys/dev/vmware/vmci/vmci_queue_pair.c index 2ff963c691d0..0e2f83b20c67 100644 --- a/sys/dev/vmware/vmci/vmci_queue_pair.c +++ b/sys/dev/vmware/vmci/vmci_queue_pair.c @@ -338,6 +338,9 @@ vmci_qp_guest_endpoints_exit(void) { struct qp_guest_endpoint *entry; + if (!vmci_mutex_initialized(&qp_guest_endpoints.mutex)) + return; + vmci_mutex_acquire(&qp_guest_endpoints.mutex); while ((entry = From nobody Sun Oct 17 00:28:40 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 8583B1806219; Sun, 17 Oct 2021 00:28:40 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HX1883LZ5z4smH; Sun, 17 Oct 2021 00:28:40 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4F9A823594; Sun, 17 Oct 2021 00:28:40 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19H0Setm042630; Sun, 17 Oct 2021 00:28:40 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19H0SeZ3042629; Sun, 17 Oct 2021 00:28:40 GMT (envelope-from git) Date: Sun, 17 Oct 2021 00:28:40 GMT Message-Id: <202110170028.19H0SeZ3042629@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: c683063a00d0 - stable/13 - Enable PPS_SYNC on amd64, arm64 and armv7 List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: c683063a00d0ff37afd16f7baf6d0a5e84e3a18f Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=c683063a00d0ff37afd16f7baf6d0a5e84e3a18f commit c683063a00d0ff37afd16f7baf6d0a5e84e3a18f Author: Konstantin Belousov AuthorDate: 2021-10-10 12:20:45 +0000 Commit: Konstantin Belousov CommitDate: 2021-10-17 00:28:13 +0000 Enable PPS_SYNC on amd64, arm64 and armv7 PR: 259036 (cherry picked from commit e81e77c5a055d1cbf6d6a6f0acbaf443267aa84f) --- sys/amd64/conf/GENERIC | 6 ++++++ sys/arm/conf/std.armv7 | 6 ++++++ sys/arm64/conf/GENERIC | 2 ++ sys/conf/NOTES | 6 ------ sys/powerpc/conf/NOTES | 2 ++ sys/riscv/conf/NOTES | 2 ++ 6 files changed, 18 insertions(+), 6 deletions(-) diff --git a/sys/amd64/conf/GENERIC b/sys/amd64/conf/GENERIC index 82d143c18f51..3478c9a3db26 100644 --- a/sys/amd64/conf/GENERIC +++ b/sys/amd64/conf/GENERIC @@ -123,6 +123,12 @@ options PCI_IOV # PCI SR-IOV support options COMPAT_LINUXKPI +# Enable support for the kernel PLL to use an external PPS signal, +# under supervision of [x]ntpd(8) +# More info in ntpd documentation: http://www.eecis.udel.edu/~ntp + +options PPS_SYNC + # Floppy drives device fdc diff --git a/sys/arm/conf/std.armv7 b/sys/arm/conf/std.armv7 index b15f9f9a70fa..dbe863d9da92 100644 --- a/sys/arm/conf/std.armv7 +++ b/sys/arm/conf/std.armv7 @@ -71,3 +71,9 @@ options KDB_TRACE # Print a stack trace for a panic. #options KTR_VERBOSE=0 #options USB_REQ_DEBUG #options USB_VERBOSE + +# Enable support for the kernel PLL to use an external PPS signal, +# under supervision of [x]ntpd(8) +# More info in ntpd documentation: http://www.eecis.udel.edu/~ntp + +options PPS_SYNC diff --git a/sys/arm64/conf/GENERIC b/sys/arm64/conf/GENERIC index eea4441f096f..a37d78332276 100644 --- a/sys/arm64/conf/GENERIC +++ b/sys/arm64/conf/GENERIC @@ -121,6 +121,8 @@ options SOC_ROCKCHIP_RK3328 options SOC_ROCKCHIP_RK3399 options SOC_XILINX_ZYNQ +options PPS_SYNC + # Timer drivers device a10_timer diff --git a/sys/conf/NOTES b/sys/conf/NOTES index f73b5a466366..5f97933a512a 100644 --- a/sys/conf/NOTES +++ b/sys/conf/NOTES @@ -1250,12 +1250,6 @@ options CAPABILITY_MODE # sandboxes with no global namespace access options HZ=100 -# Enable support for the kernel PLL to use an external PPS signal, -# under supervision of [x]ntpd(8) -# More info in ntpd documentation: http://www.eecis.udel.edu/~ntp - -options PPS_SYNC - # Enable support for generic feed-forward clocks in the kernel. # The feed-forward clock support is an alternative to the feedback oriented # ntpd/system clock approach, and is to be used with a feed-forward diff --git a/sys/powerpc/conf/NOTES b/sys/powerpc/conf/NOTES index 78d990331ead..1a0c70fb08f9 100644 --- a/sys/powerpc/conf/NOTES +++ b/sys/powerpc/conf/NOTES @@ -46,6 +46,8 @@ options PSIM #GDB PSIM ppc simulator options MAMBO #IBM Mambo Full System Simulator options QEMU #QEMU processor emulator +options PPS_SYNC + # The cpufreq(4) driver provides support for CPU frequency control device cpufreq diff --git a/sys/riscv/conf/NOTES b/sys/riscv/conf/NOTES index 7dda89bfe1a8..60e842ab2709 100644 --- a/sys/riscv/conf/NOTES +++ b/sys/riscv/conf/NOTES @@ -20,6 +20,8 @@ options FPE # Floating-point extension support options RACCT_DEFAULT_TO_DISABLED # Set kern.racct.enable=0 by default options INTRNG # Include INTRNG framework +options PPS_SYNC + # RISC-V SBI console device rcons From nobody Sun Oct 17 00:28:41 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id A10CB1806287; Sun, 17 Oct 2021 00:28: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 4HX1893zjbz4sxM; Sun, 17 Oct 2021 00:28: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 69BC023781; Sun, 17 Oct 2021 00:28:41 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19H0SfQU042654; Sun, 17 Oct 2021 00:28:41 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19H0Sftm042653; Sun, 17 Oct 2021 00:28:41 GMT (envelope-from git) Date: Sun, 17 Oct 2021 00:28:41 GMT Message-Id: <202110170028.19H0Sftm042653@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: 7b60409efa14 - stable/13 - Restore PPS_SYNC in NOTES List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 7b60409efa147b3884c5a1b9e543563666ef189f Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=7b60409efa147b3884c5a1b9e543563666ef189f commit 7b60409efa147b3884c5a1b9e543563666ef189f Author: Konstantin Belousov AuthorDate: 2021-10-11 22:02:35 +0000 Commit: Konstantin Belousov CommitDate: 2021-10-17 00:28:13 +0000 Restore PPS_SYNC in NOTES (cherry picked from commit 4cc167a35217f9cee81a2f366e451fae42fd4a6c) --- sys/conf/NOTES | 6 ++++++ sys/powerpc/conf/NOTES | 2 -- sys/riscv/conf/NOTES | 2 -- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/sys/conf/NOTES b/sys/conf/NOTES index 5f97933a512a..f73b5a466366 100644 --- a/sys/conf/NOTES +++ b/sys/conf/NOTES @@ -1250,6 +1250,12 @@ options CAPABILITY_MODE # sandboxes with no global namespace access options HZ=100 +# Enable support for the kernel PLL to use an external PPS signal, +# under supervision of [x]ntpd(8) +# More info in ntpd documentation: http://www.eecis.udel.edu/~ntp + +options PPS_SYNC + # Enable support for generic feed-forward clocks in the kernel. # The feed-forward clock support is an alternative to the feedback oriented # ntpd/system clock approach, and is to be used with a feed-forward diff --git a/sys/powerpc/conf/NOTES b/sys/powerpc/conf/NOTES index 1a0c70fb08f9..78d990331ead 100644 --- a/sys/powerpc/conf/NOTES +++ b/sys/powerpc/conf/NOTES @@ -46,8 +46,6 @@ options PSIM #GDB PSIM ppc simulator options MAMBO #IBM Mambo Full System Simulator options QEMU #QEMU processor emulator -options PPS_SYNC - # The cpufreq(4) driver provides support for CPU frequency control device cpufreq diff --git a/sys/riscv/conf/NOTES b/sys/riscv/conf/NOTES index 60e842ab2709..7dda89bfe1a8 100644 --- a/sys/riscv/conf/NOTES +++ b/sys/riscv/conf/NOTES @@ -20,8 +20,6 @@ options FPE # Floating-point extension support options RACCT_DEFAULT_TO_DISABLED # Set kern.racct.enable=0 by default options INTRNG # Include INTRNG framework -options PPS_SYNC - # RISC-V SBI console device rcons From nobody Sun Oct 17 08:35:45 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 398E518165B4; Sun, 17 Oct 2021 08:35:46 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HXCyB121rz3Drv; Sun, 17 Oct 2021 08:35: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 F384D1D0E; Sun, 17 Oct 2021 08:35:45 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19H8ZjQ1093577; Sun, 17 Oct 2021 08:35:45 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19H8Zjfu093576; Sun, 17 Oct 2021 08:35:45 GMT (envelope-from git) Date: Sun, 17 Oct 2021 08:35:45 GMT Message-Id: <202110170835.19H8Zjfu093576@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Gordon Bergling Subject: git: 9b918d1761ce - stable/13 - ng_ppp(4): Fix a typo in a comment List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: gbe X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 9b918d1761ceced37681773936f08eb6b4f9b44b Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by gbe (doc committer): URL: https://cgit.FreeBSD.org/src/commit/?id=9b918d1761ceced37681773936f08eb6b4f9b44b commit 9b918d1761ceced37681773936f08eb6b4f9b44b Author: Gordon Bergling AuthorDate: 2021-10-14 13:30:32 +0000 Commit: Gordon Bergling CommitDate: 2021-10-17 08:35:19 +0000 ng_ppp(4): Fix a typo in a comment - s/delcared/declared/ (cherry picked from commit 0a8159d8ca85383ec84076396c0a457c6d3e08f9) --- sys/netgraph/ng_ppp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/netgraph/ng_ppp.c b/sys/netgraph/ng_ppp.c index eb639aa3d900..c9cb28fd9d04 100644 --- a/sys/netgraph/ng_ppp.c +++ b/sys/netgraph/ng_ppp.c @@ -1514,7 +1514,7 @@ done: * is increased. * * o If we receive a fragment with seq# < MSEQ, we throw it away - * because we've already delcared it lost. + * because we've already declared it lost. * * This assumes linkNum != NG_PPP_BUNDLE_LINKNUM. */ From nobody Sun Oct 17 08:40:01 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 6410C17F11A3; Sun, 17 Oct 2021 08:40:01 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HXD352K8xz3GDj; Sun, 17 Oct 2021 08:40:01 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 2C30D17E4; Sun, 17 Oct 2021 08:40:01 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19H8e1N4094853; Sun, 17 Oct 2021 08:40:01 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19H8e1st094840; Sun, 17 Oct 2021 08:40:01 GMT (envelope-from git) Date: Sun, 17 Oct 2021 08:40:01 GMT Message-Id: <202110170840.19H8e1st094840@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Gordon Bergling Subject: git: a8dfac9caa7b - stable/12 - ng_ppp(4): Fix a typo in a comment List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: gbe X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: a8dfac9caa7b7624fe2546efd47c217ad86e0085 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by gbe (doc committer): URL: https://cgit.FreeBSD.org/src/commit/?id=a8dfac9caa7b7624fe2546efd47c217ad86e0085 commit a8dfac9caa7b7624fe2546efd47c217ad86e0085 Author: Gordon Bergling AuthorDate: 2021-10-14 13:30:32 +0000 Commit: Gordon Bergling CommitDate: 2021-10-17 08:37:41 +0000 ng_ppp(4): Fix a typo in a comment - s/delcared/declared/ (cherry picked from commit 0a8159d8ca85383ec84076396c0a457c6d3e08f9) --- sys/netgraph/ng_ppp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/netgraph/ng_ppp.c b/sys/netgraph/ng_ppp.c index 086d5481f725..a3dc789ed122 100644 --- a/sys/netgraph/ng_ppp.c +++ b/sys/netgraph/ng_ppp.c @@ -1514,7 +1514,7 @@ done: * is increased. * * o If we receive a fragment with seq# < MSEQ, we throw it away - * because we've already delcared it lost. + * because we've already declared it lost. * * This assumes linkNum != NG_PPP_BUNDLE_LINKNUM. */ From nobody Sun Oct 17 15:32:24 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 40248180D023; Sun, 17 Oct 2021 15:32: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 4HXPBw70MHz4tG3; Sun, 17 Oct 2021 15:32: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 B65C679BB; Sun, 17 Oct 2021 15:32: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 19HFWOws054302; Sun, 17 Oct 2021 15:32:24 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19HFWOHA054301; Sun, 17 Oct 2021 15:32:24 GMT (envelope-from git) Date: Sun, 17 Oct 2021 15:32:24 GMT Message-Id: <202110171532.19HFWOHA054301@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Peek Subject: git: b5d236785dc3 - stable/12 - vmci: fix panic due to freeing unallocated resources List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mp X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: b5d236785dc352a65bc29d97c8a89b40387eb7a0 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by mp: URL: https://cgit.FreeBSD.org/src/commit/?id=b5d236785dc352a65bc29d97c8a89b40387eb7a0 commit b5d236785dc352a65bc29d97c8a89b40387eb7a0 Author: Mark Peek AuthorDate: 2021-10-09 21:21:16 +0000 Commit: Mark Peek CommitDate: 2021-10-17 15:31:53 +0000 vmci: fix panic due to freeing unallocated resources Summary: An error mapping PCI resources results in a panic due to unallocated resources being freed up. This change puts the appropriate checks in place to prevent the panic. PR: 252445 Reported by: Marek Zarychta Tested by: marcus MFC after: 1 week Sponsored by: VMware Test Plan: Along with user testing, also simulated error by inserting a ENXIO return in vmci_map_bars(). Reviewed by: marcus Subscribers: imp Differential Revision: https://reviews.freebsd.org/D32016 (cherry picked from commit 0f14bcbe384091c729464cb770372aeb79061070) --- sys/dev/vmware/vmci/vmci.c | 9 ++++--- sys/dev/vmware/vmci/vmci_event.c | 3 +++ sys/dev/vmware/vmci/vmci_kernel_if.c | 48 ++++++++++++++++++++++++++++++++++- sys/dev/vmware/vmci/vmci_kernel_if.h | 2 ++ sys/dev/vmware/vmci/vmci_queue_pair.c | 3 +++ 5 files changed, 61 insertions(+), 4 deletions(-) diff --git a/sys/dev/vmware/vmci/vmci.c b/sys/dev/vmware/vmci/vmci.c index 3f195231d8e2..9d0cbbdef67c 100644 --- a/sys/dev/vmware/vmci/vmci.c +++ b/sys/dev/vmware/vmci/vmci.c @@ -242,8 +242,10 @@ vmci_detach(device_t dev) vmci_components_cleanup(); - taskqueue_drain(taskqueue_thread, &sc->vmci_delayed_work_task); - mtx_destroy(&sc->vmci_delayed_work_lock); + if mtx_initialized(&sc->vmci_spinlock) { + taskqueue_drain(taskqueue_thread, &sc->vmci_delayed_work_task); + mtx_destroy(&sc->vmci_delayed_work_lock); + } if (sc->vmci_res0 != NULL) bus_space_write_4(sc->vmci_iot0, sc->vmci_ioh0, @@ -254,7 +256,8 @@ vmci_detach(device_t dev) vmci_unmap_bars(sc); - mtx_destroy(&sc->vmci_spinlock); + if mtx_initialized(&sc->vmci_spinlock) + mtx_destroy(&sc->vmci_spinlock); pci_disable_busmaster(dev); diff --git a/sys/dev/vmware/vmci/vmci_event.c b/sys/dev/vmware/vmci/vmci_event.c index 9a932340a7b6..c34ff113978b 100644 --- a/sys/dev/vmware/vmci/vmci_event.c +++ b/sys/dev/vmware/vmci/vmci_event.c @@ -594,6 +594,9 @@ vmci_event_unregister_subscription(vmci_id sub_id) { struct vmci_subscription *s; + if (!vmci_initialized_lock(&subscriber_lock)) + return NULL; + vmci_grab_lock_bh(&subscriber_lock); s = vmci_event_find(sub_id); if (s != NULL) { diff --git a/sys/dev/vmware/vmci/vmci_kernel_if.c b/sys/dev/vmware/vmci/vmci_kernel_if.c index 851c4c9df214..a550277500aa 100644 --- a/sys/dev/vmware/vmci/vmci_kernel_if.c +++ b/sys/dev/vmware/vmci/vmci_kernel_if.c @@ -70,7 +70,8 @@ void vmci_cleanup_lock(vmci_lock *lock) { - mtx_destroy(lock); + if mtx_initialized(lock) + mtx_destroy(lock); } /* @@ -165,6 +166,29 @@ vmci_release_lock_bh(vmci_lock *lock) mtx_unlock(lock); } +/* + *------------------------------------------------------------------------------ + * + * vmci_initialized_lock + * + * Returns whether a lock has been initialized. + * + * Results: + * Return 1 if initialized or 0 if unininitialized. + * + * Side effects: + * None + * + *------------------------------------------------------------------------------ + */ + +int +vmci_initialized_lock(vmci_lock *lock) +{ + + return mtx_initialized(lock); +} + /* *------------------------------------------------------------------------------ * @@ -446,6 +470,28 @@ vmci_mutex_release(vmci_mutex *mutex) mtx_unlock(mutex); } +/* + *------------------------------------------------------------------------------ + * + * vmci_mutex_initialized + * + * Returns whether a mutex has been initialized. + * + * Results: + * Return 1 if initialized or 0 if unininitialized. + * + * Side effects: + * None + * + *------------------------------------------------------------------------------ + */ + +int +vmci_mutex_initialized(vmci_mutex *mutex) +{ + + return mtx_initialized(mutex); +} /* *------------------------------------------------------------------------------ * diff --git a/sys/dev/vmware/vmci/vmci_kernel_if.h b/sys/dev/vmware/vmci/vmci_kernel_if.h index fc23eefe98e0..048e480b0698 100644 --- a/sys/dev/vmware/vmci/vmci_kernel_if.h +++ b/sys/dev/vmware/vmci/vmci_kernel_if.h @@ -48,6 +48,7 @@ void vmci_grab_lock(vmci_lock *lock); void vmci_release_lock(vmci_lock *lock); void vmci_grab_lock_bh(vmci_lock *lock); void vmci_release_lock_bh(vmci_lock *lock); +int vmci_initialized_lock(vmci_lock *lock); void *vmci_alloc_kernel_mem(size_t size, int flags); void vmci_free_kernel_mem(void *ptr, size_t size); @@ -72,6 +73,7 @@ int vmci_mutex_init(vmci_mutex *mutex, char *name); void vmci_mutex_destroy(vmci_mutex *mutex); void vmci_mutex_acquire(vmci_mutex *mutex); void vmci_mutex_release(vmci_mutex *mutex); +int vmci_mutex_initialized(vmci_mutex *mutex); void *vmci_alloc_queue(uint64_t size, uint32_t flags); void vmci_free_queue(void *q, uint64_t size); diff --git a/sys/dev/vmware/vmci/vmci_queue_pair.c b/sys/dev/vmware/vmci/vmci_queue_pair.c index 65ae00c8d167..ebf2824f8d04 100644 --- a/sys/dev/vmware/vmci/vmci_queue_pair.c +++ b/sys/dev/vmware/vmci/vmci_queue_pair.c @@ -338,6 +338,9 @@ vmci_qp_guest_endpoints_exit(void) { struct qp_guest_endpoint *entry; + if (!vmci_mutex_initialized(&qp_guest_endpoints.mutex)) + return; + vmci_mutex_acquire(&qp_guest_endpoints.mutex); while ((entry = From nobody Sun Oct 17 21:15:55 2021 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 00EA017F0313; Sun, 17 Oct 2021 21:15: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 4HXXqH3cZxz4cVm; Sun, 17 Oct 2021 21:15: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 5BE73145D5; Sun, 17 Oct 2021 21:15: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 19HLFtpB009387; Sun, 17 Oct 2021 21:15:55 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19HLFtbq009386; Sun, 17 Oct 2021 21:15:55 GMT (envelope-from git) Date: Sun, 17 Oct 2021 21:15:55 GMT Message-Id: <202110172115.19HLFtbq009386@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: 54a01b5326b9 - stable/13 - vfs: Permit unix sockets to be opened with O_PATH List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 54a01b5326b9b73c4fbccb5bc085b5884eebe814 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=54a01b5326b9b73c4fbccb5bc085b5884eebe814 commit 54a01b5326b9b73c4fbccb5bc085b5884eebe814 Author: Mark Johnston AuthorDate: 2021-09-17 16:34:21 +0000 Commit: Mark Johnston CommitDate: 2021-10-17 21:15:44 +0000 vfs: Permit unix sockets to be opened with O_PATH As with FIFOs, a path descriptor for a unix socket cannot be used with kevent(). In principle connectat(2) and bindat(2) could be modified to support an AT_EMPTY_PATH-like mode which operates on the socket referenced by an O_PATH fd referencing a unix socket. That would eliminate the path length limit imposed by sockaddr_un. Update O_PATH tests. Reviewed by: kib Sponsored by: The FreeBSD Foundation (cherry picked from commit 2bd9826995ca6b23f8b088cfa035c0ad1c578ac3) --- sys/kern/vfs_vnops.c | 11 ++++------- tests/sys/file/path_test.c | 32 ++++++++++++++++++++++++++++---- 2 files changed, 32 insertions(+), 11 deletions(-) diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c index e8d6df5c4193..b78c24e3e313 100644 --- a/sys/kern/vfs_vnops.c +++ b/sys/kern/vfs_vnops.c @@ -393,13 +393,13 @@ vn_open_vnode(struct vnode *vp, int fmode, struct ucred *cred, if ((fmode & O_PATH) == 0 || (fmode & FEXEC) != 0) return (EMLINK); } - if (vp->v_type == VSOCK) - return (EOPNOTSUPP); if (vp->v_type != VDIR && fmode & O_DIRECTORY) return (ENOTDIR); accmode = 0; if ((fmode & O_PATH) == 0) { + if (vp->v_type == VSOCK) + return (EOPNOTSUPP); if ((fmode & (FWRITE | O_TRUNC)) != 0) { if (vp->v_type == VDIR) return (EISDIR); @@ -431,11 +431,8 @@ vn_open_vnode(struct vnode *vp, int fmode, struct ucred *cred, return (error); } if ((fmode & O_PATH) != 0) { - if (vp->v_type == VFIFO) - error = EPIPE; - else - error = VOP_ACCESS(vp, VREAD, cred, td); - if (error == 0) + if (vp->v_type != VFIFO && vp->v_type != VSOCK && + VOP_ACCESS(vp, VREAD, cred, td) == 0) fp->f_flag |= FKQALLOWED; return (0); } diff --git a/tests/sys/file/path_test.c b/tests/sys/file/path_test.c index ad88c691a914..a39862cc78d6 100644 --- a/tests/sys/file/path_test.c +++ b/tests/sys/file/path_test.c @@ -845,13 +845,15 @@ ATF_TC_BODY(path_rights, tc) CHECKED_CLOSE(sd[1]); } -/* Verify that a local socket can't be opened with O_PATH. */ +/* Verify that a local socket can be opened with O_PATH. */ ATF_TC_WITHOUT_HEAD(path_unix); ATF_TC_BODY(path_unix, tc) { - char path[PATH_MAX]; + char buf[BUFSIZ], path[PATH_MAX]; + struct kevent ev; struct sockaddr_un sun; - int pathfd, sd; + struct stat sb; + int kq, pathfd, sd; snprintf(path, sizeof(path), "path_unix.XXXXXX"); ATF_REQUIRE_MSG(mktemp(path) == path, FMT_ERR("mktemp")); @@ -866,9 +868,31 @@ ATF_TC_BODY(path_unix, tc) FMT_ERR("bind")); pathfd = open(path, O_PATH); - ATF_REQUIRE_ERRNO(EOPNOTSUPP, pathfd < 0); + ATF_REQUIRE_MSG(pathfd >= 0, FMT_ERR("open")); + + ATF_REQUIRE_MSG(fstatat(pathfd, "", &sb, AT_EMPTY_PATH) == 0, + FMT_ERR("fstatat")); + ATF_REQUIRE_MSG(sb.st_mode & S_IFSOCK, "socket mode %#x", sb.st_mode); + ATF_REQUIRE_MSG(sb.st_ino != 0, "socket has inode number 0"); + + memset(buf, 0, sizeof(buf)); + ATF_REQUIRE_ERRNO(EBADF, write(pathfd, buf, sizeof(buf))); + ATF_REQUIRE_ERRNO(EBADF, read(pathfd, buf, sizeof(buf))); + + /* kevent() is disallowed with sockets. */ + kq = kqueue(); + ATF_REQUIRE_MSG(kq >= 0, FMT_ERR("kqueue")); + EV_SET(&ev, pathfd, EVFILT_READ, EV_ADD | EV_ENABLE, 0, 0, 0); + ATF_REQUIRE_ERRNO(EBADF, kevent(kq, &ev, 1, NULL, 0, NULL) == -1); + + /* Should not be able to open a socket without O_PATH. */ + ATF_REQUIRE_ERRNO(EOPNOTSUPP, openat(pathfd, "", O_EMPTY_PATH) == -1); + + ATF_REQUIRE_MSG(funlinkat(AT_FDCWD, path, pathfd, 0) == 0, + FMT_ERR("funlinkat")); CHECKED_CLOSE(sd); + CHECKED_CLOSE(pathfd); } ATF_TP_ADD_TCS(tp)