Re: svn commit: r348886 - in head/sys/riscv: include riscv

2019-06-10 Thread Mitchell Horne
On Mon, Jun 10, 2019 at 9:12 PM Ian Lepore  wrote:
>
> On Tue, 2019-06-11 at 00:55 +, Mitchell Horne wrote:
> > Author: mhorne
> > Date: Tue Jun 11 00:55:54 2019
> > New Revision: 348886
> > URL: https://svnweb.freebsd.org/changeset/base/348886
> >
> > Log:
> >   RISC-V: expose extension bits in AT_HWCAP
> >
> >   AT_HWCAP is a field in the elf auxiliary vector meant to describe
> >   cpu-specific hardware features. For RISC-V we want to use this to
> >   indicate the presence of any standard extensions supported by the
> > CPU.
> >   This allows userland applications to query the system for supported
> >   extensions using elf_aux_info(3).
> >
> >   Support for an extension is indicated by the presence of its
> >   corresponding bit in AT_HWCAP -- e.g. systems supporting the 'c'
> >   extension (compressed instructions) will have the second bit set.
> >
> >   Extensions advertised through AT_HWCAP are only those that are
> > supported
> >   by all harts in the system.
> >
>
> A word of advice from the arm world (a don't make the mistakes we did
> kind of thing):  If linux has already defined AT_HWCAP values for
> riscv, life may be better in the long run if our values match theirs as
> much as possible.  It will especially help with ports.
>
> -- Ian

That's good advice. Rest assured that in this case we are mimicking the
behaviour that's been implemented in Linux.

Mitchell

