svn commit: r367672 - in head/sys/ufs: ffs ufs

2020-11-13 Thread Konstantin Belousov
Author: kib
Date: Sat Nov 14 05:30:10 2020
New Revision: 367672
URL: https://svnweb.freebsd.org/changeset/base/367672

Log:
  Handle LoR in flush_pagedep_deps().
  
  When operating in SU or SU+J mode, ffs_syncvnode() might need to
  instantiate other vnode by inode number while owning syncing vnode
  lock.  Typically this other vnode is the parent of our vnode, but due
  to renames occuring right before fsync (or during fsync when we drop
  the syncing vnode lock, see below) it might be no longer parent.
  
  More, the called function flush_pagedep_deps() needs to lock other
  vnode while owning the lock for vnode which owns the buffer, for which
  the dependencies are flushed.  This creates another instance of the
  same LoR as was fixed in softdep_sync().
  
  Put the generic code for safe relocking into new SU helper
  get_parent_vp() and use it in flush_pagedep_deps().  The case for safe
  relocking of two vnodes with undefined lock order was extracted into
  vn helper vn_lock_pair().
  
  Due to call sequence
   ffs_syncvnode()->softdep_sync_buf()->flush_pagedep_deps(),
  ffs_syncvnode() indicates with ERELOOKUP that passed vnode was
  unlocked in process, and can return ENOENT if the passed vnode
  reclaimed.  All callers of the function were inspected.
  
  Because UFS namei lookups store auxiliary information about directory
  entry in in-memory directory inode, and this information is then used
  by UFS code that creates/removed directory entry in the actual
  mutating VOPs, it is critical that directory vnode lock is not dropped
  between lookup and VOP.  For softdep_prelink(), which ensures that
  later link/unlink operation can proceed without overflowing the
  journal, calls were moved to the place where it is safe to drop
  processing VOP because mutations are not yet applied.  Then, ERELOOKUP
  causes restart of the whole VFS operation (typically VFS syscall) at
  top level, including the re-lookup of the involved pathes.  [Note that
  we already do the same restart for failing calls to vn_start_write(),
  so formally this patch does not introduce new behavior.]
  
  Similarly, unsafe calls to fsync in snapshot creation code were
  plugged.  A possible view on these failures is that it does not make
  sense to continue creating snapshot if the snapshot vnode was
  reclaimed due to forced unmount.
  
  It is possible that relock/ERELOOKUP situation occurs in
  ffs_truncate() called from ufs_inactive().  In this case, dropping the
  vnode lock is not safe.  Detect the situation with VI_DOINGINACT and
  reschedule inactivation by setting VI_OWEINACT.  ufs_inactive()
  rechecks VI_OWEINACT and avoids reclaiming vnode is truncation failed
  this way.
  
  In ffs_truncate(), allocation of the EOF block for partial truncation
  is re-done after vnode is synced, since we cannot leave the buffer
  locked through ffs_syncvnode().
  
  In collaboration with:pho
  Reviewed by:  mckusick (previous version), markj
  Tested by:markj (syzkaller), pho
  Sponsored by: The FreeBSD Foundation
  Differential revision:https://reviews.freebsd.org/D26136

Modified:
  head/sys/ufs/ffs/ffs_extern.h
  head/sys/ufs/ffs/ffs_inode.c
  head/sys/ufs/ffs/ffs_snapshot.c
  head/sys/ufs/ffs/ffs_softdep.c
  head/sys/ufs/ffs/ffs_vfsops.c
  head/sys/ufs/ffs/ffs_vnops.c
  head/sys/ufs/ufs/ufs_inode.c
  head/sys/ufs/ufs/ufs_lookup.c
  head/sys/ufs/ufs/ufs_vnops.c

