svn commit: r338794 - in head: etc lib/lib80211
Author: brd Date: Wed Sep 19 09:29:06 2018 New Revision: 338794 URL: https://svnweb.freebsd.org/changeset/base/338794 Log: Move regdomain.xml to lib/lib80211/ This leverages CONFS to handle the install. lib80211 was picked because it is where this file is actually used from. Approved by: re (blanket, pkgbase), will (mentor) Differential Revision:https://reviews.freebsd.org/D17229 Added: head/lib/lib80211/regdomain.xml - copied unchanged from r338793, head/etc/regdomain.xml Deleted: head/etc/regdomain.xml Modified: head/etc/Makefile head/lib/lib80211/Makefile Modified: head/etc/Makefile == --- head/etc/Makefile Wed Sep 19 08:13:58 2018(r338793) +++ head/etc/Makefile Wed Sep 19 09:29:06 2018(r338794) @@ -36,10 +36,6 @@ SSL= ${SRCTOP}/crypto/openssl/apps/openssl.cnf BIN1+= rc.sendmail .endif -.if ${MK_WIRELESS} != "no" -BIN1+= regdomain.xml -.endif - .if ${MK_SENDMAIL} == "no" ETCMAIL=mailer.conf aliases .else Modified: head/lib/lib80211/Makefile == --- head/lib/lib80211/Makefile Wed Sep 19 08:13:58 2018(r338793) +++ head/lib/lib80211/Makefile Wed Sep 19 09:29:06 2018(r338794) @@ -1,5 +1,6 @@ # $FreeBSD$ +CONFS= regdomain.xml PACKAGE=lib${LIB} LIB= 80211 SHLIBDIR?= /lib Copied: head/lib/lib80211/regdomain.xml (from r338793, head/etc/regdomain.xml) == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/lib/lib80211/regdomain.xml Wed Sep 19 09:29:06 2018 (r338794, copy of r338793, head/etc/regdomain.xml) @@ -0,0 +1,1943 @@ + + + + + + + + + + + DEBUG + 0x1ff + + + + FCC + 0x10 + + + + + 30 + IEEE80211_CHAN_B + + + + + + 30 + IEEE80211_CHAN_G + + + + + + 17 + + + + 23 + + + + 23 + IEEE80211_CHAN_PASSIVE + + + + + + 30 + IEEE80211_CHAN_G + IEEE80211_CHAN_HT20 + + + + 30 + IEEE80211_CHAN_G + IEEE80211_CHAN_HT40 + + + + + + 17 + IEEE80211_CHAN_HT20 + + + + 17 + IEEE80211_CHAN_HT40 + + + + 23 + IEEE80211_CHAN_HT20 + + + + 23 + IEEE80211_CHAN_HT40 + + + + + + + + FCC3 + 0x3a + + + + 30 + IEEE80211_CHAN_B + + + + + + 30 + IEEE80211_CHAN_G + + + + + + 17 + + + + 23 + IEEE80211_CHAN_PASSIVE + IEEE80211_CHAN_DFS + + + + 23 + IEEE80211_CHAN_PASSIVE + IEEE80211_CHAN_DFS + + + + 23 + IEEE80211_CHAN_PASSIVE + IEEE80211_CHAN_DFS + + + + 23 + IEEE80211_CHAN_PASSIVE + IEEE80211_CHAN_DFS + + + + 23 + IEEE80211_CHAN_PASSIVE + IEEE80211_CHAN_DFS + + + + + + 30 + IEEE80211_CHAN_G + IEEE80211_CHAN_HT20 + + + + 30 + IEEE80211_CHAN_G + IEEE80211_CHAN_HT40 + + + + + + 17 + IEEE80211_CHAN_HT20 + + + + 17 + IEEE80211_CHAN_HT40 + + + + 23 + IEEE80211_CHAN_HT20 + IEEE80211_CHAN_PASSIVE + IEEE80211_CHAN_DFS + + + + 23 + IEEE80211_CHAN_HT40 + IEEE80211_CHAN_PASSIVE + IEEE80211_CHAN_DFS + + + + 23 + IEEE80211_CHAN_HT20 + IEEE80211_CHAN_PASSIVE + IEEE80211_CHAN_DFS + + + + 23 + IEEE80211_CHAN_HT40 + IEEE80211_CHAN_PASSIVE + IEEE80211_CHAN_DFS + + + + 23 + IEEE80211_CHAN_HT20 + IEEE80211_CHAN_PASSIVE + IEEE80211_CHAN_DFS + + + + 23 + IEEE80211_CHAN_HT40 + IEEE80211_CHAN_PASSIVE + IEEE80211_CHAN_DFS + + + + 23 + IEEE80211_CHAN_HT20 + + + + 23 + IEEE80211_CHAN_HT40 + IEEE80211_CHAN_PASSIVE + IEEE80211_CHAN_DFS + + + + + + + + FCC4 + 0x12 + + + + 30 + IEEE80211_CHAN_B + + + + + + 30 + IEEE80211_CHAN_G + + + + + + 23 + + + + 27 + + + + 30 + + + + + + 30 + IEEE80211_CHAN_G + IEEE80211_CHAN_HT20 + + + + 30 + IEEE80211_CHAN_G + IEEE80211_CHAN_HT40 + + + + + + JAPAN + 0x40 + + + + + 23 + IEEE80211_CHAN_B + + + + 23 + IEEE80211_CHAN_B + + + + + + 23 + IEEE80211_CHAN_G + + + + + + 23 + + + + 23 + + + + 23 +
svn commit: r338798 - in head/sys: kern ufs/ufs
Author: kib Date: Wed Sep 19 14:36:57 2018 New Revision: 338798 URL: https://svnweb.freebsd.org/changeset/base/338798 Log: Fix state of dquot-less vnodes after failed quotaoff. UFS quotaoff iterates over all mp vnodes, and derefences and clears the pointers to corresponding dquots. If SU work items transiently reference some of dquots,quotaoff() would eventually fail, but all processed vnodes are already stripped from dquots. The state is problematic, since quotas are left enabled, but there is no dquots where blocks and inodes can be accounted. The result is assertion failures and NULL pointer dereferences. Fix it by suspending writes around quotaoff() call. Since the filesystem is synced, no dandling references to dquots from SU workitems can left behind, which means that quotaoff succeeds. The complication there is that quotaoff VFS op is performed with the mount point busied, while to suspend, we need to start write on the mp. If vn_start_write() is called on busied mp, system might deadlock against parallel unmount request. Handle this by unbusy-ing mp before starting write, which in turn requires changing the quotaoff() interface to return with the mount point not busied, same as was done for quotaon(). Reviewed by: mckusick Reported and tested by: pho Sponsored by: The FreeBSD Foundation Approved by: re (gjb) MFC after:1 week Differential revision:https://reviews.freebsd.org/D17208 Modified: head/sys/kern/vfs_syscalls.c head/sys/ufs/ufs/ufs_quota.c head/sys/ufs/ufs/ufs_vfsops.c Modified: head/sys/kern/vfs_syscalls.c == --- head/sys/kern/vfs_syscalls.cWed Sep 19 10:26:45 2018 (r338797) +++ head/sys/kern/vfs_syscalls.cWed Sep 19 14:36:57 2018 (r338798) @@ -190,7 +190,8 @@ sys_quotactl(struct thread *td, struct quotactl_args * * Require that Q_QUOTAON handles the vfs_busy() reference on * its own, always returning with ubusied mount point. */ - if ((uap->cmd >> SUBCMDSHIFT) != Q_QUOTAON) + if ((uap->cmd >> SUBCMDSHIFT) != Q_QUOTAON && + (uap->cmd >> SUBCMDSHIFT) != Q_QUOTAOFF) vfs_unbusy(mp); return (error); } Modified: head/sys/ufs/ufs/ufs_quota.c == --- head/sys/ufs/ufs/ufs_quota.cWed Sep 19 10:26:45 2018 (r338797) +++ head/sys/ufs/ufs/ufs_quota.cWed Sep 19 14:36:57 2018 (r338798) @@ -712,6 +712,34 @@ again: return (error); } +static int +quotaoff_inchange1(struct thread *td, struct mount *mp, int type) +{ + int error; + bool need_resume; + + /* +* mp is already suspended on unmount. If not, suspend it, to +* avoid the situation where quotaoff operation eventually +* failing due to SU structures still keeping references on +* dquots, but vnode's references are already clean. This +* would cause quota accounting leak and asserts otherwise. +* Note that the thread has already called vn_start_write(). +*/ + if (mp->mnt_susp_owner == td) { + need_resume = false; + } else { + error = vfs_write_suspend_umnt(mp); + if (error != 0) + return (error); + need_resume = true; + } + error = quotaoff1(td, mp, type); + if (need_resume) + vfs_write_resume(mp, VR_START_WRITE); + return (error); +} + /* * Turns off quotas, assumes that ump->um_qflags are already checked * and QTF_CLOSING is set to indicate operation in progress. Fixes @@ -721,10 +749,9 @@ int quotaoff_inchange(struct thread *td, struct mount *mp, int type) { struct ufsmount *ump; - int i; - int error; + int error, i; - error = quotaoff1(td, mp, type); + error = quotaoff_inchange1(td, mp, type); ump = VFSTOUFS(mp); UFS_LOCK(ump); Modified: head/sys/ufs/ufs/ufs_vfsops.c == --- head/sys/ufs/ufs/ufs_vfsops.c Wed Sep 19 10:26:45 2018 (r338797) +++ head/sys/ufs/ufs/ufs_vfsops.c Wed Sep 19 14:36:57 2018 (r338798) @@ -94,7 +94,8 @@ ufs_quotactl(mp, cmds, id, arg) void *arg; { #ifndef QUOTA - if ((cmds >> SUBCMDSHIFT) == Q_QUOTAON) + if ((cmds >> SUBCMDSHIFT) == Q_QUOTAON || + (cmds >> SUBCMDSHIFT) == Q_QUOTAOFF) vfs_unbusy(mp); return (EOPNOTSUPP); @@ -117,13 +118,13 @@ ufs_quotactl(mp, cmds, id, arg) break; default: - if (cmd == Q_QUOTAON) + if (cmd == Q_QUOTAON || cmd == Q_QUOTAOFF) vfs_unbusy(mp); return (
svn commit: r338799 - head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs
Author: kib Date: Wed Sep 19 14:38:01 2018 New Revision: 338799 URL: https://svnweb.freebsd.org/changeset/base/338799 Log: Fix ZFS VFS op quotactl to follow busy protocol. Reviewed by: avg, mckusick Tested by:pho Sponsored by: The FreeBSD Foundation Approved by: re (gjb) MFC after:1 week Differential revision:https://reviews.freebsd.org/D17208 Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c == --- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.cWed Sep 19 14:36:57 2018(r338798) +++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.cWed Sep 19 14:38:01 2018(r338799) @@ -198,6 +198,8 @@ zfs_quotactl(vfs_t *vfsp, int cmds, uid_t id, void *ar break; default: error = EINVAL; + if (cmd == Q_QUOTAON || cmd == Q_QUOTAOFF) + vfs_unbusy(vfsp); goto done; } } @@ -255,9 +257,11 @@ zfs_quotactl(vfs_t *vfsp, int cmds, uid_t id, void *ar case Q_QUOTAON: // As far as I can tell, you can't turn quotas on or off on zfs error = 0; + vfs_unbusy(vfsp); break; case Q_QUOTAOFF: error = ENOTSUP; + vfs_unbusy(vfsp); break; case Q_SETQUOTA: error = copyin(&dqblk, arg, sizeof(dqblk)); ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r338800 - in head: etc usr.bin/tip/tip
Author: brd Date: Wed Sep 19 14:56:53 2018 New Revision: 338800 URL: https://svnweb.freebsd.org/changeset/base/338800 Log: Move remote & phones to usr.bin/tip/tip/ Approved by: re (blanket, pkgbase), will (mentor) Differential Revision:https://reviews.freebsd.org/D17219 Added: head/usr.bin/tip/tip/phones - copied unchanged from r338799, head/etc/phones head/usr.bin/tip/tip/remote - copied unchanged from r338799, head/etc/remote Deleted: head/etc/phones head/etc/remote Modified: head/etc/Makefile head/usr.bin/tip/tip/Makefile Modified: head/etc/Makefile == --- head/etc/Makefile Wed Sep 19 14:38:01 2018(r338799) +++ head/etc/Makefile Wed Sep 19 14:56:53 2018(r338800) @@ -16,10 +16,8 @@ BIN1=\ group \ hosts.allow \ login.access \ - phones \ rc.bsdextended \ rc.firewall \ - remote \ termcap.small # NB: keep these sorted by MK_* knobs Modified: head/usr.bin/tip/tip/Makefile == --- head/usr.bin/tip/tip/Makefile Wed Sep 19 14:38:01 2018 (r338799) +++ head/usr.bin/tip/tip/Makefile Wed Sep 19 14:56:53 2018 (r338800) @@ -31,6 +31,7 @@ # explicitly to remcap.c if not 1024 # CONNECT enable ~C command (connect pgm to remote) +CONFS= phones remote PROG= tip LINKS= ${BINDIR}/tip ${BINDIR}/cu MAN= tip.1 cu.1 @@ -46,6 +47,9 @@ SRCS= acu.c acutab.c cmds.c cmdtab.c cu.c hunt.c log.c # -- remote.o depends on the Makefile because of DEFBR and DEFFS # -- log.o depends on the Makefile because of ACULOG acutab.o log.o remote.o: Makefile + +# Don't rebuild based on remote.c +remote: .MADE .include Copied: head/usr.bin/tip/tip/phones (from r338799, head/etc/phones) == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/usr.bin/tip/tip/phones Wed Sep 19 14:56:53 2018(r338800, copy of r338799, head/etc/phones) @@ -0,0 +1,8 @@ +# $FreeBSD$ +# From: @(#)phones5.2 (Berkeley) 6/30/90 +# +# phones -- remote host phone number data base +# see tip(1), phones(5) +# examples: +#system1 9=2225551212 +#system2 9995551212 Copied: head/usr.bin/tip/tip/remote (from r338799, head/etc/remote) == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/usr.bin/tip/tip/remote Wed Sep 19 14:56:53 2018(r338800, copy of r338799, head/etc/remote) @@ -0,0 +1,76 @@ +# $FreeBSD$ +# +# @(#)remote 5.2 (Berkeley) 6/30/90 +# +# remote -- remote host description file +# see tip(1), remote(5) +# +# at ACU type +# br bit rate (defaults to 9600) +# cu call unit (default is dv) +# du make a call flag (dial up) +# dv device to use for the tty +# el EOL marks (default is NULL) +# fs frame size (default is BUFSIZ) -- used in buffering writes on +# receive operations +# ie input EOF marks (default is NULL) +# oe output EOF string (default is NULL) +# pa The parity type to use: even, odd, none, zero, one (default even) +# pn phone numbers (@ =>'s search phones file; possibly taken from +# PHONES environment variable) +# tc to continue a capability + +# Example systems +unixshell|Unix Access:\ + :pn=\@:tc=unix57600: +dosbbs|DOS-based BBS:\ + :pn=\@:tc=dos57600: + +# UNIX system definitions +unix57600|57600 Baud dial-out to a UNIX system:\ + :el=^U^C^R^O^D^S^Q:ie=%$:oe=^D:tc=dial57600: +unix33600|33600 Baud dial-out to a UNIX system:\ + :el=^U^C^R^O^D^S^Q:ie=%$:oe=^D:tc=dial33600: + +# DOS system definitions +dos57600|57600 Baud dial-out to a DOS system:\ + :el=^U^C^R^O^D^S^Q:ie=%$:oe=^Z:pa=none:tc=dial57600: + +# 33.6k and 56k modems run the com port at 115200 bps to allow for the +# compression performed in the modem. Note that some serial hardware +# does not support speeds above 38400 bps and that speeds above that have +# never been formally standardized. Modern architectures with 16550 or +# better UARTs typically have no issues with the higher speeds. +dial57600|57600 Baud Hayes attributes:\ + br#115200:tc=dial: +dial33600|33600 Baud Hayes attributes:\ + br#115200:tc=dial: +# 14.4k and 28.8k modems ran the port at 4x. Some rare 19.2 baud modems +# did too, but those aren't included in this example. +dial28800|28800 Baud Hayes attributes:\ + br#115200:tc=dial: +dial14400|14400 Baud Hayes attributes:\ + br#57600:tc=dial: +dial|Generic dialing parameters:\ + :dv=/dev/cuau0:cu=/dev/cuau0:at=hayes:du:pa=none: + +# Hardwired line +cuau0c|cua0c:dv=/dev/cuau0:br#9600:pa=none: + +# Finger friendly shortcuts +uart0|com1:dv=/dev/cuau0:br#9600:pa=none: +ua
svn commit: r338801 - head/sys/amd64/amd64
Author: kib Date: Wed Sep 19 15:39:16 2018 New Revision: 338801 URL: https://svnweb.freebsd.org/changeset/base/338801 Log: amd64 pmap: remove tautological assert. pm_pcid is unsigned. Reviewed by: cem, markj CID: 1395727 Noted by: cem Sponsored by: The FreeBSD Foundation Approved by: re (gjb) MFC after:3 days Differential revision:https://reviews.freebsd.org/D17235 Modified: head/sys/amd64/amd64/pmap.c Modified: head/sys/amd64/amd64/pmap.c == --- head/sys/amd64/amd64/pmap.c Wed Sep 19 14:56:53 2018(r338800) +++ head/sys/amd64/amd64/pmap.c Wed Sep 19 15:39:16 2018(r338801) @@ -7442,8 +7442,7 @@ pmap_pcid_alloc_checked(pmap_t pmap, u_int cpuid) uint64_t cached; cached = pmap_pcid_alloc(pmap, cpuid); - KASSERT(pmap->pm_pcids[cpuid].pm_pcid >= 0 && - pmap->pm_pcids[cpuid].pm_pcid < PMAP_PCID_OVERMAX, + KASSERT(pmap->pm_pcids[cpuid].pm_pcid < PMAP_PCID_OVERMAX, ("pmap %p cpu %d pcid %#x", pmap, cpuid, pmap->pm_pcids[cpuid].pm_pcid)); KASSERT(pmap->pm_pcids[cpuid].pm_pcid != PMAP_PCID_KERN || ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r338802 - head/sys/vm
Author: mjg Date: Wed Sep 19 16:02:33 2018 New Revision: 338802 URL: https://svnweb.freebsd.org/changeset/base/338802 Log: vm: check for empty kstack cache before locking The current cache logic checks the total number of stacks in the kernel, which even on small boxes significantly exceeds the 128 limit (e.g. an 8-way box with zfs has almost 800 stacks allocated). Stacks are cached earlier for each main thread. As a result the code is rarely executed, but when it is then (on boxes like the above) it always fails. Since there are no provisions made for NUMA and release time is approaching, just do a quick check to avoid acquiring the lock. Approved by: re (kib) Modified: head/sys/vm/vm_glue.c Modified: head/sys/vm/vm_glue.c == --- head/sys/vm/vm_glue.c Wed Sep 19 15:39:16 2018(r338801) +++ head/sys/vm/vm_glue.c Wed Sep 19 16:02:33 2018(r338802) @@ -327,7 +327,7 @@ vm_thread_new(struct thread *td, int pages) else if (pages > KSTACK_MAX_PAGES) pages = KSTACK_MAX_PAGES; - if (pages == kstack_pages) { + if (pages == kstack_pages && kstack_cache != NULL) { mtx_lock(&kstack_cache_mtx); if (kstack_cache != NULL) { ks_ce = kstack_cache; ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
Re: svn commit: r338802 - head/sys/vm
On Wed, Sep 19, 2018 at 04:02:34PM +, Mateusz Guzik wrote: > Author: mjg > Date: Wed Sep 19 16:02:33 2018 > New Revision: 338802 > URL: https://svnweb.freebsd.org/changeset/base/338802 > > Log: > vm: check for empty kstack cache before locking > > The current cache logic checks the total number of stacks in the kernel, > which even on small boxes significantly exceeds the 128 limit (e.g. an > 8-way box with zfs has almost 800 stacks allocated). > > Stacks are cached earlier for each main thread. > > As a result the code is rarely executed, but when it is then (on boxes like > the above) it always fails. Since there are no provisions made for NUMA and > release time is approaching, just do a quick check to avoid acquiring the > lock. > > Approved by:re (kib) > > Modified: > head/sys/vm/vm_glue.c > > Modified: head/sys/vm/vm_glue.c > == > --- head/sys/vm/vm_glue.c Wed Sep 19 15:39:16 2018(r338801) > +++ head/sys/vm/vm_glue.c Wed Sep 19 16:02:33 2018(r338802) > @@ -327,7 +327,7 @@ vm_thread_new(struct thread *td, int pages) > else if (pages > KSTACK_MAX_PAGES) > pages = KSTACK_MAX_PAGES; > > - if (pages == kstack_pages) { > + if (pages == kstack_pages && kstack_cache != NULL) { > mtx_lock(&kstack_cache_mtx); > if (kstack_cache != NULL) { > ks_ce = kstack_cache; Since kstack_cache is guaranteed not to be NULL, can the second conditional that checks for kstack_cache not being NULL be removed? Thanks, -- Shawn Webb Cofounder and Security Engineer HardenedBSD Tor-ified Signal:+1 443-546-8752 Tor+XMPP+OTR:latt...@is.a.hacker.sx GPG Key ID: 0x6A84658F52456EEE GPG Key Fingerprint: 2ABA B6BD EF6A F486 BE89 3D9E 6A84 658F 5245 6EEE signature.asc Description: PGP signature
Re: svn commit: r338802 - head/sys/vm
On Wed, Sep 19, 2018 at 6:08 PM, Shawn Webb wrote: > On Wed, Sep 19, 2018 at 04:02:34PM +, Mateusz Guzik wrote: > > Author: mjg > > Date: Wed Sep 19 16:02:33 2018 > > New Revision: 338802 > > URL: https://svnweb.freebsd.org/changeset/base/338802 > > > > Log: > > vm: check for empty kstack cache before locking > > > > The current cache logic checks the total number of stacks in the > kernel, > > which even on small boxes significantly exceeds the 128 limit (e.g. an > > 8-way box with zfs has almost 800 stacks allocated). > > > > Stacks are cached earlier for each main thread. > > > > As a result the code is rarely executed, but when it is then (on boxes > like > > the above) it always fails. Since there are no provisions made for > NUMA and > > release time is approaching, just do a quick check to avoid acquiring > the > > lock. > > > > Approved by:re (kib) > > > > Modified: > > head/sys/vm/vm_glue.c > > > > Modified: head/sys/vm/vm_glue.c > > > == > > --- head/sys/vm/vm_glue.c Wed Sep 19 15:39:16 2018(r338801) > > +++ head/sys/vm/vm_glue.c Wed Sep 19 16:02:33 2018(r338802) > > @@ -327,7 +327,7 @@ vm_thread_new(struct thread *td, int pages) > > else if (pages > KSTACK_MAX_PAGES) > > pages = KSTACK_MAX_PAGES; > > > > - if (pages == kstack_pages) { > > + if (pages == kstack_pages && kstack_cache != NULL) { > > mtx_lock(&kstack_cache_mtx); > > if (kstack_cache != NULL) { > > ks_ce = kstack_cache; > > Since kstack_cache is guaranteed not to be NULL, can the second > conditional that checks for kstack_cache not being NULL be removed? > > The one with the lock held? By the time we get there someone else might have removed the last cached stack making the pointer NULL. Checking a condition before locking and then checking again is a common optimization pattern for cases where the condition is likely false. -- Mateusz Guzik ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
Re: svn commit: r338802 - head/sys/vm
On Wed, Sep 19, 2018 at 06:12:29PM +0200, Mateusz Guzik wrote: > On Wed, Sep 19, 2018 at 6:08 PM, Shawn Webb > wrote: > > > On Wed, Sep 19, 2018 at 04:02:34PM +, Mateusz Guzik wrote: > > > Author: mjg > > > Date: Wed Sep 19 16:02:33 2018 > > > New Revision: 338802 > > > URL: https://svnweb.freebsd.org/changeset/base/338802 > > > > > > Log: > > > vm: check for empty kstack cache before locking > > > > > > The current cache logic checks the total number of stacks in the > > kernel, > > > which even on small boxes significantly exceeds the 128 limit (e.g. an > > > 8-way box with zfs has almost 800 stacks allocated). > > > > > > Stacks are cached earlier for each main thread. > > > > > > As a result the code is rarely executed, but when it is then (on boxes > > like > > > the above) it always fails. Since there are no provisions made for > > NUMA and > > > release time is approaching, just do a quick check to avoid acquiring > > the > > > lock. > > > > > > Approved by:re (kib) > > > > > > Modified: > > > head/sys/vm/vm_glue.c > > > > > > Modified: head/sys/vm/vm_glue.c > > > > > == > > > --- head/sys/vm/vm_glue.c Wed Sep 19 15:39:16 2018(r338801) > > > +++ head/sys/vm/vm_glue.c Wed Sep 19 16:02:33 2018(r338802) > > > @@ -327,7 +327,7 @@ vm_thread_new(struct thread *td, int pages) > > > else if (pages > KSTACK_MAX_PAGES) > > > pages = KSTACK_MAX_PAGES; > > > > > > - if (pages == kstack_pages) { > > > + if (pages == kstack_pages && kstack_cache != NULL) { > > > mtx_lock(&kstack_cache_mtx); > > > if (kstack_cache != NULL) { > > > ks_ce = kstack_cache; > > > > Since kstack_cache is guaranteed not to be NULL, can the second > > conditional that checks for kstack_cache not being NULL be removed? > > > > > The one with the lock held? By the time we get there someone else might > have removed the last cached stack making the pointer NULL. > > Checking a condition before locking and then checking again is a common > optimization pattern for cases where the condition is likely false. Ah, I understand now. Thanks for the clarification! -- Shawn Webb Cofounder and Security Engineer HardenedBSD Tor-ified Signal:+1 443-546-8752 Tor+XMPP+OTR:latt...@is.a.hacker.sx GPG Key ID: 0x6A84658F52456EEE GPG Key Fingerprint: 2ABA B6BD EF6A F486 BE89 3D9E 6A84 658F 5245 6EEE signature.asc Description: PGP signature
svn commit: r338803 - head/sys/i386/i386
Author: kib Date: Wed Sep 19 16:37:43 2018 New Revision: 338803 URL: https://svnweb.freebsd.org/changeset/base/338803 Log: Convert i386 NPX hardware context save methods to ifuncs. Since ifunc-capable linker is now required on i386, bring this code in line with the amd64 counterpart. Reviewed by: alc, markj Sponsored by: The FreeBSD Foundation Approved by: re (gjb) Differential revision:https://reviews.freebsd.org/D16736 Modified: head/sys/i386/i386/npx.c Modified: head/sys/i386/i386/npx.c == --- head/sys/i386/i386/npx.cWed Sep 19 16:02:33 2018(r338802) +++ head/sys/i386/i386/npx.cWed Sep 19 16:37:43 2018(r338803) @@ -67,6 +67,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include @@ -183,7 +184,6 @@ CTASSERT(X86_XSTATE_XCR0_OFFSET >= offsetof(struct sav static voidfpu_clean_state(void); -static voidfpusave(union savefpu *); static voidfpurstor(union savefpu *); inthw_float; @@ -206,8 +206,6 @@ struct xsave_area_elm_descr { u_int size; } *xsave_area_desc; -static int use_xsaveopt; - static volatile u_int npx_traps_while_probing; alias_for_inthand_t probetrap; @@ -314,6 +312,69 @@ cleanup: return (hw_float); } +static void +npxsave_xsaveopt(union savefpu *addr) +{ + + xsaveopt((char *)addr, xsave_mask); +} + +static void +fpusave_xsave(union savefpu *addr) +{ + + xsave((char *)addr, xsave_mask); +} + +static void +fpusave_fxsave(union savefpu *addr) +{ + + fxsave((char *)addr); +} + +static void +fpusave_fnsave(union savefpu *addr) +{ + + fnsave((char *)addr); +} + +static void +init_xsave(void) +{ + + if (use_xsave) + return; + if (!cpu_fxsr || (cpu_feature2 & CPUID2_XSAVE) == 0) + return; + use_xsave = 1; + TUNABLE_INT_FETCH("hw.use_xsave", &use_xsave); +} + +DEFINE_IFUNC(, void, npxsave_core, (union savefpu *), static) +{ + + init_xsave(); + if (use_xsave) + return ((cpu_stdext_feature & CPUID_EXTSTATE_XSAVEOPT) != 0 ? + npxsave_xsaveopt : fpusave_xsave); + if (cpu_fxsr) + return (fpusave_fxsave); + return (fpusave_fnsave); +} + +DEFINE_IFUNC(, void, fpusave, (union savefpu *), static) +{ + + init_xsave(); + if (use_xsave) + return (fpusave_xsave); + if (cpu_fxsr) + return (fpusave_fxsave); + return (fpusave_fnsave); +} + /* * Enable XSAVE if supported and allowed by user. * Calculate the xsave_mask. @@ -325,13 +386,8 @@ npxinit_bsp1(void) uint64_t xsave_mask_user; TUNABLE_INT_FETCH("hw.lazy_fpu_switch", &lazy_fpu_switch); - if (cpu_fxsr && (cpu_feature2 & CPUID2_XSAVE) != 0) { - use_xsave = 1; - TUNABLE_INT_FETCH("hw.use_xsave", &use_xsave); - } if (!use_xsave) return; - cpuid_count(0xd, 0x0, cp); xsave_mask = XFEATURE_ENABLED_X87 | XFEATURE_ENABLED_SSE; if ((cp[0] & xsave_mask) != xsave_mask) @@ -345,14 +401,9 @@ npxinit_bsp1(void) xsave_mask &= ~XFEATURE_AVX512; if ((xsave_mask & XFEATURE_MPX) != XFEATURE_MPX) xsave_mask &= ~XFEATURE_MPX; - - cpuid_count(0xd, 0x1, cp); - if ((cp[0] & CPUID_EXTSTATE_XSAVEOPT) != 0) - use_xsaveopt = 1; } /* - * Calculate the fpu save area size. */ static void @@ -867,15 +918,11 @@ npxdna(void) * npxsave() atomically with checking fpcurthread. */ void -npxsave(addr) - union savefpu *addr; +npxsave(union savefpu *addr) { stop_emulating(); - if (use_xsaveopt) - xsaveopt((char *)addr, xsave_mask); - else - fpusave(addr); + npxsave_core(addr); } void npxswitch(struct thread *td, struct pcb *pcb); @@ -1097,19 +1144,6 @@ npxsetregs(struct thread *td, union savefpu *addr, cha } critical_exit(); return (error); -} - -static void -fpusave(addr) - union savefpu *addr; -{ - - if (use_xsave) - xsave((char *)addr, xsave_mask); - else if (cpu_fxsr) - fxsave(addr); - else - fnsave(addr); } static void ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
Re: svn commit: r336601 - head
[I was asked what the fix might be. So I suggest specifics.] On 2018-Sep-16, at 10:06 AM, Mark Millard wrote: > Looks like this head/ObsoleteFiles.inc update has a typo > in each thing added to OLD_FILES . . . > > # ls -lTdt /usr/tests/usr.bin/indent/* > -r--r--r-- 1 root wheel 121 Sep 13 22:53:30 2018 > /usr/tests/usr.bin/indent/Kyuafile > . . . > -r--r--r-- 1 root wheel 295 Sep 13 22:53:29 2018 > /usr/tests/usr.bin/indent/binary.0 > -r--r--r-- 1 root wheel92 May 1 19:35:24 2018 > /usr/tests/usr.bin/indent/sac.0.pro > -r--r--r-- 1 root wheel 130 May 1 19:35:24 2018 > /usr/tests/usr.bin/indent/sac.0.stdout > -r--r--r-- 1 root wheel 122 May 1 19:35:24 2018 > /usr/tests/usr.bin/indent/sac.0 > -r--r--r-- 1 root wheel94 May 1 19:35:24 2018 > /usr/tests/usr.bin/indent/nsac.0.pro > -r--r--r-- 1 root wheel 130 May 1 19:35:24 2018 > /usr/tests/usr.bin/indent/nsac.0.stdout > -r--r--r-- 1 root wheel 123 May 1 19:35:24 2018 > /usr/tests/usr.bin/indent/nsac.0 > > vs. ( note usr.bin vs. usr/bin ): > > Modified: head/ObsoleteFiles.inc > == > --- head/ObsoleteFiles.incSun Jul 22 12:04:21 2018(r336600) > +++ head/ObsoleteFiles.incSun Jul 22 12:45:02 2018(r336601) > @@ -38,6 +38,13 @@ > # xargs -n1 | sort | uniq -d; > # done > > +# 20180722: indent(1) option renamed, test files follow > +OLD_FILES+=usr/bin/indent/tests/nsac.0 > +OLD_FILES+=usr/bin/indent/tests/nsac.0.pro > +OLD_FILES+=usr/bin/indent/tests/nsac.0.stdout > +OLD_FILES+=usr/bin/indent/tests/sac.0 > +OLD_FILES+=usr/bin/indent/tests/sac.0.pro > +OLD_FILES+=usr/bin/indent/tests/sac.0.stdout > # 20180721: move of libmlx5.so.1 and libibverbs.so.1 > OLD_LIBS+=usr/lib/libmlx5.so.1 > OLD_LIBS+=usr/lib/libibverbs.so.1 As near as I can tell the fix would be something like (leading whitespace seems to be disappearing): # svnlite diff /usr/src/ObsoleteFiles.inc Index: /usr/src/ObsoleteFiles.inc === --- /usr/src/ObsoleteFiles.inc (revision 338675) +++ /usr/src/ObsoleteFiles.inc (working copy) @@ -48,12 +48,12 @@ # 20180725: Cleanup old libcasper.so.0 OLD_LIBS+=lib/libcasper.so.0 # 20180722: indent(1) option renamed, test files follow -OLD_FILES+=usr/bin/indent/tests/nsac.0 -OLD_FILES+=usr/bin/indent/tests/nsac.0.pro -OLD_FILES+=usr/bin/indent/tests/nsac.0.stdout -OLD_FILES+=usr/bin/indent/tests/sac.0 -OLD_FILES+=usr/bin/indent/tests/sac.0.pro -OLD_FILES+=usr/bin/indent/tests/sac.0.stdout +OLD_FILES+=usr/tests/usr.bin/indent/nsac.0 +OLD_FILES+=usr/tests/usr.bin/indent/nsac.0.pro +OLD_FILES+=usr/tests/usr.bin/indent/nsac.0.stdout +OLD_FILES+=usr/tests/usr.bin/indent/sac.0 +OLD_FILES+=usr/tests/usr.bin/indent/sac.0.pro +OLD_FILES+=usr/tests/usr.bin/indent/sac.0.stdout # 20180721: move of libmlx5.so.1 and libibverbs.so.1 OLD_LIBS+=usr/lib/libmlx5.so.1 OLD_LIBS+=usr/lib/libibverbs.so.1 This is sort of like the older part of the file: # 20170322: rename to _test to match the FreeBSD test suite name scheme OLD_FILES+=usr/tests/usr.bin/col/col OLD_FILES+=usr/tests/usr.bin/diff/diff OLD_FILES+=usr/tests/usr.bin/ident/ident OLD_FILES+=usr/tests/usr.bin/mkimg/mkimg OLD_FILES+=usr/tests/usr.bin/sdiff/sdiff OLD_FILES+=usr/tests/usr.bin/soelim/soelim OLD_FILES+=usr/tests/usr.sbin/pw/pw_config OLD_FILES+=usr/tests/usr.sbin/pw/pw_etcdir OLD_FILES+=usr/tests/usr.sbin/pw/pw_groupadd OLD_FILES+=usr/tests/usr.sbin/pw/pw_groupdel OLD_FILES+=usr/tests/usr.sbin/pw/pw_groupmod OLD_FILES+=usr/tests/usr.sbin/pw/pw_lock OLD_FILES+=usr/tests/usr.sbin/pw/pw_useradd OLD_FILES+=usr/tests/usr.sbin/pw/pw_userdel OLD_FILES+=usr/tests/usr.sbin/pw/pw_usermod OLD_FILES+=usr/tests/usr.sbin/pw/pw_usernext === Mark Millard marklmi at yahoo.com ( dsl-only.net went away in early 2018-Mar) ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r338804 - head/sys/netinet6
Author: bz Date: Wed Sep 19 18:49:37 2018 New Revision: 338804 URL: https://svnweb.freebsd.org/changeset/base/338804 Log: Update udp6_output() inp locking to avoid concurrency issues with route cache updates. Bring over locking changes applied to udp_output() for the route cache in r297225 and fixed in r306559 which achieve multiple things: (1) acquire an exclusive inp lock earlier depending on the expected conditions; we add a comment explaining this in udp6, (2) having acquired the exclusive lock earlier eliminates a slight possible chance for a race condition which was present in v4 for multiple years as well and is now gone, and (3) only pass the inp_route6 to ip6_output() if we are holding an exclusive inp lock, so that possible route cache updates in case of routing table generation number changes can happen safely. In addition this change (as the legacy IP counterpart) decomposes the tracking of inp and pcbinfo lock and adds extra assertions, that the two together are acquired correctly. PR: 230950 Reviewed by: karels, markj Approved by: re (gjb) Pointyhat to: bz (for completely missing this bit) Differential Revision:https://reviews.freebsd.org/D17230 Modified: head/sys/netinet6/udp6_usrreq.c Modified: head/sys/netinet6/udp6_usrreq.c == --- head/sys/netinet6/udp6_usrreq.c Wed Sep 19 16:37:43 2018 (r338803) +++ head/sys/netinet6/udp6_usrreq.c Wed Sep 19 18:49:37 2018 (r338804) @@ -698,7 +698,7 @@ udp6_output(struct socket *so, int flags_arg, struct m u_int32_t ulen, plen; uint16_t cscov; u_short fport; - uint8_t nxt, unlock_udbinfo; + uint8_t nxt, unlock_inp, unlock_udbinfo; /* addr6 has been validated in udp6_send(). */ sin6 = (struct sockaddr_in6 *)addr6; @@ -734,7 +734,22 @@ udp6_output(struct socket *so, int flags_arg, struct m inp = sotoinpcb(so); KASSERT(inp != NULL, ("%s: inp == NULL", __func__)); - INP_RLOCK(inp); + /* +* In the following cases we want a write lock on the inp for either +* local operations or for possible route cache updates in the IPv6 +* output path: +* - on connected sockets (sin6 is NULL) for route cache updates, +* - when we are not bound to an address and source port (it is +* in6_pcbsetport() which will require the write lock). +*/ + if (sin6 == NULL || (IN6_IS_ADDR_UNSPECIFIED(&inp->in6p_laddr) && + inp->inp_lport == 0)) { + INP_WLOCK(inp); + unlock_inp = UH_WLOCKED; + } else { + INP_RLOCK(inp); + unlock_inp = UH_RLOCKED; + } nxt = (inp->inp_socket->so_proto->pr_protocol == IPPROTO_UDP) ? IPPROTO_UDP : IPPROTO_UDPLITE; @@ -758,7 +773,10 @@ udp6_output(struct socket *so, int flags_arg, struct m * potential race in which the factors causing us to * select the UDPv4 output routine are invalidated? */ - INP_RUNLOCK(inp); + if (unlock_inp == UH_WLOCKED) + INP_WUNLOCK(inp); + else + INP_RUNLOCK(inp); if (sin6) in6_sin6_2_sin_in_sock((struct sockaddr *)sin6); pru = inetsw[ip_protox[nxt]].pr_usrreqs; @@ -772,7 +790,10 @@ udp6_output(struct socket *so, int flags_arg, struct m if (control) { if ((error = ip6_setpktopts(control, &opt, inp->in6p_outputopts, td->td_ucred, nxt)) != 0) { - INP_RUNLOCK(inp); + if (unlock_inp == UH_WLOCKED) + INP_WUNLOCK(inp); + else + INP_RUNLOCK(inp); ip6_clearpktopts(&opt, -1); if (control) m_freem(control); @@ -786,12 +807,6 @@ udp6_output(struct socket *so, int flags_arg, struct m pcbinfo = udp_get_inpcbinfo(so->so_proto->pr_protocol); if (sin6 != NULL && IN6_IS_ADDR_UNSPECIFIED(&inp->in6p_laddr) && inp->inp_lport == 0) { - INP_RUNLOCK(inp); - /* -* XXX there is a short window here which could lead to a race; -* should we re-check that what got us here is still valid? -*/ - INP_WLOCK(inp); INP_HASH_WLOCK(pcbinfo); unlock_udbinfo = UH_WLOCKED; } else if (sin6 != NULL && @@ -972,9 +987,10 @@ udp6_output(struct socket *so, int flags_arg, struct m UDPLITE_PROBE(send, NULL, inp, ip6, inp, udp6); else UDP_
svn commit: r338806 - head/sys/vm
Author: markj Date: Wed Sep 19 19:13:43 2018 New Revision: 338806 URL: https://svnweb.freebsd.org/changeset/base/338806 Log: Move kernel vmem arena initialization to vm_kern.c. This keeps the initialization coupled together with the kmem_* KPI implementation, which is the main user of these arenas. No functional change intended. Reviewed by: alc Approved by: re (gjb) Sponsored by: The FreeBSD Foundation Differential Revision:https://reviews.freebsd.org/D17247 Modified: head/sys/vm/vm_init.c head/sys/vm/vm_kern.c Modified: head/sys/vm/vm_init.c == --- head/sys/vm/vm_init.c Wed Sep 19 19:13:29 2018(r338805) +++ head/sys/vm/vm_init.c Wed Sep 19 19:13:43 2018(r338806) @@ -98,12 +98,6 @@ extern void uma_startup1(void); extern voiduma_startup2(void); extern voidvm_radix_reserve_kva(void); -#if VM_NRESERVLEVEL > 0 -#defineKVA_QUANTUM (1 << (VM_LEVEL_0_ORDER + PAGE_SHIFT)) -#else - /* On non-superpage architectures want large import sizes. */ -#defineKVA_QUANTUM (PAGE_SIZE * 1024) -#endif long physmem; /* @@ -113,57 +107,14 @@ static void vm_mem_init(void *); SYSINIT(vm_mem, SI_SUB_VM, SI_ORDER_FIRST, vm_mem_init, NULL); /* - * Import kva into the kernel arena. - */ -static int -kva_import(void *unused, vmem_size_t size, int flags, vmem_addr_t *addrp) -{ - vm_offset_t addr; - int result; - - KASSERT((size % KVA_QUANTUM) == 0, - ("kva_import: Size %jd is not a multiple of %d", - (intmax_t)size, (int)KVA_QUANTUM)); - addr = vm_map_min(kernel_map); - result = vm_map_find(kernel_map, NULL, 0, &addr, size, 0, - VMFS_SUPER_SPACE, VM_PROT_ALL, VM_PROT_ALL, MAP_NOFAULT); - if (result != KERN_SUCCESS) -return (ENOMEM); - - *addrp = addr; - - return (0); -} - -#if VM_NRESERVLEVEL > 0 -/* - * Import a superpage from the normal kernel arena into the special - * arena for allocations with different permissions. - */ -static int -kernel_rwx_alloc(void *arena, vmem_size_t size, int flags, vmem_addr_t *addrp) -{ - - KASSERT((size % KVA_QUANTUM) == 0, - ("kernel_rwx_alloc: Size %jd is not a multiple of %d", - (intmax_t)size, (int)KVA_QUANTUM)); - return (vmem_xalloc(arena, size, KVA_QUANTUM, 0, 0, VMEM_ADDR_MIN, - VMEM_ADDR_MAX, flags, addrp)); -} -#endif - -/* * vm_init initializes the virtual memory system. * This is done only by the first cpu up. * * The start and end address of physical memory is passed in. */ -/* ARGSUSED*/ static void -vm_mem_init(dummy) - void *dummy; +vm_mem_init(void *dummy) { - int domain; /* * Initializes resident memory structures. From here on, all physical @@ -183,39 +134,6 @@ vm_mem_init(dummy) vm_object_init(); vm_map_startup(); kmem_init(virtual_avail, virtual_end); - - /* -* Initialize the kernel_arena. This can grow on demand. -*/ - vmem_init(kernel_arena, "kernel arena", 0, 0, PAGE_SIZE, 0, 0); - vmem_set_import(kernel_arena, kva_import, NULL, NULL, KVA_QUANTUM); - -#if VM_NRESERVLEVEL > 0 - /* -* In an architecture with superpages, maintain a separate arena -* for allocations with permissions that differ from the "standard" -* read/write permissions used for memory in the kernel_arena. -*/ - kernel_rwx_arena = vmem_create("kernel rwx arena", 0, 0, PAGE_SIZE, - 0, M_WAITOK); - vmem_set_import(kernel_rwx_arena, kernel_rwx_alloc, - (vmem_release_t *)vmem_xfree, kernel_arena, KVA_QUANTUM); -#endif - - for (domain = 0; domain < vm_ndomains; domain++) { - vm_dom[domain].vmd_kernel_arena = vmem_create( - "kernel arena domain", 0, 0, PAGE_SIZE, 0, M_WAITOK); - vmem_set_import(vm_dom[domain].vmd_kernel_arena, - (vmem_import_t *)vmem_alloc, NULL, kernel_arena, - KVA_QUANTUM); -#if VM_NRESERVLEVEL > 0 - vm_dom[domain].vmd_kernel_rwx_arena = vmem_create( - "kernel rwx arena domain", 0, 0, PAGE_SIZE, 0, M_WAITOK); - vmem_set_import(vm_dom[domain].vmd_kernel_rwx_arena, - kernel_rwx_alloc, (vmem_release_t *)vmem_xfree, - vm_dom[domain].vmd_kernel_arena, KVA_QUANTUM); -#endif - } #ifndefUMA_MD_SMALL_ALLOC /* Set up radix zone to use noobj_alloc. */ Modified: head/sys/vm/vm_kern.c == --- head/sys/vm/vm_kern.c Wed Sep 19 19:13:29 2018(r338805) +++ head/sys/vm/vm_kern.c Wed Sep 19 19:13:43 2018(r338806) @@ -121,6 +121,13 @@ SYSCTL_ULONG(_vm, OID_AUTO, max_kernel_address, CTLFLA #endif "Max kernel address"
svn commit: r338807 - in head/sys: amd64/amd64 amd64/include dev/drm2 dev/drm2/i915 i386/i386 i386/include x86/iommu
Author: kib Date: Wed Sep 19 19:35:02 2018 New Revision: 338807 URL: https://svnweb.freebsd.org/changeset/base/338807 Log: Convert x86 cache invalidation functions to ifuncs. This simplifies the runtime logic and reduces the number of runtime-constant branches. Reviewed by: alc, markj Sponsored by: The FreeBSD Foundation Approved by: re (gjb) Differential revision:https://reviews.freebsd.org/D16736 Modified: head/sys/amd64/amd64/pmap.c head/sys/amd64/include/pmap.h head/sys/dev/drm2/drm_os_freebsd.c head/sys/dev/drm2/i915/intel_ringbuffer.c head/sys/i386/i386/pmap.c head/sys/i386/i386/vm_machdep.c head/sys/i386/include/pmap.h head/sys/x86/iommu/intel_utils.c Modified: head/sys/amd64/amd64/pmap.c == --- head/sys/amd64/amd64/pmap.c Wed Sep 19 19:13:43 2018(r338806) +++ head/sys/amd64/amd64/pmap.c Wed Sep 19 19:35:02 2018(r338807) @@ -648,6 +648,10 @@ static vm_page_t pmap_enter_quick_locked(pmap_t pmap, vm_page_t m, vm_prot_t prot, vm_page_t mpte, struct rwlock **lockp); static void pmap_fill_ptp(pt_entry_t *firstpte, pt_entry_t newpte); static int pmap_insert_pt_page(pmap_t pmap, vm_page_t mpte); +static void pmap_invalidate_cache_range_selfsnoop(vm_offset_t sva, +vm_offset_t eva); +static void pmap_invalidate_cache_range_all(vm_offset_t sva, +vm_offset_t eva); static void pmap_invalidate_pde_page(pmap_t pmap, vm_offset_t va, pd_entry_t pde); static void pmap_kenter_attr(vm_offset_t va, vm_paddr_t pa, int mode); @@ -2171,36 +2175,62 @@ pmap_invalidate_pde_page(pmap_t pmap, vm_offset_t va, pmap_invalidate_page(pmap, va); } +DEFINE_IFUNC(, void, pmap_invalidate_cache_range, +(vm_offset_t sva, vm_offset_t eva), static) +{ + + if ((cpu_feature & CPUID_SS) != 0) + return (pmap_invalidate_cache_range_selfsnoop); + if ((cpu_feature & CPUID_CLFSH) != 0) + return (pmap_force_invalidate_cache_range); + return (pmap_invalidate_cache_range_all); +} + #define PMAP_CLFLUSH_THRESHOLD (2 * 1024 * 1024) -void -pmap_invalidate_cache_range(vm_offset_t sva, vm_offset_t eva, boolean_t force) +static void +pmap_invalidate_cache_range_check_align(vm_offset_t sva, vm_offset_t eva) { - if (force) { - sva &= ~(vm_offset_t)(cpu_clflush_line_size - 1); - } else { - KASSERT((sva & PAGE_MASK) == 0, - ("pmap_invalidate_cache_range: sva not page-aligned")); - KASSERT((eva & PAGE_MASK) == 0, - ("pmap_invalidate_cache_range: eva not page-aligned")); - } + KASSERT((sva & PAGE_MASK) == 0, + ("pmap_invalidate_cache_range: sva not page-aligned")); + KASSERT((eva & PAGE_MASK) == 0, + ("pmap_invalidate_cache_range: eva not page-aligned")); +} - if ((cpu_feature & CPUID_SS) != 0 && !force) - ; /* If "Self Snoop" is supported and allowed, do nothing. */ - else if ((cpu_stdext_feature & CPUID_STDEXT_CLFLUSHOPT) != 0 && - eva - sva < PMAP_CLFLUSH_THRESHOLD) { +static void +pmap_invalidate_cache_range_selfsnoop(vm_offset_t sva, vm_offset_t eva) +{ + + pmap_invalidate_cache_range_check_align(sva, eva); +} + +void +pmap_force_invalidate_cache_range(vm_offset_t sva, vm_offset_t eva) +{ + + sva &= ~(vm_offset_t)(cpu_clflush_line_size - 1); + if (eva - sva >= PMAP_CLFLUSH_THRESHOLD) { /* -* XXX: Some CPUs fault, hang, or trash the local APIC -* registers if we use CLFLUSH on the local APIC -* range. The local APIC is always uncached, so we -* don't need to flush for that range anyway. +* The supplied range is bigger than 2MB. +* Globally invalidate cache. */ - if (pmap_kextract(sva) == lapic_paddr) - return; + pmap_invalidate_cache(); + return; + } + /* +* XXX: Some CPUs fault, hang, or trash the local APIC +* registers if we use CLFLUSH on the local APIC range. The +* local APIC is always uncached, so we don't need to flush +* for that range anyway. +*/ + if (pmap_kextract(sva) == lapic_paddr) + return; + + if ((cpu_stdext_feature & CPUID_STDEXT_CLFLUSHOPT) != 0) { /* -* Otherwise, do per-cache line flush. Use the sfence +* Do per-cache line flush. Use the sfence * instruction to insure that previous stores are * included in the write-back. The processor * propagates flush to other processors in the cache @@ -2210,10 +2240,7 @@ pmap_invalidate_cache_range(vm_offset_t sva, vm_offset for (; sva < eva; sva += cpu_clflush_line_size)
svn commit: r338810 - head/crypto/openssh
Author: emaste Date: Wed Sep 19 20:52:47 2018 New Revision: 338810 URL: https://svnweb.freebsd.org/changeset/base/338810 Log: openssh: rename local macro to avoid OpenSSL 1.1.1 conflict Local changes introduced an OPENSSH_VERSION macro, but this conflicts with a macro of the same name introduced with OepnsSL 1.1.1 Reviewed by: des Approved by: re (gjb) MFC after:1 week Sponsored by: The FreeBSD Foundation Modified: head/crypto/openssh/ssh.c head/crypto/openssh/sshd.c head/crypto/openssh/version.h Modified: head/crypto/openssh/ssh.c == --- head/crypto/openssh/ssh.c Wed Sep 19 19:54:13 2018(r338809) +++ head/crypto/openssh/ssh.c Wed Sep 19 20:52:47 2018(r338810) @@ -811,10 +811,10 @@ main(int ac, char **av) *options.version_addendum != '\0') fprintf(stderr, "%s %s, %s\n", SSH_RELEASE, options.version_addendum, - OPENSSL_VERSION); + OPENSSL_VERSION_STRING); else fprintf(stderr, "%s, %s\n", SSH_RELEASE, - OPENSSL_VERSION); + OPENSSL_VERSION_STRING); if (opt == 'V') exit(0); break; @@ -1078,7 +1078,7 @@ main(int ac, char **av) if (debug_flag) /* version_addendum is always NULL at this point */ - logit("%s, %s", SSH_RELEASE, OPENSSL_VERSION); + logit("%s, %s", SSH_RELEASE, OPENSSL_VERSION_STRING); /* Parse the configuration files */ process_config_files(host_arg, pw, 0); Modified: head/crypto/openssh/sshd.c == --- head/crypto/openssh/sshd.c Wed Sep 19 19:54:13 2018(r338809) +++ head/crypto/openssh/sshd.c Wed Sep 19 20:52:47 2018(r338810) @@ -939,10 +939,10 @@ usage(void) if (options.version_addendum && *options.version_addendum != '\0') fprintf(stderr, "%s %s, %s\n", SSH_RELEASE, - options.version_addendum, OPENSSL_VERSION); + options.version_addendum, OPENSSL_VERSION_STRING); else fprintf(stderr, "%s, %s\n", - SSH_RELEASE, OPENSSL_VERSION); + SSH_RELEASE, OPENSSL_VERSION_STRING); fprintf(stderr, "usage: sshd [-46DdeiqTt] [-C connection_spec] [-c host_cert_file]\n" "[-E log_file] [-f config_file] [-g login_grace_time]\n" Modified: head/crypto/openssh/version.h == --- head/crypto/openssh/version.h Wed Sep 19 19:54:13 2018 (r338809) +++ head/crypto/openssh/version.h Wed Sep 19 20:52:47 2018 (r338810) @@ -9,7 +9,7 @@ #define SSH_VERSION_FREEBSD"FreeBSD-20180909" #ifdef WITH_OPENSSL -#define OPENSSL_VERSIONSSLeay_version(SSLEAY_VERSION) +#define OPENSSL_VERSION_STRING SSLeay_version(SSLEAY_VERSION) #else -#define OPENSSL_VERSION"without OpenSSL" +#define OPENSSL_VERSION_STRING "without OpenSSL" #endif ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r338813 - head/sys/arm64/arm64
Author: jhb Date: Wed Sep 19 22:53:52 2018 New Revision: 338813 URL: https://svnweb.freebsd.org/changeset/base/338813 Log: Clear all of the VFP state in fill_fpregs(). Zero the entire FP register set structure returned for ptrace() if a thread hasn't used FP registers rather than leaking garbage in the fp_sr and fp_cr fields. Reviewed by: emaste, andrew Approved by: re (rgrimes) MFC after:2 weeks Sponsored by: DARPA, AFRL Differential Revision:https://reviews.freebsd.org/D17140 Modified: head/sys/arm64/arm64/machdep.c Modified: head/sys/arm64/arm64/machdep.c == --- head/sys/arm64/arm64/machdep.c Wed Sep 19 22:39:40 2018 (r338812) +++ head/sys/arm64/arm64/machdep.c Wed Sep 19 22:53:52 2018 (r338813) @@ -236,7 +236,7 @@ fill_fpregs(struct thread *td, struct fpreg *regs) regs->fp_sr = pcb->pcb_fpustate.vfp_fpsr; } else #endif - memset(regs->fp_q, 0, sizeof(regs->fp_q)); + memset(regs, 0, sizeof(*regs)); return (0); } ___ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"
svn commit: r338814 - in head/sys/riscv: include riscv
Author: jhb Date: Wed Sep 19 23:45:18 2018 New Revision: 338814 URL: https://svnweb.freebsd.org/changeset/base/338814 Log: Various fixes for floating point on RISC-V. - Explicitly load an empty initial state into FP registers when taking the fault on the first FP instruction in a thread. Setting SSTATE.FS to INITIAL is just a marker to let context switch restore code know that it can load FP registers with zeroes instead of memory loads. It does not imply that the hardware will reset all registers to zero on first access. In addition, set the state to CLEAN instead of INITIAL after the first FP instruction. cpu_switch() doesn't do anything for INITIAL and only restores from the pcb if the state is CLEAN. We could perhaps change cpu_switch to call fpe_state_clear if the state was INITIAL and leave SSTATE.FS set to INITIAL instead of CLEAN after the first FP instruction. However, adding this complexity to cpu_switch() doesn't seem worth the supposed gain. - Only save the current FPU registers in fill_fpregs() if the request is made to save the current thread's registers. Previously if a debugger requested FP registers via ptrace() it was getting a copy of the debugger's FP registers rather than the debugee's. - Zero the entire FP register set structure returned for ptrace() if a thread hasn't used FP registers rather than leaking garbage in the fp_fcsr field. - If a debugger writes FP registers via ptrace(), always mark the pcb as having valid FP registers and set SSTATUS.FS_MASK to CLEAN so that the registers will be restored when the debugged thread resumes. - Be more explicit about clearing the SSTATUS.FS field before setting it to CLEAN on the first FP instruction trap. Submitted by: br, markj Approved by: re (rgrimes) Sponsored by: DARPA Differential Revision:https://reviews.freebsd.org/D17141 Modified: head/sys/riscv/include/fpe.h head/sys/riscv/riscv/machdep.c head/sys/riscv/riscv/swtch.S head/sys/riscv/riscv/trap.c Modified: head/sys/riscv/include/fpe.h == --- head/sys/riscv/include/fpe.hWed Sep 19 22:53:52 2018 (r338813) +++ head/sys/riscv/include/fpe.hWed Sep 19 23:45:18 2018 (r338814) @@ -34,5 +34,6 @@ #define_MACHINE_FPE_H_ void fpe_state_save(struct thread *td); +void fpe_state_clear(void); #endif /* !_MACHINE_FPE_H_ */ Modified: head/sys/riscv/riscv/machdep.c == --- head/sys/riscv/riscv/machdep.c Wed Sep 19 22:53:52 2018 (r338813) +++ head/sys/riscv/riscv/machdep.c Wed Sep 19 23:45:18 2018 (r338814) @@ -204,13 +204,14 @@ fill_fpregs(struct thread *td, struct fpreg *regs) * If we have just been running FPE instructions we will * need to save the state to memcpy it below. */ - fpe_state_save(td); + 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->fp_x, 0, sizeof(regs->fp_x)); + memset(regs, 0, sizeof(*regs)); return (0); } @@ -219,12 +220,17 @@ 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); Modified: head/sys/riscv/riscv/swtch.S == --- head/sys/riscv/riscv/swtch.SWed Sep 19 22:53:52 2018 (r338813) +++ head/sys/riscv/riscv/swtch.SWed Sep 19 23:45:18 2018 (r338814) @@ -154,6 +154,59 @@ END(fpe_state_save) #endif /* FPE */ /* + * void + * fpe_state_clear(void) + */ +ENTRY(fpe_state_clear) + /* +* Enable FPE usage in supervisor mode, +* so we can access registers. +*/ + li t0, SSTATUS_FS_INITIAL + csrssstatus, t0 + + fscsr zero + fcvt.d.l f0, zero + fcvt.d.l f1, zero + fcvt.d.l f2, zero + fcvt.d.l f3, zero + fcvt.d.l f4, zero + fcvt.d.l f5, zero + fcvt.d.l f6, zero + fcvt.d.l f7, zero + fcvt.d.l f8, zero + fcvt.d.l f9, zero + fcvt.d.l f10, zero + fcvt.d.l f11, zero + fcvt.d.l f12, zero + fcvt.d.l f13, zero + fcvt.d.l f14, zero + fcvt.d.l f15, zero + fcvt.d.l f16, zero + fcvt.d.l f17, zero