svn commit: r346430 - in head/stand/efi: include libefi loader

2019-04-19 Thread Warner Losh
Author: imp
Date: Sat Apr 20 05:31:56 2019
New Revision: 346430
URL: https://svnweb.freebsd.org/changeset/base/346430

Log:
  Start to reduce the number of #ifdef EFI_ZFS_BOOT
  
  There's a number of EFI_ZFS_BOOT #ifdefs that aren't needed, or can be
  eliminated with some trivial #defines. Remove the EFI_ZFS_BOOT ifdefs
  that aren't needed. Replace libzfs.h include which is not safe to
  include without EFI_ZFS_BOOT with efizfs.h which is and now
  conditionally included libzfs.h. Define efizfs_set_preferred away
  and define efi_zfs_probe to NULL when ZFS is compiled out.

Modified:
  head/stand/efi/include/efizfs.h
  head/stand/efi/libefi/devicename.c
  head/stand/efi/loader/conf.c
  head/stand/efi/loader/main.c

Modified: head/stand/efi/include/efizfs.h
==
--- head/stand/efi/include/efizfs.h Sat Apr 20 04:16:51 2019
(r346429)
+++ head/stand/efi/include/efizfs.h Sat Apr 20 05:31:56 2019
(r346430)
@@ -33,6 +33,8 @@
 #define _EFIZFS_H_
 
 #ifdef EFI_ZFS_BOOT
+#include 
+
 typedef STAILQ_HEAD(zfsinfo_list, zfsinfo) zfsinfo_list_t;
 
 typedef struct zfsinfo
@@ -50,6 +52,9 @@ bool efizfs_get_guid_by_handle(EFI_HANDLE, uint64_t *)
 zfsinfo_list_t *efizfs_get_zfsinfo_list(void);
 void efizfs_set_preferred(EFI_HANDLE);
 
+#else
+#define efizfs_set_preferred(x)
+#define efi_zfs_probe NULL
 #endif
 
 #endif

Modified: head/stand/efi/libefi/devicename.c
==
--- head/stand/efi/libefi/devicename.c  Sat Apr 20 04:16:51 2019
(r346429)
+++ head/stand/efi/libefi/devicename.c  Sat Apr 20 05:31:56 2019
(r346430)
@@ -34,12 +34,10 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
-#ifdef EFI_ZFS_BOOT
-#include 
-#endif
 
 #include 
 #include 
+#include 
 
 static int efi_parsedev(struct devdesc **, const char *, const char **);
 

