svn commit: r355701 - stable/11/sys/x86/x86

2019-12-12 Thread Scott Long
Author: scottl
Date: Fri Dec 13 06:54:41 2019
New Revision: 355701
URL: https://svnweb.freebsd.org/changeset/base/355701

Log:
  Merge r355134,355375,355589
  
  Clean up and clarify meta commentary on TAA.  Add a state to denote
  that TSX doesn't exist on the CPU.
  
  x86: Add missed break to TAA status sysctl
  
  Fix the TAA state machine to do the right thing when the TAA
  migitation is available in microcode and the operator has set
  the sysctl to automatic mode.
  
  Sponsored by: Intel

Modified:
  stable/11/sys/x86/x86/cpu_machdep.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/x86/x86/cpu_machdep.c
==
--- stable/11/sys/x86/x86/cpu_machdep.c Fri Dec 13 05:54:38 2019
(r355700)
+++ stable/11/sys/x86/x86/cpu_machdep.c Fri Dec 13 06:54:41 2019
(r355701)
@@ -1192,11 +1192,15 @@ SYSCTL_PROC(_hw, OID_AUTO, mds_disable, CTLTYPE_INT |
 int x86_taa_enable;
 int x86_taa_state;
 enum {
-   TAA_NONE= 0,
-   TAA_TSX_DISABLE = 1,
-   TAA_VERW= 2,
-   TAA_AUTO= 3,
-   TAA_TAA_NO  = 4
+   TAA_NONE= 0,/* No mitigation enabled */
+   TAA_TSX_DISABLE = 1,/* Disable TSX via MSR */
+   TAA_VERW= 2,/* Use VERW mitigation */
+   TAA_AUTO= 3,/* Automatically select the mitigation */
+
+   /* The states below are not selectable by the operator */
+
+   TAA_TAA_UC  = 4,/* Mitigation present in microcode */
+   TAA_NOT_PRESENT = 5 /* TSX is not present */
 };
 
 static void
@@ -1220,15 +1224,14 @@ x86_taa_recalculate(void)
if ((cpu_stdext_feature & CPUID_STDEXT_HLE) == 0 ||
(cpu_stdext_feature & CPUID_STDEXT_RTM) == 0) {
/* TSX is not present */
-   x86_taa_state = 0;
+   x86_taa_state = TAA_NOT_PRESENT;
return;
}
 
/* Check to see what mitigation options the CPU gives us */
if (cpu_ia32_arch_caps & IA32_ARCH_CAP_TAA_NO) {
/* CPU is not suseptible to TAA */
-   taa_need = TAA_NONE;
-   taa_state = TAA_TAA_NO;
+   taa_need = TAA_TAA_UC;
} else if (cpu_ia32_arch_caps & IA32_ARCH_CAP_TSX_CTRL) {
/*
 * CPU can turn off TSX.  This is the next best option
@@ -1335,8 +1338,11 @@ sysctl_taa_state_handler(SYSCTL_HANDLER_ARGS)
case TAA_VERW:
state = "VERW";
break;
-   case TAA_TAA_NO:
-   state = "Not vulnerable";
+   case TAA_TAA_UC:
+   state = "Mitigated in microcode";
+   break;
+   case TAA_NOT_PRESENT:
+   state = "TSX not present";
break;
default:
state = "unknown";
___
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: r355700 - head/usr.sbin/ntp

2019-12-12 Thread Conrad Meyer
Author: cem
Date: Fri Dec 13 05:54:38 2019
New Revision: 355700
URL: https://svnweb.freebsd.org/changeset/base/355700

Log:
  ntpd(8): Don't use OpenSSL's RAND API
  
  The !USE_OPENSSL_CRYPTO_RAND path uses arc4random_buf() correctly.
  
  In general, we should prefer to avoid things OpenSSL does poorly when a good
  alternative exists in libc.

Modified:
  head/usr.sbin/ntp/Makefile.inc

Modified: head/usr.sbin/ntp/Makefile.inc
==
--- head/usr.sbin/ntp/Makefile.inc  Fri Dec 13 05:42:57 2019
(r355699)
+++ head/usr.sbin/ntp/Makefile.inc  Fri Dec 13 05:54:38 2019
(r355700)
@@ -11,7 +11,7 @@ NTPDEFS=   -DSYS_FREEBSD
 CFLAGS+= ${NTPDEFS} ${DEFS_LOCAL} ${CLOCKDEFS}
 
 .if ${MK_OPENSSL} != "no"
-CFLAGS+= -DOPENSSL -DUSE_OPENSSL_CRYPTO_RAND -DAUTOKEY
+CFLAGS+= -DOPENSSL -DAUTOKEY
 .endif
 
 WARNS?=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: r355699 - head/contrib/telnet/libtelnet

2019-12-12 Thread Conrad Meyer
Author: cem
Date: Fri Dec 13 05:42:57 2019
New Revision: 355699
URL: https://svnweb.freebsd.org/changeset/base/355699

Log:
  libtelnet: Replace bogus use of srandomdev + random to generate "public key 
pair"
  
  I'm pretty skeptical that any crypto in telnet is worth using, but if we're
  ostensibly generating keys, arc4random is strictly better than the previous
  construct.

Modified:
  head/contrib/telnet/libtelnet/pk.c

Modified: head/contrib/telnet/libtelnet/pk.c
==
--- head/contrib/telnet/libtelnet/pk.c  Fri Dec 13 05:29:26 2019
(r355698)
+++ head/contrib/telnet/libtelnet/pk.c  Fri Dec 13 05:42:57 2019
(r355699)
@@ -142,12 +142,7 @@ common_key(char *xsecret, char *xpublic, IdeaData *ide
 static void
 getseed(char *seed, int seedsize)
 {
-   int i;
-
-   srandomdev();
-   for (i = 0; i < seedsize; i++) {
-   seed[i] = random() & 0xff;
-   }
+   arc4random_buf(seed, seedsize);
 }
 
 /*
___
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: r355698 - stable/12/sys/x86/x86

2019-12-12 Thread Scott Long
Author: scottl
Date: Fri Dec 13 05:29:26 2019
New Revision: 355698
URL: https://svnweb.freebsd.org/changeset/base/355698

Log:
  Merge r355134,355375,355589
  
  Clean up and clarify meta commentary on TAA.  Add a state to denote
  that TSX doesn't exist on the CPU.
  
  x86: Add missed break to TAA status sysctl
  
  Fix the TAA state machine to do the right thing when the TAA
  migitation is available in microcode and the operator has set
  the sysctl to automatic mode.
  
  Sponsored by: Intel

Modified:
  stable/12/sys/x86/x86/cpu_machdep.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/x86/x86/cpu_machdep.c
==
--- stable/12/sys/x86/x86/cpu_machdep.c Fri Dec 13 05:13:25 2019
(r355697)
+++ stable/12/sys/x86/x86/cpu_machdep.c Fri Dec 13 05:29:26 2019
(r355698)
@@ -1164,11 +1164,15 @@ SYSCTL_PROC(_hw, OID_AUTO, mds_disable, CTLTYPE_INT |
 int x86_taa_enable;
 int x86_taa_state;
 enum {
-   TAA_NONE= 0,
-   TAA_TSX_DISABLE = 1,
-   TAA_VERW= 2,
-   TAA_AUTO= 3,
-   TAA_TAA_NO  = 4
+   TAA_NONE= 0,/* No mitigation enabled */
+   TAA_TSX_DISABLE = 1,/* Disable TSX via MSR */
+   TAA_VERW= 2,/* Use VERW mitigation */
+   TAA_AUTO= 3,/* Automatically select the mitigation */
+
+   /* The states below are not selectable by the operator */
+
+   TAA_TAA_UC  = 4,/* Mitigation present in microcode */
+   TAA_NOT_PRESENT = 5 /* TSX is not present */
 };
 
 static void
@@ -1192,15 +1196,14 @@ x86_taa_recalculate(void)
if ((cpu_stdext_feature & CPUID_STDEXT_HLE) == 0 ||
(cpu_stdext_feature & CPUID_STDEXT_RTM) == 0) {
/* TSX is not present */
-   x86_taa_state = 0;
+   x86_taa_state = TAA_NOT_PRESENT;
return;
}
 
/* Check to see what mitigation options the CPU gives us */
if (cpu_ia32_arch_caps & IA32_ARCH_CAP_TAA_NO) {
/* CPU is not suseptible to TAA */
-   taa_need = TAA_NONE;
-   taa_state = TAA_TAA_NO;
+   taa_need = TAA_TAA_UC;
} else if (cpu_ia32_arch_caps & IA32_ARCH_CAP_TSX_CTRL) {
/*
 * CPU can turn off TSX.  This is the next best option
@@ -1307,8 +1310,11 @@ sysctl_taa_state_handler(SYSCTL_HANDLER_ARGS)
case TAA_VERW:
state = "VERW";
break;
-   case TAA_TAA_NO:
-   state = "Not vulnerable";
+   case TAA_TAA_UC:
+   state = "Mitigated in microcode";
+   break;
+   case TAA_NOT_PRESENT:
+   state = "TSX not present";
break;
default:
state = "unknown";
___
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: r355696 - head/lib/libtacplus

2019-12-12 Thread Benjamin Kaduk
On Thu, Dec 12, 2019 at 9:11 PM Conrad Meyer  wrote:

> Author: cem
> Date: Fri Dec 13 05:11:34 2019
> New Revision: 355696
> URL: https://svnweb.freebsd.org/changeset/base/355696
>
> Log:
>   libtacplus: Remove bogus srandomdev+random
>
>   Replace with arc4random.
>
>   TACAS+ is a 1993 Cisco extension to the 1984 TACAS.  Is this something
> we want
>   in base still?  The directory has been substantively unmaintained since
> 2002,
>   at least.
>
>
It's not as dead as that makes it sound --
https://datatracker.ietf.org/doc/draft-ietf-opsawg-tacacs/ is on its way to
becoming an RFC.

-Ben
___
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: r355697 - head/contrib/bsnmp/snmpd

2019-12-12 Thread Conrad Meyer
Author: cem
Date: Fri Dec 13 05:13:25 2019
New Revision: 355697
URL: https://svnweb.freebsd.org/changeset/base/355697

Log:
  bsnmpd(1): Replace dubious srandomdev+random(3) with arc4random(3)

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

Modified: head/contrib/bsnmp/snmpd/main.c
==
--- head/contrib/bsnmp/snmpd/main.c Fri Dec 13 05:11:34 2019
(r355696)
+++ head/contrib/bsnmp/snmpd/main.c Fri Dec 13 05:13:25 2019
(r355697)
@@ -1615,9 +1615,7 @@ main(int argc, char *argv[])
progargs = argv;
nprogargs = argc;
 
-   srandomdev();
-
-   snmp_serial_no = random();
+   snmp_serial_no = arc4random();
 
 #ifdef USE_TCPWRAPPERS
/*
___
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: r355696 - head/lib/libtacplus

2019-12-12 Thread Conrad Meyer
Author: cem
Date: Fri Dec 13 05:11:34 2019
New Revision: 355696
URL: https://svnweb.freebsd.org/changeset/base/355696

Log:
  libtacplus: Remove bogus srandomdev+random
  
  Replace with arc4random.
  
  TACAS+ is a 1993 Cisco extension to the 1984 TACAS.  Is this something we want
  in base still?  The directory has been substantively unmaintained since 2002,
  at least.

Modified:
  head/lib/libtacplus/taclib.c

Modified: head/lib/libtacplus/taclib.c
==
--- head/lib/libtacplus/taclib.cFri Dec 13 04:55:17 2019
(r355695)
+++ head/lib/libtacplus/taclib.cFri Dec 13 05:11:34 2019
(r355696)
@@ -429,10 +429,10 @@ gen_session_id(struct tac_msg *msg)
 {
int r;
 
-   r = random();
+   r = arc4random();
msg->session_id[0] = r >> 8;
msg->session_id[1] = r;
-   r = random();
+   r = arc4random();
msg->session_id[2] = r >> 8;
msg->session_id[3] = r;
 }
@@ -1051,7 +1051,6 @@ tac_open(void)
}
init_srvr_str(>srvr_msg);
init_srvr_str(>srvr_data);
-   srandomdev();
}
return 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: r355695 - head/lib/libradius

2019-12-12 Thread Conrad Meyer
Author: cem
Date: Fri Dec 13 04:55:17 2019
New Revision: 355695
URL: https://svnweb.freebsd.org/changeset/base/355695

Log:
  libradius: Rip out dubious use of srandomdev(3)+random(3)
  
  These functions appear to intend to produce unpredictable results.  Just use
  arc4random.
  
  While here, use an explicit_bzero instead of memset where the intent is 
clearly
  to zero out a secret (clear_passphrase).

Modified:
  head/lib/libradius/radlib.c

Modified: head/lib/libradius/radlib.c
==
--- head/lib/libradius/radlib.c Fri Dec 13 04:48:20 2019(r355694)
+++ head/lib/libradius/radlib.c Fri Dec 13 04:55:17 2019(r355695)
@@ -79,7 +79,7 @@ static void
 clear_password(struct rad_handle *h)
 {
if (h->pass_len != 0) {
-   memset(h->pass, 0, h->pass_len);
+   explicit_bzero(h->pass, h->pass_len);
h->pass_len = 0;
}
h->pass_pos = 0;
@@ -852,8 +852,8 @@ rad_create_request(struct rad_handle *h, int code)
if (code == RAD_ACCESS_REQUEST) {
/* Create a random authenticator */
for (i = 0;  i < LEN_AUTH;  i += 2) {
-   long r;
-   r = random();
+   uint32_t r;
+   r = arc4random();
h->out[POS_AUTH+i] = (u_char)r;
h->out[POS_AUTH+i+1] = (u_char)(r >> 8);
}
@@ -1051,10 +1051,9 @@ rad_auth_open(void)
 
h = (struct rad_handle *)malloc(sizeof(struct rad_handle));
if (h != NULL) {
-   srandomdev();
h->fd = -1;
h->num_servers = 0;
-   h->ident = random();
+   h->ident = arc4random();
h->errmsg[0] = '\0';
memset(h->pass, 0, sizeof h->pass);
h->pass_len = 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: r355694 - head/sys/kern

2019-12-12 Thread Conrad Meyer
Author: cem
Date: Fri Dec 13 04:48:20 2019
New Revision: 355694
URL: https://svnweb.freebsd.org/changeset/base/355694

Log:
  kern/subr_unit: Rip srandomdev, random(3) out of dead code
  
  The simulation cannot be reproduced, so the value of using a deterministic 
PRNG
  like random(3) is dubious.  The number of repitions used in the sample isn't a
  problem for the Chacha implementation of arc4random we have today.  (Also, no
  one actually runs this code; it was provided as an example of the work the
  author did validating the implementation.  It's not even test code.)

Modified:
  head/sys/kern/subr_unit.c

Modified: head/sys/kern/subr_unit.c
==
--- head/sys/kern/subr_unit.c   Fri Dec 13 04:37:39 2019(r355693)
+++ head/sys/kern/subr_unit.c   Fri Dec 13 04:48:20 2019(r355694)
@@ -1021,7 +1021,7 @@ main(int argc, char **argv)
long count = 1; /* Number of unrs to test */
long reps = 1, m;
int ch;
-   u_int i, j;
+   u_int i;
 
verbose = false;
 
@@ -1055,20 +1055,18 @@ main(int argc, char **argv)
a = calloc(count, sizeof(char));
if (a == NULL)
err(1, "calloc failed");
-   srandomdev();
 
printf("sizeof(struct unr) %zu\n", sizeof(struct unr));
printf("sizeof(struct unrb) %zu\n", sizeof(struct unrb));
printf("sizeof(struct unrhdr) %zu\n", sizeof(struct unrhdr));
printf("NBITS %lu\n", (unsigned long)NBITS);
for (m = 0; m < count * reps; m++) {
-   j = random();
-   i = (j >> 1) % count;
+   i = arc4random_uniform(count);
 #if 0
if (a[i] && (j & 1))
continue;
 #endif
-   if ((random() & 1) != 0)
+   if ((arc4random() & 1) != 0)
test_alloc_unr(uh, i, a);
else
test_alloc_unr_specific(uh, i, a);
___
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: r355693 - head/usr.bin/random

2019-12-12 Thread Conrad Meyer
Author: cem
Date: Fri Dec 13 04:37:39 2019
New Revision: 355693
URL: https://svnweb.freebsd.org/changeset/base/355693

Log:
  random(6): produce random results
  
  This program is trash and there's no reason to keep it in base.  But as long 
as
  we're shipping a silly program named 'random', let's actually make it random.

Modified:
  head/usr.bin/random/random.6
  head/usr.bin/random/random.c
  head/usr.bin/random/randomize_fd.c
  head/usr.bin/random/randomize_fd.h

Modified: head/usr.bin/random/random.6
==
--- head/usr.bin/random/random.6Fri Dec 13 04:12:13 2019
(r355692)
+++ head/usr.bin/random/random.6Fri Dec 13 04:37:39 2019
(r355693)
@@ -28,7 +28,7 @@
 .\" @(#)random.6   8.2 (Berkeley) 3/31/94
 .\" $FreeBSD$
 .\"
-.Dd February 8, 2003
+.Dd December 12, 2019
 .Dt RANDOM 6
 .Os
 .Sh NAME
@@ -62,9 +62,7 @@ space characters as determined by
 The default
 .Ar denominator
 for this mode of operation is 1, which gives each line a chance to be
-displayed, but in a
-.Xr random 3
-order.
+displayed, but in a random order.
 .Pp
 The options are as follows:
 .Bl -tag -width Ds
@@ -112,7 +110,6 @@ Randomize words separated by
 instead of newlines.
 .El
 .Sh SEE ALSO
-.Xr random 3 ,
 .Xr fortune 6
 .Sh HISTORY
 The

Modified: head/usr.bin/random/random.c
==
--- head/usr.bin/random/random.cFri Dec 13 04:12:13 2019
(r355692)
+++ head/usr.bin/random/random.cFri Dec 13 04:37:39 2019
(r355693)
@@ -51,6 +51,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -135,8 +136,6 @@ main(int argc, char *argv[])
/* NOTREACHED */
}
 
-   srandomdev();
-
/*
 * Act as a filter, randomly choosing lines of the standard input
 * to write to the standard output.
@@ -158,7 +157,7 @@ main(int argc, char *argv[])
 
/* Compute a random exit status between 0 and denom - 1. */
if (random_exit)
-   return (int)(denom * random() / RANDOM_MAX_PLUS1);
+   return (arc4random_uniform(denom));
 
/*
 * Select whether to print the first line.  (Prime the pump.)
@@ -166,7 +165,7 @@ main(int argc, char *argv[])
 * 0 (which has a 1 / denom chance of being true), we select the
 * line.
 */
-   selected = (int)(denom * random() / RANDOM_MAX_PLUS1) == 0;
+   selected = (arc4random_uniform(denom) == 0);
while ((ch = getchar()) != EOF) {
if (selected)
(void)putchar(ch);
@@ -176,8 +175,7 @@ main(int argc, char *argv[])
err(2, "stdout");
 
/* Now see if the next line is to be printed. */
-   selected = (int)(denom * random() /
-   RANDOM_MAX_PLUS1) == 0;
+   selected = (arc4random_uniform(denom) == 0);
}
}
if (ferror(stdin))

Modified: head/usr.bin/random/randomize_fd.c
==
--- head/usr.bin/random/randomize_fd.c  Fri Dec 13 04:12:13 2019
(r355692)
+++ head/usr.bin/random/randomize_fd.c  Fri Dec 13 04:37:39 2019
(r355693)
@@ -34,6 +34,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -175,7 +176,7 @@ randomize_fd(int fd, int type, int unique, double deno
(type == RANDOM_TYPE_WORDS && isspace(buf[i])) ||
(eof && i == buflen - 1)) {
 make_token:
-   if (numnode == RANDOM_MAX_PLUS1) {
+   if (numnode == UINT32_MAX - 1) {
errno = EFBIG;
err(1, "too many delimiters");
}
@@ -210,15 +211,14 @@ make_token:
free(buf);
 
for (i = numnode; i > 0; i--) {
-   selected = random() % numnode;
+   selected = arc4random_uniform(numnode + 1);
 
for (j = 0, prev = n = rand_root; n != NULL; j++, prev = n, n = 
n->next) {
if (j == selected) {
if (n->cp == NULL)
break;
 
-   if ((int)(denom * random() /
-   RANDOM_MAX_PLUS1) == 0) {
+   if (arc4random_uniform(denom) == 0) {
ret = printf("%.*s",
(int)n->len - 1, n->cp);
if (ret < 0)

Modified: head/usr.bin/random/randomize_fd.h

svn commit: r355692 - head/sbin/fsirand

2019-12-12 Thread Conrad Meyer
Author: cem
Date: Fri Dec 13 04:12:13 2019
New Revision: 355692
URL: https://svnweb.freebsd.org/changeset/base/355692

Log:
  fsirand(8): Just use arc4random(3)
  
  Remove single use of dubious srandomdev(3) + random(3) and replace with
  arc4random(3), as is used already in this program.
  
  Follow-up question: Do we really need this program anymore?  In base?

Modified:
  head/sbin/fsirand/fsirand.c

Modified: head/sbin/fsirand/fsirand.c
==
--- head/sbin/fsirand/fsirand.c Fri Dec 13 04:03:05 2019(r355691)
+++ head/sbin/fsirand/fsirand.c Fri Dec 13 04:12:13 2019(r355692)
@@ -83,8 +83,6 @@ main(int argc, char *argv[])
if (argc - optind < 1)
usage();
 
-   srandomdev();
-
/* Increase our data size to the max */
if (getrlimit(RLIMIT_DATA, ) == 0) {
rl.rlim_cur = rl.rlim_max;
@@ -167,7 +165,7 @@ fsirand(char *device)
if (!printonly) {
/* Randomize fs_id and write out new sblock and backups */
sblock->fs_id[0] = (u_int32_t)time(NULL);
-   sblock->fs_id[1] = random();
+   sblock->fs_id[1] = arc4random();
if (sbput(devfd, sblock, sblock->fs_ncg) != 0) {
warn("could not write updated superblock");
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"


svn commit: r355690 - in stable: 11/sys/kern 11/sys/sys 12/sys/kern 12/sys/sys

2019-12-12 Thread Kyle Evans
Author: kevans
Date: Fri Dec 13 04:03:03 2019
New Revision: 355690
URL: https://svnweb.freebsd.org/changeset/base/355690

Log:
  MFC r352350: rangelock: add rangelock_cookie_assert
  
  A future change to posixshm to add file sealing will move locking out of
  shm_dotruncate as kern_shm_open() will require the lock to be held across
  the dotruncate until the seal is actually applied. For this, the cookie is
  passed into shm_dotruncate_locked which asserts RCA_WLOCKED.

Modified:
  stable/11/sys/kern/kern_rangelock.c
  stable/11/sys/sys/rangelock.h
Directory Properties:
  stable/11/   (props changed)

Changes in other areas also in this revision:
Modified:
  stable/12/sys/kern/kern_rangelock.c
  stable/12/sys/sys/rangelock.h
Directory Properties:
  stable/12/   (props changed)

Modified: stable/11/sys/kern/kern_rangelock.c
==
--- stable/11/sys/kern/kern_rangelock.c Fri Dec 13 03:29:54 2019
(r355689)
+++ stable/11/sys/kern/kern_rangelock.c Fri Dec 13 04:03:03 2019
(r355690)
@@ -246,3 +246,35 @@ rangelock_wlock(struct rangelock *lock, off_t start, o
 
return (rangelock_enqueue(lock, start, end, RL_LOCK_WRITE, ilk));
 }
+
+#ifdef INVARIANT_SUPPORT
+void
+_rangelock_cookie_assert(void *cookie, int what, const char *file, int line)
+{
+   struct rl_q_entry *entry;
+   int flags;
+
+   MPASS(cookie != NULL);
+   entry = cookie;
+   flags = entry->rl_q_flags;
+   switch (what) {
+   case RCA_LOCKED:
+   if ((flags & RL_LOCK_GRANTED) == 0)
+   panic("rangelock not held @ %s:%d\n", file, line);
+   break;
+   case RCA_RLOCKED:
+   if ((flags & (RL_LOCK_GRANTED | RL_LOCK_READ)) !=
+   (RL_LOCK_GRANTED | RL_LOCK_READ))
+   panic("rangelock not rlocked @ %s:%d\n", file, line);
+   break;
+   case RCA_WLOCKED:
+   if ((flags & (RL_LOCK_GRANTED | RL_LOCK_WRITE)) !=
+   (RL_LOCK_GRANTED | RL_LOCK_WRITE))
+   panic("rangelock not wlocked @ %s:%d\n", file, line);
+   break;
+   default:
+   panic("Unknown rangelock assertion: %d @ %s:%d", what, file,
+   line);
+   }
+}
+#endif /* INVARIANT_SUPPORT */

Modified: stable/11/sys/sys/rangelock.h
==
--- stable/11/sys/sys/rangelock.h   Fri Dec 13 03:29:54 2019
(r355689)
+++ stable/11/sys/sys/rangelock.h   Fri Dec 13 04:03:03 2019
(r355690)
@@ -76,6 +76,29 @@ void *rangelock_rlock(struct rangelock *lock, off_t st
 void   *rangelock_wlock(struct rangelock *lock, off_t start, off_t end,
struct mtx *ilk);
 voidrlqentry_free(struct rl_q_entry *rlqe);
+#if defined(INVARIANTS) || defined(INVARIANT_SUPPORT)
+void   _rangelock_cookie_assert(void *cookie, int what, const char *file,
+int line);
+#endif
+
+#ifdef INVARIANTS
+#definerangelock_cookie_assert_(cookie, what, file, line)  \
+   _rangelock_cookie_assert((cookie), (what), (file), (line))
+#else
+#definerangelock_cookie_assert_(cookie, what, file, line)  
(void)0
+#endif
+
+#definerangelock_cookie_assert(cookie, what)   \
+   rangelock_cookie_assert_((cookie), (what), __FILE__, __LINE__)
+
+/*
+ * Assertion flags.
+ */
+#if defined(INVARIANTS) || defined(INVARIANT_SUPPORT)
+#defineRCA_LOCKED  0x0001
+#defineRCA_RLOCKED 0x0002
+#defineRCA_WLOCKED 0x0004
+#endif
 
 #endif /* _KERNEL */
 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r355690 - in stable: 11/sys/kern 11/sys/sys 12/sys/kern 12/sys/sys

2019-12-12 Thread Kyle Evans
Author: kevans
Date: Fri Dec 13 04:03:03 2019
New Revision: 355690
URL: https://svnweb.freebsd.org/changeset/base/355690

Log:
  MFC r352350: rangelock: add rangelock_cookie_assert
  
  A future change to posixshm to add file sealing will move locking out of
  shm_dotruncate as kern_shm_open() will require the lock to be held across
  the dotruncate until the seal is actually applied. For this, the cookie is
  passed into shm_dotruncate_locked which asserts RCA_WLOCKED.

Modified:
  stable/12/sys/kern/kern_rangelock.c
  stable/12/sys/sys/rangelock.h
Directory Properties:
  stable/12/   (props changed)

Changes in other areas also in this revision:
Modified:
  stable/11/sys/kern/kern_rangelock.c
  stable/11/sys/sys/rangelock.h
Directory Properties:
  stable/11/   (props changed)

Modified: stable/12/sys/kern/kern_rangelock.c
==
--- stable/12/sys/kern/kern_rangelock.c Fri Dec 13 03:29:54 2019
(r355689)
+++ stable/12/sys/kern/kern_rangelock.c Fri Dec 13 04:03:03 2019
(r355690)
@@ -248,3 +248,35 @@ rangelock_wlock(struct rangelock *lock, off_t start, o
 
return (rangelock_enqueue(lock, start, end, RL_LOCK_WRITE, ilk));
 }
+
+#ifdef INVARIANT_SUPPORT
+void
+_rangelock_cookie_assert(void *cookie, int what, const char *file, int line)
+{
+   struct rl_q_entry *entry;
+   int flags;
+
+   MPASS(cookie != NULL);
+   entry = cookie;
+   flags = entry->rl_q_flags;
+   switch (what) {
+   case RCA_LOCKED:
+   if ((flags & RL_LOCK_GRANTED) == 0)
+   panic("rangelock not held @ %s:%d\n", file, line);
+   break;
+   case RCA_RLOCKED:
+   if ((flags & (RL_LOCK_GRANTED | RL_LOCK_READ)) !=
+   (RL_LOCK_GRANTED | RL_LOCK_READ))
+   panic("rangelock not rlocked @ %s:%d\n", file, line);
+   break;
+   case RCA_WLOCKED:
+   if ((flags & (RL_LOCK_GRANTED | RL_LOCK_WRITE)) !=
+   (RL_LOCK_GRANTED | RL_LOCK_WRITE))
+   panic("rangelock not wlocked @ %s:%d\n", file, line);
+   break;
+   default:
+   panic("Unknown rangelock assertion: %d @ %s:%d", what, file,
+   line);
+   }
+}
+#endif /* INVARIANT_SUPPORT */

Modified: stable/12/sys/sys/rangelock.h
==
--- stable/12/sys/sys/rangelock.h   Fri Dec 13 03:29:54 2019
(r355689)
+++ stable/12/sys/sys/rangelock.h   Fri Dec 13 04:03:03 2019
(r355690)
@@ -78,6 +78,29 @@ void *rangelock_rlock(struct rangelock *lock, off_t st
 void   *rangelock_wlock(struct rangelock *lock, off_t start, off_t end,
struct mtx *ilk);
 voidrlqentry_free(struct rl_q_entry *rlqe);
+#if defined(INVARIANTS) || defined(INVARIANT_SUPPORT)
+void   _rangelock_cookie_assert(void *cookie, int what, const char *file,
+int line);
+#endif
+
+#ifdef INVARIANTS
+#definerangelock_cookie_assert_(cookie, what, file, line)  \
+   _rangelock_cookie_assert((cookie), (what), (file), (line))
+#else
+#definerangelock_cookie_assert_(cookie, what, file, line)  
(void)0
+#endif
+
+#definerangelock_cookie_assert(cookie, what)   \
+   rangelock_cookie_assert_((cookie), (what), __FILE__, __LINE__)
+
+/*
+ * Assertion flags.
+ */
+#if defined(INVARIANTS) || defined(INVARIANT_SUPPORT)
+#defineRCA_LOCKED  0x0001
+#defineRCA_RLOCKED 0x0002
+#defineRCA_WLOCKED 0x0004
+#endif
 
 #endif /* _KERNEL */
 
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r355691 - head/usr.sbin/keyserv

2019-12-12 Thread Conrad Meyer
Author: cem
Date: Fri Dec 13 04:03:05 2019
New Revision: 355691
URL: https://svnweb.freebsd.org/changeset/base/355691

Log:
  keyserv(8): unifdef out __FreeBSD__ and KEYSERV_RANDOM
  
  This doesn't appear to have some active upstream (and it's a steaming pile of
  bad 90s crypto design).  Rip out the completely horrible bits and leave the
  only mildly less horrible bits.  The whole thing should probably be deleted; 
to
  the extent it purports to provide a security feature: it doesn't.

Modified:
  head/usr.sbin/keyserv/Makefile
  head/usr.sbin/keyserv/keyserv.c

Modified: head/usr.sbin/keyserv/Makefile
==
--- head/usr.sbin/keyserv/Makefile  Fri Dec 13 04:03:03 2019
(r355690)
+++ head/usr.sbin/keyserv/Makefile  Fri Dec 13 04:03:05 2019
(r355691)
@@ -4,7 +4,7 @@ PROG=   keyserv
 MAN=   keyserv.8
 SRCS=  keyserv.c setkey.c crypt_svc.c crypt_server.c crypt.h
 
-CFLAGS+= -DKEYSERV_RANDOM -DBROKEN_DES -I.
+CFLAGS+= -DBROKEN_DES -I.
 
 LIBADD=mp rpcsvc
 

Modified: head/usr.sbin/keyserv/keyserv.c
==
--- head/usr.sbin/keyserv/keyserv.c Fri Dec 13 04:03:03 2019
(r355690)
+++ head/usr.sbin/keyserv/keyserv.c Fri Dec 13 04:03:05 2019
(r355691)
@@ -224,38 +224,8 @@ static void
 randomize(master)
des_block *master;
 {
-#ifndef __FreeBSD__
-   int i;
-   int seed;
-   struct timeval tv;
-   int shift;
-
-   seed = 0;
-   for (i = 0; i < 1024; i++) {
-   (void)gettimeofday(, NULL);
-   shift = i % 8 * sizeof (int);
-   seed ^= (tv.tv_usec << shift) | (tv.tv_usec >> (32 - shift));
-   }
-#endif
-#ifdef KEYSERV_RANDOM
-#ifdef __FreeBSD__
master->key.low = arc4random();
master->key.high = arc4random();
-#else
-   srandom(seed);
-   master->key.low = random();
-   master->key.high = random();
-#endif
-#else
-   /* use stupid dangerous bad rand() */
-#ifdef __FreeBSD__
-   sranddev();
-#else
-   srand(seed);
-#endif
-   master->key.low = rand();
-   master->key.high = rand();
-#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: r355689 - in stable: 11/sys/kern 12/sys/kern

2019-12-12 Thread Kyle Evans
Author: kevans
Date: Fri Dec 13 03:29:54 2019
New Revision: 355689
URL: https://svnweb.freebsd.org/changeset/base/355689

Log:
  MFC r343777, r352244-r352245: kenv fix + assertions
  
  r343777:
  Fix zapping of static hints and env in init_static_kenv().  Environments
  are terminated by 2 NULs, but only 1 NUL was zapped.  Zapping only 1
  NUL just splits the first string into an empty string and a corrupted
  string.  All other strings in static hints and env remained live early
  in the boot when they were supposed to be disabled.
  
  Support calling init_static_kenv() very early in the boot, so as to
  use the env very early in the boot.  Then the pointer to the loader
  env may change after the first call due to enabling paging or otherwise
  remapping the pointer.  Another call is needed to register the change.
  Don't use the previous pointer in this (or any) later call.
  
  r352244:
  kenv: assert that an empty static buffer passed in is "empty"
  
  Garbage in the passed-in buffer can cause problems if any attempts to read
  the kenv are inadvertently made between init_static_kenv and the first
  kern_setenv -- assuming there is one.
  
  This is cheap and easy, so do it. This also helps rule out some class of
  bugs as one tries to debug; tunables fetch from the static environment up
  until SI_SUB_KMEM + 1, and many of these buffers are global ~4k buffers that
  rely on BSS clearing while others just grab a page of free memory and use it
  (e.g. xen).
  
  r352245:
  Follow up r352244: kenv: tighten up assertions
  
  As I like to forget: static kenv var formatting is actually such that an
  empty environment would be double null bytes. We should make sure that a
  non-zero buffer has at least enough for this, though most of the current
  usage is with a 4k buffer.

Modified:
  stable/11/sys/kern/kern_environment.c
Directory Properties:
  stable/11/   (props changed)

Changes in other areas also in this revision:
Modified:
  stable/12/sys/kern/kern_environment.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/11/sys/kern/kern_environment.c
==
--- stable/11/sys/kern/kern_environment.c   Fri Dec 13 02:20:26 2019
(r355688)
+++ stable/11/sys/kern/kern_environment.c   Fri Dec 13 03:29:54 2019
(r355689)
@@ -249,6 +249,33 @@ init_static_kenv(char *buf, size_t len)
 
KASSERT(!dynamic_kenv, ("kenv: dynamic_kenv already initialized"));
/*
+* Suitably sized means it must be able to hold at least one empty
+* variable, otherwise things go belly up if a kern_getenv call is
+* made without a prior call to kern_setenv as we have a malformed
+* environment.
+*/
+   KASSERT(len == 0 || len >= 2,
+   ("kenv: static env must be initialized or suitably sized"));
+   KASSERT(len == 0 || (*buf == '\0' && *(buf + 1) == '\0'),
+   ("kenv: sized buffer must be initially empty"));
+
+   /*
+* We may be called twice, with the second call needed to relocate
+* md_envp after enabling paging.  md_envp is then garbage if it is
+* not null and the relocation will move it.  Discard it so as to
+* not crash using its old value in our first call to kern_getenv().
+*
+* The second call gives the same environment as the first except
+* in silly configurations where the static env disables itself.
+*
+* Other env calls don't handle possibly-garbage pointers, so must
+* not be made between enabling paging and calling here.
+*/
+   md_envp = NULL;
+   md_env_len = 0;
+   md_env_pos = 0;
+
+   /*
 * Give the static environment a chance to disable the loader(8)
 * environment first.  This is done with loader_env.disabled=1.
 *
@@ -284,12 +311,16 @@ init_static_kenv(char *buf, size_t len)
md_env_pos = 0;
 
eval = kern_getenv("static_env.disabled");
-   if (eval != NULL && strcmp(eval, "1") == 0)
-   *static_env = '\0';
+   if (eval != NULL && strcmp(eval, "1") == 0) {
+   static_env[0] = '\0';
+   static_env[1] = '\0';
+   }
 
eval = kern_getenv("static_hints.disabled");
-   if (eval != NULL && strcmp(eval, "1") == 0)
-   *static_hints = '\0';
+   if (eval != NULL && strcmp(eval, "1") == 0) {
+   static_hints[0] = '\0';
+   static_hints[1] = '\0';
+   }
 
/*
 * Now we see if we need to tear the loader environment back down due
___
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: r355689 - in stable: 11/sys/kern 12/sys/kern

2019-12-12 Thread Kyle Evans
Author: kevans
Date: Fri Dec 13 03:29:54 2019
New Revision: 355689
URL: https://svnweb.freebsd.org/changeset/base/355689

Log:
  MFC r343777, r352244-r352245: kenv fix + assertions
  
  r343777:
  Fix zapping of static hints and env in init_static_kenv().  Environments
  are terminated by 2 NULs, but only 1 NUL was zapped.  Zapping only 1
  NUL just splits the first string into an empty string and a corrupted
  string.  All other strings in static hints and env remained live early
  in the boot when they were supposed to be disabled.
  
  Support calling init_static_kenv() very early in the boot, so as to
  use the env very early in the boot.  Then the pointer to the loader
  env may change after the first call due to enabling paging or otherwise
  remapping the pointer.  Another call is needed to register the change.
  Don't use the previous pointer in this (or any) later call.
  
  r352244:
  kenv: assert that an empty static buffer passed in is "empty"
  
  Garbage in the passed-in buffer can cause problems if any attempts to read
  the kenv are inadvertently made between init_static_kenv and the first
  kern_setenv -- assuming there is one.
  
  This is cheap and easy, so do it. This also helps rule out some class of
  bugs as one tries to debug; tunables fetch from the static environment up
  until SI_SUB_KMEM + 1, and many of these buffers are global ~4k buffers that
  rely on BSS clearing while others just grab a page of free memory and use it
  (e.g. xen).
  
  r352245:
  Follow up r352244: kenv: tighten up assertions
  
  As I like to forget: static kenv var formatting is actually such that an
  empty environment would be double null bytes. We should make sure that a
  non-zero buffer has at least enough for this, though most of the current
  usage is with a 4k buffer.

Modified:
  stable/12/sys/kern/kern_environment.c
Directory Properties:
  stable/12/   (props changed)

Changes in other areas also in this revision:
Modified:
  stable/11/sys/kern/kern_environment.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/12/sys/kern/kern_environment.c
==
--- stable/12/sys/kern/kern_environment.c   Fri Dec 13 02:20:26 2019
(r355688)
+++ stable/12/sys/kern/kern_environment.c   Fri Dec 13 03:29:54 2019
(r355689)
@@ -251,6 +251,33 @@ init_static_kenv(char *buf, size_t len)
 
KASSERT(!dynamic_kenv, ("kenv: dynamic_kenv already initialized"));
/*
+* Suitably sized means it must be able to hold at least one empty
+* variable, otherwise things go belly up if a kern_getenv call is
+* made without a prior call to kern_setenv as we have a malformed
+* environment.
+*/
+   KASSERT(len == 0 || len >= 2,
+   ("kenv: static env must be initialized or suitably sized"));
+   KASSERT(len == 0 || (*buf == '\0' && *(buf + 1) == '\0'),
+   ("kenv: sized buffer must be initially empty"));
+
+   /*
+* We may be called twice, with the second call needed to relocate
+* md_envp after enabling paging.  md_envp is then garbage if it is
+* not null and the relocation will move it.  Discard it so as to
+* not crash using its old value in our first call to kern_getenv().
+*
+* The second call gives the same environment as the first except
+* in silly configurations where the static env disables itself.
+*
+* Other env calls don't handle possibly-garbage pointers, so must
+* not be made between enabling paging and calling here.
+*/
+   md_envp = NULL;
+   md_env_len = 0;
+   md_env_pos = 0;
+
+   /*
 * Give the static environment a chance to disable the loader(8)
 * environment first.  This is done with loader_env.disabled=1.
 *
@@ -275,12 +302,16 @@ init_static_kenv(char *buf, size_t len)
md_env_pos = 0;
 
eval = kern_getenv("static_env.disabled");
-   if (eval != NULL && strcmp(eval, "1") == 0)
-   *kern_envp = '\0';
+   if (eval != NULL && strcmp(eval, "1") == 0) {
+   kern_envp[0] = '\0';
+   kern_envp[1] = '\0';
+   }
}
eval = kern_getenv("static_hints.disabled");
-   if (eval != NULL && strcmp(eval, "1") == 0)
-   *static_hints = '\0';
+   if (eval != NULL && strcmp(eval, "1") == 0) {
+   static_hints[0] = '\0';
+   static_hints[1] = '\0';
+   }
 }
 
 static 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: r355688 - head/sys/dev/iicbus

2019-12-12 Thread Ian Lepore
Author: ian
Date: Fri Dec 13 02:20:26 2019
New Revision: 355688
URL: https://svnweb.freebsd.org/changeset/base/355688

Log:
  If device_delete_children() returns an error, bail on the rest of the
  detach work and return the error.  Especially don't call iicbus_reset()
  since the most likely cause of failing to detach children is that one
  of them has IO in progress.

Modified:
  head/sys/dev/iicbus/iicbus.c

Modified: head/sys/dev/iicbus/iicbus.c
==
--- head/sys/dev/iicbus/iicbus.cFri Dec 13 02:18:44 2019
(r355687)
+++ head/sys/dev/iicbus/iicbus.cFri Dec 13 02:20:26 2019
(r355688)
@@ -134,10 +134,11 @@ static int
 iicbus_detach(device_t dev)
 {
struct iicbus_softc *sc = IICBUS_SOFTC(dev);
+   int err;
 
+   if ((err = device_delete_children(dev)) != 0)
+   return (err);
iicbus_reset(dev, IIC_FASTEST, 0, NULL);
-   bus_generic_detach(dev);
-   device_delete_children(dev);
mtx_destroy(>lock);
return (0);
 }
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


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

2019-12-12 Thread John Baldwin
Author: jhb
Date: Fri Dec 13 02:18:44 2019
New Revision: 355687
URL: https://svnweb.freebsd.org/changeset/base/355687

Log:
  Document that the debug server supports writing to guest memory.
  
  This was added in r348212.

Modified:
  head/usr.sbin/bhyve/bhyve.8

Modified: head/usr.sbin/bhyve/bhyve.8
==
--- head/usr.sbin/bhyve/bhyve.8 Fri Dec 13 02:15:34 2019(r355686)
+++ head/usr.sbin/bhyve/bhyve.8 Fri Dec 13 02:18:44 2019(r355687)
@@ -24,7 +24,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd June 24, 2019
+.Dd December 12, 2019
 .Dt BHYVE 8
 .Os
 .Sh NAME
@@ -521,8 +521,7 @@ Each virtual CPU is exposed to the debugger as a threa
 General purpose registers can be queried for each virtual CPU, but other
 registers such as floating-point and system registers cannot be queried.
 .Ss Memory
-Memory (including memory mapped I/O regions) can be read by the debugger,
-but not written.
+Memory (including memory mapped I/O regions) can be read and written by the 
debugger.
 Memory operations use virtual addresses that are resolved to physical addresses
 via the current virtual CPU's active address translation.
 .Ss Control
___
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: r355686 - head/usr.sbin/bhyve

2019-12-12 Thread John Baldwin
Author: jhb
Date: Fri Dec 13 02:15:34 2019
New Revision: 355686
URL: https://svnweb.freebsd.org/changeset/base/355686

Log:
  Fix a mismerge in r355683 and remove the local gdb_port from main.

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

Modified: head/usr.sbin/bhyve/bhyverun.c
==
--- head/usr.sbin/bhyve/bhyverun.c  Fri Dec 13 01:38:48 2019
(r355685)
+++ head/usr.sbin/bhyve/bhyverun.c  Fri Dec 13 02:15:34 2019
(r355686)
@@ -984,7 +984,7 @@ do_open(const char *vmname)
 int
 main(int argc, char *argv[])
 {
-   int c, error, dbg_port, gdb_port, err, bvmcons;
+   int c, error, dbg_port, err, bvmcons;
int max_vcpus, mptgen, memflags;
int rtc_localtime;
bool gdb_stop;
@@ -996,7 +996,6 @@ main(int argc, char *argv[])
bvmcons = 0;
progname = basename(argv[0]);
dbg_port = 0;
-   gdb_port = 0;
gdb_stop = false;
guest_ncpus = 1;
sockets = cores = threads = 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: r355685 - head/sys/dev/iicbus

2019-12-12 Thread Ian Lepore
Author: ian
Date: Fri Dec 13 01:38:48 2019
New Revision: 355685
URL: https://svnweb.freebsd.org/changeset/base/355685

Log:
  Clean up some of my copyrights; add SPDX tag and remove All rights reserved.

Modified:
  head/sys/dev/iicbus/ads111x.c
  head/sys/dev/iicbus/ds13rtc.c
  head/sys/dev/iicbus/iic_recover_bus.c
  head/sys/dev/iicbus/iic_recover_bus.h
  head/sys/dev/iicbus/isl12xx.c
  head/sys/dev/iicbus/nxprtc.c
  head/sys/dev/iicbus/rtc8583.c

Modified: head/sys/dev/iicbus/ads111x.c
==
--- head/sys/dev/iicbus/ads111x.c   Fri Dec 13 01:34:25 2019
(r355684)
+++ head/sys/dev/iicbus/ads111x.c   Fri Dec 13 01:38:48 2019
(r355685)
@@ -1,4 +1,6 @@
 /*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
  * Copyright (c) 2019 Ian Lepore.
  *
  * Redistribution and use in source and binary forms, with or without

Modified: head/sys/dev/iicbus/ds13rtc.c
==
--- head/sys/dev/iicbus/ds13rtc.c   Fri Dec 13 01:34:25 2019
(r355684)
+++ head/sys/dev/iicbus/ds13rtc.c   Fri Dec 13 01:38:48 2019
(r355685)
@@ -1,6 +1,7 @@
 /*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
  * Copyright (c) 2017 Ian Lepore 
- * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions

Modified: head/sys/dev/iicbus/iic_recover_bus.c
==
--- head/sys/dev/iicbus/iic_recover_bus.c   Fri Dec 13 01:34:25 2019
(r355684)
+++ head/sys/dev/iicbus/iic_recover_bus.c   Fri Dec 13 01:38:48 2019
(r355685)
@@ -1,6 +1,7 @@
 /*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
  * Copyright (c) 2017 Ian Lepore 
- * All rights reserved.
  *
  * Development sponsored by Microsemi, Inc.
  *

Modified: head/sys/dev/iicbus/iic_recover_bus.h
==
--- head/sys/dev/iicbus/iic_recover_bus.h   Fri Dec 13 01:34:25 2019
(r355684)
+++ head/sys/dev/iicbus/iic_recover_bus.h   Fri Dec 13 01:38:48 2019
(r355685)
@@ -1,6 +1,7 @@
 /*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
  * Copyright (c) 2017 Ian Lepore 
- * All rights reserved.
  *
  * Development sponsored by Microsemi, Inc.
  *

Modified: head/sys/dev/iicbus/isl12xx.c
==
--- head/sys/dev/iicbus/isl12xx.c   Fri Dec 13 01:34:25 2019
(r355684)
+++ head/sys/dev/iicbus/isl12xx.c   Fri Dec 13 01:38:48 2019
(r355685)
@@ -1,5 +1,7 @@
 /*-
- * Copyright (c) 2017 Ian Lepore.  All rights reserved.
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2017 Ian Lepore.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions

Modified: head/sys/dev/iicbus/nxprtc.c
==
--- head/sys/dev/iicbus/nxprtc.cFri Dec 13 01:34:25 2019
(r355684)
+++ head/sys/dev/iicbus/nxprtc.cFri Dec 13 01:38:48 2019
(r355685)
@@ -1,6 +1,7 @@
 /*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
  * Copyright (c) 2017 Ian Lepore 
- * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions

Modified: head/sys/dev/iicbus/rtc8583.c
==
--- head/sys/dev/iicbus/rtc8583.c   Fri Dec 13 01:34:25 2019
(r355684)
+++ head/sys/dev/iicbus/rtc8583.c   Fri Dec 13 01:38:48 2019
(r355685)
@@ -1,6 +1,8 @@
 /*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
  * Copyright (c) 2017 Hiroki Mori.  All rights reserved.
- * Copyright (c) 2017 Ian Lepore.  All rights reserved.
+ * Copyright (c) 2017 Ian Lepore.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
___
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: r355684 - in head/sys/fs: nfsclient nfsserver

2019-12-12 Thread Rick Macklem
Author: rmacklem
Date: Fri Dec 13 01:34:25 2019
New Revision: 355684
URL: https://svnweb.freebsd.org/changeset/base/355684

Log:
  Add some more initializations to quiet riscv build.
  
  The one case in nfs_copy_file_range() was a legitimate case, although
  it would probably never occur in practice.

Modified:
  head/sys/fs/nfsclient/nfs_clvnops.c
  head/sys/fs/nfsserver/nfs_nfsdport.c

Modified: head/sys/fs/nfsclient/nfs_clvnops.c
==
--- head/sys/fs/nfsclient/nfs_clvnops.c Fri Dec 13 01:17:20 2019
(r355683)
+++ head/sys/fs/nfsclient/nfs_clvnops.c Fri Dec 13 01:34:25 2019
(r355684)
@@ -3639,6 +3639,7 @@ nfs_copy_file_range(struct vop_copy_file_range_args *a
off_t inoff, outoff;
bool consecutive, must_commit, tryoutcred;
 
+   ret = ret2 = 0;
nmp = VFSTONFS(invp->v_mount);
mtx_lock(>nm_mtx);
/* NFSv4.2 Copy is not permitted for infile == outfile. */

Modified: head/sys/fs/nfsserver/nfs_nfsdport.c
==
--- head/sys/fs/nfsserver/nfs_nfsdport.cFri Dec 13 01:17:20 2019
(r355683)
+++ head/sys/fs/nfsserver/nfs_nfsdport.cFri Dec 13 01:34:25 2019
(r355684)
@@ -5155,7 +5155,7 @@ nfsrv_writedsrpc(fhandle_t *fhp, off_t off, int len, s
 NFSPROC_T *p, struct vnode *vp, struct nfsmount **nmpp, int mirrorcnt,
 struct mbuf **mpp, char *cp, int *failposp)
 {
-   struct nfsrvwritedsdorpc *drpc, *tdrpc;
+   struct nfsrvwritedsdorpc *drpc, *tdrpc = NULL;
struct nfsvattr na;
struct mbuf *m;
int error, i, offs, ret, timo;
@@ -5322,7 +5322,7 @@ nfsrv_allocatedsrpc(fhandle_t *fhp, off_t off, off_t l
 NFSPROC_T *p, struct vnode *vp, struct nfsmount **nmpp, int mirrorcnt,
 int *failposp)
 {
-   struct nfsrvallocatedsdorpc *drpc, *tdrpc;
+   struct nfsrvallocatedsdorpc *drpc, *tdrpc = NULL;
struct nfsvattr na;
int error, i, ret, timo;
 
@@ -5506,7 +5506,7 @@ nfsrv_setattrdsrpc(fhandle_t *fhp, struct ucred *cred,
 struct vnode *vp, struct nfsmount **nmpp, int mirrorcnt,
 struct nfsvattr *nap, int *failposp)
 {
-   struct nfsrvsetattrdsdorpc *drpc, *tdrpc;
+   struct nfsrvsetattrdsdorpc *drpc, *tdrpc = NULL;
struct nfsvattr na;
int error, i, ret, timo;
 
@@ -5655,7 +5655,7 @@ nfsrv_setacldsrpc(fhandle_t *fhp, struct ucred *cred, 
 struct vnode *vp, struct nfsmount **nmpp, int mirrorcnt, struct acl *aclp,
 int *failposp)
 {
-   struct nfsrvsetacldsdorpc *drpc, *tdrpc;
+   struct nfsrvsetacldsdorpc *drpc, *tdrpc = NULL;
int error, i, ret, timo;
 
NFSD_DEBUG(4, "in nfsrv_setacldsrpc\n");
___
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: r355683 - head/usr.sbin/bhyve

2019-12-12 Thread John Baldwin
Author: jhb
Date: Fri Dec 13 01:17:20 2019
New Revision: 355683
URL: https://svnweb.freebsd.org/changeset/base/355683

Log:
  Don't call into the debug server if it isn't configured.
  
  Reviewed by:  markj (as part of a larger diff)
  MFC after:1 month
  Differential Revision:https://reviews.freebsd.org/D20309

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

Modified: head/usr.sbin/bhyve/bhyverun.c
==
--- head/usr.sbin/bhyve/bhyverun.c  Fri Dec 13 00:45:14 2019
(r355682)
+++ head/usr.sbin/bhyve/bhyverun.c  Fri Dec 13 01:17:20 2019
(r355683)
@@ -167,6 +167,7 @@ uint16_t cores, maxcpus, sockets, threads;
 
 char *guest_uuid_str;
 
+static int gdb_port = 0;
 static int guest_vmexit_on_hlt, guest_vmexit_on_pause;
 static int virtio_msix = 1;
 static int x2apic_mode = 0;/* default is xAPIC */
@@ -416,7 +417,8 @@ fbsdrun_start_thread(void *param)
snprintf(tname, sizeof(tname), "vcpu %d", vcpu);
pthread_set_name_np(mtp->mt_thr, tname);
 
-   gdb_cpu_add(vcpu);
+   if (gdb_port != 0)
+   gdb_cpu_add(vcpu);
 
vm_loop(mtp->mt_ctx, vcpu, vmexit[vcpu].rip);
 
@@ -690,8 +692,11 @@ vmexit_mtrap(struct vmctx *ctx, struct vm_exit *vmexit
 
stats.vmexit_mtrap++;
 
+   if (gdb_port == 0) {
+   fprintf(stderr, "vm_loop: unexpected VMEXIT_MTRAP\n");
+   exit(4);
+   }
gdb_cpu_mtrap(*pvcpu);
-
return (VMEXIT_CONTINUE);
 }
 
@@ -770,6 +775,10 @@ static int
 vmexit_debug(struct vmctx *ctx, struct vm_exit *vmexit, int *pvcpu)
 {
 
+   if (gdb_port == 0) {
+   fprintf(stderr, "vm_loop: unexpected VMEXIT_DEBUG\n");
+   exit(4);
+   }
gdb_cpu_suspend(*pvcpu);
return (VMEXIT_CONTINUE);
 }
___
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: r355682 - head/sys/fs/nfsserver

2019-12-12 Thread Rick Macklem
Author: rmacklem
Date: Fri Dec 13 00:45:14 2019
New Revision: 355682
URL: https://svnweb.freebsd.org/changeset/base/355682

Log:
  Fix the build for MAC not defined and a couple of might not be initialized.
  
  r355677 broke the build for the not MAC defined case and a couple of
  might not be initialized warnings were generated for riscv. Others seem
  to be erroneous.
  
  Hopefully there won't be too many more build errors.
  
  Pointy hat goes on me.

Modified:
  head/sys/fs/nfsserver/nfs_nfsdport.c

Modified: head/sys/fs/nfsserver/nfs_nfsdport.c
==
--- head/sys/fs/nfsserver/nfs_nfsdport.cFri Dec 13 00:14:12 2019
(r355681)
+++ head/sys/fs/nfsserver/nfs_nfsdport.cFri Dec 13 00:45:14 2019
(r355682)
@@ -3980,7 +3980,7 @@ static void
 nfsrv_pnfscreate(struct vnode *vp, struct vattr *vap, struct ucred *cred,
 NFSPROC_T *p)
 {
-   struct nfsrvdscreate *dsc, *tdsc;
+   struct nfsrvdscreate *dsc, *tdsc = NULL;
struct nfsdevice *ds, *tds, *fds;
struct mount *mp;
struct pnfsdsfile *pf, *tpf;
@@ -5890,7 +5890,7 @@ nfsrv_pnfssetfh(struct vnode *vp, struct pnfsdsfile *p
 char *fnamep, struct vnode *nvp, NFSPROC_T *p)
 {
struct nfsnode *np;
-   int ret;
+   int ret = 0;
 
np = VTONFS(nvp);
NFSBCOPY(np->n_fhp->nfh_fh, >dsf_fh, NFSX_MYFH);
@@ -6210,12 +6210,13 @@ nfsvno_setxattr(struct vnode *vp, char *name, int len,
struct uio uio, *uiop = 
int cnt, error;
 
+   error = 0;
 #ifdef MAC
error = mac_vnode_check_setextattr(cred, vp, EXTATTR_NAMESPACE_USER,
name);
+#endif
if (error != 0)
goto out;
-#endif
 
uiop->uio_rw = UIO_WRITE;
uiop->uio_segflg = UIO_SYSSPACE;
@@ -6263,9 +6264,7 @@ nfsvno_rmxattr(struct nfsrv_descript *nd, struct vnode
if (error == EOPNOTSUPP)
error = VOP_SETEXTATTR(vp, EXTATTR_NAMESPACE_USER, name, NULL,
cred, p);
-#ifdef MAC
 out:
-#endif
NFSEXITCODE(error);
return (error);
 }
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r355681 - in head/sys: kern sys

2019-12-12 Thread Rick Macklem
Author: rmacklem
Date: Fri Dec 13 00:14:12 2019
New Revision: 355681
URL: https://svnweb.freebsd.org/changeset/base/355681

Log:
  r355677 requires that vop_stdioctl() be global so it can be called from NFS.
  
  r355677 modified the NFS client so that it does lseek(SEEK_DATA/SEEK_HOLE)
  for NFSv4.2, but calls vop_stdioctl() otherwise. As such, vop_stdioctl()
  needs to be a global function.
  
  Missed during the code merge for r355677.

Modified:
  head/sys/kern/vfs_default.c
  head/sys/sys/vnode.h

Modified: head/sys/kern/vfs_default.c
==
--- head/sys/kern/vfs_default.c Thu Dec 12 23:55:34 2019(r355680)
+++ head/sys/kern/vfs_default.c Fri Dec 13 00:14:12 2019(r355681)
@@ -87,7 +87,6 @@ static int vop_stdadd_writecount(struct vop_add_writec
 static int vop_stdcopy_file_range(struct vop_copy_file_range_args *ap);
 static int vop_stdfdatasync(struct vop_fdatasync_args *ap);
 static int vop_stdgetpages_async(struct vop_getpages_async_args *ap);
-static int vop_stdioctl(struct vop_ioctl_args *ap);
 
 /*
  * This vnode table stores what we want to do if the filesystem doesn't
@@ -1249,7 +1248,7 @@ vop_stdneed_inactive(struct vop_need_inactive_args *ap
return (1);
 }
 
-static int
+int
 vop_stdioctl(struct vop_ioctl_args *ap)
 {
struct vnode *vp;

Modified: head/sys/sys/vnode.h
==
--- head/sys/sys/vnode.hThu Dec 12 23:55:34 2019(r355680)
+++ head/sys/sys/vnode.hFri Dec 13 00:14:12 2019(r355681)
@@ -760,6 +760,7 @@ int vop_stdfsync(struct vop_fsync_args *);
 intvop_stdgetwritemount(struct vop_getwritemount_args *);
 intvop_stdgetpages(struct vop_getpages_args *);
 intvop_stdinactive(struct vop_inactive_args *);
+intvop_stdioctl(struct vop_ioctl_args *);
 intvop_stdneed_inactive(struct vop_need_inactive_args *);
 intvop_stdkqfilter(struct vop_kqfilter_args *);
 intvop_stdlock(struct vop_lock1_args *);
___
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: r355680 - head/sys/vm

2019-12-12 Thread Mark Johnston
Author: markj
Date: Thu Dec 12 23:55:34 2019
New Revision: 355680
URL: https://svnweb.freebsd.org/changeset/base/355680

Log:
  Avoid relying on silent type casting in the native atomic_load_32.
  
  Reported by:  np

Modified:
  head/sys/vm/vm_page.h

Modified: head/sys/vm/vm_page.h
==
--- head/sys/vm/vm_page.h   Thu Dec 12 23:37:04 2019(r355679)
+++ head/sys/vm/vm_page.h   Thu Dec 12 23:55:34 2019(r355680)
@@ -766,7 +766,7 @@ vm_page_astate_load(vm_page_t m)
 {
vm_page_astate_t a;
 
-   a._bits = atomic_load_32(>a);
+   a._bits = atomic_load_32(>a._bits);
return (a);
 }
 
___
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: r355609 - head

2019-12-12 Thread Bryan Drewery
On 12/11/2019 6:54 AM, Ed Maste wrote:
> Author: emaste
> Date: Wed Dec 11 14:54:29 2019
> New Revision: 355609
> URL: https://svnweb.freebsd.org/changeset/base/355609
> 
> Log:
>   Make NOCLEAN an error instead of a warning
>   
>   The warning was added in r289728 (over four years ago) and at that time
>   NO_CLEAN was already the correct spelling for over a decade.
>   
>   Make NOCLEAN an error as the next step to removing these backward
>   compatibility shims.
> 
> Modified:
>   head/Makefile.inc1
> 
> Modified: head/Makefile.inc1
> ==
> --- head/Makefile.inc1Wed Dec 11 14:28:13 2019(r355608)
> +++ head/Makefile.inc1Wed Dec 11 14:54:29 2019(r355609)
> @@ -458,8 +458,7 @@ SUBDIR+=etc
>  .endif   # !empty(SUBDIR_OVERRIDE)
>  
>  .if defined(NOCLEAN)
> -.warning NOCLEAN option is deprecated. Use NO_CLEAN instead.
> -NO_CLEAN=${NOCLEAN}
> +.error NOCLEAN option is deprecated. Use NO_CLEAN instead.
>  .endif
>  .if defined(NO_CLEANDIR)
>  CLEANDIR=clean cleandepend
> 

What ever happened to POLA?

Name 1 good reason this should be an .error?! Or even a .warning for
that matter.

The argument I keep hearing is "we have to maintain these 3 lines of
code", ok, well now it's just an annoyance to maintain with no benefit
to the user.

-- 
Regards,
Bryan Drewery



signature.asc
Description: OpenPGP digital signature


svn commit: r355679 - head/sys/sys

2019-12-12 Thread Rick Macklem
Author: rmacklem
Date: Thu Dec 12 23:37:04 2019
New Revision: 355679
URL: https://svnweb.freebsd.org/changeset/base/355679

Log:
  Bump __FreeBSD_version since r355677 changes the internal interface
  between the NFS modules such that they all need to be upgraded to
  post r355677 simultaneously.

Modified:
  head/sys/sys/param.h

Modified: head/sys/sys/param.h
==
--- head/sys/sys/param.hThu Dec 12 23:33:32 2019(r355678)
+++ head/sys/sys/param.hThu Dec 12 23:37:04 2019(r355679)
@@ -60,7 +60,7 @@
  * in the range 5 to 9.
  */
 #undef __FreeBSD_version
-#define __FreeBSD_version 1300065  /* Master, propagated to newvers */
+#define __FreeBSD_version 1300066  /* Master, propagated to newvers */
 
 /*
  * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD,
___
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: r355678 - head

2019-12-12 Thread Rick Macklem
Author: rmacklem
Date: Thu Dec 12 23:33:32 2019
New Revision: 355678
URL: https://svnweb.freebsd.org/changeset/base/355678

Log:
  Add an entry to UPDATING for r355677.

Modified:
  head/UPDATING

Modified: head/UPDATING
==
--- head/UPDATING   Thu Dec 12 23:22:55 2019(r355677)
+++ head/UPDATING   Thu Dec 12 23:33:32 2019(r355678)
@@ -26,6 +26,11 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 13.x IS SLOW:
disable the most expensive debugging functionality run
"ln -s 'abort:false,junk:false' /etc/malloc.conf".)
 
+20191212:
+   r355677 has modified the internal interface used between the
+   NFS modules in the kernel. As such, they must all be upgraded
+   simultaneously. I will do a version bump for this.
+
 20191205:
The root certificates of the Mozilla CA Certificate Store have been
imported into the base system and can be managed with the certctl(8)
___
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: r355677 - in head/sys/fs: nfs nfsclient nfsserver

2019-12-12 Thread Rick Macklem
Author: rmacklem
Date: Thu Dec 12 23:22:55 2019
New Revision: 355677
URL: https://svnweb.freebsd.org/changeset/base/355677

Log:
  Add support for NFSv4.2 to the NFS client and server.
  
  This patch adds support for NFSv4.2 (RFC-7862) and Extended Attributes
  (RFC-8276) to the NFS client and server.
  NFSv4.2 is comprised of several optional features that can be supported
  in addition to NFSv4.1. This patch adds the following optional features:
 - posix_fadvise(POSIX_FADV_WILLNEED/POSIX_FADV_DONTNEED)
 - posix_fallocate()
 - intra server file range copying via the copy_file_range(2) syscall
   --> Avoiding data tranfer over the wire to/from the NFS client.
 - lseek(SEEK_DATA/SEEK_HOLE)
 - Extended attribute syscalls for "user" namespace attributes as defined
   by RFC-8276.
  
  Although this patch is fairly large, it should not affect support for
  the other versions of NFS. However it does add two new sysctls that allow
  a sysadmin to limit which minor versions of NFSv4 a server supports, allowing
  a sysadmin to disable NFSv4.2.
  
  Unfortunately, when the NFS stats structure was last revised, it was assumed
  that there would be no additional operations added beyond what was
  specified in RFC-7862. However RFC-8276 did add additional operations,
  forcing the NFS stats structure to revised again. It now has extra unused
  entries in all arrays, so that future extensions to NFSv4.2 can be
  accomodated without revising this structure again.
  
  A future commit will update nfsstat(1) to report counts for the new NFSv4.2
  specific operations/procedures.
  
  This patch affects the internal interface between the nfscommon, nfscl and
  nfsd modules and, as such, they all must be upgraded simultaneously.
  I will do a version bump (although arguably not needed), due to this.
  
  This code has survived a "make universe" but has not been built with a
  recent GCC. If you encounter build problems, please email me.
  
  Relnotes: yes

Modified:
  head/sys/fs/nfs/nfs.h
  head/sys/fs/nfs/nfs_commonport.c
  head/sys/fs/nfs/nfs_commonsubs.c
  head/sys/fs/nfs/nfs_var.h
  head/sys/fs/nfs/nfsclstate.h
  head/sys/fs/nfs/nfsport.h
  head/sys/fs/nfs/nfsproto.h
  head/sys/fs/nfsclient/nfs_clrpcops.c
  head/sys/fs/nfsclient/nfs_clstate.c
  head/sys/fs/nfsclient/nfs_clvfsops.c
  head/sys/fs/nfsclient/nfs_clvnops.c
  head/sys/fs/nfsclient/nfsmount.h
  head/sys/fs/nfsserver/nfs_nfsdkrpc.c
  head/sys/fs/nfsserver/nfs_nfsdport.c
  head/sys/fs/nfsserver/nfs_nfsdserv.c
  head/sys/fs/nfsserver/nfs_nfsdsocket.c
  head/sys/fs/nfsserver/nfs_nfsdstate.c
  head/sys/fs/nfsserver/nfs_nfsdsubs.c

Modified: head/sys/fs/nfs/nfs.h
==
--- head/sys/fs/nfs/nfs.h   Thu Dec 12 22:59:22 2019(r355676)
+++ head/sys/fs/nfs/nfs.h   Thu Dec 12 23:22:55 2019(r355677)
@@ -668,6 +668,8 @@ struct nfsrv_descript {
uint32_t*nd_sequence;   /* Sequence Op. ptr */
nfsv4stateid_t  nd_curstateid;  /* Current StateID */
nfsv4stateid_t  nd_savedcurstateid; /* Saved Current StateID */
+   uint32_tnd_maxreq;  /* Max. request (session). */
+   uint32_tnd_maxresp; /* Max. reply (session). */
 };
 
 #definend_princlen nd_gssnamelen

Modified: head/sys/fs/nfs/nfs_commonport.c
==
--- head/sys/fs/nfs/nfs_commonport.cThu Dec 12 22:59:22 2019
(r355676)
+++ head/sys/fs/nfs/nfs_commonport.cThu Dec 12 23:22:55 2019
(r355677)
@@ -80,6 +80,7 @@ int nfs_pnfsio(task_fn_t *, void *);
 static int nfs_realign_test;
 static int nfs_realign_count;
 static struct ext_nfsstats oldnfsstats;
+static struct nfsstatsov1 nfsstatsov1;
 
 SYSCTL_NODE(_vfs, OID_AUTO, nfs, CTLFLAG_RW, 0, "NFS filesystem");
 SYSCTL_INT(_vfs_nfs, OID_AUTO, realign_test, CTLFLAG_RW, _realign_test,
@@ -580,11 +581,143 @@ nfssvc_call(struct thread *p, struct nfssvc_args *uap,
} else {
error = copyin(uap->argp, ,
sizeof(nfsstatver));
-   if (error == 0 && nfsstatver.vers != NFSSTATS_V1)
-   error = EPERM;
-   if (error == 0)
-   error = copyout(, uap->argp,
-   sizeof (nfsstatsv1));
+   if (error == 0) {
+   if (nfsstatver.vers == NFSSTATS_OV1) {
+   /* Copy nfsstatsv1 to nfsstatsov1. */
+   nfsstatsov1.attrcache_hits =
+   nfsstatsv1.attrcache_hits;
+   nfsstatsov1.attrcache_misses =
+   nfsstatsv1.attrcache_misses;
+

svn commit: r355676 - head/libexec/rtld-elf

2019-12-12 Thread Konstantin Belousov
Author: kib
Date: Thu Dec 12 22:59:22 2019
New Revision: 355676
URL: https://svnweb.freebsd.org/changeset/base/355676

Log:
  rtld: make checks for mmap(2) failures compliant with documentation.
  
  On error, mmap(2) returns MAP_FAILED.  There is no need to use its
  definition or to cast.
  
  Sponsored by: The FreeBSD Foundation
  MFC after:1 week

Modified:
  head/libexec/rtld-elf/map_object.c

Modified: head/libexec/rtld-elf/map_object.c
==
--- head/libexec/rtld-elf/map_object.c  Thu Dec 12 22:36:47 2019
(r355675)
+++ head/libexec/rtld-elf/map_object.c  Thu Dec 12 22:59:22 2019
(r355676)
@@ -209,7 +209,7 @@ map_object(int fd, const char *path, const struct stat
base_flags |= MAP_FIXED | MAP_EXCL;
 
 mapbase = mmap(base_addr, mapsize, PROT_NONE, base_flags, -1, 0);
-if (mapbase == (caddr_t) -1) {
+if (mapbase == MAP_FAILED) {
_rtld_error("%s: mmap of entire address space failed: %s",
  path, rtld_strerror(errno));
goto error;
@@ -266,7 +266,7 @@ map_object(int fd, const char *path, const struct stat
bss_addr = mapbase +  (bss_vaddr - base_vaddr);
if (bss_vlimit > bss_vaddr) {   /* There is something to do */
if (mmap(bss_addr, bss_vlimit - bss_vaddr, data_prot,
-   data_flags | MAP_ANON, -1, 0) == (caddr_t)-1) {
+   data_flags | MAP_ANON, -1, 0) == MAP_FAILED) {
_rtld_error("%s: mmap of bss failed: %s", path,
rtld_strerror(errno));
goto error1;
@@ -348,7 +348,7 @@ get_elf_header(int fd, const char *path, const struct 
 
hdr = mmap(NULL, PAGE_SIZE, PROT_READ, MAP_PRIVATE | MAP_PREFAULT_READ,
fd, 0);
-   if (hdr == (Elf_Ehdr *)MAP_FAILED) {
+   if (hdr == MAP_FAILED) {
_rtld_error("%s: read error: %s", path, rtld_strerror(errno));
return (NULL);
}
___
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r355674 - in stable/12/sys/fs: nfs nfsserver

2019-12-12 Thread Rick Macklem
Author: rmacklem
Date: Thu Dec 12 22:00:10 2019
New Revision: 355674
URL: https://svnweb.freebsd.org/changeset/base/355674

Log:
  MFC: r354989
  Fix the pNFS server's reporting of SpaceUsed (va_bytes).
  
  The pNFS server currently reports SpaceUsed (va_bytes) for the metadata
  file. This in not correct, since the metadata file is always empty and,
  as such, va_bytes is just the allocation for the empty file.
  This patch adds va_bytes to the list of attributes acquired from the
  DS for a file, so that it includes the allocated data size and is updated
  when the file is written.
  For files created on a pNFS server before this patch is applied, the
  va_bytes value is estimated by rounding va_size up to a multiple of
  BLKDEV_IOSIZE. Once the file is written after this patch has been
  applied to the metadata server, the va_bytes returned for the file
  will be correct.
  
  This patch only affects a pNFS metadata server.
  
  Found during testing of the NFSv4.2 pNFS server for the Allocate operation.
  (Not yet in head/current.)

Modified:
  stable/12/sys/fs/nfs/nfsrvstate.h
  stable/12/sys/fs/nfsserver/nfs_nfsdport.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/fs/nfs/nfsrvstate.h
==
--- stable/12/sys/fs/nfs/nfsrvstate.h   Thu Dec 12 21:33:00 2019
(r355673)
+++ stable/12/sys/fs/nfs/nfsrvstate.h   Thu Dec 12 22:00:10 2019
(r355674)
@@ -355,14 +355,24 @@ struct nfsdevice {
 };
 
 /*
- * This structure holds the va_size, va_filerev, va_atime and va_mtime for the
- * DS file and is stored in the metadata file's extended attribute 
pnfsd.dsattr.
+ * This structure holds the va_size, va_filerev, va_atime, va_mtime and
+ * va_bytes for the DS file and is stored in the metadata file's extended
+ * attribute pnfsd.dsattr.
+ * opnfsdsattr was missing the va_bytes field and, as such, it was updated.
  */
+struct opnfsdsattr {
+   uint64_tdsa_filerev;
+   uint64_tdsa_size;
+   struct timespec dsa_atime;
+   struct timespec dsa_mtime;
+};
+
 struct pnfsdsattr {
uint64_tdsa_filerev;
uint64_tdsa_size;
struct timespec dsa_atime;
struct timespec dsa_mtime;
+   uint64_tdsa_bytes;
 };
 
 /*

Modified: stable/12/sys/fs/nfsserver/nfs_nfsdport.c
==
--- stable/12/sys/fs/nfsserver/nfs_nfsdport.c   Thu Dec 12 21:33:00 2019
(r355673)
+++ stable/12/sys/fs/nfsserver/nfs_nfsdport.c   Thu Dec 12 22:00:10 2019
(r355674)
@@ -277,7 +277,8 @@ nfsvno_getattr(struct vnode *vp, struct nfsvattr *nvap
}
 
/*
-* Acquire the Change, Size and TimeModify attributes, as required.
+* Acquire the Change, Size, TimeAccess, TimeModify and SpaceUsed
+* attributes, as required.
 * This needs to be done for regular files if:
 * - non-NFSv4 RPCs or
 * - when attrbitp == NULL or
@@ -292,7 +293,8 @@ nfsvno_getattr(struct vnode *vp, struct nfsvattr *nvap
NFSISSET_ATTRBIT(attrbitp, NFSATTRBIT_CHANGE) ||
NFSISSET_ATTRBIT(attrbitp, NFSATTRBIT_SIZE) ||
NFSISSET_ATTRBIT(attrbitp, NFSATTRBIT_TIMEACCESS) ||
-   NFSISSET_ATTRBIT(attrbitp, NFSATTRBIT_TIMEMODIFY))) {
+   NFSISSET_ATTRBIT(attrbitp, NFSATTRBIT_TIMEMODIFY) ||
+   NFSISSET_ATTRBIT(attrbitp, NFSATTRBIT_SPACEUSED))) {
error = nfsrv_proxyds(nd, vp, 0, 0, nd->nd_cred, p,
NFSPROC_GETATTR, NULL, NULL, NULL, , NULL);
if (error == 0)
@@ -312,6 +314,7 @@ nfsvno_getattr(struct vnode *vp, struct nfsvattr *nvap
nvap->na_mtime = na.na_mtime;
nvap->na_filerev = na.na_filerev;
nvap->na_size = na.na_size;
+   nvap->na_bytes = na.na_bytes;
}
NFSD_DEBUG(4, "nfsvno_getattr: gotattr=%d err=%d chg=%ju\n", gotattr,
error, (uintmax_t)na.na_filerev);
@@ -3880,6 +3883,7 @@ nfsrv_dscreate(struct vnode *dvp, struct vattr *vap, s
dsa->dsa_size = va.va_size;
dsa->dsa_atime = va.va_atime;
dsa->dsa_mtime = va.va_mtime;
+   dsa->dsa_bytes = va.va_bytes;
}
}
if (error == 0) {
@@ -4404,6 +4408,7 @@ nfsrv_proxyds(struct nfsrv_descript *nd, struct vnode 
struct vnode *dvp[NFSDEV_MAXMIRRORS];
struct nfsdevice *ds;
struct pnfsdsattr dsattr;
+   struct opnfsdsattr odsattr;
char *buf;
int buflen, error, failpos, i, mirrorcnt, origmircnt, trycnt;
 
@@ -4428,15 +4433,31 @@ nfsrv_proxyds(struct nfsrv_descript *nd, struct vnode 
error = vn_extattr_get(vp, IO_NODELOCKED,

svn commit: r355673 - head/sys/dev/cxgbe

2019-12-12 Thread Navdeep Parhar
Author: np
Date: Thu Dec 12 21:33:00 2019
New Revision: 355673
URL: https://svnweb.freebsd.org/changeset/base/355673

Log:
  cxgbe(4): Never use hardware checksumming in netmap tx.
  
  MFC after:1 week
  Sponsored by: Chelsio Communications

Modified:
  head/sys/dev/cxgbe/t4_netmap.c

Modified: head/sys/dev/cxgbe/t4_netmap.c
==
--- head/sys/dev/cxgbe/t4_netmap.c  Thu Dec 12 21:13:20 2019
(r355672)
+++ head/sys/dev/cxgbe/t4_netmap.c  Thu Dec 12 21:33:00 2019
(r355673)
@@ -659,7 +659,7 @@ ring_nm_txq_db(struct adapter *sc, struct sge_nm_txq *
  */
 static void
 cxgbe_nm_tx(struct adapter *sc, struct sge_nm_txq *nm_txq,
-struct netmap_kring *kring, int npkt, int npkt_remaining, int txcsum)
+struct netmap_kring *kring, int npkt, int npkt_remaining)
 {
struct netmap_ring *ring = kring->ring;
struct netmap_slot *slot;
@@ -695,13 +695,9 @@ cxgbe_nm_tx(struct adapter *sc, struct sge_nm_txq *nm_
 * netmap(4) says "netmap does not use features such as
 * checksum offloading, TCP segmentation offloading,
 * encryption, VLAN encapsulation/decapsulation, etc."
-*
-* So the ncxl interfaces have tx hardware checksumming
-* disabled by default.  But you can override netmap by
-* enabling IFCAP_TXCSUM on the interface manully.
 */
-   cpl->ctrl1 = txcsum ? 0 :
-   htobe64(F_TXPKT_IPCSUM_DIS | F_TXPKT_L4CSUM_DIS);
+   cpl->ctrl1 = htobe64(F_TXPKT_IPCSUM_DIS |
+   F_TXPKT_L4CSUM_DIS);
 
usgl = (void *)(cpl + 1);
usgl->cmd_nsge = htobe32(V_ULPTX_CMD(ULP_TX_SC_DSGL) |
@@ -815,7 +811,7 @@ cxgbe_netmap_txsync(struct netmap_kring *kring, int fl
struct sge_nm_txq *nm_txq = >sge.nm_txq[vi->first_nm_txq + 
kring->ring_id];
const u_int head = kring->rhead;
u_int reclaimed = 0;
-   int n, d, npkt_remaining, ndesc_remaining, txcsum;
+   int n, d, npkt_remaining, ndesc_remaining;
 
/*
 * Tx was at kring->nr_hwcur last time around and now we need to advance
@@ -826,7 +822,6 @@ cxgbe_netmap_txsync(struct netmap_kring *kring, int fl
 
npkt_remaining = head >= kring->nr_hwcur ? head - kring->nr_hwcur :
kring->nkr_num_slots - kring->nr_hwcur + head;
-   txcsum = ifp->if_capenable & (IFCAP_TXCSUM | IFCAP_TXCSUM_IPV6);
while (npkt_remaining) {
reclaimed += reclaim_nm_tx_desc(nm_txq);
ndesc_remaining = contiguous_ndesc_available(nm_txq);
@@ -850,7 +845,7 @@ cxgbe_netmap_txsync(struct netmap_kring *kring, int fl
 
/* Send n packets and update nm_txq->pidx and kring->nr_hwcur */
npkt_remaining -= n;
-   cxgbe_nm_tx(sc, nm_txq, kring, n, npkt_remaining, txcsum);
+   cxgbe_nm_tx(sc, nm_txq, kring, n, npkt_remaining);
}
MPASS(npkt_remaining == 0);
MPASS(kring->nr_hwcur == head);
___
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: r355672 - head/sys/vm

2019-12-12 Thread Mark Johnston
Author: markj
Date: Thu Dec 12 21:13:20 2019
New Revision: 355672
URL: https://svnweb.freebsd.org/changeset/base/355672

Log:
  Implement atomic state updates using the new vm_page_astate_t structure.
  
  Introduce primitives vm_page_astate_load() and vm_page_astate_fcmpset()
  to operate on the 32-bit per-page atomic state.  Modify
  vm_page_pqstate_fcmpset() to use them.  No functional change intended.
  
  Introduce PGA_QUEUE_OP_MASK, a subset of PGA_QUEUE_STATE_MASK that only
  includes queue operation flags.  This will be used in subsequent
  patches.
  
  Reviewed by:  alc, jeff, kib
  Sponsored by: Netflix, Intel
  Differential Revision:https://reviews.freebsd.org/D22753

Modified:
  head/sys/vm/vm_page.h

Modified: head/sys/vm/vm_page.h
==
--- head/sys/vm/vm_page.h   Thu Dec 12 20:55:43 2019(r355671)
+++ head/sys/vm/vm_page.h   Thu Dec 12 21:13:20 2019(r355672)
@@ -439,8 +439,8 @@ extern struct mtx_padalign pa_lock[];
 #definePGA_REQUEUE_HEAD 0x0040 /* page requeue should bypass 
LRU */
 #definePGA_NOSYNC  0x0080  /* do not collect for syncer */
 
-#definePGA_QUEUE_STATE_MASK(PGA_ENQUEUED | PGA_DEQUEUE | 
PGA_REQUEUE | \
-   PGA_REQUEUE_HEAD)
+#definePGA_QUEUE_OP_MASK   (PGA_DEQUEUE | PGA_REQUEUE | 
PGA_REQUEUE_HEAD)
+#definePGA_QUEUE_STATE_MASK(PGA_ENQUEUED | PGA_QUEUE_OP_MASK)
 
 /*
  * Page flags.  If changed at any other time than page allocation or
@@ -756,36 +756,37 @@ void vm_page_assert_pga_writeable(vm_page_t m, uint16_
 #defineVM_PAGE_ASSERT_PGA_WRITEABLE(m, bits)   (void)0
 #endif
 
+#defineVM_PAGE_AFLAG_SHIFT (__offsetof(vm_page_astate_t, flags) * 
NBBY)
+
 /*
- * We want to use atomic updates for the aflags field, which is 8 bits wide.
- * However, not all architectures support atomic operations on 8-bit
- * destinations.  In order that we can easily use a 32-bit operation, we
- * require that the aflags field be 32-bit aligned.
+ * Load a snapshot of a page's 32-bit atomic state.
  */
-_Static_assert(offsetof(struct vm_page, a.flags) % sizeof(uint32_t) == 0,
-"aflags field is not 32-bit aligned");
+static inline vm_page_astate_t
+vm_page_astate_load(vm_page_t m)
+{
+   vm_page_astate_t a;
 
+   a._bits = atomic_load_32(>a);
+   return (a);
+}
+
 /*
- * We want to be able to update the aflags and queue fields atomically in
- * the same operation.
+ * Atomically compare and set a page's atomic state.
  */
-_Static_assert(offsetof(struct vm_page, a.flags) / sizeof(uint32_t) ==
-offsetof(struct vm_page, a.queue) / sizeof(uint32_t),
-"aflags and queue fields do not belong to the same 32-bit word");
-_Static_assert(offsetof(struct vm_page, a.queue) % sizeof(uint32_t) == 2,
-"queue field is at an unexpected offset");
-_Static_assert(sizeof(((struct vm_page *)NULL)->a.queue) == 1,
-"queue field has an unexpected size");
+static inline bool
+vm_page_astate_fcmpset(vm_page_t m, vm_page_astate_t *old, vm_page_astate_t 
new)
+{
 
-#if BYTE_ORDER == LITTLE_ENDIAN
-#defineVM_PAGE_AFLAG_SHIFT 0
-#defineVM_PAGE_QUEUE_SHIFT 16
-#else
-#defineVM_PAGE_AFLAG_SHIFT 16
-#defineVM_PAGE_QUEUE_SHIFT 8
-#endif
-#defineVM_PAGE_QUEUE_MASK  (0xff << VM_PAGE_QUEUE_SHIFT)
+   KASSERT(new.queue == PQ_INACTIVE || (new.flags & PGA_REQUEUE_HEAD) == 0,
+   ("%s: invalid head requeue request for page %p", __func__, m));
+   KASSERT((new.flags & PGA_ENQUEUED) == 0 || new.queue != PQ_NONE,
+   ("%s: setting PGA_ENQUEUED with PQ_NONE in page %p", __func__, m));
+   KASSERT(new._bits != old->_bits,
+   ("%s: bits are unchanged", __func__));
 
+   return (atomic_fcmpset_32(>a._bits, >_bits, new._bits) != 0);
+}
+
 /*
  * Clear the given bits in the specified page.
  */
@@ -805,7 +806,7 @@ vm_page_aflag_clear(vm_page_t m, uint16_t bits)
 * atomic update.  Parallel non-atomic updates to the other fields
 * within this word are handled properly by the atomic update.
 */
-   addr = (void *)>a.flags;
+   addr = (void *)>a;
val = bits << VM_PAGE_AFLAG_SHIFT;
atomic_clear_32(addr, val);
 }
@@ -825,7 +826,7 @@ vm_page_aflag_set(vm_page_t m, uint16_t bits)
 * atomic update.  Parallel non-atomic updates to the other fields
 * within this word are handled properly by the atomic update.
 */
-   addr = (void *)>a.flags;
+   addr = (void *)>a;
val = bits << VM_PAGE_AFLAG_SHIFT;
atomic_set_32(addr, val);
 }
@@ -841,24 +842,16 @@ static inline bool
 vm_page_pqstate_cmpset(vm_page_t m, uint32_t oldq, uint32_t newq,
 uint32_t fflags, uint32_t nflags)
 {
-   uint32_t *addr, nval, oval, qsmask;
+   vm_page_astate_t new, old;
 
-   fflags <<= VM_PAGE_AFLAG_SHIFT;
-  

svn commit: r355671 - head/lib/libpmc/pmu-events

2019-12-12 Thread Ed Maste
Author: emaste
Date: Thu Dec 12 20:55:43 2019
New Revision: 355671
URL: https://svnweb.freebsd.org/changeset/base/355671

Log:
  libpmc: add MIT SPDX tag to header file
  
  The jevents tool includes a copy of the jsmn json parser which is MIT
  licensed.  Upstream the MIT license appears in the jsmn.c source and a
  standalone LICENSE file, but the latter is not included in the copy
  contained in libpmc and the jsmn.h header carried no license information.
  Add an SPDX tag to clarify the situation.

Modified:
  head/lib/libpmc/pmu-events/jsmn.h

Modified: head/lib/libpmc/pmu-events/jsmn.h
==
--- head/lib/libpmc/pmu-events/jsmn.h   Thu Dec 12 20:44:49 2019
(r355670)
+++ head/lib/libpmc/pmu-events/jsmn.h   Thu Dec 12 20:55:43 2019
(r355671)
@@ -1,3 +1,4 @@
+/* SPDX-License-Identifier: MIT */
 /* $FreeBSD$ */
 #ifndef __JSMN_H_
 #define __JSMN_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: r355670 - head/sys/contrib/ipfilter/netinet

2019-12-12 Thread Cy Schubert
Author: cy
Date: Thu Dec 12 20:44:49 2019
New Revision: 355670
URL: https://svnweb.freebsd.org/changeset/base/355670

Log:
  Rather than pass the address of the packet information control block to
  ipf_pcksum6(), directly pass the adddress of the mbuf to it. This reduces
  one pointer dereference. ipf_pcksum6() doesn't use the packet information
  control block except to obtain the mbuf address.
  
  MFC after:3 days

Modified:
  head/sys/contrib/ipfilter/netinet/fil.c
  head/sys/contrib/ipfilter/netinet/ip_fil.h
  head/sys/contrib/ipfilter/netinet/ip_fil_freebsd.c

Modified: head/sys/contrib/ipfilter/netinet/fil.c
==
--- head/sys/contrib/ipfilter/netinet/fil.c Thu Dec 12 20:44:46 2019
(r355669)
+++ head/sys/contrib/ipfilter/netinet/fil.c Thu Dec 12 20:44:49 2019
(r355670)
@@ -3436,7 +3436,7 @@ fr_cksum(fin, ip, l4proto, l4hdr)
ip6 = (ip6_t *)ip;
off = ((caddr_t)ip6 - m->m_data) + sizeof(struct ip6_hdr);
int len = ntohs(ip6->ip6_plen) - (off - sizeof(*ip6));
-   return(ipf_pcksum6(fin, ip6, off, len));
+   return(ipf_pcksum6(m, ip6, off, len));
} else {
return 0x;
}

Modified: head/sys/contrib/ipfilter/netinet/ip_fil.h
==
--- head/sys/contrib/ipfilter/netinet/ip_fil.h  Thu Dec 12 20:44:46 2019
(r355669)
+++ head/sys/contrib/ipfilter/netinet/ip_fil.h  Thu Dec 12 20:44:49 2019
(r355670)
@@ -1840,7 +1840,7 @@ externint ipf_matchicmpqueryreply 
__P((int, icmpinfo
 extern u_32_t  ipf_newisn __P((fr_info_t *));
 extern u_int   ipf_pcksum __P((fr_info_t *, int, u_int));
 #ifdef USE_INET6
-extern u_int   ipf_pcksum6 __P((fr_info_t *, ip6_t *,
+extern u_int   ipf_pcksum6 __P((struct mbuf *, ip6_t *,
u_int32_t, u_int32_t));
 #endif
 extern voidipf_rule_expire __P((ipf_main_softc_t *));

Modified: head/sys/contrib/ipfilter/netinet/ip_fil_freebsd.c
==
--- head/sys/contrib/ipfilter/netinet/ip_fil_freebsd.c  Thu Dec 12 20:44:46 
2019(r355669)
+++ head/sys/contrib/ipfilter/netinet/ip_fil_freebsd.c  Thu Dec 12 20:44:49 
2019(r355670)
@@ -1456,17 +1456,15 @@ ipf_pcksum(fin, hlen, sum)
 
 #ifdef USE_INET6
 u_int
-ipf_pcksum6(fin, ip6, off, len)
-   fr_info_t *fin;
+ipf_pcksum6(m, ip6, off, len)
+   struct mbuf *m;
ip6_t *ip6;
u_int32_t off;
u_int32_t len;
 {
 #ifdef _KERNEL
-   struct mbuf *m;
int sum;
 
-   m = fin->fin_m;
if (m->m_len < sizeof(struct ip6_hdr)) {
return 0x;
}
___
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: r355669 - head/sys/contrib/ipfilter/netinet

2019-12-12 Thread Cy Schubert
Author: cy
Date: Thu Dec 12 20:44:46 2019
New Revision: 355669
URL: https://svnweb.freebsd.org/changeset/base/355669

Log:
  in6_cksum() returns zero when checksums are good.
  
  PR:   203275
  Reported by:  Frank Volf 
  MFC after:3 days

Modified:
  head/sys/contrib/ipfilter/netinet/fil.c

Modified: head/sys/contrib/ipfilter/netinet/fil.c
==
--- head/sys/contrib/ipfilter/netinet/fil.c Thu Dec 12 19:37:10 2019
(r355668)
+++ head/sys/contrib/ipfilter/netinet/fil.c Thu Dec 12 20:44:46 2019
(r355669)
@@ -6744,7 +6744,7 @@ ipf_checkl4sum(fin)
 #endif
DT3(l4sums, u_short, hdrsum, u_short, sum, fr_info_t *, fin);
 #ifdef USE_INET6
-   if (hdrsum == sum || (sum == 0 && fin->fin_p == IPPROTO_ICMPV6)) {
+   if (hdrsum == sum || (sum == 0 && IP_V(fin->fin_ip) == 6)) {
 #else
if (hdrsum == sum) {
 #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: r355668 - in head/lib/libpmc/pmu-events/arch/s390: cf_z10 cf_z13 cf_z14 cf_z196 cf_zec12

2019-12-12 Thread Ed Maste
Author: emaste
Date: Thu Dec 12 19:37:10 2019
New Revision: 355668
URL: https://svnweb.freebsd.org/changeset/base/355668

Log:
  libpmc: convert s390 events data to proper json

Modified:
  head/lib/libpmc/pmu-events/arch/s390/cf_z10/basic.json
  head/lib/libpmc/pmu-events/arch/s390/cf_z10/crypto.json
  head/lib/libpmc/pmu-events/arch/s390/cf_z10/extended.json
  head/lib/libpmc/pmu-events/arch/s390/cf_z13/basic.json
  head/lib/libpmc/pmu-events/arch/s390/cf_z13/crypto.json
  head/lib/libpmc/pmu-events/arch/s390/cf_z13/extended.json
  head/lib/libpmc/pmu-events/arch/s390/cf_z14/basic.json
  head/lib/libpmc/pmu-events/arch/s390/cf_z14/crypto.json
  head/lib/libpmc/pmu-events/arch/s390/cf_z14/extended.json
  head/lib/libpmc/pmu-events/arch/s390/cf_z196/basic.json
  head/lib/libpmc/pmu-events/arch/s390/cf_z196/crypto.json
  head/lib/libpmc/pmu-events/arch/s390/cf_z196/extended.json
  head/lib/libpmc/pmu-events/arch/s390/cf_zec12/basic.json
  head/lib/libpmc/pmu-events/arch/s390/cf_zec12/crypto.json
  head/lib/libpmc/pmu-events/arch/s390/cf_zec12/extended.json

Modified: head/lib/libpmc/pmu-events/arch/s390/cf_z10/basic.json
==
--- head/lib/libpmc/pmu-events/arch/s390/cf_z10/basic.json  Thu Dec 12 
19:33:16 2019(r355667)
+++ head/lib/libpmc/pmu-events/arch/s390/cf_z10/basic.json  Thu Dec 12 
19:37:10 2019(r355668)
@@ -70,5 +70,5 @@
"EventName": "PROBLEM_STATE_L1D_PENALTY_CYCLES",
"BriefDescription": "Problem-State L1D Penalty Cycles",
"PublicDescription": "Problem-State Level-1 D-Cache Penalty 
Cycle Count"
-   },
+   }
 ]

Modified: head/lib/libpmc/pmu-events/arch/s390/cf_z10/crypto.json
==
--- head/lib/libpmc/pmu-events/arch/s390/cf_z10/crypto.json Thu Dec 12 
19:33:16 2019(r355667)
+++ head/lib/libpmc/pmu-events/arch/s390/cf_z10/crypto.json Thu Dec 12 
19:37:10 2019(r355668)
@@ -94,5 +94,5 @@
"EventName": "AES_BLOCKED_CYCLES",
"BriefDescription": "AES Blocked Cycles",
"PublicDescription": "Total number of CPU cycles blocked for 
the AES functions issued by the CPU because the DEA/AES coprocessor is busy 
performing a function issued by another CPU"
-   },
+   }
 ]

Modified: head/lib/libpmc/pmu-events/arch/s390/cf_z10/extended.json
==
--- head/lib/libpmc/pmu-events/arch/s390/cf_z10/extended.json   Thu Dec 12 
19:33:16 2019(r355667)
+++ head/lib/libpmc/pmu-events/arch/s390/cf_z10/extended.json   Thu Dec 12 
19:37:10 2019(r355668)
@@ -106,5 +106,5 @@
"EventName": "L2C_STORES_SENT",
"BriefDescription": "L2C Stores Sent",
"PublicDescription": "Incremented by one for every store sent 
to Level-2 (L1.5) cache"
-   },
+   }
 ]

Modified: head/lib/libpmc/pmu-events/arch/s390/cf_z13/basic.json
==
--- head/lib/libpmc/pmu-events/arch/s390/cf_z13/basic.json  Thu Dec 12 
19:33:16 2019(r355667)
+++ head/lib/libpmc/pmu-events/arch/s390/cf_z13/basic.json  Thu Dec 12 
19:37:10 2019(r355668)
@@ -70,5 +70,5 @@
"EventName": "PROBLEM_STATE_L1D_PENALTY_CYCLES",
"BriefDescription": "Problem-State L1D Penalty Cycles",
"PublicDescription": "Problem-State Level-1 D-Cache Penalty 
Cycle Count"
-   },
+   }
 ]

Modified: head/lib/libpmc/pmu-events/arch/s390/cf_z13/crypto.json
==
--- head/lib/libpmc/pmu-events/arch/s390/cf_z13/crypto.json Thu Dec 12 
19:33:16 2019(r355667)
+++ head/lib/libpmc/pmu-events/arch/s390/cf_z13/crypto.json Thu Dec 12 
19:37:10 2019(r355668)
@@ -94,5 +94,5 @@
"EventName": "AES_BLOCKED_CYCLES",
"BriefDescription": "AES Blocked Cycles",
"PublicDescription": "Total number of CPU cycles blocked for 
the AES functions issued by the CPU because the DEA/AES coprocessor is busy 
performing a function issued by another CPU"
-   },
+   }
 ]

Modified: head/lib/libpmc/pmu-events/arch/s390/cf_z13/extended.json
==
--- head/lib/libpmc/pmu-events/arch/s390/cf_z13/extended.json   Thu Dec 12 
19:33:16 2019(r355667)
+++ head/lib/libpmc/pmu-events/arch/s390/cf_z13/extended.json   Thu Dec 12 
19:37:10 2019(r355668)
@@ -334,5 +334,5 @@
"EventName": "MT_DIAG_CYCLES_TWO_THR_ACTIVE",
"BriefDescription": "Cycle count with two threads active",
"PublicDescription": "Cycle count with two threads active"
-   },
+   }
 ]

Modified: 

svn commit: r355667 - in head/lib/libpmc/pmu-events/arch/powerpc: power8 power9

2019-12-12 Thread Ed Maste
Author: emaste
Date: Thu Dec 12 19:33:16 2019
New Revision: 355667
URL: https://svnweb.freebsd.org/changeset/base/355667

Log:
  libpmc: convert powerpc event files to proper json

Modified:
  head/lib/libpmc/pmu-events/arch/powerpc/power8/cache.json
  head/lib/libpmc/pmu-events/arch/powerpc/power8/floating-point.json
  head/lib/libpmc/pmu-events/arch/powerpc/power8/frontend.json
  head/lib/libpmc/pmu-events/arch/powerpc/power8/marked.json
  head/lib/libpmc/pmu-events/arch/powerpc/power8/memory.json
  head/lib/libpmc/pmu-events/arch/powerpc/power8/other.json
  head/lib/libpmc/pmu-events/arch/powerpc/power8/pipeline.json
  head/lib/libpmc/pmu-events/arch/powerpc/power8/pmc.json
  head/lib/libpmc/pmu-events/arch/powerpc/power8/translation.json
  head/lib/libpmc/pmu-events/arch/powerpc/power9/cache.json
  head/lib/libpmc/pmu-events/arch/powerpc/power9/floating-point.json
  head/lib/libpmc/pmu-events/arch/powerpc/power9/frontend.json
  head/lib/libpmc/pmu-events/arch/powerpc/power9/marked.json
  head/lib/libpmc/pmu-events/arch/powerpc/power9/memory.json
  head/lib/libpmc/pmu-events/arch/powerpc/power9/other.json
  head/lib/libpmc/pmu-events/arch/powerpc/power9/pipeline.json
  head/lib/libpmc/pmu-events/arch/powerpc/power9/pmc.json
  head/lib/libpmc/pmu-events/arch/powerpc/power9/translation.json

Modified: head/lib/libpmc/pmu-events/arch/powerpc/power8/cache.json
==
--- head/lib/libpmc/pmu-events/arch/powerpc/power8/cache.json   Thu Dec 12 
19:23:38 2019(r355666)
+++ head/lib/libpmc/pmu-events/arch/powerpc/power8/cache.json   Thu Dec 12 
19:33:16 2019(r355667)
@@ -1,176 +1,176 @@
 [
-  {,
+  {
 "EventCode": "0x4c048",
 "EventName": "PM_DATA_FROM_DL2L3_MOD",
 "BriefDescription": "The processor's data cache was reloaded with Modified 
(M) data from another chip's L2 or L3 on a different Node or Group (Distant), 
as this chip due to a demand load",
 "PublicDescription": "The processor's data cache was reloaded with 
Modified (M) data from another chip's L2 or L3 on a different Node or Group 
(Distant), as this chip due to either only demand loads or demand loads plus 
prefetches if MMCR1[16] is 1"
   },
-  {,
+  {
 "EventCode": "0x3c048",
 "EventName": "PM_DATA_FROM_DL2L3_SHR",
 "BriefDescription": "The processor's data cache was reloaded with Shared 
(S) data from another chip's L2 or L3 on a different Node or Group (Distant), 
as this chip due to a demand load",
 "PublicDescription": "The processor's data cache was reloaded with Shared 
(S) data from another chip's L2 or L3 on a different Node or Group (Distant), 
as this chip due to either only demand loads or demand loads plus prefetches if 
MMCR1[16] is 1"
   },
-  {,
+  {
 "EventCode": "0x3c04c",
 "EventName": "PM_DATA_FROM_DL4",
 "BriefDescription": "The processor's data cache was reloaded from another 
chip's L4 on a different Node or Group (Distant) due to a demand load",
 "PublicDescription": "The processor's data cache was reloaded from another 
chip's L4 on a different Node or Group (Distant) due to either only demand 
loads or demand loads plus prefetches if MMCR1[16] is 1"
   },
-  {,
+  {
 "EventCode": "0x1c042",
 "EventName": "PM_DATA_FROM_L2",
 "BriefDescription": "The processor's data cache was reloaded from local 
core's L2 due to a demand load",
 "PublicDescription": "The processor's data cache was reloaded from local 
core's L2 due to either only demand loads or demand loads plus prefetches if 
MMCR1[16] is 1"
   },
-  {,
+  {
 "EventCode": "0x200fe",
 "EventName": "PM_DATA_FROM_L2MISS",
 "BriefDescription": "Demand LD - L2 Miss (not L2 hit)",
 "PublicDescription": ""
   },
-  {,
+  {
 "EventCode": "0x1c04e",
 "EventName": "PM_DATA_FROM_L2MISS_MOD",
 "BriefDescription": "The processor's data cache was reloaded from a 
localtion other than the local core's L2 due to a demand load",
 "PublicDescription": "The processor's data cache was reloaded from a 
localtion other than the local core's L2 due to either only demand loads or 
demand loads plus prefetches if MMCR1[16] is 1"
   },
-  {,
+  {
 "EventCode": "0x3c040",
 "EventName": "PM_DATA_FROM_L2_DISP_CONFLICT_LDHITST",
 "BriefDescription": "The processor's data cache was reloaded from local 
core's L2 with load hit store conflict due to a demand load",
 "PublicDescription": "The processor's data cache was reloaded from local 
core's L2 with load hit store conflict due to either only demand loads or 
demand loads plus prefetches if MMCR1[16] is 1"
   },
-  {,
+  {
 "EventCode": "0x4c040",
 "EventName": "PM_DATA_FROM_L2_DISP_CONFLICT_OTHER",
 "BriefDescription": "The processor's data cache was reloaded from local 
core's L2 with dispatch conflict due to a demand load",
 "PublicDescription": "The processor's data cache was reloaded from local 
core's L2 with dispatch conflict due 

svn commit: r355666 - head/lib/libpmc/pmu-events/arch/x86/amdfam17h

2019-12-12 Thread Ed Maste
Author: emaste
Date: Thu Dec 12 19:23:38 2019
New Revision: 355666
URL: https://svnweb.freebsd.org/changeset/base/355666

Log:
  libpmc: sort some amdfam17h entries to make valid json

Modified:
  head/lib/libpmc/pmu-events/arch/x86/amdfam17h/core.json
  head/lib/libpmc/pmu-events/arch/x86/amdfam17h/memory.json

Modified: head/lib/libpmc/pmu-events/arch/x86/amdfam17h/core.json
==
--- head/lib/libpmc/pmu-events/arch/x86/amdfam17h/core.json Thu Dec 12 
19:21:16 2019(r355665)
+++ head/lib/libpmc/pmu-events/arch/x86/amdfam17h/core.json Thu Dec 12 
19:23:38 2019(r355666)
@@ -2,20 +2,20 @@
  {
  "EventName": "ex_ret_instr",
  "EventCode": "0xc0",
+ "SampleAfterValue": "203",
  "BriefDescription": "Retired Instructions."
-  "SampleAfterValue": "203",
  },
  {
  "EventName": "ex_ret_cops",
  "EventCode": "0xc1",
+ "SampleAfterValue": "203",
  "BriefDescription": "The number of uOps retired. This includes all processor 
activity (instructions, exceptions, interrupts, microcode assists, etc.). The 
number of events logged per cycle can vary from 0 to 4."
-  "SampleAfterValue": "203",
  },
  {
  "EventName": "ex_ret_brn",
  "EventCode": "0xc2",
+ "SampleAfterValue": "203",
  "BriefDescription": "The number of branch instructions retired. This includes 
all types of architectural control flow changes, including exceptions and 
interrupts."
-  "SampleAfterValue": "203",
  },
  {
  "EventName": "ex_ret_brn_misp",

Modified: head/lib/libpmc/pmu-events/arch/x86/amdfam17h/memory.json
==
--- head/lib/libpmc/pmu-events/arch/x86/amdfam17h/memory.json   Thu Dec 12 
19:21:16 2019(r355665)
+++ head/lib/libpmc/pmu-events/arch/x86/amdfam17h/memory.json   Thu Dec 12 
19:23:38 2019(r355666)
@@ -220,7 +220,7 @@
  {
  "EventName": "ls_not_halted_cyc",
  "EventCode": "0x76",
- "BriefDescription": "Cycles not in Halt."
  "SampleAfterValue": "203",
+ "BriefDescription": "Cycles not in Halt."
  }
 ]
___
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: r355665 - in stable/12/sys: arm/broadcom/bcm2835 arm64/conf conf

2019-12-12 Thread Kyle Evans
Author: kevans
Date: Thu Dec 12 19:21:16 2019
New Revision: 355665
URL: https://svnweb.freebsd.org/changeset/base/355665

Log:
  MFC Collection of Raspberry Pi fixes: r348803-r348804, r354488, r354524,
  r354560-r354561, r354563, r354577, r354579, r354823, r354825,
  r354844-r354846, r354868, r354875-r354876, r354930-r354933, r354956,
  r355016, r355025-r355026, r355031, r355563
  
  r348803 by bz:
  bcm2835_sdhci.c: save block registers to avoid controller bug
  
  Extending what the initial revision, r273264, r276985, r277346 have
  started for the transfer mode and command registers, another pair of
  16bit registers written in sequence are block size and block count,
  which fall together onto the same 32bit line and hence the same
  register(s) would be written twice in sequence for those as well.
  
  Use a similar approach to transfer mode and command and save the writes
  to either of the block regiters and then only execute a write once.
  We can do this as with transfer mode their values are meaningless until
  a command is issued so we can use that write to command as a trigger
  to also write out the block registers.
  Compared to transfer mode and command the value of block count can
  change, so we need to keep state and actually read the block registers
  back the first time after a write.
  
  r348804 by bz:
  bcm2835_sdhci.c: exit DMA if not enough data left to avoid timeout errors
  
  In the DMA case, given we disable the data interrupts, we never seem
  to get DATA_END.  Given we are relying on DMA interrupts we are not
  using the SDHCI state machine and hence only call into
  sdhci_platform_will_handle() for the first check of data.
  We do not call "will handle" for any following round trips of the same
  transaction if block size * count > BCM_DMA_BLOCK_SIZE.
  Manually check "left" in the DMA interrupt handler to see if we have at
  least another full BCM_DMA_BLOCK_SIZE to handle.
  Without this change we would DMA that and then even start a DMA with
  left == 0 which would lead to a timeout and error.
  Now we re-enable data interrupts and return and let the SDHCI generic
  interrupt handler and state machine pick the SPACE_AVAIL up and then
  find that it should punt to the pio_handler for the remaining bytes
  or finish the data transaction.
  
  With this change block mode seems to work beyond 7 * 64byte blocks,
  which worked as it was below BCM_DMA_BLOCK_SIZE.
  
  r354488:
  bcm_lintc: don't attach if "interrupt-controller" is missing
  
  This is a standard required property for interrupt controllers, and present
  on the bcm_lintc nodes for currently supported RPi models. For the RPi4, we
  have both bcm_lintc as well as GIC-400, but only one may be active at a
  time.
  
  Don't probe bcm_lintc if it's missing the "interrupt-controller" property --
  in RPi 4 DTS, the bcm_lintc node is actually missing this along with other
  required interrupt properties. Presumably, if the earlier boot stages will
  support switching to the legacy interrupt controller (as is suggested
  possible by the documentation), the DTS will need to be updated to indicate
  the proper interrupt-parent and hopefully also mark this node as an
  interrupt-controller instead.
  
  r354524:
  bcm2835_dma: Mark IRQs shareable
  
  On the RPi4, some of these IRQs are shared. Start moving toward a mode where
  we accept that shared IRQs happen and simply ignore interrupts that are
  seemingly for no reason.
  
  I would like to be more verbose here, but my 30-minute assessment of the
  current world order is that mapping a resource/rid to an actual IRQ number
  (as found in FDT) data is not a simple matter. Determining if more than one
  handler is attached to an IRQ is closer to feasible, but it's unclear which
  way is the cleaner path. Beyond that, we're only really using it to be
  slightly more verbose when something's going wrong, so for now just suppress
  and drop a complaint-comment.
  
  This was originally submitted (via freebsd-arm@) by Robert Crowston; the
  additional verbosity was dropped by kevans@.
  
  r354560:
  bcm2835_sdhci: add some very basic support for rpi4
  
  DMA is currently disabled while I work out why it's broken, but this is
  enough for upstream U-Boot + rpi-firmware + our rpi3-psci-monitor to boot
  with the right config.
  
  The RPi 4 is still not in a good "supported" state, as we have no
  USB/PCI-E/Ethernet drivers, but if air-gapped pies only able to operate over
  cereal is your thing, here's your guy.
  
  r354561:
  bcm2835_sdhci: remove unused power_id field
  
  This was once set, but I removed it by the time I committed it because both
  configurations use the same POWER_ID. This can be separated back out if the
  situation changes.
  
  r354563:
  bcm2835: commit missing constant from r354560
  
  Surgically pulling the patch from my debugging work lead to this slopiness-
  my apologies.
  
  r354577:
  arm64: add SOC_BRCM_BCM2838, build it in GENERIC
  
  

svn commit: r355664 - stable/11/usr.bin/netstat

2019-12-12 Thread Baptiste Daroussin
Author: bapt
Date: Thu Dec 12 19:17:30 2019
New Revision: 355664
URL: https://svnweb.freebsd.org/changeset/base/355664

Log:
  MFC: r34
  
  Fix: netstat -rs
  
  Routing statistics requires somes symbols that are only loaded when not 
running
  live. Load them only in that specific case
  
  PR:   242423
  Submitted by: olivier

Modified:
  stable/11/usr.bin/netstat/main.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/usr.bin/netstat/main.c
==
--- stable/11/usr.bin/netstat/main.cThu Dec 12 19:17:26 2019
(r355663)
+++ stable/11/usr.bin/netstat/main.cThu Dec 12 19:17:30 2019
(r355664)
@@ -478,6 +478,9 @@ main(int argc, char *argv[])
if (rflag) {
xo_open_container("statistics");
if (sflag) {
+   if (live) {
+   kresolve_list(nl);
+   }
rt_stats();
flowtable_stats();
} 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: r355663 - stable/12/usr.bin/netstat

2019-12-12 Thread Baptiste Daroussin
Author: bapt
Date: Thu Dec 12 19:17:26 2019
New Revision: 355663
URL: https://svnweb.freebsd.org/changeset/base/355663

Log:
  MFC: r34
  
  Fix: netstat -rs
  
  Routing statistics requires somes symbols that are only loaded when not 
running
  live. Load them only in that specific case
  
  PR:   242423
  Submitted by: olivier

Modified:
  stable/12/usr.bin/netstat/main.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/usr.bin/netstat/main.c
==
--- stable/12/usr.bin/netstat/main.cThu Dec 12 18:53:45 2019
(r355662)
+++ stable/12/usr.bin/netstat/main.cThu Dec 12 19:17:26 2019
(r355663)
@@ -484,6 +484,9 @@ main(int argc, char *argv[])
if (rflag) {
xo_open_container("statistics");
if (sflag) {
+   if (live) {
+   kresolve_list(nl);
+   }
rt_stats();
} else
routepr(fib, af);
___
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: r355662 - in stable: 11/lib/libbe 12/lib/libbe

2019-12-12 Thread Kyle Evans
Author: kevans
Date: Thu Dec 12 18:53:45 2019
New Revision: 355662
URL: https://svnweb.freebsd.org/changeset/base/355662

Log:
  MFC r355460: 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:
  stable/12/lib/libbe/be.c
  stable/12/lib/libbe/be_access.c
  stable/12/lib/libbe/be_info.c
Directory Properties:
  stable/12/   (props changed)

Changes in other areas also in this revision:
Modified:
  stable/11/lib/libbe/be.c
  stable/11/lib/libbe/be_access.c
  stable/11/lib/libbe/be_info.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/12/lib/libbe/be.c
==
--- stable/12/lib/libbe/be.cThu Dec 12 18:51:32 2019(r355661)
+++ stable/12/lib/libbe/be.cThu Dec 12 18:53:45 2019(r355662)
@@ -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: stable/12/lib/libbe/be_access.c
==
--- stable/12/lib/libbe/be_access.c Thu Dec 12 18:51:32 2019
(r355661)
+++ stable/12/lib/libbe/be_access.c Thu Dec 12 18:53:45 2019
(r355662)
@@ -31,6 +31,8 @@
 #include 
 __FBSDID("$FreeBSD$");
 
+#include 
+
 #include "be.h"
 #include "be_impl.h"
 

Modified: stable/12/lib/libbe/be_info.c
==
--- stable/12/lib/libbe/be_info.c   Thu Dec 12 18:51:32 2019
(r355661)
+++ stable/12/lib/libbe/be_info.c   Thu Dec 12 18:53:45 2019
(r355662)
@@ -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: r355662 - in stable: 11/lib/libbe 12/lib/libbe

2019-12-12 Thread Kyle Evans
Author: kevans
Date: Thu Dec 12 18:53:45 2019
New Revision: 355662
URL: https://svnweb.freebsd.org/changeset/base/355662

Log:
  MFC r355460: 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:
  stable/11/lib/libbe/be.c
  stable/11/lib/libbe/be_access.c
  stable/11/lib/libbe/be_info.c
Directory Properties:
  stable/11/   (props changed)

Changes in other areas also in this revision:
Modified:
  stable/12/lib/libbe/be.c
  stable/12/lib/libbe/be_access.c
  stable/12/lib/libbe/be_info.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/11/lib/libbe/be.c
==
--- stable/11/lib/libbe/be.cThu Dec 12 18:51:32 2019(r355661)
+++ stable/11/lib/libbe/be.cThu Dec 12 18:53:45 2019(r355662)
@@ -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: stable/11/lib/libbe/be_access.c
==
--- stable/11/lib/libbe/be_access.c Thu Dec 12 18:51:32 2019
(r355661)
+++ stable/11/lib/libbe/be_access.c Thu Dec 12 18:53:45 2019
(r355662)
@@ -31,6 +31,8 @@
 #include 
 __FBSDID("$FreeBSD$");
 
+#include 
+
 #include "be.h"
 #include "be_impl.h"
 

Modified: stable/11/lib/libbe/be_info.c
==
--- stable/11/lib/libbe/be_info.c   Thu Dec 12 18:51:32 2019
(r355661)
+++ stable/11/lib/libbe/be_info.c   Thu Dec 12 18:53:45 2019
(r355662)
@@ -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: r355661 - in stable: 11/stand/lua 12/stand/lua

2019-12-12 Thread Kyle Evans
Author: kevans
Date: Thu Dec 12 18:51:32 2019
New Revision: 355661
URL: https://svnweb.freebsd.org/changeset/base/355661

Log:
  MFC r354247, r355349: lualoader try_include improvement
  
  r354247: lualoader: rewrite try_include using lfs + dofile
  
  Actual modules get require()'d in, rather than try_include(). All instances
  of try_include should be provided with proper hooks/API in the rest of
  loader to do the work they need to do, since we can't rely on them to exist.
  Convert this now to lfs + dofile since we won't really be treating them as
  modules.
  
  lfs is required because dofile will properly throw an error if the file
  doesn't exist, which is not in the spirit of 'optionally included'.
  
  Getting out of the pcall game allows us to provide a loader.exit() style
  call that backs out to the common bits of loader (autoboot sequence unless
  disabled with a loader.setenv("autoboot_delay", "NO")). The most ideal way
  identified so far to implement loader.exit() is to throw a special
  abort-style error that indicates to the caller in interp_lua that we've not
  actually errored out, just continue execution. Otherwise, we have to hack in
  logic to bubble up and return from loader.lua without continuing further,
  which gets kind of ugly depending on the context in which we're aborting.
  
  A compat shim is provided temporarily in case the executing loader doesn't
  yet have loader.lua_path, which was just added in r354246.
  
  r355349: lualoader: correct a typo from r354247
  
  r354247 converted try_include to lfs + dofile with the loader.lua_path added
  just before. Fortunately, there was a hardcoded /boot/lua fallback in case
  loader.lua_path wasn't being set yet- I typo'd it as loader.lua_paths.
  
  Fix the typo.

Modified:
  stable/11/stand/lua/core.lua
Directory Properties:
  stable/11/   (props changed)

Changes in other areas also in this revision:
Modified:
  stable/12/stand/lua/core.lua
Directory Properties:
  stable/12/   (props changed)

Modified: stable/11/stand/lua/core.lua
==
--- stable/11/stand/lua/core.luaThu Dec 12 18:45:31 2019
(r355660)
+++ stable/11/stand/lua/core.luaThu Dec 12 18:51:32 2019
(r355661)
@@ -69,12 +69,28 @@ end
 -- try_include will return the loaded module on success, or false and the error
 -- message on failure.
 function try_include(module)
-   local status, ret = pcall(require, module)
-   -- ret is the module if we succeeded.
-   if status then
-   return ret
+   if module:sub(1, 1) ~= "/" then
+   local lua_path = loader.lua_path
+   -- XXX Temporary compat shim; this should be removed once the
+   -- loader.lua_path export has sufficiently spread.
+   if lua_path == nil then
+   lua_path = "/boot/lua"
+   end
+   module = lua_path .. "/" .. module
+   -- We only attempt to append an extension if an absolute path
+   -- wasn't specified.  This assumes that the caller either wants
+   -- to treat this like it would require() and specify just the
+   -- base filename, or they know what they're doing as they've
+   -- specified an absolute path and we shouldn't impede.
+   if module:match(".lua$") == nil then
+   module = module .. ".lua"
+   end
end
-   return false, ret
+   if lfs.attributes(module, "mode") ~= "file" then
+   return
+   end
+
+   return dofile(module)
 end
 
 -- Module exports
___
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: r355661 - in stable: 11/stand/lua 12/stand/lua

2019-12-12 Thread Kyle Evans
Author: kevans
Date: Thu Dec 12 18:51:32 2019
New Revision: 355661
URL: https://svnweb.freebsd.org/changeset/base/355661

Log:
  MFC r354247, r355349: lualoader try_include improvement
  
  r354247: lualoader: rewrite try_include using lfs + dofile
  
  Actual modules get require()'d in, rather than try_include(). All instances
  of try_include should be provided with proper hooks/API in the rest of
  loader to do the work they need to do, since we can't rely on them to exist.
  Convert this now to lfs + dofile since we won't really be treating them as
  modules.
  
  lfs is required because dofile will properly throw an error if the file
  doesn't exist, which is not in the spirit of 'optionally included'.
  
  Getting out of the pcall game allows us to provide a loader.exit() style
  call that backs out to the common bits of loader (autoboot sequence unless
  disabled with a loader.setenv("autoboot_delay", "NO")). The most ideal way
  identified so far to implement loader.exit() is to throw a special
  abort-style error that indicates to the caller in interp_lua that we've not
  actually errored out, just continue execution. Otherwise, we have to hack in
  logic to bubble up and return from loader.lua without continuing further,
  which gets kind of ugly depending on the context in which we're aborting.
  
  A compat shim is provided temporarily in case the executing loader doesn't
  yet have loader.lua_path, which was just added in r354246.
  
  r355349: lualoader: correct a typo from r354247
  
  r354247 converted try_include to lfs + dofile with the loader.lua_path added
  just before. Fortunately, there was a hardcoded /boot/lua fallback in case
  loader.lua_path wasn't being set yet- I typo'd it as loader.lua_paths.
  
  Fix the typo.

Modified:
  stable/12/stand/lua/core.lua
Directory Properties:
  stable/12/   (props changed)

Changes in other areas also in this revision:
Modified:
  stable/11/stand/lua/core.lua
Directory Properties:
  stable/11/   (props changed)

Modified: stable/12/stand/lua/core.lua
==
--- stable/12/stand/lua/core.luaThu Dec 12 18:45:31 2019
(r355660)
+++ stable/12/stand/lua/core.luaThu Dec 12 18:51:32 2019
(r355661)
@@ -69,12 +69,28 @@ end
 -- try_include will return the loaded module on success, or false and the error
 -- message on failure.
 function try_include(module)
-   local status, ret = pcall(require, module)
-   -- ret is the module if we succeeded.
-   if status then
-   return ret
+   if module:sub(1, 1) ~= "/" then
+   local lua_path = loader.lua_path
+   -- XXX Temporary compat shim; this should be removed once the
+   -- loader.lua_path export has sufficiently spread.
+   if lua_path == nil then
+   lua_path = "/boot/lua"
+   end
+   module = lua_path .. "/" .. module
+   -- We only attempt to append an extension if an absolute path
+   -- wasn't specified.  This assumes that the caller either wants
+   -- to treat this like it would require() and specify just the
+   -- base filename, or they know what they're doing as they've
+   -- specified an absolute path and we shouldn't impede.
+   if module:match(".lua$") == nil then
+   module = module .. ".lua"
+   end
end
-   return false, ret
+   if lfs.attributes(module, "mode") ~= "file" then
+   return
+   end
+
+   return dofile(module)
 end
 
 -- Module exports
___
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: r355660 - in head/sys: kern sys

2019-12-12 Thread Edward Tomasz Napierala
Author: trasz
Date: Thu Dec 12 18:45:31 2019
New Revision: 355660
URL: https://svnweb.freebsd.org/changeset/base/355660

Log:
  Add kern_sync(9), and make kernel code call it instead of going
  via sys_sync(2).  Minor cleanup, no functional changes.
  
  Reviewed by:  kib
  MFC after:2 weeks
  Sponsored by: The FreeBSD Foundation
  Differential Revision:https://reviews.freebsd.org/D19366

Modified:
  head/sys/kern/vfs_bio.c
  head/sys/kern/vfs_syscalls.c
  head/sys/sys/syscallsubr.h

Modified: head/sys/kern/vfs_bio.c
==
--- head/sys/kern/vfs_bio.c Thu Dec 12 18:27:54 2019(r355659)
+++ head/sys/kern/vfs_bio.c Thu Dec 12 18:45:31 2019(r355660)
@@ -72,7 +72,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
-#include 
+#include 
 #include 
 #include 
 #include 
@@ -1342,7 +1342,7 @@ bufshutdown(int show_busybufs)
 * Sync filesystems for shutdown
 */
wdog_kern_pat(WD_LASTVAL);
-   sys_sync(curthread, NULL);
+   kern_sync(curthread);
 
/*
 * With soft updates, some buffers that are
@@ -1369,7 +1369,7 @@ bufshutdown(int show_busybufs)
pbusy = nbusy;
 
wdog_kern_pat(WD_LASTVAL);
-   sys_sync(curthread, NULL);
+   kern_sync(curthread);
 
 #ifdef PREEMPTION
/*

Modified: head/sys/kern/vfs_syscalls.c
==
--- head/sys/kern/vfs_syscalls.cThu Dec 12 18:27:54 2019
(r355659)
+++ head/sys/kern/vfs_syscalls.cThu Dec 12 18:45:31 2019
(r355660)
@@ -114,17 +114,8 @@ static int kern_readlink_vp(struct vnode *vp, char *bu
 static int kern_linkat_vp(struct thread *td, struct vnode *vp, int fd,
 const char *path, enum uio_seg segflag);
 
-/*
- * Sync each mounted filesystem.
- */
-#ifndef _SYS_SYSPROTO_H_
-struct sync_args {
-   int dummy;
-};
-#endif
-/* ARGSUSED */
 int
-sys_sync(struct thread *td, struct sync_args *uap)
+kern_sync(struct thread *td)
 {
struct mount *mp, *nmp;
int save;
@@ -149,6 +140,22 @@ sys_sync(struct thread *td, struct sync_args *uap)
}
mtx_unlock(_mtx);
return (0);
+}
+
+/*
+ * Sync each mounted filesystem.
+ */
+#ifndef _SYS_SYSPROTO_H_
+struct sync_args {
+   int dummy;
+};
+#endif
+/* ARGSUSED */
+int
+sys_sync(struct thread *td, struct sync_args *uap)
+{
+
+   return (kern_sync(td));
 }
 
 /*

Modified: head/sys/sys/syscallsubr.h
==
--- head/sys/sys/syscallsubr.h  Thu Dec 12 18:27:54 2019(r355659)
+++ head/sys/sys/syscallsubr.h  Thu Dec 12 18:45:31 2019(r355660)
@@ -276,6 +276,7 @@ int kern_statfs(struct thread *td, const char *path, e
struct statfs *buf);
 intkern_symlinkat(struct thread *td, const char *path1, int fd,
const char *path2, enum uio_seg segflg);
+intkern_sync(struct thread *td);
 intkern_ktimer_create(struct thread *td, clockid_t clock_id,
struct sigevent *evp, int *timerid, int preset_id);
 intkern_ktimer_delete(struct thread *, int);
___
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: r355659 - in head/sys/arm64: arm64 include

2019-12-12 Thread Andrew Turner
Author: andrew
Date: Thu Dec 12 18:27:54 2019
New Revision: 355659
URL: https://svnweb.freebsd.org/changeset/base/355659

Log:
  Add comments and macros to the tcr_el1 setting code to help understand it.
  
  This code is non-obvious when reading for the first time. To help with
  understanding of it add comments explaining what it's doing.
  
  While here use macros from armreg.h rather than magic numbers.
  
  Sponsored by: DARPA, AFRL

Modified:
  head/sys/arm64/arm64/locore.S
  head/sys/arm64/include/armreg.h

Modified: head/sys/arm64/arm64/locore.S
==
--- head/sys/arm64/arm64/locore.S   Thu Dec 12 18:16:32 2019
(r355658)
+++ head/sys/arm64/arm64/locore.S   Thu Dec 12 18:27:54 2019
(r355659)
@@ -688,14 +688,23 @@ start_mmu:
 */
ldr x2, tcr
mrs x3, id_aa64mmfr0_el1
-   bfi x2, x3, #32, #3
-   and x3, x3, #0xF0
-   cmp x3, #0x20
+
+   /* Copy the bottom 3 bits from id_aa64mmfr0_el1 into TCR.IPS */
+   bfi x2, x3, #(TCR_IPS_SHIFT), #(TCR_IPS_WIDTH)
+   and x3, x3, #(ID_AA64MMFR0_ASIDBits_MASK)
+
+   /* Check if the HW supports 16 bit ASIDS */
+   cmp x3, #(ID_AA64MMFR0_ASIDBits_16)
+   /* If so x3 == 1, else x3 == 0 */
csetx3, eq
-   bfi x2, x3, #36, #1
+   /* Set TCR.AS with x3 */
+   bfi x2, x3, #(TCR_ASID_SHIFT), #(TCR_ASID_WIDTH)
+
msr tcr_el1, x2
 
-   /* Setup SCTLR */
+   /*
+* Setup SCTLR.
+*/
ldr x2, sctlr_set
ldr x3, sctlr_clear
mrs x1, sctlr_el1

Modified: head/sys/arm64/include/armreg.h
==
--- head/sys/arm64/include/armreg.h Thu Dec 12 18:16:32 2019
(r355658)
+++ head/sys/arm64/include/armreg.h Thu Dec 12 18:27:54 2019
(r355659)
@@ -619,9 +619,12 @@
 #definePSR_FLAGS   0xf000
 
 /* TCR_EL1 - Translation Control Register */
-#defineTCR_ASID_16 (0x1UL << 36)
+#defineTCR_ASID_SHIFT  36
+#defineTCR_ASID_WIDTH  1
+#defineTCR_ASID_16 (0x1UL << TCR_ASID_SHIFT)
 
 #defineTCR_IPS_SHIFT   32
+#defineTCR_IPS_WIDTH   3
 #defineTCR_IPS_32BIT   (0 << TCR_IPS_SHIFT)
 #defineTCR_IPS_36BIT   (1 << TCR_IPS_SHIFT)
 #defineTCR_IPS_40BIT   (2 << TCR_IPS_SHIFT)
___
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: r355658 - in stable/12: include sys/sys

2019-12-12 Thread Dimitry Andric
Author: dim
Date: Thu Dec 12 18:16:32 2019
New Revision: 355658
URL: https://svnweb.freebsd.org/changeset/base/355658

Log:
  MFC r355568:
  
  Correctly check for C++17 and higher when declaring timespec_get()
  
  Summary:
  In rS338751, the check to declare `timespec_get()` for C++17 and higher
  was incorrectly done against a `cplusplus` define, while it should have
  been `__cplusplus`.
  
  Fix this by using `__cplusplus`, and also bump `__FreeBSD_version` so it
  becomes possible to correctly check for `timespec_get()` in upstream
  libc++ headers.
  
  Reviewed by:  brooks, emaste
  Differential Revision: https://reviews.freebsd.org/D22735

Modified:
  stable/12/include/time.h
  stable/12/sys/sys/param.h
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/include/time.h
==
--- stable/12/include/time.hThu Dec 12 17:40:32 2019(r355657)
+++ stable/12/include/time.hThu Dec 12 18:16:32 2019(r355658)
@@ -208,7 +208,7 @@ time_t posix2time(time_t t);
 #endif
 
 #if defined(__BSD_VISIBLE) || __ISO_C_VISIBLE >= 2011 || \
-(defined(cplusplus) && cplusplus >= 201703)
+(defined(__cplusplus) && __cplusplus >= 201703)
 #include 
 /* ISO/IEC 9899:201x 7.27.2.5 The timespec_get function */
 #define TIME_UTC   1   /* time elapsed since epoch */

Modified: stable/12/sys/sys/param.h
==
--- stable/12/sys/sys/param.h   Thu Dec 12 17:40:32 2019(r355657)
+++ stable/12/sys/sys/param.h   Thu Dec 12 18:16:32 2019(r355658)
@@ -60,7 +60,7 @@
  * in the range 5 to 9.
  */
 #undef __FreeBSD_version
-#define __FreeBSD_version 1201503  /* Master, propagated to newvers */
+#define __FreeBSD_version 1201504  /* Master, propagated to newvers */
 
 /*
  * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD,
___
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: r355657 - head/libexec/rtld-elf

2019-12-12 Thread Brandon Bergren
Author: bdragon
Date: Thu Dec 12 17:40:32 2019
New Revision: 355657
URL: https://svnweb.freebsd.org/changeset/base/355657

Log:
  rtld: do not try to mmap a zero-sized PT_LOAD
  
  When a PT_LOAD segment has a zero p_filesz, skip the data mmap, as mmapping
  zero bytes from a file is an error.
  
  A PT_LOAD with zero p_filesz is legal (but somewhat uncommon due to segment
  merging in modern linkers, as it is more efficient to merge .data and .bss
  by just extending p_memsz in the previous segment, assuming compatible
  page protection.)
  
  This was seen on ports/graphics/glew on a powerpc64 ELFv2 experimental
  build.
  
  Submitted by: Alfredo Dal'Ava Junior 
  Reviewed by:  kib
  Differential Revision:https://reviews.freebsd.org/D22634

Modified:
  head/libexec/rtld-elf/map_object.c

Modified: head/libexec/rtld-elf/map_object.c
==
--- head/libexec/rtld-elf/map_object.c  Thu Dec 12 17:12:18 2019
(r355656)
+++ head/libexec/rtld-elf/map_object.c  Thu Dec 12 17:40:32 2019
(r355657)
@@ -228,11 +228,12 @@ map_object(int fd, const char *path, const struct stat
data_addr = mapbase + (data_vaddr - base_vaddr);
data_prot = convert_prot(segs[i]->p_flags);
data_flags = convert_flags(segs[i]->p_flags) | MAP_FIXED;
-   if (mmap(data_addr, data_vlimit - data_vaddr, data_prot,
- data_flags | MAP_PREFAULT_READ, fd, data_offset) == (caddr_t) -1) {
-   _rtld_error("%s: mmap of data failed: %s", path,
-   rtld_strerror(errno));
-   goto error1;
+   if (data_vlimit != data_vaddr &&
+   mmap(data_addr, data_vlimit - data_vaddr, data_prot, 
+   data_flags | MAP_PREFAULT_READ, fd, data_offset) == MAP_FAILED) {
+   _rtld_error("%s: mmap of data failed: %s", path,
+   rtld_strerror(errno));
+   goto error1;
}
 
/* Do BSS setup */
___
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: r355656 - in head: lib/libc/powerpcspe/gen lib/msun/powerpc sys/powerpc/booke

2019-12-12 Thread Brandon Bergren
Author: bdragon
Date: Thu Dec 12 17:12:18 2019
New Revision: 355656
URL: https://svnweb.freebsd.org/changeset/base/355656

Log:
  [PowerPC] Fix SPE floating point environment manipulation
  
  Fix multiple problems in the powerpcspe floating point code.
  
  * Endianness handling of the SPEFSCR in fenv.h was completely broken.
  * Ensure SPEFSCR synchronization requirements are being met.
  
  The __r.__d -> __r transformations were written by jhibbits.
  
  Reviewed by:  jhibbits
  Differential Revision:https://reviews.freebsd.org/D22526

Modified:
  head/lib/libc/powerpcspe/gen/fpsetmask.c
  head/lib/libc/powerpcspe/gen/fpsetround.c
  head/lib/msun/powerpc/fenv.h
  head/sys/powerpc/booke/spe.c

Modified: head/lib/libc/powerpcspe/gen/fpsetmask.c
==
--- head/lib/libc/powerpcspe/gen/fpsetmask.cThu Dec 12 16:49:55 2019
(r355655)
+++ head/lib/libc/powerpcspe/gen/fpsetmask.cThu Dec 12 17:12:18 2019
(r355656)
@@ -47,7 +47,7 @@ fpsetmask(fp_except_t mask)
__asm__ __volatile("mfspr %0, %1" : "=r"(fpscr) : "K"(SPR_SPEFSCR));
old = (fp_rnd_t)((fpscr >> 2) & 0x1f);
fpscr = (fpscr & 0xff83) | (mask << 2);
-   __asm__ __volatile("mtspr %1,%0" :: "r"(fpscr), "K"(SPR_SPEFSCR));
+   __asm__ __volatile("mtspr %1,%0;isync" :: "r"(fpscr), "K"(SPR_SPEFSCR));
return (old);
 }
 #endif

Modified: head/lib/libc/powerpcspe/gen/fpsetround.c
==
--- head/lib/libc/powerpcspe/gen/fpsetround.c   Thu Dec 12 16:49:55 2019
(r355655)
+++ head/lib/libc/powerpcspe/gen/fpsetround.c   Thu Dec 12 17:12:18 2019
(r355656)
@@ -47,7 +47,7 @@ fpsetround(fp_rnd_t rnd_dir)
__asm__ __volatile("mfspr %0, %1" : "=r"(fpscr) : "K"(SPR_SPEFSCR) );
old = (fp_rnd_t)(fpscr & 0x3);
fpscr = (fpscr & 0xfffc) | rnd_dir;
-   __asm__ __volatile("mtspr %1, %0" :: "r"(fpscr), "K"(SPR_SPEFSCR));
+   __asm__ __volatile("mtspr %1, %0;isync" :: "r"(fpscr), 
"K"(SPR_SPEFSCR));
return (old);
 }
 #endif

Modified: head/lib/msun/powerpc/fenv.h
==
--- head/lib/msun/powerpc/fenv.hThu Dec 12 16:49:55 2019
(r355655)
+++ head/lib/msun/powerpc/fenv.hThu Dec 12 17:12:18 2019
(r355656)
@@ -32,6 +32,7 @@
 #define_FENV_H_
 
 #include 
+#include 
 
 #ifndef__fenv_static
 #define__fenv_static   static
@@ -90,11 +91,15 @@ extern const fenv_t __fe_dfl_env;
 
 #ifndef _SOFT_FLOAT
 #ifdef __SPE__
-#define__mffs(__env)   __asm __volatile("mfspr %0, 512" : "=r" 
(*(__env)))
-#define__mtfsf(__env)  __asm __volatile("mtspr 512,%0" : : "r" (__env))
+#define__mffs(__env) \
+   __asm __volatile("mfspr %0, 512" : "=r" ((__env)->__bits.__reg))
+#define__mtfsf(__env) \
+   __asm __volatile("mtspr 512,%0;isync" :: "r" ((__env).__bits.__reg))
 #else
-#define__mffs(__env)   __asm __volatile("mffs %0" : "=f" (*(__env)))
-#define__mtfsf(__env)  __asm __volatile("mtfsf 255,%0" : : "f" (__env))
+#define__mffs(__env) \
+   __asm __volatile("mffs %0" : "=f" ((__env)->__d))
+#define__mtfsf(__env) \
+   __asm __volatile("mtfsf 255,%0" :: "f" ((__env).__d))
 #endif
 #else
 #define__mffs(__env)
@@ -121,9 +126,9 @@ feclearexcept(int __excepts)
 
if (__excepts & FE_INVALID)
__excepts |= FE_ALL_INVALID;
-   __mffs(&__r.__d);
+   __mffs(&__r);
__r.__bits.__reg &= ~__excepts;
-   __mtfsf(__r.__d);
+   __mtfsf(__r);
return (0);
 }
 
@@ -132,7 +137,7 @@ fegetexceptflag(fexcept_t *__flagp, int __excepts)
 {
union __fpscr __r;
 
-   __mffs(&__r.__d);
+   __mffs(&__r);
*__flagp = __r.__bits.__reg & __excepts;
return (0);
 }
@@ -144,10 +149,10 @@ fesetexceptflag(const fexcept_t *__flagp, int __except
 
if (__excepts & FE_INVALID)
__excepts |= FE_ALL_EXCEPT;
-   __mffs(&__r.__d);
+   __mffs(&__r);
__r.__bits.__reg &= ~__excepts;
__r.__bits.__reg |= *__flagp & __excepts;
-   __mtfsf(__r.__d);
+   __mtfsf(__r);
return (0);
 }
 
@@ -158,9 +163,9 @@ feraiseexcept(int __excepts)
 
if (__excepts & FE_INVALID)
__excepts |= FE_VXSOFT;
-   __mffs(&__r.__d);
+   __mffs(&__r);
__r.__bits.__reg |= __excepts;
-   __mtfsf(__r.__d);
+   __mtfsf(__r);
return (0);
 }
 
@@ -169,7 +174,7 @@ fetestexcept(int __excepts)
 {
union __fpscr __r;
 
-   __mffs(&__r.__d);
+   __mffs(&__r);
return (__r.__bits.__reg & __excepts);
 }
 
@@ -178,7 +183,7 @@ fegetround(void)
 {
union __fpscr __r;
 
-   __mffs(&__r.__d);
+   __mffs(&__r);
return (__r.__bits.__reg & _ROUND_MASK);
 }
 
@@ -189,10 +194,10 @@ 

svn commit: r355655 - head/sys/powerpc/aim

2019-12-12 Thread Brandon Bergren
Author: bdragon
Date: Thu Dec 12 16:49:55 2019
New Revision: 355655
URL: https://svnweb.freebsd.org/changeset/base/355655

Log:
  [PowerPC] Fix powerpc 32 bit build in mmu_oea64.c
  
  Due to ppc32 building mmu_oea64.c (for use when in bridge mode on a G5), we
  need to guard the new moea64_page_array_startup code behind __powerpc64__
  to avoid a compile error, since vm_offset_t is not 64-bit on ppc32.
  
  Reviewed by:  jhibbits
  Differential Revision:https://reviews.freebsd.org/D22782

Modified:
  head/sys/powerpc/aim/mmu_oea64.c

Modified: head/sys/powerpc/aim/mmu_oea64.c
==
--- head/sys/powerpc/aim/mmu_oea64.cThu Dec 12 14:52:37 2019
(r355654)
+++ head/sys/powerpc/aim/mmu_oea64.cThu Dec 12 16:49:55 2019
(r355655)
@@ -309,7 +309,9 @@ 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);
+#ifdef __powerpc64__
 static void moea64_page_array_startup(mmu_t, long);
+#endif
 
 
 static mmu_method_t moea64_methods[] = {
@@ -349,7 +351,9 @@ 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),
+#ifdef __powerpc64__
MMUMETHOD(mmu_page_array_startup,   moea64_page_array_startup),
+#endif
 
/* Internal interfaces */
MMUMETHOD(mmu_mapdev,   moea64_mapdev),
@@ -3026,6 +3030,7 @@ moea64_dump_pmap_init(mmu_t mmu, unsigned blkpgs)
 
 #endif
 
+#ifdef __powerpc64__
 static void
 moea64_map_range(mmu_t mmu, vm_offset_t va, vm_paddr_t pa, vm_size_t npages)
 {
@@ -3119,3 +3124,4 @@ moea64_page_array_startup(mmu_t mmu, long pages)
vm_page_array = (vm_page_t)vm_page_base;
vm_page_array_size = pages;
 }
+#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: r355654 - in head/lib/libpmc/pmu-events/arch/s390: cf_z13 cf_z14

2019-12-12 Thread Ed Maste
Author: emaste
Date: Thu Dec 12 14:52:37 2019
New Revision: 355654
URL: https://svnweb.freebsd.org/changeset/base/355654

Log:
  libpmc: remove undesired prefix from two s390 counters
  
  Two counters included a prefix 'Counter:###\tName:XXX' in their
  descriptions that appears to be a leftover from some conversion
  process.  Remove them.
  
  Found because a json validator tripped over the tab in the description.

Modified:
  head/lib/libpmc/pmu-events/arch/s390/cf_z13/extended.json
  head/lib/libpmc/pmu-events/arch/s390/cf_z14/extended.json

Modified: head/lib/libpmc/pmu-events/arch/s390/cf_z13/extended.json
==
--- head/lib/libpmc/pmu-events/arch/s390/cf_z13/extended.json   Thu Dec 12 
13:48:23 2019(r355653)
+++ head/lib/libpmc/pmu-events/arch/s390/cf_z13/extended.json   Thu Dec 12 
14:52:37 2019(r355654)
@@ -27,7 +27,7 @@
"EventCode": "132",
"EventName": "DTLB1_GPAGE_WRITES",
"BriefDescription": "DTLB1 Two-Gigabyte Page Writes",
-   "PublicDescription": "Counter:132   Name:DTLB1_GPAGE_WRITES 
A translation entry has been written to the Level-1 Data Translation Lookaside 
Buffer for a two-gigabyte page."
+   "PublicDescription": "A translation entry has been written to 
the Level-1 Data Translation Lookaside Buffer for a two-gigabyte page."
},
{
"EventCode": "133",

Modified: head/lib/libpmc/pmu-events/arch/s390/cf_z14/extended.json
==
--- head/lib/libpmc/pmu-events/arch/s390/cf_z14/extended.json   Thu Dec 12 
13:48:23 2019(r355653)
+++ head/lib/libpmc/pmu-events/arch/s390/cf_z14/extended.json   Thu Dec 12 
14:52:37 2019(r355654)
@@ -3,7 +3,7 @@
"EventCode": "128",
"EventName": "L1D_RO_EXCL_WRITES",
"BriefDescription": "L1D Read-only Exclusive Writes",
-   "PublicDescription": "Counter:128   Name:L1D_RO_EXCL_WRITES 
A directory write to the Level-1 Data cache where the line was originally in a 
Read-Only state in the cache but has been updated to be in the Exclusive state 
that allows stores to the cache line"
+   "PublicDescription": "A directory write to the Level-1 Data 
cache where the line was originally in a Read-Only state in the cache but has 
been updated to be in the Exclusive state that allows stores to the cache line"
},
{
"EventCode": "129",
___
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: r355653 - in stable/11/sys/dev/mlx5: . mlx5_core mlx5_en

2019-12-12 Thread Konstantin Belousov
Author: kib
Date: Thu Dec 12 13:48:23 2019
New Revision: 355653
URL: https://svnweb.freebsd.org/changeset/base/355653

Log:
  MFC r355422:
  mlx5: Do not poke hardware for statistic after teardown is started.

Modified:
  stable/11/sys/dev/mlx5/driver.h
  stable/11/sys/dev/mlx5/mlx5_core/mlx5_main.c
  stable/11/sys/dev/mlx5/mlx5_en/mlx5_en_main.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/dev/mlx5/driver.h
==
--- stable/11/sys/dev/mlx5/driver.h Thu Dec 12 13:47:02 2019
(r355652)
+++ stable/11/sys/dev/mlx5/driver.h Thu Dec 12 13:48:23 2019
(r355653)
@@ -614,7 +614,8 @@ enum mlx5_device_state {
 };
 
 enum mlx5_interface_state {
-   MLX5_INTERFACE_STATE_UP,
+   MLX5_INTERFACE_STATE_UP = 0x1,
+   MLX5_INTERFACE_STATE_TEARDOWN = 0x2,
 };
 
 enum mlx5_pci_status {

Modified: stable/11/sys/dev/mlx5/mlx5_core/mlx5_main.c
==
--- stable/11/sys/dev/mlx5/mlx5_core/mlx5_main.cThu Dec 12 13:47:02 
2019(r355652)
+++ stable/11/sys/dev/mlx5/mlx5_core/mlx5_main.cThu Dec 12 13:48:23 
2019(r355653)
@@ -1588,6 +1588,8 @@ static void shutdown_one(struct pci_dev *pdev)
/* enter polling mode */
mlx5_cmd_use_polling(dev);
 
+   set_bit(MLX5_INTERFACE_STATE_TEARDOWN, >intf_state);
+
/* disable all interrupts */
mlx5_disable_interrupts(dev);
 

Modified: stable/11/sys/dev/mlx5/mlx5_en/mlx5_en_main.c
==
--- stable/11/sys/dev/mlx5/mlx5_en/mlx5_en_main.c   Thu Dec 12 13:47:02 
2019(r355652)
+++ stable/11/sys/dev/mlx5/mlx5_en/mlx5_en_main.c   Thu Dec 12 13:48:23 
2019(r355653)
@@ -1037,9 +1037,10 @@ mlx5e_update_stats_work(struct work_struct *work)
 {
struct mlx5e_priv *priv;
 
-   priv  = container_of(work, struct mlx5e_priv, update_stats_work);
+   priv = container_of(work, struct mlx5e_priv, update_stats_work);
PRIV_LOCK(priv);
-   if (test_bit(MLX5E_STATE_OPENED, >state) != 0)
+   if (test_bit(MLX5E_STATE_OPENED, >state) != 0 &&
+   !test_bit(MLX5_INTERFACE_STATE_TEARDOWN, >mdev->intf_state))
mlx5e_update_stats_locked(priv);
PRIV_UNLOCK(priv);
 }
___
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: r355652 - in stable/12/sys/dev/mlx5: . mlx5_core mlx5_en

2019-12-12 Thread Konstantin Belousov
Author: kib
Date: Thu Dec 12 13:47:02 2019
New Revision: 355652
URL: https://svnweb.freebsd.org/changeset/base/355652

Log:
  MFC r355422:
  mlx5: Do not poke hardware for statistic after teardown is started.

Modified:
  stable/12/sys/dev/mlx5/driver.h
  stable/12/sys/dev/mlx5/mlx5_core/mlx5_main.c
  stable/12/sys/dev/mlx5/mlx5_en/mlx5_en_main.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/dev/mlx5/driver.h
==
--- stable/12/sys/dev/mlx5/driver.h Thu Dec 12 13:46:02 2019
(r355651)
+++ stable/12/sys/dev/mlx5/driver.h Thu Dec 12 13:47:02 2019
(r355652)
@@ -640,7 +640,8 @@ enum mlx5_device_state {
 };
 
 enum mlx5_interface_state {
-   MLX5_INTERFACE_STATE_UP,
+   MLX5_INTERFACE_STATE_UP = 0x1,
+   MLX5_INTERFACE_STATE_TEARDOWN = 0x2,
 };
 
 enum mlx5_pci_status {

Modified: stable/12/sys/dev/mlx5/mlx5_core/mlx5_main.c
==
--- stable/12/sys/dev/mlx5/mlx5_core/mlx5_main.cThu Dec 12 13:46:02 
2019(r355651)
+++ stable/12/sys/dev/mlx5/mlx5_core/mlx5_main.cThu Dec 12 13:47:02 
2019(r355652)
@@ -1606,6 +1606,8 @@ static void shutdown_one(struct pci_dev *pdev)
/* enter polling mode */
mlx5_cmd_use_polling(dev);
 
+   set_bit(MLX5_INTERFACE_STATE_TEARDOWN, >intf_state);
+
/* disable all interrupts */
mlx5_disable_interrupts(dev);
 

Modified: stable/12/sys/dev/mlx5/mlx5_en/mlx5_en_main.c
==
--- stable/12/sys/dev/mlx5/mlx5_en/mlx5_en_main.c   Thu Dec 12 13:46:02 
2019(r355651)
+++ stable/12/sys/dev/mlx5/mlx5_en/mlx5_en_main.c   Thu Dec 12 13:47:02 
2019(r355652)
@@ -1037,9 +1037,10 @@ mlx5e_update_stats_work(struct work_struct *work)
 {
struct mlx5e_priv *priv;
 
-   priv  = container_of(work, struct mlx5e_priv, update_stats_work);
+   priv = container_of(work, struct mlx5e_priv, update_stats_work);
PRIV_LOCK(priv);
-   if (test_bit(MLX5E_STATE_OPENED, >state) != 0)
+   if (test_bit(MLX5E_STATE_OPENED, >state) != 0 &&
+   !test_bit(MLX5_INTERFACE_STATE_TEARDOWN, >mdev->intf_state))
mlx5e_update_stats_locked(priv);
PRIV_UNLOCK(priv);
 }
___
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: r355651 - stable/12/sys/fs/tmpfs

2019-12-12 Thread Konstantin Belousov
Author: kib
Date: Thu Dec 12 13:46:02 2019
New Revision: 355651
URL: https://svnweb.freebsd.org/changeset/base/355651

Log:
  MFC r355407:
  Stop using per-mount tmpfs zones.

Modified:
  stable/12/sys/fs/tmpfs/tmpfs.h
  stable/12/sys/fs/tmpfs/tmpfs_subr.c
  stable/12/sys/fs/tmpfs/tmpfs_vfsops.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/fs/tmpfs/tmpfs.h
==
--- stable/12/sys/fs/tmpfs/tmpfs.h  Thu Dec 12 13:28:46 2019
(r355650)
+++ stable/12/sys/fs/tmpfs/tmpfs.h  Thu Dec 12 13:46:02 2019
(r355651)
@@ -378,10 +378,6 @@ struct tmpfs_mount {
/* All node lock to protect the node list and tmp_pages_used. */
struct mtx  tm_allnode_lock;
 
-   /* Zones used to store file system meta data, per tmpfs mount. */
-   uma_zone_t  tm_dirent_pool;
-   uma_zone_t  tm_node_pool;
-
/* Read-only status. */
booltm_ronly;
/* Do not use namecache. */
@@ -491,8 +487,9 @@ struct tmpfs_dirent *tmpfs_dir_next(struct tmpfs_node 
 #define TMPFS_PAGES_MINRESERVED(4 * 1024 * 1024 / PAGE_SIZE)
 
 size_t tmpfs_mem_avail(void);
-
 size_t tmpfs_pages_used(struct tmpfs_mount *tmp);
+void tmpfs_subr_init(void);
+void tmpfs_subr_uninit(void);
 
 #endif
 

Modified: stable/12/sys/fs/tmpfs/tmpfs_subr.c
==
--- stable/12/sys/fs/tmpfs/tmpfs_subr.c Thu Dec 12 13:28:46 2019
(r355650)
+++ stable/12/sys/fs/tmpfs/tmpfs_subr.c Thu Dec 12 13:46:02 2019
(r355651)
@@ -72,7 +72,74 @@ SYSCTL_NODE(_vfs, OID_AUTO, tmpfs, CTLFLAG_RW, 0, "tmp
 
 static long tmpfs_pages_reserved = TMPFS_PAGES_MINRESERVED;
 
+static uma_zone_t tmpfs_dirent_pool;
+static uma_zone_t tmpfs_node_pool;
+
 static int
+tmpfs_node_ctor(void *mem, int size, void *arg, int flags)
+{
+   struct tmpfs_node *node;
+
+   node = mem;
+   node->tn_gen++;
+   node->tn_size = 0;
+   node->tn_status = 0;
+   node->tn_flags = 0;
+   node->tn_links = 0;
+   node->tn_vnode = NULL;
+   node->tn_vpstate = 0;
+   return (0);
+}
+
+static void
+tmpfs_node_dtor(void *mem, int size, void *arg)
+{
+   struct tmpfs_node *node;
+
+   node = mem;
+   node->tn_type = VNON;
+}
+
+static int
+tmpfs_node_init(void *mem, int size, int flags)
+{
+   struct tmpfs_node *node;
+
+   node = mem;
+   node->tn_id = 0;
+   mtx_init(>tn_interlock, "tmpfsni", NULL, MTX_DEF);
+   node->tn_gen = arc4random();
+   return (0);
+}
+
+static void
+tmpfs_node_fini(void *mem, int size)
+{
+   struct tmpfs_node *node;
+
+   node = mem;
+   mtx_destroy(>tn_interlock);
+}
+
+void
+tmpfs_subr_init(void)
+{
+   tmpfs_dirent_pool = uma_zcreate("TMPFS dirent",
+   sizeof(struct tmpfs_dirent), NULL, NULL, NULL, NULL,
+   UMA_ALIGN_PTR, 0);
+   tmpfs_node_pool = uma_zcreate("TMPFS node",
+   sizeof(struct tmpfs_node), tmpfs_node_ctor, tmpfs_node_dtor,
+   tmpfs_node_init, tmpfs_node_fini, UMA_ALIGN_PTR, 0);
+}
+
+void
+tmpfs_subr_uninit(void)
+{
+   uma_zdestroy(tmpfs_node_pool);
+   uma_zdestroy(tmpfs_dirent_pool);
+}
+
+static int
 sysctl_mem_reserved(SYSCTL_HANDLER_ARGS)
 {
int error;
@@ -221,8 +288,7 @@ tmpfs_alloc_node(struct mount *mp, struct tmpfs_mount 
if ((mp->mnt_kern_flag & MNT_RDONLY) != 0)
return (EROFS);
 
-   nnode = (struct tmpfs_node *)uma_zalloc_arg(tmp->tm_node_pool, tmp,
-   M_WAITOK);
+   nnode = uma_zalloc_arg(tmpfs_node_pool, tmp, M_WAITOK);
 
/* Generic initialization. */
nnode->tn_type = type;
@@ -370,7 +436,7 @@ tmpfs_free_node_locked(struct tmpfs_mount *tmp, struct
panic("tmpfs_free_node: type %p %d", node, (int)node->tn_type);
}
 
-   uma_zfree(tmp->tm_node_pool, node);
+   uma_zfree(tmpfs_node_pool, node);
TMPFS_LOCK(tmp);
tmpfs_free_tmp(tmp);
return (true);
@@ -437,7 +503,7 @@ tmpfs_alloc_dirent(struct tmpfs_mount *tmp, struct tmp
 {
struct tmpfs_dirent *nde;
 
-   nde = uma_zalloc(tmp->tm_dirent_pool, M_WAITOK);
+   nde = uma_zalloc(tmpfs_dirent_pool, M_WAITOK);
nde->td_node = node;
if (name != NULL) {
nde->ud.td_name = malloc(len, M_TMPFSNAME, M_WAITOK);
@@ -473,7 +539,7 @@ tmpfs_free_dirent(struct tmpfs_mount *tmp, struct tmpf
}
if (!tmpfs_dirent_duphead(de) && de->ud.td_name != NULL)
free(de->ud.td_name, M_TMPFSNAME);
-   uma_zfree(tmp->tm_dirent_pool, de);
+   uma_zfree(tmpfs_dirent_pool, de);
 }
 
 void

Modified: stable/12/sys/fs/tmpfs/tmpfs_vfsops.c
==
--- stable/12/sys/fs/tmpfs/tmpfs_vfsops.c   Thu Dec 12 13:28:46 2019
(r355650)
+++ 

svn commit: r355650 - in head/sys: modules/ipfw_nat64 netpfil/ipfw/nat64

2019-12-12 Thread Andrey V. Elsukov
Author: ae
Date: Thu Dec 12 13:28:46 2019
New Revision: 355650
URL: https://svnweb.freebsd.org/changeset/base/355650

Log:
  Follow RFC 4443 p2.2 and always use own addresses for reflected ICMPv6
  datagrams.
  
  Previously destination address from original datagram was used. That
  looked confusing, especially in the traceroute6 output.
  Also honor IPSTEALTH kernel option and do TTL/HLIM decrementing only
  when stealth mode is disabled.
  
  Reported by:  Marco van Tol 
  Reviewed by:  melifaro
  MFC after:2 weeks
  Sponsored by: Yandex LLC
  Differential Revision:https://reviews.freebsd.org/D22631

Modified:
  head/sys/modules/ipfw_nat64/Makefile
  head/sys/netpfil/ipfw/nat64/nat64_translate.c

Modified: head/sys/modules/ipfw_nat64/Makefile
==
--- head/sys/modules/ipfw_nat64/MakefileThu Dec 12 13:21:43 2019
(r355649)
+++ head/sys/modules/ipfw_nat64/MakefileThu Dec 12 13:28:46 2019
(r355650)
@@ -7,6 +7,7 @@ SRCS=   ip_fw_nat64.c nat64_translate.c
 SRCS+= nat64clat.c nat64clat_control.c
 SRCS+= nat64lsn.c nat64lsn_control.c
 SRCS+= nat64stl.c nat64stl_control.c
+SRCS+= opt_ipstealth.h
 
 CFLAGS+= -I${SRCTOP}/sys/contrib/ck/include
 

Modified: head/sys/netpfil/ipfw/nat64/nat64_translate.c
==
--- head/sys/netpfil/ipfw/nat64/nat64_translate.c   Thu Dec 12 13:21:43 
2019(r355649)
+++ head/sys/netpfil/ipfw/nat64/nat64_translate.c   Thu Dec 12 13:28:46 
2019(r355650)
@@ -29,6 +29,8 @@
 #include 
 __FBSDID("$FreeBSD$");
 
+#include "opt_ipstealth.h"
+
 #include 
 #include 
 #include 
@@ -101,14 +103,39 @@ static const struct nat64_methods nat64_direct = {
.output = nat64_direct_output,
.output_one = nat64_direct_output_one
 };
-VNET_DEFINE_STATIC(const struct nat64_methods *, nat64out) = _netisr;
-#defineV_nat64out  VNET(nat64out)
 
+/* These variables should be initialized explicitly on module loading */
+VNET_DEFINE_STATIC(const struct nat64_methods *, nat64out);
+VNET_DEFINE_STATIC(const int *, nat64ipstealth);
+VNET_DEFINE_STATIC(const int *, nat64ip6stealth);
+#defineV_nat64out  VNET(nat64out)
+#defineV_nat64ipstealthVNET(nat64ipstealth)
+#defineV_nat64ip6stealth   VNET(nat64ip6stealth)
+
+static const int stealth_on = 1;
+#ifndef IPSTEALTH
+static const int stealth_off = 0;
+#endif
+
 void
 nat64_set_output_method(int direct)
 {
 
-   V_nat64out = direct != 0 ? _direct: _netisr;
+   if (direct != 0) {
+   V_nat64out = _direct;
+#ifdef IPSTEALTH
+   /* Honor corresponding variables, if IPSTEALTH is defined */
+   V_nat64ipstealth = _ipstealth;
+   V_nat64ip6stealth = _ip6stealth;
+#else
+   /* otherwise we need to decrement HLIM/TTL for direct case */
+   V_nat64ipstealth = V_nat64ip6stealth = _off;
+#endif
+   } else {
+   V_nat64out = _netisr;
+   /* Leave TTL/HLIM decrementing to forwarding code */
+   V_nat64ipstealth = V_nat64ip6stealth = _on;
+   }
 }
 
 int
@@ -486,8 +513,7 @@ nat64_init_ip4hdr(const struct ip6_hdr *ip6, const str
ip->ip_tos = (ntohl(ip6->ip6_flow) >> 20) & 0xff;
ip->ip_len = htons(sizeof(*ip) + plen);
ip->ip_ttl = ip6->ip6_hlim;
-   /* Forwarding code will decrement TTL for netisr based output. */
-   if (V_nat64out == _direct)
+   if (*V_nat64ip6stealth == 0)
ip->ip_ttl -= IPV6_HLIMDEC;
ip->ip_sum = 0;
ip->ip_p = (proto == IPPROTO_ICMPV6) ? IPPROTO_ICMP: proto;
@@ -623,18 +649,18 @@ nat64_icmp6_reflect(struct mbuf *m, uint8_t type, uint
struct icmp6_hdr *icmp6;
struct ip6_hdr *ip6, *oip6;
struct mbuf *n;
-   int len, plen;
+   int len, plen, proto;
 
len = 0;
-   plen = nat64_getlasthdr(m, );
-   if (plen < 0) {
+   proto = nat64_getlasthdr(m, );
+   if (proto < 0) {
DPRINTF(DP_DROPS, "mbuf isn't contigious");
goto freeit;
}
/*
 * Do not send ICMPv6 in reply to ICMPv6 errors.
 */
-   if (plen == IPPROTO_ICMPV6) {
+   if (proto == IPPROTO_ICMPV6) {
if (m->m_len < len + sizeof(*icmp6)) {
DPRINTF(DP_DROPS, "mbuf isn't contigious");
goto freeit;
@@ -646,6 +672,21 @@ nat64_icmp6_reflect(struct mbuf *m, uint8_t type, uint
"ICMPv6 errors");
goto freeit;
}
+   /*
+* If there are extra headers between IPv6 and ICMPv6,
+* strip off them.
+*/
+   if (len > sizeof(struct ip6_hdr)) {
+   /*
+* NOTE: ipfw_chk already did m_pullup() and it is
+  

svn commit: r355649 - head/sys/arm64/rockchip

2019-12-12 Thread Emmanuel Vadot
Author: manu
Date: Thu Dec 12 13:21:43 2019
New Revision: 355649
URL: https://svnweb.freebsd.org/changeset/base/355649

Log:
  arm64: rockchip: rk_pinctrl: Fix parse_bias for RK3399
  
  Only bank 0 and bank 2 are different than other rockchip SoC, fix this.
  While here remove some debug printfs that where added in r355648
  
  MFC after:3 days
  X-MFC-With:   r355648

Modified:
  head/sys/arm64/rockchip/rk_pinctrl.c

Modified: head/sys/arm64/rockchip/rk_pinctrl.c
==
--- head/sys/arm64/rockchip/rk_pinctrl.cThu Dec 12 13:02:22 2019
(r355648)
+++ head/sys/arm64/rockchip/rk_pinctrl.cThu Dec 12 13:21:43 2019
(r355649)
@@ -100,7 +100,7 @@ struct rk_pinctrl_conf {
uint32_tngpio_bank;
uint32_t(*get_pd_offset)(struct rk_pinctrl_softc *, uint32_t);
struct syscon   *(*get_syscon)(struct rk_pinctrl_softc *, uint32_t);
-   int (*parse_bias)(phandle_t node);
+   int (*parse_bias)(phandle_t, int);
 };
 
 struct rk_pinctrl_softc {
@@ -372,7 +372,7 @@ rk3288_get_syscon(struct rk_pinctrl_softc *sc, uint32_
 }
 
 static int
-rk3288_parse_bias(phandle_t node)
+rk3288_parse_bias(phandle_t node, int bank)
 {
if (OF_hasprop(node, "bias-disable"))
return (0);
@@ -627,24 +627,38 @@ rk3399_get_pd_offset(struct rk_pinctrl_softc *sc, uint
 static struct syscon *
 rk3399_get_syscon(struct rk_pinctrl_softc *sc, uint32_t bank)
 {
-   if (bank < 2) {
-   device_printf(sc->dev, "%s: Using PMU GRF\n", __func__);
+   if (bank < 2)
return (sc->pmu);
-   }
 
-   device_printf(sc->dev, "%s: Using GRF\n", __func__);
return (sc->grf);
 }
 
 static int
-rk3399_parse_bias(phandle_t node)
+rk3399_parse_bias(phandle_t node, int bank)
 {
+   int pullup, pulldown;
+
if (OF_hasprop(node, "bias-disable"))
return (0);
+
+   switch (bank) {
+   case 0:
+   case 2:
+   pullup = 3;
+   pulldown = 1;
+   break;
+   case 1:
+   case 3:
+   case 4:
+   pullup = 1;
+   pulldown = 2;
+   break;
+   }
+
if (OF_hasprop(node, "bias-pull-up"))
-   return (3);
+   return (pullup);
if (OF_hasprop(node, "bias-pull-down"))
-   return (1);
+   return (pulldown);
 
return (-1);
 }
@@ -862,7 +876,7 @@ rk_pinctrl_configure_pin(struct rk_pinctrl_softc *sc, 
SYSCON_MODIFY_4(syscon, reg, mask, function << bit | (mask << 16));
 
/* Pull-Up/Down */
-   bias = sc->conf->parse_bias(pin_conf);
+   bias = sc->conf->parse_bias(pin_conf, bank);
if (bias >= 0) {
reg = sc->conf->get_pd_offset(sc, bank);
 
___
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: r355648 - head/sys/arm64/rockchip

2019-12-12 Thread Emmanuel Vadot
Author: manu
Date: Thu Dec 12 13:02:22 2019
New Revision: 355648
URL: https://svnweb.freebsd.org/changeset/base/355648

Log:
  arm64: rockchip: rk_pinctrl: Add bias parsing based on the SoC type
  
  Not all rockchip have the same value for pullup/pulldown so add a function
  per SoC and call the right one to have the proper value.
  
  MFC after:3 days

Modified:
  head/sys/arm64/rockchip/rk_pinctrl.c

Modified: head/sys/arm64/rockchip/rk_pinctrl.c
==
--- head/sys/arm64/rockchip/rk_pinctrl.cThu Dec 12 05:11:53 2019
(r355647)
+++ head/sys/arm64/rockchip/rk_pinctrl.cThu Dec 12 13:02:22 2019
(r355648)
@@ -100,6 +100,7 @@ struct rk_pinctrl_conf {
uint32_tngpio_bank;
uint32_t(*get_pd_offset)(struct rk_pinctrl_softc *, uint32_t);
struct syscon   *(*get_syscon)(struct rk_pinctrl_softc *, uint32_t);
+   int (*parse_bias)(phandle_t node);
 };
 
 struct rk_pinctrl_softc {
@@ -370,6 +371,19 @@ rk3288_get_syscon(struct rk_pinctrl_softc *sc, uint32_
return (sc->grf);
 }
 
+static int
+rk3288_parse_bias(phandle_t node)
+{
+   if (OF_hasprop(node, "bias-disable"))
+   return (0);
+   if (OF_hasprop(node, "bias-pull-up"))
+   return (1);
+   if (OF_hasprop(node, "bias-pull-down"))
+   return (2);
+
+   return (-1);
+}
+
 struct rk_pinctrl_conf rk3288_conf = {
.iomux_conf = rk3288_iomux_bank,
.iomux_nbanks = nitems(rk3288_iomux_bank),
@@ -381,6 +395,7 @@ struct rk_pinctrl_conf rk3288_conf = {
.ngpio_bank = nitems(rk3288_gpio_bank),
.get_pd_offset = rk3288_get_pd_offset,
.get_syscon = rk3288_get_syscon,
+   .parse_bias = rk3288_parse_bias,
 };
 
 static struct rk_pinctrl_gpio rk3328_gpio_bank[] = {
@@ -524,6 +539,7 @@ struct rk_pinctrl_conf rk3328_conf = {
.ngpio_bank = nitems(rk3328_gpio_bank),
.get_pd_offset = rk3328_get_pd_offset,
.get_syscon = rk3328_get_syscon,
+   .parse_bias = rk3288_parse_bias,
 };
 
 static struct rk_pinctrl_gpio rk3399_gpio_bank[] = {
@@ -611,12 +627,28 @@ rk3399_get_pd_offset(struct rk_pinctrl_softc *sc, uint
 static struct syscon *
 rk3399_get_syscon(struct rk_pinctrl_softc *sc, uint32_t bank)
 {
-   if (bank < 2)
+   if (bank < 2) {
+   device_printf(sc->dev, "%s: Using PMU GRF\n", __func__);
return (sc->pmu);
+   }
 
+   device_printf(sc->dev, "%s: Using GRF\n", __func__);
return (sc->grf);
 }
 
+static int
+rk3399_parse_bias(phandle_t node)
+{
+   if (OF_hasprop(node, "bias-disable"))
+   return (0);
+   if (OF_hasprop(node, "bias-pull-up"))
+   return (3);
+   if (OF_hasprop(node, "bias-pull-down"))
+   return (1);
+
+   return (-1);
+}
+
 struct rk_pinctrl_conf rk3399_conf = {
.iomux_conf = rk3399_iomux_bank,
.iomux_nbanks = nitems(rk3399_iomux_bank),
@@ -628,6 +660,7 @@ struct rk_pinctrl_conf rk3399_conf = {
.ngpio_bank = nitems(rk3399_gpio_bank),
.get_pd_offset = rk3399_get_pd_offset,
.get_syscon = rk3399_get_syscon,
+   .parse_bias = rk3399_parse_bias,
 };
 
 static struct ofw_compat_data compat_data[] = {
@@ -638,19 +671,6 @@ static struct ofw_compat_data compat_data[] = {
 };
 
 static int
-rk_pinctrl_parse_bias(phandle_t node)
-{
-   if (OF_hasprop(node, "bias-disable"))
-   return (0);
-   if (OF_hasprop(node, "bias-pull-up"))
-   return (1);
-   if (OF_hasprop(node, "bias-pull-down"))
-   return (2);
-
-   return (-1);
-}
-
-static int
 rk_pinctrl_parse_drive(struct rk_pinctrl_softc *sc, phandle_t node,
   uint32_t bank, uint32_t subbank, uint32_t *drive, uint32_t *offset)
 {
@@ -842,7 +862,7 @@ rk_pinctrl_configure_pin(struct rk_pinctrl_softc *sc, 
SYSCON_MODIFY_4(syscon, reg, mask, function << bit | (mask << 16));
 
/* Pull-Up/Down */
-   bias = rk_pinctrl_parse_bias(pin_conf);
+   bias = sc->conf->parse_bias(pin_conf);
if (bias >= 0) {
reg = sc->conf->get_pd_offset(sc, bank);
 
___
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"