svn commit: r356540 - head/sys/kern

2020-01-08 Thread Kyle Evans
Author: kevans
Date: Thu Jan  9 06:10:25 2020
New Revision: 356540
URL: https://svnweb.freebsd.org/changeset/base/356540

Log:
  kern/Makefile: systrace_args.c is also generated

Modified:
  head/sys/kern/Makefile

Modified: head/sys/kern/Makefile
==
--- head/sys/kern/Makefile  Thu Jan  9 04:39:37 2020(r356539)
+++ head/sys/kern/Makefile  Thu Jan  9 06:10:25 2020(r356540)
@@ -13,6 +13,7 @@ SRCS= capabilities.conf   \
syscalls.master
 GENERATED= init_sysent.c   \
syscalls.c  \
+   systrace_args.c \
../sys/syscall.h\
../sys/syscall.mk   \
../sys/sysproto.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"


Re: svn commit: r354606 - in head: contrib/jemalloc contrib/jemalloc/doc contrib/jemalloc/include/jemalloc contrib/jemalloc/include/jemalloc/internal contrib/jemalloc/src lib/libc/stdlib/jemalloc

2020-01-08 Thread Bryan Drewery
Do you plan to get this back in soon? I hope to see it before 12.2 if
possible. Is there some way I can help?

I'm interested in these changes in 5.2.1 (I think)
  - Properly trigger decay on tcache destroy.  (@interwq, @amosbird)
  - Fix tcache.flush.  (@interwq)
  - Fix a side effect caused by extent_max_active_fit combined with
decay-based purging, where freed extents can accumulate and not be
reused for an extended period of time.  (@interwq, @mpghf)

I have a test case where virtual memory was peaking at 275M on 4.x, 1GB
on 5.0.0, around 750M on 5.1.0, and finally 275M again on 5.2.0. The
5.0/5.1 versions appeared to be a widespread leak to us.

On 11/10/2019 9:06 PM, Jason Evans wrote:
> Author: jasone
> Date: Mon Nov 11 05:06:49 2019
> New Revision: 354606
> URL: https://svnweb.freebsd.org/changeset/base/354606
> 
> Log:
>   Revert r354605: Update jemalloc to version 5.2.1.
>   
>   Compilation fails for non-llvm-based platforms.


-- 
Regards,
Bryan Drewery



signature.asc
Description: OpenPGP digital signature


svn commit: r356539 - head/share/man/man4

2020-01-08 Thread Kyle Evans
Author: kevans
Date: Thu Jan  9 04:39:37 2020
New Revision: 356539
URL: https://svnweb.freebsd.org/changeset/base/356539

Log:
  md(4): improve documentation of preloading
  
  It's not immediately clear by what mechanism loader(8) will be loading the
  preloaded file. Specifically name-drop loader.conf(5) with a pointer to the
  module loading section and a description of what the 'name' should look
  like, because that certainly isn't clear from the loader.conf(5) standpoint.
  
  The default loader.conf already has a pointer to md(4) where it appears and
  the reference to loader.conf in the new version of this manpage should make
  it more clear that this is where one should look for information.
  
  Reported by:  swills
  Reviewed by:  swills, manpages (bcr)
  With revision by: imp
  MFC after:3 days
  Differential Revision:https://reviews.freebsd.org/D22844

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

Modified: head/share/man/man4/md.4
==
--- head/share/man/man4/md.4Thu Jan  9 04:34:42 2020(r356538)
+++ head/share/man/man4/md.4Thu Jan  9 04:39:37 2020(r356539)
@@ -7,7 +7,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd December 26, 2017
+.Dd January 8, 2020
 .Dt MD 4
 .Os
 .Sh NAME
@@ -46,7 +46,7 @@ system.
 The exact value can be determined with
 .Xr vmstat 8 .
 .It Cm preload
-A file loaded by
+A module loaded by
 .Xr loader 8
 with type
 .Sq md_image
@@ -54,6 +54,12 @@ is used for backing store.
 For backwards compatibility the type
 .Sq mfs_root
 is also recognized.
+See the description of module loading directives in
+.Xr loader.conf 5
+and note that the module name will either be an absolute path to the image file
+or the name of a file in the
+.Va module_path .
+.Pp
 If the kernel is created with option
 .Dv MD_ROOT
 the first preloaded image found will become the root file system.
___
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: r356538 - in head/stand: fdt uboot/fdt

2020-01-08 Thread Kyle Evans
Author: kevans
Date: Thu Jan  9 04:34:42 2020
New Revision: 356538
URL: https://svnweb.freebsd.org/changeset/base/356538

Log:
  stand/fdt: Scale blob size better as overlays apply
  
  Currently, our overlay blob will grow to include the size of the complete
  overlay blob we're applying. This doesn't scale very well with a lot of
  overlays- they tend to include a lot of overhead, and they will generally
  only add a fraction of their total size to the blob they're being applied
  to.
  
  To combat this, pack the blob as we apply new overlays and keep track of how
  many overlays we've applied. Only ubldr has any fixups to be applied after
  overlays, so we only need to re-pad the blob in ubldr. Presumably the
  allocation won't fail since we just did a lot worse in trying to apply
  overlays and succeeded.
  
  I have no intention of removing the padding in make_dtb.sh. There might be
  an argument to be had over whether it should be configurable, since ubldr
  *is* the only loader that actually has fixups to be applied and we can do
  this at runtime, but I'm not too concerned about this.
  
  This diff has been sitting in Phabricator for a year and a half, but I've
  decided to flush it as it does make sure that we're scaling the blob
  appropriately and leave room at the end for fixups in case of some freak
  circumstance where applying overlays leaves us with a blob of insufficient
  size.
  
  Reviewed by:  gonzo (a long time ago)
  MFC after:1 week
  Differential Revision:https://reviews.freebsd.org/D14133

Modified:
  head/stand/fdt/fdt_loader_cmd.c
  head/stand/fdt/fdt_platform.h
  head/stand/uboot/fdt/uboot_fdt.c

Modified: head/stand/fdt/fdt_loader_cmd.c
==
--- head/stand/fdt/fdt_loader_cmd.c Thu Jan  9 04:03:17 2020
(r356537)
+++ head/stand/fdt/fdt_loader_cmd.c Thu Jan  9 04:34:42 2020
(r356538)
@@ -427,7 +427,10 @@ fdt_check_overlay_compatible(void *base_fdt, void *ove
return (1);
 }
 