Modified: head/sys/ufs/ffs/ffs_extern.h
==
--- head/sys/ufs/ffs/ffs_extern.h   Sat Nov 14 05:19:59 2020
(r367671)
+++ head/sys/ufs/ffs/ffs_extern.h   Sat Nov 14 05:30:10 2020
(r367672)
@@ -173,6 +173,9 @@ voidsoftdep_load_inodeblock(struct inode *);
 void   softdep_freefile(struct vnode *, ino_t, int);
 intsoftdep_request_cleanup(struct fs *, struct vnode *,
struct ucred *, int);
+intsoftdep_prerename(struct vnode *, struct vnode *, struct vnode *,
+   struct vnode *);
+intsoftdep_prelink(struct vnode *, struct vnode *, int);
 void   softdep_setup_freeblocks(struct inode *, off_t, int);
 void   softdep_setup_inomapdep(struct buf *, struct inode *, ino_t, int);
 void   softdep_setup_blkmapdep(struct buf *, struct mount *, ufs2_daddr_t,

Modified: head/sys/ufs/ffs/ffs_inode.c
==
--- head/sys/ufs/ffs/ffs_inode.cSat Nov 14 05:19:59 2020
(r367671)
+++ head/sys/ufs/ffs/ffs_inode.cSat Nov 14 05:30:10 2020
(r367672)
@@ -462,6 +462,8 @@ ffs_truncate(vp, length, flags, cred)
error = UFS_BALLOC(vp, length - 1, 1, cred, flags, );
if (error)
return (error);
+   ffs_inode_bwrite(vp, bp, flags);
+
/*
 * When we are doing soft updates and the UFS_BALLOC
 * above fills in a direct block hole with a full 

svn commit: r367671 - head/sys/ufs/ffs

2020-11-13 Thread Konstantin Belousov
Author: kib
Date: Sat Nov 14 05:19:59 2020
New Revision: 367671
URL: https://svnweb.freebsd.org/changeset/base/367671

Log:
  Add ffs_inode_bwrite() helper.
  
  In collaboration with:pho
  Reviewed by:  mckusick (previous version), markj
  Tested by:markj (syzkaller), pho
  Sponsored by: The FreeBSD Foundation
  Differential revision:https://reviews.freebsd.org/D26136

Modified:
  head/sys/ufs/ffs/ffs_inode.c

Modified: head/sys/ufs/ffs/ffs_inode.c
==
--- head/sys/ufs/ffs/ffs_inode.cSat Nov 14 05:19:44 2020
(r367670)
+++ head/sys/ufs/ffs/ffs_inode.cSat Nov 14 05:19:59 2020
(r367671)
@@ -67,6 +67,17 @@ __FBSDID("$FreeBSD$");
 static int ffs_indirtrunc(struct inode *, ufs2_daddr_t, ufs2_daddr_t,
ufs2_daddr_t, int, ufs2_daddr_t *);
 
+static void
+ffs_inode_bwrite(struct vnode *vp, struct buf *bp, int flags)
+{
+   if ((flags & IO_SYNC) != 0)
+   bwrite(bp);
+   else if (DOINGASYNC(vp))
+   bdwrite(bp);
+   else
+   bawrite(bp);
+}
+
 /*
  * Update the access, modified, and inode change times as specified by the
  * IN_ACCESS, IN_UPDATE, and IN_CHANGE flags respectively.  Write the inode
@@ -357,12 +368,7 @@ ffs_truncate(vp, length, flags, cred)
DIP_SET(ip, i_size, length);
if (bp->b_bufsize == fs->fs_bsize)
bp->b_flags |= B_CLUSTEROK;
-   if (flags & IO_SYNC)
-   bwrite(bp);
-   else if (DOINGASYNC(vp))
-   bdwrite(bp);
-   else
-   bawrite(bp);
+   ffs_inode_bwrite(vp, bp, flags);
UFS_INODE_SET_FLAG(ip, IN_SIZEMOD | IN_CHANGE | IN_UPDATE);
return (ffs_update(vp, waitforupdate));
}
@@ -478,12 +484,7 @@ ffs_truncate(vp, length, flags, cred)
allocbuf(bp, size);
if (bp->b_bufsize == fs->fs_bsize)
bp->b_flags |= B_CLUSTEROK;
-   if (flags & IO_SYNC)
-   bwrite(bp);
-   else if (DOINGASYNC(vp))
-   bdwrite(bp);
-   else
-   bawrite(bp);
+   ffs_inode_bwrite(vp, bp, flags);
UFS_INODE_SET_FLAG(ip, IN_SIZEMOD | IN_CHANGE | IN_UPDATE);
}
/*
___
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: r367670 - head/sys/ufs/ffs

2020-11-13 Thread Konstantin Belousov
Author: kib
Date: Sat Nov 14 05:19:44 2020
New Revision: 367670
URL: https://svnweb.freebsd.org/changeset/base/367670

Log:
  Revert r367669 to re-commit with proper message

Modified:
  head/sys/ufs/ffs/ffs_inode.c

Modified: head/sys/ufs/ffs/ffs_inode.c
==
--- head/sys/ufs/ffs/ffs_inode.cSat Nov 14 05:17:04 2020
(r367669)
+++ head/sys/ufs/ffs/ffs_inode.cSat Nov 14 05:19:44 2020
(r367670)
@@ -67,17 +67,6 @@ __FBSDID("$FreeBSD$");
 static int ffs_indirtrunc(struct inode *, ufs2_daddr_t, ufs2_daddr_t,
ufs2_daddr_t, int, ufs2_daddr_t *);
 
-static void
-ffs_inode_bwrite(struct vnode *vp, struct buf *bp, int flags)
-{
-   if ((flags & IO_SYNC) != 0)
-   bwrite(bp);
-   else if (DOINGASYNC(vp))
-   bdwrite(bp);
-   else
-   bawrite(bp);
-}
-
 /*
  * Update the access, modified, and inode change times as specified by the
  * IN_ACCESS, IN_UPDATE, and IN_CHANGE flags respectively.  Write the inode
@@ -368,7 +357,12 @@ ffs_truncate(vp, length, flags, cred)
DIP_SET(ip, i_size, length);
if (bp->b_bufsize == fs->fs_bsize)
bp->b_flags |= B_CLUSTEROK;
-   ffs_inode_bwrite(vp, bp, flags);
+   if (flags & IO_SYNC)
+   bwrite(bp);
+   else if (DOINGASYNC(vp))
+   bdwrite(bp);
+   else
+   bawrite(bp);
UFS_INODE_SET_FLAG(ip, IN_SIZEMOD | IN_CHANGE | IN_UPDATE);
return (ffs_update(vp, waitforupdate));
}
@@ -484,7 +478,12 @@ ffs_truncate(vp, length, flags, cred)
allocbuf(bp, size);
if (bp->b_bufsize == fs->fs_bsize)
bp->b_flags |= B_CLUSTEROK;
-   ffs_inode_bwrite(vp, bp, flags);
+   if (flags & IO_SYNC)
+   bwrite(bp);
+   else if (DOINGASYNC(vp))
+   bdwrite(bp);
+   else
+   bawrite(bp);
UFS_INODE_SET_FLAG(ip, IN_SIZEMOD | IN_CHANGE | IN_UPDATE);
}
/*
___
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: r367669 - head/sys/ufs/ffs

2020-11-13 Thread Konstantin Belousov
Author: kib
Date: Sat Nov 14 05:17:04 2020
New Revision: 367669
URL: https://svnweb.freebsd.org/changeset/base/367669

Log:
  Add a framework that tracks exclusive vnode lock generation count for UFS.
  
  This count is memoized together with the lookup metadata in directory
  inode, and we assert that accesses to lookup metadata are done under
  the same lock generation as they were stored.  Enabled under DIAGNOSTICS.
  
  UFS saves additional data for parent dirent when doing lookup
  (i_offset, i_count, i_endoff), and this data is used later by VOPs
  operating on dirents.  If parent vnode exclusive lock is dropped and
  re-acquired between lookup and the VOP call, we corrupt directories.
  
  Framework asserts that corruption cannot occur that way, by tracking
  vnode lock generation counter.  Updates to inode dirent members also
  save the counter, while users compare current and saved counters
  values.
  
  Also, fix a case in ufs_lookup_ino() where i_offset and i_count could
  be updated under shared lock.  It is not a bug on its own since dvp
  i_offset results from such lookup cannot be used, but it causes false
  positive in the checker.
  
  In collaboration with:pho
  Reviewed by:  mckusick (previous version), markj
  Tested by:markj (syzkaller), pho
  Sponsored by: The FreeBSD Foundation
  Differential revision:https://reviews.freebsd.org/D26136

Modified:
  head/sys/ufs/ffs/ffs_inode.c

Modified: head/sys/ufs/ffs/ffs_inode.c
==
--- head/sys/ufs/ffs/ffs_inode.cSat Nov 14 05:10:39 2020
(r367668)
+++ head/sys/ufs/ffs/ffs_inode.cSat Nov 14 05:17:04 2020
(r367669)
@@ -67,6 +67,17 @@ __FBSDID("$FreeBSD$");
 static int ffs_indirtrunc(struct inode *, ufs2_daddr_t, ufs2_daddr_t,
ufs2_daddr_t, int, ufs2_daddr_t *);
 
+static void
+ffs_inode_bwrite(struct vnode *vp, struct buf *bp, int flags)
+{
+   if ((flags & IO_SYNC) != 0)
+   bwrite(bp);
+   else if (DOINGASYNC(vp))
+   bdwrite(bp);
+   else
+   bawrite(bp);
+}
+
 /*
  * Update the access, modified, and inode change times as specified by the
  * IN_ACCESS, IN_UPDATE, and IN_CHANGE flags respectively.  Write the inode
@@ -357,12 +368,7 @@ ffs_truncate(vp, length, flags, cred)
DIP_SET(ip, i_size, length);
if (bp->b_bufsize == fs->fs_bsize)
bp->b_flags |= B_CLUSTEROK;
-   if (flags & IO_SYNC)
-   bwrite(bp);
-   else if (DOINGASYNC(vp))
-   bdwrite(bp);
-   else
-   bawrite(bp);
+   ffs_inode_bwrite(vp, bp, flags);
UFS_INODE_SET_FLAG(ip, IN_SIZEMOD | IN_CHANGE | IN_UPDATE);
return (ffs_update(vp, waitforupdate));
}
@@ -478,12 +484,7 @@ ffs_truncate(vp, length, flags, cred)
allocbuf(bp, size);
if (bp->b_bufsize == fs->fs_bsize)
bp->b_flags |= B_CLUSTEROK;
-   if (flags & IO_SYNC)
-   bwrite(bp);
-   else if (DOINGASYNC(vp))
-   bdwrite(bp);
-   else
-   bawrite(bp);
+   ffs_inode_bwrite(vp, bp, flags);
UFS_INODE_SET_FLAG(ip, IN_SIZEMOD | IN_CHANGE | IN_UPDATE);
}
/*
___
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: r367668 - in head/sys/ufs: ffs ufs

2020-11-13 Thread Konstantin Belousov
Author: kib
Date: Sat Nov 14 05:10:39 2020
New Revision: 367668
URL: https://svnweb.freebsd.org/changeset/base/367668

Log:
  Add a framework that tracks exclusive vnode lock generation count for UFS.
  
  This count is memoized together with the lookup metadata in directory
  inode, and we assert that accesses to lookup metadata are done under
  the same lock generation as they were stored.  Enabled under DIAGNOSTICS.
  
  UFS saves additional data for parent dirent when doing lookup
  (i_offset, i_count, i_endoff), and this data is used later by VOPs
  operating on dirents.  If parent vnode exclusive lock is dropped and
  re-acquired between lookup and the VOP call, we corrupt directories.
  
  Framework asserts that corruption cannot occur that way, by tracking
  vnode lock generation counter.  Updates to inode dirent members also
  save the counter, while users compare current and saved counters
  values.
  
  Also, fix a case in ufs_lookup_ino() where i_offset and i_count could
  be updated under shared lock.  It is not a bug on its own since dvp
  i_offset results from such lookup cannot be used, but it causes false
  positive in the checker.
  
  In collaboration with:pho
  Reviewed by:  mckusick (previous version), markj
  Tested by:markj (syzkaller), pho
  Sponsored by: The FreeBSD Foundation
  Differential revision:https://reviews.freebsd.org/D26136

Modified:
  head/sys/ufs/ffs/ffs_alloc.c
  head/sys/ufs/ffs/ffs_softdep.c
  head/sys/ufs/ffs/ffs_vfsops.c
  head/sys/ufs/ffs/ffs_vnops.c
  head/sys/ufs/ufs/inode.h
  head/sys/ufs/ufs/ufs_lookup.c
  head/sys/ufs/ufs/ufs_vnops.c

Modified: head/sys/ufs/ffs/ffs_alloc.c
==
--- head/sys/ufs/ffs/ffs_alloc.cSat Nov 14 02:11:56 2020
(r367667)
+++ head/sys/ufs/ffs/ffs_alloc.cSat Nov 14 05:10:39 2020
(r367668)
@@ -3468,7 +3468,7 @@ sysctl_ffs_fsck(SYSCTL_HANDLER_ARGS)
break;
}
dp = VTOI(dvp);
-   dp->i_offset = 12;  /* XXX mastertemplate.dot_reclen */
+   SET_I_OFFSET(dp, 12);   /* XXX mastertemplate.dot_reclen */
error = ufs_dirrewrite(dp, VTOI(fdvp), (ino_t)cmd.size,
DT_DIR, 0);
cache_purge(fdvp);

Modified: head/sys/ufs/ffs/ffs_softdep.c
==
--- head/sys/ufs/ffs/ffs_softdep.c  Sat Nov 14 02:11:56 2020
(r367667)
+++ head/sys/ufs/ffs/ffs_softdep.c  Sat Nov 14 05:10:39 2020
(r367668)
@@ -8764,11 +8764,11 @@ softdep_change_directoryentry_offset(bp, dp, base, old
if (MOUNTEDSUJ(mp)) {
flags = DEPALLOC;
jmvref = newjmvref(dp, de->d_ino,
-   dp->i_offset + (oldloc - base),
-   dp->i_offset + (newloc - base));
+   I_OFFSET(dp) + (oldloc - base),
+   I_OFFSET(dp) + (newloc - base));
}
-   lbn = lblkno(ump->um_fs, dp->i_offset);
-   offset = blkoff(ump->um_fs, dp->i_offset);
+   lbn = lblkno(ump->um_fs, I_OFFSET(dp));
+   offset = blkoff(ump->um_fs, I_OFFSET(dp));
oldoffset = offset + (oldloc - base);
newoffset = offset + (newloc - base);
ACQUIRE_LOCK(ump);
@@ -9280,7 +9280,7 @@ newdirrem(bp, dp, ip, isrmdir, prevdirremp)
jremref = dotremref = dotdotremref = NULL;
if (DOINGSUJ(dvp)) {
if (isrmdir) {
-   jremref = newjremref(dirrem, dp, ip, dp->i_offset,
+   jremref = newjremref(dirrem, dp, ip, I_OFFSET(dp),
ip->i_effnlink + 2);
dotremref = newjremref(dirrem, ip, ip, DOT_OFFSET,
ip->i_effnlink + 1);
@@ -9288,12 +9288,12 @@ newdirrem(bp, dp, ip, isrmdir, prevdirremp)
dp->i_effnlink + 1);
dotdotremref->jr_state |= MKDIR_PARENT;
} else
-   jremref = newjremref(dirrem, dp, ip, dp->i_offset,
+   jremref = newjremref(dirrem, dp, ip, I_OFFSET(dp),
ip->i_effnlink + 1);
}
ACQUIRE_LOCK(ump);
-   lbn = lblkno(ump->um_fs, dp->i_offset);
-   offset = blkoff(ump->um_fs, dp->i_offset);
+   lbn = lblkno(ump->um_fs, I_OFFSET(dp));
+   offset = blkoff(ump->um_fs, I_OFFSET(dp));
pagedep_lookup(UFSTOVFS(ump), bp, dp->i_number, lbn, DEPALLOC,
);
dirrem->dm_pagedep = pagedep;
@@ -9304,7 +9304,7 @@ newdirrem(bp, dp, ip, isrmdir, prevdirremp)
 * the jremref is preserved for any potential diradd in this
 * location.  This can not coincide with a rmdir.
 */
-   if (dp->i_offset == DOTDOT_OFFSET) {
+   if (I_OFFSET(dp) == DOTDOT_OFFSET) {
if (isrmdir)
panic("newdirrem: .. 

Re: svn commit: r367651 - head/usr.sbin/bhyve

2020-11-13 Thread Rebecca Cran

On 11/13/20 5:47 PM, Ravi Pokala wrote:

+#define FIRMWARE_RELEASE_DATE  "11/10/2020"

Might I suggest "2020-11-10", as sorting, logic, ${DEITY}, and ISO-8601 demand? 
;-)


I wish! I'll add a comment clarifying that the specification mandates 
mm/dd/.



--

Rebecca Cran


___
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: r367661 - head

2020-11-13 Thread Rick Macklem
Author: rmacklem
Date: Sat Nov 14 01:55:02 2020
New Revision: 367661
URL: https://svnweb.freebsd.org/changeset/base/367661

Log:
  Add a entry for r367660.

Modified:
  head/RELNOTES

Modified: head/RELNOTES
==
--- head/RELNOTES   Sat Nov 14 01:49:49 2020(r367660)
+++ head/RELNOTES   Sat Nov 14 01:55:02 2020(r367661)
@@ -10,6 +10,16 @@ newline.  Entries should be separated by a newline.
 
 Changes to this file should not be MFCed.
 
+r367660:
+   Fixes the case where gssd will not startup because /usr is a separate
+   local file system that is not yet mounted.  It does not fix the case
+   where /usr is a separately mounted remote file system (such as NFS).
+   This latter case can be fixed by adding mountcritremote to the
+   REQUIRED line.  Unfortunately doing so implies that all Kerberized
+   NFS mounts in /etc/fstab will need the "late" mount option.
+   This was not done, since the requirement for "late" would introduce
+   a POLA violation.
+
 r367423:
This commit added a new startup scripts variable called
nfsv4_server_only which uses the -R option on mountd added by r367026.
___
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: r367660 - head/libexec/rc/rc.d

2020-11-13 Thread Rick Macklem
Author: rmacklem
Date: Sat Nov 14 01:49:49 2020
New Revision: 367660
URL: https://svnweb.freebsd.org/changeset/base/367660

Log:
  Fix startup of gssd when /usr is a separately mounted local file system.
  
  meowth...@gmail.com reported that the gssd daemon was not
  starting, because /etc/rc.d/gssd was executed before his local
  /usr file system was mounted.
  He fixed the problem by adding mountcritlocal to the REQUIRED
  line.
  
  This fix seems safe and works for a separately mounted /usr file
  system on a local disk.
  The case of a separately mounted remote /usr file system (such as
  NFS) is still broken, but there is no obvious solution for that.
  Adding mountcritremote would fix the problem, but it would
  cause a POLA violation, because all kerberized NFS mounts
  in /etc/fstab would need the "late" option specified to work.
  
  Submitted by: meowth...@gmail.com
  Reported by:  meowth...@gmail.com
  Reviewed by:  0mp
  MFC after:2 weeks
  Relnotes: yes
  Differential Revision:https://reviews.freebsd.org/D27203

Modified:
  head/libexec/rc/rc.d/gssd

Modified: head/libexec/rc/rc.d/gssd
==
--- head/libexec/rc/rc.d/gssd   Sat Nov 14 01:45:34 2020(r367659)
+++ head/libexec/rc/rc.d/gssd   Sat Nov 14 01:49:49 2020(r367660)
@@ -4,7 +4,7 @@
 #
 
 # PROVIDE: gssd
-# REQUIRE: root
+# REQUIRE: root mountcritlocal
 # KEYWORD: nojail shutdown
 
 . /etc/rc.subr
___
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: r367659 - head/sys/dev/nvme

2020-11-13 Thread Alexander Motin
Author: mav
Date: Sat Nov 14 01:45:34 2020
New Revision: 367659
URL: https://svnweb.freebsd.org/changeset/base/367659

Log:
  Add PMRCAP printing and fix earlier CAP_HI.
  
  MFC after:3 days

Modified:
  head/sys/dev/nvme/nvme.h
  head/sys/dev/nvme/nvme_ctrlr.c

Modified: head/sys/dev/nvme/nvme.h
==
--- head/sys/dev/nvme/nvme.hSat Nov 14 01:39:27 2020(r367658)
+++ head/sys/dev/nvme/nvme.hSat Nov 14 01:45:34 2020(r367659)
@@ -150,6 +150,36 @@
 #define NVME_AQA_REG_ACQS_SHIFT(16)
 #define NVME_AQA_REG_ACQS_MASK (0xFFF)
 
+#define NVME_PMRCAP_REG_RDS_SHIFT  (3)
+#define NVME_PMRCAP_REG_RDS_MASK   (0x1)
+#define NVME_PMRCAP_REG_WDS_SHIFT  (4)
+#define NVME_PMRCAP_REG_WDS_MASK   (0x1)
+#define NVME_PMRCAP_REG_BIR_SHIFT  (5)
+#define NVME_PMRCAP_REG_BIR_MASK   (0x7)
+#define NVME_PMRCAP_REG_PMRTU_SHIFT(8)
+#define NVME_PMRCAP_REG_PMRTU_MASK (0x3)
+#define NVME_PMRCAP_REG_PMRWBM_SHIFT   (10)
+#define NVME_PMRCAP_REG_PMRWBM_MASK(0xf)
+#define NVME_PMRCAP_REG_PMRTO_SHIFT(16)
+#define NVME_PMRCAP_REG_PMRTO_MASK (0xff)
+#define NVME_PMRCAP_REG_CMSS_SHIFT (24)
+#define NVME_PMRCAP_REG_CMSS_MASK  (0x1)
+
+#define NVME_PMRCAP_RDS(x) \
+   (((x) >> NVME_PMRCAP_REG_RDS_SHIFT) & NVME_PMRCAP_REG_RDS_MASK)
+#define NVME_PMRCAP_WDS(x) \
+   (((x) >> NVME_PMRCAP_REG_WDS_SHIFT) & NVME_PMRCAP_REG_WDS_MASK)
+#define NVME_PMRCAP_BIR(x) \
+   (((x) >> NVME_PMRCAP_REG_BIR_SHIFT) & NVME_PMRCAP_REG_BIR_MASK)
+#define NVME_PMRCAP_PMRTU(x) \
+   (((x) >> NVME_PMRCAP_REG_PMRTU_SHIFT) & NVME_PMRCAP_REG_PMRTU_MASK)
+#define NVME_PMRCAP_PMRWBM(x) \
+   (((x) >> NVME_PMRCAP_REG_PMRWBM_SHIFT) & NVME_PMRCAP_REG_PMRWBM_MASK)
+#define NVME_PMRCAP_PMRTO(x) \
+   (((x) >> NVME_PMRCAP_REG_PMRTO_SHIFT) & NVME_PMRCAP_REG_PMRTO_MASK)
+#define NVME_PMRCAP_CMSS(x) \
+   (((x) >> NVME_PMRCAP_REG_CMSS_SHIFT) & NVME_PMRCAP_REG_CMSS_MASK)
+
 /* Command field definitions */
 
 #define NVME_CMD_FUSE_SHIFT(8)

Modified: head/sys/dev/nvme/nvme_ctrlr.c
==
--- head/sys/dev/nvme/nvme_ctrlr.c  Sat Nov 14 01:39:27 2020
(r367658)
+++ head/sys/dev/nvme/nvme_ctrlr.c  Sat Nov 14 01:45:34 2020
(r367659)
@@ -1367,7 +1367,7 @@ nvme_ctrlr_construct(struct nvme_controller *ctrlr, de
struct make_dev_argsmd_args;
uint32_tcap_lo;
uint32_tcap_hi;
-   uint32_tto, vs;
+   uint32_tto, vs, pmrcap;
uint8_t mpsmin;
int status, timeout_period;
 
@@ -1390,20 +1390,32 @@ nvme_ctrlr_construct(struct nvme_controller *ctrlr, de
cap_hi = nvme_mmio_read_4(ctrlr, cap_hi);
if (bootverbose) {
device_printf(dev, "CapHi: 0x%08x: DSTRD %u%s, CSS %x%s, "
-   "MPSMIN %u, MPSMAX %u %s%s\n", cap_hi,
+   "MPSMIN %u, MPSMAX %u%s%s\n", cap_hi,
NVME_CAP_HI_DSTRD(cap_hi),
-   NVME_CAP_HI_NSSRS(cap_lo) ? ", NSSRS" : "",
+   NVME_CAP_HI_NSSRS(cap_hi) ? ", NSSRS" : "",
NVME_CAP_HI_CSS(cap_hi),
-   NVME_CAP_HI_BPS(cap_lo) ? ", BPS" : "",
+   NVME_CAP_HI_BPS(cap_hi) ? ", BPS" : "",
NVME_CAP_HI_MPSMIN(cap_hi),
NVME_CAP_HI_MPSMAX(cap_hi),
-   NVME_CAP_HI_PMRS(cap_lo) ? ", PMRS" : "",
-   NVME_CAP_HI_CMBS(cap_lo) ? ", CMBS" : "");
+   NVME_CAP_HI_PMRS(cap_hi) ? ", PMRS" : "",
+   NVME_CAP_HI_CMBS(cap_hi) ? ", CMBS" : "");
}
if (bootverbose) {
vs = nvme_mmio_read_4(ctrlr, vs);
device_printf(dev, "Version: 0x%08x: %d.%d\n", vs,
NVME_MAJOR(vs), NVME_MINOR(vs));
+   }
+   if (bootverbose && NVME_CAP_HI_PMRS(cap_hi)) {
+   pmrcap = nvme_mmio_read_4(ctrlr, pmrcap);
+   device_printf(dev, "PMRCap: 0x%08x: BIR %u%s%s, PMRTU %u, "
+   "PMRWBM %x, PMRTO %u%s\n", pmrcap,
+   NVME_PMRCAP_BIR(pmrcap),
+   NVME_PMRCAP_RDS(pmrcap) ? ", RDS" : "",
+   NVME_PMRCAP_WDS(pmrcap) ? ", WDS" : "",
+   NVME_PMRCAP_PMRTU(pmrcap),
+   NVME_PMRCAP_PMRWBM(pmrcap),
+   NVME_PMRCAP_PMRTO(pmrcap),
+   NVME_PMRCAP_CMSS(pmrcap) ? ", CMSS" : "");
}
 
ctrlr->dstrd = NVME_CAP_HI_DSTRD(cap_hi) + 2;
___

svn commit: r367658 - head

2020-11-13 Thread Rick Macklem
Author: rmacklem
Date: Sat Nov 14 01:39:27 2020
New Revision: 367658
URL: https://svnweb.freebsd.org/changeset/base/367658

Log:
  Add an entry for r367026, r367423.

Modified:
  head/RELNOTES

Modified: head/RELNOTES
==
--- head/RELNOTES   Sat Nov 14 01:28:04 2020(r367657)
+++ head/RELNOTES   Sat Nov 14 01:39:27 2020(r367658)
@@ -10,6 +10,14 @@ newline.  Entries should be separated by a newline.
 
 Changes to this file should not be MFCed.
 
+r367423:
+   This commit added a new startup scripts variable called
+   nfsv4_server_only which uses the -R option on mountd added by r367026.
+   When nfsv4_server_only is set to "YES" in /etc/rc.conf, the NFS server
+   only handles NFSv4 and does not register with rpcbind.  As such, rpcbind
+   does not need to be running.  Useful for sites which consider rpcbind a
+   security issue.
+
 r366267:
 Kernel option ACPI_DMAR was renamed to IOMMU.  amd64's IOMMU subsystem
 was split out from amd64 DMAR support and is now generic, i.e., it can
___
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: r367651 - head/usr.sbin/bhyve

2020-11-13 Thread Ravi Pokala
-Original Message-
From:  on behalf of Jessica Clarke 

Date: 2020-11-13, Friday at 16:53
To: Ravi Pokala 
Cc: Rebecca Cran , , 
, 
Subject: Re: svn commit: r367651 - head/usr.sbin/bhyve

On 14 Nov 2020, at 00:47, Ravi Pokala  wrote:
> 
>>   +#define FIRMWARE_RELEASE_DATE "11/10/2020"
> 
> Might I suggest "2020-11-10", as sorting, logic, ${DEITY}, and ISO-8601 
demand? ;-)

Alas that is a "feature" of the specification:

  String number of the BIOS release date. The date string, if supplied,
  is in either mm/dd/yy or mm/dd/ format. If the year portion of the
  string is two digits, the year is assumed to be 19yy.

  NOTE: The mm/dd/ format is required for SMBIOS version 2.3 and
  later.

(SMBIOS Specification version 3.4.0c)



Yeah, it occurred to me that it might be something like that shortly after I 
hit "send". :-p

It might be worth putting a comment in so people don't accidentally
change it to the wrong thing in future though, given it's currently
ambiguous otherwise.

That would be appreciated.

Thanks,

Ravi (rpokala@)

Jess



___
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: r367651 - head/usr.sbin/bhyve

2020-11-13 Thread Jessica Clarke
On 14 Nov 2020, at 00:47, Ravi Pokala  wrote:
> 
>>   +#define FIRMWARE_RELEASE_DATE "11/10/2020"
> 
> Might I suggest "2020-11-10", as sorting, logic, ${DEITY}, and ISO-8601 
> demand? ;-)

Alas that is a "feature" of the specification:

  String number of the BIOS release date. The date string, if supplied,
  is in either mm/dd/yy or mm/dd/ format. If the year portion of the
  string is two digits, the year is assumed to be 19yy.

  NOTE: The mm/dd/ format is required for SMBIOS version 2.3 and
  later.

(SMBIOS Specification version 3.4.0c)

It might be worth putting a comment in so people don't accidentally
change it to the wrong thing in future though, given it's currently
ambiguous otherwise.

Jess

___
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: r367651 - head/usr.sbin/bhyve

2020-11-13 Thread Ravi Pokala
>+#define FIRMWARE_RELEASE_DATE "11/10/2020"

Might I suggest "2020-11-10", as sorting, logic, ${DEITY}, and ISO-8601 demand? 
;-)

Thanks,

Ravi (rpokala@)

-Original Message-
From:  on behalf of Rebecca Cran 

Date: 2020-11-13, Friday at 11:47
To: , , 

Subject: svn commit: r367651 - head/usr.sbin/bhyve

Author: bcran
Date: Fri Nov 13 19:47:16 2020
New Revision: 367651
URL: https://svnweb.freebsd.org/changeset/base/367651

Log:
  bhyve: update smbiostbl.c to bump the version and release date

  Since lots of work has been done on bhyve since 2014, increase the version
  to 13.0 to match 13-CURRENT, and update the release date.

  Reviewed by:  grehan
  Differential Revision:https://reviews.freebsd.org/D27147

Modified:
  head/usr.sbin/bhyve/smbiostbl.c

Modified: head/usr.sbin/bhyve/smbiostbl.c

==
--- head/usr.sbin/bhyve/smbiostbl.c Fri Nov 13 19:22:53 2020
(r367650)
+++ head/usr.sbin/bhyve/smbiostbl.c Fri Nov 13 19:47:16 2020
(r367651)
@@ -51,6 +51,9 @@ __FBSDID("$FreeBSD$");

 #define SMBIOS_BASE0xF1000

+#define FIRMWARE_VERSION   "13.0"
+#define FIRMWARE_RELEASE_DATE  "11/10/2020"
+
 /* BHYVE_ACPI_BASE - SMBIOS_BASE) */
 #defineSMBIOS_MAX_LENGTH   (0xF2400 - 0xF1000)

@@ -323,9 +326,9 @@ struct smbios_table_type0 smbios_type0_template = {
 };

 const char *smbios_type0_strings[] = {
-   "BHYVE",/* vendor string */
-   "1.00", /* bios version string */
-   "03/14/2014",   /* bios release date string */
+   "BHYVE",/* vendor string */
+   FIRMWARE_VERSION,   /* bios version string */
+   FIRMWARE_RELEASE_DATE,  /* bios release date string */
NULL
 };



___
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: r367655 - head/lib/libbsnmp

2020-11-13 Thread Brooks Davis
Author: brooks
Date: Fri Nov 13 23:18:04 2020
New Revision: 367655
URL: https://svnweb.freebsd.org/changeset/base/367655

Log:
  Add missing src.opts.mk include
  
  This was missed in r364221 so tests were not built.
  
  Reviewed by:  bdrewery
  Obtained from:CheriBSD
  Sponsored by: DARPA
  Differential Revision:https://reviews.freebsd.org/D27210

Modified:
  head/lib/libbsnmp/Makefile

Modified: head/lib/libbsnmp/Makefile
==
--- head/lib/libbsnmp/Makefile  Fri Nov 13 22:45:26 2020(r367654)
+++ head/lib/libbsnmp/Makefile  Fri Nov 13 23:18:04 2020(r367655)
@@ -1,5 +1,7 @@
 # $FreeBSD$
 
+.include 
+
 SUBDIR=libbsnmp
 SUBDIR.${MK_TESTS}+= tests
 
___
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: r367654 - in head/sys/contrib/dev/acpica: . common compiler components/events components/namespace include

2020-11-13 Thread Jung-uk Kim
Author: jkim
Date: Fri Nov 13 22:45:26 2020
New Revision: 367654
URL: https://svnweb.freebsd.org/changeset/base/367654

Log:
  MFV:  r367652
  
  Merge ACPICA 20201113.

Modified:
  head/sys/contrib/dev/acpica/changes.txt
  head/sys/contrib/dev/acpica/common/ahuuids.c
  head/sys/contrib/dev/acpica/compiler/aslbtypes.c
  head/sys/contrib/dev/acpica/compiler/aslcodegen.c
  head/sys/contrib/dev/acpica/compiler/aslmap.c
  head/sys/contrib/dev/acpica/compiler/aslmessages.c
  head/sys/contrib/dev/acpica/compiler/aslmessages.h
  head/sys/contrib/dev/acpica/compiler/aslnamesp.c
  head/sys/contrib/dev/acpica/compiler/aslopcodes.c
  head/sys/contrib/dev/acpica/compiler/aslprimaries.y
  head/sys/contrib/dev/acpica/compiler/aslrules.y
  head/sys/contrib/dev/acpica/compiler/asltypes.y
  head/sys/contrib/dev/acpica/components/events/evregion.c
  head/sys/contrib/dev/acpica/components/namespace/nspredef.c
  head/sys/contrib/dev/acpica/components/namespace/nsprepkg.c
  head/sys/contrib/dev/acpica/components/namespace/nsrepair2.c
  head/sys/contrib/dev/acpica/include/accommon.h
  head/sys/contrib/dev/acpica/include/acpixf.h
  head/sys/contrib/dev/acpica/include/acuuid.h
Directory Properties:
  head/sys/contrib/dev/acpica/   (props changed)

Modified: head/sys/contrib/dev/acpica/changes.txt
==
--- head/sys/contrib/dev/acpica/changes.txt Fri Nov 13 21:41:47 2020
(r367653)
+++ head/sys/contrib/dev/acpica/changes.txt Fri Nov 13 22:45:26 2020
(r367654)
@@ -1,6 +1,94 @@
 
 
 
+13 November 2020. Summary of changes for version 20201113:
+
+This release is available at https://acpica.org/downloads
+
+
+1) ACPICA kernel-resident subsystem:
+
+Interpreter: fixed a memory leak by using use existing buffer in _HID 
+repair. There was a memory leak that occurred when a _CID object is 
+defined as a package containing string objects. When _CID is checked for 
+any possible repairs, it calls a helper function to repair _HID (because 
+_CID basically contains multiple _HID entries). The _HID repair function 
+assumes that string objects are standalone objects that are not contained 
+inside of any packages. The _HID repair function replaced the string 
+object with a brand new object and attempted to delete the old object by 
+decrementing the reference count of the old object. Strings inside of 
+packages have a reference count of 2 so the _HID repair function leaves 
+this object in a dangling state and causes a memory leak. Instead of 
+allocating a brand new object and removing the old object, use the 
+existing object when repairing the _HID object.
+
+Added function trace macros to improve namespace debugging. The namespace 
+repair mechanism does not have function tracing macros. Add several trace 
+macros to improve debuggability.
+
+Handle "orphan" _REG methods for GPIO OpRegions. Before this change 
+AcpiEvExecuteRegMethods() had special handling to handle "orphan" (no 
+matching OpRegion declared) _REG methods for EC nodes. On Intel Cherry 
+Trail devices there are 2 possible ACPI OpRegions for accessing GPIOs. 
+The standard GeneralPurposeIo OpRegion and the Cherry Trail - specific 
+UserDefined 0x9X OpRegions. Having 2 different types of OpRegions leads 
+to potential issues with checks for OpRegion availability, or in other 
+words checks if _REG has been called for the OpRegion which the ACPI code 
+wants to use. Except for the "orphan" EC handling, ACPICA core does not 
+call _REG on an ACPI node which does not define an OpRegion matching the 
+type being registered; and the reference design DSDT, from which most 
+Cherry Trail DSDTs are derived, does not define GeneralPurposeIo, nor 
+UserDefined(0x93) OpRegions for the GPO2 (UID 3) device, because no pins 
+were assigned ACPI controlled functions in the reference design. Together 
+this leads to the perfect storm, at least on the Cherry Trail based 
+Medion Akayo E1239T. This design does use a GPO2 pin from its ACPI code 
+and has added the Cherry Trail specific UserDefined(0x93) opregion to its 
+GPO2 ACPI node to access this pin. But it uses a "has _REG been called" 
+availability check for the standard GeneralPurposeIo OpRegion. This 
+clearly is a bug in the DSDT, but this does work under Windows. This 
+issue leads to the intel vbtn driver reporting the device always being in 
+tablet-mode at boot, even if it is in laptop mode. Which in turn causes 
+userspace to ignore touchpad events. So in other words, this issue causes 
+the touchpad to not work at boot. This change fixes this by extending the 
+"orphan" _REG method handling to also apply to GPIO address-space 
+handlers.
+
+
+2) iASL Compiler/Disassembler and ACPICA tools: 
+
+iASL: Added more info to namespace dump file (-ln option). In a separate 
+section of the dump file (after the main namespace dump), emit the

