svn commit: r346626 - head/tests/sys/opencrypto

2019-04-23 Thread Enji Cooper
Author: ngie
Date: Wed Apr 24 05:49:48 2019
New Revision: 346626
URL: https://svnweb.freebsd.org/changeset/base/346626

Log:
  Fix typo: `Plen` should be `plen`
  
  MFC after:1 month
  MFC with: r346617
  Reported by:  pylint -E

Modified:
  head/tests/sys/opencrypto/cryptotest.py

Modified: head/tests/sys/opencrypto/cryptotest.py
==
--- head/tests/sys/opencrypto/cryptotest.py Wed Apr 24 05:47:09 2019
(r346625)
+++ head/tests/sys/opencrypto/cryptotest.py Wed Apr 24 05:49:48 2019
(r346626)
@@ -307,7 +307,7 @@ def GenTestCase(cname):
 aad, tag)
 
 payload = data['Payload'].decode('hex')
-Plen = int(data('Plen'))
+plen = int(data('Plen'))
 payload = payload[:plen]
 self.assertEqual(r, payload,
 "Count " + data['Count'] + \
___
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: r346625 - head/tests/sys/opencrypto

2019-04-23 Thread Enji Cooper
Author: ngie
Date: Wed Apr 24 05:47:09 2019
New Revision: 346625
URL: https://svnweb.freebsd.org/changeset/base/346625

Log:
  Don't leak `fd` when manipulating the device via `_getdev()`
  
  Close the file descriptor when done calling ioctl with a try-finally block so
  it doesn't get leaked.
  
  MFC after:2 months

Modified:
  head/tests/sys/opencrypto/cryptodev.py

Modified: head/tests/sys/opencrypto/cryptodev.py
==
--- head/tests/sys/opencrypto/cryptodev.py  Wed Apr 24 05:24:10 2019
(r346624)
+++ head/tests/sys/opencrypto/cryptodev.py  Wed Apr 24 05:47:09 2019
(r346625)
@@ -122,10 +122,12 @@ CIOCFINDDEV = 3223610220
 CIOCCRYPTAEAD = 3225445229
 
 def _getdev():
-fd = os.open('/dev/crypto', os.O_RDWR)
 buf = array.array('I', [0])
-ioctl(fd, CRIOGET, buf, 1)
-os.close(fd)
+fd = os.open('/dev/crypto', os.O_RDWR)
+try:
+ioctl(fd, CRIOGET, buf, 1)
+finally:
+os.close(fd)
 
 return buf[0]
 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r346624 - head/bin/date

2019-04-23 Thread Warner Losh
Author: imp
Date: Wed Apr 24 05:24:10 2019
New Revision: 346624
URL: https://svnweb.freebsd.org/changeset/base/346624

Log:
  Restore the -n flag parsing, but ignore it.
  
  Since D19668 was done, new users of the -n flag have surfaced. Parse
  and ignore it on the command line until they can be updated.
  
  Suggested by: rgrimes (in D19668).

Modified:
  head/bin/date/date.1
  head/bin/date/date.c

Modified: head/bin/date/date.1
==
--- head/bin/date/date.1Wed Apr 24 04:50:03 2019(r346623)
+++ head/bin/date/date.1Wed Apr 24 05:24:10 2019(r346624)
@@ -32,7 +32,7 @@
 .\" @(#)date.1 8.3 (Berkeley) 4/28/95
 .\" $FreeBSD$
 .\"
-.Dd March 20, 2019
+.Dd April 23, 2019
 .Dt DATE 1
 .Os
 .Sh NAME
@@ -40,7 +40,7 @@
 .Nd display or set date and time
 .Sh SYNOPSIS
 .Nm
-.Op Fl jRu
+.Op Fl jnRu
 .Op Fl r Ar seconds | Ar filename
 .Oo
 .Fl v
@@ -142,6 +142,8 @@ This allows you to use the
 flag in addition to the
 .Cm +
 option to convert one date format to another.
+.It Fl n
+Obsolete flag, accepted and ignored for compatibility.
 .It Fl R
 Use RFC 2822 date and time output format.
 This is equivalent to using

Modified: head/bin/date/date.c
==
--- head/bin/date/date.cWed Apr 24 04:50:03 2019(r346623)
+++ head/bin/date/date.cWed Apr 24 05:24:10 2019(r346624)
@@ -108,7 +108,7 @@ main(int argc, char *argv[])
(void) setlocale(LC_TIME, "");
rflag = 0;
Iflag = jflag = Rflag = 0;
-   while ((ch = getopt(argc, argv, "f:I::jRr:uv:")) != -1)
+   while ((ch = getopt(argc, argv, "f:I::jnRr:uv:")) != -1)
switch((char)ch) {
case 'f':
fmt = optarg;
@@ -131,6 +131,8 @@ main(int argc, char *argv[])
break;
case 'j':
jflag = 1;  /* don't set time */
+   break;
+   case 'n':
break;
case 'R':   /* RFC 2822 datetime format */
if (Iflag)
___
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: r346623 - head/tests/sys/opencrypto

2019-04-23 Thread Enji Cooper
Author: ngie
Date: Wed Apr 24 04:50:03 2019
New Revision: 346623
URL: https://svnweb.freebsd.org/changeset/base/346623

Log:
  Chase PEP-3110
  
  Replace `except Environment, e:` with `except Environment as e` for
  compatibility between python 2.x and python 3.x.
  
  While here, fix a bad indentation change from r346620 by reindenting the code
  properly.
  
  MFC after:2 months

Modified:
  head/tests/sys/opencrypto/cryptotest.py

Modified: head/tests/sys/opencrypto/cryptotest.py
==
--- head/tests/sys/opencrypto/cryptotest.py Wed Apr 24 04:45:00 2019
(r346622)
+++ head/tests/sys/opencrypto/cryptotest.py Wed Apr 24 04:50:03 2019
(r346623)
@@ -124,7 +124,7 @@ def GenTestCase(cname):
 mac=self._gmacsizes[len(cipherkey)],
 mackey=cipherkey, crid=crid,
 maclen=16)
-except EnvironmentError, e:
+except EnvironmentError as e:
 # Can't test algorithms the driver does not support.
 if e.errno != errno.EOPNOTSUPP:
 raise
@@ -133,7 +133,7 @@ def GenTestCase(cname):
 if mode == 'ENCRYPT':
 try:
 rct, rtag = c.encrypt(pt, iv, aad)
-except EnvironmentError, e:
+except EnvironmentError as e:
 # Can't test inputs the driver does not support.
 if e.errno != errno.EINVAL:
 raise
@@ -153,7 +153,7 @@ def GenTestCase(cname):
 else:
 try:
 rpt, rtag = c.decrypt(*args)
-except EnvironmentError, e:
+except EnvironmentError as e:
 # Can't test inputs the driver does not 
support.
 if e.errno != errno.EINVAL:
 raise
@@ -221,7 +221,7 @@ def GenTestCase(cname):
 try:
 c = Crypto(meth, cipherkey, crid=crid)
 r = curfun(c, pt, iv)
-except EnvironmentError, e:
+except EnvironmentError as e:
 # Can't test hashes the driver does not support.
 if e.errno != errno.EOPNOTSUPP:
 raise
@@ -252,7 +252,7 @@ def GenTestCase(cname):
 mackey=key, maclen=16)
 r, tag = Crypto.encrypt(c, payload,
 nonce, aad)
-except EnvironmentError, e:
+except EnvironmentError as e:
 if e.errno != errno.EOPNOTSUPP:
 raise
 continue
@@ -294,7 +294,7 @@ def GenTestCase(cname):
 key=key,
 mac=cryptodev.CRYPTO_AES_CCM_CBC_MAC,
 mackey=key, maclen=16)
-except EnvironmentError, e:
+except EnvironmentError as e:
 if e.errno != errno.EOPNOTSUPP:
 raise
 continue
@@ -388,13 +388,13 @@ def GenTestCase(cname):
 
 for data in lines:
 msg = data['Msg'].decode('hex')
-msg = msg[:int(data['Len'])]
+msg = msg[:int(data['Len'])]
 md = data['MD'].decode('hex')
 
 try:
 c = Crypto(mac=alg, crid=crid,
 maclen=hashlen)
-except EnvironmentError, e:
+except EnvironmentError as e:
 # Can't test hashes the driver does not support.
 if e.errno != errno.EOPNOTSUPP:
 raise
@@ -451,7 +451,7 @@ def GenTestCase(cname):
 try:
 c = Crypto(mac=alg, mackey=key,
 crid=crid, maclen=hashlen)
-except EnvironmentError, e:
+except EnvironmentError as e:
 # Can't test hashes the driver does not support.
 if e.errno != errno.EOPNOTSUPP:
 raise
___
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: r346620 - head/tests/sys/opencrypto

2019-04-23 Thread Enji Cooper
Author: ngie
Date: Wed Apr 24 04:40:24 2019
New Revision: 346620
URL: https://svnweb.freebsd.org/changeset/base/346620

Log:
  Reapply whitespace style changes from r346443 after recent changes to 
tests/sys/opencrypto
  
  From r346443:
  """
  Replace hard tabs with four-character indentations, per PEP8.
  
  This is being done to separate stylistic changes from the tests from 
functional
  ones, as I accidentally introduced a bug to the tests when I used four-space
  indentation locally.
  
  No functional change.
  """
  
  MFC after:2 months
  Discussed with:   jhb

Modified:
  head/tests/sys/opencrypto/cryptodev.py
  head/tests/sys/opencrypto/cryptotest.py

Modified: head/tests/sys/opencrypto/cryptodev.py
==
--- head/tests/sys/opencrypto/cryptodev.py  Wed Apr 24 02:51:58 2019
(r346619)
+++ head/tests/sys/opencrypto/cryptodev.py  Wed Apr 24 04:40:24 2019
(r346620)
@@ -35,73 +35,79 @@ import array
 import dpkt
 from fcntl import ioctl
 import os
+import random
 import signal
 from struct import pack as _pack
+import time
 
 from cryptodevh import *
 
 __all__ = [ 'Crypto', 'MismatchError', ]
 
 class FindOp(dpkt.Packet):
-   __byte_order__ = '@'
-   __hdr__ = ( ('crid', 'i', 0),
-   ('name', '32s', 0),
-   )
+__byte_order__ = '@'
+__hdr__ = (
+('crid', 'i',   0),
+('name', '32s', 0),
+)
 
 class SessionOp(dpkt.Packet):
