Re: svn commit: r349589 - in head: sbin/mount sys/sys sys/ufs/ffs

2019-07-01 Thread Conrad Meyer
Hi,

Maybe the sense of the flag should be reversed? Ie, add a “trusted” flag
and default to untrusted.

I have two reasons in mind. The first is that a new default-off option is
easy to forget, and a missed security feature may be worse than a missed
mount-time performance enhancement.

The second is just the basic idea of preferring  to avoid double negatives
in flag names.

Thanks,
Conrad

On Tue, Jul 2, 2019 at 04:21 Kirk McKusick  wrote:

> Author: mckusick
> Date: Mon Jul  1 23:22:26 2019
> New Revision: 349589
> URL: https://svnweb.freebsd.org/changeset/base/349589
>
> Log:
>   Add a new "untrusted" option to the mount command. Its purpose
>   is to notify the kernel that the file system is untrusted and it
>   should use more extensive checks on the file-system's metadata
>   before using it. This option is intended to be used when mounting
>   file systems from untrusted media such as USB memory sticks or other
>   externally-provided media.
>
>   It will initially be used by the UFS/FFS file system, but should
>   likely be expanded to be used by other file systems that may appear
>   on external media like msdosfs, exfat, and ext2fs.
>
>   Reviewed by:  kib
>   Sponsored by: Netflix
>   Differential Revision: https://reviews.freebsd.org/D20786
>
> Modified:
>   head/sbin/mount/mntopts.h
>   head/sbin/mount/mount.8
>   head/sbin/mount/mount.c
>   head/sys/sys/mount.h
>   head/sys/ufs/ffs/ffs_vfsops.c
>
> Modified: head/sbin/mount/mntopts.h
>
> ==
> --- head/sbin/mount/mntopts.h   Mon Jul  1 22:11:56 2019(r349588)
> +++ head/sbin/mount/mntopts.h   Mon Jul  1 23:22:26 2019(r349589)
> @@ -58,6 +58,7 @@ struct mntopt {
>  #define MOPT_ACLS  { "acls",   0, MNT_ACLS, 0 }
>  #define MOPT_NFS4ACLS  { "nfsv4acls",  0, MNT_NFS4ACLS, 0 }
>  #define MOPT_AUTOMOUNTED   { "automounted",0, MNT_AUTOMOUNTED, 0 }
> +#define MOPT_UNTRUSTED { "untrusted",  0, MNT_UNTRUSTED, 0 }
>
>  /* Control flags. */
>  #define MOPT_FORCE { "force",  0, MNT_FORCE, 0 }
> @@ -93,7 +94,8 @@ struct mntopt {
> MOPT_MULTILABEL,\
> MOPT_ACLS,  \
> MOPT_NFS4ACLS,  \
> -   MOPT_AUTOMOUNTED
> +   MOPT_AUTOMOUNTED,   \
> +   MOPT_UNTRUSTED
>
>  void getmntopts(const char *, const struct mntopt *, int *, int *);
>  void rmslashes(char *, char *);
>
> Modified: head/sbin/mount/mount.8
>
> ==
> --- head/sbin/mount/mount.8 Mon Jul  1 22:11:56 2019(r349588)
> +++ head/sbin/mount/mount.8 Mon Jul  1 23:22:26 2019(r349589)
> @@ -355,6 +355,12 @@ Lookups will be done in the mounted file system first.
>  If those operations fail due to a non-existent file the underlying
>  directory is then accessed.
>  All creates are done in the mounted file system.
> +.It Cm untrusted
> +The file system is untrusted and the kernel should use more
> +extensive checks on the file-system's metadata before using it.
> +This option is intended to be used when mounting file systems
> +from untrusted media such as USB memory sticks or other
> +externally-provided media.
>  .El
>  .Pp
>  Any additional options specific to a file system type that is not
>
> Modified: head/sbin/mount/mount.c
>
> ==
> --- head/sbin/mount/mount.c Mon Jul  1 22:11:56 2019(r349588)
> +++ head/sbin/mount/mount.c Mon Jul  1 23:22:26 2019(r349589)
> @@ -118,6 +118,7 @@ static struct opt {
> { MNT_GJOURNAL, "gjournal" },
> { MNT_AUTOMOUNTED,  "automounted" },
> { MNT_VERIFIED, "verified" },
> +   { MNT_UNTRUSTED,"untrusted" },
> { 0, NULL }
>  };
>
> @@ -972,6 +973,7 @@ flags2opts(int flags)
> if (flags & MNT_MULTILABEL) res = catopt(res, "multilabel");
> if (flags & MNT_ACLS)   res = catopt(res, "acls");
> if (flags & MNT_NFS4ACLS)   res = catopt(res, "nfsv4acls");
> +   if (flags & MNT_UNTRUSTED)  res = catopt(res, "untrusted");
>
> return (res);
>  }
>
> Modified: head/sys/sys/mount.h
>
> ==
> --- head/sys/sys/mount.hMon Jul  1 22:11:56 2019(r349588)
> +++ head/sys/sys/mount.hMon Jul  1 23:22:26 2019(r349589)
> @@ -296,6 +296,7 @@ void  __mnt_vnode_markerfree_active(struct vno
>  #defineMNT_NOCLUSTERW  0x8000ULL /* disable cluster
> write */
>  #defineMNT_SUJ 0x0001ULL /* using journaled
> soft updates */
>  #defineMNT_AUTOMOUNTED 0x0002000

svn commit: r349594 - in head/sys: amd64/conf conf dev/ntb dev/ntb/ntb_hw i386/conf modules/ntb modules/ntb/ntb_hw_amd

2019-07-01 Thread Alexander Motin
Author: mav
Date: Tue Jul  2 05:25:18 2019
New Revision: 349594
URL: https://svnweb.freebsd.org/changeset/base/349594

Log:
  Add driver for NTB in AMD SoC.
  
  This patch is the driver for NTB hardware in AMD SoCs (ported from Linux)
  and enables the NTB infrastructure like Doorbells, Scratchpads and Memory
  window in AMD SoC. This driver has been validated using ntb_transport and
  if_ntb driver already available in FreeBSD.
  
  Submitted by: Rajesh Kumar 
  MFC after:1 month
  Relnotes: yes
  Differential Revision:https://reviews.freebsd.org/D18774

Added:
  head/sys/dev/ntb/ntb_hw/ntb_hw_amd.c   (contents, props changed)
  head/sys/dev/ntb/ntb_hw/ntb_hw_amd.h   (contents, props changed)
  head/sys/modules/ntb/ntb_hw_amd/
  head/sys/modules/ntb/ntb_hw_amd/Makefile   (contents, props changed)
Modified:
  head/sys/amd64/conf/NOTES
  head/sys/conf/files.amd64
  head/sys/conf/files.i386
  head/sys/dev/ntb/ntb.c
  head/sys/dev/ntb/ntb.h
  head/sys/dev/ntb/ntb_if.m
  head/sys/dev/ntb/ntb_transport.c
  head/sys/i386/conf/NOTES
  head/sys/modules/ntb/Makefile

Modified: head/sys/amd64/conf/NOTES
==
--- head/sys/amd64/conf/NOTES   Tue Jul  2 02:52:05 2019(r349593)
+++ head/sys/amd64/conf/NOTES   Tue Jul  2 05:25:18 2019(r349594)
@@ -383,6 +383,7 @@ device  wpifw
 device if_ntb  # Virtual NTB network interface
 device ntb_transport   # NTB packet transport driver
 device ntb # NTB hardware interface
+device ntb_hw_amd  # AMD NTB hardware driver
 device ntb_hw_intel# Intel NTB hardware driver
 device ntb_hw_plx  # PLX NTB hardware driver
 

Modified: head/sys/conf/files.amd64
==
--- head/sys/conf/files.amd64   Tue Jul  2 02:52:05 2019(r349593)
+++ head/sys/conf/files.amd64   Tue Jul  2 05:25:18 2019(r349594)
@@ -352,8 +352,9 @@ dev/nctgpio/nctgpio.c   optionalnctgpio
 dev/nfe/if_nfe.c   optionalnfe pci
 dev/ntb/if_ntb/if_ntb.coptionalif_ntb
 dev/ntb/ntb_transport.coptionalntb_transport | if_ntb
-dev/ntb/ntb.c  optionalntb | ntb_transport | if_ntb | 
ntb_hw_intel | ntb_hw_plx | ntb_hw
-dev/ntb/ntb_if.m   optionalntb | ntb_transport | if_ntb | 
ntb_hw_intel | ntb_hw_plx | ntb_hw
+dev/ntb/ntb.c  optionalntb | ntb_transport | if_ntb | 
ntb_hw_amd | ntb_hw_intel | ntb_hw_plx | ntb_hw
+dev/ntb/ntb_if.m   optionalntb | ntb_transport | if_ntb | 
ntb_hw_amd | ntb_hw_intel | ntb_hw_plx | ntb_hw
+dev/ntb/ntb_hw/ntb_hw_amd.coptionalntb_hw_amd | ntb_hw
 dev/ntb/ntb_hw/ntb_hw_intel.c  optionalntb_hw_intel | ntb_hw
 dev/ntb/ntb_hw/ntb_hw_plx.coptionalntb_hw_plx | ntb_hw
 dev/nvd/nvd.c  optionalnvd nvme

Modified: head/sys/conf/files.i386
==
--- head/sys/conf/files.i386Tue Jul  2 02:52:05 2019(r349593)
+++ head/sys/conf/files.i386Tue Jul  2 05:25:18 2019(r349594)
@@ -284,8 +284,9 @@ dev/nctgpio/nctgpio.c   optional nctgpio
 dev/nfe/if_nfe.c   optional nfe pci
 dev/ntb/if_ntb/if_ntb.coptional if_ntb
 dev/ntb/ntb_transport.coptional ntb_transport | if_ntb
-dev/ntb/ntb.c  optional ntb | ntb_transport | if_ntb | 
ntb_hw_intel | ntb_hw_plx | ntb_hw
-dev/ntb/ntb_if.m   optional ntb | ntb_transport | if_ntb | 
ntb_hw_intel | ntb_hw_plx | ntb_hw
+dev/ntb/ntb.c  optional ntb | ntb_transport | if_ntb | 
ntb_hw_amd | ntb_hw_intel | ntb_hw_plx | ntb_hw
+dev/ntb/ntb_if.m   optional ntb | ntb_transport | if_ntb | 
ntb_hw_amd | ntb_hw_intel | ntb_hw_plx | ntb_hw
+dev/ntb/ntb_hw/ntb_hw_amd.coptional ntb_hw_amd | ntb_hw
 dev/ntb/ntb_hw/ntb_hw_intel.c  optional ntb_hw_intel | ntb_hw
 dev/ntb/ntb_hw/ntb_hw_plx.coptional ntb_hw_plx | ntb_hw
 dev/nvd/nvd.c  optional nvd nvme

Modified: head/sys/dev/ntb/ntb.c
==
--- head/sys/dev/ntb/ntb.c  Tue Jul  2 02:52:05 2019(r349593)
+++ head/sys/dev/ntb/ntb.c  Tue Jul  2 05:25:18 2019(r349594)
@@ -243,6 +243,30 @@ ntb_db_event(device_t dev, uint32_t vec)
}
 }
 