Re: svn commit: r367651 - head/usr.sbin/bhyve

2020-11-13 Thread Rebecca Cran

On 11/13/20 1:03 PM, Shawn Webb wrote:



Style nit: shouldn't there be a tab between #define and the macro?


Thanks, I'll try and remember that in future.


--
Rebecca Cran


___
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: r367651 - head/usr.sbin/bhyve

2020-11-13 Thread Shawn Webb
On Fri, Nov 13, 2020 at 07:47:16PM +, Rebecca Cran wrote:
> Author: bcran
> Date: Fri Nov 13 19:47:16 2020
> New Revision: 367651
> URL: https://svnweb.freebsd.org/changeset/base/367651
> 
> Log:
>   bhyve: update smbiostbl.c to bump the version and release date
>   
>   Since lots of work has been done on bhyve since 2014, increase the version
>   to 13.0 to match 13-CURRENT, and update the release date.
>   
>   Reviewed by:grehan
>   Differential Revision:  https://reviews.freebsd.org/D27147
> 
> Modified:
>   head/usr.sbin/bhyve/smbiostbl.c
> 
> Modified: head/usr.sbin/bhyve/smbiostbl.c
> ==
> --- head/usr.sbin/bhyve/smbiostbl.c   Fri Nov 13 19:22:53 2020
> (r367650)
> +++ head/usr.sbin/bhyve/smbiostbl.c   Fri Nov 13 19:47:16 2020
> (r367651)
> @@ -51,6 +51,9 @@ __FBSDID("$FreeBSD$");
>  
>  #define SMBIOS_BASE  0xF1000
>  
> +#define FIRMWARE_VERSION "13.0"
> +#define FIRMWARE_RELEASE_DATE"11/10/2020"