-   __byte_order__ = '@'
-   __hdr__ = ( ('cipher', 'I', 0),
-   ('mac', 'I', 0),
-   ('keylen', 'I', 0),
-   ('key', 'P', 0),
-   ('mackeylen', 'i', 0),
-   ('mackey', 'P', 0),
-   ('ses', 'I', 0),
-   )
+__byte_order__ = '@'
+__hdr__ = (
+('cipher','I', 0),
+('mac',   'I', 0),
+('keylen','I', 0),
+('key',   'P', 0),
+('mackeylen', 'i', 0),
+('mackey','P', 0),
+('ses',   'I', 0),
+)
 
 class SessionOp2(dpkt.Packet):
-   __byte_order__ = '@'
-   __hdr__ = ( ('cipher', 'I', 0),
-   ('mac', 'I', 0),
-   ('keylen', 'I', 0),
-   ('key', 'P', 0),
-   ('mackeylen', 'i', 0),
-   ('mackey', 'P', 0),
-   ('ses', 'I', 0),
-   ('crid', 'i', 0),
-   ('pad0', 'i', 0),
-   ('pad1', 'i', 0),
-   ('pad2', 'i', 0),
-   ('pad3', 'i', 0),
-   )
+__byte_order__ = '@'
+__hdr__ = (
+('cipher','I', 0),
+('mac',   'I', 0),
+('keylen','I', 0),
+('key',   'P', 0),
+('mackeylen', 'i', 0),
+('mackey','P', 0),
+('ses',   'I', 0),
+('crid',  'i', 0),
+('pad0',  'i', 0),
+('pad1',  'i', 0),
+('pad2',  'i', 0),
+('pad3',  'i', 0),
+)
 
 class CryptOp(dpkt.Packet):
-   __byte_order__ = '@'
-   __hdr__ = ( ('ses', 'I', 0),
-   ('op', 'H', 0),
-   ('flags', 'H', 0),
-   ('len', 'I', 0),
-   ('src', 'P', 0),
-   ('dst', 'P', 0),
-   ('mac', 'P', 0),
-   ('iv', 'P', 0),
-   )
+__byte_order__ = '@'
+__hdr__ = (
+('ses',   'I', 0),
+('op','H', 0),
+('flags', 'H', 0),
+('len',   'I', 0),
+('src',   'P', 0),
+('dst',   'P', 0),
+('mac',   'P', 0),
+('iv','P', 0),
+)
 
 class CryptAEAD(dpkt.Packet):
-   __byte_order__ = '@'
-   __hdr__ = (
-   ('ses', 'I', 0),
-   ('op',  'H', 0),
-   ('flags',   'H', 0),
-   ('len', 'I', 0),
-   ('aadlen',  'I', 0),
-   ('ivlen',   'I', 0),
-   ('src', 'P', 0),
-   ('dst', 'P', 0),
-   ('aad', 'P', 0),
-   ('tag', 'P', 0),
-   ('iv',  'P', 0),
-   )
+__byte_order__ = '@'
+__hdr__ = (
+('ses','I', 0),
+('op', 'H', 0),
+('flags',  'H', 0),
+('len','I', 0),
+('aadlen', 'I', 0),
+('ivlen',  'I', 0),
+('src','P', 0),
+('dst','P', 0),
+('aad','P', 0),
+('tag','P', 0),
+('iv', 'P', 0),
+)
 
 # h2py.py can't handle multiarg macros
 CRIOGET = 3221513060
@@ -116,549 +122,546 @@ CIOCFINDDEV = 3223610220
 CIOCCRYPTAEAD = 3225445229
 
 def _getdev():
-   fd = os.open('/dev/crypto', os.O_RDWR)
-   buf = array.array('I', [0])
-   ioctl(fd, CRIOGET, buf, 1)
-   os.close(fd)
+fd = os.open('/dev/crypto', os.O_RDWR)
+buf = array.array('I', [0])
+ioctl(fd, CRIOGET, buf, 1)
+os.close(fd)
 
-   return buf[0]
+return buf[0]
 
 

Re: svn commit: r346315 - head/lib/libcasper/services/cap_fileargs

2019-04-23 Thread Yoshihiro Ota
Hi Ed and thank you for taking a look.

my svn info says 346593 which is after few other fixes were commited.

I'm on i386 arch.
I haven't done installworld yet after picking up libcasper changes.
'make buildworld' works fine.
'make xdev-build' fails and I tried with both "arm" and "mips" for TARGET and 
TARGET_ARCH.
Both fail same way.
Please check your /usr/include/casper/ca_fileargs.h and I suspect that's where 
you pick up FA_OPEN.

I attached a log file this time.

Regards,
Hiro

On Tue, 23 Apr 2019 09:49:00 -0400
Ed Maste  wrote:

> On Tue, 23 Apr 2019 at 00:07, Yoshihiro Ota  wrote:
> >
> > It looks this change is causing 'make xdev TARGET=mips TARGET_ARCH=mips' to 
> > fail as the
> > following with HEAD checked out under "/usr/obj/freebsd":
> 
> Hello Hiro-san, sorry about that.
> 
> I tried `make xdev TARGET=mips TARGET_ARCH=mips` on HEAD just now (but
> it failed on the install as DESTDIR wasn't set and I ran as non-root).
> Just `make xdev-build` was successful though.
> 
> What version were you trying to build? There were (several) followup
> commits to address issues with the initial commit of cap_fileargs
> lstat support.
% svn info
Path: .
Working Copy Root Path: /usr/src
URL: https://svn0.us-east.freebsd.org/base/head
Relative URL: ^/head
Repository Root: https://svn0.us-east.freebsd.org/base
Repository UUID: ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Revision: 346593
Node Kind: directory
Schedule: normal
Last Changed Author: wma
Last Changed Rev: 346593
Last Changed Date: 2019-04-23 02:36:32 -0400 (Tue, 23 Apr 2019)

% make xdev-build TARGET=mips TARGET_ARCH=mips
mkdir -p /usr/obj/usr/src/mips.mips/mips-freebsd/tmp/usr
mtree -deUW -f /usr/src/etc/mtree/BSD.usr.dist  -p 
/usr/obj/usr/src/mips.mips/mips-freebsd/tmp/usr >/dev/null
===> lib/clang/libllvmminimal (obj,all,install)
===> usr.bin/clang/llvm-tblgen (obj,all,install)
sh /usr/src/tools/install.sh  -s -o root -g wheel -m 555   llvm-tblgen 
/usr/obj/usr/src/mips.mips/mips-freebsd/tmp/usr/bin/llvm-tblgen
sh /usr/src/tools/install.sh  -o root -g wheel -m 444  llvm-tblgen.debug 
/usr/obj/usr/src/mips.mips/mips-freebsd/tmp/usr/lib/debug/usr/bin/llvm-tblgen.debug
===> usr.bin/clang/clang-tblgen (obj,all,install)
sh /usr/src/tools/install.sh  -s -o root -g wheel -m 555   clang-tblgen 
/usr/obj/usr/src/mips.mips/mips-freebsd/tmp/usr/bin/clang-tblgen
sh /usr/src/tools/install.sh  -o root -g wheel -m 444  clang-tblgen.debug 
/usr/obj/usr/src/mips.mips/mips-freebsd/tmp/usr/lib/debug/usr/bin/clang-tblgen.debug
===> gnu/usr.bin/gperf (obj,all,install)
sh /usr/src/tools/install.sh  -s -o root -g wheel -m 555   gperf 
/usr/obj/usr/src/mips.mips/mips-freebsd/tmp/usr/bin/gperf
sh /usr/src/tools/install.sh  -o root -g wheel -m 444  gperf.debug 
/usr/obj/usr/src/mips.mips/mips-freebsd/tmp/usr/lib/debug/usr/bin/gperf.debug
===> lib/liby (obj,all,install)
sh /usr/src/tools/install.sh  -C -o root -g wheel -m 444   liby.a 
/usr/obj/usr/src/mips.mips/mips-freebsd/tmp/usr/lib/
===> usr.bin/yacc (obj,all,install)
sh /usr/src/tools/install.sh  -s -o root -g wheel -m 555   yacc 
/usr/obj/usr/src/mips.mips/mips-freebsd/tmp/usr/bin/yacc
sh /usr/src/tools/install.sh  -o root -g wheel -m 444  yacc.debug 
/usr/obj/usr/src/mips.mips/mips-freebsd/tmp/usr/lib/debug/usr/bin/yacc.debug
sh /usr/src/tools/install.sh -l h -o root -g wheel -m 555  
/usr/obj/usr/src/mips.mips/mips-freebsd/tmp/usr/bin/yacc 
/usr/obj/usr/src/mips.mips/mips-freebsd/tmp/usr/bin/byacc
===> bin/csh (obj,build-tools)
===> bin/sh (obj,build-tools)
===> lib/ncurses/ncurses (obj,build-tools)
===> lib/ncurses/ncursesw (obj,build-tools)
===> share/syscons/scrnmaps (obj,build-tools)
===> usr.bin/awk (obj,build-tools)
===> lib/libmagic (obj,build-tools)
===> usr.bin/mkesdb_static (obj,build-tools)
===> usr.bin/mkcsmapper_static (obj,build-tools)
===> usr.bin/vi/catalog (obj,build-tools)
===> gnu/usr.bin/cc/cc_tools (obj,build-tools)
===> xdev gnu/usr.bin/binutils (obj,all)
===> gnu/usr.bin/binutils/libiberty (all)
===> gnu/usr.bin/binutils/libbfd (all)
===> gnu/usr.bin/binutils/libopcodes (all)
===> gnu/usr.bin/binutils/doc (all)
===> gnu/usr.bin/binutils/libbinutils (all)
===> gnu/usr.bin/binutils/as (all)
===> gnu/usr.bin/binutils/objdump (all)
===> gnu/usr.bin/binutils/ld (all)
===> xdev lib/libelftc (obj,all)
===> xdev lib/libpe (obj,all)
===> xdev usr.bin/objcopy (obj,all)
===> xdev usr.bin/nm (obj,all)
===> xdev usr.bin/size (obj,all)
===> xdev usr.bin/strings (obj,all)
cc  -O2 -pipe   -DWITH_CASPER -I/usr/src/contrib/elftoolchain/libelftc 
-I/usr/src/contrib/elftoolchain/common -g -MD  -MF.depend.strings.o 
-MTstrings.o -std=gnu99 -Qunused-arguments  -c 
/usr/src/contrib/elftoolchain/strings/strings.c -o strings.o
/usr/src/contrib/elftoolchain/strings/strings.c:198:55: error: use of 
undeclared identifier 'FA_OPEN'
fa = fileargs_init(argc, argv, O_RDONLY, 0, , FA_OPEN);
 ^
1 error generated.
*** Error code 1

Stop.
make[2]: stopped in 

Re: svn commit: r346619 - head/sys/powerpc/aim

2019-04-23 Thread Enji Cooper

> On Apr 23, 2019, at 19:51, Justin Hibbits  wrote:
> 
> Author: jhibbits
> Date: Wed Apr 24 02:51:58 2019
> New Revision: 346619
> URL: https://svnweb.freebsd.org/changeset/base/346619
> 
> Log:
>  powerpc: Add a couple missing isyncs
> 
>  mtmsr and mtsr require context synchronizing instructions to follow.  Without
>  a CSI, there's a chance for a machine check exception.  This reportedly does
>  occur on a MPC750 (PowerMac G3).

G3?! Wow... the oldest I’ve used is the G4, back a decade and a half ago :0...
-Enji
___
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: r346619 - head/sys/powerpc/aim

2019-04-23 Thread Justin Hibbits
Author: jhibbits
Date: Wed Apr 24 02:51:58 2019
New Revision: 346619
URL: https://svnweb.freebsd.org/changeset/base/346619

Log:
  powerpc: Add a couple missing isyncs
  
  mtmsr and mtsr require context synchronizing instructions to follow.  Without
  a CSI, there's a chance for a machine check exception.  This reportedly does
  occur on a MPC750 (PowerMac G3).
  
  Reported by:  Mark Millard

Modified:
  head/sys/powerpc/aim/trap_subr32.S

Modified: head/sys/powerpc/aim/trap_subr32.S
==
--- head/sys/powerpc/aim/trap_subr32.S  Wed Apr 24 01:11:50 2019
(r346618)
+++ head/sys/powerpc/aim/trap_subr32.S  Wed Apr 24 02:51:58 2019
(r346619)
@@ -68,7 +68,7 @@
lwzusr,PM_SR(pmap); \
RESTORE_SRS(pmap,sr) \
/* Restore SR 12 */ \
-   lwz sr,12*4(pmap);  mtsr12,sr
+   lwz sr,12*4(pmap);  mtsr12,sr; isync
 
 /*
  * Kernel SRs are loaded directly from kernel_pmap_
@@ -799,6 +799,7 @@ CNAME(trapexit):
mfmsr   %r3
andi.   %r3,%r3,~PSL_EE@l
mtmsr   %r3
+   isync
 /* Test AST pending: */
lwz %r5,FRAME_SRR1+8(%r1)
mtcr%r5
___
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: r346618 - head/sys/conf

2019-04-23 Thread Kyle Evans
Author: kevans
Date: Wed Apr 24 01:11:50 2019
New Revision: 346618
URL: https://svnweb.freebsd.org/changeset/base/346618

Log:
  fdt: stop installing FDT_DTS_FILE
  
  r346307 inadvertently started installing FDT_DTS_FILE along with the kernel.
  While this isn't necessarily bad, it was not intended or discussed and it
  actively breaks some current setups that don't anticipate any .dtb being
  installed when it's using static fdt. This change could be reconsidered down
  the line, but it needs to be done with prior discussion.
  
  Fix it by pushing FDT_DTS_FILE build down into the raw dtb.build.mk bits.
  This technically allows modules building DTS to accidentally specify an
  FDT_DTS_FILE that gets built but isn't otherwise useful (since it's not
  installed), but I suspect this isn't a big deal and would get caught with
  any kind of testing -- and perhaps this might end up useful in some other
  way, for example by some module wanting to embed fdt in some other way than
  our current/normal mechanism.
  
  Reported by:  Mori Hiroki 
  MFC after:3 days
  X-MFC-With:   r346307

