svn commit: r331418 - head/tools/tools/crypto

2018-03-22 Thread Conrad Meyer
Author: cem
Date: Fri Mar 23 05:37:18 2018
New Revision: 331418
URL: https://svnweb.freebsd.org/changeset/base/331418

Log:
  cryptocheck: Add support for Blake2{B,S} hashes
  
  Since they are not yet present in the version of openssl in base, this will
  require installing the ports openssl.
  
  Sponsored by: Dell EMC Isilon

Modified:
  head/tools/tools/crypto/Makefile
  head/tools/tools/crypto/cryptocheck.c

Modified: head/tools/tools/crypto/Makefile
==
--- head/tools/tools/crypto/MakefileFri Mar 23 04:31:19 2018
(r331417)
+++ head/tools/tools/crypto/MakefileFri Mar 23 05:37:18 2018
(r331418)
@@ -32,7 +32,10 @@ MAN=
 BINDIR?=   /usr/local/bin
 
 # cryptocheck: test symmetric crypto functions
-LIBADD.cryptocheck+=   crypto ssl util
+# Use openssl from ports for Blake2 algorithms
+CFLAGS.cryptocheck.c+= $$(pkg-config --cflags openssl)
+LDFLAGS.cryptocheck+=  $$(pkg-config --libs openssl)
+LIBADD.cryptocheck+=   util
 
 # cryptokeytest: test asymmetric crypto functions
 LIBADD.cryptokeytest+= crypto

Modified: head/tools/tools/crypto/cryptocheck.c
==
--- head/tools/tools/crypto/cryptocheck.c   Fri Mar 23 04:31:19 2018
(r331417)
+++ head/tools/tools/crypto/cryptocheck.c   Fri Mar 23 05:37:18 2018
(r331418)
@@ -59,6 +59,8 @@
  * sha256  256-bit sha2 hmac
  * sha384  384-bit sha2 hmac
  * sha512  512-bit sha2 hmac
+ * blake2b Blake2-B
+ * blake2s Blake2-S
  *
  * Block Ciphers:
  * aes-cbc 128-bit aes cbc
@@ -115,6 +117,10 @@ struct alg {
  .evp_md = EVP_sha384 },
{ .name = "sha512", .mac = CRYPTO_SHA2_512_HMAC, .type = T_HMAC,
  .evp_md = EVP_sha512 },