+int
+ntb_port_number(device_t ntb)
+{
+   return (NTB_PORT_NUMBER(device_get_parent(ntb)));
+}
+
+int
+ntb_peer_port_count(device_t ntb)
+{
+   return (NTB_PEER_PORT_COUNT(device_get_parent(ntb)));
+}
+
+int
+ntb_peer_port_number(device_t ntb, int pidx)
+{
+   return (NTB_PEER_PORT_NUMBER(device_get_parent(ntb), pidx));
+}
+
+int
+ntb_peer_port_idx(device_t ntb, int port)
+{
+   ret

svn commit: r349592 - head/contrib/tzdata

2019-07-01 Thread Philip Paeps via svn-src-head
Author: philip
Date: Tue Jul  2 01:12:23 2019
New Revision: 349592
URL: https://svnweb.freebsd.org/changeset/base/349592

Log:
  Import tzdata 2019b
  
  Changes: https://github.com/eggert/tz/blob/2019b/NEWS
  
  MFC after:1 day

Modified:
  head/contrib/tzdata/Makefile
  head/contrib/tzdata/NEWS
  head/contrib/tzdata/africa
  head/contrib/tzdata/antarctica
  head/contrib/tzdata/asia
  head/contrib/tzdata/australasia
  head/contrib/tzdata/backzone
  head/contrib/tzdata/checktab.awk
  head/contrib/tzdata/europe
  head/contrib/tzdata/factory
  head/contrib/tzdata/northamerica
  head/contrib/tzdata/pacificnew
  head/contrib/tzdata/southamerica
  head/contrib/tzdata/systemv
  head/contrib/tzdata/theory.html
  head/contrib/tzdata/version
  head/contrib/tzdata/zishrink.awk
  head/contrib/tzdata/zone.tab
  head/contrib/tzdata/zone1970.tab
  head/contrib/tzdata/zoneinfo2tdf.pl
Directory Properties:
  head/contrib/tzdata/   (props changed)

Modified: head/contrib/tzdata/Makefile
==
--- head/contrib/tzdata/MakefileTue Jul  2 01:06:39 2019
(r349591)
+++ head/contrib/tzdata/MakefileTue Jul  2 01:12:23 2019
(r349592)
@@ -35,11 +35,13 @@ DATAFORM=   main
 
 LOCALTIME= GMT
 
-# If you want something other than Eastern United States time as a template
-# for handling ruleless POSIX-style timezone environment variables,
+# The POSIXRULES macro controls interpretation of nonstandard and obsolete
+# POSIX-like TZ settings like TZ='EET-2EEST' that lack DST transition rules.
+# In the reference implementation, if you want something other than Eastern
+# United States time as a template for handling these settings, you can
 # change the line below (after finding the timezone you want in the
 # one of the $(TDATA) source files, or adding it to a source file).
-# A ruleless environment setting like TZ='CST6CDT' uses the rules in the
+# A setting like TZ='EET-2EEST' is supposed to use the rules in the
 # template file to determine "spring forward" and "fall back" days and
 # times; the environment variable itself specifies UT offsets of standard and
 # daylight saving time.
@@ -49,6 +51,17 @@ LOCALTIME=   GMT
 # Use the command
 #  make zonenames
 # to get a list of the values you can use for POSIXRULES.
+#
+# If POSIXRULES is empty, no template is installed; this is the intended
+# future default for POSIXRULES.
+#
+# Nonempty POSIXRULES is obsolete and should not be relied on, because:
+# * It does not work correctly in popular implementations such as GNU/Linux.
+# * It does not work in the tzdb implementation for timestamps after 2037.
+# * It is incompatible with 'zic -b slim' if POSIXRULES specifies transitions
+#   at standard time or UT rather than at local time.
+# In short, software should avoid ruleless settings like TZ='EET-2EEST'
+# and so should not depend on the value of POSIXRULES.
 
 POSIXRULES=America/New_York
 
@@ -231,6 +244,13 @@ LDLIBS=
 #  other than simply getting garbage data
 #  -DUSE_LTZ=0 to build zdump with the system time zone library
 #  Also set TZDOBJS=zdump.o and CHECK_TIME_T_ALTERNATIVES= below.
+#  -DZIC_BLOAT_DEFAULT=\"slim\" to default zic's -b option to "slim", and
+#  similarly for "fat".  Fat TZif files work around incompatibilities
+#  and bugs in some TZif readers, notably readers that mishandle 64-bit
+#  data in TZif files.  Slim TZif files are more efficient and do not
+#  work around these incompatibilities and bugs.  If not given, the
+#  current default is "fat" but this is intended to change as readers
+#  requiring fat files often mishandle timestamps after 2037 anyway.
 #  -DZIC_MAX_ABBR_LEN_WO_WARN=3
 #  (or some other number) to set the maximum time zone abbreviation length
 #  that zic will accept without a warning (the default is 6)
@@ -364,7 +384,9 @@ ZIC=$(zic) $(ZFLAGS)
 
 # To shrink the size of installed TZif files,
 # append "-r @N" to omit data before N-seconds-after-the-Epoch.
-# See the zic man page for more about -r.
+# You can also append "-b slim" if that is not already the default;
+# see ZIC_BLOAT_DEFAULT above.
+# See the zic man page for more about -b and -r.
 ZFLAGS=
 
 # How to use zic to install TZif files.
@@ -388,6 +410,9 @@ KSHELL= /bin/bash
 # Name of curl , used for HTML validation.
 CURL=  curl
 
+# Name of GNU Privacy Guard , used to sign distributions.
+GPG=   gpg
+
 # The path where SGML DTDs are kept and the catalog file(s) to use when
 # validating HTML 4.01.  The default should work on both Debian and Red Hat.
 SGML_TOPDIR= /usr
@@ -562,7 +587,9 @@ install:all $(DATA) $(REDO) $(MANS)
'$(DESTDIR)$(LIBDIR)' \
'$(DESTDIR)$(MANDIR)/man3' '$(DESTDIR)$(MANDIR)/man5' \
'$(DESTDIR)$(MANDIR)/man8'
-   $(ZIC_INSTALL

svn commit: r349586 - head/sys/geom/eli

2019-07-01 Thread Ryan Libby via svn-src-head
Author: rlibby
Date: Mon Jul  1 22:06:16 2019
New Revision: 349586
URL: https://svnweb.freebsd.org/changeset/base/349586

Log:
  g_eli_create: only dec g_access acw if we inc'd it
  
  Reviewed by:  cem, markj
  Sponsored by: Dell EMC Isilon
  Differential Revision:https://reviews.freebsd.org/D20743

Modified:
  head/sys/geom/eli/g_eli.c

Modified: head/sys/geom/eli/g_eli.c
==
--- head/sys/geom/eli/g_eli.c   Mon Jul  1 22:00:42 2019(r349585)
+++ head/sys/geom/eli/g_eli.c   Mon Jul  1 22:06:16 2019(r349586)
@@ -827,7 +827,7 @@ g_eli_create(struct gctl_req *req, struct g_class *mp,
struct g_provider *pp;
struct g_consumer *cp;
u_int i, threads;
-   int error;
+   int dcw, error;
 
G_ELI_DEBUG(1, "Creating device %s%s.", bpp->name, G_ELI_SUFFIX);
 
@@ -881,10 +881,8 @@ g_eli_create(struct gctl_req *req, struct g_class *mp,
 * We don't open provider for writing only when user requested read-only
 * access.
 */
-   if (sc->sc_flags & G_ELI_FLAG_RO)
-   error = g_access(cp, 1, 0, 1);
-   else
-   error = g_access(cp, 1, 1, 1);
+   dcw = (sc->sc_flags & G_ELI_FLAG_RO) ? 0 : 1;
+   error = g_access(cp, 1, dcw, 1);
if (error != 0) {
if (req != NULL) {
gctl_error(req, "Cannot access %s (error=%d).",
@@ -996,7 +994,7 @@ failed:
mtx_destroy(&sc->sc_queue_mtx);
if (cp->provider != NULL) {
if (cp->acr == 1)
-   g_access(cp, -1, -1, -1);
+   g_access(cp, -1, -dcw, -1);
g_detach(cp);
}
g_destroy_consumer(cp);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r349589 - in head: sbin/mount sys/sys sys/ufs/ffs

2019-07-01 Thread Kirk McKusick via svn-src-head
Author: mckusick
Date: Mon Jul  1 23:22:26 2019
New Revision: 349589
URL: https://svnweb.freebsd.org/changeset/base/349589

Log:
  Add a new "untrusted" option to the mount command. Its purpose
  is to notify the kernel that the file system is untrusted and it
  should use more extensive checks on the file-system's metadata
  before using it. This option is intended to be used when mounting
  file systems from untrusted media such as USB memory sticks or other
  externally-provided media.
  
  It will initially be used by the UFS/FFS file system, but should
  likely be expanded to be used by other file systems that may appear
  on external media like msdosfs, exfat, and ext2fs.
  
  Reviewed by:  kib
  Sponsored by: Netflix
  Differential Revision: https://reviews.freebsd.org/D20786

Modified:
  head/sbin/mount/mntopts.h
  head/sbin/mount/mount.8
  head/sbin/mount/mount.c
  head/sys/sys/mount.h
  head/sys/ufs/ffs/ffs_vfsops.c

Modified: head/sbin/mount/mntopts.h
==
--- head/sbin/mount/mntopts.h   Mon Jul  1 22:11:56 2019(r349588)
+++ head/sbin/mount/mntopts.h   Mon Jul  1 23:22:26 2019(r349589)
@@ -58,6 +58,7 @@ struct mntopt {
 #define MOPT_ACLS  { "acls",   0, MNT_ACLS, 0 }
 #define MOPT_NFS4ACLS  { "nfsv4acls",  0, MNT_NFS4ACLS, 0 }
 #define MOPT_AUTOMOUNTED   { "automounted",0, MNT_AUTOMOUNTED, 0 }
+#define MOPT_UNTRUSTED { "untrusted",  0, MNT_UNTRUSTED, 0 }
 
 /* Control flags. */
 #define MOPT_FORCE { "force",  0, MNT_FORCE, 0 }
@@ -93,7 +94,8 @@ struct mntopt {
MOPT_MULTILABEL,\
MOPT_ACLS,  \
MOPT_NFS4ACLS,  \
-   MOPT_AUTOMOUNTED
+   MOPT_AUTOMOUNTED,   \
+   MOPT_UNTRUSTED
 
 void getmntopts(const char *, const struct mntopt *, int *, int *);
 void rmslashes(char *, char *);

Modified: head/sbin/mount/mount.8
==
--- head/sbin/mount/mount.8 Mon Jul  1 22:11:56 2019(r349588)
+++ head/sbin/mount/mount.8 Mon Jul  1 23:22:26 2019(r349589)
@@ -355,6 +355,12 @@ Lookups will be done in the mounted file system first.
 If those operations fail due to a non-existent file the underlying
 directory is then accessed.
 All creates are done in the mounted file system.
+.It Cm untrusted
+The file system is untrusted and the kernel should use more
+extensive checks on the file-system's metadata before using it.
+This option is intended to be used when mounting file systems
+from untrusted media such as USB memory sticks or other
+externally-provided media.
 .El
 .Pp
 Any additional options specific to a file system type that is not

Modified: head/sbin/mount/mount.c
==
--- head/sbin/mount/mount.c Mon Jul  1 22:11:56 2019(r349588)
+++ head/sbin/mount/mount.c Mon Jul  1 23:22:26 2019(r349589)
@@ -118,6 +118,7 @@ static struct opt {
{ MNT_GJOURNAL, "gjournal" },
{ MNT_AUTOMOUNTED,  "automounted" },
{ MNT_VERIFIED, "verified" },
+   { MNT_UNTRUSTED,"untrusted" },
{ 0, NULL }
 };
 
@@ -972,6 +973,7 @@ flags2opts(int flags)
if (flags & MNT_MULTILABEL) res = catopt(res, "multilabel");
if (flags & MNT_ACLS)   res = catopt(res, "acls");
if (flags & MNT_NFS4ACLS)   res = catopt(res, "nfsv4acls");
+   if (flags & MNT_UNTRUSTED)  res = catopt(res, "untrusted");
 
return (res);
 }

Modified: head/sys/sys/mount.h
==
--- head/sys/sys/mount.hMon Jul  1 22:11:56 2019(r349588)
+++ head/sys/sys/mount.hMon Jul  1 23:22:26 2019(r349589)
@@ -296,6 +296,7 @@ void  __mnt_vnode_markerfree_active(struct vno
 #defineMNT_NOCLUSTERW  0x8000ULL /* disable cluster write 
*/
 #defineMNT_SUJ 0x0001ULL /* using journaled soft 
updates */
 #defineMNT_AUTOMOUNTED 0x0002ULL /* mounted by 
automountd(8) */
+#defineMNT_UNTRUSTED   0x0008ULL /* filesys metadata 
untrusted */
 
 /*
  * NFS export related mount flags.
@@ -333,7 +334,8 @@ void  __mnt_vnode_markerfree_active(struct vno
MNT_NOCLUSTERW  | MNT_SUIDDIR   | MNT_SOFTDEP   | \
MNT_IGNORE  | MNT_EXPUBLIC  | MNT_NOSYMFOLLOW | \
MNT_GJOURNAL| MNT_MULTILABEL | MNT_ACLS | \
-   MNT_NFS4ACLS| MNT_AUTOMOUNTED | MNT_VERIFIED)
+   MNT_NFS4ACLS| MNT_AUTOMOUNTED | MNT_VERIFIED | \
+  

svn commit: r349587 - head/sys/geom/mirror

2019-07-01 Thread Ryan Libby via svn-src-head
Author: rlibby
Date: Mon Jul  1 22:06:36 2019
New Revision: 349587
URL: https://svnweb.freebsd.org/changeset/base/349587

Log:
  g_mirror_taste: avoid deadlock, always clear tasting flag
  
  If g_mirror_taste encountered an error at g_mirror_add_disk, it might
  try to g_mirror_destroy the device with the G_MIRROR_DEVICE_FLAG_TASTING
  flag still set.  This would wait on a worker to complete the destruction
  with g_mirror_try_destroy, but that function bails out if the tasting
  flag is set, resulting in a deadlock.  Clear the tasting flag before
  trying to destroy the device.
  
  Test Plan:
  sysctl debug.fail_point.mnowait="1%return"
  kyua test -k /usr/tests/sys/geom/class/mirror/Kyuafile
  
  Reviewed by:  markj
  Sponsored by: Dell EMC Isilon
  Differential Revision:https://reviews.freebsd.org/D20744

Modified:
  head/sys/geom/mirror/g_mirror.c

Modified: head/sys/geom/mirror/g_mirror.c
==
--- head/sys/geom/mirror/g_mirror.c Mon Jul  1 22:06:16 2019
(r349586)
+++ head/sys/geom/mirror/g_mirror.c Mon Jul  1 22:06:36 2019
(r349587)
@@ -3291,6 +3291,7 @@ g_mirror_taste(struct g_class *mp, struct g_provider *
sx_xlock(&sc->sc_lock);
sc->sc_flags |= G_MIRROR_DEVICE_FLAG_TASTING;
error = g_mirror_add_disk(sc, pp, &md);
+   sc->sc_flags &= ~G_MIRROR_DEVICE_FLAG_TASTING;
if (error != 0) {
G_MIRROR_DEBUG(0, "Cannot add disk %s to %s (error=%d).",
pp->name, gp->name, error);
@@ -3302,7 +3303,6 @@ g_mirror_taste(struct g_class *mp, struct g_provider *
}
gp = NULL;
}
-   sc->sc_flags &= ~G_MIRROR_DEVICE_FLAG_TASTING;
if ((sc->sc_flags & G_MIRROR_DEVICE_FLAG_DESTROY) != 0) {
g_mirror_destroy(sc, G_MIRROR_DESTROY_HARD);
g_topology_lock();
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r349588 - head/sys/arm64/arm64

2019-07-01 Thread Emmanuel Vadot via svn-src-head
Author: manu
Date: Mon Jul  1 22:11:56 2019
New Revision: 349588
URL: https://svnweb.freebsd.org/changeset/base/349588

Log:
  arm64: efi: Map memory IO region as device
  
  Reviewed by:  andrew
  Sponsored by: Ampere Computing, LLC

Modified:
  head/sys/arm64/arm64/efirt_machdep.c

Modified: head/sys/arm64/arm64/efirt_machdep.c
==
--- head/sys/arm64/arm64/efirt_machdep.cMon Jul  1 22:06:36 2019
(r349587)
+++ head/sys/arm64/arm64/efirt_machdep.cMon Jul  1 22:11:56 2019
(r349588)
@@ -208,20 +208,14 @@ efi_create_1t1_map(struct efi_md *map, int ndesc, int 
mode = VM_MEMATTR_WRITE_THROUGH;
else if ((p->md_attr & EFI_MD_ATTR_WC) != 0)
mode = VM_MEMATTR_WRITE_COMBINING;
-   else if ((p->md_attr & EFI_MD_ATTR_UC) != 0)
+   else
mode = VM_MEMATTR_DEVICE;
-   else {
-   if (bootverbose)
-   printf("EFI Runtime entry %d mapping "
-   "attributes unsupported\n", i);
-   mode = VM_MEMATTR_UNCACHEABLE;
-   }
 
printf("MAP %lx mode %x pages %lu\n", p->md_phys, mode, 
p->md_pages);
 
l3_attr = ATTR_DEFAULT | ATTR_IDX(mode) | ATTR_AP(ATTR_AP_RW) |
L3_PAGE;
-   if (mode == VM_MEMATTR_DEVICE)
+   if (mode == VM_MEMATTR_DEVICE || p->md_attr & EFI_MD_ATTR_XP)
l3_attr |= ATTR_UXN | ATTR_PXN;
 
VM_OBJECT_WLOCK(obj_1t1_pt);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r349593 - head/sys/dev/bwn

2019-07-01 Thread Landon J. Fuller
Author: landonf
Date: Tue Jul  2 02:52:05 2019
New Revision: 349593
URL: https://svnweb.freebsd.org/changeset/base/349593

Log:
  bwn(4): Include SROM revision when printing device identification.

Modified:
  head/sys/dev/bwn/if_bwn.c

Modified: head/sys/dev/bwn/if_bwn.c
==
--- head/sys/dev/bwn/if_bwn.c   Tue Jul  2 01:12:23 2019(r349592)
+++ head/sys/dev/bwn/if_bwn.c   Tue Jul  2 02:52:05 2019(r349593)
@@ -632,9 +632,10 @@ bwn_attach(device_t dev)
goto fail;
 
bhnd_format_chip_id(chip_name, sizeof(chip_name), sc->sc_cid.chip_id);
-   device_printf(sc->sc_dev, "WLAN (%s rev %u) "
+   device_printf(sc->sc_dev, "WLAN (%s rev %u sromrev %u) "
"PHY (analog %d type %d rev %d) RADIO (manuf %#x ver %#x rev %d)\n",
-   chip_name, bhnd_get_hwrev(sc->sc_dev), mac->mac_phy.analog,
+   chip_name, bhnd_get_hwrev(sc->sc_dev),
+   sc->sc_board_info.board_srom_rev, mac->mac_phy.analog,
mac->mac_phy.type, mac->mac_phy.rev, mac->mac_phy.rf_manuf,
mac->mac_phy.rf_ver, mac->mac_phy.rf_rev);
if (mac->mac_flags & BWN_MAC_FLAG_DMA)
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r349585 - head/sys/amd64/amd64

2019-07-01 Thread Alan Cox
Author: alc
Date: Mon Jul  1 22:00:42 2019
New Revision: 349585
URL: https://svnweb.freebsd.org/changeset/base/349585

Log:
  Tidy up pmap_copy().  Notably, deindent the innermost loop by making a
  simple change to the control flow.  Replace an unnecessary test by a
  KASSERT.  Add a comment explaining an obscure test.
  
  Reviewed by:  kib, markj
  MFC after:3 weeks
  Differential Revision:https://reviews.freebsd.org/D20812

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

Modified: head/sys/amd64/amd64/pmap.c
==
--- head/sys/amd64/amd64/pmap.c Mon Jul  1 21:50:53 2019(r349584)
+++ head/sys/amd64/amd64/pmap.c Mon Jul  1 22:00:42 2019(r349585)
@@ -6345,18 +6345,18 @@ pmap_unwire(pmap_t pmap, vm_offset_t sva, vm_offset_t 
  *
  * This routine is only advisory and need not do anything.
  */
-
 void
 pmap_copy(pmap_t dst_pmap, pmap_t src_pmap, vm_offset_t dst_addr, vm_size_t 
len,
 vm_offset_t src_addr)
 {
struct rwlock *lock;
struct spglist free;
-   vm_offset_t addr;
-   vm_offset_t end_addr = src_addr + len;
-   vm_offset_t va_next;
+   pml4_entry_t *pml4e;
+   pdp_entry_t *pdpe;
+   pd_entry_t *pde, srcptepaddr;
+   pt_entry_t *dst_pte, PG_A, PG_M, PG_V, ptetemp, *src_pte;
+   vm_offset_t addr, end_addr, va_next;
vm_page_t dst_pdpg, dstmpte, srcmpte;
-   pt_entry_t PG_A, PG_M, PG_V;
 
if (dst_addr != src_addr)
return;
@@ -6375,6 +6375,7 @@ pmap_copy(pmap_t dst_pmap, pmap_t src_pmap, vm_offset_
if (pmap_emulate_ad_bits(dst_pmap))
return;
 
+   end_addr = src_addr + len;
lock = NULL;
if (dst_pmap < src_pmap) {
PMAP_LOCK(dst_pmap);
@@ -6389,11 +6390,6 @@ pmap_copy(pmap_t dst_pmap, pmap_t src_pmap, vm_offset_
PG_V = pmap_valid_bit(dst_pmap);
 
for (addr = src_addr; addr < end_addr; addr = va_next) {
-   pt_entry_t *src_pte, *dst_pte;
-   pml4_entry_t *pml4e;
-   pdp_entry_t *pdpe;
-   pd_entry_t srcptepaddr, *pde;
-
KASSERT(addr < UPT_MIN_ADDRESS,
("pmap_copy: invalid to pmap_copy page tables"));
 
@@ -6435,7 +6431,8 @@ pmap_copy(pmap_t dst_pmap, pmap_t src_pmap, vm_offset_
pmap_pv_insert_pde(dst_pmap, addr, srcptepaddr,
PMAP_ENTER_NORECLAIM, &lock))) {
*pde = srcptepaddr & ~PG_W;
-   pmap_resident_count_inc(dst_pmap, NBPDR / 
PAGE_SIZE);
+   pmap_resident_count_inc(dst_pmap, NBPDR /
+   PAGE_SIZE);
atomic_add_long(&pmap_pde_mappings, 1);
} else
dst_pdpg->wire_count--;
@@ -6453,58 +6450,54 @@ pmap_copy(pmap_t dst_pmap, pmap_t src_pmap, vm_offset_
src_pte = (pt_entry_t *)PHYS_TO_DMAP(srcptepaddr);
src_pte = &src_pte[pmap_pte_index(addr)];
dstmpte = NULL;
-   while (addr < va_next) {
-   pt_entry_t ptetemp;
+   for (; addr < va_next; addr += PAGE_SIZE, src_pte++) {
ptetemp = *src_pte;
+
/*
-* we only virtual copy managed pages
+* We only virtual copy managed pages.
 */
-   if ((ptetemp & PG_MANAGED) != 0) {
-   if (dstmpte != NULL &&
-   dstmpte->pindex == pmap_pde_pindex(addr))
-   dstmpte->wire_count++;
-   else if ((dstmpte = pmap_allocpte(dst_pmap,
-   addr, NULL)) == NULL)
-   goto out;
-   dst_pte = (pt_entry_t *)
-   PHYS_TO_DMAP(VM_PAGE_TO_PHYS(dstmpte));
-   dst_pte = &dst_pte[pmap_pte_index(addr)];
-   if (*dst_pte == 0 &&
-   pmap_try_insert_pv_entry(dst_pmap, addr,
-   PHYS_TO_VM_PAGE(ptetemp & PG_FRAME),
-   &lock)) {
+   if ((ptetemp & PG_MANAGED) == 0)
+   continue;
+
+   if (dstmpte != NULL) {
+   KASSERT(dstmpte->pindex ==
+   pmap_pde_pindex(addr),
+   ("dstmpte pindex/addr mismatch"));
+   dstmpte->wire_count++;
+   } else if ((dstmpte = pmap_allocpte(dst_pmap, addr,
+   NULL)) == NULL)
+   goto out;
+  

svn commit: r349584 - head/sys/dev/mmc/host

2019-07-01 Thread Emmanuel Vadot
Author: manu
Date: Mon Jul  1 21:50:53 2019
New Revision: 349584
URL: https://svnweb.freebsd.org/changeset/base/349584

Log:
  Since r349571 we need all the accessor to be present for set or get
  otherwise we panic.
  dwmmc don't handle VCCQ (voltage for the IO line of the SD/eMMC) or
  TIMING.
  Add the needed accessor in the {read,write}_ivar functions.
  
  Reviewed by:  imp (previous version)

Modified:
  head/sys/dev/mmc/host/dwmmc.c

Modified: head/sys/dev/mmc/host/dwmmc.c
==
--- head/sys/dev/mmc/host/dwmmc.c   Mon Jul  1 21:06:10 2019
(r349583)
+++ head/sys/dev/mmc/host/dwmmc.c   Mon Jul  1 21:50:53 2019
(r349584)
@@ -1096,6 +1096,10 @@ dwmmc_read_ivar(device_t bus, device_t child, int whic
break;
case MMCBR_IVAR_MAX_DATA:
*(int *)result = sc->desc_count;
+   break;
+   case MMCBR_IVAR_TIMING:
+   *(int *)result = sc->host.ios.timing;
+   break;
}
return (0);
 }
@@ -1133,6 +1137,14 @@ dwmmc_write_ivar(device_t bus, device_t child, int whi
break;
case MMCBR_IVAR_VDD:
sc->host.ios.vdd = value;
+   break;
+   case MMCBR_IVAR_TIMING:
+   sc->host.ios.timing = value;
+   break;
+
+   /* Not handled */
+   case MMCBR_IVAR_VCCQ:
+   return (0);
break;
/* These are read-only */
case MMCBR_IVAR_CAPS:
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r349583 - in head/contrib/llvm: include/llvm/Analysis lib/Analysis lib/Transforms/Scalar

2019-07-01 Thread Dimitry Andric
Author: dim
Date: Mon Jul  1 21:06:10 2019
New Revision: 349583
URL: https://svnweb.freebsd.org/changeset/base/349583

Log:
  Pull in r360968 from upstream llvm trunk (by Philip Reames):
  
Clarify comments on helpers used by LFTR [NFC]
  
I'm slowly wrapping my head around this code, and am making comment
improvements where I can.
  
  Pull in r360972 from upstream llvm trunk (by Philip Reames):
  
[LFTR] Factor out a helper function for readability purpose [NFC]
  
  Pull in r360976 from upstream llvm trunk (by Philip Reames):
  
[IndVars] Don't reimplement Loop::isLoopInvariant [NFC]
  
Using dominance vs a set membership check is indistinguishable from a
compile time perspective, and the two queries return equivelent
results.  Simplify code by using the existing function.
  
  Pull in r360978 from upstream llvm trunk (by Philip Reames):
  
[LFTR] Strengthen assertions in genLoopLimit [NFCI]
  
  Pull in r362292 from upstream llvm trunk (by Nikita Popov):
  
[IndVarSimplify] Fixup nowrap flags during LFTR (PR31181)
  
Fix for https://bugs.llvm.org/show_bug.cgi?id=31181 and partial fix
for LFTR poison handling issues in general.
  
When LFTR moves a condition from pre-inc to post-inc, it may now
depend on value that is poison due to nowrap flags. To avoid this, we
clear any nowrap flag that SCEV cannot prove for the post-inc addrec.
  
Additionally, LFTR may switch to a different IV that is dynamically
dead and as such may be arbitrarily poison. This patch will correct
nowrap flags in some but not all cases where this happens. This is
related to the adoption of IR nowrap flags for the pre-inc addrec.
(See some of the switch_to_different_iv tests, where flags are not
dropped or insufficiently dropped.)
  
Finally, there are likely similar issues with the handling of GEP
inbounds, but we don't have a test case for this yet.
  
Differential Revision: https://reviews.llvm.org/D60935
  
  Pull in r362971 from upstream llvm trunk (by Philip Reames):
  
Prepare for multi-exit LFTR [NFC]
  
This change does the plumbing to wire an ExitingBB parameter through
the LFTR implementation, and reorganizes the code to work in terms of
a set of individual loop exits. Most of it is fairly obvious, but
there's one key complexity which makes it worthy of consideration.
The actual multi-exit LFTR patch is in D62625 for context.
  
Specifically, it turns out the existing code uses the backedge taken
count from before a IV is widened. Oddly, we can end up with a
different (more expensive, but semantically equivelent) BE count for
the loop when requerying after widening.  For the nestedIV example
from elim-extend, we end up with the following BE counts:
BEFORE: (-2 + (-1 * %innercount) + %limit)
AFTER: (-1 + (sext i32 (-1 + %limit) to i64) + (-1 * (sext i32 %innercount 
to i64)))
  
This is the only test in tree which seems sensitive to this
difference. The actual result of using the wider BETC on this example
is that we actually produce slightly better code. :)
  
In review, we decided to accept that test change.  This patch is
structured to preserve the old behavior, but a separate change will
immediate follow with the behavior change.  (I wanted it separate for
problem attribution purposes.)
  
Differential Revision: https://reviews.llvm.org/D62880
  
  Pull in r362975 from upstream llvm trunk (by Philip Reames):
  
[LFTR] Use recomputed BE count
  
This was discussed as part of D62880.  The basic thought is that
computing BE taken count after widening should produce (on average)
an equally good backedge taken count as the one before widening.
Since there's only one test in the suite which is impacted by this
change, and it's essentially equivelent codegen, that seems to be a
reasonable assertion.  This change was separated from r362971 so that
if this turns out to be problematic, the triggering piece is obvious
and easily revertable.
  
For the nestedIV example from elim-extend.ll, we end up with the
following BE counts:
BEFORE: (-2 + (-1 * %innercount) + %limit)
AFTER: (-1 + (sext i32 (-1 + %limit) to i64) + (-1 * (sext i32 %innercount 
to i64)))
  
Note that before is an i32 type, and the after is an i64.  Truncating
the i64 produces the i32.
  
  Pull in r362980 from upstream llvm trunk (by Philip Reames):
  
Factor out a helper function for readability and reuse in a future
patch [NFC]
  
  Pull in r363613 from upstream llvm trunk (by Philip Reames):
  
Fix a bug w/inbounds invalidation in LFTR (recommit)
  
Recommit r363289 with a bug fix for crash identified in pr42279.
Issue was that a loop exit test does not have to be an icmp, leading
to a null dereference crash when new logic was exercised for that
case.  Test case previously committed in r363601.
  

svn commit: r349582 - in head/sys: kern sys

2019-07-01 Thread Rick Macklem
Author: rmacklem
Date: Mon Jul  1 20:41:43 2019
New Revision: 349582
URL: https://svnweb.freebsd.org/changeset/base/349582

Log:
  Factor out the code that does a VOP_SETATTR(size) from vn_truncate().
  
  This patch factors the code in vn_truncate() that does the actual
  VOP_SETATTR() of size into a separate function called vn_truncate_locked().
  This will allow the NFS server and the patch that adds a
  copy_file_range(2) syscall to call this function instead of duplicating
  the code and carrying over changes, such as the recent r347151.
  
  Reviewed by:  kib
  Differential Revision:https://reviews.freebsd.org/D20808

Modified:
  head/sys/kern/vfs_vnops.c
  head/sys/sys/vnode.h

Modified: head/sys/kern/vfs_vnops.c
==
--- head/sys/kern/vfs_vnops.c   Mon Jul  1 20:37:35 2019(r349581)
+++ head/sys/kern/vfs_vnops.c   Mon Jul  1 20:41:43 2019(r349582)
@@ -1289,7 +1289,6 @@ static int
 vn_truncate(struct file *fp, off_t length, struct ucred *active_cred,
 struct thread *td)
 {
-   struct vattr vattr;
struct mount *mp;
struct vnode *vp;
void *rl_cookie;
@@ -1316,20 +1315,35 @@ vn_truncate(struct file *fp, off_t length, struct ucre
if (error)
goto out;
 #endif
+   error = vn_truncate_locked(vp, length, (fp->f_flag & O_FSYNC) != 0,
+   fp->f_cred);
+out:
+   VOP_UNLOCK(vp, 0);
+   vn_finished_write(mp);
+out1:
+   vn_rangelock_unlock(vp, rl_cookie);
+   return (error);
+}
+
+/*
+ * Truncate a file that is already locked.
+ */
+int
+vn_truncate_locked(struct vnode *vp, off_t length, bool sync,
+struct ucred *cred)
+{
+   struct vattr vattr;
+   int error;
+
error = VOP_ADD_WRITECOUNT(vp, 1);
if (error == 0) {
VATTR_NULL(&vattr);
vattr.va_size = length;
-   if ((fp->f_flag & O_FSYNC) != 0)
+   if (sync)
vattr.va_vaflags |= VA_SYNC;
-   error = VOP_SETATTR(vp, &vattr, fp->f_cred);
+   error = VOP_SETATTR(vp, &vattr, cred);
VOP_ADD_WRITECOUNT_CHECKED(vp, -1);
}
-out:
-   VOP_UNLOCK(vp, 0);
-   vn_finished_write(mp);
-out1:
-   vn_rangelock_unlock(vp, rl_cookie);
return (error);
 }
 

Modified: head/sys/sys/vnode.h
==
--- head/sys/sys/vnode.hMon Jul  1 20:37:35 2019(r349581)
+++ head/sys/sys/vnode.hMon Jul  1 20:41:43 2019(r349582)
@@ -695,6 +695,8 @@ int vn_stat(struct vnode *vp, struct stat *sb, struct 
 intvn_start_write(struct vnode *vp, struct mount **mpp, int flags);
 intvn_start_secondary_write(struct vnode *vp, struct mount **mpp,
int flags);
+intvn_truncate_locked(struct vnode *vp, off_t length, bool sync,
+   struct ucred *cred);
 intvn_writechk(struct vnode *vp);
 intvn_extattr_get(struct vnode *vp, int ioflg, int attrnamespace,
const char *attrname, int *buflen, char *buf, struct thread *td);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r349581 - head/sys/dev/netmap

2019-07-01 Thread Vincenzo Maffione
Author: vmaffione
Date: Mon Jul  1 20:37:35 2019
New Revision: 349581
URL: https://svnweb.freebsd.org/changeset/base/349581

Log:
  netmap: fix two panics with emulated adapter
  
  This patch fixes 2 panics. The first one is due to the current VNET not
  being set in the emulated adapter transmission path. The second one
  is caused by the M_PKTHDR flag not being set when preallocated mbufs
  are recycled in the transmit path.
  
  Submitted by: aleksandr.fedo...@itglobal.com
  Reviewed by:  vmaffione
  MFC after:2 weeks
  Differential Revision:https://reviews.freebsd.org/D20824

Modified:
  head/sys/dev/netmap/netmap_freebsd.c

Modified: head/sys/dev/netmap/netmap_freebsd.c
==
--- head/sys/dev/netmap/netmap_freebsd.cMon Jul  1 17:05:41 2019
(r349580)
+++ head/sys/dev/netmap/netmap_freebsd.cMon Jul  1 20:37:35 2019
(r349581)
@@ -444,6 +444,7 @@ nm_os_generic_xmit_frame(struct nm_os_gen_arg *a)
m->m_ext.ext_size = len;
 #endif /* __FreeBSD_version >= 110 */
 
+   m->m_flags |= M_PKTHDR;
m->m_len = m->m_pkthdr.len = len;
 
/* mbuf refcnt is not contended, no need to use atomic
@@ -452,7 +453,9 @@ nm_os_generic_xmit_frame(struct nm_os_gen_arg *a)
M_HASHTYPE_SET(m, M_HASHTYPE_OPAQUE);
m->m_pkthdr.flowid = a->ring_nr;
m->m_pkthdr.rcvif = ifp; /* used for tx notification */
+   CURVNET_SET(ifp->if_vnet);
ret = NA(ifp)->if_transmit(ifp, m);
+   CURVNET_RESTORE();
return ret ? -1 : 0;
 }
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r349580 - in head/sys: amd64/conf conf dev/superio i386/conf modules modules/superio

2019-07-01 Thread Andriy Gapon
Author: avg
Date: Mon Jul  1 17:05:41 2019
New Revision: 349580
URL: https://svnweb.freebsd.org/changeset/base/349580

Log:
  add superio driver
  
  The goal of this driver is consolidate information about SuperIO chips
  and to provide for peaceful coexistence of drivers that need to access
  SuperIO configuration registers.
  
  While SuperIO chips can host various functions most of them are
  discoverable and accessible without any knowledge of the SuperIO.
  Examples are: keyboard and mouse controllers, UARTs, floppy disk
  controllers.  SuperIO-s also provide non-standard functions such as
  GPIO, watchdog timers and hardware monitoring.  Such functions do
  require drivers with a knowledge of a specific SuperIO.
  
  At this time the driver supports a number of ITE and Nuvoton (fka
  Winbond) SuperIO chips.
  There is a single driver for all devices.  So, I have not done the usual
  split between the hardware driver and the bus functionality.  Although,
  superio does act as a bus for devices that represent known non-standard
  functions of a SuperIO chip.  The bus provides enumeration of child
  devices based on the hardcoded knowledge of such functions.  The
  knowledge as extracted from datasheets and other drivers.
  As there is a single driver, I have not defined a kobj interface for it.
  So, its interface is currently made of simple functions.
  I think that we can the flexibility (and complications) when we actually
  need it.
  
  I am planning to convert nctgpio and wbwd to superio bus very soon.
  Also, I am working on itwd driver (watchdog in ITE SuperIO-s).
  Additionally, there is ithwm driver based on the reverted sensors
  import, but I am not sure how to integrate it given that we still lack
  any sensors interface.
  
  Discussed with:   imp, jhb
  MFC after:7 weeks
  Differential Revision: https://reviews.freebsd.org/D8175

Added:
  head/sys/dev/superio/
  head/sys/dev/superio/superio.c   (contents, props changed)
  head/sys/dev/superio/superio.h   (contents, props changed)
  head/sys/modules/superio/
  head/sys/modules/superio/Makefile   (contents, props changed)
Modified:
  head/sys/amd64/conf/NOTES
  head/sys/conf/files.amd64
  head/sys/conf/files.i386
  head/sys/i386/conf/NOTES
  head/sys/modules/Makefile

Modified: head/sys/amd64/conf/NOTES
==
--- head/sys/amd64/conf/NOTES   Mon Jul  1 15:43:48 2019(r349579)
+++ head/sys/amd64/conf/NOTES   Mon Jul  1 17:05:41 2019(r349580)
@@ -567,6 +567,11 @@ device amdtemp
 device cpuctl
 
 #
+# SuperIO driver.
+#
+device superio
+
+#
 # System Management Bus (SMB)
 #
 optionsENABLE_ALART# Control alarm on Intel intpm driver

Modified: head/sys/conf/files.amd64
==
--- head/sys/conf/files.amd64   Mon Jul  1 15:43:48 2019(r349579)
+++ head/sys/conf/files.amd64   Mon Jul  1 17:05:41 2019(r349580)
@@ -493,6 +493,7 @@ dev/smartpqi/smartpqi_response.coptionalsmartpqi
 dev/smartpqi/smartpqi_sis.c optional   smartpqi
 dev/smartpqi/smartpqi_tag.c optional   smartpqi
 dev/speaker/spkr.c optionalspeaker
+dev/superio/superio.c  optionalsuperio isa
 dev/syscons/apm/apm_saver.coptionalapm_saver apm
 dev/syscons/scvesactl.coptionalsc vga vesa
 dev/syscons/scvgarndr.coptionalsc vga

Modified: head/sys/conf/files.i386
==
--- head/sys/conf/files.i386Mon Jul  1 15:43:48 2019(r349579)
+++ head/sys/conf/files.i386Mon Jul  1 17:05:41 2019(r349580)
@@ -312,6 +312,7 @@ dev/sio/sio_pccard.coptional sio pccard
 dev/sio/sio_pci.c  optional sio pci
 dev/sio/sio_puc.c  optional sio puc
 dev/speaker/spkr.c optional speaker
+dev/superio/superio.c  optional superio isa
 dev/syscons/apm/apm_saver.coptional apm_saver apm
 dev/syscons/scvesactl.coptional sc vga vesa
 dev/syscons/scvgarndr.coptional sc vga

Added: head/sys/dev/superio/superio.c
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/sys/dev/superio/superio.c  Mon Jul  1 17:05:41 2019
(r349580)
@@ -0,0 +1,953 @@
+/*
+ * Copyright (c) 2016 Andriy Gapon
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *not

svn commit: r349579 - head/sys/dev/nctgpio

2019-07-01 Thread Andriy Gapon
Author: avg
Date: Mon Jul  1 15:43:48 2019
New Revision: 349579
URL: https://svnweb.freebsd.org/changeset/base/349579

Log:
  nctgpio: change default pin names to those used by the datasheet(s)
  
  That is, instead of the current GPIO00 - GPIO15 the names will be GPIO00
  - GPIO07, GPIO10 - GPIO17.  The first digit is a GPIO "bank" / group
  number and the second one is a pin number within the bank.  Alternative
  view is that the pin names are changed from decimal numbering scheme to
  octal one (as there are 8 pins per bank).
  
  Discussed with:   cem, gonzo
  MFC after:2 weeks

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

Modified: head/sys/dev/nctgpio/nctgpio.c
==
--- head/sys/dev/nctgpio/nctgpio.c  Mon Jul  1 13:41:37 2019
(r349578)
+++ head/sys/dev/nctgpio/nctgpio.c  Mon Jul  1 15:43:48 2019
(r349579)
@@ -529,7 +529,7 @@ nct_attach(device_t dev)
pin->gp_caps = NCT_GPIO_CAPS;
pin->gp_flags = 0;
 
-   snprintf(pin->gp_name, GPIOMAXNAME, "GPIO%02u", i);
+   snprintf(pin->gp_name, GPIOMAXNAME, "GPIO%02o", i);
pin->gp_name[GPIOMAXNAME - 1] = '\0';
 
if (nct_pin_is_input(sc, i))
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r349578 - head/sys/dev/etherswitch/e6000sw

2019-07-01 Thread Luiz Otavio O Souza
Author: loos
Date: Mon Jul  1 13:41:37 2019
New Revision: 349578
URL: https://svnweb.freebsd.org/changeset/base/349578

Log:
  Add support for the Marvell 88E6190 11 ports switch.
  
  With more ports, some of the registers are shifted a bit to accommodate.
  
  This switch also adds two high speed Serdes/SGMII interfaces (2.5 Gb/s).
  
  Sponsored by: Rubicon Communications, LLC (Netgate)

Modified:
  head/sys/dev/etherswitch/e6000sw/e6000sw.c
  head/sys/dev/etherswitch/e6000sw/e6000swreg.h

Modified: head/sys/dev/etherswitch/e6000sw/e6000sw.c
==
--- head/sys/dev/etherswitch/e6000sw/e6000sw.c  Mon Jul  1 11:52:54 2019
(r349577)
+++ head/sys/dev/etherswitch/e6000sw/e6000sw.c  Mon Jul  1 13:41:37 2019
(r349578)
@@ -106,6 +106,8 @@ static int e6000sw_parse_fixed_link(e6000sw_softc_t *,
 static int e6000sw_parse_ethernet(e6000sw_softc_t *, phandle_t, uint32_t);
 static int e6000sw_attach(device_t);
 static int e6000sw_detach(device_t);
+static int e6000sw_read_xmdio(device_t, int, int, int);
+static int e6000sw_write_xmdio(device_t, int, int, int, int);
 static int e6000sw_readphy(device_t, int, int);
 static int e6000sw_writephy(device_t, int, int, int);
 static etherswitch_info_t* e6000sw_getinfo(device_t);
@@ -205,16 +207,26 @@ e6000sw_probe(device_t dev)
const char *description;
phandle_t switch_node;
 
+   sc = device_get_softc(dev);
switch_node = ofw_bus_find_compatible(OF_finddevice("/"),
"marvell,mv88e6085");
+   if (switch_node == 0) {
+   switch_node = ofw_bus_find_compatible(OF_finddevice("/"),
+   "marvell,mv88e6190");
 
-   if (switch_node == 0)
-   return (ENXIO);
+   if (switch_node == 0)
+   return (ENXIO);
 
+   /*
+* Trust DTS and fix the port register offset for the MV88E6190
+* detection bellow.
+*/
+   sc->swid = MV88E6190;
+   }
+
if (bootverbose)
device_printf(dev, "Found switch_node: 0x%x\n", switch_node);
 
-   sc = device_get_softc(dev);
sc->dev = dev;
sc->node = switch_node;
 
@@ -230,7 +242,7 @@ e6000sw_probe(device_t dev)
 */
sx_init(&sc->sx, "e6000sw_tmp");
E6000SW_LOCK(sc);
-   sc->swid = e6000sw_readreg(sc, REG_PORT(0), SWITCH_ID) & 0xfff0;
+   sc->swid = e6000sw_readreg(sc, REG_PORT(sc, 0), SWITCH_ID) & 0xfff0;
E6000SW_UNLOCK(sc);
sx_destroy(&sc->sx);
 
@@ -257,6 +269,10 @@ e6000sw_probe(device_t dev)
description = "Marvell 88E6176";
sc->num_ports = 7;
break;
+   case MV88E6190:
+   description = "Marvell 88E6190";
+   sc->num_ports = 11;
+   break;
default:
device_printf(dev, "Unrecognized device, id 0x%x.\n", sc->swid);
return (ENXIO);
@@ -278,18 +294,16 @@ e6000sw_parse_fixed_link(e6000sw_softc_t *sc, phandle_
if (fixed_link != 0) {
sc->fixed_mask |= (1 << port);
 
-   if (OF_getencprop(fixed_link, "speed", &speed, sizeof(speed))> 
0) {
-   if (speed == 2500 &&
-   (MVSWITCH(sc, MV88E6141) ||
-MVSWITCH(sc, MV88E6341)))
-   sc->fixed25_mask |= (1 << port);
-   } else {
-   device_printf(sc->dev,
+   if (OF_getencprop(fixed_link,
+   "speed", &speed, sizeof(speed)) < 0) {
+   device_printf(sc->dev,
"Port %d has a fixed-link node without a speed "
"property\n", port);
-
-   return (ENXIO);
+   return (ENXIO);
}
+   if (speed == 2500 && (MVSWITCH(sc, MV88E6141) ||
+MVSWITCH(sc, MV88E6341) || MVSWITCH(sc, MV88E6190)))
+   sc->fixed25_mask |= (1 << port);
}
 
return (0);
@@ -383,9 +397,36 @@ e6000sw_attach_miibus(e6000sw_softc_t *sc, int port)
return (0);
 }
 
+static void
+e6000sw_serdes_power(device_t dev, int port, bool sgmii)
+{
+   uint32_t reg;
+
+   /* SGMII */
+   reg = e6000sw_read_xmdio(dev, port, E6000SW_SERDES_DEV,
+   E6000SW_SERDES_SGMII_CTL);
+   if (sgmii)
+   reg &= ~E6000SW_SERDES_PDOWN;
+   else
+   reg |= E6000SW_SERDES_PDOWN;
+   e6000sw_write_xmdio(dev, port, E6000SW_SERDES_DEV,
+   E6000SW_SERDES_SGMII_CTL, reg);
+
+   /* 10GBASE-R/10GBASE-X4/X2 */
+   reg = e6000sw_read_xmdio(dev, port, E6000SW_SERDES_DEV,
+   E6000SW_SERDES_PCS_CTL1);
+   if (sgmii)
+   reg |= E6000SW_SERDES_PDOWN;
+   else
+   reg &= ~E6000SW_SERDES_PDOWN;
+   e6000sw_write_xmdio(dev, po

svn commit: r349577 - in head: contrib/elftoolchain/common contrib/elftoolchain/libelftc lib/libelf

2019-07-01 Thread Alex Richardson
Author: arichardson
Date: Mon Jul  1 11:52:54 2019
New Revision: 349577
URL: https://svnweb.freebsd.org/changeset/base/349577

Log:
  Allow bootstrapping elftoolchain on MacOS and Linux
  
  This is required in order to build on non-FreeBSD systems without setting
  all the XAR/XSTRINGS/etc. variables
  
  Reviewed By:  emaste
  Differential Revision: https://reviews.freebsd.org/D16771

Modified:
  head/contrib/elftoolchain/common/_elftc.h
  head/contrib/elftoolchain/libelftc/elftc_set_timestamps.c
  head/lib/libelf/Makefile

Modified: head/contrib/elftoolchain/common/_elftc.h
==
--- head/contrib/elftoolchain/common/_elftc.h   Mon Jul  1 11:47:45 2019
(r349576)
+++ head/contrib/elftoolchain/common/_elftc.h   Mon Jul  1 11:52:54 2019
(r349577)
@@ -374,11 +374,14 @@ extern const char *__progname;
 
 #include 
 #definehtobe32(x)  OSSwapHostToBigInt32(x)
+#definehtole32(x)  OSSwapHostToLittleInt32(x)
+#ifndef roundup2
 #defineroundup2roundup
+#endif
 
-#defineELFTC_BYTE_ORDER_BYTE_ORDER
-#defineELFTC_BYTE_ORDER_LITTLE_ENDIAN  _LITTLE_ENDIAN
-#defineELFTC_BYTE_ORDER_BIG_ENDIAN _BIG_ENDIAN
+#defineELFTC_BYTE_ORDER__DARWIN_BYTE_ORDER
+#defineELFTC_BYTE_ORDER_LITTLE_ENDIAN  __DARWIN_LITTLE_ENDIAN
+#defineELFTC_BYTE_ORDER_BIG_ENDIAN __DARWIN_BIG_ENDIAN
 
 #defineELFTC_HAVE_MMAP 1
 #defineELFTC_HAVE_STRMODE  1
@@ -418,7 +421,9 @@ extern const char *__progname;
 /* Whether we need to supply {be,le}32dec. */
 #define ELFTC_NEED_BYTEORDER_EXTENSIONS1
 
+#ifndef roundup2
 #defineroundup2roundup
+#endif
 
 #endif /* __GLIBC__ || __linux__ */
 

Modified: head/contrib/elftoolchain/libelftc/elftc_set_timestamps.c
==
--- head/contrib/elftoolchain/libelftc/elftc_set_timestamps.c   Mon Jul  1 
11:47:45 2019(r349576)
+++ head/contrib/elftoolchain/libelftc/elftc_set_timestamps.c   Mon Jul  1 
11:52:54 2019(r349577)
@@ -37,7 +37,7 @@ ELFTC_VCSID("$Id$");
  * stat'.
  */
 
-#ifdefined(__FreeBSD__) || defined(__NetBSD__)
+#ifdefined(__FreeBSD__) || defined(__NetBSD__) || defined(__APPLE__)
 #defineATIME   st_atimespec
 #defineMTIME   st_mtimespec
 #defineLIBELFTC_HAVE_UTIMES1

Modified: head/lib/libelf/Makefile
==
--- head/lib/libelf/MakefileMon Jul  1 11:47:45 2019(r349576)
+++ head/lib/libelf/MakefileMon Jul  1 11:52:54 2019(r349577)
@@ -79,6 +79,13 @@ INCS=libelf.h gelf.h
 #
 SRCS+= sys/elf32.h sys/elf64.h sys/elf_common.h
 
+# Allow bootstrapping elftoolchain on Linux:
+.if defined(BOOTSTRAPPING) && ${.MAKE.OS} == "Linux"
+native-elf-format.h:
+   ${ELFTCDIR}/common/native-elf-format > ${.TARGET} || rm ${.TARGET}
+SRCS+= native-elf-format.h
+.endif
+
 GENSRCS=   libelf_fsize.c libelf_msize.c libelf_convert.c
 CLEANFILES=${GENSRCS}
 CLEANDIRS= sys
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r349576 - head/kerberos5/usr.bin/krb5-config

2019-07-01 Thread Alex Richardson
Author: arichardson
Date: Mon Jul  1 11:47:45 2019
New Revision: 349576
URL: https://svnweb.freebsd.org/changeset/base/349576

Log:
  Fix generation of krb5-config with LC_CTYPE=*.UTF-8
  
  When building on MacOS with a UTF-8 locale sed will fail when reading
  krb-config.in due to invalid characters. Forcing the "C" locale fixes this.
  
  Reviewed By:  emaste, cy
  Differential Revision: https://reviews.freebsd.org/D16849

Modified:
  head/kerberos5/usr.bin/krb5-config/Makefile

Modified: head/kerberos5/usr.bin/krb5-config/Makefile
==
--- head/kerberos5/usr.bin/krb5-config/Makefile Mon Jul  1 10:15:52 2019
(r349575)
+++ head/kerberos5/usr.bin/krb5-config/Makefile Mon Jul  1 11:47:45 2019
(r349576)
@@ -5,8 +5,12 @@ MAN=   krb5-config.1
 
 CLEANFILES= krb5-config
 
+# In order for this to work on MacOS we need to set LC_ALL=C since the
+# krb5-config.in file contains characters that will be rejected by MacOS with
+# a UTF-8 locale (see https://stackoverflow.com/a/23584470/894271)
+# TODO: Should we just require LC_ALL=C during the build?
 krb5-config: krb5-config.in
-   sed -e "s,@PACKAGE@,FreeBSD heimdal,g" \
+   env LC_ALL=C sed -e "s,@PACKAGE@,FreeBSD heimdal,g" \
-e "s,@VERSION@,1.1.0,g" \
-e "s,@prefix@,/usr,g" \
-e "s,@exec_prefix@,/usr,g" \
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"