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

2016-06-23 Thread Andriy Gapon
Author: avg
Date: Thu Jun 23 07:01:54 2016
New Revision: 302123
URL: https://svnweb.freebsd.org/changeset/base/302123

Log:
  fix deadlock-prone code in getzfsvfs()
  
  getzfsvfs() called vfs_busy() in the waiting mode while having a hold on
  a pool (via a call to dmu_objset_hold).  In other words,
  dp_config_rwlock was held in the shared mode while a thread could be
  sleeping in vfs_busy().
  The pool's txg sync thread needs to take dp_config_rwlock in the
  exclusive mode for some actions, e.g., for executing sync tasks.  If the
  sync thread gets blocked, then any thread waiting for its sync task to
  get executed is also blocked.  Which, in turn, could mean that
  vfs_busy() will keep waiting indefinitely.
  
  The solution is to use vfs_ref() in the locked section and to call
  vfs_busy() only after dropping other locks.
  Note that a reference on a struct mount object does not prevent an
  associated zfsvfs_t object from being destroyed.  So, we have to be
  careful to operate only on the struct mount object until we successfully
  vfs_busy it.
  
  Approved by:  re (gjb)
  MFC after:2 weeks

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

Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c
==
--- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c Thu Jun 
23 06:27:41 2016(r302122)
+++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c Thu Jun 
23 07:01:54 2016(r302123)
@@ -1430,6 +1430,7 @@ static int
 getzfsvfs(const char *dsname, zfsvfs_t **zfvp)
 {
objset_t *os;
+   vfs_t *vfsp;
int error;
 
error = dmu_objset_hold(dsname, FTAG, &os);
@@ -1443,19 +1444,21 @@ getzfsvfs(const char *dsname, zfsvfs_t *
mutex_enter(&os->os_user_ptr_lock);
*zfvp = dmu_objset_get_user(os);
if (*zfvp) {
-#ifdef illumos
-   VFS_HOLD((*zfvp)->z_vfs);
-#else
-   if (vfs_busy((*zfvp)->z_vfs, 0) != 0) {
-   *zfvp = NULL;
-   error = SET_ERROR(ESRCH);
-   }
-#endif
+   vfsp = (*zfvp)->z_vfs;
+   vfs_ref(vfsp);
} else {
error = SET_ERROR(ESRCH);
}
mutex_exit(&os->os_user_ptr_lock);
dmu_objset_rele(os, FTAG);
+   if (error == 0) {
+   error = vfs_busy(vfsp, 0);
+   vfs_rel(vfsp);
+   if (error != 0) {
+   *zfvp = NULL;
+   error = SET_ERROR(ESRCH);
+   }
+   }
return (error);
 }
 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


Re: svn commit: r302092 - in head/lib/libc: aarch64/sys amd64/sys arm/sys i386/sys mips/sys powerpc/sys powerpc64/sys riscv/sys sparc64/sys sys

2016-06-23 Thread Ivan Klymenko
On Thu, 23 Jun 2016 09:32:24 +0300
Ivan Klymenko  wrote:

> On Wed, 22 Jun 2016 21:11:27 + (UTC)
> Brooks Davis  wrote:
> 
> > Author: brooks
> > Date: Wed Jun 22 21:11:27 2016
> > New Revision: 302092
> > URL: https://svnweb.freebsd.org/changeset/base/302092
> > 
> > Log:
> >   Replace use of the pipe(2) system call with pipe2(2) with a zero
> > flags value.
> >   
> >   This eliminates the need for machine dependant assembly wrappers
> > for pipe(2).
> >   
> >   It also make passing an invalid address to pipe(2) return EFAULT
> > rather than triggering a segfault.  Document this behavior (which
> > was already true for pipe2(2), but undocumented).
> >   
> >   Reviewed by:  andrew
> >   Approved by:  re (gjb)
> >   Sponsored by: DARPA, AFRL
> >   Differential Revision:https://reviews.freebsd.org/D6815
> > 
> > Added:
> >   head/lib/libc/sys/pipe.c   (contents, props changed)
> > Deleted:
> >   head/lib/libc/aarch64/sys/pipe.S
> >   head/lib/libc/amd64/sys/pipe.S
> >   head/lib/libc/arm/sys/pipe.S
> >   head/lib/libc/i386/sys/pipe.S
> >   head/lib/libc/mips/sys/pipe.S
> >   head/lib/libc/powerpc/sys/pipe.S
> >   head/lib/libc/powerpc64/sys/pipe.S
> >   head/lib/libc/riscv/sys/pipe.S
> >   head/lib/libc/sparc64/sys/pipe.S
> > Modified:
> >   head/lib/libc/aarch64/sys/Makefile.inc
> >   head/lib/libc/amd64/sys/Makefile.inc
> >   head/lib/libc/arm/sys/Makefile.inc
> >   head/lib/libc/i386/sys/Makefile.inc
> >   head/lib/libc/mips/sys/Makefile.inc
> >   head/lib/libc/powerpc/sys/Makefile.inc
> >   head/lib/libc/powerpc64/sys/Makefile.inc
> >   head/lib/libc/riscv/sys/Makefile.inc
> >   head/lib/libc/sparc64/sys/Makefile.inc
> >   head/lib/libc/sys/Makefile.inc
> >   head/lib/libc/sys/pipe.2
> >   
> 
> ...
> /usr/local/libexec/ccache/world/cc -target x86_64-unknown-freebsd11.0
> --sysroot=/media/da0s1/obj/usr/src/tmp
> -B/media/da0s1/obj/usr/src/tmp/usr/bin -fpic -DPIC  -O2 -pipe -mmmx
> -msse -msse2 -msse3 -mssse3 -msse4 -msse4.1 -msse4.2 -mavx -maes
> -mpclmul -march=native  -I/usr/src/lib/libc/include
> -I/usr/src/lib/libc/../../include -I/usr/src/lib/libc/amd64 -DNLS
> -D__DBINTERFACE_PRIVATE -I/usr/src/lib/libc/../../contrib/gdtoa
> -I/usr/src/lib/libc/../../contrib/libc-vis -DINET6
> -I/media/da0s1/obj/usr/src/lib/libc -I/usr/src/lib/libc/resolv
> -D_ACL_PRIVATE -DPOSIX_MISTAKE -I/usr/src/lib/libc/../libmd
> -I/usr/src/lib/libc/../../contrib/jemalloc/include -DMALLOC_PRODUCTION
> -I/usr/src/lib/libc/../../contrib/tzcode/stdtime
> -I/usr/src/lib/libc/stdtime -I/usr/src/lib/libc/locale -DBROKEN_DES
> -DPORTMAP -DDES_BUILTIN -I/usr/src/lib/libc/rpc -DYP -DNS_CACHING
> -DSYMBOL_VERSIONING -DNDEBUG -MD  -MF.depend.gettimeofday.So
> -MTgettimeofday.So -std=gnu99 -fstack-protector-strong
> -Wsystem-headers -Wall -Wno-format-y2k -Wno-uninitialized
> -Wno-pointer-sign -Wno-empty-body -Wno-string-plus-int
> -Wno-unused-const-variable -Wno-tautological-compare
> -Wno-unused-value -Wno-parentheses-equality -Wno-unused-function
> -Wno-enum-conversion -Wno-unused-local-typedef -Wno-switch
> -Wno-switch-enum -Wno-knr-promoted-parameter  -Ofast -fvectorize
> -fslp-vectorize -fblocks -fcolor-diagnostics -Qunused-arguments
> -I/usr/src/lib/libutil -I/usr/src/lib/msun/amd64
> -I/usr/src/lib/msun/x86 -I/usr/src/lib/msun/src
> -c /usr/src/lib/libc/sys/gettimeofday.c -o gettimeofday.So ---
> pipe.So --- /usr/local/libexec/ccache/world/cc -target
> x86_64-unknown-freebsd11.0 --sysroot=/media/da0s1/obj/usr/src/tmp
> -B/media/da0s1/obj/usr/src/tmp/usr/bin -fpic -DPIC -O2 -pipe -mmmx
> -msse -msse2 -msse3 -mssse3 -msse4 -msse4.1 -msse4.2 -mavx -maes
> -mpclmul -march=native  -I/usr/src/lib/libc/include
> -I/usr/src/lib/libc/../../include -I/usr/src/lib/libc/amd64 -DNLS
> -D__DBINTERFACE_PRIVATE -I/usr/src/lib/libc/../../contrib/gdtoa
> -I/usr/src/lib/libc/../../contrib/libc-vis -DINET6
> -I/media/da0s1/obj/usr/src/lib/libc -I/usr/src/lib/libc/resolv
> -D_ACL_PRIVATE -DPOSIX_MISTAKE -I/usr/src/lib/libc/../libmd
> -I/usr/src/lib/libc/../../contrib/jemalloc/include
> -DMALLOC_PRODUCTION -I/usr/src/lib/libc/../../contrib/tzcode/stdtime
> -I/usr/src/lib/libc/stdtime -I/usr/src/lib/libc/locale -DBROKEN_DES
> -DPORTMAP -DDES_BUILTIN -I/usr/src/lib/libc/rpc -DYP -DNS_CACHING
> -DSYMBOL_VERSIONING -DNDEBUG -MD  -MF.depend.pipe.So -MTpipe.So
> -std=gnu99 -fstack-protector-strong -Wsystem-headers -Wall
> -Wno-format-y2k -Wno-uninitialized -Wno-pointer-sign -Wno-empty-body
> -Wno-string-plus-int -Wno-unused-const-variable
> -Wno-tautological-compare -Wno-unused-value -Wno-parentheses-equality
> -Wno-unused-function -Wno-enum-conversion -Wno-unused-local-typedef
> -Wno-switch -Wno-switch-enum -Wno-knr-promoted-parameter  -Ofast
> -fvectorize -fslp-vectorize -fblocks -fcolor-diagnostics
> -Qunused-arguments  -I/usr/src/lib/libutil -I/usr/src/lib/msun/amd64
> -I/usr/src/lib/msun/x86 -I/usr/src/lib/msun/src
> -c /usr/src/lib/libc/amd64/sys/pipe.S -o pipe.So cc: error: no such
> file or directory: '/usr/src/lib/libc/amd64/sy

svn commit: r302124 - stable/10/sys/dev/hyperv/vmbus

2016-06-23 Thread Sepherosa Ziehau
Author: sephe
Date: Thu Jun 23 07:09:44 2016
New Revision: 302124
URL: https://svnweb.freebsd.org/changeset/base/302124

Log:
  MFC 300645
  
  hyperv/vmbus: Allocate/setup IDT vector after all ISR resources are ready
  
  And release IDT vector before releasing ISR resources on interrupt
  teardown path.  We still have some work to do on the interrupt tearing
  down path.
  
  MFC after:  1 week
  Sponsored by:   Microsoft OSTC
  Differential Revision:  https://reviews.freebsd.org/D6519

Modified:
  stable/10/sys/dev/hyperv/vmbus/hv_vmbus_drv_freebsd.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/dev/hyperv/vmbus/hv_vmbus_drv_freebsd.c
==
--- stable/10/sys/dev/hyperv/vmbus/hv_vmbus_drv_freebsd.c   Thu Jun 23 
07:01:54 2016(r302123)
+++ stable/10/sys/dev/hyperv/vmbus/hv_vmbus_drv_freebsd.c   Thu Jun 23 
07:09:44 2016(r302124)
@@ -447,35 +447,18 @@ vmbus_intr_setup(struct vmbus_softc *sc)
 {
int cpu;
 
-   /*
-* Find a free IDT vector for vmbus messages/events.
-*/
-   sc->vmbus_idtvec = vmbus_vector_alloc();
-   if (sc->vmbus_idtvec == 0) {
-   device_printf(sc->vmbus_dev, "cannot find free IDT vector\n");
-   return ENXIO;
-   }
-   if(bootverbose) {
-   device_printf(sc->vmbus_dev, "vmbus IDT vector %d\n",
-   sc->vmbus_idtvec);
-   }
-
CPU_FOREACH(cpu) {
+   struct task cpuset_task;
char buf[MAXCOMLEN + 1];
+   cpuset_t cpu_mask;
 
+   /* Allocate an interrupt counter for Hyper-V interrupt */
snprintf(buf, sizeof(buf), "cpu%d:hyperv", cpu);
intrcnt_add(buf, VMBUS_PCPU_PTR(sc, intr_cnt, cpu));
-   }
-
-   /*
-* Per cpu setup.
-*/
-   CPU_FOREACH(cpu) {
-   struct task cpuset_task;
-   cpuset_t cpu_mask;
 
/*
-* Setup taskqueue to handle events
+* Setup taskqueue to handle events.  Task will be per-
+* channel.
 */
hv_vmbus_g_context.hv_event_queue[cpu] =
taskqueue_create_fast("hyperv event", M_WAITOK,
@@ -493,7 +476,7 @@ vmbus_intr_setup(struct vmbus_softc *sc)
&cpuset_task);
 
/*
-* Setup per-cpu tasks and taskqueues to handle msg.
+* Setup tasks and taskqueues to handle messages.
 */
hv_vmbus_g_context.hv_msg_tq[cpu] = taskqueue_create_fast(
"hyperv msg", M_WAITOK, taskqueue_thread_enqueue,
@@ -511,6 +494,20 @@ vmbus_intr_setup(struct vmbus_softc *sc)
taskqueue_drain(hv_vmbus_g_context.hv_msg_tq[cpu],
&cpuset_task);
}
+
+   /*
+* All Hyper-V ISR required resources are setup, now let's find a
+* free IDT vector for Hyper-V ISR and set it up.
+*/
+   sc->vmbus_idtvec = vmbus_vector_alloc();
+   if (sc->vmbus_idtvec == 0) {
+   device_printf(sc->vmbus_dev, "cannot find free IDT vector\n");
+   return ENXIO;
+   }
+   if(bootverbose) {
+   device_printf(sc->vmbus_dev, "vmbus IDT vector %d\n",
+   sc->vmbus_idtvec);
+   }
return 0;
 }
 
@@ -519,9 +516,8 @@ vmbus_intr_teardown(struct vmbus_softc *
 {
int cpu;
 
-   /*
-* remove swi and vmbus callback vector;
-*/
+   vmbus_vector_free(sc->vmbus_idtvec);
+
CPU_FOREACH(cpu) {
if (hv_vmbus_g_context.hv_event_queue[cpu] != NULL) {
taskqueue_free(hv_vmbus_g_context.hv_event_queue[cpu]);
@@ -534,7 +530,6 @@ vmbus_intr_teardown(struct vmbus_softc *
hv_vmbus_g_context.hv_msg_tq[cpu] = NULL;
}
}
-   vmbus_vector_free(sc->vmbus_idtvec);
 }
 
 static int
@@ -706,16 +701,16 @@ vmbus_bus_init(void)
sc = vmbus_get_softc();
 
/*
-* Setup interrupt.
+* Allocate DMA stuffs.
 */
-   ret = vmbus_intr_setup(sc);
+   ret = vmbus_dma_alloc(sc);
if (ret != 0)
goto cleanup;
 
/*
-* Allocate DMA stuffs.
+* Setup interrupt.
 */
-   ret = vmbus_dma_alloc(sc);
+   ret = vmbus_intr_setup(sc);
if (ret != 0)
goto cleanup;
 
@@ -747,8 +742,8 @@ vmbus_bus_init(void)
return (ret);
 
 cleanup:
-   vmbus_dma_free(sc);
vmbus_intr_teardown(sc);
+   vmbus_dma_free(sc);
 
return (ret);
 }
@@ -810,8 +805,8 @@ vmbus_detach(device_t dev)
 
smp_rendezvous(NULL, vmbus_synic_teardown, NULL, NULL);
 
-   vmbus_dma_free(sc);
vmbus_intr_teardown(sc);
+   vmbus_dma_free(sc);
 
return (0);
 }
_

svn commit: r302125 - head/lib/libusb

2016-06-23 Thread Hans Petter Selasky
Author: hselasky
Date: Thu Jun 23 07:12:22 2016
New Revision: 302125
URL: https://svnweb.freebsd.org/changeset/base/302125

Log:
  Add support for USB streams to the LibUSB v1.0 API and update the
  libusb(3) manual page.
  
  Approved by:  re (gjb)
  Requested by: swills
  MFC after:1 week

Modified:
  head/lib/libusb/Makefile
  head/lib/libusb/libusb.3
  head/lib/libusb/libusb.h
  head/lib/libusb/libusb10.c
  head/lib/libusb/libusb10.h
  head/lib/libusb/libusb10_io.c

Modified: head/lib/libusb/Makefile
==
--- head/lib/libusb/MakefileThu Jun 23 07:09:44 2016(r302124)
+++ head/lib/libusb/MakefileThu Jun 23 07:12:22 2016(r302125)
@@ -120,8 +120,12 @@ MLINKS += libusb.3 libusb_get_ss_usb_dev
 MLINKS += libusb.3 libusb_free_ss_usb_device_capability_descriptor.3
 MLINKS += libusb.3 libusb_get_container_id_descriptor.3
 MLINKS += libusb.3 libusb_free_container_id_descriptor.3
+MLINKS += libusb.3 libusb_alloc_streams.3
+MLINKS += libusb.3 libusb_free_streams.3
 MLINKS += libusb.3 libusb_alloc_transfer.3
 MLINKS += libusb.3 libusb_free_transfer.3
+MLINKS += libusb.3 libusb_transfer_set_stream_id.3
+MLINKS += libusb.3 libusb_transfer_get_stream_id.3
 MLINKS += libusb.3 libusb_submit_transfer.3
 MLINKS += libusb.3 libusb_cancel_transfer.3
 MLINKS += libusb.3 libusb_control_transfer.3

Modified: head/lib/libusb/libusb.3
==
--- head/lib/libusb/libusb.3Thu Jun 23 07:09:44 2016(r302124)
+++ head/lib/libusb/libusb.3Thu Jun 23 07:12:22 2016(r302125)
@@ -26,7 +26,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd June 22, 2016
+.Dd June 23, 2016
 .Dt LIBUSB 3
 .Os
 .Sh NAME
@@ -521,6 +521,29 @@ if the transfer timed out, LIBUSB_ERROR_
 supported, LIBUSB_ERROR_OVERFLOW if the device offered more data,
 LIBUSB_ERROR_NO_DEVICE if the device has been disconnected and
 a LIBUSB_ERROR code on other failure.
+.Sh USB STREAMS SUPPORT
+.Ft int
+.Fn libusb_alloc_streams "libusb_device_handle *dev" "uint32_t num_streams" 
"unsigned char *endpoints" "int num_endpoints"
+This function verifies that the given number of streams using the
+given number of endpoints is allowed and allocates the resources
+needed to use so-called USB streams.
+Currently only a single stream per endpoint is supported to simplify
+the internals of LibUSB.
+This function returns 0 on success or a LIBUSB_ERROR code on failure.
+.Pp
+.Ft int
+.Fn libusb_free_streams "libusb_device_handle *dev" "unsigned char *endpoints" 
"int num_endpoints"
+This function release resources needed for streams usage.
+Returns 0 on success or a LIBUSB_ERROR code on failure.
+.Pp
+.Ft void
+.Fn libusb_transfer_set_stream_id "struct libusb_transfer *transfer" "uint32_t 
stream_id"
+This function sets the stream ID for the given USB transfer.
+.Pp
+.Ft uint32_t
+.Fn libusb_transfer_get_stream_id "struct libusb_transfer *transfer"
+This function returns the stream ID for the given USB transfer.
+If no stream ID is used a value of zero is returned.
 .Sh USB EVENTS
 .Ft int
 .Fn libusb_try_lock_events "libusb_context *ctx"

Modified: head/lib/libusb/libusb.h
==
--- head/lib/libusb/libusb.hThu Jun 23 07:09:44 2016(r302124)
+++ head/lib/libusb/libusb.hThu Jun 23 07:12:22 2016(r302125)
@@ -561,6 +561,13 @@ typedef int (*libusb_hotplug_callback_fn
 intlibusb_hotplug_register_callback(libusb_context *ctx, 
libusb_hotplug_event events, libusb_hotplug_flag flags, int vendor_id, int 
product_id, int dev_class, libusb_hotplug_callback_fn cb_fn, void *user_data, 
libusb_hotplug_callback_handle *handle);
 void   libusb_hotplug_deregister_callback(libusb_context *ctx, 
libusb_hotplug_callback_handle handle);
 
+/* Streams support */
+
+intlibusb_alloc_streams(libusb_device_handle *dev, uint32_t num_streams, 
unsigned char *endpoints, int num_endpoints);
+intlibusb_free_streams(libusb_device_handle *dev, unsigned char 
*endpoints, int num_endpoints);
+void   libusb_transfer_set_stream_id(struct libusb_transfer *transfer, 
uint32_t stream_id);
+uint32_t libusb_transfer_get_stream_id(struct libusb_transfer *transfer);
+
 #if 0
 {  /* indent fix */
 #endif

Modified: head/lib/libusb/libusb10.c
==
--- head/lib/libusb/libusb10.c  Thu Jun 23 07:09:44 2016(r302124)
+++ head/lib/libusb/libusb10.c  Thu Jun 23 07:12:22 2016(r302125)
@@ -1403,7 +1403,8 @@ found:
maxframe = libusb10_get_maxframe(pdev, uxfer);
 
/* make sure the transfer is opened */
-   err = libusb20_tr_open(pxfer0, buffsize, maxframe, endpoint);
+   err = libusb20_tr_open_stream(pxfer0, buffsize, maxframe,
+   endpoint, sxfer->stream_id);
if (err && (err != LIBUSB20_ERROR_BUSY)) {
  

svn commit: r302126 - stable/10/sys/dev/hyperv/vmbus

2016-06-23 Thread Sepherosa Ziehau
Author: sephe
Date: Thu Jun 23 07:36:03 2016
New Revision: 302126
URL: https://svnweb.freebsd.org/changeset/base/302126

Log:
  MFC 300646
  
  hyperv/vmbus: Move event/message taskqueue/task to vmbus softc
  
  MFC after:  1 week
  Sponsored by:   Microsoft OSTC
  Differential Revision:  https://reviews.freebsd.org/D6520

Modified:
  stable/10/sys/dev/hyperv/vmbus/hv_channel.c
  stable/10/sys/dev/hyperv/vmbus/hv_vmbus_drv_freebsd.c
  stable/10/sys/dev/hyperv/vmbus/hv_vmbus_priv.h
  stable/10/sys/dev/hyperv/vmbus/vmbus_var.h
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/dev/hyperv/vmbus/hv_channel.c
==
--- stable/10/sys/dev/hyperv/vmbus/hv_channel.c Thu Jun 23 07:12:22 2016
(r302125)
+++ stable/10/sys/dev/hyperv/vmbus/hv_channel.c Thu Jun 23 07:36:03 2016
(r302126)
@@ -202,7 +202,8 @@ hv_vmbus_channel_open(
 
vmbus_on_channel_open(new_channel);
 
-   new_channel->rxq = 
hv_vmbus_g_context.hv_event_queue[new_channel->target_cpu];
+   new_channel->rxq = VMBUS_PCPU_GET(vmbus_get_softc(), event_tq,
+   new_channel->target_cpu);
TASK_INIT(&new_channel->channel_task, 0, VmbusProcessChannelEvent, 
new_channel);
 
/* Allocate the ring buffer */

Modified: stable/10/sys/dev/hyperv/vmbus/hv_vmbus_drv_freebsd.c
==
--- stable/10/sys/dev/hyperv/vmbus/hv_vmbus_drv_freebsd.c   Thu Jun 23 
07:12:22 2016(r302125)
+++ stable/10/sys/dev/hyperv/vmbus/hv_vmbus_drv_freebsd.c   Thu Jun 23 
07:36:03 2016(r302126)
@@ -177,8 +177,8 @@ hv_vmbus_isr(struct vmbus_softc *sc, str
 
msg = msg_base + HV_VMBUS_MESSAGE_SINT;
if (msg->header.message_type != HV_MESSAGE_TYPE_NONE) {
-   taskqueue_enqueue(hv_vmbus_g_context.hv_msg_tq[cpu],
-   &hv_vmbus_g_context.hv_msg_task[cpu]);
+   taskqueue_enqueue(VMBUS_PCPU_GET(sc, message_tq, cpu),
+   VMBUS_PCPU_PTR(sc, message_task, cpu));
}
 
return (FILTER_HANDLED);
@@ -460,38 +460,37 @@ vmbus_intr_setup(struct vmbus_softc *sc)
 * Setup taskqueue to handle events.  Task will be per-
 * channel.
 */
-   hv_vmbus_g_context.hv_event_queue[cpu] =
-   taskqueue_create_fast("hyperv event", M_WAITOK,
-   taskqueue_thread_enqueue,
-   &hv_vmbus_g_context.hv_event_queue[cpu]);
-   taskqueue_start_threads(&hv_vmbus_g_context.hv_event_queue[cpu],
+   VMBUS_PCPU_GET(sc, event_tq, cpu) = taskqueue_create_fast(
+   "hyperv event", M_WAITOK, taskqueue_thread_enqueue,
+   VMBUS_PCPU_PTR(sc, event_tq, cpu));
+   taskqueue_start_threads(VMBUS_PCPU_PTR(sc, event_tq, cpu),
1, PI_NET, "hvevent%d", cpu);
 
CPU_SETOF(cpu, &cpu_mask);
TASK_INIT(&cpuset_task, 0, vmbus_cpuset_setthread_task,
&cpu_mask);
-   taskqueue_enqueue(hv_vmbus_g_context.hv_event_queue[cpu],
+   taskqueue_enqueue(VMBUS_PCPU_GET(sc, event_tq, cpu),
&cpuset_task);
-   taskqueue_drain(hv_vmbus_g_context.hv_event_queue[cpu],
+   taskqueue_drain(VMBUS_PCPU_GET(sc, event_tq, cpu),
&cpuset_task);
 
/*
 * Setup tasks and taskqueues to handle messages.
 */
-   hv_vmbus_g_context.hv_msg_tq[cpu] = taskqueue_create_fast(
+   VMBUS_PCPU_GET(sc, message_tq, cpu) = taskqueue_create_fast(
"hyperv msg", M_WAITOK, taskqueue_thread_enqueue,
-   &hv_vmbus_g_context.hv_msg_tq[cpu]);
-   taskqueue_start_threads(&hv_vmbus_g_context.hv_msg_tq[cpu], 1,
+   VMBUS_PCPU_PTR(sc, message_tq, cpu));
+   taskqueue_start_threads(VMBUS_PCPU_PTR(sc, message_tq, cpu), 1,
PI_NET, "hvmsg%d", cpu);
-   TASK_INIT(&hv_vmbus_g_context.hv_msg_task[cpu], 0,
+   TASK_INIT(VMBUS_PCPU_PTR(sc, message_task, cpu), 0,
vmbus_msg_task, sc);
 
CPU_SETOF(cpu, &cpu_mask);
TASK_INIT(&cpuset_task, 0, vmbus_cpuset_setthread_task,
&cpu_mask);
-   taskqueue_enqueue(hv_vmbus_g_context.hv_msg_tq[cpu],
+   taskqueue_enqueue(VMBUS_PCPU_GET(sc, message_tq, cpu),
&cpuset_task);
-   taskqueue_drain(hv_vmbus_g_context.hv_msg_tq[cpu],
+   taskqueue_drain(VMBUS_PCPU_GET(sc, message_tq, cpu),
&cpuset_task);
}
 
@@ -519,15 +518,15 @@ vmbus_intr_teardown(struct vmbus_softc *
vmbus_vector_free(sc->vmbus_idtvec);
 
CPU_FOREACH(cpu) {
-   if (hv_vm

svn commit: r302127 - in stable/10/sys/dev/hyperv: include vmbus

2016-06-23 Thread Sepherosa Ziehau
Author: sephe
Date: Thu Jun 23 07:53:58 2016
New Revision: 302127
URL: https://svnweb.freebsd.org/changeset/base/302127

Log:
  MFC 300647,300650,300651,300652,300653
  
  300647
  hyperv/vmbus: Move vcpuid into vmbus softc per-cpu data
  
  MFC after:  1 week
  Sponsored by:   Microsoft OSTC
  Differential Revision:  https://reviews.freebsd.org/D6521
  
  300650
  hyperv/vmbus: Move two global flags into vmbus softc
  
  And pack them into one flag field.
  
  MFC after:  1 week
  Sponsored by:   Microsoft OSTC
  Differential Revision:  https://reviews.freebsd.org/D6522
  
  300651
  hyperv/vmbus: Minor style and white space cleanup
  
  MFC after:  1 week
  Sponsored by:   Microsoft OSTC
  Differential Revision:  https://reviews.freebsd.org/D6523
  
  300652
  hyperv/vmbus: Pass vmbus softc to vmbus_synic_setup
  
  MFC after:  1 week
  Sponsored by:   Microsoft OSTC
  Differential Revision:  https://reviews.freebsd.org/D6527
  
  300653
  hyperv/vmbus: Nuke unnecessary MSR read
  
  MFC after:  1 week
  Sponsored by:   Microsoft OSTC
  Differential Revision:  https://reviews.freebsd.org/D6528

Modified:
  stable/10/sys/dev/hyperv/include/hyperv_busdma.h
  stable/10/sys/dev/hyperv/vmbus/hv_channel_mgmt.c
  stable/10/sys/dev/hyperv/vmbus/hv_hv.c
  stable/10/sys/dev/hyperv/vmbus/hv_vmbus_drv_freebsd.c
  stable/10/sys/dev/hyperv/vmbus/hv_vmbus_priv.h
  stable/10/sys/dev/hyperv/vmbus/vmbus_var.h
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/dev/hyperv/include/hyperv_busdma.h
==
--- stable/10/sys/dev/hyperv/include/hyperv_busdma.hThu Jun 23 07:36:03 
2016(r302126)
+++ stable/10/sys/dev/hyperv/include/hyperv_busdma.hThu Jun 23 07:53:58 
2016(r302127)
@@ -29,6 +29,10 @@
 #ifndef _HYPERV_BUSDMA_H_
 #define _HYPERV_BUSDMA_H_
 
+#include 
+#include 
+#include 
+
 struct hyperv_dma {
bus_addr_t  hv_paddr;
bus_dma_tag_t   hv_dtag;

Modified: stable/10/sys/dev/hyperv/vmbus/hv_channel_mgmt.c
==
--- stable/10/sys/dev/hyperv/vmbus/hv_channel_mgmt.cThu Jun 23 07:36:03 
2016(r302126)
+++ stable/10/sys/dev/hyperv/vmbus/hv_channel_mgmt.cThu Jun 23 07:53:58 
2016(r302127)
@@ -35,7 +35,8 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 
-#include "hv_vmbus_priv.h"
+#include 
+#include 
 
 /*
  * Internal functions
@@ -310,7 +311,7 @@ vmbus_channel_cpu_set(struct hv_vmbus_ch
}
 
chan->target_cpu = cpu;
-   chan->target_vcpu = hv_vmbus_g_context.hv_vcpu_index[cpu];
+   chan->target_vcpu = VMBUS_PCPU_GET(vmbus_get_softc(), vcpuid, cpu);
 
if (bootverbose) {
printf("vmbus_chan%u: assigned to cpu%u [vcpu%u]\n",
@@ -751,7 +752,7 @@ vmbus_select_outgoing_channel(struct hv_
return outgoing_channel;
}
 
-   cur_vcpu = hv_vmbus_g_context.hv_vcpu_index[smp_pro_id];
+   cur_vcpu = VMBUS_PCPU_GET(vmbus_get_softc(), vcpuid, smp_pro_id);

TAILQ_FOREACH(new_channel, &primary->sc_list_anchor, sc_list_entry) {
if (new_channel->state != HV_CHANNEL_OPENED_STATE){

Modified: stable/10/sys/dev/hyperv/vmbus/hv_hv.c
==
--- stable/10/sys/dev/hyperv/vmbus/hv_hv.c  Thu Jun 23 07:36:03 2016
(r302126)
+++ stable/10/sys/dev/hyperv/vmbus/hv_hv.c  Thu Jun 23 07:53:58 2016
(r302127)
@@ -96,13 +96,6 @@ u_inthyperv_recommends;
 static u_int   hyperv_pm_features;
 static u_int   hyperv_features3;
 
-/**
- * Globals
- */
-hv_vmbus_context hv_vmbus_g_context = {
-   .syn_ic_initialized = FALSE,
-};
-
 static struct timecounter hv_timecounter = {
hv_get_timecount, 0, ~0u, HV_NANOSECONDS_PER_SEC/100, "Hyper-V", 
HV_NANOSECONDS_PER_SEC/100
 };

Modified: stable/10/sys/dev/hyperv/vmbus/hv_vmbus_drv_freebsd.c
==
--- stable/10/sys/dev/hyperv/vmbus/hv_vmbus_drv_freebsd.c   Thu Jun 23 
07:36:03 2016(r302126)
+++ stable/10/sys/dev/hyperv/vmbus/hv_vmbus_drv_freebsd.c   Thu Jun 23 
07:53:58 2016(r302127)
@@ -68,8 +68,6 @@ __FBSDID("$FreeBSD$");
 
 struct vmbus_softc *vmbus_sc;
 
-static int vmbus_inited;
-
 static char *vmbus_ids[] = { "VMBUS", NULL };
 
 extern inthand_t IDTVEC(rsvd), IDTVEC(hv_vmbus_callback);
@@ -209,25 +207,18 @@ hv_vector_handler(struct trapframe *trap
 }
 
 static void
-vmbus_synic_setup(void *arg __unused)
+vmbus_synic_setup(void *xsc)
 {
-   struct vmbus_softc *sc = vmbus_get_softc();
+   struct vmbus_softc *sc = xsc;
int cpu;
-   uint64_thv_vcpu_index;
hv_vmbus_synic_simp simp;
 

svn commit: r302128 - stable/10/sys/dev/hyperv/vmbus

2016-06-23 Thread Sepherosa Ziehau
Author: sephe
Date: Thu Jun 23 08:09:44 2016
New Revision: 302128
URL: https://svnweb.freebsd.org/changeset/base/302128

Log:
  MFC 300654,300655,300708
  
  300654
  hyperv/vmbus: Rework SynIC setup and teardown
  
  - Avoid bit fields.
  - Fix SINT setup (preserve required bits).
  
  MFC after:  1 week
  Sponsored by:   Microsoft OSTC
  Differential Revision:  https://reviews.freebsd.org/D6529
  
  300655
  hyperv: Preserve required bits when disable Hypercall
  
  MFC after:  1 week
  Sponsored by:   Microsoft OSTC
  Differential Revision:  https://reviews.freebsd.org/D6530
  
  300708
  hyperv: Rework guest id settings according to Hyper-V spec
  
  MFC after:  1 week
  Sponsored by:   Microsoft OSTC
  Differential Revision:  https://reviews.freebsd.org/D6553

Modified:
  stable/10/sys/dev/hyperv/vmbus/hv_hv.c
  stable/10/sys/dev/hyperv/vmbus/hv_vmbus_drv_freebsd.c
  stable/10/sys/dev/hyperv/vmbus/hyperv_reg.h
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/dev/hyperv/vmbus/hv_hv.c
==
--- stable/10/sys/dev/hyperv/vmbus/hv_hv.c  Thu Jun 23 07:53:58 2016
(r302127)
+++ stable/10/sys/dev/hyperv/vmbus/hv_hv.c  Thu Jun 23 08:09:44 2016
(r302128)
@@ -52,34 +52,24 @@ __FBSDID("$FreeBSD$");
 
 #defineHYPERV_INTERFACE0x31237648  /* HV#1 */
 
-/*
- * The guest OS needs to register the guest ID with the hypervisor.
- * The guest ID is a 64 bit entity and the structure of this ID is
- * specified in the Hyper-V specification:
- *
- * http://msdn.microsoft.com/en-us/library/windows/
- * hardware/ff542653%28v=vs.85%29.aspx
- *
- * While the current guideline does not specify how FreeBSD guest ID(s)
- * need to be generated, our plan is to publish the guidelines for
- * FreeBSD and other guest operating systems that currently are hosted
- * on Hyper-V. The implementation here conforms to this yet
- * unpublished guidelines.
- *
- * Bit(s)
- * 63- Indicates if the OS is Open Source or not; 1 is Open Source
- * 62:56 - Os Type: FreeBSD is 0x02
- * 55:48 - Distro specific identification
- * 47:16 - FreeBSD kernel version number
- * 15:0  - Distro specific identification
- */
-#define HYPERV_GUESTID_OSS (0x1ULL << 63)
-#define HYPERV_GUESTID_FREEBSD (0x02ULL << 56)
-#define HYPERV_GUESTID(id) \
-   (HYPERV_GUESTID_OSS | HYPERV_GUESTID_FREEBSD |  \
-(((uint64_t)(((id) & 0xff) >> 16)) << 48) |\
-(((uint64_t)__FreeBSD_version) << 16) |\
-((uint64_t)((id) & 0x00)))
+#define HYPERV_FREEBSD_BUILD   0ULL
+#define HYPERV_FREEBSD_VERSION ((uint64_t)__FreeBSD_version)
+#define HYPERV_FREEBSD_OSID0ULL
+
+#define MSR_HV_GUESTID_BUILD_FREEBSD   \
+   (HYPERV_FREEBSD_BUILD & MSR_HV_GUESTID_BUILD_MASK)
+#define MSR_HV_GUESTID_VERSION_FREEBSD \
+   ((HYPERV_FREEBSD_VERSION << MSR_HV_GUESTID_VERSION_SHIFT) & \
+MSR_HV_GUESTID_VERSION_MASK)
+#define MSR_HV_GUESTID_OSID_FREEBSD\
+   ((HYPERV_FREEBSD_OSID << MSR_HV_GUESTID_OSID_SHIFT) & \
+MSR_HV_GUESTID_OSID_MASK)
+
+#define MSR_HV_GUESTID_FREEBSD \
+   (MSR_HV_GUESTID_BUILD_FREEBSD | \
+MSR_HV_GUESTID_VERSION_FREEBSD | \
+MSR_HV_GUESTID_OSID_FREEBSD |  \
+MSR_HV_GUESTID_OSTYPE_FREEBSD)
 
 struct hypercall_ctx {
void*hc_addr;
@@ -321,8 +311,8 @@ hyperv_init(void *dummy __unused)
return;
}
 
-   /* Write guest id */
-   wrmsr(HV_X64_MSR_GUEST_OS_ID, HYPERV_GUESTID(0));
+   /* Set guest id */
+   wrmsr(MSR_HV_GUEST_OS_ID, MSR_HV_GUESTID_FREEBSD);
 
if (hyperv_features & HV_FEATURE_MSR_TIME_REFCNT) {
/* Register virtual timecount */
@@ -390,11 +380,14 @@ SYSINIT(hypercall_ctor, SI_SUB_DRIVERS, 
 static void
 hypercall_destroy(void *arg __unused)
 {
+   uint64_t hc;
+
if (hypercall_context.hc_addr == NULL)
return;
 
/* Disable Hypercall */
-   wrmsr(MSR_HV_HYPERCALL, 0);
+   hc = rdmsr(MSR_HV_HYPERCALL);
+   wrmsr(MSR_HV_HYPERCALL, (hc & MSR_HV_HYPERCALL_RSVD_MASK));
hypercall_memfree();
 
if (bootverbose)

Modified: stable/10/sys/dev/hyperv/vmbus/hv_vmbus_drv_freebsd.c
==
--- stable/10/sys/dev/hyperv/vmbus/hv_vmbus_drv_freebsd.c   Thu Jun 23 
07:53:58 2016(r302127)
+++ stable/10/sys/dev/hyperv/vmbus/hv_vmbus_drv_freebsd.c   Thu Jun 23 
08:09:44 2016(r302128)
@@ -61,6 +61,7 @@ __FBSDID("$FreeBSD$");
 
 #include 
 #include 
+#include 
 #include 
 
 #include 
@@ -210,100 +211,97 @@ static void
 vmbus_synic_setup(void *xsc)
 {
struct vmbus_softc *sc = xsc;
-   int cpu;
-   hv_vmbus_synic_

Re: svn commit: r302099 - head/sys/netinet

2016-06-23 Thread Marko Zec
On Thu, 23 Jun 2016 00:34:03 +
"Bjoern A. Zeeb"  wrote:

> Author: bz
> Date: Thu Jun 23 00:34:03 2016
> New Revision: 302099
> URL: https://svnweb.freebsd.org/changeset/base/302099
> 
> Log:
>   Check the V_tcbinfo.ipi_count to hit 0 before doing the full TCP
> cleanup. That way timers can finish cleanly and we do not gamble with
> a DELAY(). 
>   Reviewed by:gnn, jtl
>   Approved by:re (gjb)
>   Obtained from:  projects/vnet
>   MFC after:  2 weeks
>   Sponsored by:   The FreeBSD Foundation
>   Differential Revision:  https://reviews.freebsd.org/D6923

As much as this change is welcome, it unnecesarily introduces a
mandatory 100 ms delay on each vnet teardown, which I already pointed
out in a comment to r301601 two weeks ago, which remained unanswered,
along with the question why a delay of 100 ms was introduced here, when
before r302099 the delay was only a single clock tick?  And furthermore
the delay computation expresion here is not style(9) compliant...

Hence, please rectify the above objections, perhaps by something like:

===
--- tcp_subr.c  (revision 302126)
+++ tcp_subr.c  (working copy)
@@ -739,10 +739,11 @@
 * Sleep to let all tcpcb timers really disappear and cleanup.
 */
do {
-   pause("tcpdes", hz/10);
INP_LIST_RLOCK(&V_tcbinfo);
n = V_tcbinfo.ipi_count;
INP_LIST_RUNLOCK(&V_tcbinfo);
+   if (n != 0)
+   pause("tcpdes", hz / 100);
} while (n != 0);
tcp_hc_destroy();
syncache_destroy();

Thanks,

Marko


> 
> Modified:
>   head/sys/netinet/tcp_subr.c
> 
> Modified: head/sys/netinet/tcp_subr.c
> ==
> --- head/sys/netinet/tcp_subr.c   Thu Jun 23 00:32:58
> 2016  (r302098) +++ head/sys/netinet/tcp_subr.c   Thu Jun
> 23 00:34:03 2016  (r302099) @@ -731,18 +731,19 @@ tcp_init(void)
>  static void
>  tcp_destroy(void *unused __unused)
>  {
> - int error;
> + int error, n;
>  
>   /*
>* All our processes are gone, all our sockets should be
> cleaned
>* up, which means, we should be past the tcp_discardcb()
> calls.
> -  * Sleep to let all tcpcb timers really disappear and then
> cleanup.
> -  * Timewait will cleanup its queue and will be ready to go.
> -  * XXX-BZ In theory a few ticks should be good enough to
> make sure
> -  * the timers are all really gone.  We should see if we
> could use a
> -  * better metric here and, e.g., check a tcbcb count as an
> optimization?
> +  * Sleep to let all tcpcb timers really disappear and
> cleanup. */
> - DELAY(100 / hz);
> + do {
> + pause("tcpdes", hz/10);
> + INP_LIST_RLOCK(&V_tcbinfo);
> + n = V_tcbinfo.ipi_count;
> + INP_LIST_RUNLOCK(&V_tcbinfo);
> + } while (n != 0);
>   tcp_hc_destroy();
>   syncache_destroy();
>   tcp_tw_destroy();
> 

___
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: r302129 - stable/10/sys/dev/hyperv/vmbus

2016-06-23 Thread Sepherosa Ziehau
Author: sephe
Date: Thu Jun 23 08:26:07 2016
New Revision: 302129
URL: https://svnweb.freebsd.org/changeset/base/302129

Log:
  MFC 300825,300827,300830,300831,300832,300834
  
  300825
  hyperv: Move CPUID related bits to hyperv_reg.h and give them clean name
  
  MFC after:  1 week
  Sponsored by:   Microsoft OSTC
  Differential Revision:  https://reviews.freebsd.org/D6565
  
  300827
  hyperv: Move timer related MSRs into hyperv_reg.h
  
  And avoid bit fields for event timer.
  
  MFC after:  1 week
  Sponsored by:   Microsoft OSTC
  Differential Revision:  https://reviews.freebsd.org/D6566
  
  300830
  hyperv/vmbus: Move MSR EOM to hyperv_reg.h
  
  MFC after:  1 week
  Sponsored by:   Microsoft OSTC
  Differential Revision:  https://reviews.freebsd.org/D6567
  
  300831
  hyperv: GC unneeded bits
  
  MFC after:  1 week
  Sponsored by:   Microsoft OSTC
  Differential Revision:  https://reviews.freebsd.org/D6568
  
  300832
  hyperv: Clean up Hyper-V timecounter a bit.
  
  MFC after:  1 week
  Sponsored by:   Microsoft OSTC
  Differential Revision:  https://reviews.freebsd.org/D6569
  
  300834
  hyperv: Test features before enabling optional functionalities
  
  MFC after:  1 week
  Sponsored by:   Microsoft OSTC
  Differential Revision:  https://reviews.freebsd.org/D6571

Added:
  stable/10/sys/dev/hyperv/vmbus/hyperv_var.h
 - copied unchanged from r300834, head/sys/dev/hyperv/vmbus/hyperv_var.h
Modified:
  stable/10/sys/dev/hyperv/vmbus/hv_et.c
  stable/10/sys/dev/hyperv/vmbus/hv_hv.c
  stable/10/sys/dev/hyperv/vmbus/hv_vmbus_drv_freebsd.c
  stable/10/sys/dev/hyperv/vmbus/hv_vmbus_priv.h
  stable/10/sys/dev/hyperv/vmbus/hyperv_reg.h
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/dev/hyperv/vmbus/hv_et.c
==
--- stable/10/sys/dev/hyperv/vmbus/hv_et.c  Thu Jun 23 08:09:44 2016
(r302128)
+++ stable/10/sys/dev/hyperv/vmbus/hv_et.c  Thu Jun 23 08:26:07 2016
(r302129)
@@ -37,12 +37,28 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 
-#include "hv_vmbus_priv.h"
+#include 
+#include 
+#include 
 
 #define HV_TIMER_FREQUENCY (10 * 1000 * 1000LL) /* 100ns period */
 #define HV_MAX_DELTA_TICKS 0xLL
 #define HV_MIN_DELTA_TICKS 1LL
 
+#define MSR_HV_STIMER0_CFG_SINT\
+   uint64_t)HV_VMBUS_TIMER_SINT) << MSR_HV_STIMER_CFG_SINT_SHIFT) & \
+MSR_HV_STIMER_CFG_SINT_MASK)
+
+/*
+ * Two additionally required features:
+ * - SynIC is needed for interrupt generation.
+ * - Time reference counter is needed to set ABS reference count to
+ *   STIMER0_COUNT.
+ */
+#define CPUID_HV_ET_MASK   (CPUID_HV_MSR_TIME_REFCNT | \
+CPUID_HV_MSR_SYNIC |   \
+CPUID_HV_MSR_SYNTIMER)
+
 static struct eventtimer *et;
 
 static inline uint64_t
@@ -57,18 +73,15 @@ sbintime2tick(sbintime_t time)
 static int
 hv_et_start(struct eventtimer *et, sbintime_t firsttime, sbintime_t periodtime)
 {
-   union hv_timer_config timer_cfg;
-   uint64_t current;
+   uint64_t current, config;
 
-   timer_cfg.as_uint64 = 0;
-   timer_cfg.auto_enable = 1;
-   timer_cfg.sintx = HV_VMBUS_TIMER_SINT;
+   config = MSR_HV_STIMER_CFG_AUTOEN | MSR_HV_STIMER0_CFG_SINT;
 
-   current = rdmsr(HV_X64_MSR_TIME_REF_COUNT);
+   current = rdmsr(MSR_HV_TIME_REF_COUNT);
current += sbintime2tick(firsttime);
 
-   wrmsr(HV_X64_MSR_STIMER0_CONFIG, timer_cfg.as_uint64);
-   wrmsr(HV_X64_MSR_STIMER0_COUNT, current);
+   wrmsr(MSR_HV_STIMER0_CONFIG, config);
+   wrmsr(MSR_HV_STIMER0_COUNT, current);
 
return (0);
 }
@@ -76,8 +89,8 @@ hv_et_start(struct eventtimer *et, sbint
 static int
 hv_et_stop(struct eventtimer *et)
 {
-   wrmsr(HV_X64_MSR_STIMER0_CONFIG, 0);
-   wrmsr(HV_X64_MSR_STIMER0_COUNT, 0);
+   wrmsr(MSR_HV_STIMER0_CONFIG, 0);
+   wrmsr(MSR_HV_STIMER0_COUNT, 0);
 
return (0);
 }
@@ -102,7 +115,8 @@ hv_et_intr(struct trapframe *frame)
 static void
 hv_et_identify(driver_t *driver, device_t parent)
 {
-   if (device_find_child(parent, "hv_et", -1) != NULL)
+   if (device_find_child(parent, "hv_et", -1) != NULL ||
+   (hyperv_features & CPUID_HV_ET_MASK) != CPUID_HV_ET_MASK)
return;
 
device_add_child(parent, "hv_et", -1);

Modified: stable/10/sys/dev/hyperv/vmbus/hv_hv.c
==
--- stable/10/sys/dev/hyperv/vmbus/hv_hv.c  Thu Jun 23 08:09:44 2016
(r302128)
+++ stable/10/sys/dev/hyperv/vmbus/hv_hv.c  Thu Jun 23 08:26:07 2016
(r302129)
@@ -46,12 +46,11 @@ __FBSDID("$FreeBSD$");
 #include 
 #incl

svn commit: r302131 - head/sys/vm

2016-06-23 Thread Konstantin Belousov
Author: kib
Date: Thu Jun 23 08:28:13 2016
New Revision: 302131
URL: https://svnweb.freebsd.org/changeset/base/302131

Log:
  In vm_page_xunbusy_maybelocked(), add fast path for unbusy when no
  waiters exist, same as for vm_page_xunbusy().  If previous value of
  busy_lock was VPB_SINGLE_EXCLUSIVER, no waiters existed and wakeup is
  not needed.
  
  Move common code from vm_page_xunbusy_maybelocked() and
  vm_page_xunbusy_hard() to vm_page_xunbusy_locked().
  
  Reviewed by:  alc
  Sponsored by: The FreeBSD Foundation
  MFC after:2 weeks
  Approved by:  re (gjb)

Modified:
  head/sys/vm/vm_page.c

Modified: head/sys/vm/vm_page.c
==
--- head/sys/vm/vm_page.c   Thu Jun 23 08:27:38 2016(r302130)
+++ head/sys/vm/vm_page.c   Thu Jun 23 08:28:13 2016(r302131)
@@ -760,17 +760,36 @@ vm_page_trysbusy(vm_page_t m)
 }
 
 static void
+vm_page_xunbusy_locked(vm_page_t m)
+{
+
+   vm_page_assert_xbusied(m);
+   vm_page_assert_locked(m);
+
+   atomic_store_rel_int(&m->busy_lock, VPB_UNBUSIED);
+   /* There is a waiter, do wakeup() instead of vm_page_flash(). */
+   wakeup(m);
+}
+
+static void
 vm_page_xunbusy_maybelocked(vm_page_t m)
 {
bool lockacq;
 
vm_page_assert_xbusied(m);
 
+   /*
+* Fast path for unbusy.  If it succeeds, we know that there
+* are no waiters, so we do not need a wakeup.
+*/
+   if (atomic_cmpset_rel_int(&m->busy_lock, VPB_SINGLE_EXCLUSIVER,
+   VPB_UNBUSIED))
+   return;
+
lockacq = !mtx_owned(vm_page_lockptr(m));
if (lockacq)
vm_page_lock(m);
-   vm_page_flash(m);
-   atomic_store_rel_int(&m->busy_lock, VPB_UNBUSIED);
+   vm_page_xunbusy_locked(m);
if (lockacq)
vm_page_unlock(m);
 }
@@ -788,8 +807,7 @@ vm_page_xunbusy_hard(vm_page_t m)
vm_page_assert_xbusied(m);
 
vm_page_lock(m);
-   atomic_store_rel_int(&m->busy_lock, VPB_UNBUSIED);
-   wakeup(m);
+   vm_page_xunbusy_locked(m);
vm_page_unlock(m);
 }
 
___
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: r302130 - head/sys/vm

2016-06-23 Thread Konstantin Belousov
Author: kib
Date: Thu Jun 23 08:27:38 2016
New Revision: 302130
URL: https://svnweb.freebsd.org/changeset/base/302130

Log:
  Add a comment noting locking regime for vm_page_xunbusy().
  
  Reviewed by:  alc
  Sponsored by: The FreeBSD Foundation
  MFC after:2 weeks
  Approved by:  re (gjb)

Modified:
  head/sys/vm/vm_page.h

Modified: head/sys/vm/vm_page.h
==
--- head/sys/vm/vm_page.h   Thu Jun 23 08:26:07 2016(r302129)
+++ head/sys/vm/vm_page.h   Thu Jun 23 08:27:38 2016(r302130)
@@ -552,6 +552,7 @@ void vm_page_lock_assert_KBI(vm_page_t m
(m));   \
 } while (0)
 
+/* Note: page m's lock must not be owned by the caller. */
 #definevm_page_xunbusy(m) do { 
\
if (!atomic_cmpset_rel_int(&(m)->busy_lock, \
VPB_SINGLE_EXCLUSIVER, VPB_UNBUSIED))   \
___
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: r302132 - stable/10/sys/netinet

2016-06-23 Thread Sepherosa Ziehau
Author: sephe
Date: Thu Jun 23 08:38:01 2016
New Revision: 302132
URL: https://svnweb.freebsd.org/changeset/base/302132

Log:
  MFC 300981
  
  tcp: Don't prematurely drop receiving-only connections
  
  If the connection was persistent and receiving-only, several (12)
  sporadic device insufficient buffers would cause the connection be
  dropped prematurely:
  Upon ENOBUFS in tcp_output() for an ACK, retransmission timer is
  started.  No one will stop this retransmission timer for receiving-
  only connection, so the retransmission timer promises to expire and
  t_rxtshift is promised to be increased.  And t_rxtshift will not be
  reset to 0, since no RTT measurement will be done for receiving-only
  connection.  If this receiving-only connection lived long enough
  (e.g. >350sec, given the RTO starts from 200ms), and it suffered 12
  sporadic device insufficient buffers, i.e. t_rxtshift >= 12, this
  receiving-only connection would be dropped prematurely by the
  retransmission timer.
  
  We now assert that for data segments, SYNs or FINs either rexmit or
  persist timer was wired upon ENOBUFS.  And don't set rexmit timer
  for other cases, i.e. ENOBUFS upon ACKs.
  
  Discussed with: lstewart, hiren, jtl, Mike Karels
  MFC after:  3 weeks
  Sponsored by:   Microsoft OSTC
  Differential Revision:  https://reviews.freebsd.org/D5872

Modified:
  stable/10/sys/netinet/tcp_output.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/netinet/tcp_output.c
==
--- stable/10/sys/netinet/tcp_output.c  Thu Jun 23 08:28:13 2016
(r302131)
+++ stable/10/sys/netinet/tcp_output.c  Thu Jun 23 08:38:01 2016
(r302132)
@@ -127,6 +127,16 @@ SYSCTL_VNET_INT(_net_inet_tcp, OID_AUTO,
&VNET_NAME(tcp_autosndbuf_max), 0,
"Max size of automatic send buffer");
 
+/*
+ * Make sure that either retransmit or persist timer is set for SYN, FIN and
+ * non-ACK.
+ */
+#define TCP_XMIT_TIMER_ASSERT(tp, len, th_flags)   \
+   KASSERT(((len) == 0 && ((th_flags) & (TH_SYN | TH_FIN)) == 0) ||\
+   tcp_timer_active((tp), TT_REXMT) || \
+   tcp_timer_active((tp), TT_PERSIST), \
+   ("neither rexmt nor persist timer is set"))
+
 static void inline hhook_run_tcp_est_out(struct tcpcb *tp,
struct tcphdr *th, struct tcpopt *to,
long len, int tso);
@@ -1531,9 +1541,7 @@ timer:
tp->t_softerror = error;
return (error);
case ENOBUFS:
-   if (!tcp_timer_active(tp, TT_REXMT) &&
-   !tcp_timer_active(tp, TT_PERSIST))
-   tcp_timer_activate(tp, TT_REXMT, tp->t_rxtcur);
+   TCP_XMIT_TIMER_ASSERT(tp, len, flags);
tp->snd_cwnd = tp->t_maxseg;
return (0);
case EMSGSIZE:
___
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: r302081 - head/sys/netinet6

2016-06-23 Thread Andrey V. Elsukov
On 22.06.16 18:46, hiren panchasara wrote:
>>   Fix the NULL pointer dereference for unresolved link layer entries in
>>   the netinet6 code. Copy link layer address only when corresponding entry
>>   has LLE_VALID flag.
>>   
>>   PR:210379
>>   Approved by:   re (kib)
>>
>> Modified:
>>   head/sys/netinet6/in6.c
> 
> Cursory look tells me that this bug is also present in 10. Is that true?
> If so, is it possible for you to mfc this?

The patch is applicable, but due to the difference in the LLE code
stable/10 has not affected with this bug.

-- 
WBR, Andrey V. Elsukov



signature.asc
Description: OpenPGP digital signature


svn commit: r302133 - stable/10/sys/kern

2016-06-23 Thread Konstantin Belousov
Author: kib
Date: Thu Jun 23 09:00:58 2016
New Revision: 302133
URL: https://svnweb.freebsd.org/changeset/base/302133

Log:
  MFC r301959:
  Remove code duplication.

Modified:
  stable/10/sys/kern/kern_thread.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/kern/kern_thread.c
==
--- stable/10/sys/kern/kern_thread.cThu Jun 23 08:38:01 2016
(r302132)
+++ stable/10/sys/kern/kern_thread.cThu Jun 23 09:00:58 2016
(r302133)
@@ -613,11 +613,6 @@ weed_inhib(int mode, struct thread *td2,
wakeup_swapper |= sleepq_abort(td2, EINTR);
break;
case SINGLE_BOUNDARY:
-   if (TD_IS_SUSPENDED(td2) && (td2->td_flags & TDF_BOUNDARY) == 0)
-   wakeup_swapper |= thread_unsuspend_one(td2, p, false);
-   if (TD_ON_SLEEPQ(td2) && (td2->td_flags & TDF_SINTR) != 0)
-   wakeup_swapper |= sleepq_abort(td2, ERESTART);
-   break;
case SINGLE_NO_EXIT:
if (TD_IS_SUSPENDED(td2) && (td2->td_flags & TDF_BOUNDARY) == 0)
wakeup_swapper |= thread_unsuspend_one(td2, p, false);
___
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: r302134 - stable/10/sys/kern

2016-06-23 Thread Konstantin Belousov
Author: kib
Date: Thu Jun 23 09:02:50 2016
New Revision: 302134
URL: https://svnweb.freebsd.org/changeset/base/302134

Log:
  MFC r301960:
  Remove XXX comments from kern_thread.c.

Modified:
  stable/10/sys/kern/kern_thread.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/kern/kern_thread.c
==
--- stable/10/sys/kern/kern_thread.cThu Jun 23 09:00:58 2016
(r302133)
+++ stable/10/sys/kern/kern_thread.cThu Jun 23 09:02:50 2016
(r302134)
@@ -424,7 +424,7 @@ thread_exit(void)
 * architecture specific resources that
 * would not be on a new untouched process.
 */
-   cpu_thread_exit(td);/* XXXSMP */
+   cpu_thread_exit(td);
 
/*
 * The last thread is left attached to the process
@@ -851,8 +851,8 @@ thread_suspend_check(int return_instead)
/*
 * The only suspension in action is a
 * single-threading. Single threader need not stop.
-* XXX Should be safe to access unlocked
-* as it can only be set to be true by us.
+* It is safe to access p->p_singlethread unlocked
+* because it can only be set to our address by us.
 */
if (p->p_singlethread == td)
return (0); /* Exempt from stopping. */
___
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: r302135 - stable/10/sys/dev/hyperv/vmbus

2016-06-23 Thread Sepherosa Ziehau
Author: sephe
Date: Thu Jun 23 09:03:52 2016
New Revision: 302135
URL: https://svnweb.freebsd.org/changeset/base/302135

Log:
  MFC 300987,300988,300989,300992,300993,300994,301009
  
  300987
  hyperv/et: Fix STIMER0 operations.
  
  - Make sure that STIMER0 is disabled before writting to it, since
writing to an enabled STIMER will result in undefined behaviour.
  - It is unnecessary to reconfigure STIMER0 upon each et_start().
  - Make sure that MSR_HV_REF_TIME_COUNT will not return 0, since
writing 0 to STIMER_COUNT will disable the target STIMER.
  
  MFC after:  1 week
  Sponsored by:   Microsoft OSTC
  Differential Revision:  https://reviews.freebsd.org/D6573
  
  300988
  hyperv/vmbus: Move SINT settings to vmbus_var.h
  
  While I'm here remove the event timer's dependency on hv_vmbus_priv.h
  
  MFC after:  1 week
  Sponsored by:   Microsoft OSTC
  Differential Revision:  https://reviews.freebsd.org/D6574
  
  300989
  hyperv/et: Make sure only one event timer will be registered
  
  This nullifies the need to use softc.
  
  MFC after:  1 week
  Sponsored by:   Microsoft OSTC
  Differential Revision:  https://reviews.freebsd.org/D6591
  
  300992
  hyperv: Move timer frequency definition to common place.
  
  And cleanup event timer period settings.
  
  MFC after:  1 week
  Sponsored by:   Microsoft OSTC
  Differential Revision:  https://reviews.freebsd.org/D6597
  
  300993
  hyperv/et: Device renaming; consistent w/ other Hyper-V utils
  
  While I'm here, prefix function names w/ vmbus, since unlike Hyper-V
  timecounter, Hyper-V event timer will not work w/o vmbus.
  
  MFC after:  1 week
  Sponsored by:   Microsoft OSTC
  Differential Revision:  https://reviews.freebsd.org/D6598
  
  300994
  hyperv/et: Allow Hyper-V event timer be disabled
  
  MFC after:  1 week
  Sponsored by:   Microsoft OSTC
  Differential Revision:  https://reviews.freebsd.org/D6599
  
  301009
  hyperv/vmbus: Process event timer before checking events
  
  And update comment.
  
  MFC after:  1 week
  Sponsored by:   Microsoft OSTC
  Differential Revision:  https://reviews.freebsd.org/D6600

Modified:
  stable/10/sys/dev/hyperv/vmbus/hv_connection.c
  stable/10/sys/dev/hyperv/vmbus/hv_et.c
  stable/10/sys/dev/hyperv/vmbus/hv_hv.c
  stable/10/sys/dev/hyperv/vmbus/hv_vmbus_drv_freebsd.c
  stable/10/sys/dev/hyperv/vmbus/hv_vmbus_priv.h
  stable/10/sys/dev/hyperv/vmbus/hyperv_var.h
  stable/10/sys/dev/hyperv/vmbus/vmbus_var.h
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/dev/hyperv/vmbus/hv_connection.c
==
--- stable/10/sys/dev/hyperv/vmbus/hv_connection.c  Thu Jun 23 09:02:50 
2016(r302134)
+++ stable/10/sys/dev/hyperv/vmbus/hv_connection.c  Thu Jun 23 09:03:52 
2016(r302135)
@@ -340,7 +340,7 @@ vmbus_event_proc(struct vmbus_softc *sc,
 * On Host with Win8 or above, the event page can be checked directly
 * to get the id of the channel that has the pending interrupt.
 */
-   event = VMBUS_PCPU_GET(sc, event_flag, cpu) + HV_VMBUS_MESSAGE_SINT;
+   event = VMBUS_PCPU_GET(sc, event_flag, cpu) + VMBUS_SINT_MESSAGE;
vmbus_event_flags_proc(event->flagsul,
VMBUS_PCPU_GET(sc, event_flag_cnt, cpu));
 }
@@ -350,7 +350,7 @@ vmbus_event_proc_compat(struct vmbus_sof
 {
hv_vmbus_synic_event_flags *event;
 
-   event = VMBUS_PCPU_GET(sc, event_flag, cpu) + HV_VMBUS_MESSAGE_SINT;
+   event = VMBUS_PCPU_GET(sc, event_flag, cpu) + VMBUS_SINT_MESSAGE;
if (atomic_testandclear_int(&event->flags32[0], 0)) {
vmbus_event_flags_proc(
hv_vmbus_g_connection.recv_interrupt_page,

Modified: stable/10/sys/dev/hyperv/vmbus/hv_et.c
==
--- stable/10/sys/dev/hyperv/vmbus/hv_et.c  Thu Jun 23 09:02:50 2016
(r302134)
+++ stable/10/sys/dev/hyperv/vmbus/hv_et.c  Thu Jun 23 09:03:52 2016
(r302135)
@@ -37,16 +37,16 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 
-#include 
+#include 
+
 #include 
 #include 
+#include 
 
-#define HV_TIMER_FREQUENCY (10 * 1000 * 1000LL) /* 100ns period */
-#define HV_MAX_DELTA_TICKS 0xLL
-#define HV_MIN_DELTA_TICKS 1LL
+#define VMBUS_ET_NAME  "hvet"
 
 #define MSR_HV_STIMER0_CFG_SINT\
-   uint64_t)HV_VMBUS_TIMER_SINT) << MSR_HV_STIMER_CFG_SINT_SHIFT) & \
+   uint64_t)VMBUS_SINT_TIMER) << MSR_HV_STIMER_CFG_SINT_SHIFT) & \
 MSR_HV_STIMER_CFG_SINT_MASK)
 
 /*
@@ -59,117 +59,140 @@ __FBSDID("$FreeBSD$");
 CPUID_HV_MSR_SYNIC |   \
  

svn commit: r302136 - stable/10/sys/dev/cpuctl

2016-06-23 Thread Konstantin Belousov
Author: kib
Date: Thu Jun 23 09:04:50 2016
New Revision: 302136
URL: https://svnweb.freebsd.org/changeset/base/302136

Log:
  MFC r301962:
  Always allow loading of cpuctl(4).

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

Modified: stable/10/sys/dev/cpuctl/cpuctl.c
==
--- stable/10/sys/dev/cpuctl/cpuctl.c   Thu Jun 23 09:03:52 2016
(r302135)
+++ stable/10/sys/dev/cpuctl/cpuctl.c   Thu Jun 23 09:04:50 2016
(r302136)
@@ -67,9 +67,9 @@ static d_ioctl_t cpuctl_ioctl;
 
 static int cpuctl_do_msr(int cpu, cpuctl_msr_args_t *data, u_long cmd,
 struct thread *td);
-static void cpuctl_do_cpuid(int cpu, cpuctl_cpuid_args_t *data,
+static int cpuctl_do_cpuid(int cpu, cpuctl_cpuid_args_t *data,
 struct thread *td);
-static void cpuctl_do_cpuid_count(int cpu, cpuctl_cpuid_count_args_t *data,
+static int cpuctl_do_cpuid_count(int cpu, cpuctl_cpuid_count_args_t *data,
 struct thread *td);
 static int cpuctl_do_update(int cpu, cpuctl_update_args_t *data,
 struct thread *td);
@@ -171,8 +171,7 @@ cpuctl_ioctl(struct cdev *dev, u_long cm
ret = cpuctl_do_msr(cpu, (cpuctl_msr_args_t *)data, cmd, td);
break;
case CPUCTL_CPUID:
-   cpuctl_do_cpuid(cpu, (cpuctl_cpuid_args_t *)data, td);
-   ret = 0;
+   ret = cpuctl_do_cpuid(cpu, (cpuctl_cpuid_args_t *)data, td);
break;
case CPUCTL_UPDATE:
ret = priv_check(td, PRIV_CPUCTL_UPDATE);
@@ -181,9 +180,8 @@ cpuctl_ioctl(struct cdev *dev, u_long cm
ret = cpuctl_do_update(cpu, (cpuctl_update_args_t *)data, td);
break;
case CPUCTL_CPUID_COUNT:
-   cpuctl_do_cpuid_count(cpu, (cpuctl_cpuid_count_args_t *)data,
-   td);
-   ret = 0;
+   ret = cpuctl_do_cpuid_count(cpu,
+   (cpuctl_cpuid_count_args_t *)data, td);
break;
default:
ret = EINVAL;
@@ -196,7 +194,7 @@ fail:
 /*
  * Actually perform cpuid operation.
  */
-static void
+static int
 cpuctl_do_cpuid_count(int cpu, cpuctl_cpuid_count_args_t *data,
 struct thread *td)
 {
@@ -210,23 +208,30 @@ cpuctl_do_cpuid_count(int cpu, cpuctl_cp
bzero(data->data, sizeof(data->data));
DPRINTF("[cpuctl,%d]: retrieving cpuid lev %#0x type %#0x for %d cpu\n",
__LINE__, data->level, data->level_type, cpu);
+#ifdef __i386__
+   if (cpu_id == 0)
+   return (ENODEV);
+#endif
oldcpu = td->td_oncpu;
is_bound = cpu_sched_is_bound(td);
set_cpu(cpu, td);
cpuid_count(data->level, data->level_type, data->data);
restore_cpu(oldcpu, is_bound, td);
+   return (0);
 }
 
-static void
+static int
 cpuctl_do_cpuid(int cpu, cpuctl_cpuid_args_t *data, struct thread *td)
 {
cpuctl_cpuid_count_args_t cdata;
+   int error;
 
cdata.level = data->level;
/* Override the level type. */
cdata.level_type = 0;
-   cpuctl_do_cpuid_count(cpu, &cdata, td);
+   error = cpuctl_do_cpuid_count(cpu, &cdata, td);
bcopy(cdata.data, data->data, sizeof(data->data)); /* Ignore error */
+   return (error);
 }
 
 /*
@@ -249,6 +254,10 @@ cpuctl_do_msr(int cpu, cpuctl_msr_args_t
 */
DPRINTF("[cpuctl,%d]: operating on MSR %#0x for %d cpu\n", __LINE__,
data->msr, cpu);
+#ifdef __i386__
+   if ((cpu_feature & CPUID_MSR) == 0)
+   return (ENODEV);
+#endif
oldcpu = td->td_oncpu;
is_bound = cpu_sched_is_bound(td);
set_cpu(cpu, td);
@@ -291,7 +300,9 @@ cpuctl_do_update(int cpu, cpuctl_update_
("[cpuctl,%d]: bad cpu number %d", __LINE__, cpu));
DPRINTF("[cpuctl,%d]: XXX %d", __LINE__, cpu);
 
-   cpuctl_do_cpuid(cpu, &args, td);
+   ret = cpuctl_do_cpuid(cpu, &args, td);
+   if (ret != 0)
+   return (ret);
((uint32_t *)vendor)[0] = args.data[1];
((uint32_t *)vendor)[1] = args.data[3];
((uint32_t *)vendor)[2] = args.data[2];
@@ -518,11 +529,6 @@ cpuctl_modevent(module_t mod __unused, i
 
switch(type) {
case MOD_LOAD:
-   if ((cpu_feature & CPUID_MSR) == 0) {
-   if (bootverbose)
-   printf("cpuctl: not available.\n");
-   return (ENODEV);
-   }
if (bootverbose)
printf("cpuctl: access to MSR registers/cpuid info.\n");
cpuctl_devs = malloc(sizeof(*cpuctl_devs) * mp_ncpus, M_CPUCTL,
___
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: r302137 - stable/10/usr.sbin/cpucontrol

2016-06-23 Thread Konstantin Belousov
Author: kib
Date: Thu Jun 23 09:06:11 2016
New Revision: 302137
URL: https://svnweb.freebsd.org/changeset/base/302137

Log:
  MFC r301963:
  Return usual error indicator to shell.

Modified:
  stable/10/usr.sbin/cpucontrol/cpucontrol.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/usr.sbin/cpucontrol/cpucontrol.c
==
--- stable/10/usr.sbin/cpucontrol/cpucontrol.c  Thu Jun 23 09:04:50 2016
(r302136)
+++ stable/10/usr.sbin/cpucontrol/cpucontrol.c  Thu Jun 23 09:06:11 2016
(r302137)
@@ -481,5 +481,5 @@ main(int argc, char *argv[])
usage();/* Only one command can be selected. */
}
SLIST_FREE(&datadirs, next, free);
-   return (error);
+   return (error == 0 ? 0 : 1);
 }
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r302138 - in head/sys: netinet netinet6

2016-06-23 Thread Michael Tuexen
Author: tuexen
Date: Thu Jun 23 09:13:15 2016
New Revision: 302138
URL: https://svnweb.freebsd.org/changeset/base/302138

Log:
  Don't consider the socket when processing an incoming ICMP/ICMP6 packet,
  which was triggered by an SCTP packet. Whether a socket exists, is just
  not relevant.
  
  Approved by: re (kib)
  MFC after: 1 week

Modified:
  head/sys/netinet/sctp_usrreq.c
  head/sys/netinet/sctputil.c
  head/sys/netinet6/sctp6_usrreq.c

Modified: head/sys/netinet/sctp_usrreq.c
==
--- head/sys/netinet/sctp_usrreq.c  Thu Jun 23 09:06:11 2016
(r302137)
+++ head/sys/netinet/sctp_usrreq.c  Thu Jun 23 09:13:15 2016
(r302138)
@@ -291,8 +291,7 @@ sctp_ctlinput(int cmd, struct sockaddr *
SCTP_DEFAULT_VRFID);
if ((stcb != NULL) &&
(net != NULL) &&
-   (inp != NULL) &&
-   (inp->sctp_socket != NULL)) {
+   (inp != NULL)) {
/* Check the verification tag */
if (ntohl(sh->v_tag) != 0) {
/*

Modified: head/sys/netinet/sctputil.c
==
--- head/sys/netinet/sctputil.c Thu Jun 23 09:06:11 2016(r302137)
+++ head/sys/netinet/sctputil.c Thu Jun 23 09:13:15 2016(r302138)
@@ -6965,8 +6965,7 @@ sctp_recv_icmp_tunneled_packet(int cmd, 
SCTP_DEFAULT_VRFID);
if ((stcb != NULL) &&
(net != NULL) &&
-   (inp != NULL) &&
-   (inp->sctp_socket != NULL)) {
+   (inp != NULL)) {
/* Check the UDP port numbers */
if ((udp->uh_dport != net->port) ||
(udp->uh_sport != 
htons(SCTP_BASE_SYSCTL(sctp_udp_tunneling_port {
@@ -7092,8 +7091,7 @@ sctp_recv_icmp6_tunneled_packet(int cmd,
&inp, &net, 1, SCTP_DEFAULT_VRFID);
if ((stcb != NULL) &&
(net != NULL) &&
-   (inp != NULL) &&
-   (inp->sctp_socket != NULL)) {
+   (inp != NULL)) {
/* Check the UDP port numbers */
if ((udp.uh_dport != net->port) ||
(udp.uh_sport != 
htons(SCTP_BASE_SYSCTL(sctp_udp_tunneling_port {

Modified: head/sys/netinet6/sctp6_usrreq.c
==
--- head/sys/netinet6/sctp6_usrreq.cThu Jun 23 09:06:11 2016
(r302137)
+++ head/sys/netinet6/sctp6_usrreq.cThu Jun 23 09:13:15 2016
(r302138)
@@ -341,8 +341,7 @@ sctp6_ctlinput(int cmd, struct sockaddr 
&inp, &net, 1, SCTP_DEFAULT_VRFID);
if ((stcb != NULL) &&
(net != NULL) &&
-   (inp != NULL) &&
-   (inp->sctp_socket != NULL)) {
+   (inp != NULL)) {
/* Check the verification tag */
if (ntohl(sh.v_tag) != 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: r302139 - head/sys/dev/mlx5/mlx5_core

2016-06-23 Thread Hans Petter Selasky
Author: hselasky
Date: Thu Jun 23 09:23:37 2016
New Revision: 302139
URL: https://svnweb.freebsd.org/changeset/base/302139

Log:
  Use correct Q-counter output array.
  
  Sponsored by: Mellanox Technologies
  Approved by:  re (kib)
  MFC after:3 days

Modified:
  head/sys/dev/mlx5/mlx5_core/mlx5_vport.c

Modified: head/sys/dev/mlx5/mlx5_core/mlx5_vport.c
==
--- head/sys/dev/mlx5/mlx5_core/mlx5_vport.cThu Jun 23 09:13:15 2016
(r302138)
+++ head/sys/dev/mlx5/mlx5_core/mlx5_vport.cThu Jun 23 09:23:37 2016
(r302139)
@@ -71,7 +71,7 @@ static int mlx5_query_nic_vport_context(
 int mlx5_vport_alloc_q_counter(struct mlx5_core_dev *mdev, int *counter_set_id)
 {
u32 in[MLX5_ST_SZ_DW(alloc_q_counter_in)];
-   u32 out[MLX5_ST_SZ_DW(alloc_q_counter_in)];
+   u32 out[MLX5_ST_SZ_DW(alloc_q_counter_out)];
int err;
 
memset(in, 0, sizeof(in));
___
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: r302140 - head/sys/netinet

2016-06-23 Thread Bjoern A. Zeeb
Author: bz
Date: Thu Jun 23 11:55:15 2016
New Revision: 302140
URL: https://svnweb.freebsd.org/changeset/base/302140

Log:
  In VNET TCP teardown Do not sleep unconditionally but only if we
  have any TCP connections left.
  
  Submitted by: zec
  Approved by:  re (hrs)
  MFC after:13 days

Modified:
  head/sys/netinet/tcp_subr.c

Modified: head/sys/netinet/tcp_subr.c
==
--- head/sys/netinet/tcp_subr.c Thu Jun 23 09:23:37 2016(r302139)
+++ head/sys/netinet/tcp_subr.c Thu Jun 23 11:55:15 2016(r302140)
@@ -739,10 +739,11 @@ tcp_destroy(void *unused __unused)
 * Sleep to let all tcpcb timers really disappear and cleanup.
 */
do {
-   pause("tcpdes", hz/10);
INP_LIST_RLOCK(&V_tcbinfo);
n = V_tcbinfo.ipi_count;
INP_LIST_RUNLOCK(&V_tcbinfo);
+   if (n != 0)
+   pause("tcpdes", hz / 10);
} while (n != 0);
tcp_hc_destroy();
syncache_destroy();
___
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: r302099 - head/sys/netinet

2016-06-23 Thread Bjoern A. Zeeb


On 23 Jun 2016, at 8:17, Marko Zec wrote:

> On Thu, 23 Jun 2016 00:34:03 +
> "Bjoern A. Zeeb"  wrote:
>
>> Author: bz
>> Date: Thu Jun 23 00:34:03 2016
>> New Revision: 302099
>> URL: https://svnweb.freebsd.org/changeset/base/302099
>>
>> Log:
>>   Check the V_tcbinfo.ipi_count to hit 0 before doing the full TCP
>> cleanup. That way timers can finish cleanly and we do not gamble with
>> a DELAY().
>>   Reviewed by:   gnn, jtl
>>   Approved by:   re (gjb)
>>   Obtained from: projects/vnet
>>   MFC after: 2 weeks
>>   Sponsored by:  The FreeBSD Foundation
>>   Differential Revision: https://reviews.freebsd.org/D6923
>
> As much as this change is welcome, it unnecesarily introduces a
> mandatory 100 ms delay on each vnet teardown, which I already pointed
> out in a comment to r301601 two weeks ago, which remained unanswered,

sorry about that.   While VNET teardown is a non-criticial slow path and
the pause doesn’t really matter a lot (unless you need the resources to be
freed)  you actually made me go an “benchmark” this in terms
of how often my test cases do run into the pause after your change. It was
indeed very rare.


> along with the question why a delay of 100 ms was introduced here, when
> before r302099 the delay was only a single clock tick?  And furthermore
> the delay computation expresion here is not style(9) compliant...
>
> Hence, please rectify the above objections, perhaps by something like:

Done.   Thanks a lot!

/bz
___
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: r302141 - in head/cddl/lib: libavl libctf libnvpair libumem libuutil

2016-06-23 Thread Alan Somers
Author: asomers
Date: Thu Jun 23 15:02:57 2016
New Revision: 302141
URL: https://svnweb.freebsd.org/changeset/base/302141

Log:
  Raise the WARNS level in cddl/lib
  
  cddl/lib/libavl/Makefile
  cddl/lib/libctf/Makefile
  cddl/lib/libnvpair/Makefile
  cddl/lib/libumem/Makefile
  cddl/lib/libuutil/Makefile
Increase WARNS to the highest working level for each of these
libraries
  
  Approved by:  re (gjb, hrs)
  MFC after:4 weeks
  Sponsored by: Spectra Logic Corp

Modified:
  head/cddl/lib/libavl/Makefile
  head/cddl/lib/libctf/Makefile
  head/cddl/lib/libnvpair/Makefile
  head/cddl/lib/libumem/Makefile
  head/cddl/lib/libuutil/Makefile

Modified: head/cddl/lib/libavl/Makefile
==
--- head/cddl/lib/libavl/Makefile   Thu Jun 23 11:55:15 2016
(r302140)
+++ head/cddl/lib/libavl/Makefile   Thu Jun 23 15:02:57 2016
(r302141)
@@ -4,7 +4,7 @@
 
 LIB=   avl
 SRCS=  avl.c
-WARNS?=0
+WARNS?=3
 CFLAGS+= -I${.CURDIR}/../../../sys/cddl/compat/opensolaris
 CFLAGS+= -I${.CURDIR}/../../../sys/cddl/contrib/opensolaris/uts/common
 

Modified: head/cddl/lib/libctf/Makefile
==
--- head/cddl/lib/libctf/Makefile   Thu Jun 23 11:55:15 2016
(r302140)
+++ head/cddl/lib/libctf/Makefile   Thu Jun 23 15:02:57 2016
(r302141)
@@ -18,7 +18,7 @@ SRCS= ctf_create.c \
ctf_util.c
 MAN=   ctf.5
 
-WARNS?=0
+WARNS?=2
 CFLAGS+=   -DCTF_OLD_VERSIONS
 
 CFLAGS+=   -I${.CURDIR}/../../../sys/cddl/compat/opensolaris \

Modified: head/cddl/lib/libnvpair/Makefile
==
--- head/cddl/lib/libnvpair/MakefileThu Jun 23 11:55:15 2016
(r302140)
+++ head/cddl/lib/libnvpair/MakefileThu Jun 23 15:02:57 2016
(r302141)
@@ -12,7 +12,7 @@ SRCS= libnvpair.c \
opensolaris_nvpair.c \
opensolaris_nvpair_alloc_fixed.c
 
-WARNS?=0
+WARNS?=1
 CFLAGS+= -I${.CURDIR}/../../../cddl/compat/opensolaris/include
 CFLAGS+= -I${.CURDIR}/../../../cddl/contrib/opensolaris/lib/libzpool/common
 CFLAGS+= -I${.CURDIR}/../../../sys/cddl/compat/opensolaris

Modified: head/cddl/lib/libumem/Makefile
==
--- head/cddl/lib/libumem/Makefile  Thu Jun 23 11:55:15 2016
(r302140)
+++ head/cddl/lib/libumem/Makefile  Thu Jun 23 15:02:57 2016
(r302141)
@@ -4,7 +4,7 @@
 
 LIB=   umem
 SRCS=  umem.c
-WARNS?=0
+WARNS?=3
 CFLAGS+= -I${.CURDIR}/../../../cddl/compat/opensolaris/lib/libumem
 
 .include 

Modified: head/cddl/lib/libuutil/Makefile
==
--- head/cddl/lib/libuutil/Makefile Thu Jun 23 11:55:15 2016
(r302140)
+++ head/cddl/lib/libuutil/Makefile Thu Jun 23 15:02:57 2016
(r302141)
@@ -15,7 +15,7 @@ SRCS= avl.c \
uu_pname.c \
uu_strtoint.c
 
-WARNS?=0
+WARNS?=1
 CFLAGS+= -DNATIVE_BUILD
 CFLAGS+= -I${.CURDIR}/../../../cddl/contrib/opensolaris/lib/libuutil/common
 CFLAGS+= -I${.CURDIR}/../../../sys/cddl/compat/opensolaris
___
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: r302081 - head/sys/netinet6

2016-06-23 Thread hiren panchasara
On 06/23/16 at 11:48P, Andrey V. Elsukov wrote:
> On 22.06.16 18:46, hiren panchasara wrote:
> >>   Fix the NULL pointer dereference for unresolved link layer entries in
> >>   the netinet6 code. Copy link layer address only when corresponding entry
> >>   has LLE_VALID flag.
> >>   
> >>   PR:  210379
> >>   Approved by: re (kib)
> >>
> >> Modified:
> >>   head/sys/netinet6/in6.c
> > 
> > Cursory look tells me that this bug is also present in 10. Is that true?
> > If so, is it possible for you to mfc this?
> 
> The patch is applicable, but due to the difference in the LLE code
> stable/10 has not affected with this bug.

Ah, okay. Thanks a lot for checking.

Cheers,
Hiren


pgporuAIuTqDv.pgp
Description: PGP signature


Re: svn commit: r302094 - in head/sys: compat/freebsd32 kern

2016-06-23 Thread John Baldwin
On Thursday, June 23, 2016 12:39:48 AM Brooks Davis wrote:
> On Wed, Jun 22, 2016 at 05:09:34PM -0700, John Baldwin wrote:
> > On Wednesday, June 22, 2016 09:15:59 PM Brooks Davis wrote:
> > > Author: brooks
> > > Date: Wed Jun 22 21:15:59 2016
> > > New Revision: 302094
> > > URL: https://svnweb.freebsd.org/changeset/base/302094
> > > 
> > > Log:
> > >   Mark the pipe() system call as COMPAT10.
> > >   
> > >   As of r302092 libc uses pipe2() with a zero flags value instead of 
> > > pipe().
> > >   
> > >   Commit with regenerated files and implementation to follow.
> > 
> > This breaks the build on at least i386 because other ABIs depend on being
> > able to call sys_pipe directly.  You should at least add COMPAT_FREEBSD10
> > to GENERIC on architectures that shipped a 10.x release.  That will fix the
> > build breakage on i386, but it's also the policy we follow for all the other
> > compat knobs.
> 
> It was actually that sys_pipe() was renamed by the COMPAT10 tag.  I've
> copied the implementation to a svr4_pipe().

Thanks, my bad for jumping the gun on assuming FREEBSD10 was missing from
GENERIC.

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


Re: svn commit: r302099 - head/sys/netinet

2016-06-23 Thread John Baldwin
On Thursday, June 23, 2016 10:17:57 AM Marko Zec wrote:
> On Thu, 23 Jun 2016 00:34:03 +
> "Bjoern A. Zeeb"  wrote:
> 
> > Author: bz
> > Date: Thu Jun 23 00:34:03 2016
> > New Revision: 302099
> > URL: https://svnweb.freebsd.org/changeset/base/302099
> > 
> > Log:
> >   Check the V_tcbinfo.ipi_count to hit 0 before doing the full TCP
> > cleanup. That way timers can finish cleanly and we do not gamble with
> > a DELAY(). 
> >   Reviewed by:  gnn, jtl
> >   Approved by:  re (gjb)
> >   Obtained from:projects/vnet
> >   MFC after:2 weeks
> >   Sponsored by: The FreeBSD Foundation
> >   Differential Revision:https://reviews.freebsd.org/D6923
> 
> As much as this change is welcome, it unnecesarily introduces a
> mandatory 100 ms delay on each vnet teardown, which I already pointed
> out in a comment to r301601 two weeks ago, which remained unanswered,
> along with the question why a delay of 100 ms was introduced here, when
> before r302099 the delay was only a single clock tick?  And furthermore
> the delay computation expresion here is not style(9) compliant...
> 
> Hence, please rectify the above objections, perhaps by something like:
> 
> ===
> --- tcp_subr.c  (revision 302126)
> +++ tcp_subr.c  (working copy)
> @@ -739,10 +739,11 @@
>  * Sleep to let all tcpcb timers really disappear and cleanup.
>  */
> do {
> -   pause("tcpdes", hz/10);
> INP_LIST_RLOCK(&V_tcbinfo);
> n = V_tcbinfo.ipi_count;
> INP_LIST_RUNLOCK(&V_tcbinfo);
> +   if (n != 0)
> +   pause("tcpdes", hz / 100);
> } while (n != 0);
> tcp_hc_destroy();
> syncache_destroy();

I would suggest avoiding the duplicate test by using a break:

for (;;) {
/* fetch 'n' */
if (n == 0)
break;
pause(...);
}

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


svn commit: r302145 - head/usr.sbin/bsdinstall/partedit

2016-06-23 Thread Ed Maste
Author: emaste
Date: Thu Jun 23 18:04:48 2016
New Revision: 302145
URL: https://svnweb.freebsd.org/changeset/base/302145

Log:
  bsdinstall: increase EFI partition size to 200MB
  
  A larger EFI file system size will facilitate multi-boot configurations
  and the installation other EFI applications like firmware update tools.
  200MB matches OS X.
  
  Note that this changes only the partition size, not the file system that
  bsdinstall places there. We need to do both, but as the partition size
  is difficult to adjust later make this change for now so that at least
  systems installed with FreeBSD 11.0 have a partition layout with room
  to grow.
  
  Reviewed by:  allanjude, imp
  Approved by:  re (gjb)
  Sponsored by: The FreeBSD Foundation
  Differential Revision:https://reviews.freebsd.org/D6935

Modified:
  head/usr.sbin/bsdinstall/partedit/partedit_x86.c

Modified: head/usr.sbin/bsdinstall/partedit/partedit_x86.c
==
--- head/usr.sbin/bsdinstall/partedit/partedit_x86.cThu Jun 23 16:37:43 
2016(r302144)
+++ head/usr.sbin/bsdinstall/partedit/partedit_x86.cThu Jun 23 18:04:48 
2016(r302145)
@@ -99,7 +99,7 @@ bootpart_size(const char *scheme)
if (strcmp(x86_bootmethod(), "BIOS") == 0)
return (512*1024);
else 
-   return (800*1024);
+   return (200*1024*1024);
 
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: r302146 - head/tools/tools/makeroot

2016-06-23 Thread Ed Maste
Author: emaste
Date: Thu Jun 23 19:19:44 2016
New Revision: 302146
URL: https://svnweb.freebsd.org/changeset/base/302146

Log:
  makeroot: zero out subsecond component of time= keywords
  
  They are currently not supported by makefs(1).
  
  PR:   194703
  Reviewed by:  brooks
  Approved by:  re (gjb)
  Sponsored by: The FreeBSD Foundation
  Differential Revision:https://reviews.freebsd.org/D6925

Modified:
  head/tools/tools/makeroot/makeroot.sh

Modified: head/tools/tools/makeroot/makeroot.sh
==
--- head/tools/tools/makeroot/makeroot.sh   Thu Jun 23 18:04:48 2016
(r302145)
+++ head/tools/tools/makeroot/makeroot.sh   Thu Jun 23 19:19:44 2016
(r302146)
@@ -238,5 +238,9 @@ if [ -n "${SIZE}" ]; then
 SIZEFLAG="-s ${SIZE}"
 fi
 
+# Zero out subsecond component of time= keywords as they are currently not
+# supported by makefs
+sed -i '' -E 's/(time=[0-9]*)\.[0-9]*/\1.0/' ${manifest}
+
 cd ${BSDROOT}; makefs ${DUPFLAG} -N ${DBDIR} ${SIZEFLAG} ${BFLAG} \
  -t ffs ${LABELFLAG} -f 256 ${IMGFILE} ${manifest}
___
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: r302147 - head/sys/x86/acpica

2016-06-23 Thread Mark Johnston
Author: markj
Date: Thu Jun 23 19:24:38 2016
New Revision: 302147
URL: https://svnweb.freebsd.org/changeset/base/302147

Log:
  Use M_NOWAIT when allocating memory for the ACPI wakeup handler.
  
  If the allocation attempt fails, we may otherwise VM_WAIT after a failed
  attempt to reclaim contiguous memory in the requested range. After r297466,
  this results in the thread going to sleep, causing a hang during boot.
  
  Reviewed by:  jkim, kib
  Approved by:  re (gjb)
  Sponsored by: EMC / Isilon Storage Division
  Differential Revision:https://reviews.freebsd.org/D6945

Modified:
  head/sys/x86/acpica/acpi_wakeup.c

Modified: head/sys/x86/acpica/acpi_wakeup.c
==
--- head/sys/x86/acpica/acpi_wakeup.c   Thu Jun 23 19:19:44 2016
(r302146)
+++ head/sys/x86/acpica/acpi_wakeup.c   Thu Jun 23 19:24:38 2016
(r302147)
@@ -322,7 +322,7 @@ acpi_alloc_wakeup_handler(void)
 * page-aligned.
 */
wakeaddr = contigmalloc((ACPI_PAGETABLES + 1) * PAGE_SIZE, M_DEVBUF,
-   M_WAITOK, 0x500, 0xa, PAGE_SIZE, 0ul);
+   M_NOWAIT, 0x500, 0xa, PAGE_SIZE, 0ul);
if (wakeaddr == NULL) {
printf("%s: can't alloc wake memory\n", __func__);
return (NULL);
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r302148 - head/sys/netinet

2016-06-23 Thread Michael Tuexen
Author: tuexen
Date: Thu Jun 23 19:27:29 2016
New Revision: 302148
URL: https://svnweb.freebsd.org/changeset/base/302148

Log:
  Fix a bug in the handling of non-blocking SCTP 1-to-1 sockets. When using
  this code in the userland stack, it could result in a loop. This happened on 
iOS.
  However, I was not able to reproduce this when using the code in the kernel.
  Thanks to Eugen-Andrei Gavriloaie for reporting the issue and proving detailed
  information to find the root of the problem.
  
  Approved by:  re (gjb)
  MFC after:1 week

Modified:
  head/sys/netinet/sctputil.c

Modified: head/sys/netinet/sctputil.c
==
--- head/sys/netinet/sctputil.c Thu Jun 23 19:24:38 2016(r302147)
+++ head/sys/netinet/sctputil.c Thu Jun 23 19:27:29 2016(r302148)
@@ -5274,8 +5274,14 @@ restart_nosblocks:
}
}
}
-   if ((so->so_rcv.sb_cc <= held_length) && block_allowed) {
-   /* we need to wait for data */
+   if (so->so_rcv.sb_cc <= held_length) {
+   if (so->so_error) {
+   error = so->so_error;
+   if ((in_flags & MSG_PEEK) == 0) {
+   so->so_error = 0;
+   }
+   goto out;
+   }
if ((so->so_rcv.sb_cc == 0) &&
((inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) ||
(inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL))) {
@@ -5306,51 +5312,18 @@ restart_nosblocks:
goto out;
}
}
-   error = sbwait(&so->so_rcv);
-   if (error) {
-   goto out;
-   }
-   held_length = 0;
-   goto restart_nosblocks;
-   } else if (so->so_rcv.sb_cc == 0) {
-   if (so->so_error) {
-   error = so->so_error;
-   if ((in_flags & MSG_PEEK) == 0)
-   so->so_error = 0;
-   } else {
-   if ((inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) ||
-   (inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL)) {
-   if ((inp->sctp_flags & 
SCTP_PCB_FLAGS_CONNECTED) == 0) {
-   /*
-* For active open side clear flags
-* for re-use passive open is
-* blocked by connect.
-*/
-   if (inp->sctp_flags & 
SCTP_PCB_FLAGS_WAS_ABORTED) {
-   /*
-* You were aborted, passive
-* side always hits here
-*/
-   SCTP_LTRACE_ERR_RET(inp, NULL, 
NULL, SCTP_FROM_SCTPUTIL, ECONNRESET);
-   error = ECONNRESET;
-   }
-   so->so_state &= ~(SS_ISCONNECTING |
-   SS_ISDISCONNECTING |
-   SS_ISCONFIRMING |
-   SS_ISCONNECTED);
-   if (error == 0) {
-   if ((inp->sctp_flags & 
SCTP_PCB_FLAGS_WAS_CONNECTED) == 0) {
-   
SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTPUTIL, ENOTCONN);
-   error = ENOTCONN;
-   }
-   }
-   goto out;
-   }
+   if (block_allowed) {
+   error = sbwait(&so->so_rcv);
+   if (error) {
+   goto out;
}
+   held_length = 0;
+   goto restart_nosblocks;
+   } else {
SCTP_LTRACE_ERR_RET(inp, NULL, NULL, 
SCTP_FROM_SCTPUTIL, EWOULDBLOCK);
error = EWOULDBLOCK;
+   goto out;
}
-   goto out;
}
if (hold_sblock == 1) {
SOCKBUF_UNLOCK(&so->so_rcv);
___
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: r302149 - head/etc/defaults

2016-06-23 Thread Kurt Lidl
Author: lidl
Date: Thu Jun 23 19:37:00 2016
New Revision: 302149
URL: https://svnweb.freebsd.org/changeset/base/302149

Log:
  Add support for a /etc/defaults/vendor.conf override file
  
  Reviewed by:  stas, imp
  Approved by:  re (gjb)
  Differential Revision:https://reviews.freebsd.org/D6895

Modified:
  head/etc/defaults/rc.conf

Modified: head/etc/defaults/rc.conf
==
--- head/etc/defaults/rc.conf   Thu Jun 23 19:27:29 2016(r302148)
+++ head/etc/defaults/rc.conf   Thu Jun 23 19:37:00 2016(r302149)
@@ -741,3 +741,9 @@ if [ -z "${source_rc_confs_defined}" ]; 
done
}
 fi
+
+# Allow vendors to override FreeBSD defaults in /etc/default/rc.conf
+# without the need to carefully manage /etc/rc.conf.
+if [ -r /etc/defaults/vendor.conf ]; then
+   . /etc/defaults/vendor.conf
+fi
___
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: r302150 - in head/sys: geom sys

2016-06-23 Thread Kenneth D. Merry
Author: ken
Date: Thu Jun 23 20:05:59 2016
New Revision: 302150
URL: https://svnweb.freebsd.org/changeset/base/302150

Log:
  Switch geom_disk over to using a pool mutex.
  
  The GEOM disk d_mtx is only acquired on disk creation and destruction.
  It is a good candidate for replacement with a pool mutex.  This eliminates
  the mutex initialization and teardown and the mutex and name variables
  themselves from struct disk.
  
  sys/geom/geom_disk.h:
Take d_mtx and d_mtx_name out of struct disk.
  
  sys/geom/geom_disk.c:
Use mtx_pool_lock() and mtx_pool_unlock() to guard the disk
initialization state instead of a dedicated mutex.
  
This allows removing the initialization and destruction of
d_mtx.
  
  sys/sys/param.h:
Bump __FreeBSD_version to 1100119 for the change to struct disk.
  
  Suggested by: jhb
  Sponsored by: Spectra Logic
  Approved by:  re (gjb)

Modified:
  head/sys/geom/geom_disk.c
  head/sys/geom/geom_disk.h
  head/sys/sys/param.h

Modified: head/sys/geom/geom_disk.c
==
--- head/sys/geom/geom_disk.c   Thu Jun 23 19:37:00 2016(r302149)
+++ head/sys/geom/geom_disk.c   Thu Jun 23 20:05:59 2016(r302150)
@@ -670,7 +670,7 @@ g_disk_create(void *arg, int flag)
g_topology_assert();
dp = arg;
 
-   mtx_lock(&dp->d_mtx);
+   mtx_pool_lock(mtxpool_sleep, dp);
dp->d_init_level = DISK_INIT_START;
 
/*
@@ -678,12 +678,12 @@ g_disk_create(void *arg, int flag)
 * call the user's callback to tell him we've cleaned things up.
 */
if (dp->d_goneflag != 0) {
-   mtx_unlock(&dp->d_mtx);
+   mtx_pool_unlock(mtxpool_sleep, dp);
if (dp->d_gone != NULL)
dp->d_gone(dp);
return;
}
-   mtx_unlock(&dp->d_mtx);
+   mtx_pool_unlock(mtxpool_sleep, dp);
 
sc = g_malloc(sizeof(*sc), M_WAITOK | M_ZERO);
mtx_init(&sc->start_mtx, "g_disk_start", NULL, MTX_DEF);
@@ -721,7 +721,7 @@ g_disk_create(void *arg, int flag)
dp->d_geom = gp;
g_error_provider(pp, 0);
 
-   mtx_lock(&dp->d_mtx);
+   mtx_pool_lock(mtxpool_sleep, dp);
dp->d_init_level = DISK_INIT_DONE;
 
/*
@@ -729,11 +729,11 @@ g_disk_create(void *arg, int flag)
 * process for it.
 */
if (dp->d_goneflag != 0) {
-   mtx_unlock(&dp->d_mtx);
+   mtx_pool_unlock(mtxpool_sleep, dp);
g_wither_provider(pp, ENXIO);
return;
}
-   mtx_unlock(&dp->d_mtx);
+   mtx_pool_unlock(mtxpool_sleep, dp);
 
 }
 
@@ -786,8 +786,6 @@ g_disk_destroy(void *ptr, int flag)
g_wither_geom(gp, ENXIO);
}
 
-   mtx_destroy(&dp->d_mtx);
-
g_free(dp);
 }
 
@@ -852,9 +850,6 @@ disk_create(struct disk *dp, int version
DEVSTAT_TYPE_DIRECT, DEVSTAT_PRIORITY_MAX);
dp->d_geom = NULL;
 
-   snprintf(dp->d_mtx_name, sizeof(dp->d_mtx_name), "%s%ddlk",
-dp->d_name, dp->d_unit);
-   mtx_init(&dp->d_mtx, dp->d_mtx_name, NULL, MTX_DEF);
dp->d_init_level = DISK_INIT_NONE;
 
g_disk_ident_adjust(dp->d_ident, sizeof(dp->d_ident));
@@ -878,7 +873,7 @@ disk_gone(struct disk *dp)
struct g_geom *gp;
struct g_provider *pp;
 
-   mtx_lock(&dp->d_mtx);
+   mtx_pool_lock(mtxpool_sleep, dp);
dp->d_goneflag = 1;
 
/*
@@ -897,10 +892,10 @@ disk_gone(struct disk *dp)
 * has not been fully setup in any case.
 */
if (dp->d_init_level < DISK_INIT_DONE) {
-   mtx_unlock(&dp->d_mtx);
+   mtx_pool_unlock(mtxpool_sleep, dp);
return;
}
-   mtx_unlock(&dp->d_mtx);
+   mtx_pool_unlock(mtxpool_sleep, dp);
 
gp = dp->d_geom;
if (gp != NULL) {

Modified: head/sys/geom/geom_disk.h
==
--- head/sys/geom/geom_disk.h   Thu Jun 23 19:37:00 2016(r302149)
+++ head/sys/geom/geom_disk.h   Thu Jun 23 20:05:59 2016(r302150)
@@ -72,8 +72,6 @@ struct disk {
struct devstat  *d_devstat;
int d_goneflag;
int d_destroyed;
-   struct mtx  d_mtx;
-   chard_mtx_name[24];
disk_init_level d_init_level;
 
/* Shared fields */

Modified: head/sys/sys/param.h
==
--- head/sys/sys/param.hThu Jun 23 19:37:00 2016(r302149)
+++ head/sys/sys/param.hThu Jun 23 20:05:59 2016(r302150)
@@ -58,7 +58,7 @@
  * in the range 5 to 9.
  */
 #undef __FreeBSD_version
-#define __FreeBSD_version 1100118  /* Master, propagated to newvers */
+#define __FreeBSD_version 1100

svn commit: r302151 - head/sys/kern

2016-06-23 Thread Jilles Tjoelker
Author: jilles
Date: Thu Jun 23 20:59:13 2016
New Revision: 302151
URL: https://svnweb.freebsd.org/changeset/base/302151

Log:
  posixshm: Fix lock leak when mac_posixshm_check_read rejects read.
  
  While reading the code, I noticed that shm_read() returns without unlocking
  foffset and rangelock if mac_posixshm_check_read() rejects the read.
  
  Reviewed by:  kib, jhb, rwatson
  Approved by:  re (gjb)
  MFC after:1 week
  Differential Revision:https://reviews.freebsd.org/D6927

Modified:
  head/sys/kern/uipc_shm.c

Modified: head/sys/kern/uipc_shm.c
==
--- head/sys/kern/uipc_shm.cThu Jun 23 20:05:59 2016(r302150)
+++ head/sys/kern/uipc_shm.cThu Jun 23 20:59:13 2016(r302151)
@@ -295,14 +295,14 @@ shm_read(struct file *fp, struct uio *ui
int error;
 
shmfd = fp->f_data;
-   foffset_lock_uio(fp, uio, flags);
-   rl_cookie = rangelock_rlock(&shmfd->shm_rl, uio->uio_offset,
-   uio->uio_offset + uio->uio_resid, &shmfd->shm_mtx);
 #ifdef MAC
error = mac_posixshm_check_read(active_cred, fp->f_cred, shmfd);
if (error)
return (error);
 #endif
+   foffset_lock_uio(fp, uio, flags);
+   rl_cookie = rangelock_rlock(&shmfd->shm_rl, uio->uio_offset,
+   uio->uio_offset + uio->uio_resid, &shmfd->shm_mtx);
error = uiomove_object(shmfd->shm_object, shmfd->shm_size, uio);
rangelock_unlock(&shmfd->shm_rl, rl_cookie, &shmfd->shm_mtx);
foffset_unlock_uio(fp, uio, flags);
___
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: r302152 - head

2016-06-23 Thread Brooks Davis
Author: brooks
Date: Thu Jun 23 21:02:05 2016
New Revision: 302152
URL: https://svnweb.freebsd.org/changeset/base/302152

Log:
  Add an UPDATING entry for the pipe() -> pipe2() transition.
  
  Approved by:  re (gjb)
  Sponsored by: DARPA, AFRL

Modified:
  head/UPDATING

Modified: head/UPDATING
==
--- head/UPDATING   Thu Jun 23 20:59:13 2016(r302151)
+++ head/UPDATING   Thu Jun 23 21:02:05 2016(r302152)
@@ -31,6 +31,14 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 11
disable the most expensive debugging functionality run
"ln -s 'abort:false,junk:false' /etc/malloc.conf".)
 
+20160622:
+   The the libc stub for the pipe(2) system call has been replaced with
+   a wrapper which calls the pipe2(2) system call and the pipe(2) is now
+   only implemented by the kernels which include "options
+   FREEBSD10_COMPAT" in their config file (this is the default).
+   Users should ensure that this option is enabled in their kernel
+   or upgrade userspace to r302092 before upgrading their kernel.
+
 20160527:
CAM will now strip leading spaces from SCSI disks' serial numbers.
This will effect users who create UFS filesystems on SCSI disks using
___
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: r302152 - head

2016-06-23 Thread Shawn Webb
Hey Brooks,

> On Jun 23, 2016, at 5:02 PM, Brooks Davis  wrote:
> 
> Author: brooks
> Date: Thu Jun 23 21:02:05 2016
> New Revision: 302152
> URL: https://svnweb.freebsd.org/changeset/base/302152
> 
> Log:
>  Add an UPDATING entry for the pipe() -> pipe2() transition.
> 
>  Approved by: re (gjb)
>  Sponsored by:DARPA, AFRL
> 
> Modified:
>  head/UPDATING
> 
> Modified: head/UPDATING
> ==
> --- head/UPDATING Thu Jun 23 20:59:13 2016(r302151)
> +++ head/UPDATING Thu Jun 23 21:02:05 2016(r302152)
> @@ -31,6 +31,14 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 11
>   disable the most expensive debugging functionality run
>   "ln -s 'abort:false,junk:false' /etc/malloc.conf".)
> 
> +20160622:
> + The the libc stub for the pipe(2) system call has been replaced with
> + a wrapper which calls the pipe2(2) system call and the pipe(2) is now
> + only implemented by the kernels which include "options
> + FREEBSD10_COMPAT" in their config file (this is the default).

The option is COMPAT_FREEBSD10, not FREEBSD10_COMPAT.

Shawn Webb
Cofounder and Security Engineer
HardenedBSD

GPG Key ID:  0x6A84658F52456EEE
GPG Key Fingerprint: 2ABA B6BD EF6A F486 BE89  3D9E 6A84 658F 5245 6EEE


signature.asc
Description: Message signed with OpenPGP using GPGMail


svn commit: r302153 - in head/sys: net netinet sys

2016-06-23 Thread Navdeep Parhar
Author: np
Date: Thu Jun 23 21:07:15 2016
New Revision: 302153
URL: https://svnweb.freebsd.org/changeset/base/302153

Log:
  Add spares to struct ifnet and socket for packet pacing and/or general
  use.  Update comments regarding the spare fields in struct inpcb.
  
  Bump __FreeBSD_version for the changes to the size of the structures.
  
  Reviewed by:  gnn@
  Approved by:  re@ (gjb@)
  Sponsored by: Chelsio Communications

Modified:
  head/sys/net/if_var.h
  head/sys/netinet/in_pcb.h
  head/sys/sys/param.h
  head/sys/sys/socketvar.h

Modified: head/sys/net/if_var.h
==
--- head/sys/net/if_var.h   Thu Jun 23 21:02:05 2016(r302152)
+++ head/sys/net/if_var.h   Thu Jun 23 21:07:15 2016(r302153)
@@ -311,6 +311,8 @@ struct ifnet {
 * that structure can be enhanced without changing the kernel
 * binary interface.
 */
+   void*if_pspare[4];  /* packet pacing / general use */
+   int if_ispare[4];   /* packet pacing / general use */
 };
 
 /* for compatibility with other BSDs */

Modified: head/sys/netinet/in_pcb.h
==
--- head/sys/netinet/in_pcb.h   Thu Jun 23 21:02:05 2016(r302152)
+++ head/sys/netinet/in_pcb.h   Thu Jun 23 21:07:15 2016(r302153)
@@ -202,10 +202,10 @@ struct inpcb {
u_char  inp_ip_minttl;  /* (i) minimum TTL or drop */
uint32_t inp_flowid;/* (x) flow id / queue id */
u_int   inp_refcount;   /* (i) refcount */
-   void*inp_pspare[5]; /* (x) route caching / general use */
+   void*inp_pspare[5]; /* (x) packet pacing / general use */
uint32_t inp_flowtype;  /* (x) M_HASHTYPE value */
uint32_t inp_rss_listen_bucket; /* (x) overridden RSS listen bucket */
-   u_int   inp_ispare[4];  /* (x) route caching / user cookie /
+   u_int   inp_ispare[4];  /* (x) packet pacing / user cookie /
 * general use */
 
/* Local and foreign ports, local and foreign addr. */

Modified: head/sys/sys/param.h
==
--- head/sys/sys/param.hThu Jun 23 21:02:05 2016(r302152)
+++ head/sys/sys/param.hThu Jun 23 21:07:15 2016(r302153)
@@ -58,7 +58,7 @@
  * in the range 5 to 9.
  */
 #undef __FreeBSD_version
-#define __FreeBSD_version 1100119  /* Master, propagated to newvers */
+#define __FreeBSD_version 1100120  /* Master, propagated to newvers */
 
 /*
  * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD,

Modified: head/sys/sys/socketvar.h
==
--- head/sys/sys/socketvar.hThu Jun 23 21:02:05 2016(r302152)
+++ head/sys/sys/socketvar.hThu Jun 23 21:07:15 2016(r302153)
@@ -126,6 +126,9 @@ struct socket {
 */
int so_fibnum;  /* routing domain for this socket */
uint32_t so_user_cookie;
+
+   void *so_pspare[2]; /* packet pacing / general use */
+   int so_ispare[2];   /* packet pacing / general use */
 };
 
 /*
___
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: r302154 - head

2016-06-23 Thread Brooks Davis
Author: brooks
Date: Thu Jun 23 21:09:07 2016
New Revision: 302154
URL: https://svnweb.freebsd.org/changeset/base/302154

Log:
  Fix two typos in r302152.
  
  Approved by:  re (implicit)

Modified:
  head/UPDATING

Modified: head/UPDATING
==
--- head/UPDATING   Thu Jun 23 21:07:15 2016(r302153)
+++ head/UPDATING   Thu Jun 23 21:09:07 2016(r302154)
@@ -32,10 +32,10 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 11
"ln -s 'abort:false,junk:false' /etc/malloc.conf".)
 
 20160622:
-   The the libc stub for the pipe(2) system call has been replaced with
+   The libc stub for the pipe(2) system call has been replaced with
a wrapper which calls the pipe2(2) system call and the pipe(2) is now
only implemented by the kernels which include "options
-   FREEBSD10_COMPAT" in their config file (this is the default).
+   COMPAT_FREEBSD10" in their config file (this is the default).
Users should ensure that this option is enabled in their kernel
or upgrade userspace to r302092 before upgrading their kernel.
 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r302155 - head/sys/netinet

2016-06-23 Thread Bjoern A. Zeeb
Author: bz
Date: Thu Jun 23 21:32:52 2016
New Revision: 302155
URL: https://svnweb.freebsd.org/changeset/base/302155

Log:
  Try to avoid a 2nd conditional by re-writing the loop, pause, and
  escape clause another time.
  
  Submitted by: jhb
  Approved by:  re (gjb)
  MFC after:12 days

Modified:
  head/sys/netinet/tcp_subr.c

Modified: head/sys/netinet/tcp_subr.c
==
--- head/sys/netinet/tcp_subr.c Thu Jun 23 21:09:07 2016(r302154)
+++ head/sys/netinet/tcp_subr.c Thu Jun 23 21:32:52 2016(r302155)
@@ -738,13 +738,14 @@ tcp_destroy(void *unused __unused)
 * up, which means, we should be past the tcp_discardcb() calls.
 * Sleep to let all tcpcb timers really disappear and cleanup.
 */
-   do {
+   for (;;) {
INP_LIST_RLOCK(&V_tcbinfo);
n = V_tcbinfo.ipi_count;
INP_LIST_RUNLOCK(&V_tcbinfo);
-   if (n != 0)
-   pause("tcpdes", hz / 10);
-   } while (n != 0);
+   if (n == 0)
+   break;
+   pause("tcpdes", hz / 10);
+   }
tcp_hc_destroy();
syncache_destroy();
tcp_tw_destroy();
___
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: r302092 - in head/lib/libc: aarch64/sys amd64/sys arm/sys i386/sys mips/sys powerpc/sys powerpc64/sys riscv/sys sparc64/sys sys

2016-06-23 Thread Jilles Tjoelker
On Wed, Jun 22, 2016 at 09:11:27PM +, Brooks Davis wrote:
> Author: brooks
> Date: Wed Jun 22 21:11:27 2016
> New Revision: 302092
> URL: https://svnweb.freebsd.org/changeset/base/302092

> Log:
>   Replace use of the pipe(2) system call with pipe2(2) with a zero flags
>   value.

>   This eliminates the need for machine dependant assembly wrappers for
>   pipe(2).

I like it.

>   It also make passing an invalid address to pipe(2) return EFAULT rather
>   than triggering a segfault.  Document this behavior (which was already
>   true for pipe2(2), but undocumented).

It is valid to promise [EFAULT] in this specific case since the kernel
undoes the call's effects when the copyout fails (by closing the
descriptors) and it seems unlikely that we will need a userland wrapper
around pipe() or pipe2() that needs to access the created file
descriptors. However, POSIX does not require it: passing invalid
pointers to functions specified by the standard is undefined behaviour.

See r241001 for some man pages where I removed the [EFAULT] condition
because it is wrong for both reasons mentioned above (something changes
even after copyout failure and userland wrappers dereference pointers).

-- 
Jilles Tjoelker
___
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: r302156 - in head/sys: net netpfil/pf

2016-06-23 Thread Bjoern A. Zeeb
Author: bz
Date: Thu Jun 23 21:34:38 2016
New Revision: 302156
URL: https://svnweb.freebsd.org/changeset/base/302156

Log:
  Update pf(4) and pflog(4) to survive basic VNET testing, which includes
  proper virtualisation, teardown, avoiding use-after-free, race conditions,
  no longer creating a thread per VNET (which could easily be a couple of
  thousand threads), gracefully ignoring global events (e.g., eventhandlers)
  on teardown, clearing various globally cached pointers and checking
  them before use.
  
  Reviewed by:  kp
  Approved by:  re (gjb)
  Sponsored by: The FreeBSD Foundation
  MFC after:2 weeks
  Differential Revision:https://reviews.freebsd.org/D6924

Modified:
  head/sys/net/pfvar.h
  head/sys/netpfil/pf/if_pflog.c
  head/sys/netpfil/pf/pf.c
  head/sys/netpfil/pf/pf_if.c
  head/sys/netpfil/pf/pf_ioctl.c

Modified: head/sys/net/pfvar.h
==
--- head/sys/net/pfvar.hThu Jun 23 21:32:52 2016(r302155)
+++ head/sys/net/pfvar.hThu Jun 23 21:34:38 2016(r302156)
@@ -835,7 +835,6 @@ typedef int pflog_packet_t(struct pfi_ki
 struct pf_ruleset *, struct pf_pdesc *, int);
 extern pflog_packet_t  *pflog_packet_ptr;
 
-#defineV_pf_end_threadsVNET(pf_end_threads)
 #endif /* _KERNEL */
 
 #definePFSYNC_FLAG_SRCNODE 0x04
@@ -1520,6 +1519,7 @@ VNET_DECLARE(uma_zone_t,   pf_state_scrub
 #defineV_pf_state_scrub_z   VNET(pf_state_scrub_z)
 
 extern void pf_purge_thread(void *);
+extern void pf_unload_vnet_purge(void);
 extern void pf_intr(void *);
 extern void pf_purge_expired_src_nodes(void);
 
@@ -1661,7 +1661,9 @@ VNET_DECLARE(struct pfi_kif *, pfi_all
 #defineV_pfi_allVNET(pfi_all)
 
 voidpfi_initialize(void);
+voidpfi_initialize_vnet(void);
 voidpfi_cleanup(void);
+voidpfi_cleanup_vnet(void);
 voidpfi_kif_ref(struct pfi_kif *);
 voidpfi_kif_unref(struct pfi_kif *);
 struct pfi_kif *pfi_kif_find(const char *);

Modified: head/sys/netpfil/pf/if_pflog.c
==
--- head/sys/netpfil/pf/if_pflog.c  Thu Jun 23 21:32:52 2016
(r302155)
+++ head/sys/netpfil/pf/if_pflog.c  Thu Jun 23 21:34:38 2016
(r302156)
@@ -91,19 +91,22 @@ static int  pflogioctl(struct ifnet *, u_
 static voidpflogstart(struct ifnet *);
 static int pflog_clone_create(struct if_clone *, int, caddr_t);
 static voidpflog_clone_destroy(struct ifnet *);
-static struct if_clone *pflog_cloner;
 
 static const char pflogname[] = "pflog";
 
-struct ifnet   *pflogifs[PFLOGIFS_MAX];/* for fast access */
+static VNET_DEFINE(struct if_clone *, pflog_cloner);
+#defineV_pflog_cloner  VNET(pflog_cloner)
+
+VNET_DEFINE(struct ifnet *, pflogifs[PFLOGIFS_MAX]);   /* for fast access */
+#defineV_pflogifs  VNET(pflogifs)
 
 static void
-pflogattach(int npflog)
+pflogattach(int npflog __unused)
 {
int i;
for (i = 0; i < PFLOGIFS_MAX; i++)
-   pflogifs[i] = NULL;
-   pflog_cloner = if_clone_simple(pflogname, pflog_clone_create,
+   V_pflogifs[i] = NULL;
+   V_pflog_cloner = if_clone_simple(pflogname, pflog_clone_create,
pflog_clone_destroy, 1);
 }
 
@@ -130,7 +133,7 @@ pflog_clone_create(struct if_clone *ifc,
 
bpfattach(ifp, DLT_PFLOG, PFLOG_HDRLEN);
 
-   pflogifs[unit] = ifp;
+   V_pflogifs[unit] = ifp;
 
return (0);
 }
@@ -141,8 +144,8 @@ pflog_clone_destroy(struct ifnet *ifp)
int i;
 
for (i = 0; i < PFLOGIFS_MAX; i++)
-   if (pflogifs[i] == ifp)
-   pflogifs[i] = NULL;
+   if (V_pflogifs[i] == ifp)
+   V_pflogifs[i] = NULL;
 
bpfdetach(ifp);
if_detach(ifp);
@@ -206,7 +209,7 @@ pflog_packet(struct pfi_kif *kif, struct
if (kif == NULL || m == NULL || rm == NULL || pd == NULL)
return ( 1);
 
-   if ((ifn = pflogifs[rm->logif]) == NULL || !ifn->if_bpf)
+   if ((ifn = V_pflogifs[rm->logif]) == NULL || !ifn->if_bpf)
return (0);
 
bzero(&hdr, sizeof(hdr));
@@ -259,6 +262,24 @@ pflog_packet(struct pfi_kif *kif, struct
return (0);
 }
 
+static void
+vnet_pflog_init(const void *unused __unused)
+{
+
+   pflogattach(1);
+}
+VNET_SYSINIT(vnet_pflog_init, SI_SUB_PSEUDO, SI_ORDER_ANY,
+vnet_pflog_init, NULL);
+
+static void
+vnet_pflog_uninit(const void *unused __unused)
+{
+
+   if_clone_detach(V_pflog_cloner);
+}
+VNET_SYSUNINIT(vnet_pflog_uninit, SI_SUB_INIT_IF, SI_ORDER_SECOND,
+vnet_pflog_uninit, NULL);
+
 static int
 pflog_modevent(module_t mod, int type, void *data)
 {

svn commit: r302157 - head/sys/netpfil/pf

2016-06-23 Thread Bjoern A. Zeeb
Author: bz
Date: Thu Jun 23 21:42:43 2016
New Revision: 302157
URL: https://svnweb.freebsd.org/changeset/base/302157

Log:
  PFSTATE_NOSYNC goes onto state_flags, not sync_state;
  this prevents: panic: pfsync_delete_state: unexpected sync state 8
  
  Reviewed by:  kp
  Approved by:  re (gjb)
  MFC after:2 weeks
  Sponsored by: The FreeBSD Foundation
  Differential Revision:https://reviews.freebsd.org/D6942

Modified:
  head/sys/netpfil/pf/pf_ioctl.c

Modified: head/sys/netpfil/pf/pf_ioctl.c
==
--- head/sys/netpfil/pf/pf_ioctl.c  Thu Jun 23 21:34:38 2016
(r302156)
+++ head/sys/netpfil/pf/pf_ioctl.c  Thu Jun 23 21:42:43 2016
(r302157)
@@ -3362,7 +3362,7 @@ relock:
LIST_FOREACH(s, &ih->states, entry) {
s->timeout = PFTM_PURGE;
/* Don't send out individual delete messages. */
-   s->sync_state = PFSTATE_NOSYNC;
+   s->state_flags |= PFSTATE_NOSYNC;
pf_unlink_state(s, PF_ENTER_LOCKED);
goto relock;
}
___
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: r302160 - head/sys/netpfil/pf

2016-06-23 Thread Bjoern A. Zeeb
Author: bz
Date: Thu Jun 23 22:31:44 2016
New Revision: 302160
URL: https://svnweb.freebsd.org/changeset/base/302160

Log:
  Proerply virtualize pfsync for bringup after pf is initialized and
  teardown of VNETs once pf(4) has been shut down.
  Properly split resources into VNET_SYS(UN)INITs and one time module
  loading.
  While here cover the INET parts in the uninit callpath with proper
  #ifdefs.
  
  Approved by:  re (gjb)
  Obtained from:  projects/vnet
  MFC after:  2 weeks
  Sponsored by:   The FreeBSD Foundation

Modified:
  head/sys/netpfil/pf/if_pfsync.c

Modified: head/sys/netpfil/pf/if_pfsync.c
==
--- head/sys/netpfil/pf/if_pfsync.c Thu Jun 23 22:31:10 2016
(r302159)
+++ head/sys/netpfil/pf/if_pfsync.c Thu Jun 23 22:31:44 2016
(r302160)
@@ -78,6 +78,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -2315,71 +2316,67 @@ pfsync_pointers_uninit()
PF_RULES_WUNLOCK();
 }
 
-static int
-pfsync_init()
+static void
+vnet_pfsync_init(const void *unused __unused)
 {
-   VNET_ITERATOR_DECL(vnet_iter);
-   int error = 0;
+   int error;
 
-   VNET_LIST_RLOCK();
-   VNET_FOREACH(vnet_iter) {
-   CURVNET_SET(vnet_iter);
-   V_pfsync_cloner = if_clone_simple(pfsyncname,
-   pfsync_clone_create, pfsync_clone_destroy, 1);
-   error = swi_add(NULL, pfsyncname, pfsyncintr, V_pfsyncif,
-   SWI_NET, INTR_MPSAFE, &V_pfsync_swi_cookie);
-   CURVNET_RESTORE();
-   if (error)
-   goto fail_locked;
+   V_pfsync_cloner = if_clone_simple(pfsyncname,
+   pfsync_clone_create, pfsync_clone_destroy, 1);
+   error = swi_add(NULL, pfsyncname, pfsyncintr, V_pfsyncif,
+   SWI_NET, INTR_MPSAFE, &V_pfsync_swi_cookie);
+   if (error) {
+   if_clone_detach(V_pfsync_cloner);
+   log(LOG_INFO, "swi_add() failed in %s\n", __func__);
}
-   VNET_LIST_RUNLOCK();
+}
+VNET_SYSINIT(vnet_pfsync_init, SI_SUB_PROTO_FIREWALL, SI_ORDER_ANY,
+vnet_pfsync_init, NULL);
+
+static void
+vnet_pfsync_uninit(const void *unused __unused)
+{
+
+   if_clone_detach(V_pfsync_cloner);
+   swi_remove(V_pfsync_swi_cookie);
+}
+/*
+ * Detach after pf is gone; otherwise we might touch pfsync memory
+ * from within pf after freeing pfsync.
+ */
+VNET_SYSUNINIT(vnet_pfsync_uninit, SI_SUB_INIT_IF, SI_ORDER_SECOND,
+vnet_pfsync_uninit, NULL);
+
+static int
+pfsync_init()
+{
 #ifdef INET
+   int error;
+
error = pf_proto_register(PF_INET, &in_pfsync_protosw);
if (error)
-   goto fail;
+   return (error);
error = ipproto_register(IPPROTO_PFSYNC);
if (error) {
pf_proto_unregister(PF_INET, IPPROTO_PFSYNC, SOCK_RAW);
-   goto fail;
+   return (error);
}
 #endif
pfsync_pointers_init();
 
return (0);
-
-fail:
-   VNET_LIST_RLOCK();
-fail_locked:
-   VNET_FOREACH(vnet_iter) {
-   CURVNET_SET(vnet_iter);
-   if (V_pfsync_swi_cookie) {
-   swi_remove(V_pfsync_swi_cookie);
-   if_clone_detach(V_pfsync_cloner);
-   }
-   CURVNET_RESTORE();
-   }
-   VNET_LIST_RUNLOCK();
-
-   return (error);
 }
 
 static void
 pfsync_uninit()
 {
-   VNET_ITERATOR_DECL(vnet_iter);
 
pfsync_pointers_uninit();
 
+#ifdef INET
ipproto_unregister(IPPROTO_PFSYNC);
pf_proto_unregister(PF_INET, IPPROTO_PFSYNC, SOCK_RAW);
-   VNET_LIST_RLOCK();
-   VNET_FOREACH(vnet_iter) {
-   CURVNET_SET(vnet_iter);
-   if_clone_detach(V_pfsync_cloner);
-   swi_remove(V_pfsync_swi_cookie);
-   CURVNET_RESTORE();
-   }
-   VNET_LIST_RUNLOCK();
+#endif
 }
 
 static int
@@ -2416,6 +2413,7 @@ static moduledata_t pfsync_mod = {
 
 #define PFSYNC_MODVER 1
 
-DECLARE_MODULE(pfsync, pfsync_mod, SI_SUB_PROTO_DOMAIN, SI_ORDER_ANY);
+/* Stay on FIREWALL as we depend on pf being initialized and on inetdomain. */
+DECLARE_MODULE(pfsync, pfsync_mod, SI_SUB_PROTO_FIREWALL, SI_ORDER_ANY);
 MODULE_VERSION(pfsync, PFSYNC_MODVER);
 MODULE_DEPEND(pfsync, pf, PF_MODVER, PF_MODVER, PF_MODVER);
___
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: r302159 - head/sys/netpfil/pf

2016-06-23 Thread Bjoern A. Zeeb
Author: bz
Date: Thu Jun 23 22:31:10 2016
New Revision: 302159
URL: https://svnweb.freebsd.org/changeset/base/302159

Log:
  Make sure pflog is attached after pf is initializaed so we can
  borrow pf's lock, and also make sure pflog goes after pf is gone
  in order to avoid callouts in VNETs to an already freed instance.
  
  Reported by:Ivan Klymenko, Johan Hendriks  on current@ today
  Obtained from:  projects/vnet
  Sponsored by:   The FreeBSD Foundation
  MFC after:  13 days
  Approved by:  re (gjb)

Modified:
  head/sys/netpfil/pf/if_pflog.c

Modified: head/sys/netpfil/pf/if_pflog.c
==
--- head/sys/netpfil/pf/if_pflog.c  Thu Jun 23 21:50:52 2016
(r302158)
+++ head/sys/netpfil/pf/if_pflog.c  Thu Jun 23 22:31:10 2016
(r302159)
@@ -268,7 +268,7 @@ vnet_pflog_init(const void *unused __unu
 
pflogattach(1);
 }
-VNET_SYSINIT(vnet_pflog_init, SI_SUB_PSEUDO, SI_ORDER_ANY,
+VNET_SYSINIT(vnet_pflog_init, SI_SUB_PROTO_FIREWALL, SI_ORDER_ANY,
 vnet_pflog_init, NULL);
 
 static void
@@ -277,6 +277,10 @@ vnet_pflog_uninit(const void *unused __u
 
if_clone_detach(V_pflog_cloner);
 }
+/*
+ * Detach after pf is gone; otherwise we might touch pflog memory
+ * from within pf after freeing pflog.
+ */
 VNET_SYSUNINIT(vnet_pflog_uninit, SI_SUB_INIT_IF, SI_ORDER_SECOND,
 vnet_pflog_uninit, NULL);
 
@@ -308,6 +312,7 @@ static moduledata_t pflog_mod = { pflogn
 
 #define PFLOG_MODVER 1
 
-DECLARE_MODULE(pflog, pflog_mod, SI_SUB_PSEUDO, SI_ORDER_ANY);
+/* Do not run before pf is initialized as we depend on its locks. */
+DECLARE_MODULE(pflog, pflog_mod, SI_SUB_PROTO_FIREWALL, SI_ORDER_ANY);
 MODULE_VERSION(pflog, PFLOG_MODVER);
 MODULE_DEPEND(pflog, pf, PF_MODVER, PF_MODVER, PF_MODVER);
___
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: r302162 - head/usr.sbin/gstat

2016-06-23 Thread Alan Somers
Author: asomers
Date: Thu Jun 23 23:13:14 2016
New Revision: 302162
URL: https://svnweb.freebsd.org/changeset/base/302162

Log:
  Fix gstat's interactive f and q commands
  
  curses and libedit don't play well together. After last year's libedit
  upgrade in head, they play even less well together. This change resets some
  curses settings after they get screwed up by libedit calls. Without it,
  gstat's interactive commands require an extra "enter", screw up the terminal
  on exit, and screw up the display if the user enters an invalid filter
  string.
  
  PR:   204852
  Submitted by: Keith White
  Reviewed by:  pfg
  Approved by:  re (gjb)
  MFC after:4 weeks
  Sponsored by: Spectra Logic Corp
  Differential Revision:https://reviews.freebsd.org/D6934

Modified:
  head/usr.sbin/gstat/gstat.c

Modified: head/usr.sbin/gstat/gstat.c
==
--- head/usr.sbin/gstat/gstat.c Thu Jun 23 22:42:03 2016(r302161)
+++ head/usr.sbin/gstat/gstat.c Thu Jun 23 23:13:14 2016(r302162)
@@ -167,20 +167,6 @@ main(int argc, char **argv)
if (sq == NULL)
err(1, "geom_stats_snapshot()");
if (!flag_b) {
-   /* Setup curses */
-   initscr();
-   start_color();
-   use_default_colors();
-   pair_content(0, &cf, &cb);
-   init_pair(1, COLOR_GREEN, cb);
-   init_pair(2, COLOR_MAGENTA, cb);
-   init_pair(3, COLOR_RED, cb);
-   cbreak();
-   noecho();
-   nonl();
-   nodelay(stdscr, 1);
-   intrflush(stdscr, FALSE);
-   keypad(stdscr, TRUE);
/* Setup libedit */
hist = history_init();
if (hist == NULL)
@@ -195,6 +181,20 @@ main(int argc, char **argv)
el_set(el, EL_PROMPT, el_prompt);
if (f_s[0] != '\0')
history(hist, &hist_ev, H_ENTER, f_s);
+   /* Setup curses */
+   initscr();
+   start_color();
+   use_default_colors();
+   pair_content(0, &cf, &cb);
+   init_pair(1, COLOR_GREEN, cb);
+   init_pair(2, COLOR_MAGENTA, cb);
+   init_pair(3, COLOR_RED, cb);
+   cbreak();
+   noecho();
+   nonl();
+   nodelay(stdscr, 1);
+   intrflush(stdscr, FALSE);
+   keypad(stdscr, TRUE);
}
geom_stats_snapshot_timestamp(sq, &tq);
for (quit = 0; !quit;) {
@@ -410,12 +410,15 @@ main(int argc, char **argv)
if ((p = strchr(tmp_f_s, '\n')) != NULL)
*p = '\0';
/*
-* We have to clear since we messed up
+* Fix the terminal.  We messed up
 * curses idea of the screen by using
 * libedit.
 */
clear();
refresh();
+   cbreak();
+   noecho();
+   nonl();
if (regcomp(&tmp_f_re, tmp_f_s, REG_EXTENDED)
!= 0) {
move(0, 0);
@@ -440,8 +443,8 @@ main(int argc, char **argv)
}
 
if (!flag_b) {
-   endwin();
el_end(el);
+   endwin();
}
exit(EX_OK);
 }
___
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: r302162 - head/usr.sbin/gstat

2016-06-23 Thread Alan Somers
On Thu, Jun 23, 2016 at 5:13 PM, Alan Somers  wrote:
> Author: asomers
> Date: Thu Jun 23 23:13:14 2016
> New Revision: 302162
> URL: https://svnweb.freebsd.org/changeset/base/302162
>
> Log:
>   Fix gstat's interactive f and q commands
>
>   curses and libedit don't play well together. After last year's libedit
>   upgrade in head, they play even less well together. This change resets some
>   curses settings after they get screwed up by libedit calls. Without it,
>   gstat's interactive commands require an extra "enter", screw up the terminal
>   on exit, and screw up the display if the user enters an invalid filter
>   string.
>
>   PR:   204852
>   Submitted by: Keith White
>   Reviewed by:  pfg
>   Approved by:  re (gjb)
>   MFC after:4 weeks
>   Sponsored by: Spectra Logic Corp
>   Differential Revision:https://reviews.freebsd.org/D6934
>
> Modified:
>   head/usr.sbin/gstat/gstat.c
>

For the record, the MFC field is a mistake.  This bug does not affect
stable/9 or stable/10.
___
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: r302163 - in head/sys: cam conf

2016-06-23 Thread Warner Losh
Author: imp
Date: Thu Jun 23 23:20:58 2016
New Revision: 302163
URL: https://svnweb.freebsd.org/changeset/base/302163

Log:
  Rename CAM_NETFLIX_IOSCHED to CAM_IOSCHED_DYNAMIC to better reflect
  its nature.
  
  Approved by: re
  Reviewed By: jhb
  Differential Revision: https://reviews.freebsd.org/D6811

Modified:
  head/sys/cam/cam_iosched.c
  head/sys/conf/options

Modified: head/sys/cam/cam_iosched.c
==
--- head/sys/cam/cam_iosched.c  Thu Jun 23 23:13:14 2016(r302162)
+++ head/sys/cam/cam_iosched.c  Thu Jun 23 23:20:58 2016(r302163)
@@ -61,7 +61,7 @@ static MALLOC_DEFINE(M_CAMSCHED, "CAM I/
  * for trims.
  */
 
-#ifdef CAM_NETFLIX_IOSCHED
+#ifdef CAM_IOSCHED_DYNAMIC
 
 static int do_netflix_iosched = 1;
 TUNABLE_INT("kern.cam.do_netflix_iosched", &do_netflix_iosched);
@@ -250,7 +250,7 @@ struct cam_iosched_softc
/* scheduler flags < 16, user flags >= 16 */
uint32_tflags;
int sort_io_queue;
-#ifdef CAM_NETFLIX_IOSCHED
+#ifdef CAM_IOSCHED_DYNAMIC
int read_bias;  /* Read bias setting */
int current_read_bias;  /* Current read bias state */
int total_ticks;
@@ -269,7 +269,7 @@ struct cam_iosched_softc
 #endif
 };
 
-#ifdef CAM_NETFLIX_IOSCHED
+#ifdef CAM_IOSCHED_DYNAMIC
 /*
  * helper functions to call the limsw functions.
  */
@@ -624,7 +624,7 @@ cam_iosched_cl_maybe_steer(struct contro
/* Periph drivers set these flags to indicate work */
 #define CAM_IOSCHED_FLAG_WORK_FLAGS((0xu) << 16)
 
-#ifdef CAM_NETFLIX_IOSCHED
+#ifdef CAM_IOSCHED_DYNAMIC
 static void
 cam_iosched_io_metric_update(struct cam_iosched_softc *isc,
 sbintime_t sim_latency, int cmd, size_t size);
@@ -639,7 +639,7 @@ cam_iosched_has_flagged_work(struct cam_
 static inline int
 cam_iosched_has_io(struct cam_iosched_softc *isc)
 {
-#ifdef CAM_NETFLIX_IOSCHED
+#ifdef CAM_IOSCHED_DYNAMIC
if (do_netflix_iosched) {
struct bio *rbp = bioq_first(&isc->bio_queue);
struct bio *wbp = bioq_first(&isc->write_queue);
@@ -672,7 +672,7 @@ cam_iosched_has_more_trim(struct cam_ios
 static inline int
 cam_iosched_has_work(struct cam_iosched_softc *isc)
 {
-#ifdef CAM_NETFLIX_IOSCHED
+#ifdef CAM_IOSCHED_DYNAMIC
if (iosched_debug > 2)
printf("has work: %d %d %d\n", cam_iosched_has_io(isc),
cam_iosched_has_more_trim(isc),
@@ -684,7 +684,7 @@ cam_iosched_has_work(struct cam_iosched_
cam_iosched_has_flagged_work(isc);
 }
 
-#ifdef CAM_NETFLIX_IOSCHED
+#ifdef CAM_IOSCHED_DYNAMIC
 static void
 cam_iosched_iop_stats_init(struct cam_iosched_softc *isc, struct iop_stats 
*ios)
 {
@@ -946,14 +946,14 @@ cam_iosched_init(struct cam_iosched_soft
*iscp = malloc(sizeof(**iscp), M_CAMSCHED, M_NOWAIT | M_ZERO);
if (*iscp == NULL)
return ENOMEM;
-#ifdef CAM_NETFLIX_IOSCHED
+#ifdef CAM_IOSCHED_DYNAMIC
if (iosched_debug)
printf("CAM IOSCHEDULER Allocating entry at %p\n", *iscp);
 #endif
(*iscp)->sort_io_queue = -1;
bioq_init(&(*iscp)->bio_queue);
bioq_init(&(*iscp)->trim_queue);
-#ifdef CAM_NETFLIX_IOSCHED
+#ifdef CAM_IOSCHED_DYNAMIC
if (do_netflix_iosched) {
bioq_init(&(*iscp)->write_queue);
(*iscp)->read_bias = 100;
@@ -984,7 +984,7 @@ cam_iosched_fini(struct cam_iosched_soft
 {
if (isc) {
cam_iosched_flush(isc, NULL, ENXIO);
-#ifdef CAM_NETFLIX_IOSCHED
+#ifdef CAM_IOSCHED_DYNAMIC
cam_iosched_iop_stats_fini(&isc->read_stats);
cam_iosched_iop_stats_fini(&isc->write_stats);
cam_iosched_iop_stats_fini(&isc->trim_stats);
@@ -1009,7 +1009,7 @@ cam_iosched_fini(struct cam_iosched_soft
 void cam_iosched_sysctl_init(struct cam_iosched_softc *isc,
 struct sysctl_ctx_list *ctx, struct sysctl_oid *node)
 {
-#ifdef CAM_NETFLIX_IOSCHED
+#ifdef CAM_IOSCHED_DYNAMIC
struct sysctl_oid_list *n;
 #endif
 
@@ -1018,7 +1018,7 @@ void cam_iosched_sysctl_init(struct cam_
&isc->sort_io_queue, 0,
"Sort IO queue to try and optimise disk access patterns");
 
-#ifdef CAM_NETFLIX_IOSCHED
+#ifdef CAM_IOSCHED_DYNAMIC
if (!do_netflix_iosched)
return;
 
@@ -1060,13 +1060,13 @@ cam_iosched_flush(struct cam_iosched_sof
 {
bioq_flush(&isc->bio_queue, stp, err);
bioq_flush(&isc->trim_queue, stp, err);
-#ifdef CAM_NETFLIX_IOSCHED
+#ifdef CAM_IOSCHED_DYNAMIC
if (do_netflix_iosched)
bioq_flush(&isc->write_queue, stp, err);
 #endif
 }
 
-#ifdef CAM_NETFLIX_IOSCHED
+#ifdef CAM_IOSCHED_DYNAMIC
 static struct bio *
 cam_iosched_get_write(struct cam_iosched_softc *isc)
 {
@@ -1132,7 +1132,7 @@ void
 cam_iosched_put_back_trim(struct cam_iosched_softc *isc, st

svn commit: r302164 - head/sys/conf

2016-06-23 Thread Glen Barber
Author: gjb
Date: Fri Jun 24 00:05:45 2016
New Revision: 302164
URL: https://svnweb.freebsd.org/changeset/base/302164

Log:
  Update head to ALPHA5 in preparation of new snapshot builds.
  
  Approved by:  re (implicit)
  Sponsored by: The FreeBSD Foundation

Modified:
  head/sys/conf/newvers.sh

Modified: head/sys/conf/newvers.sh
==
--- head/sys/conf/newvers.shThu Jun 23 23:20:58 2016(r302163)
+++ head/sys/conf/newvers.shFri Jun 24 00:05:45 2016(r302164)
@@ -32,7 +32,7 @@
 
 TYPE="FreeBSD"
 REVISION="11.0"
-BRANCH="ALPHA4"
+BRANCH="ALPHA5"
 if [ -n "${BRANCH_OVERRIDE}" ]; then
BRANCH=${BRANCH_OVERRIDE}
 fi
___
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: r302165 - in stable/10/sys: amd64/include dev/hyperv/vmbus dev/hyperv/vmbus/amd64 dev/hyperv/vmbus/i386 i386/include

2016-06-23 Thread Sepherosa Ziehau
Author: sephe
Date: Fri Jun 24 01:20:33 2016
New Revision: 302165
URL: https://svnweb.freebsd.org/changeset/base/302165

Log:
  MFC 301015
  
  hyperv/vmbus: Rename ISR functions
  
  MFC after:  1 week
  Sponsored by:   Microsoft OSTC
  Differential Revision:  https://reviews.freebsd.org/D6601

Modified:
  stable/10/sys/amd64/include/apicvar.h
  stable/10/sys/dev/hyperv/vmbus/amd64/hv_vector.S
  stable/10/sys/dev/hyperv/vmbus/hv_vmbus_drv_freebsd.c
  stable/10/sys/dev/hyperv/vmbus/i386/hv_vector.S
  stable/10/sys/dev/hyperv/vmbus/vmbus_var.h
  stable/10/sys/i386/include/apicvar.h
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/amd64/include/apicvar.h
==
--- stable/10/sys/amd64/include/apicvar.h   Fri Jun 24 00:05:45 2016
(r302164)
+++ stable/10/sys/amd64/include/apicvar.h   Fri Jun 24 01:20:33 2016
(r302165)
@@ -216,7 +216,6 @@ int lapic_set_lvt_triggermode(u_int apic
 void   lapic_set_tpr(u_int vector);
 void   lapic_setup(int boot);
 void   xen_intr_handle_upcall(struct trapframe *frame);
-void   hv_vector_handler(struct trapframe *frame);
 
 #endif /* !LOCORE */
 #endif /* _MACHINE_APICVAR_H_ */

Modified: stable/10/sys/dev/hyperv/vmbus/amd64/hv_vector.S
==
--- stable/10/sys/dev/hyperv/vmbus/amd64/hv_vector.SFri Jun 24 00:05:45 
2016(r302164)
+++ stable/10/sys/dev/hyperv/vmbus/amd64/hv_vector.SFri Jun 24 01:20:33 
2016(r302165)
@@ -37,10 +37,10 @@
  */
.text
SUPERALIGN_TEXT
-IDTVEC(hv_vmbus_callback)
+IDTVEC(vmbus_isr)
PUSH_FRAME
FAKE_MCOUNT(TF_RIP(%rsp))
movq%rsp, %rdi
-   callhv_vector_handler
+   callvmbus_handle_intr
MEXITCOUNT
jmp doreti

Modified: stable/10/sys/dev/hyperv/vmbus/hv_vmbus_drv_freebsd.c
==
--- stable/10/sys/dev/hyperv/vmbus/hv_vmbus_drv_freebsd.c   Fri Jun 24 
00:05:45 2016(r302164)
+++ stable/10/sys/dev/hyperv/vmbus/hv_vmbus_drv_freebsd.c   Fri Jun 24 
01:20:33 2016(r302165)
@@ -72,7 +72,7 @@ struct vmbus_softc*vmbus_sc;
 
 static char *vmbus_ids[] = { "VMBUS", NULL };
 
-extern inthand_t IDTVEC(rsvd), IDTVEC(hv_vmbus_callback);
+extern inthand_t IDTVEC(rsvd), IDTVEC(vmbus_isr);
 
 static void
 vmbus_msg_task(void *xsc, int pending __unused)
@@ -124,8 +124,8 @@ handled:
}
 }
 
-static inline int
-hv_vmbus_isr(struct vmbus_softc *sc, struct trapframe *frame, int cpu)
+static __inline int
+vmbus_handle_intr1(struct vmbus_softc *sc, struct trapframe *frame, int cpu)
 {
hv_vmbus_message *msg, *msg_base;
 
@@ -186,7 +186,7 @@ hv_vmbus_isr(struct vmbus_softc *sc, str
 }
 
 void
-hv_vector_handler(struct trapframe *trap_frame)
+vmbus_handle_intr(struct trapframe *trap_frame)
 {
struct vmbus_softc *sc = vmbus_get_softc();
int cpu = curcpu;
@@ -201,7 +201,7 @@ hv_vector_handler(struct trapframe *trap
 */
(*VMBUS_PCPU_GET(sc, intr_cnt, cpu))++;
 
-   hv_vmbus_isr(sc, trap_frame, cpu);
+   vmbus_handle_intr1(sc, trap_frame, cpu);
 
/*
 * Enable preemption.
@@ -389,10 +389,10 @@ vmbus_vector_alloc(void)
func = ((long)ip->gd_hioffset << 16 | ip->gd_looffset);
if (func == (uintptr_t)&IDTVEC(rsvd)) {
 #ifdef __i386__
-   setidt(vector , IDTVEC(hv_vmbus_callback), 
SDT_SYS386IGT,
+   setidt(vector , IDTVEC(vmbus_isr), SDT_SYS386IGT,
SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
 #else
-   setidt(vector , IDTVEC(hv_vmbus_callback), SDT_SYSIGT,
+   setidt(vector , IDTVEC(vmbus_isr), SDT_SYSIGT,
SEL_KPL, 0);
 #endif
 

Modified: stable/10/sys/dev/hyperv/vmbus/i386/hv_vector.S
==
--- stable/10/sys/dev/hyperv/vmbus/i386/hv_vector.S Fri Jun 24 00:05:45 
2016(r302164)
+++ stable/10/sys/dev/hyperv/vmbus/i386/hv_vector.S Fri Jun 24 01:20:33 
2016(r302165)
@@ -37,13 +37,13 @@
  */
 .text
 SUPERALIGN_TEXT
-IDTVEC(hv_vmbus_callback)
+IDTVEC(vmbus_isr)
 PUSH_FRAME
 SET_KERNEL_SREGS
 cld
 FAKE_MCOUNT(TF_EIP(%esp))
 pushl   %esp
-callhv_vector_handler
+callvmbus_handle_intr
 add $4, %esp
 MEXITCOUNT
 jmp doreti

Modified: stable/10/sys/dev/hyperv/vmbus/vmbus_var.h
==
--- stable/10/sys/dev/hyperv/vmbus/vmbus_var.h  Fri Jun 24 00:05:45 2016
(r302164)
+++ stable/10/sys/dev/hyperv/vmbus/vmbus_var.h  Fri Jun 24 01:20:33 2016
(r302165)
@@ -96,6 +96,7 @@ struct trap

svn commit: r302166 - in stable/10/sys/dev/hyperv: include utilities vmbus vmbus/i386

2016-06-23 Thread Sepherosa Ziehau
Author: sephe
Date: Fri Jun 24 01:49:59 2016
New Revision: 302166
URL: https://svnweb.freebsd.org/changeset/base/302166

Log:
  MFC 301017,301018,301019,301020,301021,301022,301106
  
  301017
  hyperv/vmbus: Indentation cleanup
  
  No functional changes.
  
  MFC after:  1 week
  Sponsored by:   Microsoft OSTC
  Differential Revision:  https://reviews.freebsd.org/D6602
  
  301018
  hyperv/vmbus: Move global vmbus id array to stack.
  
  MFC after:  1 week
  Sponsored by:   Microsoft OSTC
  Differential Revision:  https://reviews.freebsd.org/D6603
  
  301019
  hyperv/vmbus: Redefine SynIC message.
  
  - Avoid unnecessary indirection.
  - Avoid bit fields.
  - Use __packed.
  
  Reviewed by:Jun Su 
  MFC after:  1 week
  Sponsored by:   Microsoft OSTC
  Differential Revision:  https://reviews.freebsd.org/D6636
  
  301020
  hyperv/vmbus: White space cleanup
  
  No functional changes
  
  MFC after:  1 week
  Sponsored by:   Microsoft OSTC
  Differential Revision:  https://reviews.freebsd.org/D6637
  
  301021
  hyperv: Move guid2str from vmbus file to hyperv file
  
  - Use uint8_t for GUID byte array.
  - Define GUID string length.
  - Break long lines.
  - Nuke unnecessary stack variable.
  
  MFC after:  1 week
  Sponsored by:   Microsoft OSTC
  Differential Revision:  https://reviews.freebsd.org/D6640
  
  301022
  hyperv/kvp: Use if_xname.
  
  MFC after:  1 week
  Sponsored by:   Microsoft OSTC
  Differential Revision:  https://reviews.freebsd.org/D6641
  
  301106
  hyperv/vmbus: Redefine event flags.
  
  - Nuke unnecessary union.
  - Avoid convoluted macro indirection.
  
  MFC after:  1 week
  Sponsored by:   Microsoft OSTC
  Differential Revision:  https://reviews.freebsd.org/D6671

Added:
  stable/10/sys/dev/hyperv/vmbus/vmbus_reg.h
 - copied, changed from r301019, head/sys/dev/hyperv/vmbus/vmbus_reg.h
Modified:
  stable/10/sys/dev/hyperv/include/hyperv.h
  stable/10/sys/dev/hyperv/utilities/hv_kvp.c
  stable/10/sys/dev/hyperv/vmbus/hv_channel_mgmt.c
  stable/10/sys/dev/hyperv/vmbus/hv_connection.c
  stable/10/sys/dev/hyperv/vmbus/hv_hv.c
  stable/10/sys/dev/hyperv/vmbus/hv_vmbus_drv_freebsd.c
  stable/10/sys/dev/hyperv/vmbus/hv_vmbus_priv.h
  stable/10/sys/dev/hyperv/vmbus/i386/hv_vector.S
  stable/10/sys/dev/hyperv/vmbus/vmbus_var.h
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/dev/hyperv/include/hyperv.h
==
--- stable/10/sys/dev/hyperv/include/hyperv.h   Fri Jun 24 01:20:33 2016
(r302165)
+++ stable/10/sys/dev/hyperv/include/hyperv.h   Fri Jun 24 01:49:59 2016
(r302166)
@@ -121,10 +121,12 @@ typedef uint8_t   hv_bool_uint8_t;
HV_ALIGN_DOWN(addr, PAGE_SIZE)) >> PAGE_SHIFT )
 
 typedef struct hv_guid {
-unsigned char data[16];
+   uint8_t data[16];
 } __packed hv_guid;
 
-int snprintf_hv_guid(char *, size_t, const hv_guid *);
+#define HYPERV_GUID_STRLEN 40
+
+inthyperv_guid2str(const struct hv_guid *, char *, size_t);
 
 #define HV_NIC_GUID\
.data = {0x63, 0x51, 0x61, 0xF8, 0x3E, 0xDF, 0xc5, 0x46,\

Modified: stable/10/sys/dev/hyperv/utilities/hv_kvp.c
==
--- stable/10/sys/dev/hyperv/utilities/hv_kvp.c Fri Jun 24 01:20:33 2016
(r302165)
+++ stable/10/sys/dev/hyperv/utilities/hv_kvp.c Fri Jun 24 01:49:59 2016
(r302166)
@@ -58,7 +58,10 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+
+#include 
 #include 
+#include 
 
 #include 
 #include 
@@ -306,8 +309,7 @@ hv_kvp_convert_utf16_ipinfo_to_utf8(stru
int UNUSED_FLAG = 1;
struct hv_device *hv_dev;   /* GUID Data Structure */
hn_softc_t *sc; /* hn softc structure  */
-   char if_name[4];
-   char buf[39];
+   char buf[HYPERV_GUID_STRLEN];
 
device_t *devs;
int devcnt;
@@ -335,11 +337,12 @@ hv_kvp_convert_utf16_ipinfo_to_utf8(stru
/* Trying to find GUID of Network Device */
hv_dev = sc->hn_dev_obj;
 
-   snprintf_hv_guid(buf, sizeof(buf), &hv_dev->device_id);
-   sprintf(if_name, "%s%d", "hn", 
device_get_unit(devs[devcnt]));
+   hyperv_guid2str(&hv_dev->device_id, buf, sizeof(buf));
 
-   if (strncmp(buf, (char 
*)umsg->body.kvp_ip_val.adapter_id, 39) == 0) {
-   strcpy((char 
*)umsg->body.kvp_ip_val.adapter_id, if_name);
+   if (strncmp(buf, (char 
*)umsg->body.kvp_ip_val.adapter_id,
+   HYPERV_GUID_STRLEN - 1) == 0) {
+   

svn commit: r302167 - in stable/10/sys: conf dev/hyperv/vmbus dev/hyperv/vmbus/amd64 dev/hyperv/vmbus/i386 modules/hyperv/vmbus

2016-06-23 Thread Sepherosa Ziehau
Author: sephe
Date: Fri Jun 24 02:06:13 2016
New Revision: 302167
URL: https://svnweb.freebsd.org/changeset/base/302167

Log:
  MFC 301113
  
  hyperv: Rename some cleaned up/almost cleaned up files
  
  MFC after:  1 week
  Sponsored by:   Microsoft OSTC

Added:
  stable/10/sys/dev/hyperv/vmbus/amd64/vmbus_vector.S
 - copied unchanged from r302166, 
stable/10/sys/dev/hyperv/vmbus/amd64/hv_vector.S
  stable/10/sys/dev/hyperv/vmbus/hyperv.c
 - copied unchanged from r302166, stable/10/sys/dev/hyperv/vmbus/hv_hv.c
  stable/10/sys/dev/hyperv/vmbus/i386/vmbus_vector.S
 - copied unchanged from r302166, 
stable/10/sys/dev/hyperv/vmbus/i386/hv_vector.S
  stable/10/sys/dev/hyperv/vmbus/vmbus.c
 - copied unchanged from r302166, 
stable/10/sys/dev/hyperv/vmbus/hv_vmbus_drv_freebsd.c
  stable/10/sys/dev/hyperv/vmbus/vmbus_et.c
 - copied unchanged from r302166, stable/10/sys/dev/hyperv/vmbus/hv_et.c
Deleted:
  stable/10/sys/dev/hyperv/vmbus/amd64/hv_vector.S
  stable/10/sys/dev/hyperv/vmbus/hv_et.c
  stable/10/sys/dev/hyperv/vmbus/hv_hv.c
  stable/10/sys/dev/hyperv/vmbus/hv_vmbus_drv_freebsd.c
  stable/10/sys/dev/hyperv/vmbus/i386/hv_vector.S
Modified:
  stable/10/sys/conf/files.amd64
  stable/10/sys/conf/files.i386
  stable/10/sys/modules/hyperv/vmbus/Makefile
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/conf/files.amd64
==
--- stable/10/sys/conf/files.amd64  Fri Jun 24 01:49:59 2016
(r302166)
+++ stable/10/sys/conf/files.amd64  Fri Jun 24 02:06:13 2016
(r302167)
@@ -274,12 +274,12 @@ dev/hyperv/utilities/hv_util.c
option
 dev/hyperv/vmbus/hv_channel.c  optionalhyperv
 dev/hyperv/vmbus/hv_channel_mgmt.c optionalhyperv
 dev/hyperv/vmbus/hv_connection.c   optionalhyperv
-dev/hyperv/vmbus/hv_hv.c   optionalhyperv
-dev/hyperv/vmbus/hv_et.c   optionalhyperv
 dev/hyperv/vmbus/hv_ring_buffer.c  optionalhyperv
-dev/hyperv/vmbus/hv_vmbus_drv_freebsd.coptional
hyperv
+dev/hyperv/vmbus/hyperv.c  optionalhyperv
 dev/hyperv/vmbus/hyperv_busdma.c   optionalhyperv
-dev/hyperv/vmbus/amd64/hv_vector.S optionalhyperv
+dev/hyperv/vmbus/vmbus.c   optionalhyperv
+dev/hyperv/vmbus/vmbus_et.coptionalhyperv
+dev/hyperv/vmbus/amd64/vmbus_vector.S  optionalhyperv
 dev/kbd/kbd.c  optionalatkbd | sc | ukbd | vt
 dev/lindev/full.c  optionallindev
 dev/lindev/lindev.coptionallindev

Modified: stable/10/sys/conf/files.i386
==
--- stable/10/sys/conf/files.i386   Fri Jun 24 01:49:59 2016
(r302166)
+++ stable/10/sys/conf/files.i386   Fri Jun 24 02:06:13 2016
(r302167)
@@ -250,12 +250,12 @@ dev/hyperv/utilities/hv_util.c
option
 dev/hyperv/vmbus/hv_channel.c  optionalhyperv
 dev/hyperv/vmbus/hv_channel_mgmt.c optionalhyperv
 dev/hyperv/vmbus/hv_connection.c   optionalhyperv
-dev/hyperv/vmbus/hv_hv.c   optionalhyperv
-dev/hyperv/vmbus/hv_et.c   optionalhyperv
 dev/hyperv/vmbus/hv_ring_buffer.c  optionalhyperv
-dev/hyperv/vmbus/hv_vmbus_drv_freebsd.coptional
hyperv
+dev/hyperv/vmbus/hyperv.c  optionalhyperv
 dev/hyperv/vmbus/hyperv_busdma.c   optionalhyperv
-dev/hyperv/vmbus/i386/hv_vector.S  optionalhyperv
+dev/hyperv/vmbus/vmbus.c   optionalhyperv
+dev/hyperv/vmbus/vmbus_et.coptionalhyperv
+dev/hyperv/vmbus/i386/vmbus_vector.S   optionalhyperv
 dev/ichwd/ichwd.c  optional ichwd
 dev/if_ndis/if_ndis.c  optional ndis
 dev/if_ndis/if_ndis_pccard.c   optional ndis pccard

Copied: stable/10/sys/dev/hyperv/vmbus/amd64/vmbus_vector.S (from r302166, 
stable/10/sys/dev/hyperv/vmbus/amd64/hv_vector.S)
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ stable/10/sys/dev/hyperv/vmbus/amd64/vmbus_vector.S Fri Jun 24 02:06:13 
2016(r302167, copy of r302166, 
stable/10/sys/dev/hyperv/vmbus/amd64/hv_vector.S)
@@ -0,0 +1,46 @@
+/*-
+ * Copyright (c) 2016 Micros

svn commit: r302168 - stable/10/lib/libc/regex

2016-06-23 Thread Pedro F. Giffuni
Author: pfg
Date: Fri Jun 24 02:24:34 2016
New Revision: 302168
URL: https://svnweb.freebsd.org/changeset/base/302168

Log:
  MFC r300683:
  libc: regexec(3) adjustment.
  
  Change the behavior of when REG_STARTEND is combined with REG_NOTBOL.
  
  From the original posting[1]:
  
  "Enable the assumption that pmatch[0].rm_so is a continuation offset
  to  a string and allows us to do a proper assessment of the character
  in  regards to it's word position ('^' or '\<'), without risking going
  into unallocated memory."
  
  This change makes us similar to how glibc handles REG_STARTEND |
  REG_NOTBOL, and is closely related to a soon-to-land fix to sed.
  
  Special thanks to Martijn van Duren and Ingo Schwarze for working
  out some consistent behaviour.
  
  Differential Revision:https://reviews.freebsd.org/D6257
  Taken from:   openbsd-tech 2016-05-24 [1]  (Martijn van Duren)

Modified:
  stable/10/lib/libc/regex/engine.c
  stable/10/lib/libc/regex/regex.3
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/lib/libc/regex/engine.c
==
--- stable/10/lib/libc/regex/engine.c   Fri Jun 24 02:06:13 2016
(r302167)
+++ stable/10/lib/libc/regex/engine.c   Fri Jun 24 02:24:34 2016
(r302168)
@@ -786,7 +786,7 @@ fast(   struct match *m,
ASSIGN(fresh, st);
SP("start", st, *p);
coldp = NULL;
-   if (start == m->beginp)
+   if (start == m->offp || (start == m->beginp && !(m->eflags®_NOTBOL)))
c = OUT;
else {
/*
@@ -891,7 +891,7 @@ slow(   struct match *m,
SP("sstart", st, *p);
st = step(m->g, startst, stopst, st, NOTHING, st);
matchp = NULL;
-   if (start == m->beginp)
+   if (start == m->offp || (start == m->beginp && !(m->eflags®_NOTBOL)))
c = OUT;
else {
/*

Modified: stable/10/lib/libc/regex/regex.3
==
--- stable/10/lib/libc/regex/regex.3Fri Jun 24 02:06:13 2016
(r302167)
+++ stable/10/lib/libc/regex/regex.3Fri Jun 24 02:24:34 2016
(r302168)
@@ -32,7 +32,7 @@
 .\"@(#)regex.3 8.4 (Berkeley) 3/20/94
 .\" $FreeBSD$
 .\"
-.Dd August 17, 2005
+.Dd May 25, 2016
 .Dt REGEX 3
 .Os
 .Sh NAME
@@ -235,11 +235,16 @@ The
 argument is the bitwise OR of zero or more of the following flags:
 .Bl -tag -width REG_STARTEND
 .It Dv REG_NOTBOL
-The first character of
-the string
-is not the beginning of a line, so the
-.Ql ^\&
-anchor should not match before it.
+The first character of the string is treated as the continuation
+of a line.
+This means that the anchors
+.Ql ^\& ,
+.Ql [[:<:]] ,
+and
+.Ql \e<
+do not match before it; but see
+.Dv REG_STARTEND
+below.
 This does not affect the behavior of newlines under
 .Dv REG_NEWLINE .
 .It Dv REG_NOTEOL
@@ -247,19 +252,16 @@ The NUL terminating
 the string
 does not end a line, so the
 .Ql $\&
-anchor should not match before it.
+anchor does not match before it.
 This does not affect the behavior of newlines under
 .Dv REG_NEWLINE .
 .It Dv REG_STARTEND
 The string is considered to start at
-.Fa string
-+
-.Fa pmatch Ns [0]. Ns Va rm_so
-and to have a terminating NUL located at
-.Fa string
-+
-.Fa pmatch Ns [0]. Ns Va rm_eo
-(there need not actually be a NUL at that location),
+.Fa string No +
+.Fa pmatch Ns [0]. Ns Fa rm_so
+and to end before the byte located at
+.Fa string No +
+.Fa pmatch Ns [0]. Ns Fa rm_eo ,
 regardless of the value of
 .Fa nmatch .
 See below for the definition of
@@ -271,13 +273,37 @@ compatible with but not specified by
 .St -p1003.2 ,
 and should be used with
 caution in software intended to be portable to other systems.
-Note that a non-zero
-.Va rm_so
-does not imply
-.Dv REG_NOTBOL ;
-.Dv REG_STARTEND
-affects only the location of the string,
-not how it is matched.
+.Pp
+Without
+.Dv REG_NOTBOL ,
+the position
+.Fa rm_so
+is considered the beginning of a line, such that
+.Ql ^
+matches before it, and the beginning of a word if there is a word
+character at this position, such that
+.Ql [[:<:]]
+and
+.Ql \e<
+match before it.
+.Pp
+With
+.Dv REG_NOTBOL ,
+the character at position
+.Fa rm_so
+is treated as the continuation of a line, and if
+.Fa rm_so
+is greater than 0, the preceding character is taken into consideration.
+If the preceding character is a newline and the regular expression was compiled
+with
+.Dv REG_NEWLINE ,
+.Ql ^
+matches before the string; if the preceding character is not a word character
+but the string starts with a word character,
+.Ql [[:<:]]
+and
+.Ql \e<
+match before the string.
 .El
 .Pp
 See
___
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: r302169 - stable/9/lib/libc/regex

2016-06-23 Thread Pedro F. Giffuni
Author: pfg
Date: Fri Jun 24 02:28:24 2016
New Revision: 302169
URL: https://svnweb.freebsd.org/changeset/base/302169

Log:
  MFC r300683:
  libc: regexec(3) adjustment.
  
  Change the behavior of when REG_STARTEND is combined with REG_NOTBOL.
  
  From the original posting[1]:
  
  "Enable the assumption that pmatch[0].rm_so is a continuation offset
  to  a string and allows us to do a proper assessment of the character
  in  regards to it's word position ('^' or '\<'), without risking going
  into unallocated memory."
  
  This change makes us similar to how glibc handles REG_STARTEND |
  REG_NOTBOL, and is closely related to a soon-to-land fix to sed.
  
  Special thanks to Martijn van Duren and Ingo Schwarze for working
  out some consistent behaviour.
  
  Differential Revision:https://reviews.freebsd.org/D6257
  Taken from:   openbsd-tech 2016-05-24 [1]  (Martijn van Duren)

Modified:
  stable/9/lib/libc/regex/engine.c
  stable/9/lib/libc/regex/regex.3
Directory Properties:
  stable/9/lib/libc/   (props changed)

Modified: stable/9/lib/libc/regex/engine.c
==
--- stable/9/lib/libc/regex/engine.cFri Jun 24 02:24:34 2016
(r302168)
+++ stable/9/lib/libc/regex/engine.cFri Jun 24 02:28:24 2016
(r302169)
@@ -786,7 +786,7 @@ fast(   struct match *m,
ASSIGN(fresh, st);
SP("start", st, *p);
coldp = NULL;
-   if (start == m->beginp)
+   if (start == m->offp || (start == m->beginp && !(m->eflags®_NOTBOL)))
c = OUT;
else {
/*
@@ -891,7 +891,7 @@ slow(   struct match *m,
SP("sstart", st, *p);
st = step(m->g, startst, stopst, st, NOTHING, st);
matchp = NULL;
-   if (start == m->beginp)
+   if (start == m->offp || (start == m->beginp && !(m->eflags®_NOTBOL)))
c = OUT;
else {
/*

Modified: stable/9/lib/libc/regex/regex.3
==
--- stable/9/lib/libc/regex/regex.3 Fri Jun 24 02:24:34 2016
(r302168)
+++ stable/9/lib/libc/regex/regex.3 Fri Jun 24 02:28:24 2016
(r302169)
@@ -32,7 +32,7 @@
 .\"@(#)regex.3 8.4 (Berkeley) 3/20/94
 .\" $FreeBSD$
 .\"
-.Dd August 17, 2005
+.Dd May 25, 2016
 .Dt REGEX 3
 .Os
 .Sh NAME
@@ -235,11 +235,16 @@ The
 argument is the bitwise OR of zero or more of the following flags:
 .Bl -tag -width REG_STARTEND
 .It Dv REG_NOTBOL
-The first character of
-the string
-is not the beginning of a line, so the
-.Ql ^\&
-anchor should not match before it.
+The first character of the string is treated as the continuation
+of a line.
+This means that the anchors
+.Ql ^\& ,
+.Ql [[:<:]] ,
+and
+.Ql \e<
+do not match before it; but see
+.Dv REG_STARTEND
+below.
 This does not affect the behavior of newlines under
 .Dv REG_NEWLINE .
 .It Dv REG_NOTEOL
@@ -247,19 +252,16 @@ The NUL terminating
 the string
 does not end a line, so the
 .Ql $\&
-anchor should not match before it.
+anchor does not match before it.
 This does not affect the behavior of newlines under
 .Dv REG_NEWLINE .
 .It Dv REG_STARTEND
 The string is considered to start at
-.Fa string
-+
-.Fa pmatch Ns [0]. Ns Va rm_so
-and to have a terminating NUL located at
-.Fa string
-+
-.Fa pmatch Ns [0]. Ns Va rm_eo
-(there need not actually be a NUL at that location),
+.Fa string No +
+.Fa pmatch Ns [0]. Ns Fa rm_so
+and to end before the byte located at
+.Fa string No +
+.Fa pmatch Ns [0]. Ns Fa rm_eo ,
 regardless of the value of
 .Fa nmatch .
 See below for the definition of
@@ -271,13 +273,37 @@ compatible with but not specified by
 .St -p1003.2 ,
 and should be used with
 caution in software intended to be portable to other systems.
-Note that a non-zero
-.Va rm_so
-does not imply
-.Dv REG_NOTBOL ;
-.Dv REG_STARTEND
-affects only the location of the string,
-not how it is matched.
+.Pp
+Without
+.Dv REG_NOTBOL ,
+the position
+.Fa rm_so
+is considered the beginning of a line, such that
+.Ql ^
+matches before it, and the beginning of a word if there is a word
+character at this position, such that
+.Ql [[:<:]]
+and
+.Ql \e<
+match before it.
+.Pp
+With
+.Dv REG_NOTBOL ,
+the character at position
+.Fa rm_so
+is treated as the continuation of a line, and if
+.Fa rm_so
+is greater than 0, the preceding character is taken into consideration.
+If the preceding character is a newline and the regular expression was compiled
+with
+.Dv REG_NEWLINE ,
+.Ql ^
+matches before the string; if the preceding character is not a word character
+but the string starts with a word character,
+.Ql [[:<:]]
+and
+.Ql \e<
+match before the string.
 .El
 .Pp
 See
___
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: r302170 - in stable/10/sys: conf dev/hyperv/vmbus dev/hyperv/vmbus/amd64 dev/hyperv/vmbus/i386 modules/hyperv/vmbus

2016-06-23 Thread Sepherosa Ziehau
Author: sephe
Date: Fri Jun 24 02:30:14 2016
New Revision: 302170
URL: https://svnweb.freebsd.org/changeset/base/302170

Log:
  MFC 301483,301484,301487,301488,301583,301588
  
  301483
  hyperv: Move machine dependent bits into machine dependent files.
  
  MFC after:  1 week
  Sponsored by:   Microsoft OSTC
  Differential Revision:  https://reviews.freebsd.org/D6701
  
  301484
  hyperv/vmbus: Define type for channel messages.
  
  And fix message processing; only channel messages are supported.
  
  MFC after:  1 week
  Sponsored by:   Microsoft OSTC
  Differential Revision:  https://reviews.freebsd.org/D6706
  
  301487
  hyperv/vmbus: Factor out channel message processing
  
  This paves the way for further cleanup.
  
  MFC after:  1 week
  Sponsored by:   Microsoft OSTC
  Differential Revision:  https://reviews.freebsd.org/D6707
  
  301488
  hyperv/vmbus: Constify channel message
  
  MFC after:  1 week
  Sponsored by:   Microsoft OSTC
  Differential Revision:  https://reviews.freebsd.org/D6708
  
  301583
  hyperv/vmbus: Busdma-fy MNF and event flags.
  
  MFC after:  1 week
  Sponsored by:   Microsoft OSTC
  Differential Revision:  https://reviews.freebsd.org/D6744
  
  301588
  hyperv/vmbus: Change tx_evtflags type to u_long to match vmbus_evtflags
  
  MFC after:  1 week
  Sponsored by:   Microsoft OSTC
  Differential Revision:  https://reviews.freebsd.org/D6745

Added:
  stable/10/sys/dev/hyperv/vmbus/amd64/hyperv_machdep.c
 - copied unchanged from r301483, 
head/sys/dev/hyperv/vmbus/amd64/hyperv_machdep.c
  stable/10/sys/dev/hyperv/vmbus/hyperv_machdep.h
 - copied unchanged from r301483, head/sys/dev/hyperv/vmbus/hyperv_machdep.h
  stable/10/sys/dev/hyperv/vmbus/i386/hyperv_machdep.c
 - copied unchanged from r301483, 
head/sys/dev/hyperv/vmbus/i386/hyperv_machdep.c
Modified:
  stable/10/sys/conf/files.amd64
  stable/10/sys/conf/files.i386
  stable/10/sys/dev/hyperv/vmbus/hv_channel.c
  stable/10/sys/dev/hyperv/vmbus/hv_channel_mgmt.c
  stable/10/sys/dev/hyperv/vmbus/hv_connection.c
  stable/10/sys/dev/hyperv/vmbus/hv_vmbus_priv.h
  stable/10/sys/dev/hyperv/vmbus/hyperv.c
  stable/10/sys/dev/hyperv/vmbus/vmbus.c
  stable/10/sys/dev/hyperv/vmbus/vmbus_reg.h
  stable/10/sys/dev/hyperv/vmbus/vmbus_var.h
  stable/10/sys/modules/hyperv/vmbus/Makefile
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/conf/files.amd64
==
--- stable/10/sys/conf/files.amd64  Fri Jun 24 02:28:24 2016
(r302169)
+++ stable/10/sys/conf/files.amd64  Fri Jun 24 02:30:14 2016
(r302170)
@@ -279,6 +279,7 @@ dev/hyperv/vmbus/hyperv.c   
optionalhy
 dev/hyperv/vmbus/hyperv_busdma.c   optionalhyperv
 dev/hyperv/vmbus/vmbus.c   optionalhyperv
 dev/hyperv/vmbus/vmbus_et.coptionalhyperv
+dev/hyperv/vmbus/amd64/hyperv_machdep.coptional
hyperv
 dev/hyperv/vmbus/amd64/vmbus_vector.S  optionalhyperv
 dev/kbd/kbd.c  optionalatkbd | sc | ukbd | vt
 dev/lindev/full.c  optionallindev

Modified: stable/10/sys/conf/files.i386
==
--- stable/10/sys/conf/files.i386   Fri Jun 24 02:28:24 2016
(r302169)
+++ stable/10/sys/conf/files.i386   Fri Jun 24 02:30:14 2016
(r302170)
@@ -255,6 +255,7 @@ dev/hyperv/vmbus/hyperv.c   
optionalhy
 dev/hyperv/vmbus/hyperv_busdma.c   optionalhyperv
 dev/hyperv/vmbus/vmbus.c   optionalhyperv
 dev/hyperv/vmbus/vmbus_et.coptionalhyperv
+dev/hyperv/vmbus/i386/hyperv_machdep.c optionalhyperv
 dev/hyperv/vmbus/i386/vmbus_vector.S   optionalhyperv
 dev/ichwd/ichwd.c  optional ichwd
 dev/if_ndis/if_ndis.c  optional ndis

Copied: stable/10/sys/dev/hyperv/vmbus/amd64/hyperv_machdep.c (from r301483, 
head/sys/dev/hyperv/vmbus/amd64/hyperv_machdep.c)
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ stable/10/sys/dev/hyperv/vmbus/amd64/hyperv_machdep.c   Fri Jun 24 
02:30:14 2016(r302170, copy of r301483, 
head/sys/dev/hyperv/vmbus/amd64/hyperv_machdep.c)
@@ -0,0 +1,43 @@
+/*-
+ * Copyright (c) 2016 Microsoft Corp.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redi