[PATCH] nsclpcsio: nuke unused variable

2018-06-03 Thread Kevin Lo
Hi,

This diff zaps unused variable.  Ok?

Index: sys/dev/isa/nsclpcsio_isa.c
===
RCS file: /cvs/src/sys/dev/isa/nsclpcsio_isa.c,v
retrieving revision 1.13
diff -u -p -u -p -r1.13 nsclpcsio_isa.c
--- sys/dev/isa/nsclpcsio_isa.c 15 Oct 2008 19:12:18 -  1.13
+++ sys/dev/isa/nsclpcsio_isa.c 4 Jun 2018 03:09:04 -
@@ -279,12 +279,11 @@ nsclpcsio_isa_attach(struct device *pare
struct nsclpcsio_softc *sc = (void *)self;
struct isa_attach_args *ia = aux;
struct gpiobus_attach_args gba;
-   bus_space_tag_t iot;
int iobase;
int i;
 
iobase = ia->ipa_io[0].base;
-   sc->sc_iot = iot = ia->ia_iot;
+   sc->sc_iot = ia->ia_iot;
if (bus_space_map(ia->ia_iot, iobase, 2, 0, >sc_ioh)) {
printf(": can't map i/o space\n");
return;



Re: witness report

2018-06-03 Thread Alexander Bluhm
On Sun, Jun 03, 2018 at 10:37:30AM -0700, Philip Guenther wrote:
> @@ -1602,7 +1607,7 @@ vfs_stall(struct proc *p, int stall)
>*/
>   TAILQ_FOREACH_REVERSE(mp, , mntlist, mnt_list) {
>   if (stall) {
> - error = vfs_busy(mp, VB_WRITE|VB_WAIT);
> + error = vfs_busy(mp, VB_WRITE|VB_WAIT|VB_DUPOK);
>   if (error) {
>   printf("%s: busy\n", mp->mnt_stat.f_mntonname);
>   allerror = error;

dounmount() does the vfs busy in the forward direction of the mnt_list.
while ((mp = TAILQ_NEXT(mp, mnt_list)) != NULL) {
error = vfs_busy(mp, VB_WRITE|VB_WAIT);
Then it unmounts all nested mount points in the reverse direction.

So I think we should remove the _REVERSE in vfs_stall().

bluhm



Re: witness report

2018-06-03 Thread Alexander Bluhm
On Sun, Jun 03, 2018 at 10:37:30AM -0700, Philip Guenther wrote:
> Diff below adds VB_DUPOK to indicate that a given vfs_busy() call is 
> expected/permitted to occur while the thread already holds another 
> filesystem busy; the caller is responsible for ensuring the filesystems 
> are locked in the correct order (or that NOWAIT is used safely as in the 
> sys_mount() case).
> 
> As part of this, this plumbs RW_DUPOK for rw_enter().
> 
> I no longer get the witness warning on hibernate with this.
> 
> ok?

OK bluhm@

> Index: sys/mount.h
> ===
> RCS file: /data/src/openbsd/src/sys/sys/mount.h,v
> retrieving revision 1.136
> diff -u -p -r1.136 mount.h
> --- sys/mount.h   8 May 2018 08:58:49 -   1.136
> +++ sys/mount.h   3 Jun 2018 17:05:28 -
> @@ -564,6 +564,7 @@ int   vfs_busy(struct mount *, int);
>  #define VB_WRITE 0x02
>  #define VB_NOWAIT0x04/* immediately fail on busy lock */
>  #define VB_WAIT  0x08/* sleep fail on busy lock */
> +#define VB_DUPOK 0x10/* permit duplicate mount busying */
>  
>  int vfs_isbusy(struct mount *);
>  int vfs_mount_foreach_vnode(struct mount *, int (*func)(struct vnode *,
> Index: sys/rwlock.h
> ===
> RCS file: /data/src/openbsd/src/sys/sys/rwlock.h,v
> retrieving revision 1.22
> diff -u -p -r1.22 rwlock.h
> --- sys/rwlock.h  12 Aug 2017 23:27:44 -  1.22
> +++ sys/rwlock.h  3 Jun 2018 17:05:32 -
> @@ -116,6 +116,7 @@ struct rwlock {
>  #define RW_SLEEPFAIL 0x0020UL /* fail if we slept for the lock */
>  #define RW_NOSLEEP   0x0040UL /* don't wait for the lock */
>  #define RW_RECURSEFAIL   0x0080UL /* Fail on recursion for RRW 
> locks. */
> +#define RW_DUPOK 0x0100UL /* Permit duplicate lock */
>  
>  /*
>   * for rw_status() and rrw_status() only: exclusive lock held by
> Index: kern/kern_rwlock.c
> ===
> RCS file: /data/src/openbsd/src/sys/kern/kern_rwlock.c,v
> retrieving revision 1.35
> diff -u -p -r1.35 kern_rwlock.c
> --- kern/kern_rwlock.c21 Mar 2018 12:28:39 -  1.35
> +++ kern/kern_rwlock.c3 Jun 2018 17:00:02 -
> @@ -223,6 +223,8 @@ _rw_enter(struct rwlock *rwl, int flags 
>   lop_flags = LOP_NEWORDER;
>   if (flags & RW_WRITE)
>   lop_flags |= LOP_EXCLUSIVE;
> + if (flags & RW_DUPOK)
> + lop_flags |= LOP_DUPOK;
>   if ((flags & RW_NOSLEEP) == 0 && (flags & RW_DOWNGRADE) == 0)
>   WITNESS_CHECKORDER(>rwl_lock_obj, lop_flags, file, line,
>   NULL);
> Index: kern/vfs_subr.c
> ===
> RCS file: /data/src/openbsd/src/sys/kern/vfs_subr.c,v
> retrieving revision 1.273
> diff -u -p -r1.273 vfs_subr.c
> --- kern/vfs_subr.c   27 May 2018 06:02:14 -  1.273
> +++ kern/vfs_subr.c   3 Jun 2018 17:04:09 -
> @@ -188,6 +188,11 @@ vfs_busy(struct mount *mp, int flags)
>   else
>   rwflags |= RW_NOSLEEP;
>  
> +#ifdef WITNESS
> + if (flags & VB_DUPOK)
> + rwflags |= RW_DUPOK;
> +#endif
> +
>   if (rw_enter(>mnt_lock, rwflags))
>   return (EBUSY);
>  
> @@ -1602,7 +1607,7 @@ vfs_stall(struct proc *p, int stall)
>*/
>   TAILQ_FOREACH_REVERSE(mp, , mntlist, mnt_list) {
>   if (stall) {
> - error = vfs_busy(mp, VB_WRITE|VB_WAIT);
> + error = vfs_busy(mp, VB_WRITE|VB_WAIT|VB_DUPOK);
>   if (error) {
>   printf("%s: busy\n", mp->mnt_stat.f_mntonname);
>   allerror = error;
> Index: kern/vfs_syscalls.c
> ===
> RCS file: /data/src/openbsd/src/sys/kern/vfs_syscalls.c,v
> retrieving revision 1.284
> diff -u -p -r1.284 vfs_syscalls.c
> --- kern/vfs_syscalls.c   2 Jun 2018 10:27:43 -   1.284
> +++ kern/vfs_syscalls.c   3 Jun 2018 17:04:55 -
> @@ -230,7 +230,7 @@ sys_mount(struct proc *p, void *v, regis
>  
>  update:
>   /* Ensure that the parent mountpoint does not get unmounted. */
> - error = vfs_busy(vp->v_mount, VB_READ|VB_NOWAIT);
> + error = vfs_busy(vp->v_mount, VB_READ|VB_NOWAIT|VB_DUPOK);
>   if (error) {
>   if (mp->mnt_flag & MNT_UPDATE) {
>   mp->mnt_flag = mntflag;
> @@ -439,7 +439,7 @@ dounmount(struct mount *mp, int flags, s
>   error = EBUSY;
>   goto err;
>   }
> - error = vfs_busy(mp, VB_WRITE|VB_WAIT);
> + error = vfs_busy(mp, VB_WRITE|VB_WAIT|VB_DUPOK);
>   if (error) {
>   if ((flags & MNT_DOOMED)) {
> 

Make libc/libpthread use process-private futexes

2018-06-03 Thread Mark Kettenis
Now that the kernel distinguishes between process-shared and
process-private futexes make libc/libpthread use process-private ones.

ok?


Index: lib/libc/thread/synch.h
===
RCS file: /cvs/src/lib/libc/thread/synch.h,v
retrieving revision 1.2
diff -u -p -r1.2 synch.h
--- lib/libc/thread/synch.h 5 Sep 2017 02:40:54 -   1.2
+++ lib/libc/thread/synch.h 3 Jun 2018 21:58:58 -
@@ -22,14 +22,14 @@
 static inline int
 _wake(volatile uint32_t *p, int n)
 {
-   return futex(p, FUTEX_WAKE, n, NULL, NULL);
+   return futex(p, FUTEX_WAKE_PRIVATE, n, NULL, NULL);
 }
 
 static inline void
 _wait(volatile uint32_t *p, int val)
 {
while (*p != (uint32_t)val)
-   futex(p, FUTEX_WAIT, val, NULL, NULL);
+   futex(p, FUTEX_WAIT_PRIVATE, val, NULL, NULL);
 }
 
 static inline int
@@ -38,7 +38,7 @@ _twait(volatile uint32_t *p, int val, cl
struct timespec rel;
 
if (abs == NULL)
-   return futex(p, FUTEX_WAIT, val, NULL, NULL);
+   return futex(p, FUTEX_WAIT_PRIVATE, val, NULL, NULL);
 
if (abs->tv_nsec >= 10 || clock_gettime(clockid, ))
return (EINVAL);
@@ -51,11 +51,11 @@ _twait(volatile uint32_t *p, int val, cl
if (rel.tv_sec < 0)
return (ETIMEDOUT);
 
-   return futex(p, FUTEX_WAIT, val, , NULL);
+   return futex(p, FUTEX_WAIT_PRIVATE, val, , NULL);
 }
 
 static inline int
 _requeue(volatile uint32_t *p, int n, int m, volatile uint32_t *q)
 {
-   return futex(p, FUTEX_REQUEUE, n, (void *)(long)m, q);
+   return futex(p, FUTEX_REQUEUE_PRIVATE, n, (void *)(long)m, q);
 }



Re: netstat: zap unused maxmif

2018-06-03 Thread Alexander Bluhm
On Sun, Jun 03, 2018 at 04:22:02PM +0200, Klemens Nanni wrote:
> Unused since introduction in 1.17 from 2015.
> 
> OK?

OK bluhm@

> Index: mroute6.c
> ===
> RCS file: /cvs/src/usr.bin/netstat/mroute6.c,v
> retrieving revision 1.23
> diff -u -p -r1.23 mroute6.c
> --- mroute6.c 8 May 2017 09:31:34 -   1.23
> +++ mroute6.c 3 Jun 2018 14:09:13 -
> @@ -92,7 +92,6 @@ mroute6pr(void)
>   struct mif6info *mif;
>   size_t needed, mifi, nummifs, mfci, nummfcs;
>   int banner_printed, saved_nflag;
> - mifi_t maxmif = 0;
>   u_int mrtproto;
>   int mib[] = { CTL_NET, PF_INET6, IPPROTO_IPV6, IPV6CTL_MRTPROTO };
>   size_t len = sizeof(int);
> @@ -119,8 +118,6 @@ mroute6pr(void)
>   needed = get_sysctl(mib, sizeof(mib) / sizeof(mib[0]), );
>   nummifs = needed / sizeof(*mif);
>   mif = (struct mif6info *)buf;
> - if (nummifs)
> - maxmif = mif[nummifs - 1].m6_mifi;
>  
>   banner_printed = 0;
>   for (mifi = 0; mifi < nummifs; ++mifi, ++mif) {



Re: witness report

2018-06-03 Thread Amit Kulkarni
On Sun, 3 Jun 2018 13:09:43 -0700
Philip Guenther  wrote:

> On Sun, Jun 3, 2018 at 12:51 PM, Amit Kulkarni  wrote:
> 
> > On Sun, 3 Jun 2018 10:37:30 -0700
> > Philip Guenther  wrote:
> >
> ...
> 
> > > Index: kern/kern_rwlock.c
> > > ===
> > > RCS file: /data/src/openbsd/src/sys/kern/kern_rwlock.c,v
> > > retrieving revision 1.35
> > > diff -u -p -r1.35 kern_rwlock.c
> > > --- kern/kern_rwlock.c21 Mar 2018 12:28:39 -  1.35
> > > +++ kern/kern_rwlock.c3 Jun 2018 17:00:02 -
> > > @@ -223,6 +223,8 @@ _rw_enter(struct rwlock *rwl, int flags
> > >   lop_flags = LOP_NEWORDER;
> > >   if (flags & RW_WRITE)
> > >   lop_flags |= LOP_EXCLUSIVE;
> > > + if (flags & RW_DUPOK)
> > > + lop_flags |= LOP_DUPOK;
> > >   if ((flags & RW_NOSLEEP) == 0 && (flags & RW_DOWNGRADE) == 0)
> > >   WITNESS_CHECKORDER(>rwl_lock_obj, lop_flags, file,
> > line,
> > >   NULL);
> > > Index: kern/vfs_subr.c
> > > ===
> > > RCS file: /data/src/openbsd/src/sys/kern/vfs_subr.c,v
> > > retrieving revision 1.273
> > > diff -u -p -r1.273 vfs_subr.c
> > > --- kern/vfs_subr.c   27 May 2018 06:02:14 -  1.273
> > > +++ kern/vfs_subr.c   3 Jun 2018 17:04:09 -
> > > @@ -188,6 +188,11 @@ vfs_busy(struct mount *mp, int flags)
> > >   else
> > >   rwflags |= RW_NOSLEEP;
> > >
> > > +#ifdef WITNESS
> > > + if (flags & VB_DUPOK)
> > > + rwflags |= RW_DUPOK;
> > > +#endif
> > > +
> >
> > The other parts where you added the dup are not checking for Witness. This
> > part above should be for all kernels, right? Witness or non-witness.
> >
> 
> No, the other code-generating additions, in kern_rwlock.c, are also inside
> #ifdef WITNESS, just outside of the context of the diff.  The RW_DUPOK flag
> has no effect if it's not a WITNESS kernel so excluding those lines is
> intentional.

My apologies, and sorry for the noise!



Re: witness report

2018-06-03 Thread Philip Guenther
On Sun, Jun 3, 2018 at 12:51 PM, Amit Kulkarni  wrote:

> On Sun, 3 Jun 2018 10:37:30 -0700
> Philip Guenther  wrote:
>
...

> > Index: kern/kern_rwlock.c
> > ===
> > RCS file: /data/src/openbsd/src/sys/kern/kern_rwlock.c,v
> > retrieving revision 1.35
> > diff -u -p -r1.35 kern_rwlock.c
> > --- kern/kern_rwlock.c21 Mar 2018 12:28:39 -  1.35
> > +++ kern/kern_rwlock.c3 Jun 2018 17:00:02 -
> > @@ -223,6 +223,8 @@ _rw_enter(struct rwlock *rwl, int flags
> >   lop_flags = LOP_NEWORDER;
> >   if (flags & RW_WRITE)
> >   lop_flags |= LOP_EXCLUSIVE;
> > + if (flags & RW_DUPOK)
> > + lop_flags |= LOP_DUPOK;
> >   if ((flags & RW_NOSLEEP) == 0 && (flags & RW_DOWNGRADE) == 0)
> >   WITNESS_CHECKORDER(>rwl_lock_obj, lop_flags, file,
> line,
> >   NULL);
> > Index: kern/vfs_subr.c
> > ===
> > RCS file: /data/src/openbsd/src/sys/kern/vfs_subr.c,v
> > retrieving revision 1.273
> > diff -u -p -r1.273 vfs_subr.c
> > --- kern/vfs_subr.c   27 May 2018 06:02:14 -  1.273
> > +++ kern/vfs_subr.c   3 Jun 2018 17:04:09 -
> > @@ -188,6 +188,11 @@ vfs_busy(struct mount *mp, int flags)
> >   else
> >   rwflags |= RW_NOSLEEP;
> >
> > +#ifdef WITNESS
> > + if (flags & VB_DUPOK)
> > + rwflags |= RW_DUPOK;
> > +#endif
> > +
>
> The other parts where you added the dup are not checking for Witness. This
> part above should be for all kernels, right? Witness or non-witness.
>

No, the other code-generating additions, in kern_rwlock.c, are also inside
#ifdef WITNESS, just outside of the context of the diff.  The RW_DUPOK flag
has no effect if it's not a WITNESS kernel so excluding those lines is
intentional.


Philip Guenther


Re: witness report

2018-06-03 Thread Amit Kulkarni
On Sun, 3 Jun 2018 10:37:30 -0700
Philip Guenther  wrote:

> On Sun, 3 Jun 2018, Theo de Raadt wrote:
> > Philip Guenther  wrote:
> > > The warning is not that a single filesystem is being locked 
> > > recursively by a single thread, but just that a single thread is 
> > > holding locks on multiple filesystems.
> > 
> > vfs_stall() needs to grab locks on all filesystems, to stop a variety of 
> > filesystem transactions.  (Other types of transactions are blocked in 
> > other ways).
> > 
> > sys_umount() grabs locks on all filesystems above it, to stop anyone 
> > from doing a parallel mount/unmount along the same path.
> > 
> > This is all normal.
> 
> Diff below adds VB_DUPOK to indicate that a given vfs_busy() call is 
> expected/permitted to occur while the thread already holds another 
> filesystem busy; the caller is responsible for ensuring the filesystems 
> are locked in the correct order (or that NOWAIT is used safely as in the 
> sys_mount() case).
> 
> As part of this, this plumbs RW_DUPOK for rw_enter().
> 
> I no longer get the witness warning on hibernate with this.
> 
> ok?
> 
> Philip Guenther
> 
> 
> Index: sys/mount.h
> ===
> RCS file: /data/src/openbsd/src/sys/sys/mount.h,v
> retrieving revision 1.136
> diff -u -p -r1.136 mount.h
> --- sys/mount.h   8 May 2018 08:58:49 -   1.136
> +++ sys/mount.h   3 Jun 2018 17:05:28 -
> @@ -564,6 +564,7 @@ int   vfs_busy(struct mount *, int);
>  #define VB_WRITE 0x02
>  #define VB_NOWAIT0x04/* immediately fail on busy lock */
>  #define VB_WAIT  0x08/* sleep fail on busy lock */
> +#define VB_DUPOK 0x10/* permit duplicate mount busying */
>  
>  int vfs_isbusy(struct mount *);
>  int vfs_mount_foreach_vnode(struct mount *, int (*func)(struct vnode *,
> Index: sys/rwlock.h
> ===
> RCS file: /data/src/openbsd/src/sys/sys/rwlock.h,v
> retrieving revision 1.22
> diff -u -p -r1.22 rwlock.h
> --- sys/rwlock.h  12 Aug 2017 23:27:44 -  1.22
> +++ sys/rwlock.h  3 Jun 2018 17:05:32 -
> @@ -116,6 +116,7 @@ struct rwlock {
>  #define RW_SLEEPFAIL 0x0020UL /* fail if we slept for the lock */
>  #define RW_NOSLEEP   0x0040UL /* don't wait for the lock */
>  #define RW_RECURSEFAIL   0x0080UL /* Fail on recursion for RRW 
> locks. */
> +#define RW_DUPOK 0x0100UL /* Permit duplicate lock */
>  
>  /*
>   * for rw_status() and rrw_status() only: exclusive lock held by
> Index: kern/kern_rwlock.c
> ===
> RCS file: /data/src/openbsd/src/sys/kern/kern_rwlock.c,v
> retrieving revision 1.35
> diff -u -p -r1.35 kern_rwlock.c
> --- kern/kern_rwlock.c21 Mar 2018 12:28:39 -  1.35
> +++ kern/kern_rwlock.c3 Jun 2018 17:00:02 -
> @@ -223,6 +223,8 @@ _rw_enter(struct rwlock *rwl, int flags 
>   lop_flags = LOP_NEWORDER;
>   if (flags & RW_WRITE)
>   lop_flags |= LOP_EXCLUSIVE;
> + if (flags & RW_DUPOK)
> + lop_flags |= LOP_DUPOK;
>   if ((flags & RW_NOSLEEP) == 0 && (flags & RW_DOWNGRADE) == 0)
>   WITNESS_CHECKORDER(>rwl_lock_obj, lop_flags, file, line,
>   NULL);
> Index: kern/vfs_subr.c
> ===
> RCS file: /data/src/openbsd/src/sys/kern/vfs_subr.c,v
> retrieving revision 1.273
> diff -u -p -r1.273 vfs_subr.c
> --- kern/vfs_subr.c   27 May 2018 06:02:14 -  1.273
> +++ kern/vfs_subr.c   3 Jun 2018 17:04:09 -
> @@ -188,6 +188,11 @@ vfs_busy(struct mount *mp, int flags)
>   else
>   rwflags |= RW_NOSLEEP;
>  
> +#ifdef WITNESS
> + if (flags & VB_DUPOK)
> + rwflags |= RW_DUPOK;
> +#endif
> +

The other parts where you added the dup are not checking for Witness. This part 
above should be for all kernels, right? Witness or non-witness.



OpenBSD will never run on XScale again

2018-06-03 Thread Mark Kettenis
Time to get rid of these #ifdef __XSCALE__ bits.  No binary change.

ok?


Index: arch/arm/arm/bcopy_page.S
===
RCS file: /cvs/src/sys/arch/arm/arm/bcopy_page.S,v
retrieving revision 1.1
diff -u -p -r1.1 bcopy_page.S
--- arch/arm/arm/bcopy_page.S   1 Feb 2004 05:09:48 -   1.1
+++ arch/arm/arm/bcopy_page.S   3 Jun 2018 17:54:36 -
@@ -44,8 +44,6 @@
 
 #include "assym.h"
 
-#ifndef __XSCALE__
-
 /* #define BIG_LOOPS */
 
 /*
@@ -178,99 +176,3 @@ ENTRY(bzero_page)
bne 1b
 
ldmfd   sp!, {r4-r8, pc}
-
-#else  /* __XSCALE__ */
-
-/*
- * XSCALE version of bcopy_page
- */
-ENTRY(bcopy_page)
-   pld [r0]
-   stmfd   sp!, {r4, r5}
-   mov ip, #32
-   ldr r2, [r0], #0x04 /* 0x00 */
-   ldr r3, [r0], #0x04 /* 0x04 */
-1: pld [r0, #0x18] /* Prefetch 0x20 */
-   ldr r4, [r0], #0x04 /* 0x08 */
-   ldr r5, [r0], #0x04 /* 0x0c */
-   strdr2, [r1], #0x08
-   ldr r2, [r0], #0x04 /* 0x10 */
-   ldr r3, [r0], #0x04 /* 0x14 */
-   strdr4, [r1], #0x08
-   ldr r4, [r0], #0x04 /* 0x18 */
-   ldr r5, [r0], #0x04 /* 0x1c */
-   strdr2, [r1], #0x08
-   ldr r2, [r0], #0x04 /* 0x20 */
-   ldr r3, [r0], #0x04 /* 0x24 */
-   pld [r0, #0x18] /* Prefetch 0x40 */
-   strdr4, [r1], #0x08
-   ldr r4, [r0], #0x04 /* 0x28 */
-   ldr r5, [r0], #0x04 /* 0x2c */
-   strdr2, [r1], #0x08
-   ldr r2, [r0], #0x04 /* 0x30 */
-   ldr r3, [r0], #0x04 /* 0x34 */
-   strdr4, [r1], #0x08
-   ldr r4, [r0], #0x04 /* 0x38 */
-   ldr r5, [r0], #0x04 /* 0x3c */
-   strdr2, [r1], #0x08
-   ldr r2, [r0], #0x04 /* 0x40 */
-   ldr r3, [r0], #0x04 /* 0x44 */
-   pld [r0, #0x18] /* Prefetch 0x60 */
-   strdr4, [r1], #0x08
-   ldr r4, [r0], #0x04 /* 0x48 */
-   ldr r5, [r0], #0x04 /* 0x4c */
-   strdr2, [r1], #0x08
-   ldr r2, [r0], #0x04 /* 0x50 */
-   ldr r3, [r0], #0x04 /* 0x54 */
-   strdr4, [r1], #0x08
-   ldr r4, [r0], #0x04 /* 0x58 */
-   ldr r5, [r0], #0x04 /* 0x5c */
-   strdr2, [r1], #0x08
-   ldr r2, [r0], #0x04 /* 0x60 */
-   ldr r3, [r0], #0x04 /* 0x64 */
-   pld [r0, #0x18] /* Prefetch 0x80 */
-   strdr4, [r1], #0x08
-   ldr r4, [r0], #0x04 /* 0x68 */
-   ldr r5, [r0], #0x04 /* 0x6c */
-   strdr2, [r1], #0x08
-   ldr r2, [r0], #0x04 /* 0x70 */
-   ldr r3, [r0], #0x04 /* 0x74 */
-   strdr4, [r1], #0x08
-   ldr r4, [r0], #0x04 /* 0x78 */
-   ldr r5, [r0], #0x04 /* 0x7c */
-   strdr2, [r1], #0x08
-   subsip, ip, #0x01
-   ldrgt   r2, [r0], #0x04 /* 0x80 */
-   ldrgt   r3, [r0], #0x04 /* 0x84 */
-   strdr4, [r1], #0x08
-   bgt 1b
-   ldmfd   sp!, {r4, r5}
-   mov pc, lr
-
-/*
- * XSCALE version of bzero_page
- */
-ENTRY(bzero_page)
-   mov r1, #PAGE_SIZE
-   mov r2, #0
-   mov r3, #0
-1: strdr2, [r0], #8/* 32 */
-   strdr2, [r0], #8
-   strdr2, [r0], #8
-   strdr2, [r0], #8
-   strdr2, [r0], #8/* 64 */
-   strdr2, [r0], #8
-   strdr2, [r0], #8
-   strdr2, [r0], #8
-   strdr2, [r0], #8/* 96 */
-   strdr2, [r0], #8
-   strdr2, [r0], #8
-   strdr2, [r0], #8
-   strdr2, [r0], #8/* 128 */
-   strdr2, [r0], #8
-   strdr2, [r0], #8
-   strdr2, [r0], #8
-   subsr1, r1, #128
-   bne 1b
-   mov pc, lr
-#endif /* __XSCALE__ */
Index: arch/arm/arm/bcopyinout.S
===
RCS file: /cvs/src/sys/arch/arm/arm/bcopyinout.S,v
retrieving revision 1.7
diff -u -p -r1.7 bcopyinout.S
--- arch/arm/arm/bcopyinout.S   6 Jan 2017 00:06:02 -   1.7
+++ arch/arm/arm/bcopyinout.S   3 Jun 2018 17:54:36 -
@@ -41,10 +41,6 @@
 #include 
 #include 
 
-#ifdef __XSCALE__
-#include "bcopyinout_xscale.S"
-#else
-
.text
.align  2
 
@@ -59,13 +55,6 @@
 #define SAVE_REGS  stmfd   sp!, {r4-r11}
 #define RESTORE_REGS   ldmfd   sp!, {r4-r11}

-#if defined(__XSCALE__)
-#define HELLOCPP #
-#define PREFETCH(rx,o) pld [ rx , HELLOCPP (o) ]
-#else
-#define PREFETCH(rx,o)
-#endif
-
 /*
  * r0 = user space address
  * r1 = kernel space address
@@ -92,9 +81,6 @@ ENTRY(copyin)
adr r3, .Lcopyfault
   

Re: witness report

2018-06-03 Thread Philip Guenther
On Sun, 3 Jun 2018, Theo de Raadt wrote:
> Philip Guenther  wrote:
> > The warning is not that a single filesystem is being locked 
> > recursively by a single thread, but just that a single thread is 
> > holding locks on multiple filesystems.
> 
> vfs_stall() needs to grab locks on all filesystems, to stop a variety of 
> filesystem transactions.  (Other types of transactions are blocked in 
> other ways).
> 
> sys_umount() grabs locks on all filesystems above it, to stop anyone 
> from doing a parallel mount/unmount along the same path.
> 
> This is all normal.

Diff below adds VB_DUPOK to indicate that a given vfs_busy() call is 
expected/permitted to occur while the thread already holds another 
filesystem busy; the caller is responsible for ensuring the filesystems 
are locked in the correct order (or that NOWAIT is used safely as in the 
sys_mount() case).

As part of this, this plumbs RW_DUPOK for rw_enter().

I no longer get the witness warning on hibernate with this.

ok?

Philip Guenther


Index: sys/mount.h
===
RCS file: /data/src/openbsd/src/sys/sys/mount.h,v
retrieving revision 1.136
diff -u -p -r1.136 mount.h
--- sys/mount.h 8 May 2018 08:58:49 -   1.136
+++ sys/mount.h 3 Jun 2018 17:05:28 -
@@ -564,6 +564,7 @@ int vfs_busy(struct mount *, int);
 #define VB_WRITE   0x02
 #define VB_NOWAIT  0x04/* immediately fail on busy lock */
 #define VB_WAIT0x08/* sleep fail on busy lock */
+#define VB_DUPOK   0x10/* permit duplicate mount busying */
 
 int vfs_isbusy(struct mount *);
 int vfs_mount_foreach_vnode(struct mount *, int (*func)(struct vnode *,
Index: sys/rwlock.h
===
RCS file: /data/src/openbsd/src/sys/sys/rwlock.h,v
retrieving revision 1.22
diff -u -p -r1.22 rwlock.h
--- sys/rwlock.h12 Aug 2017 23:27:44 -  1.22
+++ sys/rwlock.h3 Jun 2018 17:05:32 -
@@ -116,6 +116,7 @@ struct rwlock {
 #define RW_SLEEPFAIL   0x0020UL /* fail if we slept for the lock */
 #define RW_NOSLEEP 0x0040UL /* don't wait for the lock */
 #define RW_RECURSEFAIL 0x0080UL /* Fail on recursion for RRW locks. */
+#define RW_DUPOK   0x0100UL /* Permit duplicate lock */
 
 /*
  * for rw_status() and rrw_status() only: exclusive lock held by
Index: kern/kern_rwlock.c
===
RCS file: /data/src/openbsd/src/sys/kern/kern_rwlock.c,v
retrieving revision 1.35
diff -u -p -r1.35 kern_rwlock.c
--- kern/kern_rwlock.c  21 Mar 2018 12:28:39 -  1.35
+++ kern/kern_rwlock.c  3 Jun 2018 17:00:02 -
@@ -223,6 +223,8 @@ _rw_enter(struct rwlock *rwl, int flags 
lop_flags = LOP_NEWORDER;
if (flags & RW_WRITE)
lop_flags |= LOP_EXCLUSIVE;
+   if (flags & RW_DUPOK)
+   lop_flags |= LOP_DUPOK;
if ((flags & RW_NOSLEEP) == 0 && (flags & RW_DOWNGRADE) == 0)
WITNESS_CHECKORDER(>rwl_lock_obj, lop_flags, file, line,
NULL);
Index: kern/vfs_subr.c
===
RCS file: /data/src/openbsd/src/sys/kern/vfs_subr.c,v
retrieving revision 1.273
diff -u -p -r1.273 vfs_subr.c
--- kern/vfs_subr.c 27 May 2018 06:02:14 -  1.273
+++ kern/vfs_subr.c 3 Jun 2018 17:04:09 -
@@ -188,6 +188,11 @@ vfs_busy(struct mount *mp, int flags)
else
rwflags |= RW_NOSLEEP;
 
+#ifdef WITNESS
+   if (flags & VB_DUPOK)
+   rwflags |= RW_DUPOK;
+#endif
+
if (rw_enter(>mnt_lock, rwflags))
return (EBUSY);
 
@@ -1602,7 +1607,7 @@ vfs_stall(struct proc *p, int stall)
 */
TAILQ_FOREACH_REVERSE(mp, , mntlist, mnt_list) {
if (stall) {
-   error = vfs_busy(mp, VB_WRITE|VB_WAIT);
+   error = vfs_busy(mp, VB_WRITE|VB_WAIT|VB_DUPOK);
if (error) {
printf("%s: busy\n", mp->mnt_stat.f_mntonname);
allerror = error;
Index: kern/vfs_syscalls.c
===
RCS file: /data/src/openbsd/src/sys/kern/vfs_syscalls.c,v
retrieving revision 1.284
diff -u -p -r1.284 vfs_syscalls.c
--- kern/vfs_syscalls.c 2 Jun 2018 10:27:43 -   1.284
+++ kern/vfs_syscalls.c 3 Jun 2018 17:04:55 -
@@ -230,7 +230,7 @@ sys_mount(struct proc *p, void *v, regis
 
 update:
/* Ensure that the parent mountpoint does not get unmounted. */
-   error = vfs_busy(vp->v_mount, VB_READ|VB_NOWAIT);
+   error = vfs_busy(vp->v_mount, VB_READ|VB_NOWAIT|VB_DUPOK);
if (error) {
if (mp->mnt_flag & MNT_UPDATE) {
mp->mnt_flag = mntflag;
@@ -439,7 +439,7 @@ dounmount(struct mount *mp, int flags, s
  

Re: witness report

2018-06-03 Thread Theo de Raadt
Philip Guenther  wrote:

> The warning is not that a single filesystem is being locked recursively by a 
> single
> thread, but just that a single thread is holding locks on multiple 
> filesystems.

vfs_stall() needs to grab locks on all filesystems, to stop a variety of
filesystem transactions.  (Other types of transactions are blocked in other
ways).

sys_umount() grabs locks on all filesystems above it, to stop anyone from
doing a parallel mount/unmount along the same path.

This is all normal.



Re: witness report

2018-06-03 Thread Philip Guenther
On Sun, Jun 3, 2018 at 9:08 AM, Theo de Raadt  wrote:

> Philip Guenther  wrote:
>
> > On Sun, Jun 3, 2018 at 3:26 AM, Klemens Nanni  wrote:
> >
> > > Snap from 31.05.2018 with
> > >
> > > OpenBSD 6.3-current (GENERIC.MP) #0: Sat Jun  2 16:21:22 CEST 2018
> > > k...@x250.my.domain:/usr/src/sys/arch/amd64/compile/GENERIC.MP
> > >
> > >
> > > acquiring duplicate lock of same type: ">mnt_lock"
> > > 1st vfslock @ /usr/src/sys/kern/vfs_subr.c:191
> > > 2nd vfslock @ /usr/src/sys/kern/vfs_subr.c:191
> > > Starting stack trace...
> > > witness_checkorder(9,81ab15c8,bf,80d00040,21) at
> > > witness_checkorder+0x63d
> > > _rw_enter(0,1,0,80d0) at _rw_enter+0x56
> > > vfs_stall(1,80025400) at vfs_stall+0xab
> > >
> >
> > [Also reported by bluhm@ and others]
> >
> > Is vfs_stall() the only place that locks (busies) multiple mounts?
>
> Isn't that also how unmount works?  I believe it locks the mount it will
> be discarding, and the filesystem it is mounted upon.  It is serializing
> against other activities, such as a new mount or another umount occuring
> against the same dir.




Hmm, yes, dounmount() can busy multiple filesystems concurrently when doing
a forced unmount of a filesystem which has a filesystem below it, but in
the normal case of unmounting a leaf filesystem I don't see where it would
have multiple filesystems busy concurrently.


I see vfs_stall() doing 1 lock per filesystem.  Why does this report
> say there are duplicates?
>

 The warning is not that a single filesystem is being locked recursively by
a single thread, but just that a single thread is holding locks on multiple
filesystems.


Philip


Re: witness report

2018-06-03 Thread Theo de Raadt
Philip Guenther  wrote:

> On Sun, Jun 3, 2018 at 3:26 AM, Klemens Nanni  wrote:
> 
> > Snap from 31.05.2018 with
> >
> > OpenBSD 6.3-current (GENERIC.MP) #0: Sat Jun  2 16:21:22 CEST 2018
> > k...@x250.my.domain:/usr/src/sys/arch/amd64/compile/GENERIC.MP
> >
> >
> > acquiring duplicate lock of same type: ">mnt_lock"
> > 1st vfslock @ /usr/src/sys/kern/vfs_subr.c:191
> > 2nd vfslock @ /usr/src/sys/kern/vfs_subr.c:191
> > Starting stack trace...
> > witness_checkorder(9,81ab15c8,bf,80d00040,21) at
> > witness_checkorder+0x63d
> > _rw_enter(0,1,0,80d0) at _rw_enter+0x56
> > vfs_stall(1,80025400) at vfs_stall+0xab
> >
> 
> [Also reported by bluhm@ and others]
> 
> Is vfs_stall() the only place that locks (busies) multiple mounts?

Isn't that also how unmount works?  I believe it locks the mount it will
be discarding, and the filesystem it is mounted upon.  It is serializing
against other activities, such as a new mount or another umount occuring
against the same dir.

I see vfs_stall() doing 1 lock per filesystem.  Why does this report
say there are duplicates?



Re: Allow disks to be specifid by duid in install.sub

2018-06-03 Thread kwesterback



> On Jun 2, 2018, at 3:27 PM, Robert Peichaer  wrote:
> 
>> On Fri, May 18, 2018 at 12:14:36PM +0200, Theo Buehler wrote:
>>> On Thu, May 17, 2018 at 06:42:15PM -0600, Aaron Bieber wrote:
 On Thu, May 17, 2018 at 06:37:56PM -0600, Aaron Bieber wrote:
> On Fri, Mar 02, 2018 at 07:32:04AM -0700, Aaron Bieber wrote:
> Hi,
> 
> Currently disks can only be entered in the [sw]d[0-9][0-9] format at the
> "Which disk is the root disk?" prompt. This is great for humans, but
> things get tricky when doing an autoinstall upgrade on systems where
> connected disks change frequently.
> 
> This diff lets you put the DUID in the response file.
> 
> If anyone has a better way to determine the disk from the duid, I am all
> ears :D
> 
> Cheers,
> Aaron
> 
 
 Thanks to tb@, kn@, Philipp Buehler and phy1729 on #metabug! I tested a
 bsd.rd with an auto-upgrade response file. Once with a duid and once
 with a disk name. Both worked.
 
 I have an OK from tb@ unless anyone objects.
 
 The diff has been distilled down to this:
 
>>> 
>>> Paste fail, here is the latest diff:
>> 
>> Sleeping over it once more, I must say I'm still not terribly fond of
>> this hack and would like to retract my ok for these two reasons:
>> 
>> * we clobber 'resp' which may then leave a confusing error message.
>>  It's only in the $AUTO case, but still.
> 
> Theo is right here. The orginal input should be preserved and used
> in the error messages and should be written to the autoinstall logfile.
> 
>> * In the is_duid case we walk the hw.disknames output twice even though
>>  we know that we already have a good device. This is a bit stupid.
> 
> The get_rootinfo() function is not very "efficient" anyway because
> it is meant to kind of dynamically detect just connected disks.
> That's why get_dkdev() is already called multiple times and this
> even on every iteration of the while-loop. Which also means walking
> through the hw.disknames output multiple times.
> 
> It's more about reusing an existing function (get_dkdev_name) that
> uses hw.disknames to extract the corresponding disk device name.
> 
>> I do think this is going in the right direction, but I'd really like to
>> see these two points resolved before it goes in. It's probably not too
>> difficult, but I've got too many things on my hand, so I won't be able
>> to do it myself anytime soon.
> 
> My suggestion is to not special case autoinstall, but to always
> use get_dkdev_name() to translate a possible supplied DUID to a
> disk device name. If the input $resp was already a disk device
> name, get_dkdev_name() just returns this disk device name. So in
> both cases, $_dkdev holds the disk device name.
> 
> $_dkdev can then be used where a disk device name is required.
> $resp can still be used for the error messages and the ai.log.
> 
> This would be the resulting diff, which looks more complex but
> the change is actually simpler then the previous diff.
> 
> I've tested it sucessfully with DUIDs and disk dev names, both
> interactivly and with autoinstall.
> 
> 
> Index: install.sub
> ===
> RCS file: /cvs/src/distrib/miniroot/install.sub,v
> retrieving revision 1.1068
> diff -u -p -p -u -r1.1068 install.sub
> --- install.sub29 May 2018 20:37:22 -1.1068
> +++ install.sub2 Jun 2018 19:27:03 -
> @@ -,7 +,7 @@ is_rootdisk() {
> 
> # Get global root information. ie. ROOTDISK, ROOTDEV and SWAPDEV.
> get_rootinfo() {
> -local _default=$(get_dkdevs)
> +local _default=$(get_dkdevs) _dkdev
>local _q="Which disk is the root disk? ('?' for details)"
> 
>while :; do
> @@ -2231,11 +2231,14 @@ get_rootinfo() {
>case $resp in
>"?")diskinfo $(get_dkdevs);;
>'');;
> -*)if isin "$resp" $(get_dkdevs); then
> +*)# Translate $resp to disk dev name in case it is a DUID.
> +# get_dkdev_name bounces back the disk dev name if not.
> +_dkdev=$(get_dkdev_name "$resp")
> +if isin "$_dkdev" $(get_dkdevs); then
>[[ $MODE == install ]] && break
> -is_rootdisk "$resp" && break
> +is_rootdisk "$_dkdev" && break
>echo "$resp is not a valid root disk."
> -_default="$(rmel "$resp" $_default) $resp"
> +_default="$(rmel "$_dkdev" $_default) $_dkdev"
>else
>echo "no such disk"
>fi
> @@ -2245,9 +2248,9 @@ get_rootinfo() {
>done
>log_answers "$_q" "$resp"
> 
> -make_dev $resp || exit
> +make_dev $_dkdev || exit
> 
> -ROOTDISK=$resp
> +ROOTDISK=$_dkdev
>ROOTDEV=${ROOTDISK}a
>SWAPDEV=${ROOTDISK}b
> }
> ===
> Stats: --- 6 lines 191 chars
> Stats: +++ 9 lines 365 chars
> Stats: 3 lines
> Stats: 174 chars


Re: witness report

2018-06-03 Thread Philip Guenther
On Sun, Jun 3, 2018 at 3:26 AM, Klemens Nanni  wrote:

> Snap from 31.05.2018 with
>
> OpenBSD 6.3-current (GENERIC.MP) #0: Sat Jun  2 16:21:22 CEST 2018
> k...@x250.my.domain:/usr/src/sys/arch/amd64/compile/GENERIC.MP
>
>
> acquiring duplicate lock of same type: ">mnt_lock"
> 1st vfslock @ /usr/src/sys/kern/vfs_subr.c:191
> 2nd vfslock @ /usr/src/sys/kern/vfs_subr.c:191
> Starting stack trace...
> witness_checkorder(9,81ab15c8,bf,80d00040,21) at
> witness_checkorder+0x63d
> _rw_enter(0,1,0,80d0) at _rw_enter+0x56
> vfs_stall(1,80025400) at vfs_stall+0xab
>

[Also reported by bluhm@ and others]

Is vfs_stall() the only place that locks (busies) multiple mounts?  If it's
the only place _and_ it hotlds no other locks when doing that then I think
it actually is safe, because it would be equivalent to multiple threads
each holding only a single mount lock and nothing else.

Even if we agree that evaluation is correct, I don't think we want to mark
mnt_lock as DUPOK for all purposes, but rather just pass LOP_DUPOK through
for the calls from vfs_stall().


Philip Guenther


Re: smtpd/parse.y : fix line count

2018-06-03 Thread Gilles Chehade
On Sat, Jun 02, 2018 at 10:32:52PM +0200, Denis Fondras wrote:
> Applying otto@'s diff to smtpd.
> Fixes an off-by-one line count when using include statements.
> 
> Ok ?
> 

tested, ok gilles@


> Index: parse.y
> ===
> RCS file: /cvs/src/usr.sbin/smtpd/parse.y,v
> retrieving revision 1.210
> diff -u -p -r1.210 parse.y
> --- parse.y   1 Jun 2018 20:31:33 -   1.210
> +++ parse.y   2 Jun 2018 19:31:08 -
> @@ -63,6 +63,10 @@ static struct file {
>   TAILQ_ENTRY(file)entry;
>   FILE*stream;
>   char*name;
> + size_t   ungetpos;
> + size_t   ungetsize;
> + u_char  *ungetbuf;
> + int  eof_reached;
>   int  lineno;
>   int  errors;
>  } *file, *topfile;
> @@ -73,8 +77,9 @@ int  yyparse(void);
>  int   yylex(void);
>  int   kw_cmp(const void *, const void *);
>  int   lookup(char *);
> +int   igetc(void);
>  int   lgetc(int);
> -int   lungetc(int);
> +void  lungetc(int);
>  int   findeol(void);
>  int   yyerror(const char *, ...)
>  __attribute__((__format__ (printf, 1, 2)))
> @@ -1663,34 +1668,39 @@ lookup(char *s)
>   return (STRING);
>  }
>  
> -#define MAXPUSHBACK  128
> +#define START_EXPAND 1
> +#define DONE_EXPAND  2
>  
> -unsigned char*parsebuf;
> -int   parseindex;
> -unsigned char pushback_buffer[MAXPUSHBACK];
> -int   pushback_index = 0;
> +static int   expanding;
>  
>  int
> -lgetc(int quotec)
> +igetc(void)
>  {
> - int c, next;
> + int c;
>  
> - if (parsebuf) {
> - /* Read character from the parsebuffer instead of input. */
> - if (parseindex >= 0) {
> - c = parsebuf[parseindex++];
> - if (c != '\0')
> - return (c);
> - parsebuf = NULL;
> - } else
> - parseindex++;
> + while (1) {
> + if (file->ungetpos > 0)
> + c = file->ungetbuf[--file->ungetpos];
> + else
> + c = getc(file->stream);
> +
> + if (c == START_EXPAND)
> + expanding = 1;
> + else if (c == DONE_EXPAND)
> + expanding = 0;
> + else
> + break;
>   }
> + return (c);
> +}
>  
> - if (pushback_index)
> - return (pushback_buffer[--pushback_index]);
> +int
> +lgetc(int quotec)
> +{
> + int c, next;
>  
>   if (quotec) {
> - if ((c = getc(file->stream)) == EOF) {
> + if ((c = igetc()) == EOF) {
>   yyerror("reached end of file while parsing "
>   "quoted string");
>   if (file == topfile || popfile() == EOF)
> @@ -1700,8 +1710,8 @@ lgetc(int quotec)
>   return (c);
>   }
>  
> - while ((c = getc(file->stream)) == '\\') {
> - next = getc(file->stream);
> + while ((c = igetc()) == '\\') {
> + next = igetc();
>   if (next != '\n') {
>   c = next;
>   break;
> @@ -1710,28 +1720,39 @@ lgetc(int quotec)
>   file->lineno++;
>   }
>  
> - while (c == EOF) {
> - if (file == topfile || popfile() == EOF)
> - return (EOF);
> - c = getc(file->stream);
> + if (c == EOF) {
> + /*
> +  * Fake EOL when hit EOF for the first time. This gets line
> +  * count right if last line in included file is syntactically
> +  * invalid and has no newline.
> +  */
> + if (file->eof_reached == 0) {
> + file->eof_reached = 1;
> + return ('\n');
> + }
> + while (c == EOF) {
> + if (file == topfile || popfile() == EOF)
> + return (EOF);
> + c = igetc();
> + }
>   }
>   return (c);
>  }
>  
> -int
> +void
>  lungetc(int c)
>  {
>   if (c == EOF)
> - return (EOF);
> - if (parsebuf) {
> - parseindex--;
> - if (parseindex >= 0)
> - return (c);
> + return;
> +
> + if (file->ungetpos >= file->ungetsize) {
> + void *p = reallocarray(file->ungetbuf, file->ungetsize, 2);
> + if (p == NULL)
> + err(1, "lungetc");
> + file->ungetbuf = p;
> + file->ungetsize *= 2;
>   }
> - if (pushback_index < MAXPUSHBACK-1)
> - return (pushback_buffer[pushback_index++] = c);
> - else
> - 

netstat: zap unused maxmif

2018-06-03 Thread Klemens Nanni
Unused since introduction in 1.17 from 2015.

OK?

Index: mroute6.c
===
RCS file: /cvs/src/usr.bin/netstat/mroute6.c,v
retrieving revision 1.23
diff -u -p -r1.23 mroute6.c
--- mroute6.c   8 May 2017 09:31:34 -   1.23
+++ mroute6.c   3 Jun 2018 14:09:13 -
@@ -92,7 +92,6 @@ mroute6pr(void)
struct mif6info *mif;
size_t needed, mifi, nummifs, mfci, nummfcs;
int banner_printed, saved_nflag;
-   mifi_t maxmif = 0;
u_int mrtproto;
int mib[] = { CTL_NET, PF_INET6, IPPROTO_IPV6, IPV6CTL_MRTPROTO };
size_t len = sizeof(int);
@@ -119,8 +118,6 @@ mroute6pr(void)
needed = get_sysctl(mib, sizeof(mib) / sizeof(mib[0]), );
nummifs = needed / sizeof(*mif);
mif = (struct mif6info *)buf;
-   if (nummifs)
-   maxmif = mif[nummifs - 1].m6_mifi;
 
banner_printed = 0;
for (mifi = 0; mifi < nummifs; ++mifi, ++mif) {



Re: Installer support to fetch/verify bsd.rd for release upgrade

2018-06-03 Thread Robert Peichaer
On Sun, Oct 08, 2017 at 09:56:15AM +, Robert Peichaer wrote:
> Up to now, the upgrade procedure from one to the next release meant
> that you had to manually download and verify the new ramdisk kernel.
> 
> What about if you just needed to boot into the existing bsd.rd and
> it would support downloading and verifying the bsd.rd of the next
> release?
> 
> This diff changes the installer script to support such a scenario.
> 
> 1) Boot the existing bsd.rd and choose (U)pgrade
> 2) Enter the "Server directory" of the new release
>The installer then offers just the bsd.rd
>The on-disk signify key of the new release is used for verify it
> 3) Reboot into the new bsd.rd and do the upgrade
> 
> 
> An important assumption for this to work properly is:
> 
>Upgrades are only supported from one release to the release
>immediately following it. [1]
> 
> 
> It would look like this for the 6.2 to 6.3 upgrade situation.
> (The version numbers are obviously faked)
> 
>   Let's upgrade the sets!
>   Location of sets? (cd0 disk http or 'done') [http]
>   HTTP proxy URL? (e.g. 'http://proxy:8080', or 'none') [none]
>   HTTP Server? (hostname, list#, 'done' or '?') [ftp.hostserver.de]
>   Server directory? [pub/OpenBSD/6.2/amd64] pub/OpenBSD/6.3/amd64
>   Unable to get a verified list of distribution sets.
>   
>   Select sets by entering a set name, a file name pattern or 'all'. De-select
>   sets by prepending a '-', e.g.: '-game*'. Selected sets are labelled '[X]'.
>   [X] bsd.rd
>   Set name(s)? (or 'abort' or 'done') [done]
>   Get/Verify SHA256.sig   100% |**|  2152   00:00
>   Signature Verified
>   Get/Verify bsd.rd   100% |**|  9565 KB00:14
>   Installing bsd.rd   100% |**|  9565 KB00:00
>   Location of sets? (cd0 disk http or 'done') [done]
>   Making all device nodes...done.
>   
>   CONGRATULATIONS! Your OpenBSD upgrade has been successfully completed!
>   To boot the new system, enter 'reboot' at the command prompt.


In October 2017 I've added this "feature" to the installer that allows
to boot with an existing bsd.rd and to download/install the bsd.rd of
the next release which can then be used to do the actual system upgrade.

It depends on differing release versions of the booted bsd.rd and sets
found in the specified HTTP "Server directory". To be more precise it
assumes the sets release version is one version ahead of the bsd.rd.

The logic is meant to be simple and to support this scenario reliably.

This is a best-effort, convenience feature intended for users that do
upgrades from release to release. Users will be able to use it when
they upgrade from 6.3 to 6.4 and so forth.

I'm aware of reports that this does not work as expected, but as far
as I was able to test and verify, the problem most probably was that 
in these cases the 6.2-current bsd.rd was too old to have the feature
or was already on some version of 6.3 which means no release version
difference and so this feature was not triggerd.

Cheers
Robert



witness report

2018-06-03 Thread Klemens Nanni
Snap from 31.05.2018 with

OpenBSD 6.3-current (GENERIC.MP) #0: Sat Jun  2 16:21:22 CEST 2018
k...@x250.my.domain:/usr/src/sys/arch/amd64/compile/GENERIC.MP


acquiring duplicate lock of same type: ">mnt_lock"
1st vfslock @ /usr/src/sys/kern/vfs_subr.c:191
2nd vfslock @ /usr/src/sys/kern/vfs_subr.c:191
Starting stack trace...
witness_checkorder(9,81ab15c8,bf,80d00040,21) at 
witness_checkorder+0x63d
_rw_enter(0,1,0,80d0) at _rw_enter+0x56
vfs_stall(1,80025400) at vfs_stall+0xab
acpi_sleep_state(80025400,80025400) at acpi_sleep_state+0x1a7
acpi_sleep_task(80025400,8002a2e0) at acpi_sleep_task+0x10
acpi_thread(0) at acpi_thread+0x1b8
end trace frame: 0x0, count: 251
End of stack trace.



Re: route: improve inet6_makenetandmask

2018-06-03 Thread Klemens Nanni
On Sun, May 27, 2018 at 03:13:04AM +0200, Klemens Nanni wrote:
> On Sat, May 26, 2018 at 11:49:29PM +0200, Denis Fondras wrote:
> > Not related to this diff but RFC2374 has been made obsolete by RFC3587 for 
> > some
> > years : "implementations should not make any assumptions about 2000::/3 
> > being
> > special". I think we can simplify this "else if" :)
> Agreed, although this should probably go into a separate diff; Your post
> on misc@ made me look at this in the first place, so I refrained from
> taking over your work.
> 
> > > + rtm_addrs |= RTA_NETMASK;
> > 
> > Can't we consider this done in prefixlen() ?
> Yes. Missed to remove it from here, thanks.
> 
> Updated diff below without the null and curly bracket cosmetics to avoid
> churn (and leave it for the RFC 3587 update around there).
Bump. Any thoughts on this?



Re: ospfd/parse.y : fix line count

2018-06-03 Thread Remi Locherer
On Sat, Jun 02, 2018 at 10:33:11PM +0200, Denis Fondras wrote:
> Applying otto@'s diff to ospfd.
> Fixes an off-by-one line count when using include statements.
> 
> Ok ?

I applied your diff and verified that the line number for errors
in included files is now correct.

ok remi@

> 
> Index: parse.y
> ===
> RCS file: /cvs/src/usr.sbin/ospfd/parse.y,v
> retrieving revision 1.87
> diff -u -p -r1.87 parse.y
> --- parse.y   26 Apr 2018 14:12:19 -  1.87
> +++ parse.y   2 Jun 2018 20:17:10 -
> @@ -48,6 +48,10 @@ static struct file {
>   TAILQ_ENTRY(file)entry;
>   FILE*stream;
>   char*name;
> + size_t   ungetpos;
> + size_t   ungetsize;
> + u_char  *ungetbuf;
> + int  eof_reached;
>   int  lineno;
>   int  errors;
>  } *file, *topfile;
> @@ -61,8 +65,9 @@ int  yyerror(const char *, ...)
>  __attribute__((__nonnull__ (1)));
>  int   kw_cmp(const void *, const void *);
>  int   lookup(char *);
> +int   igetc(void);
>  int   lgetc(int);
> -int   lungetc(int);
> +void  lungetc(int);
>  int   findeol(void);
>  
>  TAILQ_HEAD(symhead, sym)  symhead = TAILQ_HEAD_INITIALIZER(symhead);
> @@ -154,7 +159,8 @@ grammar   : /* empty */
>  include  : INCLUDE STRING{
>   struct file *nfile;
>  
> - if ((nfile = pushfile($2, 1)) == NULL) {
> + if ((nfile = pushfile($2,
> + !(conf->opts & OSPFD_OPT_NOACTION))) == NULL) {
>   yyerror("failed to include file %s", $2);
>   free($2);
>   YYERROR;
> @@ -836,34 +842,39 @@ lookup(char *s)
>   return (STRING);
>  }
>  
> -#define MAXPUSHBACK  128
> +#define START_EXPAND 1
> +#define DONE_EXPAND  2
>  
> -u_char   *parsebuf;
> -int   parseindex;
> -u_charpushback_buffer[MAXPUSHBACK];
> -int   pushback_index = 0;
> +static int   expanding;
>  
>  int
> -lgetc(int quotec)
> +igetc(void)
>  {
> - int c, next;
> + int c;
>  
> - if (parsebuf) {
> - /* Read character from the parsebuffer instead of input. */
> - if (parseindex >= 0) {
> - c = parsebuf[parseindex++];
> - if (c != '\0')
> - return (c);
> - parsebuf = NULL;
> - } else
> - parseindex++;
> + while (1) {
> + if (file->ungetpos > 0)
> + c = file->ungetbuf[--file->ungetpos];
> + else
> + c = getc(file->stream);
> +
> + if (c == START_EXPAND)
> + expanding = 1;
> + else if (c == DONE_EXPAND)
> + expanding = 0;
> + else
> + break;
>   }
> + return (c);
> +}
>  
> - if (pushback_index)
> - return (pushback_buffer[--pushback_index]);
> +int
> +lgetc(int quotec)
> +{
> + int c, next;
>  
>   if (quotec) {
> - if ((c = getc(file->stream)) == EOF) {
> + if ((c = igetc()) == EOF) {
>   yyerror("reached end of file while parsing "
>   "quoted string");
>   if (file == topfile || popfile() == EOF)
> @@ -873,8 +884,8 @@ lgetc(int quotec)
>   return (c);
>   }
>  
> - while ((c = getc(file->stream)) == '\\') {
> - next = getc(file->stream);
> + while ((c = igetc()) == '\\') {
> + next = igetc();
>   if (next != '\n') {
>   c = next;
>   break;
> @@ -883,28 +894,39 @@ lgetc(int quotec)
>   file->lineno++;
>   }
>  
> - while (c == EOF) {
> - if (file == topfile || popfile() == EOF)
> - return (EOF);
> - c = getc(file->stream);
> + if (c == EOF) {
> + /*
> +  * Fake EOL when hit EOF for the first time. This gets line
> +  * count right if last line in included file is syntactically
> +  * invalid and has no newline.
> +  */
> + if (file->eof_reached == 0) {
> + file->eof_reached = 1;
> + return ('\n');
> + }
> + while (c == EOF) {
> + if (file == topfile || popfile() == EOF)
> + return (EOF);
> + c = igetc();
> + }
>   }
>   return (c);
>  }
>  
> -int
> +void
>  lungetc(int c)
>  {
>   if (c == EOF)
> - return (EOF);
> - 

Re: ospf6d/parse.y : fix line count

2018-06-03 Thread Remi Locherer
On Sat, Jun 02, 2018 at 10:33:07PM +0200, Denis Fondras wrote:
> Applying otto@'s diff to ospf6d.
> Fixes an off-by-one line count when using include statements.
> 
> Ok ?

I applied your diff and verified that the line number for errors
in included files is now correct.

ok remi@

> 
> Index: parse.y
> ===
> RCS file: /cvs/src/usr.sbin/ospf6d/parse.y,v
> retrieving revision 1.31
> diff -u -p -r1.31 parse.y
> --- parse.y   26 Apr 2018 14:12:19 -  1.31
> +++ parse.y   2 Jun 2018 20:18:24 -
> @@ -50,6 +50,10 @@ static struct file {
>   TAILQ_ENTRY(file)entry;
>   FILE*stream;
>   char*name;
> + size_t   ungetpos;
> + size_t   ungetsize;
> + u_char  *ungetbuf;
> + int  eof_reached;
>   int  lineno;
>   int  errors;
>  } *file, *topfile;
> @@ -63,8 +67,9 @@ int  yyerror(const char *, ...)
>  __attribute__((__nonnull__ (1)));
>  int   kw_cmp(const void *, const void *);
>  int   lookup(char *);
> +int   igetc(void);
>  int   lgetc(int);
> -int   lungetc(int);
> +void  lungetc(int);
>  int   findeol(void);
>  
>  TAILQ_HEAD(symhead, sym)  symhead = TAILQ_HEAD_INITIALIZER(symhead);
> @@ -146,7 +151,8 @@ grammar   : /* empty */
>  include  : INCLUDE STRING{
>   struct file *nfile;
>  
> - if ((nfile = pushfile($2, 1)) == NULL) {
> + if ((nfile = pushfile($2,
> + !(conf->opts & OSPFD_OPT_NOACTION))) == NULL) {
>   yyerror("failed to include file %s", $2);
>   free($2);
>   YYERROR;
> @@ -591,34 +597,39 @@ lookup(char *s)
>   return (STRING);
>  }
>  
> -#define MAXPUSHBACK  128
> +#define START_EXPAND 1
> +#define DONE_EXPAND  2
>  
> -u_char   *parsebuf;
> -int   parseindex;
> -u_charpushback_buffer[MAXPUSHBACK];
> -int   pushback_index = 0;
> +static int   expanding;
>  
>  int
> -lgetc(int quotec)
> +igetc(void)
>  {
> - int c, next;
> + int c;
>  
> - if (parsebuf) {
> - /* Read character from the parsebuffer instead of input. */
> - if (parseindex >= 0) {
> - c = parsebuf[parseindex++];
> - if (c != '\0')
> - return (c);
> - parsebuf = NULL;
> - } else
> - parseindex++;
> + while (1) {
> + if (file->ungetpos > 0)
> + c = file->ungetbuf[--file->ungetpos];
> + else
> + c = getc(file->stream);
> +
> + if (c == START_EXPAND)
> + expanding = 1;
> + else if (c == DONE_EXPAND)
> + expanding = 0;
> + else
> + break;
>   }
> + return (c);
> +}
>  
> - if (pushback_index)
> - return (pushback_buffer[--pushback_index]);
> +int
> +lgetc(int quotec)
> +{
> + int c, next;
>  
>   if (quotec) {
> - if ((c = getc(file->stream)) == EOF) {
> + if ((c = igetc()) == EOF) {
>   yyerror("reached end of file while parsing "
>   "quoted string");
>   if (file == topfile || popfile() == EOF)
> @@ -628,8 +639,8 @@ lgetc(int quotec)
>   return (c);
>   }
>  
> - while ((c = getc(file->stream)) == '\\') {
> - next = getc(file->stream);
> + while ((c = igetc()) == '\\') {
> + next = igetc();
>   if (next != '\n') {
>   c = next;
>   break;
> @@ -638,28 +649,39 @@ lgetc(int quotec)
>   file->lineno++;
>   }
>  
> - while (c == EOF) {
> - if (file == topfile || popfile() == EOF)
> - return (EOF);
> - c = getc(file->stream);
> + if (c == EOF) {
> + /*
> +  * Fake EOL when hit EOF for the first time. This gets line
> +  * count right if last line in included file is syntactically
> +  * invalid and has no newline.
> +  */
> + if (file->eof_reached == 0) {
> + file->eof_reached = 1;
> + return ('\n');
> + }
> + while (c == EOF) {
> + if (file == topfile || popfile() == EOF)
> + return (EOF);
> + c = igetc();
> + }
>   }
>   return (c);
>  }
>  
> -int
> +void
>  lungetc(int c)
>  {
>   if (c == EOF)
> - return (EOF);
> -   

Re: route: zap unused sockaddr

2018-06-03 Thread Alexander Bluhm
On Sun, Jun 03, 2018 at 01:05:32AM +0200, Klemens Nanni wrote:
> No object change.
> 
> OK?

usr.bin/netstat/show.c has the same code.  They should stay in sync.
Please change it there, too.  Then OK bluhm@.

> Index: show.c
> ===
> RCS file: /cvs/src/sbin/route/show.c,v
> retrieving revision 1.112
> diff -u -p -r1.112 show.c
> --- show.c1 May 2018 18:13:21 -   1.112
> +++ show.c2 Jun 2018 22:55:26 -
> @@ -140,7 +140,6 @@ p_rttables(int af, u_int tableid, char p
>   char *buf = NULL, *next, *lim = NULL;
>   size_t needed;
>   int mib[7], mcnt;
> - struct sockaddr *sa;
>  
>   mib[0] = CTL_NET;
>   mib[1] = PF_ROUTE;
> @@ -164,7 +163,6 @@ p_rttables(int af, u_int tableid, char p
>   rtm = (struct rt_msghdr *)next;
>   if (rtm->rtm_version != RTM_VERSION)
>   continue;
> - sa = (struct sockaddr *)(next + rtm->rtm_hdrlen);
>   p_rtentry(rtm);
>   }
>   }