svn commit: r330791 - head/sys/conf

2018-03-11 Thread Conrad Meyer
Author: cem
Date: Mon Mar 12 05:41:27 2018
New Revision: 330791
URL: https://svnweb.freebsd.org/changeset/base/330791

Log:
  Implement NO_WCAST_QUAL for gcc4.2 architectures

Modified:
  head/sys/conf/kern.mk

Modified: head/sys/conf/kern.mk
==
--- head/sys/conf/kern.mk   Mon Mar 12 05:03:32 2018(r330790)
+++ head/sys/conf/kern.mk   Mon Mar 12 05:41:27 2018(r330791)
@@ -68,6 +68,9 @@ CWARNEXTRA+=  -Wno-error=misleading-indentation   
\
 .else
 # For gcc 4.2, eliminate the too-often-wrong warnings about uninitialized vars.
 CWARNEXTRA?=   -Wno-uninitialized
+# GCC 4.2 doesn't have -Wno-error=cast-qual, so just disable the warning for
+# the few files that are already known to generate cast-qual warnings.
+NO_WCAST_QUAL= -Wno-cast-qual
 .endif
 .endif
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r330790 - head/usr.sbin/mpsutil

2018-03-11 Thread Scott Long
Author: scottl
Date: Mon Mar 12 05:03:32 2018
New Revision: 330790
URL: https://svnweb.freebsd.org/changeset/base/330790

Log:
  Add a new 'debug' command tree and 'dump_reqs' command to grab and parse
  command and chain frames of in-flight I/O from the driver.
  
  Sponsored by: Netflix

Added:
  head/usr.sbin/mpsutil/mps_debug.c   (contents, props changed)
Modified:
  head/usr.sbin/mpsutil/Makefile
  head/usr.sbin/mpsutil/mps_show.c
  head/usr.sbin/mpsutil/mpsutil.c
  head/usr.sbin/mpsutil/mpsutil.h

Modified: head/usr.sbin/mpsutil/Makefile
==
--- head/usr.sbin/mpsutil/Makefile  Mon Mar 12 05:02:22 2018
(r330789)
+++ head/usr.sbin/mpsutil/Makefile  Mon Mar 12 05:03:32 2018
(r330790)
@@ -1,7 +1,7 @@
 # $FreeBSD$
 
 PROG=  mpsutil
-SRCS=  mps_cmd.c mps_flash.c mps_show.c mpsutil.c
+SRCS=  mps_cmd.c mps_debug.c mps_flash.c mps_show.c mpsutil.c
 MAN=   mpsutil.8
 
 WARNS?= 3

Added: head/usr.sbin/mpsutil/mps_debug.c
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/usr.sbin/mpsutil/mps_debug.c   Mon Mar 12 05:03:32 2018
(r330790)
@@ -0,0 +1,190 @@
+/*-
+ * Copyright (c) 2018 Netflix, Inc.
+ * All rights reserved.
+ * Written by: Scott Long 
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author nor the names of any co-contributors
+ *may be used to endorse or promote products derived from this software
+ *without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include 
+__RCSID("$FreeBSD$");
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "mpsutil.h"
+
+MPS_TABLE(top, debug);
+
+struct mps_dumpreq_hdr {
+   uint32_tsmid;
+   uint32_tstate;
+   uint32_tnumframes;
+   uint32_tdeschi;
+   uint32_tdesclo;
+};
+
+static int find_sgl(char *);
+static void print_sgl(char *, int, int);
+
+#define MPS_FRAME_LEN 128
+
+static int
+debug_dumpreqs(int ac, char **av)
+{
+   struct mps_dumpreq_hdr *hdr;
+   char *buf, sysctlbuf[128];
+   size_t len;
+   int numframes, error, offset;
+
+   len = 0;
+   buf = NULL;
+   snprintf(sysctlbuf, sizeof(sysctlbuf), "dev.%s.%d.dump_reqs",
+   is_mps ? "mps" : "mpr", mps_unit);
+
+   error = sysctlbyname(sysctlbuf, NULL, , NULL, 0);
+   if (error)
+   return (error);
+
+   if (len == 0)
+   return (0);
+
+   buf = malloc(len);
+   if (buf == NULL)
+   return (ENOMEM);
+
+   error = sysctlbyname(sysctlbuf, buf, , NULL, 0);
+   if (error) {
+   printf("len= %zd, error= %d errno= %d\n", len, error, errno);
+   return (error);
+   }
+
+   while (len >= MPS_FRAME_LEN) {
+   hdr = (struct mps_dumpreq_hdr *)buf;
+   numframes = hdr->numframes;
+
+   printf("SMID= %d state= %#x numframes= %d desc.hi= %#08x "
+   "desc.lo= %#08x\n", hdr->smid, hdr->state,
+   hdr->numframes, hdr->deschi, hdr->desclo);
+
+   buf += sizeof(struct mps_dumpreq_hdr);
+   len -= sizeof(struct mps_dumpreq_hdr);
+
+   if ((offset = find_sgl(buf)) != -1)
+   print_sgl(buf, offset, numframes);
+
+   buf += MPS_FRAME_LEN * numframes;
+   len -= MPS_FRAME_LEN * numframes;
+   }
+
+   return (error);
+}
+
+static int
+find_sgl(char *buf)
+{
+   MPI2_REQUEST_HEADER *req;
+   MPI2_SCSI_IO_REQUEST 

svn commit: r330789 - in head/sys/dev: mpr mps

2018-03-11 Thread Scott Long
Author: scottl
Date: Mon Mar 12 05:02:22 2018
New Revision: 330789
URL: https://svnweb.freebsd.org/changeset/base/330789

Log:
  Implement a sysctl to dump in-flight I/O state for debugging.  The tool to
  parse it will be committed in a separate action.
  
  Sponsored by: Netflix

Modified:
  head/sys/dev/mpr/mpr.c
  head/sys/dev/mps/mps.c

Modified: head/sys/dev/mpr/mpr.c
==
--- head/sys/dev/mpr/mpr.c  Mon Mar 12 03:54:38 2018(r330788)
+++ head/sys/dev/mpr/mpr.c  Mon Mar 12 05:02:22 2018(r330789)
@@ -56,6 +56,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -107,6 +108,7 @@ static void mpr_enqueue_request(struct mpr_softc *sc, 
 static int mpr_get_iocfacts(struct mpr_softc *sc, MPI2_IOC_FACTS_REPLY *facts);
 static int mpr_wait_db_ack(struct mpr_softc *sc, int timeout, int sleep_flag);
 static int mpr_debug_sysctl(SYSCTL_HANDLER_ARGS);
+static int mpr_dump_reqs(SYSCTL_HANDLER_ARGS);
 static void mpr_parse_debug(struct mpr_softc *sc, char *list);
 
 SYSCTL_NODE(_hw, OID_AUTO, mpr, CTLFLAG_RD, 0, "MPR Driver Parameters");
@@ -1910,6 +1912,10 @@ mpr_setup_sysctl(struct mpr_softc *sc)
>spinup_wait_time, DEFAULT_SPINUP_WAIT, "seconds to wait for "
"spinup after SATA ID error");
 
+   SYSCTL_ADD_PROC(sysctl_ctx, SYSCTL_CHILDREN(sysctl_tree),
+   OID_AUTO, "dump_reqs", CTLTYPE_OPAQUE | CTLFLAG_RD | CTLFLAG_SKIP, 
sc, 0,
+   mpr_dump_reqs, "I", "Dump Active Requests");
+
SYSCTL_ADD_INT(sysctl_ctx, SYSCTL_CHILDREN(sysctl_tree),
OID_AUTO, "use_phy_num", CTLFLAG_RD, >use_phynum, 0,
"Use the phy number for enumeration");
@@ -2051,6 +2057,70 @@ mpr_parse_debug(struct mpr_softc *sc, char *list)
break;
}
return;
+}
+
+struct mpr_dumpreq_hdr {
+   uint32_tsmid;
+   uint32_tstate;
+   uint32_tnumframes;
+   uint32_tdeschi;
+   uint32_tdesclo;
+};
+
+static int
+mpr_dump_reqs(SYSCTL_HANDLER_ARGS)
+{
+   struct mpr_softc *sc;
+   struct mpr_chain *chain, *chain1;
+   struct mpr_command *cm;
+   struct mpr_dumpreq_hdr hdr;
+   struct sbuf *sb;
+   uint32_t smid, state;
+   int i, numreqs, error = 0;
+
+   sc = (struct mpr_softc *)arg1;
+
+   if ((error = priv_check(curthread, PRIV_DRIVER)) != 0) {
+   printf("priv check error %d\n", error);
+   return (error);
+   }
+
+   state = MPR_CM_STATE_INQUEUE;
+   smid = 1;
+   numreqs = sc->num_reqs;
+
+   if (req->newptr != NULL)
+   return (EINVAL);
+
+   if (smid == 0 || smid > sc->num_reqs)
+   return (EINVAL);
+   if (numreqs <= 0 || (numreqs + smid > sc->num_reqs))
+   numreqs = sc->num_reqs;
+   sb = sbuf_new_for_sysctl(NULL, NULL, 4096, req);
+
+   /* Best effort, no locking */
+   for (i = smid; i < numreqs; i++) {
+   cm = >commands[i];
+   if (cm->cm_state != state)
+   continue;
+   hdr.smid = i;
+   hdr.state = cm->cm_state;
+   hdr.numframes = 1;
+   hdr.deschi = cm->cm_desc.Words.High;
+   hdr.desclo = cm->cm_desc.Words.Low;
+   TAILQ_FOREACH_SAFE(chain, >cm_chain_list, chain_link,
+  chain1)
+   hdr.numframes++;
+   sbuf_bcat(sb, , sizeof(hdr));
+   sbuf_bcat(sb, cm->cm_req, 128);
+   TAILQ_FOREACH_SAFE(chain, >cm_chain_list, chain_link,
+   chain1)
+   sbuf_bcat(sb, chain->chain, 128);
+   }
+
+   error = sbuf_finish(sb);
+   sbuf_delete(sb);
+   return (error);
 }
 
 int

Modified: head/sys/dev/mps/mps.c
==
--- head/sys/dev/mps/mps.c  Mon Mar 12 03:54:38 2018(r330788)
+++ head/sys/dev/mps/mps.c  Mon Mar 12 05:02:22 2018(r330789)
@@ -59,6 +59,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -106,6 +107,7 @@ static void mps_enqueue_request(struct mps_softc *sc, 
 static int mps_get_iocfacts(struct mps_softc *sc, MPI2_IOC_FACTS_REPLY *facts);
 static int mps_wait_db_ack(struct mps_softc *sc, int timeout, int sleep_flag);
 static int mps_debug_sysctl(SYSCTL_HANDLER_ARGS);
+static int mps_dump_reqs(SYSCTL_HANDLER_ARGS);
 static void mps_parse_debug(struct mps_softc *sc, char *list);
 
 SYSCTL_NODE(_hw, OID_AUTO, mps, CTLFLAG_RD, 0, "MPS Driver Parameters");
@@ -1793,6 +1795,10 @@ mps_setup_sysctl(struct mps_softc *sc)
OID_AUTO, "encl_table_dump", CTLTYPE_STRING | CTLFLAG_RD, sc, 0,
mps_mapping_encl_dump, "A", "Enclosure Table Dump");
 