Style nit: shouldn't there be a tab between #define and the macro?

Thanks,

-- 
Shawn Webb
Cofounder / Security Engineer
HardenedBSD

GPG Key ID:  0xFF2E67A277F8E1FA
GPG Key Fingerprint: D206 BB45 15E0 9C49 0CF9  3633 C85B 0AF8 AB23 0FB2
https://git-01.md.hardenedbsd.org/HardenedBSD/pubkeys/src/branch/master/Shawn_Webb/03A4CBEBB82EA5A67D9F3853FF2E67A277F8E1FA.pub.asc


signature.asc
Description: PGP signature


Re: svn commit: r367647 - head/tests/sys/vm

2020-11-13 Thread Kyle Evans
On Fri, Nov 13, 2020 at 12:50 PM Adrian Chadd  wrote:
>
> Author: adrian
> Date: Fri Nov 13 18:50:24 2020
> New Revision: 367647
> URL: https://svnweb.freebsd.org/changeset/base/367647
>
> Log:
>   [tests] Fix unused variable warning in gcc
>
>   Reviewed by:  markj, imp, cem,
>   Approved by:  markj
>   Differential Revision:https://reviews.freebsd.org/D26792
>
> Modified:
>   head/tests/sys/vm/page_fault_signal.c
>
> Modified: head/tests/sys/vm/page_fault_signal.c
> ==
> --- head/tests/sys/vm/page_fault_signal.c   Fri Nov 13 18:34:13 2020  
>   (r367646)
> +++ head/tests/sys/vm/page_fault_signal.c   Fri Nov 13 18:50:24 2020  
>   (r367647)
> @@ -115,7 +114,7 @@ ATF_TC_BODY(page_fault_signal__segv_accerr_2, tc)
> ATF_REQUIRE(p != MAP_FAILED);
> if (sigsetjmp(sig_env, 1) == 0) {
> setup_signals();
> -   dummy = *p;
> +   (void)*(volatile int *)p;
> }
> (void)munmap(p, sz);
> ATF_CHECK_EQ(SIGSEGV, last_sig);

A minor nit, we could/should probably add an explicit atf_tc_fail()
after the access. While it seems unlikely that the compiler might
elide it and it would still fail anyways because last_sig would
certainly not be SIGSEGV, it'd be good to catch it earlier with an
explicit fail. I don't recall how good atf-c's diagnostics are
otherwise, if it'd be clear that last_sig == 0 or not without
requiring further triage.

Thanks,

Kyle Evans
___
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: r367651 - head/usr.sbin/bhyve

2020-11-13 Thread Rebecca Cran
Author: bcran
Date: Fri Nov 13 19:47:16 2020
New Revision: 367651
URL: https://svnweb.freebsd.org/changeset/base/367651

Log:
  bhyve: update smbiostbl.c to bump the version and release date
  
  Since lots of work has been done on bhyve since 2014, increase the version
  to 13.0 to match 13-CURRENT, and update the release date.
  
  Reviewed by:  grehan
  Differential Revision:https://reviews.freebsd.org/D27147

Modified:
  head/usr.sbin/bhyve/smbiostbl.c

Modified: head/usr.sbin/bhyve/smbiostbl.c
==
--- head/usr.sbin/bhyve/smbiostbl.c Fri Nov 13 19:22:53 2020
(r367650)
+++ head/usr.sbin/bhyve/smbiostbl.c Fri Nov 13 19:47:16 2020
(r367651)
@@ -51,6 +51,9 @@ __FBSDID("$FreeBSD$");
 
 #define SMBIOS_BASE0xF1000
 
+#define FIRMWARE_VERSION   "13.0"
+#define FIRMWARE_RELEASE_DATE  "11/10/2020"
+
 /* BHYVE_ACPI_BASE - SMBIOS_BASE) */
 #defineSMBIOS_MAX_LENGTH   (0xF2400 - 0xF1000)
 
@@ -323,9 +326,9 @@ struct smbios_table_type0 smbios_type0_template = {
 };
 
 const char *smbios_type0_strings[] = {
-   "BHYVE",/* vendor string */
-   "1.00", /* bios version string */
-   "03/14/2014",   /* bios release date string */
+   "BHYVE",/* vendor string */
+   FIRMWARE_VERSION,   /* bios version string */
+   FIRMWARE_RELEASE_DATE,  /* bios release date string */
NULL
 };
 
___
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: r367650 - head/sys/kern

2020-11-13 Thread Mateusz Guzik
Author: mjg
Date: Fri Nov 13 19:22:53 2020
New Revision: 367650
URL: https://svnweb.freebsd.org/changeset/base/367650

Log:
  malloc: retire MALLOC_PROFILE
  
  The global array has prohibitive performance impact on multicore systems.
  
  The same data (and more) can be obtained with dtrace.
  
  Reviewed by:  markj
  Differential Revision:https://reviews.freebsd.org/D27199

Modified:
  head/sys/kern/kern_malloc.c