Modified: head/stand/efi/loader/conf.c
==
--- head/stand/efi/loader/conf.cSat Apr 20 04:16:51 2019
(r346429)
+++ head/stand/efi/loader/conf.cSat Apr 20 05:31:56 2019
(r346430)
@@ -31,9 +31,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
-#ifdef EFI_ZFS_BOOT
-#include 
-#endif
+#include 
 
 struct devsw *devsw[] = {
&efipart_fddev,

Modified: head/stand/efi/loader/main.c
==
--- head/stand/efi/loader/main.cSat Apr 20 04:16:51 2019
(r346429)
+++ head/stand/efi/loader/main.cSat Apr 20 05:31:56 2019
(r346430)
@@ -50,10 +50,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 
-#ifdef EFI_ZFS_BOOT
-#include 
 #include "efizfs.h"
-#endif
 
 #include "loader_efi.h"
 
@@ -763,18 +760,14 @@ main(int argc, CHAR16 *argv[])
archsw.arch_copyin = efi_copyin;
archsw.arch_copyout = efi_copyout;
archsw.arch_readin = efi_readin;
-#ifdef EFI_ZFS_BOOT
-   /* Note this needs to be set before ZFS init. */
archsw.arch_zfs_probe = efi_zfs_probe;
-#endif
 
 /* Get our loaded image protocol interface structure. */
BS->HandleProtocol(IH, &imgid, (VOID**)&img);
 
-#ifdef EFI_ZFS_BOOT
-   /* Tell ZFS probe code where we booted from */
+   /* Tell ZFS probe code where we booted from, if zfs configured */
efizfs_set_preferred(img->DeviceHandle);
-#endif
+
/* Init the time source */
efi_time_init();
 
___
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: r346429 - in stable/11: . contrib/mdocml etc/mtree lib lib/libbe rescue/rescue sbin sbin/bectl sbin/bectl/tests share/mk tools/build/mk

2019-04-19 Thread Kyle Evans
Author: kevans
Date: Sat Apr 20 04:16:51 2019
New Revision: 346429
URL: https://svnweb.freebsd.org/changeset/base/346429

Log:
  MFC bectl(8)/libbe(3): r337663-337664,337667,337697-337699,337800,337805,
  337915-337918,337921,337924,337947,337993-337995,338221-338222,338303,
  338417,339047,339972,339994,340334,340507-340508,340592-340594,
  340635-340636,340722-340723,340974,342466,342849,342903,342911,343335,
  343543,343977,343993-343994,344034,344067,344084,345302,345769,
  345845-345846,345848,346082
  
  There are simply too many small changes to enumerate; in summary:
  
  bectl(8)/libbe(3) has been introduced from current state in -CURRENT and
  added to the stable/11 rescue build. bectl(8) is a tool for managing ZFS
  boot environments, largely inspired by beadm. It includes features such as
  being able to jail a boot environment or easily mount it for modification.
  
  Relnotes: probably

Added:
  stable/11/lib/libbe/
 - copied from r337663, head/lib/libbe/
  stable/11/lib/libbe/Makefile
 - copied, changed from r337995, head/lib/libbe/Makefile
  stable/11/sbin/bectl/
 - copied from r337663, head/sbin/bectl/
  stable/11/sbin/bectl/tests/
 - copied from r340594, head/sbin/bectl/tests/
Modified:
  stable/11/Makefile.inc1
  stable/11/contrib/mdocml/lib.in
  stable/11/etc/mtree/BSD.tests.dist
  stable/11/lib/Makefile
  stable/11/lib/libbe/be.c
  stable/11/lib/libbe/be.h
  stable/11/lib/libbe/be_access.c
  stable/11/lib/libbe/be_error.c
  stable/11/lib/libbe/be_impl.h
  stable/11/lib/libbe/be_info.c
  stable/11/lib/libbe/libbe.3
  stable/11/rescue/rescue/Makefile
  stable/11/sbin/Makefile
  stable/11/sbin/bectl/Makefile
  stable/11/sbin/bectl/bectl.8
  stable/11/sbin/bectl/bectl.c
  stable/11/sbin/bectl/bectl_jail.c
  stable/11/sbin/bectl/bectl_list.c
  stable/11/sbin/bectl/tests/bectl_test.sh
  stable/11/share/mk/bsd.libnames.mk
  stable/11/share/mk/src.libnames.mk
  stable/11/tools/build/mk/OptionalObsoleteFiles.inc
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/Makefile.inc1
==
--- stable/11/Makefile.inc1 Sat Apr 20 03:21:47 2019(r346428)
+++ stable/11/Makefile.inc1 Sat Apr 20 04:16:51 2019(r346429)
@@ -2155,7 +2155,7 @@ _prebuild_libs=   ${_kerberos5_lib_libasn1} \
${_cddl_lib_libumem} ${_cddl_lib_libnvpair} \
${_cddl_lib_libuutil} \
${_cddl_lib_libavl} \
-   ${_cddl_lib_libzfs_core} \
+   ${_cddl_lib_libzfs_core} ${_cddl_lib_libzfs} \
${_cddl_lib_libctf} \
lib/libutil lib/libpjdlog ${_lib_libypclnt} lib/libz lib/msun \
${_secure_lib_libcrypto} ${_lib_libldns} \
@@ -2224,7 +2224,15 @@ _cddl_lib_libavl= cddl/lib/libavl
 _cddl_lib_libuutil= cddl/lib/libuutil
 .if ${MK_ZFS} != "no"
 _cddl_lib_libzfs_core= cddl/lib/libzfs_core
+_cddl_lib_libzfs= cddl/lib/libzfs
+
 cddl/lib/libzfs_core__L: cddl/lib/libnvpair__L
+
+cddl/lib/libzfs__L: cddl/lib/libzfs_core__L lib/msun__L lib/libutil__L
+cddl/lib/libzfs__L: lib/libthr__L lib/libmd__L lib/libz__L cddl/lib/libumem__L
+cddl/lib/libzfs__L: cddl/lib/libuutil__L cddl/lib/libavl__L lib/libgeom__L
+
+lib/libbe__L: cddl/lib/libzfs__L
 .endif
 _cddl_lib_libctf= cddl/lib/libctf
 _cddl_lib= cddl/lib

Modified: stable/11/contrib/mdocml/lib.in
==
--- stable/11/contrib/mdocml/lib.in Sat Apr 20 03:21:47 2019
(r346428)
+++ stable/11/contrib/mdocml/lib.in Sat Apr 20 04:16:51 2019
(r346429)
@@ -28,6 +28,7 @@ LINE("lib80211",  "802.11 Wireless Network Management L
 LINE("libarchive", "Streaming Archive Library (libarchive, \\-larchive)")
 LINE("libarm", "ARM Architecture Library (libarm, \\-larm)")
 LINE("libarm32",   "ARM32 Architecture Library (libarm32, \\-larm32)")
+LINE("libbe",  "Boot Environment Library (libbe, \\-lbe)")
 LINE("libbluetooth",   "Bluetooth Library (libbluetooth, \\-lbluetooth)")
 LINE("libbsm", "Basic Security Module Library (libbsm, \\-lbsm)")
 LINE("libc",   "Standard C\\~Library (libc, \\-lc)")

Modified: stable/11/etc/mtree/BSD.tests.dist
==
--- stable/11/etc/mtree/BSD.tests.dist  Sat Apr 20 03:21:47 2019
(r346428)
+++ stable/11/etc/mtree/BSD.tests.dist  Sat Apr 20 04:16:51 2019
(r346429)
@@ -380,6 +380,8 @@
 ..
 ..
 sbin
+bectl
+..
 dhclient
 ..
 devd

Modified: stable/11/lib/Makefile
==
--- stable/11/lib/Makefile  Sat Apr 20 03:21:47 2019(r346428)
+++ stable/11/lib/Makefile  Sat Apr 20 04:16:51 2019(r346429)
@@ -290,6 +290,7 @@ _libproc=   libproc
 _librtld_db=   librtld_db
 .endif
 SUBDIR.${MK_OFED

svn commit: r346428 - in head/sys: arm64/conf conf

2019-04-19 Thread Ganbold Tsagaankhuu
Author: ganbold
Date: Sat Apr 20 03:21:47 2019
New Revision: 346428
URL: https://svnweb.freebsd.org/changeset/base/346428

Log:
  Add SY8106A Buck Regulator and Allwinner CIR devices to GENERIC arm64 kernel.

Modified:
  head/sys/arm64/conf/GENERIC
  head/sys/conf/files.arm64

Modified: head/sys/arm64/conf/GENERIC
==
--- head/sys/arm64/conf/GENERIC Sat Apr 20 02:54:20 2019(r346427)
+++ head/sys/arm64/conf/GENERIC Sat Apr 20 03:21:47 2019(r346428)
@@ -233,6 +233,7 @@ device  iic
 device twsi# Allwinner I2C controller
 device rk_i2c  # RockChip I2C controller
 device syr827  # Silergy SYR827 PMIC
+device sy8106a # SY8106A Buck Regulator
 
 # Clock and reset controllers
 device aw_ccu  # Allwinner clock controller
@@ -278,6 +279,7 @@ device  vt_efifb
 device evdev   # input event device support
 optionsEVDEV_SUPPORT   # evdev support in legacy 
drivers
 device uinput  # install /dev/uinput cdev
+device aw_cir
 
 # Pseudo devices.
 device crypto  # core crypto support

Modified: head/sys/conf/files.arm64
==
--- head/sys/conf/files.arm64   Sat Apr 20 02:54:20 2019(r346427)
+++ head/sys/conf/files.arm64   Sat Apr 20 03:21:47 2019(r346428)
@@ -27,6 +27,7 @@ cloudabi64_vdso_blob.ooptional
compat_cloudabi64   \
 # Allwinner common files
 arm/allwinner/a10_ehci.c   optionalehci aw_ehci fdt
 arm/allwinner/a10_timer.c  optionala10_timer fdt
+arm/allwinner/aw_cir.c optionalevdev aw_cir fdt
 arm/allwinner/aw_gpio.coptionalgpio aw_gpio fdt
 arm/allwinner/aw_mmc.c optionalmmc aw_mmc fdt | mmccam aw_mmc 
fdt
 arm/allwinner/aw_nmi.c optionalaw_nmi fdt \
@@ -206,6 +207,7 @@ dev/axgbe/xgbe-dev.coptionalaxgbe
 dev/axgbe/xgbe-drv.c   optionalaxgbe
 dev/axgbe/xgbe-mdio.c  optionalaxgbe
 dev/cpufreq/cpufreq_dt.c   optionalcpufreq fdt
+dev/iicbus/sy8106a.c   optionalsy8106a fdt
 dev/iicbus/twsi/mv_twsi.c  optionaltwsi fdt
 dev/iicbus/twsi/a10_twsi.c optionaltwsi fdt
 dev/iicbus/twsi/twsi.c optionaltwsi fdt
___
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: r346427 - in head/usr.sbin/cron: cron crontab

2019-04-19 Thread Kyle Evans
Author: kevans
Date: Sat Apr 20 02:54:20 2019
New Revision: 346427
URL: https://svnweb.freebsd.org/changeset/base/346427

Log:
  cron(8): schedule interval jobs that get loaded during execution
  
  Jobs using the @ syntax currently only get executed if they exist
  when cron is started. The simplest reproducer of this is:
  
  echo '@20 root echo "Hello!"' >> /etc/cron.d/myjob
  
  myjob will get loaded at the next second==0, but this echo job will not
  run until cron restarts. These jobs are normally handled in
  run_reboot_jobs(), which sets e->lastexit of INTERVAL jobs to the startup
  time so they run 'n' seconds later.
  
  Fix this by special-casing TargetTime > 0 in the database load. Preexisting
  jobs will be handled at startup during run_reboot_jobs as normal, but if
  we've reloaded a database during runtime we'll hit this case and set
  e->lastexit to the current time when we process it. They will then run every
  'n' seconds from that point, and a full restart of cron is no longer
  required to make these jobs work.
  
  Reported by:  Juraj Lutter (otis_sk.freebsd.org)
  Reviewed by:  allanjude, bapt, bjk (earlier version), Juraj Lutter
  MFC after:3 days
  Differential Revision:https://reviews.freebsd.org/D19924

Modified:
  head/usr.sbin/cron/cron/database.c
  head/usr.sbin/cron/crontab/crontab.5

Modified: head/usr.sbin/cron/cron/database.c
==
--- head/usr.sbin/cron/cron/database.c  Sat Apr 20 02:44:38 2019
(r346426)
+++ head/usr.sbin/cron/cron/database.c  Sat Apr 20 02:54:20 2019
(r346427)
@@ -259,6 +259,8 @@ process_crontab(uname, fname, tabname, statbuf, new_db
struct passwd   *pw = NULL;
int crontab_fd = OK - 1;
user*u;
+   entry   *e;
+   time_t  now;
 
if (strcmp(fname, SYS_NAME) && !(pw = getpwnam(uname))) {
/* file doesn't have a user in passwd file.
@@ -307,6 +309,21 @@ process_crontab(uname, fname, tabname, statbuf, new_db
u = load_user(crontab_fd, pw, fname);
if (u != NULL) {
u->mtime = statbuf->st_mtime;
+   /*
+* TargetTime == 0 when we're initially populating the database,
+* and TargetTime > 0 any time after that (i.e. we're reloading
+* cron.d/ files because they've been created/modified).  In the
+* latter case, we should check for any interval jobs and run
+* them 'n' seconds from the time the job was loaded/reloaded.
+* Otherwise, they will not be run until cron is restarted.
+*/
+   if (TargetTime != 0) {
+   now = time(NULL);
+   for (e = u->crontab; e != NULL; e = e->next) {
+   if ((e->flags & INTERVAL) != 0)
+   e->lastexit = now;
+   }
+   }
link_user(new_db, u);
}
 

Modified: head/usr.sbin/cron/crontab/crontab.5
==
--- head/usr.sbin/cron/crontab/crontab.5Sat Apr 20 02:44:38 2019
(r346426)
+++ head/usr.sbin/cron/crontab/crontab.5Sat Apr 20 02:54:20 2019
(r346427)
@@ -17,7 +17,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd April 15, 2019
+.Dd April 19, 2019
 .Dt CRONTAB 5
 .Os
 .Sh NAME
@@ -245,12 +245,14 @@ stringmeaning
 The
 .Sq @
 symbol followed by a numeric value has a special notion of running
-a job that much seconds after completion of previous invocation of
+a job that many seconds after completion of the previous invocation of
 the job.
 Unlike regular syntax, it guarantees not to overlap two or more
-invocations of the same job.
-The first run is scheduled specified amount of seconds after cron
-has started.
+invocations of the same job during normal cron execution.
+Note, however, that overlap may occur if the job is running when the file
+containing the job is modified and subsequently reloaded.
+The first run is scheduled for the specified number of seconds after cron
+is started or the crontab entry is reloaded.
 .Sh EXAMPLE CRON FILE
 .Bd -literal
 
___
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: r346426 - head/sys/powerpc/powernv

2019-04-19 Thread Justin Hibbits
Author: jhibbits
Date: Sat Apr 20 02:44:38 2019
New Revision: 346426
URL: https://svnweb.freebsd.org/changeset/base/346426

Log:
  powerpc64/powernv: Relax flash block write requirements
  
  Since writes don't necessarily need to be on erase-block boundaries, we can
  relax the block size and alignments down to sector size.  If it needs to be
  erased, opalflash_erase() will check proper alignment and size.

Modified:
  head/sys/powerpc/powernv/opal_flash.c

Modified: head/sys/powerpc/powernv/opal_flash.c
==
--- head/sys/powerpc/powernv/opal_flash.c   Sat Apr 20 00:04:31 2019
(r346425)
+++ head/sys/powerpc/powernv/opal_flash.c   Sat Apr 20 02:44:38 2019
(r346426)
@@ -239,8 +239,8 @@ opalflash_write(struct opalflash_softc *sc, off_t off,
int rv, size, token;
 
/* Ensure we write aligned to a full block size. */
-   if (off % sc->sc_disk->d_stripesize != 0 ||
-   count % sc->sc_disk->d_stripesize != 0)
+   if (off % sc->sc_disk->d_sectorsize != 0 ||
+   count % sc->sc_disk->d_sectorsize != 0)
return (EIO);
 
if (sc->sc_erase) {
___
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: r346424 - in head/sys/fs: nfs nfsserver

2019-04-19 Thread Rick Macklem
Author: rmacklem
Date: Fri Apr 19 23:35:08 2019
New Revision: 346424
URL: https://svnweb.freebsd.org/changeset/base/346424

Log:
  Add support for the ModeSetMasked attribute to the NFSv4.1 server.
  
  I do not know of an extant NFSv4.1 client that currently does a Setattr
  operation for the ModeSetMasked, but it has been discussed on the linux-nfs
  mailing list.
  This patch adds support for doing a Setattr of ModeSetMasked, so that it
  will work for any future NFSv4.1 client that chooses to do so.
  Tested via a hacked FreeBSD NFSv4.1 client.
  
  MFC after:2 weeks

Modified:
  head/sys/fs/nfs/nfsproto.h
  head/sys/fs/nfsserver/nfs_nfsdport.c
  head/sys/fs/nfsserver/nfs_nfsdserv.c

Modified: head/sys/fs/nfs/nfsproto.h
==
--- head/sys/fs/nfs/nfsproto.h  Fri Apr 19 23:27:23 2019(r346423)
+++ head/sys/fs/nfs/nfsproto.h  Fri Apr 19 23:35:08 2019(r346424)
@@ -1090,7 +1090,7 @@ struct nfsv3_sattr {
  */
 #defineNFSATTRBIT_SUPPSETONLY1  (NFSATTRBM_TIMEACCESSSET | 
\
 NFSATTRBM_TIMEMODIFYSET)
-#defineNFSATTRBIT_SUPPSETONLY2 0
+#defineNFSATTRBIT_SUPPSETONLY2 (NFSATTRBM_MODESETMASKED)
 
 /*
  * NFSATTRBIT_SETABLE - SETABLE0 - bits 0<->31
@@ -1106,7 +1106,8 @@ struct nfsv3_sattr {
NFSATTRBM_OWNERGROUP |  \
NFSATTRBM_TIMEACCESSSET |   \
NFSATTRBM_TIMEMODIFYSET)
-#defineNFSATTRBIT_SETABLE2 0
+#defineNFSATTRBIT_SETABLE2 
\
+   (NFSATTRBM_MODESETMASKED)
 
 /*
  * NFSATTRBIT_NFSV41 - Attributes only supported by NFSv4.1.

Modified: head/sys/fs/nfsserver/nfs_nfsdport.c
==
--- head/sys/fs/nfsserver/nfs_nfsdport.cFri Apr 19 23:27:23 2019
(r346423)
+++ head/sys/fs/nfsserver/nfs_nfsdport.cFri Apr 19 23:35:08 2019
(r346424)
@@ -2699,10 +2699,12 @@ nfsv4_sattr(struct nfsrv_descript *nd, vnode_t vp, str
int attrsum = 0;
int i, j;
int error, attrsize, bitpos, aclsize, aceerr, retnotsup = 0;
-   int toclient = 0;
+   int moderet, toclient = 0;
u_char *cp, namestr[NFSV4_SMALLSTR + 1];
uid_t uid;
gid_t gid;
+   u_short mode, mask; /* Same type as va_mode. */
+   struct vattr va;
 
error = nfsrv_getattrbits(nd, attrbitp, NULL, &retnotsup);
if (error)
@@ -2720,6 +2722,7 @@ nfsv4_sattr(struct nfsrv_descript *nd, vnode_t vp, str
} else {
bitpos = 0;
}
+   moderet = 0;
for (; bitpos < NFSATTRBIT_MAX; bitpos++) {
if (attrsum > attrsize) {
error = NFSERR_BADXDR;
@@ -2769,6 +2772,7 @@ nfsv4_sattr(struct nfsrv_descript *nd, vnode_t vp, str
attrsum += (NFSX_UNSIGNED + NFSM_RNDUP(i));
break;
case NFSATTRBIT_MODE:
+   moderet = NFSERR_INVAL; /* Can't do MODESETMASKED. */
NFSM_DISSECT(tl, u_int32_t *, NFSX_UNSIGNED);
nvap->na_mode = nfstov_mode(*tl);
attrsum += NFSX_UNSIGNED;
@@ -2871,6 +2875,32 @@ nfsv4_sattr(struct nfsrv_descript *nd, vnode_t vp, str
if (!toclient)
nvap->na_vaflags |= VA_UTIMES_NULL;
}
+   break;
+   case NFSATTRBIT_MODESETMASKED:
+   NFSM_DISSECT(tl, uint32_t *, 2 * NFSX_UNSIGNED);
+   mode = fxdr_unsigned(u_short, *tl++);
+   mask = fxdr_unsigned(u_short, *tl);
+   /*
+* vp == NULL implies an Open/Create operation.
+* This attribute can only be used for Setattr and
+* only for NFSv4.1 or higher.
+* If moderet != 0, a mode attribute has also been
+* specified and this attribute cannot be done in the
+* same Setattr operation.
+*/
+   if ((nd->nd_flag & ND_NFSV41) == 0)
+   nd->nd_repstat = NFSERR_ATTRNOTSUPP;
+   else if ((mode & ~0) != 0 || (mask & ~0) != 0 ||
+   vp == NULL)
+   nd->nd_repstat = NFSERR_INVAL;
+   else if (moderet == 0)
+   moderet = VOP_GETATTR(vp, &va, nd->nd_cred);
+   if (moderet == 0)
+   nvap->na_mode = (mode & mask) |
+   (va.va_mode & ~mask);
+   else
+   nd->nd_repstat = moderet;
+ 

svn commit: r346423 - head/sys/fs/nfsserver

2019-04-19 Thread Rick Macklem
Author: rmacklem
Date: Fri Apr 19 23:27:23 2019
New Revision: 346423
URL: https://svnweb.freebsd.org/changeset/base/346423

Log:
  Replace "vp" with NULL to make the code more readable.
  
  At the time of this nfsv4_sattr() call, "vp == NULL", so this patch doesn't
  change the semantics, but I think it makes the code more readable.
  It also makes it consistent with the nfsv4_sattr() call a few lines above
  this one. Found during code inspection.
  
  MFC after:2 weeks

Modified:
  head/sys/fs/nfsserver/nfs_nfsdserv.c

Modified: head/sys/fs/nfsserver/nfs_nfsdserv.c
==
--- head/sys/fs/nfsserver/nfs_nfsdserv.cFri Apr 19 23:04:07 2019
(r346422)
+++ head/sys/fs/nfsserver/nfs_nfsdserv.cFri Apr 19 23:27:23 2019
(r346423)
@@ -2886,7 +2886,7 @@ nfsrvd_open(struct nfsrv_descript *nd, __unused int is
NFSM_DISSECT(tl, u_int32_t *, NFSX_VERF);
cverf[0] = *tl++;
cverf[1] = *tl;
-   error = nfsv4_sattr(nd, vp, &nva, &attrbits, aclp, p);
+   error = nfsv4_sattr(nd, NULL, &nva, &attrbits, aclp, p);
if (error != 0)
goto nfsmout;
if (NFSISSET_ATTRBIT(&attrbits,
___
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: r346421 - head/tests/sys/opencrypto

2019-04-19 Thread John Baldwin
Author: jhb
Date: Fri Apr 19 22:20:42 2019
New Revision: 346421
URL: https://svnweb.freebsd.org/changeset/base/346421

Log:
  Test SHA2-224-HMAC now that OCF supports it.
  
  Reviewed by:  cem
  MFC after:2 weeks
  Sponsored by: Chelsio Communications
  Differential Revision:https://reviews.freebsd.org/D19882

Modified:
  head/tests/sys/opencrypto/cryptotest.py

Modified: head/tests/sys/opencrypto/cryptotest.py
==
--- head/tests/sys/opencrypto/cryptotest.py Fri Apr 19 22:08:17 2019
(r346420)
+++ head/tests/sys/opencrypto/cryptotest.py Fri Apr 19 22:20:42 2019
(r346421)
@@ -279,11 +279,8 @@ def GenTestCase(cname):
alg = cryptodev.CRYPTO_SHA1_HMAC
blocksize = 64
elif hashlen == 28:
-   # Cryptodev doesn't support SHA-224
-   # Slurp remaining input in section
-   for data in lines:
-   continue
-   continue
+   alg = cryptodev.CRYPTO_SHA2_224_HMAC
+   blocksize = 64
elif hashlen == 32:
alg = cryptodev.CRYPTO_SHA2_256_HMAC
blocksize = 64
___
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: r346420 - in head: lib/libc/gen share/man/man9 sys/conf sys/libkern sys/sys

2019-04-19 Thread Conrad Meyer
Author: cem
Date: Fri Apr 19 22:08:17 2019
New Revision: 346420
URL: https://svnweb.freebsd.org/changeset/base/346420

Log:
  Revert r346410 and r346411
  
  libkern in .PATH has too many filename conflicts with libc and my -DNO_CLEAN
  tinderbox didn't catch that ahead of time.  Mea culpa.

Added:
  head/lib/libc/gen/arc4random_uniform.c
 - copied unchanged from r346409, head/lib/libc/gen/arc4random_uniform.c
Deleted:
  head/sys/libkern/arc4random_uniform.c
Modified:
  head/lib/libc/gen/Makefile.inc
  head/share/man/man9/Makefile
  head/share/man/man9/random.9
  head/sys/conf/files
  head/sys/sys/libkern.h
  head/sys/sys/param.h

Modified: head/lib/libc/gen/Makefile.inc
==
--- head/lib/libc/gen/Makefile.inc  Fri Apr 19 21:58:51 2019
(r346419)
+++ head/lib/libc/gen/Makefile.inc  Fri Apr 19 22:08:17 2019
(r346420)
@@ -3,7 +3,6 @@
 
 # machine-independent gen sources
 .PATH: ${LIBC_SRCTOP}/${LIBC_ARCH}/gen ${LIBC_SRCTOP}/gen
-.PATH: ${SRCTOP}/sys/libkern
 
 CONFS= shells
 

Copied: head/lib/libc/gen/arc4random_uniform.c (from r346409, 
head/lib/libc/gen/arc4random_uniform.c)
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/lib/libc/gen/arc4random_uniform.c  Fri Apr 19 22:08:17 2019
(r346420, copy of r346409, head/lib/libc/gen/arc4random_uniform.c)
@@ -0,0 +1,58 @@
+/* $OpenBSD: arc4random_uniform.c,v 1.2 2015/09/13 08:31:47 guenther Exp $ 
*/
+
+/*
+ * Copyright (c) 2008, Damien Miller 
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * $FreeBSD$
+ */
+
+#include 
+#include 
+
+/*
+ * Calculate a uniformly distributed random number less than upper_bound
+ * avoiding "modulo bias".
+ *
+ * Uniformity is achieved by generating new random numbers until the one
+ * returned is outside the range [0, 2**32 % upper_bound).  This
+ * guarantees the selected random number will be inside
+ * [2**32 % upper_bound, 2**32) which maps back to [0, upper_bound)
+ * after reduction modulo upper_bound.
+ */
+uint32_t
+arc4random_uniform(uint32_t upper_bound)
+{
+   uint32_t r, min;
+
+   if (upper_bound < 2)
+   return 0;
+
+   /* 2**32 % x == (2**32 - x) % x */
+   min = -upper_bound % upper_bound;
+
+   /*
+* This could theoretically loop forever but each retry has
+* p > 0.5 (worst case, usually far better) of selecting a
+* number inside the range we need, so it should rarely need
+* to re-roll.
+*/
+   for (;;) {
+   r = arc4random();
+   if (r >= min)
+   break;
+   }
+
+   return r % upper_bound;
+}

Modified: head/share/man/man9/Makefile
==
--- head/share/man/man9/MakefileFri Apr 19 21:58:51 2019
(r346419)
+++ head/share/man/man9/MakefileFri Apr 19 22:08:17 2019
(r346420)
@@ -1668,8 +1668,6 @@ MLINKS+=psignal.9 gsignal.9 \
psignal.9 tdsignal.9
 MLINKS+=random.9 arc4rand.9 \
random.9 arc4random.9 \
-   random.9 arc4random_buf.9 \
-   random.9 arc4random_uniform.9 \
random.9 is_random_seeded.9 \
random.9 read_random.9 \
random.9 read_random_uio.9 \

Modified: head/share/man/man9/random.9
==
--- head/share/man/man9/random.9Fri Apr 19 21:58:51 2019
(r346419)
+++ head/share/man/man9/random.9Fri Apr 19 22:08:17 2019
(r346420)
@@ -26,7 +26,7 @@
 .\"
 .\" $FreeBSD$
 .\" "
-.Dd April 19, 2019
+.Dd April 16, 2019
 .Dt RANDOM 9
 .Os
 .Sh NAME
@@ -45,8 +45,6 @@
 .Fn arc4random "void"
 .Ft void
 .Fn arc4random_buf "void *ptr" "size_t len"
-.Ft uint32_t
-.Fn arc4random_uniform "uint32_t upper_bound"
 .Ft void
 .Fn arc4rand "void *ptr" "u_int length" "int reseed"
 .Pp
@@ -81,15 +79,6 @@ fills
 with
 .Fa len
 bytes of random data.
-.Pp
-.Fn arc4random_uniform
-will return a single 32-bit value, uniformly distributed but less than
-.Fa upper_bound .
-This is recommended over constructions like
-.Dq Li arc4random() % upper_bound
-as it avoids 

svn commit: r346419 - head/tests/sys/opencrypto

2019-04-19 Thread John Baldwin
Author: jhb
Date: Fri Apr 19 21:58:51 2019
New Revision: 346419
URL: https://svnweb.freebsd.org/changeset/base/346419

Log:
  Sync cryptographic algorithm constants with current cryptodev.h.
  
  Reviewed by:  cem
  MFC after:2 weeks
  Sponsored by: Chelsio Communications
  Differential Revision:https://reviews.freebsd.org/D19881

Modified:
  head/tests/sys/opencrypto/cryptodevh.py

Modified: head/tests/sys/opencrypto/cryptodevh.py
==
--- head/tests/sys/opencrypto/cryptodevh.py Fri Apr 19 21:50:23 2019
(r346418)
+++ head/tests/sys/opencrypto/cryptodevh.py Fri Apr 19 21:58:51 2019
(r346419)
@@ -197,7 +197,19 @@ CRYPTO_AES_NIST_GCM_16 = 25
 CRYPTO_AES_128_NIST_GMAC = 26
 CRYPTO_AES_192_NIST_GMAC = 27
 CRYPTO_AES_256_NIST_GMAC = 28
-CRYPTO_ALGORITHM_MAX = 28
+CRYPTO_BLAKE2B = 29
+CRYPTO_BLAKE2S = 30
+CRYPTO_CHACHA20 = 31
+CRYPTO_SHA2_224_HMAC = 32
+CRYPTO_RIPEMD160 = 33
+CRYPTO_SHA2_224 = 34
+CRYPTO_SHA2_256 = 35
+CRYPTO_SHA2_384 = 36
+CRYPTO_SHA2_512 = 37
+CRYPTO_POLY1305 = 38
+CRYPTO_AES_CCM_CBC_MAC = 39
+CRYPTO_AES_CCM_16 = 40
+CRYPTO_ALGORITHM_MAX = 40
 CRYPTO_ALG_FLAG_SUPPORTED = 0x01
 CRYPTO_ALG_FLAG_RNG_ENABLE = 0x02
 CRYPTO_ALG_FLAG_DSA_SHA = 0x04
___
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: r346410 - in head: lib/libc/gen share/man/man9 sys/conf sys/libkern sys/sys

2019-04-19 Thread Charlie Li via svn-src-all
O. Hartmann wrote:
> Am Fri, 19 Apr 2019 20:05:48 + (UTC) Conrad Meyer schrieb:
>> Modified: head/lib/libc/gen/Makefile.inc
>> ==
>> --- head/lib/libc/gen/Makefile.inc   Fri Apr 19 19:45:19 2019
>> (r346409)
>> +++ head/lib/libc/gen/Makefile.inc   Fri Apr 19 20:05:47 2019
>> (r346410)
>> @@ -3,6 +3,7 @@
> 
>>  # machine-independent gen sources
>>  .PATH: ${LIBC_SRCTOP}/${LIBC_ARCH}/gen ${LIBC_SRCTOP}/gen
>> +.PATH: ${SRCTOP}/sys/libkern
> 
>>  CONFS=  shells
> 
> 
> After applying r346410 to our source tree, buildworld fails (WITH_META_MODE 
> is set):
> 
> [...]
> Building /usr/obj/usr/src/amd64.amd64/lib/libc/ev_timers.o
> --- inet_ntoa.o ---
> In file included from /usr/src/sys/libkern/inet_ntoa.c:34:
> /usr/obj/usr/src/amd64.amd64/tmp/usr/include/sys/systm.h:172:8: error: 
> unknown type name 'bool'
> extern bool dynamic_kenv;
>^
> /usr/obj/usr/src/amd64.amd64/tmp/usr/include/sys/systm.h:211:5: warning: 
> declaration of
> built-in function 'setjmp' requires inclusion of the header 
> [-Wbuiltin-requires-header] int setjmp(struct _jmp_buf *) 
> __returns_twice; ^
> /usr/obj/usr/src/amd64.amd64/tmp/usr/include/sys/systm.h:212:6: warning: 
> declaration of
> built-in function 'longjmp' requires inclusion of the header 
> [-Wbuiltin-requires-header] voidlongjmp(struct _jmp_buf *, int) __dead2; ^
> /usr/obj/usr/src/amd64.amd64/tmp/usr/include/sys/systm.h:285:6: warning: 
> incompatible
> redeclaration of library function 'log' 
> [-Wincompatible-library-redeclaration] void
> log(int, const char *, ...) __printflike(2, 3); ^
> /usr/obj/usr/src/amd64.amd64/tmp/usr/include/sys/systm.h:285:6: note: 'log' 
> is a builtin with
> type 'double (double)' 
> /usr/obj/usr/src/amd64.amd64/tmp/usr/include/sys/systm.h:382:39: error:
> unknown type name 'uintfptr_t'; did you mean 'uintptr_t'? void
> profclock(int cnt, int
> usermode, uintfptr_t pc); ^
> /usr/obj/usr/src/amd64.amd64/tmp/usr/include/sys/_stdint.h:80:22: note: 
> 'uintptr_t' declared
> here typedef __uintptr_t uintptr_t;
> 
> 
> Is there an include missing?
> Beat me to the initial email. With the specific file change quoted
above, looks like inet_*.c are getting pulled from sys/libkern instead
of the proper lib/libc/inet.

-- 
Charlie Li
…nope, still don't have an exit line.

(This email address is for mailing list use; replace local-part with
vishwin for off-list communication if possible)



signature.asc
Description: OpenPGP digital signature


Re: svn commit: r346410 - in head: lib/libc/gen share/man/man9 sys/conf sys/libkern sys/sys

2019-04-19 Thread O. Hartmann
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA256

Am Fri, 19 Apr 2019 20:05:48 + (UTC)
Conrad Meyer  schrieb:

> Author: cem
> Date: Fri Apr 19 20:05:47 2019
> New Revision: 346410
> URL: https://svnweb.freebsd.org/changeset/base/346410
> 
> Log:
>   libkern: Bring in arc4random_uniform(9) from libc
>   
>   It is a useful arc4random wrapper in the kernel for much the same reasons as
>   in userspace.  Move the source to libkern (because kernel build is
>   restricted to sys/, but userspace can include any file it likes) and build
>   kernel and libc versions from the same source file.
>   
>   Copy the documentation from arc4random_uniform(3) to the section 9 page.
>   
>   While here, add missing arc4random_buf(9) symlink.
>   
>   Sponsored by:   Dell EMC Isilon
> 
> Added:
>   head/sys/libkern/arc4random_uniform.c
>  - copied, changed from r346409, head/lib/libc/gen/arc4random_uniform.c
> Deleted:
>   head/lib/libc/gen/arc4random_uniform.c
> Modified:
>   head/lib/libc/gen/Makefile.inc
>   head/share/man/man9/Makefile
>   head/share/man/man9/random.9
>   head/sys/conf/files
>   head/sys/sys/libkern.h
> 
> Modified: head/lib/libc/gen/Makefile.inc
> ==
> --- head/lib/libc/gen/Makefile.incFri Apr 19 19:45:19 2019
> (r346409)
> +++ head/lib/libc/gen/Makefile.incFri Apr 19 20:05:47 2019
> (r346410)
> @@ -3,6 +3,7 @@
>  
>  # machine-independent gen sources
>  .PATH: ${LIBC_SRCTOP}/${LIBC_ARCH}/gen ${LIBC_SRCTOP}/gen
> +.PATH: ${SRCTOP}/sys/libkern
>  
>  CONFS=   shells
>  
> 
> Modified: head/share/man/man9/Makefile
> ==
> --- head/share/man/man9/Makefile  Fri Apr 19 19:45:19 2019
> (r346409)
> +++ head/share/man/man9/Makefile  Fri Apr 19 20:05:47 2019
> (r346410)
> @@ -1668,6 +1668,8 @@ MLINKS+=psignal.9 gsignal.9 \
>   psignal.9 tdsignal.9
>  MLINKS+=random.9 arc4rand.9 \
>   random.9 arc4random.9 \
> + random.9 arc4random_buf.9 \
> + random.9 arc4random_uniform.9 \
>   random.9 is_random_seeded.9 \
>   random.9 read_random.9 \
>   random.9 read_random_uio.9 \
> 
> Modified: head/share/man/man9/random.9
> ==
> --- head/share/man/man9/random.9  Fri Apr 19 19:45:19 2019
> (r346409)
> +++ head/share/man/man9/random.9  Fri Apr 19 20:05:47 2019
> (r346410)
> @@ -26,7 +26,7 @@
>  .\"
>  .\" $FreeBSD$
>  .\" "
> -.Dd April 16, 2019
> +.Dd April 19, 2019
>  .Dt RANDOM 9
>  .Os
>  .Sh NAME
> @@ -45,6 +45,8 @@
>  .Fn arc4random "void"
>  .Ft void
>  .Fn arc4random_buf "void *ptr" "size_t len"
> +.Ft uint32_t
> +.Fn arc4random_uniform "uint32_t upper_bound"
>  .Ft void
>  .Fn arc4rand "void *ptr" "u_int length" "int reseed"
>  .Pp
> @@ -79,6 +81,15 @@ fills
>  with
>  .Fa len
>  bytes of random data.
> +.Pp
> +.Fn arc4random_uniform
> +will return a single 32-bit value, uniformly distributed but less than
> +.Fa upper_bound .
> +This is recommended over constructions like
> +.Dq Li arc4random() % upper_bound
> +as it avoids "modulo bias" when the upper bound is not a power of two.
> +In the worst case, this function may consume multiple iterations
> +to ensure uniformity.
>  .Pp
>  The
>  .Fn arc4rand
> 
> Modified: head/sys/conf/files
> ==
> --- head/sys/conf/files   Fri Apr 19 19:45:19 2019(r346409)
> +++ head/sys/conf/files   Fri Apr 19 20:05:47 2019(r346410)
> @@ -3985,6 +3985,7 @@ kgssapi/gsstest.c   optional kgssapi_debug
>  # the file should be moved to conf/files. from here.
>  #
>  libkern/arc4random.c standard
> +libkern/arc4random_uniform.c standard
>  crypto/chacha20/chacha.c standard
>  libkern/asprintf.c   standard
>  libkern/bcd.cstandard
> 
> Copied and modified: head/sys/libkern/arc4random_uniform.c (from r346409,
> head/lib/libc/gen/arc4random_uniform.c)
> ==
>  ---
> head/lib/libc/gen/arc4random_uniform.cFri Apr 19 19:45:19 2019
> (r346409, copy
> source) +++ head/sys/libkern/arc4random_uniform.c Fri Apr 19 20:05:47 2019
> (r346410) @@ -19,7 +19,11 @@ */
>  
>  #include 
> +#ifdef _KERNEL
> +#include 
> +#else
>  #include 
> +#endif
>  
>  /*
>   * Calculate a uniformly distributed random number less than upper_bound
> 
> Modified: head/sys/sys/libkern.h
> ==
> --- head/sys/sys/libkern.hFri Apr 19 19:45:19 2019(r346409)
> +++ head/sys/sys/libkern.hFri Apr 19 20:05:47 2019(r346410)
> @@ -128,6 +128,7 @@ struct malloc_type;
>  uint32_t arc4random(void);
>  void  arc4random_buf(void *, size_t);
>  void  arc4rand(void 

svn commit: r346416 - head/lib/libvgl

2019-04-19 Thread Bruce Evans
Author: bde
Date: Fri Apr 19 20:29:49 2019
New Revision: 346416
URL: https://svnweb.freebsd.org/changeset/base/346416

Log:
  Fix copying of overlapping bitmaps.  The cases of copying within the
  screen bitmap and within a single MEMBUF were broken when first source
  line is before the first destination line and the sub-bitmaps overlap.
  
  The fix just copies horizontal lines in reverse order when the first
  source line is before the first destination line.  This switches
  directions unnecessarily in some cases, but the switch is about as
  fast as doing a precise detection of overlaps.  When the first lines
  are the same, there can be undetected overlap in the horizontal
  direction.  The old code already handles this mostly accidentally by
  using bcopy() for MEMBUFs and by copying through a temporary buffer
  for the screen bitmap although the latter is sub-optimal in direct
  modes.

Modified:
  head/lib/libvgl/bitmap.c

Modified: head/lib/libvgl/bitmap.c
==
--- head/lib/libvgl/bitmap.cFri Apr 19 20:23:39 2019(r346415)
+++ head/lib/libvgl/bitmap.cFri Apr 19 20:29:49 2019(r346416)
@@ -269,7 +269,7 @@ int
 __VGLBitmapCopy(VGLBitmap *src, int srcx, int srcy,
  VGLBitmap *dst, int dstx, int dsty, int width, int hight)
 {
-  int srcline, dstline;
+  int srcline, dstline, yend, yextra, ystep;
 
   if (srcx>src->VXsize || srcy>src->VYsize
|| dstx>dst->VXsize || dsty>dst->VYsize)
@@ -296,8 +296,17 @@ __VGLBitmapCopy(VGLBitmap *src, int srcx, int srcy,
  hight=dst->VYsize-dsty;
   if (width < 0 || hight < 0)
  return -1;
+  yend = srcy + hight;
+  yextra = 0;
+  ystep = 1;
+  if (src->Bitmap == dst->Bitmap && srcy < dsty) {
+yend = srcy;
+yextra = hight - 1;
+ystep = -1;
+  }
   if (src->Type == MEMBUF) {
-for (srcline=srcy, dstline=dsty; srclineBitmap+(srcline*src->VXsize+srcx)*dst->PixelBytes);
 }
@@ -319,7 +328,8 @@ __VGLBitmapCopy(VGLBitmap *src, int srcx, int srcy,
 } else {
   p = buffer;
 }
-for (srcline=srcy, dstline=dsty; srclinehttps://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r346415 - stable/11/sys/cam/scsi

2019-04-19 Thread Warner Losh
Author: imp
Date: Fri Apr 19 20:23:39 2019
New Revision: 346415
URL: https://svnweb.freebsd.org/changeset/base/346415

Log:
  MFC: 342657, 345025
  
  Quirks for Chipfancier chips. Their READ CAPACITY 10 and READ CAPACITY
  16 values differ, and the default of using RC16   gets the improper one.
  
  PR:   234503

Modified:
  stable/11/sys/cam/scsi/scsi_da.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/cam/scsi/scsi_da.c
==
--- stable/11/sys/cam/scsi/scsi_da.cFri Apr 19 20:22:21 2019
(r346414)
+++ stable/11/sys/cam/scsi/scsi_da.cFri Apr 19 20:23:39 2019
(r346415)
@@ -836,6 +836,15 @@ static struct da_quirk_entry da_quirk_table[] =
{T_DIRECT, SIP_MEDIA_REMOVABLE, "I-O DATA", "USB Flash Disk*",
 "*"}, /*quirks*/ DA_Q_NO_RC16
},
+   {
+   /*
+* SLC CHIPFANCIER USB drives
+* PR: usb/234503 (RC10 right, RC16 wrong)
+* 16GB, 32GB and 128GB confirmed to have same issue
+*/
+   {T_DIRECT, SIP_MEDIA_REMOVABLE, "*SLC", "CHIPFANCIER",
+"*"}, /*quirks*/ DA_Q_NO_RC16
+   },
/* ATA/SATA devices over SAS/USB/... */
{
/* Hitachi Advanced Format (4k) drives */
___
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: r346414 - stable/12/sys/cam/scsi

2019-04-19 Thread Warner Losh
Author: imp
Date: Fri Apr 19 20:22:21 2019
New Revision: 346414
URL: https://svnweb.freebsd.org/changeset/base/346414

Log:
  MFC: 342657, 345025
  
  Quirks for Chipfancier chips. Their READ CAPACITY 10 and READ CAPACITY
  16 values differ, and the default of using RC16 gets the improper one.

Modified:
  stable/12/sys/cam/scsi/scsi_da.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/cam/scsi/scsi_da.c
==
--- stable/12/sys/cam/scsi/scsi_da.cFri Apr 19 20:09:13 2019
(r346413)
+++ stable/12/sys/cam/scsi/scsi_da.cFri Apr 19 20:22:21 2019
(r346414)
@@ -858,6 +858,15 @@ static struct da_quirk_entry da_quirk_table[] =
{T_DIRECT, SIP_MEDIA_REMOVABLE, "I-O DATA", "USB Flash Disk*",
 "*"}, /*quirks*/ DA_Q_NO_RC16
},
+   {
+   /*
+* SLC CHIPFANCIER USB drives
+* PR: usb/234503 (RC10 right, RC16 wrong)
+* 16GB, 32GB and 128GB confirmed to have same issue
+*/
+   {T_DIRECT, SIP_MEDIA_REMOVABLE, "*SLC", "CHIPFANCIER",
+"*"}, /*quirks*/ DA_Q_NO_RC16
+   },
/* ATA/SATA devices over SAS/USB/... */
{
/* Hitachi Advanced Format (4k) drives */
___
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: r346413 - stable/11/lib/clang/libllvm

2019-04-19 Thread Dimitry Andric
Author: dim
Date: Fri Apr 19 20:09:13 2019
New Revision: 346413
URL: https://svnweb.freebsd.org/changeset/base/346413

Log:
  Fix minor mismerge in r346296, where one file for the LLVM BPF target
  was missing.  This would lead to link errors when attempting to build
  clang and llvm executables.
  
  Direct commit to stable/11, since head and stable/12 have correct
  libllvm Makefiles.

Modified:
  stable/11/lib/clang/libllvm/Makefile

Modified: stable/11/lib/clang/libllvm/Makefile
==
--- stable/11/lib/clang/libllvm/MakefileFri Apr 19 20:08:45 2019
(r346412)
+++ stable/11/lib/clang/libllvm/MakefileFri Apr 19 20:09:13 2019
(r346413)
@@ -1014,6 +1014,7 @@ SRCS_MIN+=Target/BPF/BPFMCInstLower.cpp
 SRCS_MIN+= Target/BPF/BPFMIChecking.cpp
 SRCS_MIN+= Target/BPF/BPFMIPeephole.cpp
 SRCS_MIN+= Target/BPF/BPFRegisterInfo.cpp
+SRCS_MIN+= Target/BPF/BPFSelectionDAGInfo.cpp
 SRCS_MIN+= Target/BPF/BPFSubtarget.cpp
 SRCS_MIN+= Target/BPF/BPFTargetMachine.cpp
 SRCS_MIN+= Target/BPF/BTFDebug.cpp
___
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: r346412 - head/sys/conf

2019-04-19 Thread Conrad Meyer
Author: cem
Date: Fri Apr 19 20:08:45 2019
New Revision: 346412
URL: https://svnweb.freebsd.org/changeset/base/346412

Log:
  kernel build: Disable unhelpful GCC warning (tripped after r346352)
  
  -Wformat-zero-length does not highlight any particularly wrong code and it
  is especially meaningless for device_printf().  Turn it off entirely to
  remove a source of false positives.
  
  Sponsored by: Dell EMC Isilon

Modified:
  head/sys/conf/kern.mk

Modified: head/sys/conf/kern.mk
==
--- head/sys/conf/kern.mk   Fri Apr 19 20:06:22 2019(r346411)
+++ head/sys/conf/kern.mk   Fri Apr 19 20:08:45 2019(r346412)
@@ -61,7 +61,8 @@ CWARNEXTRA?=  -Wno-error=address  
\
 CWARNEXTRA+=   -Wno-error=misleading-indentation   \
-Wno-error=nonnull-compare  \
-Wno-error=shift-overflow   \
-   -Wno-error=tautological-compare
+   -Wno-error=tautological-compare \
+   -Wno-format-zero-length
 .endif
 .if ${COMPILER_VERSION} >= 70200
 CWARNEXTRA+=   -Wno-error=memset-elt-size
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r346411 - head/sys/sys

2019-04-19 Thread Conrad Meyer
Author: cem
Date: Fri Apr 19 20:06:22 2019
New Revision: 346411
URL: https://svnweb.freebsd.org/changeset/base/346411

Log:
  Bump __FreeBSD_version after r346410

Modified:
  head/sys/sys/param.h

Modified: head/sys/sys/param.h
==
--- head/sys/sys/param.hFri Apr 19 20:05:47 2019(r346410)
+++ head/sys/sys/param.hFri Apr 19 20:06:22 2019(r346411)
@@ -60,7 +60,7 @@
  * in the range 5 to 9.
  */
 #undef __FreeBSD_version
-#define __FreeBSD_version 1300020  /* Master, propagated to newvers */
+#define __FreeBSD_version 1300021  /* Master, propagated to newvers */
 
 /*
  * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD,
___
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: r346410 - in head: lib/libc/gen share/man/man9 sys/conf sys/libkern sys/sys

2019-04-19 Thread Conrad Meyer
Author: cem
Date: Fri Apr 19 20:05:47 2019
New Revision: 346410
URL: https://svnweb.freebsd.org/changeset/base/346410

Log:
  libkern: Bring in arc4random_uniform(9) from libc
  
  It is a useful arc4random wrapper in the kernel for much the same reasons as
  in userspace.  Move the source to libkern (because kernel build is
  restricted to sys/, but userspace can include any file it likes) and build
  kernel and libc versions from the same source file.
  
  Copy the documentation from arc4random_uniform(3) to the section 9 page.
  
  While here, add missing arc4random_buf(9) symlink.
  
  Sponsored by: Dell EMC Isilon

Added:
  head/sys/libkern/arc4random_uniform.c
 - copied, changed from r346409, head/lib/libc/gen/arc4random_uniform.c
Deleted:
  head/lib/libc/gen/arc4random_uniform.c
Modified:
  head/lib/libc/gen/Makefile.inc
  head/share/man/man9/Makefile
  head/share/man/man9/random.9
  head/sys/conf/files
  head/sys/sys/libkern.h

Modified: head/lib/libc/gen/Makefile.inc
==
--- head/lib/libc/gen/Makefile.inc  Fri Apr 19 19:45:19 2019
(r346409)
+++ head/lib/libc/gen/Makefile.inc  Fri Apr 19 20:05:47 2019
(r346410)
@@ -3,6 +3,7 @@
 
 # machine-independent gen sources
 .PATH: ${LIBC_SRCTOP}/${LIBC_ARCH}/gen ${LIBC_SRCTOP}/gen
+.PATH: ${SRCTOP}/sys/libkern
 
 CONFS= shells
 

Modified: head/share/man/man9/Makefile
==
--- head/share/man/man9/MakefileFri Apr 19 19:45:19 2019
(r346409)
+++ head/share/man/man9/MakefileFri Apr 19 20:05:47 2019
(r346410)
@@ -1668,6 +1668,8 @@ MLINKS+=psignal.9 gsignal.9 \
psignal.9 tdsignal.9
 MLINKS+=random.9 arc4rand.9 \
random.9 arc4random.9 \
+   random.9 arc4random_buf.9 \
+   random.9 arc4random_uniform.9 \
random.9 is_random_seeded.9 \
random.9 read_random.9 \
random.9 read_random_uio.9 \

Modified: head/share/man/man9/random.9
==
--- head/share/man/man9/random.9Fri Apr 19 19:45:19 2019
(r346409)
+++ head/share/man/man9/random.9Fri Apr 19 20:05:47 2019
(r346410)
@@ -26,7 +26,7 @@
 .\"
 .\" $FreeBSD$
 .\" "
-.Dd April 16, 2019
+.Dd April 19, 2019
 .Dt RANDOM 9
 .Os
 .Sh NAME
@@ -45,6 +45,8 @@
 .Fn arc4random "void"
 .Ft void
 .Fn arc4random_buf "void *ptr" "size_t len"
+.Ft uint32_t
+.Fn arc4random_uniform "uint32_t upper_bound"
 .Ft void
 .Fn arc4rand "void *ptr" "u_int length" "int reseed"
 .Pp
@@ -79,6 +81,15 @@ fills
 with
 .Fa len
 bytes of random data.
+.Pp
+.Fn arc4random_uniform
+will return a single 32-bit value, uniformly distributed but less than
+.Fa upper_bound .
+This is recommended over constructions like
+.Dq Li arc4random() % upper_bound
+as it avoids "modulo bias" when the upper bound is not a power of two.
+In the worst case, this function may consume multiple iterations
+to ensure uniformity.
 .Pp
 The
 .Fn arc4rand

Modified: head/sys/conf/files
==
--- head/sys/conf/files Fri Apr 19 19:45:19 2019(r346409)
+++ head/sys/conf/files Fri Apr 19 20:05:47 2019(r346410)
@@ -3985,6 +3985,7 @@ kgssapi/gsstest.c optional kgssapi_debug
 # the file should be moved to conf/files. from here.
 #
 libkern/arc4random.c   standard
+libkern/arc4random_uniform.c   standard
 crypto/chacha20/chacha.c   standard
 libkern/asprintf.c standard
 libkern/bcd.c  standard

Copied and modified: head/sys/libkern/arc4random_uniform.c (from r346409, 
head/lib/libc/gen/arc4random_uniform.c)
==
--- head/lib/libc/gen/arc4random_uniform.c  Fri Apr 19 19:45:19 2019
(r346409, copy source)
+++ head/sys/libkern/arc4random_uniform.c   Fri Apr 19 20:05:47 2019
(r346410)
@@ -19,7 +19,11 @@
  */
 
 #include 
+#ifdef _KERNEL
+#include 
+#else
 #include 
+#endif
 
 /*
  * Calculate a uniformly distributed random number less than upper_bound

Modified: head/sys/sys/libkern.h
==
--- head/sys/sys/libkern.h  Fri Apr 19 19:45:19 2019(r346409)
+++ head/sys/sys/libkern.h  Fri Apr 19 20:05:47 2019(r346410)
@@ -128,6 +128,7 @@ struct malloc_type;
 uint32_t arc4random(void);
 voidarc4random_buf(void *, size_t);
 voidarc4rand(void *, u_int, int);
+uint32_t arc4random_uniform(uint32_t);
 int timingsafe_bcmp(const void *, const void *, size_t);
 void   *bsearch(const void *, const void *, size_t,
size_t, int (*)(const void *, const void *));
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe,

svn commit: r346409 - in head/stand/efi: include libefi

2019-04-19 Thread Warner Losh
Author: imp
Date: Fri Apr 19 19:45:19 2019
New Revision: 346409
URL: https://svnweb.freebsd.org/changeset/base/346409

Log:
  Add wrapper functions to convert strings to EFI_DEVICE_PATH
  
  In anticipation of new functionality, create routines to convert char *
  and a CHAR16 * to a EFI_DEVICE_PATH
EFI_DEVICE_PATH *efi_name_to_devpath(const char *path);
EFI_DEVICE_PATH *efi_name_to_devpath16(CHAR16 *path);
void efi_devpath_free(EFI_DEVICE_PATH *dp);
  The first two return an EFI_DEVICE_PATH for the passed in paths. The
  third frees up the storage the first two return when the caller is
  done with it.
  
  Differential Revision: https://reviews.freebsd.org/D19971

Modified:
  head/stand/efi/include/efilib.h
  head/stand/efi/libefi/devpath.c

Modified: head/stand/efi/include/efilib.h
==
--- head/stand/efi/include/efilib.h Fri Apr 19 19:45:15 2019
(r346408)
+++ head/stand/efi/include/efilib.h Fri Apr 19 19:45:19 2019
(r346409)
@@ -92,6 +92,9 @@ CHAR16 *efi_devpath_name(EFI_DEVICE_PATH *);
 void efi_free_devpath_name(CHAR16 *);
 EFI_DEVICE_PATH *efi_devpath_to_media_path(EFI_DEVICE_PATH *);
 UINTN efi_devpath_length(EFI_DEVICE_PATH *);
+EFI_DEVICE_PATH *efi_name_to_devpath(const char *path);
+EFI_DEVICE_PATH *efi_name_to_devpath16(CHAR16 *path);
+void efi_devpath_free(EFI_DEVICE_PATH *dp);
 
 int efi_status_to_errno(EFI_STATUS);
 EFI_STATUS errno_to_efi_status(int errno);

Modified: head/stand/efi/libefi/devpath.c
==
--- head/stand/efi/libefi/devpath.c Fri Apr 19 19:45:15 2019
(r346408)
+++ head/stand/efi/libefi/devpath.c Fri Apr 19 19:45:19 2019
(r346409)
@@ -28,12 +28,15 @@ __FBSDID("$FreeBSD$");
 
 #include 
 #include 
+#include 
 
 static EFI_GUID ImageDevicePathGUID =
 EFI_LOADED_IMAGE_DEVICE_PATH_PROTOCOL_GUID;
 static EFI_GUID DevicePathGUID = DEVICE_PATH_PROTOCOL;
 static EFI_GUID DevicePathToTextGUID = EFI_DEVICE_PATH_TO_TEXT_PROTOCOL_GUID;
-static EFI_DEVICE_PATH_TO_TEXT_PROTOCOL *textProtocol;
+static EFI_DEVICE_PATH_TO_TEXT_PROTOCOL *toTextProtocol;
+static EFI_GUID DevicePathFromTextGUID = 
EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL_GUID;
+static EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL *fromTextProtocol;
 
 EFI_DEVICE_PATH *
 efi_lookup_image_devpath(EFI_HANDLE handle)
@@ -63,22 +66,20 @@ efi_lookup_devpath(EFI_HANDLE handle)
 CHAR16 *
 efi_devpath_name(EFI_DEVICE_PATH *devpath)
 {
-   static int once = 1;
EFI_STATUS status;
 
if (devpath == NULL)
return (NULL);
-   if (once) {
+   if (toTextProtocol == NULL) {
status = BS->LocateProtocol(&DevicePathToTextGUID, NULL,
-   (VOID **)&textProtocol);
+   (VOID **)&toTextProtocol);
if (EFI_ERROR(status))
-   textProtocol = NULL;
-   once = 0;
+   toTextProtocol = NULL;
}
-   if (textProtocol == NULL)
+   if (toTextProtocol == NULL)
return (NULL);
 
-   return (textProtocol->ConvertDevicePathToText(devpath, TRUE, TRUE));
+   return (toTextProtocol->ConvertDevicePathToText(devpath, TRUE, TRUE));
 }
 
 void
@@ -86,6 +87,46 @@ efi_free_devpath_name(CHAR16 *text)
 {
 
BS->FreePool(text);
+}
+
+EFI_DEVICE_PATH *
+efi_name_to_devpath(const char *path)
+{
+   EFI_DEVICE_PATH *devpath;
+   CHAR16 *uv;
+   size_t ul;
+
+   uv = NULL;
+   if (utf8_to_ucs2(path, &uv, &ul) != 0)
+   return (NULL);
+   devpath = efi_name_to_devpath16(uv);
+   free(uv);
+   return (devpath);
+}
+
+EFI_DEVICE_PATH *
+efi_name_to_devpath16(CHAR16 *path)
+{
+   EFI_STATUS status;
+
+   if (path == NULL)
+   return (NULL);
+   if (fromTextProtocol == NULL) {
+   status = BS->LocateProtocol(&DevicePathFromTextGUID, NULL,
+   (VOID **)&fromTextProtocol);
+   if (EFI_ERROR(status))
+   fromTextProtocol = NULL;
+   }
+   if (fromTextProtocol == NULL)
+   return (NULL);
+
+   return (fromTextProtocol->ConvertTextToDevicePath(path));
+}
+
+void efi_devpath_free(EFI_DEVICE_PATH *devpath)
+{
+
+   BS->FreePool(devpath);
 }
 
 EFI_DEVICE_PATH *
___
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: r346408 - head/stand/efi/include

2019-04-19 Thread Warner Losh
Author: imp
Date: Fri Apr 19 19:45:15 2019
New Revision: 346408
URL: https://svnweb.freebsd.org/changeset/base/346408

Log:
  Add UEFI definitions related to converting string to DEVICE_PATH
  
  Add definitions from UEFI 2.7 Errata B standards doc for converting a
  text string to a device path. Added clearly missing 'e' at the end of
  Device to resolve mismatch in that document in
  EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL element names.
  
  Differential Revision: https://reviews.freebsd.org/D19971

Modified:
  head/stand/efi/include/efidevp.h

Modified: head/stand/efi/include/efidevp.h
==
--- head/stand/efi/include/efidevp.hFri Apr 19 19:44:59 2019
(r346407)
+++ head/stand/efi/include/efidevp.hFri Apr 19 19:45:15 2019
(r346408)
@@ -433,6 +433,9 @@ typedef union {
 #defineEFI_DEVICE_PATH_TO_TEXT_PROTOCOL_GUID   
\
 { 0x8b843e20, 0x8132, 0x4852, { 0x90, 0xcc, 0x55, 0x1a, 0x4e, 0x4a, 0x7f, 
0x1c } }
 
+#define EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL_GUID
\
+{ 0x05c99a21, 0xc70f, 0x4ad2, { 0x8a, 0x5f, 0x35, 0xdf, 0x33, 0x43, 0xf5, 
0x1e } }
+
 INTERFACE_DECL(_EFI_DEVICE_PATH_PROTOCOL);
 
 typedef
@@ -455,6 +458,23 @@ typedef struct _EFI_DEVICE_PATH_TO_TEXT_PROTOCOL {
EFI_DEVICE_PATH_TO_TEXT_NODE ConvertDeviceNodeToText;
EFI_DEVICE_PATH_TO_TEXT_PATH ConvertDevicePathToText;
 } EFI_DEVICE_PATH_TO_TEXT_PROTOCOL;
+
+typedef
+struct _EFI_DEVICE_PATH*
+(EFIAPI *EFI_DEVICE_PATH_FROM_TEXT_NODE) (
+IN CONST CHAR16* TextDeviceNode
+);
+typedef
+struct _EFI_DEVICE_PATH*
+(EFIAPI *EFI_DEVICE_PATH_FROM_TEXT_PATH) (
+IN CONST CHAR16* TextDevicePath
+);
+
+
+typedef struct _EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL {
+   EFI_DEVICE_PATH_FROM_TEXT_NODE ConvertTextToDeviceNode;
+   EFI_DEVICE_PATH_FROM_TEXT_PATH ConvertTextToDevicePath;
+} EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL;
 
 #pragma pack()
 
___
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: r346407 - head/stand/efi/include

2019-04-19 Thread Warner Losh
Author: imp
Date: Fri Apr 19 19:44:59 2019
New Revision: 346407
URL: https://svnweb.freebsd.org/changeset/base/346407

Log:
  Add define for CONST.
  
  Newer interfaces take CONST parameters, so define CONST to minimize
  differences between our headers and the standards docs.
  
  Differential Revision: https://reviews.freebsd.org/D19971

Modified:
  head/stand/efi/include/efidef.h

Modified: head/stand/efi/include/efidef.h
==
--- head/stand/efi/include/efidef.h Fri Apr 19 18:09:37 2019
(r346406)
+++ head/stand/efi/include/efidef.h Fri Apr 19 19:44:59 2019
(r346407)
@@ -63,6 +63,7 @@ typedef VOID*EFI_EVENT;
 #define IN
 #define OUT
 #define OPTIONAL
+#define CONST const
 #endif
 
 
___
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: r346390 - head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs

2019-04-19 Thread Enji Cooper

> On Apr 19, 2019, at 11:29, Alexander Motin  wrote:
> 
> On 19.04.2019 14:09, Enji Cooper wrote:
>>> On Apr 19, 2019, at 08:44, Alexander Motin  wrote:
>>> 
>>> Author: mav
>>> Date: Fri Apr 19 15:44:45 2019
>>> New Revision: 346390
>>> URL: https://svnweb.freebsd.org/changeset/base/346390
>>> 
>>> Log:
>>> Change the way FreeBSD GID inheritance is hacked.
>>> 
>>> I believe previous ifdef caused NULL dereference in later zfs_log_create()
>>> on attempt to create file inside directory belonging to ephemeral group
>>> created on illumos, trying to write to log information about GID domain
>>> of the newly created file, inheriting the ephemeral GID.
>>> 
>>> This patch reuses original illumos SGID code with exception that due to
>>> lack of ID mapping code on FreeBSD ephemeral GID will turn into GID_NOBODY
>>> by another ifdef inside zfs_fuid_map_id().
>> 
>> Hi mav@!
>>I was wondering, does this break ACL mappings with sticky bits for the 
>> group ID (or was it broken to begin with)? If the latter, does it make sense 
>> to file a bug/add a TODO comment?
> 
> I don't believe this change should have any visible results for native
> FreeBSD pools.  It does change change handling of some pools coming from
> illumos, but previous behavior in that case resulted in kernel panic, so
> anything else is better, while full compatibility is impossible, since
> FreeBSD has no kernel-side AD UID/GID mapping, used by illumos SMB.
> 
> Could you better describe what ACL mapping breakage you are talking about?

Ah... Yeah, it makes sense to leave this alone since it’s a missing ZFS on 
FreeBSD feature.
Thank you!
-Enji

PS I was likely messing up my interpretation of the stat field. I didn’t read 
the manpage yet.
___
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: r346390 - head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs

2019-04-19 Thread Alexander Motin
On 19.04.2019 14:09, Enji Cooper wrote:
>> On Apr 19, 2019, at 08:44, Alexander Motin  wrote:
>>
>> Author: mav
>> Date: Fri Apr 19 15:44:45 2019
>> New Revision: 346390
>> URL: https://svnweb.freebsd.org/changeset/base/346390
>>
>> Log:
>>  Change the way FreeBSD GID inheritance is hacked.
>>
>>  I believe previous ifdef caused NULL dereference in later zfs_log_create()
>>  on attempt to create file inside directory belonging to ephemeral group
>>  created on illumos, trying to write to log information about GID domain
>>  of the newly created file, inheriting the ephemeral GID.
>>
>>  This patch reuses original illumos SGID code with exception that due to
>>  lack of ID mapping code on FreeBSD ephemeral GID will turn into GID_NOBODY
>>  by another ifdef inside zfs_fuid_map_id().
> 
> Hi mav@!
> I was wondering, does this break ACL mappings with sticky bits for the 
> group ID (or was it broken to begin with)? If the latter, does it make sense 
> to file a bug/add a TODO comment?

I don't believe this change should have any visible results for native
FreeBSD pools.  It does change change handling of some pools coming from
illumos, but previous behavior in that case resulted in kernel panic, so
anything else is better, while full compatibility is impossible, since
FreeBSD has no kernel-side AD UID/GID mapping, used by illumos SMB.

Could you better describe what ACL mapping breakage you are talking about?

-- 
Alexander Motin
___
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: r346390 - head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs

2019-04-19 Thread Enji Cooper


> On Apr 19, 2019, at 08:44, Alexander Motin  wrote:
> 
> Author: mav
> Date: Fri Apr 19 15:44:45 2019
> New Revision: 346390
> URL: https://svnweb.freebsd.org/changeset/base/346390
> 
> Log:
>  Change the way FreeBSD GID inheritance is hacked.
> 
>  I believe previous ifdef caused NULL dereference in later zfs_log_create()
>  on attempt to create file inside directory belonging to ephemeral group
>  created on illumos, trying to write to log information about GID domain
>  of the newly created file, inheriting the ephemeral GID.
> 
>  This patch reuses original illumos SGID code with exception that due to
>  lack of ID mapping code on FreeBSD ephemeral GID will turn into GID_NOBODY
>  by another ifdef inside zfs_fuid_map_id().

Hi mav@!
I was wondering, does this break ACL mappings with sticky bits for the 
group ID (or was it broken to begin with)? If the latter, does it make sense to 
file a bug/add a TODO comment?
Thank you!
-Enji
___
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: r346406 - head/sys/netinet6

2019-04-19 Thread Michael Tuexen
Author: tuexen
Date: Fri Apr 19 18:09:37 2019
New Revision: 346406
URL: https://svnweb.freebsd.org/changeset/base/346406

Log:
  When an IPv6 packet is received for a raw socket which has the
  IPPROTO_IPV6 level socket option IPV6_CHECKSUM enabled and the
  checksum check fails, drop the message. Without this fix, an
  ICMP6 message was sent indicating a parameter problem.
  
  Thanks to bz@ for suggesting a way to simplify this fix.
  
  Reviewed by:  bz@
  MFC after:1 week
  Sponsored by: Netflix, Inc.
  Differential Revision:https://reviews.freebsd.org/D19969

Modified:
  head/sys/netinet6/raw_ip6.c

Modified: head/sys/netinet6/raw_ip6.c
==
--- head/sys/netinet6/raw_ip6.c Fri Apr 19 18:00:33 2019(r346405)
+++ head/sys/netinet6/raw_ip6.c Fri Apr 19 18:09:37 2019(r346406)
@@ -243,6 +243,12 @@ rip6_input(struct mbuf **mp, int *offp, int proto)
in6_cksum(m, proto, *offp,
m->m_pkthdr.len - *offp)) {
RIP6STAT_INC(rip6s_badsum);
+   /*
+* Drop the received message, don't send an
+* ICMP6 message. Set proto to IPPROTO_NONE
+* to achieve that.
+*/
+   proto = IPPROTO_NONE;
goto skip_2;
}
}
___
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: r346405 - head/sys/dev/ath

2019-04-19 Thread Adrian Chadd
Author: adrian
Date: Fri Apr 19 18:00:33 2019
New Revision: 346405
URL: https://svnweb.freebsd.org/changeset/base/346405

Log:
  [ath] Fix return value check to not complain.
  
  Compilers complain more about things, so let's keep them happy.

Modified:
  head/sys/dev/ath/if_athvar.h

Modified: head/sys/dev/ath/if_athvar.h
==
--- head/sys/dev/ath/if_athvar.hFri Apr 19 17:29:20 2019
(r346404)
+++ head/sys/dev/ath/if_athvar.hFri Apr 19 18:00:33 2019
(r346405)
@@ -1352,7 +1352,7 @@ void  ath_intr(void *);
== HAL_OK)
 #defineath_hal_setrxbufsize(_ah, _req) \
(ath_hal_setcapability(_ah, HAL_CAP_RXBUFSIZE, 0, _req, NULL)   \
-   == HAL_OK)
+   == AH_TRUE)
 
 #defineath_hal_getchannoise(_ah, _c) \
((*(_ah)->ah_getChanNoise)((_ah), (_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: r346399 - head/share/man/man4

2019-04-19 Thread Enji Cooper

> On Apr 19, 2019, at 10:15, Conrad Meyer  wrote:
> 
> Author: cem
> Date: Fri Apr 19 17:15:58 2019
> New Revision: 346399
> URL: https://svnweb.freebsd.org/changeset/base/346399
> 
> Log:
>  random.4: Include description of knobs added in r346358
> 
>  Reported by:ngie
>  Sponsored by:Dell EMC Isilon

Thank you so very much Conrad \^O^/!!! You’re awesome!
-Enji
___
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: r346404 - in stable/11: usr.bin/netstat usr.sbin/syslogd

2019-04-19 Thread Bjoern A. Zeeb
Author: bz
Date: Fri Apr 19 17:29:20 2019
New Revision: 346404
URL: https://svnweb.freebsd.org/changeset/base/346404

Log:
  MFC 344740:
  
Fix compilation of world with WITHOUT_{INET,INET6}_SUPPORT or both set.
  
Buildworld failed when both WITHOUT_INET6_SUPPORT and INET equivalent were 
set.
Fix netstat and syslogd by applying appropriate #ifdef INET/INET6 to make 
world
compile again.

Modified:
  stable/11/usr.bin/netstat/inet.c
  stable/11/usr.sbin/syslogd/syslogd.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/usr.bin/netstat/inet.c
==
--- stable/11/usr.bin/netstat/inet.cFri Apr 19 17:28:38 2019
(r346403)
+++ stable/11/usr.bin/netstat/inet.cFri Apr 19 17:29:20 2019
(r346404)
@@ -84,8 +84,10 @@ __FBSDID("$FreeBSD$");
 #include "netstat.h"
 #include "nl_defs.h"
 
-void   inetprint(const char *, struct in_addr *, int, const char *, int,
+#ifdef INET
+static void inetprint(const char *, struct in_addr *, int, const char *, int,
 const int);
+#endif
 #ifdef INET6
 static int udp_done, tcp_done, sdp_done;
 #endif /* INET6 */
@@ -506,6 +508,7 @@ protopr(u_long off, const char *name, int af1, int pro
so->so_rcv.sb_cc, so->so_snd.sb_cc);
}
if (numeric_port) {
+#ifdef INET
if (inp->inp_vflag & INP_IPV4) {
inetprint("local", &inp->inp_laddr,
(int)inp->inp_lport, name, 1, af1);
@@ -513,8 +516,12 @@ protopr(u_long off, const char *name, int af1, int pro
inetprint("remote", &inp->inp_faddr,
(int)inp->inp_fport, name, 1, af1);
}
+#endif
+#if defined(INET) && defined(INET6)
+   else
+#endif
 #ifdef INET6
-   else if (inp->inp_vflag & INP_IPV6) {
+   if (inp->inp_vflag & INP_IPV6) {
inet6print("local", &inp->in6p_laddr,
(int)inp->inp_lport, name, 1);
if (!Lflag)
@@ -523,6 +530,7 @@ protopr(u_long off, const char *name, int af1, int pro
} /* else nothing printed now */
 #endif /* INET6 */
} else if (inp->inp_flags & INP_ANONPORT) {
+#ifdef INET
if (inp->inp_vflag & INP_IPV4) {
inetprint("local", &inp->inp_laddr,
(int)inp->inp_lport, name, 1, af1);
@@ -530,8 +538,12 @@ protopr(u_long off, const char *name, int af1, int pro
inetprint("remote", &inp->inp_faddr,
(int)inp->inp_fport, name, 0, af1);
}
+#endif
+#if defined(INET) && defined(INET6)
+   else
+#endif
 #ifdef INET6
-   else if (inp->inp_vflag & INP_IPV6) {
+   if (inp->inp_vflag & INP_IPV6) {
inet6print("local", &inp->in6p_laddr,
(int)inp->inp_lport, name, 1);
if (!Lflag)
@@ -540,6 +552,7 @@ protopr(u_long off, const char *name, int af1, int pro
} /* else nothing printed now */
 #endif /* INET6 */
} else {
+#ifdef INET
if (inp->inp_vflag & INP_IPV4) {
inetprint("local", &inp->inp_laddr,
(int)inp->inp_lport, name, 0, af1);
@@ -549,8 +562,12 @@ protopr(u_long off, const char *name, int af1, int pro
inp->inp_lport != inp->inp_fport,
af1);
}
+#endif
+#if defined(INET) && defined(INET6)
+   else
+#endif
 #ifdef INET6
-   else if (inp->inp_vflag & INP_IPV6) {
+   if (inp->inp_vflag & INP_IPV6) {
inet6print("local", &inp->in6p_laddr,
(int)inp->inp_lport, name, 0);
if (!Lflag)
@@ -1415,10 +1432,11 @@ pim_stats(u_long off __unused, const char *name, int a
xo_close_container(name);
 }
 
+#ifdef INET
 /*
  * Pretty print an Internet address (net address + port).
  */
-void
+static void
 inetprint(const char *container, struct in_addr *in, int port,
 const char *proto, int num_port, const int af1)
 {
@@ -1505,3 +1523,4 @@ inetname(struct in_addr *inp)
}
return (line);
 }
+#endif

Modified: stable/11/usr.sbin/syslogd/syslogd.c
==
--- stable/11/usr.sbin/syslogd/syslogd.cFri Apr 19 17:28:38 2019
(r346403)
+++ stab

svn commit: r346403 - in stable/12: usr.bin/netstat usr.sbin/syslogd

2019-04-19 Thread Bjoern A. Zeeb
Author: bz
Date: Fri Apr 19 17:28:38 2019
New Revision: 346403
URL: https://svnweb.freebsd.org/changeset/base/346403

Log:
  MFC r344740:
  
Fix compilation of world with WITHOUT_{INET,INET6}_SUPPORT or both set.
  
Buildworld failed when both WITHOUT_INET6_SUPPORT and INET equivalent were 
set.
Fix netstat and syslogd by applying appropriate #ifdef INET/INET6 to make 
world
compile again.

Modified:
  stable/12/usr.bin/netstat/inet.c
  stable/12/usr.sbin/syslogd/syslogd.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/usr.bin/netstat/inet.c
==
--- stable/12/usr.bin/netstat/inet.cFri Apr 19 17:28:28 2019
(r346402)
+++ stable/12/usr.bin/netstat/inet.cFri Apr 19 17:28:38 2019
(r346403)
@@ -85,8 +85,10 @@ __FBSDID("$FreeBSD$");
 #include "netstat.h"
 #include "nl_defs.h"
 
-void   inetprint(const char *, struct in_addr *, int, const char *, int,
+#ifdef INET
+static void inetprint(const char *, struct in_addr *, int, const char *, int,
 const int);
+#endif
 #ifdef INET6
 static int udp_done, tcp_done, sdp_done;
 #endif /* INET6 */
@@ -390,6 +392,7 @@ protopr(u_long off, const char *name, int af1, int pro
so->so_rcv.sb_cc, so->so_snd.sb_cc);
}
if (numeric_port) {
+#ifdef INET
if (inp->inp_vflag & INP_IPV4) {
inetprint("local", &inp->inp_laddr,
(int)inp->inp_lport, name, 1, af1);
@@ -397,8 +400,12 @@ protopr(u_long off, const char *name, int af1, int pro
inetprint("remote", &inp->inp_faddr,
(int)inp->inp_fport, name, 1, af1);
}
+#endif
+#if defined(INET) && defined(INET6)
+   else
+#endif
 #ifdef INET6
-   else if (inp->inp_vflag & INP_IPV6) {
+   if (inp->inp_vflag & INP_IPV6) {
inet6print("local", &inp->in6p_laddr,
(int)inp->inp_lport, name, 1);
if (!Lflag)
@@ -407,6 +414,7 @@ protopr(u_long off, const char *name, int af1, int pro
} /* else nothing printed now */
 #endif /* INET6 */
} else if (inp->inp_flags & INP_ANONPORT) {
+#ifdef INET
if (inp->inp_vflag & INP_IPV4) {
inetprint("local", &inp->inp_laddr,
(int)inp->inp_lport, name, 1, af1);
@@ -414,8 +422,12 @@ protopr(u_long off, const char *name, int af1, int pro
inetprint("remote", &inp->inp_faddr,
(int)inp->inp_fport, name, 0, af1);
}
+#endif
+#if defined(INET) && defined(INET6)
+   else
+#endif
 #ifdef INET6
-   else if (inp->inp_vflag & INP_IPV6) {
+   if (inp->inp_vflag & INP_IPV6) {
inet6print("local", &inp->in6p_laddr,
(int)inp->inp_lport, name, 1);
if (!Lflag)
@@ -424,6 +436,7 @@ protopr(u_long off, const char *name, int af1, int pro
} /* else nothing printed now */
 #endif /* INET6 */
} else {
+#ifdef INET
if (inp->inp_vflag & INP_IPV4) {
inetprint("local", &inp->inp_laddr,
(int)inp->inp_lport, name, 0, af1);
@@ -433,8 +446,12 @@ protopr(u_long off, const char *name, int af1, int pro
inp->inp_lport != inp->inp_fport,
af1);
}
+#endif
+#if defined(INET) && defined(INET6)
+   else
+#endif
 #ifdef INET6
-   else if (inp->inp_vflag & INP_IPV6) {
+   if (inp->inp_vflag & INP_IPV6) {
inet6print("local", &inp->in6p_laddr,
(int)inp->inp_lport, name, 0);
if (!Lflag)
@@ -1314,10 +1331,11 @@ pim_stats(u_long off __unused, const char *name, int a
xo_close_container(name);
 }
 
+#ifdef INET
 /*
  * Pretty print an Internet address (net address + port).
  */
-void
+static void
 inetprint(const char *container, struct in_addr *in, int port,
 const char *proto, int num_port, const int af1)
 {
@@ -1404,3 +1422,4 @@ inetname(struct in_addr *inp)
}
return (line);
 }
+#endif

Modified: stable/12/usr.sbin/syslogd/syslogd.c
==
--- stable/12/usr.sbin/syslogd/syslogd.cFri Apr 19 17:28:28 2019
(r346402)
+++ sta

svn commit: r346402 - head/sys/netinet6

2019-04-19 Thread Michael Tuexen
Author: tuexen
Date: Fri Apr 19 17:28:28 2019
New Revision: 346402
URL: https://svnweb.freebsd.org/changeset/base/346402

Log:
  When a checksum has to be computed for a received IPv6 packet because it
  is requested by the application using the IPPROTO_IPV6 level socket option
  IPV6_CHECKSUM on a raw socket, ensure that the packet contains enough
  bytes to contain the checksum at the specified offset.
  
  Reported by:  syzbot+6295fcc5a8aced81d...@syzkaller.appspotmail.com
  Reviewed by:  bz@
  Sponsored by: Netflix, Inc.
  Differential Revision:https://reviews.freebsd.org/D19968

Modified:
  head/sys/netinet6/raw_ip6.c

Modified: head/sys/netinet6/raw_ip6.c
==
--- head/sys/netinet6/raw_ip6.c Fri Apr 19 17:21:35 2019(r346401)
+++ head/sys/netinet6/raw_ip6.c Fri Apr 19 17:28:28 2019(r346402)
@@ -239,7 +239,8 @@ rip6_input(struct mbuf **mp, int *offp, int proto)
}
if (in6p->in6p_cksum != -1) {
RIP6STAT_INC(rip6s_isum);
-   if (in6_cksum(m, proto, *offp,
+   if (m->m_pkthdr.len - (*offp + in6p->in6p_cksum) < 2 ||
+   in6_cksum(m, proto, *offp,
m->m_pkthdr.len - *offp)) {
RIP6STAT_INC(rip6s_badsum);
goto skip_2;
___
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: r346401 - head/sys/netinet6

2019-04-19 Thread Michael Tuexen
Author: tuexen
Date: Fri Apr 19 17:21:35 2019
New Revision: 346401
URL: https://svnweb.freebsd.org/changeset/base/346401

Log:
  Avoid a buffer overwrite in rip6_output() when computing the checksum
  as requested by the user via the IPPROTO_IPV6 level socket option
  IPV6_CHECKSUM. The check if there are enough bytes in the packet to
  store the checksum at the requested offset was wrong by 1.
  
  Reviewed by:  bz@
  MFC after:1 week
  Sponsored by: Netflix, Inc.
  Differential Revision:https://reviews.freebsd.org/D19967

Modified:
  head/sys/netinet6/raw_ip6.c

Modified: head/sys/netinet6/raw_ip6.c
==
--- head/sys/netinet6/raw_ip6.c Fri Apr 19 17:17:41 2019(r346400)
+++ head/sys/netinet6/raw_ip6.c Fri Apr 19 17:21:35 2019(r346401)
@@ -495,7 +495,7 @@ rip6_output(struct mbuf *m, struct socket *so, ...)
off = offsetof(struct icmp6_hdr, icmp6_cksum);
else
off = in6p->in6p_cksum;
-   if (plen < off + 1) {
+   if (plen < off + 2) {
error = EINVAL;
goto bad;
}
___
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: r346400 - head/sys/netinet6

2019-04-19 Thread Michael Tuexen
Author: tuexen
Date: Fri Apr 19 17:17:41 2019
New Revision: 346400
URL: https://svnweb.freebsd.org/changeset/base/346400

Log:
  Improve input validation for the socket option IPV6_CHECKSUM.
  
  When using the IPPROTO_IPV6 level socket option IPV6_CHECKSUM on a raw
  IPv6 socket, ensure that the value is either -1 or a non-negative even
  number.
  
  Reviewed by:  bz@, thj@
  MFC after:1 week
  Sponsored by: Netflix, Inc.
  Differential Revision:https://reviews.freebsd.org/D19966

Modified:
  head/sys/netinet6/ip6_output.c

Modified: head/sys/netinet6/ip6_output.c
==
--- head/sys/netinet6/ip6_output.c  Fri Apr 19 17:15:58 2019
(r346399)
+++ head/sys/netinet6/ip6_output.c  Fri Apr 19 17:17:41 2019
(r346400)
@@ -2221,8 +2221,11 @@ ip6_raw_ctloutput(struct socket *so, struct sockopt *s
sizeof(optval));
if (error)
break;
-   if ((optval % 2) != 0) {
-   /* the API assumes even offset values */
+   if (optval < -1 || (optval % 2) != 0) {
+   /*
+* The API assumes non-negative even offset
+* values or -1 as a special value.
+*/
error = EINVAL;
} else if (so->so_proto->pr_protocol ==
IPPROTO_ICMPV6) {
___
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: r346399 - head/share/man/man4

2019-04-19 Thread Conrad Meyer
Author: cem
Date: Fri Apr 19 17:15:58 2019
New Revision: 346399
URL: https://svnweb.freebsd.org/changeset/base/346399

Log:
  random.4: Include description of knobs added in r346358
  
  Reported by:  ngie
  Sponsored by: Dell EMC Isilon

Modified:
  head/share/man/man4/random.4

Modified: head/share/man/man4/random.4
==
--- head/share/man/man4/random.4Fri Apr 19 17:06:43 2019
(r346398)
+++ head/share/man/man4/random.4Fri Apr 19 17:15:58 2019
(r346399)
@@ -23,7 +23,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd April 15, 2019
+.Dd April 19, 2019
 .Dt RANDOM 4
 .Os
 .Sh NAME
@@ -85,6 +85,10 @@ kern.random.harvest.mask_bin: 00100011101
 kern.random.harvest.mask: 66015
 kern.random.use_chacha20_cipher: 0
 kern.random.random_sources: 'Intel Secure Key RNG'
+kern.random.initial_seeding.bypass_before_seeding: 1
+kern.random.initial_seeding.read_random_bypassed_before_seeding: 0
+kern.random.initial_seeding.arc4random_bypassed_before_seeding: 0
+kern.random.initial_seeding.disable_bypass_warnings: 0
 .Ed
 .Pp
 Other than
@@ -132,6 +136,55 @@ for more on the harvesting of entropy.
 .Bl -tag -width ".Pa /dev/urandom"
 .It Pa /dev/random
 .It Pa /dev/urandom
+.El
+.Sh DIAGNOSTICS
+The following tunables are related to initial seeding of the
+.Nm
+device:
+.Bl -tag -width 4
+.It Va kern.random.initial_seeding.bypass_before_seeding
+Defaults to 1 (on).
+When set, the system will bypass the
+.Nm
+device prior to initial seeding.
+On is
+.Em unsafe ,
+but provides availability on many systems that lack early sources
+of entropy, or cannot load
+.Pa /boot/entropy
+sufficiently early in boot for
+.Nm
+consumers.
+When unset (0), the system will block
+.Xr read_random 9
+and
+.Xr arc4random 9
+requests if and until the
+.Nm
+device is initially seeded.
+.It Va kern.random.initial_seeding.disable_bypass_warnings
+Defaults to 0 (off).
+When set non-zero, disables warnings in dmesg when the
+.Nm
+device is bypassed.
+.El
+.Pp
+The following read-only
+.Xr sysctl 8
+variables allow programmatic diagnostic of whether
+.Nm
+device bypass occurred during boot.
+If they are set (non-zero), the specific functional unit bypassed the strong
+.Nm
+device output and either produced no output
+.Xr ( read_random 9 )
+or seeded itself with minimal, non-cryptographic entropy
+.Xr ( arc4random 9 ) .
+.Bl -bullet
+.It
+.Va kern.random.initial_seeding.read_random_bypassed_before_seeding
+.It
+.Va kern.random.initial_seeding.arc4random_bypassed_before_seeding
 .El
 .Sh SEE ALSO
 .Xr getrandom 2 ,
___
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: r346398 - in head: sys/netinet6 usr.bin/netstat usr.bin/systat

2019-04-19 Thread Tom Jones
Author: thj
Date: Fri Apr 19 17:06:43 2019
New Revision: 346398
URL: https://svnweb.freebsd.org/changeset/base/346398

Log:
  Add stat counter for ipv6 atomic fragments
  
  Add a stat counter to track ipv6 atomic fragments. Atomic fragments can be
  generated in response to invalid path MTU values, but are also a potential
  attack vector and considered harmful (see RFC6946 and RFC8021).
  
  While here add tracking of the atomic fragment counter to netstat and systat.
  
  Reviewed by:tuexen, jtl, bz
  Approved by:jtl (mentor), bz (mentor)
  Event:  Aberdeen hackathon 2019
  Differential Revision:  https://reviews.freebsd.org/D17511

Modified:
  head/sys/netinet6/frag6.c
  head/sys/netinet6/ip6_var.h
  head/usr.bin/netstat/inet6.c
  head/usr.bin/systat/ip6.c

Modified: head/sys/netinet6/frag6.c
==
--- head/sys/netinet6/frag6.c   Fri Apr 19 15:54:32 2019(r346397)
+++ head/sys/netinet6/frag6.c   Fri Apr 19 17:06:43 2019(r346398)
@@ -277,12 +277,12 @@ frag6_input(struct mbuf **mp, int *offp, int proto)
offset += sizeof(struct ip6_frag);
 
/*
-* RFC 6946: Handle "atomic" fragments (offset and m bit set to 0)
-* upfront, unrelated to any reassembly.  Just skip the fragment header.
+* Handle "atomic" fragments (offset and m bit set to 0) upfront,
+* unrelated to any reassembly (see RFC 6946 and section 4.5 of RFC
+* 8200).  Just skip the fragment header.
 */
if ((ip6f->ip6f_offlg & ~IP6F_RESERVED_MASK) == 0) {
-   /* XXX-BZ we want dedicated counters for this. */
-   IP6STAT_INC(ip6s_reassembled);
+   IP6STAT_INC(ip6s_atomicfrags);
in6_ifstat_inc(dstifp, ifs6_reass_ok);
*offp = offset;
m->m_flags |= M_FRAGMENTED;

Modified: head/sys/netinet6/ip6_var.h
==
--- head/sys/netinet6/ip6_var.h Fri Apr 19 15:54:32 2019(r346397)
+++ head/sys/netinet6/ip6_var.h Fri Apr 19 17:06:43 2019(r346398)
@@ -208,6 +208,7 @@ struct  ip6stat {
uint64_t ip6s_localout; /* total ip packets generated here */
uint64_t ip6s_odropped; /* lost packets due to nobufs, etc. */
uint64_t ip6s_reassembled;  /* total packets reassembled ok */
+   uint64_t ip6s_atomicfrags;  /* atomic fragments */
uint64_t ip6s_fragmented;   /* datagrams successfully fragmented */
uint64_t ip6s_ofragments;   /* output fragments created */
uint64_t ip6s_cantfrag; /* don't fragment flag was set, etc. */

Modified: head/usr.bin/netstat/inet6.c
==
--- head/usr.bin/netstat/inet6.cFri Apr 19 15:54:32 2019
(r346397)
+++ head/usr.bin/netstat/inet6.cFri Apr 19 17:06:43 2019
(r346398)
@@ -391,6 +391,8 @@ ip6_stats(u_long off, const char *name, int af1 __unus
"{N:/fragment%s dropped after timeout}\n");
p(ip6s_fragoverflow, "\t{:dropped-fragments-overflow/%ju} "
"{N:/fragment%s that exceeded limit}\n");
+   p(ip6s_atomicfrags, "\t{:atomic-fragments/%ju} "
+   "{N:/atomic fragment%s}\n");
p(ip6s_reassembled, "\t{:reassembled-packets/%ju} "
"{N:/packet%s reassembled ok}\n");
p(ip6s_delivered, "\t{:received-local-packets/%ju} "

Modified: head/usr.bin/systat/ip6.c
==
--- head/usr.bin/systat/ip6.c   Fri Apr 19 15:54:32 2019(r346397)
+++ head/usr.bin/systat/ip6.c   Fri Apr 19 17:06:43 2019(r346398)
@@ -121,16 +121,16 @@ labelip6(void)
L(6, "- fragments dropped");R(6, "destinations unreachable");
L(7, "- fragments timed out");  R(7, "packets output via raw IP");
L(8, "- fragments overflown");
-   L(9, "- packets reassembled ok"); R(9, "Input next-header histogram");
-   L(10, "packets forwarded"); R(10, " - destination options");
-   L(11, "- unreachable dests");   R(11, " - hop-by-hop options");
-   L(12, "- redirects generated"); R(12, " - IPv4");
-   L(13, "option errors"); R(13, " - TCP");
-   L(14, "unwanted multicasts");   R(14, " - UDP");
-   L(15, "delivered to upper layer"); R(15, " - IPv6");
-   L(16, "bad scope packets"); R(16, " - routing header");
-   L(17, "address selection failed"); R(17, " - fragmentation header");
-   R(18, " - ICMP6");
+   L(9, "- atomic fragments"); R(9, "Input next-header histogram");
+   L(10, "- packets reassembled ok"); R(10, " - destination options");
+   L(11, "packets forwarded"); R(11, " - hop-by-hop options");
+   L(12, "- unreachable dests");   R(12, " - IPv4");
+   L(13, "- redirects generate

svn commit: r346397 - stable/11/sys/arm/broadcom/bcm2835

2019-04-19 Thread Bjoern A. Zeeb
Author: bz
Date: Fri Apr 19 15:54:32 2019
New Revision: 346397
URL: https://svnweb.freebsd.org/changeset/base/346397

Log:
  MFC r345757:
  
Improve debugging options in bcm2835_sdhci.c
  
Similar to bcm2835_sdhost.c add a TUNABLE and SYSCTL to selectively
turn on debugging printfs if debugging is turned on at compile time.

Modified:
  stable/11/sys/arm/broadcom/bcm2835/bcm2835_sdhci.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/arm/broadcom/bcm2835/bcm2835_sdhci.c
==
--- stable/11/sys/arm/broadcom/bcm2835/bcm2835_sdhci.c  Fri Apr 19 15:53:30 
2019(r346396)
+++ stable/11/sys/arm/broadcom/bcm2835/bcm2835_sdhci.c  Fri Apr 19 15:54:32 
2019(r346397)
@@ -63,8 +63,17 @@ __FBSDID("$FreeBSD$");
 #defineNUM_DMA_SEGS2
 
 #ifdef DEBUG
-#define dprintf(fmt, args...) do { printf("%s(): ", __func__);   \
-printf(fmt,##args); } while (0)
+static int bcm2835_sdhci_debug = 0;
+
+TUNABLE_INT("hw.bcm2835.sdhci.debug", &bcm2835_sdhci_debug);
+SYSCTL_INT(_hw_sdhci, OID_AUTO, bcm2835_sdhci_debug, CTLFLAG_RWTUN,
+&bcm2835_sdhci_debug, 0, "bcm2835 SDHCI debug level");
+
+#definedprintf(fmt, args...)   \
+   do {\
+   if (bcm2835_sdhci_debug)\
+   printf("%s: " fmt, __func__, ##args);   \
+   }  while (0)
 #else
 #define dprintf(fmt, args...)
 #endif
___
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: r346396 - stable/12/sys/arm/broadcom/bcm2835

2019-04-19 Thread Bjoern A. Zeeb
Author: bz
Date: Fri Apr 19 15:53:30 2019
New Revision: 346396
URL: https://svnweb.freebsd.org/changeset/base/346396

Log:
  MFC r345757:
  
Improve debugging options in bcm2835_sdhci.c
  
Similar to bcm2835_sdhost.c add a TUNABLE and SYSCTL to selectively
turn on debugging printfs if debugging is turned on at compile time.

Modified:
  stable/12/sys/arm/broadcom/bcm2835/bcm2835_sdhci.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/arm/broadcom/bcm2835/bcm2835_sdhci.c
==
--- stable/12/sys/arm/broadcom/bcm2835/bcm2835_sdhci.c  Fri Apr 19 15:52:09 
2019(r346395)
+++ stable/12/sys/arm/broadcom/bcm2835/bcm2835_sdhci.c  Fri Apr 19 15:53:30 
2019(r346396)
@@ -66,8 +66,17 @@ __FBSDID("$FreeBSD$");
 #defineNUM_DMA_SEGS2
 
 #ifdef DEBUG
-#define dprintf(fmt, args...) do { printf("%s(): ", __func__);   \
-printf(fmt,##args); } while (0)
+static int bcm2835_sdhci_debug = 0;
+
+TUNABLE_INT("hw.bcm2835.sdhci.debug", &bcm2835_sdhci_debug);
+SYSCTL_INT(_hw_sdhci, OID_AUTO, bcm2835_sdhci_debug, CTLFLAG_RWTUN,
+&bcm2835_sdhci_debug, 0, "bcm2835 SDHCI debug level");
+
+#definedprintf(fmt, args...)   \
+   do {\
+   if (bcm2835_sdhci_debug)\
+   printf("%s: " fmt, __func__, ##args);   \
+   }  while (0)
 #else
 #define dprintf(fmt, args...)
 #endif
___
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: r346395 - stable/12/sys/dev/sdhci

2019-04-19 Thread Bjoern A. Zeeb
Author: bz
Date: Fri Apr 19 15:52:09 2019
New Revision: 346395
URL: https://svnweb.freebsd.org/changeset/base/346395

Log:
  MFC r345372:
  
Whitespace cleanup in sdhci.c
  
No functional changes.  Replace whitespace by tabs, indent with 4 spaces,
coalesce multi-line shorter than 80 characters,

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

Modified: stable/12/sys/dev/sdhci/sdhci.c
==
--- stable/12/sys/dev/sdhci/sdhci.c Fri Apr 19 15:50:51 2019
(r346394)
+++ stable/12/sys/dev/sdhci/sdhci.c Fri Apr 19 15:52:09 2019
(r346395)
@@ -1553,23 +1553,23 @@ sdhci_retune(void *arg)
 static void
 sdhci_req_done(struct sdhci_slot *slot)
 {
-union ccb *ccb;
+   union ccb *ccb;
 
if (__predict_false(sdhci_debug > 1))
slot_printf(slot, "%s\n", __func__);
if (slot->ccb != NULL && slot->curcmd != NULL) {
callout_stop(&slot->timeout_callout);
-ccb = slot->ccb;
-slot->ccb = NULL;
+   ccb = slot->ccb;
+   slot->ccb = NULL;
slot->curcmd = NULL;
 
-/* Tell CAM the request is finished */
-struct ccb_mmcio *mmcio;
-mmcio = &ccb->mmcio;
+   /* Tell CAM the request is finished */
+   struct ccb_mmcio *mmcio;
+   mmcio = &ccb->mmcio;
 
-ccb->ccb_h.status =
-(mmcio->cmd.error == 0 ? CAM_REQ_CMP : 
CAM_REQ_CMP_ERR);
-xpt_done(ccb);
+   ccb->ccb_h.status =
+   (mmcio->cmd.error == 0 ? CAM_REQ_CMP : CAM_REQ_CMP_ERR);
+   xpt_done(ccb);
}
 }
 #else
@@ -2483,47 +2483,45 @@ void
 sdhci_start_slot(struct sdhci_slot *slot)
 {
 
-if ((slot->devq = cam_simq_alloc(1)) == NULL) {
-goto fail;
-}
+   if ((slot->devq = cam_simq_alloc(1)) == NULL)
+   goto fail;
 
-mtx_init(&slot->sim_mtx, "sdhcisim", NULL, MTX_DEF);
-slot->sim = cam_sim_alloc(sdhci_cam_action, sdhci_cam_poll,
-  "sdhci_slot", slot, 
device_get_unit(slot->bus),
-  &slot->sim_mtx, 1, 1, slot->devq);
+   mtx_init(&slot->sim_mtx, "sdhcisim", NULL, MTX_DEF);
+   slot->sim = cam_sim_alloc(sdhci_cam_action, sdhci_cam_poll,
+   "sdhci_slot", slot, device_get_unit(slot->bus),
+   &slot->sim_mtx, 1, 1, slot->devq);
 
-if (slot->sim == NULL) {
-cam_simq_free(slot->devq);
-slot_printf(slot, "cannot allocate CAM SIM\n");
-goto fail;
-}
+   if (slot->sim == NULL) {
+   cam_simq_free(slot->devq);
+   slot_printf(slot, "cannot allocate CAM SIM\n");
+   goto fail;
+   }
 
-mtx_lock(&slot->sim_mtx);
-if (xpt_bus_register(slot->sim, slot->bus, 0) != 0) {
-slot_printf(slot,
-  "cannot register SCSI pass-through bus\n");
-cam_sim_free(slot->sim, FALSE);
-cam_simq_free(slot->devq);
-mtx_unlock(&slot->sim_mtx);
-goto fail;
-}
+   mtx_lock(&slot->sim_mtx);
+   if (xpt_bus_register(slot->sim, slot->bus, 0) != 0) {
+   slot_printf(slot, "cannot register SCSI pass-through bus\n");
+   cam_sim_free(slot->sim, FALSE);
+   cam_simq_free(slot->devq);
+   mtx_unlock(&slot->sim_mtx);
+   goto fail;
+   }
+   mtx_unlock(&slot->sim_mtx);
 
-mtx_unlock(&slot->sim_mtx);
-/* End CAM-specific init */
+   /* End CAM-specific init */
slot->card_present = 0;
sdhci_card_task(slot, 0);
-return;
+   return;
 
 fail:
-if (slot->sim != NULL) {
-mtx_lock(&slot->sim_mtx);
-xpt_bus_deregister(cam_sim_path(slot->sim));
-cam_sim_free(slot->sim, FALSE);
-mtx_unlock(&slot->sim_mtx);
-}
+   if (slot->sim != NULL) {
+   mtx_lock(&slot->sim_mtx);
+   xpt_bus_deregister(cam_sim_path(slot->sim));
+   cam_sim_free(slot->sim, FALSE);
+   mtx_unlock(&slot->sim_mtx);
+   }
 
-if (slot->devq != NULL)
-cam_simq_free(slot->devq);
+   if (slot->devq != NULL)
+   cam_simq_free(slot->devq);
 }
 
 static void
@@ -2653,15 +2651,13 @@ sdhci_cam_get_possible_host_clock(const struct sdhci_s
clock = max_clock;
 
if (slot->version < SDHCI_SPEC_300) {
-   for (i = 0; i < SDHCI_200_MAX_DIVIDER;
-i <<= 1) {
+   for (i = 0; i < SDHCI_200_MAX_DIVIDER; i <<= 1) {
if (clock <= proposed_clock)
brea

svn commit: r346394 - stable/12/sys/dev/sdhci

2019-04-19 Thread Bjoern A. Zeeb
Author: bz
Date: Fri Apr 19 15:50:51 2019
New Revision: 346394
URL: https://svnweb.freebsd.org/changeset/base/346394

Log:
  MFC r345370:
  
Align struct sdhci_slot MMCCAM members.
  
Whitespace only, no functional change.

Modified:
  stable/12/sys/dev/sdhci/sdhci.h
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/dev/sdhci/sdhci.h
==
--- stable/12/sys/dev/sdhci/sdhci.h Fri Apr 19 15:48:57 2019
(r346393)
+++ stable/12/sys/dev/sdhci/sdhci.h Fri Apr 19 15:50:51 2019
(r346394)
@@ -413,10 +413,10 @@ struct sdhci_slot {
 #ifdef MMCCAM
/* CAM stuff */
union ccb   *ccb;
-   struct cam_devq *devq;
-   struct cam_sim  *sim;
-   struct mtx  sim_mtx;
-   u_char  card_present; /* XXX Maybe derive this from 
elsewhere? */
+   struct cam_devq *devq;
+   struct cam_sim  *sim;
+   struct mtx  sim_mtx;
+   u_char  card_present;   /* XXX Maybe derive this from 
elsewhere? */
 #endif
 };
 
___
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: r346393 - stable/12/sys/dev/usb

2019-04-19 Thread Bjoern A. Zeeb
Author: bz
Date: Fri Apr 19 15:48:57 2019
New Revision: 346393
URL: https://svnweb.freebsd.org/changeset/base/346393

Log:
  MFC r344959:
  
Add two more products found inside a T480 to usbdevs.
  
Add an Intel Bluetooth module.
Add Synaptics as a vendor with a fingerprint reader product.

Modified:
  stable/12/sys/dev/usb/usbdevs
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/dev/usb/usbdevs
==
--- stable/12/sys/dev/usb/usbdevs   Fri Apr 19 15:46:08 2019
(r346392)
+++ stable/12/sys/dev/usb/usbdevs   Fri Apr 19 15:48:57 2019
(r346393)
@@ -351,6 +351,7 @@ vendor ALCATELT 0x06b9  Alcatel Telecom
 vendor AGFA0x06bd  AGFA-Gevaert
 vendor ASIAMD  0x06be  Asia Microelectronic Development
 vendor BIZLINK 0x06c4  Bizlink International
+vendor SYNAPTICS   0x06cb  Synaptics, Inc.
 vendor KEYSPAN 0x06cd  Keyspan / InnoSys Inc.
 vendor CONTEC  0x06ce  Contec products
 vendor AASHIMA 0x06d6  Aashima Technology
@@ -2582,6 +2583,7 @@ product INTEL2 IRMH   0x0020  Integrated Rate 
Mat
 product INTEL2 IRMH2   0x0024  Integrated Rate Matching Hub
 product INTEL2 IRMH3   0x8000  Integrated Rate Matching Hub
 product INTEL2 IRMH4   0x8008  Integrated Rate Matching Hub
+product INTEL2 SNP 0x0a2b  Stone Peak (7265) Bluetooth Module
 product INTEL2 SFP 0x0aa7  Sandy Peak (3168) Bluetooth Module
 product INTEL2 JFP 0x0aaa  Jefferson Peak (9460/9560) Bluetooth 
Module
 product INTEL2 THP 0x0025  Thunder Peak (9160/9260) Bluetooth 
Module
@@ -2673,6 +2675,9 @@ product KEISOKUGIKEN USBDAQ   0x0068  HKS-0200 USBDAQ
 /* Kensington products */
 product KENSINGTON ORBIT   0x1003  Orbit USB/PS2 trackball
 product KENSINGTON TURBOBALL   0x1005  TurboBall
+
+/* Synaptics products */
+product SYNAPTICS FPR9A0x009a  Fingerprint Reader
 
 /* Keyspan products */
 product KEYSPAN USA28_NF   0x0101  USA-28 serial Adapter (no firmware)
___
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: r346392 - stable/11/sys/compat/linuxkpi/common/include/linux

2019-04-19 Thread Bjoern A. Zeeb
Author: bz
Date: Fri Apr 19 15:46:08 2019
New Revision: 346392
URL: https://svnweb.freebsd.org/changeset/base/346392

Log:
  MFC r344700:
  
Add ushort and ulong to linux/types.h.
  
When porting code once written for Linux we find not only uints but also 
ushort and ulong.
Provide central typedefs as part of the linuxkpi for those as well.

Modified:
  stable/11/sys/compat/linuxkpi/common/include/linux/types.h
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/compat/linuxkpi/common/include/linux/types.h
==
--- stable/11/sys/compat/linuxkpi/common/include/linux/types.h  Fri Apr 19 
15:45:36 2019(r346391)
+++ stable/11/sys/compat/linuxkpi/common/include/linux/types.h  Fri Apr 19 
15:46:08 2019(r346392)
@@ -53,7 +53,9 @@ typedef uint32_t __be32;
 typedef uint64_t __le64;
 typedef uint64_t __be64;
 
+typedef unsigned short ushort;
 typedef unsigned intuint;
+typedef unsigned long ulong;
 typedef unsigned gfp_t;
 typedef uint64_t loff_t;
 typedef vm_paddr_t resource_size_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"


svn commit: r346391 - stable/12/sys/compat/linuxkpi/common/include/linux

2019-04-19 Thread Bjoern A. Zeeb
Author: bz
Date: Fri Apr 19 15:45:36 2019
New Revision: 346391
URL: https://svnweb.freebsd.org/changeset/base/346391

Log:
  MFC r344700:
  
Add ushort and ulong to linux/types.h.
  
When porting code once written for Linux we find not only uints but also 
ushort and ulong.
Provide central typedefs as part of the linuxkpi for those as well.

Modified:
  stable/12/sys/compat/linuxkpi/common/include/linux/types.h
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/compat/linuxkpi/common/include/linux/types.h
==
--- stable/12/sys/compat/linuxkpi/common/include/linux/types.h  Fri Apr 19 
15:44:45 2019(r346390)
+++ stable/12/sys/compat/linuxkpi/common/include/linux/types.h  Fri Apr 19 
15:45:36 2019(r346391)
@@ -53,7 +53,9 @@ typedef uint32_t __be32;
 typedef uint64_t __le64;
 typedef uint64_t __be64;
 
+typedef unsigned short ushort;
 typedef unsigned intuint;
+typedef unsigned long ulong;
 typedef unsigned gfp_t;
 typedef uint64_t loff_t;
 typedef vm_paddr_t resource_size_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"


svn commit: r346390 - head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs

2019-04-19 Thread Alexander Motin
Author: mav
Date: Fri Apr 19 15:44:45 2019
New Revision: 346390
URL: https://svnweb.freebsd.org/changeset/base/346390

Log:
  Change the way FreeBSD GID inheritance is hacked.
  
  I believe previous ifdef caused NULL dereference in later zfs_log_create()
  on attempt to create file inside directory belonging to ephemeral group
  created on illumos, trying to write to log information about GID domain
  of the newly created file, inheriting the ephemeral GID.
  
  This patch reuses original illumos SGID code with exception that due to
  lack of ID mapping code on FreeBSD ephemeral GID will turn into GID_NOBODY
  by another ifdef inside zfs_fuid_map_id().
  
  MFC after:1 month
  Sponsored by: iXsystems, Inc.

Modified:
  head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_acl.c

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 Apr 
19 15:34:21 2019(r346389)
+++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_acl.c   Fri Apr 
19 15:44:45 2019(r346390)
@@ -1655,7 +1655,9 @@ zfs_acl_ids_create(znode_t *dzp, int flag, vattr_t *va
acl_ids->z_fgid = 0;
}
if (acl_ids->z_fgid == 0) {
+#ifndef __FreeBSD_kernel__
if (dzp->z_mode & S_ISGID) {
+#endif
char*domain;
uint32_trid;
 
@@ -1674,15 +1676,13 @@ zfs_acl_ids_create(znode_t *dzp, int flag, vattr_t *va
FUID_INDEX(acl_ids->z_fgid),
acl_ids->z_fgid, ZFS_GROUP);
}
+#ifndef __FreeBSD_kernel__
} else {
acl_ids->z_fgid = zfs_fuid_create_cred(zfsvfs,
ZFS_GROUP, cr, &acl_ids->z_fuidp);
-#ifdef __FreeBSD_kernel__
-   gid = acl_ids->z_fgid = dzp->z_gid;
-#else
gid = crgetgid(cr);
-#endif
}
+#endif
}
}
 
___
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: r346389 - stable/11/sys/netinet

2019-04-19 Thread Bjoern A. Zeeb
Author: bz
Date: Fri Apr 19 15:34:21 2019
New Revision: 346389
URL: https://svnweb.freebsd.org/changeset/base/346389

Log:
  MFC r340494:
  
Improve the comment for arpresolve_full() in if_ether.c.
No functional changes.

Modified:
  stable/11/sys/netinet/if_ether.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/netinet/if_ether.c
==
--- stable/11/sys/netinet/if_ether.cFri Apr 19 15:33:54 2019
(r346388)
+++ stable/11/sys/netinet/if_ether.cFri Apr 19 15:34:21 2019
(r346389)
@@ -431,10 +431,10 @@ arprequest(struct ifnet *ifp, const struct in_addr *si
 /*
  * Resolve an IP address into an ethernet address - heavy version.
  * Used internally by arpresolve().
- * We have already checked than  we can't use existing lle without
- * modification so we have to acquire LLE_EXCLUSIVE lle lock.
+ * We have already checked that we can't use an existing lle without
+ * modification so we have to acquire an LLE_EXCLUSIVE lle lock.
  *
- * On success, desten and flags are filled in and the function returns 0;
+ * On success, desten and pflags are filled in and the function returns 0;
  * If the packet must be held pending resolution, we return EWOULDBLOCK
  * On other errors, we return the corresponding error code.
  * Note that m_freem() handles 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: r346388 - stable/12/sys/netinet

2019-04-19 Thread Bjoern A. Zeeb
Author: bz
Date: Fri Apr 19 15:33:54 2019
New Revision: 346388
URL: https://svnweb.freebsd.org/changeset/base/346388

Log:
  MFC r340494:
  
Improve the comment for arpresolve_full() in if_ether.c.
No functional changes.

Modified:
  stable/12/sys/netinet/if_ether.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/netinet/if_ether.c
==
--- stable/12/sys/netinet/if_ether.cFri Apr 19 15:05:32 2019
(r346387)
+++ stable/12/sys/netinet/if_ether.cFri Apr 19 15:33:54 2019
(r346388)
@@ -433,10 +433,10 @@ arprequest(struct ifnet *ifp, const struct in_addr *si
 /*
  * Resolve an IP address into an ethernet address - heavy version.
  * Used internally by arpresolve().
- * We have already checked than  we can't use existing lle without
- * modification so we have to acquire LLE_EXCLUSIVE lle lock.
+ * We have already checked that we can't use an existing lle without
+ * modification so we have to acquire an LLE_EXCLUSIVE lle lock.
  *
- * On success, desten and flags are filled in and the function returns 0;
+ * On success, desten and pflags are filled in and the function returns 0;
  * If the packet must be held pending resolution, we return EWOULDBLOCK
  * On other errors, we return the corresponding error code.
  * Note that m_freem() handles 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: r346386 - in head/sys: dev/bge dev/pci dev/twa x86/iommu

2019-04-19 Thread Tycho Nightingale
Author: tychon
Date: Fri Apr 19 13:43:33 2019
New Revision: 346386
URL: https://svnweb.freebsd.org/changeset/base/346386

Log:
  remove the 4GB boundary requirement on PCI DMA segments
  
  Reviewed by:  kib
  Discussed with:   jhb
  Sponsored by: Dell EMC Isilon
  Differential Revision:https://reviews.freebsd.org/D19867

Modified:
  head/sys/dev/bge/if_bgereg.h
  head/sys/dev/pci/pci.c
  head/sys/dev/pci/pcivar.h
  head/sys/dev/twa/tw_osl.h
  head/sys/dev/twa/tw_osl_freebsd.c
  head/sys/x86/iommu/intel_ctx.c

Modified: head/sys/dev/bge/if_bgereg.h
==
--- head/sys/dev/bge/if_bgereg.hFri Apr 19 13:23:41 2019
(r346385)
+++ head/sys/dev/bge/if_bgereg.hFri Apr 19 13:43:33 2019
(r346386)
@@ -3067,3 +3067,11 @@ struct bge_softc {
 #defineBGE_LOCK_ASSERT(_sc)mtx_assert(&(_sc)->bge_mtx, MA_OWNED)
 #defineBGE_UNLOCK(_sc) mtx_unlock(&(_sc)->bge_mtx)
 #defineBGE_LOCK_DESTROY(_sc)   mtx_destroy(&(_sc)->bge_mtx)
+
+#ifdef BUS_SPACE_MAXADDR
+#if (BUS_SPACE_MAXADDR > 0x)
+#defineBGE_DMA_BOUNDARY(0x1)
+#else
+#defineBGE_DMA_BOUNDARY0
+#endif
+#endif

Modified: head/sys/dev/pci/pci.c
==
--- head/sys/dev/pci/pci.c  Fri Apr 19 13:23:41 2019(r346385)
+++ head/sys/dev/pci/pci.c  Fri Apr 19 13:43:33 2019(r346386)
@@ -4343,9 +4343,6 @@ pci_attach_common(device_t dev)
 {
struct pci_softc *sc;
int busno, domain;
-#ifdef PCI_DMA_BOUNDARY
-   int error, tag_valid;
-#endif
 #ifdef PCI_RES_BUS
int rid;
 #endif
@@ -4365,23 +4362,7 @@ pci_attach_common(device_t dev)
if (bootverbose)
device_printf(dev, "domain=%d, physical bus=%d\n",
domain, busno);
-#ifdef PCI_DMA_BOUNDARY
-   tag_valid = 0;
-   if (device_get_devclass(device_get_parent(device_get_parent(dev))) !=
-   devclass_find("pci")) {
-   error = bus_dma_tag_create(bus_get_dma_tag(dev), 1,
-   PCI_DMA_BOUNDARY, BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR,
-   NULL, NULL, BUS_SPACE_MAXSIZE, BUS_SPACE_UNRESTRICTED,
-   BUS_SPACE_MAXSIZE, 0, NULL, NULL, &sc->sc_dma_tag);
-   if (error)
-   device_printf(dev, "Failed to create DMA tag: %d\n",
-   error);
-   else
-   tag_valid = 1;
-   }
-   if (!tag_valid)
-#endif
-   sc->sc_dma_tag = bus_get_dma_tag(dev);
+   sc->sc_dma_tag = bus_get_dma_tag(dev);
return (0);
 }
 

Modified: head/sys/dev/pci/pcivar.h
==
--- head/sys/dev/pci/pcivar.h   Fri Apr 19 13:23:41 2019(r346385)
+++ head/sys/dev/pci/pcivar.h   Fri Apr 19 13:43:33 2019(r346386)
@@ -693,14 +693,6 @@ intpcie_link_reset(device_t port, int 
pcie_location);
 
 void   pci_print_faulted_dev(void);
 
-#ifdef BUS_SPACE_MAXADDR
-#if (BUS_SPACE_MAXADDR > 0x)
-#definePCI_DMA_BOUNDARY0x1
-#else
-#definePCI_DMA_BOUNDARY0
-#endif
-#endif
-
 #endif /* _SYS_BUS_H_ */
 
 /*

Modified: head/sys/dev/twa/tw_osl.h
==
--- head/sys/dev/twa/tw_osl.h   Fri Apr 19 13:23:41 2019(r346385)
+++ head/sys/dev/twa/tw_osl.h   Fri Apr 19 13:43:33 2019(r346386)
@@ -57,6 +57,12 @@
 #define TW_OSLI_MAX_NUM_IOS(TW_OSLI_MAX_NUM_REQUESTS - 2)
 #define TW_OSLI_MAX_NUM_AENS   0x100
 
+#ifdef PAE
+#defineTW_OSLI_DMA_BOUNDARY(1u << 31)
+#else
+#defineTW_OSLI_DMA_BOUNDARY((bus_size_t)((uint64_t)1 << 
32))
+#endif
+
 /* Possible values of req->state. */
 #define TW_OSLI_REQ_STATE_INIT 0x0 /* being initialized */
 #define TW_OSLI_REQ_STATE_BUSY 0x1 /* submitted to CL */

Modified: head/sys/dev/twa/tw_osl_freebsd.c
==
--- head/sys/dev/twa/tw_osl_freebsd.c   Fri Apr 19 13:23:41 2019
(r346385)
+++ head/sys/dev/twa/tw_osl_freebsd.c   Fri Apr 19 13:43:33 2019
(r346386)
@@ -551,7 +551,7 @@ tw_osli_alloc_mem(struct twa_softc *sc)
/* Create the parent dma tag. */
if (bus_dma_tag_create(bus_get_dma_tag(sc->bus_dev), /* parent */
sc->alignment,  /* alignment */
-   0,  /* boundary */
+   TW_OSLI_DMA_BOUNDARY,   /* boundary */
BUS_SPACE_MAXADDR,  /* lowaddr */
BUS_SPACE_MAXADDR,  /* highaddr */
NULL, NULL, /* filter, filterarg */

svn commit: r346385 - in stable: 11/etc 12/usr.sbin/portsnap/portsnap

2019-04-19 Thread Glen Barber
Author: gjb
Date: Fri Apr 19 13:23:41 2019
New Revision: 346385
URL: https://svnweb.freebsd.org/changeset/base/346385

Log:
  MFC r346275:
   Remove INDEX-10 reference, as 10.x is now EoL.
  
  Sponsored by: The FreeBSD Foundation

Modified:
  stable/12/usr.sbin/portsnap/portsnap/portsnap.conf
Directory Properties:
  stable/12/   (props changed)

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

Modified: stable/12/usr.sbin/portsnap/portsnap/portsnap.conf
==
--- stable/12/usr.sbin/portsnap/portsnap/portsnap.conf  Fri Apr 19 13:18:54 
2019(r346384)
+++ stable/12/usr.sbin/portsnap/portsnap/portsnap.conf  Fri Apr 19 13:23:41 
2019(r346385)
@@ -30,6 +30,5 @@ KEYPRINT=9b5feee6d69f170e3dd0a2c8e469ddbd64f13f978f2f3
 # REFUSE korean polish portuguese russian ukrainian vietnamese
 
 # List of INDEX files to build and the DESCRIBE file to use for each
-#INDEX INDEX-10 DESCRIBE.10
 #INDEX INDEX-11 DESCRIBE.11
 INDEX INDEX-12 DESCRIBE.12
___
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: r346385 - in stable: 11/etc 12/usr.sbin/portsnap/portsnap

2019-04-19 Thread Glen Barber
Author: gjb
Date: Fri Apr 19 13:23:41 2019
New Revision: 346385
URL: https://svnweb.freebsd.org/changeset/base/346385

Log:
  MFC r346275:
   Remove INDEX-10 reference, as 10.x is now EoL.
  
  Sponsored by: The FreeBSD Foundation

Modified:
  stable/11/etc/portsnap.conf
Directory Properties:
  stable/11/   (props changed)

Changes in other areas also in this revision:
Modified:
  stable/12/usr.sbin/portsnap/portsnap/portsnap.conf
Directory Properties:
  stable/12/   (props changed)

Modified: stable/11/etc/portsnap.conf
==
--- stable/11/etc/portsnap.conf Fri Apr 19 13:18:54 2019(r346384)
+++ stable/11/etc/portsnap.conf Fri Apr 19 13:23:41 2019(r346385)
@@ -30,5 +30,4 @@ KEYPRINT=9b5feee6d69f170e3dd0a2c8e469ddbd64f13f978f2f3
 # REFUSE korean polish portuguese russian ukrainian vietnamese
 
 # List of INDEX files to build and the DESCRIBE file to use for each
-#INDEX INDEX-10 DESCRIBE.10
 INDEX INDEX-11 DESCRIBE.11
___
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: r346384 - in stable/11: lib/libdevctl usr.sbin/devctl

2019-04-19 Thread Konstantin Belousov
Author: kib
Date: Fri Apr 19 13:18:54 2019
New Revision: 346384
URL: https://svnweb.freebsd.org/changeset/base/346384

Log:
  MFC r345966, r345968:
  Implement devctl(8) command 'reset', using DEV_RESET /dev/devctl2 ioctl.

Modified:
  stable/11/lib/libdevctl/devctl.3
  stable/11/lib/libdevctl/devctl.c
  stable/11/lib/libdevctl/devctl.h
  stable/11/usr.sbin/devctl/devctl.8
  stable/11/usr.sbin/devctl/devctl.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/lib/libdevctl/devctl.3
==
--- stable/11/lib/libdevctl/devctl.3Fri Apr 19 13:09:16 2019
(r346383)
+++ stable/11/lib/libdevctl/devctl.3Fri Apr 19 13:18:54 2019
(r346384)
@@ -25,7 +25,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd August 29, 2016
+.Dd April 4, 2019
 .Dt DEVCTL 3
 .Os
 .Sh NAME
@@ -37,6 +37,7 @@
 .Nm devctl_disable ,
 .Nm devctl_enable ,
 .Nm devctl_rescan ,
+.Nm devctl_reset ,
 .Nm devctl_resume ,
 .Nm devctl_set_driver ,
 .Nm devctl_suspend
@@ -60,6 +61,8 @@
 .Ft int
 .Fn devctl_rescan "const char *device"
 .Ft int
+.Fn devctl_reset "const char *device" "bool detach"
+.Ft int
 .Fn devctl_resume "const char *device"
 .Ft int
 .Fn devctl_set_driver "const char *device" "const char *driver" "bool force"
@@ -189,6 +192,15 @@ The
 .Fn devctl_rescan
 function rescans a bus device checking for devices that have been added or
 removed.
+.Pp
+The
+.Fn devctl_reset
+function resets the specified device using bus-specific reset method.
+The
+.Fa detach
+argument, if true, specifies that the device driver is detached before
+the reset, and re-attached afterwards.
+If false, the device is suspended before the reset, and resumed after.
 .Sh RETURN VALUES
 .Rv -std devctl_attach devctl_clear_driver devctl_delete devctl_detach \
 devctl_disable devctl_enable devctl_suspend devctl_rescan devctl_resume \
@@ -362,6 +374,21 @@ is false.
 .Fa dev
 is the root device of the device tree.
 .El
+.Pp
+The
+.Fn devctl_reset
+function may fail if:
+.Bl -tag -width Er
+.It Bq Er ENXIO
+The bus does not implement the reset method.
+.It Bq Er ETIMEDOUT
+The device failed to respond after the reset in the time limits
+specific to the bus.
+.El
+The
+.Fn devctl_reset
+function may also return errors caused by the attach, detach, suspend,
+and resume methods of the device driver.
 .Sh SEE ALSO
 .Xr devinfo 3 ,
 .Xr devstat 3 ,
@@ -376,3 +403,20 @@ If a device is suspended individually via
 .Fn devctl_suspend
 and the entire machine is subsequently suspended,
 the device will be resumed when the machine resumes.
+.Pp
+Similarly, if the device is suspended, and
+.Fn devctl_reset
+is called on the device with
+.Fa detach
+set to
+.Va false ,
+the device is resumed by the
+.Fn devctl_reset
+call.
+Or, if the driver for the device is detached manually, and
+.Fn devctl_reset
+is called on the device with
+.Fa detach
+set to
+.Va true ,
+device reset re-attaches the driver.

Modified: stable/11/lib/libdevctl/devctl.c
==
--- stable/11/lib/libdevctl/devctl.cFri Apr 19 13:09:16 2019
(r346383)
+++ stable/11/lib/libdevctl/devctl.cFri Apr 19 13:18:54 2019
(r346384)
@@ -145,3 +145,11 @@ devctl_delete(const char *device, bool force)
return (devctl_simple_request(DEV_DELETE, device, force ?
DEVF_FORCE_DELETE : 0));
 }
+
+int
+devctl_reset(const char *device, bool detach)
+{
+
+   return (devctl_simple_request(DEV_RESET, device, detach ?
+   DEVF_RESET_DETACH : 0));
+}

Modified: stable/11/lib/libdevctl/devctl.h
==
--- stable/11/lib/libdevctl/devctl.hFri Apr 19 13:09:16 2019
(r346383)
+++ stable/11/lib/libdevctl/devctl.hFri Apr 19 13:18:54 2019
(r346384)
@@ -42,6 +42,7 @@ int   devctl_set_driver(const char *device, const char *
 intdevctl_clear_driver(const char *device, bool force);
 intdevctl_rescan(const char *device);
 intdevctl_delete(const char *device, bool force);
+intdevctl_reset(const char *device, bool detach);
 __END_DECLS
 
 #endif /* !__DEVCTL_H__ */

Modified: stable/11/usr.sbin/devctl/devctl.8
==
--- stable/11/usr.sbin/devctl/devctl.8  Fri Apr 19 13:09:16 2019
(r346383)
+++ stable/11/usr.sbin/devctl/devctl.8  Fri Apr 19 13:18:54 2019
(r346384)
@@ -25,7 +25,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd August 29, 2016
+.Dd April 4, 2019
 .Dt DEVCTL 8
 .Os
 .Sh NAME
@@ -67,6 +67,10 @@
 .Cm delete
 .Op Fl f
 .Ar device
+.Nm
+.Cm reset
+.Op Fl d
+.Ar device
 .Sh DESCRIPTION
 The
 .Nm
@@ -167,7 +171,35 @@ the device will be deleted even if it is physically pr
 This command should be used with care as a device that is deleted but present
 can no longer be used unless the parent bus device rediscovers the device via
 a rescan request.
+.It Xo Cm 

svn commit: r346383 - in stable/11/sys: kern sys

2019-04-19 Thread Konstantin Belousov
Author: kib
Date: Fri Apr 19 13:09:16 2019
New Revision: 346383
URL: https://svnweb.freebsd.org/changeset/base/346383

Log:
  MFC r345965:
  Add DEV_RESET /dev/devctl2 ioctl.

Modified:
  stable/11/sys/kern/subr_bus.c
  stable/11/sys/sys/bus.h
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/kern/subr_bus.c
==
--- stable/11/sys/kern/subr_bus.c   Fri Apr 19 13:04:48 2019
(r346382)
+++ stable/11/sys/kern/subr_bus.c   Fri Apr 19 13:09:16 2019
(r346383)
@@ -5476,6 +5476,7 @@ devctl2_ioctl(struct cdev *cdev, u_long cmd, caddr_t d
case DEV_CLEAR_DRIVER:
case DEV_RESCAN:
case DEV_DELETE:
+   case DEV_RESET:
error = priv_check(td, PRIV_DRIVER);
if (error == 0)
error = find_device(req, &dev);
@@ -5683,6 +5684,14 @@ devctl2_ioctl(struct cdev *cdev, u_long cmd, caddr_t d
error = device_delete_child(parent, dev);
break;
}
+   case DEV_RESET:
+   if ((req->dr_flags & ~(DEVF_RESET_DETACH)) != 0) {
+   error = EINVAL;
+   break;
+   }
+   error = BUS_RESET_CHILD(device_get_parent(dev), dev,
+   req->dr_flags);
+   break;
}
mtx_unlock(&Giant);
return (error);

Modified: stable/11/sys/sys/bus.h
==
--- stable/11/sys/sys/bus.h Fri Apr 19 13:04:48 2019(r346382)
+++ stable/11/sys/sys/bus.h Fri Apr 19 13:09:16 2019(r346383)
@@ -120,6 +120,7 @@ struct devreq {
 #defineDEV_CLEAR_DRIVER _IOW('D', 8, struct devreq)
 #defineDEV_RESCAN  _IOW('D', 9, struct devreq)
 #defineDEV_DELETE  _IOW('D', 10, struct devreq)
+#defineDEV_RESET   _IOW('D', 13, struct devreq)
 
 /* Flags for DEV_DETACH and DEV_DISABLE. */
 #defineDEVF_FORCE_DETACH   0x001
___
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: r340905 - in stable/12: release/pkg_repos usr.sbin/pkg

2019-04-19 Thread Glen Barber
On Thu, Apr 18, 2019 at 10:02:53PM +, Colin Percival wrote:
> On 11/24/18 9:47 AM, Glen Barber wrote:
> > Author: gjb
> > Date: Sat Nov 24 17:47:53 2018
> > New Revision: 340905
> > URL: https://svnweb.freebsd.org/changeset/base/340905
> > 
> > Log:
> >   Revert r340161 in stable/12, setting the default pkg(8) repository back
> >   to 'latest' from 'quarterly' prior to branching releng/12.0.
> It looks like this is incorrect for non-x86 architectures.  Portmgr may
> correct me here, but it looks like "latest" builds are only done on non-x86
> architectures on HEAD.  (The same problem also applies on stable/11.)
> 
> I'm guessing that the answer here is to have different package configurations
> installed depending on the architecture; I knew how to do this with the old
> style of src/etc but I'm not sure how to do it now that pkgbase has spread
> configuration files all over the tree.
> 

For 13.0-CURRENT, both latest and quarterly are updated.  For non-x86 on
12.0-STABLE and 11.2-STABLE, quarterly is updated (not latest), so from
a general sense of this particular commit, it is correct.

But you are also correct in your assertion that the current default
(latest) for non-x86 does appear to be incorrect.

I'll do some poking around into this.

Thank you for bringing this up.

Glen



signature.asc
Description: PGP signature


svn commit: r346382 - stable/11/sys/dev/pci

2019-04-19 Thread Konstantin Belousov
Author: kib
Date: Fri Apr 19 13:04:48 2019
New Revision: 346382
URL: https://svnweb.freebsd.org/changeset/base/346382

Log:
  MFC r345963, r345997:
  Implement resets for PCI buses and PCIe bridges.

Modified:
  stable/11/sys/dev/pci/pci.c
  stable/11/sys/dev/pci/pci_pci.c
  stable/11/sys/dev/pci/pcivar.h
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/dev/pci/pci.c
==
--- stable/11/sys/dev/pci/pci.c Fri Apr 19 12:57:37 2019(r346381)
+++ stable/11/sys/dev/pci/pci.c Fri Apr 19 13:04:48 2019(r346382)
@@ -121,6 +121,10 @@ static voidpci_resume_msi(device_t dev);
 static voidpci_resume_msix(device_t dev);
 static int pci_remap_intr_method(device_t bus, device_t dev,
u_int irq);
+static int pci_reset_post(device_t dev, device_t child);
+static int pci_reset_prepare(device_t dev, device_t child);
+static int pci_reset_child(device_t dev, device_t child,
+   int flags);
 
 static int pci_get_id_method(device_t dev, device_t child,
enum pci_id_type type, uintptr_t *rid);
@@ -145,6 +149,9 @@ static device_method_t pci_methods[] = {
DEVMETHOD(bus_driver_added, pci_driver_added),
DEVMETHOD(bus_setup_intr,   pci_setup_intr),
DEVMETHOD(bus_teardown_intr,pci_teardown_intr),
+   DEVMETHOD(bus_reset_prepare,pci_reset_prepare),
+   DEVMETHOD(bus_reset_post,   pci_reset_post),
+   DEVMETHOD(bus_reset_child,  pci_reset_child),
 
DEVMETHOD(bus_get_dma_tag,  pci_get_dma_tag),
DEVMETHOD(bus_get_resource_list,pci_get_resource_list),
@@ -6295,6 +6302,94 @@ pcie_flr(device_t dev, u_int max_delay, bool force)
PCIEM_STA_TRANSACTION_PND)
pci_printf(&dinfo->cfg, "Transactions pending after FLR!\n");
return (true);
+}
+
+/*
+ * Attempt a power-management reset by cycling the device in/out of D3
+ * state.  PCI spec says we can only go into D3 state from D0 state.
+ * Transition from D[12] into D0 before going to D3 state.
+ */
+int
+pci_power_reset(device_t dev)
+{
+   int ps;
+
+   ps = pci_get_powerstate(dev);
+   if (ps != PCI_POWERSTATE_D0 && ps != PCI_POWERSTATE_D3)
+   pci_set_powerstate(dev, PCI_POWERSTATE_D0);
+   pci_set_powerstate(dev, PCI_POWERSTATE_D3);
+   pci_set_powerstate(dev, ps);
+   return (0);
+}
+
+/*
+ * Try link drop and retrain of the downstream port of upstream
+ * switch, for PCIe.  According to the PCIe 3.0 spec 6.6.1, this must
+ * cause Conventional Hot reset of the device in the slot.
+ * Alternative, for PCIe, could be the secondary bus reset initiatied
+ * on the upstream switch PCIR_BRIDGECTL_1, bit 6.
+ */
+int
+pcie_link_reset(device_t port, int pcie_location)
+{
+   uint16_t v;
+
+   v = pci_read_config(port, pcie_location + PCIER_LINK_CTL, 2);
+   v |= PCIEM_LINK_CTL_LINK_DIS;
+   pci_write_config(port, pcie_location + PCIER_LINK_CTL, v, 2);
+   pause_sbt("pcier1", mstosbt(20), 0, 0);
+   v &= ~PCIEM_LINK_CTL_LINK_DIS;
+   v |= PCIEM_LINK_CTL_RETRAIN_LINK;
+   pci_write_config(port, pcie_location + PCIER_LINK_CTL, v, 2);
+   pause_sbt("pcier2", mstosbt(100), 0, 0); /* 100 ms */
+   v = pci_read_config(port, pcie_location + PCIER_LINK_STA, 2);
+   return ((v & PCIEM_LINK_STA_TRAINING) != 0 ? ETIMEDOUT : 0);
+}
+
+static int
+pci_reset_post(device_t dev, device_t child)
+{
+
+   if (dev == device_get_parent(child))
+   pci_restore_state(child);
+   return (0);
+}
+
+static int
+pci_reset_prepare(device_t dev, device_t child)
+{
+
+   if (dev == device_get_parent(child))
+   pci_save_state(child);
+   return (0);
+}
+
+static int
+pci_reset_child(device_t dev, device_t child, int flags)
+{
+   int error;
+
+   if (dev == NULL || device_get_parent(child) != dev)
+   return (0);
+   if ((flags & DEVF_RESET_DETACH) != 0) {
+   error = device_get_state(child) == DS_ATTACHED ?
+   device_detach(child) : 0;
+   } else {
+   error = BUS_SUSPEND_CHILD(dev, child);
+   }
+   if (error == 0) {
+   if (!pcie_flr(child, 1000, false)) {
+   error = BUS_RESET_PREPARE(dev, child);
+   if (error == 0)
+   pci_power_reset(child);
+   BUS_RESET_POST(dev, child);
+   }
+   if ((flags & DEVF_RESET_DETACH) != 0)
+   device_probe_and_attach(child);
+   else
+   BUS_RESUME_CHILD(dev, child);
+   }
+   return (error);
 }
 
 static void

Modified: stable/11/sys/dev/pci/pci_pci.c
==

svn commit: r346381 - in stable/11/sys: kern sys

2019-04-19 Thread Konstantin Belousov
Author: kib
Date: Fri Apr 19 12:57:37 2019
New Revision: 346381
URL: https://svnweb.freebsd.org/changeset/base/346381

Log:
  MFC r345960:
  Provide newbus infrastructure for initiating device reset.

Modified:
  stable/11/sys/kern/bus_if.m
  stable/11/sys/kern/subr_bus.c
  stable/11/sys/sys/bus.h
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/kern/bus_if.m
==
--- stable/11/sys/kern/bus_if.m Fri Apr 19 12:54:05 2019(r346380)
+++ stable/11/sys/kern/bus_if.m Fri Apr 19 12:57:37 2019(r346381)
@@ -66,6 +66,16 @@ CODE {
 
panic("bus_add_child is not implemented");
}
+
+   static int null_reset_post(device_t bus, device_t dev)
+   {
+   return (0);
+   }
+
+   static int null_reset_prepare(device_t bus, device_t dev)
+   {
+   return (0);
+   }
 };
 
 /**
@@ -810,3 +820,48 @@ METHOD int get_cpus {
size_t  _setsize;
cpuset_t*_cpuset;
 } DEFAULT bus_generic_get_cpus;
+
+/**
+ * @brief Prepares the given child of the bus for reset
+ *
+ * Typically bus detaches or suspends children' drivers, and then
+ * calls this method to save bus-specific information, for instance,
+ * PCI config space, which is damaged by reset.
+ *
+ * The bus_helper_reset_prepare() helper is provided to ease
+ * implementing bus reset methods.
+ *
+ * @param _dev the bus device
+ * @param _child   the child device
+ */
+METHOD int reset_prepare {
+   device_t _dev;
+   device_t _child;
+} DEFAULT null_reset_prepare;
+
+/**
+ * @brief Restores the child operations after the reset
+ *
+ * The bus_helper_reset_post() helper is provided to ease
+ * implementing bus reset methods.
+ *
+ * @param _dev the bus device
+ * @param _child   the child device
+ */
+METHOD int reset_post {
+   device_t _dev;
+   device_t _child;
+} DEFAULT null_reset_post;
+
+/**
+ * @brief Performs reset of the child
+ *
+ * @param _dev the bus device
+ * @param _child   the child device
+ * @param _flags   DEVF_RESET_ flags
+ */
+METHOD int reset_child {
+   device_t _dev;
+   device_t _child;
+   int _flags;
+};

Modified: stable/11/sys/kern/subr_bus.c
==
--- stable/11/sys/kern/subr_bus.c   Fri Apr 19 12:54:05 2019
(r346380)
+++ stable/11/sys/kern/subr_bus.c   Fri Apr 19 12:57:37 2019
(r346381)
@@ -3822,6 +3822,96 @@ bus_generic_resume(device_t dev)
return (0);
 }
 
+
+/**
+ * @brief Helper function for implementing BUS_RESET_POST
+ *
+ * Bus can use this function to implement common operations of
+ * re-attaching or resuming the children after the bus itself was
+ * reset, and after restoring bus-unique state of children.
+ *
+ * @param dev  The bus
+ * #param flagsDEVF_RESET_*
+ */
+int
+bus_helper_reset_post(device_t dev, int flags)
+{
+   device_t child;
+   int error, error1;
+
+   error = 0;
+   TAILQ_FOREACH(child, &dev->children,link) {
+   BUS_RESET_POST(dev, child);
+   error1 = (flags & DEVF_RESET_DETACH) != 0 ?
+   device_probe_and_attach(child) :
+   BUS_RESUME_CHILD(dev, child);
+   if (error == 0 && error1 != 0)
+   error = error1;
+   }
+   return (error);
+}
+
+static void
+bus_helper_reset_prepare_rollback(device_t dev, device_t child, int flags)
+{
+
+   child = TAILQ_NEXT(child, link);
+   if (child == NULL)
+   return;
+   TAILQ_FOREACH_FROM(child, &dev->children,link) {
+   BUS_RESET_POST(dev, child);
+   if ((flags & DEVF_RESET_DETACH) != 0)
+   device_probe_and_attach(child);
+   else
+   BUS_RESUME_CHILD(dev, child);
+   }
+}
+
+/**
+ * @brief Helper function for implementing BUS_RESET_PREPARE
+ *
+ * Bus can use this function to implement common operations of
+ * detaching or suspending the children before the bus itself is
+ * reset, and then save bus-unique state of children that must
+ * persists around reset.
+ *
+ * @param dev  The bus
+ * #param flagsDEVF_RESET_*
+ */
+int
+bus_helper_reset_prepare(device_t dev, int flags)
+{
+   device_t child;
+   int error;
+
+   if (dev->state != DS_ATTACHED)
+   return (EBUSY);
+
+   TAILQ_FOREACH_REVERSE(child, &dev->children, device_list, link) {
+   if ((flags & DEVF_RESET_DETACH) != 0) {
+   error = device_get_state(child) == DS_ATTACHED ?
+   device_detach(child) : 0;
+   } else {
+   error = BUS_SUSPEND_CHILD(dev, child);
+   }
+   if (error == 0) {
+   error = BUS_RESET_PREPARE(dev, child);
+ 

svn commit: r346380 - in stable/12: lib/libdevctl usr.sbin/devctl

2019-04-19 Thread Konstantin Belousov
Author: kib
Date: Fri Apr 19 12:54:05 2019
New Revision: 346380
URL: https://svnweb.freebsd.org/changeset/base/346380

Log:
  MFC r345966, r345968:
  Implement devctl(8) command 'reset', using DEV_RESET /dev/devctl2 ioctl.

Modified:
  stable/12/lib/libdevctl/devctl.3
  stable/12/lib/libdevctl/devctl.c
  stable/12/lib/libdevctl/devctl.h
  stable/12/usr.sbin/devctl/devctl.8
  stable/12/usr.sbin/devctl/devctl.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/lib/libdevctl/devctl.3
==
--- stable/12/lib/libdevctl/devctl.3Fri Apr 19 12:50:25 2019
(r346379)
+++ stable/12/lib/libdevctl/devctl.3Fri Apr 19 12:54:05 2019
(r346380)
@@ -25,7 +25,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd August 22, 2018
+.Dd April 4, 2019
 .Dt DEVCTL 3
 .Os
 .Sh NAME
@@ -38,6 +38,7 @@
 .Nm devctl_enable ,
 .Nm devctl_freeze ,
 .Nm devctl_rescan ,
+.Nm devctl_reset ,
 .Nm devctl_resume ,
 .Nm devctl_set_driver ,
 .Nm devctl_suspend ,
@@ -64,6 +65,8 @@
 .Ft int
 .Fn devctl_rescan "const char *device"
 .Ft int
+.Fn devctl_reset "const char *device" "bool detach"
+.Ft int
 .Fn devctl_resume "const char *device"
 .Ft int
 .Fn devctl_set_driver "const char *device" "const char *driver" "bool force"
@@ -205,6 +208,15 @@ The
 .Fn devctl_thaw
 function resumes (thaws the freeze) probe and attach processing
 initiated in response to drivers being loaded.
+.Pp
+The
+.Fn devctl_reset
+function resets the specified device using bus-specific reset method.
+The
+.Fa detach
+argument, if true, specifies that the device driver is detached before
+the reset, and re-attached afterwards.
+If false, the device is suspended before the reset, and resumed after.
 .Sh RETURN VALUES
 .Rv -std devctl_attach devctl_clear_driver devctl_delete devctl_detach \
 devctl_disable devctl_enable devctl_suspend devctl_rescan devctl_resume \
@@ -378,6 +390,21 @@ is false.
 .Fa dev
 is the root device of the device tree.
 .El
+.Pp
+The
+.Fn devctl_reset
+function may fail if:
+.Bl -tag -width Er
+.It Bq Er ENXIO
+The bus does not implement the reset method.
+.It Bq Er ETIMEDOUT
+The device failed to respond after the reset in the time limits
+specific to the bus.
+.El
+The
+.Fn devctl_reset
+function may also return errors caused by the attach, detach, suspend,
+and resume methods of the device driver.
 .Sh SEE ALSO
 .Xr devinfo 3 ,
 .Xr devstat 3 ,
@@ -392,3 +419,20 @@ If a device is suspended individually via
 .Fn devctl_suspend
 and the entire machine is subsequently suspended,
 the device will be resumed when the machine resumes.
+.Pp
+Similarly, if the device is suspended, and
+.Fn devctl_reset
+is called on the device with
+.Fa detach
+set to
+.Va false ,
+the device is resumed by the
+.Fn devctl_reset
+call.
+Or, if the driver for the device is detached manually, and
+.Fn devctl_reset
+is called on the device with
+.Fa detach
+set to
+.Va true ,
+device reset re-attaches the driver.

Modified: stable/12/lib/libdevctl/devctl.c
==
--- stable/12/lib/libdevctl/devctl.cFri Apr 19 12:50:25 2019
(r346379)
+++ stable/12/lib/libdevctl/devctl.cFri Apr 19 12:54:05 2019
(r346380)
@@ -159,3 +159,11 @@ devctl_thaw(void)
 
return (devctl_simple_request(DEV_THAW, "", 0));
 }
+
+int
+devctl_reset(const char *device, bool detach)
+{
+
+   return (devctl_simple_request(DEV_RESET, device, detach ?
+   DEVF_RESET_DETACH : 0));
+}

Modified: stable/12/lib/libdevctl/devctl.h
==
--- stable/12/lib/libdevctl/devctl.hFri Apr 19 12:50:25 2019
(r346379)
+++ stable/12/lib/libdevctl/devctl.hFri Apr 19 12:54:05 2019
(r346380)
@@ -44,6 +44,7 @@ int   devctl_rescan(const char *device);
 intdevctl_delete(const char *device, bool force);
 intdevctl_freeze(void);
 intdevctl_thaw(void);
+intdevctl_reset(const char *device, bool detach);
 __END_DECLS
 
 #endif /* !__DEVCTL_H__ */

Modified: stable/12/usr.sbin/devctl/devctl.8
==
--- stable/12/usr.sbin/devctl/devctl.8  Fri Apr 19 12:50:25 2019
(r346379)
+++ stable/12/usr.sbin/devctl/devctl.8  Fri Apr 19 12:54:05 2019
(r346380)
@@ -25,7 +25,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd August 29, 2016
+.Dd April 4, 2019
 .Dt DEVCTL 8
 .Os
 .Sh NAME
@@ -67,6 +67,10 @@
 .Cm delete
 .Op Fl f
 .Ar device
+.Nm
+.Cm reset
+.Op Fl d
+.Ar device
 .Sh DESCRIPTION
 The
 .Nm
@@ -167,7 +171,35 @@ the device will be deleted even if it is physically pr
 This command should be used with care as a device that is deleted but present
 can no longer be used unless the parent bus device rediscovers the device via
 a rescan request.
+.It Xo Cm reset
+.Op Fl d
+.Ar device
+.Xc
+Reset the device, using bus-specific reset method.
+Drivers for the devices 

svn commit: r346379 - in stable/12/sys: kern sys

2019-04-19 Thread Konstantin Belousov
Author: kib
Date: Fri Apr 19 12:50:25 2019
New Revision: 346379
URL: https://svnweb.freebsd.org/changeset/base/346379

Log:
  MFC r345965:
  Add DEV_RESET /dev/devctl2 ioctl.

Modified:
  stable/12/sys/kern/subr_bus.c
  stable/12/sys/sys/bus.h
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/kern/subr_bus.c
==
--- stable/12/sys/kern/subr_bus.c   Fri Apr 19 12:48:17 2019
(r346378)
+++ stable/12/sys/kern/subr_bus.c   Fri Apr 19 12:50:25 2019
(r346379)
@@ -5636,6 +5636,7 @@ devctl2_ioctl(struct cdev *cdev, u_long cmd, caddr_t d
case DEV_CLEAR_DRIVER:
case DEV_RESCAN:
case DEV_DELETE:
+   case DEV_RESET:
error = priv_check(td, PRIV_DRIVER);
if (error == 0)
error = find_device(req, &dev);
@@ -5860,6 +5861,14 @@ devctl2_ioctl(struct cdev *cdev, u_long cmd, caddr_t d
device_do_deferred_actions();
device_frozen = false;
}
+   break;
+   case DEV_RESET:
+   if ((req->dr_flags & ~(DEVF_RESET_DETACH)) != 0) {
+   error = EINVAL;
+   break;
+   }
+   error = BUS_RESET_CHILD(device_get_parent(dev), dev,
+   req->dr_flags);
break;
}
mtx_unlock(&Giant);

Modified: stable/12/sys/sys/bus.h
==
--- stable/12/sys/sys/bus.h Fri Apr 19 12:48:17 2019(r346378)
+++ stable/12/sys/sys/bus.h Fri Apr 19 12:50:25 2019(r346379)
@@ -130,6 +130,7 @@ struct devreq {
 #defineDEV_DELETE  _IOW('D', 10, struct devreq)
 #defineDEV_FREEZE  _IOW('D', 11, struct devreq)
 #defineDEV_THAW_IOW('D', 12, struct devreq)
+#defineDEV_RESET   _IOW('D', 13, struct devreq)
 
 /* Flags for DEV_DETACH and DEV_DISABLE. */
 #defineDEVF_FORCE_DETACH   0x001
___
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: r346378 - in stable/12/sys: amd64/vmm/io dev/pci

2019-04-19 Thread Konstantin Belousov
Author: kib
Date: Fri Apr 19 12:48:17 2019
New Revision: 346378
URL: https://svnweb.freebsd.org/changeset/base/346378

Log:
  MFC r345963, r345997:
  Implement resets for PCI buses and PCIe bridges.

Modified:
  stable/12/sys/amd64/vmm/io/ppt.c
  stable/12/sys/dev/pci/pci.c
  stable/12/sys/dev/pci/pci_pci.c
  stable/12/sys/dev/pci/pcivar.h
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/amd64/vmm/io/ppt.c
==
--- stable/12/sys/amd64/vmm/io/ppt.cFri Apr 19 12:45:45 2019
(r346377)
+++ stable/12/sys/amd64/vmm/io/ppt.cFri Apr 19 12:48:17 2019
(r346378)
@@ -356,25 +356,12 @@ ppt_is_mmio(struct vm *vm, vm_paddr_t gpa)
 static void
 ppt_pci_reset(device_t dev)
 {
-   int ps;
 
if (pcie_flr(dev,
-max(pcie_get_max_completion_timeout(dev) / 1000, 10),
-true))
+max(pcie_get_max_completion_timeout(dev) / 1000, 10), true))
return;
 
-   /*
-* If FLR fails, attempt a power-management reset by cycling
-* the device in/out of D3 state.
-* PCI spec says we can only go into D3 state from D0 state.
-* Transition from D[12] into D0 before going to D3 state.
-*/
-   ps = pci_get_powerstate(dev);
-   if (ps != PCI_POWERSTATE_D0 && ps != PCI_POWERSTATE_D3)
-   pci_set_powerstate(dev, PCI_POWERSTATE_D0);
-   if (pci_get_powerstate(dev) != PCI_POWERSTATE_D3)
-   pci_set_powerstate(dev, PCI_POWERSTATE_D3);
-   pci_set_powerstate(dev, ps);
+   pci_power_reset(dev);
 }
 
 int

Modified: stable/12/sys/dev/pci/pci.c
==
--- stable/12/sys/dev/pci/pci.c Fri Apr 19 12:45:45 2019(r346377)
+++ stable/12/sys/dev/pci/pci.c Fri Apr 19 12:48:17 2019(r346378)
@@ -125,6 +125,10 @@ static int pci_remap_intr_method(device_t bus, 
device
u_int irq);
 static voidpci_hint_device_unit(device_t acdev, device_t child,
const char *name, int *unitp);
+static int pci_reset_post(device_t dev, device_t child);
+static int pci_reset_prepare(device_t dev, device_t child);
+static int pci_reset_child(device_t dev, device_t child,
+   int flags);
 
 static int pci_get_id_method(device_t dev, device_t child,
enum pci_id_type type, uintptr_t *rid);
@@ -149,6 +153,9 @@ static device_method_t pci_methods[] = {
DEVMETHOD(bus_driver_added, pci_driver_added),
DEVMETHOD(bus_setup_intr,   pci_setup_intr),
DEVMETHOD(bus_teardown_intr,pci_teardown_intr),
+   DEVMETHOD(bus_reset_prepare,pci_reset_prepare),
+   DEVMETHOD(bus_reset_post,   pci_reset_post),
+   DEVMETHOD(bus_reset_child,  pci_reset_child),
 
DEVMETHOD(bus_get_dma_tag,  pci_get_dma_tag),
DEVMETHOD(bus_get_resource_list,pci_get_resource_list),
@@ -6353,6 +6360,94 @@ pcie_flr(device_t dev, u_int max_delay, bool force)
PCIEM_STA_TRANSACTION_PND)
pci_printf(&dinfo->cfg, "Transactions pending after FLR!\n");
return (true);
+}
+
+/*
+ * Attempt a power-management reset by cycling the device in/out of D3
+ * state.  PCI spec says we can only go into D3 state from D0 state.
+ * Transition from D[12] into D0 before going to D3 state.
+ */
+int
+pci_power_reset(device_t dev)
+{
+   int ps;
+
+   ps = pci_get_powerstate(dev);
+   if (ps != PCI_POWERSTATE_D0 && ps != PCI_POWERSTATE_D3)
+   pci_set_powerstate(dev, PCI_POWERSTATE_D0);
+   pci_set_powerstate(dev, PCI_POWERSTATE_D3);
+   pci_set_powerstate(dev, ps);
+   return (0);
+}
+
+/*
+ * Try link drop and retrain of the downstream port of upstream
+ * switch, for PCIe.  According to the PCIe 3.0 spec 6.6.1, this must
+ * cause Conventional Hot reset of the device in the slot.
+ * Alternative, for PCIe, could be the secondary bus reset initiatied
+ * on the upstream switch PCIR_BRIDGECTL_1, bit 6.
+ */
+int
+pcie_link_reset(device_t port, int pcie_location)
+{
+   uint16_t v;
+
+   v = pci_read_config(port, pcie_location + PCIER_LINK_CTL, 2);
+   v |= PCIEM_LINK_CTL_LINK_DIS;
+   pci_write_config(port, pcie_location + PCIER_LINK_CTL, v, 2);
+   pause_sbt("pcier1", mstosbt(20), 0, 0);
+   v &= ~PCIEM_LINK_CTL_LINK_DIS;
+   v |= PCIEM_LINK_CTL_RETRAIN_LINK;
+   pci_write_config(port, pcie_location + PCIER_LINK_CTL, v, 2);
+   pause_sbt("pcier2", mstosbt(100), 0, 0); /* 100 ms */
+   v = pci_read_config(port, pcie_location + PCIER_LINK_STA, 2);
+   return ((v & PCIEM_LINK_STA_TRAINING) != 0 ? ETIMEDOUT : 0);
+}
+
+static int
+pci_reset_post(device_t dev, device_t child)
+{
+
+   if (dev == device_get_parent(child))
+ 

svn commit: r346377 - in stable/12/sys: kern sys

2019-04-19 Thread Konstantin Belousov
Author: kib
Date: Fri Apr 19 12:45:45 2019
New Revision: 346377
URL: https://svnweb.freebsd.org/changeset/base/346377

Log:
  MFC r345960:
  Provide newbus infrastructure for initiating device reset.

Modified:
  stable/12/sys/kern/bus_if.m
  stable/12/sys/kern/subr_bus.c
  stable/12/sys/sys/bus.h
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/kern/bus_if.m
==
--- stable/12/sys/kern/bus_if.m Fri Apr 19 12:40:21 2019(r346376)
+++ stable/12/sys/kern/bus_if.m Fri Apr 19 12:45:45 2019(r346377)
@@ -66,6 +66,16 @@ CODE {
 
panic("bus_add_child is not implemented");
}
+
+   static int null_reset_post(device_t bus, device_t dev)
+   {
+   return (0);
+   }
+
+   static int null_reset_prepare(device_t bus, device_t dev)
+   {
+   return (0);
+   }
 };
 
 /**
@@ -848,3 +858,48 @@ METHOD int get_cpus {
size_t  _setsize;
cpuset_t*_cpuset;
 } DEFAULT bus_generic_get_cpus;
+
+/**
+ * @brief Prepares the given child of the bus for reset
+ *
+ * Typically bus detaches or suspends children' drivers, and then
+ * calls this method to save bus-specific information, for instance,
+ * PCI config space, which is damaged by reset.
+ *
+ * The bus_helper_reset_prepare() helper is provided to ease
+ * implementing bus reset methods.
+ *
+ * @param _dev the bus device
+ * @param _child   the child device
+ */
+METHOD int reset_prepare {
+   device_t _dev;
+   device_t _child;
+} DEFAULT null_reset_prepare;
+
+/**
+ * @brief Restores the child operations after the reset
+ *
+ * The bus_helper_reset_post() helper is provided to ease
+ * implementing bus reset methods.
+ *
+ * @param _dev the bus device
+ * @param _child   the child device
+ */
+METHOD int reset_post {
+   device_t _dev;
+   device_t _child;
+} DEFAULT null_reset_post;
+
+/**
+ * @brief Performs reset of the child
+ *
+ * @param _dev the bus device
+ * @param _child   the child device
+ * @param _flags   DEVF_RESET_ flags
+ */
+METHOD int reset_child {
+   device_t _dev;
+   device_t _child;
+   int _flags;
+};

Modified: stable/12/sys/kern/subr_bus.c
==
--- stable/12/sys/kern/subr_bus.c   Fri Apr 19 12:40:21 2019
(r346376)
+++ stable/12/sys/kern/subr_bus.c   Fri Apr 19 12:45:45 2019
(r346377)
@@ -3854,6 +3854,96 @@ bus_generic_resume(device_t dev)
return (0);
 }
 
+
+/**
+ * @brief Helper function for implementing BUS_RESET_POST
+ *
+ * Bus can use this function to implement common operations of
+ * re-attaching or resuming the children after the bus itself was
+ * reset, and after restoring bus-unique state of children.
+ *
+ * @param dev  The bus
+ * #param flagsDEVF_RESET_*
+ */
+int
+bus_helper_reset_post(device_t dev, int flags)
+{
+   device_t child;
+   int error, error1;
+
+   error = 0;
+   TAILQ_FOREACH(child, &dev->children,link) {
+   BUS_RESET_POST(dev, child);
+   error1 = (flags & DEVF_RESET_DETACH) != 0 ?
+   device_probe_and_attach(child) :
+   BUS_RESUME_CHILD(dev, child);
+   if (error == 0 && error1 != 0)
+   error = error1;
+   }
+   return (error);
+}
+
+static void
+bus_helper_reset_prepare_rollback(device_t dev, device_t child, int flags)
+{
+
+   child = TAILQ_NEXT(child, link);
+   if (child == NULL)
+   return;
+   TAILQ_FOREACH_FROM(child, &dev->children,link) {
+   BUS_RESET_POST(dev, child);
+   if ((flags & DEVF_RESET_DETACH) != 0)
+   device_probe_and_attach(child);
+   else
+   BUS_RESUME_CHILD(dev, child);
+   }
+}
+
+/**
+ * @brief Helper function for implementing BUS_RESET_PREPARE
+ *
+ * Bus can use this function to implement common operations of
+ * detaching or suspending the children before the bus itself is
+ * reset, and then save bus-unique state of children that must
+ * persists around reset.
+ *
+ * @param dev  The bus
+ * #param flagsDEVF_RESET_*
+ */
+int
+bus_helper_reset_prepare(device_t dev, int flags)
+{
+   device_t child;
+   int error;
+
+   if (dev->state != DS_ATTACHED)
+   return (EBUSY);
+
+   TAILQ_FOREACH_REVERSE(child, &dev->children, device_list, link) {
+   if ((flags & DEVF_RESET_DETACH) != 0) {
+   error = device_get_state(child) == DS_ATTACHED ?
+   device_detach(child) : 0;
+   } else {
+   error = BUS_SUSPEND_CHILD(dev, child);
+   }
+   if (error == 0) {
+   error = BUS_RESET_PREPARE(dev, child);
+ 

svn commit: r346376 - stable/11/sys/dev/smartpqi

2019-04-19 Thread Konstantin Belousov
Author: kib
Date: Fri Apr 19 12:40:21 2019
New Revision: 346376
URL: https://svnweb.freebsd.org/changeset/base/346376

Log:
  MFC r345964:
  Remove single-use DEV_RESET() macro.

Modified:
  stable/11/sys/dev/smartpqi/smartpqi_cam.c
  stable/11/sys/dev/smartpqi/smartpqi_defines.h
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/dev/smartpqi/smartpqi_cam.c
==
--- stable/11/sys/dev/smartpqi/smartpqi_cam.c   Fri Apr 19 12:38:48 2019
(r346375)
+++ stable/11/sys/dev/smartpqi/smartpqi_cam.c   Fri Apr 19 12:40:21 2019
(r346376)
@@ -726,7 +726,7 @@ static int pqisrc_io_start(struct cam_sim *sim, union 
return error;
}
/* Check device reset */
-   if (DEV_RESET(dvp)) {
+   if (dvp->reset_in_progress) {
ccb->ccb_h.status = CAM_SCSI_BUSY | CAM_REQ_INPROG | CAM_BUSY;
DBG_WARN("Device %d reset returned busy\n", 
ccb->ccb_h.target_id);
return error;

Modified: stable/11/sys/dev/smartpqi/smartpqi_defines.h
==
--- stable/11/sys/dev/smartpqi/smartpqi_defines.h   Fri Apr 19 12:38:48 
2019(r346375)
+++ stable/11/sys/dev/smartpqi/smartpqi_defines.h   Fri Apr 19 12:40:21 
2019(r346376)
@@ -382,8 +382,6 @@ enum pqisrc_ctrl_mode{
 #define IS_AIO_PATH(dev)   (dev->aio_enabled)
 #define IS_RAID_PATH(dev)  (!dev->aio_enabled)
 
-#define DEV_RESET(dvp)  (dvp->reset_in_progress)
-
 /* SOP data direction flags */
 #define SOP_DATA_DIR_NONE  0x00
 #define SOP_DATA_DIR_FROM_DEVICE   0x01
___
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: r346375 - stable/12/sys/dev/smartpqi

2019-04-19 Thread Konstantin Belousov
Author: kib
Date: Fri Apr 19 12:38:48 2019
New Revision: 346375
URL: https://svnweb.freebsd.org/changeset/base/346375

Log:
  MFC r345964:
  Remove single-use DEV_RESET() macro.

Modified:
  stable/12/sys/dev/smartpqi/smartpqi_cam.c
  stable/12/sys/dev/smartpqi/smartpqi_defines.h
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/dev/smartpqi/smartpqi_cam.c
==
--- stable/12/sys/dev/smartpqi/smartpqi_cam.c   Fri Apr 19 12:33:58 2019
(r346374)
+++ stable/12/sys/dev/smartpqi/smartpqi_cam.c   Fri Apr 19 12:38:48 2019
(r346375)
@@ -725,7 +725,7 @@ static int pqisrc_io_start(struct cam_sim *sim, union 
return error;
}
/* Check device reset */
-   if (DEV_RESET(dvp)) {
+   if (dvp->reset_in_progress) {
ccb->ccb_h.status = CAM_SCSI_BUSY | CAM_REQ_INPROG | CAM_BUSY;
DBG_WARN("Device %d reset returned busy\n", 
ccb->ccb_h.target_id);
return error;

Modified: stable/12/sys/dev/smartpqi/smartpqi_defines.h
==
--- stable/12/sys/dev/smartpqi/smartpqi_defines.h   Fri Apr 19 12:33:58 
2019(r346374)
+++ stable/12/sys/dev/smartpqi/smartpqi_defines.h   Fri Apr 19 12:38:48 
2019(r346375)
@@ -386,8 +386,6 @@ enum pqisrc_ctrl_mode{
 #define IS_AIO_PATH(dev)   (dev->aio_enabled)
 #define IS_RAID_PATH(dev)  (!dev->aio_enabled)
 
-#define DEV_RESET(dvp)  (dvp->reset_in_progress)
-
 /* SOP data direction flags */
 #define SOP_DATA_DIR_NONE  0x00
 #define SOP_DATA_DIR_FROM_DEVICE   0x01
___
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: r346374 - stable/11/lib/libdevctl

2019-04-19 Thread Konstantin Belousov
Author: kib
Date: Fri Apr 19 12:33:58 2019
New Revision: 346374
URL: https://svnweb.freebsd.org/changeset/base/346374

Log:
  MFC r345959:
  Add __BEGIN_DECLS/__END_DECLS braces to libdevctl header.

Modified:
  stable/11/lib/libdevctl/devctl.h
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/lib/libdevctl/devctl.h
==
--- stable/11/lib/libdevctl/devctl.hFri Apr 19 12:33:16 2019
(r346373)
+++ stable/11/lib/libdevctl/devctl.hFri Apr 19 12:33:58 2019
(r346374)
@@ -31,6 +31,7 @@
 
 #include 
 
+__BEGIN_DECLS
 intdevctl_attach(const char *device);
 intdevctl_detach(const char *device, bool force);
 intdevctl_enable(const char *device);
@@ -41,5 +42,6 @@ int   devctl_set_driver(const char *device, const char *
 intdevctl_clear_driver(const char *device, bool force);
 intdevctl_rescan(const char *device);
 intdevctl_delete(const char *device, bool force);
+__END_DECLS
 
 #endif /* !__DEVCTL_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: r346373 - stable/12/lib/libdevctl

2019-04-19 Thread Konstantin Belousov
Author: kib
Date: Fri Apr 19 12:33:16 2019
New Revision: 346373
URL: https://svnweb.freebsd.org/changeset/base/346373

Log:
  MFC r345959:
  Add __BEGIN_DECLS/__END_DECLS braces to libdevctl header.

Modified:
  stable/12/lib/libdevctl/devctl.h
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/lib/libdevctl/devctl.h
==
--- stable/12/lib/libdevctl/devctl.hFri Apr 19 12:31:16 2019
(r346372)
+++ stable/12/lib/libdevctl/devctl.hFri Apr 19 12:33:16 2019
(r346373)
@@ -31,6 +31,7 @@
 
 #include 
 
+__BEGIN_DECLS
 intdevctl_attach(const char *device);
 intdevctl_detach(const char *device, bool force);
 intdevctl_enable(const char *device);
@@ -43,5 +44,6 @@ int   devctl_rescan(const char *device);
 intdevctl_delete(const char *device, bool force);
 intdevctl_freeze(void);
 intdevctl_thaw(void);
+__END_DECLS
 
 #endif /* !__DEVCTL_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: r346372 - stable/11/lib/libthr/thread

2019-04-19 Thread Konstantin Belousov
Author: kib
Date: Fri Apr 19 12:31:16 2019
New Revision: 346372
URL: https://svnweb.freebsd.org/changeset/base/346372

Log:
  MFC r346158:
  Do not access mutex memory after unlock.
  
  PR:   237195

Modified:
  stable/11/lib/libthr/thread/thr_mutex.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/lib/libthr/thread/thr_mutex.c
==
--- stable/11/lib/libthr/thread/thr_mutex.c Fri Apr 19 12:30:15 2019
(r346371)
+++ stable/11/lib/libthr/thread/thr_mutex.c Fri Apr 19 12:31:16 2019
(r346372)
@@ -945,7 +945,7 @@ mutex_unlock_common(struct pthread_mutex *m, bool cv, 
 {
struct pthread *curthread;
uint32_t id;
-   int deferred, error, robust;
+   int deferred, error, private, robust;
 
if (__predict_false(m <= THR_MUTEX_DESTROYED)) {
if (m == THR_MUTEX_DESTROYED)
@@ -963,6 +963,7 @@ mutex_unlock_common(struct pthread_mutex *m, bool cv, 
return (EPERM);
 
error = 0;
+   private = (m->m_flags & PMUTEX_FLAG_PRIVATE) != 0;
if (__predict_false(PMUTEX_TYPE(m->m_flags) ==
PTHREAD_MUTEX_RECURSIVE && m->m_count > 0)) {
m->m_count--;
@@ -987,7 +988,7 @@ mutex_unlock_common(struct pthread_mutex *m, bool cv, 
if (robust)
_mutex_leave_robust(curthread, m);
}
-   if (!cv && m->m_flags & PMUTEX_FLAG_PRIVATE)
+   if (!cv && private)
THR_CRITICAL_LEAVE(curthread);
return (error);
 }
___
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: r346371 - stable/12/lib/libthr/thread

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

Log:
  MFC r346158:
  Do not access mutex memory after unlock.
  
  PR:   237195

Modified:
  stable/12/lib/libthr/thread/thr_mutex.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/lib/libthr/thread/thr_mutex.c
==
--- stable/12/lib/libthr/thread/thr_mutex.c Fri Apr 19 10:52:54 2019
(r346370)
+++ stable/12/lib/libthr/thread/thr_mutex.c Fri Apr 19 12:30:15 2019
(r346371)
@@ -949,7 +949,7 @@ mutex_unlock_common(struct pthread_mutex *m, bool cv, 
 {
struct pthread *curthread;
uint32_t id;
-   int deferred, error, robust;
+   int deferred, error, private, robust;
 
if (__predict_false(m <= THR_MUTEX_DESTROYED)) {
if (m == THR_MUTEX_DESTROYED)
@@ -967,6 +967,7 @@ mutex_unlock_common(struct pthread_mutex *m, bool cv, 
return (EPERM);
 
error = 0;
+   private = (m->m_flags & PMUTEX_FLAG_PRIVATE) != 0;
if (__predict_false(PMUTEX_TYPE(m->m_flags) ==
PTHREAD_MUTEX_RECURSIVE && m->m_count > 0)) {
m->m_count--;
@@ -991,7 +992,7 @@ mutex_unlock_common(struct pthread_mutex *m, bool cv, 
if (robust)
_mutex_leave_robust(curthread, m);
}
-   if (!cv && m->m_flags & PMUTEX_FLAG_PRIVATE)
+   if (!cv && private)
THR_CRITICAL_LEAVE(curthread);
return (error);
 }
___
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: r346322 - head/lib/libcasper/services/cap_fileargs

2019-04-19 Thread Mariusz Zaborski
On Wed, Apr 17, 2019 at 04:58:38PM +, Adrian Chadd wrote:
> Author: adrian
> Date: Wed Apr 17 16:58:38 2019
> New Revision: 346322
> URL: https://svnweb.freebsd.org/changeset/base/346322
> 
> Log:
>   [casper] fix compilation when casper is disabled.
>   
>   This triggers an error in gcc-mips 6.4.0 complaining about unused arguments.
>   
>   Tested:
>   
>   * compiled/run on mips32; nothing complained.
> 
> Modified:
>   head/lib/libcasper/services/cap_fileargs/cap_fileargs.h
> 
> Modified: head/lib/libcasper/services/cap_fileargs/cap_fileargs.h
> ==
> --- head/lib/libcasper/services/cap_fileargs/cap_fileargs.h   Wed Apr 17 
> 16:45:42 2019(r346321)
> +++ head/lib/libcasper/services/cap_fileargs/cap_fileargs.h   Wed Apr 17 
> 16:58:38 2019(r346322)
> @@ -108,8 +108,12 @@ fileargs_cinitnv(cap_channel_t *cas __unused, nvlist_t
>   lstat(name, sb)
>  #define  fileargs_open(fa, name) 
> \
>   open(name, fa->fa_flags, fa->fa_mode)
> -#define  fileargs_fopen(fa, name, mode)  
> \
> - fopen(name, mode)
> +static inline
> +FILE *fileargs_fopen(fileargs_t *fa, const char *name, const char *mode)
> +{
> + (void) fa;
__unused is not good enough?
> + return (fopen(name, mode));
> +}
>  #define  fileargs_free(fa)   (free(fa))
>  #endif
>  
> 

-- 
Mariusz Zaborski
oshogbo//vx | http://oshogbo.vexillium.org
FreeBSD committer   | https://freebsd.org
Software developer  | http://wheelsystems.com
If it's not broken, let's fix it till it is!!1


signature.asc
Description: PGP signature


svn commit: r346370 - head/sbin/pfctl

2019-04-19 Thread Kristof Provost
Author: kp
Date: Fri Apr 19 10:52:54 2019
New Revision: 346370
URL: https://svnweb.freebsd.org/changeset/base/346370

Log:
  pfctl: Fix ifgroup check
  
  We cannot just assume that any name which ends with a letter is a group
  That's not been true since we allowed renaming of network interfaces. It's 
also
  not true for things like epair0a.
  
  Try to retrieve the group members for the name to check, since we'll get 
ENOENT
  if the group doesn't exist.
  
  MFC after:1 week
  Event:Aberdeen hackathon 2019

Modified:
  head/sbin/pfctl/pfctl_optimize.c

Modified: head/sbin/pfctl/pfctl_optimize.c
==
--- head/sbin/pfctl/pfctl_optimize.cFri Apr 19 06:49:46 2019
(r346369)
+++ head/sbin/pfctl/pfctl_optimize.cFri Apr 19 10:52:54 2019
(r346370)
@@ -1500,14 +1500,24 @@ superblock_inclusive(struct superblock *block, struct 
 int
 interface_group(const char *ifname)
 {
+   int s;
+   struct ifgroupreq   ifgr;
+
if (ifname == NULL || !ifname[0])
return (0);
 
-   /* Real interfaces must end in a number, interface groups do not */
-   if (isdigit(ifname[strlen(ifname) - 1]))
-   return (0);
-   else
-   return (1);
+   s = get_query_socket();
+
+   memset(&ifgr, 0, sizeof(ifgr));
+   strlcpy(ifgr.ifgr_name, ifname, IFNAMSIZ);
+   if (ioctl(s, SIOCGIFGMEMB, (caddr_t)&ifgr) == -1) {
+   if (errno == ENOENT)
+   return (0);
+   else
+   err(1, "SIOCGIFGMEMB");
+   }
+
+   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"