svn commit: r352467 - head/share/man/man5

2019-09-17 Thread Kyle Evans
Author: kevans
Date: Wed Sep 18 02:04:41 2019
New Revision: 352467
URL: https://svnweb.freebsd.org/changeset/base/352467

Log:
  src.conf(5): regenerate after r352465, r352466
  
  These changed the defaults for the GOOGLETEST knob and added a description
  for WITH_GOOGLETEST.

Modified:
  head/share/man/man5/src.conf.5

Modified: head/share/man/man5/src.conf.5
==
--- head/share/man/man5/src.conf.5  Wed Sep 18 02:03:39 2019
(r352466)
+++ head/share/man/man5/src.conf.5  Wed Sep 18 02:04:41 2019
(r352467)
@@ -1,6 +1,6 @@
 .\" DO NOT EDIT-- this file is @generated by tools/build/options/makeman.
 .\" $FreeBSD$
-.Dd August 16, 2019
+.Dd September 17, 2019
 .Dt SRC.CONF 5
 .Os
 .Sh NAME
@@ -831,6 +831,17 @@ Set to neither build nor install
 .Lb libgmock ,
 .Lb libgtest ,
 and dependent tests.
+.Pp
+This is a default setting on
+mips/mipsel, mips/mips, mips/mips64el, mips/mips64, mips/mipsn32, 
mips/mipselhf, mips/mipshf, mips/mips64elhf and mips/mips64hf.
+.It Va WITH_GOOGLETEST
+Set to build and install
+.Lb libgmock ,
+.Lb libgtest ,
+and dependent tests.
+.Pp
+This is a default setting on
+amd64/amd64, arm/arm, arm/armv6, arm/armv7, arm64/aarch64, i386/i386, 
powerpc/powerpc, powerpc/powerpc64, powerpc/powerpcspe, riscv/riscv64 and 
sparc64/sparc64.
 .It Va WITHOUT_GPIO
 Set to not build
 .Xr gpioctl 8
___
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: r352466 - head/tools/build/options

2019-09-17 Thread Kyle Evans
Author: kevans
Date: Wed Sep 18 02:03:39 2019
New Revision: 352466
URL: https://svnweb.freebsd.org/changeset/base/352466

Log:
  Add description for WITH_GOOGLETEST
  
  This is the logical negation of WITHOUT_GOOGLETEST, and helpful to have as
  we now have different per-arch defaults for this option.

Added:
  head/tools/build/options/WITH_GOOGLETEST   (contents, props changed)

Added: head/tools/build/options/WITH_GOOGLETEST
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/tools/build/options/WITH_GOOGLETESTWed Sep 18 02:03:39 2019
(r352466)
@@ -0,0 +1,5 @@
+.\" $FreeBSD$
+Set to build and install
+.Lb libgmock ,
+.Lb libgtest ,
+and dependent tests.
___
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: r352465 - head/share/mk

2019-09-17 Thread Kyle Evans
Author: kevans
Date: Wed Sep 18 01:58:56 2019
New Revision: 352465
URL: https://svnweb.freebsd.org/changeset/base/352465

Log:
  googletest: default-disable on all of MIPS for now
  
  Parts of the fusefs tests trigger a bug in current versions of llvm: IR
  representation of some routine for the MIPS targets is a function with a
  large number of arguments. This then leads the compiler on an hour+ long
  goose chase, which is OK if you build the current tree but less-so if you're
  trying external toolchain or doing a universe build involving mips when it
  eventually gets switched over to LLVM.
  
  Better, accurate details can be found in LLVM PR43263.

Modified:
  head/share/mk/src.opts.mk

Modified: head/share/mk/src.opts.mk
==
--- head/share/mk/src.opts.mk   Wed Sep 18 01:33:17 2019(r352464)
+++ head/share/mk/src.opts.mk   Wed Sep 18 01:58:56 2019(r352465)
@@ -108,7 +108,6 @@ __DEFAULT_YES_OPTIONS = \
 GDB \
 GNU_DIFF \
 GNU_GREP \
-GOOGLETEST \
 GPIO \
 HAST \
 HTML \
@@ -258,6 +257,15 @@ __T=${MACHINE_ARCH}
 __TT=${TARGET}
 .else
 __TT=${MACHINE}
+.endif
+
+# Default GOOGLETEST to off for MIPS while LLVM PR 43263 is active.  Part
+# of the fusefs tests trigger excessively long compile times.  It does
+# eventually succeed, but this shouldn't be forced on those building by 
default.
+.if ${__TT} == "mips"
+__DEFAULT_NO_OPTIONS+= GOOGLETEST
+.else
+__DEFAULT_YES_OPTIONS+=GOOGLETEST
 .endif
 
 # All supported backends for LLVM_TARGET_XXX
___
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: r352464 - head/stand/mips/uboot

2019-09-17 Thread Kyle Evans
Author: kevans
Date: Wed Sep 18 01:33:17 2019
New Revision: 352464
URL: https://svnweb.freebsd.org/changeset/base/352464

Log:
  mips: ubldr: use truncated load address for mips32
  
  BFD appears to silently truncate 0x8080 when it processes the
  ldscript for 32-bit mips, but LLD chokes on it as the linker script tries to
  place elements above 32-bit range. It's unclear to me if silent truncation
  is kosher or not and whether this patch is really what we want to do, but it
  is one approach at least.
  
  Reviewed by:  imp, mizhka
  Differential Revision:https://reviews.freebsd.org/D21487

Modified:
  head/stand/mips/uboot/Makefile

Modified: head/stand/mips/uboot/Makefile
==
--- head/stand/mips/uboot/Makefile  Tue Sep 17 22:09:14 2019
(r352463)
+++ head/stand/mips/uboot/Makefile  Wed Sep 18 01:33:17 2019
(r352464)
@@ -19,7 +19,11 @@ INSTALLFLAGS=-b
 WARNS?=1
 # Address at which ubldr will be loaded.
 # This varies for different boards and SOCs.
+.if ${MACHINE_ARCH:Mmips64*}
 UBLDR_LOADADDR?=   0x8080
+.else
+UBLDR_LOADADDR?=   0x8080
+.endif
 
 # Architecture-specific loader code
 SRCS=  start.S conf.c vers.c
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r352451 - head/stand/libsa

2019-09-17 Thread Conrad Meyer
Well, hang on; it's also perfectly legal for a malloc implementation
to return NULL for requests of zero bytes.  You can access exactly the
number of bytes requested in the allocation; and free(NULL) works as
expected.  NULL (0) is also aligned to any size you could want.

Best,
Conrad