>
> >   Reviewed by:jhb, markj
> >   Approved by:markj (mentor)
> >   MFC after:  2 weeks
> >   Differential Revision:  https://reviews.freebsd.org/D20493
> >
> > Modified:
> >   head/sys/riscv/include/elf.h
> >   head/sys/riscv/include/md_var.h
> >   head/sys/riscv/riscv/elf_machdep.c
> >   head/sys/riscv/riscv/identcpu.c
> >
> > Modified: head/sys/riscv/include/elf.h
> > =
> > =
> > --- head/sys/riscv/include/elf.h  Mon Jun 10 23:25:40 2019(r348
> > 885)
> > +++ head/sys/riscv/include/elf.h  Tue Jun 11 00:55:54 2019(r348
> > 886)
> > @@ -74,4 +74,15 @@ __ElfType(Auxinfo);
> >  /* TODO: set correct value */
> >  #define  ET_DYN_LOAD_ADDR 0x10
> >
> > +/* Flags passed in AT_HWCAP */
> > +#define  HWCAP_ISA_BIT(c)(1 << ((c) - 'A'))
> > +#define  HWCAP_ISA_I HWCAP_ISA_BIT('I')
> > +#define  HWCAP_ISA_M HWCAP_ISA_BIT('M')
> > +#define  HWCAP_ISA_A HWCAP_ISA_BIT('A')
> > +#define  HWCAP_ISA_F HWCAP_ISA_BIT('F')
> > +#define  HWCAP_ISA_D HWCAP_ISA_BIT('D')
> > +#define  HWCAP_ISA_C HWCAP_ISA_BIT('C')
> > +#define  HWCAP_ISA_G \
> > +(HWCAP_ISA_I | HWCAP_ISA_M | HWCAP_ISA_A | HWCAP_ISA_F |
> > HWCAP_ISA_D)
> > +
> >  #endif /* !_MACHINE_ELF_H_ */
> >
> > Modified: head/sys/riscv/include/md_var.h
> > =
> > =
> > --- head/sys/riscv/include/md_var.h   Mon Jun 10 23:25:40 2019(r348
> > 885)
> > +++ head/sys/riscv/include/md_var.h   Tue Jun 11 00:55:54 2019(r348
> > 886)
> > @@ -38,6 +38,7 @@ extern char sigcode[];
> >  extern int szsigcode;
> >  extern uint64_t *vm_page_dump;
> >  extern int vm_page_dump_size;
> > +extern u_long elf_hwcap;
> >
> >  struct dumperinfo;
> >
> >
> > Modified: head/sys/riscv/riscv/elf_machdep.c
> > =
> > =
> > --- head/sys/riscv/riscv/elf_machdep.cMon Jun 10 23:25:40
> > 2019  (r348885)
> > +++ head/sys/riscv/riscv/elf_machdep.cTue Jun 11 00:55:54
> > 2019  (r348886)
> > @@ -58,6 +58,8 @@ __FBSDID("$FreeBSD$");
> >  #include 
> >  #include 
> >
> > +u_long elf_hwcap;
> > +
> >  struct sysentvec elf64_freebsd_sysvec = {
> >   .sv_size= SYS_MAXSYSCALL,
> >   .sv_table   = sysent,
> > @@ -90,6 +92,7 @@ struct sysentvec elf64_freebsd_sysvec = {
> >   .sv_schedtail   = NULL,
> >   .sv_thread_detach = NULL,
> >   .sv_trap= NULL,
> > + .sv_hwcap   = _hwcap,
> >  };
> >  INIT_SYSENTVEC(elf64_sysvec, _freebsd_sysvec);
> >
> >
> > Modified: head/sys/riscv/riscv/identcpu.c
> > =
> > =
> > --- head/sys/riscv/riscv/identcpu.c   Mon Jun 10 23:25:40 2019(r348
> > 885)
> > +++ head/sys/riscv/riscv/identcpu.c   Tue Jun 11 00:55:54 2019(r348
> > 886)
> > @@ -32,18 +32,28 @@
> >   * SUCH DAMAGE.
> >   */
> >
> > +#include "opt_platform.h"
> > +
> >  #include 
> >  __FBSDID("$FreeBSD$");
> >
> >  #include 
> > +#include 
> > +#include 
> >  #include 
> >  #include 
> > -#include 
> >
> >  #include 
> >  #include 
> > +#include 
> > +#include 
> >  #include 
> >
> > +#ifdef FDT
> > +#include 
> > +#include 
> > +#endif
> > +
> >  char machine[] = "riscv";
> >
> >  SYSCTL_STRING(_hw, HW_MACHINE, machine, CTLFLAG_RD, machine, 0,
> > @@ -87,6 +97,84 @@ const struct 

svn commit: r348892 - stable/11/sys/contrib/ipfilter/netinet

2019-06-10 Thread Cy Schubert
Author: cy
Date: Tue Jun 11 03:40:25 2019
New Revision: 348892
URL: https://svnweb.freebsd.org/changeset/base/348892

Log:
  MFC r348667:
  
  While working on a PR, more are discovered.
  Remove more #ifdefs missed in r343701.
  
  Approved by:  re (gjb@)

Modified:
  stable/11/sys/contrib/ipfilter/netinet/ip_fil_freebsd.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/contrib/ipfilter/netinet/ip_fil_freebsd.c
==
--- stable/11/sys/contrib/ipfilter/netinet/ip_fil_freebsd.c Tue Jun 11 
03:39:20 2019(r348891)
+++ stable/11/sys/contrib/ipfilter/netinet/ip_fil_freebsd.c Tue Jun 11 
03:40:25 2019(r348892)
@@ -16,11 +16,11 @@ static const char rcsid[] = "@(#)$Id$";
 # define   KERNEL  1
 # define   _KERNEL 1
 #endif
-#if defined(__FreeBSD_version) && (__FreeBSD_version >= 40) && \
+#if defined(__FreeBSD_version) && \
 !defined(KLD_MODULE) && !defined(IPFILTER_LKM)
 # include "opt_inet6.h"
 #endif
-#if defined(__FreeBSD_version) && (__FreeBSD_version >= 44) && \
+#if defined(__FreeBSD_version) && \
 !defined(KLD_MODULE) && !defined(IPFILTER_LKM)
 # include "opt_random_ip_id.h"
 #endif
@@ -33,7 +33,7 @@ static const char rcsid[] = "@(#)$Id$";
 #include 
 #include 
 # include 
-#if defined(__FreeBSD_version) && (__FreeBSD_version >= 80)
+#if defined(__FreeBSD_version)
 #include 
 #endif
 # include 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r348891 - stable/11/sys/contrib/ipfilter/netinet

2019-06-10 Thread Cy Schubert
Author: cy
Date: Tue Jun 11 03:39:20 2019
New Revision: 348891
URL: https://svnweb.freebsd.org/changeset/base/348891

Log:
  MFC r348666:
  
  Clean up #ifdefs from old unsupported releases of FreeBSD.
  
  Approved by:  re (gjb@)

Modified:
  stable/11/sys/contrib/ipfilter/netinet/fil.c
  stable/11/sys/contrib/ipfilter/netinet/mlfk_ipl.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/contrib/ipfilter/netinet/fil.c
==
--- stable/11/sys/contrib/ipfilter/netinet/fil.cTue Jun 11 03:07:23 
2019(r348890)
+++ stable/11/sys/contrib/ipfilter/netinet/fil.cTue Jun 11 03:39:20 
2019(r348891)
@@ -2882,8 +2882,7 @@ ipf_check(ctx, ip, hlen, ifp, out
 */
m->m_flags &= ~M_CANFASTFWD;
 #  endif /* M_CANFASTFWD */
-#  if defined(CSUM_DELAY_DATA) && (!defined(__FreeBSD_version) || \
-  (__FreeBSD_version < 501108))
+#  if defined(CSUM_DELAY_DATA) && !defined(__FreeBSD_version)
/*
 * disable delayed checksums.
 */

Modified: stable/11/sys/contrib/ipfilter/netinet/mlfk_ipl.c
==
--- stable/11/sys/contrib/ipfilter/netinet/mlfk_ipl.c   Tue Jun 11 03:07:23 
2019(r348890)
+++ stable/11/sys/contrib/ipfilter/netinet/mlfk_ipl.c   Tue Jun 11 03:39:20 
2019(r348891)
@@ -22,19 +22,19 @@
 #include 
 #include 
 #include 
-#if __FreeBSD_version >= 50
+#ifdef __FreeBSD_version
 # include 
 # include 
+# ifdef _KERNEL
+#  include 
+# else
+#  define CURVNET_SET(arg)
+#  define CURVNET_RESTORE()
+#  define  VNET_DEFINE(_t, _v) _t _v
+#  define  VNET_DECLARE(_t, _v)extern _t _v
+#  define  VNET(arg)   arg
+# endif
 #endif
-#if defined(__FreeBSD_version) && (__FreeBSD_version >= 80) && 
defined(_KERNEL)
-#include 
-#else
-#define CURVNET_SET(arg)
-#define CURVNET_RESTORE()
-#defineVNET_DEFINE(_t, _v) _t _v
-#defineVNET_DECLARE(_t, _v)extern _t _v
-#defineVNET(arg)   arg
-#endif
 #include 
 #include 
 #include 
@@ -52,7 +52,7 @@
 VNET_DECLARE(ipf_main_softc_t, ipfmain);
 #defineV_ipfmain   VNET(ipfmain)
 
-#if __FreeBSD_version >= 502116
+#ifdef __FreeBSD_version
 static struct cdev *ipf_devs[IPL_LOGSIZE];
 #else
 static dev_t ipf_devs[IPL_LOGSIZE];
@@ -68,25 +68,17 @@ static int ipf_modunload(void);
 static int ipf_fbsd_sysctl_create(void);
 static int ipf_fbsd_sysctl_destroy(void);
 
-#if (__FreeBSD_version >= 500024)
-# if (__FreeBSD_version >= 502116)
+#ifdef __FreeBSD_version
 static int ipfopen __P((struct cdev*, int, int, struct thread *));
 static int ipfclose __P((struct cdev*, int, int, struct thread *));
-# else
-static int ipfopen __P((dev_t, int, int, struct thread *));
-static int ipfclose __P((dev_t, int, int, struct thread *));
-# endif /* __FreeBSD_version >= 502116 */
-#else
-static int ipfopen __P((dev_t, int, int, struct proc *));
-static int ipfclose __P((dev_t, int, int, struct proc *));
-#endif
-#if (__FreeBSD_version >= 502116)
 static int ipfread __P((struct cdev*, struct uio *, int));
 static int ipfwrite __P((struct cdev*, struct uio *, int));
 #else
+static int ipfopen __P((dev_t, int, int, struct proc *));
+static int ipfclose __P((dev_t, int, int, struct proc *));
 static int ipfread __P((dev_t, struct uio *, int));
 static int ipfwrite __P((dev_t, struct uio *, int));
-#endif /* __FreeBSD_version >= 502116 */
+#endif
 
 
 SYSCTL_DECL(_net_inet);
@@ -137,15 +129,13 @@ SYSCTL_IPF(_net_inet_ipf, OID_AUTO, fr_minttl, CTLFLAG
 
 #define CDEV_MAJOR 79
 #include 
-#if __FreeBSD_version >= 500043
+#ifdef __FreeBSD_version
 # include 
 static int ipfpoll(struct cdev *dev, int events, struct thread *td);
 
 static struct cdevsw ipf_cdevsw = {
-#if __FreeBSD_version >= 502103
.d_version =D_VERSION,
.d_flags =  0,  /* D_NEEDGIANT - Should be SMP safe */
-#endif
.d_open =   ipfopen,
.d_close =  ipfclose,
.d_read =   ipfread,
@@ -153,9 +143,6 @@ static struct cdevsw ipf_cdevsw = {
.d_ioctl =  ipfioctl,
.d_poll =   ipfpoll,
.d_name =   "ipf",
-#if __FreeBSD_version < 60
-   .d_maj =CDEV_MAJOR,
-#endif
 };
 #else
 static int ipfpoll(dev_t dev, int events, struct proc *td);
@@ -174,12 +161,6 @@ static struct cdevsw ipf_cdevsw = {
/* dump */  nodump,
/* psize */ nopsize,
/* flags */ 0,
-# if (__FreeBSD_version < 500043)
-   /* bmaj */  -1,
-# endif
-# if (__FreeBSD_version >= 43)
-   /* kqfilter */  NULL
-# endif
 };
 #endif
 
@@ -444,7 +425,7 @@ sysctl_ipf_int_frag ( SYSCTL_HANDLER_ARGS )
 
 
 static int
-#if __FreeBSD_version >= 500043
+#ifdef __FreeBSD_version
 ipfpoll(struct cdev *dev, int events, struct thread *td)
 #else
 

svn commit: r348890 - stable/12/sys/contrib/ipfilter/netinet

2019-06-10 Thread Cy Schubert
Author: cy
Date: Tue Jun 11 03:07:23 2019
New Revision: 348890
URL: https://svnweb.freebsd.org/changeset/base/348890

Log:
  MFC r348667:
  
  While working on a PR, more are discovered.
  Remove more #ifdefs missed in r343701.

Modified:
  stable/12/sys/contrib/ipfilter/netinet/ip_fil_freebsd.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/contrib/ipfilter/netinet/ip_fil_freebsd.c
==
--- stable/12/sys/contrib/ipfilter/netinet/ip_fil_freebsd.c Tue Jun 11 
03:06:36 2019(r348889)
+++ stable/12/sys/contrib/ipfilter/netinet/ip_fil_freebsd.c Tue Jun 11 
03:07:23 2019(r348890)
@@ -16,11 +16,11 @@ static const char rcsid[] = "@(#)$Id$";
 # define   KERNEL  1
 # define   _KERNEL 1
 #endif
-#if defined(__FreeBSD_version) && (__FreeBSD_version >= 40) && \
+#if defined(__FreeBSD_version) && \
 !defined(KLD_MODULE) && !defined(IPFILTER_LKM)
 # include "opt_inet6.h"
 #endif
-#if defined(__FreeBSD_version) && (__FreeBSD_version >= 44) && \
+#if defined(__FreeBSD_version) && \
 !defined(KLD_MODULE) && !defined(IPFILTER_LKM)
 # include "opt_random_ip_id.h"
 #endif
@@ -33,7 +33,7 @@ static const char rcsid[] = "@(#)$Id$";
 #include 
 #include 
 # include 
-#if defined(__FreeBSD_version) && (__FreeBSD_version >= 80)
+#if defined(__FreeBSD_version)
 #include 
 #endif
 # include 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r348889 - stable/12/sys/contrib/ipfilter/netinet

2019-06-10 Thread Cy Schubert
Author: cy
Date: Tue Jun 11 03:06:36 2019
New Revision: 348889
URL: https://svnweb.freebsd.org/changeset/base/348889

Log:
  MFC r348666:
  
  Clean up #ifdefs from old unsupported releases of FreeBSD.

Modified:
  stable/12/sys/contrib/ipfilter/netinet/fil.c
  stable/12/sys/contrib/ipfilter/netinet/mlfk_ipl.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/contrib/ipfilter/netinet/fil.c
==
--- stable/12/sys/contrib/ipfilter/netinet/fil.cTue Jun 11 01:09:54 
2019(r34)
+++ stable/12/sys/contrib/ipfilter/netinet/fil.cTue Jun 11 03:06:36 
2019(r348889)
@@ -2882,8 +2882,7 @@ ipf_check(ctx, ip, hlen, ifp, out
 */
m->m_flags &= ~M_CANFASTFWD;
 #  endif /* M_CANFASTFWD */
-#  if defined(CSUM_DELAY_DATA) && (!defined(__FreeBSD_version) || \
-  (__FreeBSD_version < 501108))
+#  if defined(CSUM_DELAY_DATA) && !defined(__FreeBSD_version)
/*
 * disable delayed checksums.
 */

Modified: stable/12/sys/contrib/ipfilter/netinet/mlfk_ipl.c
==
--- stable/12/sys/contrib/ipfilter/netinet/mlfk_ipl.c   Tue Jun 11 01:09:54 
2019(r34)
+++ stable/12/sys/contrib/ipfilter/netinet/mlfk_ipl.c   Tue Jun 11 03:06:36 
2019(r348889)
@@ -22,19 +22,19 @@
 #include 
 #include 
 #include 
-#if __FreeBSD_version >= 50
+#ifdef __FreeBSD_version
 # include 
 # include 
+# ifdef _KERNEL
+#  include 
+# else
+#  define CURVNET_SET(arg)
+#  define CURVNET_RESTORE()
+#  define  VNET_DEFINE(_t, _v) _t _v
+#  define  VNET_DECLARE(_t, _v)extern _t _v
+#  define  VNET(arg)   arg
+# endif
 #endif
-#if defined(__FreeBSD_version) && (__FreeBSD_version >= 80) && 
defined(_KERNEL)
-#include 
-#else
-#define CURVNET_SET(arg)
-#define CURVNET_RESTORE()
-#defineVNET_DEFINE(_t, _v) _t _v
-#defineVNET_DECLARE(_t, _v)extern _t _v
-#defineVNET(arg)   arg
-#endif
 #include 
 #include 
 #include 
@@ -52,7 +52,7 @@
 VNET_DECLARE(ipf_main_softc_t, ipfmain);
 #defineV_ipfmain   VNET(ipfmain)
 
-#if __FreeBSD_version >= 502116
+#ifdef __FreeBSD_version
 static struct cdev *ipf_devs[IPL_LOGSIZE];
 #else
 static dev_t ipf_devs[IPL_LOGSIZE];
@@ -68,25 +68,17 @@ static int ipf_modunload(void);
 static int ipf_fbsd_sysctl_create(void);
 static int ipf_fbsd_sysctl_destroy(void);
 
-#if (__FreeBSD_version >= 500024)
-# if (__FreeBSD_version >= 502116)
+#ifdef __FreeBSD_version
 static int ipfopen __P((struct cdev*, int, int, struct thread *));
 static int ipfclose __P((struct cdev*, int, int, struct thread *));
-# else
-static int ipfopen __P((dev_t, int, int, struct thread *));
-static int ipfclose __P((dev_t, int, int, struct thread *));
-# endif /* __FreeBSD_version >= 502116 */
-#else
-static int ipfopen __P((dev_t, int, int, struct proc *));
-static int ipfclose __P((dev_t, int, int, struct proc *));
-#endif
-#if (__FreeBSD_version >= 502116)
 static int ipfread __P((struct cdev*, struct uio *, int));
 static int ipfwrite __P((struct cdev*, struct uio *, int));
 #else
+static int ipfopen __P((dev_t, int, int, struct proc *));
+static int ipfclose __P((dev_t, int, int, struct proc *));
 static int ipfread __P((dev_t, struct uio *, int));
 static int ipfwrite __P((dev_t, struct uio *, int));
-#endif /* __FreeBSD_version >= 502116 */
+#endif
 
 
 SYSCTL_DECL(_net_inet);
@@ -137,15 +129,13 @@ SYSCTL_IPF(_net_inet_ipf, OID_AUTO, fr_minttl, CTLFLAG
 
 #define CDEV_MAJOR 79
 #include 
-#if __FreeBSD_version >= 500043
+#ifdef __FreeBSD_version
 # include 
 static int ipfpoll(struct cdev *dev, int events, struct thread *td);
 
 static struct cdevsw ipf_cdevsw = {
-#if __FreeBSD_version >= 502103
.d_version =D_VERSION,
.d_flags =  0,  /* D_NEEDGIANT - Should be SMP safe */
-#endif
.d_open =   ipfopen,
.d_close =  ipfclose,
.d_read =   ipfread,
@@ -153,9 +143,6 @@ static struct cdevsw ipf_cdevsw = {
.d_ioctl =  ipfioctl,
.d_poll =   ipfpoll,
.d_name =   "ipf",
-#if __FreeBSD_version < 60
-   .d_maj =CDEV_MAJOR,
-#endif
 };
 #else
 static int ipfpoll(dev_t dev, int events, struct proc *td);
@@ -174,12 +161,6 @@ static struct cdevsw ipf_cdevsw = {
/* dump */  nodump,
/* psize */ nopsize,
/* flags */ 0,
-# if (__FreeBSD_version < 500043)
-   /* bmaj */  -1,
-# endif
-# if (__FreeBSD_version >= 43)
-   /* kqfilter */  NULL
-# endif
 };
 #endif
 
@@ -444,7 +425,7 @@ sysctl_ipf_int_frag ( SYSCTL_HANDLER_ARGS )
 
 
 static int
-#if __FreeBSD_version >= 500043
+#ifdef __FreeBSD_version
 ipfpoll(struct cdev *dev, int events, struct thread *td)
 #else
 ipfpoll(dev_t dev, int events, struct 

Re: svn commit: r348886 - in head/sys/riscv: include riscv

2019-06-10 Thread Ian Lepore
On Tue, 2019-06-11 at 00:55 +, Mitchell Horne wrote:
> Author: mhorne
> Date: Tue Jun 11 00:55:54 2019
> New Revision: 348886
> URL: https://svnweb.freebsd.org/changeset/base/348886
> 
> Log:
>   RISC-V: expose extension bits in AT_HWCAP
>   
>   AT_HWCAP is a field in the elf auxiliary vector meant to describe
>   cpu-specific hardware features. For RISC-V we want to use this to
>   indicate the presence of any standard extensions supported by the
> CPU.
>   This allows userland applications to query the system for supported
>   extensions using elf_aux_info(3).
>   
>   Support for an extension is indicated by the presence of its
>   corresponding bit in AT_HWCAP -- e.g. systems supporting the 'c'
>   extension (compressed instructions) will have the second bit set.
>   
>   Extensions advertised through AT_HWCAP are only those that are
> supported
>   by all harts in the system.
>   

A word of advice from the arm world (a don't make the mistakes we did
kind of thing):  If linux has already defined AT_HWCAP values for
riscv, life may be better in the long run if our values match theirs as
much as possible.  It will especially help with ports.

-- Ian

>   Reviewed by:jhb, markj
>   Approved by:markj (mentor)
>   MFC after:  2 weeks
>   Differential Revision:  https://reviews.freebsd.org/D20493
> 
> Modified:
>   head/sys/riscv/include/elf.h
>   head/sys/riscv/include/md_var.h
>   head/sys/riscv/riscv/elf_machdep.c
>   head/sys/riscv/riscv/identcpu.c
> 
> Modified: head/sys/riscv/include/elf.h
> =
> =
> --- head/sys/riscv/include/elf.h  Mon Jun 10 23:25:40 2019(r348
> 885)
> +++ head/sys/riscv/include/elf.h  Tue Jun 11 00:55:54 2019(r348
> 886)
> @@ -74,4 +74,15 @@ __ElfType(Auxinfo);
>  /* TODO: set correct value */
>  #define  ET_DYN_LOAD_ADDR 0x10
>  
> +/* Flags passed in AT_HWCAP */
> +#define  HWCAP_ISA_BIT(c)(1 << ((c) - 'A'))
> +#define  HWCAP_ISA_I HWCAP_ISA_BIT('I')
> +#define  HWCAP_ISA_M HWCAP_ISA_BIT('M')
> +#define  HWCAP_ISA_A HWCAP_ISA_BIT('A')
> +#define  HWCAP_ISA_F HWCAP_ISA_BIT('F')
> +#define  HWCAP_ISA_D HWCAP_ISA_BIT('D')
> +#define  HWCAP_ISA_C HWCAP_ISA_BIT('C')
> +#define  HWCAP_ISA_G \
> +(HWCAP_ISA_I | HWCAP_ISA_M | HWCAP_ISA_A | HWCAP_ISA_F |
> HWCAP_ISA_D)
> +
>  #endif /* !_MACHINE_ELF_H_ */
> 
> Modified: head/sys/riscv/include/md_var.h
> =
> =
> --- head/sys/riscv/include/md_var.h   Mon Jun 10 23:25:40 2019(r348
> 885)
> +++ head/sys/riscv/include/md_var.h   Tue Jun 11 00:55:54 2019(r348
> 886)
> @@ -38,6 +38,7 @@ extern char sigcode[];
>  extern int szsigcode;
>  extern uint64_t *vm_page_dump;
>  extern int vm_page_dump_size;
> +extern u_long elf_hwcap;
>  
>  struct dumperinfo;
>  
> 
> Modified: head/sys/riscv/riscv/elf_machdep.c
> =
> =
> --- head/sys/riscv/riscv/elf_machdep.cMon Jun 10 23:25:40
> 2019  (r348885)
> +++ head/sys/riscv/riscv/elf_machdep.cTue Jun 11 00:55:54
> 2019  (r348886)
> @@ -58,6 +58,8 @@ __FBSDID("$FreeBSD$");
>  #include 
>  #include 
>  
> +u_long elf_hwcap;
> +
>  struct sysentvec elf64_freebsd_sysvec = {
>   .sv_size= SYS_MAXSYSCALL,
>   .sv_table   = sysent,
> @@ -90,6 +92,7 @@ struct sysentvec elf64_freebsd_sysvec = {
>   .sv_schedtail   = NULL,
>   .sv_thread_detach = NULL,
>   .sv_trap= NULL,
> + .sv_hwcap   = _hwcap,
>  };
>  INIT_SYSENTVEC(elf64_sysvec, _freebsd_sysvec);
>  
> 
> Modified: head/sys/riscv/riscv/identcpu.c
> =
> =
> --- head/sys/riscv/riscv/identcpu.c   Mon Jun 10 23:25:40 2019(r348
> 885)
> +++ head/sys/riscv/riscv/identcpu.c   Tue Jun 11 00:55:54 2019(r348
> 886)
> @@ -32,18 +32,28 @@
>   * SUCH DAMAGE.
>   */
>  
> +#include "opt_platform.h"
> +
>  #include 
>  __FBSDID("$FreeBSD$");
>  
>  #include 
> +#include 
> +#include 
>  #include 
>  #include 
> -#include 
>  
>  #include 
>  #include 
> +#include 
> +#include 
>  #include 
>  
> +#ifdef FDT
> +#include 
> +#include 
> +#endif
> +
>  char machine[] = "riscv";
>  
>  SYSCTL_STRING(_hw, HW_MACHINE, machine, CTLFLAG_RD, machine, 0,
> @@ -87,6 +97,84 @@ const struct cpu_implementers cpu_implementers[] =
> {
>   { CPU_IMPL_UCB_ROCKET,  "UC Berkeley Rocket" },
>   CPU_IMPLEMENTER_NONE,
>  };
> +
> +#ifdef FDT
> +/*
> + * The ISA string is made up of a small prefix (e.g. rv64) and up to
> 26 letters
> + * indicating the presence of the 26 possible standard extensions.
> Therefore 32
> + * characters will be sufficient.
> + */
> +#define  ISA_NAME_MAXLEN 32
> +#define  

svn commit: r348888 - stable/12/sys/dev/oce

2019-06-10 Thread Alexander Motin
Author: mav
Date: Tue Jun 11 01:09:54 2019
New Revision: 34
URL: https://svnweb.freebsd.org/changeset/base/34

Log:
  MFC r348332: Fix array out of bound panic introduced in r306219.
  
  As I see, different NICs in different configurations may have different
  numbers of TX and RX queues.  The code was assuming 1:1 mapping between
  event queues (interrupts) and TX/RX queues.  Since number of interrupts
  is set to maximum of TX and RX queues, when those two are different, the
  system is doomed.
  
  I have no documentation or deep knowledge about this hardware, so this
  change is based on general observations and code reading.  If some of my
  guesses are wrong, please do better.  I just confirmed HP NC550SFP NICs
  are working now.

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

Modified: stable/12/sys/dev/oce/oce_if.c
==
--- stable/12/sys/dev/oce/oce_if.c  Tue Jun 11 00:59:46 2019
(r348887)
+++ stable/12/sys/dev/oce/oce_if.c  Tue Jun 11 01:09:54 2019
(r34)
@@ -2394,10 +2394,20 @@ oce_eqd_set_periodic(POCE_SOFTC sc)
goto modify_eqd;
}
 
-   rq = sc->rq[i];
-   rxpkts = rq->rx_stats.rx_pkts;
-   wq = sc->wq[i];
-   tx_reqs = wq->tx_stats.tx_reqs;
+   if (i == 0) {
+   rq = sc->rq[0];
+   rxpkts = rq->rx_stats.rx_pkts;
+   } else
+   rxpkts = 0;
+   if (i + 1 < sc->nrqs) {
+   rq = sc->rq[i + 1];
+   rxpkts += rq->rx_stats.rx_pkts;
+   }
+   if (i < sc->nwqs) {
+   wq = sc->wq[i];
+   tx_reqs = wq->tx_stats.tx_reqs;
+   } else
+   tx_reqs = 0;
now = ticks;
 
if (!aic->ticks || now < aic->ticks ||
___
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: r348887 - head/usr.bin/procstat

2019-06-10 Thread Mitchell Horne
Author: mhorne
Date: Tue Jun 11 00:59:46 2019
New Revision: 348887
URL: https://svnweb.freebsd.org/changeset/base/348887

Log:
  procstat: Recognize HWCAP and HWCAP2 with auxv command
  
  The two most recent additions to the elf auxiliary vector are
  HWCAP and HWCAP2 which describe platform specific cpu capabilities.
  
  Make procstat recognize these fields so that they aren't displayed
  as UNKNOWN.
  
  Reviewed by:  trociny, markj
  Approved by:  markj (mentor)
  MFC after:3 days
  Differential Revision:https://reviews.freebsd.org/D20582

Modified:
  head/usr.bin/procstat/procstat_auxv.c

Modified: head/usr.bin/procstat/procstat_auxv.c
==
--- head/usr.bin/procstat/procstat_auxv.c   Tue Jun 11 00:55:54 2019
(r348886)
+++ head/usr.bin/procstat/procstat_auxv.c   Tue Jun 11 00:59:46 2019
(r348887)
@@ -185,6 +185,18 @@ procstat_auxv(struct procstat *procstat, struct kinfo_
prefix, "AT_EHDRFLAGS", (u_long)auxv[i].a_un.a_val);
break;
 #endif
+#ifdef AT_HWCAP
+   case AT_HWCAP:
+   xo_emit("{dw:/%s}{Lw:/%-16s/%s}{:AT_HWCAP/%#lx}\n",
+   prefix, "AT_HWCAP", (u_long)auxv[i].a_un.a_val);
+   break;
+#endif
+#ifdef AT_HWCAP2
+   case AT_HWCAP2:
+   xo_emit("{dw:/%s}{Lw:/%-16s/%s}{:AT_HWCAP2/%#lx}\n",
+   prefix, "AT_HWCAP2", (u_long)auxv[i].a_un.a_val);
+   break;
+#endif
default:
xo_emit("{dw:/%s}{Lw:/%16ld/%ld}{:UNKNOWN/%#lx}\n",
prefix, auxv[i].a_type, auxv[i].a_un.a_val);
___
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: r348886 - in head/sys/riscv: include riscv

2019-06-10 Thread Mitchell Horne
Author: mhorne
Date: Tue Jun 11 00:55:54 2019
New Revision: 348886
URL: https://svnweb.freebsd.org/changeset/base/348886

Log:
  RISC-V: expose extension bits in AT_HWCAP
  
  AT_HWCAP is a field in the elf auxiliary vector meant to describe
  cpu-specific hardware features. For RISC-V we want to use this to
  indicate the presence of any standard extensions supported by the CPU.
  This allows userland applications to query the system for supported
  extensions using elf_aux_info(3).
  
  Support for an extension is indicated by the presence of its
  corresponding bit in AT_HWCAP -- e.g. systems supporting the 'c'
  extension (compressed instructions) will have the second bit set.
  
  Extensions advertised through AT_HWCAP are only those that are supported
  by all harts in the system.
  
  Reviewed by:  jhb, markj
  Approved by:  markj (mentor)
  MFC after:2 weeks
  Differential Revision:https://reviews.freebsd.org/D20493

Modified:
  head/sys/riscv/include/elf.h
  head/sys/riscv/include/md_var.h
  head/sys/riscv/riscv/elf_machdep.c
  head/sys/riscv/riscv/identcpu.c

Modified: head/sys/riscv/include/elf.h
==
--- head/sys/riscv/include/elf.hMon Jun 10 23:25:40 2019
(r348885)
+++ head/sys/riscv/include/elf.hTue Jun 11 00:55:54 2019
(r348886)
@@ -74,4 +74,15 @@ __ElfType(Auxinfo);
 /* TODO: set correct value */
 #defineET_DYN_LOAD_ADDR 0x10
 
+/* Flags passed in AT_HWCAP */
+#defineHWCAP_ISA_BIT(c)(1 << ((c) - 'A'))
+#defineHWCAP_ISA_I HWCAP_ISA_BIT('I')
+#defineHWCAP_ISA_M HWCAP_ISA_BIT('M')
+#defineHWCAP_ISA_A HWCAP_ISA_BIT('A')
+#defineHWCAP_ISA_F HWCAP_ISA_BIT('F')
+#defineHWCAP_ISA_D HWCAP_ISA_BIT('D')
+#defineHWCAP_ISA_C HWCAP_ISA_BIT('C')
+#defineHWCAP_ISA_G \
+(HWCAP_ISA_I | HWCAP_ISA_M | HWCAP_ISA_A | HWCAP_ISA_F | HWCAP_ISA_D)
+
 #endif /* !_MACHINE_ELF_H_ */

Modified: head/sys/riscv/include/md_var.h
==
--- head/sys/riscv/include/md_var.h Mon Jun 10 23:25:40 2019
(r348885)
+++ head/sys/riscv/include/md_var.h Tue Jun 11 00:55:54 2019
(r348886)
@@ -38,6 +38,7 @@ extern char sigcode[];
 extern int szsigcode;
 extern uint64_t *vm_page_dump;
 extern int vm_page_dump_size;
+extern u_long elf_hwcap;
 
 struct dumperinfo;
 

Modified: head/sys/riscv/riscv/elf_machdep.c
==
--- head/sys/riscv/riscv/elf_machdep.c  Mon Jun 10 23:25:40 2019
(r348885)
+++ head/sys/riscv/riscv/elf_machdep.c  Tue Jun 11 00:55:54 2019
(r348886)
@@ -58,6 +58,8 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 
+u_long elf_hwcap;
+
 struct sysentvec elf64_freebsd_sysvec = {
.sv_size= SYS_MAXSYSCALL,
.sv_table   = sysent,
@@ -90,6 +92,7 @@ struct sysentvec elf64_freebsd_sysvec = {
.sv_schedtail   = NULL,
.sv_thread_detach = NULL,
.sv_trap= NULL,
+   .sv_hwcap   = _hwcap,
 };
 INIT_SYSENTVEC(elf64_sysvec, _freebsd_sysvec);
 

Modified: head/sys/riscv/riscv/identcpu.c
==
--- head/sys/riscv/riscv/identcpu.c Mon Jun 10 23:25:40 2019
(r348885)
+++ head/sys/riscv/riscv/identcpu.c Tue Jun 11 00:55:54 2019
(r348886)
@@ -32,18 +32,28 @@
  * SUCH DAMAGE.
  */
 
+#include "opt_platform.h"
+
 #include 
 __FBSDID("$FreeBSD$");
 
 #include 
+#include 
+#include 
 #include 
 #include 
-#include 
 
 #include 
 #include 
+#include 
+#include 
 #include 
 
+#ifdef FDT
+#include 
+#include 
+#endif
+
 char machine[] = "riscv";
 
 SYSCTL_STRING(_hw, HW_MACHINE, machine, CTLFLAG_RD, machine, 0,
@@ -87,6 +97,84 @@ const struct cpu_implementers cpu_implementers[] = {
{ CPU_IMPL_UCB_ROCKET,  "UC Berkeley Rocket" },
CPU_IMPLEMENTER_NONE,
 };
+
+#ifdef FDT
+/*
+ * The ISA string is made up of a small prefix (e.g. rv64) and up to 26 letters
+ * indicating the presence of the 26 possible standard extensions. Therefore 32
+ * characters will be sufficient.
+ */
+#defineISA_NAME_MAXLEN 32
+#defineISA_PREFIX  ("rv" __XSTRING(__riscv_xlen))
+#defineISA_PREFIX_LEN  (sizeof(ISA_PREFIX) - 1)
+
+static void
+fill_elf_hwcap(void *dummy __unused)
+{
+   u_long caps[256] = {0};
+   char isa[ISA_NAME_MAXLEN];
+   u_long hwcap;
+   phandle_t node;
+   ssize_t len;
+   int i;
+
+   caps['i'] = caps['I'] = HWCAP_ISA_I;
+   caps['m'] = caps['M'] = HWCAP_ISA_M;
+   caps['a'] = caps['A'] = HWCAP_ISA_A;
+#ifdef FPE
+   caps['f'] = caps['F'] = HWCAP_ISA_F;
+   caps['d'] = caps['D'] = HWCAP_ISA_D;
+#endif
+   caps['c'] = 

svn commit: r348885 - in head/sys: arm/allwinner arm/broadcom/bcm2835 arm64/rockchip

2019-06-10 Thread Bjoern A. Zeeb
Author: bz
Date: Mon Jun 10 23:25:40 2019
New Revision: 348885
URL: https://svnweb.freebsd.org/changeset/base/348885

Log:
  A bit of code hygiene (no functional changes).
  
  Hide unused code under #ifdef notyet (in one case the only caller is under
  that same ifdef), or if it is arm (not arm64) specific code under the
  __arm__ ifdef to not yield -Wunused-function warnings during the arm64
  kernel compile.
  
  MFC after:2 weeks

Modified:
  head/sys/arm/allwinner/a10_timer.c
  head/sys/arm/broadcom/bcm2835/bcm2835_sdhost.c
  head/sys/arm64/rockchip/if_dwc_rk.c

Modified: head/sys/arm/allwinner/a10_timer.c
==
--- head/sys/arm/allwinner/a10_timer.c  Mon Jun 10 22:23:37 2019
(r348884)
+++ head/sys/arm/allwinner/a10_timer.c  Mon Jun 10 23:25:40 2019
(r348885)
@@ -108,12 +108,16 @@ struct a10_timer_softc {
bus_write_4(sc->res[A10_TIMER_MEMRES], reg, val)
 
 static u_int   a10_timer_get_timecount(struct timecounter *);
+#if defined(__arm__)
 static int a10_timer_timer_start(struct eventtimer *,
 sbintime_t first, sbintime_t period);
 static int a10_timer_timer_stop(struct eventtimer *);
+#endif
 
 static uint64_t timer_read_counter64(struct a10_timer_softc *sc);
+#if defined(__arm__)
 static void a10_timer_eventtimer_setup(struct a10_timer_softc *sc);
+#endif
 
 static void a23_timer_timecounter_setup(struct a10_timer_softc *sc);
 static u_int a23_timer_get_timecount(struct timecounter *tc);
@@ -279,6 +283,7 @@ a10_timer_irq(void *arg)
  * Event timer function for A10 and A13
  */
 
+#if defined(__arm__)
 static void
 a10_timer_eventtimer_setup(struct a10_timer_softc *sc)
 {
@@ -363,6 +368,7 @@ a10_timer_timer_stop(struct eventtimer *et)
 
return (0);
 }
+#endif
 
 /*
  * Timecounter functions for A23 and above

Modified: head/sys/arm/broadcom/bcm2835/bcm2835_sdhost.c
==
--- head/sys/arm/broadcom/bcm2835/bcm2835_sdhost.c  Mon Jun 10 22:23:37 
2019(r348884)
+++ head/sys/arm/broadcom/bcm2835/bcm2835_sdhost.c  Mon Jun 10 23:25:40 
2019(r348885)
@@ -251,6 +251,7 @@ WR4(struct bcm_sdhost_softc *sc, bus_size_t off, uint3
bus_space_write_4(sc->sc_bst, sc->sc_bsh, off, val);
 }
 
+#ifdef notyet
 static inline uint16_t
 RD2(struct bcm_sdhost_softc *sc, bus_size_t off)
 {
@@ -260,6 +261,7 @@ RD2(struct bcm_sdhost_softc *sc, bus_size_t off)
 
return ((val >> (off & 3)*8) & 0x);
 }
+#endif
 
 static inline uint8_t
 RD1(struct bcm_sdhost_softc *sc, bus_size_t off)

Modified: head/sys/arm64/rockchip/if_dwc_rk.c
==
--- head/sys/arm64/rockchip/if_dwc_rk.c Mon Jun 10 22:23:37 2019
(r348884)
+++ head/sys/arm64/rockchip/if_dwc_rk.c Mon Jun 10 23:25:40 2019
(r348885)
@@ -65,6 +65,7 @@ __FBSDID("$FreeBSD$");
 #defineRK3328_GRF_MACPHY_CON3  0x0B0C
 #defineRK3328_GRF_MACPHY_STATUS0x0B10
 
+#ifdef notyet
 static void
 rk3328_set_delays(struct syscon *grf, phandle_t node)
 {
@@ -82,6 +83,7 @@ rk3328_set_delays(struct syscon *grf, phandle_t node)
 
SYSCON_WRITE_4(grf, RK3328_GRF_MAC_CON0, tx | rx | 0x);
 }
+#endif
 
 #defineRK3399_GRF_SOC_CON6 0xc218
 #define RK3399_GRF_SOC_CON6_TX_MASK0x7F
@@ -89,6 +91,7 @@ rk3328_set_delays(struct syscon *grf, phandle_t node)
 #define RK3399_GRF_SOC_CON6_RX_MASK0x7F
 #define RK3399_GRF_SOC_CON6_RX_SHIFT   8
 
+#ifdef notyet
 static void
 rk3399_set_delays(struct syscon *grf, phandle_t node)
 {
@@ -106,6 +109,7 @@ rk3399_set_delays(struct syscon *grf, phandle_t node)
 
SYSCON_WRITE_4(grf, RK3399_GRF_SOC_CON6, tx | rx | 0x);
 }
+#endif
 
 static int
 if_dwc_rk_probe(device_t dev)
___
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: r348847 - head/sys/sys

2019-06-10 Thread Warner Losh
On Mon, Jun 10, 2019 at 10:51 AM Conrad Meyer  wrote:

> On Mon, Jun 10, 2019 at 9:17 AM Bruce Evans  wrote:
> > Only headers and libraries should support -std=c89.   has
> > lots of support for compilers and POSIX versions going back to K C,
> > and only the K parts are completely broken.
>
> Is this due to specific policy, or just inertia?  (No one has bothered
> to remove the old bits?)  The older parts being totally broken
> suggests sheer inertia.
>

As far as I know, it's been policy because there are a number of ports that
compile with -std=c89, or used to be. I accidentally broke that a long time
ago and had to fix it to unbreak a few ports (but granted, this was a while
ago).

Warner
___
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: r348883 - head/sys/vm

2019-06-10 Thread Doug Moore
Author: dougm
Date: Mon Jun 10 22:06:40 2019
New Revision: 348883
URL: https://svnweb.freebsd.org/changeset/base/348883

Log:
  r348879 introduced a wrong-way comparison that broke mmap.
  This change rights that comparison.
  
  Reported by: pho
  Approved by: markj (mentor)
  MFC after: 3 days
  Differential Revision: https://reviews.freebsd.org/D20595

Modified:
  head/sys/vm/vm_mmap.c

Modified: head/sys/vm/vm_mmap.c
==
--- head/sys/vm/vm_mmap.c   Mon Jun 10 21:50:07 2019(r348882)
+++ head/sys/vm/vm_mmap.c   Mon Jun 10 22:06:40 2019(r348883)
@@ -259,7 +259,7 @@ kern_mmap(struct thread *td, uintptr_t addr0, size_t l
size = len + pageoff;   /* low end... */
size = round_page(size);/* hi end */
/* Check for rounding up to zero. */
-   if (len < size)
+   if (len > size)
return (ENOMEM);
 
/* Ensure alignment is at least a page and fits in a pointer. */
___
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: r348882 - head/sys/dev/sdhci

2019-06-10 Thread Luiz Otavio O Souza
Author: loos
Date: Mon Jun 10 21:50:07 2019
New Revision: 348882
URL: https://svnweb.freebsd.org/changeset/base/348882

Log:
  Add support for the GPIO SD Card VCC regulator/switch and the GPIO SD Card
  detection pins to the Marvell Xenon SDHCI controller.
  
  These features are enable by 'vqmmc-supply' and 'cd-gpios' properties in the
  DTS.
  
  This fixes the SD Card detection on espressobin.
  
  Sponsored by: Rubicon Communications, LLC (Netgate)

Modified:
  head/sys/dev/sdhci/sdhci_xenon.c

Modified: head/sys/dev/sdhci/sdhci_xenon.c
==
--- head/sys/dev/sdhci/sdhci_xenon.cMon Jun 10 21:34:07 2019
(r348881)
+++ head/sys/dev/sdhci/sdhci_xenon.cMon Jun 10 21:50:07 2019
(r348882)
@@ -47,6 +47,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 
+#include 
 #include 
 #include 
 #include 
@@ -56,6 +57,7 @@ __FBSDID("$FreeBSD$");
 #include 
 
 #include 
+#include 
 #include 
 
 #include "mmcbr_if.h"
@@ -84,10 +86,12 @@ struct sdhci_xenon_softc {
uint32_tmax_clk;/* Max possible freq */
struct resource *irq_res;   /* IRQ resource */
void*intrhand;  /* Interrupt handle */
+   struct sdhci_fdt_gpio *gpio;/* GPIO pins for CD detection. */
 
struct sdhci_slot *slot;/* SDHCI internal data */
struct resource *mem_res;   /* Memory resource */
 
+   regulator_t reg_vqmmc;  /* vqmmc-supply regulator */
uint8_t znr;/* PHY ZNR */
uint8_t zpr;/* PHY ZPR */
boolno_18v; /* No 1.8V support */
@@ -188,6 +192,14 @@ sdhci_xenon_get_ro(device_t bus, device_t dev)
return (sdhci_generic_get_ro(bus, dev) ^ sc->wp_inverted);
 }
 
+static bool
+sdhci_xenon_get_card_present(device_t dev, struct sdhci_slot *slot)
+{
+   struct sdhci_xenon_softc *sc = device_get_softc(dev);
+
+   return (sdhci_fdt_gpio_get_present(sc->gpio));
+}
+
 static int
 sdhci_xenon_phy_init(device_t brdev, struct mmc_ios *ios)
 {
@@ -337,6 +349,25 @@ sdhci_xenon_update_ios(device_t brdev, device_t reqdev
slot = device_get_ivars(reqdev);
ios = >host.ios;
 
+   switch (ios->power_mode) {
+   case power_on:
+   break;
+   case power_off:
+   if (bootverbose)
+   device_printf(sc->dev, "Powering down sd/mmc\n");
+
+   if (sc->reg_vqmmc)
+   regulator_disable(sc->reg_vqmmc);
+   break;
+   case power_up:
+   if (bootverbose)
+   device_printf(sc->dev, "Powering up sd/mmc\n");
+
+   if (sc->reg_vqmmc)
+   regulator_enable(sc->reg_vqmmc);
+   break;
+   };
+
/* Update the PHY settings. */
if (ios->clock != 0)
sdhci_xenon_phy_set(brdev, ios);
@@ -352,6 +383,42 @@ sdhci_xenon_update_ios(device_t brdev, device_t reqdev
 }
 
 static int
+sdhci_xenon_switch_vccq(device_t brdev, device_t reqdev)
+{
+   struct sdhci_xenon_softc *sc;
+   struct sdhci_slot *slot;
+   int uvolt, err;
+
+   sc = device_get_softc(brdev);
+
+if (sc->reg_vqmmc == NULL)
+   return EOPNOTSUPP;
+
+   slot = device_get_ivars(reqdev);
+   switch (slot->host.ios.vccq) {
+   case vccq_180:
+   uvolt = 180;
+   break;
+   case vccq_330:
+   uvolt = 330;
+   break;
+   default:
+   return EINVAL;
+   }
+
+   err = regulator_set_voltage(sc->reg_vqmmc, uvolt, uvolt);
+   if (err != 0) {
+   device_printf(sc->dev,
+   "Cannot set vqmmc to %d<->%d\n",
+   uvolt,
+   uvolt);
+   return (err);
+   }
+
+   return (0);
+}
+
+static int
 sdhci_xenon_probe(device_t dev)
 {
struct sdhci_xenon_softc *sc = device_get_softc(dev);
@@ -389,6 +456,11 @@ sdhci_xenon_probe(device_t dev)
if ((OF_getencprop(sc->node, "marvell,xenon-phy-zpr", ,
sizeof(cid))) > 0)
sc->zpr = cid & XENON_ZPR_MASK;
+   if (regulator_get_by_ofw_property(dev, 0, "vqmmc-supply",
+   >reg_vqmmc) == 0 && bootverbose) {
+   if (bootverbose)
+   device_printf(dev, "vqmmc-supply regulator found\n");
+   }
 
return (0);
 }
@@ -437,6 +509,12 @@ sdhci_xenon_attach(device_t dev)
slot->max_clk = sc->max_clk;
sc->slot = slot;
 
+   /*
+* Set up any gpio pin handling described in the FDT data. This cannot
+* fail; see comments in sdhci_fdt_gpio.h for details.
+*/
+   sc->gpio = sdhci_fdt_gpio_setup(dev, slot);
+
if (sdhci_init_slot(dev, sc->slot, 0))
goto fail;
 
@@ -497,6 +575,9 @@ sdhci_xenon_detach(device_t dev)
 {
struct sdhci_xenon_softc 

svn commit: r348881 - head/sys/vm

2019-06-10 Thread Doug Moore
Author: dougm
Date: Mon Jun 10 21:34:07 2019
New Revision: 348881
URL: https://svnweb.freebsd.org/changeset/base/348881

Log:
  The computations of vm_map_splay_split and vm_map_splay_merge touch both
  children of every entry on the search path as part of updating values of
  the max_free field. By comparing the max_free values of an entry and its
  child on the search path, the code can avoid accessing the child off the
  path in cases where the max_free value decreases along the path.
  
  Specifically, this patch changes splay_split so that the max_free field
  of every entry on the search path is replaced, temporarily, by the
  max_free field from its child not on the search path or, if the child
  in that direction is NULL, then a difference between start and end
  values of two pointers already available in the split code, without
  following any next or prev pointers. However, to find that max_free
  value does not require looking toward that other child if either the
  child on the search path has a lower max_free value, or the current max_free
  value is zero, because in either case we know that the value of max_free for
  the other child is the value we already have. So, the changes to
  vm_entry_splay_split make sure that we know all the off-search-path entries
  we will need to complete the splay, without looking at all of them. There is
  an exception at the bottom of the search path where we cannot rely on the
  max_free value in the direction of the NULL pointer that ends the search,
  because of the behavior of entry-clipping code.
  
  The corresponding change to vm_splay_entry_merge makes it simpler, since it's
  just reversing pointers and updating running maxima.
  
  In a test intended to exercise vigorously the vm_map implementation, the
  effect of this change was to reduce the data cache miss rate by 10-14% and
  the running time by 5-7%.
  
  Tested by: pho
  Reviewed by: alc
  Approved by: kib (mentor)
  MFC after: 1 month
  Differential Revision: https://reviews.freebsd.org/D19826

Modified:
  head/sys/vm/vm_map.c

Modified: head/sys/vm/vm_map.c
==
--- head/sys/vm/vm_map.cMon Jun 10 21:27:21 2019(r348880)
+++ head/sys/vm/vm_map.cMon Jun 10 21:34:07 2019(r348881)
@@ -962,55 +962,92 @@ vm_map_entry_set_behavior(vm_map_entry_t entry, u_char
 }
 
 /*
- * vm_map_entry_set_max_free:
+ * vm_map_entry_max_free_{left,right}:
  *
- * Set the max_free field in a vm_map_entry.
+ * Compute the size of the largest free gap between two entries,
+ * one the root of a tree and the other the ancestor of that root
+ * that is the least or greatest ancestor found on the search path.
  */
-static inline void
-vm_map_entry_set_max_free(vm_map_entry_t entry)
+static inline vm_size_t
+vm_map_entry_max_free_left(vm_map_entry_t root, vm_map_entry_t left_ancestor)
 {
-   vm_map_entry_t child;
-   vm_size_t max_left, max_right;
 
-   child = entry->left;
-   max_left = (child != NULL) ? child->max_free :
-   entry->start - entry->prev->end;
-   child = entry->right;
-   max_right = (child != NULL) ? child->max_free :
-   entry->next->start - entry->end;
-   entry->max_free = MAX(max_left, max_right);
+   return (root->left != NULL ?
+   root->left->max_free : root->start - left_ancestor->end);
 }
 
-#define SPLAY_LEFT_STEP(root, y, rlist, test) do { \
-   y = root->left; \
-   if (y != NULL && (test)) {  \
-   /* Rotate right and make y root. */ \
-   root->left = y->right;  \
-   y->right = root;\
-   vm_map_entry_set_max_free(root);\
-   root = y;   \
-   y = root->left; \
-   }   \
-   /* Put root on rlist. */\
-   root->left = rlist; \
-   rlist = root;   \
-   root = y;   \
+static inline vm_size_t
+vm_map_entry_max_free_right(vm_map_entry_t root, vm_map_entry_t right_ancestor)
+{
+
+   return (root->right != NULL ?
+   root->right->max_free : right_ancestor->start - root->end);
+}
+
+#define SPLAY_LEFT_STEP(root, y, rlist, test) do { \
+   vm_size_t max_free; \
+   \
+   /*  \
+* Infer root->right->max_free == root->max_free when   \
+* y->max_free < root->max_free || root->max_free == 0. \
+* Otherwise, look right to find it.   

svn commit: r348880 - in head/sys: arm/mv arm64/conf conf

2019-06-10 Thread Luiz Otavio O Souza
Author: loos
Date: Mon Jun 10 21:27:21 2019
New Revision: 348880
URL: https://svnweb.freebsd.org/changeset/base/348880

Log:
  Add the GPIO driver for the North/South bridge in Marvell Armada 37x0.
  
  The A3700 has a different GPIO controller and thus, do not use the old (and
  shared) code for Marvell.
  
  The pinctrl driver, also part of the controller, is not supported yet (but
  the implementation should be straightforward).
  
  Sponsored by: Rubicon Communications, LLC (Netgate)

Added:
  head/sys/arm/mv/a37x0_gpio.c   (contents, props changed)
Modified:
  head/sys/arm64/conf/GENERIC
  head/sys/conf/files.arm64

Added: head/sys/arm/mv/a37x0_gpio.c
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/sys/arm/mv/a37x0_gpio.cMon Jun 10 21:27:21 2019
(r348880)
@@ -0,0 +1,352 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ *
+ * Copyright (c) 2018-2019, Rubicon Communications, LLC (Netgate)
+ * 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
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#include 
+__FBSDID("$FreeBSD$");
+
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+#include "gpio_if.h"
+
+static struct resource_spec a37x0_gpio_res_spec[] = {
+   { SYS_RES_MEMORY, 0, RF_ACTIVE },   /* Pinctl / GPIO */
+   { SYS_RES_MEMORY, 1, RF_ACTIVE },   /* Interrupts control */
+   { -1, 0, 0 }
+};
+
+struct a37x0_gpio_softc {
+   bus_space_tag_t sc_bst;
+   bus_space_handle_t  sc_bsh;
+   device_tsc_busdev;
+   int sc_type;
+   uint32_tsc_max_pins;
+   uint32_tsc_npins;
+   struct resource *sc_mem_res[nitems(a37x0_gpio_res_spec) - 1];
+};
+
+/* Memory regions. */
+#defineA37X0_GPIO  0
+#defineA37X0_INTR  1
+
+/* North Bridge / South Bridge. */
+#defineA37X0_NB_GPIO   1
+#defineA37X0_SB_GPIO   2
+
+#defineA37X0_GPIO_WRITE(_sc, _off, _val)   \
+bus_space_write_4((_sc)->sc_bst, (_sc)->sc_bsh, (_off), (_val))
+#defineA37X0_GPIO_READ(_sc, _off)  \
+bus_space_read_4((_sc)->sc_bst, (_sc)->sc_bsh, (_off))
+
+#defineA37X0_GPIO_BIT(_p)  (1U << ((_p) % 32))
+#defineA37X0_GPIO_OUT_EN(_p)   (0x0 + ((_p) / 32) * 4)
+#defineA37X0_GPIO_LATCH(_p)(0x8 + ((_p) / 32) * 4)
+#defineA37X0_GPIO_INPUT(_p)(0x10 + ((_p) / 32) * 4)
+#defineA37X0_GPIO_OUTPUT(_p)   (0x18 + ((_p) / 32) * 4)
+#defineA37X0_GPIO_SEL  0x30
+
+
+static struct ofw_compat_data compat_data[] = {
+   { "marvell,armada3710-nb-pinctrl",  A37X0_NB_GPIO },
+   { "marvell,armada3710-sb-pinctrl",  A37X0_SB_GPIO },
+   { NULL, 0 }
+};
+
+static phandle_t
+a37x0_gpio_get_node(device_t bus, device_t dev)
+{
+
+   return (ofw_bus_get_node(bus));
+}
+
+static device_t
+a37x0_gpio_get_bus(device_t dev)
+{
+   struct a37x0_gpio_softc *sc;
+
+   sc = device_get_softc(dev);
+
+   return (sc->sc_busdev);
+}
+
+static int
+a37x0_gpio_pin_max(device_t dev, int *maxpin)
+{
+   struct a37x0_gpio_softc *sc;
+
+   sc = device_get_softc(dev);
+   *maxpin = sc->sc_npins - 1;
+
+   return (0);
+}
+
+static int
+a37x0_gpio_pin_getname(device_t dev, uint32_t pin, char *name)
+{
+   struct a37x0_gpio_softc *sc;
+
+   sc = device_get_softc(dev);
+   if (pin >= sc->sc_npins)
+   return (EINVAL);
+   

svn commit: r348879 - in head/sys: sys vm

2019-06-10 Thread Doug Moore
Author: dougm
Date: Mon Jun 10 21:26:14 2019
New Revision: 348879
URL: https://svnweb.freebsd.org/changeset/base/348879

Log:
  Change the check for 'size' wrapping around to zero in kern_mmap to account
  for both the lower and upper bound modifications. Change the error returned
  to ENOMEM. Rename the parameter size to len and make size a local variable
  that stores the value of len after it has been modified.
  
  This addresses concerns expressed by Bruce Evans after r348843.
  
  Reported by: b...@optusnet.com.au
  Reviewed by: kib, markj (mentors)
  MFC after: 3 days
  Relnotes: yes
  Differential Revision: https://reviews.freebsd.org/D20592

Modified:
  head/sys/sys/syscallsubr.h
  head/sys/vm/vm_mmap.c

Modified: head/sys/sys/syscallsubr.h
==
--- head/sys/sys/syscallsubr.h  Mon Jun 10 21:24:38 2019(r348878)
+++ head/sys/sys/syscallsubr.h  Mon Jun 10 21:26:14 2019(r348879)
@@ -173,7 +173,7 @@ int kern_mknodat(struct thread *td, int fd, const char
enum uio_seg pathseg, int mode, dev_t dev);
 intkern_mlock(struct proc *proc, struct ucred *cred, uintptr_t addr,
size_t len);
-intkern_mmap(struct thread *td, uintptr_t addr, size_t size, int prot,
+intkern_mmap(struct thread *td, uintptr_t addr, size_t len, int prot,
int flags, int fd, off_t pos);
 intkern_mprotect(struct thread *td, uintptr_t addr, size_t size, int prot);
 intkern_msgctl(struct thread *, int, int, struct msqid_ds *);

Modified: head/sys/vm/vm_mmap.c
==
--- head/sys/vm/vm_mmap.c   Mon Jun 10 21:24:38 2019(r348878)
+++ head/sys/vm/vm_mmap.c   Mon Jun 10 21:26:14 2019(r348879)
@@ -179,13 +179,13 @@ sys_mmap(struct thread *td, struct mmap_args *uap)
 }
 
 int
-kern_mmap(struct thread *td, uintptr_t addr0, size_t size, int prot, int flags,
+kern_mmap(struct thread *td, uintptr_t addr0, size_t len, int prot, int flags,
 int fd, off_t pos)
 {
struct vmspace *vms;
struct file *fp;
vm_offset_t addr;
-   vm_size_t pageoff;
+   vm_size_t pageoff, size;
vm_prot_t cap_maxprot;
int align, error;
cap_rights_t rights;
@@ -210,7 +210,7 @@ kern_mmap(struct thread *td, uintptr_t addr0, size_t s
 * pos.
 */
if (!SV_CURPROC_FLAG(SV_AOUT)) {
-   if ((size == 0 && curproc->p_osrel >= P_OSREL_MAP_ANON) ||
+   if ((len == 0 && curproc->p_osrel >= P_OSREL_MAP_ANON) ||
((flags & MAP_ANON) != 0 && (fd != -1 || pos != 0)))
return (EINVAL);
} else {
@@ -255,12 +255,12 @@ kern_mmap(struct thread *td, uintptr_t addr0, size_t s
pageoff = (pos & PAGE_MASK);
pos -= pageoff;
 
-   /* Adjust size for rounding (on both ends). */
-   size += pageoff;/* low end... */
-   /* Check for rounding up to zero. */
-   if (round_page(size) < size)
-   return (EINVAL);
+   /* Compute size from len by rounding (on both ends). */
+   size = len + pageoff;   /* low end... */
size = round_page(size);/* hi end */
+   /* Check for rounding up to zero. */
+   if (len < size)
+   return (ENOMEM);
 
/* Ensure alignment is at least a page and fits in a pointer. */
align = flags & MAP_ALIGNMENT_MASK;
@@ -317,7 +317,7 @@ kern_mmap(struct thread *td, uintptr_t addr0, size_t s
addr = round_page((vm_offset_t)vms->vm_daddr +
lim_max(td, RLIMIT_DATA));
}
-   if (size == 0) {
+   if (len == 0) {
/*
 * Return success without mapping anything for old
 * binaries that request a page-aligned mapping of
___
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: r348878 - head/sys/arm/broadcom/bcm2835

2019-06-10 Thread Bjoern A. Zeeb
Author: bz
Date: Mon Jun 10 21:24:38 2019
New Revision: 348878
URL: https://svnweb.freebsd.org/changeset/base/348878

Log:
  Add a bus_add_child device method to bcm2835_sdhci.
  
  This allows SDIO (through CAM) to attach to an upstream, e.g.,
..
sdhci_bcm0 pnpinfo name=mmc@7e30 compat=brcm,bcm2835-mmc
  sdiob0
..
  
  Without this, upon trying to load sdio, we would panic with
  "bus_add_child is not implemented".
  
  MFC after:2 weeks
  Sponsored by: The FreeBSD Foundation

Modified:
  head/sys/arm/broadcom/bcm2835/bcm2835_sdhci.c

Modified: head/sys/arm/broadcom/bcm2835/bcm2835_sdhci.c
==
--- head/sys/arm/broadcom/bcm2835/bcm2835_sdhci.c   Mon Jun 10 19:38:35 
2019(r348877)
+++ head/sys/arm/broadcom/bcm2835/bcm2835_sdhci.c   Mon Jun 10 21:24:38 
2019(r348878)
@@ -708,6 +708,7 @@ static device_method_t bcm_sdhci_methods[] = {
/* Bus interface */
DEVMETHOD(bus_read_ivar,sdhci_generic_read_ivar),
DEVMETHOD(bus_write_ivar,   sdhci_generic_write_ivar),
+   DEVMETHOD(bus_add_child,bus_generic_add_child),
 
/* MMC bridge interface */
DEVMETHOD(mmcbr_update_ios, sdhci_generic_update_ios),
___
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: r348873 - head/sys/dev/atkbdc

2019-06-10 Thread Rodney W. Grimes
> Author: zeising (doc,ports committer)
> Date: Mon Jun 10 18:19:49 2019
> New Revision: 348873
> URL: https://svnweb.freebsd.org/changeset/base/348873
> 
> Log:
>   psm(4): Enable touchpads and trackpads by default
>   
>   Enable synaptics and elantech touchpads, as well as IBM/Lenovo TrackPoints
>   by default, instead of having users find and toggle a loader tunable.
>   This makes things like two finger scroll and other modern features work out
>   of the box with X.  By enabling these settings by default, we get a better
>   desktop experience in X, since xserver and evdev can make use of the more
>   advanced synaptics and elantech features.
>   
>   Reviewed by:imp, wulf, 0mp
>   Approved by:imp
>   Sponsored by:   B3 Init (zeising)
>   Differential Revision:  https://reviews.freebsd.org/D20507

This should of probably had a 
Relnotes:   Yes
as it changes default system behavior.

> Modified:
>   head/sys/dev/atkbdc/psm.c
> 
> Modified: head/sys/dev/atkbdc/psm.c
> ==
> --- head/sys/dev/atkbdc/psm.c Mon Jun 10 17:44:50 2019(r348872)
> +++ head/sys/dev/atkbdc/psm.c Mon Jun 10 18:19:49 2019(r348873)
> @@ -513,9 +513,9 @@ static devclass_t psm_devclass;
>  /* Tunables */
>  static int tap_enabled = -1;
>  static int verbose = PSM_DEBUG;
> -static int synaptics_support = 0;
> -static int trackpoint_support = 0;
> -static int elantech_support = 0;
> +static int synaptics_support = 1;
> +static int trackpoint_support = 1;
> +static int elantech_support = 1;
>  
>  /* for backward compatibility */
>  #define  OLD_MOUSE_GETHWINFO _IOR('M', 1, old_mousehw_t)
> 
> 

-- 
Rod Grimes rgri...@freebsd.org
___
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: r348877 - head/share/mk

2019-06-10 Thread Bryan Drewery
Author: bdrewery
Date: Mon Jun 10 19:38:35 2019
New Revision: 348877
URL: https://svnweb.freebsd.org/changeset/base/348877

Log:
  DPSRCS need to be built before recursing.
  
  MFC after:2 weeks
  Sponsored by: DellEMC

Modified:
  head/share/mk/bsd.progs.mk

Modified: head/share/mk/bsd.progs.mk
==
--- head/share/mk/bsd.progs.mk  Mon Jun 10 19:26:57 2019(r348876)
+++ head/share/mk/bsd.progs.mk  Mon Jun 10 19:38:35 2019(r348877)
@@ -95,7 +95,7 @@ $v =
 # Find common sources among the PROGS to depend on them before building
 # anything.  This allows parallelization without them each fighting over
 # the same objects.
-_PROGS_COMMON_SRCS=
+_PROGS_COMMON_SRCS= ${DPSRCS}
 _PROGS_ALL_SRCS=
 .for p in ${PROGS}
 .for s in ${SRCS.${p}}
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r348876 - head/sys/opencrypto

2019-06-10 Thread John Baldwin
On 6/10/19 12:26 PM, John Baldwin wrote:
> Author: jhb
> Date: Mon Jun 10 19:26:57 2019
> New Revision: 348876
> URL: https://svnweb.freebsd.org/changeset/base/348876
> 
> Log:
>   Add warnings to /dev/crypto for deprecated algorithms.
>   
>   These algorithms are deprecated algorithms that will have no in-kernel
>   consumers in FreeBSD 13.  Specifically, deprecate the following
>   algorithms:
>   - ARC4
>   - Blowfish
>   - CAST128
>   - DES
>   - 3DES
>   - MD5-HMAC
>   - Skipjack
>   
>   MFC after:  1 month
>   Relnotes:   yes
>   Sponsored by:   Chelsio Communications
>   Differential Revision:  https://reviews.freebsd.org/D20554

Also, I missed 'Reviewed by: cem' for this one. :-/

-- 
John Baldwin
___
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: r348876 - head/sys/opencrypto

2019-06-10 Thread John Baldwin
On 6/10/19 12:26 PM, John Baldwin wrote:
> Author: jhb
> Date: Mon Jun 10 19:26:57 2019
> New Revision: 348876
> URL: https://svnweb.freebsd.org/changeset/base/348876
> 
> Log:
>   Add warnings to /dev/crypto for deprecated algorithms.
>   
>   These algorithms are deprecated algorithms that will have no in-kernel
>   consumers in FreeBSD 13.  Specifically, deprecate the following
>   algorithms:
>   - ARC4
>   - Blowfish
>   - CAST128
>   - DES
>   - 3DES
>   - MD5-HMAC
>   - Skipjack
>   
>   MFC after:  1 month
>   Relnotes:   yes
>   Sponsored by:   Chelsio Communications
>   Differential Revision:  https://reviews.freebsd.org/D20554

cryptocheck doesn't test any of these.  The cryptotest.py tests do test 3DES
so cryptotest.py will emit a warning due to that.  The /dev/crypto engine for
OpenSSL does support several of these, but calling into the kernel just to do
software crypto instead of doing the software crypto userland is rather
pointless (just adds overhead).

-- 
John Baldwin
___
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: r348875 - head/sys/kgssapi/krb5

2019-06-10 Thread John Baldwin
On 6/10/19 12:22 PM, John Baldwin wrote:
> Author: jhb
> Date: Mon Jun 10 19:22:36 2019
> New Revision: 348875
> URL: https://svnweb.freebsd.org/changeset/base/348875
> 
> Log:
>   Add warnings for Kerberos GSS algorithms deprecated in RFCs 6649 and 8429.
>   
>   All of these algorithms are explicitly marked SHOULD NOT in one of these
>   RFCs.
>   
>   Specifically, RFC 6649 deprecates all algorithms using DES as well as
>   the "export-friendly" variant of RC4.  RFC 8429 deprecates Triple DES
>   and the remaining RC4 algorithms.
>   
>   Reviewed by:cem
>   MFC after:  1 month
>   Sponsored by:   Chelsio Communications
>   Differential Revision:  https://reviews.freebsd.org/D20343

Bah, missed Relnotes: yes

The long MFC timer is because I haven't run-tested this yet as when I sat down 
to
look at what it would take to setup GSSAPI with NFS and Kerberos it seemed a bit
of a daunting task.  As such, I don't think it makes sense to rush into 11.3.

-- 
John Baldwin
___
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: r348876 - head/sys/opencrypto

2019-06-10 Thread John Baldwin
Author: jhb
Date: Mon Jun 10 19:26:57 2019
New Revision: 348876
URL: https://svnweb.freebsd.org/changeset/base/348876

Log:
  Add warnings to /dev/crypto for deprecated algorithms.
  
  These algorithms are deprecated algorithms that will have no in-kernel
  consumers in FreeBSD 13.  Specifically, deprecate the following
  algorithms:
  - ARC4
  - Blowfish
  - CAST128
  - DES
  - 3DES
  - MD5-HMAC
  - Skipjack
  
  MFC after:1 month
  Relnotes: yes
  Sponsored by: Chelsio Communications
  Differential Revision:https://reviews.freebsd.org/D20554

Modified:
  head/sys/opencrypto/cryptodev.c

Modified: head/sys/opencrypto/cryptodev.c
==
--- head/sys/opencrypto/cryptodev.c Mon Jun 10 19:22:36 2019
(r348875)
+++ head/sys/opencrypto/cryptodev.c Mon Jun 10 19:26:57 2019
(r348876)
@@ -386,6 +386,9 @@ cryptof_ioctl(
struct crypt_op copc;
struct crypt_kop kopc;
 #endif
+   static struct timeval arc4warn, blfwarn, castwarn, deswarn, md5warn;
+   static struct timeval skipwarn, tdeswarn;
+   static struct timeval warninterval = { .tv_sec = 60, .tv_usec = 0 };
 
switch (cmd) {
case CIOCGSESSION:
@@ -406,18 +409,28 @@ cryptof_ioctl(
case 0:
break;
case CRYPTO_DES_CBC:
+   if (ratecheck(, ))
+   gone_in(13, "DES cipher via /dev/crypto");
txform = _xform_des;
break;
case CRYPTO_3DES_CBC:
+   if (ratecheck(, ))
+   gone_in(13, "3DES cipher via /dev/crypto");
txform = _xform_3des;
break;
case CRYPTO_BLF_CBC:
+   if (ratecheck(, ))
+   gone_in(13, "Blowfish cipher via /dev/crypto");
txform = _xform_blf;
break;
case CRYPTO_CAST_CBC:
+   if (ratecheck(, ))
+   gone_in(13, "CAST128 cipher via /dev/crypto");
txform = _xform_cast5;
break;
case CRYPTO_SKIPJACK_CBC:
+   if (ratecheck(, ))
+   gone_in(13, "Skipjack cipher via /dev/crypto");
txform = _xform_skipjack;
break;
case CRYPTO_AES_CBC:
@@ -430,6 +443,8 @@ cryptof_ioctl(
txform = _xform_null;
break;
case CRYPTO_ARC4:
+   if (ratecheck(, ))
+   gone_in(13, "ARC4 cipher via /dev/crypto");
txform = _xform_arc4;
break;
case CRYPTO_CAMELLIA_CBC:
@@ -458,6 +473,9 @@ cryptof_ioctl(
case 0:
break;
case CRYPTO_MD5_HMAC:
+   if (ratecheck(, ))
+   gone_in(13,
+   "MD5-HMAC authenticator via /dev/crypto");
thash = _hash_hmac_md5;
break;
case CRYPTO_POLY1305:
___
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: r348875 - head/sys/kgssapi/krb5

2019-06-10 Thread John Baldwin
Author: jhb
Date: Mon Jun 10 19:22:36 2019
New Revision: 348875
URL: https://svnweb.freebsd.org/changeset/base/348875

Log:
  Add warnings for Kerberos GSS algorithms deprecated in RFCs 6649 and 8429.
  
  All of these algorithms are explicitly marked SHOULD NOT in one of these
  RFCs.
  
  Specifically, RFC 6649 deprecates all algorithms using DES as well as
  the "export-friendly" variant of RC4.  RFC 8429 deprecates Triple DES
  and the remaining RC4 algorithms.
  
  Reviewed by:  cem
  MFC after:1 month
  Sponsored by: Chelsio Communications
  Differential Revision:https://reviews.freebsd.org/D20343

Modified:
  head/sys/kgssapi/krb5/kcrypto_arcfour.c
  head/sys/kgssapi/krb5/kcrypto_des.c
  head/sys/kgssapi/krb5/kcrypto_des3.c

Modified: head/sys/kgssapi/krb5/kcrypto_arcfour.c
==
--- head/sys/kgssapi/krb5/kcrypto_arcfour.c Mon Jun 10 19:01:54 2019
(r348874)
+++ head/sys/kgssapi/krb5/kcrypto_arcfour.c Mon Jun 10 19:22:36 2019
(r348875)
@@ -46,8 +46,12 @@ __FBSDID("$FreeBSD$");
 static void
 arcfour_init(struct krb5_key_state *ks)
 {
+   static struct timeval lastwarn;
+   static struct timeval warninterval = { .tv_sec = 3600, .tv_usec = 0 };
 
ks->ks_priv = NULL;
+   if (ratecheck(, ))
+   gone_in(13, "RC4 cipher for Kerberos GSS");
 }
 
 static void

Modified: head/sys/kgssapi/krb5/kcrypto_des.c
==
--- head/sys/kgssapi/krb5/kcrypto_des.c Mon Jun 10 19:01:54 2019
(r348874)
+++ head/sys/kgssapi/krb5/kcrypto_des.c Mon Jun 10 19:22:36 2019
(r348875)
@@ -53,11 +53,15 @@ struct des1_state {
 static void
 des1_init(struct krb5_key_state *ks)
 {
+   static struct timeval lastwarn;
+   static struct timeval warninterval = { .tv_sec = 3600, .tv_usec = 0 };
struct des1_state *ds;
 
ds = malloc(sizeof(struct des1_state), M_GSSAPI, M_WAITOK|M_ZERO);
mtx_init(>ds_lock, "gss des lock", NULL, MTX_DEF);
ks->ks_priv = ds;
+   if (ratecheck(, ))
+   gone_in(13, "DES cipher for Kerberos GSS");
 }
 
 static void

Modified: head/sys/kgssapi/krb5/kcrypto_des3.c
==
--- head/sys/kgssapi/krb5/kcrypto_des3.cMon Jun 10 19:01:54 2019
(r348874)
+++ head/sys/kgssapi/krb5/kcrypto_des3.cMon Jun 10 19:22:36 2019
(r348875)
@@ -54,11 +54,15 @@ struct des3_state {
 static void
 des3_init(struct krb5_key_state *ks)
 {
+   static struct timeval lastwarn;
+   static struct timeval warninterval = { .tv_sec = 3600, .tv_usec = 0 };
struct des3_state *ds;
 
ds = malloc(sizeof(struct des3_state), M_GSSAPI, M_WAITOK|M_ZERO);
mtx_init(>ds_lock, "gss des3 lock", NULL, MTX_DEF);
ks->ks_priv = ds;
+   if (ratecheck(, ))
+   gone_in(13, "DES3 cipher for Kerberos GSS");
 }
 
 static void
___
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: r348874 - head/sys/vm

2019-06-10 Thread John Baldwin
Author: jhb
Date: Mon Jun 10 19:01:54 2019
New Revision: 348874
URL: https://svnweb.freebsd.org/changeset/base/348874

Log:
  Remove an overly-aggressive assertion.
  
  While it is true that the new vmspace passed to vmspace_switch_aio
  will always have a valid reference due to the AIO job or the extra
  reference on the original vmspace in the worker thread, it is not true
  that the old vmspace being switched away from will have more than one
  reference.
  
  Specifically, when a process with queued AIO jobs exits, the exit hook
  in aio_proc_rundown will only ensure that all of the AIO jobs have
  completed or been cancelled.  However, the last AIO job might have
  completed and woken up the exiting process before the worker thread
  servicing that job has switched back to its original vmspace.  In that
  case, the process might finish exiting dropping its reference to the
  vmspace before the worker thread resulting in the worker thread
  dropping the last reference.
  
  Reported by:  np
  Reviewed by:  alc, markj, np, imp
  MFC after:2 weeks
  Sponsored by: Chelsio Communications
  Differential Revision:https://reviews.freebsd.org/D20542

Modified:
  head/sys/vm/vm_map.c

Modified: head/sys/vm/vm_map.c
==
--- head/sys/vm/vm_map.cMon Jun 10 18:19:49 2019(r348873)
+++ head/sys/vm/vm_map.cMon Jun 10 19:01:54 2019(r348874)
@@ -454,18 +454,17 @@ vmspace_acquire_ref(struct proc *p)
 /*
  * Switch between vmspaces in an AIO kernel process.
  *
- * The AIO kernel processes switch to and from a user process's
- * vmspace while performing an I/O operation on behalf of a user
- * process.  The new vmspace is either the vmspace of a user process
- * obtained from an active AIO request or the initial vmspace of the
- * AIO kernel process (when it is idling).  Because user processes
- * will block to drain any active AIO requests before proceeding in
- * exit() or execve(), the vmspace reference count for these vmspaces
- * can never be 0.  This allows for a much simpler implementation than
- * the loop in vmspace_acquire_ref() above.  Similarly, AIO kernel
- * processes hold an extra reference on their initial vmspace for the
- * life of the process so that this guarantee is true for any vmspace
- * passed as 'newvm'.
+ * The new vmspace is either the vmspace of a user process obtained
+ * from an active AIO request or the initial vmspace of the AIO kernel
+ * process (when it is idling).  Because user processes will block to
+ * drain any active AIO requests before proceeding in exit() or
+ * execve(), the reference count for vmspaces from AIO requests can
+ * never be 0.  Similarly, AIO kernel processes hold an extra
+ * reference on their initial vmspace for the life of the process.  As
+ * a result, the 'newvm' vmspace always has a non-zero reference
+ * count.  This permits an additional reference on 'newvm' to be
+ * acquired via a simple atomic increment rather than the loop in
+ * vmspace_acquire_ref() above.
  */
 void
 vmspace_switch_aio(struct vmspace *newvm)
@@ -490,9 +489,6 @@ vmspace_switch_aio(struct vmspace *newvm)
/* Activate the new mapping. */
pmap_activate(curthread);
 
-   /* Remove the daemon's reference to the old address space. */
-   KASSERT(oldvm->vm_refcnt > 1,
-   ("vmspace_switch_aio: oldvm dropping last reference"));
vmspace_free(oldvm);
 }
 
___
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: r348873 - head/sys/dev/atkbdc

2019-06-10 Thread Niclas Zeising
Author: zeising (doc,ports committer)
Date: Mon Jun 10 18:19:49 2019
New Revision: 348873
URL: https://svnweb.freebsd.org/changeset/base/348873

Log:
  psm(4): Enable touchpads and trackpads by default
  
  Enable synaptics and elantech touchpads, as well as IBM/Lenovo TrackPoints
  by default, instead of having users find and toggle a loader tunable.
  This makes things like two finger scroll and other modern features work out
  of the box with X.  By enabling these settings by default, we get a better
  desktop experience in X, since xserver and evdev can make use of the more
  advanced synaptics and elantech features.
  
  Reviewed by:  imp, wulf, 0mp
  Approved by:  imp
  Sponsored by: B3 Init (zeising)
  Differential Revision:https://reviews.freebsd.org/D20507

Modified:
  head/sys/dev/atkbdc/psm.c

Modified: head/sys/dev/atkbdc/psm.c
==
--- head/sys/dev/atkbdc/psm.c   Mon Jun 10 17:44:50 2019(r348872)
+++ head/sys/dev/atkbdc/psm.c   Mon Jun 10 18:19:49 2019(r348873)
@@ -513,9 +513,9 @@ static devclass_t psm_devclass;
 /* Tunables */
 static int tap_enabled = -1;
 static int verbose = PSM_DEBUG;
-static int synaptics_support = 0;
-static int trackpoint_support = 0;
-static int elantech_support = 0;
+static int synaptics_support = 1;
+static int trackpoint_support = 1;
+static int elantech_support = 1;
 
 /* for backward compatibility */
 #defineOLD_MOUSE_GETHWINFO _IOR('M', 1, old_mousehw_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: r348872 - stable/12/sys/dev/efidev

2019-06-10 Thread Konstantin Belousov
Author: kib
Date: Mon Jun 10 17:44:50 2019
New Revision: 348872
URL: https://svnweb.freebsd.org/changeset/base/348872

Log:
  MFC r348541:
  efirt efi_enter(): Release acquired locks and restore FPU ownership if
  efi_arch_enter() returned an error.

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

Modified: stable/12/sys/dev/efidev/efirt.c
==
--- stable/12/sys/dev/efidev/efirt.cMon Jun 10 17:43:33 2019
(r348871)
+++ stable/12/sys/dev/efidev/efirt.cMon Jun 10 17:44:50 2019
(r348872)
@@ -247,6 +247,7 @@ efi_enter(void)
 {
struct thread *td;
pmap_t curpmap;
+   int error;
 
if (efi_runtime == NULL)
return (ENXIO);
@@ -255,7 +256,13 @@ efi_enter(void)
PMAP_LOCK(curpmap);
mtx_lock(_lock);
fpu_kern_enter(td, NULL, FPU_KERN_NOCTX);
-   return (efi_arch_enter());
+   error = efi_arch_enter();
+   if (error != 0) {
+   fpu_kern_leave(td, NULL);
+   mtx_unlock(_lock);
+   PMAP_UNLOCK(curpmap);
+   }
+   return (error);
 }
 
 static void
___
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: r348871 - in stable/12/sys/amd64: amd64 include

2019-06-10 Thread Konstantin Belousov
Author: kib
Date: Mon Jun 10 17:43:33 2019
New Revision: 348871
URL: https://svnweb.freebsd.org/changeset/base/348871

Log:
  MFC r348539:
  amd64 ef_rt_arch_call: Preserve %rflags around call into EFI RT service.

Modified:
  stable/12/sys/amd64/amd64/efirt_support.S
  stable/12/sys/amd64/amd64/genassym.c
  stable/12/sys/amd64/include/efi.h
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/amd64/amd64/efirt_support.S
==
--- stable/12/sys/amd64/amd64/efirt_support.S   Mon Jun 10 17:40:31 2019
(r348870)
+++ stable/12/sys/amd64/amd64/efirt_support.S   Mon Jun 10 17:43:33 2019
(r348871)
@@ -47,6 +47,9 @@ ENTRY(efi_rt_arch_call)
movq%r13, EC_R13(%rdi)
movq%r14, EC_R14(%rdi)
movq%r15, EC_R15(%rdi)
+   pushfq
+   popq%rax
+   movq%rax, EC_RFLAGS(%rdi)
movqPCPU(CURTHREAD), %rax
movq%rdi, TD_MD+MD_EFIRT_TMP(%rax)
movqPCPU(CURPCB), %rsi
@@ -98,6 +101,8 @@ efi_rt_arch_call_tail:
movqEC_RBP(%rdi), %rbp
movqEC_RSP(%rdi), %rsp
movqEC_RBX(%rdi), %rbx
+   pushq   EC_RFLAGS(%rdi)
+   popfq
 
popq%rbp
ret

Modified: stable/12/sys/amd64/amd64/genassym.c
==
--- stable/12/sys/amd64/amd64/genassym.cMon Jun 10 17:40:31 2019
(r348870)
+++ stable/12/sys/amd64/amd64/genassym.cMon Jun 10 17:43:33 2019
(r348871)
@@ -272,3 +272,4 @@ ASSYM(EC_R12, offsetof(struct efirt_callinfo, ec_r12))
 ASSYM(EC_R13, offsetof(struct efirt_callinfo, ec_r13));
 ASSYM(EC_R14, offsetof(struct efirt_callinfo, ec_r14));
 ASSYM(EC_R15, offsetof(struct efirt_callinfo, ec_r15));
+ASSYM(EC_RFLAGS, offsetof(struct efirt_callinfo, ec_rflags));

Modified: stable/12/sys/amd64/include/efi.h
==
--- stable/12/sys/amd64/include/efi.h   Mon Jun 10 17:40:31 2019
(r348870)
+++ stable/12/sys/amd64/include/efi.h   Mon Jun 10 17:43:33 2019
(r348871)
@@ -72,6 +72,7 @@ struct efirt_callinfo {
register_t  ec_r13;
register_t  ec_r14;
register_t  ec_r15;
+   register_t  ec_rflags;
 };
 
 #endif /* __AMD64_INCLUDE_EFI_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: r348870 - stable/12/sys/vm

2019-06-10 Thread Konstantin Belousov
Author: kib
Date: Mon Jun 10 17:40:31 2019
New Revision: 348870
URL: https://svnweb.freebsd.org/changeset/base/348870

Log:
  MFC r348533:
  Remove dead store.

Modified:
  stable/12/sys/vm/swap_pager.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/vm/swap_pager.c
==
--- stable/12/sys/vm/swap_pager.c   Mon Jun 10 17:38:47 2019
(r348869)
+++ stable/12/sys/vm/swap_pager.c   Mon Jun 10 17:40:31 2019
(r348870)
@@ -2232,7 +2232,6 @@ swaponsomething(struct vnode *vp, void *id, u_long nbl
sp->sw_vp = vp;
sp->sw_id = id;
sp->sw_dev = dev;
-   sp->sw_flags = 0;
sp->sw_nblks = nblks;
sp->sw_used = 0;
sp->sw_strategy = strategy;
___
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: r348869 - stable/12/sys/kern

2019-06-10 Thread Konstantin Belousov
Author: kib
Date: Mon Jun 10 17:38:47 2019
New Revision: 348869
URL: https://svnweb.freebsd.org/changeset/base/348869

Log:
  MFC r348536:
  Remove dead check.

Modified:
  stable/12/sys/kern/link_elf_obj.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/kern/link_elf_obj.c
==
--- stable/12/sys/kern/link_elf_obj.c   Mon Jun 10 17:36:14 2019
(r348868)
+++ stable/12/sys/kern/link_elf_obj.c   Mon Jun 10 17:38:47 2019
(r348869)
@@ -714,11 +714,6 @@ link_elf_load_file(linker_class_t cls, const char *fil
goto out;
}
 
-   if (symstrindex == -1) {
-   link_elf_error(filename, "lost symbol string index");
-   error = ENOEXEC;
-   goto out;
-   }
/* Allocate space for and load the symbol strings */
ef->ddbstrcnt = shdr[symstrindex].sh_size;
ef->ddbstrtab = malloc(shdr[symstrindex].sh_size, M_LINKER, M_WAITOK);
___
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: r348868 - stable/12/sys/dev/hwpmc

2019-06-10 Thread Konstantin Belousov
Author: kib
Date: Mon Jun 10 17:36:14 2019
New Revision: 348868
URL: https://svnweb.freebsd.org/changeset/base/348868

Log:
  MFC r348544:
  hwpmc_intel: List all Silvermont ids.

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

Modified: stable/12/sys/dev/hwpmc/hwpmc_intel.c
==
--- stable/12/sys/dev/hwpmc/hwpmc_intel.c   Mon Jun 10 16:36:31 2019
(r348867)
+++ stable/12/sys/dev/hwpmc/hwpmc_intel.c   Mon Jun 10 17:36:14 2019
(r348868)
@@ -195,7 +195,11 @@ pmc_intel_initialize(void)
cputype = PMC_CPU_INTEL_HASWELL;
nclasses = 5;
break;
+   case 0x37:
+   case 0x4A:
case 0x4D:  /* Per Intel document 330061-001 01/2014. */
+   case 0x5A:
+   case 0x5D:
cputype = PMC_CPU_INTEL_ATOM_SILVERMONT;
nclasses = 3;
break;
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r348847 - head/sys/sys

2019-06-10 Thread Konstantin Belousov
On Mon, Jun 10, 2019 at 09:28:24AM -0700, Conrad Meyer wrote:
> On Mon, Jun 10, 2019 at 9:17 AM Bruce Evans  wrote:
> > Only headers and libraries should support -std=c89.   has
> > lots of support for compilers and POSIX versions going back to K C,
> > and only the K parts are completely broken.
> 
> Is this due to specific policy, or just inertia?  (No one has bothered
> to remove the old bits?)  The older parts being totally broken
> suggests sheer inertia.

This is due to very important compiler, not used by FreeBSD, still only
providing c99 features, for instance.  So people who have to write portable
C might force all compilation environment to the common standard.

I personally think that c89 is not very important now, but still should
not be broken without serious cause.  While c99 must be fully supported.
Of course, the statements are limited to user-mode visible portion of
/usr/include/* and libs.
___
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: r348847 - head/sys/sys

2019-06-10 Thread Conrad Meyer
On Mon, Jun 10, 2019 at 9:17 AM Bruce Evans  wrote:
> Only headers and libraries should support -std=c89.   has
> lots of support for compilers and POSIX versions going back to K C,
> and only the K parts are completely broken.

Is this due to specific policy, or just inertia?  (No one has bothered
to remove the old bits?)  The older parts being totally broken
suggests sheer inertia.

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


svn commit: r348867 - stable/11/sys/cddl/boot/zfs

2019-06-10 Thread Kyle Evans
Author: kevans
Date: Mon Jun 10 16:36:31 2019
New Revision: 348867
URL: https://svnweb.freebsd.org/changeset/base/348867

Log:
  MFC r342747 (mmacy): zfsboot: support newer ZFS versions
  
  declare v3 objset size/layout to fix userboot and possibly other loader
  issues
  
  - fix for userboot assertion failure in zfs_dev_close in free due to out of
bounds write
  - fix for zfs_alloc / zfs_free mismatch assertion failure when booting GPT
on BIOS
  
  Approved by:  re (gjb)

Modified:
  stable/11/sys/cddl/boot/zfs/zfsimpl.h
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/cddl/boot/zfs/zfsimpl.h
==
--- stable/11/sys/cddl/boot/zfs/zfsimpl.h   Mon Jun 10 15:55:38 2019
(r348866)
+++ stable/11/sys/cddl/boot/zfs/zfsimpl.h   Mon Jun 10 16:36:31 2019
(r348867)
@@ -1121,6 +1121,8 @@ typedef struct sa_hdr_phys {
 #defineSA_PARENT_OFFSET40
 #defineSA_SYMLINK_OFFSET   160
 
+#defineZIO_OBJSET_MAC_LEN  32
+
 /*
  * Intent log header - this on disk structure holds fields to manage
  * the log.  All fields are 64 bit to easily handle cross architectures.
@@ -1133,17 +1135,24 @@ typedef struct zil_header {
uint64_t zh_pad[5];
 } zil_header_t;
 
-#defineOBJSET_PHYS_SIZE 2048
+#defineOBJSET_PHYS_SIZE_V2 2048
+#defineOBJSET_PHYS_SIZE_V3 4096
 
 typedef struct objset_phys {
dnode_phys_t os_meta_dnode;
zil_header_t os_zil_header;
uint64_t os_type;
uint64_t os_flags;
-   char os_pad[OBJSET_PHYS_SIZE - sizeof (dnode_phys_t)*3 -
-   sizeof (zil_header_t) - sizeof (uint64_t)*2];
+   uint8_t os_portable_mac[ZIO_OBJSET_MAC_LEN];
+   uint8_t os_local_mac[ZIO_OBJSET_MAC_LEN];
+   char os_pad0[OBJSET_PHYS_SIZE_V2 - sizeof (dnode_phys_t)*3 -
+   sizeof (zil_header_t) - sizeof (uint64_t)*2 -
+   2*ZIO_OBJSET_MAC_LEN];
dnode_phys_t os_userused_dnode;
dnode_phys_t os_groupused_dnode;
+   dnode_phys_t os_projectused_dnode;
+   char os_pad1[OBJSET_PHYS_SIZE_V3 - OBJSET_PHYS_SIZE_V2 -
+   sizeof (dnode_phys_t)];
 } objset_phys_t;
 
 typedef struct dsl_dir_phys {
___
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: r348847 - head/sys/sys

2019-06-10 Thread Bruce Evans

On Mon, 10 Jun 2019, Ian Lepore wrote:


On Mon, 2019-06-10 at 07:49 -0600, Warner Losh wrote:

On Mon, Jun 10, 2019, 7:44 AM Conrad Meyer  wrote:


On Mon, Jun 10, 2019 at 2:10 AM T??l Coosemans 
wrote:

On Mon, 10 Jun 2019 05:28:04 + (UTC) Dmitry Chagin
 wrote:

...
URL: https://svnweb.freebsd.org/changeset/base/348847
Log:
  Use C11 anonymous unions.

Modified: head/sys/sys/ucred.h


...

Isn't this a userland header that should work with non-C11
compilers?

...
Why would one expect userland headers to work with non-C11 (gnu89)
compilers?

...
Because those compilers can choose non c11 variants of the language?


Do we promise that userland will compile with -std=c89?  I hope not.


Only headers and libraries should support -std=c89.   has
lots of support for compilers and POSIX versions going back to K C,
and only the K parts are completely broken.

FreeBSD also has the c89 and c99 utilities.  These require c89 and c99
headers to work under FreeBSD.  c89 uses CFLAGS -std=iso9899:199409
-pedantic.  I don't see how a 1994 standard can be correct for c89,
but -pedantic here might avoid the bug that -std=cxx doesn't actually
gives standard cxx, especially for clang.  c99 uses -std=iso9899:1999
-pedantic.  So anonymous unions are correctly disallowed by both c89
and c99.

At least the following headers still compile with c89: sys/types.h,
stdio.h, stdlib.h, the old version of sys/ucred.h.


Anonymous unions may be a c11 feature, but they're also available with
-std=gnu99, which I think is how we compile userland.


That is only the default, only for for parts of userland controlled by us.
Non-FreeBSD makefiles get at most the POSIX CFLAGS (something like -O)
from sys.mk if they use FreeBSD make, and something similar using gmake.


I think -std=gnu99 is how we should also compile the kernel, and I
think Bruce has been trying to say that for several years (but I'm not
sure, because the emails that seem to say so are always so full of
semi-related extraneous material that it's hard to be sure what they're
saying).


-std can be forced for kernel builds and other pure FreeBSD builds, but
then it should be the correct one.

bsd.sys.mk only directly supports the user selecting the following standards:
- c89 or c90
- c94 or c95 (the c89 utility gives -std=c94, not -std=c89)
- c99
- gnu99 (default)
Newer and more useful old standards like gnu89 are hard to select.  The
user must set the undocumented variable CSTD even to change the default to
c89/90/94/95.  Adding -std=whatever to CFLAGS only works if it happens to
be added after -std=${CSTD}.

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


svn commit: r348866 - in stable/11/stand: common i386/zfsboot

2019-06-10 Thread Kyle Evans
Author: kevans
Date: Mon Jun 10 15:55:38 2019
New Revision: 348866
URL: https://svnweb.freebsd.org/changeset/base/348866

Log:
  MFC r348569: [zfsboot] Fix boot env back compat (#190)
  
  * Fix boot env back compat
  
  zfsboot must try zfsloader before loader in order to remain compatible
  with boot environments created prior to zfs functionality being rolled
  into loader proper.
  
  * Improve comments in zfsboot
  
  Explain the significance of the load path order, and put the comment
  about looping through the paths in the appropriate scope.
  
  Approved by:  re (gjb)

Modified:
  stable/11/stand/common/paths.h
  stable/11/stand/i386/zfsboot/zfsboot.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/stand/common/paths.h
==
--- stable/11/stand/common/paths.h  Mon Jun 10 15:46:19 2019
(r348865)
+++ stable/11/stand/common/paths.h  Mon Jun 10 15:55:38 2019
(r348866)
@@ -33,6 +33,7 @@
 #define PATH_CONFIG"/boot/config"
 #define PATH_LOADER"/boot/loader"
 #define PATH_LOADER_EFI"/boot/loader.efi"
+#define PATH_LOADER_ZFS"/boot/zfsloader"
 #define PATH_KERNEL"/boot/kernel/kernel"
 
 #endif /* _PATHS_H_ */

Modified: stable/11/stand/i386/zfsboot/zfsboot.c
==
--- stable/11/stand/i386/zfsboot/zfsboot.c  Mon Jun 10 15:46:19 2019
(r348865)
+++ stable/11/stand/i386/zfsboot/zfsboot.c  Mon Jun 10 15:55:38 2019
(r348866)
@@ -87,6 +87,24 @@ static const unsigned char flags[NOPT] = {
 };
 uint32_t opts;
 
+/*
+ * Paths to try loading before falling back to the boot2 prompt.
+ *
+ * /boot/zfsloader must be tried before /boot/loader in order to remain
+ * backward compatible with ZFS boot environments where /boot/loader exists
+ * but does not have ZFS support, which was the case before FreeBSD 12.
+ *
+ * If no loader is found, try to load a kernel directly instead.
+ */
+static const struct string {
+const char *p;
+size_t len;
+} loadpath[] = {
+{ PATH_LOADER_ZFS, sizeof(PATH_LOADER_ZFS) },
+{ PATH_LOADER, sizeof(PATH_LOADER) },
+{ PATH_KERNEL, sizeof(PATH_KERNEL) },
+};
+
 static const unsigned char dev_maj[NDEV] = {30, 4, 2};
 
 static char cmd[512];
@@ -838,16 +856,17 @@ main(void)
 if (nextboot && !autoboot)
reboot();
 
-/*
- * Try to exec /boot/loader. If interrupted by a keypress,
- * or in case of failure, try to load a kernel directly instead.
- */
-
 if (autoboot && !*kname) {
-   memcpy(kname, PATH_LOADER, sizeof(PATH_LOADER));
-   if (!keyhit(3)) {
+   /*
+* Iterate through the list of loader and kernel paths, trying to load.
+* If interrupted by a keypress, or in case of failure, drop the user
+* to the boot2 prompt.
+*/
+   for (i = 0; i < nitems(loadpath); i++) {
+   memcpy(kname, loadpath[i].p, loadpath[i].len);
+   if (keyhit(3))
+   break;
load();
-   memcpy(kname, PATH_KERNEL, sizeof(PATH_KERNEL));
}
 }
 
___
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: r348865 - in stable/12/stand: common i386/zfsboot

2019-06-10 Thread Kyle Evans
Author: kevans
Date: Mon Jun 10 15:46:19 2019
New Revision: 348865
URL: https://svnweb.freebsd.org/changeset/base/348865

Log:
  MFC r348569: [zfsboot] Fix boot env back compat (#190)
  
  * Fix boot env back compat
  
  zfsboot must try zfsloader before loader in order to remain compatible
  with boot environments created prior to zfs functionality being rolled
  into loader proper.
  
  * Improve comments in zfsboot
  
  Explain the significance of the load path order, and put the comment
  about looping through the paths in the appropriate scope.

Modified:
  stable/12/stand/common/paths.h
  stable/12/stand/i386/zfsboot/zfsboot.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/stand/common/paths.h
==
--- stable/12/stand/common/paths.h  Mon Jun 10 15:44:09 2019
(r348864)
+++ stable/12/stand/common/paths.h  Mon Jun 10 15:46:19 2019
(r348865)
@@ -33,6 +33,7 @@
 #define PATH_CONFIG"/boot/config"
 #define PATH_LOADER"/boot/loader"
 #define PATH_LOADER_EFI"/boot/loader.efi"
+#define PATH_LOADER_ZFS"/boot/zfsloader"
 #define PATH_KERNEL"/boot/kernel/kernel"
 
 #endif /* _PATHS_H_ */

Modified: stable/12/stand/i386/zfsboot/zfsboot.c
==
--- stable/12/stand/i386/zfsboot/zfsboot.c  Mon Jun 10 15:44:09 2019
(r348864)
+++ stable/12/stand/i386/zfsboot/zfsboot.c  Mon Jun 10 15:46:19 2019
(r348865)
@@ -87,6 +87,24 @@ static const unsigned char flags[NOPT] = {
 };
 uint32_t opts;
 
+/*
+ * Paths to try loading before falling back to the boot2 prompt.
+ *
+ * /boot/zfsloader must be tried before /boot/loader in order to remain
+ * backward compatible with ZFS boot environments where /boot/loader exists
+ * but does not have ZFS support, which was the case before FreeBSD 12.
+ *
+ * If no loader is found, try to load a kernel directly instead.
+ */
+static const struct string {
+const char *p;
+size_t len;
+} loadpath[] = {
+{ PATH_LOADER_ZFS, sizeof(PATH_LOADER_ZFS) },
+{ PATH_LOADER, sizeof(PATH_LOADER) },
+{ PATH_KERNEL, sizeof(PATH_KERNEL) },
+};
+
 static const unsigned char dev_maj[NDEV] = {30, 4, 2};
 
 static char cmd[512];
@@ -838,16 +856,17 @@ main(void)
 if (nextboot && !autoboot)
reboot();
 
-/*
- * Try to exec /boot/loader. If interrupted by a keypress,
- * or in case of failure, try to load a kernel directly instead.
- */
-
 if (autoboot && !*kname) {
-   memcpy(kname, PATH_LOADER, sizeof(PATH_LOADER));
-   if (!keyhit(3)) {
+   /*
+* Iterate through the list of loader and kernel paths, trying to load.
+* If interrupted by a keypress, or in case of failure, drop the user
+* to the boot2 prompt.
+*/
+   for (i = 0; i < nitems(loadpath); i++) {
+   memcpy(kname, loadpath[i].p, loadpath[i].len);
+   if (keyhit(3))
+   break;
load();
-   memcpy(kname, PATH_KERNEL, sizeof(PATH_KERNEL));
}
 }
 
___
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: r348864 - stable/12/share/examples/bhyve

2019-06-10 Thread Mark Johnston
Author: markj
Date: Mon Jun 10 15:44:09 2019
New Revision: 348864
URL: https://svnweb.freebsd.org/changeset/base/348864

Log:
  MFC r348782:
  vmrun: Add a missing close-paren to the usage message.

Modified:
  stable/12/share/examples/bhyve/vmrun.sh
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/share/examples/bhyve/vmrun.sh
==
--- stable/12/share/examples/bhyve/vmrun.sh Mon Jun 10 14:47:56 2019
(r348863)
+++ stable/12/share/examples/bhyve/vmrun.sh Mon Jun 10 15:44:09 2019
(r348864)
@@ -75,7 +75,7 @@ usage() {
echo "   -E: Use UEFI mode"
echo "   -f: Use a specific UEFI firmware"
echo "   -F: Use a custom UEFI GOP framebuffer size" \
-   "(default: ${DEFAULT_VNCSIZE}"
+   "(default: ${DEFAULT_VNCSIZE})"
echo "   -g: listen for connection from kgdb at "
echo "   -H: host filesystem to export to the loader"
echo "   -i: force boot of the Installation CDROM image"
___
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: r348843 - head/sys/vm

2019-06-10 Thread Shawn Webb
On Tue, Jun 11, 2019 at 01:33:23AM +1000, Bruce Evans wrote:
> On Mon, 10 Jun 2019, Shawn Webb wrote:
> 
> > On Mon, Jun 10, 2019 at 03:07:11AM +, Doug Moore wrote:
> > > ...
> > > Log:
> > >   There are times when a len==0 parameter to mmap is okay. But on a
> > >   32-bit machine, a len parameter just a few bytes short of 4G, rounded
> > >   up to a page boundary and hitting zero then, is not okay. Return
> > >   failure in that case.
> > > ...
> > >   /* Adjust size for rounding (on both ends). */
> > >   size += pageoff;/* low end... */
> > > - size = (vm_size_t) round_page(size);/* hi end */
> > > + /* Check for rounding up to zero. */
> > > + if (round_page(size) < size)
> > > + return (EINVAL);
> > 
> > The mmap(2) manpage says that len==0 results in EINVAL, so the manpage
> > needs updating.
> 
> The man page doesn't say that only len == 0 results in EINVAL, so it is
> not incorrect.

https://github.com/freebsd/freebsd/blob/master/lib/libc/sys/mmap.2#L451-L455

Tons of error conditions listed, one of which is len==0.

Thanks,

-- 
Shawn Webb
Cofounder / Security Engineer
HardenedBSD

Tor-ified Signal:+1 443-546-8752
Tor+XMPP+OTR:latt...@is.a.hacker.sx
GPG Key ID:  0xFF2E67A277F8E1FA
GPG Key Fingerprint: D206 BB45 15E0 9C49 0CF9  3633 C85B 0AF8 AB23 0FB2


signature.asc
Description: PGP signature


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

2019-06-10 Thread Bruce Evans

On Mon, 10 Jun 2019, Shawn Webb wrote:


On Mon, Jun 10, 2019 at 03:07:11AM +, Doug Moore wrote:

...
Log:
  There are times when a len==0 parameter to mmap is okay. But on a
  32-bit machine, a len parameter just a few bytes short of 4G, rounded
  up to a page boundary and hitting zero then, is not okay. Return
  failure in that case.
...
/* Adjust size for rounding (on both ends). */
size += pageoff;/* low end... */
-   size = (vm_size_t) round_page(size);/* hi end */
+   /* Check for rounding up to zero. */
+   if (round_page(size) < size)
+   return (EINVAL);


The mmap(2) manpage says that len==0 results in EINVAL, so the manpage
needs updating.


The man page doesn't say that only len == 0 results in EINVAL, so it is
not incorrect.

However, the errno here is incorrect.  POSIX specifies that the errno is
ENOMEM if MAP_FIXED was specified, and the range [addr,addr+len) exceeds
that allowed for the address space of the process; or, if MAP_FIXED was
not specified and there is insufficient room in the address space to effect
the mapping.  There are 2 other meanings for ENOMEM in POSIX.1-2001.

The man page documents ENOMEM, but only has a small fraction of the above
case, and no other cases.  It says that the errno is ENOMEM if MAP_FIXED was
specified and the addr argument was not available, or MAP_ANON was specified
and insufficient memory was available.  Who knows what it means for the addr
argument to be no available?

The other cases specified by POSIX but not the man page are: (1) under the
ML extension, if the mapping could not be locked...  (1a) MAP_FIXED or
MAP_PRIVATE was specified and the implementation does not support this
(but FreeBSD does support this, at least for most file types).  (2) under
the TYM extension, not enough resources in the typed memory object
designated by filedes...


I'm curious what "there are times" refers to. Can you or the original
reporter elaborate those cases?


When len == 0 is actually a parameter, and with other parameters specifying
that len == 0 is meaningful.

The code has various style bugs starting with renaming the len parameter to
a size parameter for a layered function.  So it is not actually the len
parameter that is adjusted, but adjusting it is still a style bug since it
reuses a function parameter so the original parameter is harder to describe
and to debug.

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


Re: svn commit: r348847 - head/sys/sys

2019-06-10 Thread Tijl Coosemans
On Mon, 10 Jun 2019 06:43:26 -0700 Conrad Meyer  wrote:
> On Mon, Jun 10, 2019 at 2:10 AM Tijl Coosemans  wrote:
>> On Mon, 10 Jun 2019 05:28:04 + (UTC) Dmitry Chagin
>>  wrote:
>>> ...
>>> URL: https://svnweb.freebsd.org/changeset/base/348847
>>> Log:
>>>   Use C11 anonymous unions.
>>>
>>> Modified: head/sys/sys/ucred.h
>> ...
>>
>> Isn't this a userland header that should work with non-C11 compilers?
> 
> Why would one expect userland headers to work with non-C11 (gnu89)
> compilers?

I'm thinking of third party software compiled with third party
compilers.  The system headers need to work with various C and C++
standards.  struct xucred is part of a public API documented in unix(4).
___
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: r348847 - head/sys/sys

2019-06-10 Thread Ian Lepore
On Mon, 2019-06-10 at 07:49 -0600, Warner Losh wrote:
> On Mon, Jun 10, 2019, 7:44 AM Conrad Meyer  wrote:
> 
> > On Mon, Jun 10, 2019 at 2:10 AM Tijl Coosemans 
> > wrote:
> > > On Mon, 10 Jun 2019 05:28:04 + (UTC) Dmitry Chagin
> > >  wrote:
> > > > ...
> > > > URL: https://svnweb.freebsd.org/changeset/base/348847
> > > > Log:
> > > >   Use C11 anonymous unions.
> > > > 
> > > > Modified: head/sys/sys/ucred.h
> > > 
> > > ...
> > > 
> > > Isn't this a userland header that should work with non-C11
> > > compilers?
> > 
> > Hi Tijl,
> > 
> > Why would one expect userland headers to work with non-C11 (gnu89)
> > compilers?
> > 
> 
> Because those compilers can choose non c11 variants of the language?
> 
> Warner
> 

Do we promise that userland will compile with -std=c89?  I hope not. 
Anonymous unions may be a c11 feature, but they're also available with
-std=gnu99, which I think is how we compile userland.

I think -std=gnu99 is how we should also compile the kernel, and I
think Bruce has been trying to say that for several years (but I'm not
sure, because the emails that seem to say so are always so full of
semi-related extraneous material that it's hard to be sure what they're
saying).

-- Ian


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


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

2019-06-10 Thread Doug Moore
The comment and the code that rejects size==0, or doesn't, are copied
below.  Konstantin Belousov is the last person to have touched most of
it, and can better explain its meaning than I.

Doug Moore

    /*
     * Enforce the constraints.
     * Mapping of length 0 is only allowed for old binaries.
     * Anonymous mapping shall specify -1 as filedescriptor and
     * zero position for new code. Be nice to ancient a.out
     * binaries and correct pos for anonymous mapping, since old
     * ld.so sometimes issues anonymous map requests with non-zero
     * pos.
     */
    if (!SV_CURPROC_FLAG(SV_AOUT)) {
        if ((size == 0 && curproc->p_osrel >= P_OSREL_MAP_ANON) ||
            ((flags & MAP_ANON) != 0 && (fd != -1 || pos != 0)))
            return (EINVAL);
    } else {
        if ((flags & MAP_ANON) != 0)
            pos = 0;
    }

On 6/10/19 9:27 AM, Shawn Webb wrote:
> Sounds good! I think the manpage still might still need a change
> to match the current behavior, or perhaps matching something similar
> to that vm_mmap.c comment. But that comment brings another question:
> what's the definition of "old binaries"? a.out?
>
> Thanks,
>

___
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: r348863 - stable/11/sbin/bectl

2019-06-10 Thread Kyle Evans
Author: kevans
Date: Mon Jun 10 14:47:56 2019
New Revision: 348863
URL: https://svnweb.freebsd.org/changeset/base/348863

Log:
  MFC r348510: bectl(8): Don't accept jid=0 from jail_getid
  
  This will trivially exist, but we don't want it - none of our jailed BEs
  will have jid=0.
  
  Approved by:  re (gjb)

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

Modified: stable/11/sbin/bectl/bectl_jail.c
==
--- stable/11/sbin/bectl/bectl_jail.c   Mon Jun 10 14:35:04 2019
(r348862)
+++ stable/11/sbin/bectl/bectl_jail.c   Mon Jun 10 14:47:56 2019
(r348863)
@@ -410,7 +410,12 @@ bectl_locate_jail(const char *ident)
 
/* Try the easy-match first */
jid = jail_getid(ident);
-   if (jid != -1)
+   /*
+* jail_getid(0) will always return 0, because this prison does exist.
+* bectl(8) knows that this is not what it wants, so we should fall
+* back to mount point search.
+*/
+   if (jid > 0)
return (jid);
 
/* Attempt to try it as a BE name, first */
___
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: r348847 - head/sys/sys

2019-06-10 Thread Conrad Meyer
Hi Warner,

That doesn't seem responsive to the question.

On Mon, Jun 10, 2019 at 6:49 AM Warner Losh  wrote:
>
>
>
> On Mon, Jun 10, 2019, 7:44 AM Conrad Meyer  wrote:
>>
>> On Mon, Jun 10, 2019 at 2:10 AM Tijl Coosemans  wrote:
>> > On Mon, 10 Jun 2019 05:28:04 + (UTC) Dmitry Chagin
>> >  wrote:
>> > > ...
>> > > URL: https://svnweb.freebsd.org/changeset/base/348847
>> > > Log:
>> > >   Use C11 anonymous unions.
>> > >
>> > > Modified: head/sys/sys/ucred.h
>> > ...
>> >
>> > Isn't this a userland header that should work with non-C11 compilers?
>>
>> Hi Tijl,
>>
>> Why would one expect userland headers to work with non-C11 (gnu89) compilers?
>
>
> Because those compilers can choose non c11 variants of the language?
>
> Warner
___
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: r348862 - stable/12/sbin/bectl

2019-06-10 Thread Kyle Evans
Author: kevans
Date: Mon Jun 10 14:35:04 2019
New Revision: 348862
URL: https://svnweb.freebsd.org/changeset/base/348862

Log:
  MFC r348510: bectl(8): Don't accept jid=0 from jail_getid
  
  This will trivially exist, but we don't want it - none of our jailed BEs
  will have jid=0.

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

Modified: stable/12/sbin/bectl/bectl_jail.c
==
--- stable/12/sbin/bectl/bectl_jail.c   Mon Jun 10 14:31:18 2019
(r348861)
+++ stable/12/sbin/bectl/bectl_jail.c   Mon Jun 10 14:35:04 2019
(r348862)
@@ -410,7 +410,12 @@ bectl_locate_jail(const char *ident)
 
/* Try the easy-match first */
jid = jail_getid(ident);
-   if (jid != -1)
+   /*
+* jail_getid(0) will always return 0, because this prison does exist.
+* bectl(8) knows that this is not what it wants, so we should fall
+* back to mount point search.
+*/
+   if (jid > 0)
return (jid);
 
/* Attempt to try it as a BE name, first */
___
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: r348861 - head/sys/net80211

2019-06-10 Thread Bjoern A. Zeeb
Author: bz
Date: Mon Jun 10 14:31:18 2019
New Revision: 348861
URL: https://svnweb.freebsd.org/changeset/base/348861

Log:
  Enhance the comment ieee80211_add_channel() to avoid a
  misunderstanding that the function does not work additive
  when repeatedly called for diffferent bands.
  
  Reviewed by:  avos (a few months ago)
  MFC after:2 weeks

Modified:
  head/sys/net80211/ieee80211.c

Modified: head/sys/net80211/ieee80211.c
==
--- head/sys/net80211/ieee80211.c   Mon Jun 10 13:46:36 2019
(r348860)
+++ head/sys/net80211/ieee80211.c   Mon Jun 10 14:31:18 2019
(r348861)
@@ -1386,6 +1386,8 @@ getflags(const uint8_t bands[], uint32_t flags[], int 
 
 /*
  * Add one 20 MHz channel into specified channel list.
+ * You MUST NOT mix bands when calling this.  It will not add 5ghz
+ * channels if you have any B/G/N band bit set.
  */
 /* XXX VHT */
 int
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


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

2019-06-10 Thread Shawn Webb
Sounds good! I think the manpage still might still need a change
to match the current behavior, or perhaps matching something similar
to that vm_mmap.c comment. But that comment brings another question:
what's the definition of "old binaries"? a.out?

Thanks,

-- 
Shawn Webb
Cofounder / Security Engineer
HardenedBSD

Tor-ified Signal:+1 443-546-8752
Tor+XMPP+OTR:latt...@is.a.hacker.sx
GPG Key ID:  0xFF2E67A277F8E1FA
GPG Key Fingerprint: D206 BB45 15E0 9C49 0CF9  3633 C85B 0AF8 AB23 0FB2

On Mon, Jun 10, 2019 at 09:19:55AM -0500, Doug Moore wrote:
> This comment appears in vm_mmap.c:
> 
>  * Mapping of length 0 is only allowed for old binaries.
> 
> and my intent was to say, to whoever wrote that comment, that I was not
> disallowing the mapping of length zero with this change.? I was only
> intending to affect a case in which the length was transformed to zero,
> and which was the problem that Peter Holm reported.
> 
> Doug Moore
> 
> On 6/10/19 8:00 AM, Shawn Webb wrote:
> > On Mon, Jun 10, 2019 at 03:07:11AM +, Doug Moore wrote:
> >> Author: dougm
> >> Date: Mon Jun 10 03:07:10 2019
> >> New Revision: 348843
> >> URL: https://svnweb.freebsd.org/changeset/base/348843
> >>
> >> Log:
> >>   There are times when a len==0 parameter to mmap is okay. But on a
> >>   32-bit machine, a len parameter just a few bytes short of 4G, rounded
> >>   up to a page boundary and hitting zero then, is not okay. Return
> >>   failure in that case.
> >>   
> >>   Reported by: pho
> >>   Reviewed by: alc, kib (mentor)
> >>   Tested by: pho
> >>   Differential Revision: https://reviews.freebsd.org/D20580
> >>
> >> Modified:
> >>   head/sys/vm/vm_mmap.c
> >>
> >> Modified: head/sys/vm/vm_mmap.c
> >> ==
> >> --- head/sys/vm/vm_mmap.c  Sun Jun  9 22:55:21 2019(r348842)
> >> +++ head/sys/vm/vm_mmap.c  Mon Jun 10 03:07:10 2019(r348843)
> >> @@ -257,7 +257,10 @@ kern_mmap(struct thread *td, uintptr_t addr0, size_t s
> >>  
> >>/* Adjust size for rounding (on both ends). */
> >>size += pageoff;/* low end... */
> >> -  size = (vm_size_t) round_page(size);/* hi end */
> >> +  /* Check for rounding up to zero. */
> >> +  if (round_page(size) < size)
> >> +  return (EINVAL);
> > The mmap(2) manpage says that len==0 results in EINVAL, so the manpage
> > needs updating.
> >
> > I'm curious what "there are times" refers to. Can you or the original
> > reporter elaborate those cases?
> >
> > Thanks a lot!
> >


signature.asc
Description: PGP signature


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

2019-06-10 Thread Doug Moore
This comment appears in vm_mmap.c:

 * Mapping of length 0 is only allowed for old binaries.

and my intent was to say, to whoever wrote that comment, that I was not
disallowing the mapping of length zero with this change.  I was only
intending to affect a case in which the length was transformed to zero,
and which was the problem that Peter Holm reported.

Doug Moore

On 6/10/19 8:00 AM, Shawn Webb wrote:
> On Mon, Jun 10, 2019 at 03:07:11AM +, Doug Moore wrote:
>> Author: dougm
>> Date: Mon Jun 10 03:07:10 2019
>> New Revision: 348843
>> URL: https://svnweb.freebsd.org/changeset/base/348843
>>
>> Log:
>>   There are times when a len==0 parameter to mmap is okay. But on a
>>   32-bit machine, a len parameter just a few bytes short of 4G, rounded
>>   up to a page boundary and hitting zero then, is not okay. Return
>>   failure in that case.
>>   
>>   Reported by: pho
>>   Reviewed by: alc, kib (mentor)
>>   Tested by: pho
>>   Differential Revision: https://reviews.freebsd.org/D20580
>>
>> Modified:
>>   head/sys/vm/vm_mmap.c
>>
>> Modified: head/sys/vm/vm_mmap.c
>> ==
>> --- head/sys/vm/vm_mmap.cSun Jun  9 22:55:21 2019(r348842)
>> +++ head/sys/vm/vm_mmap.cMon Jun 10 03:07:10 2019(r348843)
>> @@ -257,7 +257,10 @@ kern_mmap(struct thread *td, uintptr_t addr0, size_t s
>>  
>>  /* Adjust size for rounding (on both ends). */
>>  size += pageoff;/* low end... */
>> -size = (vm_size_t) round_page(size);/* hi end */
>> +/* Check for rounding up to zero. */
>> +if (round_page(size) < size)
>> +return (EINVAL);
> The mmap(2) manpage says that len==0 results in EINVAL, so the manpage
> needs updating.
>
> I'm curious what "there are times" refers to. Can you or the original
> reporter elaborate those cases?
>
> Thanks a lot!
>
___
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: r348847 - head/sys/sys

2019-06-10 Thread Warner Losh
On Mon, Jun 10, 2019, 7:44 AM Conrad Meyer  wrote:

> On Mon, Jun 10, 2019 at 2:10 AM Tijl Coosemans  wrote:
> > On Mon, 10 Jun 2019 05:28:04 + (UTC) Dmitry Chagin
> >  wrote:
> > > ...
> > > URL: https://svnweb.freebsd.org/changeset/base/348847
> > > Log:
> > >   Use C11 anonymous unions.
> > >
> > > Modified: head/sys/sys/ucred.h
> > ...
> >
> > Isn't this a userland header that should work with non-C11 compilers?
>
> Hi Tijl,
>
> Why would one expect userland headers to work with non-C11 (gnu89)
> compilers?
>

Because those compilers can choose non c11 variants of the language?

Warner

>
___
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: r348860 - head/sys/arm/allwinner

2019-06-10 Thread Bjoern A. Zeeb
Author: bz
Date: Mon Jun 10 13:46:36 2019
New Revision: 348860
URL: https://svnweb.freebsd.org/changeset/base/348860

Log:
  allwinner mmc: move variable assignment into block
  
  "blksz is only used in one of the two blocks, so assign it inside
  that block rather than outside.
  
  MFC after:2 weeks

Modified:
  head/sys/arm/allwinner/aw_mmc.c

Modified: head/sys/arm/allwinner/aw_mmc.c
==
--- head/sys/arm/allwinner/aw_mmc.c Mon Jun 10 13:44:29 2019
(r348859)
+++ head/sys/arm/allwinner/aw_mmc.c Mon Jun 10 13:46:36 2019
(r348860)
@@ -1104,7 +1104,6 @@ aw_mmc_request(device_t bus, device_t child, struct mm
}
if (cmd->data->flags & MMC_DATA_WRITE)
cmdreg |= AW_MMC_CMDR_DIR_WRITE;
-   blksz = min(cmd->data->len, MMC_SECTOR_SIZE);
 #ifdef MMCCAM
if (cmd->data->flags & MMC_DATA_BLOCK_SIZE) {
AW_MMC_WRITE_4(sc, AW_MMC_BKSR, cmd->data->block_size);
@@ -1112,6 +,7 @@ aw_mmc_request(device_t bus, device_t child, struct mm
} else
 #endif
{
+   blksz = min(cmd->data->len, MMC_SECTOR_SIZE);
AW_MMC_WRITE_4(sc, AW_MMC_BKSR, blksz);
AW_MMC_WRITE_4(sc, AW_MMC_BYCR, cmd->data->len);
}
___
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: r348859 - stable/11/sys/ofed/drivers/infiniband/core

2019-06-10 Thread Slava Shwartsman
Author: slavash
Date: Mon Jun 10 13:44:29 2019
New Revision: 348859
URL: https://svnweb.freebsd.org/changeset/base/348859

Log:
  MFC r348601:
  Fix prio vs. nonprio tagged traffic in RDMACM
  
  In current RDMACM implementation RDMACM server will not find a GID
  index when the request was prio-tagged and the sever is non
  prio-tagged and vise-versa.
  According to 802.1Q-2014, VLAN tagged packets with VLAN id 0 should
  be considered as untagged. Treat RDMACM request the same.
  
  Reviewed by:hselasky, kib
  Sponsored by:   Mellanox Technologies
  Approved by:re (gjb@)

Modified:
  stable/11/sys/ofed/drivers/infiniband/core/ib_verbs.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/ofed/drivers/infiniband/core/ib_verbs.c
==
--- stable/11/sys/ofed/drivers/infiniband/core/ib_verbs.c   Mon Jun 10 
13:38:57 2019(r348858)
+++ stable/11/sys/ofed/drivers/infiniband/core/ib_verbs.c   Mon Jun 10 
13:44:29 2019(r348859)
@@ -414,18 +414,32 @@ struct find_gid_index_context {
enum ib_gid_type gid_type;
 };
 
+
+/*
+ * This function will return true only if a inspected GID index
+ * matches the request based on the GID type and VLAN configuration
+ */
 static bool find_gid_index(const union ib_gid *gid,
   const struct ib_gid_attr *gid_attr,
   void *context)
 {
+   u16 vlan_diff;
struct find_gid_index_context *ctx =
(struct find_gid_index_context *)context;
 
if (ctx->gid_type != gid_attr->gid_type)
return false;
-   if (rdma_vlan_dev_vlan_id(gid_attr->ndev) != ctx->vlan_id)
-   return false;
-   return true;
+
+   /*
+* The following will verify:
+* 1. VLAN ID matching for VLAN tagged requests.
+* 2. prio-tagged/untagged to prio-tagged/untagged matching.
+*
+* This XOR is valid, since 0x0 < vlan_id < 0x0FFF.
+*/
+   vlan_diff = rdma_vlan_dev_vlan_id(gid_attr->ndev) ^ ctx->vlan_id;
+
+   return (vlan_diff == 0x || vlan_diff == 0x);
 }
 
 static int get_sgid_index_from_eth(struct ib_device *device, u8 port_num,
___
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: r348847 - head/sys/sys

2019-06-10 Thread Conrad Meyer
On Mon, Jun 10, 2019 at 2:10 AM Tijl Coosemans  wrote:
> On Mon, 10 Jun 2019 05:28:04 + (UTC) Dmitry Chagin
>  wrote:
> > ...
> > URL: https://svnweb.freebsd.org/changeset/base/348847
> > Log:
> >   Use C11 anonymous unions.
> >
> > Modified: head/sys/sys/ucred.h
> ...
>
> Isn't this a userland header that should work with non-C11 compilers?

Hi Tijl,

Why would one expect userland headers to work with non-C11 (gnu89) compilers?

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


svn commit: r348858 - stable/9/sys/dev/usb

2019-06-10 Thread Hans Petter Selasky
Author: hselasky
Date: Mon Jun 10 13:38:57 2019
New Revision: 348858
URL: https://svnweb.freebsd.org/changeset/base/348858

Log:
  MFC r348631:
  In usb(4) fix a lost completion event issue towards libusb(3). It may happen
  if a USB transfer is cancelled that we need to fake a completion event.
  Implement missing support in ugen_fs_copy_out() to handle this.
  
  This fixes issues with webcamd(8) and firefox.
  
  Sponsored by: Mellanox Technologies

Modified:
  stable/9/sys/dev/usb/usb_generic.c
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/dev/usb/usb_generic.c
==
--- stable/9/sys/dev/usb/usb_generic.c  Mon Jun 10 13:37:38 2019
(r348857)
+++ stable/9/sys/dev/usb/usb_generic.c  Mon Jun 10 13:38:57 2019
(r348858)
@@ -1206,6 +1206,40 @@ complete:
 }
 
 static int
+ugen_fs_copy_out_cancelled(struct usb_fs_endpoint *fs_ep_uptr)
+{
+   struct usb_fs_endpoint fs_ep;
+   int error;
+
+   error = copyin(fs_ep_uptr, _ep, sizeof(fs_ep));
+   if (error)
+   return (error);
+
+   fs_ep.status = USB_ERR_CANCELLED;
+   fs_ep.aFrames = 0;
+   fs_ep.isoc_time_complete = 0;
+
+   /* update "aFrames" */
+   error = copyout(_ep.aFrames, _ep_uptr->aFrames,
+   sizeof(fs_ep.aFrames));
+   if (error)
+   goto done;
+
+   /* update "isoc_time_complete" */
+   error = copyout(_ep.isoc_time_complete,
+   _ep_uptr->isoc_time_complete,
+   sizeof(fs_ep.isoc_time_complete));
+   if (error)
+   goto done;
+
+   /* update "status" */
+   error = copyout(_ep.status, _ep_uptr->status,
+   sizeof(fs_ep.status));
+done:
+   return (error);
+}
+
+static int
 ugen_fs_copy_out(struct usb_fifo *f, uint8_t ep_index)
 {
struct usb_device_request *req;
@@ -1230,8 +1264,13 @@ ugen_fs_copy_out(struct usb_fifo *f, uint8_t ep_index)
return (EINVAL);
 
mtx_lock(f->priv_mtx);
-   if (usbd_transfer_pending(xfer)) {
+   if (!xfer->flags_int.transferring &&
+   !xfer->flags_int.started) {
mtx_unlock(f->priv_mtx);
+   DPRINTF("Returning fake cancel event\n");
+   return (ugen_fs_copy_out_cancelled(f->fs_ep_ptr + ep_index));
+   } else if (usbd_transfer_pending(xfer)) {
+   mtx_unlock(f->priv_mtx);
return (EBUSY); /* should not happen */
}
mtx_unlock(f->priv_mtx);
@@ -1351,6 +1390,7 @@ complete:
sizeof(fs_ep.isoc_time_complete));
if (error)
goto done;
+
/* update "status" */
error = copyout(_ep.status, _ep_uptr->status,
sizeof(fs_ep.status));
@@ -1438,12 +1478,15 @@ ugen_ioctl(struct usb_fifo *f, u_long cmd, void *addr,
xfer = f->fs_xfer[u.pstart->ep_index];
if (usbd_transfer_pending(xfer)) {
usbd_transfer_stop(xfer);
+
/*
 * Check if the USB transfer was stopped
-* before it was even started. Else a cancel
-* callback will be pending.
+* before it was even started and fake a
+* cancel event.
 */
-   if (!xfer->flags_int.transferring) {
+   if (!xfer->flags_int.transferring &&
+   !xfer->flags_int.started) {
+   DPRINTF("Issuing fake completion event\n");
ugen_fs_set_complete(xfer->priv_sc,
USB_P2U(xfer->priv_fifo));
}
___
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: r348857 - stable/10/sys/dev/usb

2019-06-10 Thread Hans Petter Selasky
Author: hselasky
Date: Mon Jun 10 13:37:38 2019
New Revision: 348857
URL: https://svnweb.freebsd.org/changeset/base/348857

Log:
  MFC r348631:
  In usb(4) fix a lost completion event issue towards libusb(3). It may happen
  if a USB transfer is cancelled that we need to fake a completion event.
  Implement missing support in ugen_fs_copy_out() to handle this.
  
  This fixes issues with webcamd(8) and firefox.
  
  Sponsored by: Mellanox Technologies

Modified:
  stable/10/sys/dev/usb/usb_generic.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/dev/usb/usb_generic.c
==
--- stable/10/sys/dev/usb/usb_generic.c Mon Jun 10 13:36:53 2019
(r348856)
+++ stable/10/sys/dev/usb/usb_generic.c Mon Jun 10 13:37:38 2019
(r348857)
@@ -1218,6 +1218,40 @@ complete:
 }
 
 static int
+ugen_fs_copy_out_cancelled(struct usb_fs_endpoint *fs_ep_uptr)
+{
+   struct usb_fs_endpoint fs_ep;
+   int error;
+
+   error = copyin(fs_ep_uptr, _ep, sizeof(fs_ep));
+   if (error)
+   return (error);
+
+   fs_ep.status = USB_ERR_CANCELLED;
+   fs_ep.aFrames = 0;
+   fs_ep.isoc_time_complete = 0;
+
+   /* update "aFrames" */
+   error = copyout(_ep.aFrames, _ep_uptr->aFrames,
+   sizeof(fs_ep.aFrames));
+   if (error)
+   goto done;
+
+   /* update "isoc_time_complete" */
+   error = copyout(_ep.isoc_time_complete,
+   _ep_uptr->isoc_time_complete,
+   sizeof(fs_ep.isoc_time_complete));
+   if (error)
+   goto done;
+
+   /* update "status" */
+   error = copyout(_ep.status, _ep_uptr->status,
+   sizeof(fs_ep.status));
+done:
+   return (error);
+}
+
+static int
 ugen_fs_copy_out(struct usb_fifo *f, uint8_t ep_index)
 {
struct usb_device_request *req;
@@ -1242,8 +1276,13 @@ ugen_fs_copy_out(struct usb_fifo *f, uint8_t ep_index)
return (EINVAL);
 
mtx_lock(f->priv_mtx);
-   if (usbd_transfer_pending(xfer)) {
+   if (!xfer->flags_int.transferring &&
+   !xfer->flags_int.started) {
mtx_unlock(f->priv_mtx);
+   DPRINTF("Returning fake cancel event\n");
+   return (ugen_fs_copy_out_cancelled(f->fs_ep_ptr + ep_index));
+   } else if (usbd_transfer_pending(xfer)) {
+   mtx_unlock(f->priv_mtx);
return (EBUSY); /* should not happen */
}
mtx_unlock(f->priv_mtx);
@@ -1363,6 +1402,7 @@ complete:
sizeof(fs_ep.isoc_time_complete));
if (error)
goto done;
+
/* update "status" */
error = copyout(_ep.status, _ep_uptr->status,
sizeof(fs_ep.status));
@@ -1451,12 +1491,15 @@ ugen_ioctl(struct usb_fifo *f, u_long cmd, void *addr,
xfer = f->fs_xfer[u.pstart->ep_index];
if (usbd_transfer_pending(xfer)) {
usbd_transfer_stop(xfer);
+
/*
 * Check if the USB transfer was stopped
-* before it was even started. Else a cancel
-* callback will be pending.
+* before it was even started and fake a
+* cancel event.
 */
-   if (!xfer->flags_int.transferring) {
+   if (!xfer->flags_int.transferring &&
+   !xfer->flags_int.started) {
+   DPRINTF("Issuing fake completion event\n");
ugen_fs_set_complete(xfer->priv_sc,
USB_P2U(xfer->priv_fifo));
}
___
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: r348856 - stable/12/sys/dev/usb

2019-06-10 Thread Hans Petter Selasky
Author: hselasky
Date: Mon Jun 10 13:36:53 2019
New Revision: 348856
URL: https://svnweb.freebsd.org/changeset/base/348856

Log:
  MFC r348631:
  In usb(4) fix a lost completion event issue towards libusb(3). It may happen
  if a USB transfer is cancelled that we need to fake a completion event.
  Implement missing support in ugen_fs_copy_out() to handle this.
  
  This fixes issues with webcamd(8) and firefox.
  
  Sponsored by: Mellanox Technologies

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

Modified: stable/12/sys/dev/usb/usb_generic.c
==
--- stable/12/sys/dev/usb/usb_generic.c Mon Jun 10 13:36:12 2019
(r348855)
+++ stable/12/sys/dev/usb/usb_generic.c Mon Jun 10 13:36:53 2019
(r348856)
@@ -1219,6 +1219,40 @@ complete:
 }
 
 static int
+ugen_fs_copy_out_cancelled(struct usb_fs_endpoint *fs_ep_uptr)
+{
+   struct usb_fs_endpoint fs_ep;
+   int error;
+
+   error = copyin(fs_ep_uptr, _ep, sizeof(fs_ep));
+   if (error)
+   return (error);
+
+   fs_ep.status = USB_ERR_CANCELLED;
+   fs_ep.aFrames = 0;
+   fs_ep.isoc_time_complete = 0;
+
+   /* update "aFrames" */
+   error = copyout(_ep.aFrames, _ep_uptr->aFrames,
+   sizeof(fs_ep.aFrames));
+   if (error)
+   goto done;
+
+   /* update "isoc_time_complete" */
+   error = copyout(_ep.isoc_time_complete,
+   _ep_uptr->isoc_time_complete,
+   sizeof(fs_ep.isoc_time_complete));
+   if (error)
+   goto done;
+
+   /* update "status" */
+   error = copyout(_ep.status, _ep_uptr->status,
+   sizeof(fs_ep.status));
+done:
+   return (error);
+}
+
+static int
 ugen_fs_copy_out(struct usb_fifo *f, uint8_t ep_index)
 {
struct usb_device_request *req;
@@ -1243,8 +1277,13 @@ ugen_fs_copy_out(struct usb_fifo *f, uint8_t ep_index)
return (EINVAL);
 
mtx_lock(f->priv_mtx);
-   if (usbd_transfer_pending(xfer)) {
+   if (!xfer->flags_int.transferring &&
+   !xfer->flags_int.started) {
mtx_unlock(f->priv_mtx);
+   DPRINTF("Returning fake cancel event\n");
+   return (ugen_fs_copy_out_cancelled(f->fs_ep_ptr + ep_index));
+   } else if (usbd_transfer_pending(xfer)) {
+   mtx_unlock(f->priv_mtx);
return (EBUSY); /* should not happen */
}
mtx_unlock(f->priv_mtx);
@@ -1364,6 +1403,7 @@ complete:
sizeof(fs_ep.isoc_time_complete));
if (error)
goto done;
+
/* update "status" */
error = copyout(_ep.status, _ep_uptr->status,
sizeof(fs_ep.status));
@@ -1452,12 +1492,15 @@ ugen_ioctl(struct usb_fifo *f, u_long cmd, void *addr,
xfer = f->fs_xfer[u.pstart->ep_index];
if (usbd_transfer_pending(xfer)) {
usbd_transfer_stop(xfer);
+
/*
 * Check if the USB transfer was stopped
-* before it was even started. Else a cancel
-* callback will be pending.
+* before it was even started and fake a
+* cancel event.
 */
-   if (!xfer->flags_int.transferring) {
+   if (!xfer->flags_int.transferring &&
+   !xfer->flags_int.started) {
+   DPRINTF("Issuing fake completion event\n");
ugen_fs_set_complete(xfer->priv_sc,
USB_P2U(xfer->priv_fifo));
}
___
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: r348855 - stable/11/sys/dev/usb

2019-06-10 Thread Hans Petter Selasky
Author: hselasky
Date: Mon Jun 10 13:36:12 2019
New Revision: 348855
URL: https://svnweb.freebsd.org/changeset/base/348855

Log:
  MFC r348631:
  In usb(4) fix a lost completion event issue towards libusb(3). It may happen
  if a USB transfer is cancelled that we need to fake a completion event.
  Implement missing support in ugen_fs_copy_out() to handle this.
  
  This fixes issues with webcamd(8) and firefox.
  
  Approved by:  re (gjb)
  Sponsored by: Mellanox Technologies

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

Modified: stable/11/sys/dev/usb/usb_generic.c
==
--- stable/11/sys/dev/usb/usb_generic.c Mon Jun 10 13:34:18 2019
(r348854)
+++ stable/11/sys/dev/usb/usb_generic.c Mon Jun 10 13:36:12 2019
(r348855)
@@ -1217,6 +1217,40 @@ complete:
 }
 
 static int
+ugen_fs_copy_out_cancelled(struct usb_fs_endpoint *fs_ep_uptr)
+{
+   struct usb_fs_endpoint fs_ep;
+   int error;
+
+   error = copyin(fs_ep_uptr, _ep, sizeof(fs_ep));
+   if (error)
+   return (error);
+
+   fs_ep.status = USB_ERR_CANCELLED;
+   fs_ep.aFrames = 0;
+   fs_ep.isoc_time_complete = 0;
+
+   /* update "aFrames" */
+   error = copyout(_ep.aFrames, _ep_uptr->aFrames,
+   sizeof(fs_ep.aFrames));
+   if (error)
+   goto done;
+
+   /* update "isoc_time_complete" */
+   error = copyout(_ep.isoc_time_complete,
+   _ep_uptr->isoc_time_complete,
+   sizeof(fs_ep.isoc_time_complete));
+   if (error)
+   goto done;
+
+   /* update "status" */
+   error = copyout(_ep.status, _ep_uptr->status,
+   sizeof(fs_ep.status));
+done:
+   return (error);
+}
+
+static int
 ugen_fs_copy_out(struct usb_fifo *f, uint8_t ep_index)
 {
struct usb_device_request *req;
@@ -1241,8 +1275,13 @@ ugen_fs_copy_out(struct usb_fifo *f, uint8_t ep_index)
return (EINVAL);
 
mtx_lock(f->priv_mtx);
-   if (usbd_transfer_pending(xfer)) {
+   if (!xfer->flags_int.transferring &&
+   !xfer->flags_int.started) {
mtx_unlock(f->priv_mtx);
+   DPRINTF("Returning fake cancel event\n");
+   return (ugen_fs_copy_out_cancelled(f->fs_ep_ptr + ep_index));
+   } else if (usbd_transfer_pending(xfer)) {
+   mtx_unlock(f->priv_mtx);
return (EBUSY); /* should not happen */
}
mtx_unlock(f->priv_mtx);
@@ -1362,6 +1401,7 @@ complete:
sizeof(fs_ep.isoc_time_complete));
if (error)
goto done;
+
/* update "status" */
error = copyout(_ep.status, _ep_uptr->status,
sizeof(fs_ep.status));
@@ -1450,12 +1490,15 @@ ugen_ioctl(struct usb_fifo *f, u_long cmd, void *addr,
xfer = f->fs_xfer[u.pstart->ep_index];
if (usbd_transfer_pending(xfer)) {
usbd_transfer_stop(xfer);
+
/*
 * Check if the USB transfer was stopped
-* before it was even started. Else a cancel
-* callback will be pending.
+* before it was even started and fake a
+* cancel event.
 */
-   if (!xfer->flags_int.transferring) {
+   if (!xfer->flags_int.transferring &&
+   !xfer->flags_int.started) {
+   DPRINTF("Issuing fake completion event\n");
ugen_fs_set_complete(xfer->priv_sc,
USB_P2U(xfer->priv_fifo));
}
___
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: r348854 - head/libexec/rc/rc.d

2019-06-10 Thread Conrad Meyer
Author: cem
Date: Mon Jun 10 13:34:18 2019
New Revision: 348854
URL: https://svnweb.freebsd.org/changeset/base/348854

Log:
  /etc/rc.d/local: Fix typo in description
  
  PR:   238448
  Submitted by: Marián Černý 

Modified:
  head/libexec/rc/rc.d/local

Modified: head/libexec/rc/rc.d/local
==
--- head/libexec/rc/rc.d/local  Mon Jun 10 13:17:39 2019(r348853)
+++ head/libexec/rc/rc.d/local  Mon Jun 10 13:34:18 2019(r348854)
@@ -11,7 +11,7 @@
 . /etc/rc.subr
 
 name="local"
-desc="Run /etc/rc.local and /etc/shutdown.local"
+desc="Run /etc/rc.local and /etc/rc.shutdown.local"
 start_cmd="local_start"
 stop_cmd="local_stop"
 
___
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: r348853 - stable/10/sys/dev/usb/controller

2019-06-10 Thread Hans Petter Selasky
Author: hselasky
Date: Mon Jun 10 13:17:39 2019
New Revision: 348853
URL: https://svnweb.freebsd.org/changeset/base/348853

Log:
  MFC r348604:
  In xhci(4) there is no stream ID in the completion TRB.
  Instead iterate all the stream IDs in stream mode to find
  the matching USB transfer.
  
  Sponsored by: Mellanox Technologies

Modified:
  stable/10/sys/dev/usb/controller/xhci.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/dev/usb/controller/xhci.c
==
--- stable/10/sys/dev/usb/controller/xhci.c Mon Jun 10 13:16:49 2019
(r348852)
+++ stable/10/sys/dev/usb/controller/xhci.c Mon Jun 10 13:17:39 2019
(r348853)
@@ -895,7 +895,7 @@ xhci_check_transfer(struct xhci_softc *sc, struct xhci
uint64_t td_event;
uint32_t temp;
uint32_t remainder;
-   uint16_t stream_id;
+   uint16_t stream_id = 0;
uint16_t i;
uint8_t status;
uint8_t halted;
@@ -908,7 +908,6 @@ xhci_check_transfer(struct xhci_softc *sc, struct xhci
 
remainder = XHCI_TRB_2_REM_GET(temp);
status = XHCI_TRB_2_ERROR_GET(temp);
-   stream_id = XHCI_TRB_2_STREAM_GET(temp);
 
temp = le32toh(trb->dwTrb3);
epno = XHCI_TRB_3_EP_GET(temp);
@@ -918,8 +917,8 @@ xhci_check_transfer(struct xhci_softc *sc, struct xhci
halted = (status != XHCI_TRB_ERROR_SHORT_PKT &&
status != XHCI_TRB_ERROR_SUCCESS);
 
-   DPRINTF("slot=%u epno=%u stream=%u remainder=%u status=%u\n",
-   index, epno, stream_id, remainder, status);
+   DPRINTF("slot=%u epno=%u remainder=%u status=%u\n",
+   index, epno, remainder, status);
 
if (index > sc->sc_noslot) {
DPRINTF("Invalid slot.\n");
@@ -933,18 +932,19 @@ xhci_check_transfer(struct xhci_softc *sc, struct xhci
 
pepext = >sc_hw.devs[index].endp[epno];
 
-   if (pepext->trb_ep_mode != USB_EP_MODE_STREAMS) {
-   stream_id = 0;
-   DPRINTF("stream_id=0\n");
-   } else if (stream_id >= XHCI_MAX_STREAMS) {
-   DPRINTF("Invalid stream ID.\n");
-   return;
-   }
-
/* try to find the USB transfer that generated the event */
-   for (i = 0; i != (XHCI_MAX_TRANSFERS - 1); i++) {
+   for (i = 0;; i++) {
struct usb_xfer *xfer;
struct xhci_td *td;
+
+   if (i == (XHCI_MAX_TRANSFERS - 1)) {
+   if (pepext->trb_ep_mode != USB_EP_MODE_STREAMS ||
+   stream_id == (XHCI_MAX_STREAMS - 1))
+   break;
+   stream_id++;
+   i = 0;
+   DPRINTFN(5, "stream_id=%u\n", stream_id);
+   }
 
xfer = pepext->xfer[i + (XHCI_MAX_TRANSFERS * stream_id)];
if (xfer == 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: r348852 - stable/12/sys/dev/usb/controller

2019-06-10 Thread Hans Petter Selasky
Author: hselasky
Date: Mon Jun 10 13:16:49 2019
New Revision: 348852
URL: https://svnweb.freebsd.org/changeset/base/348852

Log:
  MFC r348604:
  In xhci(4) there is no stream ID in the completion TRB.
  Instead iterate all the stream IDs in stream mode to find
  the matching USB transfer.
  
  Sponsored by: Mellanox Technologies

Modified:
  stable/12/sys/dev/usb/controller/xhci.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/dev/usb/controller/xhci.c
==
--- stable/12/sys/dev/usb/controller/xhci.c Mon Jun 10 13:15:49 2019
(r348851)
+++ stable/12/sys/dev/usb/controller/xhci.c Mon Jun 10 13:16:49 2019
(r348852)
@@ -891,7 +891,7 @@ xhci_check_transfer(struct xhci_softc *sc, struct xhci
uint64_t td_event;
uint32_t temp;
uint32_t remainder;
-   uint16_t stream_id;
+   uint16_t stream_id = 0;
uint16_t i;
uint8_t status;
uint8_t halted;
@@ -904,7 +904,6 @@ xhci_check_transfer(struct xhci_softc *sc, struct xhci
 
remainder = XHCI_TRB_2_REM_GET(temp);
status = XHCI_TRB_2_ERROR_GET(temp);
-   stream_id = XHCI_TRB_2_STREAM_GET(temp);
 
temp = le32toh(trb->dwTrb3);
epno = XHCI_TRB_3_EP_GET(temp);
@@ -914,8 +913,8 @@ xhci_check_transfer(struct xhci_softc *sc, struct xhci
halted = (status != XHCI_TRB_ERROR_SHORT_PKT &&
status != XHCI_TRB_ERROR_SUCCESS);
 
-   DPRINTF("slot=%u epno=%u stream=%u remainder=%u status=%u\n",
-   index, epno, stream_id, remainder, status);
+   DPRINTF("slot=%u epno=%u remainder=%u status=%u\n",
+   index, epno, remainder, status);
 
if (index > sc->sc_noslot) {
DPRINTF("Invalid slot.\n");
@@ -929,18 +928,19 @@ xhci_check_transfer(struct xhci_softc *sc, struct xhci
 
pepext = >sc_hw.devs[index].endp[epno];
 
-   if (pepext->trb_ep_mode != USB_EP_MODE_STREAMS) {
-   stream_id = 0;
-   DPRINTF("stream_id=0\n");
-   } else if (stream_id >= XHCI_MAX_STREAMS) {
-   DPRINTF("Invalid stream ID.\n");
-   return;
-   }
-
/* try to find the USB transfer that generated the event */
-   for (i = 0; i != (XHCI_MAX_TRANSFERS - 1); i++) {
+   for (i = 0;; i++) {
struct usb_xfer *xfer;
struct xhci_td *td;
+
+   if (i == (XHCI_MAX_TRANSFERS - 1)) {
+   if (pepext->trb_ep_mode != USB_EP_MODE_STREAMS ||
+   stream_id == (XHCI_MAX_STREAMS - 1))
+   break;
+   stream_id++;
+   i = 0;
+   DPRINTFN(5, "stream_id=%u\n", stream_id);
+   }
 
xfer = pepext->xfer[i + (XHCI_MAX_TRANSFERS * stream_id)];
if (xfer == 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: r348851 - stable/11/sys/dev/usb/controller

2019-06-10 Thread Hans Petter Selasky
Author: hselasky
Date: Mon Jun 10 13:15:49 2019
New Revision: 348851
URL: https://svnweb.freebsd.org/changeset/base/348851

Log:
  MFC r348604:
  In xhci(4) there is no stream ID in the completion TRB.
  Instead iterate all the stream IDs in stream mode to find
  the matching USB transfer.
  
  Approved by:  re(kib)
  Sponsored by: Mellanox Technologies

Modified:
  stable/11/sys/dev/usb/controller/xhci.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/dev/usb/controller/xhci.c
==
--- stable/11/sys/dev/usb/controller/xhci.c Mon Jun 10 12:40:38 2019
(r348850)
+++ stable/11/sys/dev/usb/controller/xhci.c Mon Jun 10 13:15:49 2019
(r348851)
@@ -889,7 +889,7 @@ xhci_check_transfer(struct xhci_softc *sc, struct xhci
uint64_t td_event;
uint32_t temp;
uint32_t remainder;
-   uint16_t stream_id;
+   uint16_t stream_id = 0;
uint16_t i;
uint8_t status;
uint8_t halted;
@@ -902,7 +902,6 @@ xhci_check_transfer(struct xhci_softc *sc, struct xhci
 
remainder = XHCI_TRB_2_REM_GET(temp);
status = XHCI_TRB_2_ERROR_GET(temp);
-   stream_id = XHCI_TRB_2_STREAM_GET(temp);
 
temp = le32toh(trb->dwTrb3);
epno = XHCI_TRB_3_EP_GET(temp);
@@ -912,8 +911,8 @@ xhci_check_transfer(struct xhci_softc *sc, struct xhci
halted = (status != XHCI_TRB_ERROR_SHORT_PKT &&
status != XHCI_TRB_ERROR_SUCCESS);
 
-   DPRINTF("slot=%u epno=%u stream=%u remainder=%u status=%u\n",
-   index, epno, stream_id, remainder, status);
+   DPRINTF("slot=%u epno=%u remainder=%u status=%u\n",
+   index, epno, remainder, status);
 
if (index > sc->sc_noslot) {
DPRINTF("Invalid slot.\n");
@@ -927,18 +926,19 @@ xhci_check_transfer(struct xhci_softc *sc, struct xhci
 
pepext = >sc_hw.devs[index].endp[epno];
 
-   if (pepext->trb_ep_mode != USB_EP_MODE_STREAMS) {
-   stream_id = 0;
-   DPRINTF("stream_id=0\n");
-   } else if (stream_id >= XHCI_MAX_STREAMS) {
-   DPRINTF("Invalid stream ID.\n");
-   return;
-   }
-
/* try to find the USB transfer that generated the event */
-   for (i = 0; i != (XHCI_MAX_TRANSFERS - 1); i++) {
+   for (i = 0;; i++) {
struct usb_xfer *xfer;
struct xhci_td *td;
+
+   if (i == (XHCI_MAX_TRANSFERS - 1)) {
+   if (pepext->trb_ep_mode != USB_EP_MODE_STREAMS ||
+   stream_id == (XHCI_MAX_STREAMS - 1))
+   break;
+   stream_id++;
+   i = 0;
+   DPRINTFN(5, "stream_id=%u\n", stream_id);
+   }
 
xfer = pepext->xfer[i + (XHCI_MAX_TRANSFERS * stream_id)];
if (xfer == 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"


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

2019-06-10 Thread Shawn Webb
On Mon, Jun 10, 2019 at 03:07:11AM +, Doug Moore wrote:
> Author: dougm
> Date: Mon Jun 10 03:07:10 2019
> New Revision: 348843
> URL: https://svnweb.freebsd.org/changeset/base/348843
> 
> Log:
>   There are times when a len==0 parameter to mmap is okay. But on a
>   32-bit machine, a len parameter just a few bytes short of 4G, rounded
>   up to a page boundary and hitting zero then, is not okay. Return
>   failure in that case.
>   
>   Reported by: pho
>   Reviewed by: alc, kib (mentor)
>   Tested by: pho
>   Differential Revision: https://reviews.freebsd.org/D20580
> 
> Modified:
>   head/sys/vm/vm_mmap.c
> 
> Modified: head/sys/vm/vm_mmap.c
> ==
> --- head/sys/vm/vm_mmap.c Sun Jun  9 22:55:21 2019(r348842)
> +++ head/sys/vm/vm_mmap.c Mon Jun 10 03:07:10 2019(r348843)
> @@ -257,7 +257,10 @@ kern_mmap(struct thread *td, uintptr_t addr0, size_t s
>  
>   /* Adjust size for rounding (on both ends). */
>   size += pageoff;/* low end... */
> - size = (vm_size_t) round_page(size);/* hi end */
> + /* Check for rounding up to zero. */
> + if (round_page(size) < size)
> + return (EINVAL);

The mmap(2) manpage says that len==0 results in EINVAL, so the manpage
needs updating.

I'm curious what "there are times" refers to. Can you or the original
reporter elaborate those cases?

Thanks a lot!

-- 
Shawn Webb
Cofounder / Security Engineer
HardenedBSD

Tor-ified Signal:+1 443-546-8752
Tor+XMPP+OTR:latt...@is.a.hacker.sx
GPG Key ID:  0xFF2E67A277F8E1FA
GPG Key Fingerprint: D206 BB45 15E0 9C49 0CF9  3633 C85B 0AF8 AB23 0FB2


signature.asc
Description: PGP signature


svn commit: r348850 - stable/11/sys/contrib/ipfilter/netinet

2019-06-10 Thread Cy Schubert
Author: cy
Date: Mon Jun 10 12:40:38 2019
New Revision: 348850
URL: https://svnweb.freebsd.org/changeset/base/348850

Log:
  MFC r348575:
  
  Properly define the fourth argument to ipf_check, the main entry point
  into ipfilter. A proper definition simplifies dtrace scripts a little.
  
  Approved by:  re (delphij@)

Modified:
  stable/11/sys/contrib/ipfilter/netinet/fil.c
  stable/11/sys/contrib/ipfilter/netinet/ip_fil.h
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/contrib/ipfilter/netinet/fil.c
==
--- stable/11/sys/contrib/ipfilter/netinet/fil.cMon Jun 10 09:03:08 
2019(r348849)
+++ stable/11/sys/contrib/ipfilter/netinet/fil.cMon Jun 10 12:40:38 
2019(r348850)
@@ -2810,7 +2810,7 @@ ipf_check(ctx, ip, hlen, ifp, out
mb_t **mp;
ip_t *ip;
int hlen;
-   void *ifp;
+   struct ifnet *ifp;
int out;
void *ctx;
 {

Modified: stable/11/sys/contrib/ipfilter/netinet/ip_fil.h
==
--- stable/11/sys/contrib/ipfilter/netinet/ip_fil.h Mon Jun 10 09:03:08 
2019(r348849)
+++ stable/11/sys/contrib/ipfilter/netinet/ip_fil.h Mon Jun 10 12:40:38 
2019(r348850)
@@ -1655,7 +1655,7 @@ typedef struct ipf_main_softc_s {
} while (0)
 
 #ifndef_KERNEL
-extern int ipf_check __P((void *, struct ip *, int, void *, int, mb_t **));
+extern int ipf_check __P((void *, struct ip *, int, struct ifnet *, int, 
mb_t **));
 extern struct  ifnet *get_unit __P((char *, int));
 extern char*get_ifname __P((struct ifnet *));
 extern int ipfioctl __P((ipf_main_softc_t *, int, ioctlcmd_t,
@@ -1672,7 +1672,7 @@ externint ipl_enable __P((void));
 extern int ipl_disable __P((void));
 # ifdef MENTAT
 /* XXX MENTAT is always defined for Solaris */
-extern int ipf_check __P((void *, struct ip *, int, void *, int, void *,
+extern int ipf_check __P((void *, struct ip *, int, struct ifnet *, int, 
void *,
   mblk_t **));
 #  if SOLARIS
 extern voidipf_prependmbt(fr_info_t *, mblk_t *);
@@ -1681,7 +1681,7 @@ externint ipfioctl __P((dev_t, int, intptr_t, 
int, cr
 extern int ipf_qout __P((queue_t *, mblk_t *));
 # else /* MENTAT */
 /* XXX MENTAT is never defined for FreeBSD & NetBSD */
-extern int ipf_check __P((void *, struct ip *, int, void *, int, mb_t **));
+extern int ipf_check __P((void *, struct ip *, int, struct ifnet *, int, 
mb_t **));
 extern int (*fr_checkp) __P((ip_t *, int, void *, int, mb_t **));
 extern size_t  mbufchainlen __P((mb_t *));
 #   ifdef  IPFILTER_LKM
___
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: r348847 - head/sys/sys

2019-06-10 Thread Tijl Coosemans
On Mon, 10 Jun 2019 05:28:04 + (UTC) Dmitry Chagin
 wrote:
> Author: dchagin
> Date: Mon Jun 10 05:28:03 2019
> New Revision: 348847
> URL: https://svnweb.freebsd.org/changeset/base/348847
> 
> Log:
>   Use C11 anonymous unions.
>   
>   PR: 215202
>   Reported by:glebius
>   MFC after:  2 weeks
> 
> Modified:
>   head/sys/sys/ucred.h
> 
> Modified: head/sys/sys/ucred.h
> ==
> --- head/sys/sys/ucred.h  Mon Jun 10 05:09:34 2019(r348846)
> +++ head/sys/sys/ucred.h  Mon Jun 10 05:28:03 2019(r348847)
> @@ -89,12 +89,11 @@ struct xucred {
>   gid_t   cr_groups[XU_NGROUPS];  /* groups */
>   union {
>   void*_cr_unused1;   /* compatibility with old ucred */
> - pid_t   _pid;
> - } _cr;
> + pid_t   cr_pid;
> + };
>  };
>  #define  XUCRED_VERSION  0
>  
> -#define  cr_pid _cr._pid
>  /* This can be used for both ucred and xucred structures. */
>  #define  cr_gid cr_groups[0]

Isn't this a userland header that should work with non-C11 compilers?
___
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: r348849 - stable/12/sys/ofed/drivers/infiniband/core

2019-06-10 Thread Slava Shwartsman
Author: slavash
Date: Mon Jun 10 09:03:08 2019
New Revision: 348849
URL: https://svnweb.freebsd.org/changeset/base/348849

Log:
  MFC r348601:
  Fix prio vs. nonprio tagged traffic in RDMACM
  
  In current RDMACM implementation RDMACM server will not find a GID
  index when the request was prio-tagged and the sever is non
  prio-tagged and vise-versa.
  According to 802.1Q-2014, VLAN tagged packets with VLAN id 0 should
  be considered as untagged. Treat RDMACM request the same.
  
  Reviewed by:hselasky, kib
  Sponsored by:   Mellanox Technologies

Modified:
  stable/12/sys/ofed/drivers/infiniband/core/ib_verbs.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/ofed/drivers/infiniband/core/ib_verbs.c
==
--- stable/12/sys/ofed/drivers/infiniband/core/ib_verbs.c   Mon Jun 10 
07:12:46 2019(r348848)
+++ stable/12/sys/ofed/drivers/infiniband/core/ib_verbs.c   Mon Jun 10 
09:03:08 2019(r348849)
@@ -414,18 +414,32 @@ struct find_gid_index_context {
enum ib_gid_type gid_type;
 };
 
+
+/*
+ * This function will return true only if a inspected GID index
+ * matches the request based on the GID type and VLAN configuration
+ */
 static bool find_gid_index(const union ib_gid *gid,
   const struct ib_gid_attr *gid_attr,
   void *context)
 {
+   u16 vlan_diff;
struct find_gid_index_context *ctx =
(struct find_gid_index_context *)context;
 
if (ctx->gid_type != gid_attr->gid_type)
return false;
-   if (rdma_vlan_dev_vlan_id(gid_attr->ndev) != ctx->vlan_id)
-   return false;
-   return true;
+
+   /*
+* The following will verify:
+* 1. VLAN ID matching for VLAN tagged requests.
+* 2. prio-tagged/untagged to prio-tagged/untagged matching.
+*
+* This XOR is valid, since 0x0 < vlan_id < 0x0FFF.
+*/
+   vlan_diff = rdma_vlan_dev_vlan_id(gid_attr->ndev) ^ ctx->vlan_id;
+
+   return (vlan_diff == 0x || vlan_diff == 0x);
 }
 
 static int get_sgid_index_from_eth(struct ib_device *device, u8 port_num,
___
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: r348843 - head/sys/vm

2019-06-10 Thread Andriy Gapon
On 10/06/2019 09:42, Doug Moore wrote:
> -fwrapv concerns signed arithmetic.  This calculation is with unsigned
> arithmetic, and the possibility of wrapping around to 0 is part of the
> language.

Oh, sorry for the noise!

> On 6/10/19 1:35 AM, Andriy Gapon wrote:
>> On 10/06/2019 06:07, Doug Moore wrote:
>>> Author: dougm
>>> Date: Mon Jun 10 03:07:10 2019
>>> New Revision: 348843
>>> URL: https://svnweb.freebsd.org/changeset/base/348843
>>>
>>> Log:
>>>   There are times when a len==0 parameter to mmap is okay. But on a
>>>   32-bit machine, a len parameter just a few bytes short of 4G, rounded
>>>   up to a page boundary and hitting zero then, is not okay. Return
>>>   failure in that case.
>>>   
>>>   Reported by: pho
>>>   Reviewed by: alc, kib (mentor)
>>>   Tested by: pho
>>>   Differential Revision: https://reviews.freebsd.org/D20580
>>>
>>> Modified:
>>>   head/sys/vm/vm_mmap.c
>>>
>>> Modified: head/sys/vm/vm_mmap.c
>>> ==
>>> --- head/sys/vm/vm_mmap.c   Sun Jun  9 22:55:21 2019(r348842)
>>> +++ head/sys/vm/vm_mmap.c   Mon Jun 10 03:07:10 2019(r348843)
>>> @@ -257,7 +257,10 @@ kern_mmap(struct thread *td, uintptr_t addr0, size_t s
>>>  
>>> /* Adjust size for rounding (on both ends). */
>>> size += pageoff;/* low end... */
>>> -   size = (vm_size_t) round_page(size);/* hi end */
>>> +   /* Check for rounding up to zero. */
>>> +   if (round_page(size) < size)
>> Is this guaranteed to work with all compilers?
>> I think that some smart compilers may think that this condition is 
>> impossible.
>> Are we finally using -fwrapv or something like it for kernel builds?
>>
>>> +   return (EINVAL);
>>> +   size = round_page(size);/* hi end */
>>>  
>>> /* Ensure alignment is at least a page and fits in a pointer. */
>>> align = flags & MAP_ALIGNMENT_MASK;
>>>
>>


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


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

2019-06-10 Thread Bruce Evans

On Mon, 10 Jun 2019, Doug Moore wrote:


Log:
 There are times when a len==0 parameter to mmap is okay. But on a
 32-bit machine, a len parameter just a few bytes short of 4G, rounded
 up to a page boundary and hitting zero then, is not okay. Return
 failure in that case.


Some overflows still occur.

The problem is not limited to 32-bit machines.  The first overflow is for
len parameter just a few bytes short of SIZE_MAX added to a page offset of
a few bytes.  This overflows to a small value.  Then rounding up to a page
boundary doesn't overflow, but gives 0 or PAGE_SIZE, so the new overflow
check doesn't work and overflow still occurs.

The second overflow is for a len parameter just a few bytes short of
SIZE_MAX with the first overflow not occurring (usually because the offset
is 0).  This is now detected.


 Reported by: pho
 Reviewed by: alc, kib (mentor)
 Tested by: pho
 Differential Revision: https://reviews.freebsd.org/D20580

Modified:
 head/sys/vm/vm_mmap.c

Modified: head/sys/vm/vm_mmap.c
==
--- head/sys/vm/vm_mmap.c   Sun Jun  9 22:55:21 2019(r348842)
+++ head/sys/vm/vm_mmap.c   Mon Jun 10 03:07:10 2019(r348843)
@@ -257,7 +257,10 @@ kern_mmap(struct thread *td, uintptr_t addr0, size_t s

/* Adjust size for rounding (on both ends). */
size += pageoff;/* low end... */


The first overflow occurs here.  Except in special cases, pageoff can be
anything between 0 and PAGE_SIZE - 1, and size can be anything between 0
and SIZE_MAX.


-   size = (vm_size_t) round_page(size);/* hi end */
+   /* Check for rounding up to zero. */
+   if (round_page(size) < size)
+   return (EINVAL);
+   size = round_page(size);/* hi end */

/* Ensure alignment is at least a page and fits in a pointer. */
align = flags & MAP_ALIGNMENT_MASK;


This bug was implemented in r239247 and affects all versions of FreeBSD
newer than FreeBSD-7.  Before then, FreeBSD used the bogus 4.4BSD check
that (ssize_t)uap->len >= 0 (else return EINVAL).  This behaviour was
even documented.  POSIX doesn't allow this -- it requires ENOMEM for
invalid ranges, though it should require EOVERFLOW for ranges that are
so invalid that they overflow something.

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


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

2019-06-10 Thread Doug Moore
-fwrapv concerns signed arithmetic.  This calculation is with unsigned
arithmetic, and the possibility of wrapping around to 0 is part of the
language.

Doug Moore

On 6/10/19 1:35 AM, Andriy Gapon wrote:
> On 10/06/2019 06:07, Doug Moore wrote:
>> Author: dougm
>> Date: Mon Jun 10 03:07:10 2019
>> New Revision: 348843
>> URL: https://svnweb.freebsd.org/changeset/base/348843
>>
>> Log:
>>   There are times when a len==0 parameter to mmap is okay. But on a
>>   32-bit machine, a len parameter just a few bytes short of 4G, rounded
>>   up to a page boundary and hitting zero then, is not okay. Return
>>   failure in that case.
>>   
>>   Reported by: pho
>>   Reviewed by: alc, kib (mentor)
>>   Tested by: pho
>>   Differential Revision: https://reviews.freebsd.org/D20580
>>
>> Modified:
>>   head/sys/vm/vm_mmap.c
>>
>> Modified: head/sys/vm/vm_mmap.c
>> ==
>> --- head/sys/vm/vm_mmap.cSun Jun  9 22:55:21 2019(r348842)
>> +++ head/sys/vm/vm_mmap.cMon Jun 10 03:07:10 2019(r348843)
>> @@ -257,7 +257,10 @@ kern_mmap(struct thread *td, uintptr_t addr0, size_t s
>>  
>>  /* Adjust size for rounding (on both ends). */
>>  size += pageoff;/* low end... */
>> -size = (vm_size_t) round_page(size);/* hi end */
>> +/* Check for rounding up to zero. */
>> +if (round_page(size) < size)
> Is this guaranteed to work with all compilers?
> I think that some smart compilers may think that this condition is impossible.
> Are we finally using -fwrapv or something like it for kernel builds?
>
>> +return (EINVAL);
>> +size = round_page(size);/* hi end */
>>  
>>  /* Ensure alignment is at least a page and fits in a pointer. */
>>  align = flags & MAP_ALIGNMENT_MASK;
>>
>
___
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: r348843 - head/sys/vm

2019-06-10 Thread Andriy Gapon
On 10/06/2019 06:07, Doug Moore wrote:
> Author: dougm
> Date: Mon Jun 10 03:07:10 2019
> New Revision: 348843
> URL: https://svnweb.freebsd.org/changeset/base/348843
> 
> Log:
>   There are times when a len==0 parameter to mmap is okay. But on a
>   32-bit machine, a len parameter just a few bytes short of 4G, rounded
>   up to a page boundary and hitting zero then, is not okay. Return
>   failure in that case.
>   
>   Reported by: pho
>   Reviewed by: alc, kib (mentor)
>   Tested by: pho
>   Differential Revision: https://reviews.freebsd.org/D20580
> 
> Modified:
>   head/sys/vm/vm_mmap.c
> 
> Modified: head/sys/vm/vm_mmap.c
> ==
> --- head/sys/vm/vm_mmap.c Sun Jun  9 22:55:21 2019(r348842)
> +++ head/sys/vm/vm_mmap.c Mon Jun 10 03:07:10 2019(r348843)
> @@ -257,7 +257,10 @@ kern_mmap(struct thread *td, uintptr_t addr0, size_t s
>  
>   /* Adjust size for rounding (on both ends). */
>   size += pageoff;/* low end... */
> - size = (vm_size_t) round_page(size);/* hi end */
> + /* Check for rounding up to zero. */
> + if (round_page(size) < size)

Is this guaranteed to work with all compilers?
I think that some smart compilers may think that this condition is impossible.
Are we finally using -fwrapv or something like it for kernel builds?

> + return (EINVAL);
> + size = round_page(size);/* hi end */
>  
>   /* Ensure alignment is at least a page and fits in a pointer. */
>   align = flags & MAP_ALIGNMENT_MASK;
> 


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