Modified: head/sys/kern/kern_malloc.c
==
--- head/sys/kern/kern_malloc.c Fri Nov 13 19:09:21 2020(r367649)
+++ head/sys/kern/kern_malloc.c Fri Nov 13 19:22:53 2020(r367650)
@@ -223,12 +223,6 @@ SYSCTL_PROC(_vm_malloc, OID_AUTO, zone_sizes,
  */
 struct mtx malloc_mtx;
 
-#ifdef MALLOC_PROFILE
-uint64_t krequests[KMEM_ZSIZE + 1];
-
-static int sysctl_kern_mprof(SYSCTL_HANDLER_ARGS);
-#endif
-
 static int sysctl_kern_malloc_stats(SYSCTL_HANDLER_ARGS);
 
 #if defined(MALLOC_MAKE_FAILURES) || (MALLOC_DEBUG_MAXZONES > 1)
@@ -635,9 +629,6 @@ void *
size = (size & ~KMEM_ZMASK) + KMEM_ZBASE;
indx = kmemsize[size >> KMEM_ZSHIFT];
zone = kmemzones[indx].kz_zone[mtp_get_subzone(mtp)];
-#ifdef MALLOC_PROFILE
-   krequests[size >> KMEM_ZSHIFT]++;
-#endif
va = uma_zalloc(zone, flags);
if (va != NULL)
size = zone->uz_size;
@@ -673,9 +664,6 @@ malloc_domain(size_t *sizep, int *indxp, struct malloc
size = (size & ~KMEM_ZMASK) + KMEM_ZBASE;
indx = kmemsize[size >> KMEM_ZSHIFT];
zone = kmemzones[indx].kz_zone[mtp_get_subzone(mtp)];
-#ifdef MALLOC_PROFILE
-   krequests[size >> KMEM_ZSHIFT]++;
-#endif
va = uma_zalloc_domain(zone, NULL, domain, flags);
if (va != NULL)
*sizep = zone->uz_size;
@@ -1495,52 +1483,3 @@ DB_SHOW_COMMAND(multizone_matches, db_show_multizone_m
 }
 #endif /* MALLOC_DEBUG_MAXZONES > 1 */
 #endif /* DDB */
-
-#ifdef MALLOC_PROFILE
-
-static int
-sysctl_kern_mprof(SYSCTL_HANDLER_ARGS)
-{
-   struct sbuf sbuf;
-   uint64_t count;
-   uint64_t waste;
-   uint64_t mem;
-   int error;
-   int rsize;
-   int size;
-   int i;
-
-   waste = 0;
-   mem = 0;
-
-   error = sysctl_wire_old_buffer(req, 0);
-   if (error != 0)
-   return (error);
-   sbuf_new_for_sysctl(, NULL, 128, req);
-   sbuf_printf(, 
-   "\n  SizeRequests  Real Size\n");
-   for (i = 0; i < KMEM_ZSIZE; i++) {
-   size = i << KMEM_ZSHIFT;
-   rsize = kmemzones[kmemsize[i]].kz_size;
-   count = (long long unsigned)krequests[i];
-
-   sbuf_printf(, "%6d%28llu%11d\n", size,
-   (unsigned long long)count, rsize);
-
-   if ((rsize * count) > (size * count))
-   waste += (rsize * count) - (size * count);
-   mem += (rsize * count);
-   }
-   sbuf_printf(,
-   "\nTotal memory used:\t%30llu\nTotal Memory wasted:\t%30llu\n",
-   (unsigned long long)mem, (unsigned long long)waste);
-   error = sbuf_finish();
-   sbuf_delete();
-   return (error);
-}
-
-SYSCTL_OID(_kern, OID_AUTO, mprof,
-CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_NEEDGIANT, NULL, 0,
-sysctl_kern_mprof, "A",
-"Malloc Profiling");
-#endif /* MALLOC_PROFILE */
___
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: r367648 - head/share/mk

2020-11-13 Thread Jessica Clarke
On 13 Nov 2020, at 19:08, Ed Maste  wrote:
> 
> Author: emaste
> Date: Fri Nov 13 19:08:42 2020
> New Revision: 367648
> URL: https://svnweb.freebsd.org/changeset/base/367648
> 
> Log:
>  Fix `make makeman` after r367577
> 
>  WITH_INIT_ALL_ZERO and WITH_INIT_ALL_PATTERN are mutually exclusive.
>  The .error when they were both set broke makeman so demote it to a
>  warning (and presumably the compiler will fail on an error later on).
> 
>  We could improve this to make one take precedence but this is sufficient
>  for now.

You won't get an error. Currently bsd.{prog,lib}.mk and kern.mk check
MK_INIT_ALL_ZERO then MK_INIT_ALL_PATTERN so the former takes
precedence, but I suspect that if you were to pass the compiler flags
for both the last flag would just override anything else, as is the
case for most compiler flags.

Jess

___
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: r367631 - in head/sys: kern sys

2020-11-13 Thread Konstantin Belousov
On Fri, Nov 13, 2020 at 07:30:47PM +0100, Mateusz Guzik wrote:
> On 11/13/20, Konstantin Belousov  wrote:
> > +static u_long vn_lock_pair_pause_cnt;
> > +SYSCTL_ULONG(_debug, OID_AUTO, vn_lock_pair_pause, CTLFLAG_RD,
> > +_lock_pair_pause_cnt, 0,
> > +"Count of vn_lock_pair deadlocks");
> > +
> > +static void
> > +vn_lock_pair_pause(const char *wmesg)
> > +{
> > +   atomic_add_long(_lock_pair_pause_cnt, 1);
> > +   pause(wmesg, prng32_bounded(hz / 10));
> > +}
> > +
> > +/*
> > + * Lock pair of vnodes vp1, vp2, avoiding lock order reversal.
> > + * vp1_locked indicates whether vp1 is exclusively locked; if not, vp1
> > + * must be unlocked.  Same for vp2 and vp2_locked.  One of the vnodes
> > + * can be NULL.
> > + *
> > + * The function returns with both vnodes exclusively locked, and
> > + * guarantees that it does not create lock order reversal with other
> > + * threads during its execution.  Both vnodes could be unlocked
> > + * temporary (and reclaimed).
> > + */
> > +void
> > +vn_lock_pair(struct vnode *vp1, bool vp1_locked, struct vnode *vp2,
> > +bool vp2_locked)
> > +{
> > +   int error;
> > +
> > +   if (vp1 == NULL && vp2 == NULL)
> > +   return;
> > +   if (vp1 != NULL) {
> > +   if (vp1_locked)
> > +   ASSERT_VOP_ELOCKED(vp1, "vp1");
> > +   else
> > +   ASSERT_VOP_UNLOCKED(vp1, "vp1");
> > +   } else {
> > +   vp1_locked = true;
> > +   }
> > +   if (vp2 != NULL) {
> > +   if (vp2_locked)
> > +   ASSERT_VOP_ELOCKED(vp2, "vp2");
> > +   else
> > +   ASSERT_VOP_UNLOCKED(vp2, "vp2");
> > +   } else {
> > +   vp2_locked = true;
> > +   }
> > +   if (!vp1_locked && !vp2_locked) {
> > +   vn_lock(vp1, LK_EXCLUSIVE | LK_RETRY);
> > +   vp1_locked = true;
> > +   }
> > +
> > +   for (;;) {
> > +   if (vp1_locked && vp2_locked)
> > +   break;
> > +   if (vp1_locked && vp2 != NULL) {
> > +   if (vp1 != NULL) {
> > +   error = VOP_LOCK1(vp2, LK_EXCLUSIVE | LK_NOWAIT,
> > +   __FILE__, __LINE__);
> > +   if (error == 0)
> > +   break;
> > +   VOP_UNLOCK(vp1);
> > +   vp1_locked = false;
> > +   vn_lock_pair_pause("vlp1");
> > +   }
> > +   vn_lock(vp2, LK_EXCLUSIVE | LK_RETRY);
> > +   vp2_locked = true;
> > +   }
> > +   if (vp2_locked && vp1 != NULL) {
> > +   if (vp2 != NULL) {
> > +   error = VOP_LOCK1(vp1, LK_EXCLUSIVE | LK_NOWAIT,
> > +   __FILE__, __LINE__);
> > +   if (error == 0)
> > +   break;
> > +   VOP_UNLOCK(vp2);
> > +   vp2_locked = false;
> > +   vn_lock_pair_pause("vlp2");
> > +   }
> > +   vn_lock(vp1, LK_EXCLUSIVE | LK_RETRY);
> > +   vp1_locked = true;
> > +   }
> > +   }
> > +   if (vp1 != NULL)
> > +   ASSERT_VOP_ELOCKED(vp1, "vp1 ret");
> > +   if (vp2 != NULL)
> > +   ASSERT_VOP_ELOCKED(vp2, "vp2 ret");
> >  }
> >
> 
> Multiple callers who get here with flipped addresses can end up
> failing against each other in an indefinite loop.
> 
> Instead, after initial trylocking fails, the routine should establish
> ordering it will follow for itself, for example by sorting by address.
> 
> Then pseudo-code would be:
> retry:
> vn_lock(lower, ...);
> if (!VOP_LOCK(higher, LK_NOWAIT ...)) {
>  vn_unlock(lower);
>  vn_lock(higher);
>  vn_unlock(higher);
>  goto retry;
> }
> 
> Note this also eliminates the pause.

I disagree.  It will conflict with normal locking order with 50% probability.
My code switches between two orders, eventually getting out of this situation.
___
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: r367631 - in head/sys: kern sys

2020-11-13 Thread Konstantin Belousov
On Fri, Nov 13, 2020 at 08:24:30AM -0800, Conrad Meyer wrote:
> Hi Konstantin,
> 
> On Fri, Nov 13, 2020 at 1:32 AM Konstantin Belousov  wrote:
> >
> > Author: kib
> > Date: Fri Nov 13 09:31:57 2020
> > New Revision: 367631
> > URL: https://svnweb.freebsd.org/changeset/base/367631
> >
> > Log:
> >   Implement vn_lock_pair().
> >
> > Modified: head/sys/kern/vfs_vnops.c
> > ==
> > --- head/sys/kern/vfs_vnops.c   Fri Nov 13 02:05:45 2020(r367630)
> > +++ head/sys/kern/vfs_vnops.c   Fri Nov 13 09:31:57 2020(r367631)
> > @@ -3317,4 +3325,92 @@ vn_fallocate(struct file *fp, off_t offset, off_t 
> > len,
> > ...
> > +
> > +static void
> > +vn_lock_pair_pause(const char *wmesg)
> > +{
> > +   atomic_add_long(_lock_pair_pause_cnt, 1);
> > +   pause(wmesg, prng32_bounded(hz / 10));
> > +}
> 
> This function is called when the try-lock of the second lock in the
> pair (either order) fails.  The back-off period is up to 100ms,
> expected average 50ms.  That seems really high?
It is called only in deadlock avoidance case, where we already have to drop
to slow path for other reasons (this is coming in the patch that I hope to
commit today).

My selection of numbers were driven by more or less realistic estimates
of the vnode lock ownership time for sync io on very busy HDD, there was
a short discussion of it with Mark in review.

> 
> Separately: prng32_bounded() may return 0, which is transparently
> converted to the equivalent of 1 by pause_sbt(9).  This means a 1 tick
> pause is marginally more likely than any other possible duration.  It
> probably doesn't matter.
I do not quite understand the point.  Do you want the 0->1 conversion
be explicit there ?  Or something else ?
___
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: r367649 - head/share/man/man5

2020-11-13 Thread Ed Maste
Author: emaste
Date: Fri Nov 13 19:09:21 2020
New Revision: 367649
URL: https://svnweb.freebsd.org/changeset/base/367649

Log:
  src.conf.5: regenerate after r367577
  
  INIT_ALL_ZERO / INIT_ALL_PATTERN

Modified:
  head/share/man/man5/src.conf.5

Modified: head/share/man/man5/src.conf.5
==
--- head/share/man/man5/src.conf.5  Fri Nov 13 19:08:42 2020
(r367648)
+++ head/share/man/man5/src.conf.5  Fri Nov 13 19:09:21 2020
(r367649)
@@ -1,6 +1,6 @@
 .\" DO NOT EDIT-- this file is @generated by tools/build/options/makeman.
 .\" $FreeBSD$
-.Dd November 4, 2020
+.Dd November 13, 2020
 .Dt SRC.CONF 5
 .Os
 .Sh NAME
@@ -757,6 +757,15 @@ Set to not build
 .Xr inetd 8 .
 .It Va WITHOUT_INET_SUPPORT
 Set to build libraries, programs, and kernel modules without IPv4 support.
+.It Va WITH_INIT_ALL_PATTERN
+Set to build the base system or kernel with stack variables initialized to
+.Pq compiler defined
+debugging patterns on function entry.
+This option requires the clang compiler.
+.It Va WITH_INIT_ALL_ZERO
+Set to build the base system or kernel with stack variables initialized
+to zero on function entry.
+This option requires that the clang compiler be used.
 .It Va WITHOUT_INSTALLLIB
 Set this to not install optional libraries.
 For example, when creating a
___
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: r367648 - head/share/mk

2020-11-13 Thread Ed Maste
Author: emaste
Date: Fri Nov 13 19:08:42 2020
New Revision: 367648
URL: https://svnweb.freebsd.org/changeset/base/367648

Log:
  Fix `make makeman` after r367577
  
  WITH_INIT_ALL_ZERO and WITH_INIT_ALL_PATTERN are mutually exclusive.
  The .error when they were both set broke makeman so demote it to a
  warning (and presumably the compiler will fail on an error later on).
  
  We could improve this to make one take precedence but this is sufficient
  for now.
  
  MFC with: r367577
  Sponsored by: The FreeBSD Foundation

Modified:
  head/share/mk/bsd.opts.mk

Modified: head/share/mk/bsd.opts.mk
==
--- head/share/mk/bsd.opts.mk   Fri Nov 13 18:50:24 2020(r367647)
+++ head/share/mk/bsd.opts.mk   Fri Nov 13 19:08:42 2020(r367648)
@@ -88,7 +88,7 @@ __DEFAULT_DEPENDENT_OPTIONS = \
 .include 
 
 .if ${MK_INIT_ALL_PATTERN} == "yes" && ${MK_INIT_ALL_ZERO} == "yes"
-.error WITH_INIT_ALL_PATTERN and WITH_INIT_ALL_ZERO are mutually exclusive.
+.warning WITH_INIT_ALL_PATTERN and WITH_INIT_ALL_ZERO are mutually exclusive.
 .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: r367647 - head/tests/sys/vm

2020-11-13 Thread Adrian Chadd
Author: adrian
Date: Fri Nov 13 18:50:24 2020
New Revision: 367647
URL: https://svnweb.freebsd.org/changeset/base/367647

Log:
  [tests] Fix unused variable warning in gcc
  
  Reviewed by:  markj, imp, cem,
  Approved by:  markj
  Differential Revision:https://reviews.freebsd.org/D26792

Modified:
  head/tests/sys/vm/page_fault_signal.c

Modified: head/tests/sys/vm/page_fault_signal.c
==
--- head/tests/sys/vm/page_fault_signal.c   Fri Nov 13 18:34:13 2020
(r367646)
+++ head/tests/sys/vm/page_fault_signal.c   Fri Nov 13 18:50:24 2020
(r367647)
@@ -107,7 +107,6 @@ ATF_TC_WITHOUT_HEAD(page_fault_signal__segv_accerr_2);
 ATF_TC_BODY(page_fault_signal__segv_accerr_2, tc)
 {
int *p;
-   volatile int dummy;
int sz;
 
sz = getpagesize();
@@ -115,7 +114,7 @@ ATF_TC_BODY(page_fault_signal__segv_accerr_2, tc)
ATF_REQUIRE(p != MAP_FAILED);
if (sigsetjmp(sig_env, 1) == 0) {
setup_signals();
-   dummy = *p;
+   (void)*(volatile int *)p;
}
(void)munmap(p, sz);
ATF_CHECK_EQ(SIGSEGV, last_sig);
___
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: r367646 - head/sys/conf

2020-11-13 Thread Ed Maste
Author: emaste
Date: Fri Nov 13 18:34:13 2020
New Revision: 367646
URL: https://svnweb.freebsd.org/changeset/base/367646

Log:
  Disable kernel INIT_ALL_ZERO on amd64
  
  It is currently incompatible with kernel ifunc memset.
  
  PR:   251083
  MFC with: r367577
  Sponsored by: The FreeBSD Foundation

Modified:
  head/sys/conf/kern.opts.mk

Modified: head/sys/conf/kern.opts.mk
==
--- head/sys/conf/kern.opts.mk  Fri Nov 13 18:25:07 2020(r367645)
+++ head/sys/conf/kern.opts.mk  Fri Nov 13 18:34:13 2020(r367646)
@@ -68,6 +68,11 @@ __DEFAULT_NO_OPTIONS = \
 # affected by KERNEL_SYMBOLS, FORMAT_EXTENSIONS, CTF and SSP.
 
 # Things that don't work based on the CPU
+.if ${MACHINE} == "amd64"
+# PR251083 conflict between INIT_ALL_ZERO and ifunc memset
+BROKEN_OPTIONS+= INIT_ALL_ZERO
+.endif
+
 .if ${MACHINE_CPUARCH} == "arm"
 . if ${MACHINE_ARCH:Marmv[67]*} == ""
 BROKEN_OPTIONS+= CDDL ZFS
___
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: r367631 - in head/sys: kern sys

2020-11-13 Thread Mateusz Guzik
On 11/13/20, Konstantin Belousov  wrote:
> +static u_long vn_lock_pair_pause_cnt;
> +SYSCTL_ULONG(_debug, OID_AUTO, vn_lock_pair_pause, CTLFLAG_RD,
> +_lock_pair_pause_cnt, 0,
> +"Count of vn_lock_pair deadlocks");
> +
> +static void
> +vn_lock_pair_pause(const char *wmesg)
> +{
> + atomic_add_long(_lock_pair_pause_cnt, 1);
> + pause(wmesg, prng32_bounded(hz / 10));
> +}
> +
> +/*
> + * Lock pair of vnodes vp1, vp2, avoiding lock order reversal.
> + * vp1_locked indicates whether vp1 is exclusively locked; if not, vp1
> + * must be unlocked.  Same for vp2 and vp2_locked.  One of the vnodes
> + * can be NULL.
> + *
> + * The function returns with both vnodes exclusively locked, and
> + * guarantees that it does not create lock order reversal with other
> + * threads during its execution.  Both vnodes could be unlocked
> + * temporary (and reclaimed).
> + */
> +void
> +vn_lock_pair(struct vnode *vp1, bool vp1_locked, struct vnode *vp2,
> +bool vp2_locked)
> +{
> + int error;
> +
> + if (vp1 == NULL && vp2 == NULL)
> + return;
> + if (vp1 != NULL) {
> + if (vp1_locked)
> + ASSERT_VOP_ELOCKED(vp1, "vp1");
> + else
> + ASSERT_VOP_UNLOCKED(vp1, "vp1");
> + } else {
> + vp1_locked = true;
> + }
> + if (vp2 != NULL) {
> + if (vp2_locked)
> + ASSERT_VOP_ELOCKED(vp2, "vp2");
> + else
> + ASSERT_VOP_UNLOCKED(vp2, "vp2");
> + } else {
> + vp2_locked = true;
> + }
> + if (!vp1_locked && !vp2_locked) {
> + vn_lock(vp1, LK_EXCLUSIVE | LK_RETRY);
> + vp1_locked = true;
> + }
> +
> + for (;;) {
> + if (vp1_locked && vp2_locked)
> + break;
> + if (vp1_locked && vp2 != NULL) {
> + if (vp1 != NULL) {
> + error = VOP_LOCK1(vp2, LK_EXCLUSIVE | LK_NOWAIT,
> + __FILE__, __LINE__);
> + if (error == 0)
> + break;
> + VOP_UNLOCK(vp1);
> + vp1_locked = false;
> + vn_lock_pair_pause("vlp1");
> + }
> + vn_lock(vp2, LK_EXCLUSIVE | LK_RETRY);
> + vp2_locked = true;
> + }
> + if (vp2_locked && vp1 != NULL) {
> + if (vp2 != NULL) {
> + error = VOP_LOCK1(vp1, LK_EXCLUSIVE | LK_NOWAIT,
> + __FILE__, __LINE__);
> + if (error == 0)
> + break;
> + VOP_UNLOCK(vp2);
> + vp2_locked = false;
> + vn_lock_pair_pause("vlp2");
> + }
> + vn_lock(vp1, LK_EXCLUSIVE | LK_RETRY);
> + vp1_locked = true;
> + }
> + }
> + if (vp1 != NULL)
> + ASSERT_VOP_ELOCKED(vp1, "vp1 ret");
> + if (vp2 != NULL)
> + ASSERT_VOP_ELOCKED(vp2, "vp2 ret");
>  }
>

Multiple callers who get here with flipped addresses can end up
failing against each other in an indefinite loop.

Instead, after initial trylocking fails, the routine should establish
ordering it will follow for itself, for example by sorting by address.

Then pseudo-code would be:
retry:
vn_lock(lower, ...);
if (!VOP_LOCK(higher, LK_NOWAIT ...)) {
 vn_unlock(lower);
 vn_lock(higher);
 vn_unlock(higher);
 goto retry;
}

Note this also eliminates the pause.

-- 
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"


svn commit: r367645 - head/sys/netinet

2020-11-13 Thread Ed Maste
Author: emaste
Date: Fri Nov 13 18:25:07 2020
New Revision: 367645
URL: https://svnweb.freebsd.org/changeset/base/367645

Log:
  ip_fastfwd: style(9) tidy for r367628
  
  Discussed with:   gnn
  MFC with: r367628

Modified:
  head/sys/netinet/ip_fastfwd.c
  head/sys/netinet/ip_input.c

Modified: head/sys/netinet/ip_fastfwd.c
==
--- head/sys/netinet/ip_fastfwd.c   Fri Nov 13 16:56:03 2020
(r367644)
+++ head/sys/netinet/ip_fastfwd.c   Fri Nov 13 18:25:07 2020
(r367645)
@@ -131,17 +131,18 @@ ip_redir_alloc(struct mbuf *m, struct nhop_object *nh,
 */
m_free(mcopy);
return (NULL);
-   } 
+   }
mcopy->m_len = min(ntohs(ip->ip_len), M_TRAILINGSPACE(mcopy));
mcopy->m_pkthdr.len = mcopy->m_len;
m_copydata(m, 0, mcopy->m_len, mtod(mcopy, caddr_t));
-   
+
if (nh != NULL &&
((nh->nh_flags & (NHF_REDIRECT|NHF_DEFAULT)) == 0)) {
struct in_ifaddr *nh_ia = (struct in_ifaddr *)(nh->nh_ifa);
u_long src = ntohl(ip->ip_src.s_addr);
-   
-   if (nh_ia != NULL && (src & nh_ia->ia_subnetmask) == 
nh_ia->ia_subnet) {
+
+   if (nh_ia != NULL &&
+   (src & nh_ia->ia_subnetmask) == nh_ia->ia_subnet) {
if (nh->nh_flags & NHF_GATEWAY)
*addr = nh->gw4_sa.sin_addr.s_addr;
else

Modified: head/sys/netinet/ip_input.c
==
--- head/sys/netinet/ip_input.c Fri Nov 13 16:56:03 2020(r367644)
+++ head/sys/netinet/ip_input.c Fri Nov 13 18:25:07 2020(r367645)
@@ -111,7 +111,7 @@ SYSCTL_INT(_net_inet_ip, IPCTL_FORWARDING, forwarding,
 _NAME(ipforwarding), 0,
 "Enable IP forwarding between interfaces");
 
-/* 
+/*
  * Respond with an ICMP host redirect when we forward a packet out of
  * the same interface on which it was received.  See RFC 792.
  */
___
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: r367644 - head/sys/powerpc/aim

2020-11-13 Thread Brandon Bergren
Author: bdragon
Date: Fri Nov 13 16:56:03 2020
New Revision: 367644
URL: https://svnweb.freebsd.org/changeset/base/367644

Log:
  [PowerPC64LE] Radix MMU fixes for LE.
  
  There were many, many endianness fixes needed for Radix MMU. The Radix
  pagetable is stored in BE (as it is read and written to by the MMU hw),
  so we need to convert back and forth every time we interact with it when
  running in LE.
  
  With these changes, I can successfully boot with radix enabled on POWER9 hw.
  
  Reviewed by:  luporl, jhibbits
  Sponsored by: Tag1 Consulting, Inc.
  Differential Revision:https://reviews.freebsd.org/D27181

Modified:
  head/sys/powerpc/aim/mmu_radix.c

Modified: head/sys/powerpc/aim/mmu_radix.c
==
--- head/sys/powerpc/aim/mmu_radix.cFri Nov 13 16:49:41 2020
(r367643)
+++ head/sys/powerpc/aim/mmu_radix.cFri Nov 13 16:56:03 2020
(r367644)
@@ -309,7 +309,7 @@ pmap_l3e_to_pte(pt_entry_t *l3e, vm_offset_t va)
pt_entry_t *pte;
vm_paddr_t ptepa;
 
-   ptepa = (*l3e & NLB_MASK);
+   ptepa = (be64toh(*l3e) & NLB_MASK);
pte = (pt_entry_t *)PHYS_TO_DMAP(ptepa);
return ([pmap_pte_index(va)]);
 }
@@ -321,7 +321,7 @@ pmap_l2e_to_l3e(pt_entry_t *l2e, vm_offset_t va)
pt_entry_t *l3e;
vm_paddr_t l3pa;
 
-   l3pa = (*l2e & NLB_MASK);
+   l3pa = (be64toh(*l2e) & NLB_MASK);
l3e = (pml3_entry_t *)PHYS_TO_DMAP(l3pa);
return ([pmap_pml3e_index(va)]);
 }
@@ -333,7 +333,7 @@ pmap_l1e_to_l2e(pt_entry_t *l1e, vm_offset_t va)
pt_entry_t *l2e;
vm_paddr_t l2pa;
 
-   l2pa = (*l1e & NLB_MASK);
+   l2pa = (be64toh(*l1e) & NLB_MASK);
 
l2e = (pml2_entry_t *)PHYS_TO_DMAP(l2pa);
return ([pmap_pml2e_index(va)]);
@@ -352,7 +352,7 @@ pmap_pml2e(pmap_t pmap, vm_offset_t va)
pt_entry_t *l1e;
 
l1e = pmap_pml1e(pmap, va);
-   if (l1e == NULL || (*l1e & RPTE_VALID) == 0)
+   if (l1e == NULL || (be64toh(*l1e) & RPTE_VALID) == 0)
return (NULL);
return (pmap_l1e_to_l2e(l1e, va));
 }
@@ -363,7 +363,7 @@ pmap_pml3e(pmap_t pmap, vm_offset_t va)
pt_entry_t *l2e;
 
l2e = pmap_pml2e(pmap, va);
-   if (l2e == NULL || (*l2e & RPTE_VALID) == 0)
+   if (l2e == NULL || (be64toh(*l2e) & RPTE_VALID) == 0)
return (NULL);
return (pmap_l2e_to_l3e(l2e, va));
 }
@@ -374,7 +374,7 @@ pmap_pte(pmap_t pmap, vm_offset_t va)
pt_entry_t *l3e;
 
l3e = pmap_pml3e(pmap, va);
-   if (l3e == NULL || (*l3e & RPTE_VALID) == 0)
+   if (l3e == NULL || (be64toh(*l3e) & RPTE_VALID) == 0)
return (NULL);
return (pmap_l3e_to_pte(l3e, va));
 }
@@ -819,13 +819,13 @@ pa_cmp(const void *a, const void *b)
 #definepte_load_clear(ptep)atomic_swap_long(ptep, 0)
 #definepte_store(ptep, pte) do {  \
MPASS((pte) & (RPTE_EAA_R | RPTE_EAA_W | RPTE_EAA_X));  \
-   *(u_long *)(ptep) = (u_long)((pte) | PG_V | RPTE_LEAF); \
+   *(u_long *)(ptep) = htobe64((u_long)((pte) | PG_V | RPTE_LEAF)); \
 } while (0)
 /*
  * NB: should only be used for adding directories - not for direct mappings
  */
 #definepde_store(ptep, pa) do {\
