svn commit: r346264 - head/share/misc

2019-04-15 Thread Cy Schubert
Author: cy
Date: Tue Apr 16 05:11:39 2019
New Revision: 346264
URL: https://svnweb.freebsd.org/changeset/base/346264

Log:
  Document when I received my commit bits.

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

Modified: head/share/misc/committers-ports.dot
==
--- head/share/misc/committers-ports.dotTue Apr 16 04:12:41 2019
(r346263)
+++ head/share/misc/committers-ports.dotTue Apr 16 05:11:39 2019
(r346264)
@@ -84,6 +84,7 @@ cperciva [label="Colin Percival\ncperc...@freebsd.org\
 crees [label="Chris Rees\ncr...@freebsd.org\n2011/06/11"]
 cs [label="Carlo Strub\n...@freebsd.org\n2011/09/13"]
 culot [label="Frederic Culot\ncu...@freebsd.org\n2010/10/16"]
+cy [label="Cy Schubert\n...@freebsd.org\n2001/11/13"]
 daichi [label="Daichi Goto\ndai...@freebsd.org\n2002/10/17"]
 danfe [label="Alexey Dokuchaev\nda...@freebsd.org\n2004/08/20"]
 danilo [label="Danilo E. Gondolfo\ndan...@freebsd.org\n2013/09/23"]

Modified: head/share/misc/committers-src.dot
==
--- head/share/misc/committers-src.dot  Tue Apr 16 04:12:41 2019
(r346263)
+++ head/share/misc/committers-src.dot  Tue Apr 16 05:11:39 2019
(r346264)
@@ -143,6 +143,7 @@ cognet [label="Olivier Houchard\ncog...@freebsd.org\n2
 cokane [label="Coleman Kane\ncok...@freebsd.org\n2000/06/19"]
 cperciva [label="Colin Percival\ncperc...@freebsd.org\n2004/01/20"]
 csjp [label="Christian S.J. Peron\nc...@freebsd.org\n2004/05/04"]
+cy [label="Cy Schubert\n...@freebsd.org\n2013/04/23"]
 dab [label="David Bright\n...@freebsd.org\n2016/10/24"]
 das [label="David Schultz\n...@freebsd.org\n2003/02/21"]
 davide [label="Davide Italiano\ndav...@freebsd.org\n2012/01/27"]
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r346263 - head/contrib/tcpdump

2019-04-15 Thread Mariusz Zaborski
Author: oshogbo
Date: Tue Apr 16 04:12:41 2019
New Revision: 346263
URL: https://svnweb.freebsd.org/changeset/base/346263

Log:
  tcpdump: disable Capsicum if -E option is provided.
  
  The -E is used to provide a secret for decrypting IPsec.
  The secret may be provided through command line or as the file.
  The problem is that tcpdump doesn't support yet opening files in capability 
mode
  and the file may contain a list of the files to open.
  
  As a workaround, for now, let's just disable capsicum if the -E
  the option is provided.
  
  PR:   236819
  MFC after:2 weeks

Modified:
  head/contrib/tcpdump/tcpdump.c

Modified: head/contrib/tcpdump/tcpdump.c
==
--- head/contrib/tcpdump/tcpdump.c  Tue Apr 16 02:48:04 2019
(r346262)
+++ head/contrib/tcpdump/tcpdump.c  Tue Apr 16 04:12:41 2019
(r346263)
@@ -2063,7 +2063,8 @@ main(int argc, char **argv)
}
 
 #ifdef HAVE_CAPSICUM
-   cansandbox = (VFileName == NULL && zflag == NULL);
+   cansandbox = (VFileName == NULL && zflag == NULL &&
+   ndo->ndo_espsecret == NULL);
 #ifdef HAVE_CASPER
cansandbox = (cansandbox && (ndo->ndo_nflag || capdns != NULL));
 #else
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r346262 - stable/10/sys/rpc/rpcsec_gss

2019-04-15 Thread Rick Macklem
Author: rmacklem
Date: Tue Apr 16 02:48:04 2019
New Revision: 346262
URL: https://svnweb.freebsd.org/changeset/base/346262

Log:
  MFC: r345818, r345828
  Fix a race in the RPCSEC_GSS server code that caused crashes.
  
  When a new client structure was allocated, it was added to the list
  so that it was visible to other threads before the expiry time was
  initialized, with only a single reference count.
  The caller would increment the reference count, but it was possible
  for another thread to decrement the reference count to zero and free
  the structure before the caller incremented the reference count.
  This could occur because the expiry time was still set to zero when
  the new client structure was inserted in the list and the list was
  unlocked.
  
  This patch fixes the race by initializing the reference count to two
  and initializing all fields, including the expiry time, before inserting
  it in the list.

Modified:
  stable/10/sys/rpc/rpcsec_gss/svc_rpcsec_gss.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/rpc/rpcsec_gss/svc_rpcsec_gss.c
==
--- stable/10/sys/rpc/rpcsec_gss/svc_rpcsec_gss.c   Tue Apr 16 02:46:21 
2019(r346261)
+++ stable/10/sys/rpc/rpcsec_gss/svc_rpcsec_gss.c   Tue Apr 16 02:48:04 
2019(r346262)
@@ -543,18 +543,17 @@ svc_rpc_gss_create_client(void)
 
client = mem_alloc(sizeof(struct svc_rpc_gss_client));
memset(client, 0, sizeof(struct svc_rpc_gss_client));
-   refcount_init(>cl_refs, 1);
+
+   /*
+* Set the initial value of cl_refs to two.  One for the caller
+* and the other to hold onto the client structure until it expires.
+*/
+   refcount_init(>cl_refs, 2);
sx_init(>cl_lock, "GSS-client");
getcredhostid(curthread->td_ucred, );
client->cl_id.ci_hostid = hostid;
client->cl_id.ci_boottime = boottime.tv_sec;
client->cl_id.ci_id = svc_rpc_gss_next_clientid++;
-   list = _rpc_gss_client_hash[client->cl_id.ci_id % CLIENT_HASH_SIZE];
-   sx_xlock(_rpc_gss_lock);
-   TAILQ_INSERT_HEAD(list, client, cl_link);
-   TAILQ_INSERT_HEAD(_rpc_gss_clients, client, cl_alllink);
-   svc_rpc_gss_client_count++;
-   sx_xunlock(_rpc_gss_lock);
 
/*
 * Start the client off with a short expiration time. We will
@@ -564,6 +563,12 @@ svc_rpc_gss_create_client(void)
client->cl_locked = FALSE;
client->cl_expiration = time_uptime + 5*60;
 
+   list = _rpc_gss_client_hash[client->cl_id.ci_id % CLIENT_HASH_SIZE];
+   sx_xlock(_rpc_gss_lock);
+   TAILQ_INSERT_HEAD(list, client, cl_link);
+   TAILQ_INSERT_HEAD(_rpc_gss_clients, client, cl_alllink);
+   svc_rpc_gss_client_count++;
+   sx_xunlock(_rpc_gss_lock);
return (client);
 }
 
@@ -1261,7 +1266,6 @@ svc_rpc_gss(struct svc_req *rqst, struct rpc_msg *msg)
goto out;
}
client = svc_rpc_gss_create_client();
-   refcount_acquire(>cl_refs);
} else {
struct svc_rpc_gss_clientid *p;
if (gc.gc_handle.length != sizeof(*p)) {
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r346261 - head/sys/dev/tpm

2019-04-15 Thread Marcin Wojtas
Author: mw
Date: Tue Apr 16 02:46:21 2019
New Revision: 346261
URL: https://svnweb.freebsd.org/changeset/base/346261

Log:
  Improve tpm20 style
  
  No functional changes to the code are applied.
  
  Submitted by: Kornel Duleba 
  Obtained from: Semihalf
  Sponsored by: Stormshield

Modified:
  head/sys/dev/tpm/tpm20.c
  head/sys/dev/tpm/tpm20.h
  head/sys/dev/tpm/tpm_crb.c
  head/sys/dev/tpm/tpm_tis.c

Modified: head/sys/dev/tpm/tpm20.c
==
--- head/sys/dev/tpm/tpm20.cTue Apr 16 02:38:39 2019(r346260)
+++ head/sys/dev/tpm/tpm20.cTue Apr 16 02:46:21 2019(r346261)
@@ -142,7 +142,8 @@ tpm20_write(struct cdev *dev, struct uio *uio, int fla
return (result);
 }
 
-static void tpm20_discard_buffer(void *arg)
+static void
+tpm20_discard_buffer(void *arg)
 {
struct tpm_sc *sc;
 
@@ -304,9 +305,10 @@ tpm20_save_state(device_t dev, bool suspend)
 {
struct tpm_sc *sc;
uint8_t save_cmd[] = {
-   0x80, 0x01, /* TPM_ST_NO_SESSIONS tag*/
+   0x80, 0x01, /* TPM_ST_NO_SESSIONS tag*/
0x00, 0x00, 0x00, 0x0C, /* cmd length */
-   0x00, 0x00, 0x01, 0x45, 0x00, 0x00 /* cmd TPM_CC_Shutdown */
+   0x00, 0x00, 0x01, 0x45, /* cmd TPM_CC_Shutdown */
+   0x00, 0x00  /* TPM_SU_STATE */
};
 
sc = device_get_softc(dev);
@@ -315,7 +317,7 @@ tpm20_save_state(device_t dev, bool suspend)
 * Inform the TPM whether we are going to suspend or reboot/shutdown.
 */
if (suspend)
-   save_cmd[11] = 1;   /* TPM_SU_STATE */
+   save_cmd[11] = 1; /* TPM_SU_STATE */
 
if (sc == NULL || sc->buf == NULL)
return (0);

Modified: head/sys/dev/tpm/tpm20.h
==
--- head/sys/dev/tpm/tpm20.hTue Apr 16 02:38:39 2019(r346260)
+++ head/sys/dev/tpm/tpm20.hTue Apr 16 02:46:21 2019(r346261)
@@ -26,7 +26,7 @@
  */
 
 #ifndef _TPM20_H_
-#define _TPM20_H_
+#define_TPM20_H_
 
 #include 
 __FBSDID("$FreeBSD$");
@@ -60,46 +60,46 @@ __FBSDID("$FreeBSD$");
 #defineBIT(x) (1 << (x))
 
 /* Timeouts in us */
-#defineTPM_TIMEOUT_A   75
-#defineTPM_TIMEOUT_B   200
-#defineTPM_TIMEOUT_C   20
-#defineTPM_TIMEOUT_D   3
+#defineTPM_TIMEOUT_A   75
+#defineTPM_TIMEOUT_B   200
+#defineTPM_TIMEOUT_C   20
+#defineTPM_TIMEOUT_D   3
 
 /*
  * Generating RSA key pair takes ~(10-20s), which is significantly longer than
  * any timeout defined in spec. Because of that we need a new one.
  */
-#defineTPM_TIMEOUT_LONG4000
+#defineTPM_TIMEOUT_LONG4000
 
 /* List of commands that require TPM_TIMEOUT_LONG time to complete */
-#defineTPM_CC_CreatePrimary0x0131
+#defineTPM_CC_CreatePrimary0x0131
 #defineTPM_CC_Create   0x0153
 #defineTPM_CC_CreateLoaded 0x0191
 
 /* List of commands that require only TPM_TIMEOUT_C time to complete */
-#define TPM_CC_SequenceComplete0x013e
-#define TPM_CC_Startup 0x0144
-#define TPM_CC_SequenceUpdate  0x015c
-#define TPM_CC_GetCapability   0x017a
-#define TPM_CC_PCR_Extend  0x0182
-#define TPM_CC_EventSequenceComplete   0x0185
-#define TPM_CC_HashSequenceStart   0x0186
+#defineTPM_CC_SequenceComplete 0x013e
+#defineTPM_CC_Startup  0x0144
+#defineTPM_CC_SequenceUpdate   0x015c
+#defineTPM_CC_GetCapability0x017a
+#defineTPM_CC_PCR_Extend   0x0182
+#defineTPM_CC_EventSequenceComplete0x0185
+#defineTPM_CC_HashSequenceStart0x0186
 
 /* Timeout before data in read buffer is discarded */
-#defineTPM_READ_TIMEOUT50
+#defineTPM_READ_TIMEOUT50
 
-#defineTPM_BUFSIZE 0x1000
+#defineTPM_BUFSIZE 0x1000
 
-#defineTPM_HEADER_SIZE 10
+#defineTPM_HEADER_SIZE 10
 
-#defineTPM_CDEV_NAME   "tpm0"
-#defineTPM_CDEV_PERM_FLAG  0600
+#defineTPM_CDEV_NAME   "tpm0"
+#defineTPM_CDEV_PERM_FLAG  0600
 
 
-#define TPM2_START_METHOD_ACPI 2
-#define TPM2_START_METHOD_TIS 6
-#define TPM2_START_METHOD_CRB 7
-#define TPM2_START_METHOD_CRB_ACPI 8
+#defineTPM2_START_METHOD_ACPI  2
+#defineTPM2_START_METHOD_TIS 

svn commit: r346260 - stable/11/sys/rpc/rpcsec_gss

2019-04-15 Thread Rick Macklem
Author: rmacklem
Date: Tue Apr 16 02:38:39 2019
New Revision: 346260
URL: https://svnweb.freebsd.org/changeset/base/346260

Log:
  MFC: r345818, r345828
  Fix a race in the RPCSEC_GSS server code that caused crashes.
  
  When a new client structure was allocated, it was added to the list
  so that it was visible to other threads before the expiry time was
  initialized, with only a single reference count.
  The caller would increment the reference count, but it was possible
  for another thread to decrement the reference count to zero and free
  the structure before the caller incremented the reference count.
  This could occur because the expiry time was still set to zero when
  the new client structure was inserted in the list and the list was
  unlocked.
  
  This patch fixes the race by initializing the reference count to two
  and initializing all fields, including the expiry time, before inserting
  it in the list.

Modified:
  stable/11/sys/rpc/rpcsec_gss/svc_rpcsec_gss.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/rpc/rpcsec_gss/svc_rpcsec_gss.c
==
--- stable/11/sys/rpc/rpcsec_gss/svc_rpcsec_gss.c   Tue Apr 16 02:28:35 
2019(r346259)
+++ stable/11/sys/rpc/rpcsec_gss/svc_rpcsec_gss.c   Tue Apr 16 02:38:39 
2019(r346260)
@@ -559,19 +559,18 @@ svc_rpc_gss_create_client(void)
 
client = mem_alloc(sizeof(struct svc_rpc_gss_client));
memset(client, 0, sizeof(struct svc_rpc_gss_client));
-   refcount_init(>cl_refs, 1);
+
+   /*
+* Set the initial value of cl_refs to two.  One for the caller
+* and the other to hold onto the client structure until it expires.
+*/
+   refcount_init(>cl_refs, 2);
sx_init(>cl_lock, "GSS-client");
getcredhostid(curthread->td_ucred, );
client->cl_id.ci_hostid = hostid;
getboottime();
client->cl_id.ci_boottime = boottime.tv_sec;
client->cl_id.ci_id = svc_rpc_gss_next_clientid++;
-   list = _rpc_gss_client_hash[client->cl_id.ci_id % CLIENT_HASH_SIZE];
-   sx_xlock(_rpc_gss_lock);
-   TAILQ_INSERT_HEAD(list, client, cl_link);
-   TAILQ_INSERT_HEAD(_rpc_gss_clients, client, cl_alllink);
-   svc_rpc_gss_client_count++;
-   sx_xunlock(_rpc_gss_lock);
 