Modified:
  head/sys/conf/dtb.build.mk
  head/sys/conf/kern.post.mk

Modified: head/sys/conf/dtb.build.mk
==
--- head/sys/conf/dtb.build.mk  Wed Apr 24 00:23:06 2019(r346617)
+++ head/sys/conf/dtb.build.mk  Wed Apr 24 01:11:50 2019(r346618)
@@ -43,7 +43,7 @@ DTBO=${DTSO:T:R:S/$/.dtbo/}
 
 # Add dependencies on the source file so that out-of-tree things can be 
included
 # without any .PATH additions.
-.for _dts in ${DTS}
+.for _dts in ${DTS} ${FDT_DTS_FILE}
 ${_dts:R:T}.dtb: ${_dts}
 .endfor
 

Modified: head/sys/conf/kern.post.mk
==
--- head/sys/conf/kern.post.mk  Wed Apr 24 00:23:06 2019(r346617)
+++ head/sys/conf/kern.post.mk  Wed Apr 24 01:11:50 2019(r346618)
@@ -8,10 +8,7 @@
 # should be defined in the kern.pre.mk so that port makefiles can
 # override or augment them.
 
-.if !empty(FDT_DTS_FILE)
-DTS+=  ${FDT_DTS_FILE}
-.endif
-.if defined(DTS) || defined(DTSO)
+.if defined(DTS) || defined(DTSO) || defined(FDT_DTS_FILE)
 .include "dtb.build.mk"
 
 KERNEL_EXTRA+= ${DTB} ${DTBO}
___
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: r346617 - head/tests/sys/opencrypto

2019-04-23 Thread John Baldwin
Author: jhb
Date: Wed Apr 24 00:23:06 2019
New Revision: 346617
URL: https://svnweb.freebsd.org/changeset/base/346617

Log:
  Test the AES-CCM test vectors from the NIST Known Answer Tests.
  
  The CCM test vectors use a slightly different file format in that
  there are global key-value pairs as well as section key-value pairs
  that need to be used in each test.  In addition, the sections can set
  multiple key-value pairs in the section name.  The CCM KAT parser
  class is an iterator that returns a dictionary once per test where the
  dictionary contains all of the relevant key-value pairs for a given
  test (global, section name, section, test-specific).
  
  Note that all of the CCM decrypt tests use nonce and tag lengths that
  are not supported by OCF (OCF only supports a 12 byte nonce and 16
  byte tag), so none of the decryption vectors are actually tested.
  
  Reviewed by:  ngie
  MFC after:1 month
  Sponsored by: Chelsio Communications
  Differential Revision:https://reviews.freebsd.org/D19978

Modified:
  head/tests/sys/opencrypto/cryptodev.py
  head/tests/sys/opencrypto/cryptotest.py

Modified: head/tests/sys/opencrypto/cryptodev.py
==
--- head/tests/sys/opencrypto/cryptodev.py  Wed Apr 24 00:16:39 2019
(r346616)
+++ head/tests/sys/opencrypto/cryptodev.py  Wed Apr 24 00:23:06 2019
(r346617)
@@ -381,6 +381,112 @@ class KATParser:
 
yield values
 
+# The CCM files use a bit of a different syntax that doesn't quite fit
+# the generic KATParser.  In particular, some keys are set globally at
+# the start of the file, and some are set globally at the start of a
+# section.
+class KATCCMParser:
+   def __init__(self, fname):
+   self.fp = open(fname)
+   self._pending = None
+   self.read_globals()
+
+   def read_globals(self):
+   self.global_values = {}
+   while True:
+   line = self.fp.readline()
+   if not line:
+   return
+   if line[0] == '#' or not line.strip():
+   continue
+   if line[0] == '[':
+   self._pending = line
+   return
+
+   try:
+   f, v = line.split(' =')
+   except:
+   print('line:', repr(line))
+   raise
+
+   v = v.strip()
+
+   if f in self.global_values:
+   raise ValueError('already present: %r' % 
repr(f))
+   self.global_values[f] = v
+
+   def read_section_values(self, kwpairs):
+   self.section_values = self.global_values.copy()
+   for pair in kwpairs.split(', '):
+   f, v = pair.split(' = ')
+   if f in self.section_values:
+   raise ValueError('already present: %r' % 
repr(f))
+   self.section_values[f] = v
+
+   while True:
+   line = self.fp.readline()
+   if not line:
+   return
+   if line[0] == '#' or not line.strip():
+   continue
+   if line[0] == '[':
+   self._pending = line
+   return
+
+   try:
+   f, v = line.split(' =')
+   except:
+   print('line:', repr(line))
+   raise
+
+   if f == 'Count':
+   self._pending = line
+   return
+
+   v = v.strip()
+
+   if f in self.section_values:
+   raise ValueError('already present: %r' % 
repr(f))
+   self.section_values[f] = v
+
+   def __iter__(self):
+   while True:
+   if self._pending:
+   line = self._pending
+   self._pending = None
+   else:
+   line = self.fp.readline()
+   if not line:
+   return
+
+   if (line and line[0] == '#') or not line.strip():
+   continue
+
+   if line[0] == '[':
+   section = line[1:].split(']', 1)[0]
+   self.read_section_values(section)
+   continue
+
+   values = self.section_values.copy()
+
+  

svn commit: r346616 - head/tests/sys/opencrypto

2019-04-23 Thread John Baldwin
Author: jhb
Date: Wed Apr 24 00:16:39 2019
New Revision: 346616
URL: https://svnweb.freebsd.org/changeset/base/346616

Log:
  Run the plain SHA digest tests from NIST.
  
  Pass in an explicit digest length to the Crypto constructor since it
  was assuming only sessions with a MAC key would have a MAC.  Passing
  an explicit size allows us to test the full digest in HMAC tests as
  well.
  
  Reviewed by:  cem
  MFC after:1 month
  Sponsored by: Chelsio Communications
  Differential Revision:https://reviews.freebsd.org/D19884

Modified:
  head/tests/sys/opencrypto/cryptodev.py
  head/tests/sys/opencrypto/cryptotest.py

Modified: head/tests/sys/opencrypto/cryptodev.py
==
--- head/tests/sys/opencrypto/cryptodev.py  Wed Apr 24 00:14:37 2019
(r346615)
+++ head/tests/sys/opencrypto/cryptodev.py  Wed Apr 24 00:16:39 2019
(r346616)
@@ -151,8 +151,9 @@ class Crypto:
return _findop(crid, '')[1]
 