-   *(u_long *)(ptep) = (u_long)(pa|RPTE_VALID|RPTE_SHIFT); \
+   *(u_long *)(ptep) = htobe64((u_long)(pa|RPTE_VALID|RPTE_SHIFT)); \
 } while (0)
 
 #definepte_clear(ptep) do {\
@@ -885,7 +885,7 @@ kvtopte(vm_offset_t va)
pt_entry_t *l3e;
 
l3e = pmap_pml3e(kernel_pmap, va);
-   if ((*l3e & RPTE_VALID) == 0)
+   if ((be64toh(*l3e) & RPTE_VALID) == 0)
return (NULL);
return (pmap_l3e_to_pte(l3e, va));
 }
@@ -897,8 +897,8 @@ mmu_radix_kenter(vm_offset_t va, vm_paddr_t pa)
 
pte = kvtopte(va);
MPASS(pte != NULL);
-   *pte = pa | RPTE_VALID | RPTE_LEAF | RPTE_EAA_R | RPTE_EAA_W | \
-   RPTE_EAA_P | PG_M | PG_A;
+   *pte = htobe64(pa | RPTE_VALID | RPTE_LEAF | RPTE_EAA_R | \
+   RPTE_EAA_W | RPTE_EAA_P | PG_M | PG_A);
 }
 
 bool