/*
 * Start the client off with a short expiration time. We will
@@ -581,6 +580,12 @@ svc_rpc_gss_create_client(void)
client->cl_locked = FALSE;
client->cl_expiration = time_uptime + 5*60;
 
+   list = _rpc_gss_client_hash[client->cl_id.ci_id % CLIENT_HASH_SIZE];
+   sx_xlock(_rpc_gss_lock);
+   TAILQ_INSERT_HEAD(list, client, cl_link);
+   TAILQ_INSERT_HEAD(_rpc_gss_clients, client, cl_alllink);
+   svc_rpc_gss_client_count++;
+   sx_xunlock(_rpc_gss_lock);
return (client);
 }
 
@@ -1278,7 +1283,6 @@ svc_rpc_gss(struct svc_req *rqst, struct rpc_msg *msg)
goto out;
}
client = svc_rpc_gss_create_client();
-   refcount_acquire(>cl_refs);
} else {
struct svc_rpc_gss_clientid *p;
if (gc.gc_handle.length != sizeof(*p)) {
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r346259 - head/sys/dev/tpm

2019-04-15 Thread Marcin Wojtas
Author: mw
Date: Tue Apr 16 02:28:35 2019
New Revision: 346259
URL: https://svnweb.freebsd.org/changeset/base/346259

Log:
  tpm: Prevent session hijack
  
  Check caller thread id before allowing to read the buffer
  to make sure that it can only be accessed by the thread that
  did the associated write to the TPM.
  
  Submitted by: Kornel Duleba 
  Reviewed by: delphij
  Obtained from: Semihalf
  Sponsored by: Stormshield
  Differential Revision: https://reviews.freebsd.org/D19713

Modified:
  head/sys/dev/tpm/tpm20.c
  head/sys/dev/tpm/tpm20.h

Modified: head/sys/dev/tpm/tpm20.c
==
--- head/sys/dev/tpm/tpm20.cTue Apr 16 02:12:38 2019(r346258)
+++ head/sys/dev/tpm/tpm20.cTue Apr 16 02:28:35 2019(r346259)
@@ -77,6 +77,10 @@ tpm20_read(struct cdev *dev, struct uio *uio, int flag
 
callout_stop(>discard_buffer_callout);
sx_xlock(>dev_lock);
+   if (sc->owner_tid != uio->uio_td->td_tid) {
+   sx_xunlock(>dev_lock);
+   return (EPERM);
+   }
 
bytes_to_transfer = MIN(sc->pending_data_length, uio->uio_resid);
if (bytes_to_transfer > 0) {
@@ -128,9 +132,11 @@ tpm20_write(struct cdev *dev, struct uio *uio, int fla
 
result = sc->transmit(sc, byte_count);
 
-   if (result == 0)
+   if (result == 0) {
callout_reset(>discard_buffer_callout,
TPM_READ_TIMEOUT / tick, tpm20_discard_buffer, sc);
+   sc->owner_tid = uio->uio_td->td_tid;
+   }
 
sx_xunlock(>dev_lock);
return (result);

Modified: head/sys/dev/tpm/tpm20.h
==
--- head/sys/dev/tpm/tpm20.hTue Apr 16 02:12:38 2019(r346258)
+++ head/sys/dev/tpm/tpm20.hTue Apr 16 02:28:35 2019(r346259)
@@ -120,6 +120,7 @@ struct tpm_sc {
 
uint8_t *buf;
size_t  pending_data_length;
+   lwpid_t owner_tid;
 
struct callout  discard_buffer_callout;
 #ifdef TPM_HARVEST
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r346258 - stable/12/sys/rpc/rpcsec_gss

2019-04-15 Thread Rick Macklem
Author: rmacklem
Date: Tue Apr 16 02:12:38 2019
New Revision: 346258
URL: https://svnweb.freebsd.org/changeset/base/346258

Log:
  MFC: r345818, r345828
  Fix a race in the RPCSEC_GSS server code that caused crashes.
  
  When a new client structure was allocated, it was added to the list
  so that it was visible to other threads before the expiry time was
  initialized, with only a single reference count.
  The caller would increment the reference count, but it was possible
  for another thread to decrement the reference count to zero and free
  the structure before the caller incremented the reference count.
  This could occur because the expiry time was still set to zero when
  the new client structure was inserted in the list and the list was
  unlocked.
  
  This patch fixes the race by initializing the reference count to two
  and initializing all fields, including the expiry time, before inserting
  it in the list.

Modified:
  stable/12/sys/rpc/rpcsec_gss/svc_rpcsec_gss.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/rpc/rpcsec_gss/svc_rpcsec_gss.c
==
--- stable/12/sys/rpc/rpcsec_gss/svc_rpcsec_gss.c   Tue Apr 16 01:03:38 
2019(r346257)
+++ stable/12/sys/rpc/rpcsec_gss/svc_rpcsec_gss.c   Tue Apr 16 02:12:38 
2019(r346258)
@@ -562,19 +562,18 @@ svc_rpc_gss_create_client(void)
 
client = mem_alloc(sizeof(struct svc_rpc_gss_client));
memset(client, 0, sizeof(struct svc_rpc_gss_client));
-   refcount_init(>cl_refs, 1);
+
+   /*
+* Set the initial value of cl_refs to two.  One for the caller
+* and the other to hold onto the client structure until it expires.
+*/
+   refcount_init(>cl_refs, 2);
sx_init(>cl_lock, "GSS-client");
getcredhostid(curthread->td_ucred, );
client->cl_id.ci_hostid = hostid;
getboottime();
client->cl_id.ci_boottime = boottime.tv_sec;
client->cl_id.ci_id = svc_rpc_gss_next_clientid++;
-   list = _rpc_gss_client_hash[client->cl_id.ci_id % CLIENT_HASH_SIZE];
-   sx_xlock(_rpc_gss_lock);
-   TAILQ_INSERT_HEAD(list, client, cl_link);
-   TAILQ_INSERT_HEAD(_rpc_gss_clients, client, cl_alllink);
-   svc_rpc_gss_client_count++;
-   sx_xunlock(_rpc_gss_lock);
 
/*
 * Start the client off with a short expiration time. We will
@@ -584,6 +583,12 @@ svc_rpc_gss_create_client(void)
client->cl_locked = FALSE;
client->cl_expiration = time_uptime + 5*60;
 
+   list = _rpc_gss_client_hash[client->cl_id.ci_id % CLIENT_HASH_SIZE];
+   sx_xlock(_rpc_gss_lock);
+   TAILQ_INSERT_HEAD(list, client, cl_link);
+   TAILQ_INSERT_HEAD(_rpc_gss_clients, client, cl_alllink);
+   svc_rpc_gss_client_count++;
+   sx_xunlock(_rpc_gss_lock);
return (client);
 }
 
@@ -1281,7 +1286,6 @@ svc_rpc_gss(struct svc_req *rqst, struct rpc_msg *msg)
goto out;
}
client = svc_rpc_gss_create_client();
-   refcount_acquire(>cl_refs);
} else {
struct svc_rpc_gss_clientid *p;
if (gc.gc_handle.length != sizeof(*p)) {
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r346256 - stable/11/tests/sys/netmap

2019-04-15 Thread Enji Cooper
Author: ngie
Date: Tue Apr 16 01:03:32 2019
New Revision: 346256
URL: https://svnweb.freebsd.org/changeset/base/346256

Log:
  MFC r345644,r346061:
  
  r345644 (by olivier):
  
  Skip this test if if_tap module is not available
  
  PR:   236842
  
  r346061:
  
  Polish netmap(4) testcases a bit
  
  1. Not all kernels have netmap(4) support. Check for netmap(4) support before
 attempting to run the tests via the `PLAIN_REQUIRE_KERNEL_MODULE(..)` 
macro.
  2. Libraries shouldn't be added to LDFLAGS; they should be added to LIBADD
 instead. This allows the build system to evaluate dependencies for sanity.
  3. Sort some of the Makefile variables per bsd.README.
  
  1., in particular, will resolve failures when running this testcase on kernels
  lacking netmap(4) support, e.g., the i386 GENERIC kernels on ^/stable/11 and
  ^/stable/12.
  
  PR:   237129

Modified:
  stable/11/tests/sys/netmap/Makefile
  stable/11/tests/sys/netmap/ctrl-api-test.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/tests/sys/netmap/Makefile
==
--- stable/11/tests/sys/netmap/Makefile Tue Apr 16 00:41:22 2019
(r346255)
+++ stable/11/tests/sys/netmap/Makefile Tue Apr 16 01:03:32 2019
(r346256)
@@ -6,8 +6,10 @@ TESTSDIR=  ${TESTSBASE}/sys/netmap
 TEST_METADATA+=required_user="root"
 TEST_METADATA+=is_exclusive=true
 
-LDFLAGS+=  -lpthread
 PLAIN_TESTS_C+=ctrl-api-test
+
+CFLAGS+=   -I${SRCTOP}/tests
+LIBADD+=   pthread
 
 WARNS?=6
 

Modified: stable/11/tests/sys/netmap/ctrl-api-test.c
==
--- stable/11/tests/sys/netmap/ctrl-api-test.c  Tue Apr 16 00:41:22 2019
(r346255)
+++ stable/11/tests/sys/netmap/ctrl-api-test.c  Tue Apr 16 01:03:32 2019
(r346256)
@@ -48,9 +48,15 @@
 #include 
 #include 
 
+#ifdef __FreeBSD__
+#include "freebsd_test_suite/macros.h"
+#endif
+
+
 #ifdef __linux__
 #include 
 #else
+
 static int
 eventfd(int x __unused, int y __unused)
 {
@@ -1784,6 +1790,11 @@ main(int argc, char **argv)
int list = 0;
int opt;
int i;
+
+#ifdef __FreeBSD__
+   PLAIN_REQUIRE_KERNEL_MODULE("if_tap", 0);
+   PLAIN_REQUIRE_KERNEL_MODULE("netmap", 0);
+#endif
 
memset(_, 0, sizeof(ctx_));
 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r346257 - stable/12/tests/sys/netmap

2019-04-15 Thread Enji Cooper
Author: ngie
Date: Tue Apr 16 01:03:38 2019
New Revision: 346257
URL: https://svnweb.freebsd.org/changeset/base/346257

Log:
  MFC r345644,r346061:
  
  r345644 (by olivier):
  
  Skip this test if if_tap module is not available
  
  PR:   236842
  
  r346061:
  
  Polish netmap(4) testcases a bit
  
  1. Not all kernels have netmap(4) support. Check for netmap(4) support before
 attempting to run the tests via the `PLAIN_REQUIRE_KERNEL_MODULE(..)` 
macro.
  2. Libraries shouldn't be added to LDFLAGS; they should be added to LIBADD
 instead. This allows the build system to evaluate dependencies for sanity.
  3. Sort some of the Makefile variables per bsd.README.
  
  1., in particular, will resolve failures when running this testcase on kernels
  lacking netmap(4) support, e.g., the i386 GENERIC kernels on ^/stable/11 and
  ^/stable/12.
  
  PR:   237129

Modified:
  stable/12/tests/sys/netmap/Makefile
  stable/12/tests/sys/netmap/ctrl-api-test.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/tests/sys/netmap/Makefile
==
--- stable/12/tests/sys/netmap/Makefile Tue Apr 16 01:03:32 2019
(r346256)
+++ stable/12/tests/sys/netmap/Makefile Tue Apr 16 01:03:38 2019
(r346257)
@@ -6,8 +6,10 @@ TESTSDIR=  ${TESTSBASE}/sys/netmap
 TEST_METADATA+=required_user="root"
 TEST_METADATA+=is_exclusive=true
 
-LDFLAGS+=  -lpthread
 PLAIN_TESTS_C+=ctrl-api-test
+
+CFLAGS+=   -I${SRCTOP}/tests
+LIBADD+=   pthread
 
 WARNS?=6
 

Modified: stable/12/tests/sys/netmap/ctrl-api-test.c
==
--- stable/12/tests/sys/netmap/ctrl-api-test.c  Tue Apr 16 01:03:32 2019
(r346256)
+++ stable/12/tests/sys/netmap/ctrl-api-test.c  Tue Apr 16 01:03:38 2019
(r346257)
@@ -48,9 +48,15 @@
 #include 
 #include 
 
+#ifdef __FreeBSD__
+#include "freebsd_test_suite/macros.h"
+#endif
+
+
 #ifdef __linux__
 #include 
 #else
+
 static int
 eventfd(int x __unused, int y __unused)
 {
@@ -1830,6 +1836,11 @@ main(int argc, char **argv)
int list = 0;
int opt;
int i;
+
+#ifdef __FreeBSD__
+   PLAIN_REQUIRE_KERNEL_MODULE("if_tap", 0);
+   PLAIN_REQUIRE_KERNEL_MODULE("netmap", 0);
+#endif
 
memset(_, 0, sizeof(ctx_));
 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r346250 - in head: share/man/man4 share/man/man9 sys/dev/random sys/kern sys/libkern sys/sys

2019-04-15 Thread Conrad Meyer
On Mon, Apr 15, 2019 at 5:53 PM Conrad Meyer  wrote:
> E.g., the CI infrastructure for
> Riscv/Arm is/was generating minimal filesystem images and not
> populating /boot/entropy.

I should add, I say "is/was" because I have a PR out which may address
the problem: https://github.com/freebsd/freebsd-ci/pull/31

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


Re: svn commit: r346250 - in head: share/man/man4 share/man/man9 sys/dev/random sys/kern sys/libkern sys/sys

2019-04-15 Thread Conrad Meyer
Hi Justin,

On Mon, Apr 15, 2019 at 5:01 PM Justin Hibbits  wrote:
> Given the discussion over there it would probably also fail on powernv, which 
> also does not use loader.

Does power use bsdinstall (which populates /boot/entropy at install
time via usr.sbin/bsdinstall/scripts/entropy) and install the
libexec/rc/rc.d/random rc script (which re-emits new /boot/entropy on
every startup)?  If so, it should be ok.

The problem is new installs that don't use bsdinstall or otherwise
provide initial /boot/entropy.  E.g., the CI infrastructure for
Riscv/Arm is/was generating minimal filesystem images and not
populating /boot/entropy.

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


svn commit: r346255 - head/usr.bin/jot

2019-04-15 Thread Bryan Drewery
Author: bdrewery
Date: Tue Apr 16 00:41:22 2019
New Revision: 346255
URL: https://svnweb.freebsd.org/changeset/base/346255

Log:
  Fix 'jot -r 0 start end' to work.
  
  This allows an endless stream of random data within the given bounds.
  It already worked if a seed was provided as the 4th argument but not
  if one was left out.
  
  In collaboration with:jhb
  MFC after:2 weeks
  Relnotes: yes

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

Modified: head/usr.bin/jot/jot.c
==
--- head/usr.bin/jot/jot.c  Mon Apr 15 21:20:06 2019(r346254)
+++ head/usr.bin/jot/jot.c  Tue Apr 16 00:41:22 2019(r346255)
@@ -263,12 +263,15 @@ main(int argc, char **argv)
mask = 0;
break;
case HAVE_REPS | HAVE_BEGIN | HAVE_ENDER:
-   if (reps == 0)
-   errx(1, "infinite sequences cannot be bounded");
-   else if (reps == 1)
-   s = 0.0;
-   else
-   s = (ender - begin) / (reps - 1);
+   if (!randomize) {
+   if (reps == 0)
+   errx(1, "infinite sequences cannot "
+   "be bounded");
+   else if (reps == 1)
+   s = 0.0;
+   else
+   s = (ender - begin) / (reps - 1);
+   }
mask = 0;
break;
case HAVE_REPS | HAVE_BEGIN | HAVE_ENDER | HAVE_STEP:
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r346250 - in head: share/man/man4 share/man/man9 sys/dev/random sys/kern sys/libkern sys/sys

2019-04-15 Thread Justin Hibbits
On Mon, Apr 15, 2019, 18:34 Ed Maste  wrote:

> On Mon, 15 Apr 2019 at 14:40, Conrad Meyer  wrote:
> >
> > Author: cem
> > Date: Mon Apr 15 18:40:36 2019
> > New Revision: 346250
> > URL: https://svnweb.freebsd.org/changeset/base/346250
> >
> > Log:
> >   random(4): Block read_random(9) on initial seeding
>
> Because Gerald (one of the FreeBSD Foundation's co-op students for
> this term) is not on the svn mailing list I'll bring his report from
> GitHub[1] over here:
>
> As probably also seen from the official CI
> (https://ci.freebsd.org/job/FreeBSD-head-riscv64-test/), this commit
> prevents booting on both arm and arm64.
>
> Condensed Error log (arm64 Pine A64-LTS)
>
> random: randomdev_wait_until_seeded unblock wait
> panic: _sleep: curthread not running
> cpuid = 0
> time = 1
> KDB: stack backtrace:
> <...>
> randomdev_wait_until_seeded() at read_random+0x50
> pc = 0x0021b850  lr = 0x0021b930
> sp = 0x00010a00  fp = 0x00010a40
>
> read_random() at arc4rand+0x168
> pc = 0x0021b930  lr = 0x0049ae5c
> sp = 0x00010a50  fp = 0x00010af0
>
> arc4rand() at __stack_chk_init+0x18
> pc = 0x0049ae5c  lr = 0x003f0558
> sp = 0x00010b00  fp = 0x00010b40
>
> <>
>
> [1]
> https://github.com/freebsd/freebsd/commit/654aeb58dd40d3db3af91ce26c9c31d1b02cee5f#commitcomment-33187782


Given the discussion over there it would probably also fail on powernv,
which also does not use loader.

- Justin

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


Re: svn commit: r346250 - in head: share/man/man4 share/man/man9 sys/dev/random sys/kern sys/libkern sys/sys

2019-04-15 Thread Ed Maste
On Mon, 15 Apr 2019 at 14:40, Conrad Meyer  wrote:
>
> Author: cem
> Date: Mon Apr 15 18:40:36 2019
> New Revision: 346250
> URL: https://svnweb.freebsd.org/changeset/base/346250
>
> Log:
>   random(4): Block read_random(9) on initial seeding

Because Gerald (one of the FreeBSD Foundation's co-op students for
this term) is not on the svn mailing list I'll bring his report from
GitHub[1] over here:

As probably also seen from the official CI
(https://ci.freebsd.org/job/FreeBSD-head-riscv64-test/), this commit
prevents booting on both arm and arm64.

Condensed Error log (arm64 Pine A64-LTS)

random: randomdev_wait_until_seeded unblock wait
panic: _sleep: curthread not running
cpuid = 0
time = 1
KDB: stack backtrace:
<...>
randomdev_wait_until_seeded() at read_random+0x50
pc = 0x0021b850  lr = 0x0021b930
sp = 0x00010a00  fp = 0x00010a40

read_random() at arc4rand+0x168
pc = 0x0021b930  lr = 0x0049ae5c
sp = 0x00010a50  fp = 0x00010af0

arc4rand() at __stack_chk_init+0x18
pc = 0x0049ae5c  lr = 0x003f0558
sp = 0x00010b00  fp = 0x00010b40

<>

[1] 
https://github.com/freebsd/freebsd/commit/654aeb58dd40d3db3af91ce26c9c31d1b02cee5f#commitcomment-33187782
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r346254 - head/usr.sbin/config

2019-04-15 Thread Kyle Evans
Author: kevans
Date: Mon Apr 15 21:20:06 2019
New Revision: 346254
URL: https://svnweb.freebsd.org/changeset/base/346254

Log:
  config(8): replace opteq with a call to strcasecmp
  
  This obscures the comparison slightly less; when option name appear in
  files, they are case-insensitive.
  
  MFC after:1 week

Modified:
  head/usr.sbin/config/mkmakefile.c

Modified: head/usr.sbin/config/mkmakefile.c
==
--- head/usr.sbin/config/mkmakefile.c   Mon Apr 15 19:21:45 2019
(r346253)
+++ head/usr.sbin/config/mkmakefile.c   Mon Apr 15 21:20:06 2019
(r346254)
@@ -62,7 +62,6 @@ static void do_rules(FILE *);
 static void do_xxfiles(char *, FILE *);
 static void do_objs(FILE *);
 static void do_before_depend(FILE *);
-static int opteq(const char *, const char *);
 static void read_files(void);
 static void sanitize_envline(char *result, const char *src);
 static bool preprocess(char *line, char *result);
@@ -565,7 +564,8 @@ next:
goto nextparam;
}
SLIST_FOREACH(op, , op_next)
-   if (op->op_value == 0 && opteq(op->op_name, wd)) {
+   if (op->op_value == 0 &&
+   strcasecmp(op->op_name, wd) == 0) {
if (not)
match = 0;
goto nextparam;
@@ -625,23 +625,6 @@ read_files(void)
tnl = STAILQ_NEXT(nl, f_next);
free(nl->f_name);
free(nl);
-   }
-}
-
-static int
-opteq(const char *cp, const char *dp)
-{
-   char c, d;
-
-   for (; ; cp++, dp++) {
-   if (*cp != *dp) {
-   c = isupper(*cp) ? tolower(*cp) : *cp;
-   d = isupper(*dp) ? tolower(*dp) : *dp;
-   if (c != d)
-   return (0);
-   }
-   if (*cp == 0)
-   return (1);
}
 }
 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r346252 - in head/usr.sbin/cron: cron crontab

2019-04-15 Thread Kyle Evans
On Mon, Apr 15, 2019 at 2:26 PM Ian Lepore  wrote:
>
> On Mon, 2019-04-15 at 18:53 +, Kyle Evans wrote:
> > Author: kevans
> > Date: Mon Apr 15 18:53:28 2019
> > New Revision: 346252
> > URL: https://svnweb.freebsd.org/changeset/base/346252
> >
> > Log:
> >   cron(8): Add MAILFROM ability for crontabs
> >
> >   This changes the sender mail address in a similar fashion to how MAILTO 
> > may
> >   change the recipient. The default from address remains unchanged.
> >
> >   MFC after:  1 week
> >
> > Modified:
> >   head/usr.sbin/cron/cron/cron.8
> >   head/usr.sbin/cron/cron/do_command.c
> >   head/usr.sbin/cron/crontab/crontab.5
> >
>
> Is this going to allow normal users to spoof the From: using private
> crontabs?  That sounds mildly dangerous.
>
> -- Ian

I think my description here was lacking- this is a per-crontab
environment variable, so yes: a user may spoof the from address in a
private crontab for jobs within that crontab. I don't know how much of
a security concern this is, but I peaked at cronie [1] after you
brought this up and observed that their implementation is effectively
the same restriction-wise, but with sanity checking for both
mailfrom/mailto values.

[1] https://github.com/cronie-crond/cronie/blob/master/src/do_command.c
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r346252 - in head/usr.sbin/cron: cron crontab

2019-04-15 Thread Ian Lepore
On Mon, 2019-04-15 at 18:53 +, Kyle Evans wrote:
> Author: kevans
> Date: Mon Apr 15 18:53:28 2019
> New Revision: 346252
> URL: https://svnweb.freebsd.org/changeset/base/346252
> 
> Log:
>   cron(8): Add MAILFROM ability for crontabs
>   
>   This changes the sender mail address in a similar fashion to how MAILTO may
>   change the recipient. The default from address remains unchanged.
>   
>   MFC after:  1 week
> 
> Modified:
>   head/usr.sbin/cron/cron/cron.8
>   head/usr.sbin/cron/cron/do_command.c
>   head/usr.sbin/cron/crontab/crontab.5
> 

Is this going to allow normal users to spoof the From: using private
crontabs?  That sounds mildly dangerous.

-- Ian

> Modified: head/usr.sbin/cron/cron/cron.8
> =
> =
> --- head/usr.sbin/cron/cron/cron.8Mon Apr 15 18:49:04 2019(r346
> 251)
> +++ head/usr.sbin/cron/cron/cron.8Mon Apr 15 18:53:28 2019(r346
> 252)
> @@ -17,7 +17,7 @@
>  .\"
>  .\" $FreeBSD$
>  .\"
> -.Dd July 19, 2017
> +.Dd April 15, 2019
>  .Dt CRON 8
>  .Os
>  .Sh NAME
> @@ -79,6 +79,9 @@ commands, any output is mailed to the owner of the
> cro
>  named in the
>  .Ev MAILTO
>  environment variable in the crontab, if such exists).
> +The from address of this mail may be set with the
> +.Ev MAILFROM
> +environment variable.
>  .Pp
>  Additionally,
>  .Nm
> 
> Modified: head/usr.sbin/cron/cron/do_command.c
> =
> =
> --- head/usr.sbin/cron/cron/do_command.c  Mon Apr 15 18:49:04
> 2019  (r346251)
> +++ head/usr.sbin/cron/cron/do_command.c  Mon Apr 15 18:53:28
> 2019  (r346252)
> @@ -93,7 +93,7 @@ child_process(e, u)
>  {
>   int stdin_pipe[2], stdout_pipe[2];
>   register char   *input_data;
> - char*usernm, *mailto;
> + char*usernm, *mailto, *mailfrom;
>   int children = 0;
>  # if defined(LOGIN_CAP)
>   struct passwd   *pwd;
> @@ -111,6 +111,7 @@ child_process(e, u)
>*/
>   usernm = env_get("LOGNAME", e->envp);
>   mailto = env_get("MAILTO", e->envp);
> + mailfrom = env_get("MAILFROM", e->envp);
>  
>  #ifdef PAM
>   /* use PAM to see if the user's account is available,
> @@ -503,8 +504,12 @@ child_process(e, u)
>   warn("%s", MAILCMD);
>   (void) _exit(ERROR_EXIT);
>   }
> - fprintf(mail, "From: Cron Daemon
> <%s@%s>\n",
> - usernm, hostname);
> + if (mailfrom == NULL || *mailfrom ==
> '\0')
> + fprintf(mail, "From: Cron
> Daemon <%s@%s>\n",
> + usernm, hostname);
> + else
> + fprintf(mail, "From: Cron
> Daemon <%s>\n",
> + mailfrom);
>   fprintf(mail, "To: %s\n", mailto);
>   fprintf(mail, "Subject: Cron <%s@%s>
> %s\n",
>   usernm, first_word(hostname,
> "."),
> 
> Modified: head/usr.sbin/cron/crontab/crontab.5
> =
> =
> --- head/usr.sbin/cron/crontab/crontab.5  Mon Apr 15 18:49:04
> 2019  (r346251)
> +++ head/usr.sbin/cron/crontab/crontab.5  Mon Apr 15 18:53:28
> 2019  (r346252)
> @@ -17,7 +17,7 @@
>  .\"
>  .\" $FreeBSD$
>  .\"
> -.Dd June 6, 2018
> +.Dd April 15, 2019
>  .Dt CRONTAB 5
>  .Os
>  .Sh NAME
> @@ -116,6 +116,9 @@ If
>  .Ev MAILTO
>  is defined (and non-empty), mail is
>  sent to the user so named.
> +If
> +.Ev MAILFROM
> +is defined (and non-empty), its value will be used as the from
> address.
>  .Ev MAILTO
>  may also be used to direct mail to multiple recipients
>  by separating recipient users with a comma.
> 

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


svn commit: r346253 - head/share/misc

2019-04-15 Thread Piotr Kubaj
Author: pkubaj (ports committer)
Date: Mon Apr 15 19:21:45 2019
New Revision: 346253
URL: https://svnweb.freebsd.org/changeset/base/346253

Log:
  Add myself to committer list.
  
  Approved by:  tcberner (mentor)

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

Modified: head/share/misc/committers-ports.dot
==
--- head/share/misc/committers-ports.dotMon Apr 15 18:53:28 2019
(r346252)
+++ head/share/misc/committers-ports.dotMon Apr 15 19:21:45 2019
(r346253)
@@ -217,6 +217,7 @@ pgollucci [label="Philip M. Gollucci\npgollucci@FreeBS
 philip [label="Philip Paeps\nphi...@freebsd.org\n2005/10/19"]
 pi [label="Kurt Jaeger\n...@freebsd.org\n2014/03/14"]
 pizzamig [label="Luca Pizzamiglio\npizza...@freebsd.org\n2017/08/25"]
+pkubaj [label="Piotr Kubaj\npku...@freebsd.org\n2019/04/14"]
 rafan [label="Rong-En Fan\nra...@freebsd.org\n2006/06/23"]
 rakuco [label="Raphael Kubo da Costa\nrak...@freebsd.org\n2011/08/22"]
 rene [label="Rene Ladan\nr...@freebsd.org\n2010/04/11"]
@@ -519,6 +520,7 @@ ler -> leres
 lifanov -> ultima
 
 linimon -> hrs
+linimon -> pkubaj
 
 lioux -> pat
 
@@ -555,6 +557,7 @@ mat -> thierry
 mat -> tobik
 mat -> woodsb02
 mat -> rigoletto
+mat -> pkubaj
 
 matthew -> leres
 matthew -> lifanov
@@ -719,6 +722,7 @@ tcberner -> fernape
 tcberner -> arrowd
 tcberner -> rigoletto
 tcberner -> kai
+tcberner -> pkubaj
 
 thierry -> jadawin
 thierry -> riggs
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r346252 - in head/usr.sbin/cron: cron crontab

2019-04-15 Thread Kyle Evans
On Mon, Apr 15, 2019 at 1:53 PM Kyle Evans  wrote:
>
> Author: kevans
> Date: Mon Apr 15 18:53:28 2019
> New Revision: 346252
> URL: https://svnweb.freebsd.org/changeset/base/346252
>
> Log:
>   cron(8): Add MAILFROM ability for crontabs
>
>   This changes the sender mail address in a similar fashion to how MAILTO may
>   change the recipient. The default from address remains unchanged.
>
>   MFC after:1 week
>

I failed to ^C this in time to add:

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


svn commit: r346252 - in head/usr.sbin/cron: cron crontab

2019-04-15 Thread Kyle Evans
Author: kevans
Date: Mon Apr 15 18:53:28 2019
New Revision: 346252
URL: https://svnweb.freebsd.org/changeset/base/346252

Log:
  cron(8): Add MAILFROM ability for crontabs
  
  This changes the sender mail address in a similar fashion to how MAILTO may
  change the recipient. The default from address remains unchanged.
  
  MFC after:1 week

Modified:
  head/usr.sbin/cron/cron/cron.8
  head/usr.sbin/cron/cron/do_command.c
  head/usr.sbin/cron/crontab/crontab.5

Modified: head/usr.sbin/cron/cron/cron.8
==
--- head/usr.sbin/cron/cron/cron.8  Mon Apr 15 18:49:04 2019
(r346251)
+++ head/usr.sbin/cron/cron/cron.8  Mon Apr 15 18:53:28 2019
(r346252)
@@ -17,7 +17,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd July 19, 2017
+.Dd April 15, 2019
 .Dt CRON 8
 .Os
 .Sh NAME
@@ -79,6 +79,9 @@ commands, any output is mailed to the owner of the cro
 named in the
 .Ev MAILTO
 environment variable in the crontab, if such exists).
+The from address of this mail may be set with the
+.Ev MAILFROM
+environment variable.
 .Pp
 Additionally,
 .Nm

Modified: head/usr.sbin/cron/cron/do_command.c
==
--- head/usr.sbin/cron/cron/do_command.cMon Apr 15 18:49:04 2019
(r346251)
+++ head/usr.sbin/cron/cron/do_command.cMon Apr 15 18:53:28 2019
(r346252)
@@ -93,7 +93,7 @@ child_process(e, u)
 {
int stdin_pipe[2], stdout_pipe[2];
register char   *input_data;
-   char*usernm, *mailto;
+   char*usernm, *mailto, *mailfrom;
int children = 0;
 # if defined(LOGIN_CAP)
struct passwd   *pwd;
@@ -111,6 +111,7 @@ child_process(e, u)
 */