On Tue, Sep 17, 2019 at 9:16 AM Toomas Soome  wrote:
>
> Author: tsoome
> Date: Tue Sep 17 16:16:46 2019
> New Revision: 352451
> URL: https://svnweb.freebsd.org/changeset/base/352451
>
> Log:
>   loader: revert r352421
>
>   As insisted by kib, malloc(0) is quite legal.
>
> Modified:
>   head/stand/libsa/zalloc_malloc.c
>
> Modified: head/stand/libsa/zalloc_malloc.c
> ==
> --- head/stand/libsa/zalloc_malloc.cTue Sep 17 15:53:40 2019
> (r352450)
> +++ head/stand/libsa/zalloc_malloc.cTue Sep 17 16:16:46 2019
> (r352451)
> @@ -73,9 +73,6 @@ Malloc_align(size_t bytes, size_t alignment)
>  {
> Guard *res;
>
> -   if (bytes == 0)
> -   return (NULL);
> -
>  #ifdef USEENDGUARD
> bytes += MALLOCALIGN + 1;
>  #else
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r352463 - head/tests/sys/netpfil/common

2019-09-17 Thread Li-Wen Hsu
Author: lwhsu
Date: Tue Sep 17 22:09:14 2019
New Revision: 352463
URL: https://svnweb.freebsd.org/changeset/base/352463

Log:
  Temporarily skip sys.netpfil.common.tos.pf_tos on i386 CI as it always fails
  
  PR:   240086
  Sponsored by: The FreeBSD Foundation

Modified:
  head/tests/sys/netpfil/common/tos.sh

Modified: head/tests/sys/netpfil/common/tos.sh
==
--- head/tests/sys/netpfil/common/tos.shTue Sep 17 22:08:16 2019
(r352462)
+++ head/tests/sys/netpfil/common/tos.shTue Sep 17 22:09:14 2019
(r352463)
@@ -40,6 +40,10 @@ tos_head()
 tos_body()
 {
firewall=$1
+   if [ "$(atf_config_get ci false)" = "true" ] && \
+   [ "$(uname -p)" = "i386" ] && [ "${firewall}" = "pf" ]; then
+   atf_skip "https://bugs.freebsd.org/240086;
+   fi
firewall_init $firewall
 
epair_send=$(vnet_mkepair)
___
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: r352462 - head/tests/sys/netpfil/common

2019-09-17 Thread Li-Wen Hsu
Author: lwhsu
Date: Tue Sep 17 22:08:16 2019
New Revision: 352462
URL: https://svnweb.freebsd.org/changeset/base/352462

Log:
  Temporarily skip sys.netpfil.common.forward.pf_v4 on i386 CI as it always 
fails
  
  PR:   240085
  Sponsored by: The FreeBSD Foundation

Modified:
  head/tests/sys/netpfil/common/forward.sh

Modified: head/tests/sys/netpfil/common/forward.sh
==
--- head/tests/sys/netpfil/common/forward.shTue Sep 17 20:05:06 2019
(r352461)
+++ head/tests/sys/netpfil/common/forward.shTue Sep 17 22:08:16 2019
(r352462)
@@ -40,6 +40,10 @@ v4_head()
 v4_body()
 {
firewall=$1
+   if [ "$(atf_config_get ci false)" = "true" ] && \
+   [ "$(uname -p)" = "i386" ] && [ "${firewall}" = "pf" ]; then
+   atf_skip "https://bugs.freebsd.org/240085;
+   fi
firewall_init $firewall
 
epair_send=$(vnet_mkepair)
___
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: r352461 - head/usr.sbin/newsyslog

2019-09-17 Thread Steve Wills
Author: swills (ports committer)
Date: Tue Sep 17 20:05:06 2019
New Revision: 352461
URL: https://svnweb.freebsd.org/changeset/base/352461

Log:
  Use correct filename in newsyslog.conf
  
  Approved by:  bapt (implicit)
  Differential Revision:https://reviews.freebsd.org/D21561

Modified:
  head/usr.sbin/newsyslog/newsyslog.conf

Modified: head/usr.sbin/newsyslog/newsyslog.conf
==
--- head/usr.sbin/newsyslog/newsyslog.conf  Tue Sep 17 20:03:20 2019
(r352460)
+++ head/usr.sbin/newsyslog/newsyslog.conf  Tue Sep 17 20:05:06 2019
(r352461)
@@ -30,7 +30,7 @@
 /var/log/security  600  101000 * JC
 /var/log/utx.log   644  3 *@01T05 B
 /var/log/weekly.log640  5 *$W6D0 JN
-/var/log/daemon644  5 1000 @0101T JC
+/var/log/daemon.log644  5 1000 @0101T JC
 
  /etc/newsyslog.conf.d/[!.]*.conf
  /usr/local/etc/newsyslog.conf.d/[!.]*.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: r352460 - in head/usr.sbin: newsyslog syslogd

2019-09-17 Thread Steve Wills
Author: swills (ports committer)
Date: Tue Sep 17 20:03:20 2019
New Revision: 352460
URL: https://svnweb.freebsd.org/changeset/base/352460

Log:
  log daemon.info to /var/log/daemon.log by default
  
  log daemon facility now that daemon(8) has syslog support which defaults to
  daemon facility, info priority
  
  Reviewed by:  bapt
  Approved by:  bapt
  Differential Revision:https://reviews.freebsd.org/D21561

Modified:
  head/usr.sbin/newsyslog/newsyslog.conf
  head/usr.sbin/syslogd/syslog.conf

Modified: head/usr.sbin/newsyslog/newsyslog.conf
==
--- head/usr.sbin/newsyslog/newsyslog.conf  Tue Sep 17 18:51:10 2019
(r352459)
+++ head/usr.sbin/newsyslog/newsyslog.conf  Tue Sep 17 20:03:20 2019
(r352460)
@@ -30,6 +30,7 @@
 /var/log/security  600  101000 * JC
 /var/log/utx.log   644  3 *@01T05 B
 /var/log/weekly.log640  5 *$W6D0 JN
+/var/log/daemon644  5 1000 @0101T JC
 
  /etc/newsyslog.conf.d/[!.]*.conf
  /usr/local/etc/newsyslog.conf.d/[!.]*.conf

Modified: head/usr.sbin/syslogd/syslog.conf
==
--- head/usr.sbin/syslogd/syslog.conf   Tue Sep 17 18:51:10 2019
(r352459)
+++ head/usr.sbin/syslogd/syslog.conf   Tue Sep 17 20:03:20 2019
(r352460)
@@ -14,6 +14,7 @@ cron.*
/var/log/cron
 !-devd
 *.=debug   /var/log/debug.log
 *.emerg*
+daemon.info/var/log/daemon.log
 # uncomment this to log all writes to /dev/console to /var/log/console.log
 # touch /var/log/console.log and chmod it to mode 600 before it will work
 #console.info  /var/log/console.log
___
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: r352459 - head/sbin/ifconfig

2019-09-17 Thread Konstantin Belousov
Author: kib
Date: Tue Sep 17 18:51:10 2019
New Revision: 352459
URL: https://svnweb.freebsd.org/changeset/base/352459

Log:
  ifconfig: add report of the string from SIOCGIFDOWNREASON.
  
  Sample output:
  # ifconfig mce0
  mce0: flags=8802 metric 0 mtu 1500
  
options=3ed07bb
  ether e4:1d:2d:e7:10:0a
  media: Ethernet autoselect 
  status: no carrier (Negotiation failure)
  nd6 options=21
  
  Reviewed by:  hselasky, rrs
  Sponsored by: Mellanox Technologies
  MFC after:1 week
  Differential revision:https://reviews.freebsd.org/D21527

Modified:
  head/sbin/ifconfig/ifmedia.c

Modified: head/sbin/ifconfig/ifmedia.c
==
--- head/sbin/ifconfig/ifmedia.cTue Sep 17 18:49:13 2019
(r352458)
+++ head/sbin/ifconfig/ifmedia.cTue Sep 17 18:51:10 2019
(r352459)
@@ -80,6 +80,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -110,18 +111,20 @@ static void
 media_status(int s)
 {
struct ifmediareq ifmr;
+   struct ifdownreason ifdr;
int *media_list, i;
-   int xmedia = 1;
+   bool no_carrier, xmedia;
 
(void) memset(, 0, sizeof(ifmr));
(void) strlcpy(ifmr.ifm_name, name, sizeof(ifmr.ifm_name));
+   xmedia = true;
 
/*
 * Check if interface supports extended media types.
 */
if (ioctl(s, SIOCGIFXMEDIA, (caddr_t)) < 0)
-   xmedia = 0;
-   if (xmedia == 0 && ioctl(s, SIOCGIFMEDIA, (caddr_t)) < 0) {
+   xmedia = false;
+   if (!xmedia && ioctl(s, SIOCGIFMEDIA, (caddr_t)) < 0) {
/*
 * Interface doesn't support SIOC{G,S}IFMEDIA.
 */
@@ -158,6 +161,7 @@ media_status(int s)
putchar('\n');
 
if (ifmr.ifm_status & IFM_AVALID) {
+   no_carrier = false;
printf("\tstatus: ");
switch (IFM_TYPE(ifmr.ifm_active)) {
case IFM_ETHER:
@@ -165,7 +169,7 @@ media_status(int s)
if (ifmr.ifm_status & IFM_ACTIVE)
printf("active");
else
-   printf("no carrier");
+   no_carrier = true;
break;
 
case IFM_IEEE80211:
@@ -176,8 +180,26 @@ media_status(int s)
else
printf("running");
} else
-   printf("no carrier");
+   no_carrier = true;
break;
+   }
+   if (no_carrier) {
+   printf("no carrier");
+   memset(, 0, sizeof(ifdr));
+   strlcpy(ifdr.ifdr_name, name, sizeof(ifdr.ifdr_name));
+   if (ioctl(s, SIOCGIFDOWNREASON, (caddr_t)) == 0) {
+   switch (ifdr.ifdr_reason) {
+   case IFDR_REASON_MSG:
+   printf(" (%s)", ifdr.ifdr_msg);
+   break;
+   case IFDR_REASON_VENDOR:
+   printf(" (vendor code %d)",
+   ifdr.ifdr_vendor);
+   break;
+   default:
+   break;
+   }
+   }
}
putchar('\n');
}
___
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: r352458 - in head/sys: net sys

2019-09-17 Thread Konstantin Belousov
Author: kib
Date: Tue Sep 17 18:49:13 2019
New Revision: 352458
URL: https://svnweb.freebsd.org/changeset/base/352458

Log:
  Add SIOCGIFDOWNREASON.
  
  The ioctl(2) is intended to provide more details about the cause of
  the down for the link.
  
  Eventually we might define a comprehensive list of codes for the
  situations.  But interface also allows the driver to provide free-form
  null-terminated ASCII string to provide arbitrary non-formalized
  information.  Sample implementation exists for mlx5(4), where the
  string is fetched from firmware controlling the port.
  
  Reviewed by:  hselasky, rrs
  Sponsored by: Mellanox Technologies
  MFC after:1 week
  Differential revision:https://reviews.freebsd.org/D21527

Modified:
  head/sys/net/if.c
  head/sys/net/if.h
  head/sys/sys/sockio.h

Modified: head/sys/net/if.c
==
--- head/sys/net/if.c   Tue Sep 17 18:41:39 2019(r352457)
+++ head/sys/net/if.c   Tue Sep 17 18:49:13 2019(r352458)
@@ -2891,6 +2891,7 @@ ifhwioctl(u_long cmd, struct ifnet *ifp, caddr_t data,
case SIOCGIFGENERIC:
case SIOCGIFRSSKEY:
case SIOCGIFRSSHASH:
+   case SIOCGIFDOWNREASON:
if (ifp->if_ioctl == NULL)
return (EOPNOTSUPP);
error = (*ifp->if_ioctl)(ifp, cmd, data);

Modified: head/sys/net/if.h
==
--- head/sys/net/if.h   Tue Sep 17 18:41:39 2019(r352457)
+++ head/sys/net/if.h   Tue Sep 17 18:49:13 2019(r352458)
@@ -585,6 +585,16 @@ struct ifrsshash {
 
 #defineIFNET_PCP_NONE  0xff/* PCP disabled */
 
+#defineIFDR_MSG_SIZE   64
+#defineIFDR_REASON_MSG 1
+#defineIFDR_REASON_VENDOR  2
+struct ifdownreason {
+   charifdr_name[IFNAMSIZ];
+   uint32_tifdr_reason;
+   uint32_tifdr_vendor;
+   charifdr_msg[IFDR_MSG_SIZE];
+};
+
 #endif /* __BSD_VISIBLE */
 
 #ifdef _KERNEL

Modified: head/sys/sys/sockio.h
==
--- head/sys/sys/sockio.h   Tue Sep 17 18:41:39 2019(r352457)
+++ head/sys/sys/sockio.h   Tue Sep 17 18:49:13 2019(r352458)
@@ -143,4 +143,6 @@
 #defineSIOCGLANPCP _IOWR('i', 152, struct ifreq)   /* Get (V)LAN 
PCP */
 #defineSIOCSLANPCP  _IOW('i', 153, struct ifreq)   /* Set (V)LAN 
PCP */
 
+#defineSIOCGIFDOWNREASON   _IOWR('i', 154, struct ifdownreason)
+
 #endif /* !_SYS_SOCKIO_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: r352457 - head/sys/fs/nfsclient

2019-09-17 Thread Konstantin Belousov
Author: kib
Date: Tue Sep 17 18:41:39 2019
New Revision: 352457
URL: https://svnweb.freebsd.org/changeset/base/352457

Log:
  Further refine r352393, only call vnode_pager_setsize() outside the
  node lock when shrinking.
  
  This is similar to r252528, applied to the above commit.
  
  Apparently there is a race which makes necessary at least to keep the
  n_size and pager size consistent when extending.  Current suspect is
  that iod threads perform vnode_pager_setsize() without taking the
  vnode lock, which corrupts the file content.
  
  Reported and tested by:   Masachika ISHIZUKA 
  Discussed with:   rmacklem (related issues)
  Sponsored by: The FreeBSD Foundation
  MFC after:1 week

Modified:
  head/sys/fs/nfsclient/nfs_clport.c

Modified: head/sys/fs/nfsclient/nfs_clport.c
==
--- head/sys/fs/nfsclient/nfs_clport.c  Tue Sep 17 18:36:29 2019
(r352456)
+++ head/sys/fs/nfsclient/nfs_clport.c  Tue Sep 17 18:41:39 2019
(r352457)
@@ -414,12 +414,12 @@ nfscl_loadattrcache(struct vnode **vpp, struct nfsvatt
struct nfsnode *np;
struct nfsmount *nmp;
struct timespec mtime_save;
+   vm_object_t object;
u_quad_t nsize;
-   int setnsize, error, force_fid_err;
+   int error, force_fid_err;
+   bool setnsize;
 
error = 0;
-   setnsize = 0;
-   nsize = 0;
 
/*
 * If v_type == VNON it is a new node, so fill in the v_type,
@@ -511,8 +511,7 @@ nfscl_loadattrcache(struct vnode **vpp, struct nfsvatt
 * zero np->n_attrstamp to indicate that
 * the attributes are stale.
 */
-   nsize = vap->va_size = np->n_size;
-   setnsize = 1;
+   vap->va_size = np->n_size;
np->n_attrstamp = 0;
KDTRACE_NFS_ATTRCACHE_FLUSH_DONE(vp);
} else if (np->n_flag & NMODIFIED) {
@@ -526,22 +525,9 @@ nfscl_loadattrcache(struct vnode **vpp, struct nfsvatt
np->n_size = vap->va_size;
np->n_flag |= NSIZECHANGED;
}
-   nsize = np->n_size;
-   setnsize = 1;
-   } else if (vap->va_size < np->n_size) {
-   /*
-* When shrinking the size, the call to
-* vnode_pager_setsize() cannot be done
-* with the mutex held, so delay it until
-* after the mtx_unlock call.
-*/
-   nsize = np->n_size = vap->va_size;
-   np->n_flag |= NSIZECHANGED;
-   setnsize = 1;
} else {
-   nsize = np->n_size = vap->va_size;
+   np->n_size = vap->va_size;
np->n_flag |= NSIZECHANGED;
-   setnsize = 1;
}
} else {
np->n_size = vap->va_size;
@@ -579,6 +565,23 @@ out:
if (np->n_attrstamp != 0)
KDTRACE_NFS_ATTRCACHE_LOAD_DONE(vp, vap, error);
 #endif
+   nsize = vap->va_size;
+   object = vp->v_object;
+   setnsize = false;
+   if (object != NULL) {
+   if (OFF_TO_IDX(nsize + PAGE_MASK) < object->size) {
+   /*
+* When shrinking the size, the call to
+* vnode_pager_setsize() cannot be done with
+* the mutex held, because we might need to
+* wait for a busy page.  Delay it until after
+* the node is unlocked.
+*/
+   setnsize = true;
+   } else {
+   vnode_pager_setsize(vp, nsize);
+   }
+   }
NFSUNLOCKNODE(np);
if (setnsize)
vnode_pager_setsize(vp, nsize);
___
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: r352456 - head/contrib/jemalloc/src

2019-09-17 Thread Konstantin Belousov
Author: kib
Date: Tue Sep 17 18:36:29 2019
New Revision: 352456
URL: https://svnweb.freebsd.org/changeset/base/352456

Log:
  realloc(x, 0) should not return NULL.
  
  See http://www.open-std.org/jtc1/sc22/wg14/www/docs/summary.htm#dr_400.
  Upstream jemalloc issue is opened by emaste at
  https://github.com/jemalloc/jemalloc/issues/1629.
  
  Reviewed by:  emaste
  PR:   240456
  Sponsored by: The FreeBSD Foundation
  MFC after:1 week
  DIfferential revision:https://reviews.freebsd.org/D21632

Modified:
  head/contrib/jemalloc/src/jemalloc.c

Modified: head/contrib/jemalloc/src/jemalloc.c
==
--- head/contrib/jemalloc/src/jemalloc.cTue Sep 17 18:32:18 2019
(r352455)
+++ head/contrib/jemalloc/src/jemalloc.cTue Sep 17 18:36:29 2019
(r352456)
@@ -2299,21 +2299,6 @@ je_realloc(void *ptr, size_t size) {
LOG("core.realloc.entry", "ptr: %p, size: %zu\n", ptr, size);
 
if (unlikely(size == 0)) {
-   if (ptr != NULL) {
-   /* realloc(ptr, 0) is equivalent to free(ptr). */
-   UTRACE(ptr, 0, 0);
-   tcache_t *tcache;
-   tsd_t *tsd = tsd_fetch();
-   if (tsd_reentrancy_level_get(tsd) == 0) {
-   tcache = tcache_get(tsd);
-   } else {
-   tcache = NULL;
-   }
-   ifree(tsd, ptr, tcache, true);
-
-   LOG("core.realloc.exit", "result: %p", NULL);
-   return NULL;
-   }
size = 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: r352455 - in head: lib/libc/sys sys/kern

2019-09-17 Thread Konstantin Belousov
Author: kib
Date: Tue Sep 17 18:32:18 2019
New Revision: 352455
URL: https://svnweb.freebsd.org/changeset/base/352455

Log:
  Return EISDIR when directory is opened with O_CREAT without O_DIRECTORY.
  
  Reviewed by:  bcr (man page), emaste (previous version)
  PR:   240452
  Sponsored by: The FreeBSD Foundation
  MFC after:1 week
  DIfferential revision:https://reviews.freebsd.org/D21634

Modified:
  head/lib/libc/sys/open.2
  head/sys/kern/vfs_vnops.c

Modified: head/lib/libc/sys/open.2
==
--- head/lib/libc/sys/open.2Tue Sep 17 18:05:33 2019(r352454)
+++ head/lib/libc/sys/open.2Tue Sep 17 18:32:18 2019(r352455)
@@ -28,7 +28,7 @@
 .\" @(#)open.2 8.2 (Berkeley) 11/16/93
 .\" $FreeBSD$
 .\"
-.Dd June 14, 2019
+.Dd September 17, 2019
 .Dt OPEN 2
 .Os
 .Sh NAME
@@ -419,6 +419,11 @@ Too many symbolic links were encountered in translatin
 .It Bq Er EISDIR
 The named file is a directory, and the arguments specify
 it is to be modified.
+.It Bq Er EISDIR
+The named file is a directory, and the flags specified
+.Dv O_CREAT
+without
+.Dv O_DIRECTORY .
 .It Bq Er EROFS
 The named file resides on a read-only file system,
 and the file is to be modified.

Modified: head/sys/kern/vfs_vnops.c
==
--- head/sys/kern/vfs_vnops.c   Tue Sep 17 18:05:33 2019(r352454)
+++ head/sys/kern/vfs_vnops.c   Tue Sep 17 18:32:18 2019(r352455)
@@ -264,6 +264,10 @@ restart:
error = EEXIST;
goto bad;
}
+   if (vp->v_type == VDIR) {
+   error = EISDIR;
+   goto bad;
+   }
fmode &= ~O_CREAT;
}
} else {
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r352454 - head/stand/forth

2019-09-17 Thread Toomas Soome
Author: tsoome
Date: Tue Sep 17 18:05:33 2019
New Revision: 352454
URL: https://svnweb.freebsd.org/changeset/base/352454

Log:
  loader: provide u> and xemit words if needed
  
  We have external interpreter (userboot.so) which may be lagging behind
  with updates and may be missing u> xemit words.

Modified:
  head/stand/forth/loader.4th

Modified: head/stand/forth/loader.4th
==
--- head/stand/forth/loader.4th Tue Sep 17 17:44:50 2019(r352453)
+++ head/stand/forth/loader.4th Tue Sep 17 18:05:33 2019(r352454)
@@ -27,6 +27,29 @@
 
 only forth definitions
 
+\ provide u> if needed
+s" u>" sfind [if] drop [else]
+   drop
+: u>
+   2dup u< if 2drop 0 exit then
+   swap u< if -1 exit then
+   0
+;
+[then]
+
+\ provide xemit if needed
+s" xemit" sfind [if] drop [else]
+   drop
+: xemit
+   dup 0x80 u< if emit exit then
+   0 swap 0x3F
+   begin 2dup u> while
+   2/ >r dup 0x3F and 0x80 or swap 6 rshift r>
+   repeat 0x7F xor 2* or
+   begin dup 0x80 u< 0= while emit repeat drop
+;
+[then]
+
 s" arch-i386" environment? [if] [if]
s" loader_version" environment?  [if]
11 < [if]
___
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: r352453 - head/sys/kern

2019-09-17 Thread Kirk McKusick
Author: mckusick
Date: Tue Sep 17 17:44:50 2019
New Revision: 352453
URL: https://svnweb.freebsd.org/changeset/base/352453

Log:
  The VFS-level clustering code collects together sequential blocks
  by issuing delayed-writes (bdwrite()) until a non-sequential block
  is written or the maximum cluster size is reached. At that point
  it collects the delayed buffers together (using bread()) to write
  them in a single operation. The assumption was that since we just
  looked at them they will still be in memory so there is no need to
  check for a read error from bread(). Very occationally (apparently
  every 10-hours or so when being pounded by Peter Holm's tests)
  this assumption is wrong.
  
  The fix is to check for errors from bread() and fail the cluster
  write thus falling back to the default individual flushing of any
  still dirty buffers.
  
  Reported by: Peter Holm and Chuck Silvers
  Reviewed by: kib
  MFC after:   3 days

Modified:
  head/sys/kern/vfs_cluster.c

Modified: head/sys/kern/vfs_cluster.c
==
--- head/sys/kern/vfs_cluster.c Tue Sep 17 17:28:44 2019(r352452)
+++ head/sys/kern/vfs_cluster.c Tue Sep 17 17:44:50 2019(r352453)
@@ -718,6 +718,14 @@ cluster_write(struct vnode *vp, struct buf *bp, u_quad
struct cluster_save *buflist;
 
buflist = cluster_collectbufs(vp, bp, gbflags);
+   if (buflist == NULL) {
+   /*
+* Cluster build failed so just write
+* it now.
+*/
+   bawrite(bp);
+   return;
+   }
endbp = >bs_children
[buflist->bs_nchildren - 1];
if (VOP_REALLOCBLKS(vp, buflist)) {
@@ -1056,7 +1064,7 @@ cluster_collectbufs(struct vnode *vp, struct buf *last
struct cluster_save *buflist;
struct buf *bp;
daddr_t lbn;
-   int i, len;
+   int i, j, len, error;
 
len = vp->v_lastw - vp->v_cstart + 1;
buflist = malloc(sizeof(struct buf *) * (len + 1) + sizeof(*buflist),
@@ -1064,8 +1072,18 @@ cluster_collectbufs(struct vnode *vp, struct buf *last
buflist->bs_nchildren = 0;
buflist->bs_children = (struct buf **) (buflist + 1);
for (lbn = vp->v_cstart, i = 0; i < len; lbn++, i++) {
-   (void)bread_gb(vp, lbn, last_bp->b_bcount, NOCRED,
+   error = bread_gb(vp, lbn, last_bp->b_bcount, NOCRED,
gbflags, );
+   if (error != 0) {
+   /*
+* If read fails, release collected buffers
+* and return failure.
+*/
+   for (j = 0; j < i; j++)
+   brelse(buflist->bs_children[j]);
+   free(buflist, M_SEGMENT);
+   return (NULL);
+   }
buflist->bs_children[i] = bp;
if (bp->b_blkno == bp->b_lblkno)
VOP_BMAP(vp, bp->b_lblkno, NULL, >b_blkno,
___
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: r352452 - in stable/12/sys/arm64: arm64 include

2019-09-17 Thread Alan Cox
Author: alc
Date: Tue Sep 17 17:28:44 2019
New Revision: 352452
URL: https://svnweb.freebsd.org/changeset/base/352452

Log:
  MFC r349117, r349122, r349183, r349897, r349943, r350004, r350029, r350038,
r350191, r350202, r350422, r350427, r350525
  
  r349117:
Three enhancements to arm64's pmap_protect():
  
Implement protection changes on superpage mappings.  Previously, a superpage
mapping was unconditionally demoted by pmap_protect(), even if the
protection change applied to the entire superpage mapping.
  
Precompute the bit mask describing the protection changes rather than
recomputing it for every page table entry that is changed.
  
Skip page table entries that already have the requested protection changes
in place.
  
  r349122:
Three changes to arm64's pmap_unwire():
  
Implement wiring changes on superpage mappings.  Previously, a superpage
mapping was unconditionally demoted by pmap_unwire(), even if the wiring
change applied to the entire superpage mapping.
  
Rewrite a comment to use the arm64 names for bits in a page table entry.
Previously, the bits were referred to by their x86 names.
  
Use atomic_"op"_64() instead of atomic_"op"_long() to update a page table
entry in order to match the prevailing style in this file.
  
  r349183:
Correct an error in r349122.  pmap_unwire() should update the pmap's wired
count, not its resident count.
  
  r349897: (by markj)
Rename pmap_page_dirty() to pmap_pte_dirty().
  
This is a precursor to implementing dirty bit management.
  
  r349943: (by markj)
Apply some light cleanup to uses of pmap_pte_dirty().
- Check for ATTR_SW_MANAGED before anything else.
- Use pmap_pte_dirty() in pmap_remove_pages().
  
  r350004: (by markj)
Implement software access and dirty bit management for arm64.
  
Previously the arm64 pmap did no reference or modification tracking;
all mappings were treated as referenced and all read-write mappings
were treated as dirty.  This change implements software management
of these attributes.
  
Dirty bit management is implemented to emulate ARMv8.1's optional
hardware dirty bit modifier management, following a suggestion from alc.
In particular, a mapping with ATTR_SW_DBM set is logically writeable and
is dirty if the ATTR_AP_RW_BIT bit is clear.  Mappings with
ATTR_AP_RW_BIT set are write-protected, and a write access will trigger
a permission fault.  pmap_fault() handles permission faults for such
mappings and marks the page dirty by clearing ATTR_AP_RW_BIT, thus
mapping the page read-write.
  
  r350029: (by markj)
Propagate attribute changes during demotion.
  
After r349117 and r349122, some mapping attribute changes do not trigger
superpage demotion. However, pmap_demote_l2() was not updated to ensure
that the replacement L3 entries carry any attribute changes that
occurred since promotion.
  
  r350038: (by markj)
Always use the software DBM bit for now.
  
r350004 added most of the machinery needed to support hardware DBM
management, but it did not intend to actually enable use of the hardware
DBM bit.
  
  r350191:
Introduce pmap_store(), and use it to replace pmap_load_store() in places
where the page table entry was previously invalid.  (Note that I did not
replace pmap_load_store() when it was followed by a TLB invalidation, even
if we are not using the return value from pmap_load_store().)
  
Correct an error in pmap_enter().  A test for determining when to set
PGA_WRITEABLE was always true, even if the mapping was read only.
  
In pmap_enter_l2(), when replacing an empty kernel page table page by a
superpage mapping, clear the old l2 entry and issue a TLB invalidation.  My
reading of the ARM architecture manual leads me to believe that the TLB
could hold an intermediate entry referencing the empty kernel page table
page even though it contains no valid mappings.
  
Replace a couple direct uses of atomic_clear_64() by the new
pmap_clear_bits().
  
In a couple comments, replace the term "paging-structure caches", which is
an Intel-specific term for the caches that hold intermediate entries in the
page table, with wording that is more consistent with the ARM architecture
manual.
  
  r350202:
With the introduction of software dirty bit emulation for managed mappings,
we should test ATTR_SW_DBM, not ATTR_AP_RW, to determine whether to set
PGA_WRITEABLE.  In effect, we are currently setting PGA_WRITEABLE based on
whether the dirty bit is preset, not whether the mapping is writeable.
Correct this mistake.
  
  r350422: (by markj)
Remove an unneeded trunc_page() in pmap_fault().
  
  r350427: (by markj)
Have arm64's pmap_fault() handle WnR faults on dirty PTEs.
  
If we take a WnR permission fault on a managed, writeable and dirty
PTE, simply 

Re: svn commit: r352451 - head/stand/libsa

2019-09-17 Thread Konstantin Belousov
On Tue, Sep 17, 2019 at 04:16:47PM +, Toomas Soome wrote:
> Author: tsoome
> Date: Tue Sep 17 16:16:46 2019
> New Revision: 352451
> URL: https://svnweb.freebsd.org/changeset/base/352451
> 
> Log:
>   loader: revert r352421
>   
>   As insisted by kib, malloc(0) is quite legal.
Thank you.

> 
> Modified:
>   head/stand/libsa/zalloc_malloc.c
> 
> Modified: head/stand/libsa/zalloc_malloc.c
> ==
> --- head/stand/libsa/zalloc_malloc.c  Tue Sep 17 15:53:40 2019
> (r352450)
> +++ head/stand/libsa/zalloc_malloc.c  Tue Sep 17 16:16:46 2019
> (r352451)
> @@ -73,9 +73,6 @@ Malloc_align(size_t bytes, size_t alignment)
>  {
>   Guard *res;
>  
> - if (bytes == 0)
> - return (NULL);
> -
>  #ifdef USEENDGUARD
>   bytes += MALLOCALIGN + 1;
>  #else
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r352451 - head/stand/libsa

2019-09-17 Thread Ian Lepore
On Tue, 2019-09-17 at 16:16 +, Toomas Soome wrote:
> Author: tsoome
> Date: Tue Sep 17 16:16:46 2019
> New Revision: 352451
> URL: https://svnweb.freebsd.org/changeset/base/352451
> 
> Log:
>   loader: revert r352421
>   
>   As insisted by kib, malloc(0) is quite legal.
> 
> Modified:
>   head/stand/libsa/zalloc_malloc.c
> 
> Modified: head/stand/libsa/zalloc_malloc.c
> ==
> --- head/stand/libsa/zalloc_malloc.c  Tue Sep 17 15:53:40 2019
> (r352450)
> +++ head/stand/libsa/zalloc_malloc.c  Tue Sep 17 16:16:46 2019
> (r352451)
> @@ -73,9 +73,6 @@ Malloc_align(size_t bytes, size_t alignment)
>  {
>   Guard *res;
>  
> - if (bytes == 0)
> - return (NULL);
> -
>  #ifdef USEENDGUARD
>   bytes += MALLOCALIGN + 1;
>  #else

For the record, you're both right.  In both the C and posix standards
for malloc(), an implementation is allowed to return either NULL or a
unique pointer which cannot be used to access any memory but must be
passed to free().

-- Ian

___
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: r352451 - head/stand/libsa

2019-09-17 Thread Toomas Soome
Author: tsoome
Date: Tue Sep 17 16:16:46 2019
New Revision: 352451
URL: https://svnweb.freebsd.org/changeset/base/352451

Log:
  loader: revert r352421
  
  As insisted by kib, malloc(0) is quite legal.

Modified:
  head/stand/libsa/zalloc_malloc.c

Modified: head/stand/libsa/zalloc_malloc.c
==
--- head/stand/libsa/zalloc_malloc.cTue Sep 17 15:53:40 2019
(r352450)
+++ head/stand/libsa/zalloc_malloc.cTue Sep 17 16:16:46 2019
(r352451)
@@ -73,9 +73,6 @@ Malloc_align(size_t bytes, size_t alignment)
 {
Guard *res;
 
-   if (bytes == 0)
-   return (NULL);
-
 #ifdef USEENDGUARD
bytes += MALLOCALIGN + 1;
 #else
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r352450 - head/sys/kern

2019-09-17 Thread Mateusz Guzik
Author: mjg
Date: Tue Sep 17 15:53:40 2019
New Revision: 352450
URL: https://svnweb.freebsd.org/changeset/base/352450

Log:
  vfs: apply r352437 to the fast path as well
  
  This one is very hard to run into. If the filesystem is being unmounted or
  the mount point is freed the vfs_op_thread_enter will fail. For it to
  succeed the mount point itself would have to be reallocated in the time
  window between the initial read and the attempt to enter.
  
  Sponsored by: The FreeBSD Foundation

Modified:
  head/sys/kern/vfs_default.c

Modified: head/sys/kern/vfs_default.c
==
--- head/sys/kern/vfs_default.c Tue Sep 17 14:15:48 2019(r352449)
+++ head/sys/kern/vfs_default.c Tue Sep 17 15:53:40 2019(r352450)
@@ -606,11 +606,13 @@ vop_stdgetwritemount(ap)
return (0);
}
if (vfs_op_thread_enter(mp)) {
-   if (mp == vp->v_mount)
+   if (mp == vp->v_mount) {
vfs_mp_count_add_pcpu(mp, ref, 1);
-   else
+   vfs_op_thread_exit(mp);
+   } else {
+   vfs_op_thread_exit(mp);
mp = NULL;
-   vfs_op_thread_exit(mp);
+   }
} else {
MNT_ILOCK(mp);
if (mp == vp->v_mount) {
___
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: r352421 - head/stand/libsa

2019-09-17 Thread Konstantin Belousov
On Tue, Sep 17, 2019 at 12:05:26PM +0300, Toomas Soome wrote:
> 
> 
> > On 17 Sep 2019, at 11:56, Konstantin Belousov  wrote:
> > 
> > On Mon, Sep 16, 2019 at 08:28:09PM +, Toomas Soome wrote:
> >> Author: tsoome
> >> Date: Mon Sep 16 20:28:08 2019
> >> New Revision: 352421
> >> URL: https://svnweb.freebsd.org/changeset/base/352421
> >> 
> >> Log:
> >>  loader: Malloc(0) should return NULL.
> >> 
> >>  We really should not allocate anything with size 0.
> > Why ?  This is quite unexpected from other environments, where
> > malloc(0) returns unique object.
> > 
> 
> Hiding bugs. And, we are not getting unique object, we are getting chunk of 
> memory with payload length of 0 and the memory content depends on if head and 
> tail guards are used - the chunk is with size at least MALLOCALIGN (16 or 64 
> bytes) and the chunk is from random location of heap.
> 

Yes, exactly, this is how all other mallocs behave.
___
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: r352449 - head/lib/libbe

2019-09-17 Thread Andriy Gapon
Author: avg
Date: Tue Sep 17 14:15:48 2019
New Revision: 352449
URL: https://svnweb.freebsd.org/changeset/base/352449

Log:
  fixup up fallout from r352447 in libbe
  
  I totally forgot that we now have another in-tree consumer of libzfs.
  
  MFC after:3 days
  X-MFC with:   r352447

Modified:
  head/lib/libbe/be.c

Modified: head/lib/libbe/be.c
==
--- head/lib/libbe/be.c Tue Sep 17 14:08:09 2019(r352448)
+++ head/lib/libbe/be.c Tue Sep 17 14:15:48 2019(r352449)
@@ -775,6 +775,7 @@ be_export(libbe_handle_t *lbh, const char *bootenv, in
char snap_name[BE_MAXPATHLEN];
char buf[BE_MAXPATHLEN];
zfs_handle_t *zfs;
+   sendflags_t flags = { 0 };
int err;
 
if ((err = be_snapshot(lbh, bootenv, NULL, true, snap_name)) != 0)
@@ -786,7 +787,7 @@ be_export(libbe_handle_t *lbh, const char *bootenv, in
if ((zfs = zfs_open(lbh->lzh, buf, ZFS_TYPE_DATASET)) == NULL)
return (set_error(lbh, BE_ERR_ZFSOPEN));
 
-   err = zfs_send_one(zfs, NULL, fd, 0);
+   err = zfs_send_one(zfs, NULL, fd, flags);
zfs_close(zfs);
 
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: r352448 - head/contrib/netbsd-tests/lib/libc/sys

2019-09-17 Thread Li-Wen Hsu
Author: lwhsu
Date: Tue Sep 17 14:08:09 2019
New Revision: 352448
URL: https://svnweb.freebsd.org/changeset/base/352448

Log:
  Temporarily skip flakey test case lib.libc.sys.stat_test.stat_socket
  
  PR:   240621
  Sponsored by: The FreeBSD Foundation

Modified:
  head/contrib/netbsd-tests/lib/libc/sys/t_stat.c

Modified: head/contrib/netbsd-tests/lib/libc/sys/t_stat.c
==
--- head/contrib/netbsd-tests/lib/libc/sys/t_stat.c Tue Sep 17 13:58:15 
2019(r352447)
+++ head/contrib/netbsd-tests/lib/libc/sys/t_stat.c Tue Sep 17 14:08:09 
2019(r352448)
@@ -332,6 +332,9 @@ ATF_TC_BODY(stat_socket, tc)
uint32_t iaddr;
int fd, flags;
 
+   if (atf_tc_get_config_var_as_bool_wd(tc, "ci", false))
+   atf_tc_skip("https://bugs.freebsd.org/240621;);
+
(void)memset(, 0, sizeof(struct stat));
(void)memset(, 0, sizeof(struct sockaddr_in));
 
___
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: r352447 - in head/cddl/contrib/opensolaris: cmd/zfs lib/libzfs/common

2019-09-17 Thread Andriy Gapon
Author: avg
Date: Tue Sep 17 13:58:15 2019
New Revision: 352447
URL: https://svnweb.freebsd.org/changeset/base/352447

Log:
  MFZoL: Add -vnP support to 'zfs send' for bookmarks
  
  zfsonlinux/zfs@835db58592d7d947e5818eb7281882e2a46073e0
  
  We have long supported estimating a size of an incremental stream from a
  snapshot.  We should do the same for bookmarks as well.
  
  Obtained from:ZoL
  Author:   loli10K 
  MFC after:3 days

Modified:
  head/cddl/contrib/opensolaris/cmd/zfs/zfs.8
  head/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c
  head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs.h
  head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c

Modified: head/cddl/contrib/opensolaris/cmd/zfs/zfs.8
==
--- head/cddl/contrib/opensolaris/cmd/zfs/zfs.8 Tue Sep 17 13:50:25 2019
(r352446)
+++ head/cddl/contrib/opensolaris/cmd/zfs/zfs.8 Tue Sep 17 13:58:15 2019
(r352447)
@@ -190,8 +190,8 @@
 .Ar snapshot
 .Nm
 .Cm send
-.Op Fl Lce
-.Op Fl i Ar snapshot Ns | Ns bookmark
+.Op Fl LPcenv
+.Op Fl i Ar snapshot Ns | Ns Ar bookmark
 .Ar filesystem Ns | Ns Ar volume Ns | Ns Ar snapshot
 .Nm
 .Cm send
@@ -2766,7 +2766,7 @@ on future versions of
 .It Xo
 .Nm
 .Cm send
-.Op Fl Lce
+.Op Fl LPcenv
 .Op Fl i Ar snapshot Ns | Ns Ar bookmark
 .Ar filesystem Ns | Ns Ar volume Ns | Ns Ar snapshot
 .Xc
@@ -2780,7 +2780,7 @@ stream generated from a filesystem or volume is receiv
 name will be
 .Pq --head-- .
 .Bl -tag -width indent
-.It Fl i Ar snapshot Ns | Ns bookmark
+.It Fl i Ar snapshot Ns | Ns Ar bookmark
 Generate an incremental send stream.
 The incremental source must be an earlier
 snapshot in the destination's history.
@@ -2792,6 +2792,23 @@ specified as the last component of the name
 If the incremental target is a clone, the incremental source can
 be the origin snapshot, or an earlier snapshot in the origin's filesystem,
 or the origin's origin, etc.
+.It Fl n, -dryrun
+Do a dry-run
+.Pq Qq No-op
+send.
+Do not generate any actual send data.
+This is useful in conjunction with the
+.Fl v
+or
+.Fl P
+flags to determine what data will be sent.
+In this case, the verbose output will be written to standard output
+.Po contrast with a non-dry-run, where the stream is written to standard output
+and the verbose output goes to standard error
+.Pc .
+.It Fl v, -verbose
+Print verbose information about the stream package generated.
+This information includes a per-second report of how much data has been sent.
 .It Fl L, -large-block
 Generate a stream which may contain blocks larger than 128KB.
 This flag
@@ -2808,6 +2825,8 @@ See
 for details on ZFS feature flags and the
 .Sy large_blocks
 feature.
+.It Fl P, -parsable
+Print machine-parsable verbose information about the stream package generated.
 .It Fl c, -compressed
 Generate a more compact stream by using compressed WRITE records for blocks
 which are compressed on disk and in memory (see the

Modified: head/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c
==
--- head/cddl/contrib/opensolaris/cmd/zfs/zfs_main.cTue Sep 17 13:50:25 
2019(r352446)
+++ head/cddl/contrib/opensolaris/cmd/zfs/zfs_main.cTue Sep 17 13:58:15 
2019(r352447)
@@ -3928,13 +3928,11 @@ zfs_do_send(int argc, char **argv)
if (strchr(argv[0], '@') == NULL ||
(fromname && strchr(fromname, '#') != NULL)) {
char frombuf[ZFS_MAX_DATASET_NAME_LEN];
-   enum lzc_send_flags lzc_flags = 0;
 
if (flags.replicate || flags.doall || flags.props ||
-   flags.dedup || flags.dryrun || flags.verbose ||
-   flags.progress) {
-   (void) fprintf(stderr,
-   gettext("Error: "
+   flags.dedup || (strchr(argv[0], '@') == NULL &&
+   (flags.dryrun || flags.verbose || flags.progress))) {
+   (void) fprintf(stderr, gettext("Error: "
"Unsupported flag with filesystem or bookmark.\n"));
return (1);
}
@@ -3943,13 +3941,6 @@ zfs_do_send(int argc, char **argv)
if (zhp == NULL)
return (1);
 
-   if (flags.largeblock)
-   lzc_flags |= LZC_SEND_FLAG_LARGE_BLOCK;
-   if (flags.embed_data)
-   lzc_flags |= LZC_SEND_FLAG_EMBED_DATA;
-   if (flags.compress)
-   lzc_flags |= LZC_SEND_FLAG_COMPRESS;
-
if (fromname != NULL &&
(fromname[0] == '#' || fromname[0] == '@')) {
/*
@@ -3963,7 +3954,7 @@ zfs_do_send(int argc, char **argv)
(void) strlcat(frombuf, fromname, sizeof (frombuf));
fromname = frombuf;
}
- 

svn commit: r352446 - head/stand/efi/libefi

2019-09-17 Thread Toomas Soome
Author: tsoome
Date: Tue Sep 17 13:50:25 2019
New Revision: 352446
URL: https://svnweb.freebsd.org/changeset/base/352446

Log:
  loader.efi: efipart needs to use ioalign
  
  UEFI specification 2.7A, EFI_BLOCK_IO_PROTOCOL, page 566.
  
  The ioalign property does define the alignment of data buffer.
  
  If the alignment is required and our buffer is not aligned, or if
  the data buffer is not multiple of Blocksize, we need to use bounce buffer
  to perform the block IO. This is much like with BIOS version, except
  there the INT13 needs buffer to be located in low memory.
  
  Additionally, we need to handle disk writes properly.

Modified:
  head/stand/efi/libefi/efipart.c

Modified: head/stand/efi/libefi/efipart.c
==
--- head/stand/efi/libefi/efipart.c Tue Sep 17 13:15:27 2019
(r352445)
+++ head/stand/efi/libefi/efipart.c Tue Sep 17 13:50:25 2019
(r352446)
@@ -64,6 +64,9 @@ static int efipart_printhd(int);
 #definePNP0700 0x700
 #definePNP0701 0x701
 
+/* Bounce buffer max size */
+#defineBIO_BUFFER_SIZE 0x4000
+
 struct devsw efipart_fddev = {
.dv_name = "fd",
.dv_type = DEVT_FD,
@@ -266,6 +269,12 @@ efipart_inithandles(void)
continue;
}
 
+   /* Allowed values are 0, 1 and power of 2. */
+   if (blkio->Media->IoAlign > 1 &&
+   !powerof2(blkio->Media->IoAlign)) {
+   continue;
+   }
+
/* This is bad. */
if ((pd = calloc(1, sizeof(*pd))) == NULL) {
printf("efipart_inithandles: Out of memory.\n");
@@ -979,8 +988,10 @@ efipart_realstrategy(void *devdata, int rw, daddr_t bl
EFI_BLOCK_IO *blkio;
uint64_t off, disk_blocks, d_offset = 0;
char *blkbuf;
-   size_t blkoff, blksz;
-   int error;
+   size_t blkoff, blksz, bio_size;
+   unsigned ioalign;
+   bool need_buf;
+   int rc;
uint64_t diskend, readstart;
 
if (dev == NULL || blk < 0)
@@ -1028,40 +1039,118 @@ efipart_realstrategy(void *devdata, int rw, daddr_t bl
size = size * blkio->Media->BlockSize;
}
 
-   if (rsize != NULL)
-   *rsize = size;
-
+   need_buf = true;
+   /* Do we need bounce buffer? */
if ((size % blkio->Media->BlockSize == 0) &&
(off % blkio->Media->BlockSize == 0))
-   return (efipart_readwrite(blkio, rw,
-   off / blkio->Media->BlockSize,
-   size / blkio->Media->BlockSize, buf));
+   need_buf = false;
 
-   /*
-* The buffer size is not a multiple of the media block size.
-*/
-   blkbuf = malloc(blkio->Media->BlockSize);
+   /* Do we have IO alignment requirement? */
+   ioalign = blkio->Media->IoAlign;
+   if (ioalign == 0)
+   ioalign++;
+
+   if (ioalign > 1 && (uintptr_t)buf != roundup2((uintptr_t)buf, ioalign))
+   need_buf = true;
+
+   if (need_buf) {
+   for (bio_size = BIO_BUFFER_SIZE; bio_size > 0;
+   bio_size -= blkio->Media->BlockSize) {
+   blkbuf = memalign(ioalign, bio_size);
+   if (blkbuf != NULL)
+   break;
+   }
+   } else {
+   blkbuf = buf;
+   bio_size = size;
+   }
+
if (blkbuf == NULL)
return (ENOMEM);
 
-   error = 0;
+   if (rsize != NULL)
+   *rsize = size;
+
+   rc = 0;
blk = off / blkio->Media->BlockSize;
blkoff = off % blkio->Media->BlockSize;
-   blksz = blkio->Media->BlockSize - blkoff;
+
while (size > 0) {
-   error = efipart_readwrite(blkio, rw, blk, 1, blkbuf);
-   if (error)
+   size_t x = min(size, bio_size);
+
+   if (x < blkio->Media->BlockSize)
+   x = 1;
+   else
+   x /= blkio->Media->BlockSize;
+
+   switch (rw & F_MASK) {
+   case F_READ:
+   blksz = blkio->Media->BlockSize * x - blkoff;
+   if (size < blksz)
+   blksz = size;
+
+   rc = efipart_readwrite(blkio, rw, blk, x, blkbuf);
+   if (rc != 0)
+   goto error;
+
+   if (need_buf)
+   bcopy(blkbuf + blkoff, buf, blksz);
break;
-   if (size < blksz)
-   blksz = size;
-   bcopy(blkbuf + blkoff, buf, blksz);
+   case F_WRITE:
+   rc = 0;
+   if (blkoff != 0) {
+   /*
+* We got offset to sector, 

svn commit: r352445 - head/stand/libsa

2019-09-17 Thread Toomas Soome
Author: tsoome
Date: Tue Sep 17 13:15:27 2019
New Revision: 352445
URL: https://svnweb.freebsd.org/changeset/base/352445

Log:
  loader: add memalign() to libsa
  
  Implement memalign(size_t alignment, size_t size) to allocate aligned memory.

Modified:
  head/stand/libsa/stand.h
  head/stand/libsa/zalloc.c
  head/stand/libsa/zalloc_malloc.c
  head/stand/libsa/zalloc_protos.h

Modified: head/stand/libsa/stand.h
==
--- head/stand/libsa/stand.hTue Sep 17 13:07:02 2019(r352444)
+++ head/stand/libsa/stand.hTue Sep 17 13:15:27 2019(r352445)
@@ -427,19 +427,23 @@ extern uint16_t   ntohs(uint16_t);
 #endif
 
 void *Malloc(size_t, const char *, int);
+void *Memalign(size_t, size_t, const char *, int);
 void *Calloc(size_t, size_t, const char *, int);
 void *Realloc(void *, size_t, const char *, int);
+void *Reallocf(void *, size_t, const char *, int);
 void Free(void *, const char *, int);
 extern voidmallocstats(void);
 
 #ifdef DEBUG_MALLOC
 #define malloc(x)  Malloc(x, __FILE__, __LINE__)
+#define memalign(x, y) Memalign(x, y, __FILE__, __LINE__)
 #define calloc(x, y)   Calloc(x, y, __FILE__, __LINE__)
 #define free(x)Free(x, __FILE__, __LINE__)
 #define realloc(x, y)  Realloc(x, y, __FILE__, __LINE__)
 #define reallocf(x, y) Reallocf(x, y, __FILE__, __LINE__)
 #else
 #define malloc(x)  Malloc(x, NULL, 0)
+#define memalign(x, y) Memalign(x, y, NULL, 0)
 #define calloc(x, y)   Calloc(x, y, NULL, 0)
 #define free(x)Free(x, NULL, 0)
 #define realloc(x, y)  Realloc(x, y, NULL, 0)

Modified: head/stand/libsa/zalloc.c
==
--- head/stand/libsa/zalloc.c   Tue Sep 17 13:07:02 2019(r352444)
+++ head/stand/libsa/zalloc.c   Tue Sep 17 13:15:27 2019(r352445)
@@ -30,6 +30,8 @@
 #include 
 __FBSDID("$FreeBSD$");
 
+#include 
+
 /*
  * LIB/MEMORY/ZALLOC.C - self contained low-overhead memory pool/allocation
  *   subsystem
@@ -86,7 +88,7 @@ typedef char assert_align[(sizeof(struct MemNode) <= M
  */
 
 void *
-znalloc(MemPool *mp, uintptr_t bytes)
+znalloc(MemPool *mp, uintptr_t bytes, size_t align)
 {
MemNode **pmn;
MemNode *mn;
@@ -111,14 +113,40 @@ znalloc(MemPool *mp, uintptr_t bytes)
 
for (pmn = >mp_First; (mn = *pmn) != NULL; pmn = >mr_Next) {
char *ptr = (char *)mn;
+   uintptr_t dptr;
+   char *aligned;
+   size_t extra;
 
-   if (bytes > mn->mr_Bytes)
+   dptr = (uintptr_t)(ptr + MALLOCALIGN);  /* pointer to data */
+   aligned = (char *)(roundup2(dptr, align) - MALLOCALIGN);
+   extra = aligned - ptr;
+
+   if (bytes + extra > mn->mr_Bytes)
continue;
 
/*
+* Cut extra from head and create new memory node from reminder.
+*/
+
+   if (extra != 0) {
+   MemNode *new;
+
+   new = (MemNode *)aligned;
+   new->mr_Next = mn->mr_Next;
+   new->mr_Bytes = mn->mr_Bytes - extra;
+
+   /* And update current memory node */
+   mn->mr_Bytes = extra;
+   mn->mr_Next = new;
+   /* In next iteration, we will get our aligned address */
+   continue;
+   }
+
+   /*
 *  Cut a chunk of memory out of the beginning of this
 *  block and fixup the link appropriately.
 */
+
if (mn->mr_Bytes == bytes) {
*pmn = mn->mr_Next;
} else {

Modified: head/stand/libsa/zalloc_malloc.c
==
--- head/stand/libsa/zalloc_malloc.cTue Sep 17 13:07:02 2019
(r352444)
+++ head/stand/libsa/zalloc_malloc.cTue Sep 17 13:15:27 2019
(r352445)
@@ -50,9 +50,27 @@ void mallocstats(void);
 #undef free
 #endif
 
+static void *Malloc_align(size_t, size_t);
+
 void *
-Malloc(size_t bytes, const char *file, int line)
+Malloc(size_t bytes, const char *file __unused, int line __unused)
 {
+   return (Malloc_align(bytes, 1));
+}
+
+void *
+Memalign(size_t alignment, size_t bytes, const char *file __unused,
+int line __unused)
+{
+   if (alignment == 0)
+   alignment = 1;
+
+   return (Malloc_align(bytes, alignment));
+}
+
+static void *
+Malloc_align(size_t bytes, size_t alignment)
+{
Guard *res;
 
if (bytes == 0)
@@ -64,7 +82,7 @@ Malloc(size_t bytes, const char *file, int line)
bytes += MALLOCALIGN;
 #endif
 
-   while ((res = znalloc(, bytes)) == NULL) {
+   while ((res = znalloc(, bytes, alignment)) == NULL) {
int incr = 

svn commit: r352444 - head/stand/libsa

2019-09-17 Thread Toomas Soome
Author: tsoome
Date: Tue Sep 17 13:07:02 2019
New Revision: 352444
URL: https://svnweb.freebsd.org/changeset/base/352444

Log:
  loader: stand.h should define reallocf as Reallocf
  
  Use the same approach as other zalloc functions.

Modified:
  head/stand/libsa/stand.h

Modified: head/stand/libsa/stand.h
==
--- head/stand/libsa/stand.hTue Sep 17 11:35:53 2019(r352443)
+++ head/stand/libsa/stand.hTue Sep 17 13:07:02 2019(r352444)
@@ -264,9 +264,6 @@ static __inline int tolower(int c)
 extern voidsetheap(void *base, void *top);
 extern char*sbrk(int incr);
 
-extern void*reallocf(void *ptr, size_t size);
-extern voidmallocstats(void);
-
 extern int printf(const char *fmt, ...) __printflike(1, 2);
 extern int asprintf(char **buf, const char *cfmt, ...) __printflike(2, 3);
 extern int sprintf(char *buf, const char *cfmt, ...) __printflike(2, 3);
@@ -433,17 +430,20 @@ void *Malloc(size_t, const char *, int);
 void *Calloc(size_t, size_t, const char *, int);
 void *Realloc(void *, size_t, const char *, int);
 void Free(void *, const char *, int);
+extern voidmallocstats(void);
 
 #ifdef DEBUG_MALLOC
 #define malloc(x)  Malloc(x, __FILE__, __LINE__)
 #define calloc(x, y)   Calloc(x, y, __FILE__, __LINE__)
 #define free(x)Free(x, __FILE__, __LINE__)
 #define realloc(x, y)  Realloc(x, y, __FILE__, __LINE__)
+#define reallocf(x, y) Reallocf(x, y, __FILE__, __LINE__)
 #else
 #define malloc(x)  Malloc(x, NULL, 0)
 #define calloc(x, y)   Calloc(x, y, NULL, 0)
 #define free(x)Free(x, NULL, 0)
 #define realloc(x, y)  Realloc(x, y, NULL, 0)
+#define reallocf(x, y) Reallocf(x, y, NULL, 0)
 #endif
 
 #endif /* STAND_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: r352443 - head/stand/libsa

2019-09-17 Thread Toomas Soome
Author: tsoome
Date: Tue Sep 17 11:35:53 2019
New Revision: 352443
URL: https://svnweb.freebsd.org/changeset/base/352443

Log:
  loader: cstyle cleanup libsa zalloc sources
  
  Clean up libstand zalloc* sources. Note that it is not 100% whitespace 
cleanup.
  I also reduced block in znalloc and zfree as those were obvious 
simplifications
  and did help to save one level of indent.

Modified:
  head/stand/libsa/zalloc.c
  head/stand/libsa/zalloc_defs.h
  head/stand/libsa/zalloc_malloc.c
  head/stand/libsa/zalloc_mem.h
  head/stand/libsa/zalloc_protos.h

Modified: head/stand/libsa/zalloc.c
==
--- head/stand/libsa/zalloc.c   Tue Sep 17 11:20:53 2019(r352442)
+++ head/stand/libsa/zalloc.c   Tue Sep 17 11:35:53 2019(r352443)
@@ -1,5 +1,5 @@
 /*
- * This module derived from code donated to the FreeBSD Project by 
+ * This module derived from code donated to the FreeBSD Project by
  * Matthew Dillon 
  *
  * Copyright (c) 1998 The FreeBSD Project
@@ -31,10 +31,10 @@
 __FBSDID("$FreeBSD$");
 
 /*
- * LIB/MEMORY/ZALLOC.C - self contained low-overhead memory pool/allocation 
+ * LIB/MEMORY/ZALLOC.C - self contained low-overhead memory pool/allocation
  *   subsystem
  *
- * This subsystem implements memory pools and memory allocation 
+ * This subsystem implements memory pools and memory allocation
  * routines.
  *
  * Pools are managed via a linked list of 'free' areas.  Allocating
@@ -43,7 +43,7 @@ __FBSDID("$FreeBSD$");
  * to allocate the entire pool without incuring any structural overhead.
  *
  * The system works best when allocating similarly-sized chunks of
- * memory.  Care must be taken to avoid fragmentation when 
+ * memory.  Care must be taken to avoid fragmentation when
  * allocating/deallocating dissimilar chunks.
  *
  * When a memory pool is first allocated, the entire pool is marked as
@@ -53,7 +53,7 @@ __FBSDID("$FreeBSD$");
  * available.
  *
  * z[n]xalloc() works like z[n]alloc() but the allocation is made from
- * within the specified address range.  If the segment could not be 
+ * within the specified address range.  If the segment could not be
  * allocated, NULL is returned.  WARNING!  The address range will be
  * aligned to an 8 or 16 byte boundry depending on the cpu so if you
  * give an unaligned address range, unexpected results may occur.
@@ -88,56 +88,54 @@ typedef char assert_align[(sizeof(struct MemNode) <= M
 void *
 znalloc(MemPool *mp, uintptr_t bytes)
 {
-/*
- * align according to pool object size (can be 0).  This is
- * inclusive of the MEMNODE_SIZE_MASK minimum alignment.
- *
- */
-bytes = (bytes + MEMNODE_SIZE_MASK) & ~MEMNODE_SIZE_MASK;
-
-if (bytes == 0)
-   return((void *)-1);
-
-/*
- * locate freelist entry big enough to hold the object.  If all objects
- * are the same size, this is a constant-time function.
- */
-
-if (bytes <= mp->mp_Size - mp->mp_Used) {
MemNode **pmn;
MemNode *mn;
 
-   for (pmn = >mp_First; (mn=*pmn) != NULL; pmn = >mr_Next) {
-   if (bytes > mn->mr_Bytes)
-   continue;
+   /*
+* align according to pool object size (can be 0).  This is
+* inclusive of the MEMNODE_SIZE_MASK minimum alignment.
+*
+   */
+   bytes = (bytes + MEMNODE_SIZE_MASK) & ~MEMNODE_SIZE_MASK;
 
-   /*
-*  Cut a chunk of memory out of the beginning of this
-*  block and fixup the link appropriately.
-*/
+   if (bytes == 0)
+   return ((void *)-1);
 
-   {
+   /*
+* locate freelist entry big enough to hold the object.  If all objects
+* are the same size, this is a constant-time function.
+*/
+
+   if (bytes > mp->mp_Size - mp->mp_Used)
+   return (NULL);
+
+   for (pmn = >mp_First; (mn = *pmn) != NULL; pmn = >mr_Next) {
char *ptr = (char *)mn;
 
+   if (bytes > mn->mr_Bytes)
+   continue;
+
+   /*
+*  Cut a chunk of memory out of the beginning of this
+*  block and fixup the link appropriately.
+*/
if (mn->mr_Bytes == bytes) {
-   *pmn = mn->mr_Next;
+   *pmn = mn->mr_Next;
} else {
-   mn = (MemNode *)((char *)mn + bytes);
-   mn->mr_Next  = ((MemNode *)ptr)->mr_Next;
-   mn->mr_Bytes = ((MemNode *)ptr)->mr_Bytes - bytes;
-   *pmn = mn;
+   mn = (MemNode *)((char *)mn + bytes);
+   mn->mr_Next  = ((MemNode *)ptr)->mr_Next;
+   mn->mr_Bytes = ((MemNode *)ptr)->mr_Bytes - bytes;
+   *pmn = mn;
}
mp->mp_Used += 

svn commit: r352442 - stable/12/sys/arm/arm

2019-09-17 Thread Aleksandr Rybalko
Author: ray
Date: Tue Sep 17 11:20:53 2019
New Revision: 352442
URL: https://svnweb.freebsd.org/changeset/base/352442

Log:
  MFC r351649 Check for region dups.

Modified:
  stable/12/sys/arm/arm/physmem.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/arm/arm/physmem.c
==
--- stable/12/sys/arm/arm/physmem.c Tue Sep 17 10:09:59 2019
(r352441)
+++ stable/12/sys/arm/arm/physmem.c Tue Sep 17 11:20:53 2019
(r352442)
@@ -287,6 +287,8 @@ insert_region(struct region *regions, size_t rcnt, vm_
 
ep = regions + rcnt;
for (i = 0, rp = regions; i < rcnt; ++i, ++rp) {
+   if (rp->addr == addr && rp->size == size) /* Pure dup. */
+   return (rcnt);
if (flags == rp->flags) {
if (addr + size == rp->addr) {
rp->addr = addr;
___
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: r352441 - stable/12/sys/arm64/arm64

2019-09-17 Thread Andrew Turner
Author: andrew
Date: Tue Sep 17 10:09:59 2019
New Revision: 352441
URL: https://svnweb.freebsd.org/changeset/base/352441

Log:
  MFC r343042, r343875
  
  r343042:
  Ensure the I-Cache is correctly handled in arm64_icache_sync_range
  
  The cache_handle_range macro to handle the arm64 instruction and data
  cache operations would return when it was complete. This causes problems
  for arm64_icache_sync_range and arm64_icache_sync_range_checked as they
  assume they can execute the i-cache handling instruction after it has been
  called.
  
  Fix this by making this assumption correct.
  
  While here add missing instruction barriers and adjust the style to
  match the rest of the assembly.
  
  Sponsored by: DARPA, AFRL
  Differential Revision:https://reviews.freebsd.org/D18838
  
  r343875:
  Add a missing data barrier to the start of arm64_tlb_flushID.
  
  We need to ensure the page table store has happened before the tlbi.
  
  Reported by:  jchandra
  Tested by:jchandra
  Sponsored by: DARPA, AFRL
  Differential Revision:https://reviews.freebsd.org/D19097

Modified:
  stable/12/sys/arm64/arm64/cpufunc_asm.S
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/arm64/arm64/cpufunc_asm.S
==
--- stable/12/sys/arm64/arm64/cpufunc_asm.S Tue Sep 17 10:00:53 2019
(r352440)
+++ stable/12/sys/arm64/arm64/cpufunc_asm.S Tue Sep 17 10:09:59 2019
(r352441)
@@ -73,7 +73,6 @@ __FBSDID("$FreeBSD$");
 .if \ic != 0
isb
 .endif
-   ret
 .endm
 
 ENTRY(arm64_nullop)
@@ -93,6 +92,7 @@ ENTRY(arm64_setttb)
 END(arm64_setttb)
 
 ENTRY(arm64_tlb_flushID)
+   dsb ishst
 #ifdef SMP
tlbivmalle1is
 #else
@@ -108,6 +108,7 @@ END(arm64_tlb_flushID)
  */
 ENTRY(arm64_dcache_wb_range)
cache_handle_range  dcop = cvac
+   ret
 END(arm64_dcache_wb_range)
 
 /*
@@ -115,6 +116,7 @@ END(arm64_dcache_wb_range)
  */
 ENTRY(arm64_dcache_wbinv_range)
cache_handle_range  dcop = civac
+   ret
 END(arm64_dcache_wbinv_range)
 
 /*
@@ -125,6 +127,7 @@ END(arm64_dcache_wbinv_range)
  */
 ENTRY(arm64_dcache_inv_range)
cache_handle_range  dcop = ivac
+   ret
 END(arm64_dcache_inv_range)
 
 /*
@@ -132,6 +135,7 @@ END(arm64_dcache_inv_range)
  */
 ENTRY(arm64_idcache_wbinv_range)
cache_handle_range  dcop = civac, ic = 1, icop = ivau
+   ret
 END(arm64_idcache_wbinv_range)
 
 /*
@@ -146,4 +150,6 @@ ENTRY(arm64_icache_sync_range)
cache_handle_range  dcop = cvau
ic  ialluis
dsb ish
+   isb
+   ret
 END(arm64_icache_sync_range)
___
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: r352440 - stable/12/sys/arm64/arm64

2019-09-17 Thread Andrew Turner
Author: andrew
Date: Tue Sep 17 10:00:53 2019
New Revision: 352440
URL: https://svnweb.freebsd.org/changeset/base/352440

Log:
  MFC r342552:
  Pass VM_PROT_EXECUTE to vm_fault for instruction faults.
  
  We need to tell vm_fault the reason for the fault was because we tried to
  execute from the memory location. Without this it may return with success
  as we only request read-only memory, then we return to the same location
  and try to execute from the same memory address. This leads to an infinite
  loop raising the same fault and returning to the same invalid location.
  
  Sponsored by: DARPA, AFRL
  Differential Revision:https://reviews.freebsd.org/D18511

Modified:
  stable/12/sys/arm64/arm64/trap.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/arm64/arm64/trap.c
==
--- stable/12/sys/arm64/arm64/trap.cTue Sep 17 09:47:35 2019
(r352439)
+++ stable/12/sys/arm64/arm64/trap.cTue Sep 17 10:00:53 2019
(r352440)
@@ -151,7 +151,7 @@ svc_handler(struct thread *td, struct trapframe *frame
 
 static void
 data_abort(struct thread *td, struct trapframe *frame, uint64_t esr,
-uint64_t far, int lower)
+uint64_t far, int lower, int exec)
 {
struct vm_map *map;
struct proc *p;
@@ -231,6 +231,8 @@ no_pmap_fault:
 
va = trunc_page(far);
ftype = ((esr >> 6) & 1) ? VM_PROT_READ | VM_PROT_WRITE : VM_PROT_READ;
+   if (exec)
+   ftype |= VM_PROT_EXECUTE;
 
/* Fault in the page. */
error = vm_fault(map, va, ftype, VM_FAULT_NORMAL);
@@ -338,7 +340,8 @@ do_el1h_sync(struct thread *td, struct trapframe *fram
case EXCP_DATA_ABORT:
far = READ_SPECIALREG(far_el1);
intr_enable();
-   data_abort(td, frame, esr, far, 0);
+   data_abort(td, frame, esr, far, 0,
+   exception == EXCP_INSN_ABORT);
break;
case EXCP_BRK:
 #ifdef KDTRACE_HOOKS
@@ -435,7 +438,8 @@ do_el0_sync(struct thread *td, struct trapframe *frame
case EXCP_INSN_ABORT_L:
case EXCP_DATA_ABORT_L:
case EXCP_DATA_ABORT:
-   data_abort(td, frame, esr, far, 1);
+   data_abort(td, frame, esr, far, 1,
+   exception == EXCP_INSN_ABORT_L);
break;
case EXCP_UNKNOWN:
if (!undef_insn(0, frame))
___
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: r352439 - head/stand/libsa

2019-09-17 Thread Toomas Soome
Author: tsoome
Date: Tue Sep 17 09:47:35 2019
New Revision: 352439
URL: https://svnweb.freebsd.org/changeset/base/352439

Log:
  loader: factor out guard location setup from Realloc
  
  To simplify and make it easier to read, use ga_Bytes field from guard
  structure.

Modified:
  head/stand/libsa/zalloc_malloc.c

Modified: head/stand/libsa/zalloc_malloc.c
==
--- head/stand/libsa/zalloc_malloc.cTue Sep 17 09:46:42 2019
(r352438)
+++ head/stand/libsa/zalloc_malloc.cTue Sep 17 09:47:35 2019
(r352439)
@@ -156,7 +156,9 @@ Realloc(void *ptr, size_t size, const char *file, int 
 
 if ((res = Malloc(size, file, line)) != NULL) {
if (ptr) {
-   old = *(size_t *)((char *)ptr - MALLOCALIGN) - MALLOCALIGN;
+   Guard *g = (Guard *)((char *)ptr - MALLOCALIGN);
+
+   old = g->ga_Bytes - MALLOCALIGN;
if (old < size)
bcopy(ptr, res, old);
else
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r352438 - head/sys/netinet

2019-09-17 Thread Michael Tuexen
Author: tuexen
Date: Tue Sep 17 09:46:42 2019
New Revision: 352438
URL: https://svnweb.freebsd.org/changeset/base/352438

Log:
  Only allow a SCTP-AUTH shared key to be updated by the application
  if it is not deactivated and not used.
  This avoids a use-after-free problem.
  
  Reported by:  da_cheng_s...@yeah.net
  MFC after:3 days

Modified:
  head/sys/netinet/sctp_auth.c

Modified: head/sys/netinet/sctp_auth.c
==
--- head/sys/netinet/sctp_auth.cTue Sep 17 08:09:39 2019
(r352437)
+++ head/sys/netinet/sctp_auth.cTue Sep 17 09:46:42 2019
(r352438)
@@ -523,7 +523,7 @@ sctp_insert_sharedkey(struct sctp_keyhead *shared_keys
} else if (new_skey->keyid == skey->keyid) {
/* replace the existing key */
/* verify this key *can* be replaced */
-   if ((skey->deactivated) && (skey->refcount > 1)) {
+   if ((skey->deactivated) || (skey->refcount > 1)) {
SCTPDBG(SCTP_DEBUG_AUTH1,
"can't replace shared key id %u\n",
new_skey->keyid);
___
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: r352421 - head/stand/libsa

2019-09-17 Thread Toomas Soome via svn-src-all



> On 17 Sep 2019, at 11:56, Konstantin Belousov  wrote:
> 
> On Mon, Sep 16, 2019 at 08:28:09PM +, Toomas Soome wrote:
>> Author: tsoome
>> Date: Mon Sep 16 20:28:08 2019
>> New Revision: 352421
>> URL: https://svnweb.freebsd.org/changeset/base/352421
>> 
>> Log:
>>  loader: Malloc(0) should return NULL.
>> 
>>  We really should not allocate anything with size 0.
> Why ?  This is quite unexpected from other environments, where
> malloc(0) returns unique object.
> 

Hiding bugs. And, we are not getting unique object, we are getting chunk of 
memory with payload length of 0 and the memory content depends on if head and 
tail guards are used - the chunk is with size at least MALLOCALIGN (16 or 64 
bytes) and the chunk is from random location of heap.

rgds,
toomas
___
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: r352421 - head/stand/libsa

2019-09-17 Thread Konstantin Belousov
On Mon, Sep 16, 2019 at 08:28:09PM +, Toomas Soome wrote:
> Author: tsoome
> Date: Mon Sep 16 20:28:08 2019
> New Revision: 352421
> URL: https://svnweb.freebsd.org/changeset/base/352421
> 
> Log:
>   loader: Malloc(0) should return NULL.
>   
>   We really should not allocate anything with size 0.
Why ?  This is quite unexpected from other environments, where
malloc(0) returns unique object.

> 
> Modified:
>   head/stand/libsa/zalloc_malloc.c
> 
> Modified: head/stand/libsa/zalloc_malloc.c
> ==
> --- head/stand/libsa/zalloc_malloc.c  Mon Sep 16 20:26:53 2019
> (r352420)
> +++ head/stand/libsa/zalloc_malloc.c  Mon Sep 16 20:28:08 2019
> (r352421)
> @@ -55,6 +55,9 @@ Malloc(size_t bytes, const char *file, int line)
>  {
>  Guard *res;
>  
> +if (bytes == 0)
> + return (NULL);
> +
>  #ifdef USEENDGUARD
>  bytes += MALLOCALIGN + 1;
>  #else
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r352437 - head/sys/kern

2019-09-17 Thread Mateusz Guzik
Author: mjg
Date: Tue Sep 17 08:09:39 2019
New Revision: 352437
URL: https://svnweb.freebsd.org/changeset/base/352437

Log:
  vfs: fix braino resulting in NULL pointer deref in r352424
  
  The breakage was added after all the testing and the testing which followed
  was not sufficient to find it.
  
  Reported by:  pho
  Sponsored by: The FreeBSD Foundation

Modified:
  head/sys/kern/vfs_default.c

Modified: head/sys/kern/vfs_default.c
==
--- head/sys/kern/vfs_default.c Tue Sep 17 06:08:15 2019(r352436)
+++ head/sys/kern/vfs_default.c Tue Sep 17 08:09:39 2019(r352437)
@@ -613,11 +613,13 @@ vop_stdgetwritemount(ap)
vfs_op_thread_exit(mp);
} else {
MNT_ILOCK(mp);
-   if (mp == vp->v_mount)
+   if (mp == vp->v_mount) {
MNT_REF(mp);
-   else
+   MNT_IUNLOCK(mp);
+   } else {
+   MNT_IUNLOCK(mp);
mp = NULL;
-   MNT_IUNLOCK(mp);
+   }
}
*(ap->a_mpp) = mp;
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"