svn commit: r351381 - head/sys/gdb

2019-08-21 Thread Conrad Meyer
Author: cem
Date: Thu Aug 22 04:31:07 2019
New Revision: 351381
URL: https://svnweb.freebsd.org/changeset/base/351381

Log:
  Fix i386 build after r351368
  
  Reported by:  cy
  Submitted by: cy

Modified:
  head/sys/gdb/gdb_main.c

Modified: head/sys/gdb/gdb_main.c
==
--- head/sys/gdb/gdb_main.c Thu Aug 22 03:33:10 2019(r351380)
+++ head/sys/gdb/gdb_main.c Thu Aug 22 04:31:07 2019(r351381)
@@ -418,7 +418,7 @@ do_qXfer_threads_read(void)
 */
if (offset != 0) {
if (offset != ctx.qXfer.last_offset) {
-   printf("%s: Resumed offset %ju != expected %ju\n",
+   printf("%s: Resumed offset %ju != expected %zu\n",
__func__, offset, ctx.qXfer.last_offset);
error = ESPIPE;
goto request_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: r351380 - head/sys/contrib/ipfilter/netinet

2019-08-21 Thread Cy Schubert
Author: cy
Date: Thu Aug 22 03:33:10 2019
New Revision: 351380
URL: https://svnweb.freebsd.org/changeset/base/351380

Log:
  Specifying array sizes for fully initialized tables at compile time is
  redundant.
  
  MFC after:1 week

Modified:
  head/sys/contrib/ipfilter/netinet/fil.c

Modified: head/sys/contrib/ipfilter/netinet/fil.c
==
--- head/sys/contrib/ipfilter/netinet/fil.c Thu Aug 22 03:28:31 2019
(r351379)
+++ head/sys/contrib/ipfilter/netinet/fil.c Thu Aug 22 03:33:10 2019
(r351380)
@@ -194,7 +194,7 @@ static  int ppsratecheck(struct timeval *, 
int *, int)
  * hand side to allow for binary searching of the array and include a trailer
  * with a 0 for the bitmask for linear searches to easily find the end with.
  */
-static const   struct  optlist ipopts[20] = {
+static const   struct  optlist ipopts[] = {
{ IPOPT_NOP,0x01 },
{ IPOPT_RR, 0x02 },
{ IPOPT_ZSU,0x04 },
@@ -235,7 +235,7 @@ static const struct optlist ip6exthdr[] = {
 /*
  * bit values for identifying presence of individual IP security options
  */
-static const   struct  optlist secopt[8] = {
+static const   struct  optlist secopt[] = {
{ IPSO_CLASS_RES4,  0x01 },
{ IPSO_CLASS_TOPS,  0x02 },
{ IPSO_CLASS_SECR,  0x04 },
___
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: r351379 - head/usr.bin/w

2019-08-21 Thread Mike Karels
Author: karels
Date: Thu Aug 22 03:28:31 2019
New Revision: 351379
URL: https://svnweb.freebsd.org/changeset/base/351379

Log:
  Change w(1) to compute FROM (host) field size dynamically
  
  It's nice to be able to display a full IPv6 host address if
  needed, but it's also nice to display more than 3 characters of a command
  line. Compute the needed size for the FROM column in an earlier pass,
  and determine the maximum, then print what fits for the command.
  
  Reviewed by:  marcel@ (markm@ previous revision)
  MFC after:1 week
  Differential Revision:https://reviews.freebsd.org/D21211

Modified:
  head/usr.bin/w/w.c

Modified: head/usr.bin/w/w.c
==
--- head/usr.bin/w/w.c  Thu Aug 22 03:00:55 2019(r351378)
+++ head/usr.bin/w/w.c  Thu Aug 22 03:28:31 2019(r351379)
@@ -96,7 +96,8 @@ static struct winsize ws;
 static kvm_t   *kd;
 static time_t  now;/* the current time of day */
 static int ttywidth;   /* width of tty */
-static int argwidth;   /* width of tty */
+static int fromwidth = 0;  /* max width of "from" field */
+static int argwidth;   /* width of arguments */
 static int header = 1; /* true if -h flag: don't print heading */
 static int nflag;  /* true if -n flag: don't convert addrs */
 static int dflag;  /* true if -d flag: output debug info */
@@ -116,13 +117,14 @@ static struct entry {
struct  kinfo_proc *kp; /* `most interesting' proc */
char*args;  /* arg list of interesting process */
struct  kinfo_proc *dkp;/* debug option proc list */
+   char*from;  /* "from": name or addr */
 } *ep, *ehead = NULL, **nextp = 
 
 #definedebugproc(p) *(&((struct kinfo_proc *)p)->ki_udata)
 
 #defineW_DISPUSERSIZE  10
 #defineW_DISPLINESIZE  8
-#defineW_DISPHOSTSIZE  40
+#defineW_MAXHOSTSIZE   40
 
 static void pr_header(time_t *, int);
 static struct stat *ttystat(char *);
@@ -209,6 +211,13 @@ main(int argc, char *argv[])
 
setutxent();
for (nusers = 0; (utmp = getutxent()) != NULL;) {
+   struct addrinfo hints, *res;
+   struct sockaddr_storage ss;
+   struct sockaddr *sa = (struct sockaddr *)
+   struct sockaddr_in *lsin = (struct sockaddr_in *)
+   struct sockaddr_in6 *lsin6 = (struct sockaddr_in6 *)
+   int isaddr;
+
if (utmp->ut_type != USER_PROCESS)
continue;
if (!(stp = ttystat(utmp->ut_line)))
@@ -250,9 +259,76 @@ main(int argc, char *argv[])
}
if ((ep->idle = now - touched) < 0)
ep->idle = 0;
+
+   save_p = p = *ep->utmp.ut_host ? ep->utmp.ut_host : "-";
+   if ((x_suffix = strrchr(p, ':')) != NULL) {
+   if ((dot = strchr(x_suffix, '.')) != NULL &&
+   strchr(dot+1, '.') == NULL)
+   *x_suffix++ = '\0';
+   else
+   x_suffix = NULL;
+   }
+
+   isaddr = 0;
+   memset(, '\0', sizeof(ss));
+   if (inet_pton(AF_INET6, p, >sin6_addr) == 1) {
+   lsin6->sin6_len = sizeof(*lsin6);
+   lsin6->sin6_family = AF_INET6;
+   isaddr = 1;
+   } else if (inet_pton(AF_INET, p, >sin_addr) == 1) {
+   lsin->sin_len = sizeof(*lsin);
+   lsin->sin_family = AF_INET;
+   isaddr = 1;
+   }
+   if (nflag == 0) {
+   /* Attempt to change an IP address into a name */
+   if (isaddr && realhostname_sa(fn, sizeof(fn), sa,
+   sa->sa_len) == HOSTNAME_FOUND)
+   p = fn;
+   } else if (!isaddr && nflag > 1) {
+   /*
+* If a host has only one A/ RR, change a
+* name into an IP address
+*/
+   memset(, 0, sizeof(hints));
+   hints.ai_flags = AI_PASSIVE;
+   hints.ai_family = AF_UNSPEC;
+   hints.ai_socktype = SOCK_STREAM;
+   if (getaddrinfo(p, NULL, , ) == 0) {
+   if (res->ai_next == NULL &&
+   getnameinfo(res->ai_addr, res->ai_addrlen,
+   fn, sizeof(fn), NULL, 0,
+   NI_NUMERICHOST) == 0)
+   p = fn;
+   freeaddrinfo(res);
+   }
+   }
+
+   

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

2019-08-21 Thread Warner Losh
Author: imp
Date: Thu Aug 22 02:53:51 2019
New Revision: 351376
URL: https://svnweb.freebsd.org/changeset/base/351376

Log:
  Remove stray line that was duplicated.
  
  Noticed by: rpokala@

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

Modified: head/sys/dev/nvme/nvme.c
==
--- head/sys/dev/nvme/nvme.cThu Aug 22 02:53:46 2019(r351375)
+++ head/sys/dev/nvme/nvme.cThu Aug 22 02:53:51 2019(r351376)
@@ -138,7 +138,6 @@ nvme_attach(device_t dev)
 
/*
 * Reset controller twice to ensure we do a transition from cc.en==1
-* Reset controller twice to ensure we do a transition from cc.en==1
 *  to cc.en==0.  This is because we don't really know what status
 *  the controller was left in when boot handed off to OS.
 */
___
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: r351375 - head

2019-08-21 Thread Warner Losh
Author: imp
Date: Thu Aug 22 02:53:46 2019
New Revision: 351375
URL: https://svnweb.freebsd.org/changeset/base/351375

Log:
  Document Intel RST support just added

Modified:
  head/RELNOTES

Modified: head/RELNOTES
==
--- head/RELNOTES   Thu Aug 22 01:29:59 2019(r351374)
+++ head/RELNOTES   Thu Aug 22 02:53:46 2019(r351375)
@@ -15,6 +15,14 @@ r351361:
corresponding lockstat(1) events, and document the new probes in
dtrace_lockstat.4.
 
+r351356:
+   Intel RST is a new 'feature' that remaps NVMe devices from
+   their normal location to part of the AHCI bar space.  This
+   will eliminate the need to set the BIOS SATA setting from RST
+   to AHCI causing the nvme drive to be erased before FreeBSD
+   will see the nvme drive. FreeBSD will now be able to see the
+   nvme drive now in the default config.
+
 r351201, r351372:
Add a vop_stdioctl() call, so that file systems that do not support
holes will have a trivial implementation of lseek(SEEK_DATA/SEEK_HOLE).
___
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: r351374 - head

2019-08-21 Thread Rick Macklem
Author: rmacklem
Date: Thu Aug 22 01:29:59 2019
New Revision: 351374
URL: https://svnweb.freebsd.org/changeset/base/351374

Log:
  Add a couple of lines noting that r351372 maps ENOTTY->EINVAL for other cases.

Modified:
  head/RELNOTES

Modified: head/RELNOTES
==
--- head/RELNOTES   Thu Aug 22 01:18:36 2019(r351373)
+++ head/RELNOTES   Thu Aug 22 01:29:59 2019(r351374)
@@ -15,7 +15,7 @@ r351361:
corresponding lockstat(1) events, and document the new probes in
dtrace_lockstat.4.
 
-r351201:
+r351201, r351372:
Add a vop_stdioctl() call, so that file systems that do not support
holes will have a trivial implementation of lseek(SEEK_DATA/SEEK_HOLE).
The algorithm appears to be compatible with the POSIX draft and
@@ -23,6 +23,8 @@ r351201:
does not support holes.  Prior to this patch, lseek(2) would reply
-1 with errno set to ENOTTY for SEEK_DATA/SEEK_HOLE on files in
file systems that do not support holes.
+   r351372 maps ENOTTY to EINVAL for lseek(SEEK_DATA/SEEK_HOLE) for
+   any other cases, such as a ENOTTY return from vn_bmap_seekhole().
 
 r350665:
The fuse driver has been renamed to fusefs(5) and been substantially
___
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: r351373 - head

2019-08-21 Thread Mark Johnston
Author: markj
Date: Thu Aug 22 01:18:36 2019
New Revision: 351373
URL: https://svnweb.freebsd.org/changeset/base/351373

Log:
  Document r351361.

Modified:
  head/RELNOTES

Modified: head/RELNOTES
==
--- head/RELNOTES   Thu Aug 22 01:15:06 2019(r351372)
+++ head/RELNOTES   Thu Aug 22 01:18:36 2019(r351373)
@@ -10,6 +10,11 @@ newline.  Entries should be separated by a newline.
 
 Changes to this file should not be MFCed.
 
+r351361:
+   Add probes for lockmgr(9) to the lockstat DTrace provider, add
+   corresponding lockstat(1) events, and document the new probes in
+   dtrace_lockstat.4.
+
 r351201:
Add a vop_stdioctl() call, so that file systems that do not support
holes will have a trivial implementation of lseek(SEEK_DATA/SEEK_HOLE).
___
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: r351372 - head/sys/kern

2019-08-21 Thread Rick Macklem
Author: rmacklem
Date: Thu Aug 22 01:15:06 2019
New Revision: 351372
URL: https://svnweb.freebsd.org/changeset/base/351372

Log:
  Map ENOTTY to EINVAL for lseek(SEEK_DATA/SEEK_HOLE).
  
  Without this patch, when an application performed lseek(SEEK_DATA/SEEK_HOLE)
  on a file in a file system that does not have its own VOP_IOCTL(), the
  lseek(2) fails with errno ENOTTY. This didn't seem appropriate, since
  ENOTTY is not listed as an error return by either the lseek(2) man page
  nor the POSIX draft for lseek(2).
  This was discussed on freebsd-current@ here:
  
http://docs.FreeBSD.org/cgi/mid.cgi?CAOtMX2iiQdv1+15e1N_r7V6aCx_VqAJCTP1AW+qs3Yg7sPg9wA
  
  This trivial patch maps ENOTTY to EINVAL for lseek(SEEK_DATA/SEEK_HOLE).
  
  Reviewed by:  markj
  Relnotes: yes
  Differential Revision:https://reviews.freebsd.org/D21300

Modified:
  head/sys/kern/vfs_vnops.c

Modified: head/sys/kern/vfs_vnops.c
==
--- head/sys/kern/vfs_vnops.c   Thu Aug 22 00:37:38 2019(r351371)
+++ head/sys/kern/vfs_vnops.c   Thu Aug 22 01:15:06 2019(r351372)
@@ -2275,9 +2275,13 @@ vn_seek(struct file *fp, off_t offset, int whence, str
break;
case SEEK_DATA:
error = fo_ioctl(fp, FIOSEEKDATA, , cred, td);
+   if (error == ENOTTY)
+   error = EINVAL;
break;
case SEEK_HOLE:
error = fo_ioctl(fp, FIOSEEKHOLE, , cred, td);
+   if (error == ENOTTY)
+   error = EINVAL;
break;
default:
error = EINVAL;
___
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: r351370 - head/sys/gdb

2019-08-21 Thread Conrad Meyer
Author: cem
Date: Thu Aug 22 00:36:16 2019
New Revision: 351370
URL: https://svnweb.freebsd.org/changeset/base/351370

Log:
  gdb(4): Style
  
  No functional change.
  
  I was surprised to find that no sys/ header already defines the -1 EOF
  convention anywhere, so defined one locally.

Modified:
  head/sys/gdb/gdb_int.h
  head/sys/gdb/gdb_main.c
  head/sys/gdb/gdb_packet.c

Modified: head/sys/gdb/gdb_int.h
==
--- head/sys/gdb/gdb_int.h  Thu Aug 22 00:35:17 2019(r351369)
+++ head/sys/gdb/gdb_int.h  Thu Aug 22 00:36:16 2019(r351370)
@@ -31,6 +31,10 @@
 #ifndef _GDB_GDB_INT_H_
 #define_GDB_GDB_INT_H_
 
+#ifndef EOF
+#define EOF(-1)
+#endif
+
 extern struct gdb_dbgport *gdb_cur;
 
 extern int gdb_listening;
@@ -54,7 +58,7 @@ gdb_rx_char(void)
c = *gdb_rxp++;
gdb_rxsz--;
} else
-   c = -1;
+   c = EOF;
return (c);
 }
 

Modified: head/sys/gdb/gdb_main.c
==
--- head/sys/gdb/gdb_main.c Thu Aug 22 00:35:17 2019(r351369)
+++ head/sys/gdb/gdb_main.c Thu Aug 22 00:36:16 2019(r351370)
@@ -653,7 +653,10 @@ gdb_trap(int type, int code)
case 'H': { /* Set thread. */
intmax_t tid;
struct thread *thr;
-   gdb_rx_char();
+
+   /* Ignore 'g' (general) or 'c' (continue) flag. */
+   (void) gdb_rx_char();
+
if (gdb_rx_varhex()) {
gdb_tx_err(EINVAL);
break;
@@ -768,7 +771,7 @@ gdb_trap(int type, int code)
gdb_tx_err(ENOENT);
break;
}
-   case -1:
+   case EOF:
/* Empty command. Treat as unknown command. */
/* FALLTHROUGH */
default:

Modified: head/sys/gdb/gdb_packet.c
==
--- head/sys/gdb/gdb_packet.c   Thu Aug 22 00:35:17 2019(r351369)
+++ head/sys/gdb/gdb_packet.c   Thu Aug 22 00:36:16 2019(r351370)
@@ -197,7 +197,7 @@ gdb_rx_varhex(uintmax_t *vp)
v += C2N(c);
c = gdb_rx_char();
} while (isxdigit(c));
-   if (c != -1) {
+   if (c != EOF) {
gdb_rxp--;
gdb_rxsz++;
}
@@ -343,13 +343,12 @@ gdb_rx_bindata(unsigned char *data, size_t datalen, si
 
while (*amt < datalen) {
c = gdb_rx_char();
-   /* End of packet? */
-   if (c == -1)
+   if (c == EOF)
break;
/* Escaped character up next */
if (c == '}') {
-   /* Truncated packet? Bail out */
-   if ((c = gdb_rx_char()) == -1)
+   /* Malformed packet. */
+   if ((c = gdb_rx_char()) == EOF)
return (1);
c ^= 0x20;
}
___
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: r351368 - head/sys/gdb

2019-08-21 Thread Conrad Meyer
Author: cem
Date: Thu Aug 22 00:34:11 2019
New Revision: 351368
URL: https://svnweb.freebsd.org/changeset/base/351368

Log:
  gdb(4): Implement qXfer:threads:read
  
  This streams out an XML document over several GDB packets describing all
  threads in the system; their ids, name, and any loosely defined "extra info"
  we feel like including.  For now, I have included a string version of the run
  state, similar to some of the DDB logic to stringify thread state.
  
  The benefit of supporting this in addition to the qfThreadInfo/qsThreadInfo
  packing is that in this mode, the host gdb does not ask for every thread's
  "qThreadExtraInfo," saving per-thread round-trips on "info threads."
  
  To use this feature, (k)gdb needs to be built with the --with-expat option.
  I would encourage enabling this option by default in our GDB port, if it is
  not already.
  
  Finally, there is another optional attribute you can specify per-thread
  called a "handle."  Handles are arbitrarily long sequences of bytes,
  represented in the XML as hexadecimal.  It is unclear to me how or if GDB
  actually uses handles for anything.  So I have left them out.

Modified:
  head/sys/gdb/gdb_main.c

Modified: head/sys/gdb/gdb_main.c
==
--- head/sys/gdb/gdb_main.c Thu Aug 22 00:33:22 2019(r351367)
+++ head/sys/gdb/gdb_main.c Thu Aug 22 00:34:11 2019(r351368)
@@ -36,6 +36,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -252,11 +253,12 @@ gdb_do_qsupported(uint32_t *feat)
 */
gdb_tx_varhex(GDB_BUFSZ + strlen("$#nn") - 1);
 
+   gdb_tx_str(";qXfer:threads:read+");
+
/*
 * Future consideration:
 *   - vCont
 *   - multiprocess
-*   - qXfer:threads:read
 */
gdb_tx_end();
return;
@@ -266,7 +268,306 @@ error:
gdb_tx_err(EINVAL);
 }
 
+/*
+ * A qXfer_context provides a vaguely generic way to generate a multi-packet
+ * response on the fly, making some assumptions about the size of sbuf writes
+ * vs actual packet length constraints.  A non-byzantine gdb host should allow
+ * hundreds of bytes per packet or more.
+ *
+ * Upper layers are considered responsible for escaping the four forbidden
+ * characters '# $ } *'.
+ */
+struct qXfer_context {
+   struct sbuf sb;
+   size_t last_offset;
+   bool flushed;
+   bool lastmessage;
+   char xfer_buf[GDB_BUFSZ];
+};
+
 static int
+qXfer_drain(void *v, const char *buf, int len)
+{
+   struct qXfer_context *qx;
+
+   if (len < 0)
+   return (-EINVAL);
+
+   qx = v;
+   if (qx->flushed) {
+   /*
+* Overflow.  We lost some message.  Maybe the packet size is
+* ridiculously small.
+*/
+   printf("%s: Overflow in qXfer detected.\n", __func__);
+   return (-ENOBUFS);
+   }
+
+   qx->last_offset += len;
+   qx->flushed = true;
+
+   if (qx->lastmessage)
+   gdb_tx_begin('l');
+   else
+   gdb_tx_begin('m');
+
+   memcpy(gdb_txp, buf, len);
+   gdb_txp += len;
+
+   gdb_tx_end();
+   return (len);
+}
+
+static int
+init_qXfer_ctx(struct qXfer_context *qx, uintmax_t len)
+{
+
+   /* Protocol (max) length field includes framing overhead. */
+   if (len < sizeof("$m#nn"))
+   return (ENOSPC);
+
+   len -= 4;
+   len = ummin(len, GDB_BUFSZ - 1);
+
+   qx->last_offset = 0;
+   qx->flushed = false;
+   qx->lastmessage = false;
+   sbuf_new(>sb, qx->xfer_buf, len, SBUF_FIXEDLEN);
+   sbuf_set_drain(>sb, qXfer_drain, qx);
+   return (0);
+}
+
+/*
+ * dst must be 2x strlen(max_src) + 1.
+ *
+ * Squashes invalid XML characters down to _.  Sorry.  Then escapes for GDB.
+ */
+static void
+qXfer_escape_xmlattr_str(char *dst, size_t dstlen, const char *src)
+{
+   static const char *forbidden = "#$}*";
+
+   size_t i;
+   char c;
+
+   for (i = 0; i < dstlen - 1 && *src != 0; src++, i++) {
+   c = *src;
+   /* XML attr filter */
+   if (c < 32)
+   c = '_';
+   /* We assume attributes will be "" quoted. */
+   if (c == '<' || c == '&' || c == '"')
+   c = '_';
+
+   /* GDB escape. */
+   if (strchr(forbidden, c) != NULL) {
+   *dst++ = '}';
+   c ^= 0x20;
+   }
+   *dst++ = c;
+   }
+   if (*src != 0)
+   printf("XXX%s: overflow; API misuse\n", __func__);
+
+   *dst = 0;
+}
+
+/*
+ * Dynamically generate qXfer:threads document, one packet at a time.
+ *
+ * The format is loosely described[0], although it does not seem that the
+ *  mentioned on that page is required.
+ *
+ * [0]: 

svn commit: r351365 - head/sys/gdb

2019-08-21 Thread Conrad Meyer
Author: cem
Date: Thu Aug 22 00:19:14 2019
New Revision: 351365
URL: https://svnweb.freebsd.org/changeset/base/351365

Log:
  gdb(4): Include thread in Target Halt Reason
  
  This saves a round trip of the gdb remote inferior attempting to find
  the thread id of the halted thread.
  
  Sponsored by: Dell EMC Isilon

Modified:
  head/sys/gdb/gdb_main.c

Modified: head/sys/gdb/gdb_main.c
==
--- head/sys/gdb/gdb_main.c Thu Aug 22 00:02:08 2019(r351364)
+++ head/sys/gdb/gdb_main.c Thu Aug 22 00:19:14 2019(r351365)
@@ -198,8 +198,11 @@ gdb_trap(int type, int code)
/* printf("GDB: got '%s'\n", gdb_rxp); */
switch (gdb_rx_char()) {
case '?':   /* Last signal. */
-   gdb_tx_begin('S');
+   gdb_tx_begin('T');
gdb_tx_hex(gdb_cpu_signal(type, code), 2);
+   gdb_tx_str("thread:");
+   gdb_tx_varhex((long)kdb_thread->td_tid);
+   gdb_tx_char(';');
gdb_tx_end();
break;
case 'c': { /* Continue. */
___
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: r351364 - in head/sys: crypto/blowfish crypto/chacha20 crypto/des opencrypto

2019-08-21 Thread John Baldwin
Author: jhb
Date: Thu Aug 22 00:02:08 2019
New Revision: 351364
URL: https://svnweb.freebsd.org/changeset/base/351364

Log:
  Use 'const' for keys and IVs passed to software encryption algorithms.
  
  Specifically, use 'const' for the key passed to the 'setkey' method
  and 'const' for the 'iv' passed to the 'reinit' method.
  
  Reviewed by:  cem
  Sponsored by: Chelsio Communications
  Differential Revision:https://reviews.freebsd.org/D21347

Modified:
  head/sys/crypto/blowfish/bf_skey.c
  head/sys/crypto/blowfish/blowfish.h
  head/sys/crypto/chacha20/chacha-sw.c
  head/sys/crypto/des/des.h
  head/sys/crypto/des/des_setkey.c
  head/sys/opencrypto/cast.c
  head/sys/opencrypto/cast.h
  head/sys/opencrypto/skipjack.c
  head/sys/opencrypto/skipjack.h
  head/sys/opencrypto/xform_aes_icm.c
  head/sys/opencrypto/xform_aes_xts.c
  head/sys/opencrypto/xform_blf.c
  head/sys/opencrypto/xform_cast5.c
  head/sys/opencrypto/xform_cml.c
  head/sys/opencrypto/xform_des1.c
  head/sys/opencrypto/xform_des3.c
  head/sys/opencrypto/xform_enc.h
  head/sys/opencrypto/xform_null.c
  head/sys/opencrypto/xform_rijndael.c
  head/sys/opencrypto/xform_skipjack.c

Modified: head/sys/crypto/blowfish/bf_skey.c
==
--- head/sys/crypto/blowfish/bf_skey.c  Wed Aug 21 23:47:01 2019
(r351363)
+++ head/sys/crypto/blowfish/bf_skey.c  Thu Aug 22 00:02:08 2019
(r351364)
@@ -73,11 +73,11 @@ void
 BF_set_key(key, len, data)
BF_KEY *key;
int len;
-   unsigned char *data;
+   const unsigned char *data;
 {
int i;
BF_LONG *p, ri, in[2];
-   unsigned char *d, *end;
+   const unsigned char *d, *end;
 
memcpy((char *)key, (const char *)_init, sizeof(BF_KEY));
p = key->P;

Modified: head/sys/crypto/blowfish/blowfish.h
==
--- head/sys/crypto/blowfish/blowfish.h Wed Aug 21 23:47:01 2019
(r351363)
+++ head/sys/crypto/blowfish/blowfish.h Thu Aug 22 00:02:08 2019
(r351364)
@@ -80,7 +80,7 @@ typedef struct bf_key_st {
BF_LONG S[4*256];
 } BF_KEY;
 
-void BF_set_key(BF_KEY *, int, unsigned char *);
+void BF_set_key(BF_KEY *, int, const unsigned char *);
 void BF_encrypt(BF_LONG *, BF_KEY *);
 void BF_decrypt(BF_LONG *, BF_KEY *);
 void BF_ecb_encrypt(const unsigned char *, unsigned char *,

Modified: head/sys/crypto/chacha20/chacha-sw.c
==
--- head/sys/crypto/chacha20/chacha-sw.cWed Aug 21 23:47:01 2019
(r351363)
+++ head/sys/crypto/chacha20/chacha-sw.cThu Aug 22 00:02:08 2019
(r351364)
@@ -7,7 +7,7 @@ __FBSDID("$FreeBSD$");
 #include 
 
 static int
-chacha20_xform_setkey(u_int8_t **sched, u_int8_t *key, int len)
+chacha20_xform_setkey(u_int8_t **sched, const u_int8_t *key, int len)
 {
struct chacha_ctx *ctx;
 
@@ -24,7 +24,7 @@ chacha20_xform_setkey(u_int8_t **sched, u_int8_t *key,
 }
 
 static void
-chacha20_xform_reinit(caddr_t key, u_int8_t *iv)
+chacha20_xform_reinit(caddr_t key, const u_int8_t *iv)
 {
struct chacha_ctx *ctx;
 

Modified: head/sys/crypto/des/des.h
==
--- head/sys/crypto/des/des.h   Wed Aug 21 23:47:01 2019(r351363)
+++ head/sys/crypto/des/des.h   Thu Aug 22 00:02:08 2019(r351364)
@@ -103,12 +103,12 @@ void des_ede3_cbc_encrypt(const unsigned char *, unsig
 
 void des_set_odd_parity(des_cblock *);
 void des_fixup_key_parity(des_cblock *); 
-int des_is_weak_key(des_cblock *);
-int des_set_key(des_cblock *, des_key_schedule);
-int des_key_sched(des_cblock *, des_key_schedule);
-int des_set_key_checked(des_cblock *, des_key_schedule);
-void des_set_key_unchecked(des_cblock *, des_key_schedule);
-int des_check_key_parity(des_cblock *);
+int des_is_weak_key(const des_cblock *);
+int des_set_key(const des_cblock *, des_key_schedule);
+int des_key_sched(const des_cblock *, des_key_schedule);
+int des_set_key_checked(const des_cblock *, des_key_schedule);
+void des_set_key_unchecked(const des_cblock *, des_key_schedule);
+int des_check_key_parity(const des_cblock *);
 
 #ifdef  __cplusplus
 }

Modified: head/sys/crypto/des/des_setkey.c
==
--- head/sys/crypto/des/des_setkey.cWed Aug 21 23:47:01 2019
(r351363)
+++ head/sys/crypto/des/des_setkey.cThu Aug 22 00:02:08 2019
(r351364)
@@ -75,7 +75,7 @@ void des_set_odd_parity(des_cblock *key)
(*key)[i]=odd_parity[(*key)[i]];
 }
 
-int des_check_key_parity(des_cblock *key)
+int des_check_key_parity(const des_cblock *key)
 {
int i;
 
@@ -117,7 +117,7 @@ static des_cblock weak_keys[NUM_WEAK_KEY]={
{0xE0,0xFE,0xE0,0xFE,0xF1,0xFE,0xF1,0xFE},
{0xFE,0xE0,0xFE,0xE0,0xFE,0xF1,0xFE,0xF1}};
 
-int 

svn commit: r351363 - head/cddl/contrib/opensolaris/cmd/lockstat

2019-08-21 Thread Mark Johnston
Author: markj
Date: Wed Aug 21 23:47:01 2019
New Revision: 351363
URL: https://svnweb.freebsd.org/changeset/base/351363

Log:
  Add hold events for lockmgr probes, missed in r351361.
  
  MFC with: r351361

Modified:
  head/cddl/contrib/opensolaris/cmd/lockstat/lockstat.c

Modified: head/cddl/contrib/opensolaris/cmd/lockstat/lockstat.c
==
--- head/cddl/contrib/opensolaris/cmd/lockstat/lockstat.c   Wed Aug 21 
23:44:46 2019(r351362)
+++ head/cddl/contrib/opensolaris/cmd/lockstat/lockstat.c   Wed Aug 21 
23:47:01 2019(r351363)
@@ -215,8 +215,12 @@ static ls_event_info_t g_event_info[LS_MAX_EVENTS] = {
{ 'H',  "Lock", "SX exclusive hold","nsec",
"lockstat:::sx-release", "arg1 == 0",
"lockstat:::sx-acquire" },
-   { 'H',  "Lock", "Unknown event (type 38)",  "units" },
-   { 'H',  "Lock", "Unknown event (type 39)",  "units" },
+   { 'H',  "Lock", "lockmgr shared hold",  "nsec",
+   "lockstat:::lockmgr-release", "arg1 == 1",
+   "lockstat:::lockmgr-acquire" },
+   { 'H',  "Lock", "lockmgr exclusive hold",   "nsec",
+   "lockstat:::lockmgr-release,lockstat:::lockmgr-disown", "arg1 == 0",
+   "lockstat:::lockmgr-acquire" },
{ 'H',  "Lock", "Unknown event (type 40)",  "units" },
{ 'H',  "Lock", "Unknown event (type 41)",  "units" },
{ 'H',  "Lock", "Unknown event (type 42)",  "units" },
___
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: r351361 - in head: cddl/contrib/opensolaris/cmd/lockstat share/man/man4 sys/kern sys/sys

2019-08-21 Thread Mark Johnston
Author: markj
Date: Wed Aug 21 23:43:58 2019
New Revision: 351361
URL: https://svnweb.freebsd.org/changeset/base/351361

Log:
  Add lockmgr(9) probes to the lockstat DTrace provider.
  
  They follow the conventions set by rw and sx lock probes.  There is
  an additional lockstat:::lockmgr-disown probe.
  
  Update lockstat(1) to report on contention and hold events for
  lockmgr locks.  Document the new probes in dtrace_lockstat.4, and
  deduplicate some of the existing probe descriptions.
  
  Reviewed by:  mjg
  MFC after:1 week
  Sponsored by: The FreeBSD Foundation
  Differential Revision:https://reviews.freebsd.org/D21355

Modified:
  head/cddl/contrib/opensolaris/cmd/lockstat/lockstat.c
  head/share/man/man4/dtrace_lockstat.4
  head/sys/kern/kern_lock.c
  head/sys/kern/kern_lockstat.c
  head/sys/sys/lockstat.h

Modified: head/cddl/contrib/opensolaris/cmd/lockstat/lockstat.c
==
--- head/cddl/contrib/opensolaris/cmd/lockstat/lockstat.c   Wed Aug 21 
23:24:40 2019(r351360)
+++ head/cddl/contrib/opensolaris/cmd/lockstat/lockstat.c   Wed Aug 21 
23:43:58 2019(r351361)
@@ -158,29 +158,33 @@ static ls_event_info_t g_event_info[LS_MAX_EVENTS] = {
{ 'C',  "Lock", "R/W writer blocked by readers","nsec",
"lockstat:::rw-block", "arg2 == 0 && arg3 == 0 && arg4" },
{ 'C',  "Lock", "R/W reader blocked by writer", "nsec",
-   "lockstat:::rw-block", "arg2 != 0 && arg3 == 1" },
+   "lockstat:::rw-block", "arg2 == 1 && arg3 == 1" },
{ 'C',  "Lock", "R/W reader blocked by write wanted",   "nsec",
-   "lockstat:::rw-block", "arg2 != 0 && arg3 == 0 && arg4" },
+   "lockstat:::rw-block", "arg2 == 1 && arg3 == 0 && arg4" },
{ 'C',  "Lock", "R/W writer spin on writer","nsec",
"lockstat:::rw-spin", "arg2 == 0 && arg3 == 1" },
{ 'C',  "Lock", "R/W writer spin on readers",   "nsec",
"lockstat:::rw-spin", "arg2 == 0 && arg3 == 0 && arg4" },
{ 'C',  "Lock", "R/W reader spin on writer","nsec",
-   "lockstat:::rw-spin", "arg2 != 0 && arg3 == 1" },
+   "lockstat:::rw-spin", "arg2 == 1 && arg3 == 1" },
{ 'C',  "Lock", "R/W reader spin on write wanted",  "nsec",
-   "lockstat:::rw-spin", "arg2 != 0 && arg3 == 0 && arg4" },
+   "lockstat:::rw-spin", "arg2 == 1 && arg3 == 0 && arg4" },
{ 'C',  "Lock", "SX exclusive block",   "nsec",
"lockstat:::sx-block", "arg2 == 0" },
{ 'C',  "Lock", "SX shared block",  "nsec",
-   "lockstat:::sx-block", "arg2 != 0" },
+   "lockstat:::sx-block", "arg2 == 1" },
{ 'C',  "Lock", "SX exclusive spin","nsec",
"lockstat:::sx-spin", "arg2 == 0" },
{ 'C',  "Lock", "SX shared spin",   "nsec",
-   "lockstat:::sx-spin", "arg2 != 0" },
-   { 'C',  "Lock", "Unknown event (type 16)",  "units" },
-   { 'C',  "Lock", "Unknown event (type 17)",  "units" },
-   { 'C',  "Lock", "Unknown event (type 18)",  "units" },
-   { 'C',  "Lock", "Unknown event (type 19)",  "units" },
+   "lockstat:::sx-spin", "arg2 == 1" },
+   { 'C',  "Lock", "lockmgr writer blocked by writer", "nsec",
+   "lockstat:::lockmgr-block", "arg2 == 0 && arg3 == 1" },
+   { 'C',  "Lock", "lockmgr writer blocked by readers","nsec",
+   "lockstat:::lockmgr-block", "arg2 == 0 && arg3 == 0 && arg4" },
+   { 'C',  "Lock", "lockmgr reader blocked by writer", "nsec",
+   "lockstat:::lockmgr-block", "arg2 == 1 && arg3 == 1" },
+   { 'C',  "Lock", "lockmgr reader blocked by write wanted", "nsec",
+   "lockstat:::lockmgr-block", "arg2 == 1 && arg3 == 0 && arg4" },
{ 'C',  "Lock", "Unknown event (type 20)",  "units" },
{ 'C',  "Lock", "Unknown event (type 21)",  "units" },
{ 'C',  "Lock", "Unknown event (type 22)",  "units" },

Modified: head/share/man/man4/dtrace_lockstat.4
==
--- head/share/man/man4/dtrace_lockstat.4   Wed Aug 21 23:24:40 2019
(r351360)
+++ head/share/man/man4/dtrace_lockstat.4   Wed Aug 21 23:43:58 2019
(r351361)
@@ -24,7 +24,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd March 2, 2018
+.Dd August 20, 2019
 .Dt DTRACE_LOCKSTAT 4
 .Os
 .Sh NAME
@@ -50,6 +50,12 @@
 .Fn lockstat:::sx-spin "struct sx *" "uint64_t"
 .Fn lockstat:::sx-upgrade "struct sx *"
 .Fn lockstat:::sx-downgrade "struct sx *"
+.Fn lockstat:::lockmgr-acquire "struct lock *" "int"
+.Fn lockstat:::lockmgr-release "struct lock *" "int"
+.Fn lockstat:::lockmgr-disown "struct lock *" "int"
+.Fn lockstat:::lockmgr-block "struct lock *" 

svn commit: r351360 - head/sys/fs/nullfs

2019-08-21 Thread Mateusz Guzik
Author: mjg
Date: Wed Aug 21 23:24:40 2019
New Revision: 351360
URL: https://svnweb.freebsd.org/changeset/base/351360

Log:
  nullfs: lock the vnode with LK_SHARED in null_vptocnp
  
  null_nodeget which follows almost always finds the target vnode in the hash,
  avoiding insmntque1 altogether. Should it be needed, it already checks if the
  lock needs to be upgraded.
  
  Reviewed by:  kib
  Tested by:pho
  Sponsored by: The FreeBSD Foundation
  Differential Revision:https://reviews.freebsd.org/D20244

Modified:
  head/sys/fs/nullfs/null_subr.c
  head/sys/fs/nullfs/null_vnops.c

Modified: head/sys/fs/nullfs/null_subr.c
==
--- head/sys/fs/nullfs/null_subr.c  Wed Aug 21 23:13:00 2019
(r351359)
+++ head/sys/fs/nullfs/null_subr.c  Wed Aug 21 23:24:40 2019
(r351360)
@@ -222,9 +222,6 @@ null_nodeget(mp, lowervp, vpp)
 * provide ready to use vnode.
 */
if (VOP_ISLOCKED(lowervp) != LK_EXCLUSIVE) {
-   KASSERT((MOUNTTONULLMOUNT(mp)->nullm_flags & NULLM_CACHE) != 0,
-   ("lowervp %p is not excl locked and cache is disabled",
-   lowervp));
vn_lock(lowervp, LK_UPGRADE | LK_RETRY);
if ((lowervp->v_iflag & VI_DOOMED) != 0) {
vput(lowervp);

Modified: head/sys/fs/nullfs/null_vnops.c
==
--- head/sys/fs/nullfs/null_vnops.c Wed Aug 21 23:13:00 2019
(r351359)
+++ head/sys/fs/nullfs/null_vnops.c Wed Aug 21 23:24:40 2019
(r351360)
@@ -893,11 +893,7 @@ null_vptocnp(struct vop_vptocnp_args *ap)
return (ENOENT);
}
 
-   /*
-* Exclusive lock is required by insmntque1 call in
-* null_nodeget()
-*/
-   error = vn_lock(ldvp, LK_EXCLUSIVE);
+   error = vn_lock(ldvp, LK_SHARED);
if (error != 0) {
vrele(ldvp);
vn_lock(vp, locked | LK_RETRY);
___
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: r351359 - head/cddl/contrib/opensolaris/cmd/lockstat

2019-08-21 Thread Mark Johnston
Author: markj
Date: Wed Aug 21 23:13:00 2019
New Revision: 351359
URL: https://svnweb.freebsd.org/changeset/base/351359

Log:
  Fix inverted predicates for sx lock hold events in lockstat(1).
  
  This caused shared sx holds to be reported as exclusive, and vice
  versa.
  
  Reviewed by:  mjg
  MFC after:3 days
  Sponsored by: The FreeBSD Foundation

Modified:
  head/cddl/contrib/opensolaris/cmd/lockstat/lockstat.c

Modified: head/cddl/contrib/opensolaris/cmd/lockstat/lockstat.c
==
--- head/cddl/contrib/opensolaris/cmd/lockstat/lockstat.c   Wed Aug 21 
22:42:08 2019(r351358)
+++ head/cddl/contrib/opensolaris/cmd/lockstat/lockstat.c   Wed Aug 21 
23:13:00 2019(r351359)
@@ -206,10 +206,10 @@ static ls_event_info_t g_event_info[LS_MAX_EVENTS] = {
"lockstat:::rw-release", "arg1 == 1",
"lockstat:::rw-acquire" },
{ 'H',  "Lock", "SX shared hold",   "nsec",
-   "lockstat:::sx-release", "arg1 == 0",
+   "lockstat:::sx-release", "arg1 == 1",
"lockstat:::sx-acquire" },
{ 'H',  "Lock", "SX exclusive hold","nsec",
-   "lockstat:::sx-release", "arg1 == 1",
+   "lockstat:::sx-release", "arg1 == 0",
"lockstat:::sx-acquire" },
{ 'H',  "Lock", "Unknown event (type 38)",  "units" },
{ 'H',  "Lock", "Unknown event (type 39)",  "units" },
___
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: r351355 - in head/sys: conf dev/nvme modules/nvme

2019-08-21 Thread Warner Losh
Author: imp
Date: Wed Aug 21 22:17:55 2019
New Revision: 351355
URL: https://svnweb.freebsd.org/changeset/base/351355

Log:
  Separate the pci attachment from the rest of nvme
  
  Nvme drives can be attached in a number of different ways. Separate out the 
PCI
  attachment so that we can have other attachment types, like ahci and various
  types of NVMeoF.
  
  Submitted by: cognet@

Added:
  head/sys/dev/nvme/nvme_pci.c   (contents, props changed)
Modified:
  head/sys/conf/files
  head/sys/dev/nvme/nvme.c
  head/sys/dev/nvme/nvme_ctrlr.c
  head/sys/dev/nvme/nvme_private.h
  head/sys/modules/nvme/Makefile

Modified: head/sys/conf/files
==
--- head/sys/conf/files Wed Aug 21 21:05:15 2019(r351354)
+++ head/sys/conf/files Wed Aug 21 22:17:55 2019(r351355)
@@ -2483,6 +2483,7 @@ dev/nvme/nvme_ctrlr.c optional nvme
 dev/nvme/nvme_ctrlr_cmd.c  optional nvme
 dev/nvme/nvme_ns.c optional nvme
 dev/nvme/nvme_ns_cmd.c optional nvme
+dev/nvme/nvme_pci.coptional nvme pci
 dev/nvme/nvme_qpair.c  optional nvme
 dev/nvme/nvme_sim.coptional nvme scbus
 dev/nvme/nvme_sysctl.c optional nvme

Modified: head/sys/dev/nvme/nvme.c
==
--- head/sys/dev/nvme/nvme.cWed Aug 21 21:05:15 2019(r351354)
+++ head/sys/dev/nvme/nvme.cWed Aug 21 22:17:55 2019(r351355)
@@ -36,9 +36,6 @@ __FBSDID("$FreeBSD$");
 
 #include 
 
-#include 
-#include 
-
 #include "nvme_private.h"
 
 struct nvme_consumer {
@@ -58,107 +55,8 @@ int32_t nvme_retry_count;
 
 MALLOC_DEFINE(M_NVME, "nvme", "nvme(4) memory allocations");
 
-static intnvme_probe(device_t);
-static intnvme_attach(device_t);
-static intnvme_detach(device_t);
-static intnvme_shutdown(device_t);
+devclass_t nvme_devclass;
 
-static devclass_t nvme_devclass;
-
-static device_method_t nvme_pci_methods[] = {
-   /* Device interface */
-   DEVMETHOD(device_probe, nvme_probe),
-   DEVMETHOD(device_attach,nvme_attach),
-   DEVMETHOD(device_detach,nvme_detach),
-   DEVMETHOD(device_shutdown,  nvme_shutdown),
-   { 0, 0 }
-};
-
-static driver_t nvme_pci_driver = {
-   "nvme",
-   nvme_pci_methods,
-   sizeof(struct nvme_controller),
-};
-
-DRIVER_MODULE(nvme, pci, nvme_pci_driver, nvme_devclass, NULL, NULL);
-MODULE_VERSION(nvme, 1);
-MODULE_DEPEND(nvme, cam, 1, 1, 1);
-
-static struct _pcsid
-{
-   uint32_tdevid;
-   int match_subdevice;
-   uint16_tsubdevice;
-   const char  *desc;
-   uint32_tquirks;
-} pci_ids[] = {
-   { 0x01118086,   0, 0, "NVMe Controller"  },
-   { IDT32_PCI_ID, 0, 0, "IDT NVMe Controller (32 channel)"  },
-   { IDT8_PCI_ID,  0, 0, "IDT NVMe Controller (8 channel)" },
-   { 0x09538086,   1, 0x3702, "DC P3700 SSD" },
-   { 0x09538086,   1, 0x3703, "DC P3700 SSD [2.5\" SFF]" },
-   { 0x09538086,   1, 0x3704, "DC P3500 SSD [Add-in Card]" },
-   { 0x09538086,   1, 0x3705, "DC P3500 SSD [2.5\" SFF]" },
-   { 0x09538086,   1, 0x3709, "DC P3600 SSD [Add-in Card]" },
-   { 0x09538086,   1, 0x370a, "DC P3600 SSD [2.5\" SFF]" },
-   { 0x00031c58,   0, 0, "HGST SN100", QUIRK_DELAY_B4_CHK_RDY 
},
-   { 0x00231c58,   0, 0, "WDC SN200",  QUIRK_DELAY_B4_CHK_RDY 
},
-   { 0x05401c5f,   0, 0, "Memblaze Pblaze4", 
QUIRK_DELAY_B4_CHK_RDY },
-   { 0xa821144d,   0, 0, "Samsung PM1725", QUIRK_DELAY_B4_CHK_RDY 
},
-   { 0xa822144d,   0, 0, "Samsung PM1725a", QUIRK_DELAY_B4_CHK_RDY 
},
-   { 0x01161179,   0, 0, "Toshiba XG5", QUIRK_DISABLE_TIMEOUT },
-   { 0x,   0, 0, NULL  }
-};
-
-static int
-nvme_match(uint32_t devid, uint16_t subdevice, struct _pcsid *ep)
-{
-   if (devid != ep->devid)
-   return 0;
-
-   if (!ep->match_subdevice)
-   return 1;
-
-   if (subdevice == ep->subdevice)
-   return 1;
-   else
-   return 0;
-}
-
-static int
-nvme_probe (device_t device)
-{
-   struct _pcsid   *ep;
-   uint32_tdevid;
-   uint16_tsubdevice;
-
-   devid = pci_get_devid(device);
-   subdevice = pci_get_subdevice(device);
-   ep = pci_ids;
-
-   while (ep->devid) {
-   if (nvme_match(devid, subdevice, ep))
-   break;
-   ++ep;
-   }
-
-   if (ep->desc) {
-   device_set_desc(device, ep->desc);
-   return (BUS_PROBE_DEFAULT);
-   }
-
-#if defined(PCIS_STORAGE_NVM)
-   if (pci_get_class(device)== PCIC_STORAGE &&
-   pci_get_subclass(device) == PCIS_STORAGE_NVM &&
-   pci_get_progif(device)   == 

svn commit: r351357 - head/share/man/man4

2019-08-21 Thread Warner Losh
Author: imp
Date: Wed Aug 21 22:18:07 2019
New Revision: 351357
URL: https://svnweb.freebsd.org/changeset/base/351357

Log:
  Document RST support in nvme(4) and ahci(4).

Modified:
  head/share/man/man4/ahci.4
  head/share/man/man4/nvme.4

Modified: head/share/man/man4/ahci.4
==
--- head/share/man/man4/ahci.4  Wed Aug 21 22:18:01 2019(r351356)
+++ head/share/man/man4/ahci.4  Wed Aug 21 22:18:07 2019(r351357)
@@ -24,7 +24,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd November 2, 2018
+.Dd August 21, 2019
 .Dt AHCI 4
 .Os
 .Sh NAME
@@ -153,6 +153,26 @@ subclass 6 (SATA) and programming interface 1 (AHCI).
 Also, in cooperation with atamarvell and atajmicron drivers of ata(4),
 it supports AHCI part of legacy-PATA + AHCI-SATA combined controllers,
 such as JMicron JMB36x and Marvell 88SE61xx.
+.Pp
+The
+.Nm
+driver also supports AHCI devices that act as PCI bridges for
+.Xr nvme 4
+using Intel Rapid Storage Technology (RST).
+To use the
+.Xr nvme 4
+device, either one must set the SATA mode in the BIOS to AHCI (from RST),
+or one must accept the performance with RST enabled due to interrupt sharing.
+.Fx
+will automatically detect AHCI devices with this extension that are in RST
+mode.
+When that happens,
+.Nm
+will attach
+.Xr nvme 4
+children to the
+.Xr ahci 4
+device.
 .Sh FILES
 .Bl -tag -width /dev/led/ahcich*.locate
 .It Pa /dev/led/ahci*.*.act

Modified: head/share/man/man4/nvme.4
==
--- head/share/man/man4/nvme.4  Wed Aug 21 22:18:01 2019(r351356)
+++ head/share/man/man4/nvme.4  Wed Aug 21 22:18:07 2019(r351357)
@@ -33,7 +33,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd May 18, 2019
+.Dd August 21, 2019
 .Dt NVME 4
 .Os
 .Sh NAME
@@ -207,6 +207,23 @@ with a completion entry that was posted by the control
 (W) Writing 1 to this sysctl will dump the full contents of the submission
 and completion queues to the console.
 .El
+.Pp
+In addition to the typical pci attachment, the
+.Nm
+driver supports attaching to a
+.Xr ahci 4
+device.
+Intel's Rapid Storage Technology (RST) hides the nvme device
+behind the AHCI device due to limitations in Windows.
+However, this effectively hides it from the
+.Fx
+kernel.
+To work around this limitation,
+.Fx
+detects that the AHCI device supports RST and when it is enabled.
+See
+.Xr ahci 4
+for more details.
 .Sh SEE ALSO
 .Xr nda 4 ,
 .Xr nvd 4 ,
___
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: r351356 - in head/sys: conf dev/ahci dev/nvme modules/nvme

2019-08-21 Thread Warner Losh
Author: imp
Date: Wed Aug 21 22:18:01 2019
New Revision: 351356
URL: https://svnweb.freebsd.org/changeset/base/351356

Log:
  Create a AHCI attachment for nvme.
  
  Intel has created RST and many laptops from vendors like Lenovo and Asus. 
It's a
  mechanism for creating multiple boot devices under windows. It effectively 
hides
  the nvme drive inside of the ahci controller. The details are supposed to be a
  trade secret. However, there's a reverse engineered Linux driver, and this
  implements similar operations to allow nvme drives to attach. The ahci driver
  attaches nvme children that proxy the remapped resources to the child. 
nvme_ahci
  is just like nvme_pci, except it doesn't do the PCI specific things. That's
  moved into ahci where appropriate.
  
  When the nvme drive is remapped, MSI-x interrupts aren't forwarded (the linux
  driver doesn't know how to use this either). INTx interrupts are used
  instead. This is suboptimal, but usually sufficient for the laptops these 
parts
  are in.
  
  This is based loosely on https://www.spinics.net/lists/linux-ide/msg53364.html
  submitted, but not accepted by, Linux. It was written by Dan Williams. These
  changes were written from scratch by Olivier Houchard.
  
  Submitted by: cognet@ (Olivier Houchard)

Added:
  head/sys/dev/nvme/nvme_ahci.c   (contents, props changed)
Modified:
  head/sys/conf/files
  head/sys/dev/ahci/ahci.c
  head/sys/dev/ahci/ahci.h
  head/sys/dev/ahci/ahci_pci.c
  head/sys/modules/nvme/Makefile

Modified: head/sys/conf/files
==
--- head/sys/conf/files Wed Aug 21 22:17:55 2019(r351355)
+++ head/sys/conf/files Wed Aug 21 22:18:01 2019(r351356)
@@ -2479,6 +2479,7 @@ dev/nmdm/nmdm.c   optional nmdm
 dev/null/null.cstandard
 dev/nvd/nvd.c  optional nvd nvme
 dev/nvme/nvme.coptional nvme
+dev/nvme/nvme_ahci.c   optional nvme ahci
 dev/nvme/nvme_ctrlr.c  optional nvme
 dev/nvme/nvme_ctrlr_cmd.c  optional nvme
 dev/nvme/nvme_ns.c optional nvme

Modified: head/sys/dev/ahci/ahci.c
==
--- head/sys/dev/ahci/ahci.cWed Aug 21 22:17:55 2019(r351355)
+++ head/sys/dev/ahci/ahci.cWed Aug 21 22:18:01 2019(r351356)
@@ -347,6 +347,16 @@ ahci_attach(device_t dev)
if ((ctlr->ichannels & (1 << unit)) == 0)
device_disable(child);
}
+   /* Attach any remapped NVME device */
+   for (; unit < ctlr->channels + ctlr->remapped_devices; unit++) {
+   child = device_add_child(dev, "nvme", -1);
+   if (child == NULL) {
+   device_printf(dev, "failed to add remapped NVMe 
device");
+   continue;
+   }
+   device_set_ivars(child, (void *)(intptr_t)(unit | 
AHCI_REMAPPED_UNIT));
+   }
+
if (ctlr->caps & AHCI_CAP_EMS) {
child = device_add_child(dev, "ahciem", -1);
if (child == NULL)
@@ -497,6 +507,12 @@ ahci_intr(void *data)
ctlr->interrupt[unit].function(arg);
}
}
+   for (; unit < ctlr->channels + ctlr->remapped_devices; unit++) {
+   if ((arg = ctlr->interrupt[unit].argument)) {
+   ctlr->interrupt[unit].function(arg);
+   }
+   }
+
/* AHCI declares level triggered IS. */
if (!(ctlr->quirks & AHCI_Q_EDGEIS))
ATA_OUTL(ctlr->r_mem, AHCI_IS, is);
@@ -546,12 +562,23 @@ ahci_alloc_resource(device_t dev, device_t child, int 
struct resource *res;
rman_res_t st;
int offset, size, unit;
+   bool is_remapped;
 
unit = (intptr_t)device_get_ivars(child);
+   if (unit & AHCI_REMAPPED_UNIT) {
+   unit &= ~AHCI_REMAPPED_UNIT;
+   unit -= ctlr->channels;
+   is_remapped = true;
+   } else
+   is_remapped = false;
res = NULL;
switch (type) {
case SYS_RES_MEMORY:
-   if (unit >= 0) {
+   if (is_remapped) {
+   offset = ctlr->remap_offset + unit * ctlr->remap_size;
+   size = ctlr->remap_size;
+   }
+   else if (unit >= 0) {
offset = AHCI_OFFSET + (unit << 7);
size = 128;
} else if (*rid == 0) {
@@ -612,7 +639,7 @@ ahci_setup_intr(device_t dev, device_t child, struct r
 void *argument, void **cookiep)
 {
struct ahci_controller *ctlr = device_get_softc(dev);
-   int unit = (intptr_t)device_get_ivars(child);
+   int unit = (intptr_t)device_get_ivars(child) & ~AHCI_REMAPPED_UNIT;
 
if (filter != NULL) {
printf("ahci.c: we cannot use a filter 

Re: svn commit: r351253 - in head/contrib/libc++: include src

2019-08-21 Thread Tijl Coosemans
On Wed, 21 Aug 2019 18:52:31 +0300 Konstantin Belousov
 wrote:
> On Wed, Aug 21, 2019 at 02:49:08PM +0200, Tijl Coosemans wrote:
>> On Tue, 20 Aug 2019 17:39:33 + (UTC) Dimitry Andric
>>  wrote:  
>>> Author: dim
>>> Date: Tue Aug 20 17:39:32 2019
>>> New Revision: 351253
>>> URL: https://svnweb.freebsd.org/changeset/base/351253
>>> 
>>> Log:
>>>   Pull in r368867 from upstream libc++ trunk (by Marshall Clow):
>>>   
>>> Rework recursive_timed_mutex so that it uses __thread_id instead of
>>> using the lower-level __libcpp_thread_id. This is prep for fixing
>>> PR42918. Reviewed as https://reviews.llvm.org/D65895
>>>   
>>>   Pull in r368916 from upstream libc++ trunk (by Marshall Clow):
>>>   
>>> Fix thread comparison by making sure we never pass our special 'not a
>>> thread' value to the underlying implementation. Fixes PR#42918.
>>>   
>>>   This should fix std::thread::id::operator==() attempting to call
>>>   pthread_equal(3) with zero values.
>>>   
>>>   Reported by:  and...@tao11.riddles.org.uk
>>>   PR:   239038, 239550
>>>   MFC after:3 days
>>> 
>>> Modified:
>>>   head/contrib/libc++/include/__threading_support
>>>   head/contrib/libc++/include/mutex
>>>   head/contrib/libc++/include/thread
>>>   head/contrib/libc++/src/mutex.cpp
>>> 
>>> Modified: head/contrib/libc++/include/__threading_support
>>> ==
>>> --- head/contrib/libc++/include/__threading_support Tue Aug 20 17:00:31 
>>> 2019(r351252)
>>> +++ head/contrib/libc++/include/__threading_support Tue Aug 20 17:39:32 
>>> 2019(r351253)
>>> @@ -13,6 +13,7 @@
>>>  
>>>  #include <__config>
>>>  #include 
>>> +#include 
>>>  #include 
>>>  
>>>  #ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
>>> @@ -392,6 +393,86 @@ int __libcpp_tls_set(__libcpp_tls_key __key, void *__p
>>>  }
>>>  
>>>  #endif // !_LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL || 
>>> _LIBCPP_BUILDING_THREAD_LIBRARY_EXTERNAL
>>> +
>>> +class _LIBCPP_TYPE_VIS thread;  
>> 
>> This seems to break building Firefox:
>> 
>> In file included from 
>> /usr/ports/www/firefox/work/firefox-68.0.2/media/mtransport/nricectx.cpp:82:
>> In file included from 
>> /usr/ports/www/firefox/work/firefox-68.0.2/media/mtransport/third_party/nICEr/src/stun/stun_client_ctx.h:41:
>> In file included from 
>> /usr/ports/www/firefox/work/firefox-68.0.2/media/mtransport/third_party/nICEr/src/stun/stun.h:45:
>> In file included from /usr/include/net/if_var.h:84:
>> /usr/include/sys/lock.h:68:15: error: reference to 'thread' is ambiguous
>> struct thread **owner);
>>^
>> /usr/include/sys/lock.h:42:8: note: candidate found by name lookup is 
>> 'thread'
>> struct thread;
>>^
>> /usr/include/c++/v1/__threading_support:397:24: note: candidate found by name
>>   lookup is 'std::__1::thread'
>> class _LIBCPP_TYPE_VIS thread;
>>^
>> 
>> 
>> This "class thread" conflicts with "struct thread" in sys/lock.h.
>> Should everything in sys/lock.h be under #ifdef _KERNEL?  
> Why does firefox pulls if_var.h at all ?  (As I understand, this is how
> the pollution occurs.)

Right, it turns out it doesn't need it:

--- media/mtransport/third_party/nICEr/src/stun/stun.h.orig 2019-08-13 
18:06:44 UTC
+++ media/mtransport/third_party/nICEr/src/stun/stun.h
@@ -41,7 +41,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY O
 #include 
 #ifndef LINUX
 #include 
-#if !defined(__OpenBSD__) && !defined(__NetBSD__)
+#if !defined(__OpenBSD__) && !defined(__NetBSD__) && !defined(__FreeBSD__)
 #include 
 #endif
 #include 
___
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: r351354 - head/sbin/ping

2019-08-21 Thread Alan Somers
Author: asomers
Date: Wed Aug 21 21:05:15 2019
New Revision: 351354
URL: https://svnweb.freebsd.org/changeset/base/351354

Log:
  ping: add -H option for enabling reverse DNS lookup
  
  This is the reverse of the -n flag.
  
  Submitted by: Ján Sučan 
  Sponsored by: Google LLC (Google Summer of Code 2019)
  Differential Revision:https://reviews.freebsd.org/D21356

Modified:
  head/sbin/ping/ping.8
  head/sbin/ping/ping.c

Modified: head/sbin/ping/ping.8
==
--- head/sbin/ping/ping.8   Wed Aug 21 20:44:42 2019(r351353)
+++ head/sbin/ping/ping.8   Wed Aug 21 21:05:15 2019(r351354)
@@ -28,7 +28,7 @@
 .\" @(#)ping.8 8.2 (Berkeley) 12/11/93
 .\" $FreeBSD$
 .\"
-.Dd March 11, 2016
+.Dd August 21, 2019
 .Dt PING 8
 .Os
 .Sh NAME
@@ -38,7 +38,7 @@
 packets to network hosts
 .Sh SYNOPSIS
 .Nm
-.Op Fl AaDdfnoQqRrv
+.Op Fl AaDdfHnoQqRrv
 .Op Fl c Ar count
 .Op Fl G Ar sweepmaxsize
 .Op Fl g Ar sweepminsize
@@ -56,7 +56,7 @@ packets to network hosts
 .Op Fl z Ar tos
 .Ar host
 .Nm
-.Op Fl AaDdfLnoQqRrv
+.Op Fl AaDdfHLnoQqRrv
 .Op Fl c Ar count
 .Op Fl I Ar iface
 .Op Fl i Ar wait
@@ -157,6 +157,14 @@ Specify the size of
 .Tn ICMP
 payload to start with when sending sweeping pings.
 The default value is 0.
+.It Fl H
+Hostname output.
+Try to do a reverse DNS lookup when displaying addresses.
+This is the opposite of
+.Fl n ,
+and it is the default behavior.
+.Nm
+utility tries reverse-lookup by default.
 .It Fl h Ar sweepincrsize
 Specify the number of bytes to increment the size of
 .Tn ICMP

Modified: head/sbin/ping/ping.c
==
--- head/sbin/ping/ping.c   Wed Aug 21 20:44:42 2019(r351353)
+++ head/sbin/ping/ping.c   Wed Aug 21 21:05:15 2019(r351354)
@@ -297,7 +297,7 @@ main(int argc, char *const *argv)
 
outpack = outpackhdr + sizeof(struct ip);
while ((ch = getopt(argc, argv,
-   "Aac:DdfG:g:h:I:i:Ll:M:m:nop:QqRrS:s:T:t:vW:z:"
+   "Aac:DdfG:g:Hh:I:i:Ll:M:m:nop:QqRrS:s:T:t:vW:z:"
 #ifdef IPSEC
 #ifdef IPSEC_POLICY_IPSEC
"P:"
@@ -363,6 +363,9 @@ main(int argc, char *const *argv)
options |= F_SWEEP;
sweepmin = ltmp;
break;
+   case 'H':
+   options &= ~F_NUMERIC;
+   break;
case 'h': /* Packet size increment for ping sweep */
ltmp = strtol(optarg, , 0);
if (*ep || ep == optarg || ltmp < 1)
@@ -1743,11 +1746,11 @@ usage(void)
 {
 
(void)fprintf(stderr, "%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n",
-"usage: ping [-AaDdfnoQqRrv] [-c count] [-G sweepmaxsize] [-g sweepminsize]",
+"usage: ping [-AaDdfHnoQqRrv] [-c count] [-G sweepmaxsize] [-g sweepminsize]",
 "[-h sweepincrsize] [-i wait] [-l preload] [-M mask | time] [-m 
ttl]",
 "   " SECOPT " [-p pattern] [-S src_addr] [-s packetsize] [-t 
timeout]",
 "[-W waittime] [-z tos] host",
-"   ping [-AaDdfLnoQqRrv] [-c count] [-I iface] [-i wait] [-l preload]",
+"   ping [-AaDdfHLnoQqRrv] [-c count] [-I iface] [-i wait] [-l preload]",
 "[-M mask | time] [-m ttl]" SECOPT " [-p pattern] [-S src_addr]",
 "[-s packetsize] [-T ttl] [-t timeout] [-W waittime]",
 "[-z tos] mcast-group");
___
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: r351352 - head/sys/dev/nvme

2019-08-21 Thread Alexander Motin
Author: mav
Date: Wed Aug 21 20:17:30 2019
New Revision: 351352
URL: https://svnweb.freebsd.org/changeset/base/351352

Log:
  Improve NVMe hot unplug handling.
  
  If device is unplugged from the system (CSTS register reads return
  0x), it makes no sense to send any more recovery requests or
  expect any responses back.  If there is a detach call in such state,
  just stop all activity and free resources.  If there is no detach
  call (hot-plug is not supported), rely on normal timeout handling,
  but when it trigger controller reset, do not wait for impossible and
  quickly report failure.
  
  MFC after:2 weeks
  Sponsored by: iXsystems, Inc.

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

Modified: head/sys/dev/nvme/nvme_ctrlr.c
==
--- head/sys/dev/nvme/nvme_ctrlr.c  Wed Aug 21 20:01:52 2019
(r351351)
+++ head/sys/dev/nvme/nvme_ctrlr.c  Wed Aug 21 20:17:30 2019
(r351352)
@@ -207,10 +207,13 @@ nvme_ctrlr_fail(struct nvme_controller *ctrlr)
int i;
 
ctrlr->is_failed = TRUE;
+   nvme_admin_qpair_disable(>adminq);
nvme_qpair_fail(>adminq);
if (ctrlr->ioq != NULL) {
-   for (i = 0; i < ctrlr->num_io_queues; i++)
+   for (i = 0; i < ctrlr->num_io_queues; i++) {
+   nvme_io_qpair_disable(>ioq[i]);
nvme_qpair_fail(>ioq[i]);
+   }
}
nvme_notify_fail_consumers(ctrlr);
 }
@@ -249,17 +252,20 @@ nvme_ctrlr_wait_for_ready(struct nvme_controller *ctrl
int ms_waited;
uint32_t csts;
 
-   csts = nvme_mmio_read_4(ctrlr, csts);
-
ms_waited = 0;
-   while (((csts >> NVME_CSTS_REG_RDY_SHIFT) & NVME_CSTS_REG_RDY_MASK) != 
desired_val) {
+   while (1) {
+   csts = nvme_mmio_read_4(ctrlr, csts);
+   if (csts == 0x) /* Hot unplug. */
+   return (ENXIO);
+   if (((csts >> NVME_CSTS_REG_RDY_SHIFT) & NVME_CSTS_REG_RDY_MASK)
+   == desired_val)
+   break;
if (ms_waited++ > ctrlr->ready_timeout_in_ms) {
nvme_printf(ctrlr, "controller ready did not become %d "
"within %d ms\n", desired_val, 
ctrlr->ready_timeout_in_ms);
return (ENXIO);
}
DELAY(1000);
-   csts = nvme_mmio_read_4(ctrlr, csts);
}
 
return (0);
@@ -1338,12 +1344,20 @@ nvme_ctrlr_construct(struct nvme_controller *ctrlr, de
 void
 nvme_ctrlr_destruct(struct nvme_controller *ctrlr, device_t dev)
 {
-   int i;
+   int gone, i;
 
if (ctrlr->resource == NULL)
goto nores;
 
-   nvme_notify_fail_consumers(ctrlr);
+   /*
+* Check whether it is a hot unplug or a clean driver detach.
+* If device is not there any more, skip any shutdown commands.
+*/
+   gone = (nvme_mmio_read_4(ctrlr, csts) == 0x);
+   if (gone)
+   nvme_ctrlr_fail(ctrlr);
+   else
+   nvme_notify_fail_consumers(ctrlr);
 
for (i = 0; i < NVME_MAX_NAMESPACES; i++)
nvme_ns_destruct(>ns[i]);
@@ -1351,12 +1365,11 @@ nvme_ctrlr_destruct(struct nvme_controller *ctrlr, dev
if (ctrlr->cdev)
destroy_dev(ctrlr->cdev);
 
-   nvme_ctrlr_destroy_qpairs(ctrlr);
-   for (i = 0; i < ctrlr->num_io_queues; i++) {
+   if (!gone)
+   nvme_ctrlr_destroy_qpairs(ctrlr);
+   for (i = 0; i < ctrlr->num_io_queues; i++)
nvme_io_qpair_destroy(>ioq[i]);
-   }
free(ctrlr->ioq, M_NVME);
-
nvme_admin_qpair_destroy(>adminq);
 
/*
@@ -1366,9 +1379,11 @@ nvme_ctrlr_destruct(struct nvme_controller *ctrlr, dev
 *   shutdown notification in case the system is shutdown before
 *   reloading the driver.
 */
-   nvme_ctrlr_shutdown(ctrlr);
+   if (!gone)
+   nvme_ctrlr_shutdown(ctrlr);
 
-   nvme_ctrlr_disable(ctrlr);
+   if (!gone)
+   nvme_ctrlr_disable(ctrlr);
 
if (ctrlr->taskqueue)
taskqueue_free(ctrlr->taskqueue);
@@ -1407,14 +1422,19 @@ nvme_ctrlr_shutdown(struct nvme_controller *ctrlr)
cc |= NVME_SHN_NORMAL << NVME_CC_REG_SHN_SHIFT;
nvme_mmio_write_4(ctrlr, cc, cc);
 
-   csts = nvme_mmio_read_4(ctrlr, csts);
-   while ((NVME_CSTS_GET_SHST(csts) != NVME_SHST_COMPLETE) && (ticks++ < 
5*hz)) {
-   pause("nvme shn", 1);
+   while (1) {
csts = nvme_mmio_read_4(ctrlr, csts);
+   if (csts == 0x) /* Hot unplug. */
+   break;
+   if (NVME_CSTS_GET_SHST(csts) == NVME_SHST_COMPLETE)
+   break;
+   if 

svn commit: r351351 - head/sys/kern

2019-08-21 Thread Mark Johnston
Author: markj
Date: Wed Aug 21 20:01:52 2019
New Revision: 351351
URL: https://svnweb.freebsd.org/changeset/base/351351

Log:
  Remove manual wire_count adjustments from the unmapped mbuf code.
  
  The original code came from a desire to minimize the number of updates
  to v_wire_count, which prior to r329187 was updated using atomics.
  However, there is no significant benefit to batching today, so simply
  allocate pages using VM_ALLOC_WIRED and rely on system accounting.
  
  Reviewed by:  jhb
  Differential Revision:https://reviews.freebsd.org/D21323

Modified:
  head/sys/kern/uipc_mbuf.c

Modified: head/sys/kern/uipc_mbuf.c
==
--- head/sys/kern/uipc_mbuf.c   Wed Aug 21 19:57:54 2019(r351350)
+++ head/sys/kern/uipc_mbuf.c   Wed Aug 21 20:01:52 2019(r351351)
@@ -1616,22 +1616,18 @@ mb_free_mext_pgs(struct mbuf *m)
 {
struct mbuf_ext_pgs *ext_pgs;
vm_page_t pg;
-   int wire_adj;
 
MBUF_EXT_PGS_ASSERT(m);
ext_pgs = m->m_ext.ext_pgs;
-   wire_adj = 0;
for (int i = 0; i < ext_pgs->npgs; i++) {
pg = PHYS_TO_VM_PAGE(ext_pgs->pa[i]);
/*
 * Note: page is not locked, as it has no
 * object and is not on any queues.
 */
-   vm_page_free_toq(pg);
-   wire_adj++;
+   vm_page_unwire_noq(pg);
+   vm_page_free(pg);
}
-   if (wire_adj)
-   vm_wire_sub(wire_adj);
 }
 
 static struct mbuf *
@@ -1640,9 +1636,10 @@ m_uiotombuf_nomap(struct uio *uio, int how, int len, i
struct mbuf *m, *mb, *prev;
struct mbuf_ext_pgs *pgs;
vm_page_t pg_array[MBUF_PEXT_MAX_PGS];
-   int error, length, i, needed, wire_adj = 0;
+   int error, length, i, needed;
ssize_t total;
-   int pflags = malloc2vm_flags(how) | VM_ALLOC_NOOBJ | VM_ALLOC_NODUMP;
+   int pflags = malloc2vm_flags(how) | VM_ALLOC_NOOBJ | VM_ALLOC_NODUMP |
+   VM_ALLOC_WIRED;
 
/*
 * len can be zero or an arbitrary large value bound by
@@ -1676,9 +1673,6 @@ m_uiotombuf_nomap(struct uio *uio, int how, int len, i
 retry_page:
pg_array[i] = vm_page_alloc(NULL, 0, pflags);
if (pg_array[i] == NULL) {
-   if (wire_adj)
-   vm_wire_add(wire_adj);
-   wire_adj = 0;
if (how & M_NOWAIT) {
goto failed;
} else {
@@ -1686,15 +1680,12 @@ retry_page:
goto retry_page;
}
}
-   wire_adj++;
pg_array[i]->flags &= ~PG_ZERO;
pgs->pa[i] = VM_PAGE_TO_PHYS(pg_array[i]);
pgs->npgs++;
}
pgs->last_pg_len = length - PAGE_SIZE * (pgs->npgs - 1);
MBUF_EXT_PGS_ASSERT_SANITY(pgs);
-   vm_wire_add(wire_adj);
-   wire_adj = 0;
total -= length;
error = uiomove_fromphys(pg_array, 0, length, uio);
if (error != 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: r351349 - head/lib/libthr/thread

2019-08-21 Thread Konstantin Belousov
Author: kib
Date: Wed Aug 21 19:53:50 2019
New Revision: 351349
URL: https://svnweb.freebsd.org/changeset/base/351349

Log:
  Fix _pthread_cancel_enter() and _pthread_cancel_leave() jmptable entries.
  
  PR:   240022
  Reported by:  Andrew Gierth 
  Sponsored by: The FreeBSD Foundation
  MFC after:3 days

Modified:
  head/lib/libthr/thread/thr_cancel.c
  head/lib/libthr/thread/thr_init.c
  head/lib/libthr/thread/thr_private.h

Modified: head/lib/libthr/thread/thr_cancel.c
==
--- head/lib/libthr/thread/thr_cancel.c Wed Aug 21 19:35:04 2019
(r351348)
+++ head/lib/libthr/thread/thr_cancel.c Wed Aug 21 19:53:50 2019
(r351349)
@@ -43,6 +43,8 @@ __weak_reference(_thr_setcanceltype, pthread_setcancel
 __weak_reference(_thr_setcanceltype, _pthread_setcanceltype);
 __weak_reference(_Tthr_testcancel, pthread_testcancel);
 __weak_reference(_Tthr_testcancel, _pthread_testcancel);
+__weak_reference(_Tthr_cancel_enter, _pthread_cancel_enter);
+__weak_reference(_Tthr_cancel_leave, _pthread_cancel_leave);
 
 static inline void
 testcancel(struct pthread *curthread)
@@ -173,13 +175,13 @@ _thr_cancel_leave(struct pthread *curthread, int mayca
 }
 
 void
-_pthread_cancel_enter(int maycancel)
+_Tthr_cancel_enter(int maycancel)
 {
_thr_cancel_enter2(_get_curthread(), maycancel);
 }
 
 void
-_pthread_cancel_leave(int maycancel)
+_Tthr_cancel_leave(int maycancel)
 {
_thr_cancel_leave(_get_curthread(), maycancel);
 }

Modified: head/lib/libthr/thread/thr_init.c
==
--- head/lib/libthr/thread/thr_init.c   Wed Aug 21 19:35:04 2019
(r351348)
+++ head/lib/libthr/thread/thr_init.c   Wed Aug 21 19:53:50 2019
(r351349)
@@ -265,8 +265,8 @@ static pthread_func_t jmp_table[][2] = {
[PJT_TESTCANCEL] = {DUAL_ENTRY(_Tthr_testcancel)},
[PJT_CLEANUP_POP_IMP] = {DUAL_ENTRY(__thr_cleanup_pop_imp)},
[PJT_CLEANUP_PUSH_IMP] = {DUAL_ENTRY(__thr_cleanup_push_imp)},
-   [PJT_CANCEL_ENTER] = {DUAL_ENTRY(_thr_cancel_enter)},
-   [PJT_CANCEL_LEAVE] = {DUAL_ENTRY(_thr_cancel_leave)},
+   [PJT_CANCEL_ENTER] = {DUAL_ENTRY(_Tthr_cancel_enter)},
+   [PJT_CANCEL_LEAVE] = {DUAL_ENTRY(_Tthr_cancel_leave)},
[PJT_MUTEX_CONSISTENT] = {DUAL_ENTRY(_Tthr_mutex_consistent)},
[PJT_MUTEXATTR_GETROBUST] = {DUAL_ENTRY(_thr_mutexattr_getrobust)},
[PJT_MUTEXATTR_SETROBUST] = {DUAL_ENTRY(_thr_mutexattr_setrobust)},

Modified: head/lib/libthr/thread/thr_private.h
==
--- head/lib/libthr/thread/thr_private.hWed Aug 21 19:35:04 2019
(r351348)
+++ head/lib/libthr/thread/thr_private.hWed Aug 21 19:53:50 2019
(r351349)
@@ -1022,6 +1022,8 @@ void __thr_cleanup_pop_imp(int);
 void _thr_cleanup_push(void (*)(void *), void *);
 void _thr_cleanup_pop(int);
 void _Tthr_testcancel(void);
+void _Tthr_cancel_enter(int);
+void _Tthr_cancel_leave(int);
 int _thr_cancel(pthread_t);
 int _thr_atfork(void (*)(void), void (*)(void), void (*)(void));
 int _thr_attr_destroy(pthread_attr_t *);
___
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: r351348 - head/sys/kern

2019-08-21 Thread Mark Johnston
Author: markj
Date: Wed Aug 21 19:35:04 2019
New Revision: 351348
URL: https://svnweb.freebsd.org/changeset/base/351348

Log:
  Modify pipe_poll() to properly check for pending direct writes.
  
  With r349546, it is a responsibility of the writer to clear PIPE_DIRECTW
  after pinned data has been read.  In particular, once a reader has
  drained this data, there is a small window where the pipe is empty but
  PIPE_DIRECTW is set.  pipe_poll() was using the presence of PIPE_DIRECTW
  to determine whether to return POLLIN, so in this window it would
  claim that data was available to read when this was not the case.
  
  Fix this by modifying several checks for PIPE_DIRECTW to instead look
  at the number of residual bytes in data pinned by a direct writer.  In
  some cases we really do want to check for PIPE_DIRECTW, since the
  presence of this flag indicates that any attempt to write to the pipe
  will block on the existing direct writer.
  
  Bisected and test case provided by:   mav
  Tested by:pho
  Reviewed by:  kib
  MFC after:3 days
  Sponsored by: The FreeBSD Foundation
  Differential Revision:https://reviews.freebsd.org/D21333

Modified:
  head/sys/kern/sys_pipe.c

Modified: head/sys/kern/sys_pipe.c
==
--- head/sys/kern/sys_pipe.cWed Aug 21 19:09:40 2019(r351347)
+++ head/sys/kern/sys_pipe.cWed Aug 21 19:35:04 2019(r351348)
@@ -709,11 +709,9 @@ pipe_read(struct file *fp, struct uio *uio, struct ucr
/*
 * Direct copy, bypassing a kernel buffer.
 */
-   } else if ((size = rpipe->pipe_map.cnt) &&
-  (rpipe->pipe_state & PIPE_DIRECTW)) {
+   } else if ((size = rpipe->pipe_map.cnt) != 0) {
if (size > uio->uio_resid)
size = (u_int) uio->uio_resid;
-
PIPE_UNLOCK(rpipe);
error = uiomove_fromphys(rpipe->pipe_map.ms,
rpipe->pipe_map.pos, size, uio);
@@ -819,32 +817,33 @@ pipe_build_write_buffer(struct pipe *wpipe, struct uio
u_int size;
int i;
 
-   PIPE_LOCK_ASSERT(wpipe, MA_NOTOWNED);
-   KASSERT(wpipe->pipe_state & PIPE_DIRECTW,
-   ("Clone attempt on non-direct write pipe!"));
+   PIPE_LOCK_ASSERT(wpipe, MA_OWNED);
+   KASSERT((wpipe->pipe_state & PIPE_DIRECTW) == 0,
+   ("%s: PIPE_DIRECTW set on %p", __func__, wpipe));
+   KASSERT(wpipe->pipe_map.cnt == 0,
+   ("%s: pipe map for %p contains residual data", __func__, wpipe));
 
if (uio->uio_iov->iov_len > wpipe->pipe_buffer.size)
 size = wpipe->pipe_buffer.size;
else
 size = uio->uio_iov->iov_len;
 
-   if ((i = vm_fault_quick_hold_pages(>p_vmspace->vm_map,
+   wpipe->pipe_state |= PIPE_DIRECTW;
+   PIPE_UNLOCK(wpipe);
+   i = vm_fault_quick_hold_pages(>p_vmspace->vm_map,
(vm_offset_t)uio->uio_iov->iov_base, size, VM_PROT_READ,
-   wpipe->pipe_map.ms, PIPENPAGES)) < 0)
+   wpipe->pipe_map.ms, PIPENPAGES);
+   PIPE_LOCK(wpipe);
+   if (i < 0) {
+   wpipe->pipe_state &= ~PIPE_DIRECTW;
return (EFAULT);
+   }
 
-/*
- * set up the control block
- */
wpipe->pipe_map.npages = i;
wpipe->pipe_map.pos =
((vm_offset_t) uio->uio_iov->iov_base) & PAGE_MASK;
wpipe->pipe_map.cnt = size;
 
-/*
- * and update the uio data
- */
-
uio->uio_iov->iov_len -= size;
uio->uio_iov->iov_base = (char *)uio->uio_iov->iov_base + size;
if (uio->uio_iov->iov_len == 0)
@@ -864,6 +863,8 @@ pipe_destroy_write_buffer(struct pipe *wpipe)
PIPE_LOCK_ASSERT(wpipe, MA_OWNED);
KASSERT((wpipe->pipe_state & PIPE_DIRECTW) != 0,
("%s: PIPE_DIRECTW not set on %p", __func__, wpipe));
+   KASSERT(wpipe->pipe_map.cnt == 0,
+   ("%s: pipe map for %p contains residual data", __func__, wpipe));
 
wpipe->pipe_state &= ~PIPE_DIRECTW;
vm_page_unhold_pages(wpipe->pipe_map.ms, wpipe->pipe_map.npages);
@@ -889,6 +890,7 @@ pipe_clone_write_buffer(struct pipe *wpipe)
 
size = wpipe->pipe_map.cnt;
pos = wpipe->pipe_map.pos;
+   wpipe->pipe_map.cnt = 0;
 
wpipe->pipe_buffer.in = size;
wpipe->pipe_buffer.out = 0;
@@ -946,7 +948,6 @@ retry:
else
goto retry;
}
-   wpipe->pipe_map.cnt = 0;/* transfer not ready yet */
if (wpipe->pipe_buffer.cnt > 0) {
if (wpipe->pipe_state & PIPE_WANTR) {
wpipe->pipe_state &= ~PIPE_WANTR;
@@ -963,19 +964,15 @@ retry:
goto retry;
}
 
-   wpipe->pipe_state |= PIPE_DIRECTW;
-
-   PIPE_UNLOCK(wpipe);
error = pipe_build_write_buffer(wpipe, uio);
-   

svn commit: r351347 - head/usr.sbin/makefs/msdos

2019-08-21 Thread Ed Maste
Author: emaste
Date: Wed Aug 21 19:09:40 2019
New Revision: 351347
URL: https://svnweb.freebsd.org/changeset/base/351347

Log:
  makefs: Verify that the BPB media descriptor and FAT ID match
  
  From r322982 in sys/fs/msdosfs.

Modified:
  head/usr.sbin/makefs/msdos/msdosfs_fat.c

Modified: head/usr.sbin/makefs/msdos/msdosfs_fat.c
==
--- head/usr.sbin/makefs/msdos/msdosfs_fat.cWed Aug 21 19:07:13 2019
(r351346)
+++ head/usr.sbin/makefs/msdos/msdosfs_fat.cWed Aug 21 19:09:40 2019
(r351347)
@@ -887,19 +887,17 @@ fillinusemap(struct msdosfsmount *pmp)
 * zero.  These represent free clusters.
 */
pmp->pm_freeclustercount = 0;
-   for (cn = CLUST_FIRST; cn <= pmp->pm_maxcluster; cn++) {
+   for (cn = 0; cn <= pmp->pm_maxcluster; cn++) {
byteoffset = FATOFS(pmp, cn);
bo = byteoffset % pmp->pm_fatblocksize;
-   if (bo == 0 || bp == NULL) {
+   if (bo == 0) {
/* Read new FAT block */
if (bp != NULL)
brelse(bp);
fatblock(pmp, byteoffset, , , NULL);
error = bread(pmp->pm_devvp, bn, bsize, NOCRED, );
-   if (error != 0) {
-   brelse(bp);
+   if (error != 0)
return (error);
-   }
}
if (FAT32(pmp))
readcn = getulong(bp->b_data + bo);
@@ -909,7 +907,19 @@ fillinusemap(struct msdosfsmount *pmp)
readcn >>= 4;
readcn &= pmp->pm_fatmask;
 
-   if (readcn == CLUST_FREE)
+   /*
+* Check if the FAT ID matches the BPB's media descriptor and
+* all other bits are set to 1.
+*/
+   if (cn == 0 && readcn != ((pmp->pm_fatmask & 0xff00) |
+   pmp->pm_bpb.bpbMedia)) {
+#ifdef MSDOSFS_DEBUG
+   printf("mountmsdosfs(): Media descriptor in BPB"
+   "does not match FAT ID\n");
+#endif
+   brelse(bp);
+   return (EINVAL);
+   } else if (readcn == CLUST_FREE)
usemap_free(pmp, cn);
}
if (bp != NULL)
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r351346 - in head: sys/fs/msdosfs usr.sbin/makefs usr.sbin/makefs/ffs usr.sbin/makefs/msdos

2019-08-21 Thread Ed Maste
Author: emaste
Date: Wed Aug 21 19:07:13 2019
New Revision: 351346
URL: https://svnweb.freebsd.org/changeset/base/351346

Log:
  makefs: share denode.h between kernel msdosfs and makefs
  
  There is no need to duplicate this file when it can be trivially
  shared (just exposing sections previously under #ifdef _KERNEL).
  
  MFC with: r351273
  Differential Revision:The FreeBSD Foundation

Deleted:
  head/usr.sbin/makefs/msdos/denode.h
Modified:
  head/sys/fs/msdosfs/denode.h
  head/usr.sbin/makefs/ffs/buf.h
  head/usr.sbin/makefs/msdos.c
  head/usr.sbin/makefs/msdos/msdosfs_conv.c
  head/usr.sbin/makefs/msdos/msdosfs_denode.c
  head/usr.sbin/makefs/msdos/msdosfs_fat.c
  head/usr.sbin/makefs/msdos/msdosfs_lookup.c
  head/usr.sbin/makefs/msdos/msdosfs_vfsops.c
  head/usr.sbin/makefs/msdos/msdosfs_vnops.c

Modified: head/sys/fs/msdosfs/denode.h
==
--- head/sys/fs/msdosfs/denode.hWed Aug 21 18:28:38 2019
(r351345)
+++ head/sys/fs/msdosfs/denode.hWed Aug 21 19:07:13 2019
(r351346)
@@ -213,7 +213,7 @@ struct denode {
 ((dep)->de_Attributes & ATTR_DIRECTORY) ? 0 : (dep)->de_FileSize), 
\
 putushort((dp)->deHighClust, (dep)->de_StartCluster >> 16))
 
-#ifdef _KERNEL
+#if defined(_KERNEL) || defined(MAKEFS)
 
 #defineVTODE(vp)   ((struct denode *)(vp)->v_data)
 #defineDETOV(de)   ((de)->de_vnode)
@@ -262,9 +262,11 @@ struct defid {
 
 extern struct vop_vector msdosfs_vnodeops;
 
+#ifdef _KERNEL
 int msdosfs_lookup(struct vop_cachedlookup_args *);
 int msdosfs_inactive(struct vop_inactive_args *);
 int msdosfs_reclaim(struct vop_reclaim_args *);
+#endif
 
 /*
  * Internal service routine prototypes.
@@ -283,5 +285,5 @@ int deupdat(struct denode *dep, int waitfor);
 int removede(struct denode *pdep, struct denode *dep);
 int detrunc(struct denode *dep, u_long length, int flags, struct ucred *cred);
 int doscheckpath( struct denode *source, struct denode *target);
-#endif /* _KERNEL */
+#endif /* _KERNEL || MAKEFS */
 #endif /* !_FS_MSDOSFS_DENODE_H_ */

Modified: head/usr.sbin/makefs/ffs/buf.h
==
--- head/usr.sbin/makefs/ffs/buf.h  Wed Aug 21 18:28:38 2019
(r351345)
+++ head/usr.sbin/makefs/ffs/buf.h  Wed Aug 21 19:07:13 2019
(r351346)
@@ -45,6 +45,7 @@
 #include 
 #include 
 
+struct componentname;
 struct makefs_fsinfo;
 struct ucred;
 

Modified: head/usr.sbin/makefs/msdos.c
==
--- head/usr.sbin/makefs/msdos.cWed Aug 21 18:28:38 2019
(r351345)
+++ head/usr.sbin/makefs/msdos.cWed Aug 21 19:07:13 2019
(r351346)
@@ -55,17 +55,17 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 
+#include "ffs/buf.h"
 #include "makefs.h"
 #include "msdos.h"
 
 #include 
 #include 
+#include "msdos/direntry.h"
+#include 
 
-#include "ffs/buf.h"
 
 #include "msdos/msdosfsmount.h"
-#include "msdos/direntry.h"
-#include "msdos/denode.h"
 
 static int msdos_populate_dir(const char *, struct denode *, fsnode *,
 fsnode *, fsinfo_t *);

Modified: head/usr.sbin/makefs/msdos/msdosfs_conv.c
==
--- head/usr.sbin/makefs/msdos/msdosfs_conv.c   Wed Aug 21 18:28:38 2019
(r351345)
+++ head/usr.sbin/makefs/msdos/msdosfs_conv.c   Wed Aug 21 19:07:13 2019
(r351346)
@@ -56,13 +56,11 @@ __FBSDID("$FreeBSD$");
 #include 
 
 #include 
+#include "msdos/direntry.h"
+#include "msdos/msdosfsmount.h"
 
 #include "makefs.h"
 #include "msdos.h"
-
-#include "msdos/denode.h"
-#include "msdos/direntry.h"
-#include "msdos/msdosfsmount.h"
 
 static int char8ucs2str(const uint8_t *in, int n, uint16_t *out, int m);
 static void ucs2pad(uint16_t *buf, int len, int size);

Modified: head/usr.sbin/makefs/msdos/msdosfs_denode.c
==
--- head/usr.sbin/makefs/msdos/msdosfs_denode.c Wed Aug 21 18:28:38 2019
(r351345)
+++ head/usr.sbin/makefs/msdos/msdosfs_denode.c Wed Aug 21 19:07:13 2019
(r351346)
@@ -59,18 +59,18 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 
+#include "ffs/buf.h"
+
 #include 
-#include "msdos/denode.h"
-#include "msdos/msdosfsmount.h"
+#include 
+#include 
 #include 
+#include "msdos/msdosfsmount.h"
 
 #include "makefs.h"
 #include "msdos.h"
 
-#include "ffs/buf.h"
 
-#include "msdos/direntry.h"
-
 /*
  * If deget() succeeds it returns with the gotten denode locked().
  *
@@ -208,7 +208,7 @@ deget(struct msdosfsmount *pmp, u_long dirclust, u_lon
  * Truncate the file described by dep to the length specified by length.
  */
 int
-detrunc(struct denode *dep, u_long length, int flags)
+detrunc(struct denode *dep, u_long length, int flags, struct ucred *cred)
 {
int error;
int allerror;
@@ 

Re: svn commit: r351253 - in head/contrib/libc++: include src

2019-08-21 Thread Ian Lepore
On Wed, 2019-08-21 at 09:01 -0700, Marshall Clow wrote:
> On Wed, Aug 21, 2019 at 6:20 AM Tijl Coosemans 
> wrote:
> 
> > On Wed, 21 Aug 2019 15:07:56 +0200 Dimitry Andric 
> > wrote:
> > > On 21 Aug 2019, at 14:49, Tijl Coosemans  wrote:
> > > > On Tue, 20 Aug 2019 17:39:33 + (UTC) Dimitry Andric
> > > >  wrote:
> > > > > Author: dim
> > > > > Date: Tue Aug 20 17:39:32 2019
> > > > > New Revision: 351253
> > > > > URL: https://svnweb.freebsd.org/changeset/base/351253
> > > > > 
> > > > > Log:
> > > > >  Pull in r368867 from upstream libc++ trunk (by Marshall
> > > > > Clow):
> > > > > 
> > > > >Rework recursive_timed_mutex so that it uses __thread_id
> > > > > instead of
> > > > >using the lower-level __libcpp_thread_id. This is prep for
> > > > > fixing
> > > > >PR42918. Reviewed as https://reviews.llvm.org/D65895
> > > > > 
> > > > >  Pull in r368916 from upstream libc++ trunk (by Marshall
> > > > > Clow):
> > > > > 
> > > > >Fix thread comparison by making sure we never pass our
> > > > > special 'not
> > 
> > a
> > > > >thread' value to the underlying implementation. Fixes
> > > > > PR#42918.
> > > > > 
> > > > >  This should fix std::thread::id::operator==() attempting to
> > > > > call
> > > > >  pthread_equal(3) with zero values.
> > > 
> > > ...
> > > > This seems to break building Firefox:
> > > > 
> > > > In file included from
> > 
> > /usr/ports/www/firefox/work/firefox-
> > 68.0.2/media/mtransport/nricectx.cpp:82:
> > > > In file included from
> > 
> > /usr/ports/www/firefox/work/firefox-
> > 68.0.2/media/mtransport/third_party/nICEr/src/stun/stun_client_ctx.
> > h:41:
> > > > In file included from
> > 
> > /usr/ports/www/firefox/work/firefox-
> > 68.0.2/media/mtransport/third_party/nICEr/src/stun/stun.h:45:
> > > > In file included from /usr/include/net/if_var.h:84:
> > > > /usr/include/sys/lock.h:68:15: error: reference to 'thread' is
> > > > ambiguous
> > > >struct thread **owner);
> > > >   ^
> > > > /usr/include/sys/lock.h:42:8: note: candidate found by name
> > > > lookup is
> > 
> > 'thread'
> > > > struct thread;
> > > >   ^
> > > > /usr/include/c++/v1/__threading_support:397:24: note: candidate
> > > > found
> > 
> > by name
> > > >  lookup is 'std::__1::thread'
> > > > class _LIBCPP_TYPE_VIS thread;
> > > >   ^
> > > > 
> > > > This "class thread" conflicts with "struct thread" in
> > > > sys/lock.h.
> > > > Should everything in sys/lock.h be under #ifdef _KERNEL?
> > > 
> > > Maybe, but is Firefox using "using namespace std;" here?  It is a
> > > likely
> > > explanation for the ambiguity between the global struct thread
> > > from
> > > sys/lock.h, and std::thread from libc++.
> > 
> > Yes, several headers in media/mtransport/third_party/nICEr/src
> > start
> > with:
> > 
> > #ifdef __cplusplus
> > using namespace std;
> > extern "C" {
> > #endif /* __cplusplus */
> > 
> 
> libc++ has always had a `std::thread` struct.
> 
> The change here is that forward declaration moved from  to
> <__threading_support>, and
> that was included by .
> 
> 

It doesn't matter what the change was, because the error is in firefox.
It violates the c++ convention that you NEVER put 'using namespace'
statements in a header file.  Never.  Because, this stuff happens if
you do.

-- 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: r351333 - head/sys/vm

2019-08-21 Thread Mark Johnston
Author: markj
Date: Wed Aug 21 16:11:12 2019
New Revision: 351333
URL: https://svnweb.freebsd.org/changeset/base/351333

Log:
  Simplify vm_page_dequeue() and fix an assertion.
  
  - Add a vm_pagequeue_remove() function to physically remove a page
from its queue and update the queue length.
  - Remove vm_page_pagequeue_lockptr() and let vm_page_pagequeue()
return NULL for dequeued pages.
  - Avoid unnecessarily reloading the queue index if vm_page_dequeue()
loses a race with a concurrent queue operation.
  - Correct an always-true assertion: vm_page_dequeue() may be called
from the page allocator with the page unlocked.  The assertion
m->order == VM_NFREEORDER simply tests whether the page has been
removed from the vm_phys free lists; instead, check whether the
page belongs to an object.
  
  Reviewed by:  kib
  MFC after:1 week
  Sponsored by: Netflix
  Differential Revision:https://reviews.freebsd.org/D21341

Modified:
  head/sys/vm/vm_page.c
  head/sys/vm/vm_page.h
  head/sys/vm/vm_pagequeue.h

Modified: head/sys/vm/vm_page.c
==
--- head/sys/vm/vm_page.c   Wed Aug 21 16:01:17 2019(r351332)
+++ head/sys/vm/vm_page.c   Wed Aug 21 16:11:12 2019(r351333)
@@ -3056,21 +3056,15 @@ vm_waitpfault(struct domainset *dset, int timo)
mtx_unlock(_domainset_lock);
 }
 
-struct vm_pagequeue *
+static struct vm_pagequeue *
 vm_page_pagequeue(vm_page_t m)
 {
 
-   return (_pagequeue_domain(m)->vmd_pagequeues[m->queue]);
-}
-
-static struct mtx *
-vm_page_pagequeue_lockptr(vm_page_t m)
-{
uint8_t queue;
 
if ((queue = atomic_load_8(>queue)) == PQ_NONE)
return (NULL);
-   return (_pagequeue_domain(m)->vmd_pagequeues[queue].pq_mutex);
+   return (_pagequeue_domain(m)->vmd_pagequeues[queue]);
 }
 
 static inline void
@@ -3093,10 +3087,8 @@ vm_pqbatch_process_page(struct vm_pagequeue *pq, vm_pa
m, pq, qflags));
 
if ((qflags & PGA_DEQUEUE) != 0) {
-   if (__predict_true((qflags & PGA_ENQUEUED) != 0)) {
-   TAILQ_REMOVE(>pq_pl, m, plinks.q);
-   vm_pagequeue_cnt_dec(pq);
-   }
+   if (__predict_true((qflags & PGA_ENQUEUED) != 0))
+   vm_pagequeue_remove(pq, m);
vm_page_dequeue_complete(m);
} else if ((qflags & (PGA_REQUEUE | PGA_REQUEUE_HEAD)) != 0) {
if ((qflags & PGA_ENQUEUED) != 0)
@@ -3299,16 +3291,14 @@ vm_page_dequeue_deferred_free(vm_page_t m)
 void
 vm_page_dequeue(vm_page_t m)
 {
-   struct mtx *lock, *lock1;
-   struct vm_pagequeue *pq;
+   struct vm_pagequeue *pq, *pq1;
uint8_t aflags;
 
-   KASSERT(mtx_owned(vm_page_lockptr(m)) || m->order == VM_NFREEORDER,
+   KASSERT(mtx_owned(vm_page_lockptr(m)) || m->object == NULL,
("page %p is allocated and unlocked", m));
 
-   for (;;) {
-   lock = vm_page_pagequeue_lockptr(m);
-   if (lock == NULL) {
+   for (pq = vm_page_pagequeue(m);; pq = pq1) {
+   if (pq == NULL) {
/*
 * A thread may be concurrently executing
 * vm_page_dequeue_complete().  Ensure that all queue
@@ -3327,27 +3317,24 @@ vm_page_dequeue(vm_page_t m)
 * critical section.
 */
cpu_spinwait();
+   pq1 = vm_page_pagequeue(m);
continue;
}
-   mtx_lock(lock);
-   if ((lock1 = vm_page_pagequeue_lockptr(m)) == lock)
+   vm_pagequeue_lock(pq);
+   if ((pq1 = vm_page_pagequeue(m)) == pq)
break;
-   mtx_unlock(lock);
-   lock = lock1;
+   vm_pagequeue_unlock(pq);
}
-   KASSERT(lock == vm_page_pagequeue_lockptr(m),
+   KASSERT(pq == vm_page_pagequeue(m),
("%s: page %p migrated directly between queues", __func__, m));
KASSERT((m->aflags & PGA_DEQUEUE) != 0 ||
mtx_owned(vm_page_lockptr(m)),
("%s: queued unlocked page %p", __func__, m));
 
-   if ((m->aflags & PGA_ENQUEUED) != 0) {
-   pq = vm_page_pagequeue(m);
-   TAILQ_REMOVE(>pq_pl, m, plinks.q);
-   vm_pagequeue_cnt_dec(pq);
-   }
+   if ((m->aflags & PGA_ENQUEUED) != 0)
+   vm_pagequeue_remove(pq, m);
vm_page_dequeue_complete(m);
-   mtx_unlock(lock);
+   vm_pagequeue_unlock(pq);
 }
 
 /*

Modified: head/sys/vm/vm_page.h
==
--- head/sys/vm/vm_page.h   Wed Aug 21 16:01:17 2019(r351332)
+++ head/sys/vm/vm_page.h   Wed Aug 21 16:11:12 2019(r351333)
@@ -552,7 +552,6 @@ void 

Re: svn commit: r351253 - in head/contrib/libc++: include src

2019-08-21 Thread Marshall Clow
On Wed, Aug 21, 2019 at 6:20 AM Tijl Coosemans  wrote:

> On Wed, 21 Aug 2019 15:07:56 +0200 Dimitry Andric 
> wrote:
> > On 21 Aug 2019, at 14:49, Tijl Coosemans  wrote:
> >> On Tue, 20 Aug 2019 17:39:33 + (UTC) Dimitry Andric
> >>  wrote:
> >>> Author: dim
> >>> Date: Tue Aug 20 17:39:32 2019
> >>> New Revision: 351253
> >>> URL: https://svnweb.freebsd.org/changeset/base/351253
> >>>
> >>> Log:
> >>>  Pull in r368867 from upstream libc++ trunk (by Marshall Clow):
> >>>
> >>>Rework recursive_timed_mutex so that it uses __thread_id instead of
> >>>using the lower-level __libcpp_thread_id. This is prep for fixing
> >>>PR42918. Reviewed as https://reviews.llvm.org/D65895
> >>>
> >>>  Pull in r368916 from upstream libc++ trunk (by Marshall Clow):
> >>>
> >>>Fix thread comparison by making sure we never pass our special 'not
> a
> >>>thread' value to the underlying implementation. Fixes PR#42918.
> >>>
> >>>  This should fix std::thread::id::operator==() attempting to call
> >>>  pthread_equal(3) with zero values.
> > ...
> >> This seems to break building Firefox:
> >>
> >> In file included from
> /usr/ports/www/firefox/work/firefox-68.0.2/media/mtransport/nricectx.cpp:82:
> >> In file included from
> /usr/ports/www/firefox/work/firefox-68.0.2/media/mtransport/third_party/nICEr/src/stun/stun_client_ctx.h:41:
> >> In file included from
> /usr/ports/www/firefox/work/firefox-68.0.2/media/mtransport/third_party/nICEr/src/stun/stun.h:45:
> >> In file included from /usr/include/net/if_var.h:84:
> >> /usr/include/sys/lock.h:68:15: error: reference to 'thread' is ambiguous
> >>struct thread **owner);
> >>   ^
> >> /usr/include/sys/lock.h:42:8: note: candidate found by name lookup is
> 'thread'
> >> struct thread;
> >>   ^
> >> /usr/include/c++/v1/__threading_support:397:24: note: candidate found
> by name
> >>  lookup is 'std::__1::thread'
> >> class _LIBCPP_TYPE_VIS thread;
> >>   ^
> >>
> >> This "class thread" conflicts with "struct thread" in sys/lock.h.
> >> Should everything in sys/lock.h be under #ifdef _KERNEL?
> >
> > Maybe, but is Firefox using "using namespace std;" here?  It is a likely
> > explanation for the ambiguity between the global struct thread from
> > sys/lock.h, and std::thread from libc++.
>
> Yes, several headers in media/mtransport/third_party/nICEr/src start
> with:
>
> #ifdef __cplusplus
> using namespace std;
> extern "C" {
> #endif /* __cplusplus */
>

libc++ has always had a `std::thread` struct.

The change here is that forward declaration moved from  to
<__threading_support>, and
that was included by .

-- Marshall
___
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: r351332 - head/sys/vm

2019-08-21 Thread Mark Johnston
Author: markj
Date: Wed Aug 21 16:01:17 2019
New Revision: 351332
URL: https://svnweb.freebsd.org/changeset/base/351332

Log:
  Unconditionally enable debug.vm_lowmem.
  
  It is useful for testing purposes to be able to drain UMA caches, so
  do not limit the sysctl to DIAGNOSTIC kernels.
  
  MFC after:1 week
  Sponsored by: Netflix

Modified:
  head/sys/vm/vm_kern.c

Modified: head/sys/vm/vm_kern.c
==
--- head/sys/vm/vm_kern.c   Wed Aug 21 15:52:10 2019(r351331)
+++ head/sys/vm/vm_kern.c   Wed Aug 21 16:01:17 2019(r351332)
@@ -839,7 +839,6 @@ kmem_bootstrap_free(vm_offset_t start, vm_size_t size)
 #endif
 }
 
-#ifdef DIAGNOSTIC
 /*
  * Allow userspace to directly trigger the VM drain routine for testing
  * purposes.
@@ -862,4 +861,3 @@ debug_vm_lowmem(SYSCTL_HANDLER_ARGS)
 
 SYSCTL_PROC(_debug, OID_AUTO, vm_lowmem, CTLTYPE_INT | CTLFLAG_RW, 0, 0,
 debug_vm_lowmem, "I", "set to trigger vm_lowmem event with given flags");
-#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"


Re: svn commit: r351253 - in head/contrib/libc++: include src

2019-08-21 Thread Konstantin Belousov
On Wed, Aug 21, 2019 at 02:49:08PM +0200, Tijl Coosemans wrote:
> On Tue, 20 Aug 2019 17:39:33 + (UTC) Dimitry Andric
>  wrote:
> > Author: dim
> > Date: Tue Aug 20 17:39:32 2019
> > New Revision: 351253
> > URL: https://svnweb.freebsd.org/changeset/base/351253
> > 
> > Log:
> >   Pull in r368867 from upstream libc++ trunk (by Marshall Clow):
> >   
> > Rework recursive_timed_mutex so that it uses __thread_id instead of
> > using the lower-level __libcpp_thread_id. This is prep for fixing
> > PR42918. Reviewed as https://reviews.llvm.org/D65895
> >   
> >   Pull in r368916 from upstream libc++ trunk (by Marshall Clow):
> >   
> > Fix thread comparison by making sure we never pass our special 'not a
> > thread' value to the underlying implementation. Fixes PR#42918.
> >   
> >   This should fix std::thread::id::operator==() attempting to call
> >   pthread_equal(3) with zero values.
> >   
> >   Reported by:  and...@tao11.riddles.org.uk
> >   PR:   239038, 239550
> >   MFC after:3 days
> > 
> > Modified:
> >   head/contrib/libc++/include/__threading_support
> >   head/contrib/libc++/include/mutex
> >   head/contrib/libc++/include/thread
> >   head/contrib/libc++/src/mutex.cpp
> > 
> > Modified: head/contrib/libc++/include/__threading_support
> > ==
> > --- head/contrib/libc++/include/__threading_support Tue Aug 20 17:00:31 
> > 2019(r351252)
> > +++ head/contrib/libc++/include/__threading_support Tue Aug 20 17:39:32 
> > 2019(r351253)
> > @@ -13,6 +13,7 @@
> >  
> >  #include <__config>
> >  #include 
> > +#include 
> >  #include 
> >  
> >  #ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
> > @@ -392,6 +393,86 @@ int __libcpp_tls_set(__libcpp_tls_key __key, void *__p
> >  }
> >  
> >  #endif // !_LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL || 
> > _LIBCPP_BUILDING_THREAD_LIBRARY_EXTERNAL
> > +
> > +class _LIBCPP_TYPE_VIS thread;
> 
> This seems to break building Firefox:
> 
> In file included from 
> /home/root/obj/ports/home/tijl/projects/freebsd/ports/head/www/firefox/work/firefox-68.0.2/media/mtransport/nricectx.cpp:82:
> In file included from 
> /home/root/obj/ports/home/tijl/projects/freebsd/ports/head/www/firefox/work/firefox-68.0.2/media/mtransport/third_party/nICEr/src/stun/stun_client_ctx.h:41:
> In file included from 
> /home/root/obj/ports/home/tijl/projects/freebsd/ports/head/www/firefox/work/firefox-68.0.2/media/mtransport/third_party/nICEr/src/stun/stun.h:45:
> In file included from /usr/include/net/if_var.h:84:
> /usr/include/sys/lock.h:68:15: error: reference to 'thread' is ambiguous
> struct thread **owner);
>^
> /usr/include/sys/lock.h:42:8: note: candidate found by name lookup is 'thread'
> struct thread;
>^
> /usr/include/c++/v1/__threading_support:397:24: note: candidate found by name
>   lookup is 'std::__1::thread'
> class _LIBCPP_TYPE_VIS thread;
>^
> 
> 
> This "class thread" conflicts with "struct thread" in sys/lock.h.
> Should everything in sys/lock.h be under #ifdef _KERNEL?
Why does firefox pulls if_var.h at all ?  (As I understand, this is how
the pollution occurs.)
___
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: r351331 - head/sys/vm

2019-08-21 Thread Mark Johnston
Author: markj
Date: Wed Aug 21 15:52:10 2019
New Revision: 351331
URL: https://svnweb.freebsd.org/changeset/base/351331

Log:
  Don't requeue active pages in vm_swapout_object_deactivate_pages().
  
  As of r332974 the page daemon does not requeue pages during a scan
  of the active queue, so there is not much value in doing so here
  either.
  
  Reviewed by:  alc, dougm, kib
  MFC after:1 week
  Sponsored by: Netflix
  Differential Revision:https://reviews.freebsd.org/D21343

Modified:
  head/sys/vm/vm_swapout.c

Modified: head/sys/vm/vm_swapout.c
==
--- head/sys/vm/vm_swapout.cWed Aug 21 14:52:12 2019(r351330)
+++ head/sys/vm/vm_swapout.cWed Aug 21 15:52:10 2019(r351331)
@@ -226,20 +226,22 @@ vm_swapout_object_deactivate_pages(pmap_t pmap, vm_obj
vm_page_activate(p);
p->act_count += act_delta;
} else if (vm_page_active(p)) {
+   /*
+* The page daemon does not requeue pages
+* after modifying their activation count.
+*/
if (act_delta == 0) {
p->act_count -= min(p->act_count,
ACT_DECLINE);
if (!remove_mode && p->act_count == 0) {
pmap_remove_all(p);
vm_page_deactivate(p);
-   } else
-   vm_page_requeue(p);
+   }
} else {
vm_page_activate(p);
if (p->act_count < ACT_MAX -
ACT_ADVANCE)
p->act_count += ACT_ADVANCE;
-   vm_page_requeue(p);
}
} else if (vm_page_inactive(p))
pmap_remove_all(p);
___
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: r351330 - head/sbin/ping

2019-08-21 Thread Alan Somers
Author: asomers
Date: Wed Aug 21 14:52:12 2019
New Revision: 351330
URL: https://svnweb.freebsd.org/changeset/base/351330

Log:
  ping: do reverse DNS lookup of the target address
  
  When printing replies, ping will now attempt a reverse DNS lookup of the
  target.  That can be suppressed by using the "-n" option.  Curiously, ping
  has always done reverse lookups in certain error paths, but never in the
  success path.
  
  Submitted by: Ján Sučan 
  MFC after:2 weeks
  Sponsored by: Google LLC (Google Summer of Code 2019)
  Differential Revision:https://reviews.freebsd.org/D21351

Modified:
  head/sbin/ping/ping.c

Modified: head/sbin/ping/ping.c
==
--- head/sbin/ping/ping.c   Wed Aug 21 10:54:52 2019(r351329)
+++ head/sbin/ping/ping.c   Wed Aug 21 14:52:12 2019(r351330)
@@ -1168,8 +1168,7 @@ pr_pack(char *buf, int cc, struct sockaddr_in *from, s
(void)write(STDOUT_FILENO, , 1);
else {
(void)printf("%d bytes from %s: icmp_seq=%u", cc,
-  inet_ntoa(*(struct in_addr *)>sin_addr.s_addr),
-  seq);
+   pr_addr(from->sin_addr), seq);
(void)printf(" ttl=%d", ip->ip_ttl);
if (timing)
(void)printf(" time=%.3f ms", triptime);
___
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: r351253 - in head/contrib/libc++: include src

2019-08-21 Thread Tijl Coosemans
On Wed, 21 Aug 2019 15:07:56 +0200 Dimitry Andric 
wrote:
> On 21 Aug 2019, at 14:49, Tijl Coosemans  wrote:
>> On Tue, 20 Aug 2019 17:39:33 + (UTC) Dimitry Andric
>>  wrote:  
>>> Author: dim
>>> Date: Tue Aug 20 17:39:32 2019
>>> New Revision: 351253
>>> URL: https://svnweb.freebsd.org/changeset/base/351253
>>> 
>>> Log:
>>>  Pull in r368867 from upstream libc++ trunk (by Marshall Clow):
>>> 
>>>Rework recursive_timed_mutex so that it uses __thread_id instead of
>>>using the lower-level __libcpp_thread_id. This is prep for fixing
>>>PR42918. Reviewed as https://reviews.llvm.org/D65895
>>> 
>>>  Pull in r368916 from upstream libc++ trunk (by Marshall Clow):
>>> 
>>>Fix thread comparison by making sure we never pass our special 'not a
>>>thread' value to the underlying implementation. Fixes PR#42918.
>>> 
>>>  This should fix std::thread::id::operator==() attempting to call
>>>  pthread_equal(3) with zero values.  
> ...
>> This seems to break building Firefox:
>> 
>> In file included from 
>> /usr/ports/www/firefox/work/firefox-68.0.2/media/mtransport/nricectx.cpp:82:
>> In file included from 
>> /usr/ports/www/firefox/work/firefox-68.0.2/media/mtransport/third_party/nICEr/src/stun/stun_client_ctx.h:41:
>> In file included from 
>> /usr/ports/www/firefox/work/firefox-68.0.2/media/mtransport/third_party/nICEr/src/stun/stun.h:45:
>> In file included from /usr/include/net/if_var.h:84:
>> /usr/include/sys/lock.h:68:15: error: reference to 'thread' is ambiguous
>>struct thread **owner);
>>   ^
>> /usr/include/sys/lock.h:42:8: note: candidate found by name lookup is 
>> 'thread'
>> struct thread;
>>   ^
>> /usr/include/c++/v1/__threading_support:397:24: note: candidate found by name
>>  lookup is 'std::__1::thread'
>> class _LIBCPP_TYPE_VIS thread;
>>   ^
>> 
>> This "class thread" conflicts with "struct thread" in sys/lock.h.
>> Should everything in sys/lock.h be under #ifdef _KERNEL?  
> 
> Maybe, but is Firefox using "using namespace std;" here?  It is a likely
> explanation for the ambiguity between the global struct thread from
> sys/lock.h, and std::thread from libc++.

Yes, several headers in media/mtransport/third_party/nICEr/src start
with:

#ifdef __cplusplus
using namespace std;
extern "C" {
#endif /* __cplusplus */
___
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: r351253 - in head/contrib/libc++: include src

2019-08-21 Thread Dimitry Andric
On 21 Aug 2019, at 14:49, Tijl Coosemans  wrote:
> 
> On Tue, 20 Aug 2019 17:39:33 + (UTC) Dimitry Andric
>  wrote:
>> Author: dim
>> Date: Tue Aug 20 17:39:32 2019
>> New Revision: 351253
>> URL: https://svnweb.freebsd.org/changeset/base/351253
>> 
>> Log:
>>  Pull in r368867 from upstream libc++ trunk (by Marshall Clow):
>> 
>>Rework recursive_timed_mutex so that it uses __thread_id instead of
>>using the lower-level __libcpp_thread_id. This is prep for fixing
>>PR42918. Reviewed as https://reviews.llvm.org/D65895
>> 
>>  Pull in r368916 from upstream libc++ trunk (by Marshall Clow):
>> 
>>Fix thread comparison by making sure we never pass our special 'not a
>>thread' value to the underlying implementation. Fixes PR#42918.
>> 
>>  This should fix std::thread::id::operator==() attempting to call
>>  pthread_equal(3) with zero values.
...
> This seems to break building Firefox:
> 
> In file included from 
> /home/root/obj/ports/home/tijl/projects/freebsd/ports/head/www/firefox/work/firefox-68.0.2/media/mtransport/nricectx.cpp:82:
> In file included from 
> /home/root/obj/ports/home/tijl/projects/freebsd/ports/head/www/firefox/work/firefox-68.0.2/media/mtransport/third_party/nICEr/src/stun/stun_client_ctx.h:41:
> In file included from 
> /home/root/obj/ports/home/tijl/projects/freebsd/ports/head/www/firefox/work/firefox-68.0.2/media/mtransport/third_party/nICEr/src/stun/stun.h:45:
> In file included from /usr/include/net/if_var.h:84:
> /usr/include/sys/lock.h:68:15: error: reference to 'thread' is ambiguous
>struct thread **owner);
>   ^
> /usr/include/sys/lock.h:42:8: note: candidate found by name lookup is 'thread'
> struct thread;
>   ^
> /usr/include/c++/v1/__threading_support:397:24: note: candidate found by name
>  lookup is 'std::__1::thread'
> class _LIBCPP_TYPE_VIS thread;
>   ^
> 
> 
> This "class thread" conflicts with "struct thread" in sys/lock.h.
> Should everything in sys/lock.h be under #ifdef _KERNEL?

Maybe, but is Firefox using "using namespace std;" here?  It is a likely
explanation for the ambiguity between the global struct thread from
sys/lock.h, and std::thread from libc++.

-Dimitry



signature.asc
Description: Message signed with OpenPGP


Re: svn commit: r351253 - in head/contrib/libc++: include src

2019-08-21 Thread Tijl Coosemans
On Tue, 20 Aug 2019 17:39:33 + (UTC) Dimitry Andric
 wrote:
> Author: dim
> Date: Tue Aug 20 17:39:32 2019
> New Revision: 351253
> URL: https://svnweb.freebsd.org/changeset/base/351253
> 
> Log:
>   Pull in r368867 from upstream libc++ trunk (by Marshall Clow):
>   
> Rework recursive_timed_mutex so that it uses __thread_id instead of
> using the lower-level __libcpp_thread_id. This is prep for fixing
> PR42918. Reviewed as https://reviews.llvm.org/D65895
>   
>   Pull in r368916 from upstream libc++ trunk (by Marshall Clow):
>   
> Fix thread comparison by making sure we never pass our special 'not a
> thread' value to the underlying implementation. Fixes PR#42918.
>   
>   This should fix std::thread::id::operator==() attempting to call
>   pthread_equal(3) with zero values.
>   
>   Reported by:and...@tao11.riddles.org.uk
>   PR: 239038, 239550
>   MFC after:  3 days
> 
> Modified:
>   head/contrib/libc++/include/__threading_support
>   head/contrib/libc++/include/mutex
>   head/contrib/libc++/include/thread
>   head/contrib/libc++/src/mutex.cpp
> 
> Modified: head/contrib/libc++/include/__threading_support
> ==
> --- head/contrib/libc++/include/__threading_support   Tue Aug 20 17:00:31 
> 2019(r351252)
> +++ head/contrib/libc++/include/__threading_support   Tue Aug 20 17:39:32 
> 2019(r351253)
> @@ -13,6 +13,7 @@
>  
>  #include <__config>
>  #include 
> +#include 
>  #include 
>  
>  #ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
> @@ -392,6 +393,86 @@ int __libcpp_tls_set(__libcpp_tls_key __key, void *__p
>  }
>  
>  #endif // !_LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL || 
> _LIBCPP_BUILDING_THREAD_LIBRARY_EXTERNAL
> +
> +class _LIBCPP_TYPE_VIS thread;

This seems to break building Firefox:

In file included from 
/home/root/obj/ports/home/tijl/projects/freebsd/ports/head/www/firefox/work/firefox-68.0.2/media/mtransport/nricectx.cpp:82:
In file included from 
/home/root/obj/ports/home/tijl/projects/freebsd/ports/head/www/firefox/work/firefox-68.0.2/media/mtransport/third_party/nICEr/src/stun/stun_client_ctx.h:41:
In file included from 
/home/root/obj/ports/home/tijl/projects/freebsd/ports/head/www/firefox/work/firefox-68.0.2/media/mtransport/third_party/nICEr/src/stun/stun.h:45:
In file included from /usr/include/net/if_var.h:84:
/usr/include/sys/lock.h:68:15: error: reference to 'thread' is ambiguous
struct thread **owner);
   ^
/usr/include/sys/lock.h:42:8: note: candidate found by name lookup is 'thread'
struct thread;
   ^
/usr/include/c++/v1/__threading_support:397:24: note: candidate found by name
  lookup is 'std::__1::thread'
class _LIBCPP_TYPE_VIS thread;
   ^


This "class thread" conflicts with "struct thread" in sys/lock.h.
Should everything in sys/lock.h be under #ifdef _KERNEL?
___
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: r351329 - head/usr.bin/gprof

2019-08-21 Thread Bjoern A. Zeeb
Author: bz
Date: Wed Aug 21 10:54:52 2019
New Revision: 351329
URL: https://svnweb.freebsd.org/changeset/base/351329

Log:
  gprof: disable building of a.out components
  
  On arm64, riscv, and s390x disable building of aout components.
  This allows gprof to build on these architectures which never supported
  the legacy a.out binary format.
  
  Obtained from:s390x branch
  MFC after:3 months

Modified:
  head/usr.bin/gprof/Makefile
  head/usr.bin/gprof/gprof.c
  head/usr.bin/gprof/gprof.h

Modified: head/usr.bin/gprof/Makefile
==
--- head/usr.bin/gprof/Makefile Wed Aug 21 10:45:28 2019(r351328)
+++ head/usr.bin/gprof/Makefile Wed Aug 21 10:54:52 2019(r351329)
@@ -2,8 +2,14 @@
 #  $FreeBSD$
 
 PROG=  gprof
-SRCS=  gprof.c aout.c arcs.c dfn.c elf.c lookup.c hertz.c \
+SRCS=  gprof.c arcs.c dfn.c elf.c lookup.c hertz.c \
printgprof.c printlist.c kernel.c
+
+.if ${MACHINE_ARCH} != "aarch64" && ${MACHINE_ARCH} != "riscv" && \
+${MACHINE_ARCH} != "s390x"
+SRCS+= aout.c
+CFLAGS+=   -DWITH_AOUT
+.endif
 FILES= gprof.flat gprof.callg
 FILESDIR=  ${SHAREDIR}/misc
 

Modified: head/usr.bin/gprof/gprof.c
==
--- head/usr.bin/gprof/gprof.c  Wed Aug 21 10:45:28 2019(r351328)
+++ head/usr.bin/gprof/gprof.c  Wed Aug 21 10:54:52 2019(r351329)
@@ -160,8 +160,11 @@ main(int argc, char **argv)
 *  get information from the executable file.
 */
 if ((Kflag && kernel_getnfile(a_outname, ) == -1) ||
-  (!Kflag && elf_getnfile(a_outname, ) == -1 &&
-  aout_getnfile(a_outname, ) == -1))
+  (!Kflag && elf_getnfile(a_outname, ) == -1
+#ifdef WITH_AOUT
+  && aout_getnfile(a_outname, ) == -1
+#endif
+  ))
errx(1, "%s: bad format", a_outname);
/*
 *  sort symbol table.

Modified: head/usr.bin/gprof/gprof.h
==
--- head/usr.bin/gprof/gprof.h  Wed Aug 21 10:45:28 2019(r351328)
+++ head/usr.bin/gprof/gprof.h  Wed Aug 21 10:54:52 2019(r351329)
@@ -256,7 +256,9 @@ voidaddarc(nltype *, nltype *, long);
 bool   addcycle(arctype **, arctype **);
 void   addlist(struct stringlist *, char *);
 void   alignentries(void);
+#ifdef WITH_AOUT
 intaout_getnfile(const char *, char ***);
+#endif
 intarccmp(arctype *, arctype *);
 arctype*arclookup(nltype *, nltype *);
 void   asgnsamples(void);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r351328 - head/sys/netinet/tcp_stacks

2019-08-21 Thread Randall Stewart
Author: rrs
Date: Wed Aug 21 10:45:28 2019
New Revision: 351328
URL: https://svnweb.freebsd.org/changeset/base/351328

Log:
  Fix an issue when TSO and Rack play together. Basically
  an retransmission of the initial SYN (with data) would
  cause us to strip the SYN and decrement/increase offset/len
  which then caused us a -1 offset and a panic.
  
  Reported by:  Larry Rosenman
  (Michael Tuexen helped me debug this at the IETF)

Modified:
  head/sys/netinet/tcp_stacks/rack.c

Modified: head/sys/netinet/tcp_stacks/rack.c
==
--- head/sys/netinet/tcp_stacks/rack.c  Wed Aug 21 10:42:31 2019
(r351327)
+++ head/sys/netinet/tcp_stacks/rack.c  Wed Aug 21 10:45:28 2019
(r351328)
@@ -7405,9 +7405,6 @@ again:
(tp->t_state == TCPS_SYN_RECEIVED))
flags &= ~TH_SYN;
 #endif
-   sb_offset--, len++;
-   if (sbavail(sb) == 0)
-   len = 0;
}
/*
 * Be careful not to send data and/or FIN on SYN segments. This
___
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: r351327 - head/sys/contrib/dev/ath/ath_hal/ar9300

2019-08-21 Thread Bjoern A. Zeeb
Author: bz
Date: Wed Aug 21 10:42:31 2019
New Revision: 351327
URL: https://svnweb.freebsd.org/changeset/base/351327

Log:
  athhal: disable unused function (big endian only)
  
  Disable ar9300_swap_tx_desc() for the moment.  It is an unused
  function only tried to compile on big endian systems.
  
  Found by: s390x buildkernel
  MFC after:3 months

Modified:
  head/sys/contrib/dev/ath/ath_hal/ar9300/ar9300_xmit_ds.c

Modified: head/sys/contrib/dev/ath/ath_hal/ar9300/ar9300_xmit_ds.c
==
--- head/sys/contrib/dev/ath/ath_hal/ar9300/ar9300_xmit_ds.cWed Aug 21 
08:15:30 2019(r351326)
+++ head/sys/contrib/dev/ath/ath_hal/ar9300/ar9300_xmit_ds.cWed Aug 21 
10:42:31 2019(r351327)
@@ -26,9 +26,11 @@
 #include "ar9300/ar9300phy.h"
 #include "ah_devid.h"
 
+#if 0
 #if AH_BYTE_ORDER == AH_BIG_ENDIAN
 static void ar9300_swap_tx_desc(void *ds);
 #endif
+#endif
 
 void
 ar9300_tx_req_intr_desc(struct ath_hal *ah, void *ds)
@@ -174,6 +176,7 @@ ar9300_clear_dest_mask(struct ath_hal *ah, void *ds)
 }
 #endif
 
+#if 0
 #if AH_BYTE_ORDER == AH_BIG_ENDIAN
 /* XXX what words need swapping */
 /* Swap transmit descriptor */
@@ -192,6 +195,7 @@ ar9300_swap_tx_desc(void *dsp)
 ds->status7 = __bswap32(ds->status7);
 ds->status8 = __bswap32(ds->status8);
 }
+#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: r351326 - head/sys/netgraph/bluetooth/drivers/ubt

2019-08-21 Thread Xin LI
Author: delphij
Date: Wed Aug 21 08:15:30 2019
New Revision: 351326
URL: https://svnweb.freebsd.org/changeset/base/351326

Log:
  Use MTX_NEW instead of bzero().
  
  Submitted by: cem

Modified:
  head/sys/netgraph/bluetooth/drivers/ubt/ng_ubt.c

Modified: head/sys/netgraph/bluetooth/drivers/ubt/ng_ubt.c
==
--- head/sys/netgraph/bluetooth/drivers/ubt/ng_ubt.cWed Aug 21 08:01:43 
2019(r351325)
+++ head/sys/netgraph/bluetooth/drivers/ubt/ng_ubt.cWed Aug 21 08:15:30 
2019(r351326)
@@ -554,8 +554,7 @@ ubt_do_hci_request(struct usb_device *udev, struct ubt
return (USB_ERR_NORMAL_COMPLETION);
 
/* Initialize INTR endpoint xfer and wait for response */
-   bzero(, sizeof(mtx));
-   mtx_init(, "ubt pb", NULL, MTX_DEF);
+   mtx_init(, "ubt pb", NULL, MTX_DEF | MTX_NEW);
 
error = usbd_transfer_setup(udev, _index, xfer,
_probe_config, 1, evt, );
___
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: r351325 - head/sys/dev/sound/pci/hda

2019-08-21 Thread Xin LI
Author: delphij
Date: Wed Aug 21 08:01:43 2019
New Revision: 351325
URL: https://svnweb.freebsd.org/changeset/base/351325

Log:
  Fix sound on headset jack for ThinkPad T51.

Modified:
  head/sys/dev/sound/pci/hda/hdaa_patches.c

Modified: head/sys/dev/sound/pci/hda/hdaa_patches.c
==
--- head/sys/dev/sound/pci/hda/hdaa_patches.c   Wed Aug 21 07:45:39 2019
(r351324)
+++ head/sys/dev/sound/pci/hda/hdaa_patches.c   Wed Aug 21 08:01:43 2019
(r351325)
@@ -429,6 +429,15 @@ hdac_pin_patch(struct hdaa_widget *w)
patch = "as=1 seq=15";
break;
}
+   } else if (id == HDA_CODEC_ALC298 && 
HDA_DEV_MATCH(LENOVO_ALL_SUBVENDOR, subid)) {
+   switch (nid) {
+   case 23:
+   config = 0x03a1103f;
+   break;
+   case 33:
+   config = 0x2121101f;
+   break;
+   }
} else if (id == HDA_CODEC_ALC298 && subid == DELL_XPS9560_SUBVENDOR) {
switch (nid) {
case 24:
___
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: r351324 - head/sys/netgraph/bluetooth/drivers/ubt

2019-08-21 Thread Conrad Meyer
Hi Xin Li,

On Wed, Aug 21, 2019 at 12:45 AM Xin LI  wrote:
> URL: https://svnweb.freebsd.org/changeset/base/351324
>
> Log:
>   The 'mtx' is on stack and can contain garbages that would cause mtx_init
>   (and in turn lock_init) to think that the mutex was already initialized.
>
> --- head/sys/netgraph/bluetooth/drivers/ubt/ng_ubt.cWed Aug 21 04:54:48 
> 2019(r351323)
> +++ head/sys/netgraph/bluetooth/drivers/ubt/ng_ubt.cWed Aug 21 07:45:39 
> 2019(r351324)
> @@ -554,6 +554,7 @@ ubt_do_hci_request(struct usb_device *udev, struct ubt
> /* Initialize INTR endpoint xfer and wait for response */
> +   bzero(, sizeof(mtx));
> mtx_init(, "ubt pb", NULL, MTX_DEF);

This is usually spelled 'MTX_DEF | MTX_NEW' instead.

Best regards,
Conrad
___
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: r351324 - head/sys/netgraph/bluetooth/drivers/ubt

2019-08-21 Thread Xin LI
Author: delphij
Date: Wed Aug 21 07:45:39 2019
New Revision: 351324
URL: https://svnweb.freebsd.org/changeset/base/351324

Log:
  Fix a panic in ubt_do_hci_request.
  
  The 'mtx' is on stack and can contain garbages that would cause mtx_init
  (and in turn lock_init) to think that the mutex was already initialized.

Modified:
  head/sys/netgraph/bluetooth/drivers/ubt/ng_ubt.c

Modified: head/sys/netgraph/bluetooth/drivers/ubt/ng_ubt.c
==
--- head/sys/netgraph/bluetooth/drivers/ubt/ng_ubt.cWed Aug 21 04:54:48 
2019(r351323)
+++ head/sys/netgraph/bluetooth/drivers/ubt/ng_ubt.cWed Aug 21 07:45:39 
2019(r351324)
@@ -554,6 +554,7 @@ ubt_do_hci_request(struct usb_device *udev, struct ubt
return (USB_ERR_NORMAL_COMPLETION);
 
/* Initialize INTR endpoint xfer and wait for response */
+   bzero(, sizeof(mtx));
mtx_init(, "ubt pb", NULL, MTX_DEF);
 
error = usbd_transfer_setup(udev, _index, xfer,
___
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"