-void
+/*
+ * Returns the number of overlays successfully applied
+ */
+int
 fdt_apply_overlays()
 {
struct preloaded_file *fp;
@@ -436,13 +439,13 @@ fdt_apply_overlays()
void *current_fdtp;
void *next_fdtp;
void *overlay;
-   int rv;
+   int overlays_applied, rv;
 
if ((fdtp == NULL) || (fdtp_size == 0))
-   return;
+   return (0);
 
if (fdt_overlays_applied)
-   return;
+   return (0);
 
max_overlay_size = 0;
for (fp = file_findfile(NULL, "dtbo"); fp != NULL; fp = fp->f_next) {
@@ -452,15 +455,16 @@ fdt_apply_overlays()
 
/* Nothing to apply */
if (max_overlay_size == 0)
-   return;
+   return (0);
 
overlay = malloc(max_overlay_size);
if (overlay == NULL) {
printf("failed to allocate memory for DTB blob with 
overlays\n");
-   return;
+   return (0);
}
current_fdtp = fdtp;
current_fdtp_size = fdtp_size;
+   overlays_applied = 0;
for (fp = file_findfile(NULL, "dtbo"); fp != NULL; fp = fp->f_next) {
COPYOUT(fp->f_addr, overlay, fp->f_size);
/* Check compatible first to avoid unnecessary allocation */
@@ -493,7 +497,9 @@ fdt_apply_overlays()
if (current_fdtp != fdtp)
free(current_fdtp);
current_fdtp = next_fdtp;
-   current_fdtp_size = next_fdtp_size;
+   fdt_pack(current_fdtp);
+   current_fdtp_size = fdt_totalsize(current_fdtp);
+   overlays_applied++;
} else {
/*
 * Assume here that the base we tried to apply on is
@@ -513,6 +519,26 @@ fdt_apply_overlays()
}
free(overlay);
fdt_overlays_applied = 1;
+   return (overlays_applied);
+}
+
+int
+fdt_pad_dtb(size_t padding)
+{
+   void *padded_fdtp;
+   size_t padded_fdtp_size;
+
+   padded_fdtp_size = fdtp_size + padding;
+   padded_fdtp = malloc(padded_fdtp_size);
+   if (padded_fdtp == NULL)
+   return (1);
+   if (fdt_open_into(fdtp, padded_fdtp, padded_fdtp_size) != 0) {
+   free(padded_fdtp);
+   return (1);
+   }
+   fdtp = padded_fdtp;
+   fdtp_size = padded_fdtp_size;
+   return (0);
 }
 
 int

Modified: head/stand/fdt/fdt_platform.h
==
--- head/stand/fdt/fdt_platform.h   Thu Jan  9 04:03:17 2020
(r356537)
+++ head/stand/fdt/fdt_platform.h   Thu Jan  9 04:34:42 2020
(r356538)
@@ -43,7 +43,8 @@ void fdt_fixup_cpubusfreqs(unsigned long, unsigned lon
 void fdt_fixup_ethernet(const char *, char *, int);
 void fdt_fixup_memory(struct 

svn commit: r356537 - head/sys/kern

2020-01-08 Thread Kyle Evans
Author: kevans
Date: Thu Jan  9 04:03:17 2020
New Revision: 356537
URL: https://svnweb.freebsd.org/changeset/base/356537

Log:
  shmfd: posix_fallocate(2): only take rangelock for section we need
  
  Other mechanisms that resize the shmfd grab a write lock from 0 to OFF_MAX
  for safety, so we still get proper synchronization of shmfd->shm_size in
  effect. There's no need to block readers/writers of earlier segments when
  we're just reserving more space, so narrow the scope -- it would likely be
  safe to narrow it completely to just the section of the range that extends
  beyond our current size, but this likely isn't worth it since the size isn't
  stable until the writelock is granted the first time.
  
  Suggested by: cem (passing comment)

Modified:
  head/sys/kern/uipc_shm.c

Modified: head/sys/kern/uipc_shm.c
==
--- head/sys/kern/uipc_shm.cThu Jan  9 03:52:50 2020(r356536)
+++ head/sys/kern/uipc_shm.cThu Jan  9 04:03:17 2020(r356537)
@@ -1451,7 +1451,17 @@ shm_fallocate(struct file *fp, off_t offset, off_t len
error = 0;
shmfd = fp->f_data;
size = offset + len;
-   rl_cookie = rangelock_wlock(>shm_rl, 0, OFF_MAX,
+
+   /*
+* Just grab the rangelock for the range that we may be attempting to
+* grow, rather than blocking read/write for regions we won't be
+* touching while this (potential) resize is in progress.  Other
+* attempts to resize the shmfd will have to take a write lock from 0 to
+* OFF_MAX, so this being potentially beyond the current usable range of
+* the shmfd is not necessarily a concern.  If other mechanisms are
+* added to grow a shmfd, this may need to be re-evaluated.
+*/
+   rl_cookie = rangelock_wlock(>shm_rl, offset, size,
>shm_mtx);
if (size > shmfd->shm_size) {
VM_OBJECT_WLOCK(shmfd->shm_object);
___
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: r356536 - head/sys/net

2020-01-08 Thread Kyle Evans
Author: kevans
Date: Thu Jan  9 03:52:50 2020
New Revision: 356536
URL: https://svnweb.freebsd.org/changeset/base/356536

Log:
  if_vmove: return proper error status
  
  if_vmove can fail if it lost a race and the vnet's already been moved. The
  callers (and their callers) can generally cope with this, but right now
  success is assumed. Plumb out the ENOENT from if_detach_internal if it
  happens so that the error's properly reported to userland.
  
  Reviewed by:  bz, kp
  MFC after:1 week
  Differential Revision:https://reviews.freebsd.org/D22780

Modified:
  head/sys/net/if.c

Modified: head/sys/net/if.c
==
--- head/sys/net/if.c   Thu Jan  9 02:03:17 2020(r356535)
+++ head/sys/net/if.c   Thu Jan  9 03:52:50 2020(r356536)
@@ -274,7 +274,7 @@ static void if_attach_internal(struct ifnet *, int, st
 static int if_detach_internal(struct ifnet *, int, struct if_clone **);
 static voidif_siocaddmulti(void *, int);
 #ifdef VIMAGE
-static voidif_vmove(struct ifnet *, struct vnet *);
+static int if_vmove(struct ifnet *, struct vnet *);
 #endif
 
 #ifdef INET6
@@ -1257,7 +1257,7 @@ finish_vnet_shutdown:
  * unused if_index in target vnet and calls if_grow() if necessary,
  * and finally find an unused if_xname for the target vnet.
  */
-static void
+static int
 if_vmove(struct ifnet *ifp, struct vnet *new_vnet)
 {
struct if_clone *ifc;
@@ -1283,7 +1283,7 @@ if_vmove(struct ifnet *ifp, struct vnet *new_vnet)
 */
rc = if_detach_internal(ifp, 1, );
if (rc != 0)
-   return;
+   return (rc);
 
/*
 * Unlink the ifnet from ifindex_table[] in current vnet, and shrink
@@ -1327,6 +1327,7 @@ if_vmove(struct ifnet *ifp, struct vnet *new_vnet)
 #endif
 
CURVNET_RESTORE();
+   return (0);
 }
 
 /*
@@ -1337,6 +1338,7 @@ if_vmove_loan(struct thread *td, struct ifnet *ifp, ch
 {
struct prison *pr;
struct ifnet *difp;
+   int error;
 
/* Try to find the prison within our visibility. */
sx_slock(_lock);
@@ -1372,13 +1374,14 @@ if_vmove_loan(struct thread *td, struct ifnet *ifp, ch
CURVNET_RESTORE();
 
/* Move the interface into the child jail/vnet. */
-   if_vmove(ifp, pr->pr_vnet);
+   error = if_vmove(ifp, pr->pr_vnet);
 
-   /* Report the new if_xname back to the userland. */
-   sprintf(ifname, "%s", ifp->if_xname);
+   /* Report the new if_xname back to the userland on success. */
+   if (error == 0)
+   sprintf(ifname, "%s", ifp->if_xname);
 
prison_free(pr);
-   return (0);
+   return (error);
 }
 
 static int
@@ -1387,6 +1390,7 @@ if_vmove_reclaim(struct thread *td, char *ifname, int 
struct prison *pr;
struct vnet *vnet_dst;
struct ifnet *ifp;
+   int error;
 
/* Try to find the prison within our visibility. */
sx_slock(_lock);
@@ -1422,14 +1426,15 @@ if_vmove_reclaim(struct thread *td, char *ifname, int 
}
 
/* Get interface back from child jail/vnet. */
-   if_vmove(ifp, vnet_dst);
+   error = if_vmove(ifp, vnet_dst);
CURVNET_RESTORE();
 
-   /* Report the new if_xname back to the userland. */
-   sprintf(ifname, "%s", ifp->if_xname);
+   /* Report the new if_xname back to the userland on success. */
+   if (error == 0)
+   sprintf(ifname, "%s", ifp->if_xname);
 
prison_free(pr);
-   return (0);
+   return (error);
 }
 #endif /* VIMAGE */
 
___
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: r356534 - in head: share/man/man9 sys/arm/arm sys/vm

2020-01-08 Thread Ryan Libby
Author: rlibby
Date: Thu Jan  9 02:03:03 2020
New Revision: 356534
URL: https://svnweb.freebsd.org/changeset/base/356534

Log:
  uma: reorganize flags
  
   - Garbage collect UMA_ZONE_PAGEABLE & UMA_ZONE_STATIC.
   - Move flag VTOSLAB from public to private.
   - Introduce public NOTPAGE flag and make HASH private.
   - Introduce public NOTOUCH flag and make OFFPAGE private.
   - Update man page.
  
  The net effect of this should be to make the contract with clients more
  clear.  Clients should choose constraints, UMA will figure out how to
  implement them.  This also breaks the confusing double meaning of
  OFFPAGE.
  
  Reviewed by:  jeff, markj
  Sponsored by: Dell EMC Isilon
  Differential Revision:https://reviews.freebsd.org/D23016

Modified:
  head/share/man/man9/zone.9
  head/sys/arm/arm/busdma_machdep-v6.c
  head/sys/vm/uma.h
  head/sys/vm/uma_core.c
  head/sys/vm/uma_int.h

Modified: head/share/man/man9/zone.9
==
--- head/share/man/man9/zone.9  Thu Jan  9 01:17:01 2020(r356533)
+++ head/share/man/man9/zone.9  Thu Jan  9 02:03:03 2020(r356534)
@@ -25,7 +25,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd November 22, 2019
+.Dd January 8, 2020
 .Dt UMA 9
 .Os
 .Sh NAME
@@ -292,18 +292,12 @@ To obtain zeroed memory from a PCPU zone, use the
 .Fn uma_zalloc_pcpu
 function and its variants instead, and pass
 .Dv M_ZERO .
-.It Dv UMA_ZONE_OFFPAGE
-By default book-keeping of items within a slab is done in the slab page itself.
-This flag explicitly tells subsystem that book-keeping structure should be
-allocated separately from special internal zone.
-This flag requires either
-.Dv UMA_ZONE_VTOSLAB
-or
-.Dv UMA_ZONE_HASH ,
-since subsystem requires a mechanism to find a book-keeping structure
-to an item being freed.
-The subsystem may choose to prefer offpage book-keeping for certain zones
-implicitly.
+.It Dv UMA_ZONE_NOTOUCH
+The UMA subsystem may not directly touch (i.e. read or write) the slab memory.
+Otherwise, by default, book-keeping of items within a slab may be done in the
+slab page itself, and
+.Dv INVARIANTS
+kernels may also do use-after-free checking by accessing the slab memory.
 .It Dv UMA_ZONE_ZINIT
 The zone will have its
 .Ft uma_init
@@ -317,13 +311,11 @@ A zone with
 .Dv UMA_ZONE_ZINIT
 flag would not return zeroed memory on every
 .Fn uma_zalloc .
-.It Dv UMA_ZONE_HASH
-The zone should use an internal hash table to find slab book-keeping
-structure where an allocation being freed belongs to.
-.It Dv UMA_ZONE_VTOSLAB
-The zone should use special field of
-.Vt vm_page_t
-to find slab book-keeping structure where an allocation being freed belongs to.
+.It Dv UMA_ZONE_NOTPAGE
+An allocator function will be supplied with
+.Fn uma_zone_set_allocf
+and the memory that it returns may not be kernel virtual memory backed by VM
+pages in the page array.
 .It Dv UMA_ZONE_MALLOC
 The zone is for the
 .Xr malloc 9

Modified: head/sys/arm/arm/busdma_machdep-v6.c
==
--- head/sys/arm/arm/busdma_machdep-v6.cThu Jan  9 01:17:01 2020
(r356533)
+++ head/sys/arm/arm/busdma_machdep-v6.cThu Jan  9 02:03:03 2020
(r356534)
@@ -244,7 +244,7 @@ busdma_init(void *dummy)
 * atomic ops on uma_slab_t fields and safety of this
 * operation is not guaranteed for write-back caches
 */
-   uma_flags = UMA_ZONE_OFFPAGE;
+   uma_flags = UMA_ZONE_NOTOUCH;
 #endif
/*
 * Create a cache of buffers in uncacheable memory, to implement the

Modified: head/sys/vm/uma.h
==
--- head/sys/vm/uma.h   Thu Jan  9 01:17:01 2020(r356533)
+++ head/sys/vm/uma.h   Thu Jan  9 02:03:03 2020(r356534)
@@ -232,14 +232,10 @@ uma_zone_t uma_zcache_create(char *name, int size, uma
  * Definitions for uma_zcreate flags
  *
  * These flags share space with UMA_ZFLAGs in uma_int.h.  Be careful not to
- * overlap when adding new features.  0xff00 is in use by uma_int.h.
+ * overlap when adding new features.
  */
-#define UMA_ZONE_PAGEABLE  0x0001  /* Return items not fully backed by
-  physical memory XXX Not yet */
 #define UMA_ZONE_ZINIT 0x0002  /* Initialize with zeros */
-#define UMA_ZONE_STATIC0x0004  /* Statically sized zone */
-#define UMA_ZONE_OFFPAGE   0x0008  /* Force the slab structure allocation
-  off of the real memory */
+#define UMA_ZONE_NOTOUCH   0x0008  /* UMA may not access the memory */
 #define UMA_ZONE_MALLOC0x0010  /* For use by malloc(9) only! */
 #define UMA_ZONE_NOFREE0x0020  /* Do not free slabs of this 
type! */
 #define UMA_ZONE_MTXCLASS  0x0040  /* Create a new lock class */
@@ -247,20 +243,17 @@ uma_zone_t uma_zcache_create(char 

svn commit: r356535 - head/sys/vm

2020-01-08 Thread Ryan Libby
Author: rlibby
Date: Thu Jan  9 02:03:17 2020
New Revision: 356535
URL: https://svnweb.freebsd.org/changeset/base/356535

Log:
  uma: unify layout paths and improve efficiency
  
  Unify the keg layout selection paths (keg_small_init, keg_large_init,
  keg_cachespread_init), and slightly improve memory efficiecy by:
   - using the padding of the final item to store the slab header,
   - not going OFFPAGE if we have a choice unless it improves efficiency.
  
  Reviewed by:  jeff, markj
  Sponsored by: Dell EMC Isilon
  Differential Revision:https://reviews.freebsd.org/D23048

Modified:
  head/sys/vm/uma_core.c
  head/sys/vm/uma_int.h

Modified: head/sys/vm/uma_core.c
==
--- head/sys/vm/uma_core.c  Thu Jan  9 02:03:03 2020(r356534)
+++ head/sys/vm/uma_core.c  Thu Jan  9 02:03:17 2020(r356535)
@@ -258,8 +258,6 @@ static void keg_dtor(void *, int, void *);
 static int zone_ctor(void *, int, void *, int);
 static void zone_dtor(void *, int, void *);
 static int zero_init(void *, int, int);
-static void keg_small_init(uma_keg_t keg);
-static void keg_large_init(uma_keg_t keg);
 static void zone_foreach(void (*zfunc)(uma_zone_t, void *), void *);
 static void zone_timeout(uma_zone_t zone, void *);
 static int hash_alloc(struct uma_hash *, u_int);
@@ -1669,27 +1667,61 @@ slab_space(int nitems)
return (UMA_SLAB_SIZE - slab_sizeof(nitems));
 }
 
+#defineUMA_FIXPT_SHIFT 31
+#defineUMA_FRAC_FIXPT(n, d)
\
+   ((uint32_t)(((uint64_t)(n) << UMA_FIXPT_SHIFT) / (d)))
+#defineUMA_FIXPT_PCT(f)
\
+   ((u_int)(((uint64_t)100 * (f)) >> UMA_FIXPT_SHIFT))
+#defineUMA_PCT_FIXPT(pct)  UMA_FRAC_FIXPT((pct), 100)
+#defineUMA_MIN_EFF UMA_PCT_FIXPT(100 - UMA_MAX_WASTE)
+
 /*
- * Compute the number of items that will fit in an embedded (!OFFPAGE) slab
- * with a given size and alignment.
+ * Compute the number of items that will fit in a slab.  If hdr is true, the
+ * item count may be limited to provide space in the slab for an inline slab
+ * header.  Otherwise, all slab space will be provided for item storage.
  */
+static u_int
+slab_ipers_hdr(u_int size, u_int rsize, u_int slabsize, bool hdr)
+{
+   u_int ipers;
+   u_int padpi;
+
+   /* The padding between items is not needed after the last item. */
+   padpi = rsize - size;
+
+   if (hdr) {
+   /*
+* Start with the maximum item count and remove items until
+* the slab header first alongside the allocatable memory.
+*/
+   for (ipers = MIN(SLAB_MAX_SETSIZE,
+   (slabsize + padpi - slab_sizeof(1)) / rsize);
+   ipers > 0 &&
+   ipers * rsize - padpi + slab_sizeof(ipers) > slabsize;
+   ipers--)
+   continue;
+   } else {
+   ipers = MIN((slabsize + padpi) / rsize, SLAB_MAX_SETSIZE);
+   }
+
+   return (ipers);
+}
+
+/*
+ * Compute the number of items that will fit in a slab for a startup zone.
+ */
 int
 slab_ipers(size_t size, int align)
 {
int rsize;
-   int nitems;
 
-/*
- * Compute the ideal number of items that will fit in a page and
- * then compute the actual number based on a bitset nitems wide.
- */
-   rsize = roundup(size, align + 1);
-nitems = UMA_SLAB_SIZE / rsize;
-   return (slab_space(nitems) / rsize);
+   rsize = roundup(size, align + 1); /* Assume no CACHESPREAD */
+   return (slab_ipers_hdr(size, rsize, UMA_SLAB_SIZE, true));
 }
 
 /*
- * Finish creating a small uma keg.  This calculates ipers, and the keg size.
+ * Determine the format of a uma keg.  This determines where the slab header
+ * will be placed (inline or offpage) and calculates ipers, rsize, and ppera.
  *
  * Arguments
  * keg  The zone we should initialize
@@ -1698,66 +1730,77 @@ slab_ipers(size_t size, int align)
  * Nothing
  */
 static void
-keg_small_init(uma_keg_t keg)
+keg_layout(uma_keg_t keg)
 {
+   u_int alignsize;
+   u_int eff;
+   u_int eff_offpage;
+   u_int format;
+   u_int ipers;
+   u_int ipers_offpage;
+   u_int pages;
u_int rsize;
-   u_int memused;
-   u_int wastedspace;
-   u_int shsize;
u_int slabsize;
 
-   if (keg->uk_flags & UMA_ZONE_PCPU) {
-   u_int ncpus = (mp_maxid + 1) ? (mp_maxid + 1) : MAXCPU;
+   KASSERT((keg->uk_flags & UMA_ZONE_PCPU) == 0 ||
+   (keg->uk_size <= UMA_PCPU_ALLOC_SIZE &&
+(keg->uk_flags & UMA_ZONE_CACHESPREAD) == 0),
+   ("%s: cannot configure for PCPU: keg=%s, size=%u, flags=0x%b",
+__func__, keg->uk_name, keg->uk_size, keg->uk_flags,
+PRINT_UMA_ZFLAGS));
+   KASSERT((keg->uk_flags &
+

svn commit: r356533 - in stable/11: contrib/mtree contrib/netbsd-tests/usr.sbin/mtree usr.sbin/fmtree

2020-01-08 Thread Bryan Drewery
Author: bdrewery
Date: Thu Jan  9 01:17:01 2020
New Revision: 356533
URL: https://svnweb.freebsd.org/changeset/base/356533

Log:
  MFC r352261,r352262,r352265:
  
r352261:
  mtree: Fix -f -f not considering type changes.
r352262:
  mtree -c: Fix username logic when getlogin(3) fails.
r352265:
  mtree -O: Fix not descending on hash collisions
  
  Relnotes: yes

Modified:
  stable/11/contrib/mtree/create.c
  stable/11/contrib/mtree/only.c
  stable/11/contrib/mtree/specspec.c
  stable/11/contrib/netbsd-tests/usr.sbin/mtree/t_mtree.sh
  stable/11/usr.sbin/fmtree/specspec.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/contrib/mtree/create.c
==
--- stable/11/contrib/mtree/create.cThu Jan  9 01:14:26 2020
(r356532)
+++ stable/11/contrib/mtree/create.cThu Jan  9 01:17:01 2020
(r356533)
@@ -117,7 +117,7 @@ cwalk(FILE *fp)
host[sizeof(host) - 1] = '\0';
if ((user = getlogin()) == NULL) {
struct passwd *pw;
-   user = (pw = getpwuid(getuid())) == NULL ? pw->pw_name :
+   user = (pw = getpwuid(getuid())) != NULL ? pw->pw_name :
"";
}
 

Modified: stable/11/contrib/mtree/only.c
==
--- stable/11/contrib/mtree/only.c  Thu Jan  9 01:14:26 2020
(r356532)
+++ stable/11/contrib/mtree/only.c  Thu Jan  9 01:17:01 2020
(r356533)
@@ -1,4 +1,4 @@
-/* $NetBSD: only.c,v 1.2 2013/02/05 00:59:03 christos Exp $*/
+/* $NetBSD: only.c,v 1.3 2017/09/07 04:04:13 nakayama Exp $*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
 #include 
 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: only.c,v 1.2 2013/02/05 00:59:03 christos Exp $");
+__RCSID("$NetBSD: only.c,v 1.3 2017/09/07 04:04:13 nakayama Exp $");
 #endif
 
 #include 
@@ -89,11 +89,14 @@ static void
 hash_insert(char *str, uint32_t h)
 {
struct hentry *e;
+   char *x;
 
if ((e = malloc(sizeof(*e))) == NULL)
mtree_err("memory allocation error");
+   if ((x = strdup(str)) == NULL)
+   mtree_err("memory allocation error");
 
-   e->str = str;
+   e->str = x;
e->hash = h;
e->next = table[h];
table[h] = e;
@@ -110,10 +113,7 @@ fill(char *str)
 
*ptr = '\0';
if (!hash_find(str, )) {
-   char *x = strdup(str);
-   if (x == NULL)
-   mtree_err("memory allocation error");
-   hash_insert(x, h);
+   hash_insert(str, h);
fill(str);
}
*ptr = '/';
@@ -135,6 +135,7 @@ load_only(const char *fname)
err(1, "Duplicate entry %s", line);
hash_insert(line, h);
fill(line);
+   free(line);
}
 
fclose(fp);

Modified: stable/11/contrib/mtree/specspec.c
==
--- stable/11/contrib/mtree/specspec.c  Thu Jan  9 01:14:26 2020
(r356532)
+++ stable/11/contrib/mtree/specspec.c  Thu Jan  9 01:17:01 2020
(r356533)
@@ -145,7 +145,7 @@ compare_nodes(NODE *n1, NODE *n2, char const *path)
return (1);
}
if (n1->type != n2->type) {
-   differs = 0;
+   differs = F_TYPE;
mismatch(n1, n2, differs, path);
return (1);
}

Modified: stable/11/contrib/netbsd-tests/usr.sbin/mtree/t_mtree.sh
==
--- stable/11/contrib/netbsd-tests/usr.sbin/mtree/t_mtree.shThu Jan  9 
01:14:26 2020(r356532)
+++ stable/11/contrib/netbsd-tests/usr.sbin/mtree/t_mtree.shThu Jan  9 
01:17:01 2020(r356533)
@@ -411,7 +411,42 @@ netbsd6_nonemptydir_body() 
FLAVOR=netbsd6 nonemptydir_body
 }
 
+atf_test_case mtree_specspec_type
+mtree_specspec_type_head()
+{
+   atf_set "descr" "Test that spec comparisons detect type changes"
+}
 
+mtree_specspec_type_body()
+{
+   mkdir testdir
+
+   touch testdir/bar
+   mtree -c -p testdir > mtree1.spec
+
+   if [ ! -f mtree1.spec ]; then
+   atf_fail "mtree failed"
+   fi
+
+   rm -f testdir/bar
+   ln -s foo testdir/bar
+   # uid change is expected to be ignored as done in -C
+   chown -h operator testdir/bar
+   mtree -c -p testdir > mtree2.spec
+
+   if [ ! -f mtree2.spec ]; then
+   atf_fail "mtree failed"
+   fi
+
+   atf_check -s ignore -o save:output \
+   -x "mtree -f mtree1.spec -f mtree2.spec"
+
+   if ! cut -f 3 output | egrep -q "bar file" || \
+   ! cut -f 3 output | egrep -q "bar link"; then
+   atf_fail "mtree did not detect type 

svn commit: r356532 - in stable/12: contrib/mtree contrib/netbsd-tests/usr.sbin/mtree usr.sbin/fmtree

2020-01-08 Thread Bryan Drewery
Author: bdrewery
Date: Thu Jan  9 01:14:26 2020
New Revision: 356532
URL: https://svnweb.freebsd.org/changeset/base/356532

Log:
  MFC r352261,r352262,r352265:
  
r352261:
  mtree: Fix -f -f not considering type changes.
r352262:
  mtree -c: Fix username logic when getlogin(3) fails.
r352265:
  mtree -O: Fix not descending on hash collisions
  
  Relnotes: yes

Modified:
  stable/12/contrib/mtree/create.c
  stable/12/contrib/mtree/only.c
  stable/12/contrib/mtree/specspec.c
  stable/12/contrib/netbsd-tests/usr.sbin/mtree/t_mtree.sh
  stable/12/usr.sbin/fmtree/specspec.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/contrib/mtree/create.c
==
--- stable/12/contrib/mtree/create.cThu Jan  9 00:39:35 2020
(r356531)
+++ stable/12/contrib/mtree/create.cThu Jan  9 01:14:26 2020
(r356532)
@@ -117,7 +117,7 @@ cwalk(FILE *fp)
host[sizeof(host) - 1] = '\0';
if ((user = getlogin()) == NULL) {
struct passwd *pw;
-   user = (pw = getpwuid(getuid())) == NULL ? pw->pw_name :
+   user = (pw = getpwuid(getuid())) != NULL ? pw->pw_name :
"";
}
 

Modified: stable/12/contrib/mtree/only.c
==
--- stable/12/contrib/mtree/only.c  Thu Jan  9 00:39:35 2020
(r356531)
+++ stable/12/contrib/mtree/only.c  Thu Jan  9 01:14:26 2020
(r356532)
@@ -1,4 +1,4 @@
-/* $NetBSD: only.c,v 1.2 2013/02/05 00:59:03 christos Exp $*/
+/* $NetBSD: only.c,v 1.3 2017/09/07 04:04:13 nakayama Exp $*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
 #include 
 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: only.c,v 1.2 2013/02/05 00:59:03 christos Exp $");
+__RCSID("$NetBSD: only.c,v 1.3 2017/09/07 04:04:13 nakayama Exp $");
 #endif
 
 #include 
@@ -89,11 +89,14 @@ static void
 hash_insert(char *str, uint32_t h)
 {
struct hentry *e;
+   char *x;
 
if ((e = malloc(sizeof(*e))) == NULL)
mtree_err("memory allocation error");
+   if ((x = strdup(str)) == NULL)
+   mtree_err("memory allocation error");
 
-   e->str = str;
+   e->str = x;
e->hash = h;
e->next = table[h];
table[h] = e;
@@ -110,10 +113,7 @@ fill(char *str)
 
*ptr = '\0';
if (!hash_find(str, )) {
-   char *x = strdup(str);
-   if (x == NULL)
-   mtree_err("memory allocation error");
-   hash_insert(x, h);
+   hash_insert(str, h);
fill(str);
}
*ptr = '/';
@@ -135,6 +135,7 @@ load_only(const char *fname)
err(1, "Duplicate entry %s", line);
hash_insert(line, h);
fill(line);
+   free(line);
}
 
fclose(fp);

Modified: stable/12/contrib/mtree/specspec.c
==
--- stable/12/contrib/mtree/specspec.c  Thu Jan  9 00:39:35 2020
(r356531)
+++ stable/12/contrib/mtree/specspec.c  Thu Jan  9 01:14:26 2020
(r356532)
@@ -145,7 +145,7 @@ compare_nodes(NODE *n1, NODE *n2, char const *path)
return (1);
}
if (n1->type != n2->type) {
-   differs = 0;
+   differs = F_TYPE;
mismatch(n1, n2, differs, path);
return (1);
}

Modified: stable/12/contrib/netbsd-tests/usr.sbin/mtree/t_mtree.sh
==
--- stable/12/contrib/netbsd-tests/usr.sbin/mtree/t_mtree.shThu Jan  9 
00:39:35 2020(r356531)
+++ stable/12/contrib/netbsd-tests/usr.sbin/mtree/t_mtree.shThu Jan  9 
01:14:26 2020(r356532)
@@ -411,7 +411,42 @@ netbsd6_nonemptydir_body() 
FLAVOR=netbsd6 nonemptydir_body
 }
 
+atf_test_case mtree_specspec_type
+mtree_specspec_type_head()
+{
+   atf_set "descr" "Test that spec comparisons detect type changes"
+}
 
+mtree_specspec_type_body()
+{
+   mkdir testdir
+
+   touch testdir/bar
+   mtree -c -p testdir > mtree1.spec
+
+   if [ ! -f mtree1.spec ]; then
+   atf_fail "mtree failed"
+   fi
+
+   rm -f testdir/bar
+   ln -s foo testdir/bar
+   # uid change is expected to be ignored as done in -C
+   chown -h operator testdir/bar
+   mtree -c -p testdir > mtree2.spec
+
+   if [ ! -f mtree2.spec ]; then
+   atf_fail "mtree failed"
+   fi
+
+   atf_check -s ignore -o save:output \
+   -x "mtree -f mtree1.spec -f mtree2.spec"
+
+   if ! cut -f 3 output | egrep -q "bar file" || \
+   ! cut -f 3 output | egrep -q "bar link"; then
+   atf_fail "mtree did not detect type 

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

2020-01-08 Thread Conrad Meyer
On Wed, Jan 8, 2020 at 2:16 PM John Baldwin  wrote:
>
> Author: jhb
> Date: Wed Jan  8 22:16:26 2020
> New Revision: 356520
> URL: https://svnweb.freebsd.org/changeset/base/356520
>
> Log:
>   Remove no-longer-used function prototype.
>
>   Reported by:  amd64-gcc

Also me ;-).  https://reviews.freebsd.org/D23077?id=66470#inline-143562
___
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: r356531 - stable/12/sys/geom/eli

2020-01-08 Thread Alexander Motin
Author: mav
Date: Thu Jan  9 00:39:35 2020
New Revision: 356531
URL: https://svnweb.freebsd.org/changeset/base/356531

Log:
  MFC r356284: Remove extra check for provider being closed.
  
  We already checked for that earlier, and since we hold topology lock
  it could not change.

Modified:
  stable/12/sys/geom/eli/g_eli.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/geom/eli/g_eli.c
==
--- stable/12/sys/geom/eli/g_eli.c  Thu Jan  9 00:36:28 2020
(r356530)
+++ stable/12/sys/geom/eli/g_eli.c  Thu Jan  9 00:39:35 2020
(r356531)
@@ -962,8 +962,7 @@ g_eli_destroy(struct g_eli_softc *sc, boolean_t force)
bzero(sc, sizeof(*sc));
free(sc, M_ELI);
 
-   if (pp == NULL || (pp->acr == 0 && pp->acw == 0 && pp->ace == 0))
-   G_ELI_DEBUG(0, "Device %s destroyed.", gp->name);
+   G_ELI_DEBUG(0, "Device %s destroyed.", gp->name);
g_wither_geom_close(gp, ENXIO);
 
return (0);
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r356530 - stable/12/sbin/nvmecontrol

2020-01-08 Thread Alexander Motin
Author: mav
Date: Thu Jan  9 00:36:28 2020
New Revision: 356530
URL: https://svnweb.freebsd.org/changeset/base/356530

Log:
  MFC r351824, r356392: Report the Host Buffer Memory minimum and preferred 
sizes.
  
  The Host Buffer feature (NVMe 1.4 section 89) allows for the NVMe card
  request the host provide it buffer for lookaside tables and maybe
  other things. Report the card's minimum and preferred sizes with
  nvmecontrol/camcontrol identify.

Modified:
  stable/12/sbin/nvmecontrol/identify_ext.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sbin/nvmecontrol/identify_ext.c
==
--- stable/12/sbin/nvmecontrol/identify_ext.c   Wed Jan  8 23:39:23 2020
(r356529)
+++ stable/12/sbin/nvmecontrol/identify_ext.c   Thu Jan  9 00:36:28 2020
(r356530)
@@ -192,6 +192,10 @@ nvme_print_controller(struct nvme_controller_data *cda
uint128_to_str(to128(cdata->untncap.unvmcap),
cbuf, sizeof(cbuf)));
}
+   printf("Host Buffer Preferred Size:  %llu bytes\n",
+   (long long unsigned)cdata->hmpre * 4096);
+   printf("Host Buffer Minimum Size:%llu bytes\n",
+   (long long unsigned)cdata->hmmin * 4096);
 
printf("\n");
printf("NVM Command Set Attributes\n");
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r356513 - in head/contrib/llvm-project/libunwind: include src

2020-01-08 Thread Conrad Meyer
I definitely don't condone this.  I would prefer it be reverted.  It
has never been tested.  It's got my name in the commit message,
suggesting some level of my approval; I absolutely do not approve of
it in any way.

Cheers,
Conrad

On Wed, Jan 8, 2020 at 12:37 PM Ed Maste  wrote:
>
> Author: emaste
> Date: Wed Jan  8 20:37:03 2020
> New Revision: 356513
> URL: https://svnweb.freebsd.org/changeset/base/356513
>
> Log:
>   libunwind: untested attempt to fix sparc64 build
>
>   sparc64 is the only architecture currently using the DWARF unwinder from
>   GCC 4.2.1.  Old GCC and related libraries are being removed soon; absent
>   other changes sparc64 would be left with no unwinder when that happens.
>
>   Instead, commit these changes which should at least allow the LLVM
>   unwinder to build.  Someone with access to the obolete sparc64 hardware
>   supported by FreeBSD will need to test the result.
>
>   PR:   233405
>   Submitted by: cem
___
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: r356529 - stable/12/sys/netinet6

2020-01-08 Thread Bjoern A. Zeeb
Author: bz
Date: Wed Jan  8 23:39:23 2020
New Revision: 356529
URL: https://svnweb.freebsd.org/changeset/base/356529

Log:
  Remove duplicate kernel.h include which came back with 356524 due to
  out-of-order MFCs.

Modified:
  stable/12/sys/netinet6/frag6.c

Modified: stable/12/sys/netinet6/frag6.c
==
--- stable/12/sys/netinet6/frag6.c  Wed Jan  8 23:34:50 2020
(r356528)
+++ stable/12/sys/netinet6/frag6.c  Wed Jan  8 23:39:23 2020
(r356529)
@@ -45,7 +45,6 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r356528 - head/libexec/rc/rc.d

2020-01-08 Thread Bjoern A. Zeeb
Author: bz
Date: Wed Jan  8 23:34:50 2020
New Revision: 356528
URL: https://svnweb.freebsd.org/changeset/base/356528

Log:
  Run netoptions startup script in vnet jails.
  
  People use rc.conf inside vnet jails to configure networking setups.
  Presumably because some sysctl were not virtualised up until r356527 the
  script was not run for vnet jails leaving the rc.conf options without
  effect for non-obvious reasons.  Run the netoptions startup script also
  for VNET jails now to make the rc.conf options work.
  
  PR:   243193
  MFC after:2 weeks

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

Modified: head/libexec/rc/rc.d/netoptions
==
--- head/libexec/rc/rc.d/netoptions Wed Jan  8 23:30:26 2020
(r356527)
+++ head/libexec/rc/rc.d/netoptions Wed Jan  8 23:34:50 2020
(r356528)
@@ -6,7 +6,7 @@
 # PROVIDE: netoptions
 # REQUIRE: FILESYSTEMS
 # BEFORE: netif
-# KEYWORD: nojail
+# KEYWORD: nojailvnet
 
 . /etc/rc.subr
 . /etc/network.subr
___
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: r356527 - in head/sys: dev/cxgbe/tom netinet netinet/tcp_stacks netinet6

2020-01-08 Thread Bjoern A. Zeeb
Author: bz
Date: Wed Jan  8 23:30:26 2020
New Revision: 356527
URL: https://svnweb.freebsd.org/changeset/base/356527

Log:
  vnet: virtualise more network stack sysctls.
  
  Virtualise tcp_always_keepalive, TCP and UDP log_in_vain.  All three are
  set in the netoptions startup script, which we would love to run for VNETs
  as well [1].
  
  While virtualising the log_in_vain sysctls seems pointles at first for as
  long as the kernel message buffer is not virtualised, it at least allows
  an administrator to debug the base system or an individual jail if needed
  without turning the logging on for all jails running on a system.
  
  PR:   243193 [1]
  MFC after:2 weeks

Modified:
  head/sys/dev/cxgbe/tom/t4_tom.c
  head/sys/netinet/tcp_input.c
  head/sys/netinet/tcp_stacks/bbr.c
  head/sys/netinet/tcp_stacks/rack.c
  head/sys/netinet/tcp_subr.c
  head/sys/netinet/tcp_timer.c
  head/sys/netinet/tcp_timer.h
  head/sys/netinet/tcp_var.h
  head/sys/netinet/udp_usrreq.c
  head/sys/netinet/udp_var.h
  head/sys/netinet6/udp6_usrreq.c

Modified: head/sys/dev/cxgbe/tom/t4_tom.c
==
--- head/sys/dev/cxgbe/tom/t4_tom.c Wed Jan  8 23:06:13 2020
(r356526)
+++ head/sys/dev/cxgbe/tom/t4_tom.c Wed Jan  8 23:30:26 2020
(r356527)
@@ -1146,7 +1146,7 @@ init_conn_params(struct vi_info *vi , struct offload_s
cp->nagle = tp->t_flags & TF_NODELAY ? 0 : 1;
 
/* TCP Keepalive. */
-   if (tcp_always_keepalive || so_options_get(so) & SO_KEEPALIVE)
+   if (V_tcp_always_keepalive || so_options_get(so) & SO_KEEPALIVE)
cp->keepalive = 1;
else
cp->keepalive = 0;

Modified: head/sys/netinet/tcp_input.c
==
--- head/sys/netinet/tcp_input.cWed Jan  8 23:06:13 2020
(r356526)
+++ head/sys/netinet/tcp_input.cWed Jan  8 23:30:26 2020
(r356527)
@@ -132,9 +132,9 @@ __FBSDID("$FreeBSD$");
 
 const int tcprexmtthresh = 3;
 
-int tcp_log_in_vain = 0;
-SYSCTL_INT(_net_inet_tcp, OID_AUTO, log_in_vain, CTLFLAG_RW,
-_log_in_vain, 0,
+VNET_DEFINE(int, tcp_log_in_vain) = 0;
+SYSCTL_INT(_net_inet_tcp, OID_AUTO, log_in_vain, CTLFLAG_VNET | CTLFLAG_RW,
+_NAME(tcp_log_in_vain), 0,
 "Log all incoming TCP segments to closed ports");
 
 VNET_DEFINE(int, blackhole) = 0;
@@ -892,8 +892,8 @@ findpcb:
 * Log communication attempts to ports that are not
 * in use.
 */
-   if ((tcp_log_in_vain == 1 && (thflags & TH_SYN)) ||
-   tcp_log_in_vain == 2) {
+   if ((V_tcp_log_in_vain == 1 && (thflags & TH_SYN)) ||
+   V_tcp_log_in_vain == 2) {
if ((s = tcp_log_vain(NULL, th, (void *)ip, ip6)))
log(LOG_INFO, "%s; %s: Connection attempt "
"to closed port\n", s, __func__);

Modified: head/sys/netinet/tcp_stacks/bbr.c
==
--- head/sys/netinet/tcp_stacks/bbr.c   Wed Jan  8 23:06:13 2020
(r356526)
+++ head/sys/netinet/tcp_stacks/bbr.c   Wed Jan  8 23:30:26 2020
(r356527)
@@ -835,7 +835,7 @@ bbr_start_hpts_timer(struct tcp_bbr *bbr, struct tcpcb
 */
if ((hpts_timeout == 0) &&
(slot == 0)) {
-   if ((tcp_always_keepalive || inp->inp_socket->so_options & 
SO_KEEPALIVE) &&
+   if ((V_tcp_always_keepalive || inp->inp_socket->so_options & 
SO_KEEPALIVE) &&
(tp->t_state <= TCPS_CLOSING)) {
/*
 * Ok we have no timer (persists, rack, tlp, rxt  or
@@ -998,7 +998,7 @@ bbr_timer_audit(struct tcpcb *tp, struct tcp_bbr *bbr,
 * (and the hptsi timer).
 */
return;
-   } else if (((tcp_always_keepalive ||
+   } else if (((V_tcp_always_keepalive ||
inp->inp_socket->so_options & SO_KEEPALIVE) &&
(tp->t_state <= TCPS_CLOSING)) &&
(tmr_up == PACE_TMR_KEEP) &&
@@ -4919,7 +4919,7 @@ bbr_timeout_keepalive(struct tcpcb *tp, struct tcp_bbr
TCPSTAT_INC(tcps_keeptimeo);
if (tp->t_state < TCPS_ESTABLISHED)
goto dropit;
-   if ((tcp_always_keepalive || inp->inp_socket->so_options & 
SO_KEEPALIVE) &&
+   if ((V_tcp_always_keepalive || inp->inp_socket->so_options & 
SO_KEEPALIVE) &&
tp->t_state <= TCPS_CLOSING) {
if (ticks - tp->t_rcvtime >= TP_KEEPIDLE(tp) + TP_MAXIDLE(tp))
goto dropit;
@@ -11790,7 +11790,7 @@ bbr_do_segment_nounlock(struct mbuf *m, struct tcphdr 
((bbr->r_ctl.rc_hpts_flags & PACE_TMR_MASK) == 0) &&
  

svn commit: r356526 - head/sys/dev/iicbus/mux

2020-01-08 Thread Ian Lepore
Author: ian
Date: Wed Jan  8 23:06:13 2020
New Revision: 356526
URL: https://svnweb.freebsd.org/changeset/base/356526

Log:
  Remove some trailing whitespace; no functional changes.

Modified:
  head/sys/dev/iicbus/mux/iicmux.c

Modified: head/sys/dev/iicbus/mux/iicmux.c
==
--- head/sys/dev/iicbus/mux/iicmux.cWed Jan  8 23:03:47 2020
(r356525)
+++ head/sys/dev/iicbus/mux/iicmux.cWed Jan  8 23:06:13 2020
(r356526)
@@ -153,7 +153,7 @@ iicmux_intr(device_t dev, int event, char *buf)
/* XXX iicbus_intr() in iiconf.c should return status. */
 
iicbus_intr(sc->busdev, event, buf);
-   return (0); 
+   return (0);
 }
 
 static int
@@ -213,7 +213,7 @@ iicmux_write(device_t dev, const char *buf, int len, i
 }
 
 
/*--
- * iicmux helper functions, called by hardware-specific drivers.   
 
+ * iicmux helper functions, called by hardware-specific drivers.
  * All these functions return a standard errno value.
  
**/
 
@@ -324,7 +324,7 @@ iicmux_attach(device_t dev, device_t busdev, int numbu
if ((err = iicmux_attach_children(sc)) != 0)
return (err);
 
-   SYSCTL_ADD_UINT(device_get_sysctl_ctx(sc->dev), 
+   SYSCTL_ADD_UINT(device_get_sysctl_ctx(sc->dev),
SYSCTL_CHILDREN(device_get_sysctl_tree(sc->dev)), OID_AUTO,
"debugmux", CTLFLAG_RWTUN, >debugmux, 0, "debug mux 
operations");
 
___
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: r356525 - head/sys/dev/iicbus/mux

2020-01-08 Thread Ian Lepore
Author: ian
Date: Wed Jan  8 23:03:47 2020
New Revision: 356525
URL: https://svnweb.freebsd.org/changeset/base/356525

Log:
  Split the code to find and add iicbus children out to its own function.
  Move the decision to take an early exit from that function after adding
  children based on FDT data into the #ifdef FDT block, so that it doesn't
  offend coverity's notion of how the code should be written.  (What's the
  point of compilers optimizing away dead code if static analyzers won't
  let you use the feature in conjuction with an #ifdef block?)
  
  Reported by:  coverity via vangyzen@

Modified:
  head/sys/dev/iicbus/mux/iicmux.c

Modified: head/sys/dev/iicbus/mux/iicmux.c
==
--- head/sys/dev/iicbus/mux/iicmux.cWed Jan  8 22:59:31 2020
(r356524)
+++ head/sys/dev/iicbus/mux/iicmux.cWed Jan  8 23:03:47 2020
(r356525)
@@ -240,36 +240,13 @@ iicmux_add_child(device_t dev, device_t child, int bus
return (0);
 }
 
-int
-iicmux_attach(device_t dev, device_t busdev, int numbuses)
+static int
+iicmux_attach_children(struct iicmux_softc *sc)
 {
-   struct iicmux_softc *sc = device_get_softc(dev);
-   int i, numadded;
-
-   if (numbuses >= IICMUX_MAX_BUSES) {
-   device_printf(dev, "iicmux_attach: numbuses %d > max %d\n",
-   numbuses, IICMUX_MAX_BUSES);
-   return (EINVAL);
-   }
-
-   sc->dev = dev;
-   sc->busdev = busdev;
-   sc->maxbus = -1;
-   sc->numbuses = numbuses;
-
-   SYSCTL_ADD_UINT(device_get_sysctl_ctx(sc->dev), 
-   SYSCTL_CHILDREN(device_get_sysctl_tree(sc->dev)), OID_AUTO,
-   "debugmux", CTLFLAG_RWTUN, >debugmux, 0, "debug mux 
operations");
-
-/*
- * Add children...
- */
-   numadded = 0;
-
+   int i;
 #ifdef FDT
phandle_t child, node, parent;
-   pcell_t reg;
-   int idx;
+   pcell_t idx;
 
/*
 * Find our FDT node.  Child nodes within our node will become our
@@ -292,14 +269,13 @@ iicmux_attach(device_t dev, device_t busdev, int numbu
 * Attach the children represented in the device tree.
 */
for (child = OF_child(parent); child != 0; child = OF_peer(child)) {
-   if (OF_getencprop(child, "reg", , sizeof(reg)) == -1) {
-   device_printf(dev,
+   if (OF_getencprop(child, "reg", , sizeof(idx)) == -1) {
+   device_printf(sc->dev,
"child bus missing required 'reg' property\n");
continue;
}
-   idx = (int)reg;
if (idx >= sc->numbuses) {
-   device_printf(dev,
+   device_printf(sc->dev,
"child bus 'reg' property %d exceeds the number "
"of buses supported by the device (%d)\n",
idx, sc->numbuses);
@@ -309,21 +285,48 @@ iicmux_attach(device_t dev, device_t busdev, int numbu
sc->childnodes[idx] = child;
if (sc->maxbus < idx)
sc->maxbus = idx;
-   ++numadded;
}
+
+   /* If we configured anything using FDT data, we're done. */
+   if (sc->maxbus >= 0)
+   return (0);
 #endif /* FDT */
 
/*
-* If we configured anything using FDT data, we're done.  Otherwise add
-* an iicbus child for every downstream bus supported by the mux chip.
+* If we make it to here, we didn't add any children based on FDT data.
+* Add an iicbus child for every downstream bus supported by the mux.
 */
-   if (numadded > 0)
-   return (0);
-
for (i = 0; i < sc->numbuses; ++i) {
sc->childdevs[i] = device_add_child(sc->dev, "iicbus", -1);
+   sc->maxbus = i;
}
-   sc->maxbus = sc->numbuses - 1;
+
+   return (0);
+}
+
+int
+iicmux_attach(device_t dev, device_t busdev, int numbuses)
+{
+   struct iicmux_softc *sc = device_get_softc(dev);
+   int err;
+
+   if (numbuses >= IICMUX_MAX_BUSES) {
+   device_printf(dev, "iicmux_attach: numbuses %d > max %d\n",
+   numbuses, IICMUX_MAX_BUSES);
+   return (EINVAL);
+   }
+
+   sc->dev = dev;
+   sc->busdev = busdev;
+   sc->maxbus = -1;
+   sc->numbuses = numbuses;
+
+   if ((err = iicmux_attach_children(sc)) != 0)
+   return (err);
+
+   SYSCTL_ADD_UINT(device_get_sysctl_ctx(sc->dev), 
+   SYSCTL_CHILDREN(device_get_sysctl_tree(sc->dev)), OID_AUTO,
+   "debugmux", CTLFLAG_RWTUN, >debugmux, 0, "debug mux 
operations");
 
return (0);
 }
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail 

svn commit: r356524 - in stable/12/sys: netinet netinet6

2020-01-08 Thread Bjoern A. Zeeb
Author: bz
Date: Wed Jan  8 22:59:31 2020
New Revision: 356524
URL: https://svnweb.freebsd.org/changeset/base/356524

Log:
  MFC r346535 (by hselasky):
  
Fix build for mips and powerpc after r346530.
  
Need to include sys/kernel.h to define SYSINIT() which is used
by sys/eventhandler.h .
  
  This is now hit by r356489 which is unrelated to the original cause but
  the fix was never MFCed and hence manifests with different code now.

Modified:
  stable/12/sys/netinet/ip_reass.c
  stable/12/sys/netinet6/frag6.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/netinet/ip_reass.c
==
--- stable/12/sys/netinet/ip_reass.cWed Jan  8 22:55:22 2020
(r356523)
+++ stable/12/sys/netinet/ip_reass.cWed Jan  8 22:59:31 2020
(r356524)
@@ -39,6 +39,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 

Modified: stable/12/sys/netinet6/frag6.c
==
--- stable/12/sys/netinet6/frag6.c  Wed Jan  8 22:55:22 2020
(r356523)
+++ stable/12/sys/netinet6/frag6.c  Wed Jan  8 22:59:31 2020
(r356524)
@@ -45,6 +45,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r356523 - head/usr.sbin/bhyve

2020-01-08 Thread Vincenzo Maffione
Author: vmaffione
Date: Wed Jan  8 22:55:22 2020
New Revision: 356523
URL: https://svnweb.freebsd.org/changeset/base/356523

Log:
  bhyve: add wrapper for debug printf statements
  
  Add printf() wrapper to use CR/CRLF terminators depending on whether
  stdio is mapped to a tty open in raw mode.
  Try to use the wrapper everywhere.
  For now we leave the custom DPRINTF/WPRINTF defined by device
  models, but we may remove them in the future.
  
  Reviewed by:  grehan, jhb
  MFC after:2 weeks
  Differential Revision:https://reviews.freebsd.org/D22657

Added:
  head/usr.sbin/bhyve/debug.h   (contents, props changed)
Modified:
  head/usr.sbin/bhyve/audio.c
  head/usr.sbin/bhyve/bhyverun.c
  head/usr.sbin/bhyve/block_if.c
  head/usr.sbin/bhyve/bootrom.c
  head/usr.sbin/bhyve/consport.c
  head/usr.sbin/bhyve/hda_codec.c
  head/usr.sbin/bhyve/mptbl.c
  head/usr.sbin/bhyve/net_backends.c
  head/usr.sbin/bhyve/net_utils.c
  head/usr.sbin/bhyve/pci_ahci.c
  head/usr.sbin/bhyve/pci_e82545.c
  head/usr.sbin/bhyve/pci_emul.c
  head/usr.sbin/bhyve/pci_fbuf.c
  head/usr.sbin/bhyve/pci_hda.c
  head/usr.sbin/bhyve/pci_hda.h
  head/usr.sbin/bhyve/pci_lpc.c
  head/usr.sbin/bhyve/pci_nvme.c
  head/usr.sbin/bhyve/pci_uart.c
  head/usr.sbin/bhyve/pci_virtio_block.c
  head/usr.sbin/bhyve/pci_virtio_console.c
  head/usr.sbin/bhyve/pci_virtio_net.c
  head/usr.sbin/bhyve/pci_virtio_rnd.c
  head/usr.sbin/bhyve/pci_virtio_scsi.c
  head/usr.sbin/bhyve/pci_xhci.c
  head/usr.sbin/bhyve/ps2kbd.c
  head/usr.sbin/bhyve/ps2mouse.c
  head/usr.sbin/bhyve/rfb.c
  head/usr.sbin/bhyve/smbiostbl.c
  head/usr.sbin/bhyve/task_switch.c
  head/usr.sbin/bhyve/uart_emul.c
  head/usr.sbin/bhyve/usb_mouse.c
  head/usr.sbin/bhyve/virtio.c
  head/usr.sbin/bhyve/xmsr.c

Modified: head/usr.sbin/bhyve/audio.c
==
--- head/usr.sbin/bhyve/audio.c Wed Jan  8 22:48:14 2020(r356522)
+++ head/usr.sbin/bhyve/audio.c Wed Jan  8 22:55:22 2020(r356523)
@@ -92,7 +92,7 @@ audio_init(const char *dev_name, uint8_t dir)
if (strlen(dev_name) < sizeof(aud->dev_name))
memcpy(aud->dev_name, dev_name, strlen(dev_name) + 1);
else {
-   DPRINTF("dev_name too big\n\r");
+   DPRINTF("dev_name too big");
free(aud);
return NULL;
}
@@ -101,7 +101,7 @@ audio_init(const char *dev_name, uint8_t dir)
 
aud->fd = open(aud->dev_name, aud->dir ? O_WRONLY : O_RDONLY, 0);
if (aud->fd == -1) {
-   DPRINTF("Failed to open dev: %s, errno: %d\n\r",
+   DPRINTF("Failed to open dev: %s, errno: %d",
aud->dev_name, errno);
free(aud);
return (NULL);
@@ -137,7 +137,7 @@ audio_set_params(struct audio *aud, struct audio_param
assert(params);
 
if ((audio_fd = aud->fd) < 0) {
-   DPRINTF("Incorrect audio device descriptor for %s\n\r",
+   DPRINTF("Incorrect audio device descriptor for %s",
aud->dev_name);
return (-1);
}
@@ -146,7 +146,7 @@ audio_set_params(struct audio *aud, struct audio_param
if (aud->inited) {
err = ioctl(audio_fd, SNDCTL_DSP_RESET, NULL);
if (err == -1) {
-   DPRINTF("Failed to reset fd: %d, errno: %d\n\r",
+   DPRINTF("Failed to reset fd: %d, errno: %d",
aud->fd, errno);
return (-1);
}
@@ -157,14 +157,14 @@ audio_set_params(struct audio *aud, struct audio_param
format = params->format;
err = ioctl(audio_fd, SNDCTL_DSP_SETFMT, );
if (err == -1) {
-   DPRINTF("Fail to set fmt: 0x%x errno: %d\n\r",
+   DPRINTF("Fail to set fmt: 0x%x errno: %d",
params->format, errno);
return -1;
}
 
/* The device does not support the requested audio format */
if (format != params->format) {
-   DPRINTF("Mismatch format: 0x%x params->format: 0x%x\n\r",
+   DPRINTF("Mismatch format: 0x%x params->format: 0x%x",
format, params->format);
return -1;
}
@@ -173,14 +173,14 @@ audio_set_params(struct audio *aud, struct audio_param
channels = params->channels;
err = ioctl(audio_fd, SNDCTL_DSP_CHANNELS, );
if (err == -1) {
-   DPRINTF("Fail to set channels: %d errno: %d\n\r",
+   DPRINTF("Fail to set channels: %d errno: %d",
params->channels, errno);
return -1;
}
 
/* The device does not support the requested no. of channels */
if (channels != params->channels) {
-   DPRINTF("Mismatch channels: %d params->channels: %d\n\r",
+   DPRINTF("Mismatch channels: %d params->channels: %d",

svn commit: r356522 - head/sys/dev/iicbus/mux

2020-01-08 Thread Ian Lepore
Author: ian
Date: Wed Jan  8 22:48:14 2020
New Revision: 356522
URL: https://svnweb.freebsd.org/changeset/base/356522

Log:
  Change some KASSERT to device_printf + return EINVAL.  There's no need to
  bring the whole kernel down due to a configuration error detected when a
  module is loaded, it suffices to just not attach the device.

Modified:
  head/sys/dev/iicbus/mux/iicmux.c

Modified: head/sys/dev/iicbus/mux/iicmux.c
==
--- head/sys/dev/iicbus/mux/iicmux.cWed Jan  8 22:45:32 2020
(r356521)
+++ head/sys/dev/iicbus/mux/iicmux.cWed Jan  8 22:48:14 2020
(r356522)
@@ -222,10 +222,16 @@ iicmux_add_child(device_t dev, device_t child, int bus
 {
struct iicmux_softc *sc = device_get_softc(dev);
 
-   KASSERT(busidx < sc->numbuses,
-   ("iicmux_add_child: bus idx %d too big", busidx));
-   KASSERT(sc->childdevs[busidx] == NULL,
-   ("iicmux_add_child: bus idx %d already added", busidx));
+   if (busidx >= sc->numbuses) {
+   device_printf(dev,
+   "iicmux_add_child: bus idx %d too big", busidx);
+   return (EINVAL);
+   }
+   if (sc->childdevs[busidx] != NULL) {
+   device_printf(dev, "iicmux_add_child: bus idx %d already added",
+   busidx);
+   return (EINVAL);
+   }
 
sc->childdevs[busidx] = child;
if (sc->maxbus < busidx)
@@ -240,12 +246,11 @@ iicmux_attach(device_t dev, device_t busdev, int numbu
struct iicmux_softc *sc = device_get_softc(dev);
int i, numadded;
 
-/*
- * Init the softc...
- */
-   KASSERT(numbuses <= IICMUX_MAX_BUSES,
-   ("iicmux_attach: numbuses %d exceeds max %d\n",
-   numbuses, IICMUX_MAX_BUSES));
+   if (numbuses >= IICMUX_MAX_BUSES) {
+   device_printf(dev, "iicmux_attach: numbuses %d > max %d\n",
+   numbuses, IICMUX_MAX_BUSES);
+   return (EINVAL);
+   }
 
sc->dev = dev;
sc->busdev = busdev;
___
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: r356521 - head/sys/dev/iicbus/mux

2020-01-08 Thread Ian Lepore
Author: ian
Date: Wed Jan  8 22:45:32 2020
New Revision: 356521
URL: https://svnweb.freebsd.org/changeset/base/356521

Log:
  Init sc->maxbus to -1, not 0.  It represents the highest array index that
  has a non-NULL child bus stored in it, so the "none" value can't be zero
  since that's a valid array index.  Also, when adding all possible buses
  because there is no specific per-bus config, there's no need to reset
  sc->maxbus on each loop iteration, it can be set once after the loop.

Modified:
  head/sys/dev/iicbus/mux/iicmux.c

Modified: head/sys/dev/iicbus/mux/iicmux.c
==
--- head/sys/dev/iicbus/mux/iicmux.cWed Jan  8 22:16:26 2020
(r356520)
+++ head/sys/dev/iicbus/mux/iicmux.cWed Jan  8 22:45:32 2020
(r356521)
@@ -249,6 +249,7 @@ iicmux_attach(device_t dev, device_t busdev, int numbu
 
sc->dev = dev;
sc->busdev = busdev;
+   sc->maxbus = -1;
sc->numbuses = numbuses;
 
SYSCTL_ADD_UINT(device_get_sysctl_ctx(sc->dev), 
@@ -262,7 +263,8 @@ iicmux_attach(device_t dev, device_t busdev, int numbu
 
 #ifdef FDT
phandle_t child, node, parent;
-   pcell_t idx;
+   pcell_t reg;
+   int idx;
 
/*
 * Find our FDT node.  Child nodes within our node will become our
@@ -285,11 +287,12 @@ iicmux_attach(device_t dev, device_t busdev, int numbu
 * Attach the children represented in the device tree.
 */
for (child = OF_child(parent); child != 0; child = OF_peer(child)) {
-   if (OF_getencprop(child, "reg", , sizeof(idx)) == -1) {
+   if (OF_getencprop(child, "reg", , sizeof(reg)) == -1) {
device_printf(dev,
"child bus missing required 'reg' property\n");
continue;
}
+   idx = (int)reg;
if (idx >= sc->numbuses) {
device_printf(dev,
"child bus 'reg' property %d exceeds the number "
@@ -314,9 +317,8 @@ iicmux_attach(device_t dev, device_t busdev, int numbu
 
for (i = 0; i < sc->numbuses; ++i) {
sc->childdevs[i] = device_add_child(sc->dev, "iicbus", -1);
-   if (sc->maxbus < i)
-   sc->maxbus = i;
}
+   sc->maxbus = sc->numbuses - 1;
 
return (0);
 }
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r356520 - head/sys/opencrypto

2020-01-08 Thread John Baldwin
Author: jhb
Date: Wed Jan  8 22:16:26 2020
New Revision: 356520
URL: https://svnweb.freebsd.org/changeset/base/356520

Log:
  Remove no-longer-used function prototype.
  
  Reported by:  amd64-gcc

Modified:
  head/sys/opencrypto/cryptodev.c

Modified: head/sys/opencrypto/cryptodev.c
==
--- head/sys/opencrypto/cryptodev.c Wed Jan  8 22:06:31 2020
(r356519)
+++ head/sys/opencrypto/cryptodev.c Wed Jan  8 22:16:26 2020
(r356520)
@@ -326,7 +326,6 @@ static struct fileops cryptofops = {
 
 static struct csession *csefind(struct fcrypt *, u_int);
 static bool csedelete(struct fcrypt *, u_int);
-static void cseadd(struct fcrypt *, struct csession *);
 static struct csession *csecreate(struct fcrypt *, crypto_session_t, caddr_t,
 u_int64_t, caddr_t, u_int64_t, u_int32_t, u_int32_t, struct enc_xform *,
 struct auth_hash *);
___
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: r356519 - head/sys/dev/iicbus/mux

2020-01-08 Thread Ian Lepore
Author: ian
Date: Wed Jan  8 22:06:31 2020
New Revision: 356519
URL: https://svnweb.freebsd.org/changeset/base/356519

Log:
  Ensure any reserved gpio pins get released if an early exit is taken
  from the attach function.

Modified:
  head/sys/dev/iicbus/mux/iic_gpiomux.c

Modified: head/sys/dev/iicbus/mux/iic_gpiomux.c
==
--- head/sys/dev/iicbus/mux/iic_gpiomux.c   Wed Jan  8 21:22:44 2020
(r356518)
+++ head/sys/dev/iicbus/mux/iic_gpiomux.c   Wed Jan  8 22:06:31 2020
(r356519)
@@ -119,6 +119,15 @@ gpiomux_probe(device_t dev)
return (rv);
 }
 
+static void
+gpiomux_release_pins(struct gpiomux_softc *sc)
+{
+   int i;
+
+   for (i = 0; i < sc->numpins; ++i)
+   gpio_pin_release(sc->pins[i]);
+}
+
 static int
 gpiomux_attach(device_t dev)
 {
@@ -145,13 +154,16 @@ gpiomux_attach(device_t dev)
sc->numpins = i;
if (sc->numpins == 0) {
device_printf(dev, "cannot acquire pins listed in mux-gpios\n");
-   return ((err == 0) ? ENXIO : err);
+   if (err == 0)
+   err = ENXIO;
+   goto errexit;
}
numchannels = 1u << sc->numpins;
if (numchannels > IICMUX_MAX_BUSES) {
device_printf(dev, "too many mux-gpios pins for max %d buses\n",
IICMUX_MAX_BUSES);
-   return (EINVAL);
+   err = EINVAL;
+   goto errexit;
}
 
/*
@@ -163,13 +175,15 @@ gpiomux_attach(device_t dev)
len = OF_getencprop(node, "i2c-parent", , sizeof(propval));
if (len != sizeof(propval)) {
device_printf(dev, "cannot obtain i2c-parent property\n");
-   return (ENXIO);
+   err = ENXIO;
+   goto errexit;
}
busdev = OF_device_from_xref((phandle_t)propval);
if (busdev == NULL) {
device_printf(dev,
"cannot find device referenced by i2c-parent property\n");
-   return (ENXIO);
+   err = ENXIO;
+   goto errexit;
}
device_printf(dev, "upstream bus is %s\n", device_get_nameunit(busdev));
 
@@ -202,6 +216,11 @@ gpiomux_attach(device_t dev)
if ((err = iicmux_attach(dev, busdev, numchannels)) == 0)
bus_generic_attach(dev);
 
+errexit:
+
+   if (err != 0)
+   gpiomux_release_pins(sc);
+
return (err);
 }
 
@@ -209,13 +228,12 @@ static int
 gpiomux_detach(device_t dev)
 {
struct gpiomux_softc *sc = device_get_softc(dev);
-   int err, i;
+   int err;
 
if ((err = iicmux_detach(dev)) != 0)
return (err);
 
-   for (i = 0; i < sc->numpins; ++i)
-   gpio_pin_release(sc->pins[i]);
+   gpiomux_release_pins(sc);
 
return (0);
 }
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r356518 - stable/12

2020-01-08 Thread Dimitry Andric
Author: dim
Date: Wed Jan  8 21:22:44 2020
New Revision: 356518
URL: https://svnweb.freebsd.org/changeset/base/356518

Log:
  MFC r354859:
  
  WITH_SYSTEM_LINKER: Fix rebuilding lld every time.
  
  This is due to LLD_REVISION_STRING being renamed to LLD_REVISION in
  r351442 and the value being moved to another location in r351965.
  
  `make test-system-linker` can be used to see the values being used here.
  
  Reported by:  ler

Modified:
  stable/12/Makefile.inc1
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/Makefile.inc1
==
--- stable/12/Makefile.inc1 Wed Jan  8 21:07:55 2020(r356517)
+++ stable/12/Makefile.inc1 Wed Jan  8 21:22:44 2020(r356518)
@@ -279,9 +279,9 @@ WANT_LINKER_TYPE=
 .if !defined(WANT_LINKER_FREEBSD_VERSION) && !make(showconfig) && \
 !make(test-system-compiler)
 .if ${WANT_LINKER_TYPE} == "lld"
-WANT_LINKER_FREEBSD_VERSION_FILE= lib/clang/include/lld/Common/Version.inc
+WANT_LINKER_FREEBSD_VERSION_FILE= lib/clang/include/VCSVersion.inc
 WANT_LINKER_FREEBSD_VERSION!= \
-   awk '$$2 == "LLD_REVISION_STRING" {gsub(/"/, "", $$3); print $$3}' \
+   awk '$$2 == "LLD_REVISION" {gsub(/"/, "", $$3); print $$3}' \
${SRCDIR}/${WANT_LINKER_FREEBSD_VERSION_FILE} || echo unknown
 WANT_LINKER_VERSION_FILE= lib/clang/include/lld/Common/Version.inc
 WANT_LINKER_VERSION!= \
___
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: r356517 - in head/gnu/lib: . libgcc

2020-01-08 Thread Ed Maste
Author: emaste
Date: Wed Jan  8 21:07:55 2020
New Revision: 356517
URL: https://svnweb.freebsd.org/changeset/base/356517

Log:
  Retire build support for GCC's DWARF unwinder
  
  As of r356514 LLVM's libunwind is used as the DWARF unwinder on all
  supported CPU architectures, and GCC and its libraries will be removed
  soon.  Retire the build infrastructure for GCC's unwinder; from here
  if there are any unwinder bugs (on any arch) the path forward is to fix
  LLVM's libunwind.

Deleted:
  head/gnu/lib/libgcc/
Modified:
  head/gnu/lib/Makefile

Modified: head/gnu/lib/Makefile
==
--- head/gnu/lib/Makefile   Wed Jan  8 20:56:30 2020(r356516)
+++ head/gnu/lib/Makefile   Wed Jan  8 21:07:55 2020(r356517)
@@ -19,10 +19,6 @@ SUBDIR+= csu
 SUBDIR+=   libregex
 .endif
 
-.if ${MK_LLVM_LIBUNWIND} == "no"
-SUBDIR+=   libgcc
-.endif
-
 # libsupc++ uses libstdc++ headers, although 'make includes' should
 # have taken care of that already.
 .if ${MK_GNUCXX} != "no"
___
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: r356516 - head

2020-01-08 Thread Ed Maste
Author: emaste
Date: Wed Jan  8 20:56:30 2020
New Revision: 356516
URL: https://svnweb.freebsd.org/changeset/base/356516

Log:
  Remove prereq lib support for GNU unwinder
  
  LLVM's libunwind is used for all archs, as of r356514.  As GCC 4.2.1
  will soon be removed, and with it the GNU unwinder, start simplifying
  the prereq/startup lib logic in Makefile.inc1.  From here if there are
  any unwinder bugs (on any arch) the path foward is to fix LLVM's
  libunwind.

Modified:
  head/Makefile.inc1

Modified: head/Makefile.inc1
==
--- head/Makefile.inc1  Wed Jan  8 20:51:07 2020(r356515)
+++ head/Makefile.inc1  Wed Jan  8 20:56:30 2020(r356516)
@@ -2815,17 +2815,6 @@ lib/libgcc_s__L: lib/libc_nonshared__L
 .if ${MK_LIBCPLUSPLUS} != "no"
 lib/libcxxrt__L: lib/libgcc_s__L
 .endif
-
-.else # MK_LLVM_LIBUNWIND == no
-
-_prereq_libs+= gnu/lib/libgcc
-_startup_libs+=gnu/lib/libgcc
-
-gnu/lib/libgcc__L: lib/libc__L
-gnu/lib/libgcc__L: lib/libc_nonshared__L
-.if ${MK_LIBCPLUSPLUS} != "no"
-lib/libcxxrt__L: gnu/lib/libgcc__L
-.endif
 .endif
 
 _prebuild_libs=${_kerberos5_lib_libasn1} \
___
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: r356515 - head/share/mk

2020-01-08 Thread Ed Maste
Author: emaste
Date: Wed Jan  8 20:51:07 2020
New Revision: 356515
URL: https://svnweb.freebsd.org/changeset/base/356515

Log:
  src.opts.mk: Remove sparc64 LLVM_LIBUNWIND BROKEN_OPTIONS
  
  After r356513 it should build.

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

Modified: head/share/mk/src.opts.mk
==
--- head/share/mk/src.opts.mk   Wed Jan  8 20:45:18 2020(r356514)
+++ head/share/mk/src.opts.mk   Wed Jan  8 20:51:07 2020(r356515)
@@ -392,8 +392,6 @@ BROKEN_OPTIONS+=NVME
 .if ${__T:Msparc64}
 # Sparc64 need extra crt*.o files - PR 239851
 BROKEN_OPTIONS+=BSD_CRTBEGIN
-# PR 233405
-BROKEN_OPTIONS+=LLVM_LIBUNWIND
 .endif
 
 .if ${COMPILER_FEATURES:Mc++11} && \
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r356514 - head/share/mk

2020-01-08 Thread Warner Losh
On Wed, Jan 8, 2020 at 1:45 PM Ed Maste  wrote:

> Author: emaste
> Date: Wed Jan  8 20:45:18 2020
> New Revision: 356514
> URL: https://svnweb.freebsd.org/changeset/base/356514
>
> Log:
>   src.opts.mk: enable LLVM_UNWIND by default for all archs
>
>   Only sparc64 did not enable LLVM_LIBUNWIND. After r356513 LLVM_LIBUNWIND
>   should at least build on sparc64. The old DWARF unwinder will be removed
>   along with GCC 4.2.1 in the near future, so switch sparc64 to use LLVM's
>   unwinder in advance of the removal.  Someone with access to the obsolete
>   sparc64 hardware supported by FreeBSD will have to test, and investigate
>   any failures. I will gladly help, but I don't have any suitable hardware
>   myself.
>
>   PR:   233405
>

One fewer option defaults based on Arch! And there was much rejoicing.

Warner


> Modified:
>   head/share/mk/src.opts.mk
>
> Modified: head/share/mk/src.opts.mk
>
> ==
> --- head/share/mk/src.opts.mk   Wed Jan  8 20:37:03 2020(r356513)
> +++ head/share/mk/src.opts.mk   Wed Jan  8 20:45:18 2020(r356514)
> @@ -129,6 +129,7 @@ __DEFAULT_YES_OPTIONS = \
>  LIBPTHREAD \
>  LIBTHR \
>  LLVM_COV \
> +LLVM_LIBUNWIND \
>  LLVM_TARGET_ALL \
>  LOADER_GELI \
>  LOADER_LUA \
> @@ -315,11 +316,6 @@ BROKEN_OPTIONS+=BINUTILS BINUTILS_BOOTSTRAP GCC GCC_BO
>  .endif
>  .if ${__T:Mriscv*} != ""
>  BROKEN_OPTIONS+=OFED
> -.endif
> -.if ${__T} != "sparc64"
> -__DEFAULT_YES_OPTIONS+=LLVM_LIBUNWIND
> -.else
> -__DEFAULT_NO_OPTIONS+=LLVM_LIBUNWIND
>  .endif
>  .if ${__TT} != "mips" && ${__T} != "powerpc" && ${__T} != "powerpcspe" &&
> \
>  ${__T} != "sparc64"
>
___
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: r356514 - head/share/mk

2020-01-08 Thread Ed Maste
Author: emaste
Date: Wed Jan  8 20:45:18 2020
New Revision: 356514
URL: https://svnweb.freebsd.org/changeset/base/356514

Log:
  src.opts.mk: enable LLVM_UNWIND by default for all archs
  
  Only sparc64 did not enable LLVM_LIBUNWIND. After r356513 LLVM_LIBUNWIND
  should at least build on sparc64. The old DWARF unwinder will be removed
  along with GCC 4.2.1 in the near future, so switch sparc64 to use LLVM's
  unwinder in advance of the removal.  Someone with access to the obsolete
  sparc64 hardware supported by FreeBSD will have to test, and investigate
  any failures. I will gladly help, but I don't have any suitable hardware
  myself.
  
  PR:   233405

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

Modified: head/share/mk/src.opts.mk
==
--- head/share/mk/src.opts.mk   Wed Jan  8 20:37:03 2020(r356513)
+++ head/share/mk/src.opts.mk   Wed Jan  8 20:45:18 2020(r356514)
@@ -129,6 +129,7 @@ __DEFAULT_YES_OPTIONS = \
 LIBPTHREAD \
 LIBTHR \
 LLVM_COV \
+LLVM_LIBUNWIND \
 LLVM_TARGET_ALL \
 LOADER_GELI \
 LOADER_LUA \
@@ -315,11 +316,6 @@ BROKEN_OPTIONS+=BINUTILS BINUTILS_BOOTSTRAP GCC GCC_BO
 .endif
 .if ${__T:Mriscv*} != ""
 BROKEN_OPTIONS+=OFED
-.endif
-.if ${__T} != "sparc64"
-__DEFAULT_YES_OPTIONS+=LLVM_LIBUNWIND
-.else
-__DEFAULT_NO_OPTIONS+=LLVM_LIBUNWIND
 .endif
 .if ${__TT} != "mips" && ${__T} != "powerpc" && ${__T} != "powerpcspe" && \
 ${__T} != "sparc64"
___
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: r356513 - in head/contrib/llvm-project/libunwind: include src

2020-01-08 Thread Ed Maste
Author: emaste
Date: Wed Jan  8 20:37:03 2020
New Revision: 356513
URL: https://svnweb.freebsd.org/changeset/base/356513

Log:
  libunwind: untested attempt to fix sparc64 build
  
  sparc64 is the only architecture currently using the DWARF unwinder from
  GCC 4.2.1.  Old GCC and related libraries are being removed soon; absent
  other changes sparc64 would be left with no unwinder when that happens.
  
  Instead, commit these changes which should at least allow the LLVM
  unwinder to build.  Someone with access to the obolete sparc64 hardware
  supported by FreeBSD will need to test the result.
  
  PR:   233405
  Submitted by: cem

Modified:
  head/contrib/llvm-project/libunwind/include/__libunwind_config.h
  head/contrib/llvm-project/libunwind/src/config.h

Modified: head/contrib/llvm-project/libunwind/include/__libunwind_config.h
==
--- head/contrib/llvm-project/libunwind/include/__libunwind_config.hWed Jan 
 8 19:08:44 2020(r356512)
+++ head/contrib/llvm-project/libunwind/include/__libunwind_config.hWed Jan 
 8 20:37:03 2020(r356513)
@@ -124,7 +124,7 @@
   #define _LIBUNWIND_TARGET_SPARC 1
   #define _LIBUNWIND_HIGHEST_DWARF_REGISTER 
_LIBUNWIND_HIGHEST_DWARF_REGISTER_SPARC
   #define _LIBUNWIND_CONTEXT_SIZE 16
-  #define _LIBUNWIND_CURSOR_SIZE 23
+  #define _LIBUNWIND_CURSOR_SIZE 28
 # else
 #  error "Unsupported architecture."
 # endif

Modified: head/contrib/llvm-project/libunwind/src/config.h
==
--- head/contrib/llvm-project/libunwind/src/config.hWed Jan  8 19:08:44 
2020(r356512)
+++ head/contrib/llvm-project/libunwind/src/config.hWed Jan  8 20:37:03 
2020(r356513)
@@ -104,7 +104,8 @@
 (!defined(__APPLE__) && defined(__arm__)) ||   
\
 (defined(__arm64__) || defined(__aarch64__)) ||
\
 defined(__mips__) ||   
\
-defined(__riscv)
+defined(__riscv) ||
\
+defined(__sparc__)
 #if !defined(_LIBUNWIND_BUILD_SJLJ_APIS)
 #define _LIBUNWIND_BUILD_ZERO_COST_APIS
 #endif
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r356512 - in head: sys/kern tests/sys/posixshm

2020-01-08 Thread Kyle Evans
Author: kevans
Date: Wed Jan  8 19:08:44 2020
New Revision: 356512
URL: https://svnweb.freebsd.org/changeset/base/356512

Log:
  posixshm: implement posix_fallocate(2)
  
  Linux expects to be able to use posix_fallocate(2) on a memfd. Other places
  would use this with shm_open(2) to act as a smarter ftruncate(2).
  
  Test has been added to go along with this.
  
  Reviewed by:  kib (earlier version)
  Differential Revision:https://reviews.freebsd.org/D23042

Modified:
  head/sys/kern/uipc_shm.c
  head/tests/sys/posixshm/posixshm_test.c

Modified: head/sys/kern/uipc_shm.c
==
--- head/sys/kern/uipc_shm.cWed Jan  8 19:06:22 2020(r356511)
+++ head/sys/kern/uipc_shm.cWed Jan  8 19:08:44 2020(r356512)
@@ -138,6 +138,7 @@ static fo_fill_kinfo_t  shm_fill_kinfo;
 static fo_mmap_t   shm_mmap;
 static fo_get_seals_t  shm_get_seals;
 static fo_add_seals_t  shm_add_seals;
+static fo_fallocate_t  shm_fallocate;
 
 /* File descriptor operations. */
 struct fileops shm_ops = {
@@ -157,6 +158,7 @@ struct fileops shm_ops = {
.fo_mmap = shm_mmap,
.fo_get_seals = shm_get_seals,
.fo_add_seals = shm_add_seals,
+   .fo_fallocate = shm_fallocate,
.fo_flags = DFLAG_PASSABLE | DFLAG_SEEKABLE
 };
 
@@ -1435,6 +1437,32 @@ shm_get_seals(struct file *fp, int *seals)
shmfd = fp->f_data;
*seals = shmfd->shm_seals;
return (0);
+}
+
+static int
+shm_fallocate(struct file *fp, off_t offset, off_t len, struct thread *td)
+{
+   void *rl_cookie;
+   struct shmfd *shmfd;
+   size_t size;
+   int error;
+
+   /* This assumes that the caller already checked for overflow. */
+   error = 0;
+   shmfd = fp->f_data;
+   size = offset + len;
+   rl_cookie = rangelock_wlock(>shm_rl, 0, OFF_MAX,
+   >shm_mtx);
+   if (size > shmfd->shm_size) {
+   VM_OBJECT_WLOCK(shmfd->shm_object);
+   error = shm_dotruncate_locked(shmfd, size, rl_cookie);
+   VM_OBJECT_WUNLOCK(shmfd->shm_object);
+   }
+   rangelock_unlock(>shm_rl, rl_cookie, >shm_mtx);
+   /* Translate to posix_fallocate(2) return value as needed. */
+   if (error == ENOMEM)
+   error = ENOSPC;
+   return (error);
 }
 
 static int

Modified: head/tests/sys/posixshm/posixshm_test.c
==
--- head/tests/sys/posixshm/posixshm_test.c Wed Jan  8 19:06:22 2020
(r356511)
+++ head/tests/sys/posixshm/posixshm_test.c Wed Jan  8 19:08:44 2020
(r356512)
@@ -918,6 +918,44 @@ ATF_TC_BODY(mode, tc)
umask(restore_mask);
 }
 
+ATF_TC_WITHOUT_HEAD(fallocate);
+ATF_TC_BODY(fallocate, tc)
+{
+   struct stat st;
+   int error, fd, sz;
+
+   /*
+* Primitive test case for posix_fallocate with shmd.  Effectively
+* expected to work like a smarter ftruncate that will grow the region
+* as needed in a race-free way.
+*/
+   fd = shm_open(SHM_ANON, O_RDWR, 0666);
+   ATF_REQUIRE_MSG(fd >= 0, "shm_open failed; errno=%d", errno);
+   /* Set the initial size. */
+   sz = 32;
+   ATF_REQUIRE(ftruncate(fd, sz) == 0);
+
+   /* Now grow it. */
+   error = 0;
+   sz *= 2;
+   ATF_REQUIRE_MSG((error = posix_fallocate(fd, 0, sz)) == 0,
+   "posix_fallocate failed; error=%d", error);
+   ATF_REQUIRE(fstat(fd, ) == 0);
+   ATF_REQUIRE(st.st_size == sz);
+   /* Attempt to shrink it; should succeed, but not change the size. */
+   ATF_REQUIRE_MSG((error = posix_fallocate(fd, 0, sz / 2)) == 0,
+   "posix_fallocate failed; error=%d", error);
+   ATF_REQUIRE(fstat(fd, ) == 0);
+   ATF_REQUIRE(st.st_size == sz);
+   /* Grow it using an offset of sz and len of sz. */
+   ATF_REQUIRE_MSG((error = posix_fallocate(fd, sz, sz)) == 0,
+   "posix_fallocate failed; error=%d", error);
+   ATF_REQUIRE(fstat(fd, ) == 0);
+   ATF_REQUIRE(st.st_size == (sz * 2));
+
+   close(fd);
+}
+
 ATF_TP_ADD_TCS(tp)
 {
 
@@ -951,6 +989,7 @@ ATF_TP_ADD_TCS(tp)
ATF_TP_ADD_TC(tp, object_resize);
ATF_TP_ADD_TC(tp, cloexec);
ATF_TP_ADD_TC(tp, mode);
+   ATF_TP_ADD_TC(tp, fallocate);
 
return (atf_no_error());
 }
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r356511 - head/sys/sys

2020-01-08 Thread Kyle Evans
Author: kevans
Date: Wed Jan  8 19:06:22 2020
New Revision: 356511
URL: https://svnweb.freebsd.org/changeset/base/356511

Log:
  Bump __FreeBSD_version after r356510
  
  linuxkpi kmod would need to rebuilt at a minimum; fileops layout has
  changed.

Modified:
  head/sys/sys/param.h

Modified: head/sys/sys/param.h
==
--- head/sys/sys/param.hWed Jan  8 19:05:32 2020(r356510)
+++ head/sys/sys/param.hWed Jan  8 19:06:22 2020(r356511)
@@ -60,7 +60,7 @@
  * in the range 5 to 9.
  */
 #undef __FreeBSD_version
-#define __FreeBSD_version 1300075  /* Master, propagated to newvers */
+#define __FreeBSD_version 1300076  /* Master, propagated to newvers */
 
 /*
  * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD,
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r356510 - in head: lib/libc/sys sys/kern sys/sys

2020-01-08 Thread Kyle Evans
Author: kevans
Date: Wed Jan  8 19:05:32 2020
New Revision: 356510
URL: https://svnweb.freebsd.org/changeset/base/356510

Log:
  posix_fallocate: push vnop implementation into the fileop layer
  
  This opens the door for other descriptor types to implement
  posix_fallocate(2) as needed.
  
  Reviewed by:  kib, bcr (manpages)
  Differential Revision:https://reviews.freebsd.org/D23042

Modified:
  head/lib/libc/sys/posix_fallocate.2
  head/sys/kern/sys_generic.c
  head/sys/kern/vfs_syscalls.c
  head/sys/kern/vfs_vnops.c
  head/sys/sys/file.h

Modified: head/lib/libc/sys/posix_fallocate.2
==
--- head/lib/libc/sys/posix_fallocate.2 Wed Jan  8 19:05:23 2020
(r356509)
+++ head/lib/libc/sys/posix_fallocate.2 Wed Jan  8 19:05:32 2020
(r356510)
@@ -28,7 +28,7 @@
 .\" @(#)open.2 8.2 (Berkeley) 11/16/93
 .\" $FreeBSD$
 .\"
-.Dd November 4, 2017
+.Dd January 5, 2020
 .Dt POSIX_FALLOCATE 2
 .Os
 .Sh NAME
@@ -115,7 +115,8 @@ An I/O error occurred while reading from or writing to
 .It Bq Er ENODEV
 The
 .Fa fd
-argument does not refer to a regular file.
+argument does not refer to a file that supports
+.Nm .
 .It Bq Er ENOSPC
 There is insufficient free space remaining on the file system storage
 media.

Modified: head/sys/kern/sys_generic.c
==
--- head/sys/kern/sys_generic.c Wed Jan  8 19:05:23 2020(r356509)
+++ head/sys/kern/sys_generic.c Wed Jan  8 19:05:32 2020(r356510)
@@ -819,6 +819,47 @@ out:
 }
 
 int
+sys_posix_fallocate(struct thread *td, struct posix_fallocate_args *uap)
+{
+   int error;
+
+   error = kern_posix_fallocate(td, uap->fd, uap->offset, uap->len);
+   return (kern_posix_error(td, error));
+}
+
+int
+kern_posix_fallocate(struct thread *td, int fd, off_t offset, off_t len)
+{
+   struct file *fp;
+   int error;
+
+   AUDIT_ARG_FD(fd);
+   if (offset < 0 || len <= 0)
+   return (EINVAL);
+   /* Check for wrap. */
+   if (offset > OFF_MAX - len)
+   return (EFBIG);
+   AUDIT_ARG_FD(fd);
+   error = fget(td, fd, _pwrite_rights, );
+   if (error != 0)
+   return (error);
+   AUDIT_ARG_FILE(td->td_proc, fp);
+   if ((fp->f_ops->fo_flags & DFLAG_SEEKABLE) == 0) {
+   error = ESPIPE;
+   goto out;
+   }
+   if ((fp->f_flag & FWRITE) == 0) {
+   error = EBADF;
+   goto out;
+   }
+
+   error = fo_fallocate(fp, offset, len, td);
+ out:
+   fdrop(fp, td);
+   return (error);
+}
+
+int
 poll_no_poll(int events)
 {
/*

Modified: head/sys/kern/vfs_syscalls.c
==
--- head/sys/kern/vfs_syscalls.cWed Jan  8 19:05:23 2020
(r356509)
+++ head/sys/kern/vfs_syscalls.cWed Jan  8 19:05:32 2020
(r356510)
@@ -4565,99 +4565,6 @@ out:
return (error);
 }
 
-int
-kern_posix_fallocate(struct thread *td, int fd, off_t offset, off_t len)
-{
-   struct file *fp;
-   struct mount *mp;
-   struct vnode *vp;
-   off_t olen, ooffset;
-   int error;
-#ifdef AUDIT
-   int audited_vnode1 = 0;
-#endif
-
-   AUDIT_ARG_FD(fd);
-   if (offset < 0 || len <= 0)
-   return (EINVAL);
-   /* Check for wrap. */
-   if (offset > OFF_MAX - len)
-   return (EFBIG);
-   AUDIT_ARG_FD(fd);
-   error = fget(td, fd, _pwrite_rights, );
-   if (error != 0)
-   return (error);
-   AUDIT_ARG_FILE(td->td_proc, fp);
-   if ((fp->f_ops->fo_flags & DFLAG_SEEKABLE) == 0) {
-   error = ESPIPE;
-   goto out;
-   }
-   if ((fp->f_flag & FWRITE) == 0) {
-   error = EBADF;
-   goto out;
-   }
-   if (fp->f_type != DTYPE_VNODE) {
-   error = ENODEV;
-   goto out;
-   }
-   vp = fp->f_vnode;
-   if (vp->v_type != VREG) {
-   error = ENODEV;
-   goto out;
-   }
-
-   /* Allocating blocks may take a long time, so iterate. */
-   for (;;) {
-   olen = len;
-   ooffset = offset;
-
-   bwillwrite();
-   mp = NULL;
-   error = vn_start_write(vp, , V_WAIT | PCATCH);
-   if (error != 0)
-   break;
-   error = vn_lock(vp, LK_EXCLUSIVE);
-   if (error != 0) {
-   vn_finished_write(mp);
-   break;
-   }
-#ifdef AUDIT
-   if (!audited_vnode1) {
-   AUDIT_ARG_VNODE1(vp);
-   audited_vnode1 = 1;
-   }
-#endif
-#ifdef MAC
-   error = mac_vnode_check_write(td->td_ucred, fp->f_cred, vp);
-   if (error == 0)
-#endif
-   

svn commit: r356509 - head/sys/opencrypto

2020-01-08 Thread John Baldwin
Author: jhb
Date: Wed Jan  8 19:05:23 2020
New Revision: 356509
URL: https://svnweb.freebsd.org/changeset/base/356509

Log:
  Remove unneeded cdevsw methods and D_NEEDGIANT.
  
  Reviewed by:  kib
  MFC after:2 weeks
  Sponsored by: Chelsio Communications
  Differential Revision:https://reviews.freebsd.org/D23079

Modified:
  head/sys/opencrypto/cryptodev.c

Modified: head/sys/opencrypto/cryptodev.c
==
--- head/sys/opencrypto/cryptodev.c Wed Jan  8 19:03:24 2020
(r356508)
+++ head/sys/opencrypto/cryptodev.c Wed Jan  8 19:05:23 2020
(r356509)
@@ -1473,24 +1473,6 @@ csefree(struct csession *cse)
 }
 
 static int
-cryptoopen(struct cdev *dev, int oflags, int devtype, struct thread *td)
-{
-   return (0);
-}
-
-static int
-cryptoread(struct cdev *dev, struct uio *uio, int ioflag)
-{
-   return (EIO);
-}
-
-static int
-cryptowrite(struct cdev *dev, struct uio *uio, int ioflag)
-{
-   return (EIO);
-}
-
-static int
 cryptoioctl(struct cdev *dev, u_long cmd, caddr_t data, int flag, struct 
thread *td)
 {
struct file *f;
@@ -1531,10 +1513,6 @@ cryptoioctl(struct cdev *dev, u_long cmd, caddr_t data
 
 static struct cdevsw crypto_cdevsw = {
.d_version =D_VERSION,
-   .d_flags =  D_NEEDGIANT,
-   .d_open =   cryptoopen,
-   .d_read =   cryptoread,
-   .d_write =  cryptowrite,
.d_ioctl =  cryptoioctl,
.d_name =   "crypto",
 };
___
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: r356508 - head/sys/opencrypto

2020-01-08 Thread John Baldwin
Author: jhb
Date: Wed Jan  8 19:03:24 2020
New Revision: 356508
URL: https://svnweb.freebsd.org/changeset/base/356508

Log:
  Use falloc_noinstall + finstall for crypto file descriptors.
  
  Reviewed by:  cem, kib
  MFC after:1 week
  Sponsored by: Chelsio Communications
  Differential Revision:https://reviews.freebsd.org/D23078

Modified:
  head/sys/opencrypto/cryptodev.c

Modified: head/sys/opencrypto/cryptodev.c
==
--- head/sys/opencrypto/cryptodev.c Wed Jan  8 18:59:23 2020
(r356507)
+++ head/sys/opencrypto/cryptodev.c Wed Jan  8 19:03:24 2020
(r356508)
@@ -1499,20 +1499,21 @@ cryptoioctl(struct cdev *dev, u_long cmd, caddr_t data
 
switch (cmd) {
case CRIOGET:
+   error = falloc_noinstall(td, );
+   if (error)
+   break;
+
fcr = malloc(sizeof(struct fcrypt), M_XDATA, M_WAITOK | M_ZERO);
TAILQ_INIT(>csessions);
mtx_init(>lock, "fcrypt", NULL, MTX_DEF);
 
-   error = falloc(td, , , 0);
-
+   finit(f, FREAD | FWRITE, DTYPE_CRYPTO, fcr, );
+   error = finstall(td, f, , 0, NULL);
if (error) {
mtx_destroy(>lock);
free(fcr, M_XDATA);
-   return (error);
-   }
-   /* falloc automatically provides an extra reference to 'f'. */
-   finit(f, FREAD | FWRITE, DTYPE_CRYPTO, fcr, );
-   *(u_int32_t *)data = fd;
+   } else
+   *(uint32_t *)data = fd;
fdrop(f, td);
break;
case CRIOFINDDEV:
___
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: r356507 - head/sys/opencrypto

2020-01-08 Thread John Baldwin
Author: jhb
Date: Wed Jan  8 18:59:23 2020
New Revision: 356507
URL: https://svnweb.freebsd.org/changeset/base/356507

Log:
  Add a reference count to cryptodev sessions.
  
  This prevents use-after-free races with crypto requests (which may
  sleep) and CIOCFSESSION as well as races from current CIOCFSESSION
  requests.
  
  admbugs:  949
  Reported by:  Yuval Kanarenstein 
  Reviewed by:  cem
  MFC after:1 week
  Sponsored by: Chelsio Communications
  Differential Revision:https://reviews.freebsd.org/D23077

Modified:
  head/sys/opencrypto/cryptodev.c

Modified: head/sys/opencrypto/cryptodev.c
==
--- head/sys/opencrypto/cryptodev.c Wed Jan  8 18:26:23 2020
(r356506)
+++ head/sys/opencrypto/cryptodev.c Wed Jan  8 18:59:23 2020
(r356507)
@@ -266,6 +266,7 @@ crypt_kop_to_32(const struct crypt_kop *from, struct c
 struct csession {
TAILQ_ENTRY(csession) next;
crypto_session_t cses;
+   volatile u_int  refs;
u_int32_t   ses;
struct mtx  lock;   /* for op submission */
 
@@ -292,6 +293,7 @@ struct cryptop_data {
 struct fcrypt {
TAILQ_HEAD(csessionlist, csession) csessions;
int sesn;
+   struct mtx  lock;
 };
 
 static struct timeval warninterval = { .tv_sec = 60, .tv_usec = 0 };
@@ -323,8 +325,8 @@ static struct fileops cryptofops = {
 };
 
 static struct csession *csefind(struct fcrypt *, u_int);
-static int csedelete(struct fcrypt *, struct csession *);
-static struct csession *cseadd(struct fcrypt *, struct csession *);
+static bool csedelete(struct fcrypt *, u_int);
+static void cseadd(struct fcrypt *, struct csession *);
 static struct csession *csecreate(struct fcrypt *, crypto_session_t, caddr_t,
 u_int64_t, caddr_t, u_int64_t, u_int32_t, u_int32_t, struct enc_xform *,
 struct auth_hash *);
@@ -668,13 +670,10 @@ bail:
break;
case CIOCFSESSION:
ses = *(u_int32_t *)data;
-   cse = csefind(fcr, ses);
-   if (cse == NULL) {
+   if (!csedelete(fcr, ses)) {
SDT_PROBE1(opencrypto, dev, ioctl, error, __LINE__);
return (EINVAL);
}
-   csedelete(fcr, cse);
-   csefree(cse);
break;
case CIOCCRYPT:
 #ifdef COMPAT_FREEBSD32
@@ -691,6 +690,7 @@ bail:
return (EINVAL);
}
error = cryptodev_op(cse, cop, active_cred, td);
+   csefree(cse);
 #ifdef COMPAT_FREEBSD32
if (error == 0 && cmd == CIOCCRYPT32)
crypt_op_to_32(cop, data);
@@ -757,6 +757,7 @@ bail:
return (EINVAL);
}
error = cryptodev_aead(cse, caead, active_cred, td);
+   csefree(cse);
break;
default:
error = EINVAL;
@@ -1375,6 +1376,9 @@ cryptof_close(struct file *fp, struct thread *td)
 
while ((cse = TAILQ_FIRST(>csessions))) {
TAILQ_REMOVE(>csessions, cse, next);
+   KASSERT(cse->refs == 1,
+   ("%s: crypto session %p with %d refs", __func__, cse,
+   cse->refs));
csefree(cse);
}
free(fcr, M_XDATA);
@@ -1395,34 +1399,36 @@ csefind(struct fcrypt *fcr, u_int ses)
 {
struct csession *cse;
 
-   TAILQ_FOREACH(cse, >csessions, next)
-   if (cse->ses == ses)
+   mtx_lock(>lock);
+   TAILQ_FOREACH(cse, >csessions, next) {
+   if (cse->ses == ses) {
+   refcount_acquire(>refs);
+   mtx_unlock(>lock);
return (cse);
+   }
+   }
+   mtx_unlock(>lock);
return (NULL);
 }
 
-static int
-csedelete(struct fcrypt *fcr, struct csession *cse_del)
+static bool
+csedelete(struct fcrypt *fcr, u_int ses)
 {
struct csession *cse;
 
+   mtx_lock(>lock);
TAILQ_FOREACH(cse, >csessions, next) {
-   if (cse == cse_del) {
+   if (cse->ses == ses) {
TAILQ_REMOVE(>csessions, cse, next);
-   return (1);
+   mtx_unlock(>lock);
+   csefree(cse);
+   return (true);
}
}
-   return (0);
+   mtx_unlock(>lock);
+   return (false);
 }

-static struct csession *
-cseadd(struct fcrypt *fcr, struct csession *cse)
-{
-   TAILQ_INSERT_TAIL(>csessions, cse, next);
-   cse->ses = fcr->sesn++;
-   return (cse);
-}
-
 struct csession *
 csecreate(struct fcrypt *fcr, crypto_session_t cses, caddr_t key, u_int64_t 
keylen,
 caddr_t mackey, u_int64_t mackeylen, u_int32_t cipher, u_int32_t mac,
@@ -1434,6 +1440,7 @@ csecreate(struct fcrypt *fcr, crypto_session_t cses, c

svn commit: r356506 - head/sys/dev/nvme

2020-01-08 Thread Alexander Motin
Author: mav
Date: Wed Jan  8 18:26:23 2020
New Revision: 356506
URL: https://svnweb.freebsd.org/changeset/base/356506

Log:
  Fix copy-paste bug in HMB free code.
  
  MFC after:2 weeks
  X-MFC-with:   r356474

Modified:
  head/sys/dev/nvme/nvme_ctrlr.c

Modified: head/sys/dev/nvme/nvme_ctrlr.c
==
--- head/sys/dev/nvme/nvme_ctrlr.c  Wed Jan  8 17:54:44 2020
(r356505)
+++ head/sys/dev/nvme/nvme_ctrlr.c  Wed Jan  8 18:26:23 2020
(r356506)
@@ -854,7 +854,7 @@ nvme_ctrlr_hmb_free(struct nvme_controller *ctrlr)
}
if (ctrlr->hmb_desc_tag) {
bus_dma_tag_destroy(ctrlr->hmb_desc_tag);
-   ctrlr->hmb_tag = NULL;
+   ctrlr->hmb_desc_tag = NULL;
}
for (i = 0; i < ctrlr->hmb_nchunks; i++) {
hmbc = >hmb_chunks[i];
___
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: r356505 - head/share/man/man5

2020-01-08 Thread Ed Maste
Author: emaste
Date: Wed Jan  8 17:54:44 2020
New Revision: 356505
URL: https://svnweb.freebsd.org/changeset/base/356505

Log:
  src.conf.5: regen after r356423 and r356499
  
  riscv now using Clang/lld, riscv64sf reenabled, and googletest adjusted
  to avoid only the affected fuse test on mips

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

Modified: head/share/man/man5/src.conf.5
==
--- head/share/man/man5/src.conf.5  Wed Jan  8 17:49:34 2020
(r356504)
+++ head/share/man/man5/src.conf.5  Wed Jan  8 17:54:44 2020
(r356505)
@@ -1,6 +1,6 @@
 .\" DO NOT EDIT-- this file is @generated by tools/build/options/makeman.
 .\" $FreeBSD$
-.Dd January 6, 2020
+.Dd January 8, 2020
 .Dt SRC.CONF 5
 .Os
 .Sh NAME
@@ -186,7 +186,7 @@ of the normal system build.
 The resulting system cannot build programs from source.
 .Pp
 This is a default setting on
-arm64/aarch64 and riscv/riscv64.
+arm64/aarch64, riscv/riscv64 and riscv/riscv64sf.
 .It Va WITH_BINUTILS
 Set to build and install GNU
 .Xr as 1 ,
@@ -197,7 +197,7 @@ as part
 of the normal system build.
 .Pp
 This is a default setting on
-amd64/amd64, arm/armv6, arm/armv7, i386/i386, powerpc/powerpc, 
powerpc/powerpc64, mips/mipsel, mips/mips, mips/mips64el, mips/mips64, 
mips/mipsn32, mips/mipselhf, mips/mipshf, mips/mips64elhf, mips/mips64hf and 
sparc64/sparc64.
+amd64/amd64, arm/armv6, arm/armv7, i386/i386, mips/mipsel, mips/mips, 
mips/mips64el, mips/mips64, mips/mipsn32, mips/mipselhf, mips/mipshf, 
mips/mips64elhf, mips/mips64hf, powerpc/powerpc, powerpc/powerpc64 and 
sparc64/sparc64.
 .It Va WITHOUT_BINUTILS_BOOTSTRAP
 Set to not build binutils (as, ld, and objdump)
 as part of the bootstrap process.
@@ -207,7 +207,7 @@ toolchain is provided.
 .Ef
 .Pp
 This is a default setting on
-arm64/aarch64, riscv/riscv64, mips/mipsel, mips/mips, mips/mips64el, 
mips/mips64, mips/mipsn32, mips/mipselhf, mips/mipshf, mips/mips64elhf, 
mips/mips64hf and sparc64/sparc64.
+arm64/aarch64, mips/mipsel, mips/mips, mips/mips64el, mips/mips64, 
mips/mipsn32, mips/mipselhf, mips/mipshf, mips/mips64elhf, mips/mips64hf, 
riscv/riscv64, riscv/riscv64sf and sparc64/sparc64.
 .It Va WITH_BINUTILS_BOOTSTRAP
 Set build binutils (as, ld, and objdump)
 as part of the bootstrap process.
@@ -268,7 +268,7 @@ and
 .Pa crtend.o .
 .Pp
 This is a default setting on
-amd64/amd64, arm/armv6, arm/armv7, arm64/aarch64, i386/i386, powerpc/powerpc, 
powerpc/powerpc64, riscv/riscv64, mips/mipsel, mips/mips, mips/mips64el, 
mips/mips64, mips/mipsn32, mips/mipselhf, mips/mipshf, mips/mips64elhf and 
mips/mips64hf.
+amd64/amd64, arm/armv6, arm/armv7, arm64/aarch64, i386/i386, mips/mipsel, 
mips/mips, mips/mips64el, mips/mips64, mips/mipsn32, mips/mipselhf, 
mips/mipshf, mips/mips64elhf, mips/mips64hf, powerpc/powerpc, 
powerpc/powerpc64, riscv/riscv64 and riscv/riscv64sf.
 .It Va WITH_BSD_GREP
 Install BSD-licensed grep as '[ef]grep' instead of GNU grep.
 .It Va WITHOUT_BSNMP
@@ -380,7 +380,7 @@ When set, it enforces these options:
 Set to build the Clang C/C++ compiler during the normal phase of the build.
 .Pp
 This is a default setting on
-amd64/amd64, arm/armv6, arm/armv7, arm64/aarch64, i386/i386, powerpc/powerpc, 
powerpc/powerpc64, riscv/riscv64, mips/mipsel, mips/mips, mips/mips64el, 
mips/mips64, mips/mipsn32, mips/mipselhf, mips/mipshf, mips/mips64elhf and 
mips/mips64hf.
+amd64/amd64, arm/armv6, arm/armv7, arm64/aarch64, i386/i386, mips/mipsel, 
mips/mips, mips/mips64el, mips/mips64, mips/mipsn32, mips/mipselhf, 
mips/mipshf, mips/mips64elhf, mips/mips64hf, powerpc/powerpc, 
powerpc/powerpc64, riscv/riscv64 and riscv/riscv64sf.
 .It Va WITHOUT_CLANG_BOOTSTRAP
 Set to not build the Clang C/C++ compiler during the bootstrap phase of
 the build.
@@ -388,12 +388,12 @@ To be able to build the system, either gcc or clang bo
 enabled unless an alternate compiler is provided via XCC.
 .Pp
 This is a default setting on
-riscv/riscv64, mips/mipsel, mips/mips, mips/mips64el, mips/mips64, 
mips/mipsn32, mips/mipselhf, mips/mipshf, mips/mips64elhf, mips/mips64hf and 
sparc64/sparc64.
+mips/mipsel, mips/mips, mips/mips64el, mips/mips64, mips/mipsn32, 
mips/mipselhf, mips/mipshf, mips/mips64elhf, mips/mips64hf and sparc64/sparc64.
 .It Va WITH_CLANG_BOOTSTRAP
 Set to build the Clang C/C++ compiler during the bootstrap phase of the build.
 .Pp
 This is a default setting on
-amd64/amd64, arm/armv6, arm/armv7, arm64/aarch64, i386/i386, powerpc/powerpc 
and powerpc/powerpc64.
+amd64/amd64, arm/armv6, arm/armv7, arm64/aarch64, i386/i386, powerpc/powerpc, 
powerpc/powerpc64, riscv/riscv64 and riscv/riscv64sf.
 .It Va WITH_CLANG_EXTRAS
 Set to build additional clang and llvm tools, such as bugpoint and
 clang-format.
@@ -408,7 +408,7 @@ Set to build the ARCMigrate, Rewriter and StaticAnalyz
 Clang C/C++ compiler.
 .Pp
 This is a default setting on
-amd64/amd64, arm/armv6, arm/armv7, arm64/aarch64, i386/i386, 

svn commit: r356504 - head/share/mk

2020-01-08 Thread John Baldwin
Author: jhb
Date: Wed Jan  8 17:49:34 2020
New Revision: 356504
URL: https://svnweb.freebsd.org/changeset/base/356504

Log:
  Add -mno-relax to CFLAGS in bsd.prog/lib.mk instead of bsd.cpu.mk.
  
  bsd.cpu.mk is included by bsd.init.mk before bsd.linker.mk, so it
  was always setting the flag since LINKER_FEATURES wasn't defined.
  
  Reported by:  mhorne
  Reviewed by:  imp, mhorne
  Sponsored by: DARPA
  Differential Revision:https://reviews.freebsd.org/D23076

Modified:
  head/share/mk/bsd.cpu.mk
  head/share/mk/bsd.lib.mk
  head/share/mk/bsd.prog.mk

Modified: head/share/mk/bsd.cpu.mk
==
--- head/share/mk/bsd.cpu.mkWed Jan  8 17:37:20 2020(r356503)
+++ head/share/mk/bsd.cpu.mkWed Jan  8 17:49:34 2020(r356504)
@@ -375,10 +375,6 @@ CFLAGS += -march=rv64imac -mabi=lp64
 .else
 CFLAGS += -march=rv64imafdc -mabi=lp64d
 .endif
-
-.if ${LINKER_FEATURES:U:Mriscv-relaxations} == ""
-CFLAGS += -mno-relax
-.endif
 .endif
 
 # NB: COPTFLAGS is handled in /usr/src/sys/conf/kern.pre.mk

Modified: head/share/mk/bsd.lib.mk
==
--- head/share/mk/bsd.lib.mkWed Jan  8 17:37:20 2020(r356503)
+++ head/share/mk/bsd.lib.mkWed Jan  8 17:49:34 2020(r356504)
@@ -98,6 +98,10 @@ STATIC_CFLAGS+= -ftls-model=initial-exec
 STATIC_CXXFLAGS+= -ftls-model=initial-exec
 .endif
 
+.if ${MACHINE_CPUARCH} == "riscv" && ${LINKER_FEATURES:Mriscv-relaxations} == 
""
+CFLAGS += -mno-relax
+.endif
+
 .include 
 
 # prefer .s to a .c, add .po, remove stuff not used in the BSD libraries

Modified: head/share/mk/bsd.prog.mk
==
--- head/share/mk/bsd.prog.mk   Wed Jan  8 17:37:20 2020(r356503)
+++ head/share/mk/bsd.prog.mk   Wed Jan  8 17:49:34 2020(r356504)
@@ -57,6 +57,10 @@ LDFLAGS+= -Wl,-zretpolineplt
 .endif
 .endif
 
+.if ${MACHINE_CPUARCH} == "riscv" && ${LINKER_FEATURES:Mriscv-relaxations} == 
""
+CFLAGS += -mno-relax
+.endif
+
 .if defined(CRUNCH_CFLAGS)
 CFLAGS+=${CRUNCH_CFLAGS}
 .else
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r356503 - head/libexec/rtld-elf

2020-01-08 Thread Konstantin Belousov
Author: kib
Date: Wed Jan  8 17:37:20 2020
New Revision: 356503
URL: https://svnweb.freebsd.org/changeset/base/356503

Log:
  rtld: fix after r356300
  
  binpath local was changed from char array to a char pointer, update
  strlcpy/strlcat uses.
  
  Reported by:  Coverity through vangyzen
  CID:  1412239 and 1412240
  Reviewed by:  emaste, imp, vangyzen
  Sponsored by: The FreeBSD Foundation
  MFC after:1 week
  Differential revision:https://reviews.freebsd.org/D23090

Modified:
  head/libexec/rtld-elf/rtld.c

Modified: head/libexec/rtld-elf/rtld.c
==
--- head/libexec/rtld-elf/rtld.cWed Jan  8 17:31:54 2020
(r356502)
+++ head/libexec/rtld-elf/rtld.cWed Jan  8 17:37:20 2020
(r356503)
@@ -5531,15 +5531,12 @@ open_binary_fd(const char *argv0, bool search_in_path,
fd = -1;
errno = ENOENT;
while ((pe = strsep(, ":")) != NULL) {
-   if (strlcpy(binpath, pe, sizeof(binpath)) >=
-   sizeof(binpath))
+   if (strlcpy(binpath, pe, PATH_MAX) >= PATH_MAX)
continue;
if (binpath[0] != '\0' &&
-   strlcat(binpath, "/", sizeof(binpath)) >=
-   sizeof(binpath))
+   strlcat(binpath, "/", PATH_MAX) >= PATH_MAX)
continue;
-   if (strlcat(binpath, argv0, sizeof(binpath)) >=
-   sizeof(binpath))
+   if (strlcat(binpath, argv0, PATH_MAX) >= PATH_MAX)
continue;
fd = open(binpath, O_RDONLY | O_CLOEXEC | O_VERIFY);
if (fd != -1 || errno != ENOENT) {
___
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: r356502 - head

2020-01-08 Thread John Baldwin
Author: jhb
Date: Wed Jan  8 17:31:54 2020
New Revision: 356502
URL: https://svnweb.freebsd.org/changeset/base/356502

Log:
  Add notes for MAKE_OBSOLETE_GCC going away and riscv switching to clang/lld.

Modified:
  head/UPDATING

Modified: head/UPDATING
==
--- head/UPDATING   Wed Jan  8 17:31:18 2020(r356501)
+++ head/UPDATING   Wed Jan  8 17:31:54 2020(r356502)
@@ -26,6 +26,15 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 13.x IS SLOW:
disable the most expensive debugging functionality run
"ln -s 'abort:false,junk:false' /etc/malloc.conf".)
 
+20200108:
+   Clang/LLVM is now the default compiler and LLD the default
+   linker for riscv64.
+
+20200107:
+   make universe no longer uses GCC 4.2.1 on any architectures.
+   Architectures not supported by in-tree Clang/LLVM require an
+   external toolchain package.
+
 20200104:
GCC 4.2.1 is now not built by default, as part of the GCC 4.2.1
retirement plan.  Specifically, the GCC, GCC_BOOTSTRAP, and GNUCXX
___
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: r356501 - head/share/man/man7

2020-01-08 Thread John Baldwin
Author: jhb
Date: Wed Jan  8 17:31:18 2020
New Revision: 356501
URL: https://svnweb.freebsd.org/changeset/base/356501

Log:
  Remove a mention of MAKE_OBSOLETE_GCC.
  
  This should have been included in r356452.

Modified:
  head/share/man/man7/arch.7

Modified: head/share/man/man7/arch.7
==
--- head/share/man/man7/arch.7  Wed Jan  8 17:30:14 2020(r356500)
+++ head/share/man/man7/arch.7  Wed Jan  8 17:31:18 2020(r356501)
@@ -330,9 +330,7 @@ Note that GCC 4.2.1 is deprecated, and scheduled for r
 Any CPU architectures not migrated by then
 (to either base system Clang or external toolchain)
 may be removed from the tree after that date.
-Unless the make variable
-.Dv MAKE_OBSOLETE_GCC
-is defined, make universe will not build mips or sparc64
+make universe will not build mips or sparc64
 architectures unless the xtoolchain binaries have been installed for
 the architecture.
 .Ss MACHINE_ARCH vs MACHINE_CPUARCH vs MACHINE
___
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: r356500 - stable/12/usr.sbin/bhyve

2020-01-08 Thread Jung-uk Kim
Author: jkim
Date: Wed Jan  8 17:30:14 2020
New Revision: 356500
URL: https://svnweb.freebsd.org/changeset/base/356500

Log:
  MFC:  r354056
  
  Catch up with ACPICA 20191018.

Modified:
  stable/12/usr.sbin/bhyve/acpi.c
  stable/12/usr.sbin/bhyve/pci_emul.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/usr.sbin/bhyve/acpi.c
==
--- stable/12/usr.sbin/bhyve/acpi.c Wed Jan  8 17:25:59 2020
(r356499)
+++ stable/12/usr.sbin/bhyve/acpi.c Wed Jan  8 17:30:14 2020
(r356500)
@@ -309,11 +309,11 @@ basl_fwrite_madt(FILE *fp)
/* Local APIC NMI is connected to LINT 1 on all CPUs */
EFPRINTF(fp, "[0001]\t\tSubtable Type : 04\n");
EFPRINTF(fp, "[0001]\t\tLength : 06\n");
-   EFPRINTF(fp, "[0001]\t\tProcessorId : FF\n");
+   EFPRINTF(fp, "[0001]\t\tProcessor ID : FF\n");
EFPRINTF(fp, "[0002]\t\tFlags (decoded below) : 0005\n");
EFPRINTF(fp, "\t\t\tPolarity : 1\n");
EFPRINTF(fp, "\t\t\tTrigger Mode : 1\n");
-   EFPRINTF(fp, "[0001]\t\tInterrupt : 01\n");
+   EFPRINTF(fp, "[0001]\t\tInterrupt Input LINT : 01\n");
EFPRINTF(fp, "\n");
 
EFFLUSH(fp);
@@ -560,7 +560,7 @@ basl_fwrite_hpet(FILE *fp)
EFPRINTF(fp, "[0004]\t\tAsl Compiler Revision : \n");
EFPRINTF(fp, "\n");
 
-   EFPRINTF(fp, "[0004]\t\tTimer Block ID : %08X\n", hpet_capabilities);
+   EFPRINTF(fp, "[0004]\t\tHardware Block ID : %08X\n", hpet_capabilities);
EFPRINTF(fp,
"[0012]\t\tTimer Block Register : [Generic Address Structure]\n");
EFPRINTF(fp, "[0001]\t\tSpace ID : 00 [SystemMemory]\n");
@@ -571,7 +571,7 @@ basl_fwrite_hpet(FILE *fp)
EFPRINTF(fp, "[0008]\t\tAddress : FED0\n");
EFPRINTF(fp, "\n");
 
-   EFPRINTF(fp, "[0001]\t\tHPET Number : 00\n");
+   EFPRINTF(fp, "[0001]\t\tSequence Number : 00\n");
EFPRINTF(fp, "[0002]\t\tMinimum Clock Ticks : \n");
EFPRINTF(fp, "[0004]\t\tFlags (decoded below) : 0001\n");
EFPRINTF(fp, "\t\t\t4K Page Protect : 1\n");
@@ -607,9 +607,9 @@ basl_fwrite_mcfg(FILE *fp)
EFPRINTF(fp, "\n");
 
EFPRINTF(fp, "[0008]\t\tBase Address : %016lX\n", pci_ecfg_base());
-   EFPRINTF(fp, "[0002]\t\tSegment Group: \n");
-   EFPRINTF(fp, "[0001]\t\tStart Bus: 00\n");
-   EFPRINTF(fp, "[0001]\t\tEnd Bus: FF\n");
+   EFPRINTF(fp, "[0002]\t\tSegment Group Number : \n");
+   EFPRINTF(fp, "[0001]\t\tStart Bus Number : 00\n");
+   EFPRINTF(fp, "[0001]\t\tEnd Bus Number : FF\n");
EFPRINTF(fp, "[0004]\t\tReserved : 0\n");
EFFLUSH(fp);
return (0);

Modified: stable/12/usr.sbin/bhyve/pci_emul.c
==
--- stable/12/usr.sbin/bhyve/pci_emul.c Wed Jan  8 17:25:59 2020
(r356499)
+++ stable/12/usr.sbin/bhyve/pci_emul.c Wed Jan  8 17:30:14 2020
(r356500)
@@ -1268,7 +1268,6 @@ pci_bus_write_dsdt(int bus)
dsdt_line("  Device (PC%02X)", bus);
dsdt_line("  {");
dsdt_line("Name (_HID, EisaId (\"PNP0A03\"))");
-   dsdt_line("Name (_ADR, Zero)");
 
dsdt_line("Method (_BBN, 0, NotSerialized)");
dsdt_line("{");
___
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: r356499 - in head: . share/man/man7 share/mk

2020-01-08 Thread John Baldwin
Author: jhb
Date: Wed Jan  8 17:25:59 2020
New Revision: 356499
URL: https://svnweb.freebsd.org/changeset/base/356499

Log:
  Use clang and lld as the default toolchain for RISCV.
  
  - Enable clang and lld as system toolchains.
  - Don't use external GCC for universe by default.
  - Re-enable riscv64sf since it builds fine with clang + lld.
  
  Reviewed by:  emaste, mhorne
  Relnotes: yes
  Sponsored by: DARPA
  Differential Revision:https://reviews.freebsd.org/D23089

Modified:
  head/Makefile
  head/share/man/man7/arch.7
  head/share/mk/src.opts.mk

Modified: head/Makefile
==
--- head/Makefile   Wed Jan  8 17:23:52 2020(r356498)
+++ head/Makefile   Wed Jan  8 17:25:59 2020(r356499)
@@ -495,23 +495,20 @@ TARGET_ARCHES_arm64?= aarch64
 TARGET_ARCHES_mips?=   mipsel mips mips64el mips64 mipsn32 mipselhf mipshf 
mips64elhf mips64hf
 # powerpcspe excluded until clang fixed
 TARGET_ARCHES_powerpc?=powerpc powerpc64
-# riscv64sf excluded due to PR 232085
-TARGET_ARCHES_riscv?=  riscv64
+TARGET_ARCHES_riscv?=  riscv64 riscv64sf
 .for target in ${TARGETS}
 TARGET_ARCHES_${target}?= ${target}
 .endfor
 
-MAKE_PARAMS_riscv?=CROSS_TOOLCHAIN=riscv64-gcc
 MAKE_PARAMS_mips?= CROSS_TOOLCHAIN=mips-gcc6
 MAKE_PARAMS_sparc64?=  CROSS_TOOLCHAIN=sparc64-gcc6
 
 TOOLCHAINS_mips=   mips-gcc6
-TOOLCHAINS_riscv=  riscv64-gcc
 TOOLCHAINS_sparc64=sparc64-gcc6
 
 # Remove architectures only supported by external toolchain from
 # universe if required toolchain packages are missing.
-.for target in mips riscv sparc64
+.for target in mips sparc64
 .if ${_UNIVERSE_TARGETS:M${target}}
 .for toolchain in ${TOOLCHAINS_${target}}
 .if !exists(/usr/local/share/toolchains/${toolchain}.mk)

Modified: head/share/man/man7/arch.7
==
--- head/share/man/man7/arch.7  Wed Jan  8 17:23:52 2020(r356498)
+++ head/share/man/man7/arch.7  Wed Jan  8 17:25:59 2020(r356499)
@@ -26,7 +26,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd January 5, 2020
+.Dd January 8, 2020
 .Dt ARCH 7
 .Os
 .Sh NAME
@@ -319,8 +319,8 @@ This table shows the default tool chain for each archi
 .It powerpc Ta Clang Ta GNU ld 2.17.50
 .It powerpcspe  Ta Clang Ta GNU ld 2.17.50
 .It powerpc64   Ta Clang Ta lld
-.It riscv64 Ta GCC(1)Ta GNU ld(1)
-.It riscv64sf   Ta GCC(1)Ta GNU ld(1)
+.It riscv64 Ta Clang Ta lld
+.It riscv64sf   Ta Clang Ta lld
 .It sparc64 Ta GCC(1)Ta GNU ld(1)
 .El
 .Pp

Modified: head/share/mk/src.opts.mk
==
--- head/share/mk/src.opts.mk   Wed Jan  8 17:23:52 2020(r356498)
+++ head/share/mk/src.opts.mk   Wed Jan  8 17:25:59 2020(r356499)
@@ -295,8 +295,7 @@ __DEFAULT_NO_OPTIONS+=LLVM_TARGET_BPF
 # If the compiler is not C++11 capable, disable Clang.  External toolchain will
 # be required.
 
-.if ${COMPILER_FEATURES:Mc++11} && (${__TT} != "mips" && \
-${__TT} != "riscv" && ${__TT} != "sparc64")
+.if ${COMPILER_FEATURES:Mc++11} && (${__TT} != "mips" && ${__TT} != "sparc64")
 # Clang is enabled, and will be installed as the default /usr/bin/cc.
 __DEFAULT_YES_OPTIONS+=CLANG CLANG_BOOTSTRAP CLANG_IS_CC LLD
 .elif ${COMPILER_FEATURES:Mc++11} && ${__T} != "sparc64"
@@ -323,7 +322,7 @@ __DEFAULT_YES_OPTIONS+=LLVM_LIBUNWIND
 __DEFAULT_NO_OPTIONS+=LLVM_LIBUNWIND
 .endif
 .if ${__TT} != "mips" && ${__T} != "powerpc" && ${__T} != "powerpcspe" && \
-${__TT} != "riscv" && ${__T} != "sparc64"
+${__T} != "sparc64"
 __DEFAULT_YES_OPTIONS+=LLD_BOOTSTRAP LLD_IS_LD
 .else
 __DEFAULT_NO_OPTIONS+=LLD_BOOTSTRAP LLD_IS_LD
___
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: r356498 - in stable/12/lib: . libclang_rt

2020-01-08 Thread Dimitry Andric
Author: dim
Date: Wed Jan  8 17:23:52 2020
New Revision: 356498
URL: https://svnweb.freebsd.org/changeset/base/356498

Log:
  MFC r355034:
  
  libclang_rt: enable on powerpc*
  
  Summary:
  Enable on powerpc64 and in lib/libclang_rt/Makefile change
  MACHINE_CPUARCH to MACHINE_ARCH because on powerpc64
  MACHINE_ARCH==MACHINE_CPUARCH so the 32-bit library overwrites 64-bit
  library during installworld.
  
  This patch doesn't enable any other libclang_rt libraries because they
  need to be separately ported.
  
  I have verified that games/julius (which fails on powerpc64 elfv2
  without this change because of no libclang_rt profiling library) builds.
  
  Test Plan: Ship it, test on powerpc and powerpcspe
  
  Submitted by: pkubaj
  Reviewed by:  dim, jhibbits
  Differential Revision: https://reviews.freebsd.org/D22425

Modified:
  stable/12/lib/Makefile
  stable/12/lib/libclang_rt/Makefile.inc
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/lib/Makefile
==
--- stable/12/lib/Makefile  Wed Jan  8 17:05:57 2020(r356497)
+++ stable/12/lib/Makefile  Wed Jan  8 17:23:52 2020(r356498)
@@ -158,7 +158,8 @@ SUBDIR.${MK_LDNS}+= libldns
 # built for certain architectures.
 .if ${MK_CLANG} != "no" && ${COMPILER_TYPE} == "clang" && \
 (${MACHINE_CPUARCH} == "aarch64" || ${MACHINE_CPUARCH} == "amd64" || \
-${MACHINE_CPUARCH} == "arm" || ${MACHINE_CPUARCH} == "i386")
+${MACHINE_CPUARCH} == "arm" || ${MACHINE_CPUARCH} == "i386" || \
+${MACHINE_CPUARCH} == "powerpc")
 _libclang_rt=  libclang_rt
 .endif
 

Modified: stable/12/lib/libclang_rt/Makefile.inc
==
--- stable/12/lib/libclang_rt/Makefile.inc  Wed Jan  8 17:05:57 2020
(r356497)
+++ stable/12/lib/libclang_rt/Makefile.inc  Wed Jan  8 17:23:52 2020
(r356498)
@@ -8,7 +8,7 @@
 (!defined(CPUTYPE) || ${CPUTYPE:M*soft*} == "")
 CRTARCH?=  armhf
 .else
-CRTARCH?=  ${MACHINE_CPUARCH:C/amd64/x86_64/}
+CRTARCH?=  ${MACHINE_ARCH:C/amd64/x86_64/}
 .endif
 CRTSRC=${SRCTOP}/contrib/llvm-project/compiler-rt
 
___
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: r356497 - stable/12/lib/libc/resolv

2020-01-08 Thread Bjoern A. Zeeb
Author: bz
Date: Wed Jan  8 17:05:57 2020
New Revision: 356497
URL: https://svnweb.freebsd.org/changeset/base/356497

Log:
  MFC r348671:
  
Rather than using the legacy IP struct fields in the union for the
port number, properly access them by their IPv6 names.
This will make it easier to slice up and compile out address families
in the future.
  
No functional change intended.

Modified:
  stable/12/lib/libc/resolv/res_findzonecut.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/lib/libc/resolv/res_findzonecut.c
==
--- stable/12/lib/libc/resolv/res_findzonecut.c Wed Jan  8 17:04:40 2020
(r356496)
+++ stable/12/lib/libc/resolv/res_findzonecut.c Wed Jan  8 17:05:57 2020
(r356497)
@@ -629,7 +629,7 @@ save_a(res_state statp, ns_msg *msg, ns_sect sect,
arr->addr.sin6.sin6_len = sizeof(arr->addr.sin6);
 #endif
memcpy(>addr.sin6.sin6_addr, ns_rr_rdata(rr), 16);
-   arr->addr.sin.sin_port = htons(NAMESERVER_PORT);
+   arr->addr.sin6.sin6_port = htons(NAMESERVER_PORT);
nsrr->flags |= RR_NS_HAVE_V6;
break;
default:
___
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: r356496 - stable/12/sys/net80211

2020-01-08 Thread Bjoern A. Zeeb
Author: bz
Date: Wed Jan  8 17:04:40 2020
New Revision: 356496
URL: https://svnweb.freebsd.org/changeset/base/356496

Log:
  MFC r348861:
  
Enhance the comment ieee80211_add_channel() to avoid a
misunderstanding that the function does not work additive
when repeatedly called for diffferent bands.

Modified:
  stable/12/sys/net80211/ieee80211.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/net80211/ieee80211.c
==
--- stable/12/sys/net80211/ieee80211.c  Wed Jan  8 17:02:58 2020
(r356495)
+++ stable/12/sys/net80211/ieee80211.c  Wed Jan  8 17:04:40 2020
(r356496)
@@ -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"


svn commit: r356495 - stable/12/share/mk

2020-01-08 Thread Bjoern A. Zeeb
Author: bz
Date: Wed Jan  8 17:02:58 2020
New Revision: 356495
URL: https://svnweb.freebsd.org/changeset/base/356495

Log:
  MFC r354747:
  
Allow per-file lex and yacc options.
  
In order to allow software with multiple (different) options
for lex and yacc add extra per-file options to the calls.
This is especially useful when one .l file needs -Pprefix.

Modified:
  stable/12/share/mk/bsd.dep.mk
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/share/mk/bsd.dep.mk
==
--- stable/12/share/mk/bsd.dep.mk   Wed Jan  8 16:57:08 2020
(r356494)
+++ stable/12/share/mk/bsd.dep.mk   Wed Jan  8 17:02:58 2020
(r356495)
@@ -108,7 +108,7 @@ OBJS_DEPEND_GUESS.${_S:${OBJS_SRCS_FILTER:ts:}}.o+= ${
 .for _LSRC in ${SRCS:M*.l:N*/*}
 .for _LC in ${_LSRC:R}.c
 ${_LC}: ${_LSRC}
-   ${LEX} ${LFLAGS} -o${.TARGET} ${.ALLSRC}
+   ${LEX} ${LFLAGS} ${LFLAGS.${_LSRC}} -o${.TARGET} ${.ALLSRC}
 OBJS_DEPEND_GUESS.${_LC:R}.o+= ${_LC}
 SRCS:= ${SRCS:S/${_LSRC}/${_LC}/}
 CLEANFILES+= ${_LC}
@@ -124,7 +124,7 @@ CLEANFILES+= ${_YC}
 .ORDER: ${_YC} y.tab.h
 y.tab.h: .NOMETA
 ${_YC} y.tab.h: ${_YSRC}
-   ${YACC} ${YFLAGS} ${.ALLSRC}
+   ${YACC} ${YFLAGS} ${YFLAGS.${_YSRC}} ${.ALLSRC}
cp y.tab.c ${_YC}
 CLEANFILES+= y.tab.c y.tab.h
 .elif !empty(YFLAGS:M-d)
@@ -132,13 +132,13 @@ CLEANFILES+= y.tab.c y.tab.h
 .ORDER: ${_YC} ${_YH}
 ${_YH}: .NOMETA
 ${_YC} ${_YH}: ${_YSRC}
-   ${YACC} ${YFLAGS} -o ${_YC} ${.ALLSRC}
+   ${YACC} ${YFLAGS} ${YFLAGS.${_YSRC}} -o ${_YC} ${.ALLSRC}
 SRCS+= ${_YH}
 CLEANFILES+= ${_YH}
 .endfor
 .else
 ${_YC}: ${_YSRC}
-   ${YACC} ${YFLAGS} -o ${_YC} ${.ALLSRC}
+   ${YACC} ${YFLAGS} ${YFLAGS.${_YSRC}} -o ${_YC} ${.ALLSRC}
 .endif
 OBJS_DEPEND_GUESS.${_YC:R}.o+= ${_YC}
 .endfor
___
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: r356494 - head/sys/compat/linprocfs

2020-01-08 Thread Mark Johnston
Author: markj
Date: Wed Jan  8 16:57:08 2020
New Revision: 356494
URL: https://svnweb.freebsd.org/changeset/base/356494

Log:
  linprocfs: Fix some bugs in the maps file implementation.
  
  - Export the offset into the backing object, not the object size.
  - Fix a bug where we would print the previous entry's "offset" when a
map_entry has no object.
  - Try to identify shared mappings.  Linux prints "s" when the mapping
"may be shared".  This attempt is not perfect, for example, we print
"p" for anonymous memory that may be shared via
minherit(INHERIT_SHARE).
  
  PR:   240992
  Reviewed by:  kib
  MFC after:1 week
  MFC note: no OBJ_ANON in stable/12
  Differential Revision:https://reviews.freebsd.org/D23062

Modified:
  head/sys/compat/linprocfs/linprocfs.c

Modified: head/sys/compat/linprocfs/linprocfs.c
==
--- head/sys/compat/linprocfs/linprocfs.c   Wed Jan  8 16:32:16 2020
(r356493)
+++ head/sys/compat/linprocfs/linprocfs.c   Wed Jan  8 16:57:08 2020
(r356494)
@@ -1146,7 +1146,7 @@ linprocfs_doprocmaps(PFS_FILL_ARGS)
vm_map_entry_t entry, tmp_entry;
vm_object_t obj, tobj, lobj;
vm_offset_t e_start, e_end;
-   vm_ooffset_t off = 0;
+   vm_ooffset_t off;
vm_prot_t e_prot;
unsigned int last_timestamp;
char *name = "", *freename = NULL;
@@ -1156,6 +1156,7 @@ linprocfs_doprocmaps(PFS_FILL_ARGS)
int error;
struct vnode *vp;
struct vattr vat;
+   bool private;
 
PROC_LOCK(p);
error = p_candebug(td, p);
@@ -1186,17 +1187,20 @@ linprocfs_doprocmaps(PFS_FILL_ARGS)
e_start = entry->start;
e_end = entry->end;
obj = entry->object.vm_object;
-   for (lobj = tobj = obj; tobj; tobj = tobj->backing_object) {
+   off = entry->offset;
+   for (lobj = tobj = obj; tobj != NULL;
+   lobj = tobj, tobj = tobj->backing_object) {
VM_OBJECT_RLOCK(tobj);
+   off += lobj->backing_object_offset;
if (lobj != obj)
VM_OBJECT_RUNLOCK(lobj);
-   lobj = tobj;
}
+   private = (entry->eflags & MAP_ENTRY_COW) != 0 || obj == NULL ||
+   (obj->flags & OBJ_ANON) != 0;
last_timestamp = map->timestamp;
vm_map_unlock_read(map);
ino = 0;
if (lobj) {
-   off = IDX_TO_OFF(lobj->size);
vp = vm_object_vnode(lobj);
if (vp != NULL)
vref(vp);
@@ -1233,7 +1237,7 @@ linprocfs_doprocmaps(PFS_FILL_ARGS)
(e_prot & VM_PROT_READ)?"r":"-",
(e_prot & VM_PROT_WRITE)?"w":"-",
(e_prot & VM_PROT_EXECUTE)?"x":"-",
-   "p",
+   private ? "p" : "s",
(u_long)off,
0,
0,
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r356493 - in stable/12/tests/sys/netinet6: . frag6

2020-01-08 Thread Bjoern A. Zeeb
Author: bz
Date: Wed Jan  8 16:32:16 2020
New Revision: 356493
URL: https://svnweb.freebsd.org/changeset/base/356493

Log:
  MFC r354357-354358,354390,354395:
  
frag6 tests: set end to catch timeout as error
ipv6 tests: Add very simplistic extension header tests
ipv6 tests: cleanup
ipv6 tests: test case for scapy bpf parsing bug
  
  PR:   239380

Added:
  stable/12/tests/sys/netinet6/exthdr.py
 - copied unchanged from r354358, head/tests/sys/netinet6/exthdr.py
  stable/12/tests/sys/netinet6/exthdr.sh
 - copied, changed from r354358, head/tests/sys/netinet6/exthdr.sh
  stable/12/tests/sys/netinet6/scapyi386.py
 - copied unchanged from r354395, head/tests/sys/netinet6/scapyi386.py
  stable/12/tests/sys/netinet6/scapyi386.sh
 - copied unchanged from r354395, head/tests/sys/netinet6/scapyi386.sh
Modified:
  stable/12/tests/sys/netinet6/Makefile
  stable/12/tests/sys/netinet6/frag6/frag6.subr
  stable/12/tests/sys/netinet6/frag6/frag6_02.py
  stable/12/tests/sys/netinet6/frag6/frag6_04.py
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/tests/sys/netinet6/Makefile
==
--- stable/12/tests/sys/netinet6/Makefile   Wed Jan  8 16:15:43 2020
(r356492)
+++ stable/12/tests/sys/netinet6/Makefile   Wed Jan  8 16:32:16 2020
(r356493)
@@ -1,6 +1,19 @@
 # $FreeBSD$
 
+PACKAGE=   tests
+
 TESTSDIR=  ${TESTSBASE}/sys/netinet6
+FILESDIR=  ${TESTSDIR}
+
+ATF_TESTS_SH=  \
+   exthdr \
+   scapyi386
+
+${PACKAGE}FILES+=  exthdr.py
+${PACKAGE}FILES+=  scapyi386.py
+
+${PACKAGE}FILESMODE_exthdr.py= 0555
+${PACKAGE}FILESMODE_scapyi386.py=0555
 
 TESTS_SUBDIRS+=frag6
 

Copied: stable/12/tests/sys/netinet6/exthdr.py (from r354358, 
head/tests/sys/netinet6/exthdr.py)
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ stable/12/tests/sys/netinet6/exthdr.py  Wed Jan  8 16:32:16 2020
(r356493, copy of r354358, head/tests/sys/netinet6/exthdr.py)
@@ -0,0 +1,273 @@
+#!/usr/bin/env python
+#-
+# SPDX-License-Identifier: BSD-2-Clause
+#
+# Copyright (c) 2019 Netflix, Inc.
+#
+# 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 AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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.
+#
+# $FreeBSD$
+#
+
+import argparse
+import scapy.all as sp
+import socket
+import sys
+import frag6.sniffer as Sniffer
+from time import sleep
+
+def check_icmp6_error_dst_unreach_noport(args, packet):
+   ip6 = packet.getlayer(sp.IPv6)
+   if not ip6:
+   return False
+   oip6 = sp.IPv6(src=args.src[0], dst=args.to[0])
+   if ip6.dst != oip6.src:
+   return False
+   icmp6 = packet.getlayer(sp.ICMPv6DestUnreach)
+   if not icmp6:
+   return False
+   # ICMP6_DST_UNREACH_NOPORT 4
+   if icmp6.code != 4:
+   return False
+   # Should we check the payload as well?
+   # We are running in a very isolated environment and nothing else
+   # should trigger an ICMPv6 Dest Unreach / Port Unreach so leave it.
+   #icmp6.display()
+   return True
+
+def check_icmp6_error_paramprob_header(args, packet):
+   ip6 = packet.getlayer(sp.IPv6)
+   if not ip6:
+   return False
+   oip6 = sp.IPv6(src=args.src[0], dst=args.to[0])
+   if ip6.dst != oip6.src:
+   return False
+   icmp6 = packet.getlayer(sp.ICMPv6ParamProblem)
+   if not icmp6:
+   return False
+   # ICMP6_PARAMPROB_HEADER 0
+   if icmp6.code != 0:
+   return False
+   # Should we check the 

svn commit: r356492 - in stable/12/sys: netinet netinet6

2020-01-08 Thread Bjoern A. Zeeb
Author: bz
Date: Wed Jan  8 16:15:43 2020
New Revision: 356492
URL: https://svnweb.freebsd.org/changeset/base/356492

Log:
  MFC r354092:
  
Properly set VNET when nuking recvif from fragment queues.
  
In theory the eventhandler invoke should be in the same VNET as
the the current interface. We however cannot guarantee that for
all cases in the future.
  
So before checking if the fragmentation handling for this VNET
is active, switch the VNET to the VNET of the interface to always
get the one we want.

Modified:
  stable/12/sys/netinet/ip_reass.c
  stable/12/sys/netinet6/frag6.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/netinet/ip_reass.c
==
--- stable/12/sys/netinet/ip_reass.cWed Jan  8 16:14:20 2020
(r356491)
+++ stable/12/sys/netinet/ip_reass.cWed Jan  8 16:15:43 2020
(r356492)
@@ -631,14 +631,17 @@ ipreass_cleanup(void *arg __unused, struct ifnet *ifp)
 
KASSERT(ifp != NULL, ("%s: ifp is NULL", __func__));
 
+   CURVNET_SET_QUIET(ifp->if_vnet);
+
/*
 * Skip processing if IPv4 reassembly is not initialised or
 * torn down by ipreass_destroy().
 */ 
-   if (V_ipq_zone == NULL)
+   if (V_ipq_zone == NULL) {
+   CURVNET_RESTORE();
return;
+   }
 
-   CURVNET_SET_QUIET(ifp->if_vnet);
for (i = 0; i < IPREASS_NHASH; i++) {
IPQ_LOCK(i);
/* Scan fragment list. */

Modified: stable/12/sys/netinet6/frag6.c
==
--- stable/12/sys/netinet6/frag6.c  Wed Jan  8 16:14:20 2020
(r356491)
+++ stable/12/sys/netinet6/frag6.c  Wed Jan  8 16:15:43 2020
(r356492)
@@ -307,16 +307,18 @@ frag6_cleanup(void *arg __unused, struct ifnet *ifp)
 
KASSERT(ifp != NULL, ("%s: ifp is NULL", __func__));
 
+   CURVNET_SET_QUIET(ifp->if_vnet);
 #ifdef VIMAGE
/*
 * Skip processing if IPv6 reassembly is not initialised or
 * torn down by frag6_destroy().
 */
-   if (!V_frag6_on)
+   if (!V_frag6_on) {
+   CURVNET_RESTORE();
return;
+   }
 #endif
 
-   CURVNET_SET_QUIET(ifp->if_vnet);
for (bucket = 0; bucket < IP6REASS_NHASH; bucket++) {
IP6QB_LOCK(bucket);
head = IP6QB_HEAD(bucket);
___
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: r356491 - in stable/12: etc/mtree sys/netinet6 tests/sys tests/sys/netinet6 tests/sys/netinet6/frag6

2020-01-08 Thread Bjoern A. Zeeb
Author: bz
Date: Wed Jan  8 16:14:20 2020
New Revision: 356491
URL: https://svnweb.freebsd.org/changeset/base/356491

Log:
  MFC r350748,353792-353794,353963,353965-353966,354016-354017,
  354019-354020,354037,354040,354042,354045-354046,354053,354081,
  354084:
  
2nd half of the major frag6 rework and adding test cases.
  
Cleanup structures, fix vnet teardown leak, add sysctls, whitespace
cahnges, replace KAME hand-rolled queues with queue(9) TAILQs,
comments, small improvements, do not leak packet queue entry in error
case, fix counter leak in error case and optimise code, handling of
overlapping fragments to conform to RFC 8200, prevent overwriting initial
fragoff=0 packet meta-data.
  
Submitted by:   jtl (initally, partially)
Sponsored by:   Netflix (initially)

Added:
  stable/12/tests/sys/netinet6/
 - copied from r353794, head/tests/sys/netinet6/
  stable/12/tests/sys/netinet6/frag6/frag6_20.py
 - copied unchanged from r354053, head/tests/sys/netinet6/frag6/frag6_20.py
  stable/12/tests/sys/netinet6/frag6/frag6_20.sh
 - copied unchanged from r354053, head/tests/sys/netinet6/frag6/frag6_20.sh
Modified:
  stable/12/etc/mtree/BSD.tests.dist
  stable/12/sys/netinet6/frag6.c
  stable/12/sys/netinet6/ip6_input.c
  stable/12/sys/netinet6/ip6_var.h
  stable/12/tests/sys/Makefile
  stable/12/tests/sys/netinet6/frag6/Makefile
  stable/12/tests/sys/netinet6/frag6/frag6_01.sh
  stable/12/tests/sys/netinet6/frag6/frag6_02.sh
  stable/12/tests/sys/netinet6/frag6/frag6_03.py
  stable/12/tests/sys/netinet6/frag6/frag6_03.sh
  stable/12/tests/sys/netinet6/frag6/frag6_04.sh
  stable/12/tests/sys/netinet6/frag6/frag6_05.py
  stable/12/tests/sys/netinet6/frag6/frag6_05.sh
  stable/12/tests/sys/netinet6/frag6/frag6_06.sh
  stable/12/tests/sys/netinet6/frag6/frag6_07.py
  stable/12/tests/sys/netinet6/frag6/frag6_07.sh
  stable/12/tests/sys/netinet6/frag6/frag6_08.py
  stable/12/tests/sys/netinet6/frag6/frag6_08.sh
  stable/12/tests/sys/netinet6/frag6/frag6_09.sh
  stable/12/tests/sys/netinet6/frag6/frag6_10.py
  stable/12/tests/sys/netinet6/frag6/frag6_10.sh
  stable/12/tests/sys/netinet6/frag6/frag6_11.sh
  stable/12/tests/sys/netinet6/frag6/frag6_12.sh
  stable/12/tests/sys/netinet6/frag6/frag6_13.py
  stable/12/tests/sys/netinet6/frag6/frag6_13.sh
  stable/12/tests/sys/netinet6/frag6/frag6_14.py
  stable/12/tests/sys/netinet6/frag6/frag6_14.sh
  stable/12/tests/sys/netinet6/frag6/frag6_15.sh
  stable/12/tests/sys/netinet6/frag6/frag6_16.sh
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/etc/mtree/BSD.tests.dist
==
--- stable/12/etc/mtree/BSD.tests.dist  Wed Jan  8 15:50:45 2020
(r356490)
+++ stable/12/etc/mtree/BSD.tests.dist  Wed Jan  8 16:14:20 2020
(r356491)
@@ -784,6 +784,10 @@
 ..
 netinet
 ..
+netinet6
+frag6
+..
+..
 netipsec
 tunnel
 ..

Modified: stable/12/sys/netinet6/frag6.c
==
--- stable/12/sys/netinet6/frag6.c  Wed Jan  8 15:50:45 2020
(r356490)
+++ stable/12/sys/netinet6/frag6.c  Wed Jan  8 16:14:20 2020
(r356491)
@@ -3,6 +3,7 @@
  *
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
  * All rights reserved.
+ * Copyright (c) 2019 Netflix, Inc.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -45,6 +46,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -67,28 +69,52 @@ __FBSDID("$FreeBSD$");
 #include 
 #endif
 
+/*
+ * A "big picture" of how IPv6 fragment queues are all linked together.
+ *
+ * struct ip6qbucket ip6qb[...];   hashed buckets
+ * 
+ * |
+ * +--- TAILQ(struct ip6q, packets) *q6;   tailq entries holding
+ *     fragmented packets
+ *  |  (1 per original packet)
+ *  |
+ *  +--- TAILQ(struct ip6asfrag, ip6q_frags) *af6; tailq entries of IPv6
+ *   |   *ip6af;fragment packets
+ *   | for one original packet
+ *   + *mbuf
+ */
+
 /* Reassembly headers are stored in hash buckets. */
 #defineIP6REASS_NHASH_LOG2 10
 #defineIP6REASS_NHASH  (1 << IP6REASS_NHASH_LOG2)
 #defineIP6REASS_HMASK  (IP6REASS_NHASH - 1)
 
-static void frag6_enq(struct ip6asfrag *, struct ip6asfrag *,
-uint32_t bucket __unused);
-static void frag6_deq(struct ip6asfrag *, uint32_t bucket __unused);
-static void frag6_insque_head(struct ip6q *, struct ip6q *,
-uint32_t bucket);
-static void 

svn commit: r356490 - stable/12/sys/netinet6

2020-01-08 Thread Bjoern A. Zeeb
Author: bz
Date: Wed Jan  8 15:50:45 2020
New Revision: 356490
URL: https://svnweb.freebsd.org/changeset/base/356490

Log:
  MFC r344301 (by thj):
  
When dropping a fragment queue, account for the number of fragments in the
queue. This improves accounting between the number of fragments received and
the number of fragments dropped.

Modified:
  stable/12/sys/netinet6/frag6.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/netinet6/frag6.c
==
--- stable/12/sys/netinet6/frag6.c  Wed Jan  8 15:41:04 2020
(r356489)
+++ stable/12/sys/netinet6/frag6.c  Wed Jan  8 15:50:45 2020
(r356490)
@@ -672,7 +672,7 @@ insert:
 af6 = af6->ip6af_down) {
if (af6->ip6af_off != plen) {
if (q6->ip6q_nfrag > V_ip6_maxfragsperpacket) {
-   IP6STAT_INC(ip6s_fragdropped);
+   IP6STAT_ADD(ip6s_fragdropped, q6->ip6q_nfrag);
frag6_freef(q6, bucket);
}
IP6QB_UNLOCK(bucket);
@@ -682,7 +682,7 @@ insert:
}
if (af6->ip6af_up->ip6af_mff) {
if (q6->ip6q_nfrag > V_ip6_maxfragsperpacket) {
-   IP6STAT_INC(ip6s_fragdropped);
+   IP6STAT_ADD(ip6s_fragdropped, q6->ip6q_nfrag);
frag6_freef(q6, bucket);
}
IP6QB_UNLOCK(bucket);
@@ -826,7 +826,8 @@ frag6_slowtimo(void)
--q6->ip6q_ttl;
q6 = q6->ip6q_next;
if (q6->ip6q_prev->ip6q_ttl == 0) {
-   IP6STAT_INC(ip6s_fragtimeout);
+   IP6STAT_ADD(ip6s_fragtimeout,
+   q6->ip6q_prev->ip6q_nfrag);
/* XXX in6_ifstat_inc(ifp, 
ifs6_reass_fail) */
frag6_freef(q6->ip6q_prev, bucket);
}
@@ -844,7 +845,8 @@ frag6_slowtimo(void)
(V_ip6_maxfragpackets > 0 &&
V_ip6qb[bucket].count > V_ip6_maxfragbucketsize)) &&
head->ip6q_prev != head) {
-   IP6STAT_INC(ip6s_fragoverflow);
+   IP6STAT_ADD(ip6s_fragoverflow,
+   q6->ip6q_prev->ip6q_nfrag);
/* XXX in6_ifstat_inc(ifp, ifs6_reass_fail) */
frag6_freef(head->ip6q_prev, bucket);
}
@@ -861,7 +863,8 @@ frag6_slowtimo(void)
IP6QB_LOCK(bucket);
head = IP6QB_HEAD(bucket);
if (head->ip6q_prev != head) {
-   IP6STAT_INC(ip6s_fragoverflow);
+   IP6STAT_ADD(ip6s_fragoverflow,
+   q6->ip6q_prev->ip6q_nfrag);
/* XXX in6_ifstat_inc(ifp, ifs6_reass_fail) */
frag6_freef(head->ip6q_prev, bucket);
}
___
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: r356489 - in stable/12/sys: netinet netinet6

2020-01-08 Thread Bjoern A. Zeeb
Author: bz
Date: Wed Jan  8 15:41:04 2020
New Revision: 356489
URL: https://svnweb.freebsd.org/changeset/base/356489

Log:
  MFC r353635 (by hselasky):
  
Fix panic in network stack due to use after free when receiving
partial fragmented packets before a network interface is detached.
  
When sending IPv4 or IPv6 fragmented packets and a fragment is lost
before the network device is freed, the mbuf making up the fragment
will remain in the temporary hashed fragment list and cause a panic
when it times out due to accessing a freed network interface
structure.
  
1) Make sure the m_pkthdr.rcvif always points to a valid network
interface. Else the rcvif field should be set to NULL.
  
2) Use the rcvif of the last received fragment as m_pkthdr.rcvif for
the fully defragged packet, instead of the first received fragment.

Modified:
  stable/12/sys/netinet/ip_reass.c
  stable/12/sys/netinet6/frag6.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/netinet/ip_reass.c
==
--- stable/12/sys/netinet/ip_reass.cWed Jan  8 14:01:15 2020
(r356488)
+++ stable/12/sys/netinet/ip_reass.cWed Jan  8 15:41:04 2020
(r356489)
@@ -46,7 +46,10 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 
+#include 
+#include 
 #include 
 #include 
 #include 
@@ -180,6 +183,7 @@ ip_reass(struct mbuf *m)
struct ip *ip;
struct mbuf *p, *q, *nq, *t;
struct ipq *fp;
+   struct ifnet *srcifp;
struct ipqhead *head;
int i, hlen, next, tmpmax;
u_int8_t ecn, ecn0;
@@ -240,6 +244,11 @@ ip_reass(struct mbuf *m)
}
 
/*
+* Store receive network interface pointer for later.
+*/
+   srcifp = m->m_pkthdr.rcvif;
+
+   /*
 * Attempt reassembly; if it succeeds, proceed.
 * ip_reass() will return a different mbuf.
 */
@@ -489,8 +498,11 @@ ip_reass(struct mbuf *m)
m->m_len += (ip->ip_hl << 2);
m->m_data -= (ip->ip_hl << 2);
/* some debugging cruft by sklower, below, will go away soon */
-   if (m->m_flags & M_PKTHDR)  /* XXX this should be done elsewhere */
+   if (m->m_flags & M_PKTHDR) {/* XXX this should be done elsewhere */
m_fixhdr(m);
+   /* set valid receive interface pointer */
+   m->m_pkthdr.rcvif = srcifp;
+   }
IPSTAT_INC(ips_reassembled);
IPQ_UNLOCK(hash);
 
@@ -606,6 +618,43 @@ ipreass_drain(void)
}
 }
 
+/*
+ * Drain off all datagram fragments belonging to
+ * the given network interface.
+ */
+static void
+ipreass_cleanup(void *arg __unused, struct ifnet *ifp)
+{
+   struct ipq *fp, *temp;
+   struct mbuf *m;
+   int i;
+
+   KASSERT(ifp != NULL, ("%s: ifp is NULL", __func__));
+
+   /*
+* Skip processing if IPv4 reassembly is not initialised or
+* torn down by ipreass_destroy().
+*/ 
+   if (V_ipq_zone == NULL)
+   return;
+
+   CURVNET_SET_QUIET(ifp->if_vnet);
+   for (i = 0; i < IPREASS_NHASH; i++) {
+   IPQ_LOCK(i);
+   /* Scan fragment list. */
+   TAILQ_FOREACH_SAFE(fp, _ipq[i].head, ipq_list, temp) {
+   for (m = fp->ipq_frags; m != NULL; m = m->m_nextpkt) {
+   /* clear no longer valid rcvif pointer */
+   if (m->m_pkthdr.rcvif == ifp)
+   m->m_pkthdr.rcvif = NULL;
+   }
+   }
+   IPQ_UNLOCK(i);
+   }
+   CURVNET_RESTORE();
+}
+EVENTHANDLER_DEFINE(ifnet_departure_event, ipreass_cleanup, NULL, 0);
+
 #ifdef VIMAGE
 /*
  * Destroy IP reassembly structures.
@@ -616,6 +665,7 @@ ipreass_destroy(void)
 
ipreass_drain();
uma_zdestroy(V_ipq_zone);
+   V_ipq_zone = NULL;
for (int i = 0; i < IPREASS_NHASH; i++)
mtx_destroy(_ipq[i].lock);
 }

Modified: stable/12/sys/netinet6/frag6.c
==
--- stable/12/sys/netinet6/frag6.c  Wed Jan  8 14:01:15 2020
(r356488)
+++ stable/12/sys/netinet6/frag6.c  Wed Jan  8 15:41:04 2020
(r356489)
@@ -234,7 +234,7 @@ frag6_freef(struct ip6q *q6, uint32_t bucket)
 * Return ICMP time exceeded error for the 1st fragment.
 * Just free other fragments.
 */
-   if (af6->ip6af_off == 0) {
+   if (af6->ip6af_off == 0 && m->m_pkthdr.rcvif != NULL) {
 
/* Adjust pointer. */
ip6 = mtod(m, struct ip6_hdr *);
@@ -260,6 +260,43 @@ frag6_freef(struct ip6q *q6, uint32_t bucket)
 }
 
 /*
+ * Drain off all datagram fragments belonging to
+ * the given network interface.
+ */
+static void
+frag6_cleanup(void 

svn commit: r356488 - head/usr.sbin/bsdinstall

2020-01-08 Thread Maxim Konovalov
Author: maxim
Date: Wed Jan  8 14:01:15 2020
New Revision: 356488
URL: https://svnweb.freebsd.org/changeset/base/356488

Log:
  o Spell "Redundancy" and "Remember" correctly.
  
  PR:   243187
  Submitted by: mikael.uran...@gmail.com (partially)

Modified:
  head/usr.sbin/bsdinstall/bsdinstall.8

Modified: head/usr.sbin/bsdinstall/bsdinstall.8
==
--- head/usr.sbin/bsdinstall/bsdinstall.8   Wed Jan  8 11:30:42 2020
(r356487)
+++ head/usr.sbin/bsdinstall/bsdinstall.8   Wed Jan  8 14:01:15 2020
(r356488)
@@ -336,8 +336,8 @@ Default:
 The type of pool to be created for the base system.
 This variable can take one of this values: stripe (No redundacy),
 mirror (n-Way mirroring), raid10 (RAID 1+0 - n x 2-Way Mirrors),
-raidz1 (RAID-Z1 - Single Redundacy RAID), raidz2 (RAID-Z2 - Double Redundacy 
RAID)
-or raidz3 (RAID-Z3 Triple Redundacy RAID).
+raidz1 (RAID-Z1 - Single Redundancy RAID), raidz2 (RAID-Z2 - Double Redundancy 
RAID)
+or raidz3 (RAID-Z3 Triple Redundancy RAID).
 Default:
 .Dq stripe
 .It Ev ZFSBOOT_FORCE_4K_SECTORS
@@ -505,7 +505,7 @@ ZFSBOOT_DISKS="ada0 ada1"
 ZFSBOOT_VDEV_TYPE=mirror
 .Ed
 .Pp
-Remenber to export all the variables for the
+Remember to export all the variables for the
 .Cm zfsboot
 command, otherwise it will not get set.
 .Ss SETUP SCRIPT
___
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: r356486 - head/sys/arm64/rockchip

2020-01-08 Thread Emmanuel Vadot
Author: manu
Date: Wed Jan  8 11:30:03 2020
New Revision: 356486
URL: https://svnweb.freebsd.org/changeset/base/356486

Log:
  rk805: Add regnode_status method
  
  This allow consumers to check if the regulator is enable or not.
  
  Reviewed by:  mmel
  Differential Revision:https://reviews.freebsd.org/D23005

Modified:
  head/sys/arm64/rockchip/rk805.c

Modified: head/sys/arm64/rockchip/rk805.c
==
--- head/sys/arm64/rockchip/rk805.c Wed Jan  8 11:29:22 2020
(r356485)
+++ head/sys/arm64/rockchip/rk805.c Wed Jan  8 11:30:03 2020
(r356486)
@@ -413,6 +413,22 @@ rk805_regnode_voltage_to_reg(struct rk805_reg_sc *sc, 
 }
 
 static int
+rk805_regnode_status(struct regnode *regnode, int *status)
+{
+   struct rk805_reg_sc *sc;
+   uint8_t val;
+
+   sc = regnode_get_softc(regnode);
+
+   *status = 0;
+   rk805_read(sc->base_dev, sc->def->enable_reg, , 1);
+   if (val & sc->def->enable_mask)
+   *status = REGULATOR_STATUS_ENABLED;
+
+   return (0);
+}
+
+static int
 rk805_regnode_set_voltage(struct regnode *regnode, int min_uvolt,
 int max_uvolt, int *udelay)
 {
@@ -477,6 +493,7 @@ static regnode_method_t rk805_regnode_methods[] = {
/* Regulator interface */
REGNODEMETHOD(regnode_init, rk805_regnode_init),
REGNODEMETHOD(regnode_enable,   rk805_regnode_enable),
+   REGNODEMETHOD(regnode_status,   rk805_regnode_status),
REGNODEMETHOD(regnode_set_voltage,  rk805_regnode_set_voltage),
REGNODEMETHOD(regnode_get_voltage,  rk805_regnode_get_voltage),
REGNODEMETHOD(regnode_check_voltage,regnode_method_check_voltage),
___
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: r356487 - head/sys/dev/extres/regulator

2020-01-08 Thread Emmanuel Vadot
Author: manu
Date: Wed Jan  8 11:30:42 2020
New Revision: 356487
URL: https://svnweb.freebsd.org/changeset/base/356487

Log:
  regulator: fix regnode_method_get_voltage
  
  This method is supposed to write the voltage into uvolt
  and return an errno compatible value.
  
  Reviewed by:  mmel
  Differential Revision:https://reviews.freebsd.org/D23006

Modified:
  head/sys/dev/extres/regulator/regulator.c

Modified: head/sys/dev/extres/regulator/regulator.c
==
--- head/sys/dev/extres/regulator/regulator.c   Wed Jan  8 11:30:03 2020
(r356486)
+++ head/sys/dev/extres/regulator/regulator.c   Wed Jan  8 11:30:42 2020
(r356487)
@@ -275,8 +275,9 @@ static int
 regnode_method_get_voltage(struct regnode *regnode, int *uvolt)
 {
 
-   return (regnode->std_param.min_uvolt +
-   (regnode->std_param.max_uvolt - regnode->std_param.min_uvolt) / 2);
+   *uvolt = regnode->std_param.min_uvolt +
+   (regnode->std_param.max_uvolt - regnode->std_param.min_uvolt) / 2;
+   return (0);
 }
 
 int
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r356485 - head/sys/arm64/rockchip

2020-01-08 Thread Emmanuel Vadot
Author: manu
Date: Wed Jan  8 11:29:22 2020
New Revision: 356485
URL: https://svnweb.freebsd.org/changeset/base/356485

Log:
  rk808: Add min/max for the switch regulators
  
  The two switch regulator are always 3.0V.
  Add a special case in get_voltage that if min=max we directly
  return the value without calculating it.
  
  Reviewed by:  mmel
  Differential Revision:https://reviews.freebsd.org/D23004

Modified:
  head/sys/arm64/rockchip/rk805.c

Modified: head/sys/arm64/rockchip/rk805.c
==
--- head/sys/arm64/rockchip/rk805.c Wed Jan  8 10:06:32 2020
(r356484)
+++ head/sys/arm64/rockchip/rk805.c Wed Jan  8 11:29:22 2020
(r356485)
@@ -204,6 +204,7 @@ static struct rk805_regdef rk808_regdefs[] = {
.voltage_nstep = 64,
},
{
+   /* BUCK3 voltage is calculated based on external resistor */
.id = RK805_DCDC3,
.name = "DCDC_REG3",
.enable_reg = RK805_DCDC_EN,
@@ -322,12 +323,16 @@ static struct rk805_regdef rk808_regdefs[] = {
.name = "SWITCH_REG1",
.enable_reg = RK805_DCDC_EN,
.enable_mask = 0x20,
+   .voltage_min = 300,
+   .voltage_max = 300,
},
{
.id = RK808_SWITCH2,
.name = "SWITCH_REG2",
.enable_reg = RK805_DCDC_EN,
.enable_mask = 0x40,
+   .voltage_min = 300,
+   .voltage_max = 300,
},
 };
 
@@ -449,6 +454,11 @@ rk805_regnode_get_voltage(struct regnode *regnode, int
uint8_t val;
 
sc = regnode_get_softc(regnode);
+
+   if (sc->def->voltage_min ==  sc->def->voltage_max) {
+   *uvolt = sc->def->voltage_min;
+   return (0);
+   }
 
if (!sc->def->voltage_step)
return (ENXIO);
___
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: r356484 - head/sys/dev/virtio/network

2020-01-08 Thread Kristof Provost
Author: kp
Date: Wed Jan  8 10:06:32 2020
New Revision: 356484
URL: https://svnweb.freebsd.org/changeset/base/356484

Log:
  vtnet: Pre-allocate debugnet data immediately
  
  Don't wait until the vtnet_debugnet_init() call happens, because at that
  point we might already have allocated something from
  vtnet_tx_header_zone.
  
  Some systems showed this panic:
  
  vtnet0: link state changed to UP
  panic: keg vtnet_tx_hdr initialization after use.
  cpuid = 5
  time = 1578427700
  KDB: stack backtrace:
  db_trace_self_wrapper() at db_trace_self_wrapper+0x2b/frame 
0xfe004db427f0
  vpanic() at vpanic+0x17e/frame 0xfe004db42850
  panic() at panic+0x43/frame 0xfe004db428b0
  uma_zone_reserve() at uma_zone_reserve+0xf6/frame 0xfe004db428f0
  vtnet_debugnet_init() at vtnet_debugnet_init+0x77/frame 
0xfe004db42930
  debugnet_any_ifnet_update() at debugnet_any_ifnet_update+0x42/frame 
0xfe004db42980
  do_link_state_change() at do_link_state_change+0x1b3/frame 
0xfe004db429d0
  taskqueue_run_locked() at taskqueue_run_locked+0x178/frame 
0xfe004db42a30
  taskqueue_run() at taskqueue_run+0x4d/frame 0xfe004db42a50
  ithread_loop() at ithread_loop+0x1d6/frame 0xfe004db42ab0
  fork_exit() at fork_exit+0x80/frame 0xfe004db42af0
  fork_trampoline() at fork_trampoline+0xe/frame 0xfe004db42af0
  --- trap 0, rip = 0, rsp = 0, rbp = 0 ---
  KDB: enter: panic
  [ thread pid 12 tid 100011 ]
  Stopped at  kdb_enter+0x37: movq$0,0x1084eb6(%rip)
  db>
  
  Reviewed by:  cem, markj
  Differential Revision:https://reviews.freebsd.org/D23073

Modified:
  head/sys/dev/virtio/network/if_vtnet.c

Modified: head/sys/dev/virtio/network/if_vtnet.c
==
--- head/sys/dev/virtio/network/if_vtnet.c  Wed Jan  8 07:25:37 2020
(r356483)
+++ head/sys/dev/virtio/network/if_vtnet.c  Wed Jan  8 10:06:32 2020
(r356484)
@@ -337,10 +337,21 @@ vtnet_modevent(module_t mod, int type, void *unused)
 
switch (type) {
case MOD_LOAD:
-   if (loaded++ == 0)
+   if (loaded++ == 0) {
vtnet_tx_header_zone = uma_zcreate("vtnet_tx_hdr",
sizeof(struct vtnet_tx_header),
NULL, NULL, NULL, NULL, 0, 0);
+#ifdef DEBUGNET
+   /*
+* We need to allocate from this zone in the transmit 
path, so ensure
+* that we have at least one item per header available.
+* XXX add a separate zone like we do for mbufs? 
otherwise we may alloc
+* buckets
+*/
+   uma_zone_reserve(vtnet_tx_header_zone, 
DEBUGNET_MAX_IN_FLIGHT * 2);
+   uma_prealloc(vtnet_tx_header_zone, 
DEBUGNET_MAX_IN_FLIGHT * 2);
+#endif
+   }
break;
case MOD_QUIESCE:
if (uma_zone_get_cur(vtnet_tx_header_zone) > 0)
@@ -3982,15 +3993,6 @@ vtnet_debugnet_init(struct ifnet *ifp, int *nrxr, int 
*ncl = DEBUGNET_MAX_IN_FLIGHT;
*clsize = sc->vtnet_rx_clsize;
VTNET_CORE_UNLOCK(sc);
-
-   /*
-* We need to allocate from this zone in the transmit path, so ensure
-* that we have at least one item per header available.
-* XXX add a separate zone like we do for mbufs? otherwise we may alloc
-* buckets
-*/
-   uma_zone_reserve(vtnet_tx_header_zone, DEBUGNET_MAX_IN_FLIGHT * 2);
-   uma_prealloc(vtnet_tx_header_zone, DEBUGNET_MAX_IN_FLIGHT * 2);
 }
 
 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"


Re: svn commit: r356480 - head/sys/dev/nvme

2020-01-08 Thread Konstantin Belousov
On Tue, Jan 07, 2020 at 11:10:39PM +, Alexander Motin wrote:
> Author: mav
> Date: Tue Jan  7 23:10:38 2020
> New Revision: 356480
> URL: https://svnweb.freebsd.org/changeset/base/356480
> 
> Log:
>   Increate HMB limit from 1% to 5%.
>   
>   SSD capacity in laptops is growing faster then RAM size, so my original
>   guess seems too low on second thought.  Hopefully nobody will build large
>   array of those crappy SSDs.
It seems that this should be a knob.

>   
>   MFC after:  2 weeks
>   X-MFC-with: 356474
> 
> Modified:
>   head/sys/dev/nvme/nvme_ctrlr.c
> 
> Modified: head/sys/dev/nvme/nvme_ctrlr.c
> ==
> --- head/sys/dev/nvme/nvme_ctrlr.cTue Jan  7 22:45:02 2020
> (r356479)
> +++ head/sys/dev/nvme/nvme_ctrlr.cTue Jan  7 23:10:38 2020
> (r356480)
> @@ -881,8 +881,8 @@ nvme_ctrlr_hmb_alloc(struct nvme_controller *ctrlr)
>   int err, i;
>   uint64_t max;
>  
> - /* Limit HMB to 1% of RAM size per device by default. */
> - max = (uint64_t)physmem * PAGE_SIZE / 100;
> + /* Limit HMB to 5% of RAM size per device by default. */
> + max = (uint64_t)physmem * PAGE_SIZE / 20;
>   TUNABLE_UINT64_FETCH("hw.nvme.hmb_max", );
>  
>   min = (long long unsigned)ctrlr->cdata.hmmin * 4096;
___
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"