svn commit: r321179 - head/sys/dev/cxgbe/tom

2017-07-18 Thread Navdeep Parhar
Author: np
Date: Wed Jul 19 01:49:01 2017
New Revision: 321179
URL: https://svnweb.freebsd.org/changeset/base/321179

Log:
  cxgbe/t4_tom: Log more details about the newly ESTABLISHED tid to the
  trace buffer.
  
  MFC after:3 days

Modified:
  head/sys/dev/cxgbe/tom/t4_cpl_io.c

Modified: head/sys/dev/cxgbe/tom/t4_cpl_io.c
==
--- head/sys/dev/cxgbe/tom/t4_cpl_io.c  Tue Jul 18 23:35:19 2017
(r321178)
+++ head/sys/dev/cxgbe/tom/t4_cpl_io.c  Wed Jul 19 01:49:01 2017
(r321179)
@@ -385,8 +385,8 @@ make_established(struct toepcb *toep, uint32_t snd_isn
tp->t_state == TCPS_SYN_RECEIVED,
("%s: TCP state %s", __func__, tcpstates[tp->t_state]));
 
-   CTR4(KTR_CXGBE, "%s: tid %d, toep %p, inp %p",
-   __func__, toep->tid, toep, inp);
+   CTR6(KTR_CXGBE, "%s: tid %d, so %p, inp %p, tp %p, toep %p",
+   __func__, toep->tid, so, inp, tp, toep);
 
tp->t_state = TCPS_ESTABLISHED;
tp->t_starttime = ticks;
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r321178 - head/usr.sbin/bsdinstall/scripts

2017-07-18 Thread Ed Maste
Author: emaste
Date: Tue Jul 18 23:35:19 2017
New Revision: 321178
URL: https://svnweb.freebsd.org/changeset/base/321178

Log:
  bsdinstall: remove EOL whitespace

Modified:
  head/usr.sbin/bsdinstall/scripts/auto
  head/usr.sbin/bsdinstall/scripts/checksum
  head/usr.sbin/bsdinstall/scripts/keymap
  head/usr.sbin/bsdinstall/scripts/mount
  head/usr.sbin/bsdinstall/scripts/netconfig_ipv4
  head/usr.sbin/bsdinstall/scripts/netconfig_ipv6
  head/usr.sbin/bsdinstall/scripts/umount

Modified: head/usr.sbin/bsdinstall/scripts/auto
==
--- head/usr.sbin/bsdinstall/scripts/auto   Tue Jul 18 23:02:34 2017
(r321177)
+++ head/usr.sbin/bsdinstall/scripts/auto   Tue Jul 18 23:35:19 2017
(r321178)
@@ -319,7 +319,7 @@ if [ ! -z "$FETCH_DISTRIBUTIONS" ]; then
export DISTRIBUTIONS="$FETCH_DISTRIBUTIONS"
export BSDINSTALL_DISTDIR="$BSDINSTALL_FETCHDEST"
fi
-   
+
export FTP_PASSIVE_MODE=YES
# Iterate through the distribution list and set a flag if debugging
# distributions have been selected.
@@ -413,7 +413,7 @@ finalconfig() {
finalconfig
;;
"Root Password")
-   bsdinstall rootpass 
+   bsdinstall rootpass
finalconfig
;;
"Hostname")

Modified: head/usr.sbin/bsdinstall/scripts/checksum
==
--- head/usr.sbin/bsdinstall/scripts/checksum   Tue Jul 18 23:02:34 2017
(r321177)
+++ head/usr.sbin/bsdinstall/scripts/checksum   Tue Jul 18 23:35:19 2017
(r321178)
@@ -32,7 +32,7 @@ percentage=0
 for dist in $DISTRIBUTIONS; do
