svn commit: r355482 - stable/12/sbin/dhclient

2019-12-06 Thread Ed Maste
Author: emaste
Date: Sat Dec  7 03:56:36 2019
New Revision: 355482
URL: https://svnweb.freebsd.org/changeset/base/355482

Log:
  MFC r238022 (cem): dhclient: fix braino in previous bugfix r300174
  
  The previous revision missed the exact same error in a copy paste block
  of the same code in another function.  Fix the identical case, too.
  
  A DHCP client identifier is simply the hardware type (one byte)
  concatenated with the hardware address (some variable number of bytes,
  but at most 16).  Limit the size of the temporary buffer to match and
  the rest of the calculations shake out correctly.
  
  PR:   238022
  Reported by:  Young 
  Submitted by: Young 

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

Modified: stable/12/sbin/dhclient/dhclient.c
==
--- stable/12/sbin/dhclient/dhclient.c  Sat Dec  7 03:34:03 2019
(r355481)
+++ stable/12/sbin/dhclient/dhclient.c  Sat Dec  7 03:56:36 2019
(r355482)
@@ -1774,7 +1774,7 @@ make_request(struct interface_info *ip, struct client_
}
 
/* set unique client identifier */
-   char client_ident[sizeof(struct hardware)];
+   char client_ident[sizeof(ip->hw_address.haddr) + 1];
if (!options[DHO_DHCP_CLIENT_IDENTIFIER]) {
int hwlen = (ip->hw_address.hlen < sizeof(client_ident)-1) ?
ip->hw_address.hlen : sizeof(client_ident)-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: r355481 - in head/sys: powerpc/aim powerpc/booke powerpc/include powerpc/powerpc vm

2019-12-06 Thread Justin Hibbits
Author: jhibbits
Date: Sat Dec  7 03:34:03 2019
New Revision: 355481
URL: https://svnweb.freebsd.org/changeset/base/355481

Log:
  powerpc/pmap: NUMA-ize vm_page_array on powerpc
  
  Summary:
  This matches r351198 from amd64.  This only applies to AIM64 and Book-E.
  On AIM64 it short-circuits with one domain, to behave similar to
  existing.  Otherwise it will allocate 16MB huge pages to hold the page
  array, across all NUMA domains.  On the first domain it will shift the
  page array base up, to "upper-align" the page array in that domain, so
  as to reduce the number of pages from the next domain appearing in this
  domain.  After the first domain, subsequent domains will be allocated in
  full 16MB pages, until the final domain, which can be short.  This means
  some inner domains may have pages accounted in earlier domains.
  
  On Book-E the page array is setup at MMU bootstrap time so that it's
  always mapped in TLB1, on both 32-bit and 64-bit.  This reduces the TLB0
  overhead for touching the vm_page_array, which reduces up to one TLB
  miss per array access.
  
  Since page_range (vm_page_startup()) is no longer used on Book-E but is on
  32-bit AIM, mark the variable as potentially unused, rather than using a
  nasty #if defined() list.
  
  Reviewed by:  luporl
  Differential Revision:https://reviews.freebsd.org/D21449

Modified:
  head/sys/powerpc/aim/mmu_oea64.c
  head/sys/powerpc/aim/slb.c
  head/sys/powerpc/booke/pmap.c
  head/sys/powerpc/include/pmap.h
  head/sys/powerpc/include/vmparam.h
  head/sys/powerpc/powerpc/mmu_if.m
  head/sys/powerpc/powerpc/pmap_dispatch.c
  head/sys/vm/vm_page.c

Modified: head/sys/powerpc/aim/mmu_oea64.c
==
--- head/sys/powerpc/aim/mmu_oea64.cSat Dec  7 03:29:58 2019
(r355480)
+++ head/sys/powerpc/aim/mmu_oea64.cSat Dec  7 03:34:03 2019
(r355481)
@@ -309,6 +309,7 @@ static int moea64_decode_kernel_ptr(mmu_t mmu, vm_offs
 int *is_user, vm_offset_t *decoded_addr);
 static size_t moea64_scan_pmap(mmu_t mmu);
 static void *moea64_dump_pmap_init(mmu_t mmu, unsigned blkpgs);
+static void moea64_page_array_startup(mmu_t, long);
 
 
 static mmu_method_t moea64_methods[] = {
@@ -348,6 +349,7 @@ static mmu_method_t moea64_methods[] = {
MMUMETHOD(mmu_page_set_memattr, moea64_page_set_memattr),
MMUMETHOD(mmu_quick_enter_page, moea64_quick_enter_page),
MMUMETHOD(mmu_quick_remove_page, moea64_quick_remove_page),
+   MMUMETHOD(mmu_page_array_startup,   moea64_page_array_startup),
 
/* Internal interfaces */
MMUMETHOD(mmu_mapdev,   moea64_mapdev),
@@ -639,11 +641,33 @@ moea64_bootstrap_slb_prefault(vm_offset_t va, int larg
 }
 #endif
 
+static int
+moea64_kenter_large(mmu_t mmup, vm_offset_t va, vm_paddr_t pa, uint64_t attr, 
int bootstrap)
+{
+   struct pvo_entry *pvo;
+   uint64_t pte_lo;
+   int error;
+
+   pte_lo = LPTE_M;
+   pte_lo |= attr;
+
+   pvo = alloc_pvo_entry(bootstrap);
+   pvo->pvo_vaddr |= PVO_WIRED | PVO_LARGE;
+   init_pvo_entry(pvo, kernel_pmap, va);
+
+   pvo->pvo_pte.prot = VM_PROT_READ | VM_PROT_WRITE |
+   VM_PROT_EXECUTE;
+   pvo->pvo_pte.pa = pa | pte_lo;
+   error = moea64_pvo_enter(mmup, pvo, NULL, NULL);
+   if (error != 0)
+   panic("Error %d inserting large page\n", error);
+   return (0);
+}
+
 static void
 moea64_setup_direct_map(mmu_t mmup, vm_offset_t kernelstart,
 vm_offset_t kernelend)
 {
-   struct pvo_entry *pvo;
register_t msr;
vm_paddr_t pa, pkernelstart, pkernelend;
vm_offset_t size, off;
@@ -660,15 +684,6 @@ moea64_setup_direct_map(mmu_t mmup, vm_offset_t kernel
  for (pa = pregions[i].mr_start; pa < pregions[i].mr_start +
 pregions[i].mr_size; pa += moea64_large_page_size) {
pte_lo = LPTE_M;
-
-   pvo = alloc_pvo_entry(1 /* bootstrap */);
-   pvo->pvo_vaddr |= PVO_WIRED | PVO_LARGE;
-   init_pvo_entry(pvo, kernel_pmap, PHYS_TO_DMAP(pa));
-
-   /*
-* Set memory access as guarded if prefetch within
-* the page could exit the available physmem area.
-*/
if (pa & moea64_large_page_mask) {
pa &= moea64_large_page_mask;
pte_lo |= LPTE_G;
@@ -677,10 +692,7 @@ moea64_setup_direct_map(mmu_t mmup, vm_offset_t kernel
pregions[i].mr_start + pregions[i].mr_size)
pte_lo |= LPTE_G;
 
-   pvo->pvo_pte.prot = VM_PROT_READ | VM_PROT_WRITE |
-   VM_PROT_EXECUTE;
-   pvo->pvo_pte.pa = pa | pte_lo;
-   moea64_pvo_enter(mmup, pvo, NULL, NULL);
+  

svn commit: r355480 - stable/12/libexec/rc

2019-12-06 Thread Ed Maste
Author: emaste
Date: Sat Dec  7 03:29:58 2019
New Revision: 355480
URL: https://svnweb.freebsd.org/changeset/base/355480

Log:
  MFC r354446: rc.shutdown: print a newline before watchdog timeout message
  
  Previously the watchdog timeout message was appended to the last entry
  in the "Waiting for PIDS" list, resulting in a message like
  
  Waiting for PIDS: 31299 31296 90201 9020090 second watchdog timeout
  expired. Shutdown terminated.
  
  Print a newline to separate the watchdog timeout message.
  
  Also MFC 355476: rc.shutdown: kill shutdown process after logging message
  
  Move the kill -KILL $$ back to the pre-r354446 location at the end of
  the shutdown timeout handler.
  
  PR:   241072
  Sponsored by: The FreeBSD Foundation

Modified:
  stable/12/libexec/rc/rc.shutdown
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/libexec/rc/rc.shutdown
==
--- stable/12/libexec/rc/rc.shutdownSat Dec  7 01:10:38 2019
(r355479)
+++ stable/12/libexec/rc/rc.shutdownSat Dec  7 03:29:58 2019
(r355480)
@@ -72,6 +72,7 @@ if [ -n "$rcshutdown_timeout" ]; then
_msg="$rcshutdown_timeout second watchdog"
_msg="$_msg timeout expired. Shutdown terminated."
logger -t rc.shutdown "$_msg"
+   echo
echo "$_msg"
date
kill -KILL $$ >/dev/null 2>&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: r355479 - head/sys/fs/nfs

2019-12-06 Thread Rick Macklem
Author: rmacklem
Date: Sat Dec  7 01:10:38 2019
New Revision: 355479
URL: https://svnweb.freebsd.org/changeset/base/355479

Log:
  Set the XATTRSUPPORT attribute bit for NFSv4.2, always cleared for now.
  
  Since r355472 added code which clears the XATTRSUPPORT bit for non-NFSv4.2
  mounts, it is now safe to set it.
  
  There will be a series of these preliminary commits that will prepare for
  a major commit of the NFSv4.2 client/server changes currently found in
  subversion under projects/nfsv42/sys.
  This commit completes updates to nfsproto.h required by the NFSv4.2.

Modified:
  head/sys/fs/nfs/nfsproto.h

Modified: head/sys/fs/nfs/nfsproto.h
==
--- head/sys/fs/nfs/nfsproto.h  Sat Dec  7 00:53:22 2019(r355478)
+++ head/sys/fs/nfs/nfsproto.h  Sat Dec  7 01:10:38 2019(r355479)
@@ -1154,7 +1154,8 @@ struct nfsv3_sattr {
(NFSATTRBM_LAYOUTTYPE | \
NFSATTRBM_LAYOUTBLKSIZE |   \
NFSATTRBM_LAYOUTALIGNMENT | \
-   NFSATTRBM_SUPPATTREXCLCREAT)
+   NFSATTRBM_SUPPATTREXCLCREAT |   \
+   NFSATTRBM_XATTRSUPPORT)
 
 /*
  * These are the set only attributes.
___
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: r355478 - in stable: 11/usr.sbin/ntp/doc 12/usr.sbin/ntp/doc

2019-12-06 Thread Cy Schubert
Author: cy
Date: Sat Dec  7 00:53:22 2019
New Revision: 355478
URL: https://svnweb.freebsd.org/changeset/base/355478

Log:
  MFC r355388:
  
  Chase r352304. The default rlimit memlock is no memory locking.
  
  Reported by:  egypcio@

Modified:
  stable/12/usr.sbin/ntp/doc/ntp.conf.5
Directory Properties:
  stable/12/   (props changed)

Changes in other areas also in this revision:
Modified:
  stable/11/usr.sbin/ntp/doc/ntp.conf.5
Directory Properties:
  stable/11/   (props changed)

Modified: stable/12/usr.sbin/ntp/doc/ntp.conf.5
==
--- stable/12/usr.sbin/ntp/doc/ntp.conf.5   Sat Dec  7 00:51:37 2019
(r355477)
+++ stable/12/usr.sbin/ntp/doc/ntp.conf.5   Sat Dec  7 00:53:22 2019
(r355478)
@@ -2965,7 +2965,7 @@ Probably only available under Linux, this option may b
 when dropping root (the
 .Fl i
 option).
-The default is 32 megabytes on non\-Linux machines, and \-1 under Linux.
+The default is \-1.
 -1 means "do not lock the process into memory".
 0 means "lock whatever memory the process wants into memory".
 .It Cm stacksize Ar N4kPages
___
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: r355478 - in stable: 11/usr.sbin/ntp/doc 12/usr.sbin/ntp/doc

2019-12-06 Thread Cy Schubert
Author: cy
Date: Sat Dec  7 00:53:22 2019
New Revision: 355478
URL: https://svnweb.freebsd.org/changeset/base/355478

Log:
  MFC r355388:
  
  Chase r352304. The default rlimit memlock is no memory locking.
  
  Reported by:  egypcio@

Modified:
  stable/11/usr.sbin/ntp/doc/ntp.conf.5
Directory Properties:
  stable/11/   (props changed)

Changes in other areas also in this revision:
Modified:
  stable/12/usr.sbin/ntp/doc/ntp.conf.5
Directory Properties:
  stable/12/   (props changed)

Modified: stable/11/usr.sbin/ntp/doc/ntp.conf.5
==
--- stable/11/usr.sbin/ntp/doc/ntp.conf.5   Sat Dec  7 00:51:37 2019
(r355477)
+++ stable/11/usr.sbin/ntp/doc/ntp.conf.5   Sat Dec  7 00:53:22 2019
(r355478)
@@ -2965,7 +2965,7 @@ Probably only available under Linux, this option may b
 when dropping root (the
 .Fl i
 option).
-The default is 32 megabytes on non\-Linux machines, and \-1 under Linux.
+The default is \-1.
 -1 means "do not lock the process into memory".
 0 means "lock whatever memory the process wants into memory".
 .It Cm stacksize Ar N4kPages
___
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: r355477 - in stable: 11/contrib/ipfilter/man 12/contrib/ipfilter/man

2019-12-06 Thread Cy Schubert
Author: cy
Date: Sat Dec  7 00:51:37 2019
New Revision: 355477
URL: https://svnweb.freebsd.org/changeset/base/355477

Log:
  MFC r355300:
  
  Fix a typo (upto --> up to) and reword to improve word flow.

Modified:
  stable/11/contrib/ipfilter/man/ipf.5
Directory Properties:
  stable/11/   (props changed)

Changes in other areas also in this revision:
Modified:
  stable/12/contrib/ipfilter/man/ipf.5
Directory Properties:
  stable/12/   (props changed)

Modified: stable/11/contrib/ipfilter/man/ipf.5
==
--- stable/11/contrib/ipfilter/man/ipf.5Sat Dec  7 00:33:08 2019
(r355476)
+++ stable/11/contrib/ipfilter/man/ipf.5Sat Dec  7 00:51:37 2019
(r355477)
@@ -1191,7 +1191,7 @@ pass in log or-block first quick proto tcp from any \\
 .fi
 .PP
 By default, IPFilter will only log the header portion of a packet received
-on the network. A portion of the body of a packet, upto 128 bytes, can also
+on the network. Up to 128 bytes of a packet's body can also
 be logged with the body keyword. ipmon(8) will display the contents of the
 portion of the body logged in hex.
 .PP
___
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: r355477 - in stable: 11/contrib/ipfilter/man 12/contrib/ipfilter/man

2019-12-06 Thread Cy Schubert
Author: cy
Date: Sat Dec  7 00:51:37 2019
New Revision: 355477
URL: https://svnweb.freebsd.org/changeset/base/355477

Log:
  MFC r355300:
  
  Fix a typo (upto --> up to) and reword to improve word flow.

Modified:
  stable/12/contrib/ipfilter/man/ipf.5
Directory Properties:
  stable/12/   (props changed)

Changes in other areas also in this revision:
Modified:
  stable/11/contrib/ipfilter/man/ipf.5
Directory Properties:
  stable/11/   (props changed)

Modified: stable/12/contrib/ipfilter/man/ipf.5
==
--- stable/12/contrib/ipfilter/man/ipf.5Sat Dec  7 00:33:08 2019
(r355476)
+++ stable/12/contrib/ipfilter/man/ipf.5Sat Dec  7 00:51:37 2019
(r355477)
@@ -1191,7 +1191,7 @@ pass in log or-block first quick proto tcp from any \\
 .fi
 .PP
 By default, IPFilter will only log the header portion of a packet received
-on the network. A portion of the body of a packet, upto 128 bytes, can also
+on the network. Up to 128 bytes of a packet's body can also
 be logged with the body keyword. ipmon(8) will display the contents of the
 portion of the body logged in hex.
 .PP
___
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: r355476 - head/libexec/rc

2019-12-06 Thread Ed Maste
Author: emaste
Date: Sat Dec  7 00:33:08 2019
New Revision: 355476
URL: https://svnweb.freebsd.org/changeset/base/355476

Log:
  rc.shutdown: kill shutdown process after logging message
  
  Move the kill -KILL $$ back to the pre-r354446 location at the end of
  the shutdown timeout handler.
  
  MFC with: r354446

Modified:
  head/libexec/rc/rc.shutdown

Modified: head/libexec/rc/rc.shutdown
==
--- head/libexec/rc/rc.shutdown Sat Dec  7 00:28:08 2019(r355475)
+++ head/libexec/rc/rc.shutdown Sat Dec  7 00:33:08 2019(r355476)
@@ -69,13 +69,13 @@ _rcshutdown_watchdog=
 if [ -n "$rcshutdown_timeout" ]; then
debug "Initiating watchdog timer."
sleep $rcshutdown_timeout && (
-   kill -KILL $$ >/dev/null 2>&1
_msg="$rcshutdown_timeout second watchdog"
_msg="$_msg timeout expired. Shutdown terminated."
logger -t rc.shutdown "$_msg"
echo
echo "$_msg"
date
+   kill -KILL $$ >/dev/null 2>&1
) &
_rcshutdown_watchdog=$!
 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: r355475 - head/sys/x86/x86

2019-12-06 Thread Konstantin Belousov
Author: kib
Date: Sat Dec  7 00:28:08 2019
New Revision: 355475
URL: https://svnweb.freebsd.org/changeset/base/355475

Log:
  x86: Restore the critical section around whole ipi_bitmap_handler() if
  hardclock IPI is delivered.
  
  In the current code after r355311, critical section is taken only
  around hardclockintr() call, and sched_preempt() is called after the
  section is exited. If we reschedule after exit, as we typically would
  due to conditions that caused IPI, in ULE the runq tdq_ipipending is
  not cleared, which blocks generation of further preempt IPIs.
  
  Since all relatively modern (10 years) hardware has per-cpu event
  timers, restoring the critical section conditionally does not affect
  it.
  
  Reported and tested by: cy
  Diagnosed and reviewed by: jeff (previous version)
  Sponsored by: The FreeBSD Foundation
  Differential revision:https://reviews.freebsd.org/D22716

Modified:
  head/sys/x86/x86/mp_x86.c

Modified: head/sys/x86/x86/mp_x86.c
==
--- head/sys/x86/x86/mp_x86.c   Sat Dec  7 00:23:19 2019(r355474)
+++ head/sys/x86/x86/mp_x86.c   Sat Dec  7 00:28:08 2019(r355475)
@@ -1262,10 +1262,28 @@ ipi_bitmap_handler(struct trapframe frame)
u_int ipi_bitmap;
 
td = curthread;
+   ipi_bitmap = atomic_readandclear_int(_to_pcpu[cpu]->
+   pc_ipi_bitmap);
+
+   /*
+* sched_preempt() must be called to clear the pending preempt
+* IPI to enable delivery of further preempts.  However, the
+* critical section will cause extra scheduler lock thrashing
+* when used unconditionally.  Only critical_enter() if
+* hardclock must also run, which requires the section entry.
+*/
+   if (ipi_bitmap & (1 << IPI_HARDCLOCK))
+   critical_enter();
+
td->td_intr_nesting_level++;
oldframe = td->td_intr_frame;
td->td_intr_frame = 
-   ipi_bitmap = 
atomic_readandclear_int(_to_pcpu[cpu]->pc_ipi_bitmap);
+   if (ipi_bitmap & (1 << IPI_PREEMPT)) {
+#ifdef COUNT_IPIS
+   (*ipi_preempt_counts[cpu])++;
+#endif
+   sched_preempt(td);
+   }
if (ipi_bitmap & (1 << IPI_AST)) {
 #ifdef COUNT_IPIS
(*ipi_ast_counts[cpu])++;
@@ -1273,23 +1291,15 @@ ipi_bitmap_handler(struct trapframe frame)
/* Nothing to do for AST */
}
if (ipi_bitmap & (1 << IPI_HARDCLOCK)) {
-   critical_enter();
 #ifdef COUNT_IPIS
(*ipi_hardclock_counts[cpu])++;
 #endif
hardclockintr();
-   critical_exit();
}
-
-   /* Run preempt after clock handlers since it may switch. */
-   if (ipi_bitmap & (1 << IPI_PREEMPT)) {
-#ifdef COUNT_IPIS
-   (*ipi_preempt_counts[cpu])++;
-#endif
-   sched_preempt(td);
-   }
td->td_intr_frame = oldframe;
td->td_intr_nesting_level--;
+   if (ipi_bitmap & (1 << IPI_HARDCLOCK))
+   critical_exit();
 }
 
 /*
___
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: r355474 - head/sys/amd64/amd64

2019-12-06 Thread Konstantin Belousov
Author: kib
Date: Sat Dec  7 00:23:19 2019
New Revision: 355474
URL: https://svnweb.freebsd.org/changeset/base/355474

Log:
  amd64: properly set the start of the io permission bitmap for BSP
  
  ... after the initial common TSS is copied into its final location
  during PCPU reallocation.
  
  Reported by:  pho
  Sponsored by: The FreeBSD Foundation
  MFC after:1 week

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

Modified: head/sys/amd64/amd64/pmap.c
==
--- head/sys/amd64/amd64/pmap.c Fri Dec  6 23:59:23 2019(r355473)
+++ head/sys/amd64/amd64/pmap.c Sat Dec  7 00:23:19 2019(r355474)
@@ -1771,6 +1771,8 @@ pmap_bootstrap(vm_paddr_t *firstaddr)
pcpu_init(&__pcpu[0], 0, sizeof(struct pcpu));
amd64_bsp_pcpu_init1(&__pcpu[0]);
amd64_bsp_ist_init(&__pcpu[0]);
+   __pcpu[0].pc_common_tss.tss_iobase = sizeof(struct amd64tss) +
+   IOPERM_BITMAP_SIZE;
memcpy(__pcpu[0].pc_gdt, temp_bsp_pcpu.pc_gdt, NGDT *
sizeof(struct user_segment_descriptor));
gdt_segs[GPROC0_SEL].ssd_base = (uintptr_t)&__pcpu[0].pc_common_tss;
___
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: r355473 - in head/sys: amd64/linux amd64/linux32 arm64/linux compat/cloudabi32 compat/cloudabi64 compat/freebsd32 i386/linux kern

2019-12-06 Thread Brooks Davis
Author: brooks
Date: Fri Dec  6 23:59:23 2019
New Revision: 355473
URL: https://svnweb.freebsd.org/changeset/base/355473

Log:
  sysent: Reduce duplication and improve readability.
  
  Use the power of variable to avoid spelling out source and generated
  files too many times.  The previous Makefiles were hard to read, hard to
  edit, and badly formatted.
  
  Reviewed by:  kevans, emaste
  Sponsored by: DARPA, AFRL
  Differential Revision:https://reviews.freebsd.org/D22714

Modified:
  head/sys/amd64/linux/Makefile
  head/sys/amd64/linux32/Makefile
  head/sys/arm64/linux/Makefile
  head/sys/compat/cloudabi32/Makefile
  head/sys/compat/cloudabi64/Makefile
  head/sys/compat/freebsd32/Makefile
  head/sys/i386/linux/Makefile
  head/sys/kern/Makefile

Modified: head/sys/amd64/linux/Makefile
==
--- head/sys/amd64/linux/Makefile   Fri Dec  6 23:51:11 2019
(r355472)
+++ head/sys/amd64/linux/Makefile   Fri Dec  6 23:59:23 2019
(r355473)
@@ -7,11 +7,19 @@
 
 .include 
 
+MAKESYSCALLS=  ../../tools/makesyscalls.lua
+SRCS=  syscalls.conf   \
+   syscalls.master
+GENERATED= linux_proto.h   \
+   linux_syscall.h \
+   linux_syscalls.c\
+   linux_sysent.c  \
+   linux_systrace_args.c
+
 all:
@echo "make sysent only"
 
-sysent:  linux_sysent.c linux_syscall.h linux_proto.h linux_syscalls.c 
linux_systrace_args.c
+sysent: ${GENERATED}
 
-linux_sysent.c linux_syscall.h linux_proto.h linux_syscalls.c 
linux_systrace_args.c: \
-   ../../tools/makesyscalls.lua syscalls.master 
${.CURDIR}/syscalls.conf
-   ${LUA} ../../tools/makesyscalls.lua syscalls.master 
${.CURDIR}/syscalls.conf
+${GENERATED}: ${MAKESYSCALLS} ${SRCS}
+   ${LUA} ${MAKESYSCALLS} syscalls.master syscalls.conf

Modified: head/sys/amd64/linux32/Makefile
==
--- head/sys/amd64/linux32/Makefile Fri Dec  6 23:51:11 2019
(r355472)
+++ head/sys/amd64/linux32/Makefile Fri Dec  6 23:59:23 2019
(r355473)
@@ -7,11 +7,19 @@
 
 .include 
 
+MAKESYSCALLS=  ../../tools/makesyscalls.lua
+SRCS=  syscalls.conf   \
+   syscalls.master
+GENERATED= linux32_proto.h \
+   linux32_syscall.h   \
+   linux32_syscalls.c  \
+   linux32_sysent.c\
+   linux32_systrace_args.c
+
 all:
@echo "make sysent only"
 
-sysent:  linux32_sysent.c linux32_syscall.h linux32_proto.h linux32_syscalls.c 
linux32_systrace_args.c
+sysent: ${GENERATED}
 
-linux32_sysent.c linux32_syscall.h linux32_proto.h linux32_syscalls.c 
linux32_systrace_args.c: ../../tools/makesyscalls.lua \
-   syscalls.master ${.CURDIR}/syscalls.conf
-   ${LUA} ../../tools/makesyscalls.lua syscalls.master 
${.CURDIR}/syscalls.conf
+${GENERATED}: ${MAKESYSCALLS} ${SRCS}
+   ${LUA} ${MAKESYSCALLS} syscalls.master syscalls.conf

Modified: head/sys/arm64/linux/Makefile
==
--- head/sys/arm64/linux/Makefile   Fri Dec  6 23:51:11 2019
(r355472)
+++ head/sys/arm64/linux/Makefile   Fri Dec  6 23:59:23 2019
(r355473)
@@ -7,11 +7,19 @@
 
 .include 
 
+MAKESYSCALLS=  ../../tools/makesyscalls.lua
+SRCS=  syscalls.conf   \
+   syscalls.master
+GENERATED= linux_proto.h   \
+   linux_syscall.h \
+   linux_syscalls.c\
+   linux_sysent.c  \
+   linux_systrace_args.c
+
 all:
@echo "make sysent only"
 
-sysent:  linux_sysent.c linux_syscall.h linux_proto.h linux_syscalls.c 
linux_systrace_args.c
+sysent: ${GENERATED}
 
-linux_sysent.c linux_syscall.h linux_proto.h linux_syscalls.c 
linux_systrace_args.c: \
-   ../../tools/makesyscalls.lua syscalls.master 
${.CURDIR}/syscalls.conf
-   ${LUA} ../../tools/makesyscalls.lua syscalls.master 
${.CURDIR}/syscalls.conf
+${GENERATED}: ${MAKESYSCALLS} ${SRCS}
+   ${LUA} ${MAKESYSCALLS} syscalls.master syscalls.conf

Modified: head/sys/compat/cloudabi32/Makefile
==
--- head/sys/compat/cloudabi32/Makefile Fri Dec  6 23:51:11 2019
(r355472)
+++ head/sys/compat/cloudabi32/Makefile Fri Dec  6 23:59:23 2019
(r355473)
@@ -5,15 +5,20 @@
 
 .include 
 
+MAKESYSCALLS=  ../../tools/makesyscalls.lua
+SRCS=  syscalls.conf   \
+   ../../contrib/cloudabi/syscalls32.master
+GENERATED= cloudabi32_proto.h  \
+   cloudabi32_syscall.h\
+   cloudabi32_syscalls.c   \
+   cloudabi32_sysent.c \
+   cloudabi32_systrace_args.c
+
 all:
@echo 

svn commit: r355472 - head/sys/fs/nfs

2019-12-06 Thread Rick Macklem
Author: rmacklem
Date: Fri Dec  6 23:51:11 2019
New Revision: 355472
URL: https://svnweb.freebsd.org/changeset/base/355472

Log:
  Add a couple of definitions for NFSv4.2 and update macros to use them.
  
  This patch adds code to macros to clear attribute bits not supported
  by NFSv4.2. For now, these bits are never set anyhow, but this prepares
  the code for the addition of NFSv4.2 support in a future commit.
  
  There will be a series of these preliminary commits that will prepare for
  a major commit of the NFSv4.2 client/server changes currently found in
  subversion under projects/nfsv42/sys.

Modified:
  head/sys/fs/nfs/nfs.h

Modified: head/sys/fs/nfs/nfs.h
==
--- head/sys/fs/nfs/nfs.h   Fri Dec  6 23:49:37 2019(r355471)
+++ head/sys/fs/nfs/nfs.h   Fri Dec  6 23:51:11 2019(r355472)
@@ -335,6 +335,7 @@ struct nfsreferral {
 #defineLCL_NFSV41  0x0002
 #defineLCL_DONEBINDCONN0x0004
 #defineLCL_RECLAIMONEFS0x0008
+#defineLCL_NFSV42  0x0010
 
 #defineLCL_GSS LCL_KERBV   /* Or of all mechs */
 
@@ -431,6 +432,8 @@ typedef struct {
(b)->bits[1] &= ~NFSATTRBIT_NFSV41_1;   \
(b)->bits[2] &= ~NFSATTRBIT_NFSV41_2;   \
}   \
+   if (((n)->nd_flag & ND_NFSV42) == 0)\
+   (b)->bits[2] &= ~NFSATTRBIT_NFSV42_2;   \
 } while (0)
 
 #defineNFSISSET_ATTRBIT(b, p)  ((b)->bits[(p) / 32] & (1 << ((p) % 
32)))
@@ -457,6 +460,8 @@ typedef struct {
(b)->bits[1] &= ~NFSATTRBIT_NFSV41_1;   \
(b)->bits[2] &= ~NFSATTRBIT_NFSV41_2;   \
}   \
+   if (((n)->nd_flag & ND_NFSV42) == 0)\
+   (b)->bits[2] &= ~NFSATTRBIT_NFSV42_2;   \
 } while (0)
 
 #defineNFSCLRNOTSETABLE_ATTRBIT(b, n) do { 
\
@@ -465,6 +470,8 @@ typedef struct {
(b)->bits[2] &= NFSATTRBIT_SETABLE2;\
if (((n)->nd_flag & ND_NFSV41) == 0)\
(b)->bits[2] &= ~NFSATTRBIT_NFSV41_2;   \
+   if (((n)->nd_flag & ND_NFSV42) == 0)\
+   (b)->bits[2] &= ~NFSATTRBIT_NFSV42_2;   \
 } while (0)
 
 #defineNFSNONZERO_ATTRBIT(b)   ((b)->bits[0] || (b)->bits[1] || 
(b)->bits[2])
@@ -701,6 +708,7 @@ struct nfsrv_descript {
 #defineND_CURSTATEID   0x8000
 #defineND_SAVEDCURSTATEID  0x1
 #defineND_HASSLOTID0x2
+#defineND_NFSV42   0x4
 
 /*
  * ND_GSS should be the "or" of all GSS type authentications.
___
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: r355471 - head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs

2019-12-06 Thread Mark Johnston
Author: markj
Date: Fri Dec  6 23:49:37 2019
New Revision: 355471
URL: https://svnweb.freebsd.org/changeset/base/355471

Log:
  Fix an inverted condition introduced in r353539.
  
  This would have most likely resulted in read errors causing page leaks.
  
  Submitted by: jeff

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

Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c
==
--- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c Fri Dec 
 6 23:39:38 2019(r355470)
+++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c Fri Dec 
 6 23:49:37 2019(r355471)
@@ -550,7 +550,7 @@ mappedread_sf(vnode_t *vp, int nbytes, uio_t *uio)
vm_page_unlock(pp);
}
vm_page_sunbusy(pp);
-   if (error != 0 && !vm_page_wired(pp) == 0 &&
+   if (error != 0 && !vm_page_wired(pp) &&
pp->valid == 0 && vm_page_tryxbusy(pp))
vm_page_free(pp);
} else {
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r355470 - head/usr.bin/tail

2019-12-06 Thread Mark Johnston
Author: markj
Date: Fri Dec  6 23:39:38 2019
New Revision: 355470
URL: https://svnweb.freebsd.org/changeset/base/355470

Log:
  Fix tail -f in capability mode.
  
  We were not adding CAP_EVENT to input file capabilities, so kevent()
  always failed with ENOTCAPABLE.  tail implements a fallback mode to
  poll the file in this case, so the failure was not apparent.
  
  Reviewed by:  emaste
  MFC after:1 week
  Sponsored by: The FreeBSD Foundation
  Differential Revision:https://reviews.freebsd.org/D22709

Modified:
  head/usr.bin/tail/tail.c

Modified: head/usr.bin/tail/tail.c
==
--- head/usr.bin/tail/tail.cFri Dec  6 23:39:08 2019(r355469)
+++ head/usr.bin/tail/tail.cFri Dec  6 23:39:38 2019(r355470)
@@ -93,11 +93,6 @@ main(int argc, char *argv[])
char *p;
cap_rights_t rights;
 
-   cap_rights_init(, CAP_FSTAT, CAP_FSTATFS, CAP_FCNTL, 
CAP_MMAP_RW);
-   if (caph_rights_limit(STDIN_FILENO, ) < 0 ||
-   caph_limit_stderr() < 0 || caph_limit_stdout() < 0)
-   err(1, "can't limit stdio rights");
-
/*
 * Tail's options are weird.  First, -n10 is the same as -n-10, not
 * -n+10.  Second, the number options are 1 based and not offsets,
@@ -166,6 +161,14 @@ main(int argc, char *argv[])
argv += optind;
 
no_files = argc ? argc : 1;
+
+   cap_rights_init(, CAP_FSTAT, CAP_FSTATFS, CAP_FCNTL,
+   CAP_MMAP_R);
+   if (fflag)
+   cap_rights_set(, CAP_EVENT);
+   if (caph_rights_limit(STDIN_FILENO, ) < 0 ||
+   caph_limit_stderr() < 0 || caph_limit_stdout() < 0)
+   err(1, "can't limit stdio rights");
 
fa = fileargs_init(argc, argv, O_RDONLY, 0, , FA_OPEN);
if (fa == 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: r355469 - head/sys/vm

2019-12-06 Thread Mark Johnston
Author: markj
Date: Fri Dec  6 23:39:08 2019
New Revision: 355469
URL: https://svnweb.freebsd.org/changeset/base/355469

Log:
  Fix fault_type handling in vm_map_lookup().
  
  Suppose that the map entry is wired, so that we later assign
  fault_type = entry->protection.  Suppose further that we jump back to
  RetryLookup.  Then fault_type will no longer contain the original
  fault protection mask, but instead that of the wired entry.
  
  Submitted by: Wuyang Chung 
  Reviewed by:  kib
  MFC after:3 days
  Github PR:https://github.com/freebsd/freebsd/pull/419
  Differential Revision:https://reviews.freebsd.org/D22683

Modified:
  head/sys/vm/vm_map.c

Modified: head/sys/vm/vm_map.c
==
--- head/sys/vm/vm_map.cFri Dec  6 22:45:36 2019(r355468)
+++ head/sys/vm/vm_map.cFri Dec  6 23:39:08 2019(r355469)
@@ -4687,7 +4687,7 @@ vm_map_lookup(vm_map_t *var_map,  /* IN/OUT */
vm_map_entry_t entry;
vm_map_t map = *var_map;
vm_prot_t prot;
-   vm_prot_t fault_type = fault_typea;
+   vm_prot_t fault_type;
vm_object_t eobject;
vm_size_t size;
struct ucred *cred;
@@ -4731,7 +4731,7 @@ RetryLookupLocked:
vm_map_growstack(map, vaddr, entry) == KERN_SUCCESS)
goto RetryLookupLocked;
}
-   fault_type &= VM_PROT_READ | VM_PROT_WRITE | VM_PROT_EXECUTE;
+   fault_type = fault_typea & VM_PROT_ALL;
if ((fault_type & prot) != fault_type || prot == VM_PROT_NONE) {
vm_map_unlock_read(map);
return (KERN_PROTECTION_FAILURE);
___
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: r355468 - head/sys/tools

2019-12-06 Thread Kyle Evans
Author: kevans
Date: Fri Dec  6 22:45:36 2019
New Revision: 355468
URL: https://svnweb.freebsd.org/changeset/base/355468

Log:
  makesyscalls.lua: improve config processing
  
  The current version will strip out #include directives appearing inside 
strings, which is clearly wrong. Improve the processing entirely in the 
following ways:
  
  - Strip only whole-line comments on every single iteration
  - Abort if we see a malformed line that doesn't match the key=value format
  - For quoted (backtick or double quote) strings, we'll advance to the end of
the key=value pair and make sure there's not extra stuff left over
  - For unquoted key=value pairs, we'll strip any trailing comments and verify
there's no internal whitespace
  
  This has revealed the caveat that key/value pairs can't even include escaped 
quotes (and haven't been able to). I don't know if this is actually 
problematic, as we're usually looking at cases like "#include " or raw 
identifiers.The current version will strip out #include directives appearing 
inside strings, which is clearly wrong. Improve the processing entirely in the 
following ways:
  
  Reviewed and noticed by:  brooks
  Differential Revision:https://reviews.freebsd.org/D22698

Modified:
  head/sys/tools/makesyscalls.lua

Modified: head/sys/tools/makesyscalls.lua
==
--- head/sys/tools/makesyscalls.lua Fri Dec  6 22:32:06 2019
(r355467)
+++ head/sys/tools/makesyscalls.lua Fri Dec  6 22:45:36 2019
(r355468)
@@ -208,8 +208,13 @@ end
 -- be fine to make various assumptions
 local function process_config(file)
local cfg = {}
-   local commentExpr = "#.*"
-   local lineExpr = "([%w%p]+)%s*=%s*([`\"]?[^\"`]+[`\"]?)"
+   local comment_line_expr = "^%s*#.*"
+   -- We capture any whitespace padding here so we can easily advance to
+   -- the end of the line as needed to check for any trailing bogus bits.
+   -- Alternatively, we could drop the whitespace and instead try to
+   -- use a pattern to strip out the meaty part of the line, but then we
+   -- would need to sanitize the line for potentially special characters.
+   local line_expr = "^([%w%p]+%s*)=(%s*[`\"]?[^\"`]+[`\"]?)"
 
if file == nil then
return nil, "No file given"
@@ -221,18 +226,36 @@ local function process_config(file)
end
 
for nextline in fh:lines() do
-   -- Strip any comments
-   nextline = nextline:gsub(commentExpr, "")
+   -- Strip any whole-line comments
+   nextline = nextline:gsub(comment_line_expr, "")
-- Parse it into key, value pairs
-   local key, value = nextline:match(lineExpr)
+   local key, value = nextline:match(line_expr)
if key ~= nil and value ~= nil then
-   if value:sub(1,1) == '`' then
+   local kvp = key .. "=" .. value
+   key = trim(key)
+   value = trim(value)
+   local delim = value:sub(1,1)
+   if delim == '`' or delim == '"' then
+   local trailing_context
+   -- Strip off the key/value part
+   trailing_context = nextline:sub(kvp:len() + 1)
+   -- Strip off any trailing comment
+   trailing_context = trailing_context:gsub("#.*$",
+   "")
+   -- Strip off leading/trailing whitespace
+   trailing_context = trim(trailing_context)
+   if trailing_context ~= "" then
+   print(trailing_context)
+   abort(1, "Malformed line: " .. nextline)
+   end
+   end
+   if delim == '`' then
-- Command substition may use $1 and $2 to mean
-- the syscall definition file and itself
-- respectively.  We'll go ahead and replace
-- $[0-9] with respective arg in case we want to
-- expand this in the future easily...
-   value = trim(value, "`")
+   value = trim(value, delim)
for capture in value:gmatch("$([0-9]+)") do
capture = tonumber(capture)
if capture > #arg then
@@ -244,10 +267,24 @@ local function process_config(file)
end
 
value = exec(value)
+   elseif delim == '"' then
+  

svn commit: r355467 - head/sys/dev/gpio

2019-12-06 Thread Ian Lepore
Author: ian
Date: Fri Dec  6 22:32:06 2019
New Revision: 355467
URL: https://svnweb.freebsd.org/changeset/base/355467

Log:
  Implement bus_rescan for gpiobus(4).  This allows on-the-fly reconfiguration
  of gpio devices by using kenv to add hints for a new device and then do
  'devctl rescan gpiobus4' to make the new device(s) attach.
  
  It's not particularly easy to detect whether the 'at' hint has been deleted
  for a child device that's currently attached, so this doesn't handle that.
  But the user can use devctl commands to manually detach an existing device.

Modified:
  head/sys/dev/gpio/gpiobus.c

Modified: head/sys/dev/gpio/gpiobus.c
==
--- head/sys/dev/gpio/gpiobus.c Fri Dec  6 22:20:26 2019(r355466)
+++ head/sys/dev/gpio/gpiobus.c Fri Dec  6 22:32:06 2019(r355467)
@@ -716,6 +716,21 @@ gpiobus_add_child(device_t dev, u_int order, const cha
return (child);
 }
 
+static int
+gpiobus_rescan(device_t dev)
+{
+
+   /*
+* Re-scan is supposed to remove and add children, but if someone has
+* deleted the hints for a child we attached earlier, we have no easy
+* way to handle that.  So this just attaches new children for whom new
+* hints or drivers have arrived since we last tried.
+*/
+   bus_enumerate_hinted_children(dev);
+   bus_generic_attach(dev);
+   return (0);
+}
+
 static void
 gpiobus_hinted_child(device_t bus, const char *dname, int dunit)
 {
@@ -725,6 +740,10 @@ gpiobus_hinted_child(device_t bus, const char *dname, 
const char *pins;
int irq, pinmask;
 
+   if (device_find_child(bus, dname, dunit) != NULL) {
+   return;
+   }
+
child = BUS_ADD_CHILD(bus, 0, dname, dunit);
devi = GPIOBUS_IVAR(child);
if (resource_int_value(dname, dunit, "pins", ) == 0) {
@@ -1077,6 +1096,7 @@ static device_method_t gpiobus_methods[] = {
DEVMETHOD(bus_deactivate_resource,  
bus_generic_deactivate_resource),
DEVMETHOD(bus_get_resource_list,gpiobus_get_resource_list),
DEVMETHOD(bus_add_child,gpiobus_add_child),
+   DEVMETHOD(bus_rescan,   gpiobus_rescan),
DEVMETHOD(bus_probe_nomatch,gpiobus_probe_nomatch),
DEVMETHOD(bus_print_child,  gpiobus_print_child),
DEVMETHOD(bus_child_pnpinfo_str, gpiobus_child_pnpinfo_str),
___
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: r355449 - head/sys/netinet

2019-12-06 Thread Bjoern A. Zeeb

On 6 Dec 2019, at 22:09, Gleb Smirnoff wrote:


   Hi,

there is a functional change here:

On Fri, Dec 06, 2019 at 04:35:48PM +, Bjoern A. Zeeb wrote:
B> URL: https://svnweb.freebsd.org/changeset/base/355449
B>
B> Log:
B>   carp: replace caddr_t with char *
B>
B>   Change the remaining caddr_t usages to char * following the 
removal

B>   of the KAME macros
B>
B>   No functional change.
...
B> @@ -978,6 +978,7 @@ carp_send_ad_locked(struct carp_softc *sc)
B>  #endif /* INET */
B>  #ifdef INET6
B>   if (sc->sc_naddrs6) {
B> + struct epoch_tracker et;
B>   struct ip6_hdr *ip6;
B>
B>   m = m_gethdr(M_NOWAIT, MT_DATA);
B> @@ -1031,8 +1032,10 @@ carp_send_ad_locked(struct carp_softc *sc)
B>
B>   CARPSTATS_INC(carps_opackets6);
B>
B> + NET_EPOCH_ENTER(et);
B>   carp_send_ad_error(sc, ip6_output(m, NULL, NULL, 0,
B>   >sc_carpdev->if_carp->cif_im6o, NULL, NULL));
B> + NET_EPOCH_EXIT(et);
B>   }
B>  #endif /* INET6 */

This could be correct change, just needs some explanation.


Sorry.  My bad.  I had a patch from a different branch applied in 
between review and commit and forgot to clean up before committing.


I’ll put the epoch changes up for review the next hours/days.  I have 
reverted this part in the meantime in 355466.


Thanks for catching this.

/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: r355466 - head/sys/netinet

2019-12-06 Thread Bjoern A. Zeeb
Author: bz
Date: Fri Dec  6 22:20:26 2019
New Revision: 355466
URL: https://svnweb.freebsd.org/changeset/base/355466

Log:
  Remove the extra epoch tracker change sneaked into r355449 and was not part
  of the originally reviewed or described change.
  
  Pointyhat to:   bz
  Reported by:glebius

Modified:
  head/sys/netinet/ip_carp.c

Modified: head/sys/netinet/ip_carp.c
==
--- head/sys/netinet/ip_carp.c  Fri Dec  6 22:12:39 2019(r355465)
+++ head/sys/netinet/ip_carp.c  Fri Dec  6 22:20:26 2019(r355466)
@@ -978,7 +978,6 @@ carp_send_ad_locked(struct carp_softc *sc)
 #endif /* INET */
 #ifdef INET6
if (sc->sc_naddrs6) {
-   struct epoch_tracker et;
struct ip6_hdr *ip6;
 
m = m_gethdr(M_NOWAIT, MT_DATA);
@@ -1032,10 +1031,8 @@ carp_send_ad_locked(struct carp_softc *sc)
 
CARPSTATS_INC(carps_opackets6);
 
-   NET_EPOCH_ENTER(et);
carp_send_ad_error(sc, ip6_output(m, NULL, NULL, 0,
>sc_carpdev->if_carp->cif_im6o, NULL, NULL));
-   NET_EPOCH_EXIT(et);
}
 #endif /* INET6 */
 
___
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: r355465 - head/sys/dev/nvme

2019-12-06 Thread Warner Losh
Author: imp
Date: Fri Dec  6 22:12:39 2019
New Revision: 355465
URL: https://svnweb.freebsd.org/changeset/base/355465

Log:
  trackers always know what qpair they are on
  
  Don't needlessly pass around qpair pointers when the tracker knows what
  qpair it's on.  This will simplify code and make it easier to split
  submission and completion queues in the future.
  
  Signed-off-by: John Meneghini 

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

Modified: head/sys/dev/nvme/nvme_qpair.c
==
--- head/sys/dev/nvme/nvme_qpair.c  Fri Dec  6 21:50:24 2019
(r355464)
+++ head/sys/dev/nvme/nvme_qpair.c  Fri Dec  6 22:12:39 2019
(r355465)
@@ -418,9 +418,10 @@ nvme_completion_is_retry(const struct nvme_completion 
 }
 
 static void
-nvme_qpair_complete_tracker(struct nvme_qpair *qpair, struct nvme_tracker *tr,
+nvme_qpair_complete_tracker(struct nvme_tracker *tr,
 struct nvme_completion *cpl, error_print_t print_on_error)
 {
+   struct nvme_qpair * qpair = tr->qpair;
struct nvme_request *req;
boolean_t   retry, error, retriable;
 
@@ -484,19 +485,22 @@ nvme_qpair_complete_tracker(struct nvme_qpair *qpair, 
 }
 
 static void
-nvme_qpair_manual_complete_tracker(struct nvme_qpair *qpair,
+nvme_qpair_manual_complete_tracker(
 struct nvme_tracker *tr, uint32_t sct, uint32_t sc, uint32_t dnr,
 error_print_t print_on_error)
 {
struct nvme_completion  cpl;
 
memset(, 0, sizeof(cpl));
+
+   struct nvme_qpair * qpair = tr->qpair;
+
cpl.sqid = qpair->id;
cpl.cid = tr->cid;
cpl.status |= (sct & NVME_STATUS_SCT_MASK) << NVME_STATUS_SCT_SHIFT;
cpl.status |= (sc & NVME_STATUS_SC_MASK) << NVME_STATUS_SC_SHIFT;
cpl.status |= (dnr & NVME_STATUS_DNR_MASK) << NVME_STATUS_DNR_SHIFT;
-   nvme_qpair_complete_tracker(qpair, tr, , print_on_error);
+   nvme_qpair_complete_tracker(tr, , print_on_error);
 }
 
 void
@@ -589,7 +593,7 @@ nvme_qpair_process_completions(struct nvme_qpair *qpai
tr = qpair->act_tr[cpl.cid];
 
if (tr != NULL) {
-   nvme_qpair_complete_tracker(qpair, tr, , 
ERROR_PRINT_ALL);
+   nvme_qpair_complete_tracker(tr, , ERROR_PRINT_ALL);
qpair->sq_head = cpl.sqhd;
done++;
} else if (!in_panic) {
@@ -842,7 +846,7 @@ nvme_admin_qpair_abort_aers(struct nvme_qpair *qpair)
tr = TAILQ_FIRST(>outstanding_tr);
while (tr != NULL) {
if (tr->req->cmd.opc == NVME_OPC_ASYNC_EVENT_REQUEST) {
-   nvme_qpair_manual_complete_tracker(qpair, tr,
+   nvme_qpair_manual_complete_tracker(tr,
NVME_SCT_GENERIC, NVME_SC_ABORTED_SQ_DELETION, 0,
ERROR_PRINT_NONE);
tr = TAILQ_FIRST(>outstanding_tr);
@@ -886,7 +890,7 @@ nvme_abort_complete(void *arg, const struct nvme_compl
 */
nvme_printf(tr->qpair->ctrlr,
"abort command failed, aborting command manually\n");
-   nvme_qpair_manual_complete_tracker(tr->qpair, tr,
+   nvme_qpair_manual_complete_tracker(tr,
NVME_SCT_GENERIC, NVME_SC_ABORTED_BY_REQUEST, 0, 
ERROR_PRINT_ALL);
}
 }
@@ -1104,7 +1108,7 @@ _nvme_qpair_submit_request(struct nvme_qpair *qpair, s
 *  with the qpair lock held.
 */
mtx_unlock(>lock);
-   nvme_qpair_manual_complete_tracker(qpair, tr, NVME_SCT_GENERIC,
+   nvme_qpair_manual_complete_tracker(tr, NVME_SCT_GENERIC,
NVME_SC_DATA_TRANSFER_ERROR, DO_NOT_RETRY, ERROR_PRINT_ALL);
mtx_lock(>lock);
}
@@ -1162,7 +1166,7 @@ nvme_admin_qpair_enable(struct nvme_qpair *qpair)
TAILQ_FOREACH_SAFE(tr, >outstanding_tr, tailq, tr_temp) {
nvme_printf(qpair->ctrlr,
"aborting outstanding admin command\n");
-   nvme_qpair_manual_complete_tracker(qpair, tr, NVME_SCT_GENERIC,
+   nvme_qpair_manual_complete_tracker(tr, NVME_SCT_GENERIC,
NVME_SC_ABORTED_BY_REQUEST, DO_NOT_RETRY, ERROR_PRINT_ALL);
}
 
@@ -1184,7 +1188,7 @@ nvme_io_qpair_enable(struct nvme_qpair *qpair)
 */
TAILQ_FOREACH_SAFE(tr, >outstanding_tr, tailq, tr_temp) {
nvme_printf(qpair->ctrlr, "aborting outstanding i/o\n");
-   nvme_qpair_manual_complete_tracker(qpair, tr, NVME_SCT_GENERIC,
+   nvme_qpair_manual_complete_tracker(tr, NVME_SCT_GENERIC,
NVME_SC_ABORTED_BY_REQUEST, 0, ERROR_PRINT_NO_RETRY);
}
 
@@ -1263,11 +1267,10 @@ nvme_qpair_fail(struct nvme_qpair *qpair)
 */
nvme_printf(qpair->ctrlr, "failing outstanding i/o\n");
 

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

2019-12-06 Thread Gleb Smirnoff
   Hi,

there is a functional change here:

On Fri, Dec 06, 2019 at 04:35:48PM +, Bjoern A. Zeeb wrote:
B> URL: https://svnweb.freebsd.org/changeset/base/355449
B> 
B> Log:
B>   carp: replace caddr_t with char *
B>   
B>   Change the remaining caddr_t usages to char * following the removal
B>   of the KAME macros
B>   
B>   No functional change.
...
B> @@ -978,6 +978,7 @@ carp_send_ad_locked(struct carp_softc *sc)
B>  #endif /* INET */
B>  #ifdef INET6
B>  if (sc->sc_naddrs6) {
B> +struct epoch_tracker et;
B>  struct ip6_hdr *ip6;
B>  
B>  m = m_gethdr(M_NOWAIT, MT_DATA);
B> @@ -1031,8 +1032,10 @@ carp_send_ad_locked(struct carp_softc *sc)
B>  
B>  CARPSTATS_INC(carps_opackets6);
B>  
B> +NET_EPOCH_ENTER(et);
B>  carp_send_ad_error(sc, ip6_output(m, NULL, NULL, 0,
B>  >sc_carpdev->if_carp->cif_im6o, NULL, NULL));
B> +NET_EPOCH_EXIT(et);
B>  }
B>  #endif /* INET6 */

This could be correct change, just needs some explanation.

-- 
Gleb Smirnoff
___
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: r355464 - head/sys/dev/aacraid

2019-12-06 Thread Warner Losh
Author: imp
Date: Fri Dec  6 21:50:24 2019
New Revision: 355464
URL: https://svnweb.freebsd.org/changeset/base/355464

Log:
  Remove ifdefs for FreeBSD 6, 7, 8 and 9. Assume we're past that.
  
  Differential Revision: https://reviews.freebsd.org/D22539

Modified:
  head/sys/dev/aacraid/aacraid.c
  head/sys/dev/aacraid/aacraid_cam.c
  head/sys/dev/aacraid/aacraid_linux.c
  head/sys/dev/aacraid/aacraid_var.h

Modified: head/sys/dev/aacraid/aacraid.c
==
--- head/sys/dev/aacraid/aacraid.c  Fri Dec  6 21:20:32 2019
(r355463)
+++ head/sys/dev/aacraid/aacraid.c  Fri Dec  6 21:50:24 2019
(r355464)
@@ -188,11 +188,7 @@ static char*aac_describe_code(struct 
aac_code_lookup 
 static d_open_taac_open;
 static d_ioctl_t   aac_ioctl;
 static d_poll_taac_poll;
-#if __FreeBSD_version >= 702000
 static voidaac_cdevpriv_dtor(void *arg);
-#else
-static d_close_t   aac_close;
-#endif
 static int aac_ioctl_sendfib(struct aac_softc *sc, caddr_t ufib);
 static int aac_ioctl_send_raw_srb(struct aac_softc *sc, caddr_t arg);
 static voidaac_handle_aif(struct aac_softc *sc, struct aac_fib *fib);
@@ -220,9 +216,6 @@ static struct cdevsw aacraid_cdevsw = {
.d_version =D_VERSION,
.d_flags =  0,
.d_open =   aac_open,
-#if __FreeBSD_version < 702000
-   .d_close =  aac_close,
-#endif
.d_ioctl =  aac_ioctl,
.d_poll =   aac_poll,
.d_name =   "aacraid",
@@ -275,10 +268,9 @@ aacraid_attach(struct aac_softc *sc)
TAILQ_INIT(>aac_container_tqh);
TAILQ_INIT(>aac_ev_cmfree);
 
-#if __FreeBSD_version >= 80
/* Initialize the clock daemon callout. */
callout_init_mtx(>aac_daemontime, >aac_io_lock, 0);
-#endif
+
/*
 * Initialize the adapter.
 */
@@ -351,18 +343,9 @@ aacraid_attach(struct aac_softc *sc)
/* enable interrupts now */
AAC_ACCESS_DEVREG(sc, AAC_ENABLE_INTERRUPT);
 
-#if __FreeBSD_version >= 80
mtx_lock(>aac_io_lock);
callout_reset(>aac_daemontime, 60 * hz, aac_daemon, sc);
mtx_unlock(>aac_io_lock);
-#else
-   {
-   struct timeval tv;
-   tv.tv_sec = 60;
-   tv.tv_usec = 0;
-   sc->timeout_id = timeout(aac_daemon, (void *)sc, tvtohz());
-   }
-#endif
 
return(0);
 }
@@ -378,14 +361,10 @@ aac_daemon(void *arg)
sc = arg;
fwprintf(sc, HBA_FLAGS_DBG_FUNCTION_ENTRY_B, "");
 
-#if __FreeBSD_version >= 80
mtx_assert(>aac_io_lock, MA_OWNED);
if (callout_pending(>aac_daemontime) ||
callout_active(>aac_daemontime) == 0)
return;
-#else
-   mtx_lock(>aac_io_lock);
-#endif
getmicrotime();
 
if (!aacraid_alloc_command(sc, )) {
@@ -412,14 +391,7 @@ aac_daemon(void *arg)
aacraid_release_command(cm);
}
 
-#if __FreeBSD_version >= 80
callout_schedule(>aac_daemontime, 30 * 60 * hz);
-#else
-   mtx_unlock(>aac_io_lock);
-   tv.tv_sec = 30 * 60;
-   tv.tv_usec = 0;
-   sc->timeout_id = timeout(aac_daemon, (void *)sc, tvtohz());
-#endif
 }
 
 void
@@ -762,11 +734,7 @@ aacraid_detach(device_t dev)
sc = device_get_softc(dev);
fwprintf(sc, HBA_FLAGS_DBG_FUNCTION_ENTRY_B, "");
 
-#if __FreeBSD_version >= 80
callout_drain(>aac_daemontime);
-#else
-   untimeout(aac_daemon, (void *)sc, sc->timeout_id);
-#endif
/* Remove the child containers */
while ((co = TAILQ_FIRST(>aac_container_tqh)) != NULL) {
TAILQ_REMOVE(>aac_container_tqh, co, co_link);
@@ -2591,10 +2559,8 @@ aac_open(struct cdev *dev, int flags, int fmt, struct 
 
sc = dev->si_drv1;
fwprintf(sc, HBA_FLAGS_DBG_FUNCTION_ENTRY_B, "");
-#if __FreeBSD_version >= 702000
device_busy(sc->aac_dev);
devfs_set_cdevpriv(sc, aac_cdevpriv_dtor);
-#endif
return 0;
 }
 
@@ -3077,7 +3043,6 @@ aac_request_aif(struct aac_softc *sc)
 }
 
 
-#if __FreeBSD_version >= 702000
 /*
  * cdevpriv interface private destructor.
  */
@@ -3090,17 +3055,6 @@ aac_cdevpriv_dtor(void *arg)
fwprintf(sc, HBA_FLAGS_DBG_FUNCTION_ENTRY_B, "");
device_unbusy(sc->aac_dev);
 }
-#else
-static int
-aac_close(struct cdev *dev, int flags, int fmt, struct thread *td)
-{
-   struct aac_softc *sc;
-
-   sc = dev->si_drv1;
-   fwprintf(sc, HBA_FLAGS_DBG_FUNCTION_ENTRY_B, "");
-   return 0;
-}
-#endif
 
 /*
  * Handle an AIF sent to us by the controller; queue it for later reference.

Modified: head/sys/dev/aacraid/aacraid_cam.c
==
--- head/sys/dev/aacraid/aacraid_cam.c  Fri Dec  6 21:20:32 2019
(r355463)
+++ head/sys/dev/aacraid/aacraid_cam.c  Fri Dec  6 21:50:24 2019
(r355464)
@@ -49,9 

svn commit: r355463 - stable/11/release/doc/en_US.ISO8859-1/errata

2019-12-06 Thread Glen Barber
Author: gjb
Date: Fri Dec  6 21:20:32 2019
New Revision: 355463
URL: https://svnweb.freebsd.org/changeset/base/355463

Log:
  Document the 11.3-RELEASE images in GCE do not work, and provide
  information regarding alternative solutions.
  
  PR:   242303 (related)
  Sponsored by: Rubicon Communications, LLC (netgate.com)

Modified:
  stable/11/release/doc/en_US.ISO8859-1/errata/article.xml

Modified: stable/11/release/doc/en_US.ISO8859-1/errata/article.xml
==
--- stable/11/release/doc/en_US.ISO8859-1/errata/article.xmlFri Dec  6 
20:21:07 2019(r355462)
+++ stable/11/release/doc/en_US.ISO8859-1/errata/article.xmlFri Dec  6 
21:20:32 2019(r355463)
@@ -135,6 +135,30 @@
   
 Late-Breaking News
 
-No news.
+
+  
+   [2019-12-06] An issue has been reported with the
+ 11.3-RELEASE images on the Google Compute Engine
+ platform which causes virtual machines to fail to start
+ properly.
+
+   While we intend to investigate how to handle similar
+ situations should they arise in the future, updated images
+ will not be provided as of this time.
+
+   Users wanting to use  in Google Compute Engine are
+ advised to use 12.0-RELEASE or 12.1-RELEASE, or for those
+ who wish to track 11.X, the
+ freebsd-11-3-stable-amd64-v20190801
+ snapshot from stable/11 has been
+ https://github.com/cirruslabs/cirrus-ci-docs/issues/359#issuecomment-519314652;>
+   reported to work correctly.
+
+   More details can be found in https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=242303;>PR
+   242303.
+  
+
   
 
___
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: r355436 - in head/sys: amd64/amd64 x86/x86

2019-12-06 Thread Scott Long
I’m not opposed to the idea, but making any change invites a bike shed on
naming, and making no change at all invites a bike shed on naming, and
honestly the name doesn’t matter to me at this point.  I encourage you and
Ed to own this.

Scott


> On Dec 6, 2019, at 6:58 AM, Eric van Gyzen  wrote:
> 
> 
> 
>> On Dec 6, 2019, at 4:36 AM, Ed Maste  wrote:
>> 
>> On Thu, 5 Dec 2019 at 21:43, Scott Long  wrote:
>>> 
>>> Author: scottl
>>> Date: Fri Dec  6 02:43:05 2019
>>> New Revision: 355436
>>> URL: https://svnweb.freebsd.org/changeset/base/355436
>>> 
>>> Log:
>>> Move the mds, irbs, and ssb mitigation knobs into machdep.mitigations.
>> 
>> If we're moving them and adding backwards-compatibility scaffolding we
>> really should correct the sense of the sysctls at the same time.
> 
> I was just going to suggest that.  For some, 0 is secure; for others, 1 is 
> secure.  Since they’re under “mitigations,” I think 1 should consistently 
> mean “mitigated.”
> 
> Eric

___
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: r355461 - head/sys/arm/mv

2019-12-06 Thread Warner Losh
On Fri, Dec 6, 2019 at 1:17 PM Ian Lepore  wrote:

> On Fri, 2019-12-06 at 20:05 +, Luiz Otavio O Souza wrote:
> > Author: loos
> > Date: Fri Dec  6 20:05:08 2019
> > New Revision: 355461
> > URL: https://svnweb.freebsd.org/changeset/base/355461
> >
> > Log:
> >   Fix the ARM64 build, include the necessary  header.
> >
> >   While here, call device_delete_children() to detach and dealloc all
> > the
> >   existent children and handle the child's detach errors properly.
> >
> >   Reported by:jenkins, hselasky, ian
> >   Sponsored by:   Rubicon Communications, LLC (Netgate)
> >
> > Modified:
> >   head/sys/arm/mv/a37x0_spi.c
> >
> > Modified: head/sys/arm/mv/a37x0_spi.c
> > =
> > =
> > --- head/sys/arm/mv/a37x0_spi.c   Fri Dec  6 19:33:39 2019
> (r355
> > 460)
> > +++ head/sys/arm/mv/a37x0_spi.c   Fri Dec  6 20:05:08 2019
> (r355
> > 461)
> > @@ -29,9 +29,9 @@ __FBSDID("$FreeBSD$");
> >  #include 
> >  #include 
> >  #include 
> > -
> >  #include 
> >  #include 
> > +#include 
> >  #include 
> >
> >  #include 
> > @@ -228,9 +228,11 @@ a37x0_spi_attach(device_t dev)
> >  static int
> >  a37x0_spi_detach(device_t dev)
> >  {
> > + int err;
> >   struct a37x0_spi_softc *sc;
> >
> > - bus_generic_detach(dev);
> > + if ((err = device_delete_children(dev)) != 0)
> > + return (err);
> >   sc = device_get_softc(dev);
> >   mtx_destroy(>sc_mtx);
> >   if (sc->sc_intrhand)
>
> Oops, not quite right; I should have been more explicit.  Something
> more like this:
>
>   if ((err = bus_generic_detach(dev)) != 0)
>   return (err);
>   device_delete_children(dev);
>
> The delete is basically cannot-fail (as long as they're not attached),
> but bus_generic_detach() can fail if the detach method of any
> child/grandchilden fails.
>
> Hrm.  You know, now that I've just looked in the code for
> device_delete_children(), it appears it will call detach if necessary,
> so maybe your approach is fine.  I've just never done it that way.  If
> anyone knows a reason why one approach is better than the other, say
> so.  Otherwise I guess we should call this good.
>

Once upon a time, delete_children would fail if anything was attached
(well, before that was there were for loops everywhere that did this
thing). Now it calls detach so we can move that common code into one
routine. You see a mix in the tree because not all uses were updated when
functionality increased. I'd prefer the approach that Luiz did, honestly.

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


svn commit: r355462 - in head/sys: conf dev/gpio

2019-12-06 Thread Luiz Otavio O Souza
Author: loos
Date: Fri Dec  6 20:21:07 2019
New Revision: 355462
URL: https://svnweb.freebsd.org/changeset/base/355462

Log:
  Add a GPIO based MDIO bit-banging bus driver.
  
  Uses two GPIO pins as MDC (clock) and MDIO (bidirectional I/O), relies
  on mii_bitbang.
  
  Tested on SG-3200 where the PHY for one of the ports is wired independently
  of the SoC MDIO bus.
  
  Sponsored by: Rubicon Communications, LLC (Netgate)

Added:
  head/sys/dev/gpio/gpiomdio.c   (contents, props changed)
Modified:
  head/sys/conf/files

Modified: head/sys/conf/files
==
--- head/sys/conf/files Fri Dec  6 20:05:08 2019(r355461)
+++ head/sys/conf/files Fri Dec  6 20:21:07 2019(r355462)
@@ -1753,6 +1753,7 @@ dev/gpio/gpioc.c  optional gpio   
\
 dev/gpio/gpioiic.c optional gpioiic
 dev/gpio/gpioled.c optional gpioled !fdt
 dev/gpio/gpioled_fdt.c optional gpioled fdt
+dev/gpio/gpiomdio.coptional gpiomdio mii_bitbang
 dev/gpio/gpiopower.c   optional gpiopower fdt
 dev/gpio/gpioregulator.c   optional gpioregulator fdt ext_resources
 dev/gpio/gpiospi.c optional gpiospi

Added: head/sys/dev/gpio/gpiomdio.c
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/sys/dev/gpio/gpiomdio.cFri Dec  6 20:21:07 2019
(r355462)
@@ -0,0 +1,243 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ *
+ * Copyright (c) 2019 Rubicon Communications, LLC (Netgate)
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include 
+__FBSDID("$FreeBSD$");
+
+#include "opt_platform.h"
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "gpiobus_if.h"
+#include "miibus_if.h"
+
+#defineGPIOMDIO_MDC_DFLT   0
+#defineGPIOMDIO_MDIO_DFLT  1
+#defineGPIOMDIO_MIN_PINS   2
+
+#defineMDO_BIT 0x01
+#defineMDI_BIT 0x02
+#defineMDC_BIT 0x04
+#defineMDIRPHY_BIT 0x08
+#defineMDIRHOST_BIT0x10
+#defineMDO sc->miibb_ops.mbo_bits[MII_BIT_MDO]
+#defineMDI sc->miibb_ops.mbo_bits[MII_BIT_MDI]
+#defineMDC sc->miibb_ops.mbo_bits[MII_BIT_MDC]
+#defineMDIRPHY 
sc->miibb_ops.mbo_bits[MII_BIT_DIR_HOST_PHY]
+#defineMDIRHOST
sc->miibb_ops.mbo_bits[MII_BIT_DIR_PHY_HOST]
+
+static uint32_t gpiomdio_bb_read(device_t);
+static void gpiomdio_bb_write(device_t, uint32_t);
+
+struct gpiomdio_softc
+{
+   device_tsc_dev;
+   device_tsc_busdev;
+   int mdc_pin;
+   int mdio_pin;
+   struct mii_bitbang_ops  miibb_ops;
+};
+
+
+static int
+gpiomdio_probe(device_t dev)
+{
+   struct gpiobus_ivar *devi;
+
+   if (!ofw_bus_status_okay(dev))
+   return (ENXIO);
+   if (!ofw_bus_is_compatible(dev, "freebsd,gpiomdio"))
+   return (ENXIO);
+   devi = GPIOBUS_IVAR(dev);
+   if (devi->npins < GPIOMDIO_MIN_PINS) {
+   device_printf(dev,
+   "gpiomdio needs at least %d GPIO pins (only %d given).\n",
+   GPIOMDIO_MIN_PINS, devi->npins);
+   return (ENXIO);
+   }
+   device_set_desc(dev, "GPIO MDIO bit-banging Bus driver");
+
+   return 

Re: svn commit: r355461 - head/sys/arm/mv

2019-12-06 Thread Ian Lepore
On Fri, 2019-12-06 at 20:05 +, Luiz Otavio O Souza wrote:
> Author: loos
> Date: Fri Dec  6 20:05:08 2019
> New Revision: 355461
> URL: https://svnweb.freebsd.org/changeset/base/355461
> 
> Log:
>   Fix the ARM64 build, include the necessary  header.
>   
>   While here, call device_delete_children() to detach and dealloc all
> the
>   existent children and handle the child's detach errors properly.
>   
>   Reported by:jenkins, hselasky, ian
>   Sponsored by:   Rubicon Communications, LLC (Netgate)
> 
> Modified:
>   head/sys/arm/mv/a37x0_spi.c
> 
> Modified: head/sys/arm/mv/a37x0_spi.c
> =
> =
> --- head/sys/arm/mv/a37x0_spi.c   Fri Dec  6 19:33:39 2019(r355
> 460)
> +++ head/sys/arm/mv/a37x0_spi.c   Fri Dec  6 20:05:08 2019(r355
> 461)
> @@ -29,9 +29,9 @@ __FBSDID("$FreeBSD$");
>  #include 
>  #include 
>  #include 
> -
>  #include 
>  #include 
> +#include 
>  #include 
>  
>  #include 
> @@ -228,9 +228,11 @@ a37x0_spi_attach(device_t dev)
>  static int
>  a37x0_spi_detach(device_t dev)
>  {
> + int err;
>   struct a37x0_spi_softc *sc;
>  
> - bus_generic_detach(dev);
> + if ((err = device_delete_children(dev)) != 0)
> + return (err);
>   sc = device_get_softc(dev);
>   mtx_destroy(>sc_mtx);
>   if (sc->sc_intrhand)

Oops, not quite right; I should have been more explicit.  Something
more like this:

  if ((err = bus_generic_detach(dev)) != 0)
  return (err);
  device_delete_children(dev);

The delete is basically cannot-fail (as long as they're not attached),
but bus_generic_detach() can fail if the detach method of any
child/grandchilden fails.

Hrm.  You know, now that I've just looked in the code for
device_delete_children(), it appears it will call detach if necessary,
so maybe your approach is fine.  I've just never done it that way.  If
anyone knows a reason why one approach is better than the other, say
so.  Otherwise I guess we should call this good.

-- Ian


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


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

2019-12-06 Thread Luiz Otavio O Souza
On Fri, Dec 6, 2019 at 12:57 PM Hans Petter Selasky  wrote:
>
> On 2019-12-06 13:55, Luiz Otavio O Souza wrote:
> > Author: loos
> > Date: Fri Dec  6 12:55:39 2019
> > New Revision: 355444
> > URL: https://svnweb.freebsd.org/changeset/base/355444
> >
> > Log:
> >Add the SPI driver for the Marvell Armada 37x0 SoC.
> >
> >Interrupt based driver, implements SPI mode and clock configuration.
> >
> >Tested on espressobin and SG-3200.
> >
> >Sponsored by:  Rubicon Communications, LLC (Netgate)
> >
> > Added:
>
> This breaks aarch64. You need to add #include 

Fixed in r355461.

Sorry for the breakage.

Luiz
___
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: r355444 - in head/sys: arm/mv arm64/conf conf

2019-12-06 Thread Luiz Otavio O Souza
On Fri, Dec 6, 2019 at 1:58 PM Ian Lepore  wrote:
>
> On Fri, 2019-12-06 at 12:55 +, Luiz Otavio O Souza wrote:
> > Author: loos
> > Date: Fri Dec  6 12:55:39 2019
> > New Revision: 355444
> > URL: https://svnweb.freebsd.org/changeset/base/355444
> >
> > Log:
> >   Add the SPI driver for the Marvell Armada 37x0 SoC.
> >
> >   Interrupt based driver, implements SPI mode and clock configuration.
> >
> >   Tested on espressobin and SG-3200.
> >
> >   Sponsored by:   Rubicon Communications, LLC (Netgate)
> >
> > Added:
> >   head/sys/arm/mv/a37x0_spi.c   (contents, props changed)
> > Modified:
> >   head/sys/arm64/conf/GENERIC
> >   head/sys/conf/files.arm64
> >
> > Added: head/sys/arm/mv/a37x0_spi.c
> >
> >
> > +static int
> > +a37x0_spi_detach(device_t dev)
> > +{
> > + struct a37x0_spi_softc *sc;
> > +
> > + bus_generic_detach(dev);
> >
>
> It's possible for detaching children to fail (like if one of them
> returns EBUSY from its detach), in which case you should bail on your
> detach and return the error status.  Also, this needs a
> device_destroy_children() here after detaching them, to remove the
> spibus child added in attach (in case the module is unloaded then
> reloaded, that avoids adding a second copy of the child).
>

Fixed in r355461.

Thanks Ian.

Luiz
___
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: r355461 - head/sys/arm/mv

2019-12-06 Thread Luiz Otavio O Souza
Author: loos
Date: Fri Dec  6 20:05:08 2019
New Revision: 355461
URL: https://svnweb.freebsd.org/changeset/base/355461

Log:
  Fix the ARM64 build, include the necessary  header.
  
  While here, call device_delete_children() to detach and dealloc all the
  existent children and handle the child's detach errors properly.
  
  Reported by:  jenkins, hselasky, ian
  Sponsored by: Rubicon Communications, LLC (Netgate)

Modified:
  head/sys/arm/mv/a37x0_spi.c

Modified: head/sys/arm/mv/a37x0_spi.c
==
--- head/sys/arm/mv/a37x0_spi.c Fri Dec  6 19:33:39 2019(r355460)
+++ head/sys/arm/mv/a37x0_spi.c Fri Dec  6 20:05:08 2019(r355461)
@@ -29,9 +29,9 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
-
 #include 
 #include 
+#include 
 #include 
 
 #include 
@@ -228,9 +228,11 @@ a37x0_spi_attach(device_t dev)
 static int
 a37x0_spi_detach(device_t dev)
 {
+   int err;
struct a37x0_spi_softc *sc;
 
-   bus_generic_detach(dev);
+   if ((err = device_delete_children(dev)) != 0)
+   return (err);
sc = device_get_softc(dev);
mtx_destroy(>sc_mtx);
if (sc->sc_intrhand)
___
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: r355460 - head/lib/libbe

2019-12-06 Thread Kyle Evans
Author: kevans
Date: Fri Dec  6 19:33:39 2019
New Revision: 355460
URL: https://svnweb.freebsd.org/changeset/base/355460

Log:
  libbe: fix build against sysutils/openzfs, part 1
  
  This is the half of the changes required that work as-is with both in-tree
  ZFS and the new hotness, sysutils/openzfs.  Highlights are less dependency
  on header pollution (from somewhere) and using 'mnttab' instead of
  'extmnttab'.   In the in-tree ZFS, the latter is a #define for the former,
  but in the port extmnttab is actually a distinct struct that's a super-set
  of mnttab.  We really want mnttab here anyways, so just use it.

Modified:
  head/lib/libbe/be.c
  head/lib/libbe/be_access.c
  head/lib/libbe/be_info.c

Modified: head/lib/libbe/be.c
==
--- head/lib/libbe/be.c Fri Dec  6 19:20:45 2019(r355459)
+++ head/lib/libbe/be.c Fri Dec  6 19:33:39 2019(r355460)
@@ -34,6 +34,9 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 
+#include 
+#include 
+
 #include 
 #include 
 #include 
@@ -67,7 +70,7 @@ static int
 be_locate_rootfs(libbe_handle_t *lbh)
 {
struct statfs sfs;
-   struct extmnttab entry;
+   struct mnttab entry;
zfs_handle_t *zfs;
 
/*

Modified: head/lib/libbe/be_access.c
==
--- head/lib/libbe/be_access.c  Fri Dec  6 19:20:45 2019(r355459)
+++ head/lib/libbe/be_access.c  Fri Dec  6 19:33:39 2019(r355460)
@@ -31,6 +31,8 @@
 #include 
 __FBSDID("$FreeBSD$");
 
+#include 
+
 #include "be.h"
 #include "be_impl.h"
 

Modified: head/lib/libbe/be_info.c
==
--- head/lib/libbe/be_info.cFri Dec  6 19:20:45 2019(r355459)
+++ head/lib/libbe/be_info.cFri Dec  6 19:33:39 2019(r355460)
@@ -30,6 +30,8 @@
 #include 
 __FBSDID("$FreeBSD$");
 
+#include 
+
 #include "be.h"
 #include "be_impl.h"
 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r355459 - head/sys/sys

2019-12-06 Thread John Baldwin
Author: jhb
Date: Fri Dec  6 19:20:45 2019
New Revision: 355459
URL: https://svnweb.freebsd.org/changeset/base/355459

Log:
  Remove SPARE_USRSPACE.
  
  This constant was used to reserve space at the top of the stack to
  hold translated system call arguments for non-default ABIs (the
  "stackgap").  However, none of the compatibility ABIs have used the
  stackgap in many years and the last use of SPARE_USRSPACE was removed
  in r355373.
  
  Reviewed by:  kib
  Sponsored by: DARPA
  Differential Revision:https://reviews.freebsd.org/D22697

Modified:
  head/sys/sys/exec.h

Modified: head/sys/sys/exec.h
==
--- head/sys/sys/exec.h Fri Dec  6 18:51:16 2019(r355458)
+++ head/sys/sys/exec.h Fri Dec  6 19:20:45 2019(r355459)
@@ -77,7 +77,6 @@ struct execsw {
  * Prefer the kern.ps_strings or kern.proc.ps_strings sysctls to this constant.
  */
 #definePS_STRINGS  (USRSTACK - sizeof(struct ps_strings))
-#defineSPARE_USRSPACE  4096
 
 int exec_map_first_page(struct image_params *);
 void exec_unmap_first_page(struct image_params *);   
___
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: r355458 - stable/12/sys/vm

2019-12-06 Thread Mark Johnston
Author: markj
Date: Fri Dec  6 18:51:16 2019
New Revision: 355458
URL: https://svnweb.freebsd.org/changeset/base/355458

Log:
  MFC r355003:
  Update the checks in vm_page_zone_import().

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

Modified: stable/12/sys/vm/vm_page.c
==
--- stable/12/sys/vm/vm_page.c  Fri Dec  6 18:39:05 2019(r355457)
+++ stable/12/sys/vm/vm_page.c  Fri Dec  6 18:51:16 2019(r355458)
@@ -1755,21 +1755,14 @@ vm_page_alloc_after(vm_object_t object, vm_pindex_t pi
  * Returns true if the number of free pages exceeds the minimum
  * for the request class and false otherwise.
  */
-int
-vm_domain_allocate(struct vm_domain *vmd, int req, int npages)
+static int
+_vm_domain_allocate(struct vm_domain *vmd, int req_class, int npages)
 {
u_int limit, old, new;
 
-   req = req & VM_ALLOC_CLASS_MASK;
-
-   /*
-* The page daemon is allowed to dig deeper into the free page list.
-*/
-   if (curproc == pageproc && req != VM_ALLOC_INTERRUPT)
-   req = VM_ALLOC_SYSTEM;
-   if (req == VM_ALLOC_INTERRUPT)
+   if (req_class == VM_ALLOC_INTERRUPT)
limit = 0;
-   else if (req == VM_ALLOC_SYSTEM)
+   else if (req_class == VM_ALLOC_SYSTEM)
limit = vmd->vmd_interrupt_free_min;
else
limit = vmd->vmd_free_reserved;
@@ -1797,6 +1790,20 @@ vm_domain_allocate(struct vm_domain *vmd, int req, int
return (1);
 }
 
+int
+vm_domain_allocate(struct vm_domain *vmd, int req, int npages)
+{
+   int req_class;
+
+   /*
+* The page daemon is allowed to dig deeper into the free page list.
+*/
+   req_class = req & VM_ALLOC_CLASS_MASK;
+   if (curproc == pageproc && req_class != VM_ALLOC_INTERRUPT)
+   req_class = VM_ALLOC_SYSTEM;
+   return (_vm_domain_allocate(vmd, req_class, npages));
+}
+
 vm_page_t
 vm_page_alloc_domain_after(vm_object_t object, vm_pindex_t pindex, int domain,
 int req, vm_page_t mpred)
@@ -2244,8 +2251,13 @@ vm_page_zone_import(void *arg, void **store, int cnt, 
 
pgcache = arg;
vmd = VM_DOMAIN(pgcache->domain);
-   /* Only import if we can bring in a full bucket. */
-   if (cnt == 1 || !vm_domain_allocate(vmd, VM_ALLOC_NORMAL, cnt))
+
+   /*
+* The page daemon should avoid creating extra memory pressure since its
+* main purpose is to replenish the store of free pages.
+*/
+   if (vmd->vmd_severeset || curproc == pageproc ||
+   !_vm_domain_allocate(vmd, VM_ALLOC_NORMAL, cnt))
return (0);
domain = vmd->vmd_domain;
vm_domain_free_lock(vmd);
___
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: r355457 - head/sys/kern

2019-12-06 Thread Alexander Motin
Author: mav
Date: Fri Dec  6 18:39:05 2019
New Revision: 355457
URL: https://svnweb.freebsd.org/changeset/base/355457

Log:
  Make devstat_end_transaction_bio() count BIO_ORDERED.
  
  MFC after:2 weeks

Modified:
  head/sys/kern/subr_devstat.c

Modified: head/sys/kern/subr_devstat.c
==
--- head/sys/kern/subr_devstat.cFri Dec  6 18:27:50 2019
(r355456)
+++ head/sys/kern/subr_devstat.cFri Dec  6 18:39:05 2019
(r355457)
@@ -349,11 +349,16 @@ devstat_end_transaction_bio_bt(struct devstat *ds, con
 const struct bintime *now)
 {
devstat_trans_flags flg;
+   devstat_tag_type tag;
 
/* sanity check */
if (ds == NULL)
return;
 
+   if (bp->bio_flags & BIO_ORDERED)
+   tag = DEVSTAT_TAG_ORDERED;
+   else
+   tag = DEVSTAT_TAG_SIMPLE;
if (bp->bio_cmd == BIO_DELETE)
flg = DEVSTAT_FREE;
else if ((bp->bio_cmd == BIO_READ)
@@ -366,7 +371,7 @@ devstat_end_transaction_bio_bt(struct devstat *ds, con
flg = DEVSTAT_NO_DATA;
 
devstat_end_transaction(ds, bp->bio_bcount - bp->bio_resid,
-   DEVSTAT_TAG_SIMPLE, flg, now, >bio_t0);
+   tag, flg, now, >bio_t0);
DTRACE_DEVSTAT_BIO_DONE();
 }
 
___
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: r355456 - in stable/12/usr.bin/cmp: . tests

2019-12-06 Thread Mark Johnston
Author: markj
Date: Fri Dec  6 18:27:50 2019
New Revision: 355456
URL: https://svnweb.freebsd.org/changeset/base/355456

Log:
  MFC r344551:
  Fix handling of rights on stdio streams, take two.
  
  PR:   234885

Modified:
  stable/12/usr.bin/cmp/cmp.c
  stable/12/usr.bin/cmp/regular.c
  stable/12/usr.bin/cmp/special.c
  stable/12/usr.bin/cmp/tests/cmp_test2.sh
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/usr.bin/cmp/cmp.c
==
--- stable/12/usr.bin/cmp/cmp.c Fri Dec  6 18:26:34 2019(r355455)
+++ stable/12/usr.bin/cmp/cmp.c Fri Dec  6 18:27:50 2019(r355456)
@@ -45,7 +45,6 @@ static char sccsid[] = "@(#)cmp.c 8.3 (Berkeley) 4/2/9
 __FBSDID("$FreeBSD$");
 
 #include 
-#include 
 #include 
 
 #include 
@@ -80,8 +79,6 @@ main(int argc, char *argv[])
off_t skip1, skip2;
int ch, fd1, fd2, oflag, special;
const char *file1, *file2;
-   cap_rights_t rights;
-   uint32_t fcntls;
 
oflag = O_RDONLY;
while ((ch = getopt_long(argc, argv, "+hlsxz", long_opts, NULL)) != -1)
@@ -116,14 +113,19 @@ main(int argc, char *argv[])
if (argc < 2 || argc > 4)
usage();
 
+   /* Don't limit rights on stdin since it may be one of the inputs. */
+   if (caph_limit_stream(STDOUT_FILENO, CAPH_WRITE | CAPH_IGNORE_EBADF))
+   err(ERR_EXIT, "unable to limit rights on stdout");
+   if (caph_limit_stream(STDERR_FILENO, CAPH_WRITE | CAPH_IGNORE_EBADF))
+   err(ERR_EXIT, "unable to limit rights on stderr");
+
/* Backward compatibility -- handle "-" meaning stdin. */
special = 0;
if (strcmp(file1 = argv[0], "-") == 0) {
special = 1;
-   fd1 = 0;
+   fd1 = STDIN_FILENO;
file1 = "stdin";
-   }
-   else if ((fd1 = open(file1, oflag, 0)) < 0 && errno != EMLINK) {
+   } else if ((fd1 = open(file1, oflag, 0)) < 0 && errno != EMLINK) {
if (!sflag)
err(ERR_EXIT, "%s", file1);
else
@@ -134,10 +136,9 @@ main(int argc, char *argv[])
errx(ERR_EXIT,
"standard input may only be specified once");
special = 1;
-   fd2 = 0;
+   fd2 = STDIN_FILENO;
file2 = "stdin";
-   }
-   else if ((fd2 = open(file2, oflag, 0)) < 0 && errno != EMLINK) {
+   } else if ((fd2 = open(file2, oflag, 0)) < 0 && errno != EMLINK) {
if (!sflag)
err(ERR_EXIT, "%s", file2);
else
@@ -162,33 +163,8 @@ main(int argc, char *argv[])
exit(ERR_EXIT);
}
 
-   cap_rights_init(, CAP_FCNTL, CAP_FSTAT, CAP_MMAP_R);
-   if (caph_rights_limit(fd1, ) < 0)
-   err(ERR_EXIT, "unable to limit rights for %s", file1);
-   if (caph_rights_limit(fd2, ) < 0)
-   err(ERR_EXIT, "unable to limit rights for %s", file2);
-
-   /* Required for fdopen(3). */
-   fcntls = CAP_FCNTL_GETFL;
-   if (caph_fcntls_limit(fd1, fcntls) < 0)
-   err(ERR_EXIT, "unable to limit fcntls for %s", file1);
-   if (caph_fcntls_limit(fd2, fcntls) < 0)
-   err(ERR_EXIT, "unable to limit fcntls for %s", file2);
-
-   if (!special) {
-   cap_rights_init();
-   if (caph_rights_limit(STDIN_FILENO, ) < 0) {
-   err(ERR_EXIT, "unable to limit stdio");
-   }
-   }
-
-   if (caph_limit_stdout() == -1 || caph_limit_stderr() == -1)
-   err(ERR_EXIT, "unable to limit stdio");
-
+   /* FD rights are limited in c_special() and c_regular(). */
caph_cache_catpages();
-
-   if (caph_enter() < 0)
-   err(ERR_EXIT, "unable to enter capability mode");
 
if (!special) {
if (fstat(fd1, )) {

Modified: stable/12/usr.bin/cmp/regular.c
==
--- stable/12/usr.bin/cmp/regular.c Fri Dec  6 18:26:34 2019
(r355455)
+++ stable/12/usr.bin/cmp/regular.c Fri Dec  6 18:27:50 2019
(r355456)
@@ -42,6 +42,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 
+#include 
 #include 
 #include 
 #include 
@@ -61,12 +62,13 @@ void
 c_regular(int fd1, const char *file1, off_t skip1, off_t len1,
 int fd2, const char *file2, off_t skip2, off_t len2)
 {
+   struct sigaction act, oact;
+   cap_rights_t rights;
u_char ch, *p1, *p2, *m1, *m2, *e1, *e2;
off_t byte, length, line;
-   int dfound;
off_t pagemask, off1, off2;
size_t pagesize;
-   struct sigaction act, oact;
+   int dfound;
 
if (skip1 > len1)
eofmsg(file1);
@@ -78,12 +80,6 @@ c_regular(int fd1, const char *file1, off_t skip1, off
if (sflag && len1 != len2)
   

svn commit: r355455 - in stable/12: bin/dd sbin/dhclient sbin/md5 usr.bin/cmp usr.bin/diff usr.bin/diff3 usr.bin/elfdump usr.bin/indent usr.bin/jot usr.bin/ktrdump usr.bin/lam usr.bin/rwho usr.bin/...

2019-12-06 Thread Mark Johnston
Author: markj
Date: Fri Dec  6 18:26:34 2019
New Revision: 355455
URL: https://svnweb.freebsd.org/changeset/base/355455

Log:
  MFC r340138 (by oshogbo):
  capsicum: use a new capsicum helpers in tools

Modified:
  stable/12/bin/dd/dd.c
  stable/12/sbin/dhclient/bpf.c
  stable/12/sbin/dhclient/dhclient.c
  stable/12/sbin/md5/md5.c
  stable/12/usr.bin/cmp/cmp.c
  stable/12/usr.bin/diff/diffreg.c
  stable/12/usr.bin/diff3/diff3.c
  stable/12/usr.bin/elfdump/elfdump.c
  stable/12/usr.bin/indent/indent.c
  stable/12/usr.bin/jot/jot.c
  stable/12/usr.bin/ktrdump/ktrdump.c
  stable/12/usr.bin/lam/lam.c
  stable/12/usr.bin/rwho/rwho.c
  stable/12/usr.bin/tee/tee.c
  stable/12/usr.bin/uniq/uniq.c
  stable/12/usr.bin/units/units.c
  stable/12/usr.bin/write/write.c
  stable/12/usr.sbin/rwhod/rwhod.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/bin/dd/dd.c
==
--- stable/12/bin/dd/dd.c   Fri Dec  6 18:15:27 2019(r355454)
+++ stable/12/bin/dd/dd.c   Fri Dec  6 18:26:34 2019(r355455)
@@ -157,7 +157,7 @@ setup(void)
getfdtype();
 
cap_rights_init(, CAP_READ, CAP_SEEK);
-   if (cap_rights_limit(in.fd, ) == -1 && errno != ENOSYS)
+   if (caph_rights_limit(in.fd, ) == -1)
err(1, "unable to limit capability rights");
 
if (files_cnt > 1 && !(in.flags & ISTAPE))
@@ -188,10 +188,9 @@ setup(void)
 
getfdtype();
 
-   if (cap_rights_limit(out.fd, ) == -1 && errno != ENOSYS)
+   if (caph_rights_limit(out.fd, ) == -1)
err(1, "unable to limit capability rights");
-   if (cap_ioctls_limit(out.fd, cmds, nitems(cmds)) == -1 &&
-   errno != ENOSYS)
+   if (caph_ioctls_limit(out.fd, cmds, nitems(cmds)) == -1)
err(1, "unable to limit capability rights");
 
if (in.fd != STDIN_FILENO && out.fd != STDIN_FILENO) {

Modified: stable/12/sbin/dhclient/bpf.c
==
--- stable/12/sbin/dhclient/bpf.c   Fri Dec  6 18:15:27 2019
(r355454)
+++ stable/12/sbin/dhclient/bpf.c   Fri Dec  6 18:26:34 2019
(r355455)
@@ -57,6 +57,8 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 
+#include 
+
 #define BPF_FORMAT "/dev/bpf%d"
 
 /*
@@ -164,7 +166,7 @@ if_register_send(struct interface_info *info)
error("Cannot lock bpf");
 
cap_rights_init(, CAP_WRITE);
-   if (cap_rights_limit(info->wfdesc, ) < 0 && errno != ENOSYS)
+   if (caph_rights_limit(info->wfdesc, ) < 0)
error("Can't limit bpf descriptor: %m");
 
/*
@@ -270,9 +272,9 @@ if_register_receive(struct interface_info *info)
error("Cannot lock bpf");
 
cap_rights_init(, CAP_IOCTL, CAP_EVENT, CAP_READ);
-   if (cap_rights_limit(info->rfdesc, ) < 0 && errno != ENOSYS)
+   if (caph_rights_limit(info->rfdesc, ) < 0)
error("Can't limit bpf descriptor: %m");
-   if (cap_ioctls_limit(info->rfdesc, cmds, 2) < 0 && errno != ENOSYS)
+   if (caph_ioctls_limit(info->rfdesc, cmds, 2) < 0)
error("Can't limit ioctls for bpf descriptor: %m");
 }
 

Modified: stable/12/sbin/dhclient/dhclient.c
==
--- stable/12/sbin/dhclient/dhclient.c  Fri Dec  6 18:15:27 2019
(r355454)
+++ stable/12/sbin/dhclient/dhclient.c  Fri Dec  6 18:26:34 2019
(r355455)
@@ -512,7 +512,7 @@ main(int argc, char *argv[])
close(pipe_fd[0]);
privfd = pipe_fd[1];
cap_rights_init(, CAP_READ, CAP_WRITE);
-   if (cap_rights_limit(privfd, ) < 0 && errno != ENOSYS)
+   if (caph_rights_limit(privfd, ) < 0)
error("can't limit private descriptor: %m");
 
if ((fd = open(path_dhclient_db, O_RDONLY|O_EXLOCK|O_CREAT, 0)) == -1)
@@ -526,7 +526,7 @@ main(int argc, char *argv[])
if (shutdown(routefd, SHUT_WR) < 0)
error("can't shutdown route socket: %m");
cap_rights_init(, CAP_EVENT, CAP_READ);
-   if (cap_rights_limit(routefd, ) < 0 && errno != ENOSYS)
+   if (caph_rights_limit(routefd, ) < 0)
error("can't limit route socket: %m");
 
endpwent();
@@ -1928,12 +1928,10 @@ rewrite_client_leases(void)
error("can't create %s: %m", path_dhclient_db);
cap_rights_init(, CAP_FCNTL, CAP_FSTAT, CAP_FSYNC,
CAP_FTRUNCATE, CAP_SEEK, CAP_WRITE);
-   if (cap_rights_limit(fileno(leaseFile), ) < 0 &&
-   errno != ENOSYS) {
+   if (caph_rights_limit(fileno(leaseFile), ) < 0) {
error("can't limit lease descriptor: %m");
}
-   if (cap_fcntls_limit(fileno(leaseFile), CAP_FCNTL_GETFL) < 0 &&
-   errno != ENOSYS) {
+   if 

svn commit: r355454 - stable/11/sys/dev/bwn

2019-12-06 Thread Brooks Davis
Author: brooks
Date: Fri Dec  6 18:15:27 2019
New Revision: 355454
URL: https://svnweb.freebsd.org/changeset/base/355454

Log:
  MFC r355139:
  
  Fix a logic bug when "mask" contains a ?: operator.
  
  Newer versions of clang warn that '&' evaluates before '?:'.
  
  Reviewed by:  markj
  Sponsored by: DARPA, AFRL
  Differential Revision:https://reviews.freebsd.org/D22573

Modified:
  stable/11/sys/dev/bwn/if_bwnvar.h
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/dev/bwn/if_bwnvar.h
==
--- stable/11/sys/dev/bwn/if_bwnvar.h   Fri Dec  6 17:58:27 2019
(r355453)
+++ stable/11/sys/dev/bwn/if_bwnvar.h   Fri Dec  6 18:15:27 2019
(r355454)
@@ -125,7 +125,7 @@ struct bwn_mac;
mac->mac_phy.phy_maskset(mac, offset, mask, 0); \
} else  \
BWN_PHY_WRITE(mac, offset,  \
-   BWN_PHY_READ(mac, offset) & mask);  \
+   BWN_PHY_READ(mac, offset) & (mask));\
 } while (0)
 #defineBWN_PHY_COPY(mac, dst, src) do {
\
KASSERT(mac->mac_status < BWN_MAC_STATUS_INITED ||  \
___
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: r355453 - stable/12/sys/dev/bwn

2019-12-06 Thread Brooks Davis
Author: brooks
Date: Fri Dec  6 17:58:27 2019
New Revision: 355453
URL: https://svnweb.freebsd.org/changeset/base/355453

Log:
  MFC r355139:
  
  Fix a logic bug when "mask" contains a ?: operator.
  
  Newer versions of clang warn that '&' evaluates before '?:'.
  
  Reviewed by:  markj
  Sponsored by: DARPA, AFRL
  Differential Revision:https://reviews.freebsd.org/D22573

Modified:
  stable/12/sys/dev/bwn/if_bwnvar.h
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/dev/bwn/if_bwnvar.h
==
--- stable/12/sys/dev/bwn/if_bwnvar.h   Fri Dec  6 16:53:42 2019
(r355452)
+++ stable/12/sys/dev/bwn/if_bwnvar.h   Fri Dec  6 17:58:27 2019
(r355453)
@@ -129,7 +129,7 @@ struct bwn_mac;
mac->mac_phy.phy_maskset(mac, offset, mask, 0); \
} else  \
BWN_PHY_WRITE(mac, offset,  \
-   BWN_PHY_READ(mac, offset) & mask);  \
+   BWN_PHY_READ(mac, offset) & (mask));\
 } while (0)
 #defineBWN_PHY_COPY(mac, dst, src) do {
\
KASSERT(mac->mac_status < BWN_MAC_STATUS_INITED ||  \
___
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: r355444 - in head/sys: arm/mv arm64/conf conf

2019-12-06 Thread Ian Lepore
On Fri, 2019-12-06 at 12:55 +, Luiz Otavio O Souza wrote:
> Author: loos
> Date: Fri Dec  6 12:55:39 2019
> New Revision: 355444
> URL: https://svnweb.freebsd.org/changeset/base/355444
> 
> Log:
>   Add the SPI driver for the Marvell Armada 37x0 SoC.
>   
>   Interrupt based driver, implements SPI mode and clock configuration.
>   
>   Tested on espressobin and SG-3200.
>   
>   Sponsored by:   Rubicon Communications, LLC (Netgate)
> 
> Added:
>   head/sys/arm/mv/a37x0_spi.c   (contents, props changed)
> Modified:
>   head/sys/arm64/conf/GENERIC
>   head/sys/conf/files.arm64
> 
> Added: head/sys/arm/mv/a37x0_spi.c
> 
> 
> +static int
> +a37x0_spi_detach(device_t dev)
> +{
> + struct a37x0_spi_softc *sc;
> +
> + bus_generic_detach(dev);
> 

It's possible for detaching children to fail (like if one of them
returns EBUSY from its detach), in which case you should bail on your
detach and return the error status.  Also, this needs a
device_destroy_children() here after detaching them, to remove the
spibus child added in attach (in case the module is unloaded then
reloaded, that avoids adding a second copy of the child).

-- Ian


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


svn commit: r355452 - head/sys/netinet6

2019-12-06 Thread Bjoern A. Zeeb
Author: bz
Date: Fri Dec  6 16:53:42 2019
New Revision: 355452
URL: https://svnweb.freebsd.org/changeset/base/355452

Log:
  Update comment.
  
  Update the comment related to SIIT and v4mapped addresses being rejected
  by us when coming from the wire given we have supported IPv6-only kernels
  for a few years now.
  See also draft-itojun-v6ops-v4mapped-harmful.
  
  Suggested by: melifaro
  MFC after:2 weeks

Modified:
  head/sys/netinet6/ip6_input.c

Modified: head/sys/netinet6/ip6_input.c
==
--- head/sys/netinet6/ip6_input.c   Fri Dec  6 16:48:36 2019
(r355451)
+++ head/sys/netinet6/ip6_input.c   Fri Dec  6 16:53:42 2019
(r355452)
@@ -677,11 +677,10 @@ ip6_input(struct mbuf *m)
 * and bypass security checks (act as if it was from 127.0.0.1 by using
 * IPv6 src :::127.0.0.1).  Be cautious.
 *
-* This check chokes if we are in an SIIT cloud.  As none of BSDs
-* support IPv4-less kernel compilation, we cannot support SIIT
-* environment at all.  So, it makes more sense for us to reject any
-* malicious packets for non-SIIT environment, than try to do a
-* partial support for SIIT environment.
+* We have supported IPv6-only kernels for a few years and this issue
+* has not come up.  The world seems to move mostly towards not using
+* v4mapped on the wire, so it makes sense for us to keep rejecting
+* any such packets.
 */
if (IN6_IS_ADDR_V4MAPPED(>ip6_src) ||
IN6_IS_ADDR_V4MAPPED(>ip6_dst)) {
___
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: r355451 - head/sys/geom

2019-12-06 Thread Alexander Motin
Author: mav
Date: Fri Dec  6 16:48:36 2019
New Revision: 355451
URL: https://svnweb.freebsd.org/changeset/base/355451

Log:
  Remove some branching from GEOM_DISK hot path.
  
  pp->private just can not be NULL in those places.
  
  In g_disk_start() and g_disk_ioctl() both dp != NULL and !dp->d_destroyed
  should always be true if disk_gone() and disk_destroy() are used properly,
  since GEOM does not send requests to errored providers.  If the protocol is
  not followed, then no amount of additional checks here give real safety.
  
  In g_disk_access() though the checks are useful, since GEOM blocks only
  new opens for errored providers, but allows closes.  It should not happen
  if disk_gone() and disk_destroy() are used properly, but may otherwise.
  
  To improve cases when disk_gone() is not used, call it from disk_destroy().
  It does not give full guaranties, but it errors the provider and makes
  GEOM block unwanted requests at least after some race.
  
  MFC after:2 weeks

Modified:
  head/sys/geom/geom_disk.c

Modified: head/sys/geom/geom_disk.c
==
--- head/sys/geom/geom_disk.c   Fri Dec  6 16:42:58 2019(r355450)
+++ head/sys/geom/geom_disk.c   Fri Dec  6 16:48:36 2019(r355451)
@@ -108,7 +108,7 @@ g_disk_access(struct g_provider *pp, int r, int w, int
pp->name, r, w, e);
g_topology_assert();
sc = pp->private;
-   if (sc == NULL || (dp = sc->dp) == NULL || dp->d_destroyed) {
+   if ((dp = sc->dp) == NULL || dp->d_destroyed) {
/*
 * Allow decreasing access count even if disk is not
 * available anymore.
@@ -274,6 +274,8 @@ g_disk_ioctl(struct g_provider *pp, u_long cmd, void *
 
sc = pp->private;
dp = sc->dp;
+   KASSERT(dp != NULL && !dp->d_destroyed,
+   ("g_disk_ioctl(%lx) on destroyed disk %s", cmd, pp->name));
 
if (dp->d_ioctl == NULL)
return (ENOIOCTL);
@@ -432,10 +434,9 @@ g_disk_start(struct bio *bp)
biotrack(bp, __func__);
 
sc = bp->bio_to->private;
-   if (sc == NULL || (dp = sc->dp) == NULL || dp->d_destroyed) {
-   g_io_deliver(bp, ENXIO);
-   return;
-   }
+   dp = sc->dp;
+   KASSERT(dp != NULL && !dp->d_destroyed,
+   ("g_disk_start(%p) on destroyed disk %s", bp, bp->bio_to->name));
error = EJUSTRETURN;
switch(bp->bio_cmd) {
case BIO_DELETE:
@@ -896,8 +897,9 @@ void
 disk_destroy(struct disk *dp)
 {
 
-   g_cancel_event(dp);
+   disk_gone(dp);
dp->d_destroyed = 1;
+   g_cancel_event(dp);
if (dp->d_devstat != NULL)
devstat_remove_entry(dp->d_devstat);
g_post_event(g_disk_destroy, dp, M_WAITOK, NULL);
@@ -922,6 +924,16 @@ disk_gone(struct disk *dp)
struct g_provider *pp;
 
mtx_pool_lock(mtxpool_sleep, dp);
+
+   /*
+* Second wither call makes no sense, plus we can not access the list
+* of providers without topology lock after calling wither once.
+*/
+   if (dp->d_goneflag != 0) {
+   mtx_pool_unlock(mtxpool_sleep, dp);
+   return;
+   }
+
dp->d_goneflag = 1;
 
/*
@@ -946,13 +958,11 @@ disk_gone(struct disk *dp)
mtx_pool_unlock(mtxpool_sleep, dp);
 
gp = dp->d_geom;
-   if (gp != NULL) {
-   pp = LIST_FIRST(>provider);
-   if (pp != NULL) {
-   KASSERT(LIST_NEXT(pp, provider) == NULL,
-   ("geom %p has more than one provider", gp));
-   g_wither_provider(pp, ENXIO);
-   }
+   pp = LIST_FIRST(>provider);
+   if (pp != NULL) {
+   KASSERT(LIST_NEXT(pp, provider) == NULL,
+   ("geom %p has more than one provider", gp));
+   g_wither_provider(pp, ENXIO);
}
 }
 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r355450 - head/sys/netinet6

2019-12-06 Thread Bjoern A. Zeeb
Author: bz
Date: Fri Dec  6 16:42:58 2019
New Revision: 355450
URL: https://svnweb.freebsd.org/changeset/base/355450

Log:
  ip6_input: remove redundant v4mapped check
  
  In ip6_input() we apply the same v4mapped address check twice. The only
  case which skipps the first one is M_FASTFWD_OURS which should have passed
  the check on the firstinput pass and passed the firewall.
  Remove the 2nd redundant check.
  
  Reviewed by:  kp, melifaro
  MFC after:2 weeks
  Sponsored by: Netflix (originally)
  Differential Revision:https://reviews.freebsd.org/D22462

Modified:
  head/sys/netinet6/ip6_input.c

Modified: head/sys/netinet6/ip6_input.c
==
--- head/sys/netinet6/ip6_input.c   Fri Dec  6 16:35:48 2019
(r355449)
+++ head/sys/netinet6/ip6_input.c   Fri Dec  6 16:42:58 2019
(r355450)
@@ -897,24 +897,6 @@ passin:
return;
}
 
-   ip6 = mtod(m, struct ip6_hdr *);
-
-   /*
-* Malicious party may be able to use IPv4 mapped addr to confuse
-* tcp/udp stack and bypass security checks (act as if it was from
-* 127.0.0.1 by using IPv6 src :::127.0.0.1).  Be cautious.
-*
-* For SIIT end node behavior, you may want to disable the check.
-* However, you will  become vulnerable to attacks using IPv4 mapped
-* source.
-*/
-   if (IN6_IS_ADDR_V4MAPPED(>ip6_src) ||
-   IN6_IS_ADDR_V4MAPPED(>ip6_dst)) {
-   IP6STAT_INC(ip6s_badscope);
-   in6_ifstat_inc(rcvif, ifs6_in_addrerr);
-   goto bad;
-   }
-
/*
 * Tell launch routine the next header
 */
___
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: r355449 - head/sys/netinet

2019-12-06 Thread Bjoern A. Zeeb
Author: bz
Date: Fri Dec  6 16:35:48 2019
New Revision: 355449
URL: https://svnweb.freebsd.org/changeset/base/355449

Log:
  carp: replace caddr_t with char *
  
  Change the remaining caddr_t usages to char * following the removal
  of the KAME macros
  
  No functional change.
  
  Requested by: glebius
  Reviewed by:  glebius
  MFC after:2 weeks
  Sponsored by: Netflix (originally)
  Differential Revision:https://reviews.freebsd.org/D22399

Modified:
  head/sys/netinet/ip_carp.c
  head/sys/netinet/ip_carp.h

Modified: head/sys/netinet/ip_carp.c
==
--- head/sys/netinet/ip_carp.c  Fri Dec  6 16:34:04 2019(r355448)
+++ head/sys/netinet/ip_carp.c  Fri Dec  6 16:35:48 2019(r355449)
@@ -575,7 +575,7 @@ carp6_input(struct mbuf **mp, int *offp, int proto)
return (IPPROTO_DONE);
}
}
-   ch = (struct carp_header *)(mtod(m, caddr_t) + *offp);
+   ch = (struct carp_header *)(mtod(m, char *) + *offp);
 
 
/* verify the CARP checksum */
@@ -978,6 +978,7 @@ carp_send_ad_locked(struct carp_softc *sc)
 #endif /* INET */
 #ifdef INET6
if (sc->sc_naddrs6) {
+   struct epoch_tracker et;
struct ip6_hdr *ip6;
 
m = m_gethdr(M_NOWAIT, MT_DATA);
@@ -1031,8 +1032,10 @@ carp_send_ad_locked(struct carp_softc *sc)
 
CARPSTATS_INC(carps_opackets6);
 
+   NET_EPOCH_ENTER(et);
carp_send_ad_error(sc, ip6_output(m, NULL, NULL, 0,
>sc_carpdev->if_carp->cif_im6o, NULL, NULL));
+   NET_EPOCH_EXIT(et);
}
 #endif /* INET6 */
 
@@ -1190,7 +1193,7 @@ carp_iamatch6(struct ifnet *ifp, struct in6_addr *tadd
return (ifa);
 }
 
-caddr_t
+char *
 carp_macmatch6(struct ifnet *ifp, struct mbuf *m, const struct in6_addr *taddr)
 {
struct ifaddr *ifa;
@@ -1847,7 +1850,7 @@ carp_ioctl(struct ifreq *ifr, u_long cmd, struct threa
carp_carprcp(, sc, priveleged);
carpr.carpr_count = count;
error = copyout(,
-   (caddr_t)ifr_data_get_ptr(ifr) +
+   (char *)ifr_data_get_ptr(ifr) +
(i * sizeof(carpr)), sizeof(carpr));
if (error) {
CIF_UNLOCK(ifp->if_carp);

Modified: head/sys/netinet/ip_carp.h
==
--- head/sys/netinet/ip_carp.h  Fri Dec  6 16:34:04 2019(r355448)
+++ head/sys/netinet/ip_carp.h  Fri Dec  6 16:35:48 2019(r355449)
@@ -149,7 +149,7 @@ int carp_output (struct ifnet *, struct mbuf *,
 intcarp_master(struct ifaddr *);
 intcarp_iamatch(struct ifaddr *, uint8_t **);
 struct ifaddr  *carp_iamatch6(struct ifnet *, struct in6_addr *);
-caddr_tcarp_macmatch6(struct ifnet *, struct mbuf *, const 
struct in6_addr *);
+char * carp_macmatch6(struct ifnet *, struct mbuf *, const struct 
in6_addr *);
 intcarp_forus(struct ifnet *, u_char *);
 
 /* These are external networking stack hooks for CARP */
@@ -174,7 +174,7 @@ extern int (*carp_iamatch_p)(struct ifaddr *, uint8_t 
 #ifdef INET6
 /* netinet6/nd6_nbr.c */
 extern struct ifaddr *(*carp_iamatch6_p)(struct ifnet *, struct in6_addr *);
-extern caddr_t (*carp_macmatch6_p)(struct ifnet *, struct mbuf *,
+extern char * (*carp_macmatch6_p)(struct ifnet *, struct mbuf *,
 const struct in6_addr *);
 #endif
 #endif
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r355448 - head/sys/kern

2019-12-06 Thread Bjoern A. Zeeb
Author: bz
Date: Fri Dec  6 16:34:04 2019
New Revision: 355448
URL: https://svnweb.freebsd.org/changeset/base/355448

Log:
  Improve EPOCH_TRACE
  
  Two changes to EPOCH_TRACE:
  (1) add a sysctl to surpress the backtrace from epoch_trace_report().
  Sometimes the log line for the recursion is enough and the
  backtrace massively spams the console.
  (2) In order to be able to go without the backtrace do not only
  print where the previous occurance happened, but also where
  the current one happens.  That way we have file:line information
  for both and can look at them without the need for getting line
  numbers from backtrace and a debugging tool.
  
  Reviewed by:  glebius
  Sponsored by: Netflix (originally)
  Differential Revision:https://reviews.freebsd.org/D22641

Modified:
  head/sys/kern/subr_epoch.c

Modified: head/sys/kern/subr_epoch.c
==
--- head/sys/kern/subr_epoch.c  Fri Dec  6 16:20:22 2019(r355447)
+++ head/sys/kern/subr_epoch.c  Fri Dec  6 16:34:04 2019(r355448)
@@ -169,6 +169,10 @@ RB_GENERATE_STATIC(stacktree, stackentry, se_node, sta
 static struct mtx epoch_stacks_lock;
 MTX_SYSINIT(epochstacks, _stacks_lock, "epoch_stacks", MTX_DEF);
 
+static bool epoch_trace_stack_print = true;
+SYSCTL_BOOL(_kern_epoch, OID_AUTO, trace_stack_print, CTLFLAG_RWTUN,
+_trace_stack_print, 0, "Print stack traces on epoch reports");
+
 static void epoch_trace_report(const char *fmt, ...) __printflike(1, 2);
 static inline void
 epoch_trace_report(const char *fmt, ...)
@@ -197,7 +201,8 @@ epoch_trace_report(const char *fmt, ...)
va_start(ap, fmt);
(void)vprintf(fmt, ap);
va_end(ap);
-   stack_print_ddb(_stack);
+   if (epoch_trace_stack_print)
+   stack_print_ddb(_stack);
 }
 
 static inline void
@@ -209,8 +214,9 @@ epoch_trace_enter(struct thread *td, epoch_t epoch, ep
SLIST_FOREACH(iet, >td_epochs, et_tlink)
if (iet->et_epoch == epoch)
epoch_trace_report("Recursively entering epoch %s "
-   "previously entered at %s:%d\n",
-   epoch->e_name, iet->et_file, iet->et_line);
+   "at %s:%d, previously entered at %s:%d\n",
+   epoch->e_name, file, line,
+   iet->et_file, iet->et_line);
et->et_epoch = epoch;
et->et_file = file;
et->et_line = line;
@@ -223,9 +229,10 @@ epoch_trace_exit(struct thread *td, epoch_t epoch, epo
 {
 
if (SLIST_FIRST(>td_epochs) != et) {
-   epoch_trace_report("Exiting epoch %s in a not nested order. "
-   "Most recently entered %s at %s:%d\n",
+   epoch_trace_report("Exiting epoch %s in a not nested order "
+   "at %s:%d. Most recently entered %s at %s:%d\n",
epoch->e_name,
+   file, line,
SLIST_FIRST(>td_epochs)->et_epoch->e_name,
SLIST_FIRST(>td_epochs)->et_file,
SLIST_FIRST(>td_epochs)->et_line);
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r355447 - head/sys/dev/mlx5

2019-12-06 Thread Hans Petter Selasky
Author: hselasky
Date: Fri Dec  6 16:20:22 2019
New Revision: 355447
URL: https://svnweb.freebsd.org/changeset/base/355447

Log:
  Fix compilation issue with mlx5core and sparc64 (gcc48):
  
  sys/dev/mlx5/mlx5_en/mlx5_en_tx.c:335: error: requested alignment is not a 
constant
  
  MFC after:1 week
  Sponsored by: Mellanox Technologies

Modified:
  head/sys/dev/mlx5/qp.h

Modified: head/sys/dev/mlx5/qp.h
==
--- head/sys/dev/mlx5/qp.h  Fri Dec  6 15:36:32 2019(r355446)
+++ head/sys/dev/mlx5/qp.h  Fri Dec  6 16:20:22 2019(r355447)
@@ -143,11 +143,8 @@ enum {
MLX5_WQE_CTRL_SOLICITED = 1 << 1,
 };
 
-enum {
-   MLX5_SEND_WQE_DS= 16,
-   MLX5_SEND_WQE_BB= 64,
-};
-
+#defineMLX5_SEND_WQE_DS16
+#defineMLX5_SEND_WQE_BB64
 #define MLX5_SEND_WQEBB_NUM_DS (MLX5_SEND_WQE_BB / MLX5_SEND_WQE_DS)
 
 enum {
___
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: r355444 - in head/sys: arm/mv arm64/conf conf

2019-12-06 Thread Hans Petter Selasky

On 2019-12-06 13:55, Luiz Otavio O Souza wrote:

Author: loos
Date: Fri Dec  6 12:55:39 2019
New Revision: 355444
URL: https://svnweb.freebsd.org/changeset/base/355444

Log:
   Add the SPI driver for the Marvell Armada 37x0 SoC.
   
   Interrupt based driver, implements SPI mode and clock configuration.
   
   Tested on espressobin and SG-3200.
   
   Sponsored by:	Rubicon Communications, LLC (Netgate)


Added:


This breaks aarch64. You need to add #include 

somewhere:

13:30:54 ctfconvert -L VERSION -g bcm2835_rng.o
13:30:54 --- a37x0_spi.o ---
13:30:54 /usr/src/sys/arm/mv/a37x0_spi.c:212:2: error: implicit 
declaration of function 'mtx_init' is invalid in C99 
[-Werror,-Wimplicit-function-declaration]

13:30:54 mtx_init(>sc_mtx, "a37x0_spi", NULL, MTX_DEF);
13:30:54 ^
13:30:54 --- mv_ap806_gicp.o ---
13:30:54 cc -target aarch64-unknown-freebsd13.0 
--sysroot=/usr/obj/usr/src/arm64.aarch64/tmp 
-B/usr/obj/usr/src/arm64.aarch64/tmp/usr/bin -


https://ci.freebsd.org/tinderbox/

--HPS

___
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: r355446 - in head/sys: conf dev/mlx5 dev/mlx5/mlx5_en modules/mlx5en

2019-12-06 Thread Hans Petter Selasky
Author: hselasky
Date: Fri Dec  6 15:36:32 2019
New Revision: 355446
URL: https://svnweb.freebsd.org/changeset/base/355446

Log:
  Implement hardware TLS via send tags for mlx5en(4), which is supported by
  ConnectX-6 DX.
  
  Currently TLS v1.2 and v1.3 with AES 128/256 crypto over TCP/IP (v4
  and v6) is supported.
  
  A per PCI device UMA zone is used to manage the memory of the send
  tags.  To optimize performance some crypto contexts may be cached by
  the UMA zone, until the UMA zone finishes the memory of the given send
  tag.
  
  An asynchronous task is used manage setup of the send tags towards the
  firmware. Most importantly setting the AES 128/256 bit pre-shared keys
  for the crypto context.
  
  Updating the state of the AES crypto engine and encrypting data, is
  all done in the fast path. Each send tag tracks the TCP sequence
  number in order to detect non-contiguous blocks of data, which may
  require a dump of prior unencrypted data, to restore the crypto state
  prior to wire transmission.
  
  Statistics counters have been added to count the amount of TLS data
  transmitted in total, and the amount of TLS data which has been dumped
  prior to transmission. When non-contiguous TCP sequence numbers are
  detected, the software needs to dump the beginning of the current TLS
  record up until the point of retransmission. All TLS counters utilize
  the counter(9) API.
  
  In order to enable hardware TLS offload the following sysctls must be set:
  kern.ipc.mb_use_ext_pgs=1
  kern.ipc.tls.ifnet.permitted=1
  kern.ipc.tls.enable=1
  
  Sponsored by: Mellanox Technologies

Added:
  head/sys/dev/mlx5/mlx5_en/en_hw_tls.h   (contents, props changed)
  head/sys/dev/mlx5/mlx5_en/mlx5_en_hw_tls.c   (contents, props changed)
Modified:
  head/sys/conf/files
  head/sys/dev/mlx5/device.h
  head/sys/dev/mlx5/mlx5_en/en.h
  head/sys/dev/mlx5/mlx5_en/en_rl.h
  head/sys/dev/mlx5/mlx5_en/mlx5_en_ethtool.c
  head/sys/dev/mlx5/mlx5_en/mlx5_en_main.c
  head/sys/dev/mlx5/mlx5_en/mlx5_en_rl.c
  head/sys/dev/mlx5/mlx5_en/mlx5_en_tx.c
  head/sys/modules/mlx5en/Makefile

Modified: head/sys/conf/files
==
--- head/sys/conf/files Fri Dec  6 15:01:36 2019(r355445)
+++ head/sys/conf/files Fri Dec  6 15:36:32 2019(r355446)
@@ -4781,6 +4781,8 @@ dev/mlx5/mlx5_en/mlx5_en_tx.c 
optional mlx5en pci in
compile-with "${OFED_C}"
 dev/mlx5/mlx5_en/mlx5_en_flow_table.c  optional mlx5en pci inet inet6  
\
compile-with "${OFED_C}"
+dev/mlx5/mlx5_en/mlx5_en_hw_tls.c  optional mlx5en pci inet inet6  
\
+   compile-with "${OFED_C}"
 dev/mlx5/mlx5_en/mlx5_en_rx.c  optional mlx5en pci inet inet6  
\
compile-with "${OFED_C}"
 dev/mlx5/mlx5_en/mlx5_en_rl.c  optional mlx5en pci inet inet6  
\

Modified: head/sys/dev/mlx5/device.h
==
--- head/sys/dev/mlx5/device.h  Fri Dec  6 15:01:36 2019(r355445)
+++ head/sys/dev/mlx5/device.h  Fri Dec  6 15:36:32 2019(r355446)
@@ -361,6 +361,7 @@ enum {
MLX5_OPCODE_ATOMIC_MASKED_FA= 0x15,
MLX5_OPCODE_BIND_MW = 0x18,
MLX5_OPCODE_CONFIG_CMD  = 0x1f,
+   MLX5_OPCODE_DUMP= 0x23,
 
MLX5_RECV_OPCODE_RDMA_WRITE_IMM = 0x00,
MLX5_RECV_OPCODE_SEND   = 0x01,

Modified: head/sys/dev/mlx5/mlx5_en/en.h
==
--- head/sys/dev/mlx5/mlx5_en/en.h  Fri Dec  6 15:01:36 2019
(r355445)
+++ head/sys/dev/mlx5/mlx5_en/en.h  Fri Dec  6 15:36:32 2019
(r355446)
@@ -53,6 +53,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "opt_rss.h"
 
@@ -167,6 +168,7 @@ typedef void (mlx5e_cq_comp_t)(struct mlx5_core_cq *);
 
 #defineMLX5E_STATS_COUNT(a, ...) a
 #defineMLX5E_STATS_VAR(a, b, c, ...) b c;
+#defineMLX5E_STATS_COUNTER(a, b, c, ...) counter_##b##_t c;
 #defineMLX5E_STATS_DESC(a, b, c, d, e, ...) d, e,
 
 #defineMLX5E_VPORT_STATS(m)
\
@@ -724,6 +726,7 @@ struct mlx5e_params_ethtool {
u8  fec_avail_10x_25x[MLX5E_MAX_FEC_10X_25X];
u16 fec_avail_50x[MLX5E_MAX_FEC_50X];
u32 fec_mode_active;
+   u32 hw_mtu_msb;
 };
 
 struct mlx5e_cq {
@@ -775,6 +778,7 @@ struct mlx5e_rq {
 struct mlx5e_sq_mbuf {
bus_dmamap_t dma_map;
struct mbuf *mbuf;
+   volatile s32 *p_refcount;   /* in use refcount, if any */
u32 num_bytes;
u32 num_wqebbs;
 };
@@ -959,9 +963,14 @@ struct mlx5e_flow_tables {
struct mlx5e_flow_table inner_rss;
 };
 
-#ifdef RATELIMIT
+struct mlx5e_xmit_args {
+   volatile s32 *pref;
+   u32 tisn;
+   u16 ihs;
+};
+
 #include "en_rl.h"
-#endif
+#include "en_hw_tls.h"

svn commit: r355445 - stable/12/sys/vm

2019-12-06 Thread Mark Johnston
Author: markj
Date: Fri Dec  6 15:01:36 2019
New Revision: 355445
URL: https://svnweb.freebsd.org/changeset/base/355445

Log:
  MFC r355001:
  Fix locking in vm_reserv_reclaim_contig().

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

Modified: stable/12/sys/vm/vm_reserv.c
==
--- stable/12/sys/vm/vm_reserv.cFri Dec  6 12:55:39 2019
(r355444)
+++ stable/12/sys/vm/vm_reserv.cFri Dec  6 15:01:36 2019
(r355445)
@@ -181,10 +181,11 @@ popmap_is_set(popmap_t popmap[], int i)
  *
  * A partially populated reservation can be broken and reclaimed at any time.
  *
- * r - vm_reserv_lock
+ * c - constant after boot
  * d - vm_reserv_domain_lock
  * o - vm_reserv_object_lock
- * c - constant after boot
+ * r - vm_reserv_lock
+ * s - vm_reserv_domain_scan_lock
  */
 struct vm_reserv {
struct mtx  lock;   /* reservation lock. */
@@ -200,6 +201,8 @@ struct vm_reserv {
popmap_tpopmap[NPOPMAP_MAX];/* (r) bit vector, used pages */
 };
 
+TAILQ_HEAD(vm_reserv_queue, vm_reserv);
+
 #definevm_reserv_lockptr(rv)   (&(rv)->lock)
 #definevm_reserv_assert_locked(rv) 
\
mtx_assert(vm_reserv_lockptr(rv), MA_OWNED)
@@ -238,18 +241,26 @@ static vm_reserv_t vm_reserv_array;
  * is the least recently changed, partially populated reservation.
  *
  * Access to this queue is synchronized by the per-domain reservation lock.
+ * Threads reclaiming free pages from the queue must hold the per-domain scan
+ * lock.
  */
 struct vm_reserv_domain {
-   struct mtx lock;
-   TAILQ_HEAD(, vm_reserv) partpop;
+   struct mtx  lock;
+   struct vm_reserv_queue  partpop;/* (d) */
+   struct vm_reservmarker; /* (d, s) scan marker/lock */
 } __aligned(CACHE_LINE_SIZE);
 
 static struct vm_reserv_domain vm_rvd[MAXMEMDOM];
 
 #definevm_reserv_domain_lockptr(d) (_rvd[(d)].lock)
+#definevm_reserv_domain_assert_locked(d)   \
+   mtx_assert(vm_reserv_domain_lockptr(d), MA_OWNED)
 #definevm_reserv_domain_lock(d)
mtx_lock(vm_reserv_domain_lockptr(d))
 #definevm_reserv_domain_unlock(d)  
mtx_unlock(vm_reserv_domain_lockptr(d))
 
+#definevm_reserv_domain_scan_lock(d)   
mtx_lock(_rvd[(d)].marker.lock)
+#definevm_reserv_domain_scan_unlock(d) 
mtx_unlock(_rvd[(d)].marker.lock)
+
 static SYSCTL_NODE(_vm, OID_AUTO, reserv, CTLFLAG_RD, 0, "Reservation Info");
 
 static counter_u64_t vm_reserv_broken = EARLY_COUNTER;
@@ -350,6 +361,8 @@ sysctl_vm_reserv_partpopq(SYSCTL_HANDLER_ARGS)
unused_pages = 0;
vm_reserv_domain_lock(domain);
TAILQ_FOREACH(rv, _rvd[domain].partpop, partpopq) {
+   if (rv == _rvd[domain].marker)
+   continue;
counter++;
unused_pages += VM_LEVEL_0_NPAGES - rv->popcnt;
}
@@ -1156,7 +1169,8 @@ vm_reserv_init(void)
vm_paddr_t paddr;
struct vm_phys_seg *seg;
struct vm_reserv *rv;
-   int i, segind;
+   struct vm_reserv_domain *rvd;
+   int i, j, segind;
 
/*
 * Initialize the reservation array.  Specifically, initialize the
@@ -1175,8 +1189,18 @@ vm_reserv_init(void)
}
}
for (i = 0; i < MAXMEMDOM; i++) {
-   mtx_init(_rvd[i].lock, "VM reserv domain", NULL, MTX_DEF);
-   TAILQ_INIT(_rvd[i].partpop);
+   rvd = _rvd[i];
+   mtx_init(>lock, "vm reserv domain", NULL, MTX_DEF);
+   TAILQ_INIT(>partpop);
+   mtx_init(>marker.lock, "vm reserv marker", NULL, MTX_DEF);
+
+   /*
+* Fully populated reservations should never be present in the
+* partially populated reservation queues.
+*/
+   rvd->marker.popcnt = VM_LEVEL_0_NPAGES;
+   for (j = 0; j < NBPOPMAP; j++)
+   popmap_set(rvd->marker.popmap, j);
}
 
for (i = 0; i < VM_RESERV_OBJ_LOCK_COUNT; i++)
@@ -1226,50 +1250,71 @@ vm_reserv_level_iffullpop(vm_page_t m)
 }
 
 /*
- * Breaks the given partially populated reservation, releasing its free pages
- * to the physical memory allocator.
+ * Remove a partially populated reservation from the queue.
  */
 static void
-vm_reserv_reclaim(vm_reserv_t rv)
+vm_reserv_dequeue(vm_reserv_t rv)
 {
 
+   vm_reserv_domain_assert_locked(rv->domain);
vm_reserv_assert_locked(rv);
CTR5(KTR_VM, "%s: rv %p object %p popcnt %d inpartpop %d",
__FUNCTION__, rv, rv->object, rv->popcnt, rv->inpartpopq);
-   

Re: svn commit: r355436 - in head/sys: amd64/amd64 x86/x86

2019-12-06 Thread Eric van Gyzen


> On Dec 6, 2019, at 4:36 AM, Ed Maste  wrote:
> 
> On Thu, 5 Dec 2019 at 21:43, Scott Long  wrote:
>> 
>> Author: scottl
>> Date: Fri Dec  6 02:43:05 2019
>> New Revision: 355436
>> URL: https://svnweb.freebsd.org/changeset/base/355436
>> 
>> Log:
>>  Move the mds, irbs, and ssb mitigation knobs into machdep.mitigations.
> 
> If we're moving them and adding backwards-compatibility scaffolding we
> really should correct the sense of the sysctls at the same time.

I was just going to suggest that.  For some, 0 is secure; for others, 1 is 
secure.  Since they’re under “mitigations,” I think 1 should consistently mean 
“mitigated.”

Eric
___
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: r355436 - in head/sys: amd64/amd64 x86/x86

2019-12-06 Thread Ed Maste
On Thu, 5 Dec 2019 at 21:43, Scott Long  wrote:
>
> Author: scottl
> Date: Fri Dec  6 02:43:05 2019
> New Revision: 355436
> URL: https://svnweb.freebsd.org/changeset/base/355436
>
> Log:
>   Move the mds, irbs, and ssb mitigation knobs into machdep.mitigations.

If we're moving them and adding backwards-compatibility scaffolding we
really should correct the sense of the sysctls at the same time.
___
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: r355436 - in head/sys: amd64/amd64 x86/x86

2019-12-06 Thread Konstantin Belousov
On Fri, Dec 06, 2019 at 02:43:05AM +, Scott Long wrote:
> Author: scottl
> Date: Fri Dec  6 02:43:05 2019
> New Revision: 355436
> URL: https://svnweb.freebsd.org/changeset/base/355436
> 
> Log:
>   Move the mds, irbs, and ssb mitigation knobs into machdep.mitigations.
>   They're in both the old and new places in HEAD for the moment for
>   discussion and transition.  The old locations will be garbage collected
>   in 4 weeks.  MFCs to 12 an 11 will keep the old and new for transition
>   purposes.
>   
>   Reviewed by:kib
You did not updated security(7).

>   MFC after:  4 weeks
>   Sponsored by:   Intel
>   Differential Revision:  https://reviews.freebsd.org/D22590
> 
> Modified:
>   head/sys/amd64/amd64/machdep.c
>   head/sys/x86/x86/cpu_machdep.c
> 
> Modified: head/sys/amd64/amd64/machdep.c
> ==
> --- head/sys/amd64/amd64/machdep.cFri Dec  6 01:53:02 2019
> (r355435)
> +++ head/sys/amd64/amd64/machdep.cFri Dec  6 02:43:05 2019
> (r355436)
> @@ -1778,10 +1778,17 @@ hammer_time(u_int64_t modulep, u_int64_t physfree)
>   vty_set_preferred(VTY_VT);
>  
>   TUNABLE_INT_FETCH("hw.ibrs_disable", _ibrs_disable);
> + TUNABLE_INT_FETCH("machdep.mitigations.ibrs.disable", _ibrs_disable);
> +
>   TUNABLE_INT_FETCH("hw.spec_store_bypass_disable", _ssb_disable);
> + TUNABLE_INT_FETCH("machdep.mitigations.ssb.disable", _ssb_disable);
> +
>   TUNABLE_INT_FETCH("machdep.syscall_ret_l1d_flush",
>   _ret_l1d_flush_mode);
> +
>   TUNABLE_INT_FETCH("hw.mds_disable", _mds_disable);
> + TUNABLE_INT_FETCH("machdep.mitigations.mds.disable", _mds_disable);
> +
>   TUNABLE_INT_FETCH("machdep.mitigations.taa.enable", _taa_enable);
>  
>   finishidentcpu();   /* Final stage of CPU initialization */
> 
> Modified: head/sys/x86/x86/cpu_machdep.c
> ==
> --- head/sys/x86/x86/cpu_machdep.cFri Dec  6 01:53:02 2019
> (r355435)
> +++ head/sys/x86/x86/cpu_machdep.cFri Dec  6 02:43:05 2019
> (r355436)
> @@ -877,6 +877,12 @@ int hw_ibrs_disable = 1;
>  SYSCTL_INT(_hw, OID_AUTO, ibrs_active, CTLFLAG_RD, _ibrs_active, 0,
>  "Indirect Branch Restricted Speculation active");
>  
> +SYSCTL_NODE(_machdep_mitigations, OID_AUTO, ibrs, CTLFLAG_RW, 0,
> +"Indirect Branch Restricted Speculation active");
> +
> +SYSCTL_INT(_machdep_mitigations_ibrs, OID_AUTO, active, CTLFLAG_RD,
> +_ibrs_active, 0, "Indirect Branch Restricted Speculation active");
> +
>  void
>  hw_ibrs_recalculate(void)
>  {
> @@ -907,6 +913,11 @@ SYSCTL_PROC(_hw, OID_AUTO, ibrs_disable, CTLTYPE_INT |
>  CTLFLAG_NOFETCH | CTLFLAG_MPSAFE, NULL, 0, hw_ibrs_disable_handler, "I",
>  "Disable Indirect Branch Restricted Speculation");
>  
> +SYSCTL_PROC(_machdep_mitigations_ibrs, OID_AUTO, disable, CTLTYPE_INT |
> +CTLFLAG_RWTUN | CTLFLAG_NOFETCH | CTLFLAG_MPSAFE, NULL, 0,
> +hw_ibrs_disable_handler, "I",
> +"Disable Indirect Branch Restricted Speculation");
> +
>  int hw_ssb_active;
>  int hw_ssb_disable;
>  
> @@ -914,6 +925,12 @@ SYSCTL_INT(_hw, OID_AUTO, spec_store_bypass_disable_ac
>  _ssb_active, 0,
>  "Speculative Store Bypass Disable active");
>  
> +SYSCTL_NODE(_machdep_mitigations, OID_AUTO, ssb, CTLFLAG_RW, 0,
> +"Speculative Store Bypass Disable active");
> +
> +SYSCTL_INT(_machdep_mitigations_ssb, OID_AUTO, active, CTLFLAG_RD,
> +_ssb_active, 0, "Speculative Store Bypass Disable active");
> +
>  static void
>  hw_ssb_set(bool enable, bool for_all_cpus)
>  {
> @@ -967,6 +984,11 @@ SYSCTL_PROC(_hw, OID_AUTO, spec_store_bypass_disable, 
>  hw_ssb_disable_handler, "I",
>  "Speculative Store Bypass Disable (0 - off, 1 - on, 2 - auto");
>  
> +SYSCTL_PROC(_machdep_mitigations_ssb, OID_AUTO, disable, CTLTYPE_INT |
> +CTLFLAG_RWTUN | CTLFLAG_NOFETCH | CTLFLAG_MPSAFE, NULL, 0,
> +hw_ssb_disable_handler, "I",
> +"Speculative Store Bypass Disable (0 - off, 1 - on, 2 - auto");
> +
>  int hw_mds_disable;
>  
>  /*
> @@ -1016,6 +1038,14 @@ SYSCTL_PROC(_hw, OID_AUTO, mds_disable_state,
>  sysctl_hw_mds_disable_state_handler, "A",
>  "Microarchitectural Data Sampling Mitigation state");
>  
> +SYSCTL_NODE(_machdep_mitigations, OID_AUTO, mds, CTLFLAG_RW, 0,
> +"Microarchitectural Data Sampling Mitigation state");
> +
> +SYSCTL_PROC(_machdep_mitigations_mds, OID_AUTO, state,
> +CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, 0,
> +sysctl_hw_mds_disable_state_handler, "A",
> +"Microarchitectural Data Sampling Mitigation state");
> +
>  _Static_assert(__offsetof(struct pcpu, pc_mds_tmp) % 64 == 0, "MDS AVX512");
>  
>  void
> @@ -1172,6 +1202,11 @@ SYSCTL_PROC(_hw, OID_AUTO, mds_disable, CTLTYPE_INT |
>  "Microarchitectural Data Sampling Mitigation "
>  "(0 - off, 1 - on VERW, 2 - on SW, 3 - on AUTO");
>  
> 

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

2019-12-06 Thread Luiz Otavio O Souza
Author: loos
Date: Fri Dec  6 12:55:39 2019
New Revision: 355444
URL: https://svnweb.freebsd.org/changeset/base/355444

Log:
  Add the SPI driver for the Marvell Armada 37x0 SoC.
  
  Interrupt based driver, implements SPI mode and clock configuration.
  
  Tested on espressobin and SG-3200.
  
  Sponsored by: Rubicon Communications, LLC (Netgate)

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

Added: head/sys/arm/mv/a37x0_spi.c
==
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/sys/arm/mv/a37x0_spi.c Fri Dec  6 12:55:39 2019(r355444)
@@ -0,0 +1,494 @@
+/*-
+ * Copyright (c) 2018, 2019 Rubicon Communications, LLC (Netgate)
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#include 
+__FBSDID("$FreeBSD$");
+
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+
+#include "spibus_if.h"
+
+struct a37x0_spi_softc {
+   device_tsc_dev;
+   struct mtx  sc_mtx;
+   struct resource *sc_mem_res;
+   struct resource *sc_irq_res;
+   struct spi_command  *sc_cmd;
+   bus_space_tag_t sc_bst;
+   bus_space_handle_t  sc_bsh;
+   uint32_tsc_len;
+   uint32_tsc_maxfreq;
+   uint32_tsc_read;
+   uint32_tsc_flags;
+   uint32_tsc_written;
+   void*sc_intrhand;
+};
+
+#defineA37X0_SPI_WRITE(_sc, _off, _val)\
+bus_space_write_4((_sc)->sc_bst, (_sc)->sc_bsh, (_off), (_val))
+#defineA37X0_SPI_READ(_sc, _off)   \
+bus_space_read_4((_sc)->sc_bst, (_sc)->sc_bsh, (_off))
+#defineA37X0_SPI_LOCK(_sc) mtx_lock(&(_sc)->sc_mtx)
+#defineA37X0_SPI_UNLOCK(_sc)   mtx_unlock(&(_sc)->sc_mtx)
+
+#defineA37X0_SPI_BUSY  (1 << 0)
+/*
+ * While the A3700 utils from Marvell usually sets the QSF clock to 200MHz,
+ * there is no guarantee that it is correct without the proper clock framework
+ * to retrieve the actual TBG and PLL settings.
+ */
+#defineA37X0_SPI_CLOCK 2   /* QSF Clock 
200MHz */
+
+#defineA37X0_SPI_CONTROL   0x0
+#define A37X0_SPI_CS_SHIFT 16
+#define A37X0_SPI_CS_MASK  (0xf << A37X0_SPI_CS_SHIFT)
+#defineA37X0_SPI_CONF  0x4
+#define A37X0_SPI_WFIFO_THRS_SHIFT 28
+#define A37X0_SPI_RFIFO_THRS_SHIFT 24
+#define A37X0_SPI_AUTO_CS_EN   (1 << 20)
+#define A37X0_SPI_DMA_WR_EN(1 << 19)
+#define A37X0_SPI_DMA_RD_EN(1 << 18)
+#define A37X0_SPI_FIFO_MODE(1 << 17)
+#define A37X0_SPI_SRST (1 << 16)
+#define A37X0_SPI_XFER_START   (1 << 15)
+#define A37X0_SPI_XFER_STOP(1 << 14)
+#define A37X0_SPI_INSTR_PIN(1 << 13)
+#define A37X0_SPI_ADDR_PIN (1 << 12)
+#define A37X0_SPI_DATA_PIN_MASK0x3
+#define A37X0_SPI_DATA_PIN_SHIFT   10
+#define A37X0_SPI_FIFO_FLUSH   (1 << 9)
+#define A37X0_SPI_RW_EN(1 << 8)
+#define A37X0_SPI_CLK_POL  (1 << 7)
+#define A37X0_SPI_CLK_PHASE(1 << 6)
+#define A37X0_SPI_BYTE_LEN (1 << 5)
+#define A37X0_SPI_PSC_MASK 0x1f
+#defineA37X0_SPI_DATA_OUT 

svn commit: r355443 - in stable/11/sys: cddl/contrib/opensolaris/uts/common/fs/zfs kern sys

2019-12-06 Thread Konstantin Belousov
Author: kib
Date: Fri Dec  6 11:48:22 2019
New Revision: 355443
URL: https://svnweb.freebsd.org/changeset/base/355443

Log:
  MFC r355211:
  Add a VN_OPEN_INVFS flag.

Modified:
  stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c
  stable/11/sys/kern/vfs_vnops.c
  stable/11/sys/sys/vnode.h
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c
==
--- stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c
Fri Dec  6 11:46:15 2019(r355442)
+++ stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c
Fri Dec  6 11:48:22 2019(r355443)
@@ -5544,7 +5544,7 @@ vop_getextattr {
flags = FREAD;
NDINIT_ATVP(, LOOKUP, NOFOLLOW, UIO_SYSSPACE, attrname,
xvp, td);
-   error = vn_open_cred(, , 0, 0, ap->a_cred, NULL);
+   error = vn_open_cred(, , VN_OPEN_INVFS, 0, ap->a_cred, NULL);
vp = nd.ni_vp;
NDFREE(, NDF_ONLY_PNBUF);
if (error != 0) {
@@ -5681,7 +5681,8 @@ vop_setextattr {
flags = FFLAGS(O_WRONLY | O_CREAT);
NDINIT_ATVP(, LOOKUP, NOFOLLOW, UIO_SYSSPACE, attrname,
xvp, td);
-   error = vn_open_cred(, , 0600, 0, ap->a_cred, NULL);
+   error = vn_open_cred(, , 0600, VN_OPEN_INVFS, ap->a_cred,
+   NULL);
vp = nd.ni_vp;
NDFREE(, NDF_ONLY_PNBUF);
if (error != 0) {

Modified: stable/11/sys/kern/vfs_vnops.c
==
--- stable/11/sys/kern/vfs_vnops.c  Fri Dec  6 11:46:15 2019
(r355442)
+++ stable/11/sys/kern/vfs_vnops.c  Fri Dec  6 11:48:22 2019
(r355443)
@@ -217,7 +217,8 @@ restart:
ndp->ni_cnd.cn_flags |= AUDITVNODE1;
if (vn_open_flags & VN_OPEN_NOCAPCHECK)
ndp->ni_cnd.cn_flags |= NOCAPCHECK;
-   bwillwrite();
+   if ((vn_open_flags & VN_OPEN_INVFS) == 0)
+   bwillwrite();
if ((error = namei(ndp)) != 0)
return (error);
if (ndp->ni_vp == NULL) {

Modified: stable/11/sys/sys/vnode.h
==
--- stable/11/sys/sys/vnode.h   Fri Dec  6 11:46:15 2019(r355442)
+++ stable/11/sys/sys/vnode.h   Fri Dec  6 11:48:22 2019(r355443)
@@ -591,6 +591,7 @@ typedef void vop_getpages_iodone_t(void *, vm_page_t *
 #defineVN_OPEN_NOAUDIT 0x0001
 #defineVN_OPEN_NOCAPCHECK  0x0002
 #defineVN_OPEN_NAMECACHE   0x0004
+#defineVN_OPEN_INVFS   0x0008
 
 /*
  * Public vnode manipulation functions.
___
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: r355442 - in stable/12/sys: cddl/contrib/opensolaris/uts/common/fs/zfs kern sys

2019-12-06 Thread Konstantin Belousov
Author: kib
Date: Fri Dec  6 11:46:15 2019
New Revision: 355442
URL: https://svnweb.freebsd.org/changeset/base/355442

Log:
  MFC r355211:
  Add a VN_OPEN_INVFS flag.

Modified:
  stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c
  stable/12/sys/kern/vfs_vnops.c
  stable/12/sys/sys/vnode.h
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c
==
--- stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c
Fri Dec  6 09:50:29 2019(r355441)
+++ stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c
Fri Dec  6 11:46:15 2019(r355442)
@@ -5541,7 +5541,7 @@ vop_getextattr {
flags = FREAD;
NDINIT_ATVP(, LOOKUP, NOFOLLOW, UIO_SYSSPACE, attrname,
xvp, td);
-   error = vn_open_cred(, , 0, 0, ap->a_cred, NULL);
+   error = vn_open_cred(, , VN_OPEN_INVFS, 0, ap->a_cred, NULL);
vp = nd.ni_vp;
NDFREE(, NDF_ONLY_PNBUF);
if (error != 0) {
@@ -5678,7 +5678,8 @@ vop_setextattr {
flags = FFLAGS(O_WRONLY | O_CREAT);
NDINIT_ATVP(, LOOKUP, NOFOLLOW, UIO_SYSSPACE, attrname,
xvp, td);
-   error = vn_open_cred(, , 0600, 0, ap->a_cred, NULL);
+   error = vn_open_cred(, , 0600, VN_OPEN_INVFS, ap->a_cred,
+   NULL);
vp = nd.ni_vp;
NDFREE(, NDF_ONLY_PNBUF);
if (error != 0) {

Modified: stable/12/sys/kern/vfs_vnops.c
==
--- stable/12/sys/kern/vfs_vnops.c  Fri Dec  6 09:50:29 2019
(r355441)
+++ stable/12/sys/kern/vfs_vnops.c  Fri Dec  6 11:46:15 2019
(r355442)
@@ -216,7 +216,8 @@ restart:
ndp->ni_cnd.cn_flags |= AUDITVNODE1;
if (vn_open_flags & VN_OPEN_NOCAPCHECK)
ndp->ni_cnd.cn_flags |= NOCAPCHECK;
-   bwillwrite();
+   if ((vn_open_flags & VN_OPEN_INVFS) == 0)
+   bwillwrite();
if ((error = namei(ndp)) != 0)
return (error);
if (ndp->ni_vp == NULL) {

Modified: stable/12/sys/sys/vnode.h
==
--- stable/12/sys/sys/vnode.h   Fri Dec  6 09:50:29 2019(r355441)
+++ stable/12/sys/sys/vnode.h   Fri Dec  6 11:46:15 2019(r355442)
@@ -577,6 +577,7 @@ typedef void vop_getpages_iodone_t(void *, vm_page_t *
 #defineVN_OPEN_NOAUDIT 0x0001
 #defineVN_OPEN_NOCAPCHECK  0x0002
 #defineVN_OPEN_NAMECACHE   0x0004
+#defineVN_OPEN_INVFS   0x0008
 
 /*
  * Public vnode manipulation functions.
___
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: r355440 - stable/12/sys/amd64/vmm/intel

2019-12-06 Thread Scott Long
Author: scottl
Date: Fri Dec  6 09:50:01 2019
New Revision: 355440
URL: https://svnweb.freebsd.org/changeset/base/355440

Log:
  MFC r349184.  This fixing PCI passthrough via VT-d on modern chipsets with
  multiple translation units.
  
  PR:   229852
  Submitted by: cal...@mitchison.org

Modified:
  stable/12/sys/amd64/vmm/intel/vtd.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/amd64/vmm/intel/vtd.c
==
--- stable/12/sys/amd64/vmm/intel/vtd.c Fri Dec  6 03:48:35 2019
(r355439)
+++ stable/12/sys/amd64/vmm/intel/vtd.c Fri Dec  6 09:50:01 2019
(r355440)
@@ -51,6 +51,8 @@ __FBSDID("$FreeBSD$");
  * Architecture Spec, September 2008.
  */
 
+#define VTD_DRHD_INCLUDE_PCI_ALL(Flags)  (((Flags) >> 0) & 0x1)
+
 /* Section 10.4 "Register Descriptions" */
 struct vtdmap {
volatile uint32_t   version;
@@ -116,10 +118,11 @@ struct domain {
 static SLIST_HEAD(, domain) domhead;
 
 #defineDRHD_MAX_UNITS  8
-static int drhd_num;
-static struct vtdmap   *vtdmaps[DRHD_MAX_UNITS];
-static int max_domains;
-typedef int(*drhd_ident_func_t)(void);
+static ACPI_DMAR_HARDWARE_UNIT *drhds[DRHD_MAX_UNITS];
+static int drhd_num;
+static struct vtdmap   *vtdmaps[DRHD_MAX_UNITS];
+static int max_domains;
+typedef int(*drhd_ident_func_t)(void);
 
 static uint64_t root_table[PAGE_SIZE / sizeof(uint64_t)] __aligned(4096);
 static uint64_t ctx_tables[256][PAGE_SIZE / sizeof(uint64_t)] __aligned(4096);
@@ -175,6 +178,69 @@ domain_id(void)
return (id);
 }
 
+static struct vtdmap *
+vtd_device_scope(uint16_t rid)
+{
+   int i, remaining, pathremaining;
+   char *end, *pathend;
+   struct vtdmap *vtdmap;
+   ACPI_DMAR_HARDWARE_UNIT *drhd;
+   ACPI_DMAR_DEVICE_SCOPE *device_scope;
+   ACPI_DMAR_PCI_PATH *path;
+
+   for (i = 0; i < drhd_num; i++) {
+   drhd = drhds[i];
+
+   if (VTD_DRHD_INCLUDE_PCI_ALL(drhd->Flags)) {
+   /*
+* From Intel VT-d arch spec, version 3.0:
+* If a DRHD structure with INCLUDE_PCI_ALL flag Set is 
reported
+* for a Segment, it must be enumerated by BIOS after 
all other
+* DRHD structures for the same Segment.
+*/
+   vtdmap = vtdmaps[i];
+   return(vtdmap);
+   }
+
+   end = (char *)drhd + drhd->Header.Length;
+   remaining = drhd->Header.Length - 
sizeof(ACPI_DMAR_HARDWARE_UNIT);
+   while (remaining > sizeof(ACPI_DMAR_DEVICE_SCOPE)) {
+   device_scope = (ACPI_DMAR_DEVICE_SCOPE *)(end - 
remaining);
+   remaining -= device_scope->Length;
+
+   switch (device_scope->EntryType){
+   /* 0x01 and 0x02 are PCI device entries */
+   case 0x01:
+   case 0x02:
+   break;
+   default:
+   continue;
+   }
+
+   if (PCI_RID2BUS(rid) != device_scope->Bus)
+   continue;
+
+   pathend = (char *)device_scope + device_scope->Length;
+   pathremaining = device_scope->Length - 
sizeof(ACPI_DMAR_DEVICE_SCOPE);
+   while (pathremaining >= sizeof(ACPI_DMAR_PCI_PATH)) {
+   path = (ACPI_DMAR_PCI_PATH *)(pathend - 
pathremaining);
+   pathremaining -= sizeof(ACPI_DMAR_PCI_PATH);
+
+   if (PCI_RID2SLOT(rid) != path->Device)
+   continue;
+   if (PCI_RID2FUNC(rid) != path->Function)
+   continue;
+
+   vtdmap = vtdmaps[i];
+   return (vtdmap);
+   }
+   }
+   }
+
+   /* No matching scope */
+   return (NULL);
+}
+
 static void
 vtd_wbflush(struct vtdmap *vtdmap)
 {
@@ -240,7 +306,7 @@ vtd_translation_disable(struct vtdmap *vtdmap)
 static int
 vtd_init(void)
 {
-   int i, units, remaining;
+   int i, units, remaining, tmp;
struct vtdmap *vtdmap;
vm_paddr_t ctx_paddr;
char *end, envname[32];
@@ -291,8 +357,9 @@ vtd_init(void)
break;
 
drhd = (ACPI_DMAR_HARDWARE_UNIT *)hdr;
-   vtdmaps[units++] = (struct vtdmap *)PHYS_TO_DMAP(drhd->Address);
-   if (units >= DRHD_MAX_UNITS)
+   drhds[units] = drhd;
+   vtdmaps[units] = (struct vtdmap 

svn commit: r355441 - head/stand/efi/loader

2019-12-06 Thread Toomas Soome
Author: tsoome
Date: Fri Dec  6 09:50:29 2019
New Revision: 355441
URL: https://svnweb.freebsd.org/changeset/base/355441

Log:
  loader.efi: print ImageBase so we know where we are
  
  Output a bit of debugging aid.

Modified:
  head/stand/efi/loader/main.c

Modified: head/stand/efi/loader/main.c
==
--- head/stand/efi/loader/main.cFri Dec  6 09:50:01 2019
(r355440)
+++ head/stand/efi/loader/main.cFri Dec  6 09:50:29 2019
(r355441)
@@ -999,6 +999,7 @@ main(int argc, CHAR16 *argv[])
printf(" %S", argv[i]);
printf("\n");
 
+   printf("   Image base: 0x%lx\n", (unsigned long)boot_img->ImageBase);
printf("   EFI version: %d.%02d\n", ST->Hdr.Revision >> 16,
ST->Hdr.Revision & 0x);
printf("   EFI Firmware: %S (rev %d.%02d)\n", ST->FirmwareVendor,
___
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: r355430 - head/sys/cam/scsi

2019-12-06 Thread Steven Hartland
If the illegal chars where removed or replaced would the result be useful,
if so might that be a better approach?

On Fri, 6 Dec 2019 at 00:06, Alan Somers  wrote:

> Author: asomers
> Date: Fri Dec  6 00:06:05 2019
> New Revision: 355430
> URL: https://svnweb.freebsd.org/changeset/base/355430
>
> Log:
>   ses: sanitize illegal strings in SES element descriptors
>
>   The SES4r3 standard requires that element descriptors may only contain
> ASCII
>   characters in the range 0x20 to 0x7e.  Some SuperMicro expanders violate
>   that rule.  This patch adds a sanity check to ses(4).  Descriptors in
>   violation will be replaced by "".
>
>   This patch fixes "sesutil --libxo xml" on such systems.  Previously it
> would
>   generate non-well-formed XML output.
>
>   PR:   241929
>   Reviewed by:  allanjude
>   MFC after:2 weeks
>   Sponsored by: Axcient
>
> Modified:
>   head/sys/cam/scsi/scsi_enc_ses.c
>
> Modified: head/sys/cam/scsi/scsi_enc_ses.c
>
> ==
> --- head/sys/cam/scsi/scsi_enc_ses.cThu Dec  5 19:39:51 2019
> (r355429)
> +++ head/sys/cam/scsi/scsi_enc_ses.cFri Dec  6 00:06:05 2019
> (r355430)
> @@ -110,7 +110,7 @@ typedef struct ses_addl_status {
>  typedef struct ses_element {
> uint8_t eip;/* eip bit is set */
> uint16_t descr_len; /* length of the descriptor */
> -   char *descr;/* descriptor for this object */
> +   const char *descr;  /* descriptor for this object */
> struct ses_addl_status addl;/* additional status info */
>  } ses_element_t;
>
> @@ -1977,6 +1977,35 @@ ses_publish_cache(enc_softc_t *enc, struct
> enc_fsm_sta
> return (0);
>  }
>
> +/*
> + * \brief Sanitize an element descriptor
> + *
> + * The SES4r3 standard, sections 3.1.2 and 6.1.10, specifies that element
> + * descriptors may only contain ASCII characters in the range 0x20 to
> 0x7e.
> + * But some vendors violate that rule.  Ensure that we only expose
> compliant
> + * descriptors to userland.
> + *
> + * \param desc SES element descriptor as reported by the hardware
> + * \param len  Length of desc in bytes, not necessarily including
> + * trailing NUL.  It will be modified if desc is
> invalid.
> + */
> +static const char*
> +ses_sanitize_elm_desc(const char *desc, uint16_t *len)
> +{
> +   const char *invalid = "";
> +   int i;
> +
> +   for (i = 0; i < *len; i++) {
> +   if (desc[i] < 0x20 || desc[i] > 0x7e) {
> +   *len = strlen(invalid);
> +   return (invalid);
> +   } else if (desc[i] == 0) {
> +   break;
> +   }
> +   }
> +   return (desc);
> +}
> +
>  /**
>   * \brief Parse the descriptors for each object.
>   *
> @@ -2061,7 +2090,8 @@ ses_process_elm_descs(enc_softc_t *enc, struct
> enc_fsm
> if (length > 0) {
> elmpriv = element->elm_private;
> elmpriv->descr_len = length;
> -   elmpriv->descr = [offset];
> +   elmpriv->descr =
> ses_sanitize_elm_desc([offset],
> +   >descr_len);
> }
>
> /* skip over the descriptor itself */
>
___
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"