def __init__(self, cipher=0, key=None, mac=0, mackey=None,
-   crid=CRYPTOCAP_F_SOFTWARE | CRYPTOCAP_F_HARDWARE):
+   crid=CRYPTOCAP_F_SOFTWARE | CRYPTOCAP_F_HARDWARE, maclen=None):
self._ses = None
+   self._maclen = maclen
ses = SessionOp2()
ses.cipher = cipher
ses.mac = mac
@@ -168,9 +169,6 @@ class Crypto:
ses.mackeylen = len(mackey)
mk = array.array('B', mackey)
ses.mackey = mk.buffer_info()[0]
-   self._maclen = 16   # parameterize?
-   else:
-   self._maclen = None
 
if not cipher and not mac:
raise ValueError('one of cipher or mac MUST be 
specified.')

Modified: head/tests/sys/opencrypto/cryptotest.py
==
--- head/tests/sys/opencrypto/cryptotest.py Wed Apr 24 00:14:37 2019
(r346615)
+++ head/tests/sys/opencrypto/cryptotest.py Wed Apr 24 00:16:39 2019
(r346616)
@@ -114,7 +114,8 @@ def GenTestCase(cname):
c = 
Crypto(cryptodev.CRYPTO_AES_NIST_GCM_16,
cipherkey,

mac=self._gmacsizes[len(cipherkey)],
-   mackey=cipherkey, crid=crid)
+   mackey=cipherkey, crid=crid,
+   maclen=16)
except EnvironmentError, e:
# Can't test algorithms the 
driver does not support.
if e.errno != errno.EOPNOTSUPP:
@@ -260,11 +261,55 @@ def GenTestCase(cname):
###
@unittest.skipIf(cname not in shamodules, 'skipping SHA on %s' 
% str(cname))
def test_sha(self):
-   # SHA not available in software
-   pass
-   #for i in iglob('SHA1*'):
-   #   self.runSHA(i)
+   for i in katg('shabytetestvectors', 'SHA*Msg.rsp'):
+   self.runSHA(i)
 
+   def runSHA(self, fname):
+   # Skip SHA512_(224|256) tests
+   if fname.find('SHA512_') != -1:
+   return
+
+   for hashlength, lines in cryptodev.KATParser(fname,
+   [ 'Len', 'Msg', 'MD' ]):
+   # E.g., hashlength will be "L=20" (bytes)
+   hashlen = int(hashlength.split("=")[1])
+
+   if hashlen == 20:
+   alg = cryptodev.CRYPTO_SHA1
+   elif hashlen == 28:
+   alg = cryptodev.CRYPTO_SHA2_224
+   elif hashlen == 32:
+   alg = cryptodev.CRYPTO_SHA2_256
+   elif hashlen == 48:
+   alg = cryptodev.CRYPTO_SHA2_384
+   elif hashlen == 64:
+   alg = cryptodev.CRYPTO_SHA2_512
+   else:
+   # Skip unsupported hashes
+   # Slurp remaining input in section
+   for data in lines:
+   continue
+   continue
+
+   for data in lines:
+   msg = 

svn commit: r346615 - head/tests/sys/opencrypto

2019-04-23 Thread John Baldwin
Author: jhb
Date: Wed Apr 24 00:14:37 2019
New Revision: 346615
URL: https://svnweb.freebsd.org/changeset/base/346615

Log:
  Use more descriptive algorithm names in skip messages.
  
  Reviewed by:  cem, ngie
  MFC after:1 month
  Sponsored by: Chelsio Communications
  Differential Revision:https://reviews.freebsd.org/D19977

Modified:
  head/tests/sys/opencrypto/cryptotest.py

