svn commit: r354878 - head/contrib/netbsd-tests/usr.bin/unifdef

2019-11-19 Thread Li-Wen Hsu
Author: lwhsu
Date: Wed Nov 20 05:34:02 2019
New Revision: 354878
URL: https://svnweb.freebsd.org/changeset/base/354878

Log:
  Only skip failing test case in CI.
  
  PR:   242095
  Sponsored by: The FreeBSD Foundation

Modified:
  head/contrib/netbsd-tests/usr.bin/unifdef/t_basic.sh

Modified: head/contrib/netbsd-tests/usr.bin/unifdef/t_basic.sh
==
--- head/contrib/netbsd-tests/usr.bin/unifdef/t_basic.shWed Nov 20 
05:30:31 2019(r354877)
+++ head/contrib/netbsd-tests/usr.bin/unifdef/t_basic.shWed Nov 20 
05:34:02 2019(r354878)
@@ -35,7 +35,9 @@ basic_head() {
 }
 
 basic_body() {
-   atf_skip "https://bugs.freebsd.org/242095";
+   if [ "$(atf_config_get ci false)" = "true" ]; then
+   atf_skip "https://bugs.freebsd.org/242095";
+   fi
 
atf_check -s ignore -o file:$(atf_get_srcdir)/d_basic.out \
-x "unifdef -U__FreeBSD__ $(atf_get_srcdir)/d_basic.in"
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r354877 - head/contrib/netbsd-tests/usr.bin/unifdef

2019-11-19 Thread Li-Wen Hsu
Author: lwhsu
Date: Wed Nov 20 05:30:31 2019
New Revision: 354877
URL: https://svnweb.freebsd.org/changeset/base/354877

Log:
  Temporarily skip the failing test case usr.bin.unifdef.basic_test.basic
  
  PR:   242095
  Sponsored by: The FreeBSD Foundation

Modified:
  head/contrib/netbsd-tests/usr.bin/unifdef/t_basic.sh

Modified: head/contrib/netbsd-tests/usr.bin/unifdef/t_basic.sh
==
--- head/contrib/netbsd-tests/usr.bin/unifdef/t_basic.shWed Nov 20 
05:04:44 2019(r354876)
+++ head/contrib/netbsd-tests/usr.bin/unifdef/t_basic.shWed Nov 20 
05:30:31 2019(r354877)
@@ -35,6 +35,7 @@ basic_head() {
 }
 
 basic_body() {
+   atf_skip "https://bugs.freebsd.org/242095";
 
atf_check -s ignore -o file:$(atf_get_srcdir)/d_basic.out \
-x "unifdef -U__FreeBSD__ $(atf_get_srcdir)/d_basic.in"
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r354876 - head/sys/arm/broadcom/bcm2835

2019-11-19 Thread Kyle Evans
Author: kevans
Date: Wed Nov 20 05:04:44 2019
New Revision: 354876
URL: https://svnweb.freebsd.org/changeset/base/354876

Log:
  bcm2835_vcbus: add compatibility name for ^/sys/contrib/vchiq
  
  It's unclear how this didn't get caught in my last iteration, but the fix is
  easy- the interface is still compatible, it was just gratuituously renamed
  to match my arbitrary definition of consistency... VCBUS, the BCM2835 name,
  represents an address on the VideoCore CPU Bus.
  
  In a similar fashion, while it is a physical address, the ARMC portion
  represents that these are addresses as seen by the ARM CPU.
  
  To make things even more fun, the BCM2711 peripheral documentation describes
  not virtual address space vs. physical address space, but instead the 32-bit
  address map vs. the address map in "Low Peripheral" mode. The latter of
  these is what the *ARMC* macros translate to/from.

Modified:
  head/sys/arm/broadcom/bcm2835/bcm2835_vcbus.h

Modified: head/sys/arm/broadcom/bcm2835/bcm2835_vcbus.h
==
--- head/sys/arm/broadcom/bcm2835/bcm2835_vcbus.h   Wed Nov 20 03:57:46 
2019(r354875)
+++ head/sys/arm/broadcom/bcm2835/bcm2835_vcbus.h   Wed Nov 20 05:04:44 
2019(r354876)
@@ -71,4 +71,7 @@ bus_addr_t bcm283x_dmabus_peripheral_lowaddr(void);
 #defineARMC_TO_VCBUS(pa)   bcm283x_armc_to_vcbus(pa)
 #defineVCBUS_TO_ARMC(vca)  bcm283x_vcbus_to_armc(vca)
 
+/* Compatibility name for vchiq arm interface. */
+#definePHYS_TO_VCBUS   ARMC_TO_VCBUS
+
 #endif /* _BCM2835_VCBUS_H_ */
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r354875 - in head/sys: arm/broadcom/bcm2835 conf

2019-11-19 Thread Kyle Evans
Author: kevans
Date: Wed Nov 20 03:57:46 2019
New Revision: 354875
URL: https://svnweb.freebsd.org/changeset/base/354875

Log:
  bcm2835: push address mapping conversion for DMA/mailbox to runtime
  
  We could maintain the static conversions for the !AArch64 Raspberry Pis, but
  I'm not sure it's worth it -- we'll traverse the platform list exactly once
  (of which there are only two for armv7), then every conversion there-after
  traverses the memory map listing of which there are at-most two entries for
  these boards: sdram and peripheral space.
  
  Detecting this at runtime is necessary for the AArch64 SOC, though, because
  of the distinct IO windows being otherwise not discernible just from support
  compiled into the kernel. We currently select the correct window based on
  /compatible in the FDT.
  
  We also use a similar mechanism to describe the DMA restrictions- the RPi 4
  can have up to 4GB of RAM while the DMA controller and mailbox mechanism can
  technically, kind of, only access the lowest 1GB. See the comment in
  bcm2835_vcbus.h for a fun description/clarification of this.
  
  Differential Revision:https://reviews.freebsd.org/D22301

Added:
  head/sys/arm/broadcom/bcm2835/bcm2835_vcbus.c   (contents, props changed)
Modified:
  head/sys/arm/broadcom/bcm2835/bcm2835_dma.c
  head/sys/arm/broadcom/bcm2835/bcm2835_ft5406.c
  head/sys/arm/broadcom/bcm2835/bcm2835_mbox.c
  head/sys/arm/broadcom/bcm2835/bcm2835_sdhci.c
  head/sys/arm/broadcom/bcm2835/bcm2835_vcbus.h
  head/sys/arm/broadcom/bcm2835/files.bcm283x
  head/sys/conf/files.arm64

Modified: head/sys/arm/broadcom/bcm2835/bcm2835_dma.c
==
--- head/sys/arm/broadcom/bcm2835/bcm2835_dma.c Wed Nov 20 01:57:33 2019
(r354874)
+++ head/sys/arm/broadcom/bcm2835/bcm2835_dma.c Wed Nov 20 03:57:46 2019
(r354875)
@@ -169,7 +169,7 @@ bcm_dmamap_cb(void *arg, bus_dma_segment_t *segs,
 return;
 
 addr = (bus_addr_t*)arg;
-*addr = PHYS_TO_VCBUS(segs[0].ds_addr);
+*addr = ARMC_TO_VCBUS(segs[0].ds_addr);
 }
 
 static void
@@ -247,8 +247,12 @@ bcm_dma_init(device_t dev)
if ((reg & bcm_dma_channel_mask) != 0)
device_printf(dev, "statuses are not cleared\n");
 
-   /* Allocate DMA chunks control blocks */
-   /* p.40 of spec - control block should be 32-bit aligned */
+   /*
+* Allocate DMA chunks control blocks based on p.40 of the peripheral
+* spec - control block should be 32-bit aligned.  The DMA controller
+* has a full 32-bit register dedicated to this address, so we do not
+* need to bother with the per-SoC peripheral restrictions.
+*/
err = bus_dma_tag_create(bus_get_dma_tag(dev),
1, 0, BUS_SPACE_MAXADDR_32BIT,
BUS_SPACE_MAXADDR, NULL, NULL,
@@ -561,14 +565,9 @@ bcm_dma_start(int ch, vm_paddr_t src, vm_paddr_t dst, 
return (-1);
 
cb = sc->sc_dma_ch[ch].cb;
-   if (BCM2835_ARM_IS_IO(src))
-   cb->src = IO_TO_VCBUS(src);
-   else
-   cb->src = PHYS_TO_VCBUS(src);
-   if (BCM2835_ARM_IS_IO(dst))
-   cb->dst = IO_TO_VCBUS(dst);
-   else
-   cb->dst = PHYS_TO_VCBUS(dst);
+   cb->src = ARMC_TO_VCBUS(src);
+   cb->dst = ARMC_TO_VCBUS(dst);
+
cb->len = len;
 
bus_dmamap_sync(sc->sc_dma_tag,

Modified: head/sys/arm/broadcom/bcm2835/bcm2835_ft5406.c
==
--- head/sys/arm/broadcom/bcm2835/bcm2835_ft5406.c  Wed Nov 20 01:57:33 
2019(r354874)
+++ head/sys/arm/broadcom/bcm2835/bcm2835_ft5406.c  Wed Nov 20 03:57:46 
2019(r354875)
@@ -227,7 +227,7 @@ ft5406ts_init(void *arg)
return;
}
 
-   touchbuf = VCBUS_TO_PHYS(msg.body.resp.address);
+   touchbuf = VCBUS_TO_ARMC(msg.body.resp.address);
sc->touch_buf = (uint8_t*)pmap_mapdev(touchbuf, FT5406_WINDOW_SIZE);
 
/* 60Hz */

Modified: head/sys/arm/broadcom/bcm2835/bcm2835_mbox.c
==
--- head/sys/arm/broadcom/bcm2835/bcm2835_mbox.cWed Nov 20 01:57:33 
2019(r354874)
+++ head/sys/arm/broadcom/bcm2835/bcm2835_mbox.cWed Nov 20 03:57:46 
2019(r354875)
@@ -303,7 +303,7 @@ bcm2835_mbox_dma_cb(void *arg, bus_dma_segment_t *segs
if (err)
return;
addr = (bus_addr_t *)arg;
-   *addr = PHYS_TO_VCBUS(segs[0].ds_addr);
+   *addr = ARMC_TO_VCBUS(segs[0].ds_addr);
 }
 
 static void *
@@ -314,7 +314,7 @@ bcm2835_mbox_init_dma(device_t dev, size_t len, bus_dm
int err;
 
err = bus_dma_tag_create(bus_get_dma_tag(dev), 16, 0,
-   BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL,
+   bcm283x_dmabus_peripheral_lowaddr(), BUS_SPACE_MAXADDR, NULL, NULL,

svn commit: r354874 - head/sys/vm

2019-11-19 Thread Jeff Roberson
Author: jeff
Date: Wed Nov 20 01:57:33 2019
New Revision: 354874
URL: https://svnweb.freebsd.org/changeset/base/354874

Log:
  When we set OFFPAGE to limit fragmentation we should also set VTOSLAB
  so that we avoid the hashtables.  The hashtable is now only required if
  a zone is created with OFFPAGE specified initially, not internally.  This
  flag signals to UMA that it can't touch the allocated memory and so
  can't store a slab pointer in the containing page.
  
  Reviewed by:  markj
  Differential Revision:https://reviews.freebsd.org/D22453

Modified:
  head/sys/vm/uma_core.c

Modified: head/sys/vm/uma_core.c
==
--- head/sys/vm/uma_core.c  Wed Nov 20 01:14:22 2019(r354873)
+++ head/sys/vm/uma_core.c  Wed Nov 20 01:57:33 2019(r354874)
@@ -585,7 +585,7 @@ zone_timeout(uma_zone_t zone)
uma_keg_t keg;
u_int slabs;
 
-   if ((zone->uz_flags & UMA_ZFLAG_CACHE) != 0)
+   if ((zone->uz_flags & UMA_ZONE_HASH) == 0)
goto update_wss;
 
keg = zone->uz_keg;
@@ -1568,7 +1568,14 @@ keg_small_init(uma_keg_t keg)
"new wasted space = %d\n", keg->uk_name, keg, wastedspace,
slabsize / UMA_MAX_WASTE, keg->uk_ipers,
slabsize - keg->uk_ipers * keg->uk_rsize);
-   keg->uk_flags |= UMA_ZONE_OFFPAGE;
+   /*
+* If we had access to memory to embed a slab header we
+* also have a page structure to use vtoslab() instead of
+* hash to find slabs.  If the zone was explicitly created
+* OFFPAGE we can't necessarily touch the memory.
+*/
+   if ((keg->uk_flags & UMA_ZONE_OFFPAGE) == 0)
+   keg->uk_flags |= UMA_ZONE_OFFPAGE | UMA_ZONE_VTOSLAB;
}
 
if ((keg->uk_flags & UMA_ZONE_OFFPAGE) &&
@@ -1608,7 +1615,7 @@ keg_large_init(uma_keg_t keg)
 * slab header.
 */
if ((keg->uk_flags & UMA_ZFLAG_INTERNAL) == 0)
-   keg->uk_flags |= UMA_ZONE_OFFPAGE;
+   keg->uk_flags |= UMA_ZONE_OFFPAGE | UMA_ZONE_VTOSLAB;
else
keg->uk_ppera++;
}
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r354873 - head/sys/sys

2019-11-19 Thread Kirk McKusick
Author: mckusick
Date: Wed Nov 20 01:14:22 2019
New Revision: 354873
URL: https://svnweb.freebsd.org/changeset/base/354873

Log:
  White space cleanup. No functional change.
  
  Sponsored by: Netflix

Modified:
  head/sys/sys/buf.h

Modified: head/sys/sys/buf.h
==
--- head/sys/sys/buf.h  Wed Nov 20 01:10:01 2019(r354872)
+++ head/sys/sys/buf.h  Wed Nov 20 01:14:22 2019(r354873)
@@ -262,9 +262,9 @@ struct buf {
 #defineBX_VNDIRTY  0x0001  /* On vnode dirty list */
 #defineBX_VNCLEAN  0x0002  /* On vnode clean list */
 #defineBX_BKGRDWRITE   0x0010  /* Do writes in background */
-#define BX_BKGRDMARKER 0x0020  /* Mark buffer for splay tree */
+#defineBX_BKGRDMARKER  0x0020  /* Mark buffer for splay tree */
 #defineBX_ALTDATA  0x0040  /* Holds extended data */
-#defineBX_FSPRIV   0x00FF  /* filesystem-specific flags 
mask */
+#defineBX_FSPRIV   0x00FF  /* Filesystem-specific flags 
mask */
 
 #definePRINT_BUF_XFLAGS 
"\20\7altdata\6bkgrdmarker\5bkgrdwrite\2clean\1dirty"
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r354872 - head/sys/ufs/ffs

2019-11-19 Thread Kirk McKusick
Author: mckusick
Date: Wed Nov 20 01:10:01 2019
New Revision: 354872
URL: https://svnweb.freebsd.org/changeset/base/354872

Log:
  Add some KASSERTs. Reacquire a mutex after a kernel printf rather
  than holding it during the printf. White space cleanup.
  
  Sponsored by: Netflix

Modified:
  head/sys/ufs/ffs/ffs_softdep.c

Modified: head/sys/ufs/ffs/ffs_softdep.c
==
--- head/sys/ufs/ffs/ffs_softdep.c  Wed Nov 20 00:31:14 2019
(r354871)
+++ head/sys/ufs/ffs/ffs_softdep.c  Wed Nov 20 01:10:01 2019
(r354872)
@@ -9881,6 +9881,9 @@ handle_workitem_remove(dirrem, flags)
 */
if ((dirrem->dm_state & RMDIR) == 0) {
ip->i_nlink--;
+   KASSERT(ip->i_nlink >= 0, ("handle_workitem_remove: file ino "
+   "%ju negative i_nlink %d", (intmax_t)ip->i_number,
+   ip->i_nlink));
DIP_SET(ip, i_nlink, ip->i_nlink);
ip->i_flag |= IN_CHANGE;
if (ip->i_nlink < ip->i_effnlink)
@@ -9902,6 +9905,8 @@ handle_workitem_remove(dirrem, flags)
 * to account for the loss of "..".
 */
ip->i_nlink -= 2;
+   KASSERT(ip->i_nlink >= 0, ("handle_workitem_remove: directory ino "
+   "%ju negative i_nlink %d", (intmax_t)ip->i_number, ip->i_nlink));
DIP_SET(ip, i_nlink, ip->i_nlink);
ip->i_flag |= IN_CHANGE;
if (ip->i_nlink < ip->i_effnlink)
@@ -10802,7 +10807,6 @@ softdep_setup_inofree(mp, bp, ino, wkhd)
FREE_LOCK(ump);
 }
 
-
 /*
  * Called via ffs_blkfree() after a set of frags has been cleared from a cg
  * map.  Any dependencies waiting for the write to clear are added to the
@@ -12265,6 +12269,8 @@ softdep_load_inodeblock(ip)
return;
}
ip->i_effnlink -= inodedep->id_nlinkdelta;
+   KASSERT(ip->i_effnlink >= 0,
+   ("softdep_load_inodeblock: negative i_effnlink"));
FREE_LOCK(ump);
 }
 
@@ -13429,9 +13435,9 @@ softdep_request_cleanup(fs, vp, cred, resource)
roundup((fs->fs_dsize * fs->fs_minfree / 100) -
fs->fs_cstotal.cs_nffree, fs->fs_frag));
} else {
-   UFS_LOCK(ump);
printf("softdep_request_cleanup: Unknown resource type %d\n",
resource);
+   UFS_LOCK(ump);
return (0);
}
starttime = time_second;
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r354871 - head/sys/vm

2019-11-19 Thread Jeff Roberson
Author: jeff
Date: Wed Nov 20 00:31:14 2019
New Revision: 354871
URL: https://svnweb.freebsd.org/changeset/base/354871

Log:
  Only keep anonymous objects on shadow lists.  This eliminates locking of
  globally visible objects when they are part of a backing chain.
  
  Reviewed by:  kib, markj
  Differential Revision:https://reviews.freebsd.org/D22423

Modified:
  head/sys/vm/vm_object.c
  head/sys/vm/vm_object.h

Modified: head/sys/vm/vm_object.c
==
--- head/sys/vm/vm_object.c Tue Nov 19 23:30:09 2019(r354870)
+++ head/sys/vm/vm_object.c Wed Nov 20 00:31:14 2019(r354871)
@@ -118,6 +118,7 @@ static boolean_t vm_object_page_remove_write(vm_page_t
boolean_t *allclean);
 static voidvm_object_qcollapse(vm_object_t object);
 static voidvm_object_vndeallocate(vm_object_t object);
+static voidvm_object_backing_remove(vm_object_t object);
 
 /*
  * Virtual memory objects maintain the actual data
@@ -651,11 +652,7 @@ doterm:
if (temp != NULL) {
KASSERT((object->flags & OBJ_TMPFS_NODE) == 0,
("shadowed tmpfs v_object 2 %p", object));
-   VM_OBJECT_WLOCK(temp);
-   LIST_REMOVE(object, shadow_list);
-   temp->shadow_count--;
-   VM_OBJECT_WUNLOCK(temp);
-   object->backing_object = NULL;
+   vm_object_backing_remove(object);
}
/*
 * Don't double-terminate, we could be in a termination
@@ -695,6 +692,70 @@ vm_object_destroy(vm_object_t object)
uma_zfree(obj_zone, object);
 }
 
+static void
+vm_object_backing_remove_locked(vm_object_t object)
+{
+   vm_object_t backing_object;
+
+   backing_object = object->backing_object;
+   VM_OBJECT_ASSERT_WLOCKED(object);
+   VM_OBJECT_ASSERT_WLOCKED(backing_object);
+
+   if ((object->flags & OBJ_SHADOWLIST) != 0) {
+   LIST_REMOVE(object, shadow_list);
+   backing_object->shadow_count--;
+   object->flags &= ~OBJ_SHADOWLIST;
+   }
+   object->backing_object = NULL;
+}
+
+static void
+vm_object_backing_remove(vm_object_t object)
+{
+   vm_object_t backing_object;
+
+   VM_OBJECT_ASSERT_WLOCKED(object);
+
+   if ((object->flags & OBJ_SHADOWLIST) != 0) {
+   backing_object = object->backing_object;
+   VM_OBJECT_WLOCK(backing_object);
+   vm_object_backing_remove_locked(object);
+   VM_OBJECT_WUNLOCK(backing_object);
+   } else
+   object->backing_object = NULL;
+}
+
+static void
+vm_object_backing_insert_locked(vm_object_t object, vm_object_t backing_object)
+{
+
+   VM_OBJECT_ASSERT_WLOCKED(object);
+
+   if ((backing_object->flags & OBJ_ANON) != 0) {
+   VM_OBJECT_ASSERT_WLOCKED(backing_object);
+   LIST_INSERT_HEAD(&backing_object->shadow_head, object,
+   shadow_list);
+   backing_object->shadow_count++;
+   object->flags |= OBJ_SHADOWLIST;
+   }
+   object->backing_object = backing_object;
+}
+
+static void
+vm_object_backing_insert(vm_object_t object, vm_object_t backing_object)
+{
+
+   VM_OBJECT_ASSERT_WLOCKED(object);
+
+   if ((backing_object->flags & OBJ_ANON) != 0) {
+   VM_OBJECT_WLOCK(backing_object);
+   vm_object_backing_insert_locked(object, backing_object);
+   VM_OBJECT_WUNLOCK(backing_object);
+   } else
+   object->backing_object = backing_object;
+}
+
+
 /*
  * vm_object_terminate_pages removes any remaining pageable pages
  * from the object and resets the object to an empty state.
@@ -1250,6 +1311,12 @@ vm_object_shadow(
result = vm_object_allocate_anon(atop(length));
 
/*
+* Store the offset into the source object, and fix up the offset into
+* the new object.
+*/
+   result->backing_object_offset = *offset;
+
+   /*
 * The new object shadows the source object, adding a reference to it.
 * Our caller changes his reference to point to the new object,
 * removing a reference to the source object.  Net result: no change
@@ -1259,26 +1326,18 @@ vm_object_shadow(
 * in order to maintain page coloring consistency in the combined 
 * shadowed object.
 */
-   result->backing_object = source;
-   /*
-* Store the offset into the source object, and fix up the offset into
-* the new object.
-*/
-   result->backing_object_offset = *offset;
if (source != NULL) {
-   VM_OBJECT_WLOCK(source);
+   VM_OBJECT_WLOCK(result);
+   vm_object_backing_insert(result, source);
result->domain = source->domain;
-   LIST_I

svn commit: r354870 - head/sys/vm

2019-11-19 Thread Jeff Roberson
Author: jeff
Date: Tue Nov 19 23:30:09 2019
New Revision: 354870
URL: https://svnweb.freebsd.org/changeset/base/354870

Log:
  Remove unnecessary object locking from the vnode pager.  Recent changes to
  busy/valid/dirty locking make these acquires redundant.
  
  Reviewed by:  kib, markj
  Differential Revision:https://reviews.freebsd.org/D22186

Modified:
  head/sys/vm/vm_page.c
  head/sys/vm/vm_page.h
  head/sys/vm/vnode_pager.c

Modified: head/sys/vm/vm_page.c
==
--- head/sys/vm/vm_page.c   Tue Nov 19 23:19:43 2019(r354869)
+++ head/sys/vm/vm_page.c   Tue Nov 19 23:30:09 2019(r354870)
@@ -4527,7 +4527,7 @@ vm_page_bits(int base, int size)
((vm_page_bits_t)1 << first_bit));
 }
 
-static inline void
+void
 vm_page_bits_set(vm_page_t m, vm_page_bits_t *bits, vm_page_bits_t set)
 {
 

Modified: head/sys/vm/vm_page.h
==
--- head/sys/vm/vm_page.h   Tue Nov 19 23:19:43 2019(r354869)
+++ head/sys/vm/vm_page.h   Tue Nov 19 23:30:09 2019(r354870)
@@ -587,6 +587,7 @@ vm_page_t vm_page_alloc_contig_domain(vm_object_t obje
 vm_memattr_t memattr);
 vm_page_t vm_page_alloc_freelist(int, int);
 vm_page_t vm_page_alloc_freelist_domain(int, int, int);
+void vm_page_bits_set(vm_page_t m, vm_page_bits_t *bits, vm_page_bits_t set);
 bool vm_page_blacklist_add(vm_paddr_t pa, bool verbose);
 void vm_page_change_lock(vm_page_t m, struct mtx **mtx);
 vm_page_t vm_page_grab (vm_object_t, vm_pindex_t, int);

Modified: head/sys/vm/vnode_pager.c
==
--- head/sys/vm/vnode_pager.c   Tue Nov 19 23:19:43 2019(r354869)
+++ head/sys/vm/vnode_pager.c   Tue Nov 19 23:30:09 2019(r354870)
@@ -649,9 +649,7 @@ vnode_pager_input_smlfs(vm_object_t object, vm_page_t 
bzero((caddr_t)sf_buf_kva(sf) + i * bsize, bsize);
KASSERT((m->dirty & bits) == 0,
("vnode_pager_input_smlfs: page %p is dirty", m));
-   VM_OBJECT_WLOCK(object);
-   m->valid |= bits;
-   VM_OBJECT_WUNLOCK(object);
+   vm_page_bits_set(m, &m->valid, bits);
}
sf_buf_free(sf);
if (error) {
@@ -888,9 +886,7 @@ vnode_pager_generic_getpages(struct vnode *vp, vm_page
pmap_zero_page(m[0]);
KASSERT(m[0]->dirty == 0, ("%s: page %p is dirty",
__func__, m[0]));
-   VM_OBJECT_WLOCK(object);
vm_page_valid(m[0]);
-   VM_OBJECT_WUNLOCK(object);
return (VM_PAGER_OK);
}
 
@@ -1143,7 +1139,8 @@ vnode_pager_generic_getpages_done(struct buf *bp)
bp->b_data = unmapped_buf;
}
 
-   VM_OBJECT_WLOCK(object);
+   /* Read lock to protect size. */
+   VM_OBJECT_RLOCK(object);
for (i = 0, tfoff = IDX_TO_OFF(bp->b_pages[0]->pindex);
i < bp->b_npages; i++, tfoff = nextoff) {
vm_page_t mt;
@@ -1180,7 +1177,7 @@ vnode_pager_generic_getpages_done(struct buf *bp)
if (i < bp->b_pgbefore || i >= bp->b_npages - bp->b_pgafter)
vm_page_readahead_finish(mt);
}
-   VM_OBJECT_WUNLOCK(object);
+   VM_OBJECT_RUNLOCK(object);
if (error != 0)
printf("%s: I/O read error %d\n", __func__, error);
 
@@ -1304,12 +1301,6 @@ vnode_pager_generic_putpages(struct vnode *vp, vm_page
 */
VM_OBJECT_RLOCK(object);
if (maxsize + poffset > object->un_pager.vnp.vnp_size) {
-   if (!VM_OBJECT_TRYUPGRADE(object)) {
-   VM_OBJECT_RUNLOCK(object);
-   VM_OBJECT_WLOCK(object);
-   if (maxsize + poffset <= object->un_pager.vnp.vnp_size)
-   goto downgrade;
-   }
if (object->un_pager.vnp.vnp_size > poffset) {
maxsize = object->un_pager.vnp.vnp_size - poffset;
ncount = btoc(maxsize);
@@ -1317,7 +1308,7 @@ vnode_pager_generic_putpages(struct vnode *vp, vm_page
pgoff = roundup2(pgoff, DEV_BSIZE);
 
/*
-* If the object is locked and the following
+* If the page is busy and the following
 * conditions hold, then the page's dirty
 * field cannot be concurrently changed by a
 * pmap operation.
@@ -1336,9 +1327,8 @@ vnode_pager_generic_putpages(struct vnode *vp, vm_page
}
for (i = ncount; i < count; i++)
rtvals[i] = VM_PAGER_BAD;
-downgrade:
-   VM_OBJECT_LOCK_DOWNGRADE(obje

svn commit: r354869 - in head/sys: fs/tmpfs kern vm

2019-11-19 Thread Jeff Roberson
Author: jeff
Date: Tue Nov 19 23:19:43 2019
New Revision: 354869
URL: https://svnweb.freebsd.org/changeset/base/354869

Log:
  Simplify anonymous memory handling with an OBJ_ANON flag.  This eliminates
  reudundant complicated checks and additional locking required only for
  anonymous memory.  Introduce vm_object_allocate_anon() to create these
  objects.  DEFAULT and SWAP objects now have the correct settings for
  non-anonymous consumers and so individual consumers need not modify the
  default flags to create super-pages and avoid ONEMAPPING/NOSPLIT.
  
  Reviewed by:  alc, dougm, kib, markj
  Tested by:pho
  Differential Revision:https://reviews.freebsd.org/D22119

Modified:
  head/sys/fs/tmpfs/tmpfs_subr.c
  head/sys/kern/sysv_shm.c
  head/sys/kern/uipc_shm.c
  head/sys/vm/swap_pager.c
  head/sys/vm/vm_fault.c
  head/sys/vm/vm_map.c
  head/sys/vm/vm_meter.c
  head/sys/vm/vm_object.c
  head/sys/vm/vm_object.h
  head/sys/vm/vm_reserv.c

Modified: head/sys/fs/tmpfs/tmpfs_subr.c
==
--- head/sys/fs/tmpfs/tmpfs_subr.c  Tue Nov 19 23:12:43 2019
(r354868)
+++ head/sys/fs/tmpfs/tmpfs_subr.c  Tue Nov 19 23:19:43 2019
(r354869)
@@ -273,8 +273,7 @@ tmpfs_alloc_node(struct mount *mp, struct tmpfs_mount 
NULL /* XXXKIB - tmpfs needs swap reservation */);
VM_OBJECT_WLOCK(obj);
/* OBJ_TMPFS is set together with the setting of vp->v_object */
-   vm_object_set_flag(obj, OBJ_NOSPLIT | OBJ_TMPFS_NODE);
-   vm_object_clear_flag(obj, OBJ_ONEMAPPING);
+   vm_object_set_flag(obj, OBJ_TMPFS_NODE);
VM_OBJECT_WUNLOCK(obj);
break;
 

Modified: head/sys/kern/sysv_shm.c
==
--- head/sys/kern/sysv_shm.cTue Nov 19 23:12:43 2019(r354868)
+++ head/sys/kern/sysv_shm.cTue Nov 19 23:19:43 2019(r354869)
@@ -751,11 +751,6 @@ shmget_allocate_segment(struct thread *td, struct shmg
 #endif
return (ENOMEM);
}
-   shm_object->pg_color = 0;
-   VM_OBJECT_WLOCK(shm_object);
-   vm_object_clear_flag(shm_object, OBJ_ONEMAPPING);
-   vm_object_set_flag(shm_object, OBJ_COLORED | OBJ_NOSPLIT);
-   VM_OBJECT_WUNLOCK(shm_object);
 
shmseg->object = shm_object;
shmseg->u.shm_perm.cuid = shmseg->u.shm_perm.uid = cred->cr_uid;

Modified: head/sys/kern/uipc_shm.c
==
--- head/sys/kern/uipc_shm.cTue Nov 19 23:12:43 2019(r354868)
+++ head/sys/kern/uipc_shm.cTue Nov 19 23:19:43 2019(r354869)
@@ -597,11 +597,6 @@ shm_alloc(struct ucred *ucred, mode_t mode)
shmfd->shm_object = vm_pager_allocate(OBJT_SWAP, NULL,
shmfd->shm_size, VM_PROT_DEFAULT, 0, ucred);
KASSERT(shmfd->shm_object != NULL, ("shm_create: vm_pager_allocate"));
-   shmfd->shm_object->pg_color = 0;
-   VM_OBJECT_WLOCK(shmfd->shm_object);
-   vm_object_clear_flag(shmfd->shm_object, OBJ_ONEMAPPING);
-   vm_object_set_flag(shmfd->shm_object, OBJ_COLORED | OBJ_NOSPLIT);
-   VM_OBJECT_WUNLOCK(shmfd->shm_object);
vfs_timestamp(&shmfd->shm_birthtime);
shmfd->shm_atime = shmfd->shm_mtime = shmfd->shm_ctime =
shmfd->shm_birthtime;

Modified: head/sys/vm/swap_pager.c
==
--- head/sys/vm/swap_pager.cTue Nov 19 23:12:43 2019(r354868)
+++ head/sys/vm/swap_pager.cTue Nov 19 23:19:43 2019(r354869)
@@ -3038,7 +3038,7 @@ swap_pager_update_writecount(vm_object_t object, vm_of
 {
 
VM_OBJECT_WLOCK(object);
-   KASSERT((object->flags & OBJ_NOSPLIT) != 0,
+   KASSERT((object->flags & OBJ_ANON) == 0,
("Splittable object with writecount"));
object->un_pager.swp.writemappings += (vm_ooffset_t)end - start;
VM_OBJECT_WUNLOCK(object);
@@ -3050,7 +3050,7 @@ swap_pager_release_writecount(vm_object_t object, vm_o
 {
 
VM_OBJECT_WLOCK(object);
-   KASSERT((object->flags & OBJ_NOSPLIT) != 0,
+   KASSERT((object->flags & OBJ_ANON) == 0,
("Splittable object with writecount"));
object->un_pager.swp.writemappings -= (vm_ooffset_t)end - start;
VM_OBJECT_WUNLOCK(object);

Modified: head/sys/vm/vm_fault.c
==
--- head/sys/vm/vm_fault.c  Tue Nov 19 23:12:43 2019(r354868)
+++ head/sys/vm/vm_fault.c  Tue Nov 19 23:19:43 2019(r354869)
@@ -1239,8 +1239,7 @@ readrest:
/*
 * No other ways to look the object up
 */
-   ((fs.object->type == OBJT_DEFAULT) ||
- 

svn commit: r354868 - head/sys/arm/broadcom/bcm2835

2019-11-19 Thread Kyle Evans
Author: kevans
Date: Tue Nov 19 23:12:43 2019
New Revision: 354868
URL: https://svnweb.freebsd.org/changeset/base/354868

Log:
  bcm2835_sdhci: various refactoring of DMA path
  
  This round of refactoring is mostly about streamlining the interrupt handler
  to make it easier to verify and reason about operations taking place while
  trying to bring FreeBSD up on the RPi4.

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

Modified: head/sys/arm/broadcom/bcm2835/bcm2835_sdhci.c
==
--- head/sys/arm/broadcom/bcm2835/bcm2835_sdhci.c   Tue Nov 19 21:29:49 
2019(r354867)
+++ head/sys/arm/broadcom/bcm2835/bcm2835_sdhci.c   Tue Nov 19 23:12:43 
2019(r354868)
@@ -78,6 +78,13 @@ __FBSDID("$FreeBSD$");
 #defineALLOCATED_DMA_SEGS  (NUM_DMA_SEGS + 
NUM_DMA_SPILL_SEGS)
 #defineBCM_DMA_MAXSIZE (NUM_DMA_SEGS * 
BCM_SDHCI_BUFFER_SIZE)
 
+#defineBCM_SDHCI_SLOT_LEFT(slot)   \
+   ((slot)->curcmd->data->len - (slot)->offset)
+
+#defineBCM_SDHCI_SEGSZ_LEFT(slot)  \
+   min(BCM_DMA_MAXSIZE,\
+   rounddown(BCM_SDHCI_SLOT_LEFT(slot), BCM_SDHCI_BUFFER_SIZE))
+
 #defineDATA_PENDING_MASK   (SDHCI_INT_DATA_AVAIL | 
SDHCI_INT_SPACE_AVAIL)
 
 #ifdef DEBUG
@@ -172,6 +179,7 @@ static void bcm_sdhci_intr(void *);
 
 static int bcm_sdhci_get_ro(device_t, device_t);
 static void bcm_sdhci_dma_intr(int ch, void *arg);
+static void bcm_sdhci_start_dma(struct sdhci_slot *slot);
 
 static void
 bcm_sdhci_dmacb(void *arg, bus_dma_segment_t *segs, int nseg, int err)
@@ -569,8 +577,9 @@ bcm_sdhci_start_dma_seg(struct bcm_sdhci_softc *sc)
 */
if (idx == 0) {
bus_dmamap_sync(sc->sc_dma_tag, sc->sc_dma_map, sync_op);
+
slot->intmask &= ~DATA_PENDING_MASK;
-   bcm_sdhci_write_4(sc->sc_dev, &sc->sc_slot, SDHCI_SIGNAL_ENABLE,
+   bcm_sdhci_write_4(sc->sc_dev, slot, SDHCI_SIGNAL_ENABLE,
slot->intmask);
}
 
@@ -583,20 +592,28 @@ bcm_sdhci_start_dma_seg(struct bcm_sdhci_softc *sc)
 }
 
 static void
+bcm_sdhci_dma_exit(struct bcm_sdhci_softc *sc)
+{
+   struct sdhci_slot *slot = &sc->sc_slot;
+
+   mtx_assert(&slot->mtx, MA_OWNED);
+
+   /* Re-enable interrupts */
+   slot->intmask |= DATA_PENDING_MASK;
+   bcm_sdhci_write_4(slot->bus, slot, SDHCI_SIGNAL_ENABLE,
+   slot->intmask);
+}
+
+static void
 bcm_sdhci_dma_intr(int ch, void *arg)
 {
struct bcm_sdhci_softc *sc = (struct bcm_sdhci_softc *)arg;
struct sdhci_slot *slot = &sc->sc_slot;
uint32_t reg;
-   int left, sync_op;
 
mtx_lock(&slot->mtx);
-
-   if (slot->curcmd == NULL) {
-   mtx_unlock(&slot->mtx);
-   return;
-   }
-
+   if (slot->curcmd == NULL)
+   goto out;
/*
 * If there are more segments for the current dma, start the next one.
 * Otherwise unload the dma map and decide what to do next based on the
@@ -604,92 +621,64 @@ bcm_sdhci_dma_intr(int ch, void *arg)
 */
if (sc->dmamap_seg_index < sc->dmamap_seg_count) {
bcm_sdhci_start_dma_seg(sc);
-   mtx_unlock(&slot->mtx);
-   return;
+   goto out;
}
 
-   if (slot->curcmd->data->flags & MMC_DATA_READ)
-   sync_op = BUS_DMASYNC_POSTREAD;
+   if ((slot->curcmd->data->flags & MMC_DATA_READ) != 0)
+   bus_dmamap_sync(sc->sc_dma_tag, sc->sc_dma_map,
+   BUS_DMASYNC_POSTREAD);
else
-   sync_op = BUS_DMASYNC_POSTWRITE;
+   bus_dmamap_sync(sc->sc_dma_tag, sc->sc_dma_map,
+   BUS_DMASYNC_POSTWRITE);
+   bus_dmamap_unload(sc->sc_dma_tag, sc->sc_dma_map);
 
-   if (sc->dmamap_seg_count != 0) {
-   bus_dmamap_sync(sc->sc_dma_tag, sc->sc_dma_map, sync_op);
-   bus_dmamap_unload(sc->sc_dma_tag, sc->sc_dma_map);
+   sc->dmamap_seg_count = 0;
+   sc->dmamap_seg_index = 0;
 
-   sc->dmamap_seg_count = 0;
-   sc->dmamap_seg_index = 0;
-   }
-
-   left = min(BCM_SDHCI_BUFFER_SIZE,
-   slot->curcmd->data->len - slot->offset);
-
/*
-* If there is less than buffer size outstanding, we would not handle
-* it anymore using DMA if bcm_sdhci_will_handle_transfer() were asked.
-* Re-enable interrupts and return and let the SDHCI state machine
-* finish the job.
+* If we had no further segments pending, we need to determine how to
+* proceed next.  If the 'data/space pending' bit is already set and we
+* can continue via DMA, do so.  Otherwise, re-enable interrupts and
+* return.
 */
-   if (left < BCM_SDHCI_BUFFER_SIZE) {
-   /* Re-enable data interrupts. */
-   slot->intm

svn commit: r354867 - head/sys/net

2019-11-19 Thread Vincenzo Maffione
Author: vmaffione
Date: Tue Nov 19 21:29:49 2019
New Revision: 354867
URL: https://svnweb.freebsd.org/changeset/base/354867

Log:
  netmap: check if we already ran mmap before we attempt it
  
  Submitted by: n...@neelc.org
  Reviewed by:  vmaffione
  MFC after:1 week
  Differential Revision:https://reviews.freebsd.org/D22390

Modified:
  head/sys/net/netmap_user.h

Modified: head/sys/net/netmap_user.h
==
--- head/sys/net/netmap_user.h  Tue Nov 19 21:15:12 2019(r354866)
+++ head/sys/net/netmap_user.h  Tue Nov 19 21:29:49 2019(r354867)
@@ -981,7 +981,8 @@ nm_close(struct nm_desc *d)
 static int
 nm_mmap(struct nm_desc *d, const struct nm_desc *parent)
 {
-   //XXX TODO: check if mmap is already done
+   if (d->done_mmap)
+   return 0;
 
if (IS_NETMAP_DESC(parent) && parent->mem &&
parent->req.nr_arg2 == d->req.nr_arg2) {
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r354865 - head/sys/netinet6

2019-11-19 Thread Bjoern A. Zeeb
Author: bz
Date: Tue Nov 19 21:14:15 2019
New Revision: 354865
URL: https://svnweb.freebsd.org/changeset/base/354865

Log:
  in6: move include
  
  Move the include for sysctl.h out of the middle of the file to the
  includes at the beginning.  This is will make it easier to add new
  sysctls.
  
  No functional changes.
  
  MFC after:3 weeks
  Sponsored by: Netflix

Modified:
  head/sys/netinet6/in6.c

Modified: head/sys/netinet6/in6.c
==
--- head/sys/netinet6/in6.c Tue Nov 19 21:10:44 2019(r354864)
+++ head/sys/netinet6/in6.c Tue Nov 19 21:14:15 2019(r354865)
@@ -84,6 +84,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include 
@@ -2023,8 +2024,6 @@ in6_if2idlen(struct ifnet *ifp)
return (64);
}
 }
-
-#include 
 
 struct in6_llentry {
struct llentry  base;
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


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

2019-11-19 Thread Vincenzo Maffione
Author: vmaffione
Date: Tue Nov 19 21:10:44 2019
New Revision: 354864
URL: https://svnweb.freebsd.org/changeset/base/354864

Log:
  bhyve: virtio-net: disable receive until features are negotiated
  
  This patch fixes a race condition where the receive callback is called
  while the device is being reset. Since the rx_merge variable may change
  during reset, the receive callback may operate inconsistently with what
  the guest expects.
  Also, get rid of the unused rx_vhdrlen variable.
  
  PR:   242023
  Reported by:  aleksandr.fedo...@itglobal.com
  Reviewed by:  markj, jhb
  MFC with: r354552
  Differential Revision:https://reviews.freebsd.org/D22440

Modified:
  head/usr.sbin/bhyve/pci_virtio_net.c

Modified: head/usr.sbin/bhyve/pci_virtio_net.c
==
--- head/usr.sbin/bhyve/pci_virtio_net.cTue Nov 19 21:08:18 2019
(r354863)
+++ head/usr.sbin/bhyve/pci_virtio_net.cTue Nov 19 21:10:44 2019
(r354864)
@@ -109,7 +109,6 @@ struct pci_vtnet_softc {
uint64_tvsc_features;   /* negotiated features */

pthread_mutex_t rx_mtx;
-   unsigned intrx_vhdrlen;
int rx_merge;   /* merged rx bufs in use */
 
pthread_t   tx_tid;
@@ -149,6 +148,16 @@ pci_vtnet_reset(void *vsc)
/* Acquire the RX lock to block RX processing. */
pthread_mutex_lock(&sc->rx_mtx);
 
+   /*
+* Make sure receive operation is disabled at least until we
+* re-negotiate the features, since receive operation depends
+* on the value of sc->rx_merge and the header length, which
+* are both set in pci_vtnet_neg_features().
+* Receive operation will be enabled again once the guest adds
+* the first receive buffers and kicks us.
+*/
+   netbe_rx_disable(sc->vsc_be);
+
/* Set sc->resetting and give a chance to the TX thread to stop. */
pthread_mutex_lock(&sc->tx_mtx);
sc->resetting = 1;
@@ -158,9 +167,6 @@ pci_vtnet_reset(void *vsc)
pthread_mutex_lock(&sc->tx_mtx);
}
 
-   sc->rx_merge = 1;
-   sc->rx_vhdrlen = sizeof(struct virtio_net_rxhdr);
-
/*
 * Now reset rings, MSI-X vectors, and negotiated capabilities.
 * Do that with the TX lock held, since we need to reset
@@ -512,8 +518,7 @@ pci_vtnet_init(struct vmctx *ctx, struct pci_devinst *
 
sc->resetting = 0;
 
-   sc->rx_merge = 1;
-   sc->rx_vhdrlen = sizeof(struct virtio_net_rxhdr);
+   sc->rx_merge = 0;
pthread_mutex_init(&sc->rx_mtx, NULL); 
 
/* 
@@ -568,18 +573,24 @@ static void
 pci_vtnet_neg_features(void *vsc, uint64_t negotiated_features)
 {
struct pci_vtnet_softc *sc = vsc;
+   unsigned int rx_vhdrlen;
 
sc->vsc_features = negotiated_features;
 
-   if (!(negotiated_features & VIRTIO_NET_F_MRG_RXBUF)) {
+   if (negotiated_features & VIRTIO_NET_F_MRG_RXBUF) {
+   rx_vhdrlen = sizeof(struct virtio_net_rxhdr);
+   sc->rx_merge = 1;
+   } else {
+   /*
+* Without mergeable rx buffers, virtio-net header is 2
+* bytes shorter than sizeof(struct virtio_net_rxhdr).
+*/
+   rx_vhdrlen = sizeof(struct virtio_net_rxhdr) - 2;
sc->rx_merge = 0;
-   /* Without mergeable rx buffers, virtio-net header is 2
-* bytes shorter than sizeof(struct virtio_net_rxhdr). */
-   sc->rx_vhdrlen = sizeof(struct virtio_net_rxhdr) - 2;
}
 
/* Tell the backend to enable some capabilities it has advertised. */
-   netbe_set_cap(sc->vsc_be, negotiated_features, sc->rx_vhdrlen);
+   netbe_set_cap(sc->vsc_be, negotiated_features, rx_vhdrlen);
 }
 
 static struct pci_devemu pci_de_vnet = {
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r354863 - head/sys/netinet6

2019-11-19 Thread Bjoern A. Zeeb
Author: bz
Date: Tue Nov 19 21:08:18 2019
New Revision: 354863
URL: https://svnweb.freebsd.org/changeset/base/354863

Log:
  nd6: sysctl
  
  Move the SYSCTL_DECL to the top of the file.  Move the sysctl function
  before SYSCTL_PROC so that we don't need an extra function declaration in
  the middle of the file.
  
  No functional changes.
  
  MFC after:3 weeks
  Sponsored by: Netflix

Modified:
  head/sys/netinet6/nd6.c

Modified: head/sys/netinet6/nd6.c
==
--- head/sys/netinet6/nd6.c Tue Nov 19 20:54:17 2019(r354862)
+++ head/sys/netinet6/nd6.c Tue Nov 19 21:08:18 2019(r354863)
@@ -148,6 +148,8 @@ VNET_DEFINE_STATIC(struct callout, nd6_slowtimo_ch);
 VNET_DEFINE_STATIC(struct callout, nd6_timer_ch);
 #defineV_nd6_timer_ch  VNET(nd6_timer_ch)
 
+SYSCTL_DECL(_net_inet6_icmp6);
+
 static void
 nd6_lle_event(void *arg __unused, struct llentry *lle, int evt)
 {
@@ -2571,18 +2573,6 @@ clear_llinfo_pqueue(struct llentry *ln)
ln->la_hold = NULL;
 }
 
-static int nd6_sysctl_prlist(SYSCTL_HANDLER_ARGS);
-
-SYSCTL_DECL(_net_inet6_icmp6);
-SYSCTL_PROC(_net_inet6_icmp6, ICMPV6CTL_ND6_PRLIST, nd6_prlist,
-   CTLTYPE_OPAQUE | CTLFLAG_RD | CTLFLAG_MPSAFE,
-   NULL, 0, nd6_sysctl_prlist, "S,in6_prefix",
-   "NDP prefix list");
-SYSCTL_INT(_net_inet6_icmp6, ICMPV6CTL_ND6_MAXQLEN, nd6_maxqueuelen,
-   CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(nd6_maxqueuelen), 1, "");
-SYSCTL_INT(_net_inet6_icmp6, OID_AUTO, nd6_gctimer,
-   CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(nd6_gctimer), (60 * 60 * 24), "");
-
 static int
 nd6_sysctl_prlist(SYSCTL_HANDLER_ARGS)
 {
@@ -2656,3 +2646,11 @@ out:
ND6_RUNLOCK();
return (error);
 }
+SYSCTL_PROC(_net_inet6_icmp6, ICMPV6CTL_ND6_PRLIST, nd6_prlist,
+   CTLTYPE_OPAQUE | CTLFLAG_RD | CTLFLAG_MPSAFE,
+   NULL, 0, nd6_sysctl_prlist, "S,in6_prefix",
+   "NDP prefix list");
+SYSCTL_INT(_net_inet6_icmp6, ICMPV6CTL_ND6_MAXQLEN, nd6_maxqueuelen,
+   CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(nd6_maxqueuelen), 1, "");
+SYSCTL_INT(_net_inet6_icmp6, OID_AUTO, nd6_gctimer,
+   CTLFLAG_VNET | CTLFLAG_RW, &VNET_NAME(nd6_gctimer), (60 * 60 * 24), "");
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r354862 - head/sys/netinet6

2019-11-19 Thread Bjoern A. Zeeb
Author: bz
Date: Tue Nov 19 20:54:17 2019
New Revision: 354862
URL: https://svnweb.freebsd.org/changeset/base/354862

Log:
  nd6: make nd6_timer_ch static
  
  nd6_timer_ch is only used in file local context.  There is no need to
  export it, so make it static.
  
  MFC after:3 weeks
  Sponsored by: Netflix

Modified:
  head/sys/netinet6/nd6.c

Modified: head/sys/netinet6/nd6.c
==
--- head/sys/netinet6/nd6.c Tue Nov 19 20:34:33 2019(r354861)
+++ head/sys/netinet6/nd6.c Tue Nov 19 20:54:17 2019(r354862)
@@ -145,7 +145,7 @@ static int nd6_need_cache(struct ifnet *);
 VNET_DEFINE_STATIC(struct callout, nd6_slowtimo_ch);
 #defineV_nd6_slowtimo_ch   VNET(nd6_slowtimo_ch)
 
-VNET_DEFINE(struct callout, nd6_timer_ch);
+VNET_DEFINE_STATIC(struct callout, nd6_timer_ch);
 #defineV_nd6_timer_ch  VNET(nd6_timer_ch)
 
 static void
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r354861 - head/sys/netinet6

2019-11-19 Thread Bjoern A. Zeeb
Author: bz
Date: Tue Nov 19 20:34:33 2019
New Revision: 354861
URL: https://svnweb.freebsd.org/changeset/base/354861

Log:
  nd6_rtr: re-sort functions
  
  Resort functions within file in a way that they depend on each other as
  that makes it easier to rework various things.
  Also allows us to remove file local function declarations.
  
  No functional changes.
  
  MFC after:3 weeks
  Sponsored by: Netflix

Modified:
  head/sys/netinet6/nd6_rtr.c

Modified: head/sys/netinet6/nd6_rtr.c
==
--- head/sys/netinet6/nd6_rtr.c Tue Nov 19 19:05:05 2019(r354860)
+++ head/sys/netinet6/nd6_rtr.c Tue Nov 19 20:34:33 2019(r354861)
@@ -73,25 +73,10 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 
-static int rtpref(struct nd_defrouter *);
 static struct nd_defrouter *defrtrlist_update(struct nd_defrouter *);
 static int prelist_update(struct nd_prefixctl *, struct nd_defrouter *,
 struct mbuf *, int);
-static struct in6_ifaddr *in6_ifadd(struct nd_prefixctl *, int);
-static struct nd_pfxrouter *pfxrtr_lookup(struct nd_prefix *,
-struct nd_defrouter *);
-static void pfxrtr_add(struct nd_prefix *, struct nd_defrouter *);
-static void pfxrtr_del(struct nd_pfxrouter *);
-static struct nd_pfxrouter *find_pfxlist_reachable_router(struct nd_prefix *);
-static void defrouter_delreq(struct nd_defrouter *);
-static void nd6_rtmsg(int, struct rtentry *);
 
-static int in6_init_prefix_ltimes(struct nd_prefix *);
-static void in6_init_address_ltimes(struct nd_prefix *,
-struct in6_addrlifetime *);
-
-static int rt6_deleteroute(const struct rtentry *, void *);
-
 TAILQ_HEAD(nd6_drhead, nd_defrouter);
 VNET_DEFINE_STATIC(struct nd6_drhead, nd6_defrouter);
 #defineV_nd6_defrouter VNET(nd6_defrouter)
@@ -115,6 +100,8 @@ VNET_DEFINE(int, ip6_temp_regen_advance) = TEMPADDR_RE
 VNET_DEFINE(int, nd6_ignore_ipv6_only_ra) = 1;
 #endif
 
+SYSCTL_DECL(_net_inet6_icmp6);
+
 /* RTPREF_MEDIUM has to be 0! */
 #define RTPREF_HIGH1
 #define RTPREF_MEDIUM  0
@@ -644,11 +631,72 @@ nd6_rtmsg(int cmd, struct rtentry *rt)
ifa_free(ifa);
 }
 
-/*
- * default router list processing sub routines
- */
+/* PFXRTR */
+static struct nd_pfxrouter *
+pfxrtr_lookup(struct nd_prefix *pr, struct nd_defrouter *dr)
+{
+   struct nd_pfxrouter *search;
 
+   ND6_LOCK_ASSERT();
+
+   LIST_FOREACH(search, &pr->ndpr_advrtrs, pfr_entry) {
+   if (search->router == dr)
+   break;
+   }
+   return (search);
+}
+
 static void
+pfxrtr_add(struct nd_prefix *pr, struct nd_defrouter *dr)
+{
+   struct nd_pfxrouter *new;
+   bool update;
+
+   ND6_UNLOCK_ASSERT();
+
+   ND6_RLOCK();
+   if (pfxrtr_lookup(pr, dr) != NULL) {
+   ND6_RUNLOCK();
+   return;
+   }
+   ND6_RUNLOCK();
+
+   new = malloc(sizeof(*new), M_IP6NDP, M_NOWAIT | M_ZERO);
+   if (new == NULL)
+   return;
+   defrouter_ref(dr);
+   new->router = dr;
+
+   ND6_WLOCK();
+   if (pfxrtr_lookup(pr, dr) == NULL) {
+   LIST_INSERT_HEAD(&pr->ndpr_advrtrs, new, pfr_entry);
+   update = true;
+   } else {
+   /* We lost a race to add the reference. */
+   defrouter_rele(dr);
+   free(new, M_IP6NDP);
+   update = false;
+   }
+   ND6_WUNLOCK();
+
+   if (update)
+   pfxlist_onlink_check();
+}
+
+static void
+pfxrtr_del(struct nd_pfxrouter *pfr)
+{
+
+   ND6_WLOCK_ASSERT();
+
+   LIST_REMOVE(pfr, pfr_entry);
+   defrouter_rele(pfr->router);
+   free(pfr, M_IP6NDP);
+}
+
+
+/* Default router list processing sub routines. */
+static void
 defrouter_addreq(struct nd_defrouter *new)
 {
struct sockaddr_in6 def, mask, gate;
@@ -675,31 +723,6 @@ defrouter_addreq(struct nd_defrouter *new)
new->installed = 1;
 }
 
-struct nd_defrouter *
-defrouter_lookup_locked(struct in6_addr *addr, struct ifnet *ifp)
-{
-   struct nd_defrouter *dr;
-
-   ND6_LOCK_ASSERT();
-   TAILQ_FOREACH(dr, &V_nd6_defrouter, dr_entry)
-   if (dr->ifp == ifp && IN6_ARE_ADDR_EQUAL(addr, &dr->rtaddr)) {
-   defrouter_ref(dr);
-   return (dr);
-   }
-   return (NULL);
-}
-
-struct nd_defrouter *
-defrouter_lookup(struct in6_addr *addr, struct ifnet *ifp)
-{
-   struct nd_defrouter *dr;
-
-   ND6_RLOCK();
-   dr = defrouter_lookup_locked(addr, ifp);
-   ND6_RUNLOCK();
-   return (dr);
-}
-
 /*
  * Remove the default route for a given router.
  * This is just a subroutine function for defrouter_select_fib(), and
@@ -731,49 +754,6 @@ defrouter_delreq(struct nd_defrouter *dr)
dr->installed = 0;
 }
 
-/*
- * Remove all default routes from default router list.
- */
-void
-defrouter_reset(void)
-{
-   struct nd_defrouter *dr, **dra;
-  

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

2019-11-19 Thread Alan Cox
Author: alc
Date: Tue Nov 19 19:05:05 2019
New Revision: 354860
URL: https://svnweb.freebsd.org/changeset/base/354860

Log:
  Achieve two goals at once: (1) Avoid an unnecessary broadcast TLB
  invalidation in reclaim_pv_chunk(). (2) Prevent an "invalid ASID" assertion
  failure in reclaim_pv_chunk().  The detailed explanation for this change is
  provided by r354792.
  
  X-MFC with:   r354792

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

Modified: head/sys/arm64/arm64/pmap.c
==
--- head/sys/arm64/arm64/pmap.c Tue Nov 19 16:40:46 2019(r354859)
+++ head/sys/arm64/arm64/pmap.c Tue Nov 19 19:05:05 2019(r354860)
@@ -2062,12 +2062,13 @@ reclaim_pv_chunk(pmap_t locked_pmap, struct rwlock **l
if ((tpte & ATTR_SW_WIRED) != 0)
continue;
tpte = pmap_load_clear(pte);
-   pmap_invalidate_page(pmap, va);
m = PHYS_TO_VM_PAGE(tpte & ~ATTR_MASK);
if (pmap_pte_dirty(tpte))
vm_page_dirty(m);
-   if ((tpte & ATTR_AF) != 0)
+   if ((tpte & ATTR_AF) != 0) {
+   pmap_invalidate_page(pmap, va);
vm_page_aflag_set(m, PGA_REFERENCED);
+   }
CHANGE_PV_LIST_LOCK_TO_VM_PAGE(lockp, m);
TAILQ_REMOVE(&m->md.pv_list, pv, pv_next);
m->md.pv_gen++;
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r354859 - head

2019-11-19 Thread Bryan Drewery
Author: bdrewery
Date: Tue Nov 19 16:40:46 2019
New Revision: 354859
URL: https://svnweb.freebsd.org/changeset/base/354859

Log:
  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:
  head/Makefile.inc1

Modified: head/Makefile.inc1
==
--- head/Makefile.inc1  Tue Nov 19 16:29:47 2019(r354858)
+++ head/Makefile.inc1  Tue Nov 19 16:40:46 2019(r354859)
@@ -289,9 +289,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-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r354858 - head/contrib/bsnmp/snmpd

2019-11-19 Thread Andrey V. Elsukov
Author: ae
Date: Tue Nov 19 16:29:47 2019
New Revision: 354858
URL: https://svnweb.freebsd.org/changeset/base/354858

Log:
  Fix the byte order of IPv4 address parsed from begemotSnmpdTransInetStatus
  config option.
  
  An address is already in network byte order, there is no need to do
  htonl().
  
  PR:   242056
  MFC after:1 week

Modified:
  head/contrib/bsnmp/snmpd/trans_inet.c

Modified: head/contrib/bsnmp/snmpd/trans_inet.c
==
--- head/contrib/bsnmp/snmpd/trans_inet.c   Tue Nov 19 15:38:55 2019
(r354857)
+++ head/contrib/bsnmp/snmpd/trans_inet.c   Tue Nov 19 16:29:47 2019
(r354858)
@@ -458,12 +458,10 @@ struct inet_port_params {
 static int
 ipv4_create(struct inet_port *port, struct inet_port_params *params)
 {
-   uint32_t ip;
 
if (params->addr_len != 4)
return (SNMP_ERR_INCONS_VALUE);
 
-   memcpy(&ip, params->addr, 4);
struct port_sock *sock = calloc(1, sizeof(struct port_sock));
if (sock == NULL)
return (SNMP_ERR_GENERR);
@@ -477,8 +475,8 @@ ipv4_create(struct inet_port *port, struct inet_port_p
 
sin->sin_len = sizeof(struct sockaddr_in);
sin->sin_family = AF_INET;
-   sin->sin_addr.s_addr = htonl(ip);
sin->sin_port = htons(params->port);
+   memcpy(&sin->sin_addr, params->addr, 4); /* network byte order */
 
sock->port = port;
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r354857 - head/sys/netinet

2019-11-19 Thread Bjoern A. Zeeb
Author: bz
Date: Tue Nov 19 15:38:55 2019
New Revision: 354857
URL: https://svnweb.freebsd.org/changeset/base/354857

Log:
  Reduce the vnet_set module size of ip_mroute to allow loading as a module.
  
  With VIMAGE kernels modules get special treatment as they need
  to also keep the original values and make copies for each instance.
  For that a few pages of vnet modspace are provided and the
  kernel-linker and the VNET framework know how to deal with things.
  When the modspace is (almost) full, other modules which would
  overflow the modspace cannot be loaded and kldload will fail.
  
  ip_mroute uses a lot of variable space, mostly be four big arrays:
  set_vnet 0510 vnet_entry_multicast_register_if
  set_vnet 0700 vnet_entry_viftable
  set_vnet 2000 vnet_entry_bw_meter_timers
  set_vnet 2800 vnet_entry_bw_upcalls
  
  Dynamically malloc the three big ones for each instance we need
  and free them again on vnet teardown (the 4th is an ifnet).
  That way they only need module space for a single pointer and
  allow a lot more modules using virtualized variables to be loaded
  on a VNET kernel.
  
  PR:   206583
  Reviewed by:  hselasky, kp
  MFC after:3 weeks
  Differential Revision:https://reviews.freebsd.org/D22443

Modified:
  head/sys/netinet/ip_mroute.c

Modified: head/sys/netinet/ip_mroute.c
==
--- head/sys/netinet/ip_mroute.cTue Nov 19 15:32:15 2019
(r354856)
+++ head/sys/netinet/ip_mroute.cTue Nov 19 15:38:55 2019
(r354857)
@@ -179,10 +179,14 @@ static struct mtx mfc_mtx;
 
 VNET_DEFINE_STATIC(vifi_t, numvifs);
 #defineV_numvifs   VNET(numvifs)
-VNET_DEFINE_STATIC(struct vif, viftable[MAXVIFS]);
+VNET_DEFINE_STATIC(struct vif *, viftable);
 #defineV_viftable  VNET(viftable)
+/*
+ * No one should be able to "query" this before initialisation happened in 
+ * vnet_mroute_init(), so we should still be fine.
+ */
 SYSCTL_OPAQUE(_net_inet_ip, OID_AUTO, viftable, CTLFLAG_VNET | CTLFLAG_RD,
-&VNET_NAME(viftable), sizeof(V_viftable), "S,vif[MAXVIFS]",
+&VNET_NAME(viftable), sizeof(*V_viftable) * MAXVIFS, "S,vif[MAXVIFS]",
 "IPv4 Multicast Interfaces (struct vif[MAXVIFS], netinet/ip_mroute.h)");
 
 static struct mtx vif_mtx;
@@ -210,7 +214,7 @@ static MALLOC_DEFINE(M_BWMETER, "bwmeter", "multicast 
  * expiration time. Periodically, the entries are analysed and processed.
  */
 #defineBW_METER_BUCKETS1024
-VNET_DEFINE_STATIC(struct bw_meter*, bw_meter_timers[BW_METER_BUCKETS]);
+VNET_DEFINE_STATIC(struct bw_meter **, bw_meter_timers);
 #defineV_bw_meter_timers   VNET(bw_meter_timers)
 VNET_DEFINE_STATIC(struct callout, bw_meter_ch);
 #defineV_bw_meter_ch   VNET(bw_meter_ch)
@@ -220,7 +224,7 @@ VNET_DEFINE_STATIC(struct callout, bw_meter_ch);
  * Pending upcalls are stored in a vector which is flushed when
  * full, or periodically
  */
-VNET_DEFINE_STATIC(struct bw_upcall, bw_upcalls[BW_UPCALLS_MAX]);
+VNET_DEFINE_STATIC(struct bw_upcall *, bw_upcalls);
 #defineV_bw_upcallsVNET(bw_upcalls)
 VNET_DEFINE_STATIC(u_int, bw_upcalls_n); /* # of pending upcalls */
 #defineV_bw_upcalls_n  VNET(bw_upcalls_n)
@@ -764,7 +768,7 @@ X_ip_mrouter_done(void)
 bzero(V_nexpire, sizeof(V_nexpire[0]) * mfchashsize);
 
 V_bw_upcalls_n = 0;
-bzero(V_bw_meter_timers, sizeof(V_bw_meter_timers));
+bzero(V_bw_meter_timers, BW_METER_BUCKETS * sizeof(*V_bw_meter_timers));
 
 MFC_UNLOCK();
 
@@ -2802,7 +2806,14 @@ vnet_mroute_init(const void *unused __unused)
 {
 
V_nexpire = malloc(mfchashsize, M_MRTABLE, M_WAITOK|M_ZERO);
-   bzero(V_bw_meter_timers, sizeof(V_bw_meter_timers));
+
+   V_viftable = mallocarray(MAXVIFS, sizeof(*V_viftable),
+   M_MRTABLE, M_WAITOK|M_ZERO);
+   V_bw_meter_timers = mallocarray(BW_METER_BUCKETS,
+   sizeof(*V_bw_meter_timers), M_MRTABLE, M_WAITOK|M_ZERO);
+   V_bw_upcalls = mallocarray(BW_UPCALLS_MAX, sizeof(*V_bw_upcalls),
+   M_MRTABLE, M_WAITOK|M_ZERO);
+
callout_init(&V_expire_upcalls_ch, 1);
callout_init(&V_bw_upcalls_ch, 1);
callout_init(&V_bw_meter_ch, 1);
@@ -2815,6 +2826,9 @@ static void
 vnet_mroute_uninit(const void *unused __unused)
 {
 
+   free(V_bw_upcalls, M_MRTABLE);
+   free(V_bw_meter_timers, M_MRTABLE);
+   free(V_viftable, M_MRTABLE);
free(V_nexpire, M_MRTABLE);
V_nexpire = NULL;
 }
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r354855 - head/sys/netinet6

2019-11-19 Thread Bjoern A. Zeeb
Author: bz
Date: Tue Nov 19 14:53:13 2019
New Revision: 354855
URL: https://svnweb.freebsd.org/changeset/base/354855

Log:
  mld: fix epoch assertion
  
  in6ifa_ifpforlinklocal() asserts the net epoch.  The test case from r354832
  revealed code paths where we call into the function without having
  acquired the net epoch first and consequently we hit the assert.
  This happens in certain MLD states during VNET shutdown and most people
  normaly not notice this.
  
  For correctness acquire the net epoch around calls to
  mld_v1_transmit_report() in all cases to avoid the assertion firing.
  
  MFC after:2 weeks
  Sponsored by: Netflix

Modified:
  head/sys/netinet6/mld6.c

Modified: head/sys/netinet6/mld6.c
==
--- head/sys/netinet6/mld6.cTue Nov 19 14:46:28 2019(r354854)
+++ head/sys/netinet6/mld6.cTue Nov 19 14:53:13 2019(r354855)
@@ -1800,6 +1800,7 @@ mld_v1_transmit_report(struct in6_multi *in6m, const i
struct mbuf *mh, *md;
struct mld_hdr  *mld;
 
+   NET_EPOCH_ASSERT();
IN6_MULTI_LIST_LOCK_ASSERT();
MLD_LOCK_ASSERT();

@@ -1968,6 +1969,7 @@ static int
 mld_initial_join(struct in6_multi *inm, struct mld_ifsoftc *mli,
 const int delay)
 {
+   struct epoch_tracker et;
struct ifnet*ifp;
struct mbufq*mq;
int  error, retval, syncstates;
@@ -2035,8 +2037,10 @@ mld_initial_join(struct in6_multi *inm, struct mld_ifs
V_current_state_timers_running6 = 1;
} else {
inm->in6m_state = MLD_IDLE_MEMBER;
+   NET_EPOCH_ENTER(et);
error = mld_v1_transmit_report(inm,
 MLD_LISTENER_REPORT);
+   NET_EPOCH_EXIT(et);
if (error == 0) {
inm->in6m_timer = odelay;
V_current_state_timers_running6 = 1;
@@ -2181,6 +2185,7 @@ mld_handle_state_change(struct in6_multi *inm, struct 
 static void
 mld_final_leave(struct in6_multi *inm, struct mld_ifsoftc *mli)
 {
+   struct epoch_tracker et;
int syncstates;
 #ifdef KTR
char ip6tbuf[INET6_ADDRSTRLEN];
@@ -2214,7 +2219,9 @@ mld_final_leave(struct in6_multi *inm, struct mld_ifso
panic("%s: MLDv2 state reached, not MLDv2 mode",
 __func__);
 #endif
+   NET_EPOCH_ENTER(et);
mld_v1_transmit_report(inm, MLD_LISTENER_DONE);
+   NET_EPOCH_EXIT(et);
inm->in6m_state = MLD_NOT_MEMBER;
V_current_state_timers_running6 = 1;
} else if (mli->mli_version == MLD_VERSION_2) {
@@ -3194,6 +3201,7 @@ mld_v2_encap_report(struct ifnet *ifp, struct mbuf *m)
/*
 * RFC3590: OK to send as :: or tentative during DAD.
 */
+   NET_EPOCH_ASSERT();
ia = in6ifa_ifpforlinklocal(ifp, IN6_IFF_NOTREADY|IN6_IFF_ANYCAST);
if (ia == NULL)
CTR1(KTR_MLD, "%s: warning: ia is NULL", __func__);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r354854 - head/sys/sys

2019-11-19 Thread David Bright
Author: dab
Date: Tue Nov 19 14:46:28 2019
New Revision: 354854
URL: https://svnweb.freebsd.org/changeset/base/354854

Log:
  Don't sanitize linker_set
  
  The assumptions of linker_set don't play nicely with
  AddressSanitizer. AddressSanitizer adds a 'redzone' of zeros around
  globals (including those in named sections), whereas linker_set
  assumes they are all packed consecutively like a pointer array. So:
  let's annotate linker_set so that AddressSanitizer ignores it.
  
  Submitted by: Matthew Bryan 
  Reviewed by:  kib, rang_acm.org
  Sponsored by: Dell EMC Isilon
  Differential Revision:https://reviews.freebsd.org/D22239

Modified:
  head/sys/sys/cdefs.h
  head/sys/sys/linker_set.h

Modified: head/sys/sys/cdefs.h
==
--- head/sys/sys/cdefs.hTue Nov 19 13:28:59 2019(r354853)
+++ head/sys/sys/cdefs.hTue Nov 19 14:46:28 2019(r354854)
@@ -872,6 +872,13 @@
 /* Function should not be analyzed. */
 #define__no_lock_analysis  
__lock_annotate(no_thread_safety_analysis)
 
+/* Function or variable should not be sanitized, ie. by AddressSanitizer */
+#if __has_attribute(no_sanitize)
+#define __nosanitizeaddress__attribute__((no_sanitize("address")))
+#else
+#define __nosanitizeaddress
+#endif
+
 /* Guard variables and structure members by lock. */
 #define__guarded_by(x) __lock_annotate(guarded_by(x))
 #define__pt_guarded_by(x)  __lock_annotate(pt_guarded_by(x))

Modified: head/sys/sys/linker_set.h
==
--- head/sys/sys/linker_set.h   Tue Nov 19 13:28:59 2019(r354853)
+++ head/sys/sys/linker_set.h   Tue Nov 19 14:46:28 2019(r354854)
@@ -61,6 +61,7 @@
__GLOBL(__CONCAT(__stop_set_,set)); \
static void const * qv  \
__set_##set##_sym_##sym __section("set_" #set)  \
+   __nosanitizeaddress \
__used = &(sym)
 #define __MAKE_SET(set, sym)   __MAKE_SET_QV(set, sym, __MAKE_SET_CONST)
 #else /* !__GNUCLIKE___SECTION */
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


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

2019-11-19 Thread Andrew Turner
Author: andrew
Date: Tue Nov 19 13:28:59 2019
New Revision: 354853
URL: https://svnweb.freebsd.org/changeset/base/354853

Log:
  Return 0 from ptrace_set_pc as it now completes successfully.
  
  Sponsored by: DARPA, AFRL

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

Modified: head/sys/arm64/arm64/machdep.c
==
--- head/sys/arm64/arm64/machdep.c  Tue Nov 19 13:25:46 2019
(r354852)
+++ head/sys/arm64/arm64/machdep.c  Tue Nov 19 13:28:59 2019
(r354853)
@@ -413,7 +413,7 @@ ptrace_set_pc(struct thread *td, u_long addr)
 {
 
td->td_frame->tf_elr = addr;
-   return (EDOOFUS);
+   return (0);
 }
 
 int
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


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

2019-11-19 Thread Andrew Turner
Author: andrew
Date: Tue Nov 19 13:25:46 2019
New Revision: 354852
URL: https://svnweb.freebsd.org/changeset/base/354852

Log:
  Allow ptrace to set the probram counter on arm64.
  
  Sponsored by: DARPA, AFRL

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

Modified: head/sys/arm64/arm64/machdep.c
==
--- head/sys/arm64/arm64/machdep.c  Tue Nov 19 10:57:44 2019
(r354851)
+++ head/sys/arm64/arm64/machdep.c  Tue Nov 19 13:25:46 2019
(r354852)
@@ -412,7 +412,7 @@ int
 ptrace_set_pc(struct thread *td, u_long addr)
 {
 
-   printf("ARM64TODO: ptrace_set_pc");
+   td->td_frame->tf_elr = addr;
return (EDOOFUS);
 }
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r354851 - head/sys/arm64/include

2019-11-19 Thread Andrew Turner
Author: andrew
Date: Tue Nov 19 10:57:44 2019
New Revision: 354851
URL: https://svnweb.freebsd.org/changeset/base/354851

Log:
  Fix the definition of bus_space_read_stream_8 on arm64.
  
  This is currently unused, however will be when the Kernel Concurrency
  Sanitizer (KCSAN) is imported from NetBSD.
  
  Sponsored by: DARPA, AFRL

Modified:
  head/sys/arm64/include/bus.h

Modified: head/sys/arm64/include/bus.h
==
--- head/sys/arm64/include/bus.hTue Nov 19 08:06:31 2019
(r354850)
+++ head/sys/arm64/include/bus.hTue Nov 19 10:57:44 2019
(r354851)
@@ -322,7 +322,7 @@ struct bus_space {
 #definebus_space_read_stream_1(t, h, o)__bs_rs_s(1,(t), (h), 
(o))
 #definebus_space_read_stream_2(t, h, o)__bs_rs_s(2,(t), (h), 
(o))
 #definebus_space_read_stream_4(t, h, o)__bs_rs_s(4,(t), (h), 
(o))
-#definebus_space_read_stream_8(t, h, o)
__bs_rs_s(8,8,(t),(h),(o))
+#definebus_space_read_stream_8(t, h, o)__bs_rs_s(8,(t), (h), 
(o))
 
 /*
  * Bus read multiple operations.
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r354850 - head/sys/vm

2019-11-19 Thread Doug Moore
Author: dougm
Date: Tue Nov 19 08:06:31 2019
New Revision: 354850
URL: https://svnweb.freebsd.org/changeset/base/354850

Log:
  Drop the extra argument from swp_pager_meta_ctl and have it do lookup
  only.  Rename it swp_pager_meta_lookup.  Stop checking for obj->type
  == swap there and assert it instead.  Make the caller responsible for
  the obj->type check.
  
  Move the meta_ctl 'pop' functionality to swap_pager_unswapped, the
  only place that uses it, and assume obj->type == swap there too.
  
  Assisted by: ota_j.email.ne.jp
  Reviewed by: kib
  Tested by: pho
  Differential Revision: https://reviews.freebsd.org/D22437

Modified:
  head/sys/vm/swap_pager.c

Modified: head/sys/vm/swap_pager.c
==
--- head/sys/vm/swap_pager.cTue Nov 19 07:20:59 2019(r354849)
+++ head/sys/vm/swap_pager.cTue Nov 19 08:06:31 2019(r354850)
@@ -321,8 +321,6 @@ swap_release_by_cred(vm_ooffset_t decr, struct ucred *
 #endif
 }
 
-#define SWM_POP0x01/* pop out  */
-
 static int swap_pager_full = 2;/* swap space exhaustion (task killing) 
*/
 static int swap_pager_almost_full = 1; /* swap space exhaustion 
(w/hysteresis)*/
 static struct mtx swbuf_mtx;   /* to sync nsw_wcount_async */
@@ -426,7 +424,7 @@ static void swp_pager_meta_free(vm_object_t, vm_pindex
 static void swp_pager_meta_transfer(vm_object_t src, vm_object_t dst,
 vm_pindex_t pindex, vm_pindex_t count);
 static void swp_pager_meta_free_all(vm_object_t);
-static daddr_t swp_pager_meta_ctl(vm_object_t, vm_pindex_t, int);
+static daddr_t swp_pager_meta_lookup(vm_object_t, vm_pindex_t);
 
 static void
 swp_pager_init_freerange(daddr_t *start, daddr_t *num)
@@ -942,7 +940,10 @@ swp_pager_xfer_source(vm_object_t srcobject, vm_object
 {
daddr_t dstaddr;
 
-   if (swp_pager_meta_ctl(dstobject, pindex, 0) != SWAPBLK_NONE) {
+   KASSERT(srcobject->type == OBJT_SWAP,
+   ("%s: Srcobject not swappable", __func__));
+   if (dstobject->type == OBJT_SWAP &&
+   swp_pager_meta_lookup(dstobject, pindex) != SWAPBLK_NONE) {
/* Caller should destroy the source block. */
return (false);
}
@@ -1050,11 +1051,13 @@ swap_pager_haspage(vm_object_t object, vm_pindex_t pin
int i;
 
VM_OBJECT_ASSERT_LOCKED(object);
+   KASSERT(object->type == OBJT_SWAP,
+   ("%s: object not swappable", __func__));
 
/*
 * do we have good backing store at the requested index ?
 */
-   blk0 = swp_pager_meta_ctl(object, pindex, 0);
+   blk0 = swp_pager_meta_lookup(object, pindex);
if (blk0 == SWAPBLK_NONE) {
if (before)
*before = 0;
@@ -1070,7 +1073,7 @@ swap_pager_haspage(vm_object_t object, vm_pindex_t pin
for (i = 1; i < SWB_NPAGES; i++) {
if (i > pindex)
break;
-   blk = swp_pager_meta_ctl(object, pindex - i, 0);
+   blk = swp_pager_meta_lookup(object, pindex - i);
if (blk != blk0 - i)
break;
}
@@ -1082,7 +1085,7 @@ swap_pager_haspage(vm_object_t object, vm_pindex_t pin
 */
if (after != NULL) {
for (i = 1; i < SWB_NPAGES; i++) {
-   blk = swp_pager_meta_ctl(object, pindex + i, 0);
+   blk = swp_pager_meta_lookup(object, pindex + i);
if (blk != blk0 + i)
break;
}
@@ -1113,11 +1116,26 @@ swap_pager_haspage(vm_object_t object, vm_pindex_t pin
 static void
 swap_pager_unswapped(vm_page_t m)
 {
-   daddr_t srcaddr;
+   struct swblk *sb;
 
-   srcaddr = swp_pager_meta_ctl(m->object, m->pindex, SWM_POP);
-   if (srcaddr != SWAPBLK_NONE)
-   swp_pager_freeswapspace(srcaddr, 1);
+   VM_OBJECT_ASSERT_WLOCKED(m->object);
+
+   /*
+* The meta data only exists if the object is OBJT_SWAP
+* and even then might not be allocated yet.
+*/
+   KASSERT(m->object->type == OBJT_SWAP,
+   ("Free object not swappable"));
+
+   sb = SWAP_PCTRIE_LOOKUP(&m->object->un_pager.swp.swp_blks,
+   rounddown(m->pindex, SWAP_META_PAGES));
+   if (sb == NULL)
+   return;
+   if (sb->d[m->pindex % SWAP_META_PAGES] == SWAPBLK_NONE)
+   return;
+   swp_pager_freeswapspace(sb->d[m->pindex % SWAP_META_PAGES], 1);
+   sb->d[m->pindex % SWAP_META_PAGES] = SWAPBLK_NONE;
+   swp_pager_free_empty_swblk(m->object, sb);
 }
 
 /*
@@ -1152,6 +1170,8 @@ swap_pager_getpages(vm_object_t object, vm_page_t *ma,
 * and then this function incorrectly recreates those pages as
 * read-behind pages in the current object.
 */
+   KASSERT(object->type == OBJT_SW