distname=$(basename $dist .txz)
eval "status_$distname=7"
-   
+
items=""
for i in $DISTRIBUTIONS; do
items="$items $i `eval echo \\\${status_$(basename $i 
.txz):-Pending}`"

Modified: head/usr.sbin/bsdinstall/scripts/keymap
==
--- head/usr.sbin/bsdinstall/scripts/keymap Tue Jul 18 23:02:34 2017
(r321177)
+++ head/usr.sbin/bsdinstall/scripts/keymap Tue Jul 18 23:35:19 2017
(r321178)
@@ -28,7 +28,7 @@
 # $FreeBSD$
 #
  INCLUDES
- 
+
 BSDCFG_SHARE="/usr/share/bsdconfig"
 . $BSDCFG_SHARE/common.subr || exit 1
 f_dprintf "%s: loading includes..." "$0"

Modified: head/usr.sbin/bsdinstall/scripts/mount
==
--- head/usr.sbin/bsdinstall/scripts/mount  Tue Jul 18 23:02:34 2017
(r321177)
+++ head/usr.sbin/bsdinstall/scripts/mount  Tue Jul 18 23:35:19 2017
(r321178)
@@ -33,7 +33,7 @@ cat $PATH_FSTAB | awk -v BSDINSTALL_CHROOT=$BSDINSTALL
fsname = $2;
if (fsname == "/")
fsname = ""
-   printf("%s\t%s%s\t%s\t%s\t%s\t%s\n", $1, BSDINSTALL_CHROOT, 
+   printf("%s\t%s%s\t%s\t%s\t%s\t%s\n", $1, BSDINSTALL_CHROOT,
fsname, $3, $4, $5, $6);
}
 }' > $TMP_FSTAB

Modified: head/usr.sbin/bsdinstall/scripts/netconfig_ipv4
==
--- head/usr.sbin/bsdinstall/scripts/netconfig_ipv4 Tue Jul 18 23:02:34 
2017(r321177)
+++ head/usr.sbin/bsdinstall/scripts/netconfig_ipv4 Tue Jul 18 23:35:19 
2017(r321178)
@@ -75,7 +75,7 @@ IF_CONFIG=$(dialog --backtitle 'FreeBSD Installer' --t
 if [ $? -eq $DIALOG_CANCEL ]; then exit 1; fi
 exec 3>&-
 
-echo $INTERFACE $IF_CONFIG | 
+echo $INTERFACE $IF_CONFIG |
 awk -v prefix="$IFCONFIG_PREFIX" '{
printf("ifconfig_%s=\"%s\inet %s netmask %s\"\n", $1, prefix, $2, $3);
printf("defaultrouter=\"%s\"\n", $4);

Modified: head/usr.sbin/bsdinstall/scripts/netconfig_ipv6
==
--- head/usr.sbin/bsdinstall/scripts/netconfig_ipv6 Tue Jul 18 23:02:34 
2017(r321177)
+++ head/usr.sbin/bsdinstall/scripts/netconfig_ipv6 Tue Jul 18 23:35:19 
2017(r321178)
@@ -41,9 +41,9 @@ f_include $BSDCFG_SHARE/dialog.subr
  MAIN
 
 #
-# TODO: 
+# TODO:
 # - Add DHCPv6 support once FreeBSD ships with it.
-# 
+#
 
 INTERFACE=$1
 case "${INTERFACE}" in

Modified: head/usr.sbin/bsdinstall/scripts/umount
==
--- head/usr.sbin/bsdinstall/scripts/umount Tue Jul 18 23:02:34 2017
(r321177)
+++ head/usr.sbin/bsdinstall/scripts/umount Tue Jul 18 23:35:19 2017
(r321178)
@@ -33,7 +33,7 @@ cat $PATH_FSTAB | awk -v BSDINSTALL_CHROOT=$BSDINSTALL
fsname = $2;
if (fsname == "/")
   

svn commit: r321176 - head/lib/libsysdecode

2017-07-18 Thread John Baldwin
Author: jhb
Date: Tue Jul 18 21:09:29 2017
New Revision: 321176
URL: https://svnweb.freebsd.org/changeset/base/321176

Log:
  Remove special handling for 'disk*.h'
  
  This was originally added so that only one of diskmbr.h or diskpc98.h
  was chosen and is no longer needed after PC98's removal.  However, the
  special handling was also broken as it effectively prevented the decoding
  of ioctls declared in other headers such as  or
  .

Modified:
  head/lib/libsysdecode/mkioctls

Modified: head/lib/libsysdecode/mkioctls
==
--- head/lib/libsysdecode/mkioctls  Tue Jul 18 20:46:29 2017
(r321175)
+++ head/lib/libsysdecode/mkioctls  Tue Jul 18 21:09:29 2017
(r321176)
@@ -18,13 +18,11 @@ LC_ALL=C; export LC_ALL
 ioctl_includes=$(
cd $includedir
find -H -s * -name '*.h' | \
-   egrep -v '(.*disk.*|net/pfvar|net/if_pfsync)\.h' | \
+   egrep -v '(net/pfvar|net/if_pfsync)\.h' | \
xargs egrep -l \
 '^#[   ]*define[   ]+[A-Za-z_][A-Za-z0-9_]*[   ]+_IO[^a-z0-9_]' |
awk '{printf("#include <%s>\\n", $1)}'
 )
-
-ioctl_includes="$ioctl_includes#include \\n"
 
 awk -v x="$ioctl_includes" 'BEGIN {print x}' |
$CPP -nostdinc -I$includedir -dM -DCOMPAT_43TTY - |
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r321173 - head/sys/vm

2017-07-18 Thread Konstantin Belousov
Author: kib
Date: Tue Jul 18 20:26:41 2017
New Revision: 321173
URL: https://svnweb.freebsd.org/changeset/base/321173

Log:
  Convert assertion that only vmspace owner grows the stack, into a
  check blocking grow from other processes accesses.
  
  Debugger may access stack grow area with ptrace(2).  In this case,
  real state of the process is to not have the stack grown, which
  provides more accurate inspection.  Technical reason to avoid the grow
  is to avoid applying wrong process (debugger) stack limit.
  
  This change also has a consequence of making aio workers accesses past
  the bottom of stacks into EFAULT, arguably the situation is a
  programmers mistake.
  
  Reported by:  jhb
  Discussed with:   alc, jhb
  Sponsored by: The FreeBSD Foundation
  MFC after:3 days

Modified:
  head/sys/vm/vm_map.c

Modified: head/sys/vm/vm_map.c
==
--- head/sys/vm/vm_map.cTue Jul 18 19:50:02 2017(r321172)
+++ head/sys/vm/vm_map.cTue Jul 18 20:26:41 2017(r321173)
@@ -3698,7 +3698,8 @@ vm_map_growstack(vm_map_t map, vm_offset_t addr, vm_ma
 
p = curproc;
vm = p->p_vmspace;
-   MPASS(map == >p_vmspace->vm_map);
+   if (map != >p_vmspace->vm_map)
+   return (KERN_FAILURE);
MPASS(!map->system_map);
 
guard = stack_guard_page * PAGE_SIZE;
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r321172 - head/sys/arm/allwinner

2017-07-18 Thread Emmanuel Vadot
Author: manu
Date: Tue Jul 18 19:50:02 2017
New Revision: 321172
URL: https://svnweb.freebsd.org/changeset/base/321172

Log:
  Allwinner EHCI: Do not fail if we cannot get a phy
  
  If we cannot get a phy, do not detach the driver, some boards have phy
  always enabled and not exposed.
  While here do not release the clocks if we fails as we release them
  in a10_ehci_detach.
  
  Tested-on:OrangePi-One

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

Modified: head/sys/arm/allwinner/a10_ehci.c
==
--- head/sys/arm/allwinner/a10_ehci.c   Tue Jul 18 19:00:15 2017
(r321171)
+++ head/sys/arm/allwinner/a10_ehci.c   Tue Jul 18 19:50:02 2017
(r321172)
@@ -226,16 +226,13 @@ a10_ehci_attach(device_t self)
}
 
/* Enable USB PHY */
-   err = phy_get_by_ofw_name(self, 0, "usb", _sc->phy);
-   if (err != 0) {
-   device_printf(self, "Could not get phy\n");
-   goto error;
+   if (phy_get_by_ofw_name(self, 0, "usb", _sc->phy) == 0) {
+   err = phy_enable(self, aw_sc->phy);
+   if (err != 0) {
+   device_printf(self, "Could not enable phy\n");
+   goto error;
+   }
}
-   err = phy_enable(self, aw_sc->phy);
-   if (err != 0) {
-   device_printf(self, "Could not enable phy\n");
-   goto error;
-   }
 
/* Enable passby */
reg_value = A10_READ_4(sc, SW_USB_PMU_IRQ_ENABLE);
@@ -263,10 +260,6 @@ a10_ehci_attach(device_t self)
return (0);
 
 error:
-   if (aw_sc->clk != NULL) {
-   clk_disable(aw_sc->clk);
-   clk_release(aw_sc->clk);
-   }
a10_ehci_detach(self);
return (ENXIO);
 }
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r321171 - head/bin/sh

2017-07-18 Thread Jilles Tjoelker
Author: jilles
Date: Tue Jul 18 19:00:15 2017
New Revision: 321171
URL: https://svnweb.freebsd.org/changeset/base/321171

Log:
  sh: Remove broken #ifdef NOHACK code (related to sh -c).
  
  Apart from the fact that subtle syntactic changes make a poor compile-time
  option, the NOHACK case has been obviously broken since it was added,
  because it uses q uninitialized if (*p != '\0').
  
  No functional change is intended.

Modified:
  head/bin/sh/options.c

Modified: head/bin/sh/options.c
==
--- head/bin/sh/options.c   Tue Jul 18 18:56:51 2017(r321170)
+++ head/bin/sh/options.c   Tue Jul 18 19:00:15 2017(r321171)
@@ -191,16 +191,11 @@ options(int cmdline)
while ((c = *p++) != '\0') {
if (c == 'c' && cmdline) {
char *q;
-#ifdef NOHACK  /* removing this code allows sh -ce 'foo' for compat */
-   if (*p == '\0')
-#endif
-   q = *argptr++;
+
+   q = *argptr++;
if (q == NULL || minusc != NULL)
error("Bad -c option");
minusc = q;
-#ifdef NOHACK
-   break;
-#endif
} else if (c == 'o') {
minus_o(*argptr, val);
if (*argptr)
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r321138 - head/bin/dd/tests

2017-07-18 Thread Ngie Cooper
Author: ngie
Date: Tue Jul 18 17:29:12 2017
New Revision: 321138
URL: https://svnweb.freebsd.org/changeset/base/321138

Log:
  Remove unnecessary make logic added in r319339
  
  This makes the change cleaner and easier to backport to ^/stable/10.
  
  MFC after:now

Modified:
  head/bin/dd/tests/Makefile

Modified: head/bin/dd/tests/Makefile
==
--- head/bin/dd/tests/Makefile  Tue Jul 18 17:16:58 2017(r321137)
+++ head/bin/dd/tests/Makefile  Tue Jul 18 17:29:12 2017(r321138)
@@ -1,9 +1,5 @@
 # $FreeBSD$
 
-.include 
-
-.PATH: ${.CURDIR}/..
-
 ATF_TESTS_SH=  dd2_test
 NETBSD_ATF_TESTS_SH=   dd_test
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r321131 - in head/sys/arm64: arm64 include

2017-07-18 Thread Andrew Turner
Author: andrew
Date: Tue Jul 18 16:36:32 2017
New Revision: 321131
URL: https://svnweb.freebsd.org/changeset/base/321131

Log:
  Add support for passing FPU_KERN_NOCTX to fpu_kern_enter on arm64. This
  will be used to call into UEFI from the kernel.
  
  Sponsored by: DARPA, AFRL

Modified:
  head/sys/arm64/arm64/vfp.c
  head/sys/arm64/include/pcb.h
  head/sys/arm64/include/vfp.h

Modified: head/sys/arm64/arm64/vfp.c
==
--- head/sys/arm64/arm64/vfp.c  Tue Jul 18 16:27:10 2017(r321130)
+++ head/sys/arm64/arm64/vfp.c  Tue Jul 18 16:36:32 2017(r321131)
@@ -262,9 +262,29 @@ fpu_kern_enter(struct thread *td, struct fpu_kern_ctx 
struct pcb *pcb;
 
pcb = td->td_pcb;
+   KASSERT((flags & FPU_KERN_NOCTX) != 0 || ctx != NULL,
+   ("ctx is required when !FPU_KERN_NOCTX"));
KASSERT(ctx == NULL || (ctx->flags & FPU_KERN_CTX_INUSE) == 0,
("using inuse ctx"));
+   KASSERT((pcb->pcb_fpflags & PCB_FP_NOSAVE) == 0,
+   ("recursive fpu_kern_enter while in PCB_FP_NOSAVE state"));
 
+   if ((flags & FPU_KERN_NOCTX) != 0) {
+   critical_enter();
+   if (curthread == PCPU_GET(fpcurthread)) {
+   vfp_save_state(curthread, pcb);
+   PCPU_SET(fpcurthread, NULL);
+   } else {
+   KASSERT(PCPU_GET(fpcurthread) == NULL,
+   ("invalid fpcurthread"));
+   }
+
+   vfp_enable();
+   pcb->pcb_fpflags |= PCB_FP_KERN | PCB_FP_NOSAVE |
+   PCB_FP_STARTED;
+   return (0);
+   }
+
if ((flags & FPU_KERN_KTHR) != 0 && is_fpu_kern_thread(0)) {
ctx->flags = FPU_KERN_CTX_DUMMY | FPU_KERN_CTX_INUSE;
return (0);
@@ -293,19 +313,30 @@ fpu_kern_leave(struct thread *td, struct fpu_kern_ctx 
 
pcb = td->td_pcb;
 
-   KASSERT((ctx->flags & FPU_KERN_CTX_INUSE) != 0,
-   ("FPU context not inuse"));
-   ctx->flags &= ~FPU_KERN_CTX_INUSE;
+   if ((pcb->pcb_fpflags & PCB_FP_NOSAVE) != 0) {
+   KASSERT(ctx == NULL, ("non-null ctx after FPU_KERN_NOCTX"));
+   KASSERT(PCPU_GET(fpcurthread) == NULL,
+   ("non-NULL fpcurthread for PCB_FP_NOSAVE"));
+   CRITICAL_ASSERT(td);
 
-   if (is_fpu_kern_thread(0) &&
-   (ctx->flags & FPU_KERN_CTX_DUMMY) != 0)
-   return (0);
-   KASSERT((ctx->flags & FPU_KERN_CTX_DUMMY) == 0, ("dummy ctx"));
-   critical_enter();
-   vfp_discard(td);
-   critical_exit();
-   pcb->pcb_fpflags &= ~PCB_FP_STARTED;
-   pcb->pcb_fpusaved = ctx->prev;
+   vfp_disable();
+   pcb->pcb_fpflags &= ~(PCB_FP_NOSAVE | PCB_FP_STARTED);
+   critical_exit();
+   } else {
+   KASSERT((ctx->flags & FPU_KERN_CTX_INUSE) != 0,
+   ("FPU context not inuse"));
+   ctx->flags &= ~FPU_KERN_CTX_INUSE;
+
+   if (is_fpu_kern_thread(0) &&
+   (ctx->flags & FPU_KERN_CTX_DUMMY) != 0)
+   return (0);
+   KASSERT((ctx->flags & FPU_KERN_CTX_DUMMY) == 0, ("dummy ctx"));
+   critical_enter();
+   vfp_discard(td);
+   critical_exit();
+   pcb->pcb_fpflags &= ~PCB_FP_STARTED;
+   pcb->pcb_fpusaved = ctx->prev;
+   }
 
if (pcb->pcb_fpusaved == >pcb_fpustate) {
pcb->pcb_fpflags &= ~PCB_FP_KERN;

Modified: head/sys/arm64/include/pcb.h
==
--- head/sys/arm64/include/pcb.hTue Jul 18 16:27:10 2017
(r321130)
+++ head/sys/arm64/include/pcb.hTue Jul 18 16:36:32 2017
(r321131)
@@ -56,6 +56,7 @@ struct pcb {
int pcb_fpflags;
 #definePCB_FP_STARTED  0x01
 #definePCB_FP_KERN 0x02
+#definePCB_FP_NOSAVE   0x04
 /* The bits passed to userspace in get_fpcontext */
 #definePCB_FP_USERMASK (PCB_FP_STARTED)
u_int   pcb_vfpcpu; /* Last cpu this thread ran VFP code */

Modified: head/sys/arm64/include/vfp.h
==
--- head/sys/arm64/include/vfp.hTue Jul 18 16:27:10 2017
(r321130)
+++ head/sys/arm64/include/vfp.hTue Jul 18 16:36:32 2017
(r321131)
@@ -56,6 +56,7 @@ struct fpu_kern_ctx;
 #defineFPU_KERN_NORMAL 0x
 #defineFPU_KERN_NOWAIT 0x0001
 #defineFPU_KERN_KTHR   0x0002
+#defineFPU_KERN_NOCTX  0x0004
 
 struct fpu_kern_ctx *fpu_kern_alloc_ctx(u_int);
 void fpu_kern_free_ctx(struct fpu_kern_ctx *);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, 

Re: svn commit: r320901 - in head/sys: amd64/amd64 isa x86/isa

2017-07-18 Thread Ian Lepore
On Tue, 2017-07-18 at 18:08 +1000, Bruce Evans wrote:
> On Mon, 17 Jul 2017, Ian Lepore wrote:
> 
> > On Thu, 2017-07-13 at 01:42 +1000, Bruce Evans wrote:
> >> On Wed, 12 Jul 2017, Ian Lepore wrote:
> >>
> >>> Log:
> [...]
> 
> I could barely read the reply, due to corruption of whitespace to
> spaces
> and \xa0.  Formatting fixed, except all tabs are corrupted to spaces,
> and there are extra blank lines after quotes.
> 

My mail client broke two updates ago.  I think nobody who works on gui
apps does plain-text email anymore; if html mail looks good they're
done.  ::sigh::

> >
> [lots of stuff about locking and accurate time-setting]
> 
> Good idea.
> 
> My inittodr() waits for the seconds register to change.  This
> increases
> boot time by an average of 0.5 seconds, but is needed to get a result
> that is not out of date by an average of 0.5 seconds.  After the
> seconds
> register changes, the window for reading the other registers is
> almost
> 1 second, but the reads must complete in a few microseconds anyway
> else
> the result is still too out of date.  Debugging printf()s show that
> the reads usually complete in 10-50 usec with low latency (faster on
> old systems with faster ISA buses).
> 

I was considering adding a tunable to do that for people who don't mind
the extra time to boot/wakeup.  It's interesting that you label an
error of a few microseconds as "too out of date", I was thinking that
reducing the average error from .5s to .005s was good enough.

The .005s number comes from an idea of using a callout that begins as
soon as interrupts are available that checks for rtc rollover every
10ms, with the hopes that it can catch the rollover between the time
callouts start working and rootfs mount time when inittodr() gets
called.  If it can catch the rollover happening in that window, it can
latch the monotonic clock and then use that at inittodr() time to
calculate the fractional part of the time.  Even if it doesn't catch
the rollover in that time, it at least has a measurement that sets a
floor value for the fractional part, reducing the error to something
less than .5s.

I have no idea yet how much time elapses between interrupts coming
online and the first inittodr() call on a typical modern x86
system.  For all my arm systems with nfsroot it's several seconds.  If
it averages a few milliseconds on x86 systems, it isn't useful enough
to justify the extra work.  If it's typically half a second or more it
probably is worth it.

> Accuracy for reading is not very important because accuracy for
> writing
> is very low (1-2 seconds).  My resettodr() only writes if the
> difference
> is more than 2 seconds.
> 

The gross inaccuracy when writing is fixable now.  I'm not worried
about the microsecond inaccuracies of accessing the hardware, what I
want to fix is the fact that clock_settime() may get called at x.995
and will record the time as x.0.

Because settime is now called from a task thread, any clock driver is
free to sleep as needed to set the clock hardware in a way that aligns
its second rollover with kernel time.  Not efficient, but easy to do.

Even better, most rtc hardware has unused storage.  Sometimes in the
form of battery-backed ram, sometimes in the form of things like alarm
registers that aren't used for anything and a driver can tuck away
values in them for its own use.  If clock_settime() stores the
fractional part of the second in such a location, clock_gettime() can
use it to remove all of the inaccuracy that otherwise happens when the
fraction is discarded.  If even a single bit is available the error is
cut in half.  If a byte is available it drops to ~40ms.

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


svn commit: r321128 - in head: etc/rc.d share/man/man5

2017-07-18 Thread Emmanuel Vadot
Author: manu
Date: Tue Jul 18 14:02:02 2017
New Revision: 321128
URL: https://svnweb.freebsd.org/changeset/base/321128

Log:
  ipfw_netflow: Add support for FIB
  
  If ipfw_netflow_fib, the ipfw rule will only match packets in that FIB.
  
  While here correct some value in rc.conf(5) to be int and not str.
  
  Sponsored by: Gandi.net

Modified:
  head/etc/rc.d/ipfw_netflow
  head/share/man/man5/rc.conf.5

Modified: head/etc/rc.d/ipfw_netflow
==
--- head/etc/rc.d/ipfw_netflow  Tue Jul 18 08:54:35 2017(r321127)
+++ head/etc/rc.d/ipfw_netflow  Tue Jul 18 14:02:02 2017(r321128)
@@ -54,7 +54,7 @@ ipfw_netflow_status()
 ipfw_netflow_start()
 {
ipfw_netflow_is_running && err 1 "ipfw_netflow is already active"
-   ipfw add ${ipfw_netflow_rule} ngtee ${ipfw_netflow_hook} ip from any to 
any
+   ipfw add ${ipfw_netflow_rule} ngtee ${ipfw_netflow_hook} ip from any to 
any ${ipfw_netflow_fib:+fib ${ipfw_netflow_fib}}
ngctl -f - <<-EOF
mkpeer ipfw: netflow ${ipfw_netflow_hook} iface0
name ipfw:${ipfw_netflow_hook} netflow

Modified: head/share/man/man5/rc.conf.5
==
--- head/share/man/man5/rc.conf.5   Tue Jul 18 08:54:35 2017
(r321127)
+++ head/share/man/man5/rc.conf.5   Tue Jul 18 14:02:02 2017
(r321128)
@@ -602,12 +602,12 @@ By default a ipfw rule is inserted and all packets are
 the ngtee command and netflow packets are sent to 127.0.0.1 on the netflow
 port using protocol version 5.
 .It Va ipfw_netflow_hook
-.Pq Vt str
+.Pq Vt int
 netflow hook name, must be numerical
 (default
 .Pa 9995 ) .
 .It Va ipfw_netflow_rule
-.Pq Vt str
+.Pq Vt int
 ipfw rule number
 (default
 .Pa 1000 ) .
@@ -617,13 +617,18 @@ Destination server ip for receiving netflow data
 (default
 .Pa 127.0.0.1 ) .
 .It Va ipfw_netflow_port
-.Pq Vt str
+.Pq Vt int
 Destination server port for receiving netflow data
 (default
 .Pa 9995 ) .
 .It Va ipfw_netflow_version
-.Pq Vt str
+.Pq Vt int
 Do not set for using version 5 of the netflow protocol, set it to 9 for using 
version 9.
+.It Va ipfw_netflow_fib
+.Pq Vt int
+Only match packet in FIB
+.Pa ipfw_netflow_fib
+(default is undefined meaning all FIBs).
 .It Va natd_program
 .Pq Vt str
 Path to
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r320901 - in head/sys: amd64/amd64 isa x86/isa

2017-07-18 Thread Bruce Evans

On Mon, 17 Jul 2017, Konstantin Belousov wrote:


On Mon, Jul 17, 2017 at 10:29:33AM -0600, Ian Lepore wrote:

I assumed the reason the efirt code was using the same mutex that
protected access to the at rtc was because under the hood, the efi rt
clock is really the same hardware too, accessed via bios code.


EFI spec states it explicitely, e.g. in the description of the GetTime()
function of the Time Services interface:

During runtime, if a PC-AT CMOS device is present in the platform the
caller must synchronize access to the device before calling GetTime().


The clock_lock mutex still protects individual cmos registers, provided
efi uses rtcin() etc., which it apparently doesn't.

The new atrtc_time_lock mutex doesn't protect even the rtc cmos
registers as a group.  Other subsystems can still access the registers
holding only their own lock or just clock_lock.  Only write accesses
would be harmful.  Read accesses do occur if rtcintr() is active, but
these only change the index register.

Even the rtc subsystem has (groups of) write accesses that are not
properly locked.  These are for (re)initializations.  Reinitializations
occur for changing the rtc rate for profiling and for resuming.  There
is no locking except possibly Giant for even the rtc_status[ab] images
vs their registers.  Giant locking might work for that, but it doesn't
work for settime() calling rtc code, at least after removing Giant
from settime().

If efi accesses the rtc directly, then that is just broken and sharing the
new mutex doesn't help much.  The new mutex only prevents contention between
efi code that uses it and rtc code that use it -- that is, just the rtc
timer parts of the rtc code (as the name of the new mutex suggests).
The following remain unprotected:
- rtc initialization code
- more seriously, rtc interrupt code and rtcin()/writertc() generally.
resettodr_mtx was no better.  But further abuse of clock_lock might have
worked.  Holding clock_lock around efi_runtime->rt_gettime() calls would
prevent both rtc timer code and rtc_intr() from contending.  I can't
find rt_gettime().  I think these sources of contention are normally
inactive if efi is used, but efi can still race with rtc initialization,
the cmos driver, and possibly acpi code.

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


Re: svn commit: r320901 - in head/sys: amd64/amd64 isa x86/isa

2017-07-18 Thread Bruce Evans

On Mon, 17 Jul 2017, Ian Lepore wrote:


On Thu, 2017-07-13 at 01:42 +1000, Bruce Evans wrote:

On Wed, 12 Jul 2017, Ian Lepore wrote:


Log:
  Protect access to the AT realtime clock with its own mutex.

  The mutex protecting access to the registered realtime clock should not be
  overloaded to protect access to the atrtc hardware, which might not even be
  the registered rtc. More importantly, the resettodr mutex needs to be
  eliminated to remove locking/sleeping restrictions on clock drivers, and
  that can't happen if MD code for amd64 depends on it. This change moves the
  protection into what's really being protected: access to the atrtc date and
  time registers.


The spin mutex provided some protection against timing bugs caused by
preemption, but it is impossible to hold the mutex around the user code
that is setting the time, so both the kernel and user code should check
if the operation took too long and fail/retry if it did.



I could barely read the reply, due to corruption of whitespace to spaces
and \xa0.  Formatting fixed, except all tabs are corrupted to spaces,
and there are extra blank lines after quotes.



I can't figure out what you're talking about here.  There is no
userland code involved in any of this stuff.


I seemed to have edited out examples with pseudo-code.  Times are normally
set by userland, and there is a larger race for the userland part than the
kernel part:

decide_time_to_set();
--> Preempt to run another thread.
// Back here much later.  Could be several quanta of 10 msec each
// later.  The time to set is now wrong by a large amount.
clock_settime(CLOCK_REALTIME, ...); // further races here
// Should check here to see if the above took too long, and retry
// from the top if so.  But on slow and/or loaded systems, this
// might give endless retries.  We should hold a mutex or something
// around the whole operation to try to limit preemption.

ntpd can be configured to run at high priority (-N flag, which gives
realtime priority 0 on FreeBSD), but I haven't noticed any systems
where this is used (except mine of course).  ntpd mostly uses delta-
micor-adjustments which are not affected much by the time taken to
make the adjustment.  At least old versions of ntpd don't do anything
like the above when they set or step the time using clock_settime().
They just do the syscall.  If this gives an error of only several
milliseconds, then ntpd will correct the error eventually using
delta-micro-adjustments.

The kernel could also increase the thread's priority, but never did.
Mutexes would help a bit.  Parts of the operation are now in a critical
section, which works similarly to increasing the priority to realtime 0.
But nothing in the kernel can protect agains the race in the userland
part.

Kernel code using mutexes (of any sort) should look like the above
retry loop if the mutex has to be dropped:

// Have time to set.
again:
mtx_lock_spin(_mtx);
...
r = set_time();
mtx_unlock_spin(_mtx);
if (r != 0 || operation_took_too_long())
goto again;

If set_time() has to drop the mutex, then it might abort and return
nonzero to reach the retry at the top level, or retry or continue
itself and depend on the top level retrying if necessary.


With correct code like that, spin mutexes are still good for limiting
retries.  I think it is best to try to hold one around the entire kernel
part of the operation, and release it when sleeping at lower levels.



I'm not sure what this is about either.  The current code for getting
the atrtc has no retries.


It is too incorrect to retry.


Modified: head/sys/x86/isa/atrtc.c
==
--- head/sys/x86/isa/atrtc.c  Tue Jul 11 21:55:20 2017(r320900)
+++ head/sys/x86/isa/atrtc.c  Wed Jul 12 02:42:57 2017(r320901)
@@ -53,9 +53,17 @@ __FBSDID("$FreeBSD$");
#include
#include "clock_if.h"

+/*
+ * clock_lock protects low-level access to individual hardware registers.
+ * atrtc_time_lock protects the entire sequence of accessing multiple registers
+ * to read or write the date and time.
+ */
#define   RTC_LOCKdo { if (!kdb_active) mtx_lock_spin(_lock); 
} while (0)
#define   RTC_UNLOCK  do { if (!kdb_active) 
mtx_unlock_spin(_lock); } while (0)


This has a lot of old design and implementation bugs:
- it abuses the i8254 mutex for the rtc
- it obfuscates this using macros
- locking individual register accesses is buggy.  Register accesses need to
   be locked in groups like your new code does
- the kdb_active hack is buggy (it can't use mutexes and is unnecessarily
   non-reentrant)
The locks should be separate and statically allocated.



I've always assumed the locking of individual register access was
because rtcin() and writertc() are global functions used by other parts
of the kernel to access 

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

2017-07-18 Thread Andriy Gapon
Author: avg
Date: Tue Jul 18 07:41:38 2017
New Revision: 32
URL: https://svnweb.freebsd.org/changeset/base/32

Log:
  fix a regression in r320452, ZFS ABD import
  
  I overlooked the fact that vdev_op_io_done hook is called even if the
  actual I/O is skipped, for example, in the case of a missing vdev.
  Arguably, this could be considered an issue in the zio pipeline engine,
  but for now I am adding defensive code to check for io_bp being NULL
  along with assertions that that happens only when it can be really
  expected.
  
  PR:   220691
  Reported by:  peter, cy
  Tested by:cy
  MFC after:1 week
  X-MFC with:   r320156, r320452

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

Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c
==
--- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c Tue Jul 
18 06:57:50 2017(r321110)
+++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c Tue Jul 
18 07:41:38 2017(r32)
@@ -1090,6 +1090,14 @@ vdev_geom_io_done(zio_t *zio)
 {
struct bio *bp = zio->io_bio;
 
+   if (bp == NULL) {
+   ASSERT3S(zio->io_error, !=, 0);
+   IMPLY(zio->io_type == ZIO_TYPE_READ ||
+   zio->io_type == ZIO_TYPE_WRITE,
+   zio->io_error == ENXIO);
+   return;
+   }
+
if (zio->io_type == ZIO_TYPE_READ) {
abd_return_buf_copy(zio->io_abd, bp->bio_data, zio->io_size);
} else if (zio->io_type == ZIO_TYPE_WRITE) {
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r321109 - head/sys/kern

2017-07-18 Thread Ngie Cooper
Author: ngie
Date: Tue Jul 18 06:51:27 2017
New Revision: 321109
URL: https://svnweb.freebsd.org/changeset/base/321109

Log:
  Fix whitespace regression accidentally checked in via ^/head@r280149
  
  MFC after:now

Modified:
  head/sys/kern/subr_sbuf.c

Modified: head/sys/kern/subr_sbuf.c
==
--- head/sys/kern/subr_sbuf.c   Tue Jul 18 06:45:41 2017(r321108)
+++ head/sys/kern/subr_sbuf.c   Tue Jul 18 06:51:27 2017(r321109)
@@ -104,7 +104,7 @@ _assert_sbuf_integrity(const char *fun, struct sbuf *s
("%s called with a NULL sbuf pointer", fun));
KASSERT(s->s_buf != NULL,
("%s called with uninitialized or corrupt sbuf", fun));
-if (SBUF_ISFINISHED(s) && SBUF_NULINCLUDED(s)) {
+   if (SBUF_ISFINISHED(s) && SBUF_NULINCLUDED(s)) {
KASSERT(s->s_len <= s->s_size,
("wrote past end of sbuf (%jd >= %jd)",
(intmax_t)s->s_len, (intmax_t)s->s_size));
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r321106 - in head/sys: dev/qlnx/qlnxe modules/qlnx modules/qlnx/qlnxe

2017-07-18 Thread Ryan Libby
Author: rlibby
Date: Tue Jul 18 06:15:05 2017
New Revision: 321106
URL: https://svnweb.freebsd.org/changeset/base/321106

Log:
  qlnx: gcc build errors
  
  Propagate warning flags from kern.opts.mk and then fix minor -Werror
  issues when building with gcc from -Wredundant-decls, -Wnested-externs,
  -Wuninitialized.
  
  Reviewed by:  davidcs
  Approved by:  markj (mentor)
  Sponsored by: Dell EMC Isilon
  Differential Revision:https://reviews.freebsd.org/D11413

Modified:
  head/sys/dev/qlnx/qlnxe/ecore_hw.h
  head/sys/dev/qlnx/qlnxe/qlnx_ioctl.c
  head/sys/dev/qlnx/qlnxe/qlnx_os.c
  head/sys/modules/qlnx/Makefile
  head/sys/modules/qlnx/qlnxe/Makefile

Modified: head/sys/dev/qlnx/qlnxe/ecore_hw.h
==
--- head/sys/dev/qlnx/qlnxe/ecore_hw.h  Tue Jul 18 03:58:59 2017
(r321105)
+++ head/sys/dev/qlnx/qlnxe/ecore_hw.h  Tue Jul 18 06:15:05 2017
(r321106)
@@ -90,15 +90,6 @@ enum _dmae_cmd_crc_mask {
 #define DMAE_MAX_CLIENTS   32
 
 /**
-* @brief ecore_gtt_init - Initialize GTT windows
-*
-* @param p_hwfn
-* @param p_ptt
-*/
-void ecore_gtt_init(struct ecore_hwfn *p_hwfn,
-   struct ecore_ptt *p_ptt);
-
-/**
  * @brief ecore_ptt_invalidate - Forces all ptt entries to be re-configured
  *
  * @param p_hwfn

Modified: head/sys/dev/qlnx/qlnxe/qlnx_ioctl.c
==
--- head/sys/dev/qlnx/qlnxe/qlnx_ioctl.cTue Jul 18 03:58:59 2017
(r321105)
+++ head/sys/dev/qlnx/qlnxe/qlnx_ioctl.cTue Jul 18 06:15:05 2017
(r321106)
@@ -534,12 +534,13 @@ qlnx_get_regs(qlnx_host_t *ha, qlnx_get_regs_t *regs)
return (rval);
 }
 
+extern char qlnx_name_str[];
+extern char qlnx_ver_str[];
+
 static int
 qlnx_drv_info(qlnx_host_t *ha, qlnx_drvinfo_t *drv_info)
 {
int i;
-   extern char qlnx_name_str[];
-   extern char qlnx_ver_str[];
 
bzero(drv_info, sizeof(qlnx_drvinfo_t));
 

Modified: head/sys/dev/qlnx/qlnxe/qlnx_os.c
==
--- head/sys/dev/qlnx/qlnxe/qlnx_os.c   Tue Jul 18 03:58:59 2017
(r321105)
+++ head/sys/dev/qlnx/qlnxe/qlnx_os.c   Tue Jul 18 06:15:05 2017
(r321106)
@@ -396,7 +396,7 @@ qlnx_fp_taskqueue(void *context, int pending)
 qlnx_host_t*ha;
 struct ifnet   *ifp;
 struct mbuf*mp;
-intret;
+intret = -1;
int lro_enable;
int rx_int = 0, total_rx_count = 0;
struct thread   *cthread;

Modified: head/sys/modules/qlnx/Makefile
==
--- head/sys/modules/qlnx/Makefile  Tue Jul 18 03:58:59 2017
(r321105)
+++ head/sys/modules/qlnx/Makefile  Tue Jul 18 06:15:05 2017
(r321106)
@@ -32,6 +32,8 @@
 # $FreeBSD$
 #
 
+SYSDIR?=${SRCTOP}/sys
+.include "${SYSDIR}/conf/kern.opts.mk"
 
 SUBDIR=qlnxe
 

Modified: head/sys/modules/qlnx/qlnxe/Makefile
==
--- head/sys/modules/qlnx/qlnxe/MakefileTue Jul 18 03:58:59 2017
(r321105)
+++ head/sys/modules/qlnx/qlnxe/MakefileTue Jul 18 06:15:05 2017
(r321106)
@@ -50,7 +50,7 @@ SRCS+= device_if.h
 SRCS+= bus_if.h
 SRCS+= pci_if.h
 
-CWARNEXTRA += -Wno-cast-qual
+.include 
 
 CFLAGS += -DQLNX_DEBUG
 CFLAGS += -DECORE_PACKAGE
@@ -66,6 +66,4 @@ CFLAGS+= -I${SRCTOP}/sys/compat/linuxkpi/common/includ
 #CFLAGS += -DQLNX_QSORT_LRO
 #CFLAGS += -DQLNX_MAX_COALESCE
 
-
-.include 
-
+CWARNFLAGS+= -Wno-cast-qual
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"