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,
+&vn_lock_pair_pause_cnt, 0,
+"Count of vn_lock_pair deadlocks");
+
+static void
+vn_lock_pair_pause(const char *wmesg)
+{
+   atomic_add_long(&vn_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_

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->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(&nd, 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(&nd, 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(&nd, 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(&nd, 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(&nd, NDF_ONLY_PNBUF);
vput(nd.ni_dvp);
vn_finished_write(mp);
+   

svn commit: r367633 - stable/12/sbin/reboot

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

Log:
  MFC r367567:
  
  Address a mandoc warning

Modified:
  stable/12/sbin/reboot/boot_i386.8
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sbin/reboot/boot_i386.8
==
--- stable/12/sbin/reboot/boot_i386.8   Fri Nov 13 09:42:32 2020
(r367632)
+++ stable/12/sbin/reboot/boot_i386.8   Fri Nov 13 09:48:54 2020
(r367633)
@@ -107,7 +107,7 @@ from partition
 of either the floppy or the hard disk.
 This boot may be aborted by typing any character on the keyboard
 at the
-.Ql boot:
+.Ql boot\&:
 prompt.
 At this time, the following input will be accepted:
 .Bl -tag -width indent
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r367634 - stable/11/sbin/reboot

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

Log:
  MFC r367567:
  
  Address a mandoc warning

Modified:
  stable/11/sbin/reboot/boot_i386.8
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sbin/reboot/boot_i386.8
==
--- stable/11/sbin/reboot/boot_i386.8   Fri Nov 13 09:48:54 2020
(r367633)
+++ stable/11/sbin/reboot/boot_i386.8   Fri Nov 13 09:49:22 2020
(r367634)
@@ -107,7 +107,7 @@ from partition
 of either the floppy or the hard disk.
 This boot may be aborted by typing any character on the keyboard
 at the
-.Ql boot:
+.Ql boot\&:
 prompt.
 At this time, the following input will be accepted:
 .Bl -tag -width indent
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-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-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-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-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-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-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r367637 - stable/12/sys/kern

2020-11-13 Thread Mateusz Guzik
Author: mjg
Date: Fri Nov 13 13:36:46 2020
New Revision: 367637
URL: https://svnweb.freebsd.org/changeset/base/367637

Log:
  MFC r367352,r367353:
  
  pipe: fix POLLHUP handling if no events were specified
  pipe: whitespace nit in previous

Modified:
  stable/12/sys/kern/sys_pipe.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/kern/sys_pipe.c
==
--- stable/12/sys/kern/sys_pipe.c   Fri Nov 13 13:18:48 2020
(r367636)
+++ stable/12/sys/kern/sys_pipe.c   Fri Nov 13 13:36:46 2020
(r367637)
@@ -1446,13 +1446,17 @@ pipe_poll(struct file *fp, int events, struct ucred *a
}
 
if (revents == 0) {
-   if (fp->f_flag & FREAD && events & (POLLIN | POLLRDNORM)) {
+   /*
+* Add ourselves regardless of eventmask as we have to return
+* POLLHUP even if it was not asked for.
+*/
+   if ((fp->f_flag & FREAD) != 0) {
selrecord(td, &rpipe->pipe_sel);
if (SEL_WAITING(&rpipe->pipe_sel))
rpipe->pipe_state |= PIPE_SEL;
}
 
-   if (fp->f_flag & FWRITE && events & (POLLOUT | POLLWRNORM)) {
+   if ((fp->f_flag & FWRITE) != 0) {
selrecord(td, &wpipe->pipe_sel);
if (SEL_WAITING(&wpipe->pipe_sel))
wpipe->pipe_state |= PIPE_SEL;
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r367638 - stable/12/sys/kern

2020-11-13 Thread Mateusz Guzik
Author: mjg
Date: Fri Nov 13 13:38:08 2020
New Revision: 367638
URL: https://svnweb.freebsd.org/changeset/base/367638

Log:
  MFC r367572:
  
  Allow rtprio_thread to operate on threads of any process

Modified:
  stable/12/sys/kern/kern_resource.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/kern/kern_resource.c
==
--- stable/12/sys/kern/kern_resource.c  Fri Nov 13 13:36:46 2020
(r367637)
+++ stable/12/sys/kern/kern_resource.c  Fri Nov 13 13:38:08 2020
(r367638)
@@ -303,8 +303,7 @@ sys_rtprio_thread(struct thread *td, struct rtprio_thr
td1 = td;
PROC_LOCK(p);
} else {
-   /* Only look up thread in current process */
-   td1 = tdfind(uap->lwpid, curproc->p_pid);
+   td1 = tdfind(uap->lwpid, -1);
if (td1 == NULL)
return (ESRCH);
p = td1->td_proc;
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-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-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-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-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-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-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


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(&vn_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-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r367359 - stable/12/sys/dev/pci

2020-11-13 Thread martin

 I am encountering a problem with hw.pci.enable_aspm:

System: ASUS RS500A-E10-RS12U
CPU: AMD EPYC 7502 32-Core.
NVMe drive model: Micron 9300 PRO
Number of NVMe drives: 10

 Using X2APIC

When hw.pci.enable_aspm is enabled, PCIe hot plug of Micron NVMe  
drives does not work (including detection on boot) and the system  
reports the following errors for the vast majority of the drives:


 Nov 13 15:11:30 xxx kernel: pcib9: Timed out waiting for Data Link  
Layer Active
Nov 13 15:12:17 xxx kernel: pcib30: Timed out waiting for Data Link  
Layer Active
Nov 13 15:12:44 xxx kernel: pcib29: Timed out waiting for Data Link  
Layer Active
Nov 13 15:13:04 xxx kernel: pcib11: Timed out waiting for Data Link  
Layer Active

...

Flipping the tunable back to 0 workarounds the problem.

Reproduced both on latest head and stable/12.

Best regards,
mm

Quoting Alexander Motin :


Author: mav
Date: Thu Nov  5 02:57:40 2020
New Revision: 367359
URL: https://svnweb.freebsd.org/changeset/base/367359

Log:
MFC r364038: Enable hw.pci.enable_aspm tunable by default.

While effects on power saving is only a guess, effects on hot-plug are
clearly visible.  Lets try to enable it and see what happen.

Modified:
stable/12/sys/dev/pci/pci.c
Directory Properties:
stable/12/   (props changed)

Modified: stable/12/sys/dev/pci/pci.c
==
--- stable/12/sys/dev/pci/pci.c        Thu Nov  5 02:12:33 2020       
  (r367358)
+++ stable/12/sys/dev/pci/pci.c        Thu Nov  5 02:57:40 2020       
  (r367359)

@@ -411,7 +411,7 @@ static int pci_enable_ari = 1;
SYSCTL_INT(_hw_pci, OID_AUTO, enable_ari, CTLFLAG_RDTUN, &pci_enable_ari,
    0, "Enable support for PCIe Alternative RID Interpretation");

-int pci_enable_aspm;
+int pci_enable_aspm = 1;
SYSCTL_INT(_hw_pci, OID_AUTO, enable_aspm, CTLFLAG_RDTUN,  
&pci_enable_aspm,    0, "Enable support for PCIe Active State Power  
Management");

___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-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(&iov, &iovlen);
-   build_iovec_argf(&iov, &iovlen, "fstype", "%s",
-   fstype);
-   build_iovec_argf(&iov, &iovlen, "fspath", "%s",
-   mntpath);
-   build_iovec_argf(&iov, &iovlen, "from", "%s",
-   *argv);
-   build_iovec(&iov, &iovlen, "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);
-   

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-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-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 (&pte[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 (&l3e[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 (&l2e[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 ((p

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,
 &VNET_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-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-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,
> +&vn_lock_pair_pause_cnt, 0,
> +"Count of vn_lock_pair deadlocks");
> +
> +static void
> +vn_lock_pair_pause(const char *wmesg)
> +{
> + atomic_add_long(&vn_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-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-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-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-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-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-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-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-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-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-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(&vn_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-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-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,
> > +&vn_lock_pair_pause_cnt, 0,
> > +"Count of vn_lock_pair deadlocks");
> > +
> > +static void
> > +vn_lock_pair_pause(const char *wmesg)
> > +{
> > +   atomic_add_long(&vn_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-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-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-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-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(&sbuf, NULL, 128, req);
-   sbuf_printf(&sbuf, 
-   "\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(&sbuf, "%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(&sbuf,
-   "\nTotal memory used:\t%30llu\nTotal Memory wasted:\t%30llu\n",
-   (unsigned long long)mem, (unsigned long long)waste);
-   error = sbuf_finish(&sbuf);
-   sbuf_delete(&sbuf);
-   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-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-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-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


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-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-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: 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-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r367653 - vendor-sys/acpica/20201113

2020-11-13 Thread Jung-uk Kim
Author: jkim
Date: Fri Nov 13 21:41:47 2020
New Revision: 367653
URL: https://svnweb.freebsd.org/changeset/base/367653

Log:
  Tag ACPICA 20201113.

Added:
  vendor-sys/acpica/20201113/
 - copied from r367652, vendor-sys/acpica/dist/
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r367652 - in vendor-sys/acpica/dist: . generate/lint generate/unix/acpihelp source/common source/compiler source/components/events source/components/namespace source/include source/tool...

2020-11-13 Thread Jung-uk Kim
Author: jkim
Date: Fri Nov 13 21:41:15 2020
New Revision: 367652
URL: https://svnweb.freebsd.org/changeset/base/367652

Log:
  Import ACPICA 20201113.

Modified:
  vendor-sys/acpica/dist/changes.txt
  vendor-sys/acpica/dist/generate/lint/std32.lnt
  vendor-sys/acpica/dist/generate/lint/std64.lnt
  vendor-sys/acpica/dist/generate/unix/acpihelp/Makefile
  vendor-sys/acpica/dist/source/common/ahuuids.c
  vendor-sys/acpica/dist/source/compiler/aslbtypes.c
  vendor-sys/acpica/dist/source/compiler/aslcodegen.c
  vendor-sys/acpica/dist/source/compiler/aslmap.c
  vendor-sys/acpica/dist/source/compiler/aslmessages.c
  vendor-sys/acpica/dist/source/compiler/aslmessages.h
  vendor-sys/acpica/dist/source/compiler/aslnamesp.c
  vendor-sys/acpica/dist/source/compiler/aslopcodes.c
  vendor-sys/acpica/dist/source/compiler/aslprimaries.y
  vendor-sys/acpica/dist/source/compiler/aslrules.y
  vendor-sys/acpica/dist/source/compiler/asltypes.y
  vendor-sys/acpica/dist/source/components/events/evregion.c
  vendor-sys/acpica/dist/source/components/namespace/nspredef.c
  vendor-sys/acpica/dist/source/components/namespace/nsprepkg.c
  vendor-sys/acpica/dist/source/components/namespace/nsrepair2.c
  vendor-sys/acpica/dist/source/include/accommon.h
  vendor-sys/acpica/dist/source/include/acpixf.h
  vendor-sys/acpica/dist/source/include/acuuid.h
  vendor-sys/acpica/dist/source/tools/acpihelp/acpihelp.h
  vendor-sys/acpica/dist/source/tools/acpihelp/ahdecode.c
  vendor-sys/acpica/dist/source/tools/acpihelp/ahmain.c

Modified: vendor-sys/acpica/dist/changes.txt
==
--- vendor-sys/acpica/dist/changes.txt  Fri Nov 13 19:47:16 2020
(r367651)
+++ vendor-sys/acpica/dist/changes.txt  Fri Nov 13 21:41:15 2020
(r367652)
@@ -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 a

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 full 
+p

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-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-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-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-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-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-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-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r367656 - stable/12/usr.bin/diff

2020-11-13 Thread Kyle Evans
Author: kevans
Date: Sat Nov 14 00:59:55 2020
New Revision: 367656
URL: https://svnweb.freebsd.org/changeset/base/367656

Log:
  MFC r367076: diff: don't force the format to 'context' with -p immediately
  
  Instead, leave the fomat as unspecified (if it hasn't been) and use the
  -p flag as a hint to 'context' if no other formatting option is specified.
  
  This fixes `diff -purw`, used frequently by emaste, and matches the behavior
  of its GNU counterpart.
  
  PR:   250015

Modified:
  stable/12/usr.bin/diff/diff.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/usr.bin/diff/diff.c
==
--- stable/12/usr.bin/diff/diff.c   Fri Nov 13 23:18:04 2020
(r367655)
+++ stable/12/usr.bin/diff/diff.c   Sat Nov 14 00:59:55 2020
(r367656)
@@ -210,17 +210,6 @@ main(int argc, char **argv)
diff_format = D_NREVERSE;
break;
case 'p':
-   /*
-* If it's not unset and it's not set to context or
-* unified, we'll error out here as a conflicting
-* format.  If it's unset, we'll go ahead and set it to
-* context.
-*/
-   if (FORMAT_MISMATCHED(D_CONTEXT) &&
-   FORMAT_MISMATCHED(D_UNIFIED))
-   conflicting_format();
-   if (diff_format == D_UNSET)
-   diff_format = D_CONTEXT;
dflags |= D_PROTOTYPE;
break;
case 'P':
@@ -320,6 +309,8 @@ main(int argc, char **argv)
newarg = optind != prevoptind;
prevoptind = optind;
}
+   if (diff_format == D_UNSET && (dflags & D_PROTOTYPE) != 0)
+   diff_format = D_CONTEXT;
if (diff_format == D_UNSET)
diff_format = D_NORMAL;
argc -= optind;
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r367657 - in stable/12: sys/kern sys/sys usr.sbin/binmiscctl

2020-11-13 Thread Kyle Evans
Author: kevans
Date: Sat Nov 14 01:28:04 2020
New Revision: 367657
URL: https://svnweb.freebsd.org/changeset/base/367657

Log:
  MFC imgact_binmisc housecleaning: r367361, r367439, r367441-r367442,
  r367444, r367452, r367456, r367477
  
  r367361:
  imgact_binmisc: fix up some minor nits
  
  - Removed a bunch of redundant headers
  - Don't explicitly initialize to 0
  - The !error check prior to setting imgp->interpreter_name is redundant, all
error paths should and do return or go to 'done'. We have larger problems
otherwise.
  
  r367439:
  imgact_binmisc: minor re-organization of imgact_binmisc_exec exits
  
  Notably, streamline error paths through the existing 'done' label, making it
  easier to quickly verify correct cleanup.
  
  Future work might add a kernel-only flag to indicate that a interpreter uses
  #a. Currently, all executions via imgact_binmisc pay the penalty of
  constructing sname/fname, even if they will not use it. qemu-user-static
  doesn't need it, the stock rc script for qemu-user-static certainly doesn't
  use it, and I suspect these are the vast majority of (if not the only)
  current users.
  
  r367441:
  binmiscctl(8): miscellaneous cleanup
  
  - Bad whitespace in Makefile.
  - Reordered headers, sys/ first.
  - Annotated fatal/usage __dead2 to help `make analyze` out a little bit.
  - Spell a couple of sizeof constructs as "nitems" and "howmany" instead.
  
  r367442:
  imgact_binmisc: validate flags coming from userland
  
  We may want to reserve bits in the future for kernel-only use, so start
  rejecting any that aren't the two that we're currently expecting from
  userland.
  
  r367444:
  imgact_binmisc: abstract away the list lock (NFC)
  
  This module handles relatively few execs (initial qemu-user-static, then
  qemu-user-static handles exec'ing itself for binaries it's already running),
  but all execs pay the price of at least taking the relatively expensive
  sx/slock to check for a match when this module is loaded. Future work will
  almost certainly swap this out for another lock, perhaps an rmslock.
  
  The RLOCK/WLOCK phrasing was chosen based on what the callers are really
  wanting, rather than using the verbiage typically appropriate for an sx.
  
  r367452:
  imgact_binmisc: reorder members of struct imgact_binmisc_entry (NFC)
  
  This doesn't change anything at the moment since the out-of-order elements
  were a pair of uint32_t, but future additions may have caused unnecessary
  padding by following the existing precedent.
  
  r367456:
  imgact_binmisc: move some calculations out of the exec path
  
  The offset we need to account for in the interpreter string comes in two
  variants:
  
  1. Fixed - macros other than #a that will not vary from invocation to
 invocation
  2. Variable - #a, which is substitued with the argv0 that we're replacing
  
  Note that we don't have a mechanism to modify an existing entry.  By
  recording both of these offset requirements when the interpreter is added,
  we can avoid some unnecessary calculations in the exec path.
  
  Most importantly, we can know up-front whether we need to grab
  calculate/grab the the filename for this interpreter. We also get to avoid
  walking the string a first time looking for macros. For most invocations,
  it's a swift exit as they won't have any, but there's no point entering a
  loop and searching for the macro indicator if we already know there will not
  be one.
  
  While we're here, go ahead and only calculate the argv0 name length once per
  invocation. While it's unlikely that we'll have more than one #a, there's no
  reason to recalculate it every time we encounter an #a when it will not
  change.
  
  I have not bothered trying to benchmark this at all, because it's arguably a
  minor and straightforward/obvious improvement.
  
  r367477:
  imgact_binmisc: limit the extent of match on incoming entries
  
  imgact_binmisc matches magic/mask from imgp->image_header, which is only a
  single page in size mapped from the first page of an image. One can specify
  an interpreter that matches on, e.g., --offset 4096 --size 256 to read up to
  256 bytes past the mapped first page.
  
  The limitation is that we cannot specify a magic string that exceeds a
  single page, and we can't allow offset + size to exceed a single page
  either.  A static assert has been added in case someone finds it useful to
  try and expand the size, but it does seem a little unlikely.
  
  While this looks kind of exploitable at a sideways squinty-glance, there are
  a couple of mitigating factors:
  
  1.) imgact_binmisc is not enabled by default,
  2.) entries may only be added by the superuser,
  3.) trying to exploit this information to read what's mapped past the end
would be worse than a root canal or some other relatably painful
experience, and
  4.) there's no way one could pull this off without it being completely
obvious.
  
  The first page is mapped out of an sf_b

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-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-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-src-all@free

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-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-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-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r367662 - stable/12/sys/kern

2020-11-13 Thread Kyle Evans
Author: kevans
Date: Sat Nov 14 01:55:54 2020
New Revision: 367662
URL: https://svnweb.freebsd.org/changeset/base/367662

Log:
  MFC r367440: epoch: support non-preemptible epochs checking in_epoch()
  
  Previously, non-preemptible epochs could not check; in_epoch() would always
  fail, usually because non-preemptible epochs don't imply THREAD_NO_SLEEPING.
  
  For default epochs, it's easy enough to verify that we're in the given
  epoch: if we're in a critical section and our record for the given epoch
  is active, then we're in it.
  
  This patch also adds some additional INVARIANTS bookkeeping. Notably, we set
  and check the recorded thread in epoch_enter/epoch_exit to try and catch
  some edge-cases for the caller. It also checks upon freeing that none of the
  records had a thread in the epoch, which may make it a little easier to
  diagnose some improper use if epoch_free() took place while some other
  thread was inside.
  
  This version differs slightly from what was just previously reviewed by the
  below-listed, in that in_epoch() will assert that no CPU has this thread
  recorded even if it *is* currently in a critical section. This is intended
  to catch cases where the caller might have somehow messed up critical
  section nesting, we can catch both if they exited the critical section or if
  they exited, migrated, then re-entered (on the wrong CPU).

Modified:
  stable/12/sys/kern/subr_epoch.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/kern/subr_epoch.c
==
--- stable/12/sys/kern/subr_epoch.c Sat Nov 14 01:55:02 2020
(r367661)
+++ stable/12/sys/kern/subr_epoch.c Sat Nov 14 01:55:54 2020
(r367662)
@@ -69,6 +69,10 @@ typedef struct epoch_record {
/* fields above are part of KBI and cannot be modified */
struct epoch_context er_drain_ctx;
struct epoch *er_parent;
+#ifdef INVARIANTS
+   /* Used to verify record ownership for non-preemptible epochs. */
+   struct thread *er_td;
+#endif
 } __aligned(EPOCH_ALIGN) *epoch_record_t;
 
 struct epoch {
@@ -251,6 +255,9 @@ done:
 void
 epoch_free(epoch_t epoch)
 {
+#ifdef INVARIANTS
+   int cpu;
+#endif
 
EPOCH_LOCK();
 
@@ -264,6 +271,21 @@ epoch_free(epoch_t epoch)
 * to zero, by calling epoch_wait() on the global_epoch:
 */
epoch_wait(global_epoch);
+#ifdef INVARIANTS
+   CPU_FOREACH(cpu) {
+   epoch_record_t er;
+
+   er = zpcpu_get_cpu(epoch->e_pcpu_record, cpu);
+
+   /*
+* Sanity check: none of the records should be in use anymore.
+* We drained callbacks above and freeing the pcpu records is
+* imminent.
+*/
+   MPASS(er->er_td == NULL);
+   MPASS(TAILQ_EMPTY(&er->er_tdlist));
+   }
+#endif
uma_zfree_pcpu(pcpu_zone_record, epoch->e_pcpu_record);
mtx_destroy(&epoch->e_drain_mtx);
sx_destroy(&epoch->e_drain_sx);
@@ -306,6 +328,8 @@ epoch_enter_preempt(epoch_t epoch, epoch_tracker_t et)
 
td->td_pre_epoch_prio = td->td_priority;
er = epoch_currecord(epoch);
+   /* Record-level tracking is reserved for non-preemptible epochs. */
+   MPASS(er->er_td == NULL);
TAILQ_INSERT_TAIL(&er->er_tdlist, et, et_link);
ck_epoch_begin(&er->er_record, &et->et_section);
critical_exit();
@@ -324,6 +348,15 @@ epoch_enter(epoch_t epoch)
td->td_epochnest++;
critical_enter();
er = epoch_currecord(epoch);
+#ifdef INVARIANTS
+   if (er->er_record.active == 0) {
+   MPASS(er->er_td == NULL);
+   er->er_td = curthread;
+   } else {
+   /* We've recursed, just make sure our accounting isn't wrong. */
+   MPASS(er->er_td == curthread);
+   }
+#endif
ck_epoch_begin(&er->er_record, NULL);
 }
 
@@ -351,6 +384,8 @@ epoch_exit_preempt(epoch_t epoch, epoch_tracker_t et)
 #endif
 #ifdef INVARIANTS
et->et_td = (void*)0xDEADBEEF;
+   /* Record-level tracking is reserved for non-preemptible epochs. */
+   MPASS(er->er_td == NULL);
 #endif
ck_epoch_end(&er->er_record, &et->et_section);
TAILQ_REMOVE(&er->er_tdlist, et, et_link);
@@ -372,6 +407,11 @@ epoch_exit(epoch_t epoch)
td->td_epochnest--;
er = epoch_currecord(epoch);
ck_epoch_end(&er->er_record, NULL);
+#ifdef INVARIANTS
+   MPASS(er->er_td == curthread);
+   if (er->er_record.active == 0)
+   er->er_td = NULL;
+#endif
critical_exit();
 }
 
@@ -662,18 +702,18 @@ epoch_call_task(void *arg __unused)
}
 }
 
-int
-in_epoch_verbose(epoch_t epoch, int dump_onfail)
+static int
+in_epoch_verbose_preempt(epoch_t epoch, int dump_onfail)
 {
+   epoch_record_t er;
struct epoch_tracker *tdwait;
struct thread *td;
-   epoch_record_t er;

svn commit: r367663 - stable/12/sys/dev/vt

2020-11-13 Thread Kyle Evans
Author: kevans
Date: Sat Nov 14 01:58:33 2020
New Revision: 367663
URL: https://svnweb.freebsd.org/changeset/base/367663

Log:
  MFC r367448: vt: resolve conflict between VT_ALT_TO_ESC_HACK and DBG
  
  When using the ALT+CTRL+ESC sequence to break into kdb, the keyboard is
  completely borked when you return. watch(8) shows that it's working, but
  it's inserting escape sequences.
  
  Further investigation revealed that VT_ALT_TO_ESC_HACK is the default and
  directly conflicts with this sequence, so upon return from the debugger
  ALKED is set.
  
  If they triggered the break to debugger, it's safe to assume they didn't
  mean to use VT_ALT_TO_ESC_HACK, so just unset it to reduce the surprise when
  the keyboard seems non-functional upon return.

Modified:
  stable/12/sys/dev/vt/vt_core.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/dev/vt/vt_core.c
==
--- stable/12/sys/dev/vt/vt_core.c  Sat Nov 14 01:55:54 2020
(r367662)
+++ stable/12/sys/dev/vt/vt_core.c  Sat Nov 14 01:58:33 2020
(r367663)
@@ -725,13 +725,22 @@ vt_scroll(struct vt_window *vw, int offset, int whence
 }
 
 static int
-vt_machine_kbdevent(int c)
+vt_machine_kbdevent(struct vt_device *vd, int c)
 {
 
switch (c) {
case SPCLKEY | DBG: /* kbdmap(5) keyword `debug`. */
-   if (vt_kbd_debug)
+   if (vt_kbd_debug) {
kdb_enter(KDB_WHY_BREAK, "manual escape to debugger");
+#if VT_ALT_TO_ESC_HACK
+   /*
+* There's an unfortunate conflict between SPCLKEY|DBG
+* and VT_ALT_TO_ESC_HACK.  Just assume they didn't mean
+* it if we got to here.
+*/
+   vd->vd_kbstate &= ~ALKED;
+#endif
+   }
return (1);
case SPCLKEY | HALT: /* kbdmap(5) keyword `halt`. */
if (vt_kbd_halt)
@@ -864,7 +873,7 @@ vt_processkey(keyboard_t *kbd, struct vt_device *vd, i
return (0);
 #endif
 
-   if (vt_machine_kbdevent(c))
+   if (vt_machine_kbdevent(vd, c))
return (0);
 
if (vw->vw_flags & VWF_SCROLL) {
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r367664 - stable/12/usr.sbin/ngctl

2020-11-13 Thread Kyle Evans
Author: kevans
Date: Sat Nov 14 02:00:50 2020
New Revision: 367664
URL: https://svnweb.freebsd.org/changeset/base/367664

Log:
  MFC r366430: ngctl: add -c (compact output) for the dot command
  
  The output of "ngctl dot" is suitable for small netgraph networks. Even
  moderate complex netgraph setups (about a dozen nodes) are hard to
  understand from the .dot output, because each node and each hook are shown
  as a full blown structure.
  
  This patch allows to generate much more compact output and graphs by
  omitting the extra structures for the individual hooks. Instead the names of
  the hooks are labels to the edges.

Modified:
  stable/12/usr.sbin/ngctl/dot.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/usr.sbin/ngctl/dot.c
==
--- stable/12/usr.sbin/ngctl/dot.c  Sat Nov 14 01:58:33 2020
(r367663)
+++ stable/12/usr.sbin/ngctl/dot.c  Sat Nov 14 02:00:50 2020
(r367664)
@@ -2,6 +2,7 @@
 /*
  * dot.c
  *
+ * Copyright (c) 2019 Lutz Donnerhacke
  * Copyright (c) 2004 Brian Fundakowski Feldman
  * Copyright (c) 1996-1999 Whistle Communications, Inc.
  * All rights reserved.
@@ -53,9 +54,11 @@ static int DotCmd(int ac, char **av);
 
 const struct ngcmd dot_cmd = {
DotCmd,
-   "dot [outputfile]",
+   "dot [-c] [outputfile]",
"Produce a GraphViz (.dot) of the entire netgraph.",
-   "If no outputfile is specified, stdout will be assumed.",
+   "If no outputfile is specified, stdout will be assumed."
+   " The optional -c argument generates a graph without separate"
+   " structures for edge names. Such a graph is more compact.",
{ "graphviz", "confdot" }
 };
 
@@ -66,12 +69,16 @@ DotCmd(int ac, char **av)
struct namelist *nlist;
FILE *f = stdout;
int ch;
+   int compact = 0;
u_int i;
 
/* Get options */
optind = 1;
-   while ((ch = getopt(ac, av, "")) != -1) {
+   while ((ch = getopt(ac, av, "c")) != -1) {
switch (ch) {
+   case 'c':
+   compact = 1;
+   break;
case '?':
default:
return (CMDRTN_USAGE);
@@ -109,9 +116,14 @@ DotCmd(int ac, char **av)
}
 
nlist = (struct namelist *)nlresp->data;
-   fprintf(f, "graph netgraph {\n");
-   /* TODO: implement rank = same or subgraphs at some point */
-   fprintf(f, "\tedge [ weight = 1.0 ];\n");
+   if (compact) {
+   fprintf(f, "digraph netgraph {\n");
+   fprintf(f, "\tedge [ dir = \"none\", fontsize = 10 ];\n");
+   } else {
+   fprintf(f, "graph netgraph {\n");
+   /* TODO: implement rank = same or subgraphs at some point */
+   fprintf(f, "\tedge [ weight = 1.0 ];\n");
+   }
fprintf(f, "\tnode [ shape = record, fontsize = 12 ] {\n");
for (i = 0; i < nlist->numnames; i++)
fprintf(f, "\t\t\"%jx\" [ label = \"{%s:|{%s|[%jx]:}}\" ];\n",
@@ -159,30 +171,40 @@ DotCmd(int ac, char **av)
continue;
}
 
-   fprintf(f, "\tnode [ shape = octagon, fontsize = 10 ] {\n");
-   for (j = 0; j < ninfo->hooks; j++)
-   fprintf(f, "\t\t\"%jx.%s\" [ label = \"%s\" ];\n",
-   (uintmax_t)nlist->nodeinfo[i].id,
-   hlist->link[j].ourhook, hlist->link[j].ourhook);
-   fprintf(f, "\t};\n");
+   if (!compact) {
+   fprintf(f, "\tnode [ shape = octagon, fontsize = 10 ] 
{\n");
+   for (j = 0; j < ninfo->hooks; j++)
+   fprintf(f, "\t\t\"%jx.%s\" [ label = \"%s\" 
];\n",
+   (uintmax_t)nlist->nodeinfo[i].id,
+   hlist->link[j].ourhook, 
hlist->link[j].ourhook);
+   fprintf(f, "\t};\n");
 
-   fprintf(f, "\t{\n\t\tedge [ weight = 2.0, style = bold ];\n");
-   for (j = 0; j < ninfo->hooks; j++)
-   fprintf(f, "\t\t\"%jx\" -- \"%jx.%s\";\n",
-   (uintmax_t)nlist->nodeinfo[i].id,
-   (uintmax_t)nlist->nodeinfo[i].id,
-   hlist->link[j].ourhook);
-   fprintf(f, "\t};\n");
+   fprintf(f, "\t{\n\t\tedge [ weight = 2.0, style = bold 
];\n");
+   for (j = 0; j < ninfo->hooks; j++)
+   fprintf(f, "\t\t\"%jx\" -- \"%jx.%s\";\n",
+   (uintmax_t)nlist->nodeinfo[i].id,
+   (uintmax_t)nlist->nodeinfo[i].id,
+   hlist->link[j].ourhook);
+   fprintf(f, "\t};\n");
+   }
 
for (j = 0; j 

svn commit: r367665 - stable/12

2020-11-13 Thread Kyle Evans
Author: kevans
Date: Sat Nov 14 02:03:34 2020
New Revision: 367665
URL: https://svnweb.freebsd.org/changeset/base/367665

Log:
  MFC r366275: Makefile.inc1: sysent: parallel subordinate sysent targets
  
  makesyscalls.lua (and indeed makesyscalls.sh) are both safe to be run in
  parallel, so let's do it.
  
  This is a trivial difference because runtime per-target is pretty small, but
  I like seeing it run in parallel when my muscle memory types `make -sj4`.

Modified:
  stable/12/Makefile.inc1
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/Makefile.inc1
==
--- stable/12/Makefile.inc1 Sat Nov 14 02:00:50 2020(r367664)
+++ stable/12/Makefile.inc1 Sat Nov 14 02:03:34 2020(r367665)
@@ -1475,9 +1475,13 @@ _sysent_dirs+=   sys/amd64/linux \
sys/amd64/linux32   \
sys/arm64/linux \
sys/i386/linux
+
 sysent: .PHONY
 .for _dir in ${_sysent_dirs}
+sysent-${_dir}: .PHONY
${_+_}${MAKE} -C ${.CURDIR}/${_dir} sysent
+
+sysent: sysent-${_dir}
 .endfor
 
 #
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r367667 - stable/12/lib/libc/stdlib

2020-11-13 Thread Kyle Evans
Author: kevans
Date: Sat Nov 14 02:11:56 2020
New Revision: 367667
URL: https://svnweb.freebsd.org/changeset/base/367667

Log:
  MFC r366770: libc: typo fix (s/involes/involves)

Modified:
  stable/12/lib/libc/stdlib/bsearch.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/lib/libc/stdlib/bsearch.c
==
--- stable/12/lib/libc/stdlib/bsearch.c Sat Nov 14 02:11:04 2020
(r367666)
+++ stable/12/lib/libc/stdlib/bsearch.c Sat Nov 14 02:11:56 2020
(r367667)
@@ -53,7 +53,7 @@ __FBSDID("$FreeBSD$");
  * is odd, moving left simply involves halving lim: e.g., when lim
  * is 5 we look at item 2, so we change lim to 2 so that we will
  * look at items 0 & 1.  If lim is even, the same applies.  If lim
- * is odd, moving right again involes halving lim, this time moving
+ * is odd, moving right again involves halving lim, this time moving
  * the base up one item past p: e.g., when lim is 5 we change base
  * to item 3 and make lim 2 so that we will look at items 3 and 4.
  * If lim is even, however, we have to shrink it by one before
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r367666 - in stable/12: . stand/lua

2020-11-13 Thread Kyle Evans
Author: kevans
Date: Sat Nov 14 02:11:04 2020
New Revision: 367666
URL: https://svnweb.freebsd.org/changeset/base/367666

Log:
  MFC r366435: lualoader: improve the design of the brand-/logo- mechanism
  
  In the previous world order, any brand/logo was forced to pull in the
  drawer and call drawer.add{Brand,Logo} with the name their brand/logo is
  taking and a table describing it.
  
  In the new world order, these files just need to return a table that maps
  out graphics types to a table of the exact same format as what was
  previously being passed back into the drawer. The appeal here is not needing
  to grab a reference back to the drawer module and having a cleaner
  data-driven looking format for these. The format has been renamed to 'gfx-*'
  prefixes and each one can provide a logo and a brand.
  
  drawer.addBrand/drawer.addLogo will remain in place until FreeBSD 13, as
  there's no overhead to them and it's not yet worth the break in
  compatibility with any pre-existing brands and logos.

Added:
  stable/12/stand/lua/gfx-beastie.lua
 - copied unchanged from r366435, head/stand/lua/gfx-beastie.lua
  stable/12/stand/lua/gfx-beastiebw.lua
 - copied unchanged from r366435, head/stand/lua/gfx-beastiebw.lua
  stable/12/stand/lua/gfx-fbsdbw.lua
 - copied unchanged from r366435, head/stand/lua/gfx-fbsdbw.lua
  stable/12/stand/lua/gfx-orb.lua
 - copied unchanged from r366435, head/stand/lua/gfx-orb.lua
  stable/12/stand/lua/gfx-orbbw.lua
 - copied unchanged from r366435, head/stand/lua/gfx-orbbw.lua
Deleted:
  stable/12/stand/lua/logo-beastie.lua
  stable/12/stand/lua/logo-beastiebw.lua
  stable/12/stand/lua/logo-fbsdbw.lua
  stable/12/stand/lua/logo-orb.lua
  stable/12/stand/lua/logo-orbbw.lua
Modified:
  stable/12/ObsoleteFiles.inc
  stable/12/stand/lua/Makefile
  stable/12/stand/lua/drawer.lua
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/ObsoleteFiles.inc
==
--- stable/12/ObsoleteFiles.inc Sat Nov 14 02:03:34 2020(r367665)
+++ stable/12/ObsoleteFiles.inc Sat Nov 14 02:11:04 2020(r367666)
@@ -38,6 +38,13 @@
 #   xargs -n1 | sort | uniq -d;
 # done
 
+# 20201004: logo files renamed to type-agnostic gfx-*.lua
+OLD_FILES+=boot/lua/logo-beastie.lua
+OLD_FILES+=boot/lua/logo-beastiebw.lua
+OLD_FILES+=boot/lua/logo-fbsdbw.lua
+OLD_FILES+=boot/lua/logo-orb.lua
+OLD_FILES+=boot/lua/logo-orbbw.lua
+
 # 20200722: new clang import which bumps version from 10.0.0 to 10.0.1.
 OLD_FILES+=usr/lib/clang/10.0.0/include/cuda_wrappers/algorithm
 OLD_FILES+=usr/lib/clang/10.0.0/include/cuda_wrappers/complex

Modified: stable/12/stand/lua/Makefile
==
--- stable/12/stand/lua/MakefileSat Nov 14 02:03:34 2020
(r367665)
+++ stable/12/stand/lua/MakefileSat Nov 14 02:11:04 2020
(r367666)
@@ -20,11 +20,11 @@ FILES=  cli.lua \
drawer.lua \
hook.lua \
loader.lua \
-   logo-beastie.lua \
-   logo-beastiebw.lua \
-   logo-fbsdbw.lua \
-   logo-orb.lua \
-   logo-orbbw.lua \
+   gfx-beastie.lua \
+   gfx-beastiebw.lua \
+   gfx-fbsdbw.lua \
+   gfx-orb.lua \
+   gfx-orbbw.lua \
menu.lua \
password.lua \
screen.lua

Modified: stable/12/stand/lua/drawer.lua
==
--- stable/12/stand/lua/drawer.lua  Sat Nov 14 02:03:34 2020
(r367665)
+++ stable/12/stand/lua/drawer.lua  Sat Nov 14 02:11:04 2020
(r367666)
@@ -61,6 +61,35 @@ local function menuEntryName(drawing_menu, entry)
return entry.name
 end
 
+local function processFile(gfxname)
+   if gfxname == nil then
+   return false, "Missing filename"
+   end
+
+   local ret = try_include('gfx-' .. gfxname)
+   if ret == nil then
+   return false, "Failed to include gfx-" .. gfxname
+   end
+
+   -- Legacy format
+   if type(ret) ~= "table" then
+   return true
+   end
+
+   for gfxtype, def in pairs(ret) do
+   if gfxtype == "brand" then
+   drawer.addBrand(gfxname, def)
+   elseif gfxtype == "logo" then
+   drawer.addLogo(gfxname, def)
+   else
+   return false, "Unknown graphics type '" .. gfxtype ..
+   "'"
+   end
+   end
+
+   return true
+end
+
 local function getBranddef(brand)
if brand == nil then
return nil
@@ -70,7 +99,18 @@ local function getBranddef(brand)
 
-- Try to pull it in
if branddef == nil then
-   try_include('brand-' .. brand)
+   local res, err = processFile(brand)
+   if not res then
+   -- This fallback should go away after 

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-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-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,
&pagedep);
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: 

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-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-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-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


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-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


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, &bp);
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