usernm = env_get("LOGNAME", e->envp);
mailto = env_get("MAILTO", e->envp);
+   mailfrom = env_get("MAILFROM", e->envp);
 
 #ifdef PAM
/* use PAM to see if the user's account is available,
@@ -503,8 +504,12 @@ child_process(e, u)
warn("%s", MAILCMD);
(void) _exit(ERROR_EXIT);
}
-   fprintf(mail, "From: Cron Daemon <%s@%s>\n",
-   usernm, hostname);
+   if (mailfrom == NULL || *mailfrom == '\0')
+   fprintf(mail, "From: Cron Daemon 
<%s@%s>\n",
+   usernm, hostname);
+   else
+   fprintf(mail, "From: Cron Daemon 
<%s>\n",
+   mailfrom);
fprintf(mail, "To: %s\n", mailto);
fprintf(mail, "Subject: Cron <%s@%s> %s\n",
usernm, first_word(hostname, "."),

Modified: head/usr.sbin/cron/crontab/crontab.5
==
--- head/usr.sbin/cron/crontab/crontab.5Mon Apr 15 18:49:04 2019
(r346251)
+++ head/usr.sbin/cron/crontab/crontab.5Mon Apr 15 18:53:28 2019
(r346252)
@@ -17,7 +17,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd June 6, 2018
+.Dd April 15, 2019
 .Dt CRONTAB 5
 .Os
 .Sh NAME
@@ -116,6 +116,9 @@ If
 .Ev MAILTO
 is defined (and non-empty), mail is
 sent to the user so named.
+If
+.Ev MAILFROM
+is defined (and non-empty), its value will be used as the from address.
 .Ev MAILTO
 may also be used to direct mail to multiple recipients
 by separating recipient users with a comma.
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r346251 - head/lib/libc/stdlib

2019-04-15 Thread Conrad Meyer
Author: cem
Date: Mon Apr 15 18:49:04 2019
New Revision: 346251
URL: https://svnweb.freebsd.org/changeset/base/346251

Log:
  random.3: Clarify confusing summary
  
  random.3 is only "better" in contrast to rand.3.  Both are non-cryptographic
  pseudo-random number generators.  The opening blurbs of each's DESCRIPTION
  section does emphasize this, and correctly directs unfamiliar developers to
  arc4random(3).  However, the summary (".Nd" or Name description) of random.3
  conflicted in tone and message with that warning.
  
  Resolve the conflict by clarifying in the Nd section that random(3) is
  non-cryptographic and pseudo-random.  Elide the "better" qualifier which
  implied a comparison but did not provide a specific object to contrast.
  
  Sponsored by: Dell EMC Isilon

Modified:
  head/lib/libc/stdlib/random.3

Modified: head/lib/libc/stdlib/random.3
==
--- head/lib/libc/stdlib/random.3   Mon Apr 15 18:40:36 2019
(r346250)
+++ head/lib/libc/stdlib/random.3   Mon Apr 15 18:49:04 2019
(r346251)
@@ -28,7 +28,7 @@
 .\" @(#)random.3   8.1 (Berkeley) 6/4/93
 .\" $FreeBSD$
 .\"
-.Dd July 26, 2016
+.Dd April 15, 2019
 .Dt RANDOM 3
 .Os
 .Sh NAME
@@ -37,7 +37,7 @@
 .Nm srandomdev ,
 .Nm initstate ,
 .Nm setstate
-.Nd better random number generator; routines for changing generators
+.Nd non-cryptographic pseudorandom number generator; routines for changing 
generators
 .Sh LIBRARY
 .Lb libc
 .Sh SYNOPSIS
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r346250 - in head: share/man/man4 share/man/man9 sys/dev/random sys/kern sys/libkern sys/sys

2019-04-15 Thread Conrad Meyer
Author: cem
Date: Mon Apr 15 18:40:36 2019
New Revision: 346250
URL: https://svnweb.freebsd.org/changeset/base/346250

Log:
  random(4): Block read_random(9) on initial seeding
  
  read_random() is/was used, mostly without error checking, in a lot of
  very sensitive places in the kernel -- including seeding the widely used
  arc4random(9).
  
  Most uses, especially arc4random(9), should block until the device is seeded
  rather than proceeding with a bogus or empty seed.  I did not spy any
  obvious kernel consumers where blocking would be inappropriate (in the
  sense that lack of entropy would be ok -- I did not investigate locking
  angle thoroughly).  In many instances, arc4random_buf(9) or that family
  of APIs would be more appropriate anyway; that work was done in r345865.
  
  A minor cleanup was made to the implementation of the READ_RANDOM function:
  instead of using a variable-length array on the stack to temporarily store
  all full random blocks sufficient to satisfy the requested 'len', only store
  a single block on the stack.  This has some benefit in terms of reducing
  stack usage, reducing memcpy overhead and reducing devrandom output leakage
  via the stack.  Additionally, the stack block is now safely zeroed if it was
  used.
  
  One caveat of this change is that the kern.arandom sysctl no longer returns
  zero bytes immediately if the random device is not seeded.  This means that
  FreeBSD-specific userspace applications which attempted to handle an
  unseeded random device may be broken by this change.  If such behavior is
  needed, it can be replaced by the more portable getrandom(2) GRND_NONBLOCK
  option.
  
  On any typical FreeBSD system, entropy is persisted on read/write media and
  used to seed the random device very early in boot, and blocking is never a
  problem.
  
  This change primarily impacts the behavior of /dev/random on embedded
  systems with read-only media that do not configure "nodevice random".  We
  toggle the default from 'charge on blindly with no entropy' to 'block
  indefinitely.'  This default is safer, but may cause frustration.  Embedded
  system designers using FreeBSD have several options.  The most obvious is to
  plan to have a small writable NVRAM or NAND to persist entropy, like larger
  systems.  Early entropy can be fed from any loader, or by writing directly
  to /dev/random during boot.  Some embedded SoCs now provide a fast hardware
  entropy source; this would also work for quickly seeding Fortuna.  A 3rd
  option would be creating an embedded-specific, more simplistic random
  module, like that designed by DJB in [1] (this design still requires a small
  rewritable media for forward secrecy).  Finally, the least preferred option
  might be "nodevice random", although I plan to remove this in a subsequent
  revision.
  
  To help developers emulate the behavior of these embedded systems on
  ordinary workstations, the tunable kern.random.block_seeded_status was
  added.  When set to 1, it blocks the random device.
  
  I attempted to document this change in random.4 and random.9 and ran into a
  bunch of out-of-date or irrelevant or inaccurate content and ended up
  rototilling those documents more than I intended to.  Sorry.  I think
  they're in a better state now.
  
  PR:   230875
  Reviewed by:  delphij, markm (earlier version)
  Approved by:  secteam(delphij), devrandom(markm)
  Relnotes: yes
  Differential Revision:https://reviews.freebsd.org/D19744

Modified:
  head/share/man/man4/random.4
  head/share/man/man9/random.9
  head/sys/dev/random/fortuna.c
  head/sys/dev/random/random_harvestq.c
  head/sys/dev/random/random_infra.c
  head/sys/dev/random/randomdev.c
  head/sys/dev/random/randomdev.h
  head/sys/kern/kern_mib.c
  head/sys/libkern/arc4random.c
  head/sys/sys/random.h

Modified: head/share/man/man4/random.4
==
--- head/share/man/man4/random.4Mon Apr 15 17:54:40 2019
(r346249)
+++ head/share/man/man4/random.4Mon Apr 15 18:40:36 2019
(r346250)
@@ -23,7 +23,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd August 26, 2018
+.Dd April 15, 2019
 .Dt RANDOM 4
 .Os
 .Sh NAME
@@ -32,63 +32,44 @@
 .Sh SYNOPSIS
 .Cd "device random"
 .Cd "options RANDOM_LOADABLE"
+.Cd "options RANDOM_ENABLE_ETHER"
 .Cd "options RANDOM_ENABLE_UMA"
 .Sh DESCRIPTION
 The
 .Nm
-device
-returns an endless supply of random bytes when read.
-It also accepts and reads data
-as any ordinary file.
+device returns an endless supply of random bytes when read.
 .Pp
 The generator will start in an
 .Em unseeded
-state, and will block reads until
-it is seeded for the first time.
-This may cause trouble at system boot
-when keys and the like
-are generated from
-.Nm
-so steps should be taken to ensure a
-seeding as soon as possible.
+state, and will block reads until it is seeded for the first time.
 .Pp
-It is also possible
-to read random bytes
-by 

svn commit: r346249 - stable/11/sys/dev/nvme

2019-04-15 Thread Alexander Motin
Author: mav
Date: Mon Apr 15 17:54:40 2019
New Revision: 346249
URL: https://svnweb.freebsd.org/changeset/base/346249

Log:
  MFC r330760: Add new opcodes and statuses from NVMe 1.3a.

Modified:
  stable/11/sys/dev/nvme/nvme.h
  stable/11/sys/dev/nvme/nvme_qpair.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/dev/nvme/nvme.h
==
--- stable/11/sys/dev/nvme/nvme.h   Mon Apr 15 17:32:38 2019
(r346248)
+++ stable/11/sys/dev/nvme/nvme.h   Mon Apr 15 17:54:40 2019
(r346249)
@@ -316,10 +316,31 @@ enum nvme_generic_command_status_code {
NVME_SC_ABORTED_MISSING_FUSED   = 0x0a,
NVME_SC_INVALID_NAMESPACE_OR_FORMAT = 0x0b,
NVME_SC_COMMAND_SEQUENCE_ERROR  = 0x0c,
+   NVME_SC_INVALID_SGL_SEGMENT_DESCR   = 0x0d,
+   NVME_SC_INVALID_NUMBER_OF_SGL_DESCR = 0x0e,
+   NVME_SC_DATA_SGL_LENGTH_INVALID = 0x0f,
+   NVME_SC_METADATA_SGL_LENGTH_INVALID = 0x10,
+   NVME_SC_SGL_DESCRIPTOR_TYPE_INVALID = 0x11,
+   NVME_SC_INVALID_USE_OF_CMB  = 0x12,
+   NVME_SC_PRP_OFFET_INVALID   = 0x13,
+   NVME_SC_ATOMIC_WRITE_UNIT_EXCEEDED  = 0x14,
+   NVME_SC_OPERATION_DENIED= 0x15,
+   NVME_SC_SGL_OFFSET_INVALID  = 0x16,
+   /* 0x17 - reserved */
+   NVME_SC_HOST_ID_INCONSISTENT_FORMAT = 0x18,
+   NVME_SC_KEEP_ALIVE_TIMEOUT_EXPIRED  = 0x19,
+   NVME_SC_KEEP_ALIVE_TIMEOUT_INVALID  = 0x1a,
+   NVME_SC_ABORTED_DUE_TO_PREEMPT  = 0x1b,
+   NVME_SC_SANITIZE_FAILED = 0x1c,
+   NVME_SC_SANITIZE_IN_PROGRESS= 0x1d,
+   NVME_SC_SGL_DATA_BLOCK_GRAN_INVALID = 0x1e,
+   NVME_SC_NOT_SUPPORTED_IN_CMB= 0x1f,
 