+   { .name = "blake2b", .mac = CRYPTO_BLAKE2B, .type = T_HMAC,
+ .evp_md = EVP_blake2b512 },
+   { .name = "blake2s", .mac = CRYPTO_BLAKE2S, .type = T_HMAC,
+ .evp_md = EVP_blake2s256 },
{ .name = "aes-cbc", .cipher = CRYPTO_AES_CBC, .type = T_BLKCIPHER,
  .evp_cipher = EVP_aes_128_cbc },
{ .name = "aes-cbc192", .cipher = CRYPTO_AES_CBC, .type = T_BLKCIPHER,
___
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: r331369 - head/sys/vm

2018-03-22 Thread Bruce Evans

On Thu, 22 Mar 2018, Jeff Roberson wrote:


On Thu, 22 Mar 2018, Cy Schubert wrote:


It broke i386 too.


I just did
TARGET_ARCH=i386 make buildworld
TARGET_ARCH=i386 make buildkernel

This worked for me?


Index: sys/vm/vm_reserv.c
===
--- sys/vm/vm_reserv.c  (revision 331399)
+++ sys/vm/vm_reserv.c  (working copy)
@@ -45,8 +45,6 @@

#include 
#include 
-#include 
-#include 
#include 
#include 
#include 
@@ -55,6 +53,8 @@
#include 
#include 
#include 
+#include 
+#include 
#include 
#include 

This is because sys/i386/include/machine.h uses critical_enter() and
critical_exit() which are defined in sys/systm.h.


Wrong fix.  I see you committed this.  Now there are more bugs to fix.

 is a prerequisite for all kernel headers except
, since it defines and declares things like KASSERT() and
critical_enter() which might be used in other headers (except
sys/param.h and its standard pollution).  Sometimes sys/systm.h is
included as undocumented namespace pollution in headers that are
accidentally included before the (other) ones that use KASSERT(), etc.
The headers that have this bug have it to work around bugs in .c files
like the one above.  It is more usual to have this bug by not including
sys/systm.h at all than to have it by including it in a wrong order.
Sorting it alphabetically almost always gives a wrong order.  It must
be included after sys/param.h and that must be included first.

It is a related bug to include only sys/types.h and not sys/param.h.
This requires chumminess with the current implementation and all
future implementations.  sys/param.h provides certain undocumented
but standard namespace pollution which might vary with the implementation,
as necessary to satisfy some of the pollution requirements of all current
and future implementations of other headers.  (The pollution should be
monotonically decreasing but it was only that for a few years about 20
years ago when I worked on fixing it.)  .c files that include sys/types.h
instead of sys/param.h have do some subset of the includes in sys/param.h.
Since nothing is documented and the subset might depend on the arch and
user options, it is hard to know the minimal subset.

.c files that include sys/types.h tend to have lots of other #include
bugs like not including sys/systm.h.  Again it is hard to know the
minimal replacement for sys/systm.h and its undocumented but standard
pollution.  It is a style bug to include both sys/types.h and sys/param.h.
style(9) even explicitly forbids including both.  It is a larger style
bug to include the standard pollution in sys/systm.h direction.  This
includes especially  and .  These
should be considered as being implemented in sys/systm.h, with the
 headers for them only and implementation detail.  Similarly
for .


It built nicely on my amd64's though.


amd64 apparently has more namespace pollution which breaks detection
of the bug.  But I couldn't find where it is.  sys/systm.h isn't included
nested in any amd64 or x86 headers.  Apparently some amd64 option gives
it.

Bruce
___
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: r331417 - head/tools/tools/crypto

2018-03-22 Thread Conrad Meyer
Author: cem
Date: Fri Mar 23 04:31:19 2018
New Revision: 331417
URL: https://svnweb.freebsd.org/changeset/base/331417

Log:
  Bring in JHB's cryptocheck tool
  
  It can be used to validate basic algorithm correctness on a variety of inputs,
  by comarison to openssl.
  
  While here, add some sanity to the crypto/Makefile.
  
  The tool may not be perfect, but getting it in tree where collaboration can
  happen is a nice first step.  The pace of development outside of svn seems
  to have slowed down mid-2017.
  
  Obtained from:github bsdjhb/freebsd:cryptocheck
  Sponsored by: Dell EMC Isilon

Added:
  head/tools/tools/crypto/cryptocheck.c   (contents, props changed)
Modified:
  head/tools/tools/crypto/Makefile

Modified: head/tools/tools/crypto/Makefile
==
--- head/tools/tools/crypto/MakefileFri Mar 23 03:48:45 2018
(r331416)
+++ head/tools/tools/crypto/MakefileFri Mar 23 04:31:19 2018
(r331417)
@@ -1,5 +1,6 @@
 #  $FreeBSD$
 #
+# Copyright (c) 2018   Conrad Meyer 
 # Copyright (c) 2002, 2003 Sam Leffler, Errno Consulting
 # All rights reserved.
 #
@@ -25,40 +26,23 @@
 # SUCH DAMAGE.
 #
 
-ALL=   cryptotest cryptokeytest cryptostats \
+PROGS= cryptocheck cryptotest cryptokeytest cryptostats \
ubsecstats hifnstats ipsecstats safestats
-BINDIR=/usr/local/bin
+MAN=
+BINDIR?=   /usr/local/bin
 
-all:   ${ALL}
+# cryptocheck: test symmetric crypto functions
+LIBADD.cryptocheck+=   crypto ssl util
 
-# program to test asymmetric crypto functions
-cryptokeytest: cryptokeytest.c
-   ${CC} -o cryptokeytest cryptokeytest.c -lcrypto
+# cryptokeytest: test asymmetric crypto functions
+LIBADD.cryptokeytest+= crypto
 
-# program to dump statistics kept by the core crypto code
-cryptostats: cryptostats.c
-   ${CC} -o cryptostats cryptostats.c
+# cryptostats: dump statistics kept by the core crypto code
+# ubsecstats: print statistics kept by the Broadcom driver
+# hifnstats: print statistics kept by the HIFN driver
+# safestats: statistics kept by the SafeNet driver
+# ipsecstats: print statistics kept by fast ipsec
 
-# program to print statistics kept by the Broadcom driver
-ubsecstats: ubsecstats.c
-   ${CC} -o ubsecstats ubsecstats.c
+CLEANFILES+=   core a.out
 
-# program to print statistics kept by the HIFN driver
-hifnstats: hifnstats.c
-   ${CC} -o hifnstats hifnstats.c
-
-# program to print statistics kept by the SafeNet driver
-safestats: safestats.c
-   ${CC} -o safestats safestats.c
-
-# program to print statistics kept by fast ipsec
-ipsecstats: ipsecstats.c
-   ${CC} -o ipsecstats ipsecstats.c
-
-clean:
-   rm -f ${ALL} core a.out
-
-install: ${ALL}
-   for i in ${ALL}; do \
-   install $$i ${DESTDIR}${BINDIR}; \
-   done
+.include 

Added: head/tools/tools/crypto/cryptocheck.c
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/tools/tools/crypto/cryptocheck.c   Fri Mar 23 04:31:19 2018
(r331417)
@@ -0,0 +1,1168 @@
+/*-
+ * Copyright (c) 2017 John Baldwin, 
+ * Copyright (c) 2004 Sam Leffler, Errno Consulting
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer,
+ *without modification.
+ * 2. Redistributions in binary form must reproduce at minimum a disclaimer
+ *similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any
+ *redistribution must be conditioned upon including a substantially
+ *similar Disclaimer requirement for further binary redistribution.
+ * 3. Neither the names of the above-listed copyright holders nor the names
+ *of any contributors may be used to endorse or promote products derived
+ *from this software without specific prior written permission.
+ *
+ * NO WARRANTY
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY
+ * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY,
+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+ * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGES.
+ *
+ 

svn commit: r331416 - in head/stand: efi/libefi i386/libi386

2018-03-22 Thread Kyle Evans
Author: kevans
Date: Fri Mar 23 03:48:45 2018
New Revision: 331416
URL: https://svnweb.freebsd.org/changeset/base/331416

Log:
  Loader consoles: Implement SGR 22, reset intensity
  
  MFC after:3 days

Modified:
  head/stand/efi/libefi/efi_console.c
  head/stand/i386/libi386/vidconsole.c

Modified: head/stand/efi/libefi/efi_console.c
==
--- head/stand/efi/libefi/efi_console.c Fri Mar 23 03:22:30 2018
(r331415)
+++ head/stand/efi/libefi/efi_console.c Fri Mar 23 03:48:45 2018
(r331416)
@@ -383,6 +383,9 @@ efi_term_emu(int c)
fg_c = bg_c;
bg_c = t;
break;
+   case 22:/* normal intensity */
+   fg_c &= ~0x8;
+   break;
case 30: case 31: case 32: case 33:
case 34: case 35: case 36: case 37:
fg_c = ansi_col[args[i] - 30];

Modified: head/stand/i386/libi386/vidconsole.c
==
--- head/stand/i386/libi386/vidconsole.cFri Mar 23 03:22:30 2018
(r331415)
+++ head/stand/i386/libi386/vidconsole.cFri Mar 23 03:48:45 2018
(r331416)
@@ -449,6 +449,9 @@ vidc_term_emu(int c)
fg_c = bg_c;
bg_c = t;
break;
+case 22:   /* normal intensity */
+fg_c &= ~0x8;
+break;
case 30: case 31: case 32: case 33:
case 34: case 35: case 36: case 37:
fg_c = ansi_col[args[i] - 30];
___
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: r331415 - head/sys/vm

2018-03-22 Thread Cy Schubert
Author: cy
Date: Fri Mar 23 03:22:30 2018
New Revision: 331415
URL: https://svnweb.freebsd.org/changeset/base/331415

Log:
  Fix build on i386 without INVARIANTS following r331369.
  
  --- vm_reserv.o ---
  In file included from /opt/src/svn-current/sys/vm/vm_reserv.c:48:
  In file included from /opt/src/svn-current/sys/sys/counter.h:37:
  ./machine/counter.h:174:3: error: implicit declaration of function
  'critical_enter' is invalid in C99 [-Werror,-Wimplicit-function-declarat
  ion]
  critical_enter();
  
  Reviewed by:  jeff@

Modified:
  head/sys/vm/vm_reserv.c

Modified: head/sys/vm/vm_reserv.c
==
--- head/sys/vm/vm_reserv.c Fri Mar 23 02:50:38 2018(r331414)
+++ head/sys/vm/vm_reserv.c Fri Mar 23 03:22:30 2018(r331415)
@@ -45,8 +45,6 @@ __FBSDID("$FreeBSD$");
 
 #include 
 #include 
-#include 
-#include 
 #include 
 #include 
 #include 
@@ -55,6 +53,8 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
+#include 
 #include 
 #include 
 
___
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: r331414 - head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys

2018-03-22 Thread Alexander Motin
Author: mav
Date: Fri Mar 23 02:50:38 2018
New Revision: 331414
URL: https://svnweb.freebsd.org/changeset/base/331414

Log:
  Reduce struct aggsum_bucket padding to fit into one cache line.
  
  Reported by:  mjg

Modified:
  head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/aggsum.h

Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/aggsum.h
==
--- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/aggsum.hFri Mar 
23 02:45:09 2018(r331413)
+++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/aggsum.hFri Mar 
23 02:50:38 2018(r331414)
@@ -29,7 +29,7 @@ typedef struct aggsum_bucket {
kmutex_t asc_lock;
int64_t asc_delta;
uint64_t asc_borrowed;
-   uint64_t asc_pad[4]; /* pad out to cache line (64 bytes) */
+   uint64_t asc_pad[2]; /* pad out to cache line (64 bytes) */
 } aggsum_bucket_t __aligned(CACHE_LINE_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"


Re: svn commit: r331369 - head/sys/vm

2018-03-22 Thread Cy Schubert
In message , Jeff Roberson 
writes:
> On Thu, 22 Mar 2018, Cy Schubert wrote:
>
> > In message , Jeff Roberson
> > writes:
> >> On Thu, 22 Mar 2018, Cy Schubert wrote:
> >>
> >>> It broke i386 too.
> >>
> >> I just did
> >> TARGET_ARCH=i386 make buildworld
> >> TARGET_ARCH=i386 make buildkernel
> >>
> >> This worked for me?
> >>
> >> Jeff
> >
> > hmmm.
> >
> > make TARGET=i386 TARGET_ARCH=i386 buildkernel
>
> Do you have changes to GENERIC?

Not to GENERIC but I used a different kernel by default that removes 
most drivers (as I load them dynamically -- single kernel different 
modules on each machine).

Ahh but this particular i386 kernel I was building does not include 
INVARIANTS. sys/i386/include/counter.h at line 35 has:

#ifdef INVARIANTS
#include 
#endif

sys/proc.h includes sys/systm.h.

i386 without INVARIANTS will fail to build. With INVARIANTS i386 does 
build.

I'll commit the fix.

~cy


>
> Thanks,
> Jeff
> >
> > --- vm_reserv.o ---
> > In file included from /opt/src/svn-current/sys/vm/vm_reserv.c:48:
> > In file included from /opt/src/svn-current/sys/sys/counter.h:37:
> > ./machine/counter.h:174:3: error: implicit declaration of function
> > 'critical_enter' is invalid in C99 [-Werror,-Wimplicit-function-declarat
> > ion]
> >critical_enter();
> >^
> > ./machine/counter.h:174:3: error: this function declaration is not a
> > prototype [-Werror,-Wstrict-prototypes]
> > ./machine/counter.h:176:3: error: implicit declaration of function
> > 'critical_exit' is invalid in C99 [-Werror,-Wimplicit-function-declarati
> > on]
> >critical_exit();
> >^
> > ./machine/counter.h:176:3: note: did you mean 'critical_enter'?
> > ./machine/counter.h:174:3: note: 'critical_enter' declared here
> >critical_enter();
> >^
> > ./machine/counter.h:176:3: error: this function declaration is not a
> > prototype [-Werror,-Wstrict-prototypes]
> >critical_exit();
> >^
> > In file included from /opt/src/svn-current/sys/vm/vm_reserv.c:57:
> > /opt/src/svn-current/sys/sys/systm.h:217:6: error: conflicting types
> > for 'critical_enter'
> > voidcritical_enter(void);
> >^
> > ./machine/counter.h:174:3: note: previous implicit declaration is here
> >critical_enter();
> >^
> > In file included from /opt/src/svn-current/sys/vm/vm_reserv.c:57:
> > /opt/src/svn-current/sys/sys/systm.h:218:6: error: conflicting types
> > for 'critical_exit'
> > voidcritical_exit(void);
> >^
> > ./machine/counter.h:176:3: note: previous implicit declaration is here
> >critical_exit();
> >^
> > 6 errors generated.
> > *** [vm_reserv.o] Error code 1
> >
> > make[2]: stopped in /export/obj/opt/src/svn-current/i386.i386/sys/BREAK
> > --- modules-all ---
> > A failure has been detected in another branch of the parallel make
> >
> > make[3]: stopped in /opt/src/svn-current/sys/modules
> > *** [modules-all] Error code 2
> >
> > make[2]: stopped in /export/obj/opt/src/svn-current/i386.i386/sys/BREAK
> > 2 errors
> >
> > make[2]: stopped in /export/obj/opt/src/svn-current/i386.i386/sys/BREAK
> > *** [buildkernel] Error code 2
> >
> > make[1]: stopped in /opt/src/svn-current
> > 1 error
> >
> > make[1]: stopped in /opt/src/svn-current
> > *** [buildkernel] Error code 2
> >
> > make: stopped in /opt/src/svn-current
> > 1 error
> >
> > make: stopped in /opt/src/svn-current
> >
> > ~cy
> >
> >>
> >>>
> >>> Index: sys/vm/vm_reserv.c
> >>> ===
> >>> --- sys/vm/vm_reserv.c(revision 331399)
> >>> +++ sys/vm/vm_reserv.c(working copy)
> >>> @@ -45,8 +45,6 @@
> >>>
> >>> #include 
> >>> #include 
> >>> -#include 
> >>> -#include 
> >>> #include 
> >>> #include 
> >>> #include 
> >>> @@ -55,6 +53,8 @@
> >>> #include 
> >>> #include 
> >>> #include 
> >>> +#include 
> >>> +#include 
> >>> #include 
> >>> #include 
> >>>
> >>> This is because sys/i386/include/machine.h uses critical_enter() and
> >>> critical_exit() which are defined in sys/systm.h.
> >>>
> >>> It built nicely on my amd64's though.
> >>>
> >>> ~cy
> >>>
> >>> In message , Jeff Roberson
> >>> writes:
>  Thank you, working on it.  I had done a make universe before getting
>  review feedback.
> 
>  Jeff
> 
>  On Thu, 22 Mar 2018, Justin Hibbits wrote:
> 
> > This broke gcc builds.
> >
> > On Thu, Mar 22, 2018 at 2:21 PM, Jeff Roberson  wrote
> :
> >> Author: jeff
> >> Date: Thu Mar 22 19:21:11 2018
> >> New Revision: 331369
> >> URL: https://svnweb.freebsd.org/changeset/base/331369
> >>
> >> Log:
> >>   Lock reservations with a dedicated lock in each reservation.  Protec
> t
> >> th
>  e
> >>   

svn commit: r331413 - head/sys/dev/efidev

2018-03-22 Thread Kyle Evans
Author: kevans
Date: Fri Mar 23 02:45:09 2018
New Revision: 331413
URL: https://svnweb.freebsd.org/changeset/base/331413

Log:
  efidev: Drop a quick note in about efi_cfgtbl/efi_runtime
  
  There's no real annotation for it, so it's not immediately obvious to the
  unfamiliar that these pointers are to locations in the EFI runtime map
  unlike the system table pointer immediately above them.

Modified:
  head/sys/dev/efidev/efirt.c

Modified: head/sys/dev/efidev/efirt.c
==
--- head/sys/dev/efidev/efirt.c Fri Mar 23 02:38:31 2018(r331412)
+++ head/sys/dev/efidev/efirt.c Fri Mar 23 02:45:09 2018(r331413)
@@ -57,6 +57,11 @@ __FBSDID("$FreeBSD$");
 #include 
 
 static struct efi_systbl *efi_systbl;
+/*
+ * The following pointers point to tables in the EFI runtime service data 
pages.
+ * Care should be taken to make sure that we've properly entered the EFI 
runtime
+ * environment (efi_enter()) before dereferencing them.
+ */
 static struct efi_cfgtbl *efi_cfgtbl;
 static struct efi_rt *efi_runtime;
 
___
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: r331412 - stable/10/sys/dev/drm

2018-03-22 Thread Ed Maste
Author: emaste
Date: Fri Mar 23 02:38:31 2018
New Revision: 331412
URL: https://svnweb.freebsd.org/changeset/base/331412

Log:
  MFC r331333: Fix kernel memory disclosure in drm_infobufs
  
  drm_infobufs() has a structure on the stack, fills it out and copies it
  to userland.  There are 2 elements in the struct that are not filled out
  and left uninitialized.  This will leak uninitialized kernel stack data
  to userland.
  
  Submitted by: Domagoj Stolfa 
  Reported by:  Ilja Van Sprundel 
  Security: Kernel memory disclosure (798)

Modified:
  stable/10/sys/dev/drm/drm_bufs.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/dev/drm/drm_bufs.c
==
--- stable/10/sys/dev/drm/drm_bufs.cFri Mar 23 02:37:08 2018
(r331411)
+++ stable/10/sys/dev/drm/drm_bufs.cFri Mar 23 02:38:31 2018
(r331412)
@@ -935,6 +935,7 @@ int drm_infobufs(struct drm_device *dev, void *data, s
if (dma->bufs[i].buf_count) {
struct drm_buf_desc from;
 
+   memset(, 0, sizeof(from));
from.count = dma->bufs[i].buf_count;
from.size = dma->bufs[i].buf_size;
from.low_mark = dma->bufs[i].freelist.low_mark;
___
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: r331411 - stable/11/sys/dev/drm

2018-03-22 Thread Ed Maste
Author: emaste
Date: Fri Mar 23 02:37:08 2018
New Revision: 331411
URL: https://svnweb.freebsd.org/changeset/base/331411

Log:
  MFC r331333: Fix kernel memory disclosure in drm_infobufs
  
  drm_infobufs() has a structure on the stack, fills it out and copies it
  to userland.  There are 2 elements in the struct that are not filled out
  and left uninitialized.  This will leak uninitialized kernel stack data
  to userland.
  
  Submitted by: Domagoj Stolfa 
  Reported by:  Ilja Van Sprundel 
  Security: Kernel memory disclosure (798)

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

Modified: stable/11/sys/dev/drm/drm_bufs.c
==
--- stable/11/sys/dev/drm/drm_bufs.cFri Mar 23 02:34:45 2018
(r331410)
+++ stable/11/sys/dev/drm/drm_bufs.cFri Mar 23 02:37:08 2018
(r331411)
@@ -935,6 +935,7 @@ int drm_infobufs(struct drm_device *dev, void *data, s
if (dma->bufs[i].buf_count) {
struct drm_buf_desc from;
 
+   memset(, 0, sizeof(from));
from.count = dma->bufs[i].buf_count;
from.size = dma->bufs[i].buf_size;
from.low_mark = dma->bufs[i].freelist.low_mark;
___
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: r331404 - in head: cddl/contrib/opensolaris/lib/libzpool/common/sys sys/cddl/contrib/opensolaris/uts/common sys/cddl/contrib/opensolaris/uts/common/fs/zfs sys/cddl/contrib/opensolaris/

2018-03-22 Thread Mateusz Guzik
On Fri, Mar 23, 2018 at 3:15 AM, Alexander Motin  wrote:

> Author: mav
> Date: Fri Mar 23 02:15:05 2018
> New Revision: 331404
> URL: https://svnweb.freebsd.org/changeset/base/331404
>
> Log:
>   MFV r331400: 8484 Implement aggregate sum and use for arc counters
>
>   In pursuit of improving performance on multi-core systems, we should
>   implements fanned out counters and use them to improve the performance of
>   some of the arc statistics. These stats are updated extremely frequently,
>   and can consume a significant amount of CPU time.
>
>
>
>
Due to seriously fat locks this struct:

typedef struct aggsum_bucket {
kmutex_t asc_lock;
int64_t asc_delta;
uint64_t asc_borrowed;
uint64_t asc_pad[4]; /* pad out to cache line (64 bytes) */
} aggsum_bucket_t __aligned(CACHE_LINE_SIZE);

ends up using *two* cache lines. Without asc_pad the size is 48 bytes.
asc_pad adds 4 * 8 = 32 which pushes it to the next line for no good reason.

That said, I suggest #ifndefing it the field.

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


Re: svn commit: r331369 - head/sys/vm

2018-03-22 Thread Cy Schubert
In message , Jeff Roberson 
writes:
> On Thu, 22 Mar 2018, Cy Schubert wrote:
>
> > It broke i386 too.
>
> I believe I'm not able to reproduce this because it is a result of changes 
> in kernel config.  I can not reproduce it so I can't verify the fix. 
> Since you can, would you mind committing?  I see no problem with the diff 
> below.

I don't mind.

>
> Thanks,
> Jeff
>
> >
> > Index: sys/vm/vm_reserv.c
> > ===
> > --- sys/vm/vm_reserv.c  (revision 331399)
> > +++ sys/vm/vm_reserv.c  (working copy)
> > @@ -45,8 +45,6 @@
> >
> > #include 
> > #include 
> > -#include 
> > -#include 
> > #include 
> > #include 
> > #include 
> > @@ -55,6 +53,8 @@
> > #include 
> > #include 
> > #include 
> > +#include 
> > +#include 
> > #include 
> > #include 
> >
> > This is because sys/i386/include/machine.h uses critical_enter() and
> > critical_exit() which are defined in sys/systm.h.
> >
> > It built nicely on my amd64's though.
> >
> > ~cy
> >
> > In message , Jeff Roberson
> > writes:
> >> Thank you, working on it.  I had done a make universe before getting
> >> review feedback.
> >>
> >> Jeff
> >>
> >> On Thu, 22 Mar 2018, Justin Hibbits wrote:
> >>
> >>> This broke gcc builds.
> >>>
> >>> On Thu, Mar 22, 2018 at 2:21 PM, Jeff Roberson  wrote:
>  Author: jeff
>  Date: Thu Mar 22 19:21:11 2018
>  New Revision: 331369
>  URL: https://svnweb.freebsd.org/changeset/base/331369
> 
>  Log:
>    Lock reservations with a dedicated lock in each reservation.  Protect 
> th
> >> e
>    vmd_free_count with atomics.
> 
>    This allows us to allocate and free from reservations without the free
>  l
> >> ock
>    except where a superpage is allocated from the physical layer, which i
> s
>    roughly 1/512 of the operations on amd64.
> 
>    Use the counter api to eliminate cache conention on counters.
> 
>    Reviewed by:  markj
>    Tested by:pho
>    Sponsored by: Netflix, Dell/EMC Isilon
>    Differential Revision:https://reviews.freebsd.org/D14707
> 
>  Modified:
>    head/sys/vm/vm_page.c
>    head/sys/vm/vm_pagequeue.h
>    head/sys/vm/vm_reserv.c
>    head/sys/vm/vm_reserv.h
> 
>  Modified: head/sys/vm/vm_page.c
>  
> ==
> >> 
>  --- head/sys/vm/vm_page.c   Thu Mar 22 19:11:43 2018(r331368
> )
>  +++ head/sys/vm/vm_page.c   Thu Mar 22 19:21:11 2018(r331369
> )
>  @@ -177,7 +177,6 @@ static uma_zone_t fakepg_zone;
>   static void vm_page_alloc_check(vm_page_t m);
>   static void vm_page_clear_dirty_mask(vm_page_t m, vm_page_bits_t pagebi
> ts
> >> );
>   static void vm_page_enqueue(uint8_t queue, vm_page_t m);
>  -static void vm_page_free_phys(struct vm_domain *vmd, vm_page_t m);
>   static void vm_page_init(void *dummy);
>   static int vm_page_insert_after(vm_page_t m, vm_object_t object,
>   vm_pindex_t pindex, vm_page_t mpred);
>  @@ -1677,10 +1676,10 @@ vm_page_alloc_after(vm_object_t object, vm_pinde
> x_
> >> t pi
>    * for the request class and false otherwise.
>    */
>   int
>  -vm_domain_available(struct vm_domain *vmd, int req, int npages)
>  +vm_domain_allocate(struct vm_domain *vmd, int req, int npages)
>   {
>  +   u_int limit, old, new;
> 
>  -   vm_domain_free_assert_locked(vmd);
>  req = req & VM_ALLOC_CLASS_MASK;
> 
>  /*
>  @@ -1688,15 +1687,34 @@ vm_domain_available(struct vm_domain *vmd, int r
> eq
> >> , in
>   */
>  if (curproc == pageproc && req != VM_ALLOC_INTERRUPT)
>  req = VM_ALLOC_SYSTEM;
>  +   if (req == VM_ALLOC_INTERRUPT)
>  +   limit = 0;
>  +   else if (req == VM_ALLOC_SYSTEM)
>  +   limit = vmd->vmd_interrupt_free_min;
>  +   else
>  +   limit = vmd->vmd_free_reserved;
> 
>  -   if (vmd->vmd_free_count >= npages + vmd->vmd_free_reserved ||
>  -   (req == VM_ALLOC_SYSTEM &&
>  -   vmd->vmd_free_count >= npages + vmd->vmd_interrupt_free_min)
>  |
> >> |
>  -   (req == VM_ALLOC_INTERRUPT &&
>  -   vmd->vmd_free_count >= npages))
>  -   return (1);
>  +   /*
>  +* Attempt to reserve the pages.  Fail if we're below the limit.
>  +*/
>  +   limit += npages;
>  +   old = vmd->vmd_free_count;
>  +   do {
>  +   if (old < limit)
>  +   return (0);
>  +   new = old - npages;
>  +   } while (atomic_fcmpset_int(>vmd_free_count, , new) == 
> 0)
> >> ;
> 
>  -   

svn commit: r331410 - stable/10/sys/dev/drm

2018-03-22 Thread Ed Maste
Author: emaste
Date: Fri Mar 23 02:34:45 2018
New Revision: 331410
URL: https://svnweb.freebsd.org/changeset/base/331410

Log:
  MFC r331339: Correct signedness bug in drm_modeset_ctl
  
  drm_modeset_ctl() takes a signed in from userland, does a boundscheck,
  and then uses it to index into a structure and write to it.  The
  boundscheck only checks upper bound, and never checks for nagative
  values.  If the int coming from userland is negative [after conversion]
  it will bypass the boundscheck, perform a negative index into an array
  and write to it, causing memory corruption.
  
  Note that this is in the "old" drm driver; this issue does not exist
  in drm2.
  
  Reported by:  Ilja Van Sprundel 
  Reviewed by:  cem
  Sponsored by: The FreeBSD Foundation

Modified:
  stable/10/sys/dev/drm/drm_irq.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/dev/drm/drm_irq.c
==
--- stable/10/sys/dev/drm/drm_irq.c Fri Mar 23 02:33:30 2018
(r331409)
+++ stable/10/sys/dev/drm/drm_irq.c Fri Mar 23 02:34:45 2018
(r331410)
@@ -357,7 +357,7 @@ int drm_modeset_ctl(struct drm_device *dev, void *data
goto out;
 
crtc = modeset->crtc;
-   if (crtc >= dev->num_crtcs) {
+   if (crtc < 0 || crtc >= dev->num_crtcs) {
ret = EINVAL;
goto out;
}
___
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: r331409 - stable/11/sys/dev/drm

2018-03-22 Thread Ed Maste
Author: emaste
Date: Fri Mar 23 02:33:30 2018
New Revision: 331409
URL: https://svnweb.freebsd.org/changeset/base/331409

Log:
  MFC r331339: Correct signedness bug in drm_modeset_ctl
  
  drm_modeset_ctl() takes a signed in from userland, does a boundscheck,
  and then uses it to index into a structure and write to it.  The
  boundscheck only checks upper bound, and never checks for nagative
  values.  If the int coming from userland is negative [after conversion]
  it will bypass the boundscheck, perform a negative index into an array
  and write to it, causing memory corruption.
  
  Note that this is in the "old" drm driver; this issue does not exist
  in drm2.
  
  Reported by:  Ilja Van Sprundel 
  Reviewed by:  cem
  Sponsored by: The FreeBSD Foundation

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

Modified: stable/11/sys/dev/drm/drm_irq.c
==
--- stable/11/sys/dev/drm/drm_irq.c Fri Mar 23 02:30:29 2018
(r331408)
+++ stable/11/sys/dev/drm/drm_irq.c Fri Mar 23 02:33:30 2018
(r331409)
@@ -351,7 +351,7 @@ int drm_modeset_ctl(struct drm_device *dev, void *data
goto out;
 
crtc = modeset->crtc;
-   if (crtc >= dev->num_crtcs) {
+   if (crtc < 0 || crtc >= dev->num_crtcs) {
ret = EINVAL;
goto out;
}
___
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: r331408 - in head: cddl/contrib/opensolaris/cmd/zfs cddl/contrib/opensolaris/cmd/zpool sys/cddl/contrib/opensolaris/uts/common/fs/zfs

2018-03-22 Thread Alexander Motin
Author: mav
Date: Fri Mar 23 02:30:29 2018
New Revision: 331408
URL: https://svnweb.freebsd.org/changeset/base/331408

Log:
  MFV r331407: 9213 zfs: sytem typo
  
  illumos/illumos-gate@edc8ef7d921c96b23969898aeb766cb24960bda7
  
  Reviewed by: C Fraire 
  Reviewed by: Andy Fiddaman 
  Approved by: Joshua M. Clulow 
  Author: Toomas Soome 

Modified:
  head/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c
  head/cddl/contrib/opensolaris/cmd/zpool/zpool_main.c
  head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_acl.c
Directory Properties:
  head/cddl/contrib/opensolaris/   (props changed)
  head/cddl/contrib/opensolaris/cmd/zfs/   (props changed)
  head/sys/cddl/contrib/opensolaris/   (props changed)

Modified: head/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c
==
--- head/cddl/contrib/opensolaris/cmd/zfs/zfs_main.cFri Mar 23 02:28:37 
2018(r331407)
+++ head/cddl/contrib/opensolaris/cmd/zfs/zfs_main.cFri Mar 23 02:30:29 
2018(r331408)
@@ -2215,7 +2215,7 @@ zfs_do_upgrade(int argc, char **argv)
if (cb.cb_numfailed != 0)
ret = 1;
} else {
-   /* List old-version filesytems */
+   /* List old-version filesystems */
boolean_t found;
(void) printf(gettext("This system is currently running "
"ZFS filesystem version %llu.\n\n"), ZPL_VERSION);

Modified: head/cddl/contrib/opensolaris/cmd/zpool/zpool_main.c
==
--- head/cddl/contrib/opensolaris/cmd/zpool/zpool_main.cFri Mar 23 
02:28:37 2018(r331407)
+++ head/cddl/contrib/opensolaris/cmd/zpool/zpool_main.cFri Mar 23 
02:30:29 2018(r331408)
@@ -1852,7 +1852,7 @@ show_import(nvlist_t *config)
 
case ZPOOL_STATUS_UNSUP_FEAT_READ:
(void) printf(gettext("status: The pool uses the following "
-   "feature(s) not supported on this sytem:\n"));
+   "feature(s) not supported on this system:\n"));
zpool_print_unsup_feat(config);
break;
 

Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_acl.c
==
--- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_acl.c   Fri Mar 
23 02:28:37 2018(r331407)
+++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_acl.c   Fri Mar 
23 02:30:29 2018(r331408)
@@ -2369,7 +2369,7 @@ slow:
 /*
  * Determine whether Access should be granted/denied.
  *
- * The least priv subsytem is always consulted as a basic privilege
+ * The least priv subsystem is always consulted as a basic privilege
  * can define any form of access.
  */
 int
___
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: r331407 - vendor-sys/illumos/dist/uts/common/fs/zfs vendor/illumos/dist/cmd/zfs vendor/illumos/dist/cmd/zpool

2018-03-22 Thread Alexander Motin
Author: mav
Date: Fri Mar 23 02:28:37 2018
New Revision: 331407
URL: https://svnweb.freebsd.org/changeset/base/331407

Log:
  9213 zfs: sytem typo
  
  illumos/illumos-gate@edc8ef7d921c96b23969898aeb766cb24960bda7
  
  Reviewed by: C Fraire 
  Reviewed by: Andy Fiddaman 
  Approved by: Joshua M. Clulow 
  Author: Toomas Soome 

Modified:
  vendor-sys/illumos/dist/uts/common/fs/zfs/zfs_acl.c

Changes in other areas also in this revision:
Modified:
  vendor/illumos/dist/cmd/zfs/zfs_main.c
  vendor/illumos/dist/cmd/zpool/zpool_main.c

Modified: vendor-sys/illumos/dist/uts/common/fs/zfs/zfs_acl.c
==
--- vendor-sys/illumos/dist/uts/common/fs/zfs/zfs_acl.c Fri Mar 23 02:24:52 
2018(r331406)
+++ vendor-sys/illumos/dist/uts/common/fs/zfs/zfs_acl.c Fri Mar 23 02:28:37 
2018(r331407)
@@ -2371,7 +2371,7 @@ slow:
 /*
  * Determine whether Access should be granted/denied.
  *
- * The least priv subsytem is always consulted as a basic privilege
+ * The least priv subsystem is always consulted as a basic privilege
  * can define any form of access.
  */
 int
___
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: r331407 - vendor-sys/illumos/dist/uts/common/fs/zfs vendor/illumos/dist/cmd/zfs vendor/illumos/dist/cmd/zpool

2018-03-22 Thread Alexander Motin
Author: mav
Date: Fri Mar 23 02:28:37 2018
New Revision: 331407
URL: https://svnweb.freebsd.org/changeset/base/331407

Log:
  9213 zfs: sytem typo
  
  illumos/illumos-gate@edc8ef7d921c96b23969898aeb766cb24960bda7
  
  Reviewed by: C Fraire 
  Reviewed by: Andy Fiddaman 
  Approved by: Joshua M. Clulow 
  Author: Toomas Soome 

Modified:
  vendor/illumos/dist/cmd/zfs/zfs_main.c
  vendor/illumos/dist/cmd/zpool/zpool_main.c

Changes in other areas also in this revision:
Modified:
  vendor-sys/illumos/dist/uts/common/fs/zfs/zfs_acl.c

Modified: vendor/illumos/dist/cmd/zfs/zfs_main.c
==
--- vendor/illumos/dist/cmd/zfs/zfs_main.c  Fri Mar 23 02:24:52 2018
(r331406)
+++ vendor/illumos/dist/cmd/zfs/zfs_main.c  Fri Mar 23 02:28:37 2018
(r331407)
@@ -2188,7 +2188,7 @@ zfs_do_upgrade(int argc, char **argv)
if (cb.cb_numfailed != 0)
ret = 1;
} else {
-   /* List old-version filesytems */
+   /* List old-version filesystems */
boolean_t found;
(void) printf(gettext("This system is currently running "
"ZFS filesystem version %llu.\n\n"), ZPL_VERSION);

Modified: vendor/illumos/dist/cmd/zpool/zpool_main.c
==
--- vendor/illumos/dist/cmd/zpool/zpool_main.c  Fri Mar 23 02:24:52 2018
(r331406)
+++ vendor/illumos/dist/cmd/zpool/zpool_main.c  Fri Mar 23 02:28:37 2018
(r331407)
@@ -1826,7 +1826,7 @@ show_import(nvlist_t *config)
 
case ZPOOL_STATUS_UNSUP_FEAT_READ:
(void) printf(gettext("status: The pool uses the following "
-   "feature(s) not supported on this sytem:\n"));
+   "feature(s) not supported on this system:\n"));
zpool_print_unsup_feat(config);
break;
 
___
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: r331406 - head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs

2018-03-22 Thread Alexander Motin
Author: mav
Date: Fri Mar 23 02:24:52 2018
New Revision: 331406
URL: https://svnweb.freebsd.org/changeset/base/331406

Log:
  MFV r331405: 9084 spa_*_ashift must ignore spare devices
  
  illumos/illumos-gate@b037f3dbd69cef4a7ffd576ad33e07bfaf0b1e84
  
  Reviewed by: Prashanth Sreenivasa 
  Reviewed by: George Wilson 
  Approved by: Dan McDonald 
  Author: Prakash Surya 

Modified:
  head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev.c
Directory Properties:
  head/sys/cddl/contrib/opensolaris/   (props changed)

Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev.c
==
--- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev.c  Fri Mar 23 
02:22:16 2018(r331405)
+++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev.c  Fri Mar 23 
02:24:52 2018(r331406)
@@ -1589,14 +1589,6 @@ vdev_open(vdev_t *vd)
return (error);
}
 
-   if (vd->vdev_top == vd && vd->vdev_ashift != 0 &&
-   !vd->vdev_isl2cache && !vd->vdev_islog) {
-   if (vd->vdev_ashift > spa->spa_max_ashift)
-   spa->spa_max_ashift = vd->vdev_ashift;
-   if (vd->vdev_ashift < spa->spa_min_ashift)
-   spa->spa_min_ashift = vd->vdev_ashift;
-   }
-
/*
 * Track the min and max ashift values for normal data devices.
 */
___
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: r331405 - vendor-sys/illumos/dist/uts/common/fs/zfs

2018-03-22 Thread Alexander Motin
Author: mav
Date: Fri Mar 23 02:22:16 2018
New Revision: 331405
URL: https://svnweb.freebsd.org/changeset/base/331405

Log:
  9084 spa_*_ashift must ignore spare devices
  
  illumos/illumos-gate@b037f3dbd69cef4a7ffd576ad33e07bfaf0b1e84
  
  Reviewed by: Prashanth Sreenivasa 
  Reviewed by: George Wilson 
  Approved by: Dan McDonald 
  Author: Prakash Surya 

Modified:
  vendor-sys/illumos/dist/uts/common/fs/zfs/vdev.c

Modified: vendor-sys/illumos/dist/uts/common/fs/zfs/vdev.c
==
--- vendor-sys/illumos/dist/uts/common/fs/zfs/vdev.cFri Mar 23 02:15:05 
2018(r331404)
+++ vendor-sys/illumos/dist/uts/common/fs/zfs/vdev.cFri Mar 23 02:22:16 
2018(r331405)
@@ -1478,14 +1478,6 @@ vdev_open(vdev_t *vd)
return (error);
}
 
-   if (vd->vdev_top == vd && vd->vdev_ashift != 0 &&
-   !vd->vdev_isl2cache && !vd->vdev_islog) {
-   if (vd->vdev_ashift > spa->spa_max_ashift)
-   spa->spa_max_ashift = vd->vdev_ashift;
-   if (vd->vdev_ashift < spa->spa_min_ashift)
-   spa->spa_min_ashift = vd->vdev_ashift;
-   }
-
/*
 * Track the min and max ashift values for normal data devices.
 */
___
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: r331404 - in head: cddl/contrib/opensolaris/lib/libzpool/common/sys sys/cddl/contrib/opensolaris/uts/common sys/cddl/contrib/opensolaris/uts/common/fs/zfs sys/cddl/contrib/opensolaris/u...

2018-03-22 Thread Alexander Motin
Author: mav
Date: Fri Mar 23 02:15:05 2018
New Revision: 331404
URL: https://svnweb.freebsd.org/changeset/base/331404

Log:
  MFV r331400: 8484 Implement aggregate sum and use for arc counters
  
  In pursuit of improving performance on multi-core systems, we should
  implements fanned out counters and use them to improve the performance of
  some of the arc statistics. These stats are updated extremely frequently,
  and can consume a significant amount of CPU time.
  
  Reviewed by: Pavel Zakharov 
  Reviewed by: Matthew Ahrens 
  Approved by: Dan McDonald 
  Author: Paul Dagnelie 

Added:
  head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/THIRDPARTYLICENSE.cityhash
 - copied unchanged from r331400, 
vendor-sys/illumos/dist/uts/common/fs/zfs/THIRDPARTYLICENSE.cityhash
  
head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/THIRDPARTYLICENSE.cityhash.descrip
 - copied unchanged from r331400, 
vendor-sys/illumos/dist/uts/common/fs/zfs/THIRDPARTYLICENSE.cityhash.descrip
  head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/aggsum.c
 - copied unchanged from r331400, 
vendor-sys/illumos/dist/uts/common/fs/zfs/aggsum.c
  head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/cityhash.c
 - copied unchanged from r331400, 
vendor-sys/illumos/dist/uts/common/fs/zfs/cityhash.c
  head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/aggsum.h
 - copied, changed from r331400, 
vendor-sys/illumos/dist/uts/common/fs/zfs/sys/aggsum.h
  head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/cityhash.h
 - copied unchanged from r331400, 
vendor-sys/illumos/dist/uts/common/fs/zfs/sys/cityhash.h
Modified:
  head/cddl/contrib/opensolaris/lib/libzpool/common/sys/zfs_context.h
  head/sys/cddl/contrib/opensolaris/uts/common/Makefile.files
  head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c
  head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dbuf.c
  head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_context.h
  head/sys/conf/files
Directory Properties:
  head/sys/cddl/contrib/opensolaris/   (props changed)

Modified: head/cddl/contrib/opensolaris/lib/libzpool/common/sys/zfs_context.h
==
--- head/cddl/contrib/opensolaris/lib/libzpool/common/sys/zfs_context.h Fri Mar 
23 01:43:27 2018(r331403)
+++ head/cddl/contrib/opensolaris/lib/libzpool/common/sys/zfs_context.h Fri Mar 
23 02:15:05 2018(r331404)
@@ -559,6 +559,7 @@ extern void delay(clock_t ticks);
} while (0);
 
 #definemax_ncpus   64
+#defineboot_ncpus  (sysconf(_SC_NPROCESSORS_ONLN))
 
 #defineminclsyspri 60
 #definemaxclsyspri 99

Modified: head/sys/cddl/contrib/opensolaris/uts/common/Makefile.files
==
--- head/sys/cddl/contrib/opensolaris/uts/common/Makefile.files Fri Mar 23 
01:43:27 2018(r331403)
+++ head/sys/cddl/contrib/opensolaris/uts/common/Makefile.files Fri Mar 23 
02:15:05 2018(r331404)
@@ -63,12 +63,14 @@ LUA_OBJS += \
 
 ZFS_COMMON_OBJS += \
abd.o   \
+   aggsum.o\
arc.o   \
bplist.o\
blkptr.o\
bpobj.o \
bptree.o\
bqueue.o\
+   cityhash.o  \
dbuf.o  \
ddt.o   \
ddt_zap.o   \

Copied: 
head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/THIRDPARTYLICENSE.cityhash 
(from r331400, 
vendor-sys/illumos/dist/uts/common/fs/zfs/THIRDPARTYLICENSE.cityhash)
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ 
head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/THIRDPARTYLICENSE.cityhash  
Fri Mar 23 02:15:05 2018(r331404, copy of r331400, 
vendor-sys/illumos/dist/uts/common/fs/zfs/THIRDPARTYLICENSE.cityhash)
@@ -0,0 +1,19 @@
+Copyright (c) 2011 Google, Inc.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND 

Re: svn commit: r331369 - head/sys/vm

2018-03-22 Thread Jeff Roberson

On Thu, 22 Mar 2018, Cy Schubert wrote:


In message , Jeff Roberson
writes:

On Thu, 22 Mar 2018, Cy Schubert wrote:


It broke i386 too.


I just did
TARGET_ARCH=i386 make buildworld
TARGET_ARCH=i386 make buildkernel

This worked for me?

Jeff


hmmm.

make TARGET=i386 TARGET_ARCH=i386 buildkernel


Do you have changes to GENERIC?

Thanks,
Jeff


--- vm_reserv.o ---
In file included from /opt/src/svn-current/sys/vm/vm_reserv.c:48:
In file included from /opt/src/svn-current/sys/sys/counter.h:37:
./machine/counter.h:174:3: error: implicit declaration of function
'critical_enter' is invalid in C99 [-Werror,-Wimplicit-function-declarat
ion]
   critical_enter();
   ^
./machine/counter.h:174:3: error: this function declaration is not a
prototype [-Werror,-Wstrict-prototypes]
./machine/counter.h:176:3: error: implicit declaration of function
'critical_exit' is invalid in C99 [-Werror,-Wimplicit-function-declarati
on]
   critical_exit();
   ^
./machine/counter.h:176:3: note: did you mean 'critical_enter'?
./machine/counter.h:174:3: note: 'critical_enter' declared here
   critical_enter();
   ^
./machine/counter.h:176:3: error: this function declaration is not a
prototype [-Werror,-Wstrict-prototypes]
   critical_exit();
   ^
In file included from /opt/src/svn-current/sys/vm/vm_reserv.c:57:
/opt/src/svn-current/sys/sys/systm.h:217:6: error: conflicting types
for 'critical_enter'
voidcritical_enter(void);
   ^
./machine/counter.h:174:3: note: previous implicit declaration is here
   critical_enter();
   ^
In file included from /opt/src/svn-current/sys/vm/vm_reserv.c:57:
/opt/src/svn-current/sys/sys/systm.h:218:6: error: conflicting types
for 'critical_exit'
voidcritical_exit(void);
   ^
./machine/counter.h:176:3: note: previous implicit declaration is here
   critical_exit();
   ^
6 errors generated.
*** [vm_reserv.o] Error code 1

make[2]: stopped in /export/obj/opt/src/svn-current/i386.i386/sys/BREAK
--- modules-all ---
A failure has been detected in another branch of the parallel make

make[3]: stopped in /opt/src/svn-current/sys/modules
*** [modules-all] Error code 2

make[2]: stopped in /export/obj/opt/src/svn-current/i386.i386/sys/BREAK
2 errors

make[2]: stopped in /export/obj/opt/src/svn-current/i386.i386/sys/BREAK
*** [buildkernel] Error code 2

make[1]: stopped in /opt/src/svn-current
1 error

make[1]: stopped in /opt/src/svn-current
*** [buildkernel] Error code 2

make: stopped in /opt/src/svn-current
1 error

make: stopped in /opt/src/svn-current

~cy





Index: sys/vm/vm_reserv.c
===
--- sys/vm/vm_reserv.c  (revision 331399)
+++ sys/vm/vm_reserv.c  (working copy)
@@ -45,8 +45,6 @@

#include 
#include 
-#include 
-#include 
#include 
#include 
#include 
@@ -55,6 +53,8 @@
#include 
#include 
#include 
+#include 
+#include 
#include 
#include 

This is because sys/i386/include/machine.h uses critical_enter() and
critical_exit() which are defined in sys/systm.h.

It built nicely on my amd64's though.

~cy

In message , Jeff Roberson
writes:

Thank you, working on it.  I had done a make universe before getting
review feedback.

Jeff

On Thu, 22 Mar 2018, Justin Hibbits wrote:


This broke gcc builds.

On Thu, Mar 22, 2018 at 2:21 PM, Jeff Roberson  wrote:

Author: jeff
Date: Thu Mar 22 19:21:11 2018
New Revision: 331369
URL: https://svnweb.freebsd.org/changeset/base/331369

Log:
  Lock reservations with a dedicated lock in each reservation.  Protect

th

e

  vmd_free_count with atomics.

  This allows us to allocate and free from reservations without the free

 l

ock

  except where a superpage is allocated from the physical layer, which i

s

  roughly 1/512 of the operations on amd64.

  Use the counter api to eliminate cache conention on counters.

  Reviewed by:  markj
  Tested by:pho
  Sponsored by: Netflix, Dell/EMC Isilon
  Differential Revision:https://reviews.freebsd.org/D14707

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

Modified: head/sys/vm/vm_page.c


==



--- head/sys/vm/vm_page.c   Thu Mar 22 19:11:43 2018(r331368

)

+++ head/sys/vm/vm_page.c   Thu Mar 22 19:21:11 2018(r331369

)

@@ -177,7 +177,6 @@ static uma_zone_t fakepg_zone;
 static void vm_page_alloc_check(vm_page_t m);
 static void vm_page_clear_dirty_mask(vm_page_t m, vm_page_bits_t pagebi

ts

);

 static void vm_page_enqueue(uint8_t queue, vm_page_t m);
-static void vm_page_free_phys(struct vm_domain *vmd, vm_page_t m);
 static void vm_page_init(void *dummy);
 static int vm_page_insert_after(vm_page_t m, vm_object_t 

Re: svn commit: r331369 - head/sys/vm

2018-03-22 Thread Cy Schubert
In message , Jeff Roberson 
writes:
> On Thu, 22 Mar 2018, Cy Schubert wrote:
>
> > It broke i386 too.
>
> I just did
> TARGET_ARCH=i386 make buildworld
> TARGET_ARCH=i386 make buildkernel
>
> This worked for me?
>
> Jeff

hmmm.

make TARGET=i386 TARGET_ARCH=i386 buildkernel

--- vm_reserv.o ---
In file included from /opt/src/svn-current/sys/vm/vm_reserv.c:48:
In file included from /opt/src/svn-current/sys/sys/counter.h:37:
./machine/counter.h:174:3: error: implicit declaration of function 
'critical_enter' is invalid in C99 [-Werror,-Wimplicit-function-declarat
ion]
critical_enter();
^
./machine/counter.h:174:3: error: this function declaration is not a 
prototype [-Werror,-Wstrict-prototypes]
./machine/counter.h:176:3: error: implicit declaration of function 
'critical_exit' is invalid in C99 [-Werror,-Wimplicit-function-declarati
on]
critical_exit();
^
./machine/counter.h:176:3: note: did you mean 'critical_enter'?
./machine/counter.h:174:3: note: 'critical_enter' declared here
critical_enter();
^
./machine/counter.h:176:3: error: this function declaration is not a 
prototype [-Werror,-Wstrict-prototypes]
critical_exit();
^
In file included from /opt/src/svn-current/sys/vm/vm_reserv.c:57:
/opt/src/svn-current/sys/sys/systm.h:217:6: error: conflicting types 
for 'critical_enter'
voidcritical_enter(void);
^
./machine/counter.h:174:3: note: previous implicit declaration is here
critical_enter();
^
In file included from /opt/src/svn-current/sys/vm/vm_reserv.c:57:
/opt/src/svn-current/sys/sys/systm.h:218:6: error: conflicting types 
for 'critical_exit'
voidcritical_exit(void);
^
./machine/counter.h:176:3: note: previous implicit declaration is here
critical_exit();
^
6 errors generated.
*** [vm_reserv.o] Error code 1

make[2]: stopped in /export/obj/opt/src/svn-current/i386.i386/sys/BREAK
--- modules-all ---
A failure has been detected in another branch of the parallel make

make[3]: stopped in /opt/src/svn-current/sys/modules
*** [modules-all] Error code 2

make[2]: stopped in /export/obj/opt/src/svn-current/i386.i386/sys/BREAK
2 errors

make[2]: stopped in /export/obj/opt/src/svn-current/i386.i386/sys/BREAK
*** [buildkernel] Error code 2

make[1]: stopped in /opt/src/svn-current
1 error

make[1]: stopped in /opt/src/svn-current
*** [buildkernel] Error code 2

make: stopped in /opt/src/svn-current
1 error

make: stopped in /opt/src/svn-current

~cy

>
> >
> > Index: sys/vm/vm_reserv.c
> > ===
> > --- sys/vm/vm_reserv.c  (revision 331399)
> > +++ sys/vm/vm_reserv.c  (working copy)
> > @@ -45,8 +45,6 @@
> >
> > #include 
> > #include 
> > -#include 
> > -#include 
> > #include 
> > #include 
> > #include 
> > @@ -55,6 +53,8 @@
> > #include 
> > #include 
> > #include 
> > +#include 
> > +#include 
> > #include 
> > #include 
> >
> > This is because sys/i386/include/machine.h uses critical_enter() and
> > critical_exit() which are defined in sys/systm.h.
> >
> > It built nicely on my amd64's though.
> >
> > ~cy
> >
> > In message , Jeff Roberson
> > writes:
> >> Thank you, working on it.  I had done a make universe before getting
> >> review feedback.
> >>
> >> Jeff
> >>
> >> On Thu, 22 Mar 2018, Justin Hibbits wrote:
> >>
> >>> This broke gcc builds.
> >>>
> >>> On Thu, Mar 22, 2018 at 2:21 PM, Jeff Roberson  wrote:
>  Author: jeff
>  Date: Thu Mar 22 19:21:11 2018
>  New Revision: 331369
>  URL: https://svnweb.freebsd.org/changeset/base/331369
> 
>  Log:
>    Lock reservations with a dedicated lock in each reservation.  Protect 
> th
> >> e
>    vmd_free_count with atomics.
> 
>    This allows us to allocate and free from reservations without the free
>  l
> >> ock
>    except where a superpage is allocated from the physical layer, which i
> s
>    roughly 1/512 of the operations on amd64.
> 
>    Use the counter api to eliminate cache conention on counters.
> 
>    Reviewed by:  markj
>    Tested by:pho
>    Sponsored by: Netflix, Dell/EMC Isilon
>    Differential Revision:https://reviews.freebsd.org/D14707
> 
>  Modified:
>    head/sys/vm/vm_page.c
>    head/sys/vm/vm_pagequeue.h
>    head/sys/vm/vm_reserv.c
>    head/sys/vm/vm_reserv.h
> 
>  Modified: head/sys/vm/vm_page.c
>  
> ==
> >> 
>  --- head/sys/vm/vm_page.c   Thu Mar 22 19:11:43 2018(r331368
> )
>  +++ head/sys/vm/vm_page.c   Thu Mar 22 19:21:11 2018(r331369
> )
>  @@ -177,7 +177,6 @@ static uma_zone_t fakepg_zone;
>   

Re: svn commit: r331369 - head/sys/vm

2018-03-22 Thread Jeff Roberson

On Thu, 22 Mar 2018, Cy Schubert wrote:


It broke i386 too.


I believe I'm not able to reproduce this because it is a result of changes 
in kernel config.  I can not reproduce it so I can't verify the fix. 
Since you can, would you mind committing?  I see no problem with the diff 
below.


Thanks,
Jeff



Index: sys/vm/vm_reserv.c
===
--- sys/vm/vm_reserv.c  (revision 331399)
+++ sys/vm/vm_reserv.c  (working copy)
@@ -45,8 +45,6 @@

#include 
#include 
-#include 
-#include 
#include 
#include 
#include 
@@ -55,6 +53,8 @@
#include 
#include 
#include 
+#include 
+#include 
#include 
#include 

This is because sys/i386/include/machine.h uses critical_enter() and
critical_exit() which are defined in sys/systm.h.

It built nicely on my amd64's though.

~cy

In message , Jeff Roberson
writes:

Thank you, working on it.  I had done a make universe before getting
review feedback.

Jeff

On Thu, 22 Mar 2018, Justin Hibbits wrote:


This broke gcc builds.

On Thu, Mar 22, 2018 at 2:21 PM, Jeff Roberson  wrote:

Author: jeff
Date: Thu Mar 22 19:21:11 2018
New Revision: 331369
URL: https://svnweb.freebsd.org/changeset/base/331369

Log:
  Lock reservations with a dedicated lock in each reservation.  Protect th

e

  vmd_free_count with atomics.

  This allows us to allocate and free from reservations without the free l

ock

  except where a superpage is allocated from the physical layer, which is
  roughly 1/512 of the operations on amd64.

  Use the counter api to eliminate cache conention on counters.

  Reviewed by:  markj
  Tested by:pho
  Sponsored by: Netflix, Dell/EMC Isilon
  Differential Revision:https://reviews.freebsd.org/D14707

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

Modified: head/sys/vm/vm_page.c
==



--- head/sys/vm/vm_page.c   Thu Mar 22 19:11:43 2018(r331368)
+++ head/sys/vm/vm_page.c   Thu Mar 22 19:21:11 2018(r331369)
@@ -177,7 +177,6 @@ static uma_zone_t fakepg_zone;
 static void vm_page_alloc_check(vm_page_t m);
 static void vm_page_clear_dirty_mask(vm_page_t m, vm_page_bits_t pagebits

);

 static void vm_page_enqueue(uint8_t queue, vm_page_t m);
-static void vm_page_free_phys(struct vm_domain *vmd, vm_page_t m);
 static void vm_page_init(void *dummy);
 static int vm_page_insert_after(vm_page_t m, vm_object_t object,
 vm_pindex_t pindex, vm_page_t mpred);
@@ -1677,10 +1676,10 @@ vm_page_alloc_after(vm_object_t object, vm_pindex_

t pi

  * for the request class and false otherwise.
  */
 int
-vm_domain_available(struct vm_domain *vmd, int req, int npages)
+vm_domain_allocate(struct vm_domain *vmd, int req, int npages)
 {
+   u_int limit, old, new;

-   vm_domain_free_assert_locked(vmd);
req = req & VM_ALLOC_CLASS_MASK;

/*
@@ -1688,15 +1687,34 @@ vm_domain_available(struct vm_domain *vmd, int req

, in

 */
if (curproc == pageproc && req != VM_ALLOC_INTERRUPT)
req = VM_ALLOC_SYSTEM;
+   if (req == VM_ALLOC_INTERRUPT)
+   limit = 0;
+   else if (req == VM_ALLOC_SYSTEM)
+   limit = vmd->vmd_interrupt_free_min;
+   else
+   limit = vmd->vmd_free_reserved;

-   if (vmd->vmd_free_count >= npages + vmd->vmd_free_reserved ||
-   (req == VM_ALLOC_SYSTEM &&
-   vmd->vmd_free_count >= npages + vmd->vmd_interrupt_free_min) |

|

-   (req == VM_ALLOC_INTERRUPT &&
-   vmd->vmd_free_count >= npages))
-   return (1);
+   /*
+* Attempt to reserve the pages.  Fail if we're below the limit.
+*/
+   limit += npages;
+   old = vmd->vmd_free_count;
+   do {
+   if (old < limit)
+   return (0);
+   new = old - npages;
+   } while (atomic_fcmpset_int(>vmd_free_count, , new) == 0)

;


-   return (0);
+   /* Wake the page daemon if we've crossed the threshold. */
+   if (vm_paging_needed(vmd, new) && !vm_paging_needed(vmd, old))
+   pagedaemon_wakeup(vmd->vmd_domain);
+
+   /* Only update bitsets on transitions. */
+   if ((old >= vmd->vmd_free_min && new < vmd->vmd_free_min) ||
+   (old >= vmd->vmd_free_severe && new < vmd->vmd_free_severe))
+   vm_domain_set(vmd);
+
+   return (1);
 }

 vm_page_t
@@ -1723,44 +1741,34 @@ vm_page_alloc_domain_after(vm_object_t object, vm_

pind

 again:
m = NULL;
 #if VM_NRESERVLEVEL > 0
+   /*
+* Can we allocate the page from a reservation?
+*/
if (vm_object_reserv(object) &&
-   (m = vm_reserv_extend(req, object, pindex, domain, mpred))
-   != NULL) {
+   ((m = vm_reserv_extend(req, object, pindex, domain, mpred)) !=

 NULL 

svn commit: r331403 - stable/11/sys/gnu/dts/arm

2018-03-22 Thread Oleksandr Tymoshenko
Author: gonzo
Date: Fri Mar 23 01:43:27 2018
New Revision: 331403
URL: https://svnweb.freebsd.org/changeset/base/331403

Log:
  Fix VERSATILEPB boot after r331402
  
  r331402 MFCed switch from custom DTS to upstream one. stable/11 version
  still has main bus compatibility as "arm,amba-bus" while in Linux and HEAD
  it has been changed to "simple-bus". simplebus(4) supports only the latter
  so VERSATILEPB boot was broken by r331402. To fix this make manual change
  to stable/11 version of versatile-ab.dts

Modified:
  stable/11/sys/gnu/dts/arm/versatile-ab.dts

Modified: stable/11/sys/gnu/dts/arm/versatile-ab.dts
==
--- stable/11/sys/gnu/dts/arm/versatile-ab.dts  Fri Mar 23 01:37:31 2018
(r331402)
+++ stable/11/sys/gnu/dts/arm/versatile-ab.dts  Fri Mar 23 01:43:27 2018
(r331403)
@@ -148,7 +148,7 @@
};
 
amba {
-   compatible = "arm,amba-bus";
+   compatible = "simple-bus";
#address-cells = <1>;
#size-cells = <1>;
ranges;
___
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: r331402 - in stable/11/sys/arm: conf versatile

2018-03-22 Thread Oleksandr Tymoshenko
Author: gonzo
Date: Fri Mar 23 01:37:31 2018
New Revision: 331402
URL: https://svnweb.freebsd.org/changeset/base/331402

Log:
  MFC r316370-r316371
  
  r316370:
  [versatilepb] Convert VERSATILEPB kernel to INTRNG and switch to upstream DTB
  
  Scope of this change is somewhat larger than just converting to INTRNG.
  The reason for this is that INTRNG support required switching from custom
  to upstream DTS because custom DTS didn't have interrup routing information.
  This switch caused rewrite of PCI and CLCD drivers and adding SCM module.
  List of changes in this commit:
  
  - Enable INTRNG and switch to versatile-pb.dts
  
  - Add SCM driver that controls various peripheral devices like LCD or
PCI controller. Previously registers required for power-up and
configuring peripherals were part of their respective nodes. Upstream
DTS has dedicated node for SCM
  
  - Convert PL190 driver to INTRNG
  
  - Convert Versatile SIC (secondary interrupt controller) to INTRNG
  
  - Refactor CLCD driver to use SCM API to power up and configuration
  
  - Refactor PCI driver to use SCM API to enable controller
  
  - Refactor PCI driver to use interrupt map provided in DTS for
interrupt routing. As a result it fixes broken IRQ routing and
it's no longer required to run QEMU with "-global 
versatile_pci.broken-irq-mapping=1"
command-line arguments
  
  r316371:
  [versatilepb] Fix keyboard driver after switching to upstream DTS
  
  FreeBSD's DTS contained only one PL050 node and driver considered it to
  be PS/2 keyboard. In reality PL050 is a PS/2 port that pushes bytes to/from
  the periphers connected to it. New DTS contains two nodes and QEMU emulates
  keyboard connected to port #0 and mouse connected to port #1. Since there
  is no way to say what's connected to port by checking DTS we hardcode
  this knowledge in the driver: it assumes keyboard on port #0 and ignores
  port #1 altogether.
  
  Also QEMU defaults emulated keyboard to scan code set 2 while driver used
  to work with scan code set 1 so when initializing driver make sure keyboard
  is switched to scan code set 1

Added:
  stable/11/sys/arm/versatile/versatile_scm.c
 - copied unchanged from r316371, head/sys/arm/versatile/versatile_scm.c
  stable/11/sys/arm/versatile/versatile_scm.h
 - copied unchanged from r316371, head/sys/arm/versatile/versatile_scm.h
Modified:
  stable/11/sys/arm/conf/VERSATILEPB
  stable/11/sys/arm/versatile/files.versatile
  stable/11/sys/arm/versatile/pl050.c
  stable/11/sys/arm/versatile/versatile_clcd.c
  stable/11/sys/arm/versatile/versatile_pci.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/arm/conf/VERSATILEPB
==
--- stable/11/sys/arm/conf/VERSATILEPB  Fri Mar 23 00:40:08 2018
(r331401)
+++ stable/11/sys/arm/conf/VERSATILEPB  Fri Mar 23 01:37:31 2018
(r331402)
@@ -68,7 +68,9 @@ makeoptions   SC_DFLT_FONT=cp437
 device md
 device random  # Entropy device
 
+optionsINTRNG
+
 # Flattened Device Tree
 optionsFDT # Configure using FDT/DTB data
 optionsFDT_DTB_STATIC
-makeoptionsFDT_DTS_FILE=versatilepb.dts
+makeoptionsFDT_DTS_FILE=versatile-pb.dts

Modified: stable/11/sys/arm/versatile/files.versatile
==
--- stable/11/sys/arm/versatile/files.versatile Fri Mar 23 00:40:08 2018
(r331401)
+++ stable/11/sys/arm/versatile/files.versatile Fri Mar 23 01:37:31 2018
(r331402)
@@ -6,6 +6,7 @@ arm/versatile/versatile_machdep.c   standard
 arm/versatile/versatile_clcd.c optional sc
 arm/versatile/versatile_common.c   standard
 arm/versatile/versatile_pci.c  optional pci
+arm/versatile/versatile_scm.c  standard
 arm/versatile/versatile_sic.c  standard
 arm/versatile/versatile_timer.cstandard
 

Modified: stable/11/sys/arm/versatile/pl050.c
==
--- stable/11/sys/arm/versatile/pl050.c Fri Mar 23 00:40:08 2018
(r331401)
+++ stable/11/sys/arm/versatile/pl050.c Fri Mar 23 01:37:31 2018
(r331402)
@@ -109,7 +109,10 @@ __FBSDID("$FreeBSD$");
 #defineKMI_DRIVER_NAME  "kmi"
 #defineKMI_NFKEY(sizeof(fkey_tab)/sizeof(fkey_tab[0])) /* 
units */
 
+#defineSET_SCANCODE_SET0xf0
+
 struct kmi_softc {
+   device_t sc_dev;
keyboard_t sc_kbd;
keymap_t sc_keymap;
accentmap_t sc_accmap;
@@ -145,6 +148,8 @@ static int  kmi_ioctl(keyboard_t *, u_long, caddr_t);
 static int kmi_enable(keyboard_t *);
 static int kmi_disable(keyboard_t *);
 
+static int kmi_attached = 0;
+
 /* early keyboard probe, not supported */
 static int
 kmi_configure(int 

Re: svn commit: r331369 - head/sys/vm

2018-03-22 Thread Jeff Roberson

On Thu, 22 Mar 2018, Cy Schubert wrote:


It broke i386 too.


I just did
TARGET_ARCH=i386 make buildworld
TARGET_ARCH=i386 make buildkernel

This worked for me?

Jeff



Index: sys/vm/vm_reserv.c
===
--- sys/vm/vm_reserv.c  (revision 331399)
+++ sys/vm/vm_reserv.c  (working copy)
@@ -45,8 +45,6 @@

#include 
#include 
-#include 
-#include 
#include 
#include 
#include 
@@ -55,6 +53,8 @@
#include 
#include 
#include 
+#include 
+#include 
#include 
#include 

This is because sys/i386/include/machine.h uses critical_enter() and
critical_exit() which are defined in sys/systm.h.

It built nicely on my amd64's though.

~cy

In message , Jeff Roberson
writes:

Thank you, working on it.  I had done a make universe before getting
review feedback.

Jeff

On Thu, 22 Mar 2018, Justin Hibbits wrote:


This broke gcc builds.

On Thu, Mar 22, 2018 at 2:21 PM, Jeff Roberson  wrote:

Author: jeff
Date: Thu Mar 22 19:21:11 2018
New Revision: 331369
URL: https://svnweb.freebsd.org/changeset/base/331369

Log:
  Lock reservations with a dedicated lock in each reservation.  Protect th

e

  vmd_free_count with atomics.

  This allows us to allocate and free from reservations without the free l

ock

  except where a superpage is allocated from the physical layer, which is
  roughly 1/512 of the operations on amd64.

  Use the counter api to eliminate cache conention on counters.

  Reviewed by:  markj
  Tested by:pho
  Sponsored by: Netflix, Dell/EMC Isilon
  Differential Revision:https://reviews.freebsd.org/D14707

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

Modified: head/sys/vm/vm_page.c
==



--- head/sys/vm/vm_page.c   Thu Mar 22 19:11:43 2018(r331368)
+++ head/sys/vm/vm_page.c   Thu Mar 22 19:21:11 2018(r331369)
@@ -177,7 +177,6 @@ static uma_zone_t fakepg_zone;
 static void vm_page_alloc_check(vm_page_t m);
 static void vm_page_clear_dirty_mask(vm_page_t m, vm_page_bits_t pagebits

);

 static void vm_page_enqueue(uint8_t queue, vm_page_t m);
-static void vm_page_free_phys(struct vm_domain *vmd, vm_page_t m);
 static void vm_page_init(void *dummy);
 static int vm_page_insert_after(vm_page_t m, vm_object_t object,
 vm_pindex_t pindex, vm_page_t mpred);
@@ -1677,10 +1676,10 @@ vm_page_alloc_after(vm_object_t object, vm_pindex_

t pi

  * for the request class and false otherwise.
  */
 int
-vm_domain_available(struct vm_domain *vmd, int req, int npages)
+vm_domain_allocate(struct vm_domain *vmd, int req, int npages)
 {
+   u_int limit, old, new;

-   vm_domain_free_assert_locked(vmd);
req = req & VM_ALLOC_CLASS_MASK;

/*
@@ -1688,15 +1687,34 @@ vm_domain_available(struct vm_domain *vmd, int req

, in

 */
if (curproc == pageproc && req != VM_ALLOC_INTERRUPT)
req = VM_ALLOC_SYSTEM;
+   if (req == VM_ALLOC_INTERRUPT)
+   limit = 0;
+   else if (req == VM_ALLOC_SYSTEM)
+   limit = vmd->vmd_interrupt_free_min;
+   else
+   limit = vmd->vmd_free_reserved;

-   if (vmd->vmd_free_count >= npages + vmd->vmd_free_reserved ||
-   (req == VM_ALLOC_SYSTEM &&
-   vmd->vmd_free_count >= npages + vmd->vmd_interrupt_free_min) |

|

-   (req == VM_ALLOC_INTERRUPT &&
-   vmd->vmd_free_count >= npages))
-   return (1);
+   /*
+* Attempt to reserve the pages.  Fail if we're below the limit.
+*/
+   limit += npages;
+   old = vmd->vmd_free_count;
+   do {
+   if (old < limit)
+   return (0);
+   new = old - npages;
+   } while (atomic_fcmpset_int(>vmd_free_count, , new) == 0)

;


-   return (0);
+   /* Wake the page daemon if we've crossed the threshold. */
+   if (vm_paging_needed(vmd, new) && !vm_paging_needed(vmd, old))
+   pagedaemon_wakeup(vmd->vmd_domain);
+
+   /* Only update bitsets on transitions. */
+   if ((old >= vmd->vmd_free_min && new < vmd->vmd_free_min) ||
+   (old >= vmd->vmd_free_severe && new < vmd->vmd_free_severe))
+   vm_domain_set(vmd);
+
+   return (1);
 }

 vm_page_t
@@ -1723,44 +1741,34 @@ vm_page_alloc_domain_after(vm_object_t object, vm_

pind

 again:
m = NULL;
 #if VM_NRESERVLEVEL > 0
+   /*
+* Can we allocate the page from a reservation?
+*/
if (vm_object_reserv(object) &&
-   (m = vm_reserv_extend(req, object, pindex, domain, mpred))
-   != NULL) {
+   ((m = vm_reserv_extend(req, object, pindex, domain, mpred)) !=

 NULL ||

+   (m = vm_reserv_alloc_page(req, object, pindex, domain, mpred))

 != NULL)) {

domain = vm_phys_domain(m);
 

Re: svn commit: r331369 - head/sys/vm

2018-03-22 Thread Cy Schubert
It broke i386 too.

Index: sys/vm/vm_reserv.c
===
--- sys/vm/vm_reserv.c  (revision 331399)
+++ sys/vm/vm_reserv.c  (working copy)
@@ -45,8 +45,6 @@
 
 #include 
 #include 
-#include 
-#include 
 #include 
 #include 
 #include 
@@ -55,6 +53,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 #include 
 #include 
 
This is because sys/i386/include/machine.h uses critical_enter() and 
critical_exit() which are defined in sys/systm.h.

It built nicely on my amd64's though.

~cy

In message , Jeff Roberson 
writes:
> Thank you, working on it.  I had done a make universe before getting 
> review feedback.
>
> Jeff
>
> On Thu, 22 Mar 2018, Justin Hibbits wrote:
>
> > This broke gcc builds.
> >
> > On Thu, Mar 22, 2018 at 2:21 PM, Jeff Roberson  wrote:
> >> Author: jeff
> >> Date: Thu Mar 22 19:21:11 2018
> >> New Revision: 331369
> >> URL: https://svnweb.freebsd.org/changeset/base/331369
> >>
> >> Log:
> >>   Lock reservations with a dedicated lock in each reservation.  Protect th
> e
> >>   vmd_free_count with atomics.
> >>
> >>   This allows us to allocate and free from reservations without the free l
> ock
> >>   except where a superpage is allocated from the physical layer, which is
> >>   roughly 1/512 of the operations on amd64.
> >>
> >>   Use the counter api to eliminate cache conention on counters.
> >>
> >>   Reviewed by:  markj
> >>   Tested by:pho
> >>   Sponsored by: Netflix, Dell/EMC Isilon
> >>   Differential Revision:https://reviews.freebsd.org/D14707
> >>
> >> Modified:
> >>   head/sys/vm/vm_page.c
> >>   head/sys/vm/vm_pagequeue.h
> >>   head/sys/vm/vm_reserv.c
> >>   head/sys/vm/vm_reserv.h
> >>
> >> Modified: head/sys/vm/vm_page.c
> >> ==
> 
> >> --- head/sys/vm/vm_page.c   Thu Mar 22 19:11:43 2018(r331368)
> >> +++ head/sys/vm/vm_page.c   Thu Mar 22 19:21:11 2018(r331369)
> >> @@ -177,7 +177,6 @@ static uma_zone_t fakepg_zone;
> >>  static void vm_page_alloc_check(vm_page_t m);
> >>  static void vm_page_clear_dirty_mask(vm_page_t m, vm_page_bits_t pagebits
> );
> >>  static void vm_page_enqueue(uint8_t queue, vm_page_t m);
> >> -static void vm_page_free_phys(struct vm_domain *vmd, vm_page_t m);
> >>  static void vm_page_init(void *dummy);
> >>  static int vm_page_insert_after(vm_page_t m, vm_object_t object,
> >>  vm_pindex_t pindex, vm_page_t mpred);
> >> @@ -1677,10 +1676,10 @@ vm_page_alloc_after(vm_object_t object, vm_pindex_
> t pi
> >>   * for the request class and false otherwise.
> >>   */
> >>  int
> >> -vm_domain_available(struct vm_domain *vmd, int req, int npages)
> >> +vm_domain_allocate(struct vm_domain *vmd, int req, int npages)
> >>  {
> >> +   u_int limit, old, new;
> >>
> >> -   vm_domain_free_assert_locked(vmd);
> >> req = req & VM_ALLOC_CLASS_MASK;
> >>
> >> /*
> >> @@ -1688,15 +1687,34 @@ vm_domain_available(struct vm_domain *vmd, int req
> , in
> >>  */
> >> if (curproc == pageproc && req != VM_ALLOC_INTERRUPT)
> >> req = VM_ALLOC_SYSTEM;
> >> +   if (req == VM_ALLOC_INTERRUPT)
> >> +   limit = 0;
> >> +   else if (req == VM_ALLOC_SYSTEM)
> >> +   limit = vmd->vmd_interrupt_free_min;
> >> +   else
> >> +   limit = vmd->vmd_free_reserved;
> >>
> >> -   if (vmd->vmd_free_count >= npages + vmd->vmd_free_reserved ||
> >> -   (req == VM_ALLOC_SYSTEM &&
> >> -   vmd->vmd_free_count >= npages + vmd->vmd_interrupt_free_min) |
> |
> >> -   (req == VM_ALLOC_INTERRUPT &&
> >> -   vmd->vmd_free_count >= npages))
> >> -   return (1);
> >> +   /*
> >> +* Attempt to reserve the pages.  Fail if we're below the limit.
> >> +*/
> >> +   limit += npages;
> >> +   old = vmd->vmd_free_count;
> >> +   do {
> >> +   if (old < limit)
> >> +   return (0);
> >> +   new = old - npages;
> >> +   } while (atomic_fcmpset_int(>vmd_free_count, , new) == 0)
> ;
> >>
> >> -   return (0);
> >> +   /* Wake the page daemon if we've crossed the threshold. */
> >> +   if (vm_paging_needed(vmd, new) && !vm_paging_needed(vmd, old))
> >> +   pagedaemon_wakeup(vmd->vmd_domain);
> >> +
> >> +   /* Only update bitsets on transitions. */
> >> +   if ((old >= vmd->vmd_free_min && new < vmd->vmd_free_min) ||
> >> +   (old >= vmd->vmd_free_severe && new < vmd->vmd_free_severe))
> >> +   vm_domain_set(vmd);
> >> +
> >> +   return (1);
> >>  }
> >>
> >>  vm_page_t
> >> @@ -1723,44 +1741,34 @@ vm_page_alloc_domain_after(vm_object_t object, vm_
> pind
> >>  again:
> >> m = NULL;
> >>  #if VM_NRESERVLEVEL > 0
> >> +   /*
> >> +* Can we allocate the page from a reservation?

Re: svn commit: r331369 - head/sys/vm

2018-03-22 Thread Jeff Roberson
Thank you, working on it.  I had done a make universe before getting 
review feedback.


Jeff

On Thu, 22 Mar 2018, Justin Hibbits wrote:


This broke gcc builds.

On Thu, Mar 22, 2018 at 2:21 PM, Jeff Roberson  wrote:

Author: jeff
Date: Thu Mar 22 19:21:11 2018
New Revision: 331369
URL: https://svnweb.freebsd.org/changeset/base/331369

Log:
  Lock reservations with a dedicated lock in each reservation.  Protect the
  vmd_free_count with atomics.

  This allows us to allocate and free from reservations without the free lock
  except where a superpage is allocated from the physical layer, which is
  roughly 1/512 of the operations on amd64.

  Use the counter api to eliminate cache conention on counters.

  Reviewed by:  markj
  Tested by:pho
  Sponsored by: Netflix, Dell/EMC Isilon
  Differential Revision:https://reviews.freebsd.org/D14707

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

Modified: head/sys/vm/vm_page.c
==
--- head/sys/vm/vm_page.c   Thu Mar 22 19:11:43 2018(r331368)
+++ head/sys/vm/vm_page.c   Thu Mar 22 19:21:11 2018(r331369)
@@ -177,7 +177,6 @@ static uma_zone_t fakepg_zone;
 static void vm_page_alloc_check(vm_page_t m);
 static void vm_page_clear_dirty_mask(vm_page_t m, vm_page_bits_t pagebits);
 static void vm_page_enqueue(uint8_t queue, vm_page_t m);
-static void vm_page_free_phys(struct vm_domain *vmd, vm_page_t m);
 static void vm_page_init(void *dummy);
 static int vm_page_insert_after(vm_page_t m, vm_object_t object,
 vm_pindex_t pindex, vm_page_t mpred);
@@ -1677,10 +1676,10 @@ vm_page_alloc_after(vm_object_t object, vm_pindex_t pi
  * for the request class and false otherwise.
  */
 int
-vm_domain_available(struct vm_domain *vmd, int req, int npages)
+vm_domain_allocate(struct vm_domain *vmd, int req, int npages)
 {
+   u_int limit, old, new;

-   vm_domain_free_assert_locked(vmd);
req = req & VM_ALLOC_CLASS_MASK;

/*
@@ -1688,15 +1687,34 @@ vm_domain_available(struct vm_domain *vmd, int req, in
 */
if (curproc == pageproc && req != VM_ALLOC_INTERRUPT)
req = VM_ALLOC_SYSTEM;
+   if (req == VM_ALLOC_INTERRUPT)
+   limit = 0;
+   else if (req == VM_ALLOC_SYSTEM)
+   limit = vmd->vmd_interrupt_free_min;
+   else
+   limit = vmd->vmd_free_reserved;

-   if (vmd->vmd_free_count >= npages + vmd->vmd_free_reserved ||
-   (req == VM_ALLOC_SYSTEM &&
-   vmd->vmd_free_count >= npages + vmd->vmd_interrupt_free_min) ||
-   (req == VM_ALLOC_INTERRUPT &&
-   vmd->vmd_free_count >= npages))
-   return (1);
+   /*
+* Attempt to reserve the pages.  Fail if we're below the limit.
+*/
+   limit += npages;
+   old = vmd->vmd_free_count;
+   do {
+   if (old < limit)
+   return (0);
+   new = old - npages;
+   } while (atomic_fcmpset_int(>vmd_free_count, , new) == 0);

-   return (0);
+   /* Wake the page daemon if we've crossed the threshold. */
+   if (vm_paging_needed(vmd, new) && !vm_paging_needed(vmd, old))
+   pagedaemon_wakeup(vmd->vmd_domain);
+
+   /* Only update bitsets on transitions. */
+   if ((old >= vmd->vmd_free_min && new < vmd->vmd_free_min) ||
+   (old >= vmd->vmd_free_severe && new < vmd->vmd_free_severe))
+   vm_domain_set(vmd);
+
+   return (1);
 }

 vm_page_t
@@ -1723,44 +1741,34 @@ vm_page_alloc_domain_after(vm_object_t object, vm_pind
 again:
m = NULL;
 #if VM_NRESERVLEVEL > 0
+   /*
+* Can we allocate the page from a reservation?
+*/
if (vm_object_reserv(object) &&
-   (m = vm_reserv_extend(req, object, pindex, domain, mpred))
-   != NULL) {
+   ((m = vm_reserv_extend(req, object, pindex, domain, mpred)) != NULL 
||
+   (m = vm_reserv_alloc_page(req, object, pindex, domain, mpred)) != 
NULL)) {
domain = vm_phys_domain(m);
vmd = VM_DOMAIN(domain);
goto found;
}
 #endif
vmd = VM_DOMAIN(domain);
-   vm_domain_free_lock(vmd);
-   if (vm_domain_available(vmd, req, 1)) {
+   if (vm_domain_allocate(vmd, req, 1)) {
/*
-* Can we allocate the page from a reservation?
+* If not, allocate it from the free page queues.
 */
+   vm_domain_free_lock(vmd);
+   m = vm_phys_alloc_pages(domain, object != NULL ?
+   VM_FREEPOOL_DEFAULT : VM_FREEPOOL_DIRECT, 0);
+   vm_domain_free_unlock(vmd);
+   if (m == NULL) {
+   vm_domain_freecnt_inc(vmd, 1);
 #if VM_NRESERVLEVEL > 0
-   if (!vm_object_reserv(object) ||
- 

svn commit: r331401 - head/sys/powerpc/powerpc

2018-03-22 Thread Justin Hibbits
Author: jhibbits
Date: Fri Mar 23 00:40:08 2018
New Revision: 331401
URL: https://svnweb.freebsd.org/changeset/base/331401

Log:
  Debug interrupts aren't instruction traps
  
  The EXC_DEBUG type is akin to the MPC74xx "Instruction Breakpoint" trap.
  Don't treat it as a trap instruction.

Modified:
  head/sys/powerpc/powerpc/trap.c

Modified: head/sys/powerpc/powerpc/trap.c
==
--- head/sys/powerpc/powerpc/trap.c Fri Mar 23 00:20:42 2018
(r331400)
+++ head/sys/powerpc/powerpc/trap.c Fri Mar 23 00:40:08 2018
(r331401)
@@ -189,7 +189,7 @@ frame_is_trap_inst(struct trapframe *frame)
 #ifdef AIM
return (frame->exc == EXC_PGM && frame->srr1 & EXC_PGM_TRAP);
 #else
-   return (frame->exc == EXC_DEBUG || frame->cpu.booke.esr & ESR_PTR);
+   return ((frame->cpu.booke.esr & ESR_PTR) != 0);
 #endif
 }
 
@@ -895,6 +895,7 @@ db_trap_glue(struct trapframe *frame)
&& (frame->exc == EXC_TRC || frame->exc == EXC_RUNMODETRC
|| frame_is_trap_inst(frame)
|| frame->exc == EXC_BPT
+   || frame->exc == EXC_DEBUG
|| frame->exc == EXC_DSI)) {
int type = frame->exc;
 
___
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: r331400 - in vendor-sys/illumos/dist/uts/common: . fs/zfs fs/zfs/sys

2018-03-22 Thread Alexander Motin
Author: mav
Date: Fri Mar 23 00:20:42 2018
New Revision: 331400
URL: https://svnweb.freebsd.org/changeset/base/331400

Log:
  8484 Implement aggregate sum and use for arc counters
  
  In pursuit of improving performance on multi-core systems, we should
  implements fanned out counters and use them to improve the performance of
  some of the arc statistics. These stats are updated extremely frequently,
  and can consume a significant amount of CPU time.
  
  Reviewed by: Pavel Zakharov 
  Reviewed by: Matthew Ahrens 
  Approved by: Dan McDonald 
  Author: Paul Dagnelie 

Added:
  vendor-sys/illumos/dist/uts/common/fs/zfs/THIRDPARTYLICENSE.cityhash   
(contents, props changed)
  vendor-sys/illumos/dist/uts/common/fs/zfs/THIRDPARTYLICENSE.cityhash.descrip  
 (contents, props changed)
  vendor-sys/illumos/dist/uts/common/fs/zfs/aggsum.c   (contents, props changed)
  vendor-sys/illumos/dist/uts/common/fs/zfs/cityhash.c   (contents, props 
changed)
  vendor-sys/illumos/dist/uts/common/fs/zfs/sys/aggsum.h   (contents, props 
changed)
  vendor-sys/illumos/dist/uts/common/fs/zfs/sys/cityhash.h   (contents, props 
changed)
Modified:
  vendor-sys/illumos/dist/uts/common/Makefile.files
  vendor-sys/illumos/dist/uts/common/fs/zfs/arc.c
  vendor-sys/illumos/dist/uts/common/fs/zfs/dbuf.c

Modified: vendor-sys/illumos/dist/uts/common/Makefile.files
==
--- vendor-sys/illumos/dist/uts/common/Makefile.files   Thu Mar 22 23:58:05 
2018(r331399)
+++ vendor-sys/illumos/dist/uts/common/Makefile.files   Fri Mar 23 00:20:42 
2018(r331400)
@@ -1339,12 +1339,14 @@ LUA_OBJS += \
 
 ZFS_COMMON_OBJS += \
abd.o   \
+   aggsum.o\
arc.o   \
blkptr.o\
bplist.o\
bpobj.o \
bptree.o\
bqueue.o\
+   cityhash.o  \
dbuf.o  \
ddt.o   \
ddt_zap.o   \

Added: vendor-sys/illumos/dist/uts/common/fs/zfs/THIRDPARTYLICENSE.cityhash
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ vendor-sys/illumos/dist/uts/common/fs/zfs/THIRDPARTYLICENSE.cityhash
Fri Mar 23 00:20:42 2018(r331400)
@@ -0,0 +1,19 @@
+Copyright (c) 2011 Google, Inc.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.

Added: 
vendor-sys/illumos/dist/uts/common/fs/zfs/THIRDPARTYLICENSE.cityhash.descrip
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ 
vendor-sys/illumos/dist/uts/common/fs/zfs/THIRDPARTYLICENSE.cityhash.descrip
Fri Mar 23 00:20:42 2018(r331400)
@@ -0,0 +1 @@
+CITYHASH CHECKSUM FUNCTIONALITY IN ZFS

Added: vendor-sys/illumos/dist/uts/common/fs/zfs/aggsum.c
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ vendor-sys/illumos/dist/uts/common/fs/zfs/aggsum.c  Fri Mar 23 00:20:42 
2018(r331400)
@@ -0,0 +1,232 @@
+/*
+ * CDDL HEADER START
+ *
+ * This file and its contents are supplied under the terms of the
+ * Common Development and Distribution License ("CDDL"), version 1.0.
+ * You may only use this file in accordance with the terms of version
+ * 1.0 of the CDDL.
+ *
+ * A full copy of the text of the CDDL should have accompanied this
+ * source.  A copy of the CDDL is also available via the Internet at
+ * http://www.illumos.org/license/CDDL.
+ *
+ * CDDL HEADER END
+ */
+/*
+ * Copyright (c) 2017 by Delphix. All rights reserved.
+ */
+
+#include 
+#include 
+
+/*
+ * Aggregate-sum 

svn commit: r331399 - in stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs: . sys

2018-03-22 Thread Alexander Motin
Author: mav
Date: Thu Mar 22 23:58:05 2018
New Revision: 331399
URL: https://svnweb.freebsd.org/changeset/base/331399

Log:
  MFC r329694: MFV r324198: 8081 Compiler warnings in zdb
  
  illumos/illumos-gate@3f7978d02b206a6ebc5652c91aa9f42da6fbe00c
  
https://github.com/illumos/illumos-gate/commit/3f7978d02b206a6ebc5652c91aa9f42da6fbe00c
  
  https://www.illumos.org/issues/8081
zdb(8) is full of minor problems that generate compiler warnings. On 
FreeBSD,
which uses -WError, the only way to build it is to disable all compiler
warnings. This makes it much harder to detect newly introduced bugs. We 
should
cleanup all the warnings.
  
  Reviewed by: Matthew Ahrens 
  Reviewed by: Prakash Surya 
  Approved by: Richard Lowe 
  Author: Alan Somers 

Modified:
  stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c
  stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dbuf.c
  stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c
  stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/refcount.h
  stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/sa.h
  stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/spa.h
  stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zil.h
  stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_replay.c
  stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zvol.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c
==
--- stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c  Thu Mar 
22 23:56:53 2018(r331398)
+++ stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c  Thu Mar 
22 23:58:05 2018(r331399)
@@ -4458,8 +4458,9 @@ arc_kmem_reap_now(void)
  * This possible deadlock is avoided by always acquiring a hash lock
  * using mutex_tryenter() from arc_reclaim_thread().
  */
+/* ARGSUSED */
 static void
-arc_reclaim_thread(void *dummy __unused)
+arc_reclaim_thread(void *unused __unused)
 {
hrtime_tgrowtime = 0;
callb_cpr_t cpr;
@@ -7596,8 +7597,9 @@ l2arc_write_buffers(spa_t *spa, l2arc_dev_t *dev, uint
  * This thread feeds the L2ARC at regular intervals.  This is the beating
  * heart of the L2ARC.
  */
+/* ARGSUSED */
 static void
-l2arc_feed_thread(void *dummy __unused)
+l2arc_feed_thread(void *unused __unused)
 {
callb_cpr_t cpr;
l2arc_dev_t *dev;

Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dbuf.c
==
--- stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dbuf.c Thu Mar 
22 23:56:53 2018(r331398)
+++ stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dbuf.c Thu Mar 
22 23:58:05 2018(r331399)
@@ -505,8 +505,9 @@ dbuf_evict_one(void)
  * of the dbuf cache is at or below the maximum size. Once the dbuf is aged
  * out of the cache it is destroyed and becomes eligible for arc eviction.
  */
+/* ARGSUSED */
 static void
-dbuf_evict_thread(void *dummy __unused)
+dbuf_evict_thread(void *unused __unused)
 {
callb_cpr_t cpr;
 

Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c
==
--- stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c  Thu Mar 
22 23:56:53 2018(r331398)
+++ stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c  Thu Mar 
22 23:58:05 2018(r331399)
@@ -6180,7 +6180,7 @@ spa_async_autoexpand(spa_t *spa, vdev_t *vd)
 static void
 spa_async_thread(void *arg)
 {
-   spa_t *spa = arg;
+   spa_t *spa = (spa_t *)arg;
int tasks;
 
ASSERT(spa->spa_sync_on);

Modified: 
stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/refcount.h
==
--- stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/refcount.h 
Thu Mar 22 23:56:53 2018(r331398)
+++ stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/refcount.h 
Thu Mar 22 23:58:05 2018(r331399)
@@ -41,7 +41,7 @@ extern "C" {
  * particular object, use FTAG (which is a string) for the holder_tag.
  * Otherwise, use the object that holds the reference.
  */
-#defineFTAG ((char *)__func__)
+#defineFTAG ((char *)(uintptr_t)__func__)
 
 #ifdef ZFS_DEBUG
 typedef struct reference {

Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/sa.h
==
--- stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/sa.h   Thu Mar 
22 23:56:53 2018(r331398)
+++ 

svn commit: r331398 - stable/11/cddl/contrib/opensolaris/lib/libzfs/common

2018-03-22 Thread Alexander Motin
Author: mav
Date: Thu Mar 22 23:56:53 2018
New Revision: 331398
URL: https://svnweb.freebsd.org/changeset/base/331398

Log:
  MFC r329691: MFV r322231:
  8430 dir_is_empty_readdir() doesn't properly handle error from fdopendir()
  
  illumos/illumos-gate@ba6e7e6505150388de6dc6a88741164118a421bf
  
https://github.com/illumos/illumos-gate/commit/ba6e7e6505150388de6dc6a88741164118a421bf
  
  https://www.illumos.org/issues/8430
we should close dirfd if fdopendir() fails.
  
  Reviewed by: Serapheim Dimitropoulos 
  Reviewed by: Matthew Ahrens 
  Reviewed by: Dan Kimmel 
  Reviewed by: Yuri Pankov 
  Reviewed by: Igor Kozhukhov 
  Approved by: Robert Mustacchi 
  Author: Sowrabha Gopal 

Modified:
  stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_mount.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_mount.c
==
--- stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_mount.c Thu Mar 
22 23:56:17 2018(r331397)
+++ stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_mount.c Thu Mar 
22 23:56:53 2018(r331398)
@@ -216,6 +216,7 @@ dir_is_empty_readdir(const char *dirname)
}
 
if ((dirp = fdopendir(dirfd)) == NULL) {
+   (void) close(dirfd);
return (B_TRUE);
}
 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r331397 - in stable/11/sys/cddl/contrib/opensolaris/uts/common: fs/zfs fs/zfs/sys sys/fs sys/sysevent

2018-03-22 Thread Alexander Motin
Author: mav
Date: Thu Mar 22 23:56:17 2018
New Revision: 331397
URL: https://svnweb.freebsd.org/changeset/base/331397

Log:
  MFC r329690: MFV r319737: 6939 add sysevents to zfs core for commands
  
  illumos/illumos-gate@ce1577b04976f1d8bb5f235b6eaaab15b46a3068
  
https://github.com/illumos/illumos-gate/commit/ce1577b04976f1d8bb5f235b6eaaab15b46a3068
  
  https://www.illumos.org/issues/6939
Originally created https://smartos.org/bugview/OS-4489
 sysevents should be fired in the kernel from ZFS whenever a command
 is run that is logged in zpool history.
Example output
Terminal 1
root - gz sunos ~ # zfs create zones/foobar
root - gz sunos ~ # zfs set quota=10g zones/foobar
root - gz sunos ~ # zfs destroy zones/foobar
Terminal 2
root - gz sunos ~ # sysevent EC_zfs
nvlist version: 0
date = 2016-04-28T14:50:08.964Z
vendor = SUNW
publisher = zfs
class = EC_zfs
subclass = ESC_ZFS_history_event
pid = 0
data = (embedded nvlist)
nvlist version: 0
pool_name = zones
pool_guid = 0x40c964e8f9a7a694
history_record = (embedded nvlist)
nvlist version: 0
dsname = zones/foobar
dsid = 0x1525
history internal str =
internal_name = create
history txg = 0x4c4ef3
  
  Reviewed by: Patrick Mooney 
  Reviewed by: Joshua M. Clulow 
  Reviewed by: Josh Wilsdon 
  Reviewed by: Matthew Ahrens 
  Reviewed by: George Wilson 
  Reviewed by: Richard Elling 
  Reviewed by: Alan Somers 
  Reviewed by: Andrew Stormont 
  Approved by: Matthew Ahrens 
  Author: Dave Eddy 

Modified:
  stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_scan.c
  stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c
  stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_config.c
  stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa_history.c
  stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/spa.h
  stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev.c
  stable/11/sys/cddl/contrib/opensolaris/uts/common/sys/fs/zfs.h
  stable/11/sys/cddl/contrib/opensolaris/uts/common/sys/sysevent/eventdefs.h
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_scan.c
==
--- stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_scan.c Thu Mar 
22 23:55:00 2018(r331396)
+++ stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_scan.c Thu Mar 
22 23:56:17 2018(r331397)
@@ -22,6 +22,7 @@
  * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
  * Copyright 2016 Gary Mills
  * Copyright (c) 2011, 2016 by Delphix. All rights reserved.
+ * Copyright 2017 Joyent, Inc.
  * Copyright (c) 2017 Datto Inc.
  */
 
@@ -242,9 +243,10 @@ dsl_scan_setup_sync(void *arg, dmu_tx_t *tx)
 
if (vdev_resilver_needed(spa->spa_root_vdev,
>scn_phys.scn_min_txg, >scn_phys.scn_max_txg)) {
-   spa_event_notify(spa, NULL, ESC_ZFS_RESILVER_START);
+   spa_event_notify(spa, NULL, NULL,
+   ESC_ZFS_RESILVER_START);
} else {
-   spa_event_notify(spa, NULL, ESC_ZFS_SCRUB_START);
+   spa_event_notify(spa, NULL, NULL, ESC_ZFS_SCRUB_START);
}
 
spa->spa_scrub_started = B_TRUE;
@@ -353,7 +355,8 @@ dsl_scan_done(dsl_scan_t *scn, boolean_t complete, dmu
vdev_dtl_reassess(spa->spa_root_vdev, tx->tx_txg,
complete ? scn->scn_phys.scn_max_txg : 0, B_TRUE);
if (complete) {
-   spa_event_notify(spa, NULL, scn->scn_phys.scn_min_txg ?
+   spa_event_notify(spa, NULL, NULL,
+   scn->scn_phys.scn_min_txg ?
ESC_ZFS_RESILVER_FINISH : ESC_ZFS_SCRUB_FINISH);
}
spa_errlog_rotate(spa);
@@ -387,7 +390,7 @@ dsl_scan_cancel_sync(void *arg, dmu_tx_t *tx)
 
dsl_scan_done(scn, B_FALSE, tx);
dsl_scan_sync_state(scn, tx);
-   spa_event_notify(scn->scn_dp->dp_spa, NULL, ESC_ZFS_SCRUB_ABORT);
+   spa_event_notify(scn->scn_dp->dp_spa, NULL, NULL, ESC_ZFS_SCRUB_ABORT);
 }
 
 int
@@ -442,7 +445,7 @@ dsl_scrub_pause_resume_sync(void *arg, dmu_tx_t *tx)
spa->spa_scan_pass_scrub_pause = gethrestime_sec();
scn->scn_phys.scn_flags |= DSF_SCRUB_PAUSED;
dsl_scan_sync_state(scn, tx);
-   

svn commit: r331396 - stable/11/sys/cddl/contrib/opensolaris/uts/common/sys/sysevent

2018-03-22 Thread Alexander Motin
Author: mav
Date: Thu Mar 22 23:55:00 2018
New Revision: 331396
URL: https://svnweb.freebsd.org/changeset/base/331396

Log:
  MFC r329683: MFV r319736: 6396 remove SVM
  
  illumos/illumos-gate@5f10ef697f250374b7b917e10961c4e02d4e3112
  
https://github.com/illumos/illumos-gate/commit/5f10ef697f250374b7b917e10961c4e02d4e3112
  
  https://www.illumos.org/issues/6396
LVM = SVM = Solaris Volume Manager
dead code and not using with ZFS based platform.
  
  Reviewed by: Igor Kozhukhov 
  Reviewed by: Toomas Soome 
  Approved by: Hans Rosenfeld 
  Author: Yuri Pankov 

Modified:
  stable/11/sys/cddl/contrib/opensolaris/uts/common/sys/sysevent/eventdefs.h
Directory Properties:
  stable/11/   (props changed)

Modified: 
stable/11/sys/cddl/contrib/opensolaris/uts/common/sys/sysevent/eventdefs.h
==
--- stable/11/sys/cddl/contrib/opensolaris/uts/common/sys/sysevent/eventdefs.h  
Thu Mar 22 23:54:14 2018(r331395)
+++ stable/11/sys/cddl/contrib/opensolaris/uts/common/sys/sysevent/eventdefs.h  
Thu Mar 22 23:55:00 2018(r331396)
@@ -18,9 +18,10 @@
  *
  * CDDL HEADER END
  */
+
 /*
  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright 2015 Nexenta Systems, Inc.  All rights reserved.
+ * Copyright 2016 Nexenta Systems, Inc.
  */
 
 #ifndef_SYS_SYSEVENT_EVENTDEFS_H
@@ -59,67 +60,6 @@ extern "C" {
  * by Sun Cluster software.
  */
 #defineEC_CLUSTER  "EC_Cluster"
-
-/*
- * The following classes are exclusively reserved for use by the
- * Solaris Volume Manager (SVM)
- */
-#defineEC_SVM_CONFIG   "EC_SVM_Config"
-#defineEC_SVM_STATE"EC_SVM_State"
-
-/*
- * EC_SVM_CONFIG subclass definitions - supporting attributes (name/value 
pairs)
- * are found in sys/sysevent/svm.h
- */
-#defineESC_SVM_CREATE  "ESC_SVM_Create"
-#defineESC_SVM_DELETE  "ESC_SVM_Delete"
-#defineESC_SVM_ADD "ESC_SVM_Add"
-#defineESC_SVM_REMOVE  "ESC_SVM_Remove"
-#defineESC_SVM_REPLACE "ESC_SVM_Replace"
-#defineESC_SVM_GROW"ESC_SVM_Grow"
-#defineESC_SVM_RENAME_SRC  "ESC_SVM_Rename_Src"
-#defineESC_SVM_RENAME_DST  "ESC_SVM_Rename_Dst"
-#defineESC_SVM_MEDIATOR_ADD"ESC_SVM_Mediator_Add"
-#defineESC_SVM_MEDIATOR_DELETE "ESC_SVM_Mediator_Delete"
-#defineESC_SVM_HOST_ADD"ESC_SVM_Host_Add"
-#defineESC_SVM_HOST_DELETE "ESC_SVM_Host_Delete"
-#defineESC_SVM_DRIVE_ADD   "ESC_SVM_Drive_Add"
-#defineESC_SVM_DRIVE_DELETE"ESC_SVM_Drive_Delete"
-#defineESC_SVM_DETACH  "ESC_SVM_Detach"
-#defineESC_SVM_DETACHING   "ESC_SVM_Detaching"
-#defineESC_SVM_ATTACH  "ESC_SVM_Attach"
-#defineESC_SVM_ATTACHING   "ESC_SVM_Attaching"
-
-/*
- * EC_SVM_STATE subclass definitions - supporting attributes (name/value pairs)
- * are found in sys/sysevent/svm.h
- */
-#defineESC_SVM_INIT_START  "ESC_SVM_Init_Start"
-#defineESC_SVM_INIT_FAILED "ESC_SVM_Init_Failed"
-#defineESC_SVM_INIT_FATAL  "ESC_SVM_Init_Fatal"
-#defineESC_SVM_INIT_SUCCESS"ESC_SVM_Init_Success"
-#defineESC_SVM_IOERR   "ESC_SVM_Ioerr"
-#defineESC_SVM_ERRED   "ESC_SVM_Erred"
-#defineESC_SVM_LASTERRED   "ESC_SVM_Lasterred"
-#defineESC_SVM_OK  "ESC_SVM_Ok"
-#defineESC_SVM_ENABLE  "ESC_SVM_Enable"
-#defineESC_SVM_RESYNC_START"ESC_SVM_Resync_Start"
-#defineESC_SVM_RESYNC_FAILED   "ESC_SVM_Resync_Failed"
-#defineESC_SVM_RESYNC_SUCCESS  "ESC_SVM_Resync_Success"
-#defineESC_SVM_RESYNC_DONE "ESC_SVM_Resync_Done"
-#defineESC_SVM_HOTSPARED   "ESC_SVM_Hotspared"
-#defineESC_SVM_HS_FREED"ESC_SVM_HS_Freed"
-#defineESC_SVM_HS_CHANGED  "ESC_SVM_HS_Changed"
-#defineESC_SVM_TAKEOVER"ESC_SVM_Takeover"
-#defineESC_SVM_RELEASE "ESC_SVM_Release"
-#defineESC_SVM_OPEN_FAIL   "ESC_SVM_Open_Fail"
-#defineESC_SVM_OFFLINE "ESC_SVM_Offline"
-#defineESC_SVM_ONLINE  "ESC_SVM_Online"
-#defineESC_SVM_CHANGE  "ESC_SVM_Change"
-#defineESC_SVM_EXCHANGE"ESC_SVM_Exchange"
-#defineESC_SVM_REGEN_START "ESC_SVM_Regen_Start"
-#defineESC_SVM_REGEN_DONE  "ESC_SVM_Regen_Done"
-#defineESC_SVM_REGEN_FAILED"ESC_SVM_Regen_Failed"
 
 /*
  * EC_DR subclass definitions - supporting attributes (name/value pairs)
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to 

svn commit: r331395 - in stable/11: cddl/contrib/opensolaris/cmd/zpool cddl/contrib/opensolaris/lib/libzfs/common cddl/usr.sbin/zfsd sys/cddl/contrib/opensolaris/common/zfs sys/cddl/contrib/opensol...

2018-03-22 Thread Alexander Motin
Author: mav
Date: Thu Mar 22 23:54:14 2018
New Revision: 331395
URL: https://svnweb.freebsd.org/changeset/base/331395

Log:
  MFC r329681: MFV r318941: 7446 zpool create should support efi system 
partition
  
  illumos/illumos-gate@7855d95b30fd903e3918bad5a29b777e765db821
  
https://github.com/illumos/illumos-gate/commit/7855d95b30fd903e3918bad5a29b777e765db821
  
  https://www.illumos.org/issues/7446
Since we support whole-disk configuration for boot pool, we also will need
whole disk support with UEFI boot and for this, zpool create should create 
efi-
system partition.
I have borrowed the idea from oracle solaris, and introducing zpool create -
B switch to provide an way to specify that boot partition should be created.
However, there is still an question, how big should the system partition be.
For time being, I have set default size 256MB (thats minimum size for FAT32
with 4k blocks). To support custom size, the set on creation "bootsize"
property is created and so the custom size can be set as: zpool create B -
o bootsize=34MB rpool c0t0d0
After pool is created, the "bootsize" property is read only. When -B switch 
is
not used, the bootsize defaults to 0 and is shown in zpool get output with
value ''. Older zfs/zpool implementations are ignoring this property.
https://www.illumos.org/rb/r/219/
  
  Reviewed by: Andrew Stormont 
  Reviewed by: Yuri Pankov 
  Approved by: Dan McDonald 
  Author: Toomas Soome 
  
  This commit makes no sense for FreeBSD, that is why I blocked the option,
  but it should be good to stay closer to upstream.

Modified:
  stable/11/cddl/contrib/opensolaris/cmd/zpool/zpool_main.c
  stable/11/cddl/contrib/opensolaris/cmd/zpool/zpool_util.h
  stable/11/cddl/contrib/opensolaris/cmd/zpool/zpool_vdev.c
  stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs.h
  stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c
  stable/11/cddl/usr.sbin/zfsd/case_file.cc
  stable/11/sys/cddl/contrib/opensolaris/common/zfs/zpool_prop.c
  stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/metaslab.c
  stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c
  stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/spa_impl.h
  stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev.c
  stable/11/sys/cddl/contrib/opensolaris/uts/common/sys/fs/zfs.h
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/cddl/contrib/opensolaris/cmd/zpool/zpool_main.c
==
--- stable/11/cddl/contrib/opensolaris/cmd/zpool/zpool_main.c   Thu Mar 22 
23:53:18 2018(r331394)
+++ stable/11/cddl/contrib/opensolaris/cmd/zpool/zpool_main.c   Thu Mar 22 
23:54:14 2018(r331395)
@@ -212,7 +212,8 @@ get_usage(zpool_help_t idx)
case HELP_CLEAR:
return (gettext("\tclear [-nF]  [device]\n"));
case HELP_CREATE:
-   return (gettext("\tcreate [-fnd] [-o property=value] ... \n"
+   return (gettext("\tcreate [-fnd] [-B] "
+   "[-o property=value] ... \n"
"\t[-O file-system-property=value] ... \n"
"\t[-m mountpoint] [-R root]   ...\n"));
case HELP_DESTROY:
@@ -499,6 +500,8 @@ zpool_do_add(int argc, char **argv)
int c;
nvlist_t *nvroot;
char *poolname;
+   zpool_boot_label_t boot_type;
+   uint64_t boot_size;
int ret;
zpool_handle_t *zhp;
nvlist_t *config;
@@ -547,9 +550,15 @@ zpool_do_add(int argc, char **argv)
return (1);
}
 
+   if (zpool_is_bootable(zhp))
+   boot_type = ZPOOL_COPY_BOOT_LABEL;
+   else
+   boot_type = ZPOOL_NO_BOOT_LABEL;
+
/* pass off to get_vdev_spec for processing */
+   boot_size = zpool_get_prop_int(zhp, ZPOOL_PROP_BOOTSIZE, NULL);
nvroot = make_root_vdev(zhp, force, !force, B_FALSE, dryrun,
-   argc, argv);
+   boot_type, boot_size, argc, argv);
if (nvroot == NULL) {
zpool_close(zhp);
return (1);
@@ -774,10 +783,11 @@ errout:
 }
 
 /*
- * zpool create [-fnd] [-o property=value] ...
+ * zpool create [-fnd] [-B] [-o property=value] ...
  * [-O file-system-property=value] ...
  * [-R root] [-m mountpoint]   ...
  *
+ * -B  Create boot partition.
  * -f  Force creation, even if devices appear in use
  * -n  Do not create the pool, but display the resulting layout if it
  * were to be created.
@@ -794,12 +804,16 @@ errout:
  * we get the nvlist back from get_vdev_spec(), we either print out the 
contents
  * (if '-n' was specified), or pass it to libzfs to do the creation.
  */
+
+#defineSYSTEM256   (256 * 1024 * 1024)
 int
 zpool_do_create(int argc, 

svn commit: r331394 - stable/11/cddl/contrib/opensolaris/lib/libzfs/common

2018-03-22 Thread Alexander Motin
Author: mav
Date: Thu Mar 22 23:53:18 2018
New Revision: 331394
URL: https://svnweb.freebsd.org/changeset/base/331394

Log:
  MFC r329668: MFV r316918:
  7990 libzfs: snapspec_cb() does not need to call zfs_strdup()
  
  illumos/illumos-gate@d8584ba6fb7a5e46da1725845b99ae5fab5a4baf
  
https://github.com/illumos/illumos-gate/commit/d8584ba6fb7a5e46da1725845b99ae5fab5a4baf
  
  https://www.illumos.org/issues/7990
The snapspec_cb() callback function in libzfs does not need to call 
zfs_strdup().
  
  Reviewed by: Yuri Pankov 
  Reviewed by: Toomas Soome 
  Approved by: Matthew Ahrens 
  Author: Marcel Telka 

Modified:
  stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_iter.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_iter.c
==
--- stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_iter.c  Thu Mar 
22 23:52:37 2018(r331393)
+++ stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_iter.c  Thu Mar 
22 23:53:18 2018(r331394)
@@ -317,26 +317,23 @@ static int
 snapspec_cb(zfs_handle_t *zhp, void *arg)
 {
snapspec_arg_t *ssa = arg;
-   char *shortsnapname;
+   const char *shortsnapname;
int err = 0;
 
if (ssa->ssa_seenlast)
return (0);
-   shortsnapname = zfs_strdup(zhp->zfs_hdl,
-   strchr(zfs_get_name(zhp), '@') + 1);
 
+   shortsnapname = strchr(zfs_get_name(zhp), '@') + 1;
if (!ssa->ssa_seenfirst && strcmp(shortsnapname, ssa->ssa_first) == 0)
ssa->ssa_seenfirst = B_TRUE;
+   if (strcmp(shortsnapname, ssa->ssa_last) == 0)
+   ssa->ssa_seenlast = B_TRUE;
 
if (ssa->ssa_seenfirst) {
err = ssa->ssa_func(zhp, ssa->ssa_arg);
} else {
zfs_close(zhp);
}
-
-   if (strcmp(shortsnapname, ssa->ssa_last) == 0)
-   ssa->ssa_seenlast = B_TRUE;
-   free(shortsnapname);
 
return (err);
 }
___
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: r331393 - in stable/11/cddl/contrib/opensolaris/lib: libzfs/common libzfs_core/common

2018-03-22 Thread Alexander Motin
Author: mav
Date: Thu Mar 22 23:52:37 2018
New Revision: 331393
URL: https://svnweb.freebsd.org/changeset/base/331393

Log:
  MFC r329667: MFV r316902:
  7745 print error if lzc_* is called before libzfs_core_init
  
  illumos/illumos-gate@7c13517fff71be473e47531ef4330160c042bedc
  
https://github.com/illumos/illumos-gate/commit/7c13517fff71be473e47531ef4330160c042bedc
  
  https://www.illumos.org/issues/7745
The problem is that consumers of `libZFS_Core` that forget to call
`libzfs_core_init()` before calling any other function of the library
are having a hard time realizing their mistake. The library's internal
file descriptor is declared as global static, which is ok, but it is not
initialized explicitly; therefore, it defaults to 0, which is a valid
file descriptor. If `libzfs_core_init()`, which explicitly initializes
the correct fd, is skipped, the ioctl functions return errors that do
not have anything to do with `libZFS_Core`, where the problem is
actually located.
Even though assertions for that existed within `libZFS_Core` for debug
builds, they were never enabled because the `-DDEBUG` flag was missing
from the compiler flags.
This patch applies the following changes:
1. It adds `-DDEBUG` for debug builds of `libZFS_Core` and `libzfs`,
   to enable their assertions on debug builds.
2. It corrects an assertion within `libzfs`, where a function had
   been spelled incorrectly (`zpool_prop_unsupported()`) and nobody
   knew because the `-DDEBUG` flag was missing, and the preprocessor
   was taking that part of the code away.
3. The library's internal fd is initialized to `-1` and `VERIFY`
   assertions have been placed to check that the fd is not equal to
   `-1` before issuing any ioctl. It is important here to note, that
   the `VERIFY` assertions exist in both debug and non-debug builds.
4. In `libzfs_core_fini` we make sure to never increment the
   refcount of our fd below 0, and also reset the fd to `-1` when no
   one refers to it. The reason for this, is for the rare case that
   the consumer closes all references but then calls one of the
   library's functions without using `libzfs_core_init()` first, and
   in the mean time, a previous call to `open()` decided to reuse
   our previous fd. This scenario would have passed our assertion in
  
  Reviewed by: Pavel Zakharov 
  Reviewed by: Matthew Ahrens 
  Approved by: Dan McDonald 
  Author: Serapheim Dimitropoulos 

Modified:
  stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c
  stable/11/cddl/contrib/opensolaris/lib/libzfs_core/common/libzfs_core.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c
==
--- stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c  
Thu Mar 22 23:51:39 2018(r331392)
+++ stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c  
Thu Mar 22 23:52:37 2018(r331393)
@@ -273,6 +273,15 @@ cksummer(void *arg)
ofp = fdopen(dda->inputfd, "r");
while (ssread(drr, sizeof (*drr), ofp) != 0) {
 
+   /*
+* kernel filled in checksum, we are going to write same
+* record, but need to regenerate checksum.
+*/
+   if (drr->drr_type != DRR_BEGIN) {
+   bzero(>drr_u.drr_checksum.drr_checksum,
+   sizeof (drr->drr_u.drr_checksum.drr_checksum));
+   }
+
switch (drr->drr_type) {
case DRR_BEGIN:
{

Modified: 
stable/11/cddl/contrib/opensolaris/lib/libzfs_core/common/libzfs_core.c
==
--- stable/11/cddl/contrib/opensolaris/lib/libzfs_core/common/libzfs_core.c 
Thu Mar 22 23:51:39 2018(r331392)
+++ stable/11/cddl/contrib/opensolaris/lib/libzfs_core/common/libzfs_core.c 
Thu Mar 22 23:52:37 2018(r331393)
@@ -94,7 +94,7 @@
 extern int zfs_ioctl_version;
 #endif
 
-static int g_fd;
+static int g_fd = -1;
 static pthread_mutex_t g_lock = PTHREAD_MUTEX_INITIALIZER;
 static int g_refcount;
 
@@ -120,9 +120,14 @@ libzfs_core_fini(void)
 {
(void) pthread_mutex_lock(_lock);
ASSERT3S(g_refcount, >, 0);
-   g_refcount--;
-   if (g_refcount == 0)
+
+   if (g_refcount > 0)
+   g_refcount--;
+
+   if (g_refcount == 0 && g_fd != -1) {
(void) close(g_fd);
+   g_fd = -1;
+   }
(void) pthread_mutex_unlock(_lock);
 }
 
@@ -139,6 +144,7 @@ lzc_ioctl(zfs_ioc_t ioc, const char *name,
size_t 

svn commit: r331392 - stable/11/cddl/contrib/opensolaris/lib/libzfs/common

2018-03-22 Thread Alexander Motin
Author: mav
Date: Thu Mar 22 23:51:39 2018
New Revision: 331392
URL: https://svnweb.freebsd.org/changeset/base/331392

Log:
  MFC r329665: MFV r316901:
  7730 libzfs`add_config() leaks config nvl when reading spare/l2cache devices
  
  illumos/illumos-gate@105686550ee9cbf5d033166a8a2a5a763667d436
  
https://github.com/illumos/illumos-gate/commit/105686550ee9cbf5d033166a8a2a5a763667d436
  
  https://www.illumos.org/issues/7730
antares:root:~# mdb /usr/sbin/zpool
> ::sysbp _exit
> ::run import
   pool: data
 id: 2093977168778024605
  state: ONLINE
 action: The pool can be imported using its name or numeric identifier.
 config:
  
dataONLINE
  c6t0d0ONLINE
  c6t1d0ONLINE
cache
  c6t2d0
mdb: stop on entry to _exit
mdb: target stopped at:
0xfee556ba: nop
mdb: You've got symbols!
Loading modules: [ ld.so.1 libumem.so.1 libc.so.1 libtopo.so.1 libavl.so.1
libnvpair.so.1 ]
> ::findleaks -d
BYTES LEAKED VMEM_SEG CALLER
4096  10 fda7b000 MMAP
8192   1 fea8d000 MMAP
8192   1 fe76d000 MMAP
8192   1 fe66e000 MMAP
4096   1 fe57 MMAP
8192   1 fe47 MMAP
4096   1 fe372000 MMAP
4096   1 fe273000 MMAP
  
  Reviewed by: Matthew Ahrens 
  Reviewed by: Serapheim Dimitropoulos 
  Approved by: Robert Mustacchi 
  Author: Yuri Pankov 

Modified:
  stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_import.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_import.c
==
--- stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_import.c
Thu Mar 22 23:50:43 2018(r331391)
+++ stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_import.c
Thu Mar 22 23:51:39 2018(r331392)
@@ -240,9 +240,12 @@ add_config(libzfs_handle_t *hdl, pool_list_t *pl, cons
free(ne);
return (-1);
}
+
ne->ne_guid = vdev_guid;
ne->ne_next = pl->names;
pl->names = ne;
+
+   nvlist_free(config);
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: r331391 - stable/11/cddl/contrib/opensolaris/lib/libzfs/common

2018-03-22 Thread Alexander Motin
Author: mav
Date: Thu Mar 22 23:50:43 2018
New Revision: 331391
URL: https://svnweb.freebsd.org/changeset/base/331391

Log:
  MFC r329664: MFV r316893:
  7604 if volblocksize property is the default, it displays as "-" rather than 
8K
  
  illumos/illumos-gate@4d86c0eab246bdfddc2dd52410ba808433bd6266
  
https://github.com/illumos/illumos-gate/commit/4d86c0eab246bdfddc2dd52410ba808433bd6266
  
  https://www.illumos.org/issues/7604
If a zvol has the default setting for the "volblocksize" property, it is
8KB. However, it is displayed as "-" (not present), rather than "8K".
The problem was introduced by:
commit 25228e830e86924a41243343b1de9daf2d7dd43a
Author: Matthew Ahrens mahr...@delphix.com
Date:   Thu Nov 17 14:37:24 2016 -0800
7571 non-present readonly numeric ZFS props do not have default value
which changed changed get_numeric_property() to indicate that readonly
default properties are not present. However, zfs_prop_readonly() returns
TRUE for both readonly and set-once properties (e.g. volblocksize).
Amusingly, that commit essentially reverted:
6900484 default volblocksize is no longer being reported correctly
from November 2009. However, that change was not correct either; the
correct solution is to only do this check for "truly readonly" (i.e. not
setonce) properties.
$ zfs list -t volume -o name,volblocksize
NAME
VOLBLOCK
domain0/group-100/appdata_container-101/appdata_windows_timeflow-102/
archive-
domain0/group-100/appdata_container-101/appdata_windows_timeflow-102/
datafile   -
domain0/group-100/appdata_container-101/appdata_windows_timeflow-102/
external   -
rpool/dump
128K
rpool/swap
4K
rpool/swap1

===
  
  Reviewed by: Pavel Zakharov 
  Reviewed by: Paul Dagnelie 
  Reviewed by: John Kennedy 
  Reviewed by: George Wilson 
  Approved by: Robert Mustacchi 
  Author: Matthew Ahrens 

Modified:
  stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c
==
--- stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c   
Thu Mar 22 23:49:54 2018(r331390)
+++ stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c   
Thu Mar 22 23:50:43 2018(r331391)
@@ -2161,9 +2161,12 @@ get_numeric_property(zfs_handle_t *zhp, zfs_prop_t pro
/*
 * If we tried to use a default value for a
 * readonly property, it means that it was not
-* present.
+* present.  Note this only applies to "truly"
+* readonly properties, not set-once properties
+* like volblocksize.
 */
if (zfs_prop_readonly(prop) &&
+   !zfs_prop_setonce(prop) &&
*source != NULL && (*source)[0] == '\0') {
*source = NULL;
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"


svn commit: r331390 - stable/11/cddl/contrib/opensolaris/lib/libzfs/common

2018-03-22 Thread Alexander Motin
Author: mav
Date: Thu Mar 22 23:49:54 2018
New Revision: 331390
URL: https://svnweb.freebsd.org/changeset/base/331390

Log:
  MFC r329663: MFV r316876: 7542 zfs_unmount failed with EZFS_UNSHARENFSFAILED
  
  illumos/illumos-gate@09c9e6dc9b69d10b771bb87e01040ec320a0bfd3
  
https://github.com/illumos/illumos-gate/commit/09c9e6dc9b69d10b771bb87e01040ec320a0bfd3
  
  https://www.illumos.org/issues/7542
libshare keeps a cached copy of the sharetab listing in memory, which can
become out of date if shares are destroyed or created while leaving a libzfs
handle open. This results in a spurious unmounting failure when an NFS share
exists but isn't in the stale libshare cache.
  
  Reviewed by: Matthew Ahrens 
  Reviewed by: Dan Kimmel 
  Reviewed by: Matt Amdur 
  Approved by: Robert Mustacchi 
  Author: Chris Williamson 

Modified:
  stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_impl.h
  stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_mount.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_impl.h
==
--- stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_impl.h  Thu Mar 
22 23:48:07 2018(r331389)
+++ stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_impl.h  Thu Mar 
22 23:49:54 2018(r331390)
@@ -22,7 +22,7 @@
 /*
  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
  * Copyright (c) 2011 Pawel Jakub Dawidek. All rights reserved.
- * Copyright (c) 2011, 2015 by Delphix. All rights reserved.
+ * Copyright (c) 2011, 2016 by Delphix. All rights reserved.
  * Copyright (c) 2013 Martin Matuska . All rights reserved.
  */
 
@@ -72,7 +72,6 @@ struct libzfs_handle {
int libzfs_printerr;
int libzfs_storeerr; /* stuff error messages into buffer */
void *libzfs_sharehdl; /* libshare handle */
-   uint_t libzfs_shareflags;
boolean_t libzfs_mnttab_enable;
avl_tree_t libzfs_mnttab_cache;
int libzfs_pool_iter;
@@ -81,8 +80,6 @@ struct libzfs_handle {
char libzfs_chassis_id[256];
boolean_t libzfs_prop_debug;
 };
-
-#defineZFSSHARE_MISS   0x01/* Didn't find entry in cache */
 
 struct zfs_handle {
libzfs_handle_t *zfs_hdl;

Modified: stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_mount.c
==
--- stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_mount.c Thu Mar 
22 23:48:07 2018(r331389)
+++ stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_mount.c Thu Mar 
22 23:49:54 2018(r331390)
@@ -22,7 +22,7 @@
 /*
  * Copyright 2015 Nexenta Systems, Inc.  All rights reserved.
  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2014, 2015 by Delphix. All rights reserved.
+ * Copyright (c) 2014, 2016 by Delphix. All rights reserved.
  * Copyright 2016 Igor Kozhukhov 
  * Copyright 2017 Joyent, Inc.
  * Copyright 2017 RackTop Systems.
@@ -672,8 +672,6 @@ _zfs_init_libshare(void)
 int
 zfs_init_libshare(libzfs_handle_t *zhandle, int service)
 {
-   int ret = SA_OK;
-
 #ifdef illumos
/*
 * libshare is either not installed or we're in a branded zone. The
@@ -684,31 +682,28 @@ zfs_init_libshare(libzfs_handle_t *zhandle, int servic
if (_sa_init == NULL)
return (SA_OK);
 
-   if (ret == SA_OK && zhandle->libzfs_shareflags & ZFSSHARE_MISS) {
-   /*
-* We had a cache miss. Most likely it is a new ZFS
-* dataset that was just created. We want to make sure
-* so check timestamps to see if a different process
-* has updated any of the configuration. If there was
-* some non-ZFS change, we need to re-initialize the
-* internal cache.
-*/
-   zhandle->libzfs_shareflags &= ~ZFSSHARE_MISS;
-   if (_sa_needs_refresh != NULL &&
-   _sa_needs_refresh(zhandle->libzfs_sharehdl)) {
-   zfs_uninit_libshare(zhandle);
-   zhandle->libzfs_sharehdl = _sa_init(service);
-   }
+   /*
+* Attempt to refresh libshare. This is necessary if there was a cache
+* miss for a new ZFS dataset that was just created, or if state of the
+* sharetab file has changed since libshare was last initialized. We
+* want to make sure so check timestamps to see if a different process
+* has updated any of the configuration. If there was some non-ZFS
+* change, we need to re-initialize the internal cache.
+*/
+   if 

svn commit: r331389 - stable/11/cddl/contrib/opensolaris/lib/libzfs/common

2018-03-22 Thread Alexander Motin
Author: mav
Date: Thu Mar 22 23:48:07 2018
New Revision: 331389
URL: https://svnweb.freebsd.org/changeset/base/331389

Log:
  MFC r329661: MFV r316875: 7336 vfork and O_CLOEXEC causes zfs_mount EBUSY
  
  illumos/illumos-gate@873c4903a52d089cd8234b79d24f5a3fc3bccc82
  
https://github.com/illumos/illumos-gate/commit/873c4903a52d089cd8234b79d24f5a3fc3bccc82
  
  https://www.illumos.org/issues/7336
We can run into a problem where we call into zfs_mount, which in turn calls
is_dir_empty, which opens the directory to try and make sure it's empty. The
issue with the current approach is that it holds the directory open while it
traverses it with readdir, which, due to subtle interaction with the Java 
JVM,
vfork, and exec can cause a tricky race condition resulting in zfs_mount
failures.
The approach to resolving the issue in this patch is to drop the usage of
readdir altogether, and instead rely on the fact that ZFS stores the number 
of
entries contained in a directory using the st_size field of the stat 
structure.
Thus, if the directory in question is a ZFS directory, we can check to see 
if
it's empty by calling stat() and inspecting the st_size field of structure
returned.

===
The root cause appears to be an interesting race between vfork, exec, and
zfs_mount's usage of O_CLOEXEC when calling openat. Here's what is going on:
1. We call zfs_mount, and this in turn calls openat to check if the 
directory
is empty, which results in opening the directory we're trying to mount onto,
and increment v_count.
2. As we're in the middle of reading the directory, vfork is called by the 
JVM
and proceeds to exec the jspawnhelper utility. As a result of the vfork, we
take an additional hold on the directory, which increments v_count a second
time. The semantics of vfork mean the parent process will wait for the child
process to exit or exec before the parent can continue; at this point the
parent is in the middle of zfs_mount, reading the directory to determine if
it's empty or not.
3. The child process exec-ing jspawnhelper gets to the relvm call within
exec_args (which is called by exec_common). relvm is the function that 
releases
the parent process, allowing the parent to proceed. The problem is, at this
point of calling relvm, the child hasn't yet called close_exec which is
responsible for closing the file descriptors inherited from the parent 
process
  
  Reviewed by: Matt Ahrens 
  Reviewed by: Paul Dagnelie 
  Reviewed by: Robert Mustacchi 
  Approved by: Dan McDonald 
  Author: Prakash Surya 

Modified:
  stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_mount.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_mount.c
==
--- stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_mount.c Thu Mar 
22 23:47:04 2018(r331388)
+++ stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_mount.c Thu Mar 
22 23:48:07 2018(r331389)
@@ -78,6 +78,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -178,14 +179,33 @@ is_shared(libzfs_handle_t *hdl, const char *mountpoint
 }
 
 #ifdef illumos
-/*
- * Returns true if the specified directory is empty.  If we can't open the
- * directory at all, return true so that the mount can fail with a more
- * informative error message.
- */
 static boolean_t
-dir_is_empty(const char *dirname)
+dir_is_empty_stat(const char *dirname)
 {
+   struct stat st;
+
+   /*
+* We only want to return false if the given path is a non empty
+* directory, all other errors are handled elsewhere.
+*/
+   if (stat(dirname, ) < 0 || !S_ISDIR(st.st_mode)) {
+   return (B_TRUE);
+   }
+
+   /*
+* An empty directory will still have two entries in it, one
+* entry for each of "." and "..".
+*/
+   if (st.st_size > 2) {
+   return (B_FALSE);
+   }
+
+   return (B_TRUE);
+}
+
+static boolean_t
+dir_is_empty_readdir(const char *dirname)
+{
DIR *dirp;
struct dirent64 *dp;
int dirfd;
@@ -211,6 +231,42 @@ dir_is_empty(const char *dirname)
 
(void) closedir(dirp);
return (B_TRUE);
+}
+
+/*
+ * Returns true if the specified directory is empty.  If we can't open the
+ * directory at all, return true so that the mount can fail with a more
+ * informative error message.
+ */
+static boolean_t
+dir_is_empty(const char *dirname)
+{
+   struct statvfs64 st;
+
+   /*
+* If the statvfs call fails or the filesystem is not a ZFS
+* filesystem, fall back to the slow path 

svn commit: r331388 - stable/11/cddl/contrib/opensolaris/lib/libzfs/common

2018-03-22 Thread Alexander Motin
Author: mav
Date: Thu Mar 22 23:47:04 2018
New Revision: 331388
URL: https://svnweb.freebsd.org/changeset/base/331388

Log:
  MFC r329659: MFV r316873: 7233 dir_is_empty should open directory with CLOEXEC
  
  illumos/illumos-gate@d420209d9c807f782c1d31f5683be74798142198
  
https://github.com/illumos/illumos-gate/commit/d420209d9c807f782c1d31f5683be74798142198
  
  https://www.illumos.org/issues/7233
This fixes a race where one thread is executing zfs_mount() while another
thread forks and execs. If the fork occurs while the directory is open, the
child process will inherit (but not necessarily close immediately) the open 
fd
for the directory, preventing the mount.
  
  Reviewed by: Matthew Ahrens 
  Reviewed by: Paul Dagnelie 
  Approved by: Richard Lowe 
  Author: Alex Reece 

Modified:
  stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_mount.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_mount.c
==
--- stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_mount.c Thu Mar 
22 23:45:46 2018(r331387)
+++ stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_mount.c Thu Mar 
22 23:47:04 2018(r331388)
@@ -22,7 +22,7 @@
 /*
  * Copyright 2015 Nexenta Systems, Inc.  All rights reserved.
  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2014 by Delphix. All rights reserved.
+ * Copyright (c) 2014, 2015 by Delphix. All rights reserved.
  * Copyright 2016 Igor Kozhukhov 
  * Copyright 2017 Joyent, Inc.
  * Copyright 2017 RackTop Systems.
@@ -67,6 +67,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -187,9 +188,16 @@ dir_is_empty(const char *dirname)
 {
DIR *dirp;
struct dirent64 *dp;
+   int dirfd;
 
-   if ((dirp = opendir(dirname)) == NULL)
+   if ((dirfd = openat(AT_FDCWD, dirname,
+   O_RDONLY | O_NDELAY | O_LARGEFILE | O_CLOEXEC, 0)) < 0) {
return (B_TRUE);
+   }
+
+   if ((dirp = fdopendir(dirfd)) == NULL) {
+   return (B_TRUE);
+   }
 
while ((dp = readdir64(dirp)) != NULL) {
 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r331387 - stable/11/cddl/contrib/opensolaris/cmd/ztest

2018-03-22 Thread Alexander Motin
Author: mav
Date: Thu Mar 22 23:45:46 2018
New Revision: 331387
URL: https://svnweb.freebsd.org/changeset/base/331387

Log:
  MFC r329658: MFV r316872: 7502 ztest should run zdb with -G (debug mode)
  
  illumos/illumos-gate@c3c65d17f7b6689bbd6568a1a1fcc0c4a3bac127
  
https://github.com/illumos/illumos-gate/commit/c3c65d17f7b6689bbd6568a1a1fcc0c4a3bac127
  
  https://www.illumos.org/issues/7502
Right now ztest executes zdb without -G, so when it has errors, the messages
are often not very helpful:
Executing zdb -bccsv -d -U /rpool/tmp/zpool.cache ztest
zdb: can't open 'ztest': Operation not supported
ztest: '/usr/sbin/amd64/zdb -bccsv -d -U /rpool/tmp/zpool.cache ztest' exit
code 1
With -G, we'd have:
/usr/sbin/amd64/zdb -bccsv -d -U /rpool/tmp/zpool.cache -G ztest
zdb: can't open 'ztest': Operation not supported
  
ZFS_DBGMSG(zdb):
spa_open_common: opening ztest
spa_load(ztest): LOADING
spa_load(ztest): FAILED: unable to parse config [error=48]
spa_load(ztest): UNLOADING
Which indicates where the error came from
  
  Reviewed by: Matthew Ahrens 
  Reviewed by: Dan Kimmel 
  Approved by: Gordon Ross 
  Author: Pavel Zakharov 

Modified:
  stable/11/cddl/contrib/opensolaris/cmd/ztest/ztest.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/cddl/contrib/opensolaris/cmd/ztest/ztest.c
==
--- stable/11/cddl/contrib/opensolaris/cmd/ztest/ztest.cThu Mar 22 
23:45:01 2018(r331386)
+++ stable/11/cddl/contrib/opensolaris/cmd/ztest/ztest.cThu Mar 22 
23:45:46 2018(r331387)
@@ -5277,7 +5277,7 @@ ztest_run_zdb(char *pool)
isa = strdup(isa);
/* LINTED */
(void) sprintf(bin,
-   "/usr/sbin%.*s/zdb -bcc%s%s -d -U %s %s",
+   "/usr/sbin%.*s/zdb -bcc%s%s -G -d -U %s %s",
isalen,
isa,
ztest_opts.zo_verbose >= 3 ? "s" : "",
___
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: r331386 - stable/11/cddl/contrib/opensolaris/cmd/zdb

2018-03-22 Thread Alexander Motin
Author: mav
Date: Thu Mar 22 23:45:01 2018
New Revision: 331386
URL: https://svnweb.freebsd.org/changeset/base/331386

Log:
  MFC r329657 (by asomers): Fix memory leaks in zdb introduced by r329508
  
  Reported by:Coverity
  CID:1386185

Modified:
  stable/11/cddl/contrib/opensolaris/cmd/zdb/zdb.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/cddl/contrib/opensolaris/cmd/zdb/zdb.c
==
--- stable/11/cddl/contrib/opensolaris/cmd/zdb/zdb.cThu Mar 22 23:43:48 
2018(r331385)
+++ stable/11/cddl/contrib/opensolaris/cmd/zdb/zdb.cThu Mar 22 23:45:01 
2018(r331386)
@@ -3570,6 +3570,7 @@ zdb_read_block(char *thing, spa_t *spa)
s = "offset must be a multiple of sector size";
if (s) {
(void) printf("Invalid block specifier: %s  - %s\n", thing, s);
+   free(flagstr);
free(dup);
return;
}
@@ -3595,6 +3596,7 @@ zdb_read_block(char *thing, spa_t *spa)
blkptr_offset = strtoull(p, , 16);
if (*p != ':' && *p != '\0') {
(void) printf("***Invalid flag arg: '%s'\n", s);
+   free(flagstr);
free(dup);
return;
}
___
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: r331385 - in stable/11/sys/cddl/contrib/opensolaris: common/nvpair uts/common/fs/zfs

2018-03-22 Thread Alexander Motin
Author: mav
Date: Thu Mar 22 23:43:48 2018
New Revision: 331385
URL: https://svnweb.freebsd.org/changeset/base/331385

Log:
  MFC r329628: MFC r316910: 7812 Remove gender specific language
  
  illumos/illumos-gate@48bbca816818409505a6e214d0911fda44e622e3
  
https://github.com/illumos/illumos-gate/commit/48bbca816818409505a6e214d0911fda44e622e3
  
  https://www.illumos.org/issues/7812
This change removes all gendered language that did not refer specifically
to an individual person or pet. The convention taken was to use
variations on "they" when referring to users and/or human beings, while
using "it" when referring to code, functions, and/or libraries.
Additionally, we took the liberty to fix up any whitespace issues that
were found in any files that were already being modified.
  
  Reviewed by: Matt Ahrens 
  Reviewed by: Prakash Surya 
  Reviewed by: Steve Gonczi 
  Reviewed by: Chris Williamson 
  Reviewed by: George Wilson 
  Reviewed by: Igor Kozhukhov 
  Reviewed by: Dan McDonald 
  Reviewed by: Robert Mustacchi 
  Approved by: Richard Lowe 
  Author: Daniel Hoffman 

Modified:
  stable/11/sys/cddl/contrib/opensolaris/common/nvpair/opensolaris_nvpair.c
  stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_dir.c
  stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zio.c
Directory Properties:
  stable/11/   (props changed)

Modified: 
stable/11/sys/cddl/contrib/opensolaris/common/nvpair/opensolaris_nvpair.c
==
--- stable/11/sys/cddl/contrib/opensolaris/common/nvpair/opensolaris_nvpair.c   
Thu Mar 22 23:43:05 2018(r331384)
+++ stable/11/sys/cddl/contrib/opensolaris/common/nvpair/opensolaris_nvpair.c   
Thu Mar 22 23:43:48 2018(r331385)
@@ -2379,7 +2379,7 @@ nvlist_xpack(nvlist_t *nvl, char **bufp, size_t *bufle
 * 1. The nvlist has fixed allocator properties.
 *All other nvlist routines (like nvlist_add_*, ...) use
 *these properties.
-* 2. When using nvlist_pack() the user can specify his own
+* 2. When using nvlist_pack() the user can specify their own
 *allocator properties (e.g. by using KM_NOSLEEP).
 *
 * We use the user specified properties (2). A clearer solution

Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_dir.c
==
--- stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_dir.c  Thu Mar 
22 23:43:05 2018(r331384)
+++ stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_dir.c  Thu Mar 
22 23:43:48 2018(r331385)
@@ -21,7 +21,7 @@
 
 /*
  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2013, 2015 by Delphix. All rights reserved.
+ * Copyright (c) 2013, 2016 by Delphix. All rights reserved.
  * Copyright 2017 Nexenta Systems, Inc.
  */
 

Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zio.c
==
--- stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zio.c  Thu Mar 
22 23:43:05 2018(r331384)
+++ stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zio.c  Thu Mar 
22 23:43:48 2018(r331385)
@@ -1812,7 +1812,7 @@ zio_reexecute(zio_t *pio)
/*
 * Now that all children have been reexecuted, execute the parent.
 * We don't reexecute "The Godfather" I/O here as it's the
-* responsibility of the caller to wait on him.
+* responsibility of the caller to wait on it.
 */
if (!(pio->io_flags & ZIO_FLAG_GODFATHER)) {
pio->io_queued_timestamp = gethrtime();
___
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: r331384 - in stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs: . sys

2018-03-22 Thread Alexander Motin
Author: mav
Date: Thu Mar 22 23:43:05 2018
New Revision: 331384
URL: https://svnweb.freebsd.org/changeset/base/331384

Log:
  MFC r329625: MFV r307315:
  7301 zpool export -f should be able to interrupt file freeing
  
  Reviewed by: Matthew Ahrens 
  Reviewed by: Sanjay Nadkarni 
  Reviewed by: Saso Kiselkov 
  Reviewed by: John Kennedy 
  Author: Alek Pinchuk 
  
  Closes #175

Modified:
  stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu.c
  stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_znode.h
  stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_dir.c
  stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu.c
==
--- stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu.c  Thu Mar 
22 23:41:26 2018(r331383)
+++ stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu.c  Thu Mar 
22 23:43:05 2018(r331384)
@@ -24,7 +24,7 @@
  */
 /* Copyright (c) 2013 by Saso Kiselkov. All rights reserved. */
 /* Copyright (c) 2013, Joyent, Inc. All rights reserved. */
-/* Copyright (c) 2014, Nexenta Systems, Inc. All rights reserved. */
+/* Copyright 2016 Nexenta Systems, Inc. All rights reserved. */
 
 #include 
 #include 
@@ -723,6 +723,22 @@ get_next_chunk(dnode_t *dn, uint64_t *start, uint64_t 
return (0);
 }
 
+/*
+ * If this objset is of type OST_ZFS return true if vfs's unmounted flag is 
set,
+ * otherwise return false.
+ * Used below in dmu_free_long_range_impl() to enable abort when unmounting
+ */
+/*ARGSUSED*/
+static boolean_t
+dmu_objset_zfs_unmounting(objset_t *os)
+{
+#ifdef _KERNEL
+   if (dmu_objset_type(os) == DMU_OST_ZFS)
+   return (zfs_get_vfs_flag_unmounted(os));
+#endif
+   return (B_FALSE);
+}
+
 static int
 dmu_free_long_range_impl(objset_t *os, dnode_t *dn, uint64_t offset,
 uint64_t length)
@@ -748,6 +764,9 @@ dmu_free_long_range_impl(objset_t *os, dnode_t *dn, ui
uint64_t chunk_end, chunk_begin, chunk_len;
uint64_t long_free_dirty_all_txgs = 0;
dmu_tx_t *tx;
+
+   if (dmu_objset_zfs_unmounting(dn->dn_objset))
+   return (SET_ERROR(EINTR));
 
chunk_end = chunk_begin = offset + length;
 

Modified: 
stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_znode.h
==
--- stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_znode.h
Thu Mar 22 23:41:26 2018(r331383)
+++ stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_znode.h
Thu Mar 22 23:43:05 2018(r331384)
@@ -22,6 +22,7 @@
  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
  * Copyright (c) 2012, 2015 by Delphix. All rights reserved.
  * Copyright (c) 2014 Integros [integros.com]
+ * Copyright 2016 Nexenta Systems, Inc. All rights reserved.
  */
 
 #ifndef_SYS_FS_ZFS_ZNODE_H
@@ -321,6 +322,7 @@ extern int  zfs_create_op_tables();
 extern dev_t   zfs_cmpldev(uint64_t);
 extern int zfs_get_zplprop(objset_t *os, zfs_prop_t prop, uint64_t *value);
 extern int zfs_get_stats(objset_t *os, nvlist_t *nv);
+extern boolean_t zfs_get_vfs_flag_unmounted(objset_t *os);
 extern voidzfs_znode_dmu_fini(znode_t *);
 
 extern void zfs_log_create(zilog_t *zilog, dmu_tx_t *tx, uint64_t txtype,

Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_dir.c
==
--- stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_dir.c  Thu Mar 
22 23:41:26 2018(r331383)
+++ stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_dir.c  Thu Mar 
22 23:43:05 2018(r331384)
@@ -428,8 +428,8 @@ zfs_rmnode(znode_t *zp)
error = dmu_free_long_range(os, zp->z_id, 0, DMU_OBJECT_END);
if (error) {
/*
-* Not enough space.  Leave the file in the unlinked
-* set.
+* Not enough space or we were interrupted by unmount.
+* Leave the file in the unlinked set.
 */
zfs_znode_dmu_fini(zp);
zfs_znode_free(zp);

Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c
==
--- stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c   
Thu Mar 22 23:41:26 2018(r331383)
+++ 

svn commit: r331383 - stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs

2018-03-22 Thread Alexander Motin
Author: mav
Date: Thu Mar 22 23:41:26 2018
New Revision: 331383
URL: https://svnweb.freebsd.org/changeset/base/331383

Log:
  MFC r329623: MFV r302649: 7016 arc_available_memory is not 32-bit safe
  
  illumos/illumos-gate@0dd053d7d890618ea1fc697b07de364e69eb4190
  
https://github.com/illumos/illumos-gate/commit/0dd053d7d890618ea1fc697b07de364e69eb4190
  
  https://www.illumos.org/issues/7016
upstream DLPX-39446 arc_available_memory is not 32-bit safe
https://github.com/delphix/delphix-os/commit/
6b353ea3b8a1610be22e71e657d051743c64190b
related to this upstream:
DLPX-38547 delphix engine hang
https://github.com/delphix/delphix-os/commit/
3183a567b3e8c62a74a65885ca60c86f3d693783
DLPX-38547 delphix engine hang (fix static global)
https://github.com/delphix/delphix-os/commit/
22ac551d8ef085ad66cc8f65e51ac372b12993b9
DLPX-38882 system hung waiting on free segment
https://github.com/delphix/delphix-os/commit/
cdd6beef7548cd3b12f0fc0328eeb3af540079c2
  
  Reviewed by: Igor Kozhukhov 
  Reviewed by: Matthew Ahrens 
  Reviewed by: Paul Dagnelie 
  Reviewed by: George Wilson 
  Approved by: Gordon Ross 
  Author: Prakash Surya 

Modified:
  stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c
==
--- stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c  Thu Mar 
22 23:39:49 2018(r331382)
+++ stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/arc.c  Thu Mar 
22 23:41:26 2018(r331383)
@@ -350,6 +350,11 @@ extern boolean_t zfs_prefetch_disable;
 static boolean_t arc_warm;
 
 /*
+ * log2 fraction of the zio arena to keep free.
+ */
+int arc_zio_arena_free_shift = 2;
+
+/*
  * These tunables are for performance analysis.
  */
 uint64_t zfs_arc_max;
@@ -4326,15 +4331,16 @@ arc_available_memory(void)
/*
 * If zio data pages are being allocated out of a separate heap segment,
 * then enforce that the size of available vmem for this arena remains
-* above about 1/16th free.
+* above about 1/4th (1/(2^arc_zio_arena_free_shift)) free.
 *
-* Note: The 1/16th arena free requirement was put in place
-* to aggressively evict memory from the arc in order to avoid
-* memory fragmentation issues.
+* Note that reducing the arc_zio_arena_free_shift keeps more virtual
+* memory (in the zio_arena) free, which can avoid memory
+* fragmentation issues.
 */
if (zio_arena != NULL) {
n = (int64_t)vmem_size(zio_arena, VMEM_FREE) -
-   (vmem_size(zio_arena, VMEM_ALLOC) >> 4);
+   (vmem_size(zio_arena, VMEM_ALLOC) >>
+   arc_zio_arena_free_shift);
if (n < lowest) {
lowest = n;
r = FMR_ZIO_ARENA;
___
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: r331382 - in stable/11/cddl/contrib/opensolaris: cmd/zdb cmd/ztest lib/libzpool/common/sys

2018-03-22 Thread Alexander Motin
Author: mav
Date: Thu Mar 22 23:39:49 2018
New Revision: 331382
URL: https://svnweb.freebsd.org/changeset/base/331382

Log:
  MFC r329508: MFV r324198: 8081 Compiler warnings in zdb
  
  illumos/illumos-gate@3f7978d02b206a6ebc5652c91aa9f42da6fbe00c
  
https://github.com/illumos/illumos-gate/commit/3f7978d02b206a6ebc5652c91aa9f42da6fbe00c
  
  https://www.illumos.org/issues/8081
zdb(8) is full of minor problems that generate compiler warnings. On 
FreeBSD,
which uses -WError, the only way to build it is to disable all compiler
warnings. This makes it much harder to detect newly introduced bugs. We 
should
cleanup all the warnings.
  
  Reviewed by: Matthew Ahrens 
  Reviewed by: Prakash Surya 
  Approved by: Richard Lowe 
  Author: Alan Somers 

Added:
  stable/11/cddl/contrib/opensolaris/cmd/zdb/zdb.h
 - copied unchanged from r329508, 
head/cddl/contrib/opensolaris/cmd/zdb/zdb.h
Modified:
  stable/11/cddl/contrib/opensolaris/cmd/zdb/zdb.c
  stable/11/cddl/contrib/opensolaris/cmd/zdb/zdb_il.c
  stable/11/cddl/contrib/opensolaris/cmd/ztest/ztest.c
  stable/11/cddl/contrib/opensolaris/lib/libzpool/common/sys/zfs_context.h
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/cddl/contrib/opensolaris/cmd/zdb/zdb.c
==
--- stable/11/cddl/contrib/opensolaris/cmd/zdb/zdb.cThu Mar 22 23:38:03 
2018(r331381)
+++ stable/11/cddl/contrib/opensolaris/cmd/zdb/zdb.cThu Mar 22 23:39:49 
2018(r331382)
@@ -67,6 +67,8 @@
 #undef verify
 #include 
 
+#include "zdb.h"
+
 #defineZDB_COMPRESS_NAME(idx) ((idx) < ZIO_COMPRESS_FUNCTIONS ?
\
zio_compress_table[(idx)].ci_name : "UNKNOWN")
 #defineZDB_CHECKSUM_NAME(idx) ((idx) < ZIO_CHECKSUM_FUNCTIONS ?
\
@@ -90,14 +92,13 @@ uint64_t zfs_arc_max, zfs_arc_meta_limit;
 int zfs_vdev_async_read_max_active;
 #endif
 
-const char cmdname[] = "zdb";
+static const char cmdname[] = "zdb";
 uint8_t dump_opt[256];
 
 typedef void object_viewer_t(objset_t *, uint64_t, void *data, size_t size);
 
-extern void dump_intent_log(zilog_t *);
 static uint64_t *zopt_object = NULL;
-static int zopt_objects = 0;
+static unsigned zopt_objects = 0;
 static libzfs_handle_t *g_zfs;
 static uint64_t max_inflight = 1000;
 
@@ -285,8 +286,8 @@ zdb_nicenum(uint64_t num, char *buf, size_t buflen)
nicenum(num, buf, sizeof (buf));
 }
 
-const char histo_stars[] = "";
-const int histo_width = sizeof (histo_stars) - 1;
+static const char histo_stars[] = "";
+static const uint64_t histo_width = sizeof (histo_stars) - 1;
 
 static void
 dump_histogram(const uint64_t *histo, int size, int offset)
@@ -392,7 +393,7 @@ dump_unknown(objset_t *os, uint64_t object, void *data
 }
 
 /*ARGSUSED*/
-void
+static void
 dump_uint8(objset_t *os, uint64_t object, void *data, size_t size)
 {
 }
@@ -410,7 +411,7 @@ dump_zap(objset_t *os, uint64_t object, void *data, si
zap_cursor_t zc;
zap_attribute_t attr;
void *prop;
-   int i;
+   unsigned i;
 
dump_zap_stats(os, object);
(void) printf("\n");
@@ -573,7 +574,7 @@ dump_sa_layouts(objset_t *os, uint64_t object, void *d
zap_cursor_t zc;
zap_attribute_t attr;
uint16_t *layout_attrs;
-   int i;
+   unsigned i;
 
dump_zap_stats(os, object);
(void) printf("\n");
@@ -642,7 +643,7 @@ dump_zpldir(objset_t *os, uint64_t object, void *data,
zap_cursor_fini();
 }
 
-int
+static int
 get_dtl_refcount(vdev_t *vd)
 {
int refcount = 0;
@@ -656,18 +657,18 @@ get_dtl_refcount(vdev_t *vd)
return (0);
}
 
-   for (int c = 0; c < vd->vdev_children; c++)
+   for (unsigned c = 0; c < vd->vdev_children; c++)
refcount += get_dtl_refcount(vd->vdev_child[c]);
return (refcount);
 }
 
-int
+static int
 get_metaslab_refcount(vdev_t *vd)
 {
int refcount = 0;
 
if (vd->vdev_top == vd && !vd->vdev_removing) {
-   for (int m = 0; m < vd->vdev_ms_count; m++) {
+   for (unsigned m = 0; m < vd->vdev_ms_count; m++) {
space_map_t *sm = vd->vdev_ms[m]->ms_sm;
 
if (sm != NULL &&
@@ -675,7 +676,7 @@ get_metaslab_refcount(vdev_t *vd)
refcount++;
}
}
-   for (int c = 0; c < vd->vdev_children; c++)
+   for (unsigned c = 0; c < vd->vdev_children; c++)
refcount += get_metaslab_refcount(vd->vdev_child[c]);
 
return (refcount);
@@ -707,7 +708,7 @@ static void
 dump_spacemap(objset_t *os, space_map_t *sm)
 {
uint64_t alloc, offset, entry;
-   char *ddata[] = { "ALLOC", "FREE", "CONDENSE", "INVALID",
+   const char *ddata[] 

svn commit: r331381 - stable/11/cddl/contrib/opensolaris/lib/libzfs/common

2018-03-22 Thread Alexander Motin
Author: mav
Date: Thu Mar 22 23:38:03 2018
New Revision: 331381
URL: https://svnweb.freebsd.org/changeset/base/331381

Log:
  MFC r329505: MFV r323911:
  8502 illumos#7955 broke delegated datasets when libshare is not present
  
  illumos/illumos-gate@1c18e8fbd8db41a9fb39bd3ef7a18ee71ece20da
  
https://github.com/illumos/illumos-gate/commit/1c18e8fbd8db41a9fb39bd3ef7a18ee71ece20da
  
  https://www.illumos.org/issues/8502
The code in lib/libzfs/common/libzfs_mount.c already basically handles
the case when libshare is not installed. We just need to not fail in
zfs_init_libshare_impl.  I tested this in lx and things work as
expected. I also tested there trying to set sharenfs and sharesmb on
the delegated dataset. Neither is allowed from within a zone.  The
spew of msgs from a native zone is not ZFS specific. I see the same
spew simply running the share command.
  
  Reviewed by: Robert Mustacchi 
  Reviewed by: Yuri Pankov 
  Approved by: Richard Lowe 
  Author: Jerry Jelinek 

Modified:
  stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_mount.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_mount.c
==
--- stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_mount.c Thu Mar 
22 23:34:48 2018(r331380)
+++ stable/11/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_mount.c Thu Mar 
22 23:38:03 2018(r331381)
@@ -24,6 +24,7 @@
  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
  * Copyright (c) 2014 by Delphix. All rights reserved.
  * Copyright 2016 Igor Kozhukhov 
+ * Copyright 2017 Joyent, Inc.
  * Copyright 2017 RackTop Systems.
  */
 
@@ -610,8 +611,14 @@ zfs_init_libshare(libzfs_handle_t *zhandle, int servic
int ret = SA_OK;
 
 #ifdef illumos
+   /*
+* libshare is either not installed or we're in a branded zone. The
+* rest of the wrapper functions around the libshare calls already
+* handle NULL function pointers, but we don't want the callers of
+* zfs_init_libshare() to fail prematurely if libshare is not available.
+*/
if (_sa_init == NULL)
-   ret = SA_CONFIG_ERR;
+   return (SA_OK);
 
if (ret == SA_OK && zhandle->libzfs_shareflags & ZFSSHARE_MISS) {
/*
___
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: r331380 - head/sys/netinet6

2018-03-22 Thread Sean Bruno
Author: sbruno
Date: Thu Mar 22 23:34:48 2018
New Revision: 331380
URL: https://svnweb.freebsd.org/changeset/base/331380

Log:
  Refactor ip6_getpcbopt() for better locking and memory management
  
  Created GET_PKTOPT_EXT_HDR() and GET_PKTOPT_SOCKADDR() macros to
  handle safely fetching options from in6p_outputopts, including
  properly dealing with in6p locking and preparing memory for
  sooptcopyout().
  
  Changed the function signature of ip6_getpcbopt() to allow the
  function to acquire and release locks on in6p as needed.
  
  Submitted by: Jason Eggleston 
  Sponsored by: Limelight Networks
  Differential Revision:https://reviews.freebsd.org/D14619

Modified:
  head/sys/netinet6/ip6_output.c

Modified: head/sys/netinet6/ip6_output.c
==
--- head/sys/netinet6/ip6_output.c  Thu Mar 22 22:29:32 2018
(r331379)
+++ head/sys/netinet6/ip6_output.c  Thu Mar 22 23:34:48 2018
(r331380)
@@ -135,7 +135,7 @@ static int ip6_pcbopt(int, u_char *, int, struct ip6_p
   struct ucred *, int);
 static int ip6_pcbopts(struct ip6_pktopts **, struct mbuf *,
struct socket *, struct sockopt *);
-static int ip6_getpcbopt(struct ip6_pktopts *, int, struct sockopt *);
+static int ip6_getpcbopt(struct inpcb *, int, struct sockopt *);
 static int ip6_setpktopt(int, u_char *, int, struct ip6_pktopts *,
struct ucred *, int, int, int);
 
@@ -2132,8 +2132,7 @@ do {  
\
case IPV6_DONTFRAG:
case IPV6_USE_MIN_MTU:
case IPV6_PREFER_TEMPADDR:
-   error = ip6_getpcbopt(in6p->in6p_outputopts,
-   optname, sopt);
+   error = ip6_getpcbopt(in6p, optname, sopt);
break;
 
case IPV6_MULTICAST_IF:
@@ -2310,18 +2309,51 @@ ip6_pcbopt(int optname, u_char *buf, int len, struct i
return (ip6_setpktopt(optname, buf, len, opt, cred, 1, 0, uproto));
 }
 
+#define GET_PKTOPT_VAR(field, lenexpr) do {
\
+   if (pktopt && pktopt->field) {  
\
+   INP_RUNLOCK(in6p);  
\
+   optdata = malloc(sopt->sopt_valsize, M_TEMP, M_WAITOK); 
\
+   malloc_optdata = true;  
\
+   INP_RLOCK(in6p);
\
+   if (in6p->inp_flags & (INP_TIMEWAIT | INP_DROPPED)) {   
\
+   INP_RUNLOCK(in6p);  
\
+   free(optdata, M_TEMP);  
\
+   return (ECONNRESET);
\
+   }   
\
+   pktopt = in6p->in6p_outputopts; 
\
+   if (pktopt && pktopt->field) {  
\
+   optdatalen = min(lenexpr, sopt->sopt_valsize);  
\
+   bcopy(>field, optdata, optdatalen); 
\
+   } else {
\
+   free(optdata, M_TEMP);  
\
+   optdata = NULL; 
\
+   malloc_optdata = false; 
\
+   }   
\
+   }   
\
+} while(0)
+
+#define GET_PKTOPT_EXT_HDR(field) GET_PKTOPT_VAR(field,
\
+   (((struct ip6_ext *)pktopt->field)->ip6e_len + 1) << 3)
+
+#define GET_PKTOPT_SOCKADDR(field) GET_PKTOPT_VAR(field,   
\
+   pktopt->field->sa_len)
+
 static int
-ip6_getpcbopt(struct ip6_pktopts *pktopt, int optname, struct sockopt *sopt)
+ip6_getpcbopt(struct inpcb *in6p, int optname, struct sockopt *sopt)
 {
void *optdata = NULL;
+   bool malloc_optdata = false;
int optdatalen = 0;
-   struct ip6_ext *ip6e;
int error = 0;
struct in6_pktinfo null_pktinfo;
int deftclass = 0, on;
int defminmtu = IP6PO_MINMTU_MCASTONLY;
int defpreftemp = IP6PO_TEMPADDR_SYSTEM;
+   struct ip6_pktopts *pktopt;
 
+   INP_RLOCK(in6p);
+   pktopt = in6p->in6p_outputopts;
+
switch (optname) {
case IPV6_PKTINFO:
optdata = (void *)_pktinfo;
@@ -2337,50 +2369,29 @@ ip6_getpcbopt(struct ip6_pktopts *pktopt, int optname,

svn commit: r331379 - in head/sys: netinet netinet6

2018-03-22 Thread Sean Bruno
Author: sbruno
Date: Thu Mar 22 22:29:32 2018
New Revision: 331379
URL: https://svnweb.freebsd.org/changeset/base/331379

Log:
  Simple locking fixes in ip_ctloutput, ip6_ctloutput, rip_ctloutput.
  
  Submitted by: Jason Eggleston 
  Sponsored by: Limelight Networks
  Differential Revision:https://reviews.freebsd.org/D14624

Modified:
  head/sys/netinet/ip_output.c
  head/sys/netinet/raw_ip.c
  head/sys/netinet6/ip6_output.c

Modified: head/sys/netinet/ip_output.c
==
--- head/sys/netinet/ip_output.cThu Mar 22 22:13:46 2018
(r331378)
+++ head/sys/netinet/ip_output.cThu Mar 22 22:29:32 2018
(r331379)
@@ -1314,12 +1314,14 @@ ip_ctloutput(struct socket *so, struct sockopt *sopt)
break;
 
case IP_PORTRANGE:
+   INP_RLOCK(inp);
if (inp->inp_flags & INP_HIGHPORT)
optval = IP_PORTRANGE_HIGH;
else if (inp->inp_flags & INP_LOWPORT)
optval = IP_PORTRANGE_LOW;
else
optval = 0;
+   INP_RUNLOCK(inp);
break;
 
case IP_ONESBCAST:
@@ -1345,9 +1347,11 @@ ip_ctloutput(struct socket *so, struct sockopt *sopt)
break;
 #ifdef RSS
case IP_RSSBUCKETID:
+   INP_RLOCK(inp);
retval = rss_hash2bucket(inp->inp_flowid,
inp->inp_flowtype,
_bucket);
+   INP_RUNLOCK(inp);
if (retval == 0)
optval = rss_bucket;
else

Modified: head/sys/netinet/raw_ip.c
==
--- head/sys/netinet/raw_ip.c   Thu Mar 22 22:13:46 2018(r331378)
+++ head/sys/netinet/raw_ip.c   Thu Mar 22 22:29:32 2018(r331379)
@@ -639,10 +639,12 @@ rip_ctloutput(struct socket *so, struct sockopt *sopt)
sizeof optval);
if (error)
break;
+   INP_WLOCK(inp);
if (optval)
inp->inp_flags |= INP_HDRINCL;
else
inp->inp_flags &= ~INP_HDRINCL;
+   INP_WUNLOCK(inp);
break;
 
case IP_FW3:/* generic ipfw v.3 functions */

Modified: head/sys/netinet6/ip6_output.c
==
--- head/sys/netinet6/ip6_output.c  Thu Mar 22 22:13:46 2018
(r331378)
+++ head/sys/netinet6/ip6_output.c  Thu Mar 22 22:29:32 2018
(r331379)
@@ -1498,8 +1498,10 @@ ip6_ctloutput(struct socket *so, struct sockopt *sopt)
error = soopt_mcopyin(sopt, m); /* XXX */
if (error != 0)
break;
+   INP_WLOCK(in6p);
error = ip6_pcbopts(>in6p_outputopts,
m, so, sopt);
+   INP_WUNLOCK(in6p);
m_freem(m); /* XXX */
break;
}
@@ -1635,11 +1637,13 @@ do {
\
error = EINVAL;
break;
}
+   INP_WLOCK(in6p);
optp = >in6p_outputopts;
error = ip6_pcbopt(IPV6_HOPLIMIT,
(u_char *), sizeof(optval),
optp, (td != NULL) ? td->td_ucred :
NULL, uproto);
+   INP_WUNLOCK(in6p);
break;
}
 
@@ -1690,8 +1694,10 @@ do { 
\
 * available only prior to bind(2).
 * see ipng mailing list, Jun 22 2001.
 */
+   INP_WLOCK(in6p);
if 

svn commit: r331378 - head/sys/dev/bhnd/nvram

2018-03-22 Thread Landon J. Fuller
Author: landonf
Date: Thu Mar 22 22:13:46 2018
New Revision: 331378
URL: https://svnweb.freebsd.org/changeset/base/331378

Log:
  Add missing NULL checks when calling malloc(M_NOWAIT) in
  bhnd_nv_strdup/bhnd_nv_strndup.
  
  If malloc(9) failed during initial bhnd(4) attach, while allocating the root
  NVRAM path string ("/"), the returned NULL pointer would be passed as the
  destination to memcpy().
  
  Reported by:  Ilja Van Sprundel 

Modified:
  head/sys/dev/bhnd/nvram/bhnd_nvram_private.h

Modified: head/sys/dev/bhnd/nvram/bhnd_nvram_private.h
==
--- head/sys/dev/bhnd/nvram/bhnd_nvram_private.hThu Mar 22 21:57:10 
2018(r331377)
+++ head/sys/dev/bhnd/nvram/bhnd_nvram_private.hThu Mar 22 22:13:46 
2018(r331378)
@@ -91,6 +91,9 @@ bhnd_nv_strdup(const char *str)
 
len = strlen(str);
dest = malloc(len + 1, M_BHND_NVRAM, M_NOWAIT);
+   if (dest == NULL)
+   return (NULL);
+
memcpy(dest, str, len);
dest[len] = '\0';
 
@@ -105,6 +108,9 @@ bhnd_nv_strndup(const char *str, size_t len)
 
len = strnlen(str, len);
dest = malloc(len + 1, M_BHND_NVRAM, M_NOWAIT);
+   if (dest == NULL)
+   return (NULL);
+
memcpy(dest, str, len);
dest[len] = '\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"


Re: svn commit: r331369 - head/sys/vm

2018-03-22 Thread Justin Hibbits
This broke gcc builds.

On Thu, Mar 22, 2018 at 2:21 PM, Jeff Roberson  wrote:
> Author: jeff
> Date: Thu Mar 22 19:21:11 2018
> New Revision: 331369
> URL: https://svnweb.freebsd.org/changeset/base/331369
>
> Log:
>   Lock reservations with a dedicated lock in each reservation.  Protect the
>   vmd_free_count with atomics.
>
>   This allows us to allocate and free from reservations without the free lock
>   except where a superpage is allocated from the physical layer, which is
>   roughly 1/512 of the operations on amd64.
>
>   Use the counter api to eliminate cache conention on counters.
>
>   Reviewed by:  markj
>   Tested by:pho
>   Sponsored by: Netflix, Dell/EMC Isilon
>   Differential Revision:https://reviews.freebsd.org/D14707
>
> Modified:
>   head/sys/vm/vm_page.c
>   head/sys/vm/vm_pagequeue.h
>   head/sys/vm/vm_reserv.c
>   head/sys/vm/vm_reserv.h
>
> Modified: head/sys/vm/vm_page.c
> ==
> --- head/sys/vm/vm_page.c   Thu Mar 22 19:11:43 2018(r331368)
> +++ head/sys/vm/vm_page.c   Thu Mar 22 19:21:11 2018(r331369)
> @@ -177,7 +177,6 @@ static uma_zone_t fakepg_zone;
>  static void vm_page_alloc_check(vm_page_t m);
>  static void vm_page_clear_dirty_mask(vm_page_t m, vm_page_bits_t pagebits);
>  static void vm_page_enqueue(uint8_t queue, vm_page_t m);
> -static void vm_page_free_phys(struct vm_domain *vmd, vm_page_t m);
>  static void vm_page_init(void *dummy);
>  static int vm_page_insert_after(vm_page_t m, vm_object_t object,
>  vm_pindex_t pindex, vm_page_t mpred);
> @@ -1677,10 +1676,10 @@ vm_page_alloc_after(vm_object_t object, vm_pindex_t pi
>   * for the request class and false otherwise.
>   */
>  int
> -vm_domain_available(struct vm_domain *vmd, int req, int npages)
> +vm_domain_allocate(struct vm_domain *vmd, int req, int npages)
>  {
> +   u_int limit, old, new;
>
> -   vm_domain_free_assert_locked(vmd);
> req = req & VM_ALLOC_CLASS_MASK;
>
> /*
> @@ -1688,15 +1687,34 @@ vm_domain_available(struct vm_domain *vmd, int req, in
>  */
> if (curproc == pageproc && req != VM_ALLOC_INTERRUPT)
> req = VM_ALLOC_SYSTEM;
> +   if (req == VM_ALLOC_INTERRUPT)
> +   limit = 0;
> +   else if (req == VM_ALLOC_SYSTEM)
> +   limit = vmd->vmd_interrupt_free_min;
> +   else
> +   limit = vmd->vmd_free_reserved;
>
> -   if (vmd->vmd_free_count >= npages + vmd->vmd_free_reserved ||
> -   (req == VM_ALLOC_SYSTEM &&
> -   vmd->vmd_free_count >= npages + vmd->vmd_interrupt_free_min) ||
> -   (req == VM_ALLOC_INTERRUPT &&
> -   vmd->vmd_free_count >= npages))
> -   return (1);
> +   /*
> +* Attempt to reserve the pages.  Fail if we're below the limit.
> +*/
> +   limit += npages;
> +   old = vmd->vmd_free_count;
> +   do {
> +   if (old < limit)
> +   return (0);
> +   new = old - npages;
> +   } while (atomic_fcmpset_int(>vmd_free_count, , new) == 0);
>
> -   return (0);
> +   /* Wake the page daemon if we've crossed the threshold. */
> +   if (vm_paging_needed(vmd, new) && !vm_paging_needed(vmd, old))
> +   pagedaemon_wakeup(vmd->vmd_domain);
> +
> +   /* Only update bitsets on transitions. */
> +   if ((old >= vmd->vmd_free_min && new < vmd->vmd_free_min) ||
> +   (old >= vmd->vmd_free_severe && new < vmd->vmd_free_severe))
> +   vm_domain_set(vmd);
> +
> +   return (1);
>  }
>
>  vm_page_t
> @@ -1723,44 +1741,34 @@ vm_page_alloc_domain_after(vm_object_t object, vm_pind
>  again:
> m = NULL;
>  #if VM_NRESERVLEVEL > 0
> +   /*
> +* Can we allocate the page from a reservation?
> +*/
> if (vm_object_reserv(object) &&
> -   (m = vm_reserv_extend(req, object, pindex, domain, mpred))
> -   != NULL) {
> +   ((m = vm_reserv_extend(req, object, pindex, domain, mpred)) != 
> NULL ||
> +   (m = vm_reserv_alloc_page(req, object, pindex, domain, mpred)) != 
> NULL)) {
> domain = vm_phys_domain(m);
> vmd = VM_DOMAIN(domain);
> goto found;
> }
>  #endif
> vmd = VM_DOMAIN(domain);
> -   vm_domain_free_lock(vmd);
> -   if (vm_domain_available(vmd, req, 1)) {
> +   if (vm_domain_allocate(vmd, req, 1)) {
> /*
> -* Can we allocate the page from a reservation?
> +* If not, allocate it from the free page queues.
>  */
> +   vm_domain_free_lock(vmd);
> +   m = vm_phys_alloc_pages(domain, object != NULL ?
> +   VM_FREEPOOL_DEFAULT : VM_FREEPOOL_DIRECT, 0);
> +   vm_domain_free_unlock(vmd);
> +   if (m == NULL) {
> +   

svn commit: r331376 - head/sys/netinet6

2018-03-22 Thread Sean Bruno
Author: sbruno
Date: Thu Mar 22 21:18:34 2018
New Revision: 331376
URL: https://svnweb.freebsd.org/changeset/base/331376

Log:
  Handle locking and memory safety for IPV6_PATHMTU in ip6_ctloutput().
  
  Submitted by: Jason Eggleston 
  Reviewed by:  ae
  Sponsored by: Limelight Networks
  Differential Revision:https://reviews.freebsd.org/D14622

Modified:
  head/sys/netinet6/ip6_output.c

Modified: head/sys/netinet6/ip6_output.c
==
--- head/sys/netinet6/ip6_output.c  Thu Mar 22 20:47:25 2018
(r331375)
+++ head/sys/netinet6/ip6_output.c  Thu Mar 22 21:18:34 2018
(r331376)
@@ -2053,6 +2053,7 @@ do {  
\
{
u_long pmtu = 0;
struct ip6_mtuinfo mtuinfo;
+   struct in6_addr addr;
 
if (!(so->so_state & SS_ISCONNECTED))
return (ENOTCONN);
@@ -2060,9 +2061,14 @@ do { 
\
 * XXX: we dot not consider the case of source
 * routing, or optional information to specify
 * the outgoing interface.
+* Copy faddr out of in6p to avoid holding lock
+* on inp during route lookup.
 */
+   INP_RLOCK(in6p);
+   bcopy(>in6p_faddr, , sizeof(addr));
+   INP_RUNLOCK(in6p);
error = ip6_getpmtu_ctl(so->so_fibnum,
-   >in6p_faddr, );
+   , );
if (error)
break;
if (pmtu > IPV6_MAXPACKET)
___
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: r331347 - in head: etc/mtree include sys/conf sys/dev/tcp_log sys/kern sys/netinet usr.bin/netstat

2018-03-22 Thread Justin Hibbits
On Thu, Mar 22, 2018 at 3:44 PM, Andriy Gapon  wrote:
> On 22/03/2018 17:39, Jonathan Looney wrote:
>> A tinderbox build didn't complain about atomic_fetchadd_64, so I assume it 
>> is OK.
>>
>> Yes, this can be made optional, if there is a need for that.
>>
>
> FWWI, TARGET=powerpc TARGET_ARCH=powerpc build failed for me.
>
> cc1: warnings being treated as errors
> /usr/devel/svn/head/sys/netinet/tcp_log_buf.c: In function 
> 'tcp_log_selectauto':
> /usr/devel/svn/head/sys/netinet/tcp_log_buf.c:286: warning: implicit 
> declaration
> of function 'atomic_fetchadd_64'
> /usr/devel/svn/head/sys/netinet/tcp_log_buf.c:286: warning: nested extern
> declaration of 'atomic_fetchadd_64' [-Wnested-externs]
>
> --
> Andriy Gapon
>

mips complains, too.  Check out https://ci.freebsd.org/tinderbox .

- 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"


svn commit: r331375 - head/sys/kern

2018-03-22 Thread Konstantin Belousov
Author: kib
Date: Thu Mar 22 20:47:25 2018
New Revision: 331375
URL: https://svnweb.freebsd.org/changeset/base/331375

Log:
  Do not send signals to init directly from shutdown_nice(9), do it from
  the task context.
  
  shutdown_nice() is used from the fast interrupt handlers, mostly for
  console drivers, where we cannot lock blockable locks.  Schedule the
  task in the fast queue to send the signal from the proper context.
  
  Reviewed by:  imp
  Discussed with:   bde
  Sponsored by: The FreeBSD Foundation
  MFC after:1 week

Modified:
  head/sys/kern/kern_shutdown.c

Modified: head/sys/kern/kern_shutdown.c
==
--- head/sys/kern/kern_shutdown.c   Thu Mar 22 20:44:27 2018
(r331374)
+++ head/sys/kern/kern_shutdown.c   Thu Mar 22 20:47:25 2018
(r331375)
@@ -72,6 +72,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -276,6 +277,28 @@ sys_reboot(struct thread *td, struct reboot_args *uap)
return (error);
 }
 
+static void
+shutdown_nice_task_fn(void *arg, int pending __unused)
+{
+   int howto;
+
+   howto = (uintptr_t)arg;
+   /* Send a signal to init(8) and have it shutdown the world. */
+   PROC_LOCK(initproc);
+   if (howto & RB_POWEROFF)
+   kern_psignal(initproc, SIGUSR2);
+   else if (howto & RB_POWERCYCLE)
+   kern_psignal(initproc, SIGWINCH);
+   else if (howto & RB_HALT)
+   kern_psignal(initproc, SIGUSR1);
+   else
+   kern_psignal(initproc, SIGINT);
+   PROC_UNLOCK(initproc);
+}
+
+static struct task shutdown_nice_task = TASK_INITIALIZER(0,
+_nice_task_fn, NULL);
+
 /*
  * Called by events that want to shut down.. e.g   on a PC
  */
@@ -283,20 +306,14 @@ void
 shutdown_nice(int howto)
 {
 
-   if (initproc != NULL) {
-   /* Send a signal to init(8) and have it shutdown the world. */
-   PROC_LOCK(initproc);
-   if (howto & RB_POWEROFF)
-   kern_psignal(initproc, SIGUSR2);
-   else if (howto & RB_POWERCYCLE)
-   kern_psignal(initproc, SIGWINCH);
-   else if (howto & RB_HALT)
-   kern_psignal(initproc, SIGUSR1);
-   else
-   kern_psignal(initproc, SIGINT);
-   PROC_UNLOCK(initproc);
+   if (initproc != NULL && !SCHEDULER_STOPPED()) {
+   shutdown_nice_task.ta_context = (void *)(uintptr_t)howto;
+   taskqueue_enqueue(taskqueue_fast, _nice_task);
} else {
-   /* No init(8) running, so simply reboot. */
+   /*
+* No init(8) running, or scheduler would not allow it
+* to run, so simply reboot.
+*/
kern_reboot(howto | RB_NOSYNC);
}
 }
___
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: r331374 - head/sys/amd64/amd64

2018-03-22 Thread Konstantin Belousov
Author: kib
Date: Thu Mar 22 20:44:27 2018
New Revision: 331374
URL: https://svnweb.freebsd.org/changeset/base/331374

Log:
  Fixes for ptrace(PT_GETXSTATE_INFO) related to the padding in struct
  ptrace_xstate_info).
  
  struct ptrace_xstate_info has 64bit member but ends up with 32bit
  one. As result, on amd64 there is a 32bit padding at the end, but not
  on i386.
  
  We must clear the padding before doing the copyout. For compat32 case,
  we must copyout the structure which does not have the padding at the
  end.  The later fixes 32bit gdb display of the YMM registers when
  running on amd64 kernel.
  
  Reported by:  Vlad Tsyrklevich
  Reviewed by:  brooks (previous version)
  Sponsored by: The FreeBSD Foundation
  admbugs:  765
  MFC after:1 week
  Differential revision:https://reviews.freebsd.org/D14794

Modified:
  head/sys/amd64/amd64/ptrace_machdep.c

Modified: head/sys/amd64/amd64/ptrace_machdep.c
==
--- head/sys/amd64/amd64/ptrace_machdep.c   Thu Mar 22 20:21:05 2018
(r331373)
+++ head/sys/amd64/amd64/ptrace_machdep.c   Thu Mar 22 20:44:27 2018
(r331374)
@@ -45,10 +45,20 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 
+#ifdef COMPAT_FREEBSD32
+struct ptrace_xstate_info32 {
+   uint32_txsave_mask1, xsave_mask2;
+   uint32_txsave_len;
+};
+#endif
+
 static int
 cpu_ptrace_xstate(struct thread *td, int req, void *addr, int data)
 {
struct ptrace_xstate_info info;
+#ifdef COMPAT_FREEBSD32
+   struct ptrace_xstate_info32 info32;
+#endif
char *savefpu;
int error;
 
@@ -78,13 +88,28 @@ cpu_ptrace_xstate(struct thread *td, int req, void *ad
break;
 
case PT_GETXSTATE_INFO:
-   if (data != sizeof(info)) {
-   error  = EINVAL;
-   break;
+#ifdef COMPAT_FREEBSD32
+   if (SV_CURPROC_FLAG(SV_ILP32)) {
+   if (data != sizeof(info32)) {
+   error = EINVAL;
+   } else {
+   info32.xsave_len = cpu_max_ext_state_size;
+   info32.xsave_mask1 = xsave_mask;
+   info32.xsave_mask2 = xsave_mask >> 32;
+   error = copyout(, addr, data);
+   }
+   } else
+#endif
+   {
+   if (data != sizeof(info)) {
+   error  = EINVAL;
+   } else {
+   bzero(, sizeof(info));
+   info.xsave_len = cpu_max_ext_state_size;
+   info.xsave_mask = xsave_mask;
+   error = copyout(, addr, data);
+   }
}
-   info.xsave_len = cpu_max_ext_state_size;
-   info.xsave_mask = xsave_mask;
-   error = copyout(, addr, data);
break;
 
case PT_GETXSTATE:
___
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: r331347 - in head: etc/mtree include sys/conf sys/dev/tcp_log sys/kern sys/netinet usr.bin/netstat

2018-03-22 Thread Andriy Gapon
On 22/03/2018 17:39, Jonathan Looney wrote:
> A tinderbox build didn't complain about atomic_fetchadd_64, so I assume it is 
> OK.
> 
> Yes, this can be made optional, if there is a need for that.
> 

FWWI, TARGET=powerpc TARGET_ARCH=powerpc build failed for me.

cc1: warnings being treated as errors
/usr/devel/svn/head/sys/netinet/tcp_log_buf.c: In function 'tcp_log_selectauto':
/usr/devel/svn/head/sys/netinet/tcp_log_buf.c:286: warning: implicit declaration
of function 'atomic_fetchadd_64'
/usr/devel/svn/head/sys/netinet/tcp_log_buf.c:286: warning: nested extern
declaration of 'atomic_fetchadd_64' [-Wnested-externs]

-- 
Andriy Gapon
___
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: r331373 - head/sys/netinet6

2018-03-22 Thread Sean Bruno
Author: sbruno
Date: Thu Mar 22 20:21:05 2018
New Revision: 331373
URL: https://svnweb.freebsd.org/changeset/base/331373

Log:
  Improve write locking in ip6_ctloutput() with macros.
  
  Submitted by: Jason Eggleston 
  Sponsored by: Limelight Networks
  Differential Revision:https://reviews.freebsd.org/D14620

Modified:
  head/sys/netinet6/ip6_output.c

Modified: head/sys/netinet6/ip6_output.c
==
--- head/sys/netinet6/ip6_output.c  Thu Mar 22 19:49:37 2018
(r331372)
+++ head/sys/netinet6/ip6_output.c  Thu Mar 22 20:21:05 2018
(r331373)
@@ -1596,23 +1596,34 @@ do { \
 } while (/*CONSTCOND*/ 0)
 #define OPTBIT(bit) (in6p->inp_flags & (bit) ? 1 : 0)
 
-#define OPTSET2(bit, val) do { \
-   INP_WLOCK(in6p);\
+#define OPTSET2_N(bit, val) do {   \
if (val)\
in6p->inp_flags2 |= bit;\
else\
in6p->inp_flags2 &= ~bit;   \
+} while (0)
+#define OPTSET2(bit, val) do { \
+   INP_WLOCK(in6p);\
+   OPTSET2_N(bit, val);\
INP_WUNLOCK(in6p);  \
 } while (0)
 #define OPTBIT2(bit) (in6p->inp_flags2 & (bit) ? 1 : 0)
+#define OPTSET2292_EXCLUSIVE(bit)  \
+do {   \
+   INP_WLOCK(in6p);\
+   if (OPTBIT(IN6P_RFC2292)) { \
+   error = EINVAL; \
+   } else {\
+   if (optval) \
+   in6p->inp_flags |= (bit);   \
+   else\
+   in6p->inp_flags &= ~(bit);  \
+   }   \
+   INP_WUNLOCK(in6p);  \
+} while (/*CONSTCOND*/ 0)
 
case IPV6_RECVPKTINFO:
-   /* cannot mix with RFC2292 */
-   if (OPTBIT(IN6P_RFC2292)) {
-   error = EINVAL;
-   break;
-   }
-   OPTSET(IN6P_PKTINFO);
+   OPTSET2292_EXCLUSIVE(IN6P_PKTINFO);
break;
 
case IPV6_HOPLIMIT:
@@ -1633,48 +1644,23 @@ do { \
}
 
case IPV6_RECVHOPLIMIT:
-   /* cannot mix with RFC2292 */
-   if (OPTBIT(IN6P_RFC2292)) {
-   error = EINVAL;
-   break;
-   }
-   OPTSET(IN6P_HOPLIMIT);
+   OPTSET2292_EXCLUSIVE(IN6P_HOPLIMIT);
break;
 
case IPV6_RECVHOPOPTS:
-   /* cannot mix with RFC2292 */
-   if (OPTBIT(IN6P_RFC2292)) {
-   error = EINVAL;
-   break;
-   }
-   OPTSET(IN6P_HOPOPTS);
+   OPTSET2292_EXCLUSIVE(IN6P_HOPOPTS);
break;
 
case IPV6_RECVDSTOPTS:
-   /* cannot mix with RFC2292 */
-   if (OPTBIT(IN6P_RFC2292)) {
-   error = EINVAL;
-   break;
-   }
-   OPTSET(IN6P_DSTOPTS);
+   OPTSET2292_EXCLUSIVE(IN6P_DSTOPTS);
break;
 
case IPV6_RECVRTHDRDSTOPTS:
-   /* cannot mix 

svn commit: r331369 - head/sys/vm

2018-03-22 Thread Jeff Roberson
Author: jeff
Date: Thu Mar 22 19:21:11 2018
New Revision: 331369
URL: https://svnweb.freebsd.org/changeset/base/331369

Log:
  Lock reservations with a dedicated lock in each reservation.  Protect the
  vmd_free_count with atomics.
  
  This allows us to allocate and free from reservations without the free lock
  except where a superpage is allocated from the physical layer, which is
  roughly 1/512 of the operations on amd64.
  
  Use the counter api to eliminate cache conention on counters.
  
  Reviewed by:  markj
  Tested by:pho
  Sponsored by: Netflix, Dell/EMC Isilon
  Differential Revision:https://reviews.freebsd.org/D14707

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

Modified: head/sys/vm/vm_page.c
==
--- head/sys/vm/vm_page.c   Thu Mar 22 19:11:43 2018(r331368)
+++ head/sys/vm/vm_page.c   Thu Mar 22 19:21:11 2018(r331369)
@@ -177,7 +177,6 @@ static uma_zone_t fakepg_zone;
 static void vm_page_alloc_check(vm_page_t m);
 static void vm_page_clear_dirty_mask(vm_page_t m, vm_page_bits_t pagebits);
 static void vm_page_enqueue(uint8_t queue, vm_page_t m);
-static void vm_page_free_phys(struct vm_domain *vmd, vm_page_t m);
 static void vm_page_init(void *dummy);
 static int vm_page_insert_after(vm_page_t m, vm_object_t object,
 vm_pindex_t pindex, vm_page_t mpred);
@@ -1677,10 +1676,10 @@ vm_page_alloc_after(vm_object_t object, vm_pindex_t pi
  * for the request class and false otherwise.
  */
 int
-vm_domain_available(struct vm_domain *vmd, int req, int npages)
+vm_domain_allocate(struct vm_domain *vmd, int req, int npages)
 {
+   u_int limit, old, new;
 
-   vm_domain_free_assert_locked(vmd);
req = req & VM_ALLOC_CLASS_MASK;
 
/*
@@ -1688,15 +1687,34 @@ vm_domain_available(struct vm_domain *vmd, int req, in
 */
if (curproc == pageproc && req != VM_ALLOC_INTERRUPT)
req = VM_ALLOC_SYSTEM;
+   if (req == VM_ALLOC_INTERRUPT)
+   limit = 0;
+   else if (req == VM_ALLOC_SYSTEM)
+   limit = vmd->vmd_interrupt_free_min;
+   else
+   limit = vmd->vmd_free_reserved;
 
-   if (vmd->vmd_free_count >= npages + vmd->vmd_free_reserved ||
-   (req == VM_ALLOC_SYSTEM &&
-   vmd->vmd_free_count >= npages + vmd->vmd_interrupt_free_min) ||
-   (req == VM_ALLOC_INTERRUPT &&
-   vmd->vmd_free_count >= npages))
-   return (1);
+   /*
+* Attempt to reserve the pages.  Fail if we're below the limit.
+*/
+   limit += npages;
+   old = vmd->vmd_free_count;
+   do {
+   if (old < limit)
+   return (0);
+   new = old - npages;
+   } while (atomic_fcmpset_int(>vmd_free_count, , new) == 0);
 
-   return (0);
+   /* Wake the page daemon if we've crossed the threshold. */
+   if (vm_paging_needed(vmd, new) && !vm_paging_needed(vmd, old))
+   pagedaemon_wakeup(vmd->vmd_domain);
+
+   /* Only update bitsets on transitions. */
+   if ((old >= vmd->vmd_free_min && new < vmd->vmd_free_min) ||
+   (old >= vmd->vmd_free_severe && new < vmd->vmd_free_severe))
+   vm_domain_set(vmd);
+
+   return (1);
 }
 
 vm_page_t
@@ -1723,44 +1741,34 @@ vm_page_alloc_domain_after(vm_object_t object, vm_pind
 again:
m = NULL;
 #if VM_NRESERVLEVEL > 0
+   /*
+* Can we allocate the page from a reservation?
+*/
if (vm_object_reserv(object) &&
-   (m = vm_reserv_extend(req, object, pindex, domain, mpred))
-   != NULL) {
+   ((m = vm_reserv_extend(req, object, pindex, domain, mpred)) != NULL 
||
+   (m = vm_reserv_alloc_page(req, object, pindex, domain, mpred)) != 
NULL)) {
domain = vm_phys_domain(m);
vmd = VM_DOMAIN(domain);
goto found;
}
 #endif
vmd = VM_DOMAIN(domain);
-   vm_domain_free_lock(vmd);
-   if (vm_domain_available(vmd, req, 1)) {
+   if (vm_domain_allocate(vmd, req, 1)) {
/*
-* Can we allocate the page from a reservation?
+* If not, allocate it from the free page queues.
 */
+   vm_domain_free_lock(vmd);
+   m = vm_phys_alloc_pages(domain, object != NULL ?
+   VM_FREEPOOL_DEFAULT : VM_FREEPOOL_DIRECT, 0);
+   vm_domain_free_unlock(vmd);
+   if (m == NULL) {
+   vm_domain_freecnt_inc(vmd, 1);
 #if VM_NRESERVLEVEL > 0
-   if (!vm_object_reserv(object) ||
-   (m = vm_reserv_alloc_page(object, pindex,
-   domain, mpred)) == NULL)
+   if (vm_reserv_reclaim_inactive(domain))
+   goto again;
 #endif
- 

svn commit: r331368 - in head/sys: kern sys vm

2018-03-22 Thread Jeff Roberson
Author: jeff
Date: Thu Mar 22 19:11:43 2018
New Revision: 331368
URL: https://svnweb.freebsd.org/changeset/base/331368

Log:
  Start witness much earlier in boot so that we can shrink the pend list and
  make it more immune to further change.
  
  Reviewed by:  markj, imp (Part of D14707)
  Sponsored by: Netflix, Dell/EMC Isilon

Modified:
  head/sys/kern/subr_witness.c
  head/sys/sys/lock.h
  head/sys/vm/vm_page.c

Modified: head/sys/kern/subr_witness.c
==
--- head/sys/kern/subr_witness.cThu Mar 22 19:06:50 2018
(r331367)
+++ head/sys/kern/subr_witness.cThu Mar 22 19:11:43 2018
(r331368)
@@ -139,7 +139,7 @@ __FBSDID("$FreeBSD$");
 #defineWITNESS_COUNT   1536
 #endif
 #defineWITNESS_HASH_SIZE   251 /* Prime, gives load factor < 2 
*/
-#defineWITNESS_PENDLIST(2048 + (MAXCPU * 4))
+#defineWITNESS_PENDLIST(512 + (MAXCPU * 4))
 
 /* Allocate 256 KB of stack data space */
 #defineWITNESS_LO_DATA_COUNT   2048
@@ -752,27 +752,45 @@ fixup_filename(const char *file)
 }
 
 /*
+ * Calculate the size of early witness structures.
+ */
+int
+witness_startup_count(void)
+{
+   int sz;
+
+   sz = sizeof(struct witness) * witness_count;
+   sz += sizeof(*w_rmatrix) * (witness_count + 1);
+   sz += sizeof(*w_rmatrix[0]) * (witness_count + 1) *
+   (witness_count + 1);
+
+   return (sz);
+}
+
+/*
  * The WITNESS-enabled diagnostic code.  Note that the witness code does
  * assume that the early boot is single-threaded at least until after this
  * routine is completed.
  */
-static void
-witness_initialize(void *dummy __unused)
+void
+witness_startup(void *mem)
 {
struct lock_object *lock;
struct witness_order_list_entry *order;
struct witness *w, *w1;
+   uintptr_t p;
int i;
 
-   w_data = malloc(sizeof (struct witness) * witness_count, M_WITNESS,
-   M_WAITOK | M_ZERO);
+   p = (uintptr_t)mem;
+   w_data = (void *)p;
+   p += sizeof(struct witness) * witness_count;
 
-   w_rmatrix = malloc(sizeof(*w_rmatrix) * (witness_count + 1),
-   M_WITNESS, M_WAITOK | M_ZERO);
+   w_rmatrix = (void *)p;
+   p += sizeof(*w_rmatrix) * (witness_count + 1);
 
for (i = 0; i < witness_count + 1; i++) {
-   w_rmatrix[i] = malloc(sizeof(*w_rmatrix[i]) *
-   (witness_count + 1), M_WITNESS, M_WAITOK | M_ZERO);
+   w_rmatrix[i] = (void *)p;
+   p += sizeof(*w_rmatrix[i]) * (witness_count + 1);
}
badstack_sbuf_size = witness_count * 256;
 
@@ -840,8 +858,6 @@ witness_initialize(void *dummy __unused)
 
mtx_lock();
 }
-SYSINIT(witness_init, SI_SUB_WITNESS, SI_ORDER_FIRST, witness_initialize,
-NULL);
 
 void
 witness_init(struct lock_object *lock, const char *type)

Modified: head/sys/sys/lock.h
==
--- head/sys/sys/lock.h Thu Mar 22 19:06:50 2018(r331367)
+++ head/sys/sys/lock.h Thu Mar 22 19:11:43 2018(r331368)
@@ -277,6 +277,8 @@ const char *witness_file(struct lock_object *);
 void   witness_thread_exit(struct thread *);
 
 #ifdef WITNESS
+intwitness_startup_count(void);
+void   witness_startup(void *);
 
 /* Flags for witness_warn(). */
 #defineWARN_GIANTOK0x01/* Giant is exempt from this check. */

Modified: head/sys/vm/vm_page.c
==
--- head/sys/vm/vm_page.c   Thu Mar 22 19:06:50 2018(r331367)
+++ head/sys/vm/vm_page.c   Thu Mar 22 19:11:43 2018(r331368)
@@ -539,6 +539,15 @@ vm_page_startup(vm_offset_t vaddr)
bzero((void *)mapped, end - new_end);
uma_startup((void *)mapped, boot_pages);
 
+#ifdef WITNESS
+   end = new_end;
+   new_end = end - round_page(witness_startup_count());
+   mapped = pmap_map(, new_end, end,
+   VM_PROT_READ | VM_PROT_WRITE);
+   bzero((void *)mapped, end - new_end);
+   witness_startup((void *)mapped);
+#endif
+
 #if defined(__aarch64__) || defined(__amd64__) || defined(__arm__) || \
 defined(__i386__) || defined(__mips__)
/*
___
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: r331367 - head/sys/vm

2018-03-22 Thread Jeff Roberson
Author: jeff
Date: Thu Mar 22 19:06:50 2018
New Revision: 331367
URL: https://svnweb.freebsd.org/changeset/base/331367

Log:
  Use read_mostly and alignment tags to eliminate or limit false sharing.
  
  Reviewed by:  markj (Part of D14707)
  Sponsored by: Netflix, Dell/EMC Isilon

Modified:
  head/sys/vm/vm_phys.c

Modified: head/sys/vm/vm_phys.c
==
--- head/sys/vm/vm_phys.c   Thu Mar 22 18:58:34 2018(r331366)
+++ head/sys/vm/vm_phys.c   Thu Mar 22 19:06:50 2018(r331367)
@@ -73,14 +73,14 @@ _Static_assert(sizeof(long) * NBBY >= VM_PHYSSEG_MAX,
 "Too many physsegs.");
 
 #ifdef NUMA
-struct mem_affinity *mem_affinity;
-int *mem_locality;
+struct mem_affinity __read_mostly *mem_affinity;
+int __read_mostly *mem_locality;
 #endif
 
-int vm_ndomains = 1;
+int __read_mostly vm_ndomains = 1;
 
-struct vm_phys_seg vm_phys_segs[VM_PHYSSEG_MAX];
-int vm_phys_nsegs;
+struct vm_phys_seg __read_mostly vm_phys_segs[VM_PHYSSEG_MAX];
+int __read_mostly vm_phys_nsegs;
 
 struct vm_phys_fictitious_seg;
 static int vm_phys_fictitious_cmp(struct vm_phys_fictitious_seg *,
@@ -100,18 +100,18 @@ struct vm_phys_fictitious_seg {
 RB_GENERATE_STATIC(fict_tree, vm_phys_fictitious_seg, node,
 vm_phys_fictitious_cmp);
 
-static struct rwlock vm_phys_fictitious_reg_lock;
+static struct rwlock_padalign vm_phys_fictitious_reg_lock;
 MALLOC_DEFINE(M_FICT_PAGES, "vm_fictitious", "Fictitious VM pages");
 
-static struct vm_freelist
+static struct vm_freelist __aligned(CACHE_LINE_SIZE)
 vm_phys_free_queues[MAXMEMDOM][VM_NFREELIST][VM_NFREEPOOL][VM_NFREEORDER];
 
-static int vm_nfreelists;
+static int __read_mostly vm_nfreelists;
 
 /*
  * Provides the mapping from VM_FREELIST_* to free list indices (flind).
  */
-static int vm_freelist_to_flind[VM_NFREELIST];
+static int __read_mostly vm_freelist_to_flind[VM_NFREELIST];
 
 CTASSERT(VM_FREELIST_DEFAULT == 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: r331366 - in head/contrib/llvm: include/llvm/MC lib/MC lib/MC/MCParser lib/Object

2018-03-22 Thread Dimitry Andric
Author: dim
Date: Thu Mar 22 18:58:34 2018
New Revision: 331366
URL: https://svnweb.freebsd.org/changeset/base/331366

Log:
  Pull in r327101 from upstream llvm trunk (by Rafael Espindola):
  
Don't treat .symver as a regular alias definition.
  
This patch starts simplifying the handling of .symver.
  
For now it just moves the responsibility for creating an alias down to
the streamer. With that the asm streamer can pass a .symver unchanged,
which is nice since gas cannot parse "foo@bar = zed".
  
In a followup I hope to move the handling down to the writer so that
we don't need special hacks for avoiding breaking names with @@@ on
windows.
  
  Pull in r327160 from upstream llvm trunk (by Rafael Espindola):
  
Delay creating an alias for @@@.
  
With this we only create an alias for @@@ once we know if it should
use @ or @@. This avoids last minutes renames and hacks to handle MS
names.
  
This only handles the ELF writer. LTO still has issues with @@@
aliases.
  
  Pull in r327928 from upstream llvm trunk (by Vitaly Buka):
  
Object: Move attribute calculation into RecordStreamer. NFC
  
Summary: Preparation for D44274
  
Reviewers: pcc, espindola
  
Subscribers: hiraditya
  
Differential Revision: https://reviews.llvm.org/D44276
  
  Pull in r327930 from upstream llvm trunk (by Vitaly Buka):
  
Object: Fix handling of @@@ in .symver directive
  
Summary:
name@@@nodename is going to be replaced with name@@nodename if symbols is
defined in the assembled file, or name@nodename if undefined.
https://sourceware.org/binutils/docs/as/Symver.html
  
Fixes PR36623
  
Reviewers: pcc, espindola
  
Subscribers: mehdi_amini, hiraditya
  
Differential Revision: https://reviews.llvm.org/D44274
  
  Together, these changes fix handling of @@@ in .symver directives when
  doing Link Time Optimization.
  
  Reported by:  Shawn Webb 
  MFC after:3 months
  X-MFC-With:   r327952

Modified:
  head/contrib/llvm/include/llvm/MC/MCAssembler.h
  head/contrib/llvm/include/llvm/MC/MCELFStreamer.h
  head/contrib/llvm/include/llvm/MC/MCStreamer.h
  head/contrib/llvm/lib/MC/ELFObjectWriter.cpp
  head/contrib/llvm/lib/MC/MCAsmStreamer.cpp
  head/contrib/llvm/lib/MC/MCELFStreamer.cpp
  head/contrib/llvm/lib/MC/MCParser/ELFAsmParser.cpp
  head/contrib/llvm/lib/MC/MCStreamer.cpp
  head/contrib/llvm/lib/Object/ModuleSymbolTable.cpp
  head/contrib/llvm/lib/Object/RecordStreamer.cpp
  head/contrib/llvm/lib/Object/RecordStreamer.h

Modified: head/contrib/llvm/include/llvm/MC/MCAssembler.h
==
--- head/contrib/llvm/include/llvm/MC/MCAssembler.h Thu Mar 22 18:24:00 
2018(r331365)
+++ head/contrib/llvm/include/llvm/MC/MCAssembler.h Thu Mar 22 18:58:34 
2018(r331366)
@@ -206,6 +206,8 @@ class MCAssembler { (private)
   handleFixup(const MCAsmLayout , MCFragment , const MCFixup );
 
 public:
+  std::vector> Symvers;
+
   /// Construct a new assembler instance.
   //
   // FIXME: How are we going to parameterize this? Two obvious options are stay

Modified: head/contrib/llvm/include/llvm/MC/MCELFStreamer.h
==
--- head/contrib/llvm/include/llvm/MC/MCELFStreamer.h   Thu Mar 22 18:24:00 
2018(r331365)
+++ head/contrib/llvm/include/llvm/MC/MCELFStreamer.h   Thu Mar 22 18:58:34 
2018(r331366)
@@ -51,6 +51,8 @@ class MCELFStreamer : public MCObjectStreamer { (publi
 unsigned ByteAlignment) override;
 
   void emitELFSize(MCSymbol *Symbol, const MCExpr *Value) override;
+  void emitELFSymverDirective(StringRef AliasName,
+  const MCSymbol *Aliasee) override;
 
   void EmitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size,
  unsigned ByteAlignment) override;

Modified: head/contrib/llvm/include/llvm/MC/MCStreamer.h
==
--- head/contrib/llvm/include/llvm/MC/MCStreamer.h  Thu Mar 22 18:24:00 
2018(r331365)
+++ head/contrib/llvm/include/llvm/MC/MCStreamer.h  Thu Mar 22 18:58:34 
2018(r331366)
@@ -519,9 +519,10 @@ class MCStreamer { (public)
   ///
   /// This corresponds to an assembler statement such as:
   ///  .symver _start, foo@@SOME_VERSION
-  /// \param Alias - The versioned alias (i.e. "foo@@SOME_VERSION")
+  /// \param AliasName - The versioned alias (i.e. "foo@@SOME_VERSION")
   /// \param Aliasee - The aliased symbol (i.e. "_start")
-  virtual void emitELFSymverDirective(MCSymbol *Alias, const MCSymbol 
*Aliasee);
+  virtual void emitELFSymverDirective(StringRef AliasName,
+  const MCSymbol *Aliasee);
 
   /// \brief Emit a Linker Optimization Hint (LOH) directive.
  

Re: svn commit: r331347 - in head: etc/mtree include sys/conf sys/dev/tcp_log sys/kern sys/netinet usr.bin/netstat

2018-03-22 Thread Ruslan Bukin
On Thu, Mar 22, 2018 at 03:39:23PM +, Jonathan Looney wrote:
>Yes, this can be made optional, if there is a need for that.

It may be good to have kernel option for that I think. As we target embedded 
market it is good to have things pluggable.

Example: I able to fit freebsd kernel and minimalistic world to 2MB flash 
device (compressed).
But I think if some code added I unable to fit anymore. 
But I agree that ROM memory is almost free, however some ASICs has this memory 
only and you may have no space for external chips on PCB.

Ruslan
___
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: r331365 - in head/sys: amd64/amd64 dev/efidev

2018-03-22 Thread Kyle Evans
Author: kevans
Date: Thu Mar 22 18:24:00 2018
New Revision: 331365
URL: https://svnweb.freebsd.org/changeset/base/331365

Log:
  Re-work efidev ordering to fix efirt preloaded by loader on amd64
  
  On amd64, efi_enter calls fpu_kern_enter(). This may not be called until
  fpuinitstate has been invoked, resulting in a kernel panic with
  efirt_load="YES" in loader.conf(5).
  
  Move fpuinitstate a little earlier in SI_SUB_DRIVERS so that we can squeeze
  efirt between it and efirtc at SI_SUB_DRIVERS, SI_ORDER_ANY. efidev must be
  after efirt and doesn't really need to be at SI_SUB_DEVFS, so drop it at
  SI_SUB_DRIVER, SI_ORDER_ANY.
  
  The not immediately obvious dependency of fpuinitstate by efirt has been
  noted in both places.
  
  Discussed with:   kib, andrew
  Reported by:  Jakob Alvermark 
  X-MFC-With:   r330868

Modified:
  head/sys/amd64/amd64/fpu.c
  head/sys/dev/efidev/efidev.c
  head/sys/dev/efidev/efirt.c

Modified: head/sys/amd64/amd64/fpu.c
==
--- head/sys/amd64/amd64/fpu.c  Thu Mar 22 17:49:27 2018(r331364)
+++ head/sys/amd64/amd64/fpu.c  Thu Mar 22 18:24:00 2018(r331365)
@@ -366,7 +366,8 @@ fpuinitstate(void *arg __unused)
start_emulating();
intr_restore(saveintr);
 }
-SYSINIT(fpuinitstate, SI_SUB_DRIVERS, SI_ORDER_ANY, fpuinitstate, NULL);
+/* EFIRT needs this to be initialized before we can enter our EFI environment 
*/
+SYSINIT(fpuinitstate, SI_SUB_DRIVERS, SI_ORDER_FIRST, fpuinitstate, NULL);
 
 /*
  * Free coprocessor (if we have it).

Modified: head/sys/dev/efidev/efidev.c
==
--- head/sys/dev/efidev/efidev.cThu Mar 22 17:49:27 2018
(r331364)
+++ head/sys/dev/efidev/efidev.cThu Mar 22 18:24:00 2018
(r331365)
@@ -216,6 +216,6 @@ static moduledata_t efidev_moddata = {
.priv = NULL,
 };
 
-DECLARE_MODULE(efidev, efidev_moddata, SI_SUB_DEVFS, SI_ORDER_ANY);
+DECLARE_MODULE(efidev, efidev_moddata, SI_SUB_DRIVERS, SI_ORDER_ANY);
 MODULE_VERSION(efidev, 1);
 MODULE_DEPEND(efidev, efirt, 1, 1, 1);

Modified: head/sys/dev/efidev/efirt.c
==
--- head/sys/dev/efidev/efirt.c Thu Mar 22 17:49:27 2018(r331364)
+++ head/sys/dev/efidev/efirt.c Thu Mar 22 18:24:00 2018(r331365)
@@ -450,5 +450,6 @@ static moduledata_t efirt_moddata = {
.evhand = efirt_modevents,
.priv = NULL,
 };
-DECLARE_MODULE(efirt, efirt_moddata, SI_SUB_VM_CONF, SI_ORDER_ANY);
+/* After fpuinitstate, before efidev */
+DECLARE_MODULE(efirt, efirt_moddata, SI_SUB_DRIVERS, SI_ORDER_SECOND);
 MODULE_VERSION(efirt, 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: r331347 - in head: etc/mtree include sys/conf sys/dev/tcp_log sys/kern sys/netinet usr.bin/netstat

2018-03-22 Thread Ruslan Bukin
Look at these
https://ci.freebsd.org/job/FreeBSD-head-mips-build/lastBuild/console
https://ci.freebsd.org/job/FreeBSD-head-powerpc-build/lastBuild/console

Example
make -j5 TARGET=mips TARGET_ARCH=mipsel kernel-toolchain
make -j5 TARGET=mips TARGET_ARCH=mipsel KERNCONF=CANNA buildkernel

Ruslan

On Thu, Mar 22, 2018 at 03:39:23PM +, Jonathan Looney wrote:
>A tinderbox build didn't complain about atomic_fetchadd_64, so I assume it
>is OK.
>Yes, this can be made optional, if there is a need for that.
>Jonathan
>On Thu, Mar 22, 2018 at 2:22 PM, Ruslan Bukin
><[1]ruslan.bu...@cl.cam.ac.uk> wrote:
> 
>  Also can this be pluggable ?
>  It looks like it is optional device which means it can free up some
>  space in embedded environment when unused
>  Ruslan
>  On Thu, Mar 22, 2018 at 02:16:06PM +, Ruslan Bukin wrote:
>  > We don't have atomic_fetchadd_64 for mips32 I think
>  >
>  > Ruslan
>  >
>  > On Thu, Mar 22, 2018 at 09:40:08AM +, Jonathan T. Looney wrote:
>  > > Author: jtl
>  > > Date: Thu Mar 22 09:40:08 2018
>  > > New Revision: 331347
>  > > URL: [2]https://svnweb.freebsd.org/changeset/base/331347
>  > >
>  > > Log:
>  > >   Add the "TCP Blackbox Recorder" which we discussed at the
>  developer
>  > >   summits at BSDCan and BSDCam in 2017.
>  > >
>  > >   The TCP Blackbox Recorder allows you to capture events on a TCP
>  connection
>  > >   in a ring buffer. It stores metadata with the event. It
>  optionally stores
>  > >   the TCP header associated with an event (if the event is
>  associated with a
>  > >   packet) and also optionally stores information on the sockets.
>  > >
>  > >   It supports setting a log ID on a TCP connection and using this
>  to correlate
>  > >   multiple connections that share a common log ID.
>  > >
>  > >   You can log connections in different modes. If you are doing a
>  coordinated
>  > >   test with a particular connection, you may tell the system to
>  put it in
>  > >   mode 4 (continuous dump). Or, if you just want to monitor for
>  errors, you
>  > >   can put it in mode 1 (ring buffer) and dump all the ring buffers
>  associated
>  > >   with the connection ID when we receive an error signal for that
>  connection
>  > >   ID. You can set a default mode that will be applied to a
>  particular ratio
>  > >   of incoming connections. You can also manually set a mode using
>  a socket
>  > >   option.
>  > >
>  > >   This commit includes only basic probes. rrs@ has added quite an
>  abundance
>  > >   of probes in his TCP development work. He plans to commit those
>  soon.
>  > >
>  > >   There are user-space programs which we plan to commit as ports.
>  These read
>  > >   the data from the log device and output pcapng files, and then
>  let you
>  > >   analyze the data (and metadata) in the pcapng files.
>  > >
>  > >   Reviewed by:      gnn (previous version)
>  > >   Obtained from:    Netflix, Inc.
>  > >   Relnotes: yes
>  > >   Differential Revision:   
>  [3]https://reviews.freebsd.org/D11085
>  > >
>  > > Added:
>  > >   head/sys/dev/tcp_log/
>  > >   head/sys/dev/tcp_log/tcp_log_dev.c   (contents, props changed)
>  > >   head/sys/dev/tcp_log/tcp_log_dev.h   (contents, props changed)
>  > >   head/sys/netinet/tcp_log_buf.c   (contents, props changed)
>  > >   head/sys/netinet/tcp_log_buf.h   (contents, props changed)
>  > > Modified:
>  > >   head/etc/mtree/BSD.include.dist
>  > >   head/include/Makefile
>  > >   head/sys/conf/files
>  > >   head/sys/kern/subr_witness.c
>  > >   head/sys/netinet/tcp.h
>  > >   head/sys/netinet/tcp_input.c
>  > >   head/sys/netinet/tcp_output.c
>  > >   head/sys/netinet/tcp_subr.c
>  > >   head/sys/netinet/tcp_timer.c
>  > >   head/sys/netinet/tcp_usrreq.c
>  > >   head/sys/netinet/tcp_var.h
>  > >   head/usr.bin/netstat/inet.c
>  > >   head/usr.bin/netstat/main.c
>  > >   head/usr.bin/netstat/netstat.1
>  > >   head/usr.bin/netstat/netstat.h
>  > >
>  > > Modified: head/etc/mtree/BSD.include.dist
>  > >
>  
> ==
>  > > --- head/etc/mtree/BSD.include.dist Thu Mar 22 08:32:39 2018     
>    (r331346)
>  > > +++ head/etc/mtree/BSD.include.dist Thu Mar 22 09:40:08 2018     
>    (r331347)
>  > > @@ -158,6 +158,8 @@
>  > >          ..
>  > >          speaker
>  > >          ..
>  > > +        tcp_log
>  > > +        ..
>  > >          usb
>  > >          ..
>  > >          vkbd
>  > >
>  > > Modified: head/include/Makefile
>  > >
>  
> 

Re: svn commit: r331209 - head

2018-03-22 Thread Kyle Evans
On Thu, Mar 22, 2018 at 1:13 PM, Steven Hartland
 wrote:
> I think it would be worth specifically detailing the steps to achieve this,
> as its not immediately obvious how this would be done.
>

Hi,

A later commit clarified, but then an even later commit made these
instructions obsolete. =) The problem this entry was made for has been
eradicated, and the entry has since been removed.

Thanks,

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


Re: svn commit: r331209 - head

2018-03-22 Thread Steven Hartland
I think it would be worth specifically detailing the steps to achieve 
this, as its not immediately obvious how this would be done.


On 19/03/2018 15:27, Kyle Evans wrote:

Author: kevans
Date: Mon Mar 19 15:27:53 2018
New Revision: 331209
URL: https://svnweb.freebsd.org/changeset/base/331209

Log:
   Add note to UPDATING about UEFI changes requiring loader(8) update
   
   These problems have only been observed with boards using U-Boot (e.g. ARM)

   where virtual addresses are already set in the memory map by the firmware
   and the firmware is expecting a call to SetVirtualAddressMap to be made.
   I refrain from mentioning this in the note because this could also be the
   case on some not-yet-tested firmware on amd64 and it's not a bad
   recommendation for the general case.

Modified:
   head/UPDATING

Modified: head/UPDATING
==
--- head/UPDATING   Mon Mar 19 15:11:10 2018(r331208)
+++ head/UPDATING   Mon Mar 19 15:27:53 2018(r331209)
@@ -51,6 +51,13 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 12.x IS SLOW:
  
  ** SPECIAL WARNING: **
  
+20180319:

+   For UEFI systems: the UEFI loader(8), loader.efi, should be updated in
+   conjunction with installing a new kernel after r330868. The kernel,
+   after this revision, will be more lenient when mapping addresses for
+   UEFI Runtime Services and this may result in a kernel panic without the
+   corresponding loader(8) update.
+
  20180212:
FreeBSD boot loader enhanced with Lua scripting. It's purely opt-in for
now by building WITH_LOADER_LUA and WITHOUT_FORTH in /etc/src.conf.



___
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: r331364 - head/release/tools

2018-03-22 Thread Glen Barber
Author: gjb
Date: Thu Mar 22 17:49:27 2018
New Revision: 331364
URL: https://svnweb.freebsd.org/changeset/base/331364

Log:
  Remove google_accounts_manager from VM_RC_LIST in the GCE configuration
  file, no longer needed.
  
  PR:   221714
  MFC after:3 days
  Sponsored by: The FreeBSD Foundation

Modified:
  head/release/tools/gce.conf

Modified: head/release/tools/gce.conf
==
--- head/release/tools/gce.conf Thu Mar 22 17:46:38 2018(r331363)
+++ head/release/tools/gce.conf Thu Mar 22 17:49:27 2018(r331364)
@@ -9,7 +9,7 @@ export VM_EXTRA_PACKAGES="firstboot-freebsd-update fir
sysutils/py-google-compute-engine"
 
 # Set to a list of third-party software to enable in rc.conf(5).
-export VM_RC_LIST="google_accounts_manager ntpd sshd firstboot_growfs \
+export VM_RC_LIST="ntpd sshd firstboot_growfs \
firstboot_pkgs firstboot_freebsd_update google_startup \
google_accounts_daemon google_clock_skew_daemon
google_instance_setup google_ip_forwarding_daemon
___
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: r331363 - in stable: 10/release/tools 11/release/tools

2018-03-22 Thread Glen Barber
Author: gjb
Date: Thu Mar 22 17:46:38 2018
New Revision: 331363
URL: https://svnweb.freebsd.org/changeset/base/331363

Log:
  MFC r322794:
   Use py-google-compute-engine instead for releasing Google Compute
   Engine (GCE) images with an updated version of Google's tools.
  
  PR:   221714
  Sponsored by: The FreeBSD Foundation

Modified:
  stable/11/release/tools/gce.conf
Directory Properties:
  stable/11/   (props changed)

Changes in other areas also in this revision:
Modified:
  stable/10/release/tools/gce.conf
Directory Properties:
  stable/10/   (props changed)

Modified: stable/11/release/tools/gce.conf
==
--- stable/11/release/tools/gce.confThu Mar 22 15:34:37 2018
(r331362)
+++ stable/11/release/tools/gce.confThu Mar 22 17:46:38 2018
(r331363)
@@ -5,12 +5,15 @@
 
 # Set to a list of packages to install.
 export VM_EXTRA_PACKAGES="firstboot-freebsd-update firstboot-pkgs \
-   google-cloud-sdk google-daemon panicmail sudo firstboot-growfs \
-   google-startup-scripts"
+   google-cloud-sdk panicmail sudo firstboot-growfs \
+   sysutils/py-google-compute-engine"
 
 # Set to a list of third-party software to enable in rc.conf(5).
 export VM_RC_LIST="google_accounts_manager ntpd sshd firstboot_growfs \
-   firstboot_pkgs firstboot_freebsd_update google_startup"
+   firstboot_pkgs firstboot_freebsd_update google_startup \
+   google_accounts_daemon google_clock_skew_daemon
+   google_instance_setup google_ip_forwarding_daemon
+   google_network_setup"
 
 vm_extra_install_base() {
echo 'search google.internal' > ${DESTDIR}/etc/resolv.conf
___
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: r331363 - in stable: 10/release/tools 11/release/tools

2018-03-22 Thread Glen Barber
Author: gjb
Date: Thu Mar 22 17:46:38 2018
New Revision: 331363
URL: https://svnweb.freebsd.org/changeset/base/331363

Log:
  MFC r322794:
   Use py-google-compute-engine instead for releasing Google Compute
   Engine (GCE) images with an updated version of Google's tools.
  
  PR:   221714
  Sponsored by: The FreeBSD Foundation

Modified:
  stable/10/release/tools/gce.conf
Directory Properties:
  stable/10/   (props changed)

Changes in other areas also in this revision:
Modified:
  stable/11/release/tools/gce.conf
Directory Properties:
  stable/11/   (props changed)

Modified: stable/10/release/tools/gce.conf
==
--- stable/10/release/tools/gce.confThu Mar 22 15:34:37 2018
(r331362)
+++ stable/10/release/tools/gce.confThu Mar 22 17:46:38 2018
(r331363)
@@ -5,12 +5,15 @@
 
 # Set to a list of packages to install.
 export VM_EXTRA_PACKAGES="firstboot-freebsd-update firstboot-pkgs \
-   google-cloud-sdk google-daemon panicmail sudo firstboot-growfs \
-   google-startup-scripts"
+   google-cloud-sdk panicmail sudo firstboot-growfs \
+   sysutils/py-google-compute-engine"
 
 # Set to a list of third-party software to enable in rc.conf(5).
 export VM_RC_LIST="google_accounts_manager ntpd sshd firstboot_growfs \
-   firstboot_pkgs firstboot_freebsd_update google_startup"
+   firstboot_pkgs firstboot_freebsd_update google_startup \
+   google_accounts_daemon google_clock_skew_daemon
+   google_instance_setup google_ip_forwarding_daemon
+   google_network_setup"
 
 vm_extra_install_base() {
echo 'search google.internal' > ${DESTDIR}/etc/resolv.conf
___
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: r331347 - in head: etc/mtree include sys/conf sys/dev/tcp_log sys/kern sys/netinet usr.bin/netstat

2018-03-22 Thread Jonathan Looney
A tinderbox build didn't complain about atomic_fetchadd_64, so I assume it
is OK.

Yes, this can be made optional, if there is a need for that.

Jonathan

On Thu, Mar 22, 2018 at 2:22 PM, Ruslan Bukin 
wrote:

> Also can this be pluggable ?
> It looks like it is optional device which means it can free up some space
> in embedded environment when unused
>
> Ruslan
>
> On Thu, Mar 22, 2018 at 02:16:06PM +, Ruslan Bukin wrote:
> > We don't have atomic_fetchadd_64 for mips32 I think
> >
> > Ruslan
> >
> > On Thu, Mar 22, 2018 at 09:40:08AM +, Jonathan T. Looney wrote:
> > > Author: jtl
> > > Date: Thu Mar 22 09:40:08 2018
> > > New Revision: 331347
> > > URL: https://svnweb.freebsd.org/changeset/base/331347
> > >
> > > Log:
> > >   Add the "TCP Blackbox Recorder" which we discussed at the developer
> > >   summits at BSDCan and BSDCam in 2017.
> > >
> > >   The TCP Blackbox Recorder allows you to capture events on a TCP
> connection
> > >   in a ring buffer. It stores metadata with the event. It optionally
> stores
> > >   the TCP header associated with an event (if the event is associated
> with a
> > >   packet) and also optionally stores information on the sockets.
> > >
> > >   It supports setting a log ID on a TCP connection and using this to
> correlate
> > >   multiple connections that share a common log ID.
> > >
> > >   You can log connections in different modes. If you are doing a
> coordinated
> > >   test with a particular connection, you may tell the system to put it
> in
> > >   mode 4 (continuous dump). Or, if you just want to monitor for
> errors, you
> > >   can put it in mode 1 (ring buffer) and dump all the ring buffers
> associated
> > >   with the connection ID when we receive an error signal for that
> connection
> > >   ID. You can set a default mode that will be applied to a particular
> ratio
> > >   of incoming connections. You can also manually set a mode using a
> socket
> > >   option.
> > >
> > >   This commit includes only basic probes. rrs@ has added quite an
> abundance
> > >   of probes in his TCP development work. He plans to commit those soon.
> > >
> > >   There are user-space programs which we plan to commit as ports.
> These read
> > >   the data from the log device and output pcapng files, and then let
> you
> > >   analyze the data (and metadata) in the pcapng files.
> > >
> > >   Reviewed by:  gnn (previous version)
> > >   Obtained from:Netflix, Inc.
> > >   Relnotes: yes
> > >   Differential Revision:https://reviews.freebsd.org/D11085
> > >
> > > Added:
> > >   head/sys/dev/tcp_log/
> > >   head/sys/dev/tcp_log/tcp_log_dev.c   (contents, props changed)
> > >   head/sys/dev/tcp_log/tcp_log_dev.h   (contents, props changed)
> > >   head/sys/netinet/tcp_log_buf.c   (contents, props changed)
> > >   head/sys/netinet/tcp_log_buf.h   (contents, props changed)
> > > Modified:
> > >   head/etc/mtree/BSD.include.dist
> > >   head/include/Makefile
> > >   head/sys/conf/files
> > >   head/sys/kern/subr_witness.c
> > >   head/sys/netinet/tcp.h
> > >   head/sys/netinet/tcp_input.c
> > >   head/sys/netinet/tcp_output.c
> > >   head/sys/netinet/tcp_subr.c
> > >   head/sys/netinet/tcp_timer.c
> > >   head/sys/netinet/tcp_usrreq.c
> > >   head/sys/netinet/tcp_var.h
> > >   head/usr.bin/netstat/inet.c
> > >   head/usr.bin/netstat/main.c
> > >   head/usr.bin/netstat/netstat.1
> > >   head/usr.bin/netstat/netstat.h
> > >
> > > Modified: head/etc/mtree/BSD.include.dist
> > > 
> ==
> > > --- head/etc/mtree/BSD.include.dist Thu Mar 22 08:32:39 2018
> (r331346)
> > > +++ head/etc/mtree/BSD.include.dist Thu Mar 22 09:40:08 2018
> (r331347)
> > > @@ -158,6 +158,8 @@
> > >  ..
> > >  speaker
> > >  ..
> > > +tcp_log
> > > +..
> > >  usb
> > >  ..
> > >  vkbd
> > >
> > > Modified: head/include/Makefile
> > > 
> ==
> > > --- head/include/Makefile   Thu Mar 22 08:32:39 2018(r331346)
> > > +++ head/include/Makefile   Thu Mar 22 09:40:08 2018(r331347)
> > > @@ -47,7 +47,7 @@ LSUBDIRS= cam/ata cam/mmc cam/nvme cam/scsi \
> > > dev/hwpmc dev/hyperv \
> > > dev/ic dev/iicbus dev/io dev/lmc dev/mfi dev/mmc dev/nvme \
> > > dev/ofw dev/pbio dev/pci ${_dev_powermac_nvram} dev/ppbus
> dev/smbus \
> > > -   dev/speaker dev/vkbd dev/wi \
> > > +   dev/speaker dev/tcp_log dev/vkbd dev/wi \
> > > fs/devfs fs/fdescfs fs/msdosfs fs/nandfs fs/nfs fs/nullfs \
> > > fs/procfs fs/smbfs fs/udf fs/unionfs \
> > > geom/cache geom/concat geom/eli geom/gate geom/journal geom/label \
> > >
> > > Modified: head/sys/conf/files
> > > 
> ==
> > > --- head/sys/conf/files Thu Mar 22 08:32:39 2018(r331346)
> > > +++ head/sys/conf/files Thu 

svn commit: r331362 - head/sys/kern

2018-03-22 Thread Warner Losh
Author: imp
Date: Thu Mar 22 15:34:37 2018
New Revision: 331362
URL: https://svnweb.freebsd.org/changeset/base/331362

Log:
  Drop any recursed taking of Giant once and for all at the top of
  kern_reboot(). The shutdown path is now safe to run without Giant.
  
  Discussed with: kib@
  Sponsored by: Netflix

Modified:
  head/sys/kern/kern_shutdown.c

Modified: head/sys/kern/kern_shutdown.c
==
--- head/sys/kern/kern_shutdown.c   Thu Mar 22 15:32:57 2018
(r331361)
+++ head/sys/kern/kern_shutdown.c   Thu Mar 22 15:34:37 2018
(r331362)
@@ -366,6 +366,17 @@ kern_reboot(int howto)
 {
static int once = 0;
 
+   /*
+* Normal paths here don't hold Giant, but we can wind up here
+* unexpectedly with it held.  Drop it now so we don't have to
+* drop and pick it up elsewhere. The paths it is locking will
+* never be returned to, and it is preferable to preclude
+* deadlock than to lock against code that won't ever
+* continue.
+*/
+   while (mtx_owned())
+   mtx_unlock();
+
 #if defined(SMP)
/*
 * Bind us to the first CPU so that all shutdown code runs there.  Some
___
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: r331361 - head/sys/dev/efidev

2018-03-22 Thread Andrew Turner
Author: andrew
Date: Thu Mar 22 15:32:57 2018
New Revision: 331361
URL: https://svnweb.freebsd.org/changeset/base/331361

Log:
  Enter into the EFI environment before dereferencing the runtime services
  pointer. This may be within the EFI address space and not the FreeBSD
  kernel address space.
  
  X-MFC-With:   r330868
  Sponsored by: DARPA, AFRL

Modified:
  head/sys/dev/efidev/efirt.c

Modified: head/sys/dev/efidev/efirt.c
==
--- head/sys/dev/efidev/efirt.c Thu Mar 22 15:24:26 2018(r331360)
+++ head/sys/dev/efidev/efirt.c Thu Mar 22 15:32:57 2018(r331361)
@@ -88,6 +88,9 @@ static int efi_status2err[25] = {
EPROTO  /* EFI_PROTOCOL_ERROR */
 };
 
+static int efi_enter(void);
+static void efi_leave(void);
+
 static int
 efi_status_to_errno(efi_status status)
 {
@@ -190,9 +193,14 @@ efi_init(void)
 * call RS->SetVirtualAddressMap. As this is not always the case, e.g.
 * with an old loader.efi, check if the RS->GetTime function is within
 * the EFI map, and fail to attach if not.
+*
+* We need to enter into the EFI environment as efi_runtime may point
+* to an EFI address.
 */
+   efi_enter();
if (!efi_is_in_map(map, efihdr->memory_size / efihdr->descriptor_size,
efihdr->descriptor_size, (vm_offset_t)efi_runtime->rt_gettime)) {
+   efi_leave();
if (bootverbose)
printf(
 "EFI runtime services table has an invalid pointer\n");
@@ -200,6 +208,7 @@ efi_init(void)
efi_destroy_1t1_map();
return (ENXIO);
}
+   efi_leave();
 
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: r331360 - head/sys/dev/usb/controller

2018-03-22 Thread Andrew Turner
Author: andrew
Date: Thu Mar 22 15:24:26 2018
New Revision: 331360
URL: https://svnweb.freebsd.org/changeset/base/331360

Log:
  Increase the size of the endpoint buffers. They are double buffered so
  need to be twice the size.
  
  Sponsored by: DARPA, AFRL

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

Modified: head/sys/dev/usb/controller/musb_otg.c
==
--- head/sys/dev/usb/controller/musb_otg.c  Thu Mar 22 15:11:53 2018
(r331359)
+++ head/sys/dev/usb/controller/musb_otg.c  Thu Mar 22 15:24:26 2018
(r331360)
@@ -157,7 +157,7 @@ static const struct musb_otg_ep_cfg musbotg_ep_default
},
{
.ep_end = 7,
-   .ep_fifosz_shift = 9,
+   .ep_fifosz_shift = 10,
.ep_fifosz_reg = MUSB2_VAL_FIFOSZ_512 | MUSB2_MASK_FIFODB,
},
{
___
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: r331359 - head/sys/dev/syscons

2018-03-22 Thread Warner Losh
Author: imp
Date: Thu Mar 22 15:11:53 2018
New Revision: 331359
URL: https://svnweb.freebsd.org/changeset/base/331359

Log:
  Revert r331298
  
  Normally, shutdown_nice() just signals init. However, sometimes it
  calls kern_reboot directly. For that case, r331298 dropped the Giant
  lock before calling it. This turns out to be incorrect for the more
  common case where init exists and we just signal it. Restore the old
  behavior. The direct call to kern_reboot() doesn't sync buffers to the
  disk, so should work with Giant held, so we don't need to drop locks
  here for that.
  
  Noticed by: bde@
  Sponsored by: Netflix

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

Modified: head/sys/dev/syscons/syscons.c
==
--- head/sys/dev/syscons/syscons.c  Thu Mar 22 14:51:05 2018
(r331358)
+++ head/sys/dev/syscons/syscons.c  Thu Mar 22 15:11:53 2018
(r331359)
@@ -3858,28 +3858,22 @@ next_code:
 
case RBT:
 #ifndef SC_DISABLE_REBOOT
-   if (enable_reboot && !(flags & SCGETC_CN)) {
-   mtx_unlock();
+   if (enable_reboot && !(flags & SCGETC_CN))
shutdown_nice(0);
-   }
 #endif
break;
 
case HALT:
 #ifndef SC_DISABLE_REBOOT
-   if (enable_reboot && !(flags & SCGETC_CN)) {
-   mtx_unlock();
+   if (enable_reboot && !(flags & SCGETC_CN))
shutdown_nice(RB_HALT);
-   }
 #endif
break;
 
case PDWN:
 #ifndef SC_DISABLE_REBOOT
-   if (enable_reboot && !(flags & SCGETC_CN)) {
-   mtx_unlock();
+   if (enable_reboot && !(flags & SCGETC_CN))
shutdown_nice(RB_HALT|RB_POWEROFF);
-   }
 #endif
break;
 
___
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: r331298 - head/sys/dev/syscons

2018-03-22 Thread Konstantin Belousov
On Fri, Mar 23, 2018 at 01:21:43AM +1100, Bruce Evans wrote:
> I don't like having a whole task for this.  The whole thing is just a
> hack to work around some the upper layers of the tty driver and some
> lower layers not having any input [escape] sequences to control the
> kernel.  Only the syscons and vt lower layers have such sequences
> (where they are actually key combinations that are converted to control
> operations instead of to input [escape] sequences).  To work around for
> hardware ttys, the filter for kdb sequences is abused to implement a
> non-kdb sequence for rebooting.
> 
> The tty input methods could check for kernel-control sequences and safely
> signal init.  This is a bit too complicated for syscons and vt since they
> can more easily check for key combinations, but wouldhave to convert these
> to standard sequences to get the tty layer to do the same thing.  (They
> have many more kernel-control key combinations and the non-kdb one for
> rebooting is just a bug for them.)  This is a bit complicated for hardware
> tty drivers too -- some use the tty bulk-input method and this shouldn't
> check for sequences, but should reduce to bcopy().  Hoever, to detect the
> kdb sequences, these drivers han to check at a low level anyway.  They
> can be clever about this and only check for the console device[s] which are
> usually only used for for input at a low rate.
This is both complicated and mostly pointless. The task mechanism
provides the easy solution, and more, the task mechanism was
specifically designed to allow to schedule activities in the more
allowing context, from a more restrictive context. I have no intent to
start the self-inflicting activity to code the attempt to modify a lot
of drivers to do what can be done in 10 lines of code.

> Calling kern_reboot() from fast interrupt handlers is still invalid.
> It is quite likely to deadlock.  In particular, it should deadlock in
> when kern_reboot() prints messages to the console.  Most console drivers
> have races instead of deadlocks by dropping their lock[s] in their
> fast interrupt handler before calling the buggy alt escape function.
I agree that it is mostly invalid. If SCHEDULER_STOPPED() evaluates to
true, then the clean shutdown is not possible at all on modern hardware.
Most drivers are asynchronous, and even the hardware reboot command
management is async.

Similarly, if initproc is not yet initialized, it is silly to expect
clean shutdown to occur. I just keep the existing behavior for these
corner cases, perhaps it was added for some reasons and might sometime
work.
___
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: r331298 - head/sys/dev/syscons

2018-03-22 Thread Warner Losh
On Thu, Mar 22, 2018 at 5:42 AM, Konstantin Belousov 
wrote:

> On Thu, Mar 22, 2018 at 05:50:57PM +1100, Bruce Evans wrote:
> > On Wed, 21 Mar 2018, Warner Losh wrote:
> >
> > > On Wed, Mar 21, 2018 at 2:27 PM, Konstantin Belousov <
> kostik...@gmail.com>
> > > wrote:
> > >> ...
> > >> Are you saying that fast interrupt handlers call shutdown_nice() ?
> This
> > >> is the quite serious bug on its own.  To fix it, shutdown_nice()
> should
> > >> use a fast taskqueue to schedule the task which would lock the process
> > >> and send the signal.
> > >
> > > Is there some way we know we're in a fast interrupt handler? If so, it
> > > should be simple to fix. If not, then there's an API change ahead of
> us...
> >
> > There is a td_intr_nesting_level flag that might work.  (I invented this,
> > but don't like its current use.)
> But why do we need to know this ?  We can always schedule a task in the
> fast taskqueue if init is present and can be scheduled.


Ah, good point. Seems like a poster child example of doing a fast task
queue deferment. That's always safe, except maybe in BDE's fast interrupt
world.

> > But bde is right: the system has to be in good enough shape to cope. I
> > > wonder if we should put that coping into kdb_reboot() instead. It's
> only an
> > > issue for  TILDE ^R, which is a fairly edge case.
> >
> > shutdown_nice() is also called directly from syscons and vt for the
> reboot,
> > halt and poweroff keys.  This happens in normal interrupt handler
> context,
> > so there is only a problem when init is not running.
>
> diff --git a/sys/kern/kern_shutdown.c b/sys/kern/kern_shutdown.c
> index e5ea9644ad3..e7c6d4c92b2 100644
> --- a/sys/kern/kern_shutdown.c
> +++ b/sys/kern/kern_shutdown.c
> @@ -72,6 +72,7 @@ __FBSDID("$FreeBSD$");
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>
> @@ -276,6 +277,28 @@ sys_reboot(struct thread *td, struct reboot_args *uap)
> return (error);
>  }
>
> +static void
> +shutdown_nice_task_fn(void *arg, int pending __unused)
> +{
> +   int howto;
> +
> +   howto = (uintptr_t)arg;
> +   /* Send a signal to init(8) and have it shutdown the world. */
> +   PROC_LOCK(initproc);
> +   if (howto & RB_POWEROFF)
> +   kern_psignal(initproc, SIGUSR2);
> +   else if (howto & RB_POWERCYCLE)
> +   kern_psignal(initproc, SIGWINCH);
> +   else if (howto & RB_HALT)
> +   kern_psignal(initproc, SIGUSR1);
> +   else
> +   kern_psignal(initproc, SIGINT);
> +   PROC_UNLOCK(initproc);
> +}
> +
> +static struct task shutdown_nice_task = TASK_INITIALIZER(0,
> +_nice_task_fn, NULL);
> +
>  /*
>   * Called by events that want to shut down.. e.g   on a PC
>   */
> @@ -283,20 +306,14 @@ void
>  shutdown_nice(int howto)
>  {
>
> -   if (initproc != NULL) {
> -   /* Send a signal to init(8) and have it shutdown the
> world. */
> -   PROC_LOCK(initproc);
> -   if (howto & RB_POWEROFF)
> -   kern_psignal(initproc, SIGUSR2);
> -   else if (howto & RB_POWERCYCLE)
> -   kern_psignal(initproc, SIGWINCH);
> -   else if (howto & RB_HALT)
> -   kern_psignal(initproc, SIGUSR1);
> -   else
> -   kern_psignal(initproc, SIGINT);
> -   PROC_UNLOCK(initproc);
> +   if (initproc != NULL && !SCHEDULER_STOPPED()) {
> +   shutdown_nice_task.ta_context = (void *)(uintptr_t)howto;
> +   taskqueue_enqueue(taskqueue_fast, _nice_task);
> } else {
> -   /* No init(8) running, so simply reboot. */
> +   /*
> +* No init(8) running, or scheduler would not allow it
> +* to run, so simply reboot.
> +*/
> kern_reboot(howto | RB_NOSYNC);
> }
>  }
>

I like this elegance. I think we should commit this. While it would be nice
to support the super-fast interrupts that bde has done, we already don't
support it in a number of places. Conceptually, I like the notion of the
tilde escape machine in the tty layer, but I don't like the trade offs.
Here we only defer to reboot, which requires a fair amount of machinery
working to work right. it's not the dependencies I'd prefer, but usually it
doesn't matter. However, to do that, it would also mean that breaking to
the debugger would need to be done in the tty layer, which requires more of
the context switching mechanisms to be working, which would be a bigger
loss. So this is a good trade-off.

If kern_reboot() can't be called from a fast interrupt handler in bdeBSD,
it would be a simple matter to put a wrapper around it here so his kernel
can context switch. Though, if the scheduler isn't running, I'm not sure
what you can do in this situation. The system is already hung or in a
really bad way, so it would have to jump to somewhere late in 

svn commit: r331358 - head/libexec/tftpd/tests

2018-03-22 Thread Alan Somers
Author: asomers
Date: Thu Mar 22 14:51:05 2018
New Revision: 331358
URL: https://svnweb.freebsd.org/changeset/base/331358

Log:
  tftpd: misc Coverity cleanup in the tests
  
  A bunch of unchecked return values from open(2) and read(2)
  
  Reported by:  Coverity
  CID:  1386900, 1386911, 1386926, 1386928, 1386932, 1386942
  CID:  1386961, 1386979
  MFC after:8 days
  X-MFC-With:   330696

Modified:
  head/libexec/tftpd/tests/functional.c

Modified: head/libexec/tftpd/tests/functional.c
==
--- head/libexec/tftpd/tests/functional.c   Thu Mar 22 13:30:35 2018
(r331357)
+++ head/libexec/tftpd/tests/functional.c   Thu Mar 22 14:51:05 2018
(r331358)
@@ -224,19 +224,17 @@ do { \
 static void
 cleanup(void)
 {
-   int fd = -1;
-   char buffer[80] = {0};
+   FILE *f;
pid_t pid;
 
-   fd = open(pidfile, O_RDONLY);
-   if (fd < 0)
+   f = fopen(pidfile, "r");
+   if (f == NULL)
return;
-   if (read(fd, buffer, sizeof(buffer)) > 0) {
-   sscanf(buffer, "%d", );
+   if (fscanf(f, "%d", ) == 1) {
kill(pid, SIGTERM);
waitpid(pid, NULL, 0);
}
-   close(fd);
+   fclose(f);
unlink(pidfile);
 }
 
@@ -698,6 +696,7 @@ TFTPD_TC_DEFINE(w_flag,, w_flag = 1;)
recv_ack(1);
 
fd = open("small.txt", O_RDONLY);
+   ATF_REQUIRE(fd >= 0);
r = read(fd, buffer, sizeof(buffer));
close(fd);
require_bufeq(contents, contents_len, buffer, r);
@@ -734,6 +733,7 @@ TFTPD_TC_DEFINE(wrq_dropped_ack,)
recv_ack(2);
 
fd = open("medium.txt", O_RDONLY);
+   ATF_REQUIRE(fd >= 0);
r = read(fd, buffer, sizeof(buffer));
close(fd);
require_bufeq((const char*)contents, 768, buffer, r);
@@ -766,6 +766,7 @@ TFTPD_TC_DEFINE(wrq_dropped_data,)
recv_ack(1);
 
fd = open("small.txt", O_RDONLY);
+   ATF_REQUIRE(fd >= 0);
r = read(fd, buffer, sizeof(buffer));
close(fd);
require_bufeq(contents, contents_len, buffer, r);
@@ -799,6 +800,7 @@ TFTPD_TC_DEFINE(wrq_duped_data,)
recv_ack(2);
 
fd = open("medium.txt", O_RDONLY);
+   ATF_REQUIRE(fd >= 0);
r = read(fd, buffer, sizeof(buffer));
close(fd);
require_bufeq((const char*)contents, 768, buffer, r);
@@ -862,6 +864,7 @@ TFTPD_TC_DEFINE(wrq_medium,)
recv_ack(2);
 
fd = open("medium.txt", O_RDONLY);
+   ATF_REQUIRE(fd >= 0);
r = read(fd, buffer, sizeof(buffer));
close(fd);
require_bufeq((const char*)contents, 768, buffer, r);
@@ -894,6 +897,7 @@ TFTPD_TC_DEFINE(wrq_netascii,)
recv_ack(1);
 
fd = open("unix.txt", O_RDONLY);
+   ATF_REQUIRE(fd >= 0);
r = read(fd, buffer, sizeof(buffer));
close(fd);
require_bufeq(expected, sizeof(expected), buffer, r);
@@ -931,6 +935,7 @@ TFTPD_TC_DEFINE(wrq_small,)
recv_ack(1);
 
fd = open("small.txt", O_RDONLY);
+   ATF_REQUIRE(fd >= 0);
r = read(fd, buffer, sizeof(buffer));
close(fd);
require_bufeq(contents, contents_len, buffer, r);
___
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: r331347 - in head: etc/mtree include sys/conf sys/dev/tcp_log sys/kern sys/netinet usr.bin/netstat

2018-03-22 Thread Ruslan Bukin
Also can this be pluggable ?
It looks like it is optional device which means it can free up some space in 
embedded environment when unused

Ruslan

On Thu, Mar 22, 2018 at 02:16:06PM +, Ruslan Bukin wrote:
> We don't have atomic_fetchadd_64 for mips32 I think
> 
> Ruslan
> 
> On Thu, Mar 22, 2018 at 09:40:08AM +, Jonathan T. Looney wrote:
> > Author: jtl
> > Date: Thu Mar 22 09:40:08 2018
> > New Revision: 331347
> > URL: https://svnweb.freebsd.org/changeset/base/331347
> > 
> > Log:
> >   Add the "TCP Blackbox Recorder" which we discussed at the developer
> >   summits at BSDCan and BSDCam in 2017.
> >   
> >   The TCP Blackbox Recorder allows you to capture events on a TCP connection
> >   in a ring buffer. It stores metadata with the event. It optionally stores
> >   the TCP header associated with an event (if the event is associated with a
> >   packet) and also optionally stores information on the sockets.
> >   
> >   It supports setting a log ID on a TCP connection and using this to 
> > correlate
> >   multiple connections that share a common log ID.
> >   
> >   You can log connections in different modes. If you are doing a coordinated
> >   test with a particular connection, you may tell the system to put it in
> >   mode 4 (continuous dump). Or, if you just want to monitor for errors, you
> >   can put it in mode 1 (ring buffer) and dump all the ring buffers 
> > associated
> >   with the connection ID when we receive an error signal for that connection
> >   ID. You can set a default mode that will be applied to a particular ratio
> >   of incoming connections. You can also manually set a mode using a socket
> >   option.
> >   
> >   This commit includes only basic probes. rrs@ has added quite an abundance
> >   of probes in his TCP development work. He plans to commit those soon.
> >   
> >   There are user-space programs which we plan to commit as ports. These read
> >   the data from the log device and output pcapng files, and then let you
> >   analyze the data (and metadata) in the pcapng files.
> >   
> >   Reviewed by:  gnn (previous version)
> >   Obtained from:Netflix, Inc.
> >   Relnotes: yes
> >   Differential Revision:https://reviews.freebsd.org/D11085
> > 
> > Added:
> >   head/sys/dev/tcp_log/
> >   head/sys/dev/tcp_log/tcp_log_dev.c   (contents, props changed)
> >   head/sys/dev/tcp_log/tcp_log_dev.h   (contents, props changed)
> >   head/sys/netinet/tcp_log_buf.c   (contents, props changed)
> >   head/sys/netinet/tcp_log_buf.h   (contents, props changed)
> > Modified:
> >   head/etc/mtree/BSD.include.dist
> >   head/include/Makefile
> >   head/sys/conf/files
> >   head/sys/kern/subr_witness.c
> >   head/sys/netinet/tcp.h
> >   head/sys/netinet/tcp_input.c
> >   head/sys/netinet/tcp_output.c
> >   head/sys/netinet/tcp_subr.c
> >   head/sys/netinet/tcp_timer.c
> >   head/sys/netinet/tcp_usrreq.c
> >   head/sys/netinet/tcp_var.h
> >   head/usr.bin/netstat/inet.c
> >   head/usr.bin/netstat/main.c
> >   head/usr.bin/netstat/netstat.1
> >   head/usr.bin/netstat/netstat.h
> > 
> > Modified: head/etc/mtree/BSD.include.dist
> > ==
> > --- head/etc/mtree/BSD.include.dist Thu Mar 22 08:32:39 2018
> > (r331346)
> > +++ head/etc/mtree/BSD.include.dist Thu Mar 22 09:40:08 2018
> > (r331347)
> > @@ -158,6 +158,8 @@
> >  ..
> >  speaker
> >  ..
> > +tcp_log
> > +..
> >  usb
> >  ..
> >  vkbd
> > 
> > Modified: head/include/Makefile
> > ==
> > --- head/include/Makefile   Thu Mar 22 08:32:39 2018(r331346)
> > +++ head/include/Makefile   Thu Mar 22 09:40:08 2018(r331347)
> > @@ -47,7 +47,7 @@ LSUBDIRS= cam/ata cam/mmc cam/nvme cam/scsi \
> > dev/hwpmc dev/hyperv \
> > dev/ic dev/iicbus dev/io dev/lmc dev/mfi dev/mmc dev/nvme \
> > dev/ofw dev/pbio dev/pci ${_dev_powermac_nvram} dev/ppbus dev/smbus \
> > -   dev/speaker dev/vkbd dev/wi \
> > +   dev/speaker dev/tcp_log dev/vkbd dev/wi \
> > fs/devfs fs/fdescfs fs/msdosfs fs/nandfs fs/nfs fs/nullfs \
> > fs/procfs fs/smbfs fs/udf fs/unionfs \
> > geom/cache geom/concat geom/eli geom/gate geom/journal geom/label \
> > 
> > Modified: head/sys/conf/files
> > ==
> > --- head/sys/conf/files Thu Mar 22 08:32:39 2018(r331346)
> > +++ head/sys/conf/files Thu Mar 22 09:40:08 2018(r331347)
> > @@ -3161,6 +3161,7 @@ dev/syscons/star/star_saver.c optional star_saver
> >  dev/syscons/syscons.c  optional sc
> >  dev/syscons/sysmouse.c optional sc
> >  dev/syscons/warp/warp_saver.c  optional warp_saver
> > +dev/tcp_log/tcp_log_dev.c  optional inet | inet6
> >  dev/tdfx/tdfx_linux.c  optional tdfx_linux tdfx compat_linux
> >  

Re: svn commit: r331347 - in head: etc/mtree include sys/conf sys/dev/tcp_log sys/kern sys/netinet usr.bin/netstat

2018-03-22 Thread Ruslan Bukin
We don't have atomic_fetchadd_64 for mips32 I think

Ruslan

On Thu, Mar 22, 2018 at 09:40:08AM +, Jonathan T. Looney wrote:
> Author: jtl
> Date: Thu Mar 22 09:40:08 2018
> New Revision: 331347
> URL: https://svnweb.freebsd.org/changeset/base/331347
> 
> Log:
>   Add the "TCP Blackbox Recorder" which we discussed at the developer
>   summits at BSDCan and BSDCam in 2017.
>   
>   The TCP Blackbox Recorder allows you to capture events on a TCP connection
>   in a ring buffer. It stores metadata with the event. It optionally stores
>   the TCP header associated with an event (if the event is associated with a
>   packet) and also optionally stores information on the sockets.
>   
>   It supports setting a log ID on a TCP connection and using this to correlate
>   multiple connections that share a common log ID.
>   
>   You can log connections in different modes. If you are doing a coordinated
>   test with a particular connection, you may tell the system to put it in
>   mode 4 (continuous dump). Or, if you just want to monitor for errors, you
>   can put it in mode 1 (ring buffer) and dump all the ring buffers associated
>   with the connection ID when we receive an error signal for that connection
>   ID. You can set a default mode that will be applied to a particular ratio
>   of incoming connections. You can also manually set a mode using a socket
>   option.
>   
>   This commit includes only basic probes. rrs@ has added quite an abundance
>   of probes in his TCP development work. He plans to commit those soon.
>   
>   There are user-space programs which we plan to commit as ports. These read
>   the data from the log device and output pcapng files, and then let you
>   analyze the data (and metadata) in the pcapng files.
>   
>   Reviewed by:gnn (previous version)
>   Obtained from:  Netflix, Inc.
>   Relnotes:   yes
>   Differential Revision:  https://reviews.freebsd.org/D11085
> 
> Added:
>   head/sys/dev/tcp_log/
>   head/sys/dev/tcp_log/tcp_log_dev.c   (contents, props changed)
>   head/sys/dev/tcp_log/tcp_log_dev.h   (contents, props changed)
>   head/sys/netinet/tcp_log_buf.c   (contents, props changed)
>   head/sys/netinet/tcp_log_buf.h   (contents, props changed)
> Modified:
>   head/etc/mtree/BSD.include.dist
>   head/include/Makefile
>   head/sys/conf/files
>   head/sys/kern/subr_witness.c
>   head/sys/netinet/tcp.h
>   head/sys/netinet/tcp_input.c
>   head/sys/netinet/tcp_output.c
>   head/sys/netinet/tcp_subr.c
>   head/sys/netinet/tcp_timer.c
>   head/sys/netinet/tcp_usrreq.c
>   head/sys/netinet/tcp_var.h
>   head/usr.bin/netstat/inet.c
>   head/usr.bin/netstat/main.c
>   head/usr.bin/netstat/netstat.1
>   head/usr.bin/netstat/netstat.h
> 
> Modified: head/etc/mtree/BSD.include.dist
> ==
> --- head/etc/mtree/BSD.include.dist   Thu Mar 22 08:32:39 2018
> (r331346)
> +++ head/etc/mtree/BSD.include.dist   Thu Mar 22 09:40:08 2018
> (r331347)
> @@ -158,6 +158,8 @@
>  ..
>  speaker
>  ..
> +tcp_log
> +..
>  usb
>  ..
>  vkbd
> 
> Modified: head/include/Makefile
> ==
> --- head/include/Makefile Thu Mar 22 08:32:39 2018(r331346)
> +++ head/include/Makefile Thu Mar 22 09:40:08 2018(r331347)
> @@ -47,7 +47,7 @@ LSUBDIRS=   cam/ata cam/mmc cam/nvme cam/scsi \
>   dev/hwpmc dev/hyperv \
>   dev/ic dev/iicbus dev/io dev/lmc dev/mfi dev/mmc dev/nvme \
>   dev/ofw dev/pbio dev/pci ${_dev_powermac_nvram} dev/ppbus dev/smbus \
> - dev/speaker dev/vkbd dev/wi \
> + dev/speaker dev/tcp_log dev/vkbd dev/wi \
>   fs/devfs fs/fdescfs fs/msdosfs fs/nandfs fs/nfs fs/nullfs \
>   fs/procfs fs/smbfs fs/udf fs/unionfs \
>   geom/cache geom/concat geom/eli geom/gate geom/journal geom/label \
> 
> Modified: head/sys/conf/files
> ==
> --- head/sys/conf/files   Thu Mar 22 08:32:39 2018(r331346)
> +++ head/sys/conf/files   Thu Mar 22 09:40:08 2018(r331347)
> @@ -3161,6 +3161,7 @@ dev/syscons/star/star_saver.c   optional star_saver
>  dev/syscons/syscons.coptional sc
>  dev/syscons/sysmouse.c   optional sc
>  dev/syscons/warp/warp_saver.coptional warp_saver
> +dev/tcp_log/tcp_log_dev.coptional inet | inet6
>  dev/tdfx/tdfx_linux.coptional tdfx_linux tdfx compat_linux
>  dev/tdfx/tdfx_pci.c  optional tdfx pci
>  dev/ti/if_ti.c   optional ti pci
> @@ -4309,6 +4310,7 @@ netinet/tcp_debug.c optional tcpdebug
>  netinet/tcp_fastopen.c   optional inet tcp_rfc7413 | inet6 
> tcp_rfc7413
>  netinet/tcp_hostcache.c  optional inet | inet6
>  netinet/tcp_input.c  optional inet | inet6
> 

Re: svn commit: r331298 - head/sys/dev/syscons

2018-03-22 Thread Bruce Evans

On Thu, 22 Mar 2018, Konstantin Belousov wrote:


On Thu, Mar 22, 2018 at 05:50:57PM +1100, Bruce Evans wrote:

On Wed, 21 Mar 2018, Warner Losh wrote:


On Wed, Mar 21, 2018 at 2:27 PM, Konstantin Belousov 
wrote:

...
Are you saying that fast interrupt handlers call shutdown_nice() ?  This
is the quite serious bug on its own.  To fix it, shutdown_nice() should
use a fast taskqueue to schedule the task which would lock the process
and send the signal.


Is there some way we know we're in a fast interrupt handler? If so, it
should be simple to fix. If not, then there's an API change ahead of us...


There is a td_intr_nesting_level flag that might work.  (I invented this,
but don't like its current use.)

But why do we need to know this ?  We can always schedule a task in the
fast taskqueue if init is present and can be scheduled.


Not quite always.  In my version, fast interrupt handlers are actually
fast, so they can interrupt any spin mutex and cannot call any
scheduling function.  This is enforced by setting the pcpu pointer to
NULL.  Taskqueues and even SWIs are unavailable for fast interrupt
handlers.  Scheduling is done by setting a flag that is checked in
timeout handlers like it was in FreeBSD-1.


...

shutdown_nice() is also called directly from syscons and vt for the reboot,
halt and poweroff keys.  This happens in normal interrupt handler context,
so there is only a problem when init is not running.


diff --git a/sys/kern/kern_shutdown.c b/sys/kern/kern_shutdown.c
index e5ea9644ad3..e7c6d4c92b2 100644
--- a/sys/kern/kern_shutdown.c
+++ b/sys/kern/kern_shutdown.c
@@ -72,6 +72,7 @@ __FBSDID("$FreeBSD$");
#include 
#include 
#include 
+#include 
#include 
#include 

@@ -276,6 +277,28 @@ sys_reboot(struct thread *td, struct reboot_args *uap)
return (error);
}

+static void
+shutdown_nice_task_fn(void *arg, int pending __unused)
+{
+   int howto;
+
+   howto = (uintptr_t)arg;
+   /* Send a signal to init(8) and have it shutdown the world. */
+   PROC_LOCK(initproc);
+   if (howto & RB_POWEROFF)
+   kern_psignal(initproc, SIGUSR2);
+   else if (howto & RB_POWERCYCLE)
+   kern_psignal(initproc, SIGWINCH);
+   else if (howto & RB_HALT)
+   kern_psignal(initproc, SIGUSR1);
+   else
+   kern_psignal(initproc, SIGINT);
+   PROC_UNLOCK(initproc);
+}
+
+static struct task shutdown_nice_task = TASK_INITIALIZER(0,
+_nice_task_fn, NULL);
+


I don't like having a whole task for this.  The whole thing is just a
hack to work around some the upper layers of the tty driver and some
lower layers not having any input [escape] sequences to control the
kernel.  Only the syscons and vt lower layers have such sequences
(where they are actually key combinations that are converted to control
operations instead of to input [escape] sequences).  To work around for
hardware ttys, the filter for kdb sequences is abused to implement a
non-kdb sequence for rebooting.

The tty input methods could check for kernel-control sequences and safely
signal init.  This is a bit too complicated for syscons and vt since they
can more easily check for key combinations, but wouldhave to convert these
to standard sequences to get the tty layer to do the same thing.  (They
have many more kernel-control key combinations and the non-kdb one for
rebooting is just a bug for them.)  This is a bit complicated for hardware
tty drivers too -- some use the tty bulk-input method and this shouldn't
check for sequences, but should reduce to bcopy().  Hoever, to detect the
kdb sequences, these drivers han to check at a low level anyway.  They
can be clever about this and only check for the console device[s] which are
usually only used for for input at a low rate.


/*
 * Called by events that want to shut down.. e.g   on a PC
 */
@@ -283,20 +306,14 @@ void
shutdown_nice(int howto)
{

-   if (initproc != NULL) {
-   /* Send a signal to init(8) and have it shutdown the world. */
-   PROC_LOCK(initproc);
-   if (howto & RB_POWEROFF)
-   kern_psignal(initproc, SIGUSR2);
-   else if (howto & RB_POWERCYCLE)
-   kern_psignal(initproc, SIGWINCH);
-   else if (howto & RB_HALT)
-   kern_psignal(initproc, SIGUSR1);
-   else
-   kern_psignal(initproc, SIGINT);
-   PROC_UNLOCK(initproc);
+   if (initproc != NULL && !SCHEDULER_STOPPED()) {
+   shutdown_nice_task.ta_context = (void *)(uintptr_t)howto;
+   taskqueue_enqueue(taskqueue_fast, _nice_task);
} else {
-   /* No init(8) running, so simply reboot. */
+   /*
+* No init(8) running, or scheduler would not allow it
+* to run, so simply reboot.
+*/
kern_reboot(howto | RB_NOSYNC);
}
}


Calling 

Re: svn commit: r331356 - in head: lib/libsysdecode sys/amd64/linux sys/amd64/linux32 sys/compat/linux sys/i386/linux sys/modules/linux_common

2018-03-22 Thread Ed Maste
On 22 March 2018 at 08:58, Ed Maste  wrote:
> Author: emaste
> Date: Thu Mar 22 12:58:49 2018
> New Revision: 331356
> URL: https://svnweb.freebsd.org/changeset/base/331356
>
> Log:
>   Share Linux errno table with libsysdecode

I had a question about using ".inc" vs ".h". I followed the ".inc"
convention from some examples in llvm and elsewhere, because
linux_errno.inc is unlike regular headers - it's not idempotent, and
the array has to be the first non-comment content in the file because
it's prefixed with "static" before one of the #includes.
___
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: r331357 - head/sys/compat/linuxkpi/common/include/linux

2018-03-22 Thread Hans Petter Selasky
Author: hselasky
Date: Thu Mar 22 13:30:35 2018
New Revision: 331357
URL: https://svnweb.freebsd.org/changeset/base/331357

Log:
  The pci_disable_device() function is also expected to clear the PCI
  busmaster. This fixes LinuxKPI compliancy with Linux.
  
  MFC after:1 week
  Sponsored by: Mellanox Technologies

Modified:
  head/sys/compat/linuxkpi/common/include/linux/pci.h

Modified: head/sys/compat/linuxkpi/common/include/linux/pci.h
==
--- head/sys/compat/linuxkpi/common/include/linux/pci.h Thu Mar 22 12:58:49 
2018(r331356)
+++ head/sys/compat/linuxkpi/common/include/linux/pci.h Thu Mar 22 13:30:35 
2018(r331357)
@@ -343,6 +343,7 @@ pci_disable_device(struct pci_dev *pdev)
 
pci_disable_io(pdev->dev.bsddev, SYS_RES_IOPORT);
pci_disable_io(pdev->dev.bsddev, SYS_RES_MEMORY);
+   pci_disable_busmaster(pdev->dev.bsddev);
 }
 
 static inline int
___
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: r331356 - in head: lib/libsysdecode sys/amd64/linux sys/amd64/linux32 sys/compat/linux sys/i386/linux sys/modules/linux_common

2018-03-22 Thread Ed Maste
Author: emaste
Date: Thu Mar 22 12:58:49 2018
New Revision: 331356
URL: https://svnweb.freebsd.org/changeset/base/331356

Log:
  Share Linux errno table with libsysdecode
  
  Requested by: jhb
  Reviewed by:  jhb
  Sponsored by: Turing Robotic Industries Inc.

Added:
  head/sys/compat/linux/linux_errno.inc
 - copied, changed from r331355, head/sys/compat/linux/linux_errno.c
Modified:
  head/lib/libsysdecode/errno.c
  head/sys/amd64/linux/linux_sysvec.c
  head/sys/amd64/linux32/linux32_sysvec.c
  head/sys/compat/linux/linux_emul.h
  head/sys/compat/linux/linux_errno.c
  head/sys/i386/linux/linux_sysvec.c
  head/sys/modules/linux_common/Makefile

Modified: head/lib/libsysdecode/errno.c
==
--- head/lib/libsysdecode/errno.c   Thu Mar 22 12:26:27 2018
(r331355)
+++ head/lib/libsysdecode/errno.c   Thu Mar 22 12:58:49 2018
(r331356)
@@ -37,25 +37,8 @@ __FBSDID("$FreeBSD$");
 #include 
 
 #if defined(__i386__) || defined(__amd64__)
-/*
- * Linux syscalls return negative errno's, we do positive and map them
- * Reference:
- *   FreeBSD: src/sys/sys/errno.h
- *   Linux:   include/uapi/asm-generic/errno-base.h
- *include/uapi/asm-generic/errno.h
- */
-static int bsd_to_linux_errno[ELAST + 1] = {
-   -0,  -1,  -2,  -3,  -4,  -5,  -6,  -7,  -8,  -9,
-   -10, -35, -12, -13, -14, -15, -16, -17, -18, -19,
-   -20, -21, -22, -23, -24, -25, -26, -27, -28, -29,
-   -30, -31, -32, -33, -34, -11,-115,-114, -88, -89,
-   -90, -91, -92, -93, -94, -95, -96, -97, -98, -99,
-   -100,-101,-102,-103,-104,-105,-106,-107,-108,-109,
-   -110,-111, -40, -36,-112,-113, -39, -11, -87,-122,
-   -116, -66,  -6,  -6,  -6,  -6,  -6, -37, -38,  -9,
- -6,  -6, -43, -42, -75,-125, -84, -61, -16, -74,
--72, -67, -71,  -1,  -1, -131, -130
-};
+static
+#include 
 #endif
 
 #include 
@@ -156,8 +139,8 @@ sysdecode_abi_to_freebsd_errno(enum sysdecode_abi abi,
 * This is imprecise since it returns the first
 * matching errno.
 */
-   for (i = 0; i < nitems(bsd_to_linux_errno); i++) {
-   if (error == bsd_to_linux_errno[i])
+   for (i = 0; i < nitems(linux_errtbl); i++) {
+   if (error == linux_errtbl[i])
return (i);
}
break;
@@ -187,7 +170,7 @@ sysdecode_freebsd_to_abi_errno(enum sysdecode_abi abi,
case SYSDECODE_ABI_LINUX:
case SYSDECODE_ABI_LINUX32:
if (error >= 0 && error <= ELAST)
-   return (bsd_to_linux_errno[error]);
+   return (linux_errtbl[error]);
break;
 #endif
case SYSDECODE_ABI_CLOUDABI32:

Modified: head/sys/amd64/linux/linux_sysvec.c
==
--- head/sys/amd64/linux/linux_sysvec.c Thu Mar 22 12:26:27 2018
(r331355)
+++ head/sys/amd64/linux/linux_sysvec.c Thu Mar 22 12:58:49 2018
(r331356)
@@ -752,7 +752,7 @@ struct sysentvec elf_linux_sysvec = {
.sv_table   = linux_sysent,
.sv_mask= 0,
.sv_errsize = ELAST + 1,
-   .sv_errtbl  = bsd_to_linux_errno_generic,
+   .sv_errtbl  = linux_errtbl,
.sv_transtrap   = linux_translate_traps,
.sv_fixup   = linux_fixup_elf,
.sv_sendsig = linux_rt_sendsig,

Modified: head/sys/amd64/linux32/linux32_sysvec.c
==
--- head/sys/amd64/linux32/linux32_sysvec.c Thu Mar 22 12:26:27 2018
(r331355)
+++ head/sys/amd64/linux32/linux32_sysvec.c Thu Mar 22 12:58:49 2018
(r331356)
@@ -952,7 +952,7 @@ struct sysentvec elf_linux_sysvec = {
.sv_table   = linux32_sysent,
.sv_mask= 0,
.sv_errsize = ELAST + 1,
-   .sv_errtbl  = bsd_to_linux_errno_generic,
+   .sv_errtbl  = linux_errtbl,
.sv_transtrap   = linux_translate_traps,
.sv_fixup   = linux_fixup_elf,
.sv_sendsig = linux_sendsig,

Modified: head/sys/compat/linux/linux_emul.h
==
--- head/sys/compat/linux/linux_emul.h  Thu Mar 22 12:26:27 2018
(r331355)
+++ head/sys/compat/linux/linux_emul.h  Thu Mar 22 12:58:49 2018
(r331356)
@@ -77,6 +77,6 @@ struct linux_pemuldata {
 
 struct linux_pemuldata *pem_find(struct proc *);
 
-extern const int bsd_to_linux_errno_generic[];
+extern const int linux_errtbl[];
 
 #endif /* !_LINUX_EMUL_H_ */

Modified: head/sys/compat/linux/linux_errno.c
==
--- head/sys/compat/linux/linux_errno.c Thu Mar 22 12:26:27 2018
(r331355)
+++ head/sys/compat/linux/linux_errno.c Thu Mar 22 12:58:49 

svn commit: r331355 - head/sys/compat/linuxkpi/common/include/linux

2018-03-22 Thread Hans Petter Selasky
Author: hselasky
Date: Thu Mar 22 12:26:27 2018
New Revision: 331355
URL: https://svnweb.freebsd.org/changeset/base/331355

Log:
  Clear old MSIX IRQ numbers in the LinuxKPI.
  
  When disabling the MSIX IRQ vectors for a PCI device through the
  LinuxKPI, make sure any old MSIX IRQ numbers are no longer visible to
  the linux_pci_find_irq_dev() function else IRQs can be requested from
  the wrong PCI device.
  
  MFC after:1 week
  Sponsored by: Mellanox Technologies

Modified:
  head/sys/compat/linuxkpi/common/include/linux/pci.h

Modified: head/sys/compat/linuxkpi/common/include/linux/pci.h
==
--- head/sys/compat/linuxkpi/common/include/linux/pci.h Thu Mar 22 12:01:30 
2018(r331354)
+++ head/sys/compat/linuxkpi/common/include/linux/pci.h Thu Mar 22 12:26:27 
2018(r331355)
@@ -425,6 +425,15 @@ pci_disable_msix(struct pci_dev *pdev)
 {
 
pci_release_msi(pdev->dev.bsddev);
+
+   /*
+* The MSIX IRQ numbers associated with this PCI device are no
+* longer valid and might be re-assigned. Make sure
+* linux_pci_find_irq_dev() does no longer see them by
+* resetting their references to zero:
+*/
+   pdev->dev.msix = 0;
+   pdev->dev.msix_max = 0;
 }
 
 static inline bus_addr_t
___
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: r331306 - head/sys/dev/usb/controller

2018-03-22 Thread Hans Petter Selasky

On 03/22/18 13:02, Andrew Turner wrote:

On 21 Mar 2018, at 21:54, Hans Petter Selasky  wrote:

On 03/21/18 17:45, Andrew Turner wrote:

On 21 Mar 2018, at 15:37, Hans Petter Selasky  wrote:

On 03/21/18 16:24, Kyle Evans wrote:

+   {
+   .ep_end = 7,
+   .ep_fifosz_shift = 9,
+   .ep_fifosz_reg = MUSB2_VAL_FIFOSZ_512 | MUSB2_MASK_FIFODB,
+   },

I'm afraid I'm not familiar with this- why did .ep_fifosz_shift for
this case drop to 9? frx = 10 in the temp < 8 case in the removals of
the following hunks. Mostly curious because the others seemed to stay
the same.


Hi Andrew,

It might be an idea to keep the fifosz_shift at 10, else high-speed BULK 
traffic won't be double buffered, and this might affect performance.

Should the endpoint 1 size also be fixed? The register has it at 4k, but it 
wasn’t an 8k buffer.


No, because High-Speed BULK will only use 512 byte packets, and 4k is reserved 
for isochronous, which doesn't need double buffering at the moment.


Ok, in that case should we remove the double buffer flag on endpoint 1? The 
Linux driver seems to always use a 512 byte buffer there, and always doubles 
the offset increment when the double buffer flag is set.


Hi Andrew,

That's a good question. I think you should leave the double buffer flag 
on for this register. Double buffering is then later on re-programmed by:



static void
musbotg_clear_stall_sub(struct musbotg_softc *sc, uint16_t wMaxPacket,
uint8_t ep_no, uint8_t ep_type, uint8_t ep_dir)


If you look at the writes to MUSB2_REG_TXDBDIS and MUSB2_REG_RXDBDIS.

I think those registers override the "master" register. You might want 
to check the PRM to be absolutely sure.


--HPS
___
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: r331306 - head/sys/dev/usb/controller

2018-03-22 Thread Andrew Turner
> On 21 Mar 2018, at 21:54, Hans Petter Selasky  wrote:
> 
> On 03/21/18 17:45, Andrew Turner wrote:
>>> On 21 Mar 2018, at 15:37, Hans Petter Selasky  wrote:
>>> 
>>> On 03/21/18 16:24, Kyle Evans wrote:
> +   {
> +   .ep_end = 7,
> +   .ep_fifosz_shift = 9,
> +   .ep_fifosz_reg = MUSB2_VAL_FIFOSZ_512 | MUSB2_MASK_FIFODB,
> +   },
 I'm afraid I'm not familiar with this- why did .ep_fifosz_shift for
 this case drop to 9? frx = 10 in the temp < 8 case in the removals of
 the following hunks. Mostly curious because the others seemed to stay
 the same.
>>> 
>>> Hi Andrew,
>>> 
>>> It might be an idea to keep the fifosz_shift at 10, else high-speed BULK 
>>> traffic won't be double buffered, and this might affect performance.
>> Should the endpoint 1 size also be fixed? The register has it at 4k, but it 
>> wasn’t an 8k buffer.
> 
> No, because High-Speed BULK will only use 512 byte packets, and 4k is 
> reserved for isochronous, which doesn't need double buffering at the moment.

Ok, in that case should we remove the double buffer flag on endpoint 1? The 
Linux driver seems to always use a 512 byte buffer there, and always doubles 
the offset increment when the double buffer flag is set.

Andrew

___
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: r331353 - head

2018-03-22 Thread Kyle Evans
Author: kevans
Date: Thu Mar 22 11:57:59 2018
New Revision: 331353
URL: https://svnweb.freebsd.org/changeset/base/331353

Log:
  Partially revert r328780
  
  efi.4th was added to ObsoleteFiles and disconnected from the build, but not
  removed from hte repo. We've since found a mild use for it that makes some
  amount of sense, so partially revert r328780 and bring it back to life.
  
  Reported by:  many
  X-MFC-With:   r331326

Modified:
  head/ObsoleteFiles.inc

Modified: head/ObsoleteFiles.inc
==
--- head/ObsoleteFiles.inc  Thu Mar 22 11:57:12 2018(r331352)
+++ head/ObsoleteFiles.inc  Thu Mar 22 11:57:59 2018(r331353)
@@ -59,7 +59,6 @@ OLD_FILES+=usr/share/openssl/man/man1/c_rehash.1.gz
 # 20180206: remove gdbtui
 OLD_FILES+=usr/bin/gdbtui
 # 20180201: Obsolete forth files
-OLD_FILES+=boot/efi.4th
 OLD_FILES+=boot/pcibios.4th
 # 20180114: new clang import which bumps version from 5.0.1 to 6.0.0.
 OLD_FILES+=usr/lib/clang/5.0.1/include/sanitizer/allocator_interface.h
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r331350 - stable/11/contrib/dma

2018-03-22 Thread Ed Maste
Author: emaste
Date: Thu Mar 22 11:48:14 2018
New Revision: 331350
URL: https://svnweb.freebsd.org/changeset/base/331350

Log:
  MFC r325047: dma: fix use-after-free
  
  Sponsored by: The FreeBSD Foundation

Modified:
  stable/11/contrib/dma/dma.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/contrib/dma/dma.c
==
--- stable/11/contrib/dma/dma.c Thu Mar 22 10:57:51 2018(r331349)
+++ stable/11/contrib/dma/dma.c Thu Mar 22 11:48:14 2018(r331350)
@@ -331,8 +331,8 @@ retry:
 
switch (error) {
case 0:
-   delqueue(it);
syslog(LOG_INFO, "<%s> delivery successful", it->addr);
+   delqueue(it);
exit(EX_OK);
 
case 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: r331298 - head/sys/dev/syscons

2018-03-22 Thread Konstantin Belousov
On Thu, Mar 22, 2018 at 05:50:57PM +1100, Bruce Evans wrote:
> On Wed, 21 Mar 2018, Warner Losh wrote:
> 
> > On Wed, Mar 21, 2018 at 2:27 PM, Konstantin Belousov 
> > wrote:
> >> ...
> >> Are you saying that fast interrupt handlers call shutdown_nice() ?  This
> >> is the quite serious bug on its own.  To fix it, shutdown_nice() should
> >> use a fast taskqueue to schedule the task which would lock the process
> >> and send the signal.
> >
> > Is there some way we know we're in a fast interrupt handler? If so, it
> > should be simple to fix. If not, then there's an API change ahead of us...
> 
> There is a td_intr_nesting_level flag that might work.  (I invented this,
> but don't like its current use.)
But why do we need to know this ?  We can always schedule a task in the
fast taskqueue if init is present and can be scheduled.

> 
> > But bde is right: the system has to be in good enough shape to cope. I
> > wonder if we should put that coping into kdb_reboot() instead. It's only an
> > issue for  TILDE ^R, which is a fairly edge case.
> 
> shutdown_nice() is also called directly from syscons and vt for the reboot,
> halt and poweroff keys.  This happens in normal interrupt handler context,
> so there is only a problem when init is not running.

diff --git a/sys/kern/kern_shutdown.c b/sys/kern/kern_shutdown.c
index e5ea9644ad3..e7c6d4c92b2 100644
--- a/sys/kern/kern_shutdown.c
+++ b/sys/kern/kern_shutdown.c
@@ -72,6 +72,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -276,6 +277,28 @@ sys_reboot(struct thread *td, struct reboot_args *uap)
return (error);
 }
 
+static void
+shutdown_nice_task_fn(void *arg, int pending __unused)
+{
+   int howto;
+
+   howto = (uintptr_t)arg;
+   /* Send a signal to init(8) and have it shutdown the world. */
+   PROC_LOCK(initproc);
+   if (howto & RB_POWEROFF)
+   kern_psignal(initproc, SIGUSR2);
+   else if (howto & RB_POWERCYCLE)
+   kern_psignal(initproc, SIGWINCH);
+   else if (howto & RB_HALT)
+   kern_psignal(initproc, SIGUSR1);
+   else
+   kern_psignal(initproc, SIGINT);
+   PROC_UNLOCK(initproc);
+}
+
+static struct task shutdown_nice_task = TASK_INITIALIZER(0,
+_nice_task_fn, NULL);
+
 /*
  * Called by events that want to shut down.. e.g   on a PC
  */
@@ -283,20 +306,14 @@ void
 shutdown_nice(int howto)
 {
 
-   if (initproc != NULL) {
-   /* Send a signal to init(8) and have it shutdown the world. */
-   PROC_LOCK(initproc);
-   if (howto & RB_POWEROFF)
-   kern_psignal(initproc, SIGUSR2);
-   else if (howto & RB_POWERCYCLE)
-   kern_psignal(initproc, SIGWINCH);
-   else if (howto & RB_HALT)
-   kern_psignal(initproc, SIGUSR1);
-   else
-   kern_psignal(initproc, SIGINT);
-   PROC_UNLOCK(initproc);
+   if (initproc != NULL && !SCHEDULER_STOPPED()) {
+   shutdown_nice_task.ta_context = (void *)(uintptr_t)howto;
+   taskqueue_enqueue(taskqueue_fast, _nice_task);
} else {
-   /* No init(8) running, so simply reboot. */
+   /*
+* No init(8) running, or scheduler would not allow it
+* to run, so simply reboot.
+*/
kern_reboot(howto | RB_NOSYNC);
}
 }
___
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: r331349 - stable/11/sbin/ifconfig

2018-03-22 Thread Renato Botelho
Author: garga (ports committer)
Date: Thu Mar 22 10:57:51 2018
New Revision: 331349
URL: https://svnweb.freebsd.org/changeset/base/331349

Log:
  MFC r322281:
  
  Add missing parenthesis on error message
  
  Approved by:  loos
  Sponsored by: Rubicon Communications, LLC (Netgate)

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

Modified: stable/11/sbin/ifconfig/ifconfig.c
==
--- stable/11/sbin/ifconfig/ifconfig.c  Thu Mar 22 09:43:15 2018
(r331348)
+++ stable/11/sbin/ifconfig/ifconfig.c  Thu Mar 22 10:57:51 2018
(r331349)
@@ -762,7 +762,7 @@ top:
if ((s = socket(ifr.ifr_addr.sa_family, SOCK_DGRAM, 0)) < 0 &&
(uafp != NULL || errno != EAFNOSUPPORT ||
 (s = socket(AF_LOCAL, SOCK_DGRAM, 0)) < 0))
-   err(1, "socket(family %u,SOCK_DGRAM", ifr.ifr_addr.sa_family);
+   err(1, "socket(family %u,SOCK_DGRAM)", ifr.ifr_addr.sa_family);
 
while (argc > 0) {
p = cmd_lookup(*argv, iscreate);
___
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: r331348 - head/usr.bin/netstat

2018-03-22 Thread Jonathan T. Looney
Author: jtl
Date: Thu Mar 22 09:43:15 2018
New Revision: 331348
URL: https://svnweb.freebsd.org/changeset/base/331348

Log:
  Bump netstat.1's .Dd after r331347.

Modified:
  head/usr.bin/netstat/netstat.1

Modified: head/usr.bin/netstat/netstat.1
==
--- head/usr.bin/netstat/netstat.1  Thu Mar 22 09:40:08 2018
(r331347)
+++ head/usr.bin/netstat/netstat.1  Thu Mar 22 09:43:15 2018
(r331348)
@@ -28,7 +28,7 @@
 .\"@(#)netstat.1   8.8 (Berkeley) 4/18/94
 .\" $FreeBSD$
 .\"
-.Dd September 9, 2017
+.Dd March 22, 2018
 .Dt NETSTAT 1
 .Os
 .Sh NAME
___
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: r331347 - in head: etc/mtree include sys/conf sys/dev/tcp_log sys/kern sys/netinet usr.bin/netstat

2018-03-22 Thread Jonathan T. Looney
Author: jtl
Date: Thu Mar 22 09:40:08 2018
New Revision: 331347
URL: https://svnweb.freebsd.org/changeset/base/331347

Log:
  Add the "TCP Blackbox Recorder" which we discussed at the developer
  summits at BSDCan and BSDCam in 2017.
  
  The TCP Blackbox Recorder allows you to capture events on a TCP connection
  in a ring buffer. It stores metadata with the event. It optionally stores
  the TCP header associated with an event (if the event is associated with a
  packet) and also optionally stores information on the sockets.
  
  It supports setting a log ID on a TCP connection and using this to correlate
  multiple connections that share a common log ID.
  
  You can log connections in different modes. If you are doing a coordinated
  test with a particular connection, you may tell the system to put it in
  mode 4 (continuous dump). Or, if you just want to monitor for errors, you
  can put it in mode 1 (ring buffer) and dump all the ring buffers associated
  with the connection ID when we receive an error signal for that connection
  ID. You can set a default mode that will be applied to a particular ratio
  of incoming connections. You can also manually set a mode using a socket
  option.
  
  This commit includes only basic probes. rrs@ has added quite an abundance
  of probes in his TCP development work. He plans to commit those soon.
  
  There are user-space programs which we plan to commit as ports. These read
  the data from the log device and output pcapng files, and then let you
  analyze the data (and metadata) in the pcapng files.
  
  Reviewed by:  gnn (previous version)
  Obtained from:Netflix, Inc.
  Relnotes: yes
  Differential Revision:https://reviews.freebsd.org/D11085

Added:
  head/sys/dev/tcp_log/
  head/sys/dev/tcp_log/tcp_log_dev.c   (contents, props changed)
  head/sys/dev/tcp_log/tcp_log_dev.h   (contents, props changed)
  head/sys/netinet/tcp_log_buf.c   (contents, props changed)
  head/sys/netinet/tcp_log_buf.h   (contents, props changed)
Modified:
  head/etc/mtree/BSD.include.dist
  head/include/Makefile
  head/sys/conf/files
  head/sys/kern/subr_witness.c
  head/sys/netinet/tcp.h
  head/sys/netinet/tcp_input.c
  head/sys/netinet/tcp_output.c
  head/sys/netinet/tcp_subr.c
  head/sys/netinet/tcp_timer.c
  head/sys/netinet/tcp_usrreq.c
  head/sys/netinet/tcp_var.h
  head/usr.bin/netstat/inet.c
  head/usr.bin/netstat/main.c
  head/usr.bin/netstat/netstat.1
  head/usr.bin/netstat/netstat.h

Modified: head/etc/mtree/BSD.include.dist
==
--- head/etc/mtree/BSD.include.dist Thu Mar 22 08:32:39 2018
(r331346)
+++ head/etc/mtree/BSD.include.dist Thu Mar 22 09:40:08 2018
(r331347)
@@ -158,6 +158,8 @@
 ..
 speaker
 ..
+tcp_log
+..
 usb
 ..
 vkbd

Modified: head/include/Makefile
==
--- head/include/Makefile   Thu Mar 22 08:32:39 2018(r331346)
+++ head/include/Makefile   Thu Mar 22 09:40:08 2018(r331347)
@@ -47,7 +47,7 @@ LSUBDIRS= cam/ata cam/mmc cam/nvme cam/scsi \
dev/hwpmc dev/hyperv \
dev/ic dev/iicbus dev/io dev/lmc dev/mfi dev/mmc dev/nvme \
dev/ofw dev/pbio dev/pci ${_dev_powermac_nvram} dev/ppbus dev/smbus \
-   dev/speaker dev/vkbd dev/wi \
+   dev/speaker dev/tcp_log dev/vkbd dev/wi \
fs/devfs fs/fdescfs fs/msdosfs fs/nandfs fs/nfs fs/nullfs \
fs/procfs fs/smbfs fs/udf fs/unionfs \
geom/cache geom/concat geom/eli geom/gate geom/journal geom/label \

Modified: head/sys/conf/files
==
--- head/sys/conf/files Thu Mar 22 08:32:39 2018(r331346)
+++ head/sys/conf/files Thu Mar 22 09:40:08 2018(r331347)
@@ -3161,6 +3161,7 @@ dev/syscons/star/star_saver.c optional star_saver
 dev/syscons/syscons.c  optional sc
 dev/syscons/sysmouse.c optional sc
 dev/syscons/warp/warp_saver.c  optional warp_saver
+dev/tcp_log/tcp_log_dev.c  optional inet | inet6
 dev/tdfx/tdfx_linux.c  optional tdfx_linux tdfx compat_linux
 dev/tdfx/tdfx_pci.coptional tdfx pci
 dev/ti/if_ti.c optional ti pci
@@ -4309,6 +4310,7 @@ netinet/tcp_debug.c   optional tcpdebug
 netinet/tcp_fastopen.c optional inet tcp_rfc7413 | inet6 tcp_rfc7413
 netinet/tcp_hostcache.coptional inet | inet6
 netinet/tcp_input.coptional inet | inet6
+netinet/tcp_log_buf.c  optional inet | inet6
 netinet/tcp_lro.c  optional inet | inet6
 netinet/tcp_output.c   optional inet | inet6
 netinet/tcp_offload.c  optional tcp_offload inet | tcp_offload inet6

Added: head/sys/dev/tcp_log/tcp_log_dev.c
==
--- 

svn commit: r331346 - head/sys/modules/blake2

2018-03-22 Thread Li-Wen Hsu
Author: lwhsu (ports committer)
Date: Thu Mar 22 08:32:39 2018
New Revision: 331346
URL: https://svnweb.freebsd.org/changeset/base/331346

Log:
  Fix build.
  
  Reviewed by:  cem
  Differential Revision:https://reviews.freebsd.org/D14793

Modified:
  head/sys/modules/blake2/Makefile

Modified: head/sys/modules/blake2/Makefile
==
--- head/sys/modules/blake2/MakefileThu Mar 22 06:31:05 2018
(r331345)
+++ head/sys/modules/blake2/MakefileThu Mar 22 08:32:39 2018
(r331346)
@@ -80,7 +80,7 @@ SRCS  += string.h
 
 SRCS   += blake2_cryptodev.c
 
-SRCS   += opt_param.h cryptodev_if.h
+SRCS   += opt_param.h cryptodev_if.h bus_if.h device_if.h
 
 WARNS  ?= 6
 
___
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: r331298 - head/sys/dev/syscons

2018-03-22 Thread Bruce Evans

On Wed, 21 Mar 2018, Warner Losh wrote:


On Wed, Mar 21, 2018 at 2:27 PM, Konstantin Belousov 
wrote:

...
Are you saying that fast interrupt handlers call shutdown_nice() ?  This
is the quite serious bug on its own.  To fix it, shutdown_nice() should
use a fast taskqueue to schedule the task which would lock the process
and send the signal.


Is there some way we know we're in a fast interrupt handler? If so, it
should be simple to fix. If not, then there's an API change ahead of us...


There is a td_intr_nesting_level flag that might work.  (I invented this,
but don't like its current use.)


But bde is right: the system has to be in good enough shape to cope. I
wonder if we should put that coping into kdb_reboot() instead. It's only an
issue for  TILDE ^R, which is a fairly edge case.


shutdown_nice() is also called directly from syscons and vt for the reboot,
halt and poweroff keys.  This happens in normal interrupt handler context,
so there is only a problem when init is not running.

Bruce
___
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: r331326 - in head/stand: forth i386/loader

2018-03-22 Thread Cy Schubert
In message 
, Kyle Evans writes:
> On Wed, Mar 21, 2018 at 10:30 PM, Cy Schubert  wro
> te:
> > In message <201803212201.w2lm1pvl020...@repo.freebsd.org>, Kyle Evans
> > writes:
> >> Author: kevans
> >> Date: Wed Mar 21 22:01:51 2018
> >> New Revision: 331326
> >> URL: https://svnweb.freebsd.org/changeset/base/331326
> >>
> >> Log:
> >>   Forth version of EFI autoresizing
> >>
> >>   r331321 delegated autoresizing to an efi-autoresizecons command that
> >>   currently is expected to be done in forth/lua prior to drawing anything
> >>   useful.
> >>
> >>   Add the Forth version of the lua addition in r331321, hook efi.4th up to
>  be
> >>   installed.
> >>
> >>   efiboot? was written by dteske@; anything outside of that may be blamed 
> on
> >>   me.
> >>
> >> Modified:
> >>   head/stand/forth/Makefile
> >>   head/stand/forth/efi.4th
> >>   head/stand/forth/loader.rc
> >>   head/stand/i386/loader/loader.rc
> >>
> >> Modified: head/stand/forth/Makefile
> >> ==
> ===
> >> =
> >> --- head/stand/forth/Makefile Wed Mar 21 21:15:43 2018(r331325)
> >> +++ head/stand/forth/Makefile Wed Mar 21 22:01:51 2018(r331326)
> >> @@ -18,6 +18,7 @@ FILES+= brand-fbsd.4th
> >>  FILES+=  check-password.4th
> >>  FILES+=  color.4th
> >>  FILES+=  delay.4th
> >> +FILES+=  efi.4th
> >>  FILES+=  frames.4th
> >>  FILES+=  loader.4th
> >>  FILES+=  logo-beastie.4th
> >>
> >> Modified: head/stand/forth/efi.4th
> >> ==
> ===
> >> =
> >> --- head/stand/forth/efi.4th  Wed Mar 21 21:15:43 2018(r331325)
> >> +++ head/stand/forth/efi.4th  Wed Mar 21 22:01:51 2018(r331326)
> >> @@ -26,5 +26,16 @@
> >>
> >>  only forth definitions
> >>
> >> -\ Place holder for more functions
> >> +: efiboot? ( -- flag )
> >> + s" efi-version" getenv -1 <> dup if
> >> + swap drop ( c-addr flag -- flag )
> >> + then
> >> +;
> >> +
> >> +: maybe-efi-resizecons
> >> + efiboot? if
> >> + efi-autoresizecons
> >
> > This statement breaks boot on my BIOS machines. It cannot find
> > efi-autoresizecons, causing a bare kernel without modules to load or
> > kenv variables set.
> >
>
> Ugh, sorry about that. =( I've converted that to a runtime evaluation
> in r331341 and (hopefully) properly observed my failure to succeed.

No problem. That fixed it.

>
> On the plus side, today I learned about `boot-conf` to get back to the
> Forth-intercepted 'boot' behavior to workaround the breakage. =)

Yes. Good point. I'll remember that too.

Thanks again.
-- 
Cheers,
Cy Schubert 
FreeBSD UNIX:     Web:  http://www.FreeBSD.org

The need of the many outweighs the greed of the few.


___
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: r331298 - head/sys/dev/syscons

2018-03-22 Thread Bruce Evans

On Wed, 21 Mar 2018, Warner Losh wrote:


On Wed, Mar 21, 2018 at 11:53 AM, Bruce Evans  wrote:


On Wed, 21 Mar 2018, Warner Losh wrote:

Log:

 Unlock giant when calling shutdown_nice()


This breaks the driver.  Giant is syscons' driver lock, and also the
interrupt handler lock for at least the atkbd keyboard driver, so vt
sometimes holds the lock for.


OK. I got carried away. You're right. The proper fix is to unlock Giant at
the top of kern_reboot() instead. This handles the case where we call
shutdown_nice() with no init running and have to call kern_reboot directly.
Otherwise it's perfectly fine to just call shutdown_nice() with Giant held
since we just signal init from there. So I'll revert this change and make
that other change instead.
...
Good point. I think the following change is good for everything except
calling shutdown_nice() from a fast interrupt handler with noinit running:

diff --git a/sys/kern/kern_shutdown.c b/sys/kern/kern_shutdown.c
index e5ea9644ad3f..564aecd811be 100644
--- a/sys/kern/kern_shutdown.c
+++ b/sys/kern/kern_shutdown.c
@@ -366,6 +366,12 @@ kern_reboot(int howto)
{
   static int once = 0;

+   /*
+* Drop Giant once and for all.
+*/
+   while (mtx_owned())
+   mtx_unlock();
+
#if defined(SMP)
   /*
* Bind us to the first CPU so that all shutdown code runs there.
Some

Comments?


Try putting this in vfs_mountroot_parse() and/or the second clause of
shutdown_nice() only.  The only other calls are from is from sys_reboot()
and vpanic().  sys_reboot() is either MPSAFE or not, and it should know
when it is safe to drop its Giant lock if at all.  vpanic() sets
SCHEDULER_STOPPED() to avoid seeing problems with Giant or any other
mutex.

Bruce
___
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: r331345 - head/sys/dev/jedec_dimm

2018-03-22 Thread Ravi Pokala
Author: rpokala
Date: Thu Mar 22 06:31:05 2018
New Revision: 331345
URL: https://svnweb.freebsd.org/changeset/base/331345

Log:
  jedec_dimm: Use correct string length when populating sc->slotid_str
  
  Don't limit the copy to the size of the target string *pointer* (always
  4 on 32-bit / 8 on 64-bit). Instead, just use strdup().
  
  Reported by:  Coverity
  CID:  1386912
  Reviewed by:  cem, imp
  MFC after:1 week

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

Modified: head/sys/dev/jedec_dimm/jedec_dimm.c
==
--- head/sys/dev/jedec_dimm/jedec_dimm.cThu Mar 22 05:26:27 2018
(r331344)
+++ head/sys/dev/jedec_dimm/jedec_dimm.cThu Mar 22 06:31:05 2018
(r331345)
@@ -341,10 +341,7 @@ jedec_dimm_attach(device_t dev)
if (resource_string_value(device_get_name(dev), device_get_unit(dev),
"slotid", _str) == 0) {
if (slotid_str != NULL) {
-   sc->slotid_str = malloc(strlen(slotid_str) + 1,
-   M_DEVBUF, (M_WAITOK | M_ZERO));
-   strlcpy(sc->slotid_str, slotid_str,
-   sizeof(sc->slotid_str));
+   sc->slotid_str = strdup(slotid_str, M_DEVBUF);
SYSCTL_ADD_STRING(ctx, children, OID_AUTO, "slotid",
CTLFLAG_RD | CTLFLAG_MPSAFE, sc->slotid_str, 0,
"DIMM Slot Identifier");
___
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: r331298 - head/sys/dev/syscons

2018-03-22 Thread Bruce Evans

On Wed, 21 Mar 2018, Konstantin Belousov wrote:


On Thu, Mar 22, 2018 at 04:53:22AM +1100, Bruce Evans wrote:

Serial console drivers with fast interrupt handlers have much more
broken locking for ddb special keys.  It is invalid to either drop locks
or call the "any" function from a fast interrupt handler, but buggy
serial console drivers calls kbd_alt_break(), and that now calls
shutdown_nice() and other functions that cannot be called from a fast
interrupt handler.  ddb keys supply most of the shutdown_nice()
functionality for serial consoles, and there are no escape sequence to
get this without ddb or maybe another debugger, so these bugs don't
affect most users.

Handling this correctly requires much the same fix as an unsafe signal
handler, and fixes have much the same problems -- not much more than
setting a flag is safe, and the flag might never be looked at if the
system is in a bad state.  However, if a nice shutdown is possible then
the sytem must be in a good enough state to poll for flags.


Are you saying that fast interrupt handlers call shutdown_nice() ?  This
is the quite serious bug on its own.  To fix it, shutdown_nice() should
use a fast taskqueue to schedule the task which would lock the process
and send the signal.


Yes.  See kdb_reboot().  This is called for an escape sequence from
kdb_alt_break_internal().  The other calls in kdb_alt_break_internal()
don't wander into a function that calls shutdown_nice() and are
relatively safe.  They have to be not completely safe to work in "any"
context.  kdb_reboot() is the opposite -- we want it to fail if the
context is not nice enough to reboot nicely.

BTW, I've often wanted to be able to send more general signals to init
using keystrokes, independent of being logged in.  Mainly SIGHUP to
shut down to single user mode.  This has some security problems,
especially for the "any" signal to the "any" process.  At least syscons
defaults to allowing Ctrl-Alt-Del to reboot.  I like that and miss it
on serial consoles and on some non-FreeBSD OS's (the alt-break sequence
to reach kdb_reboot() is not equivalent, since it is only available
if much more insecure sequences are also allowed).  Shutdown isn't as
fundamentally insecure as sending arbitrary signals and most systems
allow it without much more than a password for users that have physical
access to the system.

OTOH, I don't like the syscons key that suspends.  This is also allowed
by default.  I sometimes press it by mistake on a system that can suspend
but not resume.  Unlike the reboot key, there are no knobs for controlling
it.  There are 3 static configuration knobs, 2 sysctls and the keymap
which must be understood for securing the main reboot key in syscons, and a
slightly different set of controls in vt :-(.  For suspend, there is only
the keymap.  Syscons also has a standby key and more shutdown keys, but
these are in more obscure parts of keymaps and I've never noticed typing
them by mistake.

Bruce
___
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"


  1   2   >