Modified: head/tests/sys/opencrypto/cryptotest.py
==
--- head/tests/sys/opencrypto/cryptotest.py Wed Apr 24 00:10:21 2019
(r346614)
+++ head/tests/sys/opencrypto/cryptotest.py Wed Apr 24 00:14:37 2019
(r346615)
@@ -61,17 +61,17 @@ def GenTestCase(cname):
###
# AES #
###
-   @unittest.skipIf(cname not in aesmodules, 'skipping AES on %s' 
% (cname))
+   @unittest.skipIf(cname not in aesmodules, 'skipping AES-XTS on 
%s' % (cname))
def test_xts(self):
for i in katg('XTSTestVectors/format tweak value input 
- data unit seq no', '*.rsp'):
self.runXTS(i, cryptodev.CRYPTO_AES_XTS)
 
-   @unittest.skipIf(cname not in aesmodules, 'skipping AES on %s' 
% (cname))
+   @unittest.skipIf(cname not in aesmodules, 'skipping AES-CBC on 
%s' % (cname))
def test_cbc(self):
for i in katg('KAT_AES', 'CBC[GKV]*.rsp'):
self.runCBC(i)
 
-   @unittest.skipIf(cname not in aesmodules, 'skipping AES on %s' 
% (cname))
+   @unittest.skipIf(cname not in aesmodules, 'skipping AES-GCM on 
%s' % (cname))
def test_gcm(self):
for i in katg('gcmtestvectors', 'gcmEncrypt*'):
self.runGCM(i, 'ENCRYPT')
@@ -265,7 +265,7 @@ def GenTestCase(cname):
#for i in iglob('SHA1*'):
#   self.runSHA(i)
 
-   @unittest.skipIf(cname not in shamodules, 'skipping SHA on %s' 
% str(cname))
+   @unittest.skipIf(cname not in shamodules, 'skipping SHA-HMAC on 
%s' % str(cname))
def test_sha1hmac(self):
for i in katg('hmactestvectors', 'HMAC.rsp'):
self.runSHA1HMAC(i)
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r346614 - head/tests/sys/opencrypto

2019-04-23 Thread John Baldwin
Author: jhb
Date: Wed Apr 24 00:10:21 2019
New Revision: 346614
URL: https://svnweb.freebsd.org/changeset/base/346614

Log:
  Skip tests with missing test vectors instead of failing.
  
  This copes more gracefully when older version of the nist-kat package
  are intalled that don't have newer test vectors such as CCM or plain
  SHA.
  
  If the nist-kat package is not installed at all, this still fails with
  an error.
  
  Reviewed by:  cem
  MFC after:1 month
  Sponsored by: Chelsio Communications
  Differential Revision:https://reviews.freebsd.org/D20034

Modified:
  head/tests/sys/opencrypto/cryptotest.py

Modified: head/tests/sys/opencrypto/cryptotest.py
==
--- head/tests/sys/opencrypto/cryptotest.py Tue Apr 23 22:43:47 2019
(r346613)
+++ head/tests/sys/opencrypto/cryptotest.py Wed Apr 24 00:10:21 2019
(r346614)
@@ -42,7 +42,9 @@ from glob import iglob
 katdir = '/usr/local/share/nist-kat'
 
 def katg(base, glob):
-   assert os.path.exists(os.path.join(katdir, base)), "Please 'pkg install 
nist-kat'"
+   assert os.path.exists(katdir), "Please 'pkg install nist-kat'"
+   if not os.path.exists(os.path.join(katdir, base)):
+   raise unittest.SkipTest("Missing %s test vectors" % (base))
return iglob(os.path.join(katdir, base, glob))
 
 aesmodules = [ 'cryptosoft0', 'aesni0', 'ccr0', 'ccp0' ]
___
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: r346605 - head/tests/sys/geom/class/mirror

2019-04-23 Thread Olivier Cochard
Author: olivier (ports committer)
Date: Tue Apr 23 21:07:47 2019
New Revision: 346605
URL: https://svnweb.freebsd.org/changeset/base/346605

Log:
  Skip test component_selection:run_latest_genid if gmirror/gnop GEOM classes
  aren't available
  
  PR:   237051
  Reviewed by:  asomers, imp, ngie, emaste (IRC)
  Approved by:  ngie
  MFC after: 1 month
  Sponsored by: Netflix
  Differential Revision:https://reviews.freebsd.org/D19958

Modified:
  head/tests/sys/geom/class/mirror/component_selection.sh

Modified: head/tests/sys/geom/class/mirror/component_selection.sh
==
--- head/tests/sys/geom/class/mirror/component_selection.sh Tue Apr 23 
20:25:25 2019(r346604)
+++ head/tests/sys/geom/class/mirror/component_selection.sh Tue Apr 23 
21:07:47 2019(r346605)
@@ -1,5 +1,9 @@
 # $FreeBSD$
 
+ATF_TEST=true
+class=mirror
+. $(atf_get_srcdir)/conf.sh
+
 atf_test_case run_latest_genid cleanup
 run_latest_genid_head()
 {
@@ -9,7 +13,10 @@ run_latest_genid_head()
 }
 run_latest_genid_body()
 {
-   . $(atf_get_srcdir)/conf.sh
+   geom_atf_test_setup
+   if ! error_message=$(geom_load_class_if_needed nop); then
+   atf_skip "$error_message"
+   fi
 
f1=$(mktemp ${base}.XX)
f2=$(mktemp ${base}.XX)
___
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: r346604 - in head/lib/libsecureboot: . h

2019-04-23 Thread Simon J. Gerraty
Author: sjg
Date: Tue Apr 23 20:25:25 2019
New Revision: 346604
URL: https://svnweb.freebsd.org/changeset/base/346604

Log:
  Allow no_hash to appear in manifest.
  
  sbin/veriexec will ignore entries that have no hash anyway,
  but loader needs to be explicitly told that such files are
  ok to ignore (not verify).
  
  We will report as Unverified depending on verbose level,
  but with no reason - because we are not rejecting the file.
  
  Reviewed by: imp, mindal_semihalf
  Sponsored by:   Juniper Networks
  MFC After: 1 week
  Differential Revision: https://reviews.freebsd.org//D20018

Modified:
  head/lib/libsecureboot/h/libsecureboot.h
  head/lib/libsecureboot/vectx.c
  head/lib/libsecureboot/veopen.c
  head/lib/libsecureboot/verify_file.c

Modified: head/lib/libsecureboot/h/libsecureboot.h
==
--- head/lib/libsecureboot/h/libsecureboot.hTue Apr 23 18:10:46 2019
(r346603)
+++ head/lib/libsecureboot/h/libsecureboot.hTue Apr 23 20:25:25 2019
(r346604)
@@ -86,6 +86,7 @@ ssize_t ve_pcr_get(unsigned char *, size_t);
 #define VEF_VERBOSE1
 
 #define VE_FINGERPRINT_OK  1
+#define VE_FINGERPRINT_IGNORE  2
 /* errors from verify_fd */
 #define VE_FINGERPRINT_NONE-2
 #define VE_FINGERPRINT_WRONG   -3

Modified: head/lib/libsecureboot/vectx.c
==
--- head/lib/libsecureboot/vectx.c  Tue Apr 23 18:10:46 2019
(r346603)
+++ head/lib/libsecureboot/vectx.c  Tue Apr 23 20:25:25 2019
(r346604)
@@ -120,7 +120,10 @@ vectx_open(int fd, const char *path, off_t off, struct
ctx->vec_status = VE_FINGERPRINT_NONE;
ve_error_set("%s: no entry", path);
} else {
-   if (strncmp(cp, "sha256=", 7) == 0) {
+   if (strncmp(cp, "no_hash", 7) == 0) {
+   ctx->vec_status = VE_FINGERPRINT_IGNORE;
+   hashsz = 0;
+   } else if (strncmp(cp, "sha256=", 7) == 0) {
ctx->vec_md = _sha256_vtable;
hashsz = br_sha256_SIZE;
cp += 7;
@@ -150,11 +153,13 @@ vectx_open(int fd, const char *path, off_t off, struct
*error = ctx->vec_status;
ctx->vec_hashsz = hashsz;
ctx->vec_want = cp;
-   ctx->vec_md->init(>vec_ctx.vtable);
+   if (hashsz > 0) {
+   ctx->vec_md->init(>vec_ctx.vtable);
 
-   if (hashsz > 0 && off > 0) {
-   lseek(fd, 0, SEEK_SET);
-   vectx_lseek(ctx, off, SEEK_SET);
+   if (off > 0) {
+   lseek(fd, 0, SEEK_SET);
+   vectx_lseek(ctx, off, SEEK_SET);
+   }
}
return (ctx);
 

Modified: head/lib/libsecureboot/veopen.c
==
--- head/lib/libsecureboot/veopen.c Tue Apr 23 18:10:46 2019
(r346603)
+++ head/lib/libsecureboot/veopen.c Tue Apr 23 20:25:25 2019
(r346604)
@@ -345,7 +345,9 @@ verify_fingerprint(int fd, const char *path, const cha
size_t hlen;
int n;
 
-   if (strncmp(cp, "sha256=", 7) == 0) {
+   if (strncmp(cp, "no_hash", 7) == 0) {
+   return (VE_FINGERPRINT_IGNORE);
+   } else if (strncmp(cp, "sha256=", 7) == 0) {
md = _sha256_vtable;
hlen = br_sha256_SIZE;
cp += 7;
@@ -423,6 +425,7 @@ verify_fd(int fd, const char *path, off_t off, struct 
rc = verify_fingerprint(fd, path, cp, off);
switch (rc) {
case VE_FINGERPRINT_OK:
+   case VE_FINGERPRINT_IGNORE:
case VE_FINGERPRINT_UNKNOWN:
return (rc);
default:

Modified: head/lib/libsecureboot/verify_file.c
==
--- head/lib/libsecureboot/verify_file.cTue Apr 23 18:10:46 2019
(r346603)
+++ head/lib/libsecureboot/verify_file.cTue Apr 23 20:25:25 2019
(r346604)
@@ -343,10 +343,14 @@ verify_file(int fd, const char *filename, off_t off, i
if ((rc = verify_fd(fd, filename, off, )) >= 0) {
if (verbose || severity > VE_WANT) {
 #if defined(VE_DEBUG_LEVEL) && VE_DEBUG_LEVEL > 0
-   printf("Verified %s %llu,%llu\n", filename,
+   printf("%serified %s %llu,%llu\n",
+   (rc == VE_FINGERPRINT_IGNORE) ? "Unv" : "V",
+   filename,
(long long)st.st_dev, (long long)st.st_ino);
 #else
-   printf("Verified %s\n", filename);
+   printf("%serified %s\n",
+   (rc == VE_FINGERPRINT_IGNORE) ? "Unv" : "V",
+   

svn commit: r346603 - in head/sys: amd64/linux32 i386/linux

2019-04-23 Thread Dmitry Chagin
Author: dchagin
Date: Tue Apr 23 18:10:46 2019
New Revision: 346603
URL: https://svnweb.freebsd.org/changeset/base/346603

Log:
  Since r339624 HEAD does not need for backslashes in syscalls.master,
  however to make a merge r345471 to the stable add backslashes
  to the syscalls.master.
  
  MFC after:3 days

Modified:
  head/sys/amd64/linux32/syscalls.master
  head/sys/i386/linux/syscalls.master

Modified: head/sys/amd64/linux32/syscalls.master
==
--- head/sys/amd64/linux32/syscalls.master  Tue Apr 23 17:28:28 2019
(r346602)
+++ head/sys/amd64/linux32/syscalls.master  Tue Apr 23 18:10:46 2019
(r346603)
@@ -690,7 +690,7 @@
 383AUE_NULLSTD { int linux_statx(l_int dirfd,  
\
const char *pathname, l_uint flags, 
\
l_uint mask, void *statxbuf); }
-384AUE_NULLSTD { int linux_arch_prctl(l_int option,
+384AUE_NULLSTD { int linux_arch_prctl(l_int option,
\
l_ulong arg2); }
 ; Linux 4.18:
 385AUE_NULLSTD { int linux_io_pgetevents(void); }

Modified: head/sys/i386/linux/syscalls.master
==
--- head/sys/i386/linux/syscalls.master Tue Apr 23 17:28:28 2019
(r346602)
+++ head/sys/i386/linux/syscalls.master Tue Apr 23 18:10:46 2019
(r346603)
@@ -698,7 +698,7 @@
 383AUE_NULLSTD { int linux_statx(l_int dirfd,  
\
const char *pathname, l_uint flags, 
\
l_uint mask, void *statxbuf); }
-384AUE_PRCTL   STD { int linux_arch_prctl(l_int option,
+384AUE_PRCTL   STD { int linux_arch_prctl(l_int option,
\
l_ulong arg2); }
 ; Linux 4.18:
 385AUE_NULLSTD { int linux_io_pgetevents(void); }
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r346602 - head/sys/net

2019-04-23 Thread Kyle Evans
Author: kevans
Date: Tue Apr 23 17:28:28 2019
New Revision: 346602
URL: https://svnweb.freebsd.org/changeset/base/346602

Log:
  tun(4): Defer clearing TUN_OPEN until much later
  
  tun destruction will not continue until TUN_OPEN is cleared. There are brief
  moments in tunclose where the mutex is dropped and we've already cleared
  TUN_OPEN, so tun_destroy would be able to proceed while we're in the middle
  of cleaning up the tun still. tun_destroy should be blocked until these
  parts (address/route purges, mostly) are complete.
  
  PR:   233955
  MFC after:2 weeks

Modified:
  head/sys/net/if_tun.c

Modified: head/sys/net/if_tun.c
==
--- head/sys/net/if_tun.c   Tue Apr 23 17:18:20 2019(r346601)
+++ head/sys/net/if_tun.c   Tue Apr 23 17:28:28 2019(r346602)
@@ -500,8 +500,6 @@ tunclose(struct cdev *dev, int foo, int bar, struct th
ifp = TUN2IFP(tp);
 
mtx_lock(>tun_mtx);
-   tp->tun_flags &= ~TUN_OPEN;
-   tp->tun_pid = 0;
 
/*
 * junk all pending output
@@ -540,6 +538,8 @@ tunclose(struct cdev *dev, int foo, int bar, struct th
selwakeuppri(>tun_rsel, PZERO + 1);
KNOTE_LOCKED(>tun_rsel.si_note, 0);
TUNDEBUG (ifp, "closed\n");
+   tp->tun_flags &= ~TUN_OPEN;
+   tp->tun_pid = 0;
 
cv_broadcast(>tun_cv);
mtx_unlock(>tun_mtx);
___
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: r346598 - head/sys/modules

2019-04-23 Thread Rodney W. Grimes
> Author: emaste
> Date: Tue Apr 23 15:11:01 2019
> New Revision: 346598
> URL: https://svnweb.freebsd.org/changeset/base/346598
> 
> Log:
>   Enable Mellanox drivers (modules) on AArch64
>   
>   Tested by Greg V with mlx5en on an Ampere eMAG instance at Packet.com on
>   c2.large.arm (with some additional uncommitted PCIe WIP).
>   
>   PR: 237055
>   Submitted by:   Greg V 
>   Reviewed by:hselasky
>   MFC after:  1 month
>   Differential Revision:  https://reviews.freebsd.org/D19983

Very cool, now how do I get a PCIe slot into a RPI3!!! lol  :-)

This does make some of the newer RockPro64 type boards an
interesting thing to experiment with.

I am hopeing some of that PCIe WIP might include some of the
bits needed or do we already have PCIe slot on RockPro64 code that works?

Thanks for this work Greg!

> Modified:
>   head/sys/modules/Makefile
> 
> Modified: head/sys/modules/Makefile
> ==
> --- head/sys/modules/Makefile Tue Apr 23 12:29:19 2019(r346597)
> +++ head/sys/modules/Makefile Tue Apr 23 15:11:01 2019(r346598)
> @@ -483,7 +483,24 @@ SUBDIR+= fdt
>  SUBDIR+= linprocfs
>  SUBDIR+= linsysfs
>  _ena=ena
> +.if ${MK_OFED} != "no" || defined(ALL_MODULES)
> +_ibcore= ibcore
> +_ipoib=  ipoib
> +_iser=   iser
>  .endif
> +_mlx4=   mlx4
> +_mlx5=   mlx5
> +.if (${MK_INET_SUPPORT} != "no" && ${MK_INET6_SUPPORT} != "no") || \
> + defined(ALL_MODULES)
> +_mlx4en= mlx4en
> +_mlx5en= mlx5en
> +.endif
> +.if ${MK_OFED} != "no" || defined(ALL_MODULES)
> +_mthca=  mthca
> +_mlx4ib= mlx4ib
> +_mlx5ib= mlx5ib
> +.endif
> +.endif
>  
>  .if ${MK_NAND} != "no" || defined(ALL_MODULES)
>  _nandfs= nandfs
> @@ -592,15 +609,8 @@ _ep= ep
>  _et= et
>  _exca=   exca
>  _fe= fe
> -.if ${MK_OFED} != "no" || defined(ALL_MODULES)
> -_ibcore=ibcore
> -.endif
>  _if_ndis=if_ndis
>  _io= io
> -.if ${MK_OFED} != "no" || defined(ALL_MODULES)
> -_ipoib= ipoib
> -_iser=   iser
> -.endif
>  _ix= ix
>  _ixv=ixv
>  _linux=  linux
> @@ -672,18 +682,6 @@ _ipwfw=  ipwfw
>  _iwifw=  iwifw
>  _iwmfw=  iwmfw
>  _iwnfw=  iwnfw
> -.endif
> -_mlx4=   mlx4
> -_mlx5=   mlx5
> -.if (${MK_INET_SUPPORT} != "no" && ${MK_INET6_SUPPORT} != "no") || \
> - defined(ALL_MODULES)
> -_mlx4en= mlx4en
> -_mlx5en= mlx5en
> -.endif
> -.if ${MK_OFED} != "no" || defined(ALL_MODULES)
> -_mthca=  mthca
> -_mlx4ib= mlx4ib
> -_mlx5ib= mlx5ib
>  .endif
>  _mly=mly
>  _nfe=nfe
> 
> 

-- 
Rod Grimes rgri...@freebsd.org
___
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: r346601 - head/sys/netinet6

2019-04-23 Thread Conrad Meyer
Author: cem
Date: Tue Apr 23 17:18:20 2019
New Revision: 346601
URL: https://svnweb.freebsd.org/changeset/base/346601

Log:
  ip6_randomflowlabel: Avoid blocking if random(4) is not available
  
  If kern.random.initial_seeding.bypass_before_seeding is disabled, random(4)
  and arc4random(9) will block indefinitely until enough entropy is available
  to initially seed Fortuna.
  
  It seems that zero flowids are perfectly valid, so avoid blocking on random
  until initial seeding takes place.
  
  Discussed with:   bz (earlier revision)
  Reviewed by:  thj
  Sponsored by: Dell EMC Isilon
  Differential Revision:https://reviews.freebsd.org/D20011

Modified:
  head/sys/netinet6/ip6_id.c

Modified: head/sys/netinet6/ip6_id.c
==
--- head/sys/netinet6/ip6_id.c  Tue Apr 23 17:11:45 2019(r346600)
+++ head/sys/netinet6/ip6_id.c  Tue Apr 23 17:18:20 2019(r346601)
@@ -89,6 +89,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -257,6 +258,16 @@ ip6_randomid(void)
 u_int32_t
 ip6_randomflowlabel(void)
 {
+
+   /*
+* It's ok to emit zero flow labels early, before random is available
+* (seeded).  RFC 6437:
+*
+* "A Flow Label of zero is used to indicate packets that have not been
+* labeled."
+*/
+   if (__predict_false(!is_random_seeded()))
+   return (0);
 
return randomid(_20) & 0xf;
 }
___
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: r346600 - head/sys/powerpc/pseries

2019-04-23 Thread Leandro Lupori
Author: luporl
Date: Tue Apr 23 17:11:45 2019
New Revision: 346600
URL: https://svnweb.freebsd.org/changeset/base/346600

Log:
  [PPC64] Fix wrong KASSERT in mphyp_pte_insert()
  
  As mphyp_pte_unset() can also remove PTE entries, and as this can
  happen in parallel with PTEs evicted by mphyp_pte_insert(), there
  is a (rare) chance the PTE being evicted gets removed before
  mphyp_pte_insert() is able to do so. Thus, the KASSERT should
  check wether the result is H_SUCCESS or H_NOT_FOUND, to avoid
  panics if the situation described above occurs.
  
  More details about this issue can be found in PR 237470.
  
  PR:   237470
  Reviewed by:  jhibbits
  Differential Revision:https://reviews.freebsd.org/D20012

Modified:
  head/sys/powerpc/pseries/mmu_phyp.c

Modified: head/sys/powerpc/pseries/mmu_phyp.c
==
--- head/sys/powerpc/pseries/mmu_phyp.c Tue Apr 23 17:05:57 2019
(r346599)
+++ head/sys/powerpc/pseries/mmu_phyp.c Tue Apr 23 17:11:45 2019
(r346600)
@@ -453,7 +453,7 @@ mphyp_pte_insert(mmu_t mmu, struct pvo_entry *pvo)
evicted.pte_hi & LPTE_AVPN_MASK, 0, , ,
);
moea64_pte_overflow++;
-   KASSERT(result == H_SUCCESS,
+   KASSERT(result == H_SUCCESS || result == H_NOT_FOUND,
("Error evicting page: %d", (int)result));
}
 
___
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: r346599 - head/sys/netinet/netdump

2019-04-23 Thread Conrad Meyer
Author: cem
Date: Tue Apr 23 17:05:57 2019
New Revision: 346599
URL: https://svnweb.freebsd.org/changeset/base/346599

Log:
  netdump: Fix !COMPAT_FREEBSD11 unused variable warning
  
  Reported by:  Ralf Wenk 
  Sponsored by: Dell EMC Isilon

Modified:
  head/sys/netinet/netdump/netdump_client.c

Modified: head/sys/netinet/netdump/netdump_client.c
==
--- head/sys/netinet/netdump/netdump_client.c   Tue Apr 23 15:11:01 2019
(r346598)
+++ head/sys/netinet/netdump/netdump_client.c   Tue Apr 23 17:05:57 2019
(r346599)
@@ -1140,7 +1140,9 @@ netdump_ioctl(struct cdev *dev __unused, u_long cmd, c
struct netdump_conf *conf;
uint8_t *encryptedkey;
int error;
+#ifdef COMPAT_FREEBSD11
u_int u;
+#endif
 
error = 0;
switch (cmd) {
___
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: r346598 - head/sys/modules

2019-04-23 Thread Ed Maste
Author: emaste
Date: Tue Apr 23 15:11:01 2019
New Revision: 346598
URL: https://svnweb.freebsd.org/changeset/base/346598

Log:
  Enable Mellanox drivers (modules) on AArch64
  
  Tested by Greg V with mlx5en on an Ampere eMAG instance at Packet.com on
  c2.large.arm (with some additional uncommitted PCIe WIP).
  
  PR:   237055
  Submitted by: Greg V 
  Reviewed by:  hselasky
  MFC after:1 month
  Differential Revision:https://reviews.freebsd.org/D19983

Modified:
  head/sys/modules/Makefile

Modified: head/sys/modules/Makefile
==
--- head/sys/modules/Makefile   Tue Apr 23 12:29:19 2019(r346597)
+++ head/sys/modules/Makefile   Tue Apr 23 15:11:01 2019(r346598)
@@ -483,7 +483,24 @@ SUBDIR+=   fdt
 SUBDIR+=   linprocfs
 SUBDIR+=   linsysfs
 _ena=  ena
+.if ${MK_OFED} != "no" || defined(ALL_MODULES)
+_ibcore=   ibcore
+_ipoib=ipoib
+_iser= iser
 .endif
+_mlx4= mlx4
+_mlx5= mlx5
+.if (${MK_INET_SUPPORT} != "no" && ${MK_INET6_SUPPORT} != "no") || \
+   defined(ALL_MODULES)
+_mlx4en=   mlx4en
+_mlx5en=   mlx5en
+.endif
+.if ${MK_OFED} != "no" || defined(ALL_MODULES)
+_mthca=mthca
+_mlx4ib=   mlx4ib
+_mlx5ib=   mlx5ib
+.endif
+.endif
 
 .if ${MK_NAND} != "no" || defined(ALL_MODULES)
 _nandfs=   nandfs
@@ -592,15 +609,8 @@ _ep=   ep
 _et=   et
 _exca= exca
 _fe=   fe
-.if ${MK_OFED} != "no" || defined(ALL_MODULES)
-_ibcore=ibcore
-.endif
 _if_ndis=  if_ndis
 _io=   io
-.if ${MK_OFED} != "no" || defined(ALL_MODULES)
-_ipoib= ipoib
-_iser= iser
-.endif
 _ix=   ix
 _ixv=  ixv
 _linux=linux
@@ -672,18 +682,6 @@ _ipwfw=ipwfw
 _iwifw=iwifw
 _iwmfw=iwmfw
 _iwnfw=iwnfw
-.endif
-_mlx4= mlx4
-_mlx5= mlx5
-.if (${MK_INET_SUPPORT} != "no" && ${MK_INET6_SUPPORT} != "no") || \
-   defined(ALL_MODULES)
-_mlx4en=   mlx4en
-_mlx5en=   mlx5en
-.endif
-.if ${MK_OFED} != "no" || defined(ALL_MODULES)
-_mthca=mthca
-_mlx4ib=   mlx4ib
-_mlx5ib=   mlx5ib
 .endif
 _mly=  mly
 _nfe=  nfe
___
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: r346315 - head/lib/libcasper/services/cap_fileargs

2019-04-23 Thread Ed Maste
On Tue, 23 Apr 2019 at 00:07, Yoshihiro Ota  wrote:
>
> It looks this change is causing 'make xdev TARGET=mips TARGET_ARCH=mips' to 
> fail as the following with HEAD checked out under "/usr/obj/freebsd":

Hello Hiro-san, sorry about that.

I tried `make xdev TARGET=mips TARGET_ARCH=mips` on HEAD just now (but
it failed on the install as DESTDIR wasn't set and I ran as non-root).
Just `make xdev-build` was successful though.

What version were you trying to build? There were (several) followup
commits to address issues with the initial commit of cap_fileargs
lstat support.
___
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: r346597 - in stable/12/sys: amd64/amd64 i386/i386

2019-04-23 Thread Konstantin Belousov
Author: kib
Date: Tue Apr 23 12:29:19 2019
New Revision: 346597
URL: https://svnweb.freebsd.org/changeset/base/346597

Log:
  MFC r345562 (by cem), r346294:
  x86: Use XSAVEOPT for fpusave(), when available.

Modified:
  stable/12/sys/amd64/amd64/fpu.c
  stable/12/sys/i386/i386/npx.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/amd64/amd64/fpu.c
==
--- stable/12/sys/amd64/amd64/fpu.c Tue Apr 23 12:23:44 2019
(r346596)
+++ stable/12/sys/amd64/amd64/fpu.c Tue Apr 23 12:29:19 2019
(r346597)
@@ -100,6 +100,17 @@ xsave(char *addr, uint64_t mask)
"memory");
 }
 
+static __inline void
+xsaveopt(char *addr, uint64_t mask)
+{
+   uint32_t low, hi;
+
+   low = mask;
+   hi = mask >> 32;
+   __asm __volatile("xsaveopt %0" : "=m" (*addr) : "a" (low), "d" (hi) :
+   "memory");
+}
+
 #else  /* !(__GNUCLIKE_ASM && !lint) */
 
 void   fldcw(u_short cw);
@@ -113,6 +124,7 @@ voidldmxcsr(u_int csr);
 void   stmxcsr(u_int *csr);
 void   xrstor(char *addr, uint64_t mask);
 void   xsave(char *addr, uint64_t mask);
+void   xsaveopt(char *addr, uint64_t mask);
 
 #endif /* __GNUCLIKE_ASM && !lint */
 
@@ -158,6 +170,13 @@ struct xsave_area_elm_descr {
 } *xsave_area_desc;
 
 static void
+fpusave_xsaveopt(void *addr)
+{
+
+   xsaveopt((char *)addr, xsave_mask);
+}
+
+static void
 fpusave_xsave(void *addr)
 {
 
@@ -201,7 +220,10 @@ DEFINE_IFUNC(, void, fpusave, (void *), static)
 {
 
init_xsave();
-   return (use_xsave ? fpusave_xsave : fpusave_fxsave);
+   if (use_xsave)
+   return ((cpu_stdext_feature & CPUID_EXTSTATE_XSAVEOPT) != 0 ?
+   fpusave_xsaveopt : fpusave_xsave);
+   return (fpusave_fxsave);
 }
 
 DEFINE_IFUNC(, void, fpurestore, (void *), static)
@@ -348,6 +370,7 @@ fpuinit(void)
 static void
 fpuinitstate(void *arg __unused)
 {
+   uint64_t *xstate_bv;
register_t saveintr;
int cp[4], i, max_ext_n;
 
@@ -356,7 +379,7 @@ fpuinitstate(void *arg __unused)
saveintr = intr_disable();
stop_emulating();
 
-   fpusave(fpu_initialstate);
+   fpusave_fxsave(fpu_initialstate);
if (fpu_initialstate->sv_env.en_mxcsr_mask)
cpu_mxcsr_mask = fpu_initialstate->sv_env.en_mxcsr_mask;
else
@@ -378,6 +401,10 @@ fpuinitstate(void *arg __unused)
 * Save Area.
 */
if (use_xsave) {
+   xstate_bv = (uint64_t *)((char *)(fpu_initialstate + 1) +
+   offsetof(struct xstate_hdr, xstate_bv));
+   *xstate_bv = XFEATURE_ENABLED_X87 | XFEATURE_ENABLED_SSE;
+
max_ext_n = flsl(xsave_mask);
xsave_area_desc = malloc(max_ext_n * sizeof(struct
xsave_area_elm_descr), M_DEVBUF, M_WAITOK | M_ZERO);

Modified: stable/12/sys/i386/i386/npx.c
==
--- stable/12/sys/i386/i386/npx.c   Tue Apr 23 12:23:44 2019
(r346596)
+++ stable/12/sys/i386/i386/npx.c   Tue Apr 23 12:29:19 2019
(r346597)
@@ -313,7 +313,7 @@ cleanup:
 }
 
 static void
-npxsave_xsaveopt(union savefpu *addr)
+fpusave_xsaveopt(union savefpu *addr)
 {
 
xsaveopt((char *)addr, xsave_mask);
@@ -352,29 +352,18 @@ init_xsave(void)
TUNABLE_INT_FETCH("hw.use_xsave", _xsave);
 }
 
-DEFINE_IFUNC(, void, npxsave_core, (union savefpu *), static)
+DEFINE_IFUNC(, void, fpusave, (union savefpu *), static)
 {
 
init_xsave();
if (use_xsave)
return ((cpu_stdext_feature & CPUID_EXTSTATE_XSAVEOPT) != 0 ?
-   npxsave_xsaveopt : fpusave_xsave);
+   fpusave_xsaveopt : fpusave_xsave);
if (cpu_fxsr)
return (fpusave_fxsave);
return (fpusave_fnsave);
 }
 
-DEFINE_IFUNC(, void, fpusave, (union savefpu *), static)
-{
-
-   init_xsave();
-   if (use_xsave)
-   return (fpusave_xsave);
-   if (cpu_fxsr)
-   return (fpusave_fxsave);
-   return (fpusave_fnsave);
-}
-
 /*
  * Enable XSAVE if supported and allowed by user.
  * Calculate the xsave_mask.
@@ -483,6 +472,7 @@ npxinit(bool bsp)
 static void
 npxinitstate(void *arg __unused)
 {
+   uint64_t *xstate_bv;
register_t saveintr;
int cp[4], i, max_ext_n;
 
@@ -494,7 +484,10 @@ npxinitstate(void *arg __unused)
saveintr = intr_disable();
stop_emulating();
 
-   fpusave(npx_initialstate);
+   if (cpu_fxsr)
+   fpusave_fxsave(npx_initialstate);
+   else
+   fpusave_fnsave(npx_initialstate);
if (cpu_fxsr) {
if (npx_initialstate->sv_xmm.sv_env.en_mxcsr_mask)
cpu_mxcsr_mask = 
@@ -515,6 +508,7 @@ npxinitstate(void *arg __unused)
sizeof(npx_initialstate->sv_xmm.sv_fp));

svn commit: r346596 - head/sys/netinet6

2019-04-23 Thread Konstantin Belousov
Author: kib
Date: Tue Apr 23 12:23:44 2019
New Revision: 346596
URL: https://svnweb.freebsd.org/changeset/base/346596

Log:
  poib: assign link-local address according to RFC
  
  RFC 4391 specifies that the IB interface GID should be re-used as IPv6
  link-local address.  Since the code in in6_get_hw_ifid() ignored
  IFT_INFINIBAND case, ibX interfaces ended up with the local address
  borrowed from some other interface, which is non-compliant.
  
  Use lowest eight bytes from GID for filling the link-local address,
  same as Linux.
  
  Reviewed by:  bz (previous version), ae, hselasky, slavash,
  Sponsored by: Mellanox Technologies
  MFC after:1 week
  Differential revision:https://reviews.freebsd.org/D20006

Modified:
  head/sys/netinet6/in6_ifattach.c

Modified: head/sys/netinet6/in6_ifattach.c
==
--- head/sys/netinet6/in6_ifattach.cTue Apr 23 10:12:33 2019
(r346595)
+++ head/sys/netinet6/in6_ifattach.cTue Apr 23 12:23:44 2019
(r346596)
@@ -328,6 +328,14 @@ found:
NET_EPOCH_EXIT(et);
return -1;
 
+   case IFT_INFINIBAND:
+   if (addrlen != 20) {
+   NET_EPOCH_EXIT(et);
+   return -1;
+   }
+   bcopy(addr + 12, >s6_addr[8], 8);
+   break;
+
default:
NET_EPOCH_EXIT(et);
return -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"


Re: svn commit: r346588 - head/lib/libc/powerpc64/string

2019-04-23 Thread Alexey Dokuchaev
On Tue, Apr 23, 2019 at 02:53:53AM +, Justin Hibbits wrote:
> New Revision: 346588
> URL: https://svnweb.freebsd.org/changeset/base/346588
> 
> Log:
>   powerpc64: Rewrite strcmp in asm to take advantage of word size
> ...
>   Some performance gain rates between the current and the optimized
>   solution:
> 
>   String size (bytes) Gain rate
>   <=8 0.59%
>   <=161.92%
>   32  3.02%
>   64  5.60%
>   128 10.16%
>   256 18.05%
>   512 30.18%
>   102442.82%

Nice!  This should help to speed up buildworld quite a bit.  Would it
be feasible to patch ppc32 in a similar fashion?  Thanks,

./danfe
___
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: r346595 - head/sys/netinet

2019-04-23 Thread Bjoern A. Zeeb
Author: bz
Date: Tue Apr 23 10:12:33 2019
New Revision: 346595
URL: https://svnweb.freebsd.org/changeset/base/346595

Log:
  iFix udp_output() lock inconsistency.
  
  In r297225 the initial INP_RLOCK() was replaced by an early
  acquisition of an r- or w-lock depending on input variables
  possibly extending the write locked area for reasons not entirely
  clear but possibly to avoid a later case of unlock and relock
  leading to a possible race condition and possibly in order to
  allow the route cache to work for connected sockets.
  
  Unfortunately the conditions were not 1:1 replicated (probably
  because of the route cache needs). While this would not be a
  problem the legacy IP code compared to IPv6 has an extra case
  when dealing with IP_SENDSRCADDR. In a particular case we were
  holding an exclusive inp lock and acquired the shared udbinfo
  lock (now epoch).
  When then running into an error case, the locking assertions
  on release fired as the udpinfo and inp lock levels did not match.
  
  Break up the special case and in that particular case acquire
  and udpinfo lock depending on the exclusitivity of the inp lock.
  
  MFC After:9 days
  Reported-by:  syzbot+1f5c6800e4f99bdb1...@syzkaller.appspotmail.com
  Reviewed by:  tuexen
  Differential Revision:https://reviews.freebsd.org/D19594

Modified:
  head/sys/netinet/udp_usrreq.c

Modified: head/sys/netinet/udp_usrreq.c
==
--- head/sys/netinet/udp_usrreq.c   Tue Apr 23 07:46:38 2019
(r346594)
+++ head/sys/netinet/udp_usrreq.c   Tue Apr 23 10:12:33 2019
(r346595)
@@ -1258,20 +1258,22 @@ udp_output(struct inpcb *inp, struct mbuf *m, struct s
}
 
/*
-* Depending on whether or not the application has bound or connected
-* the socket, we may have to do varying levels of work.  The optimal
-* case is for a connected UDP socket, as a global lock isn't
-* required at all.
-*
-* In order to decide which we need, we require stability of the
-* inpcb binding, which we ensure by acquiring a read lock on the
-* inpcb.  This doesn't strictly follow the lock order, so we play
-* the trylock and retry game; note that we may end up with more
-* conservative locks than required the second time around, so later
-* assertions have to accept that.  Further analysis of the number of
-* misses under contention is required.
-*
-* XXXRW: Check that hash locking update here is correct.
+* In the old days, depending on whether or not the application had
+* bound or connected the socket, we had to do varying levels of work.
+* The optimal case was for a connected UDP socket, as a global lock
+* wasn't required at all.
+* In order to decide which we need, we required stability of the
+* inpcb binding, which we ensured by acquiring a read lock on the
+* inpcb.  This didn't strictly follow the lock order, so we played
+* the trylock and retry game.
+* With the re-introduction of the route-cache in some cases, we started
+* to acquire an early inp wlock and a possible race during re-lock
+* went away.  With the introduction of epoch(9) some read locking
+* became epoch(9) and the lock-order issues also went away.
+* Due to route-cache we may now hold more conservative locks than
+* otherwise required and have split up the 2nd case in case 2 and 3
+* in order to keep the udpinfo lock level in sync with the inp one
+* for the IP_SENDSRCADDR case below.
 */
pr = inp->inp_socket->so_proto->pr_protocol;
pcbinfo = udp_get_inpcbinfo(pr);
@@ -1279,14 +1281,21 @@ udp_output(struct inpcb *inp, struct mbuf *m, struct s
(inp->inp_laddr.s_addr == INADDR_ANY && inp->inp_lport == 0)) {
INP_HASH_WLOCK(pcbinfo);
unlock_udbinfo = UH_WLOCKED;
-   } else if ((sin != NULL &&
-   (sin->sin_addr.s_addr == INADDR_ANY ||
-   sin->sin_addr.s_addr == INADDR_BROADCAST ||
-   inp->inp_laddr.s_addr == INADDR_ANY ||
-   inp->inp_lport == 0)) ||
-   src.sin_family == AF_INET) {
+   } else if (sin != NULL &&
+   (sin->sin_addr.s_addr == INADDR_ANY ||
+   sin->sin_addr.s_addr == INADDR_BROADCAST ||
+   inp->inp_laddr.s_addr == INADDR_ANY ||
+   inp->inp_lport == 0)) {
INP_HASH_RLOCK_ET(pcbinfo, et);
unlock_udbinfo = UH_RLOCKED;
+   } else if (src.sin_family == AF_INET) {
+   if (unlock_inp == UH_WLOCKED) {
+   INP_HASH_WLOCK(pcbinfo);
+   unlock_udbinfo = UH_WLOCKED;
+   } else {
+   INP_HASH_RLOCK_ET(pcbinfo, et);
+   unlock_udbinfo = 

svn commit: r346594 - head/sbin/camcontrol

2019-04-23 Thread Steven Hartland
Author: smh
Date: Tue Apr 23 07:46:38 2019
New Revision: 346594
URL: https://svnweb.freebsd.org/changeset/base/346594

Log:
  Add ATA power mode support to camcontrol
  
  Add the ability to report ATA device power mode with the cmmand 'powermode'
  to compliment the existing ability to set it using idle, standby and sleep
  commands.
  
  MFC after:2 weeks
  Sponsored by: Multiplay

Modified:
  head/sbin/camcontrol/camcontrol.8
  head/sbin/camcontrol/camcontrol.c

Modified: head/sbin/camcontrol/camcontrol.8
==
--- head/sbin/camcontrol/camcontrol.8   Tue Apr 23 06:36:32 2019
(r346593)
+++ head/sbin/camcontrol/camcontrol.8   Tue Apr 23 07:46:38 2019
(r346594)
@@ -27,7 +27,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd March 12, 2019
+.Dd April 22, 2019
 .Dt CAMCONTROL 8
 .Os
 .Sh NAME
@@ -243,6 +243,10 @@
 .Op device id
 .Op generic args
 .Nm
+.Ic powermode
+.Op device id
+.Op generic args
+.Nm
 .Ic apm
 .Op device id
 .Op generic args
@@ -1388,6 +1392,8 @@ Value 0 disables timer.
 Put ATA device into SLEEP state.
 Note that the only way get device out of
 this state may be reset.
+.It Ic powermode
+Report ATA device power mode.
 .It Ic apm
 It optional parameter
 .Pq Fl l

Modified: head/sbin/camcontrol/camcontrol.c
==
--- head/sbin/camcontrol/camcontrol.c   Tue Apr 23 06:36:32 2019
(r346593)
+++ head/sbin/camcontrol/camcontrol.c   Tue Apr 23 07:46:38 2019
(r346594)
@@ -109,7 +109,8 @@ typedef enum {
CAM_CMD_ZONE= 0x0026,
CAM_CMD_EPC = 0x0027,
CAM_CMD_TIMESTAMP   = 0x0028,
-   CAM_CMD_MMCSD_CMD   = 0x0029
+   CAM_CMD_MMCSD_CMD   = 0x0029,
+   CAM_CMD_POWER_MODE  = 0x002a,
 } cam_cmdmask;
 
 typedef enum {
@@ -236,6 +237,7 @@ static struct camcontrol_opts option_table[] = {
{"idle", CAM_CMD_IDLE, CAM_ARG_NONE, "t:"},
{"standby", CAM_CMD_STANDBY, CAM_ARG_NONE, "t:"},
{"sleep", CAM_CMD_SLEEP, CAM_ARG_NONE, ""},
+   {"powermode", CAM_CMD_POWER_MODE, CAM_ARG_NONE, ""},
{"apm", CAM_CMD_APM, CAM_ARG_NONE, "l:"},
{"aam", CAM_CMD_AAM, CAM_ARG_NONE, "l:"},
{"fwdownload", CAM_CMD_DOWNLOAD_FW, CAM_ARG_NONE, "f:qsy"},
@@ -8885,6 +8887,61 @@ bailout:
 }
 
 static int
+atapm_proc_resp(struct cam_device *device, union ccb *ccb)
+{
+struct ata_res *res;
+
+res = >ataio.res;
+if (res->status & ATA_STATUS_ERROR) {
+if (arglist & CAM_ARG_VERBOSE) {
+cam_error_print(device, ccb, CAM_ESF_ALL,
+CAM_EPF_ALL, stderr);
+printf("error = 0x%02x, sector_count = 0x%04x, "
+   "device = 0x%02x, status = 0x%02x\n",
+   res->error, res->sector_count,
+   res->device, res->status);
+}
+
+return (1);
+}
+
+if (arglist & CAM_ARG_VERBOSE) {
+fprintf(stdout, "%s%d: Raw native check power data:\n",
+device->device_name, device->dev_unit_num);
+/* res is 4 byte aligned */
+dump_data((uint16_t*)(uintptr_t)res, sizeof(struct ata_res));
+
+printf("error = 0x%02x, sector_count = 0x%04x, device = 0x%02x, "
+   "status = 0x%02x\n", res->error, res->sector_count,
+   res->device, res->status);
+}
+
+printf("%s%d: ", device->device_name, device->dev_unit_num);
+switch (res->sector_count) {
+case 0x00:
+   printf("Standby mode\n");
+   break;
+case 0x40:
+   printf("NV Cache Power Mode and the spindle is spun down or spinning 
down\n");
+   break;
+case 0x41:
+   printf("NV Cache Power Mode and the spindle is spun up or spinning 
up\n");
+   break;
+case 0x80:
+   printf("Idle mode\n");
+   break;
+case 0xff:
+   printf("Active or Idle mode\n");
+   break;
+default:
+   printf("Unknown mode 0x%02x\n", res->sector_count);
+   break;
+}
+
+return (0);
+}
+
+static int
 atapm(struct cam_device *device, int argc, char **argv,
 char *combinedopt, int retry_count, int timeout)
 {
@@ -8892,6 +8949,7 @@ atapm(struct cam_device *device, int argc, char **argv
int retval = 0;
int t = -1;
int c;
+   u_int8_t ata_flags = 0;
u_char cmd, sc;
 
ccb = cam_getccb(device);
@@ -8920,6 +8978,10 @@ atapm(struct cam_device *device, int argc, char **argv
cmd = ATA_STANDBY_IMMEDIATE;
else
cmd = ATA_STANDBY_CMD;
+   } else if (strcmp(argv[1], "powermode") == 0) {
+   cmd = ATA_CHECK_POWER_MODE;
+   ata_flags = AP_FLAG_CHK_COND;
+   t = -1;
} else {
cmd = ATA_SLEEP;
t = -1;
@@ -8937,11 +8999,12 @@ atapm(struct cam_device *device, int argc, char **argv
else

svn commit: r346593 - head/sys/sys

2019-04-23 Thread Wojciech Macek
Author: wma
Date: Tue Apr 23 06:36:32 2019
New Revision: 346593
URL: https://svnweb.freebsd.org/changeset/base/346593

Log:
  This patch offers a workaround to buf_ring reordering
  visible on armv7 and armv8. Similar issue to rS302292.
  
  Obtained from: Semihalf
  Authored by:   Michal Krawczyk 
  Approved by:   wma
  Differential Revision: https://reviews.freebsd.org/D19932

Modified:
  head/sys/sys/buf_ring.h

Modified: head/sys/sys/buf_ring.h
==
--- head/sys/sys/buf_ring.h Tue Apr 23 04:06:26 2019(r346592)
+++ head/sys/sys/buf_ring.h Tue Apr 23 06:36:32 2019(r346593)
@@ -310,14 +310,23 @@ buf_ring_peek_clear_sc(struct buf_ring *br)
if (!mtx_owned(br->br_lock))
panic("lock not held on single consumer dequeue");
 #endif 
-   /*
-* I believe it is safe to not have a memory barrier
-* here because we control cons and tail is worst case
-* a lagging indicator so we worst case we might
-* return NULL immediately after a buffer has been enqueued
-*/
+
if (br->br_cons_head == br->br_prod_tail)
return (NULL);
+
+#if defined(__arm__) || defined(__aarch64__)
+   /*
+* The barrier is required there on ARM and ARM64 to ensure, that
+* br->br_ring[br->br_cons_head] will not be fetched before the above
+* condition is checked.
+* Without the barrier, it is possible, that buffer will be fetched
+* before the enqueue will put mbuf into br, then, in the meantime, the
+* enqueue will update the array and the br_prod_tail, and the
+* conditional check will be true, so we will return previously fetched
+* (and invalid) buffer.
+*/
+   atomic_thread_fence_acq();
+#endif
 
 #ifdef DEBUG_BUFRING
/*
___
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"