@@ -915,17 +915,17 @@ pmap_nofault_pte(pmap_t pmap, vm_offset_t va, int *is_
 
va &= PG_PS_FRAME;
l3e = pmap_pml3e(pmap, va);
-   if (l3e == NULL || (*l3e & PG_V) == 0)
+   if (l3e == NULL || (be64toh(*l3e) & PG_V) == 0)
return (NULL);
 
-   if (*l3e & RPTE_LEAF) {
+   if (be64toh(*l3e) & RPTE_LEAF) {
*is_l3e = 1;
return (l3e);
}
*is_l3e = 0;
va &= PG_FRAME;
pte = pmap_l3e_to_pte(l3e, va);
-   if (pte == NULL || (*pte & PG_V) == 0)
+   if (pte == NULL || (be64toh(*pte) & PG_V) == 0)
return (NULL);
return (pte);
 }
@@ -942,7 +942,7 @@ pmap_nofault(pmap_t pmap, vm_offset_t va, vm_prot_t fl
  retry:
if ((pte = 

svn commit: r367643 - in head: sys/dev/ofw usr.sbin/ofwdump

2020-11-13 Thread Brandon Bergren
Author: bdragon
Date: Fri Nov 13 16:49:41 2020
New Revision: 367643
URL: https://svnweb.freebsd.org/changeset/base/367643

Log:
  [PowerPC] Allow traversal of oversize OF properties.
  
  In standards such as LoPAPR, property names in excess of the usual 31
  characters exist.
  
  This breaks property traversal.
  
  While in IEEE 1275-1994, nextprop is defined explicitly to work with a
  32-byte region of memory, using a larger buffer should be fine. There is
  actually no way to pass a buffer length to the nextprop call in the OF
  client interface, so SLOF actually just blindly overflows the buffer.
  
  So we have to defensively make the buffer larger, to avoid memory
  corruption when reading out long properties on live OF systems.
  
  Note also that on real-mode OF, things are pretty tight because we are
  allocating against a static bounce buffer in low memory, so we can't just
  use a huge buffer to work around this without it being wasteful of our
  limited amount of 32-bit physical memory.
  
  This allows a patched ofwdump to operate properly on SLOF (i.e. pseries)
  systems, as well as any other PowerPC systems with overlength properties.
  
  Reviewed by:  jhibbits
  MFC after:2 weeks
  Sponsored by: Tag1 Consulting, Inc.
  Differential Revision:https://reviews.freebsd.org/D26669

Modified:
  head/sys/dev/ofw/openfirmio.c
  head/sys/dev/ofw/openfirmio.h
  head/usr.sbin/ofwdump/ofwdump.c

Modified: head/sys/dev/ofw/openfirmio.c
==
--- head/sys/dev/ofw/openfirmio.c   Fri Nov 13 16:47:42 2020
(r367642)
+++ head/sys/dev/ofw/openfirmio.c   Fri Nov 13 16:49:41 2020
(r367643)
@@ -115,7 +115,7 @@ openfirm_ioctl(struct cdev *dev, u_long cmd, caddr_t d
phandle_t node;
int len, ok, error;
char *name, *value;
-   char newname[32];
+   char newname[OFIOCSUGGPROPNAMELEN];
 
if ((flags & FREAD) == 0)
return (EBADF);
@@ -222,8 +222,19 @@ openfirm_ioctl(struct cdev *dev, u_long cmd, caddr_t d
break;
}
len = strlen(newname) + 1;
-   if (len > of->of_buflen)
+   if (len > of->of_buflen) {
+   /*
+* Passed buffer was insufficient.
+*
+* Instead of returning an error here, truncate the
+* property name to fit the buffer.
+*
+* This allows us to retain compatibility with old
+* tools which always pass a 32 character buffer.
+*/
len = of->of_buflen;
+   newname[len - 1] = '\0';
+   }
else
of->of_buflen = len;
error = copyout(newname, of->of_buf, len);

Modified: head/sys/dev/ofw/openfirmio.h
==
--- head/sys/dev/ofw/openfirmio.h   Fri Nov 13 16:47:42 2020
(r367642)
+++ head/sys/dev/ofw/openfirmio.h   Fri Nov 13 16:49:41 2020
(r367643)
@@ -76,4 +76,18 @@ struct ofiocdesc {
 /* Maximum accepted value length (maximum of nvramrc property). */
 #defineOFIOCMAXVALUE   8192
 
+/*
+ * While IEEE 1275-1994 states in 3.2.2.1.1 that property names are 1-31
+ * printable characters, in practice, this limit has been ignored.
+ * Noncompliant properties have been codified in standards such as LoPAPR.
+ *
+ * This is a suggested buffer length that should be large enough to hold
+ * any property name currently seen in device trees, without being overly
+ * wasteful of memory.
+ *
+ * If a future version of the Devicetree specification updates the property
+ * names length requirement, this value will be updated to match.
+ */
+#defineOFIOCSUGGPROPNAMELEN64
+
 #endif /* _DEV_OFW_OPENFIRMIO_H_ */

Modified: head/usr.sbin/ofwdump/ofwdump.c
==
--- head/usr.sbin/ofwdump/ofwdump.c Fri Nov 13 16:47:42 2020
(r367642)
+++ head/usr.sbin/ofwdump/ofwdump.c Fri Nov 13 16:49:41 2020
(r367643)
@@ -144,7 +144,7 @@ static void
 ofw_dump_properties(int fd, phandle_t n, int level, int raw, int str)
 {
int nlen;
-   char prop[32];
+   char prop[OFIOCSUGGPROPNAMELEN];
 
for (nlen = ofw_firstprop(fd, n, prop, sizeof(prop)); nlen != 0;
 nlen = ofw_nextprop(fd, n, prop, prop, sizeof(prop)))
___
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: r367642 - head/bin/df

2020-11-13 Thread Mark Johnston
Author: markj
Date: Fri Nov 13 16:47:42 2020
New Revision: 367642
URL: https://svnweb.freebsd.org/changeset/base/367642

Log:
  df: Remove support for mounting devices
  
  This was marked deprecated in r329092, over two and a half years ago.
  This functionality is also buggy per PR 237368.
  
  PR:   237368
  Reviewed by:  brooks, cem, emaste, imp
  Differential Revision:https://reviews.freebsd.org/D27197

Modified:
  head/bin/df/Makefile
  head/bin/df/df.1
  head/bin/df/df.c

Modified: head/bin/df/Makefile
==
--- head/bin/df/MakefileFri Nov 13 14:56:34 2020(r367641)
+++ head/bin/df/MakefileFri Nov 13 16:47:42 2020(r367642)
@@ -10,9 +10,6 @@ SRCS= df.c vfslist.c
 
 CFLAGS+= -I${MOUNT}
 
-CFLAGS+= -DMOUNT_CHAR_DEVS
-SRCS+= getmntopts.c
-
 LIBADD=xo util
 
 .include 

Modified: head/bin/df/df.1
==
--- head/bin/df/df.1Fri Nov 13 14:56:34 2020(r367641)
+++ head/bin/df/df.1Fri Nov 13 16:47:42 2020(r367642)
@@ -48,6 +48,7 @@ The
 .Nm
 utility
 displays statistics about the amount of free disk space on the specified
+mounted
 .Ar file system
 or on the file system of which
 .Ar file

Modified: head/bin/df/df.c
==
--- head/bin/df/df.cFri Nov 13 14:56:34 2020(r367641)
+++ head/bin/df/df.cFri Nov 13 16:47:42 2020(r367642)
@@ -52,16 +52,10 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
-#ifdef MOUNT_CHAR_DEVS
-#include 
-#endif
 #include 
 #include 
 #include 
 #include 
-#ifdef MOUNT_CHAR_DEVS
-#include 
-#endif
 #include 
 #include 
 #include 
@@ -106,9 +100,6 @@ imax(int a, int b)
 
 static int aflag = 0, cflag, hflag, iflag, kflag, lflag = 0, nflag, Tflag;
 static int thousands;
-#ifdef MOUNT_CHAR_DEVS
-static struct  ufs_args mdev;
-#endif
 
 static const struct option long_options[] =
 {
@@ -123,21 +114,11 @@ main(int argc, char *argv[])
struct statfs statfsbuf, totalbuf;
struct maxwidths maxwidths;
struct statfs *mntbuf;
-#ifdef MOUNT_CHAR_DEVS
-   struct iovec *iov = NULL;
-#endif
const char *fstype;
-#ifdef MOUNT_CHAR_DEVS
-   char *mntpath;
-   char errmsg[255] = {0};
-#endif
char *mntpt;
const char **vfslist;
int i, mntsize;
int ch, rv;
-#ifdef MOUNT_CHAR_DEVS
-   int iovlen = 0;
-#endif
 
fstype = "ufs";
(void)setlocale(LC_ALL, "");
@@ -255,66 +236,15 @@ main(int argc, char *argv[])
continue;
}
} else if (S_ISCHR(stbuf.st_mode)) {
-   if ((mntpt = getmntpt(*argv)) == NULL) {
-#ifdef MOUNT_CHAR_DEVS
-   xo_warnx(
-   "df on unmounted devices is deprecated");
-   mdev.fspec = *argv;
-   mntpath = strdup("/tmp/df.XX");
-   if (mntpath == NULL) {
-   xo_warn("strdup failed");
-   rv = 1;
-   continue;
-   }
-   mntpt = mkdtemp(mntpath);
-   if (mntpt == NULL) {
-   xo_warn("mkdtemp(\"%s\") failed", 
mntpath);
-   rv = 1;
-   free(mntpath);
-   continue;
-   }
-   if (iov != NULL)
-   free_iovec(, );
-   build_iovec_argf(, , "fstype", "%s",
-   fstype);
-   build_iovec_argf(, , "fspath", "%s",
-   mntpath);
-   build_iovec_argf(, , "from", "%s",
-   *argv);
-   build_iovec(, , "errmsg", errmsg,
-   sizeof(errmsg));
-   if (nmount(iov, iovlen,
-   MNT_RDONLY|MNT_NOEXEC) < 0) {
-   if (errmsg[0])
-   xo_warn("%s: %s", *argv,
-   errmsg);
-   else
-   xo_warn("%s", *argv);
-   rv = 1;
-   (void)rmdir(mntpt);
-   free(mntpath);
-   continue;
-   } 

Re: svn commit: r367631 - in head/sys: kern sys

2020-11-13 Thread Conrad Meyer
Hi Konstantin,

On Fri, Nov 13, 2020 at 1:32 AM Konstantin Belousov  wrote:
>
> Author: kib
> Date: Fri Nov 13 09:31:57 2020
> New Revision: 367631
> URL: https://svnweb.freebsd.org/changeset/base/367631
>
> Log:
>   Implement vn_lock_pair().
>
> Modified: head/sys/kern/vfs_vnops.c
> ==
> --- head/sys/kern/vfs_vnops.c   Fri Nov 13 02:05:45 2020(r367630)
> +++ head/sys/kern/vfs_vnops.c   Fri Nov 13 09:31:57 2020(r367631)
> @@ -3317,4 +3325,92 @@ vn_fallocate(struct file *fp, off_t offset, off_t len,
> ...
> +
> +static void
> +vn_lock_pair_pause(const char *wmesg)
> +{
> +   atomic_add_long(_lock_pair_pause_cnt, 1);
> +   pause(wmesg, prng32_bounded(hz / 10));
> +}

This function is called when the try-lock of the second lock in the
pair (either order) fails.  The back-off period is up to 100ms,
expected average 50ms.  That seems really high?

Separately: prng32_bounded() may return 0, which is transparently
converted to the equivalent of 1 by pause_sbt(9).  This means a 1 tick
pause is marginally more likely than any other possible duration.  It
probably doesn't matter.

Thanks,
Conrad

> +
> +/*
> + * Lock pair of vnodes vp1, vp2, avoiding lock order reversal.
> + * vp1_locked indicates whether vp1 is exclusively locked; if not, vp1
> + * must be unlocked.  Same for vp2 and vp2_locked.  One of the vnodes
> + * can be NULL.
> + *
> + * The function returns with both vnodes exclusively locked, and
> + * guarantees that it does not create lock order reversal with other
> + * threads during its execution.  Both vnodes could be unlocked
> + * temporary (and reclaimed).
> + */
> +void
> +vn_lock_pair(struct vnode *vp1, bool vp1_locked, struct vnode *vp2,
> +bool vp2_locked)
> +{
> +   int error;
> +
> +   if (vp1 == NULL && vp2 == NULL)
> +   return;
> +   if (vp1 != NULL) {
> +   if (vp1_locked)
> +   ASSERT_VOP_ELOCKED(vp1, "vp1");
> +   else
> +   ASSERT_VOP_UNLOCKED(vp1, "vp1");
> +   } else {
> +   vp1_locked = true;
> +   }
> +   if (vp2 != NULL) {
> +   if (vp2_locked)
> +   ASSERT_VOP_ELOCKED(vp2, "vp2");
> +   else
> +   ASSERT_VOP_UNLOCKED(vp2, "vp2");
> +   } else {
> +   vp2_locked = true;
> +   }
> +   if (!vp1_locked && !vp2_locked) {
> +   vn_lock(vp1, LK_EXCLUSIVE | LK_RETRY);
> +   vp1_locked = true;
> +   }
> +
> +   for (;;) {
> +   if (vp1_locked && vp2_locked)
> +   break;
> +   if (vp1_locked && vp2 != NULL) {
> +   if (vp1 != NULL) {
> +   error = VOP_LOCK1(vp2, LK_EXCLUSIVE | 
> LK_NOWAIT,
> +   __FILE__, __LINE__);
> +   if (error == 0)
> +   break;
> +   VOP_UNLOCK(vp1);
> +   vp1_locked = false;
> +   vn_lock_pair_pause("vlp1");

(Pause called here and in similar elided case for vp2 -> vp1 below.)

> +   }
> +   vn_lock(vp2, LK_EXCLUSIVE | LK_RETRY);
> +   vp2_locked = true;
> +   }
___
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: r367641 - head/lib/libc/gen

2020-11-13 Thread Mateusz Piotrowski
Author: 0mp (doc,ports committer)
Date: Fri Nov 13 14:56:34 2020
New Revision: 367641
URL: https://svnweb.freebsd.org/changeset/base/367641

Log:
  Add a missing Nm macro
  
  All functions documented in a manual page should be enumerated
  with the Nm macros.

Modified:
  head/lib/libc/gen/setproctitle.3

Modified: head/lib/libc/gen/setproctitle.3
==
--- head/lib/libc/gen/setproctitle.3Fri Nov 13 14:48:37 2020
(r367640)
+++ head/lib/libc/gen/setproctitle.3Fri Nov 13 14:56:34 2020
(r367641)
@@ -25,6 +25,7 @@
 .Os
 .Sh NAME
 .Nm setproctitle
+.Nm setproctitle_fast
 .Nd set process title
 .Sh SYNOPSIS
 .In sys/types.h
___
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: r367640 - head/usr.bin/uname

2020-11-13 Thread Mateusz Piotrowski
Author: 0mp (doc,ports committer)
Date: Fri Nov 13 14:48:37 2020
New Revision: 367640
URL: https://svnweb.freebsd.org/changeset/base/367640

Log:
  Explicitly note in the EXAMPLES section that uname(3) contains more details
  
  MFC after:1 week

Modified:
  head/usr.bin/uname/uname.1

Modified: head/usr.bin/uname/uname.1
==
--- head/usr.bin/uname/uname.1  Fri Nov 13 13:47:18 2020(r367639)
+++ head/usr.bin/uname/uname.1  Fri Nov 13 14:48:37 2020(r367640)
@@ -28,7 +28,7 @@
 .\"@(#)uname.1 8.3 (Berkeley) 4/8/94
 .\" $FreeBSD$
 .\"
-.Dd August 10, 2020
+.Dd Novermber 13, 2020
 .Dt UNAME 1
 .Os
 .Sh NAME
@@ -119,6 +119,9 @@ utility (except for
 .Fl a )
 will allow the corresponding data to be set to the contents
 of the environment variable.
+See
+.Xr uname 3
+for more information.
 .Sh EXIT STATUS
 .Ex -std
 .Sh EXAMPLES
___
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: r367639 - head/lib/libc/gen

2020-11-13 Thread Mateusz Piotrowski
Author: 0mp (doc,ports committer)
Date: Fri Nov 13 13:47:18 2020
New Revision: 367639
URL: https://svnweb.freebsd.org/changeset/base/367639

Log:
  Reference setprogname(3) in setproctitle(3)
  
  The reference to setproctitle(3) in the setprogname(3) manual is already
  in place.
  
  MFC after:3 days

Modified:
  head/lib/libc/gen/setproctitle.3

Modified: head/lib/libc/gen/setproctitle.3
==
--- head/lib/libc/gen/setproctitle.3Fri Nov 13 13:38:08 2020
(r367638)
+++ head/lib/libc/gen/setproctitle.3Fri Nov 13 13:47:18 2020
(r367639)
@@ -20,7 +20,7 @@
 .\" $FreeBSD$
 .\"
 .\" The following requests are required for all man pages.
-.Dd July 4, 2018
+.Dd November 13, 2020
 .Dt SETPROCTITLE 3
 .Os
 .Sh NAME
@@ -69,6 +69,7 @@ setproctitle("talking to %s", inet_ntoa(addr));
 .Sh SEE ALSO
 .Xr ps 1 ,
 .Xr w 1 ,
+.Xr setprogname 3 ,
 .Xr kvm 3 ,
 .Xr kvm_getargv 3 ,
 .Xr printf 3
___
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: r367636 - head

2020-11-13 Thread Alex Richardson
Author: arichardson
Date: Fri Nov 13 13:18:48 2020
New Revision: 367636
URL: https://svnweb.freebsd.org/changeset/base/367636

Log:
  Makefile.inc1: remove no-longer required variable
  
  This variable is unsed since r364760 but I forgot to delete it in that commit.
  
  Reported By:  bdrewery

Modified:
  head/Makefile.inc1

Modified: head/Makefile.inc1
==
--- head/Makefile.inc1  Fri Nov 13 13:07:44 2020(r367635)
+++ head/Makefile.inc1  Fri Nov 13 13:18:48 2020(r367636)
@@ -2117,11 +2117,6 @@ update: .PHONY
 # which don't have the APIs required by the targets built in bootstrap-tools,
 # build-tools or cross-tools.
 #
-
-# libnv and libsbuf are requirements for config(8), which is an unconditional
-# bootstrap-tool.
-_config_deps= lib/libnv lib/libsbuf
-
 legacy: .PHONY
 .if ${BOOTSTRAPPING} < ${MINIMUM_SUPPORTED_OSREL} && ${BOOTSTRAPPING} != 0
@echo "ERROR: Source upgrades from versions prior to 
${MINIMUM_SUPPORTED_REL} are not supported."; \
___
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: r367635 - head/sys/netinet

2020-11-13 Thread George V. Neville-Neil
Author: gnn
Date: Fri Nov 13 13:07:44 2020
New Revision: 367635
URL: https://svnweb.freebsd.org/changeset/base/367635

Log:
  Followup pointed out by ae@

Modified:
  head/sys/netinet/ip_fastfwd.c

Modified: head/sys/netinet/ip_fastfwd.c
==
--- head/sys/netinet/ip_fastfwd.c   Fri Nov 13 09:49:22 2020
(r367634)
+++ head/sys/netinet/ip_fastfwd.c   Fri Nov 13 13:07:44 2020
(r367635)
@@ -118,7 +118,11 @@ ip_redir_alloc(struct mbuf *m, struct nhop_object *nh,
 struct ip *ip, in_addr_t *addr)
 {
struct mbuf *mcopy = m_gethdr(M_NOWAIT, m->m_type);
-   if (mcopy != NULL && !m_dup_pkthdr(mcopy, m, M_NOWAIT)) {
+
+   if (mcopy == NULL)
+   return (NULL);
+
+   if (m_dup_pkthdr(mcopy, m, M_NOWAIT) == 0) {
/*
 * It's probably ok if the pkthdr dup fails (because
 * the deep copy of the tag chain failed), but for now
___
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: r367631 - in head/sys: kern sys

2020-11-13 Thread Konstantin Belousov
On Fri, Nov 13, 2020 at 09:31:58AM +, Konstantin Belousov wrote:
> Author: kib
> Date: Fri Nov 13 09:31:57 2020
> New Revision: 367631
> URL: https://svnweb.freebsd.org/changeset/base/367631
> 
> Log:
>   Implement vn_lock_pair().
>   
>   In collaboration with:  pho
>   Reviewed by:mckusick (previous version), markj (previous version)
>   Tested by:  markj (syzkaller), pho
>   Sponsored by:   The FreeBSD Foundation
>   Differential revision:  https://reviews.freebsd.org/D26136
> 
> Modified:
>   head/sys/kern/vfs_vnops.c
>   head/sys/sys/vnode.h
> 
> Modified: head/sys/kern/vfs_vnops.c
> ==
> --- head/sys/kern/vfs_vnops.c Fri Nov 13 02:05:45 2020(r367630)
> +++ head/sys/kern/vfs_vnops.c Fri Nov 13 09:31:57 2020(r367631)
> @@ -275,6 +276,10 @@ restart:
>   vn_finished_write(mp);
>   if (error) {
>   NDFREE(ndp, NDF_ONLY_PNBUF);
> + if (error == ERELOOKUP) {
> + NDREINIT(ndp);
> + goto restart;
> + }
>   return (error);
>   }
>   fmode &= ~O_TRUNC;
> @@ -1524,6 +1529,7 @@ vn_truncate(struct file *fp, off_t length, struct ucre
>  
>   vp = fp->f_vnode;
>  
> +retry:
>   /*
>* Lock the whole range for truncation.  Otherwise split i/o
>* might happen partly before and partly after the truncation.
> @@ -1550,6 +1556,8 @@ out:
>   vn_finished_write(mp);
>  out1:
>   vn_rangelock_unlock(vp, rl_cookie);
> + if (error == ERELOOKUP)
> + goto retry;
>   return (error);
>  }
These chunks really belong to r367632 and not r367631, they leaked there
due to my mishandling of the split.  I am sorry for that, but I do not think
it is reasonable to revert and re-commit.
___
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: r367632 - head/sys/kern

2020-11-13 Thread Konstantin Belousov
Author: kib
Date: Fri Nov 13 09:42:32 2020
New Revision: 367632
URL: https://svnweb.freebsd.org/changeset/base/367632

Log:
  Allow some VOPs to return ERELOOKUP to indicate VFS operation restart at top 
level.
  
  Restart syscalls and some sync operations when filesystem indicated
  ERELOOKUP condition, mostly for VOPs operating on metdata.  In
  particular, lookup results cached in the inode/v_data is no longer
  valid and needs recalculating.  Right now this should be nop.
  
  Assert that ERELOOKUP is catched everywhere and not returned to
  userspace, by asserting that td_errno != ERELOOKUP on syscall return
  path.
  
  In collaboration with:pho
  Reviewed by:  mckusick (previous version), markj
  Tested by:markj (syzkaller), pho
  Sponsored by: The FreeBSD Foundation
  Differential revision:https://reviews.freebsd.org/D26136

Modified:
  head/sys/kern/subr_syscall.c
  head/sys/kern/uipc_usrreq.c
  head/sys/kern/vfs_subr.c
  head/sys/kern/vfs_syscalls.c

Modified: head/sys/kern/subr_syscall.c
==
--- head/sys/kern/subr_syscall.cFri Nov 13 09:31:57 2020
(r367631)
+++ head/sys/kern/subr_syscall.cFri Nov 13 09:42:32 2020
(r367632)
@@ -217,6 +217,8 @@ syscallret(struct thread *td)
 
KASSERT((td->td_pflags & TDP_FORKING) == 0,
("fork() did not clear TDP_FORKING upon completion"));
+   KASSERT(td->td_errno != ERELOOKUP,
+   ("ERELOOKUP not consumed syscall %d", td->td_sa.code));
 
p = td->td_proc;
sa = >td_sa;

Modified: head/sys/kern/uipc_usrreq.c
==
--- head/sys/kern/uipc_usrreq.c Fri Nov 13 09:31:57 2020(r367631)
+++ head/sys/kern/uipc_usrreq.c Fri Nov 13 09:42:32 2020(r367632)
@@ -671,6 +671,8 @@ restart:
vput(nd.ni_dvp);
if (error) {
vn_finished_write(mp);
+   if (error == ERELOOKUP)
+   goto restart;
goto error;
}
vp = nd.ni_vp;

Modified: head/sys/kern/vfs_subr.c
==
--- head/sys/kern/vfs_subr.cFri Nov 13 09:31:57 2020(r367631)
+++ head/sys/kern/vfs_subr.cFri Nov 13 09:42:32 2020(r367632)
@@ -1937,7 +1937,10 @@ bufobj_invalbuf(struct bufobj *bo, int flags, int slpf
}
if (bo->bo_dirty.bv_cnt > 0) {
BO_UNLOCK(bo);
-   if ((error = BO_SYNC(bo, MNT_WAIT)) != 0)
+   do {
+   error = BO_SYNC(bo, MNT_WAIT);
+   } while (error == ERELOOKUP);
+   if (error != 0)
return (error);
/*
 * XXX We could save a lock/unlock if this was only
@@ -3678,7 +3681,9 @@ loop:
vm_object_page_clean(vp->v_object, 0, 0, 0);
VM_OBJECT_WUNLOCK(vp->v_object);
}
-   error = VOP_FSYNC(vp, MNT_WAIT, td);
+   do {
+   error = VOP_FSYNC(vp, MNT_WAIT, td);
+   } while (error == ERELOOKUP);
if (error != 0) {
VOP_UNLOCK(vp);
vdrop(vp);

Modified: head/sys/kern/vfs_syscalls.c
==
--- head/sys/kern/vfs_syscalls.cFri Nov 13 09:31:57 2020
(r367631)
+++ head/sys/kern/vfs_syscalls.cFri Nov 13 09:42:32 2020
(r367632)
@@ -1384,6 +1384,8 @@ restart:
NDFREE(, NDF_ONLY_PNBUF);
vput(nd.ni_dvp);
vn_finished_write(mp);
+   if (error == ERELOOKUP)
+   goto restart;
return (error);
 }
 
@@ -1470,6 +1472,8 @@ out:
vput(nd.ni_dvp);
vn_finished_write(mp);
NDFREE(, NDF_ONLY_PNBUF);
+   if (error == ERELOOKUP)
+   goto restart;
return (error);
 }
 
@@ -1568,7 +1572,7 @@ kern_linkat(struct thread *td, int fd1, int fd2, const
return (error);
NDFREE(, NDF_ONLY_PNBUF);
error = kern_linkat_vp(td, nd.ni_vp, fd2, path2, segflag);
-   } while (error ==  EAGAIN);
+   } while (error ==  EAGAIN || error == ERELOOKUP);
return (error);
 }
 
@@ -1741,6 +1745,8 @@ out2:
NDFREE(, NDF_ONLY_PNBUF);
vput(nd.ni_dvp);
vn_finished_write(mp);
+   if (error == ERELOOKUP)
+   goto restart;
 out:
if (segflg != UIO_SYSSPACE)
uma_zfree(namei_zone, tmppath);
@@ -1791,6 +1797,8 @@ restart:
NDFREE(, NDF_ONLY_PNBUF);
vput(nd.ni_dvp);
vn_finished_write(mp);
+   if (error == 

svn commit: r367631 - in head/sys: kern sys

2020-11-13 Thread Konstantin Belousov
Author: kib
Date: Fri Nov 13 09:31:57 2020
New Revision: 367631
URL: https://svnweb.freebsd.org/changeset/base/367631

Log:
  Implement vn_lock_pair().
  
  In collaboration with:pho
  Reviewed by:  mckusick (previous version), markj (previous version)
  Tested by:markj (syzkaller), pho
  Sponsored by: The FreeBSD Foundation
  Differential revision:https://reviews.freebsd.org/D26136

Modified:
  head/sys/kern/vfs_vnops.c
  head/sys/sys/vnode.h

Modified: head/sys/kern/vfs_vnops.c
==
--- head/sys/kern/vfs_vnops.c   Fri Nov 13 02:05:45 2020(r367630)
+++ head/sys/kern/vfs_vnops.c   Fri Nov 13 09:31:57 2020(r367631)
@@ -70,6 +70,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -275,6 +276,10 @@ restart:
vn_finished_write(mp);
if (error) {
NDFREE(ndp, NDF_ONLY_PNBUF);
+   if (error == ERELOOKUP) {
+   NDREINIT(ndp);
+   goto restart;
+   }
return (error);
}
fmode &= ~O_TRUNC;
@@ -1524,6 +1529,7 @@ vn_truncate(struct file *fp, off_t length, struct ucre
 
vp = fp->f_vnode;
 
+retry:
/*
 * Lock the whole range for truncation.  Otherwise split i/o
 * might happen partly before and partly after the truncation.
@@ -1550,6 +1556,8 @@ out:
vn_finished_write(mp);
 out1:
vn_rangelock_unlock(vp, rl_cookie);
+   if (error == ERELOOKUP)
+   goto retry;
return (error);
 }
 
@@ -3317,4 +3325,92 @@ vn_fallocate(struct file *fp, off_t offset, off_t len,
}
 
return (error);
+}
+
+static u_long vn_lock_pair_pause_cnt;
+SYSCTL_ULONG(_debug, OID_AUTO, vn_lock_pair_pause, CTLFLAG_RD,
+_lock_pair_pause_cnt, 0,
+"Count of vn_lock_pair deadlocks");
+
+static void
+vn_lock_pair_pause(const char *wmesg)
+{
+   atomic_add_long(_lock_pair_pause_cnt, 1);
+   pause(wmesg, prng32_bounded(hz / 10));
+}
+
+/*
+ * Lock pair of vnodes vp1, vp2, avoiding lock order reversal.
+ * vp1_locked indicates whether vp1 is exclusively locked; if not, vp1
+ * must be unlocked.  Same for vp2 and vp2_locked.  One of the vnodes
+ * can be NULL.
+ *
+ * The function returns with both vnodes exclusively locked, and
+ * guarantees that it does not create lock order reversal with other
+ * threads during its execution.  Both vnodes could be unlocked
+ * temporary (and reclaimed).
+ */
+void
+vn_lock_pair(struct vnode *vp1, bool vp1_locked, struct vnode *vp2,
+bool vp2_locked)
+{
+   int error;
+
+   if (vp1 == NULL && vp2 == NULL)
+   return;
+   if (vp1 != NULL) {
+   if (vp1_locked)
+   ASSERT_VOP_ELOCKED(vp1, "vp1");
+   else
+   ASSERT_VOP_UNLOCKED(vp1, "vp1");
+   } else {
+   vp1_locked = true;
+   }
+   if (vp2 != NULL) {
+   if (vp2_locked)
+   ASSERT_VOP_ELOCKED(vp2, "vp2");
+   else
+   ASSERT_VOP_UNLOCKED(vp2, "vp2");
+   } else {
+   vp2_locked = true;
+   }
+   if (!vp1_locked && !vp2_locked) {
+   vn_lock(vp1, LK_EXCLUSIVE | LK_RETRY);
+   vp1_locked = true;
+   }
+
+   for (;;) {
+   if (vp1_locked && vp2_locked)
+   break;
+   if (vp1_locked && vp2 != NULL) {
+   if (vp1 != NULL) {
+   error = VOP_LOCK1(vp2, LK_EXCLUSIVE | LK_NOWAIT,
+   __FILE__, __LINE__);
+   if (error == 0)
+   break;
+   VOP_UNLOCK(vp1);
+   vp1_locked = false;
+   vn_lock_pair_pause("vlp1");
+   }
+   vn_lock(vp2, LK_EXCLUSIVE | LK_RETRY);
+   vp2_locked = true;
+   }
+   if (vp2_locked && vp1 != NULL) {
+   if (vp2 != NULL) {
+   error = VOP_LOCK1(vp1, LK_EXCLUSIVE | LK_NOWAIT,
+   __FILE__, __LINE__);
+   if (error == 0)
+   break;
+   VOP_UNLOCK(vp2);
+   vp2_locked = false;
+   vn_lock_pair_pause("vlp2");
+   }
+   vn_lock(vp1, LK_EXCLUSIVE | LK_RETRY);
+   vp1_locked = true;
+   }
+   }
+   if (vp1 != NULL)
+