+   SYSCTL_ADD_PROC(sysctl_ctx, SYSCTL_CHILDREN(sysctl_tree),
+   

svn commit: r330788 - in head/stand/mips/beri: boot2 common loader

2018-03-11 Thread Kyle Evans
Author: kevans
Date: Mon Mar 12 03:54:38 2018
New Revision: 330788
URL: https://svnweb.freebsd.org/changeset/base/330788

Log:
  beri loader: Replace getc/putc with beri_ prefixed versions
  
  This matches a convention that we use, at least in ubldr, to prefix
  getc/putc with a loader-specific prefix to avoid collisions. This was
  encountered while trying to build the beri loader with MK_LOADER_LUA=yes.
  
  No objection from:brooks
  Reported by:  emaste

Modified:
  head/stand/mips/beri/boot2/boot2.c
  head/stand/mips/beri/common/altera_jtag_uart.c
  head/stand/mips/beri/common/cons.h
  head/stand/mips/beri/loader/beri_console.c

Modified: head/stand/mips/beri/boot2/boot2.c
==
--- head/stand/mips/beri/boot2/boot2.c  Mon Mar 12 01:41:16 2018
(r330787)
+++ head/stand/mips/beri/boot2/boot2.c  Mon Mar 12 03:54:38 2018
(r330788)
@@ -627,7 +627,7 @@ static int
 xputc(int c)
 {
 if (ioctrl & IO_KEYBOARD)
-   putc(c);
+   beri_putc(c);
 #if 0
 if (ioctrl & IO_SERIAL)
sio_putc(c);
@@ -642,7 +642,7 @@ xgetc(int fn)
return 0;
 for (;;) {
if (ioctrl & IO_KEYBOARD && keyhit(0))
-   return fn ? 1 : getc();
+   return fn ? 1 : beri_getc();
 #if 0
if (ioctrl & IO_SERIAL && sio_ischar())
return fn ? 1 : sio_getc();

Modified: head/stand/mips/beri/common/altera_jtag_uart.c
==
--- head/stand/mips/beri/common/altera_jtag_uart.c  Mon Mar 12 01:41:16 
2018(r330787)
+++ head/stand/mips/beri/common/altera_jtag_uart.c  Mon Mar 12 03:54:38 
2018(r330788)
@@ -159,7 +159,7 @@ keyhit(int seconds)
 }
 
 int
-getc(void)
+beri_getc(void)
 {
 
while (!(uart_readable()));
@@ -168,7 +168,7 @@ getc(void)
 }
 
 void
-putc(int ch)
+beri_putc(int ch)
 {
 
uart_data_write(ch);

Modified: head/stand/mips/beri/common/cons.h
==
--- head/stand/mips/beri/common/cons.h  Mon Mar 12 01:41:16 2018
(r330787)
+++ head/stand/mips/beri/common/cons.h  Mon Mar 12 03:54:38 2018
(r330788)
@@ -33,8 +33,8 @@
 #ifndef _CONS_H_
 #define_CONS_H_
 
-intgetc(void);
+intberi_getc(void);
 intkeyhit(int);
-void   putc(int);
+void   beri_putc(int);
 
 #endif

Modified: head/stand/mips/beri/loader/beri_console.c
==
--- head/stand/mips/beri/loader/beri_console.c  Mon Mar 12 01:41:16 2018
(r330787)
+++ head/stand/mips/beri/loader/beri_console.c  Mon Mar 12 03:54:38 2018
(r330788)
@@ -72,14 +72,14 @@ static void
 c_out(int c)
 {
 
-   putc(c);
+   beri_putc(c);
 }
 
 static int
 c_in(void)
 {
 
-   return (getc());
+   return (beri_getc());
 }
 
 static int
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r328554 - head/sys/cam/scsi

2018-03-11 Thread Dexuan-BSD Cui
Hi imp and all,
I think this patch is very important, because it can fix a panic I
noticed recently when I try to hot-remove a SCSI disk from a VM
running on Azure/Hyper-V.

The panic is almost 100% reproducible with stable/11, but not in the
latest CURRENT code, so finally I identified this fix in the CURRENT
branch.

Can you please MFC this patch to 11 and 10?
It looks there is a major difference in the CAM code between 11/10
and the CURRENT code, and we may have to MFC more related patches. If
this is difficult, I hope at least we can provide a minimal re-written
version of the patch to 11 and 10?

Looking forward to your insight!

Thanks,
-- Dexuan


On Mon, Jan 29, 2018 at 10:07 AM, Warner Losh  wrote:
> Author: imp
> Date: Mon Jan 29 18:07:14 2018
> New Revision: 328554
> URL: https://svnweb.freebsd.org/changeset/base/328554
>
> Log:
>   Do the book-keeping on release before we release the reference. The
>   periph was going away on final release, and then returning and we
>   started dancing in free memory.
>
>   Sponsored by: Netflix
>
> Modified:
>   head/sys/cam/scsi/scsi_da.c
>
> Modified: head/sys/cam/scsi/scsi_da.c
> ==
> --- head/sys/cam/scsi/scsi_da.c Mon Jan 29 17:32:30 2018(r328553)
> +++ head/sys/cam/scsi/scsi_da.c Mon Jan 29 18:07:14 2018(r328554)
> @@ -1549,12 +1549,12 @@ da_periph_unhold(struct cam_periph *periph, da_ref_tok
> struct da_softc *softc = periph->softc;
>
> token_sanity(token);
> -   cam_periph_unhold(periph);
> DA_PERIPH_PRINT(periph, "Unholding device %s (%d)\n",
> da_ref_text[token], token);
> cnt = atomic_fetchadd_int(>ref_flags[token], -1);
> if (cnt != 1)
> panic("Unholding %d with cnt = %d", token, cnt);
> +   cam_periph_unhold(periph);
>  }
>
>  static inline int
> @@ -1583,12 +1583,12 @@ da_periph_release(struct cam_periph *periph, da_ref_to
> struct da_softc *softc = periph->softc;
>
> token_sanity(token);
> -   cam_periph_release(periph);
> DA_PERIPH_PRINT(periph, "releasing device %s (%d)\n",
> da_ref_text[token], token);
> cnt = atomic_fetchadd_int(>ref_flags[token], -1);
> if (cnt != 1)
> panic("Releasing %d with cnt = %d", token, cnt);
> +   cam_periph_release(periph);
>  }
>
>  static inline void
> @@ -1598,12 +1598,12 @@ da_periph_release_locked(struct cam_periph *periph, da
> struct da_softc *softc = periph->softc;
>
> token_sanity(token);
> -   cam_periph_release_locked(periph);
> DA_PERIPH_PRINT(periph, "releasing device (locked) %s (%d)\n",
> da_ref_text[token], token);
> cnt = atomic_fetchadd_int(>ref_flags[token], -1);
> if (cnt != 1)
> panic("Unholding %d with cnt = %d", token, cnt);
> +   cam_periph_release_locked(periph);
>  }
>
>  #define cam_periph_hold POISON
>
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r330787 - head/usr.sbin/lpr/common_source

2018-03-11 Thread Garance A Drosehn
Author: gad
Date: Mon Mar 12 01:41:16 2018
New Revision: 330787
URL: https://svnweb.freebsd.org/changeset/base/330787

Log:
  Fix the resource leak of a 'FILE *' which could happen in routine
  ctl_readcf() if a call to malloc failed.
  
  PR:   204955
  Reported by:  David Binderman

Modified:
  head/usr.sbin/lpr/common_source/ctlinfo.c

Modified: head/usr.sbin/lpr/common_source/ctlinfo.c
==
--- head/usr.sbin/lpr/common_source/ctlinfo.c   Mon Mar 12 00:33:01 2018
(r330786)
+++ head/usr.sbin/lpr/common_source/ctlinfo.c   Mon Mar 12 01:41:16 2018
(r330787)
@@ -292,8 +292,10 @@ ctl_readcf(const char *ptrname, const char *cfname)
msize = sroom2 + CTI_LINEMAX;
msize = roundup(msize, 8);
cstart = malloc(msize);
-   if (cstart == NULL)
+   if (cstart == NULL) {
+   fclose(cfile);
return NULL;
+   }
memset(cstart, 0, msize);
cpriv = (struct cjprivate *)cstart;
cpriv->pub.cji_priv = cpriv;
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r330785 - head/sys/arm/conf

2018-03-11 Thread Emmanuel Vadot
Author: manu
Date: Sun Mar 11 23:14:50 2018
New Revision: 330785
URL: https://svnweb.freebsd.org/changeset/base/330785

Log:
  arm: Remove SoC Specific -MMCCAM kernelconfig
  
  One should use the GENERIC-MMCCAM for this.

Deleted:
  head/sys/arm/conf/BEAGLEBONE-MMCCAM
  head/sys/arm/conf/IMX6-MMCCAM
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r330780 - in head/sys: amd64/include isa x86/isa

2018-03-11 Thread Konstantin Belousov
On Sun, Mar 11, 2018 at 02:20:39PM -0600, Ian Lepore wrote:
> On Sun, 2018-03-11 at 21:58 +0200, Konstantin Belousov wrote:
> > On Sun, Mar 11, 2018 at 07:22:58PM +, Ian Lepore wrote:
> > > 
> > > Author: ian
> > > Date: Sun Mar 11 19:22:58 2018
> > > New Revision: 330780
> > > URL: https://svnweb.freebsd.org/changeset/base/330780
> > > 
> > > Log:
> > >   Eliminate atrtc_time_lock, and use atrtc_lock for efirtc locking.
> > > 
> > > Modified:
> > >   head/sys/amd64/include/efi.h
> > >   head/sys/isa/rtc.h
> > >   head/sys/x86/isa/atrtc.c
> > > 
> > > Modified: head/sys/amd64/include/efi.h
> > > ==
> > > --- head/sys/amd64/include/efi.h  Sun Mar 11 19:14:01 2018
> > > (r330779)
> > > +++ head/sys/amd64/include/efi.h  Sun Mar 11 19:22:58 2018
> > > (r330780)
> > > @@ -48,9 +48,9 @@
> > >  #ifdef _KERNEL
> > >  #include 
> > >  
> > > -#define  EFI_TIME_LOCK() mtx_lock(_time_lock);
> > > -#define  EFI_TIME_UNLOCK()   mtx_unlock(_time_lock);
> > > -#define  EFI_TIME_OWNED()mtx_assert(_time_lock, MA_OWNED);
> > > +#define  EFI_TIME_LOCK() mtx_lock_spin(_lock);
> > > +#define  EFI_TIME_UNLOCK()   mtx_unlock_spin(_lock);
> > > +#define  EFI_TIME_OWNED()mtx_assert(_lock, MA_OWNED);
> > I do not understand how this can work. You changed EFI_TIME_LOCK() to
> > spinlock.  As result, the spinlock is taken before efi_enter() is called.
> > efi_enter() locks the pmap and efi_lock, both of which are sleepable
> > mutexes.  Also, arch efirt code is allowed to take arch-specific
> > sleepable mutexes and perhaps some spinlocks (but currently does not).
> > 
> > The first context switch when either of the listed sleepable mutexes
> > are contested and the thread is taken off CPU would panic.  I suspect
> > that some invariants check might fire earlier.
> > 
> 
> Oops, sure enough; I reverted it.
> 
> I think I knew that about efi_enter() at one time, but I had completely
> forgotten it did any locking.  I just realized my only efi-capable
> machine that I tested this on has virtually all debugging and witness
> disabled, so I didn't really give it much of a test after all.
> 
> Unfortunately, this reverts one type of wrong locking back to another.
>  The need is to prevent access to the atrtc hardware if efi is
> accessing it, and the locking I just reverted to that uses a sleepable
> mutex only protects against inittodr()/resettodr() access, but not
> against nvram(4) or if the atrtc is being used as an eventtimer (of
> course nobody uses it for that, but the driver supports it).
> 
> I have some pending changes that cause the atrtc driver to just not
> attach at all if the efirtc driver attached, but they're stacked up
> behind some other changes in phab.  And that still doesn't fix the
> nvram(4) part of it.
Not attaching atrtc if efirtc is attached sounds reasonable. But then
you should also disable efirt attach if atrtc is on. One possible issue
is that efirt is typicall loadable, while atrtc is compiled into the
kernel, which means that efirt would become virtually unusable.

For nvram(4), you can take the atrtc_time_lock around accesses in addition
to the atrtc_lock, instead of providing exclusivity on the level of drivers
attach.
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r330780 - in head/sys: amd64/include isa x86/isa

2018-03-11 Thread Ian Lepore
On Sun, 2018-03-11 at 21:58 +0200, Konstantin Belousov wrote:
> On Sun, Mar 11, 2018 at 07:22:58PM +, Ian Lepore wrote:
> > 
> > Author: ian
> > Date: Sun Mar 11 19:22:58 2018
> > New Revision: 330780
> > URL: https://svnweb.freebsd.org/changeset/base/330780
> > 
> > Log:
> >   Eliminate atrtc_time_lock, and use atrtc_lock for efirtc locking.
> > 
> > Modified:
> >   head/sys/amd64/include/efi.h
> >   head/sys/isa/rtc.h
> >   head/sys/x86/isa/atrtc.c
> > 
> > Modified: head/sys/amd64/include/efi.h
> > ==
> > --- head/sys/amd64/include/efi.hSun Mar 11 19:14:01 2018
> > (r330779)
> > +++ head/sys/amd64/include/efi.hSun Mar 11 19:22:58 2018
> > (r330780)
> > @@ -48,9 +48,9 @@
> >  #ifdef _KERNEL
> >  #include 
> >  
> > -#defineEFI_TIME_LOCK() mtx_lock(_time_lock);
> > -#defineEFI_TIME_UNLOCK()   mtx_unlock(_time_lock);
> > -#defineEFI_TIME_OWNED()mtx_assert(_time_lock, MA_OWNED);
> > +#defineEFI_TIME_LOCK() mtx_lock_spin(_lock);
> > +#defineEFI_TIME_UNLOCK()   mtx_unlock_spin(_lock);
> > +#defineEFI_TIME_OWNED()mtx_assert(_lock, MA_OWNED);
> I do not understand how this can work. You changed EFI_TIME_LOCK() to
> spinlock.  As result, the spinlock is taken before efi_enter() is called.
> efi_enter() locks the pmap and efi_lock, both of which are sleepable
> mutexes.  Also, arch efirt code is allowed to take arch-specific
> sleepable mutexes and perhaps some spinlocks (but currently does not).
> 
> The first context switch when either of the listed sleepable mutexes
> are contested and the thread is taken off CPU would panic.  I suspect
> that some invariants check might fire earlier.
> 

Oops, sure enough; I reverted it.

I think I knew that about efi_enter() at one time, but I had completely
forgotten it did any locking.  I just realized my only efi-capable
machine that I tested this on has virtually all debugging and witness
disabled, so I didn't really give it much of a test after all.

Unfortunately, this reverts one type of wrong locking back to another.
 The need is to prevent access to the atrtc hardware if efi is
accessing it, and the locking I just reverted to that uses a sleepable
mutex only protects against inittodr()/resettodr() access, but not
against nvram(4) or if the atrtc is being used as an eventtimer (of
course nobody uses it for that, but the driver supports it).

I have some pending changes that cause the atrtc driver to just not
attach at all if the efirtc driver attached, but they're stacked up
behind some other changes in phab.  And that still doesn't fix the
nvram(4) part of it.

-- Ian
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r330783 - in head/sys: amd64/include isa x86/isa

2018-03-11 Thread Ian Lepore
Author: ian
Date: Sun Mar 11 20:13:15 2018
New Revision: 330783
URL: https://svnweb.freebsd.org/changeset/base/330783

Log:
  Revert r330780, it was improperly tested and results in taking a spin
  mutex before acquiring sleep mutexes.
  
  Reported by:  kib@

Modified:
  head/sys/amd64/include/efi.h
  head/sys/isa/rtc.h
  head/sys/x86/isa/atrtc.c

Modified: head/sys/amd64/include/efi.h
==
--- head/sys/amd64/include/efi.hSun Mar 11 19:56:07 2018
(r330782)
+++ head/sys/amd64/include/efi.hSun Mar 11 20:13:15 2018
(r330783)
@@ -48,9 +48,9 @@
 #ifdef _KERNEL
 #include 
 
-#defineEFI_TIME_LOCK() mtx_lock_spin(_lock);
-#defineEFI_TIME_UNLOCK()   mtx_unlock_spin(_lock);
-#defineEFI_TIME_OWNED()mtx_assert(_lock, MA_OWNED);
+#defineEFI_TIME_LOCK() mtx_lock(_time_lock);
+#defineEFI_TIME_UNLOCK()   mtx_unlock(_time_lock);
+#defineEFI_TIME_OWNED()mtx_assert(_time_lock, MA_OWNED);
 #endif
 
 #endif /* __AMD64_INCLUDE_EFI_H_ */

Modified: head/sys/isa/rtc.h
==
--- head/sys/isa/rtc.h  Sun Mar 11 19:56:07 2018(r330782)
+++ head/sys/isa/rtc.h  Sun Mar 11 20:13:15 2018(r330783)
@@ -114,7 +114,7 @@
 #defineRTC_CENTURY 0x32/* current century */
 
 #ifdef _KERNEL
-extern  struct mtx atrtc_lock;
+extern  struct mtx atrtc_time_lock;
 extern int atrtcclock_disable;
 intrtcin(int reg);
 void   atrtc_restore(void);

Modified: head/sys/x86/isa/atrtc.c
==
--- head/sys/x86/isa/atrtc.cSun Mar 11 19:56:07 2018(r330782)
+++ head/sys/x86/isa/atrtc.cSun Mar 11 20:13:15 2018(r330783)
@@ -56,15 +56,16 @@ __FBSDID("$FreeBSD$");
 #include "clock_if.h"
 
 /*
- * atrtc_lock protects access to the RTC ioports, which are accessed by this
- * driver, the nvram(4) driver (via rtcin()/writertc() calls), and the rtc code
- * in efi runtime services.  The efirt wrapper code directly locks atrtc lock
- * using the EFI_TIME_LOCK/UNLOCK() macros which are defined to use this mutex
- * on x86 platforms.
+ * atrtc_lock protects low-level access to individual hardware registers.
+ * atrtc_time_lock protects the entire sequence of accessing multiple registers
+ * to read or write the date and time.
  */
-struct mtx atrtc_lock;
+static struct mtx atrtc_lock;
 MTX_SYSINIT(atrtc_lock_init, _lock, "atrtc", MTX_SPIN);
 
+struct mtx atrtc_time_lock;
+MTX_SYSINIT(atrtc_time_lock_init, _time_lock, "atrtc", MTX_DEF);
+
 intatrtcclock_disable = 0;
 
 static int rtc_reg = -1;
@@ -327,6 +328,7 @@ atrtc_settime(device_t dev __unused, struct timespec *
clock_ts_to_bcd(ts, , false);
clock_dbgprint_bcd(dev, CLOCK_DBG_WRITE, );
 
+   mtx_lock(_time_lock);
mtx_lock_spin(_lock);
 
/* Disable RTC updates and interrupts.  */
@@ -351,6 +353,7 @@ atrtc_settime(device_t dev __unused, struct timespec *
rtcin_locked(RTC_INTR);
 
mtx_unlock_spin(_lock);
+   mtx_unlock(_time_lock);
 
return (0);
 }
@@ -373,6 +376,7 @@ atrtc_gettime(device_t dev, struct timespec *ts)
 * to make sure that no more than 240us pass after we start reading,
 * and try again if so.
 */
+   mtx_lock(_time_lock);
while (rtcin(RTC_STATUSA) & RTCSA_TUP)
continue;
mtx_lock_spin(_lock);
@@ -386,6 +390,7 @@ atrtc_gettime(device_t dev, struct timespec *ts)
bct.year |= rtcin_locked(RTC_CENTURY) << 8;
 #endif
mtx_unlock_spin(_lock);
+   mtx_unlock(_time_lock);
/* dow is unused in timespec conversion and we have no nsec info. */
bct.dow  = 0;
bct.nsec = 0;
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r330782 - head/sys/x86/isa

2018-03-11 Thread Ian Lepore
On Sun, 2018-03-11 at 19:56 +, Ian Lepore wrote:
> Author: ian
> Date: Sun Mar 11 19:56:07 2018
> New Revision: 330782
> URL: https://svnweb.freebsd.org/changeset/base/330782
> 
> Log:
>   Remove MTX_NOPROFILE from atrtc_lock, it was inappropriately copy/pasted
>   from the i8254 driver when I created separate mutexes for each.  The i8254
>   driver could be the active timecounter, leading to recursion during mutex
>   profiling, but the atrtc driver cannot be a timecounter, so it isn't needed.
> 
> Modified:
>   head/sys/x86/isa/atrtc.c

Oops, should have included: Pointed out by: bde.

-- Ian
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r330780 - in head/sys: amd64/include isa x86/isa

2018-03-11 Thread Konstantin Belousov
On Sun, Mar 11, 2018 at 07:22:58PM +, Ian Lepore wrote:
> Author: ian
> Date: Sun Mar 11 19:22:58 2018
> New Revision: 330780
> URL: https://svnweb.freebsd.org/changeset/base/330780
> 
> Log:
>   Eliminate atrtc_time_lock, and use atrtc_lock for efirtc locking.
> 
> Modified:
>   head/sys/amd64/include/efi.h
>   head/sys/isa/rtc.h
>   head/sys/x86/isa/atrtc.c
> 
> Modified: head/sys/amd64/include/efi.h
> ==
> --- head/sys/amd64/include/efi.h  Sun Mar 11 19:14:01 2018
> (r330779)
> +++ head/sys/amd64/include/efi.h  Sun Mar 11 19:22:58 2018
> (r330780)
> @@ -48,9 +48,9 @@
>  #ifdef _KERNEL
>  #include 
>  
> -#define  EFI_TIME_LOCK() mtx_lock(_time_lock);
> -#define  EFI_TIME_UNLOCK()   mtx_unlock(_time_lock);
> -#define  EFI_TIME_OWNED()mtx_assert(_time_lock, MA_OWNED);
> +#define  EFI_TIME_LOCK() mtx_lock_spin(_lock);
> +#define  EFI_TIME_UNLOCK()   mtx_unlock_spin(_lock);
> +#define  EFI_TIME_OWNED()mtx_assert(_lock, MA_OWNED);

I do not understand how this can work. You changed EFI_TIME_LOCK() to
spinlock.  As result, the spinlock is taken before efi_enter() is called.
efi_enter() locks the pmap and efi_lock, both of which are sleepable
mutexes.  Also, arch efirt code is allowed to take arch-specific
sleepable mutexes and perhaps some spinlocks (but currently does not).

The first context switch when either of the listed sleepable mutexes
are contested and the thread is taken off CPU would panic.  I suspect
that some invariants check might fire earlier.
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r330782 - head/sys/x86/isa

2018-03-11 Thread Ian Lepore
Author: ian
Date: Sun Mar 11 19:56:07 2018
New Revision: 330782
URL: https://svnweb.freebsd.org/changeset/base/330782

Log:
  Remove MTX_NOPROFILE from atrtc_lock, it was inappropriately copy/pasted
  from the i8254 driver when I created separate mutexes for each.  The i8254
  driver could be the active timecounter, leading to recursion during mutex
  profiling, but the atrtc driver cannot be a timecounter, so it isn't needed.

Modified:
  head/sys/x86/isa/atrtc.c

Modified: head/sys/x86/isa/atrtc.c
==
--- head/sys/x86/isa/atrtc.cSun Mar 11 19:26:34 2018(r330781)
+++ head/sys/x86/isa/atrtc.cSun Mar 11 19:56:07 2018(r330782)
@@ -63,7 +63,7 @@ __FBSDID("$FreeBSD$");
  * on x86 platforms.
  */
 struct mtx atrtc_lock;
-MTX_SYSINIT(atrtc_lock_init, _lock, "atrtc", MTX_SPIN | MTX_NOPROFILE);
+MTX_SYSINIT(atrtc_lock_init, _lock, "atrtc", MTX_SPIN);
 
 intatrtcclock_disable = 0;
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r330781 - head/lib/libipsec

2018-03-11 Thread Andrey V. Elsukov
Author: ae
Date: Sun Mar 11 19:26:34 2018
New Revision: 330781
URL: https://svnweb.freebsd.org/changeset/base/330781

Log:
  Update pfkey_open() function to set socket's write buffer size to
  128k and receive buffer size to 2MB. In case if system has bigger
  default values, do not lower them.
  
  This should partially solve the problem, when setkey(8) returns
  EAGAIN error on systems with many SAs or SPs.
  
  PR:   88336
  Obtained from:NetBSD/ipsec-tools
  MFC after:2 weeks

Modified:
  head/lib/libipsec/pfkey.c

Modified: head/lib/libipsec/pfkey.c
==
--- head/lib/libipsec/pfkey.c   Sun Mar 11 19:22:58 2018(r330780)
+++ head/lib/libipsec/pfkey.c   Sun Mar 11 19:26:34 2018(r330781)
@@ -1595,10 +1595,12 @@ pfkey_send_x5(so, type, spid)
  * others : success and return value of socket.
  */
 int
-pfkey_open()
+pfkey_open(void)
 {
int so;
-   const int bufsiz = 128 * 1024;  /*is 128K enough?*/
+   int bufsiz_current, bufsiz_wanted;
+   int ret;
+   socklen_t len;
 
if ((so = socket(PF_KEY, SOCK_RAW, PF_KEY_V2)) < 0) {
__ipsec_set_strerror(strerror(errno));
@@ -1609,8 +1611,28 @@ pfkey_open()
 * This is a temporary workaround for KAME PR 154.
 * Don't really care even if it fails.
 */
-   (void)setsockopt(so, SOL_SOCKET, SO_SNDBUF, , sizeof(bufsiz));
-   (void)setsockopt(so, SOL_SOCKET, SO_RCVBUF, , sizeof(bufsiz));
+   /* Try to have 128k. If we have more, do not lower it. */
+   bufsiz_wanted = 128 * 1024;
+   len = sizeof(bufsiz_current);
+   ret = getsockopt(so, SOL_SOCKET, SO_SNDBUF,
+   _current, );
+   if ((ret < 0) || (bufsiz_current < bufsiz_wanted))
+   (void)setsockopt(so, SOL_SOCKET, SO_SNDBUF,
+   _wanted, sizeof(bufsiz_wanted));
+
+   /* Try to have have at least 2MB. If we have more, do not lower it. */
+   bufsiz_wanted = 2 * 1024 * 1024;
+   len = sizeof(bufsiz_current);
+   ret = getsockopt(so, SOL_SOCKET, SO_RCVBUF,
+   _current, );
+   if (ret < 0)
+   bufsiz_current = 128 * 1024;
+
+   for (; bufsiz_wanted > bufsiz_current; bufsiz_wanted /= 2) {
+   if (setsockopt(so, SOL_SOCKET, SO_RCVBUF,
+   _wanted, sizeof(bufsiz_wanted)) == 0)
+   break;
+   }
 
__ipsec_errcode = EIPSEC_NO_ERROR;
return so;
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r330780 - in head/sys: amd64/include isa x86/isa

2018-03-11 Thread Ian Lepore
Author: ian
Date: Sun Mar 11 19:22:58 2018
New Revision: 330780
URL: https://svnweb.freebsd.org/changeset/base/330780

Log:
  Eliminate atrtc_time_lock, and use atrtc_lock for efirtc locking.

Modified:
  head/sys/amd64/include/efi.h
  head/sys/isa/rtc.h
  head/sys/x86/isa/atrtc.c

Modified: head/sys/amd64/include/efi.h
==
--- head/sys/amd64/include/efi.hSun Mar 11 19:14:01 2018
(r330779)
+++ head/sys/amd64/include/efi.hSun Mar 11 19:22:58 2018
(r330780)
@@ -48,9 +48,9 @@
 #ifdef _KERNEL
 #include 
 
-#defineEFI_TIME_LOCK() mtx_lock(_time_lock);
-#defineEFI_TIME_UNLOCK()   mtx_unlock(_time_lock);
-#defineEFI_TIME_OWNED()mtx_assert(_time_lock, MA_OWNED);
+#defineEFI_TIME_LOCK() mtx_lock_spin(_lock);
+#defineEFI_TIME_UNLOCK()   mtx_unlock_spin(_lock);
+#defineEFI_TIME_OWNED()mtx_assert(_lock, MA_OWNED);
 #endif
 
 #endif /* __AMD64_INCLUDE_EFI_H_ */

Modified: head/sys/isa/rtc.h
==
--- head/sys/isa/rtc.h  Sun Mar 11 19:14:01 2018(r330779)
+++ head/sys/isa/rtc.h  Sun Mar 11 19:22:58 2018(r330780)
@@ -114,7 +114,7 @@
 #defineRTC_CENTURY 0x32/* current century */
 
 #ifdef _KERNEL
-extern  struct mtx atrtc_time_lock;
+extern  struct mtx atrtc_lock;
 extern int atrtcclock_disable;
 intrtcin(int reg);
 void   atrtc_restore(void);

Modified: head/sys/x86/isa/atrtc.c
==
--- head/sys/x86/isa/atrtc.cSun Mar 11 19:14:01 2018(r330779)
+++ head/sys/x86/isa/atrtc.cSun Mar 11 19:22:58 2018(r330780)
@@ -56,16 +56,15 @@ __FBSDID("$FreeBSD$");
 #include "clock_if.h"
 
 /*
- * atrtc_lock protects low-level access to individual hardware registers.
- * atrtc_time_lock protects the entire sequence of accessing multiple registers
- * to read or write the date and time.
+ * atrtc_lock protects access to the RTC ioports, which are accessed by this
+ * driver, the nvram(4) driver (via rtcin()/writertc() calls), and the rtc code
+ * in efi runtime services.  The efirt wrapper code directly locks atrtc lock
+ * using the EFI_TIME_LOCK/UNLOCK() macros which are defined to use this mutex
+ * on x86 platforms.
  */
-static struct mtx atrtc_lock;
+struct mtx atrtc_lock;
 MTX_SYSINIT(atrtc_lock_init, _lock, "atrtc", MTX_SPIN | MTX_NOPROFILE);
 
-struct mtx atrtc_time_lock;
-MTX_SYSINIT(atrtc_time_lock_init, _time_lock, "atrtc", MTX_DEF);
-
 intatrtcclock_disable = 0;
 
 static int rtc_reg = -1;
@@ -328,7 +327,6 @@ atrtc_settime(device_t dev __unused, struct timespec *
clock_ts_to_bcd(ts, , false);
clock_dbgprint_bcd(dev, CLOCK_DBG_WRITE, );
 
-   mtx_lock(_time_lock);
mtx_lock_spin(_lock);
 
/* Disable RTC updates and interrupts.  */
@@ -353,7 +351,6 @@ atrtc_settime(device_t dev __unused, struct timespec *
rtcin_locked(RTC_INTR);
 
mtx_unlock_spin(_lock);
-   mtx_unlock(_time_lock);
 
return (0);
 }
@@ -376,7 +373,6 @@ atrtc_gettime(device_t dev, struct timespec *ts)
 * to make sure that no more than 240us pass after we start reading,
 * and try again if so.
 */
-   mtx_lock(_time_lock);
while (rtcin(RTC_STATUSA) & RTCSA_TUP)
continue;
mtx_lock_spin(_lock);
@@ -390,7 +386,6 @@ atrtc_gettime(device_t dev, struct timespec *ts)
bct.year |= rtcin_locked(RTC_CENTURY) << 8;
 #endif
mtx_unlock_spin(_lock);
-   mtx_unlock(_time_lock);
/* dow is unused in timespec conversion and we have no nsec info. */
bct.dow  = 0;
bct.nsec = 0;
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r330779 - head/sys/netipsec

2018-03-11 Thread Andrey V. Elsukov
Author: ae
Date: Sun Mar 11 19:14:01 2018
New Revision: 330779
URL: https://svnweb.freebsd.org/changeset/base/330779

Log:
  Rework key_sendup_mbuf() a bit:
  
  o count in_nomem counter when we have failed to allocate mbuf for
promisc socket;
  o count in_msgtarget counter when we have secussfully sent data to socket;
  o Since we are sending messages in a loop, returning error on first fail
interrupts the loop, and all remaining sockets will not receive this
message. So, do not return error when we have failed to send data to ALL
or REGISTERED target. Return error only for KEY_SENDUP_ONE case. Now,
when some socket has overfilled its receive buffer, this will not break
other sockets.
  
  MFC after:2 weeks

Modified:
  head/sys/netipsec/keysock.c

Modified: head/sys/netipsec/keysock.c
==
--- head/sys/netipsec/keysock.c Sun Mar 11 18:54:45 2018(r330778)
+++ head/sys/netipsec/keysock.c Sun Mar 11 19:14:01 2018(r330779)
@@ -178,7 +178,6 @@ key_sendup_mbuf(struct socket *so, struct mbuf *m, int
 {
struct mbuf *n;
struct keycb *kp;
-   int sendup;
struct rawcb *rp;
int error = 0;
 
@@ -217,69 +216,50 @@ key_sendup_mbuf(struct socket *so, struct mbuf *m, int
continue;
}
 
-   kp = (struct keycb *)rp;
-
/*
 * If you are in promiscuous mode, and when you get broadcasted
 * reply, you'll get two PF_KEY messages.
 * (based on pf_...@inner.net message on 14 Oct 1998)
 */
-   if (((struct keycb *)rp)->kp_promisc) {
-   if ((n = m_copym(m, 0, M_COPYALL, M_NOWAIT)) != NULL) {
-   (void)key_sendup0(rp, n, 1);
-   n = NULL;
-   }
+   kp = (struct keycb *)rp;
+   if (kp->kp_promisc) {
+   n = m_copym(m, 0, M_COPYALL, M_NOWAIT);
+   if (n != NULL)
+   key_sendup0(rp, n, 1);
+   else
+   PFKEYSTAT_INC(in_nomem);
}
 
/* the exact target will be processed later */
if (so && sotorawcb(so) == rp)
continue;
 
-   sendup = 0;
-   switch (target) {
-   case KEY_SENDUP_ONE:
-   /* the statement has no effect */
-   if (so && sotorawcb(so) == rp)
-   sendup++;
-   break;
-   case KEY_SENDUP_ALL:
-   sendup++;
-   break;
-   case KEY_SENDUP_REGISTERED:
-   if (kp->kp_registered)
-   sendup++;
-   break;
-   }
-   PFKEYSTAT_INC(in_msgtarget[target]);
-
-   if (!sendup)
+   if (target == KEY_SENDUP_ONE || (
+   target == KEY_SENDUP_REGISTERED && kp->kp_registered == 0))
continue;
 
-   if ((n = m_copym(m, 0, M_COPYALL, M_NOWAIT)) == NULL) {
-   m_freem(m);
+   /* KEY_SENDUP_ALL + KEY_SENDUP_REGISTERED */
+   n = m_copym(m, 0, M_COPYALL, M_NOWAIT);
+   if (n == NULL) {
PFKEYSTAT_INC(in_nomem);
-   mtx_unlock(_mtx);
-   return ENOBUFS;
+   /* Try send to another socket */
+   continue;
}
 
-   if ((error = key_sendup0(rp, n, 0)) != 0) {
-   m_freem(m);
-   mtx_unlock(_mtx);
-   return error;
-   }
-
-   n = NULL;
+   if (key_sendup0(rp, n, 0) == 0)
+   PFKEYSTAT_INC(in_msgtarget[target]);
}
 
-   if (so) {
+   if (so) { /* KEY_SENDUP_ONE */
error = key_sendup0(sotorawcb(so), m, 0);
-   m = NULL;
+   if (error == 0)
+   PFKEYSTAT_INC(in_msgtarget[KEY_SENDUP_ONE]);
} else {
error = 0;
m_freem(m);
}
mtx_unlock(_mtx);
-   return error;
+   return (error);
 }
 
 /*
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r330778 - head/sys/x86/isa

2018-03-11 Thread Ian Lepore
Author: ian
Date: Sun Mar 11 18:54:45 2018
New Revision: 330778
URL: https://svnweb.freebsd.org/changeset/base/330778

Log:
  Everywhere that multiple registers are accessed in sequence, lock/unlock
  just once around the whole group of accesses.

Modified:
  head/sys/x86/isa/atrtc.c

Modified: head/sys/x86/isa/atrtc.c
==
--- head/sys/x86/isa/atrtc.cSun Mar 11 18:46:40 2018(r330777)
+++ head/sys/x86/isa/atrtc.cSun Mar 11 18:54:45 2018(r330778)
@@ -127,8 +127,10 @@ static void
 atrtc_start(void)
 {
 
-   writertc(RTC_STATUSA, rtc_statusa);
-   writertc(RTC_STATUSB, RTCSB_24HR);
+   mtx_lock_spin(_lock);
+   rtcout_locked(RTC_STATUSA, rtc_statusa);
+   rtcout_locked(RTC_STATUSB, RTCSB_24HR);
+   mtx_unlock_spin(_lock);
 }
 
 static void
@@ -144,8 +146,10 @@ atrtc_enable_intr(void)
 {
 
rtc_statusb |= RTCSB_PINTR;
-   writertc(RTC_STATUSB, rtc_statusb);
-   rtcin(RTC_INTR);
+   mtx_lock_spin(_lock);
+   rtcout_locked(RTC_STATUSB, rtc_statusb);
+   rtcin_locked(RTC_INTR);
+   mtx_unlock_spin(_lock);
 }
 
 static void
@@ -153,8 +157,10 @@ atrtc_disable_intr(void)
 {
 
rtc_statusb &= ~RTCSB_PINTR;
-   writertc(RTC_STATUSB, rtc_statusb);
-   rtcin(RTC_INTR);
+   mtx_lock_spin(_lock);
+   rtcout_locked(RTC_STATUSB, rtc_statusb);
+   rtcin_locked(RTC_INTR);
+   mtx_unlock_spin(_lock);
 }
 
 void
@@ -162,11 +168,13 @@ atrtc_restore(void)
 {
 
/* Restore all of the RTC's "status" (actually, control) registers. */
-   rtcin(RTC_STATUSA); /* dummy to get rtc_reg set */
-   writertc(RTC_STATUSB, RTCSB_24HR);
-   writertc(RTC_STATUSA, rtc_statusa);
-   writertc(RTC_STATUSB, rtc_statusb);
-   rtcin(RTC_INTR);
+   mtx_lock_spin(_lock);
+   rtcin_locked(RTC_STATUSA);  /* dummy to get rtc_reg set */
+   rtcout_locked(RTC_STATUSB, RTCSB_24HR);
+   rtcout_locked(RTC_STATUSA, rtc_statusa);
+   rtcout_locked(RTC_STATUSB, rtc_statusb);
+   rtcin_locked(RTC_INTR);
+   mtx_unlock_spin(_lock);
 }
 
 /**
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r330777 - head/sys/netipsec

2018-03-11 Thread Andrey V. Elsukov
Author: ae
Date: Sun Mar 11 18:46:40 2018
New Revision: 330777
URL: https://svnweb.freebsd.org/changeset/base/330777

Log:
  Add KASSERT to check that proper targed was used.
  
  MFC after:2 weeks

Modified:
  head/sys/netipsec/keysock.c

Modified: head/sys/netipsec/keysock.c
==
--- head/sys/netipsec/keysock.c Sun Mar 11 18:43:36 2018(r330776)
+++ head/sys/netipsec/keysock.c Sun Mar 11 18:46:40 2018(r330777)
@@ -185,6 +185,8 @@ key_sendup_mbuf(struct socket *so, struct mbuf *m, int
KASSERT(m != NULL, ("NULL mbuf pointer was passed."));
KASSERT(so != NULL || target != KEY_SENDUP_ONE,
("NULL socket pointer was passed."));
+   KASSERT(target == KEY_SENDUP_ONE || target == KEY_SENDUP_ALL ||
+   target == KEY_SENDUP_REGISTERED, ("Wrong target %d", target));
 
PFKEYSTAT_INC(in_total);
PFKEYSTAT_ADD(in_bytes, m->m_pkthdr.len);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r330775 - head/sys/netipsec

2018-03-11 Thread Andrey V. Elsukov
Author: ae
Date: Sun Mar 11 18:37:55 2018
New Revision: 330775
URL: https://svnweb.freebsd.org/changeset/base/330775

Log:
  Replace panic() with KASSERTs.
  
  MFC after:2 weeks

Modified:
  head/sys/netipsec/keysock.c

Modified: head/sys/netipsec/keysock.c
==
--- head/sys/netipsec/keysock.c Sun Mar 11 18:31:21 2018(r330774)
+++ head/sys/netipsec/keysock.c Sun Mar 11 18:37:55 2018(r330775)
@@ -182,10 +182,9 @@ key_sendup_mbuf(struct socket *so, struct mbuf *m, int
struct rawcb *rp;
int error = 0;
 
-   if (m == NULL)
-   panic("key_sendup_mbuf: NULL pointer was passed.\n");
-   if (so == NULL && target == KEY_SENDUP_ONE)
-   panic("%s: NULL pointer was passed.\n", __func__);
+   KASSERT(m != NULL, ("NULL mbuf pointer was passed."));
+   KASSERT(so != NULL || target != KEY_SENDUP_ONE,
+   ("NULL socket pointer was passed."));
 
PFKEYSTAT_INC(in_total);
PFKEYSTAT_ADD(in_bytes, m->m_pkthdr.len);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r330773 - in head/sys: isa x86/isa

2018-03-11 Thread Ian Lepore
Author: ian
Date: Sun Mar 11 18:20:49 2018
New Revision: 330773
URL: https://svnweb.freebsd.org/changeset/base/330773

Log:
  Use separate mutexes for atrtc and i8254 locking.  Change all the strange
  un-function-like RTC_LOCK/UNLOCK macro usage into normal function calls.
  Since there is no longer any need to handle register access from a debugger
  context, those function calls can just be regular mutex lock/unlock calls.
  
  Requested by:  bde

Modified:
  head/sys/isa/rtc.h
  head/sys/x86/isa/atrtc.c
  head/sys/x86/isa/clock.c

Modified: head/sys/isa/rtc.h
==
--- head/sys/isa/rtc.h  Sun Mar 11 18:10:59 2018(r330772)
+++ head/sys/isa/rtc.h  Sun Mar 11 18:20:49 2018(r330773)
@@ -114,7 +114,6 @@
 #defineRTC_CENTURY 0x32/* current century */
 
 #ifdef _KERNEL
-extern  struct mtx clock_lock;
 extern  struct mtx atrtc_time_lock;
 extern int atrtcclock_disable;
 intrtcin(int reg);

Modified: head/sys/x86/isa/atrtc.c
==
--- head/sys/x86/isa/atrtc.cSun Mar 11 18:10:59 2018(r330772)
+++ head/sys/x86/isa/atrtc.cSun Mar 11 18:20:49 2018(r330773)
@@ -56,15 +56,15 @@ __FBSDID("$FreeBSD$");
 #include "clock_if.h"
 
 /*
- * clock_lock protects low-level access to individual hardware registers.
+ * atrtc_lock protects low-level access to individual hardware registers.
  * atrtc_time_lock protects the entire sequence of accessing multiple registers
  * to read or write the date and time.
  */
-#defineRTC_LOCKdo { if (!kdb_active) 
mtx_lock_spin(_lock); } while (0)
-#defineRTC_UNLOCK  do { if (!kdb_active) 
mtx_unlock_spin(_lock); } while (0)
+static struct mtx atrtc_lock;
+MTX_SYSINIT(atrtc_lock_init, _lock, "atrtc", MTX_SPIN | MTX_NOPROFILE);
 
 struct mtx atrtc_time_lock;
-MTX_SYSINIT(atrtc_lock_init, _time_lock, "atrtc", MTX_DEF);
+MTX_SYSINIT(atrtc_time_lock_init, _time_lock, "atrtc", MTX_DEF);
 
 intatrtcclock_disable = 0;
 
@@ -108,9 +108,9 @@ rtcin(int reg)
 {
u_char val;
 
-   RTC_LOCK;
+   mtx_lock_spin(_lock);
val = rtcin_locked(reg);
-   RTC_UNLOCK;
+   mtx_unlock_spin(_lock);
return (val);
 }
 
@@ -118,9 +118,9 @@ void
 writertc(int reg, u_char val)
 {
 
-   RTC_LOCK;
+   mtx_lock_spin(_lock);
rtcout_locked(reg, val);
-   RTC_UNLOCK;
+   mtx_unlock_spin(_lock);
 }
 
 static void
@@ -321,7 +321,7 @@ atrtc_settime(device_t dev __unused, struct timespec *
clock_dbgprint_bcd(dev, CLOCK_DBG_WRITE, );
 
mtx_lock(_time_lock);
-   RTC_LOCK;
+   mtx_lock_spin(_lock);
 
/* Disable RTC updates and interrupts.  */
rtcout_locked(RTC_STATUSB, RTCSB_HALT | RTCSB_24HR);
@@ -344,7 +344,7 @@ atrtc_settime(device_t dev __unused, struct timespec *
rtcout_locked(RTC_STATUSB, rtc_statusb);
rtcin_locked(RTC_INTR);
 
-   RTC_UNLOCK;
+   mtx_unlock_spin(_lock);
mtx_unlock(_time_lock);
 
return (0);
@@ -371,7 +371,7 @@ atrtc_gettime(device_t dev, struct timespec *ts)
mtx_lock(_time_lock);
while (rtcin(RTC_STATUSA) & RTCSA_TUP)
continue;
-   RTC_LOCK;
+   mtx_lock_spin(_lock);
bct.sec  = rtcin_locked(RTC_SEC);
bct.min  = rtcin_locked(RTC_MIN);
bct.hour = rtcin_locked(RTC_HRS);
@@ -381,7 +381,7 @@ atrtc_gettime(device_t dev, struct timespec *ts)
 #ifdef USE_RTC_CENTURY
bct.year |= rtcin_locked(RTC_CENTURY) << 8;
 #endif
-   RTC_UNLOCK;
+   mtx_unlock_spin(_lock);
mtx_unlock(_time_lock);
/* dow is unused in timespec conversion and we have no nsec info. */
bct.dow  = 0;

Modified: head/sys/x86/isa/clock.c
==
--- head/sys/x86/isa/clock.cSun Mar 11 18:10:59 2018(r330772)
+++ head/sys/x86/isa/clock.cSun Mar 11 18:20:49 2018(r330773)
@@ -83,7 +83,7 @@ TUNABLE_INT("hw.i8254.freq", _freq);
 inti8254_max_count;
 static int i8254_timecounter = 1;
 
-struct mtx clock_lock;
+static struct mtx clock_lock;
 static struct intsrc *i8254_intsrc;
 static uint16_t i8254_lastcount;
 static uint16_t i8254_offset;
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r330772 - head/sys/netipsec

2018-03-11 Thread Andrey V. Elsukov
Author: ae
Date: Sun Mar 11 18:10:59 2018
New Revision: 330772
URL: https://svnweb.freebsd.org/changeset/base/330772

Log:
  Check that we have PF_KEY sockets before iterating over all RAW sockets.
  
  MFC after:2 weeks

Modified:
  head/sys/netipsec/keysock.c

Modified: head/sys/netipsec/keysock.c
==
--- head/sys/netipsec/keysock.c Sun Mar 11 18:03:55 2018(r330771)
+++ head/sys/netipsec/keysock.c Sun Mar 11 18:10:59 2018(r330772)
@@ -202,6 +202,11 @@ key_sendup_mbuf(struct socket *so, struct mbuf *m, int
PFKEYSTAT_INC(in_msgtype[msg->sadb_msg_type]);
}
mtx_lock(_mtx);
+   if (V_key_cb.any_count == 0) {
+   mtx_unlock(_mtx);
+   m_freem(m);
+   return (0);
+   }
LIST_FOREACH(rp, _rawcb_list, list)
{
if (rp->rcb_proto.sp_family != PF_KEY)
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r330771 - head/sys/netipsec

2018-03-11 Thread Andrey V. Elsukov
Author: ae
Date: Sun Mar 11 18:03:55 2018
New Revision: 330771
URL: https://svnweb.freebsd.org/changeset/base/330771

Log:
  Remove obsoleted and unused key_sendup() function.
  Also remove declaration for nonexistend key_usrreq() function.
  
  MFC after:2 weeks

Modified:
  head/sys/netipsec/keysock.c
  head/sys/netipsec/keysock.h

Modified: head/sys/netipsec/keysock.c
==
--- head/sys/netipsec/keysock.c Sun Mar 11 17:43:04 2018(r330770)
+++ head/sys/netipsec/keysock.c Sun Mar 11 18:03:55 2018(r330771)
@@ -172,90 +172,6 @@ key_sendup0(struct rawcb *rp, struct mbuf *m, int prom
return error;
 }
 
-/* XXX this interface should be obsoleted. */
-int
-key_sendup(struct socket *so, struct sadb_msg *msg, u_int len, int target)
-{
-   struct mbuf *m, *n, *mprev;
-   int tlen;
-
-   /* sanity check */
-   if (so == NULL || msg == NULL)
-   panic("%s: NULL pointer was passed.\n", __func__);
-
-   KEYDBG(KEY_DUMP,
-   printf("%s: \n", __func__);
-   kdebug_sadb(msg));
-
-   /*
-* we increment statistics here, just in case we have ENOBUFS
-* in this function.
-*/
-   PFKEYSTAT_INC(in_total);
-   PFKEYSTAT_ADD(in_bytes, len);
-   PFKEYSTAT_INC(in_msgtype[msg->sadb_msg_type]);
-
-   /*
-* Get mbuf chain whenever possible (not clusters),
-* to save socket buffer.  We'll be generating many SADB_ACQUIRE
-* messages to listening key sockets.  If we simply allocate clusters,
-* sbappendaddr() will raise ENOBUFS due to too little sbspace().
-* sbspace() computes # of actual data bytes AND mbuf region.
-*
-* TODO: SADB_ACQUIRE filters should be implemented.
-*/
-   tlen = len;
-   m = mprev = NULL;
-   while (tlen > 0) {
-   if (tlen == len) {
-   MGETHDR(n, M_NOWAIT, MT_DATA);
-   if (n == NULL) {
-   PFKEYSTAT_INC(in_nomem);
-   return ENOBUFS;
-   }
-   n->m_len = MHLEN;
-   } else {
-   MGET(n, M_NOWAIT, MT_DATA);
-   if (n == NULL) {
-   PFKEYSTAT_INC(in_nomem);
-   return ENOBUFS;
-   }
-   n->m_len = MLEN;
-   }
-   if (tlen >= MCLBYTES) { /*XXX better threshold? */
-   if (!(MCLGET(n, M_NOWAIT))) {
-   m_free(n);
-   m_freem(m);
-   PFKEYSTAT_INC(in_nomem);
-   return ENOBUFS;
-   }
-   n->m_len = MCLBYTES;
-   }
-
-   if (tlen < n->m_len)
-   n->m_len = tlen;
-   n->m_next = NULL;
-   if (m == NULL)
-   m = mprev = n;
-   else {
-   mprev->m_next = n;
-   mprev = n;
-   }
-   tlen -= n->m_len;
-   n = NULL;
-   }
-   m->m_pkthdr.len = len;
-   m->m_pkthdr.rcvif = NULL;
-   m_copyback(m, 0, len, (caddr_t)msg);
-
-   /* avoid duplicated statistics */
-   PFKEYSTAT_ADD(in_total, -1);
-   PFKEYSTAT_ADD(in_bytes, -len);
-   PFKEYSTAT_ADD(in_msgtype[msg->sadb_msg_type], -1);
-
-   return key_sendup_mbuf(so, m, target);
-}
-
 /* so can be NULL if target != KEY_SENDUP_ONE */
 int
 key_sendup_mbuf(struct socket *so, struct mbuf *m, int target)

Modified: head/sys/netipsec/keysock.h
==
--- head/sys/netipsec/keysock.h Sun Mar 11 17:43:04 2018(r330770)
+++ head/sys/netipsec/keysock.h Sun Mar 11 18:03:55 2018(r330771)
@@ -78,12 +78,8 @@ VNET_PCPUSTAT_DECLARE(struct pfkeystat, pfkeystat);
 VNET_PCPUSTAT_ADD(struct pfkeystat, pfkeystat, name, (val))
 #definePFKEYSTAT_INC(name) PFKEYSTAT_ADD(name, 1)
 
-extern int key_output(struct mbuf *m, struct socket *so, ...);
-extern int key_usrreq(struct socket *, int, struct mbuf *,
-struct mbuf *, struct mbuf *);
-
-extern int key_sendup(struct socket *, struct sadb_msg *, u_int, int);
-extern int key_sendup_mbuf(struct socket *, struct mbuf *, int);
+int key_output(struct mbuf *m, struct socket *so, ...);
+int key_sendup_mbuf(struct socket *, struct mbuf *, int);
 #endif /* _KERNEL */
 
 #endif /*_NETIPSEC_KEYSOCK_H_*/
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r330768 - head/usr.bin/calendar/calendars

2018-03-11 Thread Fernando Apesteguía
Author: fernape (ports committer)
Date: Sun Mar 11 17:21:48 2018
New Revision: 330768
URL: https://svnweb.freebsd.org/changeset/base/330768

Log:
  Add myself (fernape) to calendar.freebsd
  
  As indicated in Committers guide Chapter 6, point 9
  "Optional: Update Ports with Personal Information"
  
  Approved by:  tcberner
  Differential Revision:https://reviews.freebsd.org/D14653

Modified:
  head/usr.bin/calendar/calendars/calendar.freebsd

Modified: head/usr.bin/calendar/calendars/calendar.freebsd
==
--- head/usr.bin/calendar/calendars/calendar.freebsdSun Mar 11 16:57:14 
2018(r330767)
+++ head/usr.bin/calendar/calendars/calendar.freebsdSun Mar 11 17:21:48 
2018(r330768)
@@ -266,6 +266,7 @@
 07/10  David Schultz  born in Oakland, California, United 
States, 1982
 07/10  Ben Woods  born in Perth, Western Australia, 
Australia, 1984
 07/11  Jesus R. Camou  born in Hermosillo, Sonora, Mexico, 
1983
+07/14  Fernando Apesteguia  born in Madrid, Spain, 1981
 07/15  Gary Jennejohn  born in Rochester, New York, United 
States, 1950
 07/16  Suleiman Souhlal  born in Roma, Italy, 1983
 07/16  Davide Italiano  born in Milazzo, Italy, 1989
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r330767 - head/sys/x86/isa

2018-03-11 Thread Ian Lepore
Author: ian
Date: Sun Mar 11 16:57:14 2018
New Revision: 330767
URL: https://svnweb.freebsd.org/changeset/base/330767

Log:
  Convert atrtc the new style rtc debugging output.  Remove the db show
  command handler which provided much the same information.  Removing the
  possibility of accessing the hardware regs from the debugger context
  paves the way for simplifying the locking code in the driver.

Modified:
  head/sys/x86/isa/atrtc.c

Modified: head/sys/x86/isa/atrtc.c
==
--- head/sys/x86/isa/atrtc.cSun Mar 11 16:17:53 2018(r330766)
+++ head/sys/x86/isa/atrtc.cSun Mar 11 16:57:14 2018(r330767)
@@ -318,6 +318,7 @@ atrtc_settime(device_t dev __unused, struct timespec *
struct bcd_clocktime bct;
 
clock_ts_to_bcd(ts, , false);
+   clock_dbgprint_bcd(dev, CLOCK_DBG_WRITE, );
 
mtx_lock(_time_lock);
RTC_LOCK;
@@ -385,6 +386,7 @@ atrtc_gettime(device_t dev, struct timespec *ts)
/* dow is unused in timespec conversion and we have no nsec info. */
bct.dow  = 0;
bct.nsec = 0;
+   clock_dbgprint_bcd(dev, CLOCK_DBG_READ, );
return (clock_bcd_to_ts(, ts, false));
 }
 
@@ -416,16 +418,3 @@ static devclass_t atrtc_devclass;
 DRIVER_MODULE(atrtc, isa, atrtc_driver, atrtc_devclass, 0, 0);
 DRIVER_MODULE(atrtc, acpi, atrtc_driver, atrtc_devclass, 0, 0);
 ISA_PNP_INFO(atrtc_ids);
-
-#include "opt_ddb.h"
-#ifdef DDB
-#include 
-
-DB_SHOW_COMMAND(rtc, rtc)
-{
-   printf("%02x/%02x/%02x %02x:%02x:%02x, A = %02x, B = %02x, C = %02x\n",
-   rtcin(RTC_YEAR), rtcin(RTC_MONTH), rtcin(RTC_DAY),
-   rtcin(RTC_HRS), rtcin(RTC_MIN), rtcin(RTC_SEC),
-   rtcin(RTC_STATUSA), rtcin(RTC_STATUSB), rtcin(RTC_INTR));
-}
-#endif /* DDB */
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r330766 - head/sys/i386/include

2018-03-11 Thread Brooks Davis
Author: brooks
Date: Sun Mar 11 16:17:53 2018
New Revision: 330766
URL: https://svnweb.freebsd.org/changeset/base/330766

Log:
  Remove obsolete pcaudioio.h.
  
  Nothing uses the #define's values or the types.  (Some NTP code does use
  an audio_info_t, but it is in #ifdef'd support for Solaris and is not
  this audio_info_t).
  
  Sponsored by: DARPA, AFRL

Deleted:
  head/sys/i386/include/pcaudioio.h
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r330765 - head/share/misc

2018-03-11 Thread Fernando Apesteguía
Author: fernape (ports committer)
Date: Sun Mar 11 10:47:40 2018
New Revision: 330765
URL: https://svnweb.freebsd.org/changeset/base/330765

Log:
  Add myself (fernape) to commiters-port.dot
  
  Approved by:  tcberner (mentor)
  Differential Revision:https://reviews.freebsd.org/D14639

Modified:
  head/share/misc/committers-ports.dot

Modified: head/share/misc/committers-ports.dot
==
--- head/share/misc/committers-ports.dotSun Mar 11 08:27:11 2018
(r330764)
+++ head/share/misc/committers-ports.dotSun Mar 11 10:47:40 2018
(r330765)
@@ -103,6 +103,7 @@ erwin [label="Erwin Lansing\ner...@freebsd.org\n2003/0
 eugen [label="Eugene Grosbein\neu...@freebsd.org\n2017/03/04"]
 farrokhi [label="Babak Farrokhi\nfarro...@freebsd.org\n2006/11/07"]
 feld [label="Mark Felder\nf...@freebsd.org\n2013/06/25"]
+fernape [label="Fernando Apesteguia\nfern...@freebsd.org\n2018/03/03"]
 fjoe [label="Max Khon\nf...@freebsd.org\n2001/08/06"]
 flo [label="Florian Smeets\n...@freebsd.org\n2010/12/07"]
 fluffy [label="Dima Panov\nflu...@freebsd.org\n2009/08/10"]
@@ -663,6 +664,7 @@ tabthorpe -> gblach
 tcberner -> adridg
 tcberner -> joneum
 tcberner -> yuri
+tcberner -> fernape
 
 thierry -> jadawin
 thierry -> riggs
@@ -671,6 +673,7 @@ tmclaugh -> itetcu
 tmclaugh -> xride
 
 tz -> joneum
+tz -> fernape
 
 vsevolod -> eugen
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r330745 - head/sys/kern

2018-03-11 Thread Bruce Evans

On Sat, 10 Mar 2018, Ian Lepore wrote:


Author: ian
...
Log:
 Make root mount timeout logic work for filesystems other than ufs.
...
 These changes are based on the patch attached to the PR, but it's rewritten
 enough that all mistakes belong to me.

 PR:208882
 X-MFC after:   sufficient testing, and hopefully in time for 11.1


This clones overflow bug, and I just noticed that the existing delays
are misplaced too.


Modified: head/sys/kern/vfs_mountroot.c
==
--- head/sys/kern/vfs_mountroot.c   Sat Mar 10 20:46:36 2018
(r330744)
+++ head/sys/kern/vfs_mountroot.c   Sat Mar 10 22:07:57 2018
(r330745)
@@ -755,15 +755,31 @@ parse_mount(char **conf)
if (error != 0)
goto out;

-   ma = NULL;
-   ma = mount_arg(ma, "fstype", fs, -1);
-   ma = mount_arg(ma, "fspath", "/", -1);
-   ma = mount_arg(ma, "from", dev, -1);
-   ma = mount_arg(ma, "errmsg", errmsg, ERRMSGL);
-   ma = mount_arg(ma, "ro", NULL, 0);
-   ma = parse_mountroot_options(ma, opts);
-   error = kernel_mount(ma, MNT_ROOTFS);
+   delay = hz / 10;
+   timeout = root_mount_timeout * hz;


Old bugs cloned from vfs_mountroot_wait_if_necessary():
- when hz < 10, delay is 0 which means infinity for pause(), and also for
  the loop
- when hz >= 10 but is not a multiple of 10, there is a minor inaccuracy
- when hz is "infinity" or just large, root_mount_timeout * hz overflows.
These bugs can be fixed using sbt_pause().



+   for (;;) {
+   ma = NULL;
+   ma = mount_arg(ma, "fstype", fs, -1);
+   ma = mount_arg(ma, "fspath", "/", -1);
+   ma = mount_arg(ma, "from", dev, -1);
+   ma = mount_arg(ma, "errmsg", errmsg, ERRMSGL);
+   ma = mount_arg(ma, "ro", NULL, 0);
+   ma = parse_mountroot_options(ma, opts);
+
+   error = kernel_mount(ma, MNT_ROOTFS);
+   if (error == 0 || timeout <= 0)
+   break;
+
+   if (root_mount_timeout * hz == timeout ||
+   (bootverbose && timeout % hz == 0)) {
+   printf("Mounting from %s:%s failed with error %d; "
+   "retrying for %d more second%s\n", fs, dev, error,
+   timeout / hz, (timeout / hz > 1) ? "s" : "");
+   }
+   pause("rmretry", delay);
+   timeout -= delay;
+   }
 out:
if (error) {
printf("Mounting from %s:%s failed with error %d",


Misplaced delays: the order is to try each device in vfs.root.mountfrom
in the outer loop with delays in the inner loop, but should be to try
each device in the inner loop with delays in the outer loop.

I use a generic vfs.root.mountfrom with entries for many different FreeBSD
versions and target systems.  Renaming and renumbering devices causes
problems, but it can usually be arranged that the preferred device either
exists initially or never exists.  Retrying for never-existing devices in
the inner loop wastes many seconds.  Retrying in the outer loop would
waste at most  * 0.1 seconds.

Only the error reporting for the correct is complicated.  Currently, failure
is reported once for devices probed but not found, so later devices in my
list are not probed and not reported.  The above gives a new bug: double
error reporting for the first retry and the final failure for devices early
on the list that never exist.  I want to see exactly 1 report for all 
nonexistent devices early in the list.  In the usual case, there is 1

failure and no retries for devices early in the list; then mount succeeds
on the first try for some device and the probe completes (it is too difficult
to probe the list after 1 success).

Bruce
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r330763 - head/share/misc

2018-03-11 Thread Jochen Neumeister
Author: joneum (ports committer)
Date: Sun Mar 11 08:07:40 2018
New Revision: 330763
URL: https://svnweb.freebsd.org/changeset/base/330763

Log:
  sorry for that. Fix next typo
  
  Pointy hat to:joneum

Modified:
  head/share/misc/committers-ports.dot

Modified: head/share/misc/committers-ports.dot
==
--- head/share/misc/committers-ports.dotSun Mar 11 08:02:14 2018
(r330762)
+++ head/share/misc/committers-ports.dotSun Mar 11 08:07:40 2018
(r330763)
@@ -131,7 +131,7 @@ jkim [label="Jung-uk Kim\nj...@freebsd.org\n2007/09/12
 jlaffaye [label="Julien Laffaye\njlaff...@freebsd.org\n2011/06/06"]
 jmd [label="Johannes M. Dieterich\n...@freebsd.org\n2017/01/09"]
 jmelo [label="Jean Milanez Melo\njm...@freebsd.org\n2006/03/31"]
-joneum [label="Jochen Neumeister\jon...@freebsd.org\n2017/05/11"]
+joneum [label="Jochen Neumeister\njon...@freebsd.org\n2017/05/11"]
 joerg [label="Joerg Wunsch\njo...@freebsd.org\n1994/08/22"]
 johans [label="Johan Selst\njoh...@freebsd.org\n2006/04/01"]
 josef [label="Josef El-Rayes\njo...@freebsd.org\n2004/12/20"]
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r330764 - head/usr.sbin/bhyvectl

2018-03-11 Thread Peter Grehan
Author: grehan
Date: Sun Mar 11 08:27:11 2018
New Revision: 330764
URL: https://svnweb.freebsd.org/changeset/base/330764

Log:
  Add CR2 get/set support.
  
  Reported/Tested by:  Fabian Freyer
  Reviewed by:  araujo
  Differential Revision:https://reviews.freebsd.org/D14648
  MFC after:3 weeks

Modified:
  head/usr.sbin/bhyvectl/bhyvectl.c

Modified: head/usr.sbin/bhyvectl/bhyvectl.c
==
--- head/usr.sbin/bhyvectl/bhyvectl.c   Sun Mar 11 08:07:40 2018
(r330763)
+++ head/usr.sbin/bhyvectl/bhyvectl.c   Sun Mar 11 08:27:11 2018
(r330764)
@@ -109,6 +109,8 @@ usage(bool cpu_intel)
"   [--desc-access=]\n"
"   [--set-cr0=]\n"
"   [--get-cr0]\n"
+   "   [--set-cr2=]\n"
+   "   [--get-cr2]\n"
"   [--set-cr3=]\n"
"   [--get-cr3]\n"
"   [--set-cr4=]\n"
@@ -254,7 +256,8 @@ static int create, destroy, get_memmap, get_memseg;
 static int get_intinfo;
 static int get_active_cpus, get_suspended_cpus;
 static uint64_t memsize;
-static int set_cr0, get_cr0, set_cr3, get_cr3, set_cr4, get_cr4;
+static int set_cr0, get_cr0, set_cr2, get_cr2, set_cr3, get_cr3;
+static int set_cr4, get_cr4;
 static int set_efer, get_efer;
 static int set_dr0, get_dr0;
 static int set_dr1, get_dr1;
@@ -551,6 +554,7 @@ enum {
SET_MEM,
SET_EFER,
SET_CR0,
+   SET_CR2,
SET_CR3,
SET_CR4,
SET_DR0,
@@ -662,7 +666,7 @@ cpu_vendor_intel(void)
 static int
 get_all_registers(struct vmctx *ctx, int vcpu)
 {
-   uint64_t cr0, cr3, cr4, dr0, dr1, dr2, dr3, dr6, dr7;
+   uint64_t cr0, cr2, cr3, cr4, dr0, dr1, dr2, dr3, dr6, dr7;
uint64_t rsp, rip, rflags, efer;
uint64_t rax, rbx, rcx, rdx, rsi, rdi, rbp;
uint64_t r8, r9, r10, r11, r12, r13, r14, r15;
@@ -680,6 +684,12 @@ get_all_registers(struct vmctx *ctx, int vcpu)
printf("cr0[%d]\t\t0x%016lx\n", vcpu, cr0);
}
 
+   if (!error && (get_cr2 || get_all)) {
+   error = vm_get_register(ctx, vcpu, VM_REG_GUEST_CR2, );
+   if (error == 0)
+   printf("cr2[%d]\t\t0x%016lx\n", vcpu, cr2);
+   }
+
if (!error && (get_cr3 || get_all)) {
error = vm_get_register(ctx, vcpu, VM_REG_GUEST_CR3, );
if (error == 0)
@@ -1322,6 +1332,7 @@ setup_options(bool cpu_intel)
{ "set-mem",REQ_ARG,0,  SET_MEM },
{ "set-efer",   REQ_ARG,0,  SET_EFER },
{ "set-cr0",REQ_ARG,0,  SET_CR0 },
+   { "set-cr2",REQ_ARG,0,  SET_CR2 },
{ "set-cr3",REQ_ARG,0,  SET_CR3 },
{ "set-cr4",REQ_ARG,0,  SET_CR4 },
{ "set-dr0",REQ_ARG,0,  SET_DR0 },
@@ -1384,6 +1395,7 @@ setup_options(bool cpu_intel)
{ "get-memseg", NO_ARG, _memseg,1 },
{ "get-efer",   NO_ARG, _efer,  1 },
{ "get-cr0",NO_ARG, _cr0,   1 },
+   { "get-cr2",NO_ARG, _cr2,   1 },
{ "get-cr3",NO_ARG, _cr3,   1 },
{ "get-cr4",NO_ARG, _cr4,   1 },
{ "get-dr0",NO_ARG, _dr0,   1 },
@@ -1668,7 +1680,7 @@ main(int argc, char *argv[])
int error, ch, vcpu, ptenum;
vm_paddr_t gpa_pmap;
struct vm_exit vmexit;
-   uint64_t rax, cr0, cr3, cr4, dr0, dr1, dr2, dr3, dr6, dr7;
+   uint64_t rax, cr0, cr2, cr3, cr4, dr0, dr1, dr2, dr3, dr6, dr7;
uint64_t rsp, rip, rflags, efer, pat;
uint64_t eptp, bm, addr, u64, pteval[4], *pte, info[2];
struct vmctx *ctx;
@@ -1708,6 +1720,10 @@ main(int argc, char *argv[])
cr0 = strtoul(optarg, NULL, 0);
set_cr0 = 1;
break;
+   case SET_CR2:
+   cr2 = strtoul(optarg, NULL, 0);
+   set_cr2 = 1;
+   break;
case SET_CR3:
cr3 = strtoul(optarg, NULL, 0);
set_cr3 = 1;
@@ -1870,6 +1886,9 @@ main(int argc, char *argv[])
 
if (!error && set_cr0)
error = vm_set_register(ctx, vcpu, VM_REG_GUEST_CR0, cr0);
+
+   if (!error && set_cr2)
+   error = vm_set_register(ctx, vcpu, VM_REG_GUEST_CR2, cr2);
 
if (!error && set_cr3)
error = vm_set_register(ctx, vcpu, VM_REG_GUEST_CR3, cr3);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r330760 - head/sys/dev/nvme

2018-03-11 Thread Alexander Motin
Author: mav
Date: Sun Mar 11 06:30:09 2018
New Revision: 330760
URL: https://svnweb.freebsd.org/changeset/base/330760

Log:
  Add new opcodes and statuses from NVMe 1.3a.
  
  MFC after:2 weeks
  Sponsored by: iXsystems, Inc.

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

Modified: head/sys/dev/nvme/nvme.h
==
--- head/sys/dev/nvme/nvme.hSun Mar 11 05:09:02 2018(r330759)
+++ head/sys/dev/nvme/nvme.hSun Mar 11 06:30:09 2018(r330760)
@@ -498,10 +498,31 @@ enum nvme_generic_command_status_code {
NVME_SC_ABORTED_MISSING_FUSED   = 0x0a,
NVME_SC_INVALID_NAMESPACE_OR_FORMAT = 0x0b,
NVME_SC_COMMAND_SEQUENCE_ERROR  = 0x0c,
+   NVME_SC_INVALID_SGL_SEGMENT_DESCR   = 0x0d,
+   NVME_SC_INVALID_NUMBER_OF_SGL_DESCR = 0x0e,
+   NVME_SC_DATA_SGL_LENGTH_INVALID = 0x0f,
+   NVME_SC_METADATA_SGL_LENGTH_INVALID = 0x10,
+   NVME_SC_SGL_DESCRIPTOR_TYPE_INVALID = 0x11,
+   NVME_SC_INVALID_USE_OF_CMB  = 0x12,
+   NVME_SC_PRP_OFFET_INVALID   = 0x13,
+   NVME_SC_ATOMIC_WRITE_UNIT_EXCEEDED  = 0x14,
+   NVME_SC_OPERATION_DENIED= 0x15,
+   NVME_SC_SGL_OFFSET_INVALID  = 0x16,
+   /* 0x17 - reserved */
+   NVME_SC_HOST_ID_INCONSISTENT_FORMAT = 0x18,
+   NVME_SC_KEEP_ALIVE_TIMEOUT_EXPIRED  = 0x19,
+   NVME_SC_KEEP_ALIVE_TIMEOUT_INVALID  = 0x1a,
+   NVME_SC_ABORTED_DUE_TO_PREEMPT  = 0x1b,
+   NVME_SC_SANITIZE_FAILED = 0x1c,
+   NVME_SC_SANITIZE_IN_PROGRESS= 0x1d,
+   NVME_SC_SGL_DATA_BLOCK_GRAN_INVALID = 0x1e,
+   NVME_SC_NOT_SUPPORTED_IN_CMB= 0x1f,
 
NVME_SC_LBA_OUT_OF_RANGE= 0x80,
NVME_SC_CAPACITY_EXCEEDED   = 0x81,
NVME_SC_NAMESPACE_NOT_READY = 0x82,
+   NVME_SC_RESERVATION_CONFLICT= 0x83,
+   NVME_SC_FORMAT_IN_PROGRESS  = 0x84,
 };
 
 /* command specific status codes */
@@ -518,6 +539,29 @@ enum nvme_command_specific_status_code {
NVME_SC_INVALID_LOG_PAGE= 0x09,
NVME_SC_INVALID_FORMAT  = 0x0a,
NVME_SC_FIRMWARE_REQUIRES_RESET = 0x0b,
+   NVME_SC_INVALID_QUEUE_DELETION  = 0x0c,
+   NVME_SC_FEATURE_NOT_SAVEABLE= 0x0d,
+   NVME_SC_FEATURE_NOT_CHANGEABLE  = 0x0e,
+   NVME_SC_FEATURE_NOT_NS_SPECIFIC = 0x0f,
+   NVME_SC_FW_ACT_REQUIRES_NVMS_RESET  = 0x10,
+   NVME_SC_FW_ACT_REQUIRES_RESET   = 0x11,
+   NVME_SC_FW_ACT_REQUIRES_TIME= 0x12,
+   NVME_SC_FW_ACT_PROHIBITED   = 0x13,
+   NVME_SC_OVERLAPPING_RANGE   = 0x14,
+   NVME_SC_NS_INSUFFICIENT_CAPACITY= 0x15,
+   NVME_SC_NS_ID_UNAVAILABLE   = 0x16,
+   /* 0x17 - reserved */
+   NVME_SC_NS_ALREADY_ATTACHED = 0x18,
+   NVME_SC_NS_IS_PRIVATE   = 0x19,
+   NVME_SC_NS_NOT_ATTACHED = 0x1a,
+   NVME_SC_THIN_PROV_NOT_SUPPORTED = 0x1b,
+   NVME_SC_CTRLR_LIST_INVALID  = 0x1c,
+   NVME_SC_SELT_TEST_IN_PROGRESS   = 0x1d,
+   NVME_SC_BOOT_PART_WRITE_PROHIB  = 0x1e,
+   NVME_SC_INVALID_CTRLR_ID= 0x1f,
+   NVME_SC_INVALID_SEC_CTRLR_STATE = 0x20,
+   NVME_SC_INVALID_NUM_OF_CTRLR_RESRC  = 0x21,
+   NVME_SC_INVALID_RESOURCE_ID = 0x22,
 
NVME_SC_CONFLICTING_ATTRIBUTES  = 0x80,
NVME_SC_INVALID_PROTECTION_INFO = 0x81,
@@ -533,6 +577,7 @@ enum nvme_media_error_status_code {
NVME_SC_REFERENCE_TAG_CHECK_ERROR   = 0x84,
NVME_SC_COMPARE_FAILURE = 0x85,
NVME_SC_ACCESS_DENIED   = 0x86,
+   NVME_SC_DEALLOCATED_OR_UNWRITTEN= 0x87,
 };
 
 /* admin opcodes */
@@ -554,11 +599,20 @@ enum nvme_admin_opcode {
/* 0x0e-0x0f - reserved */
NVME_OPC_FIRMWARE_ACTIVATE  = 0x10,
NVME_OPC_FIRMWARE_IMAGE_DOWNLOAD= 0x11,
+   NVME_OPC_DEVICE_SELF_TEST   = 0x14,
NVME_OPC_NAMESPACE_ATTACHMENT   = 0x15,
+   NVME_OPC_KEEP_ALIVE = 0x18,
+   NVME_OPC_DIRECTIVE_SEND = 0x19,
+   NVME_OPC_DIRECTIVE_RECEIVE  = 0x1a,
+   NVME_OPC_VIRTUALIZATION_MANAGEMENT  = 0x1c,
+   NVME_OPC_NVME_MI_SEND   = 0x1d,
+   NVME_OPC_NVME_MI_RECEIVE= 0x1e,
+   NVME_OPC_DOORBELL_BUFFER_CONFIG = 0x7c,
 
NVME_OPC_FORMAT_NVM = 0x80,
NVME_OPC_SECURITY_SEND  = 0x81,
NVME_OPC_SECURITY_RECEIVE   = 0x82,
+   NVME_OPC_SANITIZE   = 0x84,
 };
 

svn commit: r330762 - head/share/misc

2018-03-11 Thread Jochen Neumeister
Author: joneum (ports committer)
Date: Sun Mar 11 08:02:14 2018
New Revision: 330762
URL: https://svnweb.freebsd.org/changeset/base/330762

Log:
  Fix typo
  
  Reported by:  tcberner

Modified:
  head/share/misc/committers-ports.dot

Modified: head/share/misc/committers-ports.dot
==
--- head/share/misc/committers-ports.dotSun Mar 11 07:33:49 2018
(r330761)
+++ head/share/misc/committers-ports.dotSun Mar 11 08:02:14 2018
(r330762)
@@ -131,7 +131,7 @@ jkim [label="Jung-uk Kim\nj...@freebsd.org\n2007/09/12
 jlaffaye [label="Julien Laffaye\njlaff...@freebsd.org\n2011/06/06"]
 jmd [label="Johannes M. Dieterich\n...@freebsd.org\n2017/01/09"]
 jmelo [label="Jean Milanez Melo\njm...@freebsd.org\n2006/03/31"]
-joneum [label="Jochen Neumeister\jon...@freebsd.org\n2017/05/11"
+joneum [label="Jochen Neumeister\jon...@freebsd.org\n2017/05/11"]
 joerg [label="Joerg Wunsch\njo...@freebsd.org\n1994/08/22"]
 johans [label="Johan Selst\njoh...@freebsd.org\n2006/04/01"]
 josef [label="Josef El-Rayes\njo...@freebsd.org\n2004/12/20"]
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"