NVME_SC_LBA_OUT_OF_RANGE= 0x80,
NVME_SC_CAPACITY_EXCEEDED   = 0x81,
NVME_SC_NAMESPACE_NOT_READY = 0x82,
+   NVME_SC_RESERVATION_CONFLICT= 0x83,
+   NVME_SC_FORMAT_IN_PROGRESS  = 0x84,
 };
 
 /* command specific status codes */
@@ -336,6 +357,29 @@ enum nvme_command_specific_status_code {
NVME_SC_INVALID_LOG_PAGE= 0x09,
NVME_SC_INVALID_FORMAT  = 0x0a,
NVME_SC_FIRMWARE_REQUIRES_RESET = 0x0b,
+   NVME_SC_INVALID_QUEUE_DELETION  = 0x0c,
+   NVME_SC_FEATURE_NOT_SAVEABLE= 0x0d,
+   NVME_SC_FEATURE_NOT_CHANGEABLE  = 0x0e,
+   NVME_SC_FEATURE_NOT_NS_SPECIFIC = 0x0f,
+   NVME_SC_FW_ACT_REQUIRES_NVMS_RESET  = 0x10,
+   NVME_SC_FW_ACT_REQUIRES_RESET   = 0x11,
+   NVME_SC_FW_ACT_REQUIRES_TIME= 0x12,
+   NVME_SC_FW_ACT_PROHIBITED   = 0x13,
+   NVME_SC_OVERLAPPING_RANGE   = 0x14,
+   NVME_SC_NS_INSUFFICIENT_CAPACITY= 0x15,
+   NVME_SC_NS_ID_UNAVAILABLE   = 0x16,
+   /* 0x17 - reserved */
+   NVME_SC_NS_ALREADY_ATTACHED = 0x18,
+   NVME_SC_NS_IS_PRIVATE   = 0x19,
+   NVME_SC_NS_NOT_ATTACHED = 0x1a,
+   NVME_SC_THIN_PROV_NOT_SUPPORTED = 0x1b,
+   NVME_SC_CTRLR_LIST_INVALID  = 0x1c,
+   NVME_SC_SELT_TEST_IN_PROGRESS   = 0x1d,
+   NVME_SC_BOOT_PART_WRITE_PROHIB  = 0x1e,
+   NVME_SC_INVALID_CTRLR_ID= 0x1f,
+   NVME_SC_INVALID_SEC_CTRLR_STATE = 0x20,
+   NVME_SC_INVALID_NUM_OF_CTRLR_RESRC  = 0x21,
+   NVME_SC_INVALID_RESOURCE_ID = 0x22,
 
NVME_SC_CONFLICTING_ATTRIBUTES  = 0x80,
NVME_SC_INVALID_PROTECTION_INFO = 0x81,
@@ -351,6 +395,7 @@ enum nvme_media_error_status_code {
NVME_SC_REFERENCE_TAG_CHECK_ERROR   = 0x84,
NVME_SC_COMPARE_FAILURE = 0x85,
NVME_SC_ACCESS_DENIED   = 0x86,
+   NVME_SC_DEALLOCATED_OR_UNWRITTEN= 0x87,
 };
 
 /* admin opcodes */
@@ -372,11 +417,20 @@ enum nvme_admin_opcode {
/* 0x0e-0x0f - reserved */
NVME_OPC_FIRMWARE_ACTIVATE  = 0x10,
NVME_OPC_FIRMWARE_IMAGE_DOWNLOAD= 0x11,
+   NVME_OPC_DEVICE_SELF_TEST   = 0x14,
NVME_OPC_NAMESPACE_ATTACHMENT   = 0x15,
+   NVME_OPC_KEEP_ALIVE = 0x18,
+   NVME_OPC_DIRECTIVE_SEND = 0x19,
+   NVME_OPC_DIRECTIVE_RECEIVE  = 0x1a,
+   NVME_OPC_VIRTUALIZATION_MANAGEMENT  = 0x1c,
+   NVME_OPC_NVME_MI_SEND   = 0x1d,
+   NVME_OPC_NVME_MI_RECEIVE= 0x1e,
+   NVME_OPC_DOORBELL_BUFFER_CONFIG = 0x7c,
 
NVME_OPC_FORMAT_NVM = 0x80,
NVME_OPC_SECURITY_SEND  = 0x81,
NVME_OPC_SECURITY_RECEIVE   = 0x82,
+   

svn commit: r346248 - head/sys/dev/usb/controller

2019-04-15 Thread Hans Petter Selasky
Author: hselasky
Date: Mon Apr 15 17:32:38 2019
New Revision: 346248
URL: https://svnweb.freebsd.org/changeset/base/346248

Log:
  Remove superfluous USB keyword.
  
  Discussed with:   danfe@
  MFC after:1 week
  Sponsored by: Mellanox Technologies

Modified:
  head/sys/dev/usb/controller/ehci_pci.c

Modified: head/sys/dev/usb/controller/ehci_pci.c
==
--- head/sys/dev/usb/controller/ehci_pci.c  Mon Apr 15 17:14:50 2019
(r346247)
+++ head/sys/dev/usb/controller/ehci_pci.c  Mon Apr 15 17:32:38 2019
(r346248)
@@ -181,7 +181,7 @@ ehci_pci_match(device_t self)
case 0x8d2d8086:
return ("Intel Wellsburg USB 2.0 controller");
case 0x9c268086:
-   return ("Intel Lynx Point-LP USB 2.0 controller USB");
+   return ("Intel Lynx Point-LP USB 2.0 controller");
 
case 0x00e01033:
return ("NEC uPD 72010x USB 2.0 controller");
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r346247 - head/sys/dev/mlx5/mlx5_en

2019-04-15 Thread Andrew Gallatin
Author: gallatin
Date: Mon Apr 15 17:14:50 2019
New Revision: 346247
URL: https://svnweb.freebsd.org/changeset/base/346247

Log:
  mlx5en: Enable new pfil(9) KPI ethernet filtering hooks
  
  This allows efficient filtering at packet ingress on mlx5en.
  
  Note that the packets are filtered (and potentially dropped) *before*
  the driver has committed to (re)allocating an mbuf for the
  packet. Dropped packets are treated essentially the same as an
  error. Nothing is allocated, and the existing buffer is recycled. This
  allows us to drop malicious packets at close to line rate with very
  little CPU use.
  
  Reviewed by:  hselasky, slavash, kib
  Sponsored by: Netflix
  Differential Revision:https://reviews.freebsd.org/D19063

Modified:
  head/sys/dev/mlx5/mlx5_en/en.h
  head/sys/dev/mlx5/mlx5_en/mlx5_en_main.c
  head/sys/dev/mlx5/mlx5_en/mlx5_en_rx.c

Modified: head/sys/dev/mlx5/mlx5_en/en.h
==
--- head/sys/dev/mlx5/mlx5_en/en.h  Mon Apr 15 16:57:27 2019
(r346246)
+++ head/sys/dev/mlx5/mlx5_en/en.h  Mon Apr 15 17:14:50 2019
(r346247)
@@ -48,6 +48,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -838,6 +839,7 @@ struct mlx5e_priv {
struct mlx5e_clbr_point clbr_points[2];
u_int   clbr_gen;
 
+   struct pfil_head *pfil;
struct mlx5e_channel channel[];
 };
 

Modified: head/sys/dev/mlx5/mlx5_en/mlx5_en_main.c
==
--- head/sys/dev/mlx5/mlx5_en/mlx5_en_main.cMon Apr 15 16:57:27 2019
(r346246)
+++ head/sys/dev/mlx5/mlx5_en/mlx5_en_main.cMon Apr 15 17:14:50 2019
(r346247)
@@ -3664,6 +3664,7 @@ mlx5e_create_ifp(struct mlx5_core_dev *mdev)
struct sysctl_oid_list *child;
int ncv = mdev->priv.eq_table.num_comp_vectors;
char unit[16];
+   struct pfil_head_args pa;
int err;
int i;
u32 eth_proto_cap;
@@ -3898,6 +3899,12 @@ mlx5e_create_ifp(struct mlx5_core_dev *mdev)
callout_init(>tstmp_clbr, CALLOUT_DIRECT);
mlx5e_reset_calibration_callout(priv);
 
+   pa.pa_version = PFIL_VERSION;
+   pa.pa_flags = PFIL_IN;
+   pa.pa_type = PFIL_TYPE_ETHERNET;
+   pa.pa_headname = ifp->if_xname;
+   priv->pfil = pfil_head_register();
+
return (priv);
 
 #ifdef RATELIMIT
@@ -3972,6 +3979,12 @@ mlx5e_destroy_ifp(struct mlx5_core_dev *mdev, void *vp
if_printf(priv->ifp, "Waiting for all unlimited connections "
"to terminate\n");
pause("W", hz);
+   }
+
+   /* deregister pfil */
+   if (priv->pfil != NULL) {
+   pfil_head_unregister(priv->pfil);
+   priv->pfil = NULL;
}
 
/* unregister device */

Modified: head/sys/dev/mlx5/mlx5_en/mlx5_en_rx.c
==
--- head/sys/dev/mlx5/mlx5_en/mlx5_en_rx.c  Mon Apr 15 16:57:27 2019
(r346246)
+++ head/sys/dev/mlx5/mlx5_en/mlx5_en_rx.c  Mon Apr 15 17:14:50 2019
(r346247)
@@ -430,15 +430,18 @@ mlx5e_decompress_cqes(struct mlx5e_cq *cq)
 static int
 mlx5e_poll_rx_cq(struct mlx5e_rq *rq, int budget)
 {
-   int i;
+   struct pfil_head *pfil;
+   int i, rv;
 
+   CURVNET_SET_QUIET(rq->ifp->if_vnet);
+   pfil = rq->channel->priv->pfil;
for (i = 0; i < budget; i++) {
struct mlx5e_rx_wqe *wqe;
struct mlx5_cqe64 *cqe;
struct mbuf *mb;
__be16 wqe_counter_be;
u16 wqe_counter;
-   u32 byte_cnt;
+   u32 byte_cnt, seglen;
 
cqe = mlx5e_get_cqe(>cq);
if (!cqe)
@@ -462,6 +465,39 @@ mlx5e_poll_rx_cq(struct mlx5e_rq *rq, int budget)
rq->stats.wqe_err++;
goto wq_ll_pop;
}
+   if (pfil != NULL && PFIL_HOOKED_IN(pfil)) {
+   seglen = MIN(byte_cnt, MLX5E_MAX_RX_BYTES);
+   rv = pfil_run_hooks(rq->channel->priv->pfil,
+   rq->mbuf[wqe_counter].data, rq->ifp,
+   seglen | PFIL_MEMPTR | PFIL_IN, NULL);
+
+   switch (rv) {
+   case PFIL_DROPPED:
+   case PFIL_CONSUMED:
+   /*
+* Filter dropped or consumed it. In
+* either case, we can just recycle
+* buffer; there is no more work to do.
+*/
+   rq->stats.packets++;
+   goto wq_ll_pop;
+   case PFIL_REALLOCED:
+   /*
+* Filter copied it; recycle buffer
+

svn commit: r346246 - stable/11/sys/dev/nvme

2019-04-15 Thread Alexander Motin
Author: mav
Date: Mon Apr 15 16:57:27 2019
New Revision: 346246
URL: https://svnweb.freebsd.org/changeset/base/346246

Log:
  MFC part of r334200:
   - Add missing nvme_notify_fail_consumers() call on controller detach.
  
  With nvd(4) driver fixes merged it should now handle detach properly.
  The rest of r334200 seems too invasive and depending to be MFC'd.

Modified:
  stable/11/sys/dev/nvme/nvme_ctrlr.c

Modified: stable/11/sys/dev/nvme/nvme_ctrlr.c
==
--- stable/11/sys/dev/nvme/nvme_ctrlr.c Mon Apr 15 16:29:47 2019
(r346245)
+++ stable/11/sys/dev/nvme/nvme_ctrlr.c Mon Apr 15 16:57:27 2019
(r346246)
@@ -1226,6 +1226,8 @@ nvme_ctrlr_destruct(struct nvme_controller *ctrlr, dev
if (ctrlr->resource == NULL)
goto nores;
 
+   nvme_notify_fail_consumers(ctrlr);
+
for (i = 0; i < NVME_MAX_NAMESPACES; i++)
nvme_ns_destruct(>ns[i]);
 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r346245 - stable/11/sys/dev/nvme

2019-04-15 Thread Alexander Motin
Author: mav
Date: Mon Apr 15 16:29:47 2019
New Revision: 346245
URL: https://svnweb.freebsd.org/changeset/base/346245

Log:
  MFC r344736 (by imp): Add ABORTED_BY_REQUEST to the list of things we look
  at DNR bit and tell why to comment (code already does this)

Modified:
  stable/11/sys/dev/nvme/nvme_qpair.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/dev/nvme/nvme_qpair.c
==
--- stable/11/sys/dev/nvme/nvme_qpair.c Mon Apr 15 16:28:25 2019
(r346244)
+++ stable/11/sys/dev/nvme/nvme_qpair.c Mon Apr 15 16:29:47 2019
(r346245)
@@ -255,7 +255,8 @@ nvme_completion_is_retry(const struct nvme_completion 
 * TODO: spec is not clear how commands that are aborted due
 *  to TLER will be marked.  So for now, it seems
 *  NAMESPACE_NOT_READY is the only case where we should
-*  look at the DNR bit.
+*  look at the DNR bit. Requests failed with ABORTED_BY_REQUEST
+*  set the DNR bit correctly since the driver controls that.
 */
switch (cpl->status.sct) {
case NVME_SCT_GENERIC:
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r346244 - stable/11/sys/dev/nvme

2019-04-15 Thread Alexander Motin
Author: mav
Date: Mon Apr 15 16:28:25 2019
New Revision: 346244
URL: https://svnweb.freebsd.org/changeset/base/346244

Log:
  MFC r344642 (by imp):
  Unconditionally support unmapped BIOs. This was another shim for
  supporting older kernels. However, all supported versions of FreeBSD
  have unmapped I/Os (as do several that have gone EOL), remove it. It's
  unlikely the driver would work on the older kernels anyway at this
  point.

Modified:
  stable/11/sys/dev/nvme/nvme_ctrlr.c
  stable/11/sys/dev/nvme/nvme_ns.c
  stable/11/sys/dev/nvme/nvme_private.h
  stable/11/sys/dev/nvme/nvme_qpair.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/dev/nvme/nvme_ctrlr.c
==
--- stable/11/sys/dev/nvme/nvme_ctrlr.c Mon Apr 15 16:27:53 2019
(r346243)
+++ stable/11/sys/dev/nvme/nvme_ctrlr.c Mon Apr 15 16:28:25 2019
(r346244)
@@ -986,11 +986,7 @@ nvme_ctrlr_passthrough_cmd(struct nvme_controller *ctr
buf->b_data = pt->buf;
buf->b_bufsize = pt->len;
buf->b_iocmd = pt->is_read ? BIO_READ : BIO_WRITE;
-#ifdef NVME_UNMAPPED_BIO_SUPPORT
if (vmapbuf(buf, 1) < 0) {
-#else
-   if (vmapbuf(buf) < 0) {
-#endif
ret = EFAULT;
goto err;
}

Modified: stable/11/sys/dev/nvme/nvme_ns.c
==
--- stable/11/sys/dev/nvme/nvme_ns.cMon Apr 15 16:27:53 2019
(r346243)
+++ stable/11/sys/dev/nvme/nvme_ns.cMon Apr 15 16:28:25 2019
(r346244)
@@ -346,10 +346,8 @@ nvme_construct_child_bios(struct bio *bp, uint32_t ali
caddr_t data;
uint32_trem_bcount;
int i;
-#ifdef NVME_UNMAPPED_BIO_SUPPORT
struct vm_page  **ma;
uint32_tma_offset;
-#endif
 
*num_bios = nvme_get_num_segments(bp->bio_offset, bp->bio_bcount,
alignment);
@@ -362,10 +360,8 @@ nvme_construct_child_bios(struct bio *bp, uint32_t ali
cur_offset = bp->bio_offset;
rem_bcount = bp->bio_bcount;
data = bp->bio_data;
-#ifdef NVME_UNMAPPED_BIO_SUPPORT
ma_offset = bp->bio_ma_offset;
ma = bp->bio_ma;
-#endif
 
for (i = 0; i < *num_bios; i++) {
child = child_bios[i];
@@ -375,7 +371,6 @@ nvme_construct_child_bios(struct bio *bp, uint32_t ali
child->bio_bcount = min(rem_bcount,
alignment - (cur_offset & (alignment - 1)));
child->bio_flags = bp->bio_flags;
-#ifdef NVME_UNMAPPED_BIO_SUPPORT
if (bp->bio_flags & BIO_UNMAPPED) {
child->bio_ma_offset = ma_offset;
child->bio_ma = ma;
@@ -387,9 +382,7 @@ nvme_construct_child_bios(struct bio *bp, uint32_t ali
ma += child->bio_ma_n;
if (ma_offset != 0)
ma -= 1;
-   } else
-#endif
-   {
+   } else {
child->bio_data = data;
data += child->bio_bcount;
}
@@ -575,9 +568,7 @@ nvme_ns_construct(struct nvme_namespace *ns, uint32_t 
if (res != 0)
return (ENXIO);
 
-#ifdef NVME_UNMAPPED_BIO_SUPPORT
ns->cdev->si_flags |= SI_UNMAPPED;
-#endif
 
return (0);
 }

Modified: stable/11/sys/dev/nvme/nvme_private.h
==
--- stable/11/sys/dev/nvme/nvme_private.h   Mon Apr 15 16:27:53 2019
(r346243)
+++ stable/11/sys/dev/nvme/nvme_private.h   Mon Apr 15 16:28:25 2019
(r346244)
@@ -110,16 +110,6 @@ MALLOC_DECLARE(M_NVME);
 #define CACHE_LINE_SIZE(64)
 #endif
 
-/*
- * Use presence of the BIO_UNMAPPED flag to determine whether unmapped I/O
- *  support and the bus_dmamap_load_bio API are available on the target
- *  kernel.  This will ease porting back to earlier stable branches at a
- *  later point.
- */
-#ifdef BIO_UNMAPPED
-#define NVME_UNMAPPED_BIO_SUPPORT
-#endif
-
 extern uma_zone_t  nvme_request_zone;
 extern int32_t nvme_retry_count;
 
@@ -132,9 +122,7 @@ struct nvme_completion_poll_status {
 #define NVME_REQUEST_VADDR 1
 #define NVME_REQUEST_NULL  2 /* For requests with no payload. */
 #define NVME_REQUEST_UIO   3
-#ifdef NVME_UNMAPPED_BIO_SUPPORT
 #define NVME_REQUEST_BIO   4
-#endif
 #define NVME_REQUEST_CCB5
 
 struct nvme_request {
@@ -504,14 +492,8 @@ nvme_allocate_request_bio(struct bio *bio, nvme_cb_fn_
 
req = _nvme_allocate_request(cb_fn, cb_arg);
if (req != NULL) {
-#ifdef NVME_UNMAPPED_BIO_SUPPORT
req->type = NVME_REQUEST_BIO;
req->u.bio = bio;
-#else
-   

svn commit: r346243 - stable/11/sys/dev/nvme

2019-04-15 Thread Alexander Motin
Author: mav
Date: Mon Apr 15 16:27:53 2019
New Revision: 346243
URL: https://svnweb.freebsd.org/changeset/base/346243

Log:
  MFC r344640 (by imp):
  Remove #ifdef code to support FreeBSD versions that haven't been
  supported in years. A number of changes have been made to the driver
  that likely wouldn't work on those older versions that aren't properly
  ifdef'd and it's project policy to GC such code once it is stale.

Modified:
  stable/11/sys/dev/nvme/nvme_private.h
  stable/11/sys/dev/nvme/nvme_qpair.c
  stable/11/sys/dev/nvme/nvme_test.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/dev/nvme/nvme_private.h
==
--- stable/11/sys/dev/nvme/nvme_private.h   Mon Apr 15 16:27:06 2019
(r346242)
+++ stable/11/sys/dev/nvme/nvme_private.h   Mon Apr 15 16:27:53 2019
(r346243)
@@ -347,11 +347,6 @@ struct nvme_controller {
(val & 0xUL) >> 32);   \
} while (0);
 
-#if __FreeBSD_version < 800054
-#define wmb()  __asm volatile("sfence" ::: "memory")
-#define mb()   __asm volatile("mfence" ::: "memory")
-#endif
-
 #define nvme_printf(ctrlr, fmt, args...)   \
 device_printf(ctrlr->dev, fmt, ##args)
 

Modified: stable/11/sys/dev/nvme/nvme_qpair.c
==
--- stable/11/sys/dev/nvme/nvme_qpair.c Mon Apr 15 16:27:06 2019
(r346242)
+++ stable/11/sys/dev/nvme/nvme_qpair.c Mon Apr 15 16:27:53 2019
(r346243)
@@ -741,13 +741,8 @@ nvme_qpair_submit_tracker(struct nvme_qpair *qpair, st
ctrlr = qpair->ctrlr;
 
if (req->timeout)
-#if __FreeBSD_version >= 800030
callout_reset_curcpu(>timer, ctrlr->timeout_period * hz,
nvme_timeout, tr);
-#else
-   callout_reset(>timer, ctrlr->timeout_period * hz,
-   nvme_timeout, tr);
-#endif
 
/* Copy the command from the tracker to the submission queue. */
memcpy(>cmd[qpair->sq_tail], >cmd, sizeof(req->cmd));

Modified: stable/11/sys/dev/nvme/nvme_test.c
==
--- stable/11/sys/dev/nvme/nvme_test.c  Mon Apr 15 16:27:06 2019
(r346242)
+++ stable/11/sys/dev/nvme/nvme_test.c  Mon Apr 15 16:27:53 2019
(r346243)
@@ -92,9 +92,7 @@ nvme_ns_bio_test(void *arg)
struct timeval  t;
uint64_tio_completed = 0, offset;
uint32_tidx;
-#if __FreeBSD_version >= 900017
int ref;
-#endif
 
buf = malloc(io_test->size, M_NVME, M_WAITOK);
idx = atomic_fetchadd_int(_test->td_idx, 1);
@@ -116,11 +114,7 @@ nvme_ns_bio_test(void *arg)
bio->bio_bcount = io_test->size;
 
if (io_test->flags & NVME_TEST_FLAG_REFTHREAD) {
-#if __FreeBSD_version >= 900017
csw = dev_refthread(dev, );
-#else
-   csw = dev_refthread(dev);
-#endif
} else
csw = dev->si_devsw;
 
@@ -131,11 +125,7 @@ nvme_ns_bio_test(void *arg)
mtx_unlock(mtx);
 
if (io_test->flags & NVME_TEST_FLAG_REFTHREAD) {
-#if __FreeBSD_version >= 900017
dev_relthread(dev, ref);
-#else
-   dev_relthread(dev);
-#endif
}
 
if ((bio->bio_flags & BIO_ERROR) || (bio->bio_resid > 0))
@@ -164,11 +154,7 @@ nvme_ns_bio_test(void *arg)
atomic_subtract_int(_test->td_active, 1);
mb();
 
-#if __FreeBSD_version >= 80
kthread_exit();
-#else
-   kthread_exit(0);
-#endif
 }
 
 static void
@@ -244,11 +230,7 @@ nvme_ns_io_test(void *arg)
atomic_subtract_int(_test->td_active, 1);
mb();
 
-#if __FreeBSD_version >= 84
kthread_exit();
-#else
-   kthread_exit(0);
-#endif
 }
 
 void
@@ -285,13 +267,8 @@ nvme_ns_test(struct nvme_namespace *ns, u_long cmd, ca
getmicrouptime(_test_internal->start);
 
for (i = 0; i < io_test->num_threads; i++)
-#if __FreeBSD_version >= 84
kthread_add(fn, io_test_internal,
NULL, NULL, 0, 0, "nvme_io_test[%d]", i);
-#else
-   kthread_create(fn, io_test_internal,
-   NULL, 0, 0, "nvme_io_test[%d]", i);
-#endif
 
tsleep(io_test_internal, 0, "nvme_test", io_test->time * 2 * hz);
 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r346242 - stable/11/sys/dev/nvme

2019-04-15 Thread Alexander Motin
Author: mav
Date: Mon Apr 15 16:27:06 2019
New Revision: 346242
URL: https://svnweb.freebsd.org/changeset/base/346242

Log:
  MFC r342862 (by chuck): Add NVMe drive to NOIOB quirk list
  
  Dell-branded Intel P4600 NVMe drives benefit from NVMe 1.3's NOIOB
  feature. Unfortunately just like Intel DC P4500s, they don't advertise
  themselves as benefiting from this...
  
  This changes adds P4600s to the existing list of old drives which
  benefit from striping.

Modified:
  stable/11/sys/dev/nvme/nvme_ns.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/dev/nvme/nvme_ns.c
==
--- stable/11/sys/dev/nvme/nvme_ns.cMon Apr 15 16:25:00 2019
(r346241)
+++ stable/11/sys/dev/nvme/nvme_ns.cMon Apr 15 16:27:06 2019
(r346242)
@@ -497,6 +497,7 @@ nvme_ns_construct(struct nvme_namespace *ns, uint32_t 
case 0x09538086:/* Intel DC PC3500 */
case 0x0a538086:/* Intel DC PC3520 */
case 0x0a548086:/* Intel DC PC4500 */
+   case 0x0a558086:/* Dell Intel P4600 */
if (ctrlr->cdata.vs[3] != 0)
ns->stripesize =
(1 << ctrlr->cdata.vs[3]) * ctrlr->min_page_size;
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r346241 - stable/11/sys/dev/nvme

2019-04-15 Thread Alexander Motin
Author: mav
Date: Mon Apr 15 16:25:00 2019
New Revision: 346241
URL: https://svnweb.freebsd.org/changeset/base/346241

Log:
  MFC r340481 (by imp): Remove do-nothing nvme_modevent.
  
  nvme_modevent no longer does anything interesting, remove it.

Modified:
  stable/11/sys/dev/nvme/nvme.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/dev/nvme/nvme.c
==
--- stable/11/sys/dev/nvme/nvme.c   Mon Apr 15 16:24:26 2019
(r346240)
+++ stable/11/sys/dev/nvme/nvme.c   Mon Apr 15 16:25:00 2019
(r346241)
@@ -59,7 +59,6 @@ static intnvme_probe(device_t);
 static intnvme_attach(device_t);
 static intnvme_detach(device_t);
 static intnvme_shutdown(device_t);
-static intnvme_modevent(module_t mod, int type, void *arg);
 
 static devclass_t nvme_devclass;
 
@@ -78,7 +77,7 @@ static driver_t nvme_pci_driver = {
sizeof(struct nvme_controller),
 };
 
-DRIVER_MODULE(nvme, pci, nvme_pci_driver, nvme_devclass, nvme_modevent, 0);
+DRIVER_MODULE(nvme, pci, nvme_pci_driver, nvme_devclass, NULL, NULL);
 MODULE_VERSION(nvme, 1);
 MODULE_DEPEND(nvme, cam, 1, 1, 1);
 
@@ -179,16 +178,6 @@ nvme_uninit(void)
 
 SYSUNINIT(nvme_unregister, SI_SUB_DRIVERS, SI_ORDER_SECOND, nvme_uninit, NULL);
 
-static void
-nvme_load(void)
-{
-}
-
-static void
-nvme_unload(void)
-{
-}
-
 static int
 nvme_shutdown(device_t dev)
 {
@@ -196,24 +185,6 @@ nvme_shutdown(device_t dev)
 
ctrlr = DEVICE2SOFTC(dev);
nvme_ctrlr_shutdown(ctrlr);
-
-   return (0);
-}
-
-static int
-nvme_modevent(module_t mod, int type, void *arg)
-{
-
-   switch (type) {
-   case MOD_LOAD:
-   nvme_load();
-   break;
-   case MOD_UNLOAD:
-   nvme_unload();
-   break;
-   default:
-   break;
-   }
 
return (0);
 }
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r346240 - stable/11/sys/dev/nvme

2019-04-15 Thread Alexander Motin
Author: mav
Date: Mon Apr 15 16:24:26 2019
New Revision: 346240
URL: https://svnweb.freebsd.org/changeset/base/346240

Log:
  MFC r340412: Use atomic_load_acq_int() here too to poll done, ala r328521

Modified:
  stable/11/sys/dev/nvme/nvme_ns.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/dev/nvme/nvme_ns.c
==
--- stable/11/sys/dev/nvme/nvme_ns.cMon Apr 15 16:23:57 2019
(r346239)
+++ stable/11/sys/dev/nvme/nvme_ns.cMon Apr 15 16:24:26 2019
(r346240)
@@ -516,11 +516,11 @@ nvme_ns_construct(struct nvme_namespace *ns, uint32_t 
if (!mtx_initialized(>lock))
mtx_init(>lock, "nvme ns lock", NULL, MTX_DEF);
 
-   status.done = FALSE;
+   status.done = 0;
nvme_ctrlr_cmd_identify_namespace(ctrlr, id, >data,
nvme_completion_poll_cb, );
-   while (status.done == FALSE)
-   DELAY(5);
+   while (!atomic_load_acq_int())
+   pause("nvme", 1);
if (nvme_completion_is_error()) {
nvme_printf(ctrlr, "nvme_identify_namespace failed\n");
return (ENXIO);
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r346239 - stable/11/sys/dev/nvme

2019-04-15 Thread Alexander Motin
Author: mav
Date: Mon Apr 15 16:23:57 2019
New Revision: 346239
URL: https://svnweb.freebsd.org/changeset/base/346239

Log:
  MFC r339775: Put a workaround in for command timeout malfunctioning
  
  At least one NVMe drive has a bug that makeing the Command Time Out
  PCIe feature unreliable. The workaround is to disable this
  feature. The driver wouldn't deal correctly with a timeout anyway.
  Only do this for drives that are known bad.

Modified:
  stable/11/sys/dev/nvme/nvme.c
  stable/11/sys/dev/nvme/nvme_private.h
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/dev/nvme/nvme.c
==
--- stable/11/sys/dev/nvme/nvme.c   Mon Apr 15 15:35:42 2019
(r346238)
+++ stable/11/sys/dev/nvme/nvme.c   Mon Apr 15 16:23:57 2019
(r346239)
@@ -104,6 +104,7 @@ static struct _pcsid
{ 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  }
 };
 
@@ -263,6 +264,25 @@ nvme_attach(device_t dev)
if (status != 0) {
nvme_ctrlr_destruct(ctrlr, dev);
return (status);
+   }
+
+   /*
+* Some drives do not implement the completion timeout feature
+* correctly. There's a WAR from the manufacturer to just disable it.
+* The driver wouldn't respond correctly to a timeout anyway.
+*/
+   if (ep->quirks & QUIRK_DISABLE_TIMEOUT) {
+   int ptr;
+   uint16_t devctl2;
+
+   status = pci_find_cap(dev, PCIY_EXPRESS, );
+   if (status) {
+   device_printf(dev, "Can't locate PCIe capability?");
+   return (status);
+   }
+   devctl2 = pci_read_config(dev, ptr + PCIER_DEVICE_CTL2, 
sizeof(devctl2));
+   devctl2 |= PCIEM_CTL2_COMP_TIMO_DISABLE;
+   pci_write_config(dev, ptr + PCIER_DEVICE_CTL2, devctl2, 
sizeof(devctl2));
}
 
/*

Modified: stable/11/sys/dev/nvme/nvme_private.h
==
--- stable/11/sys/dev/nvme/nvme_private.h   Mon Apr 15 15:35:42 2019
(r346238)
+++ stable/11/sys/dev/nvme/nvme_private.h   Mon Apr 15 16:23:57 2019
(r346239)
@@ -245,7 +245,8 @@ struct nvme_controller {
 
uint32_tready_timeout_in_ms;
uint32_tquirks;
-#define QUIRK_DELAY_B4_CHK_RDY 1   /* Can't touch MMIO on disable 
*/
+#defineQUIRK_DELAY_B4_CHK_RDY  1   /* Can't touch MMIO on 
disable */
+#defineQUIRK_DISABLE_TIMEOUT   2   /* Disable broken 
completion timeout feature */
 
bus_space_tag_t bus_tag;
bus_space_handle_t  bus_handle;
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r346238 - stable/11/sys/dev/nvme

2019-04-15 Thread Alexander Motin
Author: mav
Date: Mon Apr 15 15:35:42 2019
New Revision: 346238
URL: https://svnweb.freebsd.org/changeset/base/346238

Log:
  MFC r337273 (by jhibbits):
  nvme(4): Add bus_dmamap_sync() at the end of the request path
  
  Summary:
  Some architectures, in this case powerpc64, need explicit synchronization
  barriers vs device accesses.
  
  Prior to this change, when running 'make buildworld -j72' on a 18-core
  (72-thread) POWER9, I would see controller resets often.  With this change, I
  don't see these resets messages, though another tester still does, for yet to 
be
  determined reasons, so this may not be a complete fix.  Additionally, I see a
  ~5-10% speed up in buildworld times, likely due to not needing to reset the
  controller.

Modified:
  stable/11/sys/dev/nvme/nvme_qpair.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/dev/nvme/nvme_qpair.c
==
--- stable/11/sys/dev/nvme/nvme_qpair.c Mon Apr 15 15:09:25 2019
(r346237)
+++ stable/11/sys/dev/nvme/nvme_qpair.c Mon Apr 15 15:35:42 2019
(r346238)
@@ -321,9 +321,13 @@ nvme_qpair_complete_tracker(struct nvme_qpair *qpair, 
req->retries++;
nvme_qpair_submit_tracker(qpair, tr);
} else {
-   if (req->type != NVME_REQUEST_NULL)
+   if (req->type != NVME_REQUEST_NULL) {
+   bus_dmamap_sync(qpair->dma_tag_payload,
+   tr->payload_dma_map,
+   BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE);
bus_dmamap_unload(qpair->dma_tag_payload,
tr->payload_dma_map);
+   }
 
nvme_free_request(req);
tr->req = NULL;
@@ -407,6 +411,8 @@ nvme_qpair_process_completions(struct nvme_qpair *qpai
 */
return (false);
 
+   bus_dmamap_sync(qpair->dma_tag, qpair->queuemem_map,
+   BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE);
while (1) {
cpl = >cpl[qpair->cq_head];
 
@@ -749,7 +755,16 @@ nvme_qpair_submit_tracker(struct nvme_qpair *qpair, st
if (++qpair->sq_tail == qpair->num_entries)
qpair->sq_tail = 0;
 
+   bus_dmamap_sync(qpair->dma_tag, qpair->queuemem_map,
+   BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
+#ifndef __powerpc__
+   /*
+* powerpc's bus_dmamap_sync() already includes a heavyweight sync, but
+* no other archs do.
+*/
wmb();
+#endif
+
nvme_mmio_write_4(qpair->ctrlr, doorbell[qpair->id].sq_tdbl,
qpair->sq_tail);
 
@@ -800,6 +815,8 @@ nvme_payload_map(void *arg, bus_dma_segment_t *seg, in
tr->req->cmd.prp2 = 0;
}
 
+   bus_dmamap_sync(tr->qpair->dma_tag_payload, tr->payload_dma_map,
+   BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
nvme_qpair_submit_tracker(tr->qpair, tr);
 }
 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r346096 - head/sys/arm/conf

2019-04-15 Thread Ian Lepore
On Thu, 2019-04-11 at 21:23 +0200, Svatopluk Kraus wrote:
> I understand the reason for GENERIC. But are we so blind that we will
> delete everything that is not GENERIC? In other words, why to delete
> nice specific KERNEL configurations for boards we support when only
> reason I see is that GENERIC is so cool for some people?
> 
> Svatopluk Kraus
> 
> 

I completely agree with this.  We had a plan for removing board-
specific configs that had been rolled into GENERIC, and it did not
involve just deleting them without providing any alternative to people
who have custom configs based on them.  That plan's execution has
stalled, but that's not a good reason for this abrupt deletion without
any warning.

I think these deletions fall into two categories:

 1. Configs for hardware that isn't adequately supported anymore.
 2. Configs for popular supported hardware which can use GENERIC.

We need to figure out which ones count as #2 and restore them until
we've implemented our original plan for phasing them out.  I think
those would be:

  BEAGLEBONE
  PANDABOARD
  RPI2

For the others, we need to evaluate:  if we are removing the only
config file that refers to some chunks of sys/arm code, shouldn't we be
removing that code too?  For example, removing AML8726 probably implies
that all of arm/amlogic/* can be deleted.

-- Ian

> 
> On Wed, Apr 10, 2019 at 9:27 PM Emmanuel Vadot 
> wrote:
> > 
> > Author: manu
> > Date: Wed Apr 10 19:27:14 2019
> > New Revision: 346096
> > URL: https://svnweb.freebsd.org/changeset/base/346096
> > 
> > Log:
> >   arm: kernel: Remove old kernel configs
> > 
> >   Follow up to r346095
> >   All those kernels are either not working or the release have
> > switched
> >   to GENERIC
> > 
> > Deleted:
> >   head/sys/arm/conf/AML8726
> >   head/sys/arm/conf/BEAGLEBONE
> >   head/sys/arm/conf/CHROMEBOOK
> >   head/sys/arm/conf/CHROMEBOOK-PEACH-PIT
> >   head/sys/arm/conf/CHROMEBOOK-PEACH-PIT.hints
> >   head/sys/arm/conf/CHROMEBOOK-SNOW
> >   head/sys/arm/conf/CHROMEBOOK-SPRING
> >   head/sys/arm/conf/CHROMEBOOK.hints
> >   head/sys/arm/conf/EXYNOS5.common
> >   head/sys/arm/conf/EXYNOS5250
> >   head/sys/arm/conf/EXYNOS5420
> >   head/sys/arm/conf/ODROIDC1
> >   head/sys/arm/conf/PANDABOARD
> >   head/sys/arm/conf/PANDABOARD.hints
> >   head/sys/arm/conf/RADXA
> >   head/sys/arm/conf/RADXA-LITE
> >   head/sys/arm/conf/RK3188
> >   head/sys/arm/conf/RPI2
> > 
> 
> 

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


svn commit: r346237 - stable/12/sys/dev/nvme

2019-04-15 Thread Alexander Motin
Author: mav
Date: Mon Apr 15 15:09:25 2019
New Revision: 346237
URL: https://svnweb.freebsd.org/changeset/base/346237

Log:
  MFC r344736 (by imp): Add ABORTED_BY_REQUEST to the list of things we look
  at DNR bit and tell why to comment (code already does this)

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

Modified: stable/12/sys/dev/nvme/nvme_qpair.c
==
--- stable/12/sys/dev/nvme/nvme_qpair.c Mon Apr 15 15:02:18 2019
(r346236)
+++ stable/12/sys/dev/nvme/nvme_qpair.c Mon Apr 15 15:09:25 2019
(r346237)
@@ -331,7 +331,8 @@ nvme_completion_is_retry(const struct nvme_completion 
 * TODO: spec is not clear how commands that are aborted due
 *  to TLER will be marked.  So for now, it seems
 *  NAMESPACE_NOT_READY is the only case where we should
-*  look at the DNR bit.
+*  look at the DNR bit. Requests failed with ABORTED_BY_REQUEST
+*  set the DNR bit correctly since the driver controls that.
 */
switch (sct) {
case NVME_SCT_GENERIC:
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r346236 - stable/12/sys/dev/nvme

2019-04-15 Thread Alexander Motin
Author: mav
Date: Mon Apr 15 15:02:18 2019
New Revision: 346236
URL: https://svnweb.freebsd.org/changeset/base/346236

Log:
  MFC r344642 (by imp):
  Unconditionally support unmapped BIOs. This was another shim for
  supporting older kernels. However, all supported versions of FreeBSD
  have unmapped I/Os (as do several that have gone EOL), remove it. It's
  unlikely the driver would work on the older kernels anyway at this
  point.

Modified:
  stable/12/sys/dev/nvme/nvme_ctrlr.c
  stable/12/sys/dev/nvme/nvme_ns.c
  stable/12/sys/dev/nvme/nvme_private.h
  stable/12/sys/dev/nvme/nvme_qpair.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/dev/nvme/nvme_ctrlr.c
==
--- stable/12/sys/dev/nvme/nvme_ctrlr.c Mon Apr 15 15:01:32 2019
(r346235)
+++ stable/12/sys/dev/nvme/nvme_ctrlr.c Mon Apr 15 15:02:18 2019
(r346236)
@@ -1056,11 +1056,7 @@ nvme_ctrlr_passthrough_cmd(struct nvme_controller *ctr
buf->b_data = pt->buf;
buf->b_bufsize = pt->len;
buf->b_iocmd = pt->is_read ? BIO_READ : BIO_WRITE;
-#ifdef NVME_UNMAPPED_BIO_SUPPORT
if (vmapbuf(buf, 1) < 0) {
-#else
-   if (vmapbuf(buf) < 0) {
-#endif
ret = EFAULT;
goto err;
}

Modified: stable/12/sys/dev/nvme/nvme_ns.c
==
--- stable/12/sys/dev/nvme/nvme_ns.cMon Apr 15 15:01:32 2019
(r346235)
+++ stable/12/sys/dev/nvme/nvme_ns.cMon Apr 15 15:02:18 2019
(r346236)
@@ -357,10 +357,8 @@ nvme_construct_child_bios(struct bio *bp, uint32_t ali
caddr_t data;
uint32_trem_bcount;
int i;
-#ifdef NVME_UNMAPPED_BIO_SUPPORT
struct vm_page  **ma;
uint32_tma_offset;
-#endif
 
*num_bios = nvme_get_num_segments(bp->bio_offset, bp->bio_bcount,
alignment);
@@ -373,10 +371,8 @@ nvme_construct_child_bios(struct bio *bp, uint32_t ali
cur_offset = bp->bio_offset;
rem_bcount = bp->bio_bcount;
data = bp->bio_data;
-#ifdef NVME_UNMAPPED_BIO_SUPPORT
ma_offset = bp->bio_ma_offset;
ma = bp->bio_ma;
-#endif
 
for (i = 0; i < *num_bios; i++) {
child = child_bios[i];
@@ -386,7 +382,6 @@ nvme_construct_child_bios(struct bio *bp, uint32_t ali
child->bio_bcount = min(rem_bcount,
alignment - (cur_offset & (alignment - 1)));
child->bio_flags = bp->bio_flags;
-#ifdef NVME_UNMAPPED_BIO_SUPPORT
if (bp->bio_flags & BIO_UNMAPPED) {
child->bio_ma_offset = ma_offset;
child->bio_ma = ma;
@@ -398,9 +393,7 @@ nvme_construct_child_bios(struct bio *bp, uint32_t ali
ma += child->bio_ma_n;
if (ma_offset != 0)
ma -= 1;
-   } else
-#endif
-   {
+   } else {
child->bio_data = data;
data += child->bio_bcount;
}
@@ -599,9 +592,7 @@ nvme_ns_construct(struct nvme_namespace *ns, uint32_t 
if (res != 0)
return (ENXIO);
 
-#ifdef NVME_UNMAPPED_BIO_SUPPORT
ns->cdev->si_flags |= SI_UNMAPPED;
-#endif
 
return (0);
 }

Modified: stable/12/sys/dev/nvme/nvme_private.h
==
--- stable/12/sys/dev/nvme/nvme_private.h   Mon Apr 15 15:01:32 2019
(r346235)
+++ stable/12/sys/dev/nvme/nvme_private.h   Mon Apr 15 15:02:18 2019
(r346236)
@@ -112,16 +112,6 @@ MALLOC_DECLARE(M_NVME);
 #define CACHE_LINE_SIZE(64)
 #endif
 
-/*
- * Use presence of the BIO_UNMAPPED flag to determine whether unmapped I/O
- *  support and the bus_dmamap_load_bio API are available on the target
- *  kernel.  This will ease porting back to earlier stable branches at a
- *  later point.
- */
-#ifdef BIO_UNMAPPED
-#define NVME_UNMAPPED_BIO_SUPPORT
-#endif
-
 extern uma_zone_t  nvme_request_zone;
 extern int32_t nvme_retry_count;
 
@@ -134,9 +124,7 @@ struct nvme_completion_poll_status {
 #define NVME_REQUEST_VADDR 1
 #define NVME_REQUEST_NULL  2 /* For requests with no payload. */
 #define NVME_REQUEST_UIO   3
-#ifdef NVME_UNMAPPED_BIO_SUPPORT
 #define NVME_REQUEST_BIO   4
-#endif
 #define NVME_REQUEST_CCB5
 
 struct nvme_request {
@@ -506,14 +494,8 @@ nvme_allocate_request_bio(struct bio *bio, nvme_cb_fn_
 
req = _nvme_allocate_request(cb_fn, cb_arg);
if (req != NULL) {
-#ifdef NVME_UNMAPPED_BIO_SUPPORT
req->type = NVME_REQUEST_BIO;
req->u.bio = bio;
-#else
-   

svn commit: r346235 - stable/12/sys/dev/nvme

2019-04-15 Thread Alexander Motin
Author: mav
Date: Mon Apr 15 15:01:32 2019
New Revision: 346235
URL: https://svnweb.freebsd.org/changeset/base/346235

Log:
  MFC r344640 (by imp):
  Remove #ifdef code to support FreeBSD versions that haven't been
  supported in years. A number of changes have been made to the driver
  that likely wouldn't work on those older versions that aren't properly
  ifdef'd and it's project policy to GC such code once it is stale.

Modified:
  stable/12/sys/dev/nvme/nvme_private.h
  stable/12/sys/dev/nvme/nvme_qpair.c
  stable/12/sys/dev/nvme/nvme_test.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/dev/nvme/nvme_private.h
==
--- stable/12/sys/dev/nvme/nvme_private.h   Mon Apr 15 15:00:13 2019
(r346234)
+++ stable/12/sys/dev/nvme/nvme_private.h   Mon Apr 15 15:01:32 2019
(r346235)
@@ -349,11 +349,6 @@ struct nvme_controller {
(val & 0xULL) >> 32);  \
} while (0);
 
-#if __FreeBSD_version < 800054
-#define wmb()  __asm volatile("sfence" ::: "memory")
-#define mb()   __asm volatile("mfence" ::: "memory")
-#endif
-
 #define nvme_printf(ctrlr, fmt, args...)   \
 device_printf(ctrlr->dev, fmt, ##args)
 

Modified: stable/12/sys/dev/nvme/nvme_qpair.c
==
--- stable/12/sys/dev/nvme/nvme_qpair.c Mon Apr 15 15:00:13 2019
(r346234)
+++ stable/12/sys/dev/nvme/nvme_qpair.c Mon Apr 15 15:01:32 2019
(r346235)
@@ -823,13 +823,8 @@ nvme_qpair_submit_tracker(struct nvme_qpair *qpair, st
ctrlr = qpair->ctrlr;
 
if (req->timeout)
-#if __FreeBSD_version >= 800030
callout_reset_curcpu(>timer, ctrlr->timeout_period * hz,
nvme_timeout, tr);
-#else
-   callout_reset(>timer, ctrlr->timeout_period * hz,
-   nvme_timeout, tr);
-#endif
 
/* Copy the command from the tracker to the submission queue. */
memcpy(>cmd[qpair->sq_tail], >cmd, sizeof(req->cmd));

Modified: stable/12/sys/dev/nvme/nvme_test.c
==
--- stable/12/sys/dev/nvme/nvme_test.c  Mon Apr 15 15:00:13 2019
(r346234)
+++ stable/12/sys/dev/nvme/nvme_test.c  Mon Apr 15 15:01:32 2019
(r346235)
@@ -94,9 +94,7 @@ nvme_ns_bio_test(void *arg)
struct timeval  t;
uint64_tio_completed = 0, offset;
uint32_tidx;
-#if __FreeBSD_version >= 900017
int ref;
-#endif
 
buf = malloc(io_test->size, M_NVME, M_WAITOK);
idx = atomic_fetchadd_int(_test->td_idx, 1);
@@ -118,11 +116,7 @@ nvme_ns_bio_test(void *arg)
bio->bio_bcount = io_test->size;
 
if (io_test->flags & NVME_TEST_FLAG_REFTHREAD) {
-#if __FreeBSD_version >= 900017
csw = dev_refthread(dev, );
-#else
-   csw = dev_refthread(dev);
-#endif
} else
csw = dev->si_devsw;
 
@@ -133,11 +127,7 @@ nvme_ns_bio_test(void *arg)
mtx_unlock(mtx);
 
if (io_test->flags & NVME_TEST_FLAG_REFTHREAD) {
-#if __FreeBSD_version >= 900017
dev_relthread(dev, ref);
-#else
-   dev_relthread(dev);
-#endif
}
 
if ((bio->bio_flags & BIO_ERROR) || (bio->bio_resid > 0))
@@ -166,11 +156,7 @@ nvme_ns_bio_test(void *arg)
atomic_subtract_int(_test->td_active, 1);
mb();
 
-#if __FreeBSD_version >= 80
kthread_exit();
-#else
-   kthread_exit(0);
-#endif
 }
 
 static void
@@ -246,11 +232,7 @@ nvme_ns_io_test(void *arg)
atomic_subtract_int(_test->td_active, 1);
mb();
 
-#if __FreeBSD_version >= 84
kthread_exit();
-#else
-   kthread_exit(0);
-#endif
 }
 
 void
@@ -287,13 +269,8 @@ nvme_ns_test(struct nvme_namespace *ns, u_long cmd, ca
getmicrouptime(_test_internal->start);
 
for (i = 0; i < io_test->num_threads; i++)
-#if __FreeBSD_version >= 84
kthread_add(fn, io_test_internal,
NULL, NULL, 0, 0, "nvme_io_test[%d]", i);
-#else
-   kthread_create(fn, io_test_internal,
-   NULL, 0, 0, "nvme_io_test[%d]", i);
-#endif
 
tsleep(io_test_internal, 0, "nvme_test", io_test->time * 2 * hz);
 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r346234 - stable/12/sys/dev/nvme

2019-04-15 Thread Alexander Motin
Author: mav
Date: Mon Apr 15 15:00:13 2019
New Revision: 346234
URL: https://svnweb.freebsd.org/changeset/base/346234

Log:
  MFC r342862 (by chuck): Add NVMe drive to NOIOB quirk list
  
  Dell-branded Intel P4600 NVMe drives benefit from NVMe 1.3's NOIOB
  feature. Unfortunately just like Intel DC P4500s, they don't advertise
  themselves as benefiting from this...
  
  This changes adds P4600s to the existing list of old drives which
  benefit from striping.
  
  PR:   233969

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

Modified: stable/12/sys/dev/nvme/nvme_ns.c
==
--- stable/12/sys/dev/nvme/nvme_ns.cMon Apr 15 14:58:40 2019
(r346233)
+++ stable/12/sys/dev/nvme/nvme_ns.cMon Apr 15 15:00:13 2019
(r346234)
@@ -514,6 +514,7 @@ nvme_ns_construct(struct nvme_namespace *ns, uint32_t 
case 0x09538086:/* Intel DC PC3500 */
case 0x0a538086:/* Intel DC PC3520 */
case 0x0a548086:/* Intel DC PC4500 */
+   case 0x0a558086:/* Dell Intel P4600 */
if (ctrlr->cdata.vs[3] != 0)
ns->stripesize =
(1 << ctrlr->cdata.vs[3]) * ctrlr->min_page_size;
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r346233 - stable/12/sys/dev/nvme

2019-04-15 Thread Alexander Motin
Author: mav
Date: Mon Apr 15 14:58:40 2019
New Revision: 346233
URL: https://svnweb.freebsd.org/changeset/base/346233

Log:
  MFC r341710 (by imp):
  Even though they are reserved, cdw2 and cdw3 can be set via nvme-cli
  (and soon nvmecontrol). Go ahead and copy them into rsvd2 and rsvd3.

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

Modified: stable/12/sys/dev/nvme/nvme_ctrlr.c
==
--- stable/12/sys/dev/nvme/nvme_ctrlr.c Mon Apr 15 14:57:50 2019
(r346232)
+++ stable/12/sys/dev/nvme/nvme_ctrlr.c Mon Apr 15 14:58:40 2019
(r346233)
@@ -1075,6 +1075,8 @@ nvme_ctrlr_passthrough_cmd(struct nvme_controller *ctr
/* Assume userspace already converted to little-endian */
req->cmd.opc = pt->cmd.opc;
req->cmd.fuse = pt->cmd.fuse;
+   req->cmd.rsvd2 = pt->cmd.rsvd2;
+   req->cmd.rsvd3 = pt->cmd.rsvd3;
req->cmd.cdw10 = pt->cmd.cdw10;
req->cmd.cdw11 = pt->cmd.cdw11;
req->cmd.cdw12 = pt->cmd.cdw12;
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r346232 - stable/12/sys/dev/nvme

2019-04-15 Thread Alexander Motin
Author: mav
Date: Mon Apr 15 14:57:50 2019
New Revision: 346232
URL: https://svnweb.freebsd.org/changeset/base/346232

Log:
  MFC r340481 (by imp): Remove do-nothing nvme_modevent.
  
  nvme_modevent no longer does anything interesting, remove it.

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

Modified: stable/12/sys/dev/nvme/nvme.c
==
--- stable/12/sys/dev/nvme/nvme.c   Mon Apr 15 14:56:59 2019
(r346231)
+++ stable/12/sys/dev/nvme/nvme.c   Mon Apr 15 14:57:50 2019
(r346232)
@@ -61,7 +61,6 @@ static intnvme_probe(device_t);
 static intnvme_attach(device_t);
 static intnvme_detach(device_t);
 static intnvme_shutdown(device_t);
-static intnvme_modevent(module_t mod, int type, void *arg);
 
 static devclass_t nvme_devclass;
 
@@ -80,7 +79,7 @@ static driver_t nvme_pci_driver = {
sizeof(struct nvme_controller),
 };
 
-DRIVER_MODULE(nvme, pci, nvme_pci_driver, nvme_devclass, nvme_modevent, 0);
+DRIVER_MODULE(nvme, pci, nvme_pci_driver, nvme_devclass, NULL, NULL);
 MODULE_VERSION(nvme, 1);
 MODULE_DEPEND(nvme, cam, 1, 1, 1);
 
@@ -181,16 +180,6 @@ nvme_uninit(void)
 
 SYSUNINIT(nvme_unregister, SI_SUB_DRIVERS, SI_ORDER_SECOND, nvme_uninit, NULL);
 
-static void
-nvme_load(void)
-{
-}
-
-static void
-nvme_unload(void)
-{
-}
-
 static int
 nvme_shutdown(device_t dev)
 {
@@ -198,24 +187,6 @@ nvme_shutdown(device_t dev)
 
ctrlr = DEVICE2SOFTC(dev);
nvme_ctrlr_shutdown(ctrlr);
-
-   return (0);
-}
-
-static int
-nvme_modevent(module_t mod, int type, void *arg)
-{
-
-   switch (type) {
-   case MOD_LOAD:
-   nvme_load();
-   break;
-   case MOD_UNLOAD:
-   nvme_unload();
-   break;
-   default:
-   break;
-   }
 
return (0);
 }
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r346231 - stable/12/sys/dev/nvme

2019-04-15 Thread Alexander Motin
Author: mav
Date: Mon Apr 15 14:56:59 2019
New Revision: 346231
URL: https://svnweb.freebsd.org/changeset/base/346231

Log:
  MFC r340412 (by imp): Use atomic_load_acq_int() here too to poll done,
  ala r328521

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

Modified: stable/12/sys/dev/nvme/nvme_ns.c
==
--- stable/12/sys/dev/nvme/nvme_ns.cMon Apr 15 14:54:48 2019
(r346230)
+++ stable/12/sys/dev/nvme/nvme_ns.cMon Apr 15 14:56:59 2019
(r346231)
@@ -533,11 +533,11 @@ nvme_ns_construct(struct nvme_namespace *ns, uint32_t 
if (!mtx_initialized(>lock))
mtx_init(>lock, "nvme ns lock", NULL, MTX_DEF);
 
-   status.done = FALSE;
+   status.done = 0;
nvme_ctrlr_cmd_identify_namespace(ctrlr, id, >data,
nvme_completion_poll_cb, );
-   while (status.done == FALSE)
-   DELAY(5);
+   while (!atomic_load_acq_int())
+   pause("nvme", 1);
if (nvme_completion_is_error()) {
nvme_printf(ctrlr, "nvme_identify_namespace failed\n");
return (ENXIO);
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r346230 - stable/12/sys/dev/nvme

2019-04-15 Thread Alexander Motin
Author: mav
Date: Mon Apr 15 14:54:48 2019
New Revision: 346230
URL: https://svnweb.freebsd.org/changeset/base/346230

Log:
  MFC r339775 (by imp): Put a workaround in for command timeout malfunctioning
  
  At least one NVMe drive has a bug that makeing the Command Time Out
  PCIe feature unreliable. The workaround is to disable this
  feature. The driver wouldn't deal correctly with a timeout anyway.
  Only do this for drives that are known bad.

Modified:
  stable/12/sys/dev/nvme/nvme.c
  stable/12/sys/dev/nvme/nvme_private.h
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/dev/nvme/nvme.c
==
--- stable/12/sys/dev/nvme/nvme.c   Mon Apr 15 14:32:19 2019
(r346229)
+++ stable/12/sys/dev/nvme/nvme.c   Mon Apr 15 14:54:48 2019
(r346230)
@@ -106,6 +106,7 @@ static struct _pcsid
{ 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  }
 };
 
@@ -276,6 +277,25 @@ nvme_attach(device_t dev)
if (status != 0) {
nvme_ctrlr_destruct(ctrlr, dev);
return (status);
+   }
+
+   /*
+* Some drives do not implement the completion timeout feature
+* correctly. There's a WAR from the manufacturer to just disable it.
+* The driver wouldn't respond correctly to a timeout anyway.
+*/
+   if (ep->quirks & QUIRK_DISABLE_TIMEOUT) {
+   int ptr;
+   uint16_t devctl2;
+
+   status = pci_find_cap(dev, PCIY_EXPRESS, );
+   if (status) {
+   device_printf(dev, "Can't locate PCIe capability?");
+   return (status);
+   }
+   devctl2 = pci_read_config(dev, ptr + PCIER_DEVICE_CTL2, 
sizeof(devctl2));
+   devctl2 |= PCIEM_CTL2_COMP_TIMO_DISABLE;
+   pci_write_config(dev, ptr + PCIER_DEVICE_CTL2, devctl2, 
sizeof(devctl2));
}
 
/*

Modified: stable/12/sys/dev/nvme/nvme_private.h
==
--- stable/12/sys/dev/nvme/nvme_private.h   Mon Apr 15 14:32:19 2019
(r346229)
+++ stable/12/sys/dev/nvme/nvme_private.h   Mon Apr 15 14:54:48 2019
(r346230)
@@ -247,7 +247,8 @@ struct nvme_controller {
 
uint32_tready_timeout_in_ms;
uint32_tquirks;
-#define QUIRK_DELAY_B4_CHK_RDY 1   /* Can't touch MMIO on disable 
*/
+#defineQUIRK_DELAY_B4_CHK_RDY  1   /* Can't touch MMIO on 
disable */
+#defineQUIRK_DISABLE_TIMEOUT   2   /* Disable broken 
completion timeout feature */
 
bus_space_tag_t bus_tag;
bus_space_handle_t  bus_handle;
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r346229 - head/sys/dev/usb/controller

2019-04-15 Thread Hans Petter Selasky
Author: hselasky
Date: Mon Apr 15 14:32:19 2019
New Revision: 346229
URL: https://svnweb.freebsd.org/changeset/base/346229

Log:
  Fix spelling.
  
  Submitted by: Dmitry Luhtionov 
  MFC after:1 week
  Sponsored by: Mellanox Technologies

Modified:
  head/sys/dev/usb/controller/ehci_pci.c

Modified: head/sys/dev/usb/controller/ehci_pci.c
==
--- head/sys/dev/usb/controller/ehci_pci.c  Mon Apr 15 13:41:53 2019
(r346228)
+++ head/sys/dev/usb/controller/ehci_pci.c  Mon Apr 15 14:32:19 2019
(r346229)
@@ -181,7 +181,7 @@ ehci_pci_match(device_t self)
case 0x8d2d8086:
return ("Intel Wellsburg USB 2.0 controller");
case 0x9c268086:
-   return ("Intel Lynx Point LP USB 2.0 controller USB");
+   return ("Intel Lynx Point-LP USB 2.0 controller USB");
 
case 0x00e01033:
return ("NEC uPD 72010x USB 2.0 controller");
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r346228 - head/sys/dev/uart

2019-04-15 Thread Ed Maste
Author: emaste
Date: Mon Apr 15 13:41:53 2019
New Revision: 346228
URL: https://svnweb.freebsd.org/changeset/base/346228

Log:
  Add quirk for ignoring SPCR AccessWidth values on the PL011 UART
  
  The SPCR table on the Lenovo HR330A Ampere eMAG server indicates 8-bit
  access, but 32-bit access is required for the PL011 to work.
  
  PL011 on SBSA platforms always supports 32-bit access (and that was
  hardcoded here before my EC2 fix), let's use 32-bit access for PL011
  and 32BIT interface types.
  
  Tested by emaste on Ampere eMAG and Cavium/Marvell ThunderX2.
  
  Submitted by: Greg V 
  Reviewed by:  andrew, imp (earlier)
  Differential Revision:https://reviews.freebsd.org/D19507

Modified:
  head/sys/dev/uart/uart_bus.h
  head/sys/dev/uart/uart_cpu_arm64.c
  head/sys/dev/uart/uart_dev_pl011.c

Modified: head/sys/dev/uart/uart_bus.h
==
--- head/sys/dev/uart/uart_bus.hMon Apr 15 13:12:54 2019
(r346227)
+++ head/sys/dev/uart/uart_bus.hMon Apr 15 13:41:53 2019
(r346228)
@@ -57,7 +57,8 @@
 #defineUART_IOCTL_BAUD 4
 
 /* UART quirk flags */
-#defineUART_F_BUSY_DETECT  0x1
+#defineUART_F_BUSY_DETECT  0x1
+#defineUART_F_IGNORE_SPCR_REGSHFT  0x2
 
 /*
  * UART class & instance (=softc)

Modified: head/sys/dev/uart/uart_cpu_arm64.c
==
--- head/sys/dev/uart/uart_cpu_arm64.c  Mon Apr 15 13:12:54 2019
(r346227)
+++ head/sys/dev/uart/uart_cpu_arm64.c  Mon Apr 15 13:41:53 2019
(r346228)
@@ -153,6 +153,11 @@ uart_cpu_acpi_probe(struct uart_class **classp, bus_sp
*shiftp = spcr->SerialPort.AccessWidth - 1;
*iowidthp = spcr->SerialPort.BitWidth / 8;
 
+   if ((cd->cd_quirks & UART_F_IGNORE_SPCR_REGSHFT) ==
+   UART_F_IGNORE_SPCR_REGSHFT) {
+   *shiftp = cd->cd_regshft;
+   }
+
 out:
acpi_unmap_table(spcr);
return (err);

Modified: head/sys/dev/uart/uart_dev_pl011.c
==
--- head/sys/dev/uart/uart_dev_pl011.c  Mon Apr 15 13:12:54 2019
(r346227)
+++ head/sys/dev/uart/uart_dev_pl011.c  Mon Apr 15 13:41:53 2019
(r346228)
@@ -342,8 +342,9 @@ UART_FDT_CLASS_AND_DEVICE(fdt_compat_data);
 
 #ifdef DEV_ACPI
 static struct acpi_uart_compat_data acpi_compat_data[] = {
-   {"ARMH0011", _pl011_class, ACPI_DBG2_ARM_PL011, 2, 0, 0, 0, "uart 
plo11"},
-   {"ARMH0011", _pl011_class, ACPI_DBG2_ARM_SBSA_GENERIC, 2, 0, 0, 0, 
"uart plo11"},
+   {"ARMH0011", _pl011_class, ACPI_DBG2_ARM_PL011, 2, 0, 0, 
UART_F_IGNORE_SPCR_REGSHFT, "uart pl011"},
+   {"ARMH0011", _pl011_class, ACPI_DBG2_ARM_SBSA_GENERIC, 2, 0, 0, 
UART_F_IGNORE_SPCR_REGSHFT, "uart pl011"},
+   {"ARMH0011", _pl011_class, ACPI_DBG2_ARM_SBSA_32BIT, 2, 0, 0, 
UART_F_IGNORE_SPCR_REGSHFT, "uart pl011"},
{NULL, NULL, 0, 0, 0, 0, 0, NULL},
 };
 UART_ACPI_CLASS_AND_DEVICE(acpi_compat_data);
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r346227 - stable/11/sbin/mount

2019-04-15 Thread Konstantin Belousov
Author: kib
Date: Mon Apr 15 13:12:54 2019
New Revision: 346227
URL: https://svnweb.freebsd.org/changeset/base/346227

Log:
  MFC r346038:
  Exercise some care before sending SIGHUP to mountd.

Modified:
  stable/11/sbin/mount/mount.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sbin/mount/mount.c
==
--- stable/11/sbin/mount/mount.cMon Apr 15 13:11:51 2019
(r346226)
+++ stable/11/sbin/mount/mount.cMon Apr 15 13:12:54 2019
(r346227)
@@ -224,6 +224,7 @@ restart_mountd(void)
struct pidfh *pfh;
pid_t mountdpid;
 
+   mountdpid = 0;
pfh = pidfile_open(_PATH_MOUNTDPID, 0600, );
if (pfh != NULL) {
/* Mountd is not running. */
@@ -234,6 +235,16 @@ restart_mountd(void)
/* Cannot open pidfile for some reason. */
return;
}
+
+   /*
+* Refuse to send broadcast or group signals, this has
+* happened due to the bugs in pidfile(3).
+*/
+   if (mountdpid <= 0) {
+   warnx("mountd pid %d, refusing to send SIGHUP", mountdpid);
+   return;
+   }
+
/* We have mountd(8) PID in mountdpid varible, let's signal it. */
if (kill(mountdpid, SIGHUP) == -1)
err(1, "signal mountd");
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r346226 - stable/11/sys/ufs/ffs

2019-04-15 Thread Konstantin Belousov
Author: kib
Date: Mon Apr 15 13:11:51 2019
New Revision: 346226
URL: https://svnweb.freebsd.org/changeset/base/346226

Log:
  MFC r346031:
  Handle races when remounting UFS volume from ro to rw.

Modified:
  stable/11/sys/ufs/ffs/ffs_vfsops.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/ufs/ffs/ffs_vfsops.c
==
--- stable/11/sys/ufs/ffs/ffs_vfsops.c  Mon Apr 15 13:03:09 2019
(r346225)
+++ stable/11/sys/ufs/ffs/ffs_vfsops.c  Mon Apr 15 13:11:51 2019
(r346226)
@@ -149,7 +149,7 @@ ffs_mount(struct mount *mp)
struct fs *fs;
pid_t fsckpid = 0;
int error, error1, flags;
-   uint64_t mntorflags;
+   uint64_t mntorflags, saved_mnt_flag;
accmode_t accmode;
struct nameidata ndp;
char *fspec;
@@ -366,25 +366,40 @@ ffs_mount(struct mount *mp)
return (error);
if ((error = vn_start_write(NULL, , V_WAIT)) != 0)
return (error);
+   error = vfs_write_suspend_umnt(mp);
+   if (error != 0)
+   return (error);
fs->fs_ronly = 0;
MNT_ILOCK(mp);
-   mp->mnt_flag &= ~MNT_RDONLY;
+   saved_mnt_flag = MNT_RDONLY;
+   if (MOUNTEDSOFTDEP(mp) && (mp->mnt_flag &
+   MNT_ASYNC) != 0)
+   saved_mnt_flag |= MNT_ASYNC;
+   mp->mnt_flag &= ~saved_mnt_flag;
MNT_IUNLOCK(mp);
fs->fs_mtime = time_second;
/* check to see if we need to start softdep */
if ((fs->fs_flags & FS_DOSOFTDEP) &&
(error = softdep_mount(devvp, mp, fs, 
td->td_ucred))){
-   vn_finished_write(mp);
+   fs->fs_ronly = 1;
+   MNT_ILOCK(mp);
+   mp->mnt_flag |= saved_mnt_flag;
+   MNT_IUNLOCK(mp);
+   vfs_write_resume(mp, 0);
return (error);
}
fs->fs_clean = 0;
if ((error = ffs_sbupdate(ump, MNT_WAIT, 0)) != 0) {
-   vn_finished_write(mp);
+   fs->fs_ronly = 1;
+   MNT_ILOCK(mp);
+   mp->mnt_flag |= saved_mnt_flag;
+   MNT_IUNLOCK(mp);
+   vfs_write_resume(mp, 0);
return (error);
}
if (fs->fs_snapinum[0] != 0)
ffs_snapshot_mount(mp);
-   vn_finished_write(mp);
+   vfs_write_resume(mp, 0);
}
/*
 * Soft updates is incompatible with "async",
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r346225 - in head: lib/libc/stdlib libexec/rtld-elf

2019-04-15 Thread Konstantin Belousov
Author: kib
Date: Mon Apr 15 13:03:09 2019
New Revision: 346225
URL: https://svnweb.freebsd.org/changeset/base/346225

Log:
  Fix order of destructors between main binary and libraries.
  
  Since inits for the main binary are run from rtld (for some time), the
  rtld_exit atexit(3) handler, which is passed from rtld to the program
  entry and installed by csu, is installed after any atexit(3) handlers
  installed by main binary constructors.  This means that rtld_exit() is
  fired before main binary handlers.
  
  Typical C++ static constructors are executed from init (either binary
  or libs) but use atexit(3) to ensure that destructors are called in
  the right order, independent of the linking order.  Also, C++
  libraries finalizers call __cxa_finalize(3) to flush library'
  atexit(3) entries.  Since atexit(3) entry is cleared after being run,
  this would be mostly innocent, except that, atexit(rtld_exit) done
  after main binary constructors, makes destructors from libraries
  executed before destructors for main.
  
  Fix by reordering atexit(rtld_exit) before inits for main binary, same
  as it happened when inits were called by csu.  Do it using new private
  libc symbol with pre-defined ABI.
  
  Reported. tested, and reviewed by:kan
  Sponsored by: The FreeBSD Foundation
  MFC after:1 week

Modified:
  head/lib/libc/stdlib/Symbol.map
  head/lib/libc/stdlib/atexit.c
  head/libexec/rtld-elf/rtld.c

Modified: head/lib/libc/stdlib/Symbol.map
==
--- head/lib/libc/stdlib/Symbol.map Mon Apr 15 12:24:19 2019
(r346224)
+++ head/lib/libc/stdlib/Symbol.map Mon Apr 15 13:03:09 2019
(r346225)
@@ -129,4 +129,5 @@ FBSDprivate_1.0 {
_system;
__libc_system;
__cxa_thread_call_dtors;
+   __libc_atexit;
 };

Modified: head/lib/libc/stdlib/atexit.c
==
--- head/lib/libc/stdlib/atexit.c   Mon Apr 15 12:24:19 2019
(r346224)
+++ head/lib/libc/stdlib/atexit.c   Mon Apr 15 13:03:09 2019
(r346225)
@@ -142,6 +142,7 @@ atexit(void (*func)(void))
error = atexit_register();
return (error);
 }
+__weak_reference(atexit, __libc_atexit);
 
 /**
  * Register a block to be performed at exit.

Modified: head/libexec/rtld-elf/rtld.c
==
--- head/libexec/rtld-elf/rtld.cMon Apr 15 12:24:19 2019
(r346224)
+++ head/libexec/rtld-elf/rtld.cMon Apr 15 13:03:09 2019
(r346225)
@@ -151,6 +151,7 @@ static int rtld_dirname(const char *, char *);
 static int rtld_dirname_abs(const char *, char *);
 static void *rtld_dlopen(const char *name, int fd, int mode);
 static void rtld_exit(void);
+static void rtld_nop_exit(void);
 static char *search_library_path(const char *, const char *, const char *,
 int *);
 static char *search_library_pathfds(const char *, const char *, int *);
@@ -295,6 +296,8 @@ const char *ld_path_rtld = _PATH_RTLD;
 const char *ld_standard_library_path = STANDARD_LIBRARY_PATH;
 const char *ld_env_prefix = LD_;
 
+static void (*rtld_exit_ptr)(void);
+
 /*
  * Fill in a DoneList with an allocation large enough to hold all of
  * the currently-loaded objects.  Keep this as a macro since it calls
@@ -756,6 +759,7 @@ _rtld(Elf_Addr *sp, func_ptr_type *exit_proc, Obj_Entr
   *ld_bind_now != '\0', SYMLOOK_EARLY, ) == -1)
rtld_die();
 
+rtld_exit_ptr = rtld_exit;
 if (obj_main->crt_no_init)
preinit_main();
 objlist_call_init(, );
@@ -778,7 +782,7 @@ _rtld(Elf_Addr *sp, func_ptr_type *exit_proc, Obj_Entr
 dbg("transferring control to program entry point = %p", obj_main->entry);
 
 /* Return the exit procedure and the program entry point. */
-*exit_proc = rtld_exit;
+*exit_proc = rtld_exit_ptr;
 *objp = obj_main;
 return (func_ptr_type) obj_main->entry;
 }
@@ -2662,6 +2666,7 @@ objlist_call_init(Objlist *list, RtldLockState *lockst
 Obj_Entry *obj;
 char *saved_msg;
 Elf_Addr *init_addr;
+void (*reg)(void (*)(void));
 int index;
 
 /*
@@ -2690,7 +2695,16 @@ objlist_call_init(Objlist *list, RtldLockState *lockst
 */
elm->obj->init_done = true;
hold_object(elm->obj);
+   reg = NULL;
+   if (elm->obj == obj_main && obj_main->crt_no_init) {
+   reg = (void (*)(void (*)(void)))get_program_var_addr(
+   "__libc_atexit", lockstate);
+   }
lock_release(rtld_bind_lock, lockstate);
+   if (reg != NULL) {
+   reg(rtld_exit);
+   rtld_exit_ptr = rtld_nop_exit;
+   }
 
 /*
  * It is legal to have both DT_INIT and DT_INIT_ARRAY defined.
@@ -3002,6 +3016,11 @@ rtld_exit(void)
 if (!libmap_disable)
 lm_fini();
 lock_release(rtld_bind_lock, );
+}
+
+static void
+rtld_nop_exit(void)
+{

svn commit: r346224 - stable/12/sbin/mount

2019-04-15 Thread Konstantin Belousov
Author: kib
Date: Mon Apr 15 12:24:19 2019
New Revision: 346224
URL: https://svnweb.freebsd.org/changeset/base/346224

Log:
  MFC r346038:
  Exercise some care before sending SIGHUP to mountd.

Modified:
  stable/12/sbin/mount/mount.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sbin/mount/mount.c
==
--- stable/12/sbin/mount/mount.cMon Apr 15 12:23:33 2019
(r346223)
+++ stable/12/sbin/mount/mount.cMon Apr 15 12:24:19 2019
(r346224)
@@ -227,6 +227,7 @@ restart_mountd(void)
struct pidfh *pfh;
pid_t mountdpid;
 
+   mountdpid = 0;
pfh = pidfile_open(_PATH_MOUNTDPID, 0600, );
if (pfh != NULL) {
/* Mountd is not running. */
@@ -237,6 +238,16 @@ restart_mountd(void)
/* Cannot open pidfile for some reason. */
return;
}
+
+   /*
+* Refuse to send broadcast or group signals, this has
+* happened due to the bugs in pidfile(3).
+*/
+   if (mountdpid <= 0) {
+   warnx("mountd pid %d, refusing to send SIGHUP", mountdpid);
+   return;
+   }
+
/* We have mountd(8) PID in mountdpid varible, let's signal it. */
if (kill(mountdpid, SIGHUP) == -1)
err(1, "signal mountd");
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r346223 - stable/12/sys/ufs/ffs

2019-04-15 Thread Konstantin Belousov
Author: kib
Date: Mon Apr 15 12:23:33 2019
New Revision: 346223
URL: https://svnweb.freebsd.org/changeset/base/346223

Log:
  MFC r346031:
  Handle races when remounting UFS volume from ro to rw.

Modified:
  stable/12/sys/ufs/ffs/ffs_vfsops.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/ufs/ffs/ffs_vfsops.c
==
--- stable/12/sys/ufs/ffs/ffs_vfsops.c  Mon Apr 15 12:09:58 2019
(r346222)
+++ stable/12/sys/ufs/ffs/ffs_vfsops.c  Mon Apr 15 12:23:33 2019
(r346223)
@@ -154,7 +154,7 @@ ffs_mount(struct mount *mp)
struct fs *fs;
pid_t fsckpid = 0;
int error, error1, flags;
-   uint64_t mntorflags;
+   uint64_t mntorflags, saved_mnt_flag;
accmode_t accmode;
struct nameidata ndp;
char *fspec;
@@ -371,25 +371,40 @@ ffs_mount(struct mount *mp)
return (error);
if ((error = vn_start_write(NULL, , V_WAIT)) != 0)
return (error);
+   error = vfs_write_suspend_umnt(mp);
+   if (error != 0)
+   return (error);
fs->fs_ronly = 0;
MNT_ILOCK(mp);
-   mp->mnt_flag &= ~MNT_RDONLY;
+   saved_mnt_flag = MNT_RDONLY;
+   if (MOUNTEDSOFTDEP(mp) && (mp->mnt_flag &
+   MNT_ASYNC) != 0)
+   saved_mnt_flag |= MNT_ASYNC;
+   mp->mnt_flag &= ~saved_mnt_flag;
MNT_IUNLOCK(mp);
fs->fs_mtime = time_second;
/* check to see if we need to start softdep */
if ((fs->fs_flags & FS_DOSOFTDEP) &&
(error = softdep_mount(devvp, mp, fs, 
td->td_ucred))){
-   vn_finished_write(mp);
+   fs->fs_ronly = 1;
+   MNT_ILOCK(mp);
+   mp->mnt_flag |= saved_mnt_flag;
+   MNT_IUNLOCK(mp);
+   vfs_write_resume(mp, 0);
return (error);
}
fs->fs_clean = 0;
if ((error = ffs_sbupdate(ump, MNT_WAIT, 0)) != 0) {
-   vn_finished_write(mp);
+   fs->fs_ronly = 1;
+   MNT_ILOCK(mp);
+   mp->mnt_flag |= saved_mnt_flag;
+   MNT_IUNLOCK(mp);
+   vfs_write_resume(mp, 0);
return (error);
}
if (fs->fs_snapinum[0] != 0)
ffs_snapshot_mount(mp);
-   vn_finished_write(mp);
+   vfs_write_resume(mp, 0);
}
/*
 * Soft updates is incompatible with "async",
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r346222 - stable/11/sys/dev/md

2019-04-15 Thread Kirk McKusick
Author: mckusick
Date: Mon Apr 15 12:09:58 2019
New Revision: 346222
URL: https://svnweb.freebsd.org/changeset/base/346222

Log:
  MFC of 345758
  
  Properly flush outstanding I/Os when forcibly deleteing a memory disk device.
  
  Sponsored by: Netflix

Modified:
  stable/11/sys/dev/md/md.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/dev/md/md.c
==
--- stable/11/sys/dev/md/md.c   Mon Apr 15 12:07:41 2019(r346221)
+++ stable/11/sys/dev/md/md.c   Mon Apr 15 12:09:58 2019(r346222)
@@ -106,6 +106,7 @@
 
 #define MD_SHUTDOWN0x1 /* Tell worker thread to terminate. */
 #defineMD_EXITING  0x2 /* Worker thread is exiting. */
+#defineMD_PROVIDERGONE 0x4 /* Safe to free the softc */
 
 #ifndef MD_NSECT
 #define MD_NSECT (1 * 2)
@@ -152,6 +153,7 @@ static g_start_t g_md_start;
 static g_access_t g_md_access;
 static void g_md_dumpconf(struct sbuf *sb, const char *indent,
 struct g_geom *gp, struct g_consumer *cp __unused, struct g_provider *pp);
+static g_provgone_t g_md_providergone;
 
 static struct cdev *status_dev = NULL;
 static struct sx md_sx;
@@ -173,6 +175,7 @@ struct g_class g_md_class = {
.start = g_md_start,
.access = g_md_access,
.dumpconf = g_md_dumpconf,
+   .providergone = g_md_providergone,
 };
 
 DECLARE_GEOM_CLASS(g_md_class, g_md);
@@ -432,8 +435,8 @@ g_md_start(struct bio *bp)
}
mtx_lock(>queue_mtx);
bioq_disksort(>bio_queue, bp);
-   mtx_unlock(>queue_mtx);
wakeup(sc);
+   mtx_unlock(>queue_mtx);
 }
 
 #defineMD_MALLOC_MOVE_ZERO 1
@@ -1421,17 +1424,30 @@ bad:
return (error);
 }
 
+static void
+g_md_providergone(struct g_provider *pp)
+{
+   struct md_s *sc = pp->geom->softc;
+
+   mtx_lock(>queue_mtx);
+   sc->flags |= MD_PROVIDERGONE;
+   wakeup(>flags);
+   mtx_unlock(>queue_mtx);
+}
+
 static int
 mddestroy(struct md_s *sc, struct thread *td)
 {
 
if (sc->gp) {
-   sc->gp->softc = NULL;
g_topology_lock();
g_wither_geom(sc->gp, ENXIO);
g_topology_unlock();
-   sc->gp = NULL;
-   sc->pp = NULL;
+
+   mtx_lock(>queue_mtx);
+   while (!(sc->flags & MD_PROVIDERGONE))
+   msleep(>flags, >queue_mtx, PRIBIO, "mddestroy", 
0);
+   mtx_unlock(>queue_mtx);
}
if (sc->devstat) {
devstat_remove_entry(sc->devstat);
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r346221 - stable/12/sys/dev/md

2019-04-15 Thread Kirk McKusick
Author: mckusick
Date: Mon Apr 15 12:07:41 2019
New Revision: 346221
URL: https://svnweb.freebsd.org/changeset/base/346221

Log:
  MFC of 345758
  
  Properly flush outstanding I/Os when forcibly deleteing a memory disk device.
  
  Sponsored by: Netflix

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

Modified: stable/12/sys/dev/md/md.c
==
--- stable/12/sys/dev/md/md.c   Mon Apr 15 06:33:05 2019(r346220)
+++ stable/12/sys/dev/md/md.c   Mon Apr 15 12:07:41 2019(r346221)
@@ -110,6 +110,7 @@
 
 #define MD_SHUTDOWN0x1 /* Tell worker thread to terminate. */
 #defineMD_EXITING  0x2 /* Worker thread is exiting. */
+#defineMD_PROVIDERGONE 0x4 /* Safe to free the softc */
 
 #ifndef MD_NSECT
 #define MD_NSECT (1 * 2)
@@ -199,6 +200,7 @@ static g_start_t g_md_start;
 static g_access_t g_md_access;
 static void g_md_dumpconf(struct sbuf *sb, const char *indent,
 struct g_geom *gp, struct g_consumer *cp __unused, struct g_provider *pp);
+static g_provgone_t g_md_providergone;
 
 static struct cdev *status_dev = NULL;
 static struct sx md_sx;
@@ -220,6 +222,7 @@ struct g_class g_md_class = {
.start = g_md_start,
.access = g_md_access,
.dumpconf = g_md_dumpconf,
+   .providergone = g_md_providergone,
 };
 
 DECLARE_GEOM_CLASS(g_md_class, g_md);
@@ -481,8 +484,8 @@ g_md_start(struct bio *bp)
}
mtx_lock(>queue_mtx);
bioq_disksort(>bio_queue, bp);
-   mtx_unlock(>queue_mtx);
wakeup(sc);
+   mtx_unlock(>queue_mtx);
 }
 
 #defineMD_MALLOC_MOVE_ZERO 1
@@ -1483,17 +1486,30 @@ bad:
return (error);
 }
 
+static void
+g_md_providergone(struct g_provider *pp)
+{
+   struct md_s *sc = pp->geom->softc;
+
+   mtx_lock(>queue_mtx);
+   sc->flags |= MD_PROVIDERGONE;
+   wakeup(>flags);
+   mtx_unlock(>queue_mtx);
+}
+
 static int
 mddestroy(struct md_s *sc, struct thread *td)
 {
 
if (sc->gp) {
-   sc->gp->softc = NULL;
g_topology_lock();
g_wither_geom(sc->gp, ENXIO);
g_topology_unlock();
-   sc->gp = NULL;
-   sc->pp = NULL;
+
+   mtx_lock(>queue_mtx);
+   while (!(sc->flags & MD_PROVIDERGONE))
+   msleep(>flags, >queue_mtx, PRIBIO, "mddestroy", 
0);
+   mtx_unlock(>queue_mtx);
}
if (sc->devstat) {
devstat_remove_entry(sc->devstat);
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r346220 - head/sbin/fsck_msdosfs

2019-04-15 Thread Xin LI
Author: delphij
Date: Mon Apr 15 06:33:05 2019
New Revision: 346220
URL: https://svnweb.freebsd.org/changeset/base/346220

Log:
  Don't cast result from malloc().
  
  MFC after:2 weeks

Modified:
  head/sbin/fsck_msdosfs/dir.c

Modified: head/sbin/fsck_msdosfs/dir.c
==
--- head/sbin/fsck_msdosfs/dir.cMon Apr 15 03:32:01 2019
(r346219)
+++ head/sbin/fsck_msdosfs/dir.cMon Apr 15 06:33:05 2019
(r346220)
@@ -115,7 +115,7 @@ newDosDirEntry(void)
struct dosDirEntry *de;
 
if (!(de = freede)) {
-   if (!(de = (struct dosDirEntry *)malloc(sizeof *de)))
+   if (!(de = malloc(sizeof *de)))
return 0;
} else
freede = de->next;
@@ -140,7 +140,7 @@ newDirTodo(void)
struct dirTodoNode *dt;
 
if (!(dt = freedt)) {
-   if (!(dt = (struct dirTodoNode *)malloc(sizeof *dt)))
+   if (!(dt = malloc(sizeof *dt)))
return 0;
} else
freedt = dt->next;
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"