svn commit: r365499 - in head: contrib/nvi contrib/nvi/catalog contrib/nvi/cl contrib/nvi/common contrib/nvi/docs contrib/nvi/ex contrib/nvi/files contrib/nvi/man contrib/nvi/vi usr.bin/vi usr.bin/...

2020-09-09 Thread Baptiste Daroussin
Author: bapt
Date: Wed Sep  9 08:38:47 2020
New Revision: 365499
URL: https://svnweb.freebsd.org/changeset/base/365499

Log:
  Update nvi to 2.2.0
  
  Main changes:
  * Vim-style expandtab option
  * Provides Turkish translation
  * Backspace now deletes \ rather than being escaped
  * T during motion commands is now VI-compatible
  * Encoding related fixes, such as UTF-8 detection
  * Fixed a number of memory management issues
  
  MFC after:3 weeks

Added:
  head/contrib/nvi/.gitignore
 - copied unchanged from r365495, vendor/nvi/dist/.gitignore
  head/contrib/nvi/CMakeLists.txt
 - copied unchanged from r365495, vendor/nvi/dist/CMakeLists.txt
  head/contrib/nvi/catalog/tr_TR.ISO8859-9.base
 - copied unchanged from r365495, 
vendor/nvi/dist/catalog/tr_TR.ISO8859-9.base
  head/contrib/nvi/catalog/tr_TR.ISO8859-9.owner
 - copied unchanged from r365495, 
vendor/nvi/dist/catalog/tr_TR.ISO8859-9.owner
  head/contrib/nvi/catalog/tr_TR.UTF-8.base
 - copied unchanged from r365495, vendor/nvi/dist/catalog/tr_TR.UTF-8.base
  head/contrib/nvi/catalog/tr_TR.UTF-8.owner
 - copied unchanged from r365495, vendor/nvi/dist/catalog/tr_TR.UTF-8.owner
  head/contrib/nvi/files/
 - copied from r365495, vendor/nvi/dist/files/
  head/contrib/nvi/man/
 - copied from r365495, vendor/nvi/dist/man/
Replaced:
  head/contrib/nvi/cl/extern.h
 - copied unchanged from r365497, vendor/nvi/dist/cl/extern.h
  head/contrib/nvi/common/extern.h
 - copied unchanged from r365497, vendor/nvi/dist/common/extern.h
  head/contrib/nvi/common/options_def.h
 - copied unchanged from r365497, vendor/nvi/dist/common/options_def.h
  head/contrib/nvi/ex/ex_def.h
 - copied unchanged from r365497, vendor/nvi/dist/ex/ex_def.h
  head/contrib/nvi/ex/extern.h
 - copied unchanged from r365497, vendor/nvi/dist/ex/extern.h
  head/contrib/nvi/ex/version.h
 - copied unchanged from r365497, vendor/nvi/dist/ex/version.h
  head/contrib/nvi/vi/extern.h
 - copied unchanged from r365497, vendor/nvi/dist/vi/extern.h
Deleted:
  head/contrib/nvi/docs/
Modified:
  head/contrib/nvi/LICENSE
  head/contrib/nvi/README
  head/contrib/nvi/catalog/Makefile
  head/contrib/nvi/catalog/README
  head/contrib/nvi/catalog/dump.c
  head/contrib/nvi/cl/README.signal
  head/contrib/nvi/cl/cl.h
  head/contrib/nvi/cl/cl_funcs.c
  head/contrib/nvi/cl/cl_main.c
  head/contrib/nvi/cl/cl_read.c
  head/contrib/nvi/cl/cl_screen.c
  head/contrib/nvi/cl/cl_term.c
  head/contrib/nvi/common/args.h
  head/contrib/nvi/common/common.h
  head/contrib/nvi/common/conv.c
  head/contrib/nvi/common/conv.h
  head/contrib/nvi/common/cut.c
  head/contrib/nvi/common/cut.h
  head/contrib/nvi/common/delete.c
  head/contrib/nvi/common/encoding.c
  head/contrib/nvi/common/exf.c
  head/contrib/nvi/common/exf.h
  head/contrib/nvi/common/gs.h
  head/contrib/nvi/common/key.c
  head/contrib/nvi/common/key.h
  head/contrib/nvi/common/line.c
  head/contrib/nvi/common/log.c
  head/contrib/nvi/common/log.h
  head/contrib/nvi/common/main.c
  head/contrib/nvi/common/mark.c
  head/contrib/nvi/common/mark.h
  head/contrib/nvi/common/mem.h
  head/contrib/nvi/common/msg.c
  head/contrib/nvi/common/msg.h
  head/contrib/nvi/common/multibyte.h
  head/contrib/nvi/common/options.c
  head/contrib/nvi/common/options.h
  head/contrib/nvi/common/options_f.c
  head/contrib/nvi/common/put.c
  head/contrib/nvi/common/recover.c
  head/contrib/nvi/common/screen.c
  head/contrib/nvi/common/screen.h
  head/contrib/nvi/common/search.c
  head/contrib/nvi/common/seq.c
  head/contrib/nvi/common/seq.h
  head/contrib/nvi/common/util.c
  head/contrib/nvi/common/util.h
  head/contrib/nvi/ex/ex.c
  head/contrib/nvi/ex/ex.h
  head/contrib/nvi/ex/ex_abbrev.c
  head/contrib/nvi/ex/ex_append.c
  head/contrib/nvi/ex/ex_args.c
  head/contrib/nvi/ex/ex_argv.c
  head/contrib/nvi/ex/ex_at.c
  head/contrib/nvi/ex/ex_bang.c
  head/contrib/nvi/ex/ex_cd.c
  head/contrib/nvi/ex/ex_cmd.c
  head/contrib/nvi/ex/ex_cscope.c
  head/contrib/nvi/ex/ex_delete.c
  head/contrib/nvi/ex/ex_display.c
  head/contrib/nvi/ex/ex_edit.c
  head/contrib/nvi/ex/ex_equal.c
  head/contrib/nvi/ex/ex_file.c
  head/contrib/nvi/ex/ex_filter.c
  head/contrib/nvi/ex/ex_global.c
  head/contrib/nvi/ex/ex_init.c
  head/contrib/nvi/ex/ex_join.c
  head/contrib/nvi/ex/ex_map.c
  head/contrib/nvi/ex/ex_mark.c
  head/contrib/nvi/ex/ex_mkexrc.c
  head/contrib/nvi/ex/ex_move.c
  head/contrib/nvi/ex/ex_open.c
  head/contrib/nvi/ex/ex_preserve.c
  head/contrib/nvi/ex/ex_print.c
  head/contrib/nvi/ex/ex_put.c
  head/contrib/nvi/ex/ex_quit.c
  head/contrib/nvi/ex/ex_read.c
  head/contrib/nvi/ex/ex_screen.c
  head/contrib/nvi/ex/ex_script.c
  head/contrib/nvi/ex/ex_set.c
  head/contrib/nvi/ex/ex_shell.c
  head/contrib/nvi/ex/ex_shift.c
  head/contrib/nvi/ex/ex_source.c
  head/contrib/nvi/ex/ex_stop.c
  head/contrib/nvi/ex/ex_subst.c
  head/contrib/nvi/ex/ex_tag.c
  head/contrib/nvi/ex/ex_txt.c
  head/contrib/nvi/ex/ex_undo.c
  head/contrib/nvi/ex/ex_usag

svn commit: r365500 - head/usr.sbin/certctl

2020-09-09 Thread Kyle Evans
Author: kevans
Date: Wed Sep  9 09:08:09 2020
New Revision: 365500
URL: https://svnweb.freebsd.org/changeset/base/365500

Log:
  certctl: fix hashed link generation with duplicate subjects
  
  Currently, certctl rehash will just keep clobbering .0 rather than
  incrementing the suffix upon encountering a duplicate. Do this, and do it
  for blacklisted certs as well.
  
  This also improves the situation with the blacklist to be a little less
  flakey, comparing cert fingerprints for all certs with a matching subject
  hash in the blacklist to determine if the cert we're looking at can be
  installed.
  
  Future work needs to completely revamp the blacklist to align more with how
  it's described in PR 246614. In particular, /etc/ssl/blacklisted should go
  away to avoid potential confusion -- OpenSSL will not read it, it's
  basically certctl internal.
  
  PR:   246614
  Reviewed by:  Michael Osipov 
  Tested by:Michael Osipov
  With suggestions from:Michael Osipov
  MFC after:1 week
  Differential Revision:https://reviews.freebsd.org/D26167

Modified:
  head/usr.sbin/certctl/certctl.sh

Modified: head/usr.sbin/certctl/certctl.sh
==
--- head/usr.sbin/certctl/certctl.shWed Sep  9 08:38:47 2020
(r365499)
+++ head/usr.sbin/certctl/certctl.shWed Sep  9 09:08:09 2020
(r365500)
@@ -30,7 +30,7 @@
  CONFIGURATION
 
 : ${DESTDIR:=}
-: ${FILEPAT:="\.pem$|\.crt$|\.cer$|\.crl$|\.0$"}
+: ${FILEPAT:="\.pem$|\.crt$|\.cer$|\.crl$"}
 : ${VERBOSE:=0}
 
  GLOBALS
@@ -56,31 +56,58 @@ do_hash()
fi
 }
 
+get_decimal()
+{
+   local checkdir hash decimal
+
+   checkdir=$1
+   hash=$2
+   decimal=0
+
+   while [ -e "$checkdir/$hash.$decimal" ]; do
+   decimal=$((decimal + 1))
+   done
+
+   echo ${decimal}
+   return 0
+}
+
 create_trusted_link()
 {
-   local hash
+   local blisthash certhash hash
+   local suffix
 
hash=$( do_hash "$1" ) || return
-   if [ -e "$BLACKLISTDESTDIR/$hash.0" ]; then
-   echo "Skipping blacklisted certificate $1 
($BLACKLISTDESTDIR/$hash.0)"
-   return 1
-   fi
-   [ $VERBOSE -gt 0 ] && echo "Adding $hash.0 to trust store"
-   [ $NOOP -eq 0 ] && install ${INSTALLFLAGS} -lrs $(realpath "$1") 
"$CERTDESTDIR/$hash.0"
+   certhash=$( openssl x509 -sha1 -in "$1" -noout -fingerprint )
+   for blistfile in $(find $BLACKLISTDESTDIR -name "$hash.*"); do
+   blisthash=$( openssl x509 -sha1 -in "$blistfile" -noout 
-fingerprint )
+   if [ "$certhash" = "$blisthash" ]; then
+   echo "Skipping blacklisted certificate $1 ($blistfile)"
+   return 1
+   fi
+   done
+   suffix=$(get_decimal "$CERTDESTDIR" "$hash")
+   [ $VERBOSE -gt 0 ] && echo "Adding $hash.$suffix to trust store"
+   [ $NOOP -eq 0 ] && \
+   install ${INSTALLFLAGS} -lrs $(realpath "$1") 
"$CERTDESTDIR/$hash.$suffix"
 }
 
 create_blacklisted()
 {
local hash srcfile filename
+   local suffix
 
# If it exists as a file, we'll try that; otherwise, we'll scan
if [ -e "$1" ]; then
hash=$( do_hash "$1" ) || return
srcfile=$(realpath "$1")
-   filename="$hash.0"
+   suffix=$(get_decimal "$BLACKLISTDESTDIR" "$hash")
+   filename="$hash.$suffix"
elif [ -e "${CERTDESTDIR}/$1" ];  then
srcfile=$(realpath "${CERTDESTDIR}/$1")
-   filename="$1"
+   hash=$(echo "$1" | sed -Ee 's/\.([0-9])+$//')
+   suffix=$(get_decimal "$BLACKLISTDESTDIR" "$hash")
+   filename="$hash.$suffix"
else
return
fi
@@ -115,7 +142,7 @@ do_list()
 
if [ -e "$1" ]; then
cd "$1"
-   for CFILE in *.0; do
+   for CFILE in *.[0-9]; do
if [ ! -s "$CFILE" ]; then
echo "Unable to read $CFILE" >&2
ERRORS=$(( $ERRORS + 1 ))
@@ -174,14 +201,20 @@ cmd_blacklist()
 
 cmd_unblacklist()
 {
-   local BFILE hash
+   local BFILE blisthash certhash hash
 
shift # verb
for BFILE in "$@"; do
if [ -s "$BFILE" ]; then
hash=$( do_hash "$BFILE" )
-   echo "Removing $hash.0 from blacklist"
-   [ $NOOP -eq 0 ] && rm -f "$BLACKLISTDESTDIR/$hash.0"
+   certhash=$( openssl x509 -sha1 -in "$BFILE" -noout 
-fingerprint )
+   for BLISTEDFILE in $(find $BLACKLISTDESTDIR -name 
"$hash.*"); do
+   blisthash=$( openssl x509 -sha1 -in 
"$BLISTEDFILE" -noout -fi

svn commit: r365501 - head/sys/netinet/tcp_stacks

2020-09-09 Thread Randall Stewart
Author: rrs
Date: Wed Sep  9 11:11:50 2020
New Revision: 365501
URL: https://svnweb.freebsd.org/changeset/base/365501

Log:
  So it turns out that syzkaller hit another crash. It has to do with switching
  stacks with a SENT_FIN outstanding. Both rack and bbr will only send a
  FIN if all data is ack'd so this must be enforced. Also if the previous stack
  sent the FIN we need to make sure in rack that when we manufacture the
  "unknown" sends that we include the proper HAS_FIN bits.
  
  Note for BBR we take a simpler approach and just refuse to switch.
  
  Sponsored by: Netflix Inc.
  Differential Revision:https://reviews.freebsd.org/D26269

Modified:
  head/sys/netinet/tcp_stacks/bbr.c
  head/sys/netinet/tcp_stacks/rack.c

Modified: head/sys/netinet/tcp_stacks/bbr.c
==
--- head/sys/netinet/tcp_stacks/bbr.c   Wed Sep  9 09:08:09 2020
(r365500)
+++ head/sys/netinet/tcp_stacks/bbr.c   Wed Sep  9 11:11:50 2020
(r365501)
@@ -10281,6 +10281,8 @@ bbr_handoff_ok(struct tcpcb *tp)
 */
return (EAGAIN);
}
+   if (tp->t_flags & TF_SENTFIN)
+   return (EINVAL);
if ((tp->t_flags & TF_SACK_PERMIT) || bbr_sack_not_required) {
return (0);
}

Modified: head/sys/netinet/tcp_stacks/rack.c
==
--- head/sys/netinet/tcp_stacks/rack.c  Wed Sep  9 09:08:09 2020
(r365500)
+++ head/sys/netinet/tcp_stacks/rack.c  Wed Sep  9 11:11:50 2020
(r365501)
@@ -10451,7 +10451,12 @@ rack_init(struct tcpcb *tp)
rsm->r_rtr_cnt = 1;
rsm->r_rtr_bytes = 0;
rsm->r_start = tp->snd_una;
-   rsm->r_end = tp->snd_max;
+   if (tp->t_flags & TF_SENTFIN) {
+   rsm->r_end = tp->snd_max - 1;
+   rsm->r_flags |= RACK_HAS_FIN;
+   } else {
+   rsm->r_end = tp->snd_max;
+   }
rsm->usec_orig_send = us_cts;
rsm->r_dupack = 0;
insret = RB_INSERT(rack_rb_tree_head, &rack->r_ctl.rc_mtree, 
rsm);
@@ -10518,8 +10523,21 @@ rack_handoff_ok(struct tcpcb *tp)
if ((tp->t_state == TCPS_SYN_SENT) ||
(tp->t_state == TCPS_SYN_RECEIVED)) {
/*
-* We really don't know you have to get to ESTAB or beyond
-* to tell.
+* We really don't know if you support sack, 
+* you have to get to ESTAB or beyond to tell.
+*/
+   return (EAGAIN);
+   }
+   if ((tp->t_flags & TF_SENTFIN) && ((tp->snd_max - tp->snd_una) > 1)) {
+   /*
+* Rack will only send a FIN after all data is acknowledged.
+* So in this case we have more data outstanding. We can't
+* switch stacks until either all data and only the FIN
+* is left (in which case rack_init() now knows how
+* to deal with that)  all is acknowledged and we
+* are only left with incoming data, though why you
+* would want to switch to rack after all data is acknowledged
+* I have no idea (rrs)!
 */
return (EAGAIN);
}
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r365502 - in head/sbin/ggate: ggatec ggated

2020-09-09 Thread Mark Johnston
Author: markj
Date: Wed Sep  9 12:58:19 2020
New Revision: 365502
URL: https://svnweb.freebsd.org/changeset/base/365502

Log:
  ggate: Fix ggated/ggatec debug print of offsets.
  
  The request offset and length are always unsigned, so print them as
  such.
  
  Submitted by: Yoshihiro Ota 
  MFC after:1 week
  Differential Revision:https://reviews.freebsd.org/D21388

Modified:
  head/sbin/ggate/ggatec/ggatec.c
  head/sbin/ggate/ggated/ggated.c

Modified: head/sbin/ggate/ggatec/ggatec.c
==
--- head/sbin/ggate/ggatec/ggatec.c Wed Sep  9 11:11:50 2020
(r365501)
+++ head/sbin/ggate/ggatec/ggatec.c Wed Sep  9 12:58:19 2020
(r365502)
@@ -35,6 +35,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -174,8 +175,9 @@ send_thread(void *arg __unused)
pthread_kill(recvtd, SIGUSR1);
break;
}
-   g_gate_log(LOG_DEBUG, "Sent %zd bytes (offset=%llu, "
-   "size=%u).", data, hdr.gh_offset, hdr.gh_length);
+   g_gate_log(LOG_DEBUG, "Sent %zd bytes (offset=%"
+   PRIu64 ", length=%" PRIu32 ").", data,
+   hdr.gh_offset, hdr.gh_length);
}
}
g_gate_log(LOG_DEBUG, "%s: Died.", __func__);
@@ -229,9 +231,9 @@ recv_thread(void *arg __unused)
pthread_kill(sendtd, SIGUSR1);
break;
}
-   g_gate_log(LOG_DEBUG, "Received %d bytes (offset=%ju, "
-   "size=%zu).", data, (uintmax_t)hdr.gh_offset,
-   (size_t)hdr.gh_length);
+   g_gate_log(LOG_DEBUG, "Received %d bytes (offset=%"
+   PRIu64 ", length=%" PRIu32 ").", data,
+   hdr.gh_offset, hdr.gh_length);
}
 
g_gate_ioctl(G_GATE_CMD_DONE, &ggio);

Modified: head/sbin/ggate/ggated/ggated.c
==
--- head/sbin/ggate/ggated/ggated.c Wed Sep  9 11:11:50 2020
(r365501)
+++ head/sbin/ggate/ggated/ggated.c Wed Sep  9 12:58:19 2020
(r365502)
@@ -43,6 +43,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -662,8 +663,8 @@ recv_thread(void *arg)
g_gate_log(LOG_DEBUG, "Received hdr packet.");
g_gate_swap2h_hdr(&req->r_hdr);
 
-   g_gate_log(LOG_DEBUG, "%s: offset=%jd length=%u", __func__,
-   (intmax_t)req->r_offset, (unsigned)req->r_length);
+   g_gate_log(LOG_DEBUG, "%s: offset=%" PRIu64 " length=%" PRIu32,
+   __func__, req->r_offset, req->r_length);
 
/*
 * Allocate memory for data.
@@ -730,8 +731,8 @@ disk_thread(void *arg)
assert((req->r_offset % conn->c_sectorsize) == 0);
assert((req->r_length % conn->c_sectorsize) == 0);
 
-   g_gate_log(LOG_DEBUG, "%s: offset=%jd length=%u", __func__,
-   (intmax_t)req->r_offset, (unsigned)req->r_length);
+   g_gate_log(LOG_DEBUG, "%s: offset=%" PRIu64 " length=%" PRIu32,
+__func__, req->r_offset, req->r_length);
 
/*
 * Do the request.
@@ -804,8 +805,8 @@ send_thread(void *arg)
error = pthread_mutex_unlock(&outqueue_mtx);
assert(error == 0);
 
-   g_gate_log(LOG_DEBUG, "%s: offset=%jd length=%u", __func__,
-   (intmax_t)req->r_offset, (unsigned)req->r_length);
+   g_gate_log(LOG_DEBUG, "%s: offset=%" PRIu64 " length=%" PRIu32,
+   __func__, req->r_offset, req->r_length);
 
/*
 * Send the request.
@@ -824,8 +825,8 @@ send_thread(void *arg)
strerror(errno));
}
g_gate_log(LOG_DEBUG,
-   "Sent %zd bytes (offset=%ju, size=%zu).", data,
-   (uintmax_t)req->r_offset, (size_t)req->r_length);
+   "Sent %zd bytes (offset=%" PRIu64 ", size=%" PRIu32
+   ").", data, req->r_offset, req->r_length);
free(req->r_data);
}
free(req);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: uninitialized variables [Was: svn commit: r365445 - head/sys/cam/mmc]

2020-09-09 Thread Mark Johnston
On Wed, Sep 09, 2020 at 08:49:01AM +0300, Andriy Gapon wrote:
> On 08/09/2020 15:48, Mark Johnston wrote:
> > I observed the same thing recently as well: the compiler catches
> > uninitialized variables only in simple cases.  In my case, any uses of
> > goto within the function seemed to silence the warning, even if they
> > appeared after the uninitialized reference.
> 
> I am running a kernel build now with this addition (for clang):
> CWARNEXTRA+=   -Wconditional-uninitialized 
> -Wno-error-conditional-uninitialized
> 
> It produces a ton of warnings.
> Some of them are probably false positives, but some look quite reasonable.

It has a lot of trouble with code patterns of the form:

for (i = 0; i < 100; i++) {
val = foo();
}
if (val != 0) /* may be uninitialized!!1 */
bar();

or

if (foo == bar)
val = baz();

if (foo == bar && val == 3)


The second example makes some sense to me since it's hard to prove that
foo == bar will not change between the first and second evaluations.

> E.g.:
> sys/cam/cam_periph.c:314:19: warning: variable 'p_drv' may be uninitialized 
> when
> used here [-Wconditional-uninitialized]
> TAILQ_REMOVE(&(*p_drv)->units, periph, unit_links);
> 
> Indeed, there is a conditional 'goto failure' before a first assignment to 
> p_drv
> and the line is after the label.  So, maybe the situation is impossible, but 
> it
> is reasonable to warn about it.
>
> But the number of false positives (and "possible but impossible" situations) 
> is
> too overwhelming.

Yeah.  I looked at maybe 30 warnings (out of hundreds) this morning
and they were all false positives.  KMSAN will provide a new tool for
finding such bugs, but they will only be detected at runtime.
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r364891 - in head: . release release/scripts

2020-09-09 Thread Glen Barber
On Wed, Sep 09, 2020 at 11:45:49AM +0500, Ruslan Garipov wrote:
> On August 28, 2020 2:19:33 AM Glen Barber  wrote:
> 
> > Author: gjb
> > Date: Thu Aug 27 21:19:16 2020
> > New Revision: 364891
> > URL: https://svnweb.freebsd.org/changeset/base/364891
> > 
> > Log:
> >   Merge the projects/release-git branch to head.
> >   This allows building 13.x from Git instead of Subversion.
> I'm sorry for the late response (and for the bad first one I made on this
> commit recently via Gmail web client).
> 
> My build machine is completely offline.  I provide it with fresh snapshots
> of the source and ports tree manually -- via tarballs which I'm pulling on
> a FreeBSD machine having Internet connection.  Therefore, neither
> "/scratch", nor the chrooted environment for me don't require Internet
> access (I fetch distfiles for offline usage too).
> 
> Can we somehow remove that requirement for the devel/git port?  For
> example, if one has set all three {SRC,PORTS,DOC}_UPDATE_SKIP variables,
> then release/release.sh doesn't require devel/git to exist on the host.
> 
> I really don't need git on my build machine (and don't need it for
> building).
> 

Can you verify if the attached patch works for your use case?  You will
need to set NOGIT=1 in your release.conf.

Glen

Index: release/release.conf.sample
===
--- release/release.conf.sample (revision 365503)
+++ release/release.conf.sample (working copy)
@@ -12,6 +12,8 @@
 ## Set the directory within which the release will be built.
 CHROOTDIR="/scratch"
 
+## Do not explicitly require the devel/git port to be installed.
+#NOGIT=1
 ## Set the version control system host.
 GITROOT="https://cgit-beta.freebsd.org/";
 GITSRC="src.git"
Index: release/release.sh
===
--- release/release.sh  (revision 365503)
+++ release/release.sh  (working copy)
@@ -65,7 +65,7 @@ env_setup() {
[ ! -z "${VCSCMD}" ] && break 2
done
 
-   if [ -z "${VCSCMD}" ]; then
+   if [ -z "${VCSCMD}" -a ! -z "${NOGIT}" ]; then
echo "*** The devel/git port/package is required."
exit 1
fi
@@ -275,30 +275,32 @@ extra_chroot_setup() {
cp ${SRC_CONF} ${CHROOTDIR}/${SRC_CONF}
fi
 
-   # Install git from ports or packages if the ports tree is
-   # available and VCSCMD is unset.
-   _gitcmd="$(which git)"
-   if [ -d ${CHROOTDIR}/usr/ports -a -z "${_gitcmd}" ]; then
-   # Trick the ports 'run-autotools-fixup' target to do the right
-   # thing.
-   _OSVERSION=$(chroot ${CHROOTDIR} /usr/bin/uname -U)
-   REVISION=$(chroot ${CHROOTDIR} make -C /usr/src/release -V 
REVISION)
-   BRANCH=$(chroot ${CHROOTDIR} make -C /usr/src/release -V BRANCH)
-   UNAME_r=${REVISION}-${BRANCH}
-   GITUNSETOPTS="CONTRIB CURL CVS GITWEB GUI HTMLDOCS"
-   GITUNSETOPTS="${GITUNSETOPTS} ICONV NLS P4 PERL"
-   GITUNSETOPTS="${GITUNSETOPTS} SEND_EMAIL SUBTREE SVN"
-   GITUNSETOPTS="${GITUNSETOPTS} PCRE PCRE2"
-   eval chroot ${CHROOTDIR} env OPTIONS_UNSET=\"${GITUNSETOPTS}\" \
-   make -C /usr/ports/devel/git FORCE_PKG_REGISTER=1 \
-   WRKDIRPREFIX=/tmp/ports \
-   DISTDIR=/tmp/distfiles \
-   install clean distclean
-   else
-   eval chroot ${CHROOTDIR} env ASSUME_ALWAYS_YES=yes \
-   pkg install -y devel/git
-   eval chroot ${CHROOTDIR} env ASSUME_ALWAYS_YES=yes \
-   pkg clean -y
+   if [ ! -z "${NOGIT}" ]; then
+   # Install git from ports or packages if the ports tree is
+   # available and VCSCMD is unset.
+   _gitcmd="$(which git)"
+   if [ -d ${CHROOTDIR}/usr/ports -a -z "${_gitcmd}" ]; then
+   # Trick the ports 'run-autotools-fixup' target to do 
the right
+   # thing.
+   _OSVERSION=$(chroot ${CHROOTDIR} /usr/bin/uname -U)
+   REVISION=$(chroot ${CHROOTDIR} make -C /usr/src/release 
-V REVISION)
+   BRANCH=$(chroot ${CHROOTDIR} make -C /usr/src/release 
-V BRANCH)
+   UNAME_r=${REVISION}-${BRANCH}
+   GITUNSETOPTS="CONTRIB CURL CVS GITWEB GUI HTMLDOCS"
+   GITUNSETOPTS="${GITUNSETOPTS} ICONV NLS P4 PERL"
+   GITUNSETOPTS="${GITUNSETOPTS} SEND_EMAIL SUBTREE SVN"
+   GITUNSETOPTS="${GITUNSETOPTS} PCRE PCRE2"
+   eval chroot ${CHROOTDIR} env 
OPTIONS_UNSET=\"${GITUNSETOPTS}\" \
+   make -C /usr/ports/devel/git 
FORCE_PKG_REGISTER=1 \
+   WRKDIRPREFIX=/tmp/ports \
+   D

svn commit: r365504 - head/sys/kern

2020-09-09 Thread Gleb Smirnoff
Author: glebius
Date: Wed Sep  9 16:13:33 2020
New Revision: 365504
URL: https://svnweb.freebsd.org/changeset/base/365504

Log:
  In r354148 the goal was to check THREAD_CAN_SLEEP() only once for the
  purpose of epoch_trace() and for calling subsequent panic, but to keep
  code fully under INVARIANTS, so don't use bare function call to panic().
  However, at the last stage of review a true value slipped in, while
  always false was assumed.  I checked that in email archive with kib@.
  
  Noticed by:   trasz

Modified:
  head/sys/kern/subr_sleepqueue.c
  head/sys/kern/subr_trap.c

Modified: head/sys/kern/subr_sleepqueue.c
==
--- head/sys/kern/subr_sleepqueue.c Wed Sep  9 13:16:20 2020
(r365503)
+++ head/sys/kern/subr_sleepqueue.c Wed Sep  9 16:13:33 2020
(r365504)
@@ -325,7 +325,7 @@ sleepq_add(const void *wchan, struct lock_object *lock
 #ifdef EPOCH_TRACE
epoch_trace_list(curthread);
 #endif
-   KASSERT(1,
+   KASSERT(0,
("%s: td %p to sleep on wchan %p with sleeping prohibited",
__func__, td, wchan));
}

Modified: head/sys/kern/subr_trap.c
==
--- head/sys/kern/subr_trap.c   Wed Sep  9 13:16:20 2020(r365503)
+++ head/sys/kern/subr_trap.c   Wed Sep  9 16:13:33 2020(r365504)
@@ -187,7 +187,7 @@ userret(struct thread *td, struct trapframe *frame)
 #ifdef EPOCH_TRACE
epoch_trace_list(curthread);
 #endif
-   KASSERT(1, ("userret: Returning with sleep disabled"));
+   KASSERT(0, ("userret: Returning with sleep disabled"));
}
KASSERT(td->td_pinned == 0 || (td->td_pflags & TDP_CALLCHAIN) != 0,
("userret: Returning with with pinned thread"));
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r365505 - head/stand/efi/libefi

2020-09-09 Thread D Scott Phillips
Author: scottph
Date: Wed Sep  9 16:35:51 2020
New Revision: 365505
URL: https://svnweb.freebsd.org/changeset/base/365505

Log:
  stand/efihttp: Work around a bug in edk2 http instance reconfiguration
  
  A bug in the EFI HTTP driver of TianoCore EDK2 causes memory
  corruption when an http instance that uses tls is reconfigured,
  leading to a crash.
  
  Work around this by forcing a new http instance for each request
  instead of reconfiguring the existing one.
  
  The upstream bug report is https://bugzilla.tianocore.org/show_bug.cgi?id=1917
  
  Submitted by: bcran
  Reviewed By:  imp, kevans, tsoome
  MFC after:1 week
  Differential Revision:https://reviews.freebsd.org/D21281

Modified:
  head/stand/efi/libefi/efihttp.c

Modified: head/stand/efi/libefi/efihttp.c
==
--- head/stand/efi/libefi/efihttp.c Wed Sep  9 16:13:33 2020
(r365504)
+++ head/stand/efi/libefi/efihttp.c Wed Sep  9 16:35:51 2020
(r365505)
@@ -576,6 +576,14 @@ efihttp_fs_open(const char *path, struct open_file *f)
 */
err = _efihttp_fs_open(path, f);
if (err != 0) {
+   /*
+* Work around a bug in the EFI HTTP implementation which
+* causes a crash if the http instance isn't torn down
+* between requests.
+* See https://bugzilla.tianocore.org/show_bug.cgi?id=1917
+*/
+   efihttp_dev_close(f);
+   efihttp_dev_open(f);
path_slash = malloc(strlen(path) + 2);
if (path_slash == NULL)
return (ENOMEM);
@@ -719,6 +727,14 @@ efihttp_fs_seek(struct open_file *f, off_t offset, int
path = fh->path;
fh->path = NULL;
efihttp_fs_close(f);
+   /*
+* Work around a bug in the EFI HTTP implementation which
+* causes a crash if the http instance isn't torn down
+* between requests.
+* See https://bugzilla.tianocore.org/show_bug.cgi?id=1917
+*/
+   efihttp_dev_close(f);
+   efihttp_dev_open(f);
err = efihttp_fs_open(path, f);
free(path);
if (err != 0)
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r365506 - in head: include lib/libc/gen lib/libc/sys

2020-09-09 Thread Kyle Evans
Author: kevans
Date: Wed Sep  9 18:07:13 2020
New Revision: 365506
URL: https://svnweb.freebsd.org/changeset/base/365506

Log:
  getlogin_r: fix the type of len
  
  getlogin_r is specified by POSIX to to take a size_t len, not int. Fix our
  version to do the same, bump the symbol version due to ABI change and
  provide compat.
  
  This was reported to break compilation of Ruby 2.8.
  
  Some discussion about the necessity of the ABI compat did take place in the
  review. While many 64-bit platforms would likely be passing it in a 64-bit
  register and zero-extended and thus, not notice ABI breakage, some do
  sign-extend (e.g. mips).
  
  PR:   247102
  Submitted by: Bertram Scharpf  (original)
  Submitted by: cem (ABI compat)
  MFC after:1 week
  Differential Revision:https://reviews.freebsd.org/D26335

Modified:
  head/include/unistd.h
  head/lib/libc/gen/Symbol.map
  head/lib/libc/gen/getlogin.c
  head/lib/libc/sys/getlogin.2

Modified: head/include/unistd.h
==
--- head/include/unistd.h   Wed Sep  9 16:35:51 2020(r365505)
+++ head/include/unistd.h   Wed Sep  9 18:07:13 2020(r365506)
@@ -399,7 +399,7 @@ int  ftruncate(int, off_t);
 #endif
 
 #if __POSIX_VISIBLE >= 199506
-int getlogin_r(char *, int);
+int getlogin_r(char *, size_t);
 #endif
 
 /* 1003.1-2001 */

Modified: head/lib/libc/gen/Symbol.map
==
--- head/lib/libc/gen/Symbol.mapWed Sep  9 16:35:51 2020
(r365505)
+++ head/lib/libc/gen/Symbol.mapWed Sep  9 18:07:13 2020
(r365506)
@@ -156,7 +156,6 @@ FBSD_1.0 {
gethostname;
getloadavg;
getlogin;
-   getlogin_r;
setnetgrent;
getnetgrent;
endnetgrent;
@@ -422,6 +421,7 @@ FBSD_1.5 {
 };
 
 FBSD_1.6 {
+   getlogin_r;
memalign;
scandir_b;
sigandset;

Modified: head/lib/libc/gen/getlogin.c
==
--- head/lib/libc/gen/getlogin.cWed Sep  9 16:35:51 2020
(r365505)
+++ head/lib/libc/gen/getlogin.cWed Sep  9 18:07:13 2020
(r365506)
@@ -58,7 +58,7 @@ getlogin(void)
 }
 
 int
-getlogin_r(char *logname, int namelen)
+getlogin_r(char *logname, size_t namelen)
 {
char tmpname[MAXLOGNAME];
int len;
@@ -75,3 +75,13 @@ getlogin_r(char *logname, int namelen)
strlcpy(logname, tmpname, len);
return (0);
 }
+
+/* FreeBSD 12 and earlier compat. */
+int
+__getlogin_r_fbsd12(char *logname, int namelen)
+{
+   if (namelen < 1)
+   return (ERANGE);
+   return (getlogin_r(logname, namelen));
+}
+__sym_compat(getlogin_r, __getlogin_r_fbsd12, FBSD_1.0);

Modified: head/lib/libc/sys/getlogin.2
==
--- head/lib/libc/sys/getlogin.2Wed Sep  9 16:35:51 2020
(r365505)
+++ head/lib/libc/sys/getlogin.2Wed Sep  9 18:07:13 2020
(r365506)
@@ -28,7 +28,7 @@
 .\"@(#)getlogin.2  8.1 (Berkeley) 6/9/93
 .\" $FreeBSD$
 .\"
-.Dd June 9, 1993
+.Dd September 9, 2020
 .Dt GETLOGIN 2
 .Os
 .Sh NAME
@@ -44,7 +44,7 @@
 .Fn getlogin void
 .In sys/param.h
 .Ft int
-.Fn getlogin_r "char *name" "int len"
+.Fn getlogin_r "char *name" "size_t len"
 .Ft int
 .Fn setlogin "const char *name"
 .Sh DESCRIPTION
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r365506 - in head: include lib/libc/gen lib/libc/sys

2020-09-09 Thread Kyle Evans
On Wed, Sep 9, 2020 at 1:07 PM Kyle Evans  wrote:
>
> Author: kevans
> Date: Wed Sep  9 18:07:13 2020
> New Revision: 365506
> URL: https://svnweb.freebsd.org/changeset/base/365506
>
> Log:
>   getlogin_r: fix the type of len
>
>   getlogin_r is specified by POSIX to to take a size_t len, not int. Fix our
>   version to do the same, bump the symbol version due to ABI change and
>   provide compat.
>
>   This was reported to break compilation of Ruby 2.8.
>
>   Some discussion about the necessity of the ABI compat did take place in the
>   review. While many 64-bit platforms would likely be passing it in a 64-bit
>   register and zero-extended and thus, not notice ABI breakage, some do
>   sign-extend (e.g. mips).
>
>   PR:   247102
>   Submitted by: Bertram Scharpf  (original)
>   Submitted by: cem (ABI compat)
>   MFC after:1 week
>   Differential Revision:https://reviews.freebsd.org/D26335
>

Argh, I dropped this =(:

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


svn commit: r365507 - head/contrib/llvm-project/llvm/lib/Support

2020-09-09 Thread Dimitry Andric
Author: dim
Date: Wed Sep  9 18:11:04 2020
New Revision: 365507
URL: https://svnweb.freebsd.org/changeset/base/365507

Log:
  Merge commit e6bb4c8e7 from llvm git (by Craig Topper):
  
[X86] SSE4_A should only imply SSE3 not SSSE3 in the frontend.
  
SSE4_1 and SSE4_2 due imply SSSE3. So I guess I got confused when
switching the code to being table based in D83273.
  
Fixes PR47464
  
  This should fix builds with -march=amdfam10 emitting SSSE3 instructions
  such as pshufb, which lead to programs crashing with SIGILL on such
  processors.
  
  Reported by:  avg
  MFC after:6 weeks
  X-MFC-With:   r364284

Modified:
  head/contrib/llvm-project/llvm/lib/Support/X86TargetParser.cpp

Modified: head/contrib/llvm-project/llvm/lib/Support/X86TargetParser.cpp
==
--- head/contrib/llvm-project/llvm/lib/Support/X86TargetParser.cpp  Wed Sep 
 9 18:07:13 2020(r365506)
+++ head/contrib/llvm-project/llvm/lib/Support/X86TargetParser.cpp  Wed Sep 
 9 18:11:04 2020(r365507)
@@ -522,7 +522,7 @@ static constexpr FeatureBitset ImpliedFeaturesAVX5124F
 static constexpr FeatureBitset ImpliedFeaturesAVX5124VNNIW = {};
 
 // SSE4_A->FMA4->XOP chain.
-static constexpr FeatureBitset ImpliedFeaturesSSE4_A = FeatureSSSE3;
+static constexpr FeatureBitset ImpliedFeaturesSSE4_A = FeatureSSE3;
 static constexpr FeatureBitset ImpliedFeaturesFMA4 = FeatureAVX | 
FeatureSSE4_A;
 static constexpr FeatureBitset ImpliedFeaturesXOP = FeatureFMA4;
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r365508 - in head: share/man/man5 usr.sbin/periodic

2020-09-09 Thread Robert Wing
Author: rew
Date: Wed Sep  9 19:07:34 2020
New Revision: 365508
URL: https://svnweb.freebsd.org/changeset/base/365508

Log:
  periodic.conf(5): don't truncate interface names reported by 
420.status-network.
  
  The daily periodic script, 420.status-network uses netstat(1) to report
  interface status. By default, netstat(1) truncates interface names.
  
  Add the '-W' flag (avoid truncating interface names) as the default for
  'daily_status_network_netstat_flags' in periodic.conf(5).
  
  The default 420.status-network command is now 'netstat -i -d -W -n'.
  
  PR: 163572
  Reported by: kes-...@yandex.ru
  Reviewed by: allanjude (mentor) bcr (manpages)
  Approved by: allanjude (mentor)
  MFC after:  1 week
  Differential Revision:  https://reviews.freebsd.org/D26023

Modified:
  head/share/man/man5/periodic.conf.5
  head/usr.sbin/periodic/periodic.conf

Modified: head/share/man/man5/periodic.conf.5
==
--- head/share/man/man5/periodic.conf.5 Wed Sep  9 18:11:04 2020
(r365507)
+++ head/share/man/man5/periodic.conf.5 Wed Sep  9 19:07:34 2020
(r365508)
@@ -25,7 +25,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd June 16, 2020
+.Dd September 9, 2020
 .Dt PERIODIC.CONF 5
 .Os
 .Sh NAME
@@ -439,7 +439,7 @@ utility when
 is set to
 .Dq Li YES .
 The default is
-.Fl d .
+.Fl d W .
 .It Va daily_status_network_usedns
 .Pq Vt bool
 Set to

Modified: head/usr.sbin/periodic/periodic.conf
==
--- head/usr.sbin/periodic/periodic.confWed Sep  9 18:11:04 2020
(r365507)
+++ head/usr.sbin/periodic/periodic.confWed Sep  9 19:07:34 2020
(r365508)
@@ -123,7 +123,7 @@ daily_status_mfi_enable="NO"
# Check mfiutil(8)
 # 420.status-network
 daily_status_network_enable="YES"  # Check network status
 daily_status_network_usedns="YES"  # DNS lookups are ok
-daily_status_network_netstat_flags="-d"# netstat(1) 
flags
+daily_status_network_netstat_flags="-d -W" # netstat(1) flags
 
 # 430.status-uptime
 daily_status_uptime_enable="YES"   # Check system uptime
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r365509 - head/lib/libcompiler_rt

2020-09-09 Thread Dimitry Andric
Author: dim
Date: Wed Sep  9 20:48:57 2020
New Revision: 365509
URL: https://svnweb.freebsd.org/changeset/base/365509

Log:
  Follow-up r364753 by enabling compiler-rt's atomic implementation only
  for clang, as it uses clang specific builtins, and does not compile
  correctly with gcc. Note that gcc packages usually come with their own
  libatomic, providing these primitives.
  
  PR:   230888
  MFC after:3 days
  X-MFC-With:   r364753

Modified:
  head/lib/libcompiler_rt/Makefile.inc

Modified: head/lib/libcompiler_rt/Makefile.inc
==
--- head/lib/libcompiler_rt/Makefile.incWed Sep  9 19:07:34 2020
(r365508)
+++ head/lib/libcompiler_rt/Makefile.incWed Sep  9 20:48:57 2020
(r365509)
@@ -18,7 +18,6 @@ SRCF+=ashldi3
 SRCF+= ashlti3
 SRCF+= ashrdi3
 SRCF+= ashrti3
-SRCF+= atomic
 SRCF+= bswapdi2
 SRCF+= bswapsi2
 SRCF+= clear_cache
@@ -122,6 +121,12 @@ SRCF+= udivti3
 SRCF+= umoddi3
 SRCF+= umodsi3
 SRCF+= umodti3
+
+# Enable compiler-rt's atomic implementation only for clang, as it uses clang
+# specific builtins, and gcc packages usually come with their own libatomic.
+.if "${COMPILER_TYPE}" == "clang"
+SRCF+= atomic
+.endif
 
 # Avoid using SSE2 instructions on i386, if unsupported.
 .if ${MACHINE_CPUARCH} == "i386" && empty(MACHINE_CPU:Msse2)
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r365510 - head/sys/kern

2020-09-09 Thread Konstantin Belousov
Author: kib
Date: Wed Sep  9 21:00:11 2020
New Revision: 365510
URL: https://svnweb.freebsd.org/changeset/base/365510

Log:
  uipc_shm.c: Move comment where it belongs.
  
  Reviewed by:  markj
  Tested by:pho
  Sponsored by: The FreeBSD Foundation
  MFC after:1 week
  Differential revision:https://reviews.freebsd.org/D24652

Modified:
  head/sys/kern/uipc_shm.c

Modified: head/sys/kern/uipc_shm.c
==
--- head/sys/kern/uipc_shm.cWed Sep  9 20:48:57 2020(r365509)
+++ head/sys/kern/uipc_shm.cWed Sep  9 21:00:11 2020(r365510)
@@ -684,11 +684,6 @@ shm_access(struct shmfd *shmfd, struct ucred *ucred, i
return (error);
 }
 
-/*
- * Dictionary management.  We maintain an in-kernel dictionary to map
- * paths to shmfd objects.  We use the FNV hash on the path to store
- * the mappings in a hash table.
- */
 static void
 shm_init(void *arg)
 {
@@ -702,6 +697,11 @@ shm_init(void *arg)
 }
 SYSINIT(shm_init, SI_SUB_SYSV_SHM, SI_ORDER_ANY, shm_init, NULL);
 
+/*
+ * Dictionary management.  We maintain an in-kernel dictionary to map
+ * paths to shmfd objects.  We use the FNV hash on the path to store
+ * the mappings in a hash table.
+ */
 static struct shmfd *
 shm_lookup(char *path, Fnv32_t fnv)
 {
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r365511 - head/sys/amd64/amd64

2020-09-09 Thread Konstantin Belousov
Author: kib
Date: Wed Sep  9 21:01:36 2020
New Revision: 365511
URL: https://svnweb.freebsd.org/changeset/base/365511

Log:
  amd64: report support for 1G superpages in getpagesizes(2).
  
  Reviewed by:  markj
  Tested by:pho
  Sponsored by: The FreeBSD Foundation
  MFC after:1 week
  Differential revision:https://reviews.freebsd.org/D24652

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

Modified: head/sys/amd64/amd64/pmap.c
==
--- head/sys/amd64/amd64/pmap.c Wed Sep  9 21:00:11 2020(r365510)
+++ head/sys/amd64/amd64/pmap.c Wed Sep  9 21:01:36 2020(r365511)
@@ -2382,6 +2382,11 @@ pmap_init(void)
KASSERT(MAXPAGESIZES > 1 && pagesizes[1] == 0,
("pmap_init: can't assign to pagesizes[1]"));
pagesizes[1] = NBPDR;
+   if ((amd_feature & AMDID_PAGE1GB) != 0) {
+   KASSERT(MAXPAGESIZES > 1 && pagesizes[2] == 0,
+   ("pmap_init: can't assign to pagesizes[2]"));
+   pagesizes[2] = NBPDP;
+   }
}
 
/*
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r365512 - head/sys/amd64/amd64

2020-09-09 Thread Konstantin Belousov
Author: kib
Date: Wed Sep  9 21:08:45 2020
New Revision: 365512
URL: https://svnweb.freebsd.org/changeset/base/365512

Log:
  amd64 pmap: teach functions walking user page tables about PG_PS bit in PDPE.
  
  Only unmanaged 1G superpages are handled.
  
  Reviewed by:  markj
  Tested by:pho
  Sponsored by: The FreeBSD Foundation
  MFC after:1 week
  Differential revision:https://reviews.freebsd.org/D24652

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

Modified: head/sys/amd64/amd64/pmap.c
==
--- head/sys/amd64/amd64/pmap.c Wed Sep  9 21:01:36 2020(r365511)
+++ head/sys/amd64/amd64/pmap.c Wed Sep  9 21:08:45 2020(r365512)
@@ -48,7 +48,7 @@
  */
 /*-
  * Copyright (c) 2003 Networks Associates Technology, Inc.
- * Copyright (c) 2014-2019 The FreeBSD Foundation
+ * Copyright (c) 2014-2020 The FreeBSD Foundation
  * All rights reserved.
  *
  * This software was developed for the FreeBSD Project by Jake Burkholder,
@@ -1415,6 +1415,8 @@ pmap_pde(pmap_t pmap, vm_offset_t va)
pdpe = pmap_pdpe(pmap, va);
if (pdpe == NULL || (*pdpe & PG_V) == 0)
return (NULL);
+   KASSERT((*pdpe & PG_PS) == 0,
+   ("pmap_pde for 1G page, pmap %p va %#lx", pmap, va));
return (pmap_pdpe_to_pde(pdpe, va));
 }
 
@@ -3570,6 +3572,7 @@ pmap_extract(pmap_t pmap, vm_offset_t va)
 vm_page_t
 pmap_extract_and_hold(pmap_t pmap, vm_offset_t va, vm_prot_t prot)
 {
+   pdp_entry_t pdpe, *pdpep;
pd_entry_t pde, *pdep;
pt_entry_t pte, PG_RW, PG_V;
vm_page_t m;
@@ -3577,23 +3580,38 @@ pmap_extract_and_hold(pmap_t pmap, vm_offset_t va, vm_
m = NULL;
PG_RW = pmap_rw_bit(pmap);
PG_V = pmap_valid_bit(pmap);
-
PMAP_LOCK(pmap);
-   pdep = pmap_pde(pmap, va);
-   if (pdep != NULL && (pde = *pdep)) {
-   if (pde & PG_PS) {
-   if ((pde & PG_RW) != 0 || (prot & VM_PROT_WRITE) == 0)
-   m = PHYS_TO_VM_PAGE((pde & PG_PS_FRAME) |
-   (va & PDRMASK));
-   } else {
-   pte = *pmap_pde_to_pte(pdep, va);
-   if ((pte & PG_V) != 0 &&
-   ((pte & PG_RW) != 0 || (prot & VM_PROT_WRITE) == 0))
-   m = PHYS_TO_VM_PAGE(pte & PG_FRAME);
-   }
-   if (m != NULL && !vm_page_wire_mapped(m))
-   m = NULL;
+
+   pdpep = pmap_pdpe(pmap, va);
+   if (pdpep == NULL || ((pdpe = *pdpep) & PG_V) == 0)
+   goto out;
+   if ((pdpe & PG_PS) != 0) {
+   if ((pdpe & PG_RW) == 0 && (prot & VM_PROT_WRITE) != 0)
+   goto out;
+   m = PHYS_TO_VM_PAGE((pdpe & PG_PS_FRAME) | (va & PDPMASK));
+   goto check_page;
}
+
+   pdep = pmap_pdpe_to_pde(pdpep, va);
+   if (pdep == NULL || ((pde = *pdep) & PG_V) == 0)
+   goto out;
+   if ((pde & PG_PS) != 0) {
+   if ((pde & PG_RW) == 0 && (prot & VM_PROT_WRITE) != 0)
+   goto out;
+   m = PHYS_TO_VM_PAGE((pde & PG_PS_FRAME) | (va & PDRMASK));
+   goto check_page;
+   }
+
+   pte = *pmap_pde_to_pte(pdep, va);
+   if ((pte & PG_V) == 0 ||
+   ((pte & PG_RW) == 0 && (prot & VM_PROT_WRITE) != 0))
+   goto out;
+   m = PHYS_TO_VM_PAGE(pte & PG_FRAME);
+
+check_page:
+   if (m != NULL && !vm_page_wire_mapped(m))
+   m = NULL;
+out:
PMAP_UNLOCK(pmap);
return (m);
 }
@@ -5854,6 +5872,7 @@ void
 pmap_remove(pmap_t pmap, vm_offset_t sva, vm_offset_t eva)
 {
struct rwlock *lock;
+   vm_page_t mt;
vm_offset_t va_next;
pml5_entry_t *pml5e;
pml4_entry_t *pml4e;
@@ -5917,13 +5936,28 @@ pmap_remove(pmap_t pmap, vm_offset_t sva, vm_offset_t 
}
 
pdpe = pmap_pml4e_to_pdpe(pml4e, sva);
+   va_next = (sva + NBPDP) & ~PDPMASK;
if ((*pdpe & PG_V) == 0) {
-   va_next = (sva + NBPDP) & ~PDPMASK;
if (va_next < sva)
va_next = eva;
continue;
}
 
+   KASSERT((*pdpe & PG_PS) == 0 || va_next <= eva,
+   ("pmap_remove of non-transient 1G page "
+   "pdpe %#lx sva %#lx eva %#lx va_next %#lx",
+   *pdpe, sva, eva, va_next));
+   if ((*pdpe & PG_PS) != 0) {
+   MPASS(pmap != kernel_pmap); /* XXXKIB */
+   MPASS((*pdpe & (PG_MANAGED | PG_G)) == 0);
+   anyvalid =  1;
+   *pdpe = 0;
+   pmap_resident_count_dec(pmap, NBPDP / PAGE_SIZE);
+   mt = PHYS_TO_VM_PAGE(*pmap_pml4e(pmap, sva) & PG_FRAME);
+ 

svn commit: r365513 - head/sys/vm

2020-09-09 Thread Konstantin Belousov
Author: kib
Date: Wed Sep  9 21:34:31 2020
New Revision: 365513
URL: https://svnweb.freebsd.org/changeset/base/365513

Log:
  Prepare to handle non-trivial errors from vm_map_delete().
  
  Reviewed by:  markj
  Tested by:pho
  Sponsored by: The FreeBSD Foundation
  MFC after:1 week
  Differential revision:https://reviews.freebsd.org/D24652

Modified:
  head/sys/vm/vm_map.c
  head/sys/vm/vm_mmap.c
  head/sys/vm/vm_unix.c

Modified: head/sys/vm/vm_map.c
==
--- head/sys/vm/vm_map.cWed Sep  9 21:08:45 2020(r365512)
+++ head/sys/vm/vm_map.cWed Sep  9 21:34:31 2020(r365513)
@@ -1868,8 +1868,11 @@ vm_map_fixed(vm_map_t map, vm_object_t object, vm_ooff
("vm_map_fixed: non-NULL backing object for stack"));
vm_map_lock(map);
VM_MAP_RANGE_CHECK(map, start, end);
-   if ((cow & MAP_CHECK_EXCL) == 0)
-   vm_map_delete(map, start, end);
+   if ((cow & MAP_CHECK_EXCL) == 0) {
+   result = vm_map_delete(map, start, end);
+   if (result != KERN_SUCCESS)
+   goto out;
+   }
if ((cow & (MAP_STACK_GROWS_DOWN | MAP_STACK_GROWS_UP)) != 0) {
result = vm_map_stack_locked(map, start, length, sgrowsiz,
prot, max, cow);
@@ -1877,6 +1880,7 @@ vm_map_fixed(vm_map_t map, vm_object_t object, vm_ooff
result = vm_map_insert(map, object, offset, start, end,
prot, max, cow);
}
+out:
vm_map_unlock(map);
return (result);
 }
@@ -2115,7 +2119,9 @@ again:
rv = KERN_INVALID_ADDRESS;
goto done;
}
-   vm_map_delete(map, *addr, *addr + length);
+   rv = vm_map_delete(map, *addr, *addr + length);
+   if (rv != KERN_SUCCESS)
+   goto done;
}
if ((cow & (MAP_STACK_GROWS_DOWN | MAP_STACK_GROWS_UP)) != 0) {
rv = vm_map_stack_locked(map, *addr, length, sgrowsiz, prot,

Modified: head/sys/vm/vm_mmap.c
==
--- head/sys/vm/vm_mmap.c   Wed Sep  9 21:08:45 2020(r365512)
+++ head/sys/vm/vm_mmap.c   Wed Sep  9 21:34:31 2020(r365513)
@@ -577,6 +577,7 @@ kern_munmap(struct thread *td, uintptr_t addr0, size_t
vm_offset_t addr, end;
vm_size_t pageoff;
vm_map_t map;
+   int rv;
 
if (size == 0)
return (EINVAL);
@@ -614,10 +615,10 @@ kern_munmap(struct thread *td, uintptr_t addr0, size_t
}
}
 #endif
-   vm_map_delete(map, addr, end);
+   rv = vm_map_delete(map, addr, end);
 
 #ifdef HWPMC_HOOKS
-   if (__predict_false(pmc_handled)) {
+   if (rv == KERN_SUCCESS && __predict_false(pmc_handled)) {
/* downgrade the lock to prevent a LOR with the pmc-sx lock */
vm_map_lock_downgrade(map);
if (pkm.pm_address != (uintptr_t) NULL)
@@ -627,8 +628,7 @@ kern_munmap(struct thread *td, uintptr_t addr0, size_t
 #endif
vm_map_unlock(map);
 
-   /* vm_map_delete returns nothing but KERN_SUCCESS anyway */
-   return (0);
+   return (vm_mmap_to_errno(rv));
 }
 
 #ifndef _SYS_SYSPROTO_H_

Modified: head/sys/vm/vm_unix.c
==
--- head/sys/vm/vm_unix.c   Wed Sep  9 21:08:45 2020(r365512)
+++ head/sys/vm/vm_unix.c   Wed Sep  9 21:34:31 2020(r365513)
@@ -188,7 +188,7 @@ kern_break(struct thread *td, uintptr_t *addr)
rv = vm_map_wire_locked(map, old, new,
VM_MAP_WIRE_USER | VM_MAP_WIRE_NOHOLES);
if (rv != KERN_SUCCESS)
-   vm_map_delete(map, old, new);
+   (void)vm_map_delete(map, old, new);
}
if (rv != KERN_SUCCESS) {
 #ifdef RACCT
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r365514 - head/sys/amd64/amd64

2020-09-09 Thread Konstantin Belousov
Author: kib
Date: Wed Sep  9 21:35:44 2020
New Revision: 365514
URL: https://svnweb.freebsd.org/changeset/base/365514

Log:
  Fix assert.
  
  Noted by: alc
  MFC after:1 week

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

Modified: head/sys/amd64/amd64/pmap.c
==
--- head/sys/amd64/amd64/pmap.c Wed Sep  9 21:34:31 2020(r365513)
+++ head/sys/amd64/amd64/pmap.c Wed Sep  9 21:35:44 2020(r365514)
@@ -2385,7 +2385,7 @@ pmap_init(void)
("pmap_init: can't assign to pagesizes[1]"));
pagesizes[1] = NBPDR;
if ((amd_feature & AMDID_PAGE1GB) != 0) {
-   KASSERT(MAXPAGESIZES > 1 && pagesizes[2] == 0,
+   KASSERT(MAXPAGESIZES > 2 && pagesizes[2] == 0,
("pmap_init: can't assign to pagesizes[2]"));
pagesizes[2] = NBPDP;
}
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r365515 - in head/sys: sys vm

2020-09-09 Thread Konstantin Belousov
Author: kib
Date: Wed Sep  9 21:39:06 2020
New Revision: 365515
URL: https://svnweb.freebsd.org/changeset/base/365515

Log:
  Move MAP_32BIT_MAX_ADDR definition to sys/mman.h.
  
  Reviewed by:  markj
  Tested by:pho
  Sponsored by: The FreeBSD Foundation
  MFC after:1 week
  Differential revision:https://reviews.freebsd.org/D24652

Modified:
  head/sys/sys/mman.h
  head/sys/vm/vm_map.c

Modified: head/sys/sys/mman.h
==
--- head/sys/sys/mman.h Wed Sep  9 21:35:44 2020(r365514)
+++ head/sys/sys/mman.h Wed Sep  9 21:39:06 2020(r365515)
@@ -296,6 +296,9 @@ voidshm_drop(struct shmfd *shmfd);
 intshm_dotruncate(struct shmfd *shmfd, off_t length);
 
 extern struct fileops shm_ops;
+
+#defineMAP_32BIT_MAX_ADDR  ((vm_offset_t)1 << 31)
+
 #else /* !_KERNEL */
 
 __BEGIN_DECLS

Modified: head/sys/vm/vm_map.c
==
--- head/sys/vm/vm_map.cWed Sep  9 21:35:44 2020(r365514)
+++ head/sys/vm/vm_map.cWed Sep  9 21:39:06 2020(r365515)
@@ -1913,8 +1913,6 @@ SYSCTL_LONG(_vm, OID_AUTO, aslr_restarts, CTLFLAG_RD,
 &aslr_restarts, 0,
 "Number of aslr failures");
 
-#defineMAP_32BIT_MAX_ADDR  ((vm_offset_t)1 << 31)
-
 /*
  * Searches for the specified amount of free space in the given map with the
  * specified alignment.  Performs an address-ordered, first-fit search from
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r365516 - head/sys/vm

2020-09-09 Thread Konstantin Belousov
Author: kib
Date: Wed Sep  9 21:44:59 2020
New Revision: 365516
URL: https://svnweb.freebsd.org/changeset/base/365516

Log:
  Add vm_map_find_aligned(9).
  
  Reviewed by:  markj
  Tested by:pho
  Sponsored by: The FreeBSD Foundation
  MFC after:1 week
  Differential revision:https://reviews.freebsd.org/D24652

Modified:
  head/sys/vm/vm_map.c
  head/sys/vm/vm_map.h

Modified: head/sys/vm/vm_map.c
==
--- head/sys/vm/vm_map.cWed Sep  9 21:39:06 2020(r365515)
+++ head/sys/vm/vm_map.cWed Sep  9 21:44:59 2020(r365516)
@@ -1980,6 +1980,19 @@ vm_map_alignspace(vm_map_t map, vm_object_t object, vm
}
 }
 
+int
+vm_map_find_aligned(vm_map_t map, vm_offset_t *addr, vm_size_t length,
+vm_offset_t max_addr, vm_offset_t alignment)
+{
+   /* XXXKIB ASLR eh ? */
+   *addr = vm_map_findspace(map, *addr, length);
+   if (*addr + length > vm_map_max(map) ||
+   (max_addr != 0 && *addr + length > max_addr))
+   return (KERN_NO_SPACE);
+   return (vm_map_alignspace(map, NULL, 0, addr, length, max_addr,
+   alignment));
+}
+
 /*
  * vm_map_find finds an unallocated region in the target address
  * map with the given length.  The search is defined to be

Modified: head/sys/vm/vm_map.h
==
--- head/sys/vm/vm_map.hWed Sep  9 21:39:06 2020(r365515)
+++ head/sys/vm/vm_map.hWed Sep  9 21:44:59 2020(r365516)
@@ -460,6 +460,8 @@ int vm_map_find(vm_map_t, vm_object_t, vm_ooffset_t, v
 vm_offset_t, int, vm_prot_t, vm_prot_t, int);
 int vm_map_find_min(vm_map_t, vm_object_t, vm_ooffset_t, vm_offset_t *,
 vm_size_t, vm_offset_t, vm_offset_t, int, vm_prot_t, vm_prot_t, int);
+int vm_map_find_aligned(vm_map_t map, vm_offset_t *addr, vm_size_t length,
+vm_offset_t max_addr, vm_offset_t alignment);
 int vm_map_fixed(vm_map_t, vm_object_t, vm_ooffset_t, vm_offset_t, vm_size_t,
 vm_prot_t, vm_prot_t, int);
 vm_offset_t vm_map_findspace(vm_map_t, vm_offset_t, vm_size_t);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r365517 - head/sys/net/route

2020-09-09 Thread Alexander V. Chernikov
Author: melifaro
Date: Wed Sep  9 21:45:18 2020
New Revision: 365517
URL: https://svnweb.freebsd.org/changeset/base/365517

Log:
  Retain marking net.fibs sysctl as a tunable.
  
  Suggested by: avg

Modified:
  head/sys/net/route/route_tables.c

Modified: head/sys/net/route/route_tables.c
==
--- head/sys/net/route/route_tables.c   Wed Sep  9 21:44:59 2020
(r365516)
+++ head/sys/net/route/route_tables.c   Wed Sep  9 21:45:18 2020
(r365517)
@@ -140,8 +140,8 @@ sysctl_fibs(SYSCTL_HANDLER_ARGS)
return (error);
 }
 SYSCTL_PROC(_net, OID_AUTO, fibs,
-CTLFLAG_VNET | CTLTYPE_U32 | CTLFLAG_MPSAFE, NULL, 0,
-&sysctl_fibs, "IU",
+CTLFLAG_VNET | CTLTYPE_U32 | CTLFLAG_RWTUN | CTLFLAG_NOFETCH | 
CTLFLAG_MPSAFE,
+NULL, 0, &sysctl_fibs, "IU",
 "set number of fibs");
 
 /*
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r364465 - in head/sys: conf net net/route

2020-09-09 Thread Alexander V . Chernikov
09.09.2020, 07:13, "Andriy Gapon" :
> On 09/09/2020 00:50, Alexander V. Chernikov wrote:
>>  08.09.2020, 21:03, "Andriy Gapon" :
>>>  On 22/08/2020 00:34, Alexander V. Chernikov wrote:
   Author: melifaro
   Date: Fri Aug 21 21:34:52 2020
   New Revision: 364465
   URL: https://svnweb.freebsd.org/changeset/base/364465

   Log:
 Make net.fibs growable.

 Allow to dynamically grow the amount of fibs in each vnet.

 This change alters current behavior. Currently, if one defines
  ROUTETABLES > 1 in the kernel config, each vnet will be created
  with the number of fibs defined in the kernel config.
  After this commit vnets will be created with fibs=1.

 Dynamic net.fibs is not compatible with net.add_addr_allfibs.
  The plan is to deprecate the latter and make
  net.add_addr_allfibs=0 default behaviour.

 Reviewed by: glebius
 Relnotes: yes
 Differential Revision: https://reviews.freebsd.org/D26062
>>>
>>>  I wonder why no one reported a problem that I am seeing after upgrading 
>>> past
>>>  this revision. Maybe because I do have net.fibs=2 in my loader.conf?
>>  Hi Andriy,
>>
>>  Does r365475 fix the problem for you?
>>  CTLFLAG_RWTUN flag got slipped through the cracks somewhere :-(
>
> I am not sure that it does, I haven't tried it, but I agree with Ryan's 
> comment.
It should.
> In general, I would keep CTLFLAG_RWTUN as the knob is a tunable indeed and 
> some
> tools query that flag.
Thanks for the suggestion, I've updated the params to include CTLFLAG_NOFETCH 
in r365517.
> So, I would like to re-iterate my earlier suggestion to use CTLFLAG_NOFETCH
> paired with explicit TUNABLE_INT_FETCH (which seems to be there already).
>
>>>  The problem -- unfortunately I only have a screenshot -- but it's a page 
>>> fault
>>>  trap in this call chain:
>>>  sysctl_register_all -> sysctl_load_tunable_by_oid_locked -> sysctl_fibs ->
>>>  _sx_xlock.
>>>
>>>  The crash is on the RTABLES_LOCK() line.
>>>  And it's kind of obvious why.
>>>
>>>  The tunables, including net.fibs which is declared as RWTUN, are set at
>>>  SI_SUB_TUNABLES stage, but RTABLES_LOCK_INIT() is not called until
>>>  SI_SUB_PROTO_DOMAIN much later. In other words, sysctal_fibs can be called
>>>  earlier than vnet_rtables_init.
>>>
>>>  I think that the best way to handle the problem would be to add 
>>> CTLFLAG_NOFETCH
>>>  to the sysctl declaration and then to add -- if necessary at all -- an 
>>> explicit
>>>  query of the kenv.
>>>
>>>  --
>>>  Andriy Gapon
>
> --
> Andriy Gapon
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r365518 - in head/sys: amd64/amd64 vm

2020-09-09 Thread Konstantin Belousov
Author: kib
Date: Wed Sep  9 21:50:24 2020
New Revision: 365518
URL: https://svnweb.freebsd.org/changeset/base/365518

Log:
  Add pmap_enter(9) PMAP_ENTER_LARGEPAGE flag and implement it on amd64.
  
  The flag requests entry of non-managed superpage mapping of size
  pagesizes[psind] into the page table.
  
  Pmap supports fake wiring of the largepage mappings.  Only attributes
  of the largepage mapping can be changed by calling pmap_enter(9) over
  existing mapping, physical address of the page must be unchanged.
  
  Reviewed by:  markj
  Tested by:pho
  Sponsored by: The FreeBSD Foundation
  MFC after:1 week
  Differential revision:https://reviews.freebsd.org/D24652

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

Modified: head/sys/amd64/amd64/pmap.c
==
--- head/sys/amd64/amd64/pmap.c Wed Sep  9 21:45:18 2020(r365517)
+++ head/sys/amd64/amd64/pmap.c Wed Sep  9 21:50:24 2020(r365518)
@@ -6475,6 +6475,119 @@ setpte:
 }
 #endif /* VM_NRESERVLEVEL > 0 */
 
+static int
+pmap_enter_largepage(pmap_t pmap, vm_offset_t va, pt_entry_t newpte, int flags,
+int psind)
+{
+   vm_page_t mp;
+   pt_entry_t origpte, *pml4e, *pdpe, *pde, pten, PG_V;
+
+   PMAP_LOCK_ASSERT(pmap, MA_OWNED);
+   KASSERT(psind > 0 && psind < MAXPAGESIZES,
+   ("psind %d unexpected", psind));
+   KASSERT(((newpte & PG_FRAME) & (pagesizes[psind] - 1)) == 0,
+   ("unaligned phys address %#lx newpte %#lx psind %d",
+   newpte & PG_FRAME, newpte, psind));
+   KASSERT((va & (pagesizes[psind] - 1)) == 0,
+   ("unaligned va %#lx psind %d", va, psind));
+   KASSERT(va < VM_MAXUSER_ADDRESS,
+   ("kernel mode non-transparent superpage")); /* XXXKIB */
+   KASSERT(va + pagesizes[psind] < VM_MAXUSER_ADDRESS,
+   ("overflowing user map va %#lx psind %d", va, psind)); /* XXXKIB */
+
+   PG_V = pmap_valid_bit(pmap);
+
+restart:
+   pten = newpte;
+   if (va < VM_MAXUSER_ADDRESS && pmap->pm_type == PT_X86)
+   pten |= pmap_pkru_get(pmap, va);
+
+   if (psind == 2) {   /* 1G */
+   if (!pmap_pkru_same(pmap, va, va + NBPDP))
+   return (KERN_PROTECTION_FAILURE);
+   pml4e = pmap_pml4e(pmap, va);
+   if ((*pml4e & PG_V) == 0) {
+   mp = _pmap_allocpte(pmap, pmap_pml4e_pindex(va),
+   NULL, va);
+   if (mp == NULL) {
+   if ((flags & PMAP_ENTER_NOSLEEP) != 0)
+   return (KERN_RESOURCE_SHORTAGE);
+   PMAP_UNLOCK(pmap);
+   vm_wait(NULL);
+   PMAP_LOCK(pmap);
+
+   /*
+* Restart at least to recalcuate the pkru
+* key.  Our caller must keep the map locked
+* so no paging structure can be validated
+* under us.
+*/
+   goto restart;
+   }
+   pdpe = pmap_pdpe(pmap, va);
+   KASSERT(pdpe != NULL, ("va %#lx lost pdpe", va));
+   origpte = *pdpe;
+   MPASS(origpte == 0);
+   } else {
+   mp = PHYS_TO_VM_PAGE(*pml4e & PG_FRAME);
+   pdpe = pmap_pdpe(pmap, va);
+   KASSERT(pdpe != NULL, ("va %#lx lost pdpe", va));
+   origpte = *pdpe;
+   if ((origpte & PG_V) == 0)
+   mp->ref_count++;
+   }
+   KASSERT((origpte & PG_V) == 0 || ((origpte & PG_PS) != 0 &&
+   (origpte & PG_FRAME) == (newpte & PG_FRAME)),
+   ("va %#lx changing 1G phys page pdpe %#lx newpte %#lx",
+   va, origpte, newpte));
+   if ((newpte & PG_W) != 0 && (origpte & PG_W) == 0)
+   pmap->pm_stats.wired_count += NBPDP / PAGE_SIZE;
+   else if ((newpte & PG_W) == 0 && (origpte & PG_W) != 0)
+   pmap->pm_stats.wired_count -= NBPDP / PAGE_SIZE;
+   *pdpe = newpte;
+   } else /* (psind == 1) */ { /* 2M */
+   if (!pmap_pkru_same(pmap, va, va + NBPDR))
+   return (KERN_PROTECTION_FAILURE);
+   pde = pmap_pde(pmap, va);
+   if (pde == NULL) {
+   mp = _pmap_allocpte(pmap, pmap_pdpe_pindex(va),
+   NULL, va);
+   if (mp == NULL) {
+   if ((flags & PMAP_ENTER_NOSLEEP) != 0)
+   return (KERN_RESOURCE_SHORTAGE);
+

svn commit: r365520 - head/sys/vm

2020-09-09 Thread Konstantin Belousov
Author: kib
Date: Wed Sep  9 22:02:30 2020
New Revision: 365520
URL: https://svnweb.freebsd.org/changeset/base/365520

Log:
  vm_map: Add a map entry kind that can only be clipped at specific boundary.
  
  The entries and their clip boundaries must be aligned on supported
  superpages sizes from pagesizes[].  vm_map operations return Mach
  error KERN_INVALID_ARGUMENT, which is usually translated to EINVAL, if
  it would require clip not at the boundary.
  
  In other words, entries force preserving virtual addresses superpage
  properties.
  
  Reviewed by:  markj
  Tested by:pho
  Sponsored by: The FreeBSD Foundation
  MFC after:1 week
  Differential revision:https://reviews.freebsd.org/D24652

Modified:
  head/sys/vm/vm_map.c
  head/sys/vm/vm_map.h

Modified: head/sys/vm/vm_map.c
==
--- head/sys/vm/vm_map.cWed Sep  9 21:57:55 2020(r365519)
+++ head/sys/vm/vm_map.cWed Sep  9 22:02:30 2020(r365520)
@@ -1554,13 +1554,17 @@ vm_map_insert(vm_map_t map, vm_object_t object, vm_oof
struct ucred *cred;
vm_eflags_t protoeflags;
vm_inherit_t inheritance;
+   u_long bdry;
+   u_int bidx;
 
VM_MAP_ASSERT_LOCKED(map);
KASSERT(object != kernel_object ||
(cow & MAP_COPY_ON_WRITE) == 0,
("vm_map_insert: kernel object and COW"));
-   KASSERT(object == NULL || (cow & MAP_NOFAULT) == 0,
-   ("vm_map_insert: paradoxical MAP_NOFAULT request"));
+   KASSERT(object == NULL || (cow & MAP_NOFAULT) == 0 ||
+   (cow & MAP_SPLIT_BOUNDARY_MASK) != 0,
+   ("vm_map_insert: paradoxical MAP_NOFAULT request, obj %p cow %#x",
+   object, cow));
KASSERT((prot & ~max) == 0,
("prot %#x is not subset of max_prot %#x", prot, max));
 
@@ -1615,6 +1619,17 @@ vm_map_insert(vm_map_t map, vm_object_t object, vm_oof
inheritance = VM_INHERIT_SHARE;
else
inheritance = VM_INHERIT_DEFAULT;
+   if ((cow & MAP_SPLIT_BOUNDARY_MASK) != 0) {
+   /* This magically ignores index 0, for usual page size. */
+   bidx = (cow & MAP_SPLIT_BOUNDARY_MASK) >>
+   MAP_SPLIT_BOUNDARY_SHIFT;
+   if (bidx >= MAXPAGESIZES)
+   return (KERN_INVALID_ARGUMENT);
+   bdry = pagesizes[bidx] - 1;
+   if ((start & bdry) != 0 || (end & bdry) != 0)
+   return (KERN_INVALID_ARGUMENT);
+   protoeflags |= bidx << MAP_ENTRY_SPLIT_BOUNDARY_SHIFT;
+   }
 
cred = NULL;
if ((cow & (MAP_ACC_NO_CHARGE | MAP_NOFAULT | MAP_CREATE_GUARD)) != 0)
@@ -2342,31 +2357,40 @@ vm_map_entry_clone(vm_map_t map, vm_map_entry_t entry)
  * the specified address; if necessary,
  * it splits the entry into two.
  */
-static inline void
-vm_map_clip_start(vm_map_t map, vm_map_entry_t entry, vm_offset_t start)
+static int
+vm_map_clip_start(vm_map_t map, vm_map_entry_t entry, vm_offset_t startaddr)
 {
vm_map_entry_t new_entry;
+   int bdry_idx;
 
if (!map->system_map)
WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL,
"%s: map %p entry %p start 0x%jx", __func__, map, entry,
-   (uintmax_t)start);
+   (uintmax_t)startaddr);
 
-   if (start <= entry->start)
-   return;
+   if (startaddr <= entry->start)
+   return (KERN_SUCCESS);
 
VM_MAP_ASSERT_LOCKED(map);
-   KASSERT(entry->end > start && entry->start < start,
+   KASSERT(entry->end > startaddr && entry->start < startaddr,
("%s: invalid clip of entry %p", __func__, entry));
 
+   bdry_idx = (entry->eflags & MAP_ENTRY_SPLIT_BOUNDARY_MASK) >>
+   MAP_ENTRY_SPLIT_BOUNDARY_SHIFT;
+   if (bdry_idx != 0) {
+   if ((startaddr & (pagesizes[bdry_idx] - 1)) != 0)
+   return (KERN_INVALID_ARGUMENT);
+   }
+
new_entry = vm_map_entry_clone(map, entry);
 
/*
 * Split off the front portion.  Insert the new entry BEFORE this one,
 * so that this entry has the specified starting address.
 */
-   new_entry->end = start;
+   new_entry->end = startaddr;
vm_map_entry_link(map, new_entry);
+   return (KERN_SUCCESS);
 }
 
 /*
@@ -2376,11 +2400,12 @@ vm_map_clip_start(vm_map_t map, vm_map_entry_t entry, 
  * the interior of the entry.  Return entry after 'start', and in
  * prev_entry set the entry before 'start'.
  */
-static inline vm_map_entry_t
+static int
 vm_map_lookup_clip_start(vm_map_t map, vm_offset_t start,
-vm_map_entry_t *prev_entry)
+vm_map_entry_t *res_entry, vm_map_entry_t *prev_entry)
 {
vm_map_entry_t entry;
+   int rv;
 
if (!map->system_map)
WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL,
@@ -2389,11 +2414,14 @@ vm_

svn commit: r365521 - head/sys/net/route

2020-09-09 Thread Alexander V. Chernikov
Author: melifaro
Date: Wed Sep  9 22:07:54 2020
New Revision: 365521
URL: https://svnweb.freebsd.org/changeset/base/365521

Log:
  Update nexthop handling for route addition/deletion in preparation for mpath.
  
  Currently kernel requests deletion for the certain routes with specified 
gateway,
   but this gateway is not actually checked. With multipath routes, internal 
gateway
   checking becomes mandatory. Add the logic performing this check.
  
  Generalise RTF_PINNED routes to the generic route priorities, simplifying the 
logic.
  
  Add lookup_prefix() function to perform exact match search based on data in 
@info.
  
  Differential Revision:https://reviews.freebsd.org/D26356

Modified:
  head/sys/net/route/route_ctl.c
  head/sys/net/route/route_var.h

Modified: head/sys/net/route/route_ctl.c
==
--- head/sys/net/route/route_ctl.c  Wed Sep  9 22:02:30 2020
(r365520)
+++ head/sys/net/route/route_ctl.c  Wed Sep  9 22:07:54 2020
(r365521)
@@ -86,6 +86,10 @@ static int change_route(struct rib_head *rnh, struct r
 static int change_route_nhop(struct rib_head *rnh, struct rtentry *rt,
 struct rt_addrinfo *info, struct route_nhop_data *rnd,
 struct rib_cmd_info *rc);
+
+static int rt_unlinkrte(struct rib_head *rnh, struct rt_addrinfo *info,
+struct rib_cmd_info *rc);
+
 static void rib_notify(struct rib_head *rnh, enum rib_subscription_type type,
 struct rib_cmd_info *rc);
 
@@ -172,6 +176,141 @@ get_rnh(uint32_t fibnum, const struct rt_addrinfo *inf
 }
 
 /*
+ * Check if specified @gw matches gw data in the nexthop @nh.
+ *
+ * Returns true if matches, false otherwise.
+ */
+static bool
+match_nhop_gw(const struct nhop_object *nh, const struct sockaddr *gw)
+{
+
+   if (nh->gw_sa.sa_family != gw->sa_family)
+   return (false);
+
+   switch (gw->sa_family) {
+   case AF_INET:
+   return (nh->gw4_sa.sin_addr.s_addr ==
+   ((const struct sockaddr_in *)gw)->sin_addr.s_addr);
+   case AF_INET6:
+   {
+   const struct sockaddr_in6 *gw6;
+   gw6 = (const struct sockaddr_in6 *)gw;
+
+   /*
+* Currently (2020-09) IPv6 gws in kernel have their
+* scope embedded. Once this becomes false, this code
+* has to be revisited.
+*/
+   if (IN6_ARE_ADDR_EQUAL(&nh->gw6_sa.sin6_addr,
+   &gw6->sin6_addr))
+   return (true);
+   return (false);
+   }
+   case AF_LINK:
+   {
+   const struct sockaddr_dl *sdl;
+   sdl = (const struct sockaddr_dl *)gw;
+   return (nh->gwl_sa.sdl_index == sdl->sdl_index);
+   }
+   default:
+   return (memcmp(&nh->gw_sa, gw, nh->gw_sa.sa_len) == 0);
+   }
+
+   /* NOTREACHED */
+   return (false);
+}
+
+/*
+ * Checks if data in @info matches nexhop @nh.
+ *
+ * Returns 0 on success,
+ * ESRCH if not matched,
+ * ENOENT if filter function returned false
+ */
+int
+check_info_match_nhop(const struct rt_addrinfo *info, const struct rtentry *rt,
+const struct nhop_object *nh)
+{
+   const struct sockaddr *gw = info->rti_info[RTAX_GATEWAY];
+
+   if (info->rti_filter != NULL) {
+   if (info->rti_filter(rt, nh, info->rti_filterdata) == 0)
+   return (ENOENT);
+   else
+   return (0);
+   }
+   if ((gw != NULL) && !match_nhop_gw(nh, gw))
+   return (ESRCH);
+
+   return (0);
+}
+
+/*
+ * Checks if nexhop @nh can be rewritten by data in @info because
+ *  of higher "priority". Currently the only case for such scenario
+ *  is kernel installing interface routes, marked by RTF_PINNED flag.
+ *
+ * Returns:
+ * 1 if @info data has higher priority
+ * 0 if priority is the same
+ * -1 if priority is lower
+ */
+int
+can_override_nhop(const struct rt_addrinfo *info, const struct nhop_object *nh)
+{
+
+   if (info->rti_flags & RTF_PINNED) {
+   return (NH_IS_PINNED(nh)) ? 0 : 1;
+   } else {
+   return (NH_IS_PINNED(nh)) ? -1 : 0;
+   }
+}
+
+/*
+ * Runs exact prefix match based on @dst and @netmask.
+ * Returns matched @rtentry if found or NULL.
+ * If rtentry was found, saves nexthop / weight value into @rnd.
+ */
+static struct rtentry *
+lookup_prefix_bysa(struct rib_head *rnh, const struct sockaddr *dst,
+const struct sockaddr *netmask, struct route_nhop_data *rnd)
+{
+   struct rtentry *rt;
+
+   RIB_LOCK_ASSERT(rnh);
+
+   rt = (struct rtentry *)rnh->rnh_lookup(__DECONST(void *, dst),
+   __DECONST(void *, netmask), &rnh->head);
+   if (rt != NULL) {
+   rnd->rnd_nhop = rt->rt_nhop;
+   

svn commit: r365522 - in head/sys: kern sys vm

2020-09-09 Thread Konstantin Belousov
Author: kib
Date: Wed Sep  9 22:12:51 2020
New Revision: 365522
URL: https://svnweb.freebsd.org/changeset/base/365522

Log:
  Support for userspace non-transparent superpages (largepages).
  
  Created with shm_open2(SHM_LARGEPAGE) and then configured with
  FIOSSHMLPGCNF ioctl, largepages posix shared memory objects guarantee
  that all userspace mappings of it are served by superpage non-managed
  mappings.
  
  Only amd64 for now, both 2M and 1G superpages can be requested, the
  later requires CPU feature.
  
  Reviewed by:  markj
  Tested by:pho
  Sponsored by: The FreeBSD Foundation
  MFC after:1 week
  Differential revision:https://reviews.freebsd.org/D24652

Modified:
  head/sys/kern/kern_umtx.c
  head/sys/kern/uipc_shm.c
  head/sys/sys/filio.h
  head/sys/sys/mman.h
  head/sys/vm/vm_fault.c
  head/sys/vm/vm_mmap.c

Modified: head/sys/kern/kern_umtx.c
==
--- head/sys/kern/kern_umtx.c   Wed Sep  9 22:07:54 2020(r365521)
+++ head/sys/kern/kern_umtx.c   Wed Sep  9 22:12:51 2020(r365522)
@@ -3933,7 +3933,7 @@ umtx_shm_create_reg(struct thread *td, const struct um
reg = uma_zalloc(umtx_shm_reg_zone, M_WAITOK | M_ZERO);
reg->ushm_refcnt = 1;
bcopy(key, ®->ushm_key, sizeof(*key));
-   reg->ushm_obj = shm_alloc(td->td_ucred, O_RDWR);
+   reg->ushm_obj = shm_alloc(td->td_ucred, O_RDWR, false);
reg->ushm_cred = crhold(cred);
error = shm_dotruncate(reg->ushm_obj, PAGE_SIZE);
if (error != 0) {

Modified: head/sys/kern/uipc_shm.c
==
--- head/sys/kern/uipc_shm.cWed Sep  9 22:07:54 2020(r365521)
+++ head/sys/kern/uipc_shm.cWed Sep  9 22:12:51 2020(r365522)
@@ -2,6 +2,7 @@
  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
  *
  * Copyright (c) 2006, 2011, 2016-2017 Robert N. M. Watson
+ * Copyright 2020 The FreeBSD Foundation
  * All rights reserved.
  *
  * Portions of this software were developed by BAE Systems, the University of
@@ -9,6 +10,9 @@
  * contract FA8650-15-C-7558 ("CADETS"), as part of the DARPA Transparent
  * Computing (TC) research program.
  *
+ * Portions of this software were developed by Konstantin Belousov
+ * under sponsorship from the FreeBSD Foundation.
+ *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
@@ -80,6 +84,7 @@ __FBSDID("$FreeBSD$");
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -120,6 +125,8 @@ static void shm_init(void *arg);
 static voidshm_insert(char *path, Fnv32_t fnv, struct shmfd *shmfd);
 static struct shmfd *shm_lookup(char *path, Fnv32_t fnv);
 static int shm_remove(char *path, Fnv32_t fnv, struct ucred *ucred);
+static int shm_dotruncate_cookie(struct shmfd *shmfd, off_t length,
+void *rl_cookie);
 static int shm_dotruncate_locked(struct shmfd *shmfd, off_t length,
 void *rl_cookie);
 static int shm_copyin_path(struct thread *td, const char *userpath_in,
@@ -159,11 +166,19 @@ struct fileops shm_ops = {
.fo_get_seals = shm_get_seals,
.fo_add_seals = shm_add_seals,
.fo_fallocate = shm_fallocate,
-   .fo_flags = DFLAG_PASSABLE | DFLAG_SEEKABLE
+   .fo_flags = DFLAG_PASSABLE | DFLAG_SEEKABLE,
 };
 
 FEATURE(posix_shm, "POSIX shared memory");
 
+static SYSCTL_NODE(_vm, OID_AUTO, largepages, CTLFLAG_RD | CTLFLAG_MPSAFE, 0,
+"");
+
+static int largepage_reclaim_tries = 1;
+SYSCTL_INT(_vm_largepages, OID_AUTO, reclaim_tries,
+CTLFLAG_RWTUN, &largepage_reclaim_tries, 0,
+"Number of contig reclaims before giving up for default alloc policy");
+
 static int
 uiomove_object_page(vm_object_t obj, size_t len, struct uio *uio)
 {
@@ -242,7 +257,90 @@ uiomove_object(vm_object_t obj, off_t obj_size, struct
return (error);
 }
 
+static u_long count_largepages[MAXPAGESIZES];
+
 static int
+shm_largepage_phys_populate(vm_object_t object, vm_pindex_t pidx,
+int fault_type, vm_prot_t max_prot, vm_pindex_t *first, vm_pindex_t *last)
+{
+   vm_page_t m;
+   int psind;
+
+   psind = object->un_pager.phys.data_val;
+   if (psind == 0 || pidx >= object->size)
+   return (VM_PAGER_FAIL);
+   *first = rounddown2(pidx, pagesizes[psind] / PAGE_SIZE);
+
+   /*
+* We only busy the first page in the superpage run.  It is
+* useless to busy whole run since we only remove full
+* superpage, and it takes too long to busy e.g. 512 * 512 ==
+* 262144 pages constituing 1G amd64 superage.
+*/
+   m = vm_page_grab(object, *first, VM_ALLOC_NORMAL | VM_ALLOC_NOCREAT);
+   MPASS(m != NULL);
+
+   *last = *first + atop(pagesizes[psind]) - 1;
+   return (VM_PAGER_OK);
+}
+
+static boolean_t
+shm_largepage_phys_haspage(vm_object_t object, vm_pi

svn commit: r365523 - head/lib/libsysdecode

2020-09-09 Thread Konstantin Belousov
Author: kib
Date: Wed Sep  9 22:18:44 2020
New Revision: 365523
URL: https://svnweb.freebsd.org/changeset/base/365523

Log:
  Fix compilation of libsysdecode after r365522, should have been part of it.
  
  Reviewed by:  markj
  Tested by:pho
  Sponsored by: The FreeBSD Foundation
  MFC after:1 week
  Differential revision:https://reviews.freebsd.org/D24652

Modified:
  head/lib/libsysdecode/mkioctls

Modified: head/lib/libsysdecode/mkioctls
==
--- head/lib/libsysdecode/mkioctls  Wed Sep  9 22:12:51 2020
(r365522)
+++ head/lib/libsysdecode/mkioctls  Wed Sep  9 22:18:44 2020
(r365523)
@@ -51,6 +51,7 @@ BEGIN {
print "#include "
print "#include "
print "#include "
+   print "#include "
print "#include "
print "#include "
print "#include "
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r365524 - head/lib/libc/sys

2020-09-09 Thread Konstantin Belousov
Author: kib
Date: Wed Sep  9 22:20:36 2020
New Revision: 365524
URL: https://svnweb.freebsd.org/changeset/base/365524

Log:
  Add shm_create_largepage(3) helper for creation and configuration of
  largepage shm objects.
  
  And since we can, add memfd_create(MFD_HUGETLB) support, hopefully
  close enough to the Linux feature.
  
  Reviewed by:  markj
  Tested by:pho
  Sponsored by: The FreeBSD Foundation
  MFC after:1 week
  Differential revision:https://reviews.freebsd.org/D24652

Modified:
  head/lib/libc/sys/Symbol.map
  head/lib/libc/sys/shm_open.c

Modified: head/lib/libc/sys/Symbol.map
==
--- head/lib/libc/sys/Symbol.mapWed Sep  9 22:18:44 2020
(r365523)
+++ head/lib/libc/sys/Symbol.mapWed Sep  9 22:20:36 2020
(r365524)
@@ -411,6 +411,7 @@ FBSD_1.6 {
getfhat;
funlinkat;
memfd_create;
+   shm_create_largepage;
shm_rename;
 };
 
@@ -919,6 +920,7 @@ FBSDprivate_1.0 {
__sys_setuid;
_shm_open;
__sys_shm_open;
+   __sys_shm_open2;
_shm_unlink;
__sys_shm_unlink;
_shmat;

Modified: head/lib/libc/sys/shm_open.c
==
--- head/lib/libc/sys/shm_open.cWed Sep  9 22:18:44 2020
(r365523)
+++ head/lib/libc/sys/shm_open.cWed Sep  9 22:20:36 2020
(r365524)
@@ -31,14 +31,17 @@
 #include 
 __FBSDID("$FreeBSD$");
 
-#include 
+#include 
+#include 
 #include 
 
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
+#include 
 
 #include "libc_private.h"
 
@@ -54,6 +57,51 @@ shm_open(const char *path, int flags, mode_t mode)
return (__sys_shm_open2(path, flags | O_CLOEXEC, mode, 0, NULL));
 }
 
+int
+shm_create_largepage(const char *path, int flags, int psind, int alloc_policy,
+mode_t mode)
+{
+   struct shm_largepage_conf slc;
+   int error, fd, saved_errno;
+
+   fd = __sys_shm_open2(path, flags | O_CREAT, mode, SHM_LARGEPAGE, NULL);
+   if (error == -1)
+   return (-1);
+
+   memset(&slc, 0, sizeof(slc));
+   slc.psind = psind;
+   slc.alloc_policy = alloc_policy;
+   error = ioctl(fd, FIOSSHMLPGCNF, &slc);
+   if (error == -1) {
+   saved_errno = errno;
+   close(fd);
+   errno = saved_errno;
+   return (-1);
+   }
+   return (fd);
+}
+
+#defineK(x)((size_t)(x) * 1024)
+#defineM(x)(K(x) * 1024)
+#defineG(x)(M(x) * 1024)
+static const struct {
+   int mask;
+   size_t pgsize;
+} mfd_huge_sizes[] = {
+   { .mask = MFD_HUGE_64KB,.pgsize = K(64) },
+   { .mask = MFD_HUGE_512KB,   .pgsize = K(512) },
+   { .mask = MFD_HUGE_1MB, .pgsize = M(1) },
+   { .mask = MFD_HUGE_2MB, .pgsize = M(2) },
+   { .mask = MFD_HUGE_8MB, .pgsize = M(8) },
+   { .mask = MFD_HUGE_16MB,.pgsize = M(16) },
+   { .mask = MFD_HUGE_32MB,.pgsize = M(32) },
+   { .mask = MFD_HUGE_256MB,   .pgsize = M(256) },
+   { .mask = MFD_HUGE_512MB,   .pgsize = M(512) },
+   { .mask = MFD_HUGE_1GB, .pgsize = G(1) },
+   { .mask = MFD_HUGE_2GB, .pgsize = G(2) },
+   { .mask = MFD_HUGE_16GB,.pgsize = G(16) },
+};
+
 /*
  * The path argument is passed to the kernel, but the kernel doesn't currently
  * do anything with it.  Linux exposes it in linprocfs for debugging purposes
@@ -63,8 +111,9 @@ int
 memfd_create(const char *name, unsigned int flags)
 {
char memfd_name[NAME_MAX + 1];
-   size_t namelen;
-   int oflags, shmflags;
+   size_t namelen, *pgs;
+   struct shm_largepage_conf slc;
+   int error, fd, i, npgs, oflags, pgidx, saved_errno, shmflags;
 
if (name == NULL)
return (EBADF);
@@ -75,11 +124,9 @@ memfd_create(const char *name, unsigned int flags)
MFD_HUGE_MASK)) != 0)
return (EINVAL);
/* Size specified but no HUGETLB. */
-   if ((flags & MFD_HUGE_MASK) != 0 && (flags & MFD_HUGETLB) == 0)
+   if (((flags & MFD_HUGE_MASK) != 0 && (flags & MFD_HUGETLB) == 0) ||
+   __bitcount(flags & MFD_HUGE_MASK) > 1)
return (EINVAL);
-   /* We don't actually support HUGETLB. */
-   if ((flags & MFD_HUGETLB) != 0)
-   return (ENOSYS);
 
/* We've already validated that we're sufficiently sized. */
snprintf(memfd_name, NAME_MAX + 1, "%s%s", MEMFD_NAME_PREFIX, name);
@@ -89,5 +136,57 @@ memfd_create(const char *name, unsigned int flags)
oflags |= O_CLOEXEC;
if ((flags & MFD_ALLOW_SEALING) != 0)
shmflags |= SHM_ALLOW_SEALING;
-   return (__sys_shm_open2(SHM_ANON, oflags, 0, shmflags, memfd_name));
+   if ((flags & MFD_HUGETLB) == 0)
+   shmflags |= SHM_LA

svn commit: r365525 - head/usr.bin/posixshmcontrol

2020-09-09 Thread Konstantin Belousov
Author: kib
Date: Wed Sep  9 22:22:02 2020
New Revision: 365525
URL: https://svnweb.freebsd.org/changeset/base/365525

Log:
  Add posixshmcontrol(1) support for largepage shm objects.
  
  Create op with -l  option can create it, stat displays
  configured page size.
  
  Reviewed by:  markj
  Tested by:pho
  Sponsored by: The FreeBSD Foundation
  MFC after:1 week
  Differential revision:https://reviews.freebsd.org/D24652

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

Modified: head/usr.bin/posixshmcontrol/posixshmcontrol.c
==
--- head/usr.bin/posixshmcontrol/posixshmcontrol.c  Wed Sep  9 22:20:36 
2020(r365524)
+++ head/usr.bin/posixshmcontrol/posixshmcontrol.c  Wed Sep  9 22:22:02 
2020(r365525)
@@ -30,8 +30,10 @@
 __FBSDID("$FreeBSD$");
 
 #include 
+#include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -50,7 +52,7 @@ usage(void)
 {
 
fprintf(stderr, "Usage:\n"
-   "posixshmcontrol create [-m ]  ...\n"
+   "posixshmcontrol create [-m ] [-l ]  ...\n"
"posixshmcontrol rm  ...\n"
"posixshmcontrol ls [-h] [-n]\n"
"posixshmcontrol dump  ...\n"
@@ -59,14 +61,23 @@ usage(void)
 }
 
 static int
-create_one_shm(const char *path, long mode)
+create_one_shm(const char *path, long mode, int idx)
 {
int fd;
 
-   fd = shm_open(path, O_RDWR | O_CREAT, mode);
-   if (fd == -1) {
-   warn("create %s", path);
-   return (1);
+   if (idx == -1) {
+   fd = shm_open(path, O_RDWR | O_CREAT, mode);
+   if (fd == -1) {
+   warn("create %s", path);
+   return (1);
+   }
+   } else {
+   fd = shm_create_largepage(path, O_RDWR, idx,
+   SHM_LARGEPAGE_ALLOC_DEFAULT, mode);
+   if (fd == -1) {
+   warn("shm_create_largepage %s psind %d", path, idx);
+   return (1);
+   }
}
close(fd);
return (0);
@@ -76,20 +87,60 @@ static int
 create_shm(int argc, char **argv)
 {
char *end;
+   size_t *pagesizes;
long mode;
-   int c, i, ret, ret1;
+   uint64_t pgsz;
+   int c, i, idx, pn, ret, ret1;
+   bool printed;
 
mode = 0600;
-   while ((c = getopt(argc, argv, "m:")) != -1) {
+   idx = -1;
+   while ((c = getopt(argc, argv, "l:m:")) != -1) {
switch (c) {
case 'm':
errno = 0;
mode = strtol(optarg, &end, 0);
if (mode == 0 && errno != 0)
-   err(1, "mode:");
+   err(1, "mode");
if (*end != '\0')
errx(1, "non-integer mode");
break;
+   case 'l':
+   if (expand_number(optarg, &pgsz) == -1)
+   err(1, "size");
+   pn = getpagesizes(NULL, 0);
+   if (pn == -1)
+   err(1, "getpagesizes");
+   pagesizes = malloc(sizeof(size_t) * pn);
+   if (pagesizes == NULL)
+   err(1, "malloc");
+   if (getpagesizes(pagesizes, pn) == -1)
+   err(1, "gtpagesizes");
+   for (idx = 0; idx < pn; idx++) {
+   if (pagesizes[idx] == pgsz)
+   break;
+   }
+   if (idx == pn) {
+   fprintf(stderr,
+"pagesize should be superpagesize, supported sizes:");
+   printed = false;
+   for (i = 0; i < pn; i++) {
+   if (pagesizes[i] == 0 ||
+   pagesizes[i] == (size_t)
+   getpagesize())
+   continue;
+   printed = true;
+   fprintf(stderr, " %zu", pagesizes[i]);
+   }
+   if (!printed)
+   fprintf(stderr, " none");
+   fprintf(stderr, "\n");
+   exit(1);
+   }
+   if (pgsz == (uint64_t)getpagesize())
+   errx(1, "pagesize should be large");
+   free(pagesizes);
+   break;
case '?':
default:
usage();
@@ -101,7 +152,7 @@ create_shm(int argc, char **argv)
ar

Re: svn commit: r365419 - in head/sys/dev: ath bwi iwm iwn mwl otus usb/wlan wtap

2020-09-09 Thread Tomoaki AOKI
This breaks at least iwm. (Other drivers not tested.)

Messages below are repeatedly shown and no carrier detected.
Manually reverting this commit fixes the issue.

iwm0: failed to send antennas before calibration: 35
iwm_run_init_ucode: failed 35
iwm_init_hw failed 35
iwm0: could not initiate scan


and lesser times messages below.

iwm0: iwm_send_phy_db_data: Cannot send HCMD of Phy DB cfg section, 35
iwm_init_hw failed 35
iwm0: could not initiate scan


> Author: bz
> Date: Mon Sep  7 15:35:40 2020
> New Revision: 365419
> URL: https://svnweb.freebsd.org/changeset/base/365419
> 
> Log:
>   WiFi: fix ieee80211_media_change() callers
>   
>   In r178354 with the introduction of multi-bss ("vap") support
factoring
>   out started and with r193340 ieee80211_media_change() no longer returned
>  ENETRESET but only 0 or error.
>   As ieee80211(9) tells the ieee80211_media_change() function should not
>   be called directly but is registered with ieee80211_vap_attach()
instead. 
>   Some drivers have not been fully converted.  After fixing the return
>   checking some of these functions were simply wrappers between
>   ieee80211_vap_attach() and ieee80211_media_change(), so remove the
extra
>   function, where possible as well.
>   
>   PR: 248955
>   Submitted by:   Tong Zhang (ztong0001 gmail.com) (original)
>   MFC after:  3 days
>   Sponsored by:   The FreeBSD Foundation
> 
> Modified:
>   head/sys/dev/ath/if_ath.c
>   head/sys/dev/bwi/if_bwi.c
>   head/sys/dev/iwm/if_iwm.c
>   head/sys/dev/iwn/if_iwn.c
>   head/sys/dev/mwl/if_mwl.c
>   head/sys/dev/otus/if_otus.c
>   head/sys/dev/usb/wlan/if_run.c
>   head/sys/dev/wtap/if_wtap.c
> 
> Modified: head/sys/dev/ath/if_ath.c
> ==
> --- head/sys/dev/ath/if_ath.c Mon Sep  7 14:40:33 2020(r365418)
> +++ head/sys/dev/ath/if_ath.c Mon Sep  7 15:35:40 2020(r365419)
> @@ -160,7 +160,6 @@ static intath_init(struct ath_softc *);
>  static void  ath_stop(struct ath_softc *);
>  static int   ath_reset_vap(struct ieee80211vap *, u_long);
>  static int   ath_transmit(struct ieee80211com *, struct mbuf *);
> -static int   ath_media_change(struct ifnet *);
>  static void  ath_watchdog(void *);
>  static void  ath_parent(struct ieee80211com *);
>  static void  ath_fatal_proc(void *, int);

(snip)

> Modified: head/sys/dev/iwm/if_iwm.c
> ==
> --- head/sys/dev/iwm/if_iwm.c Mon Sep  7 14:40:33 2020(r365418)
> +++ head/sys/dev/iwm/if_iwm.c Mon Sep  7 15:35:40 2020(r365419)
> @@ -4426,8 +4426,8 @@ iwm_media_change(struct ifnet *ifp)
>   int error;
>  
>   error = ieee80211_media_change(ifp);
> - if (error != ENETRESET)
> - return error;
> + if (error != 0)
> + return (error);
>  
>   IWM_LOCK(sc);
>   if (ic->ic_nrunning > 0) {
> @@ -4435,7 +4435,7 @@ iwm_media_change(struct ifnet *ifp)
>   iwm_init(sc);
>   }
>   IWM_UNLOCK(sc);
> - return error;
> + return (0);
>  }
>  
>  static void

(snip)
 

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


svn commit: r365546 - head/sys/netinet/cc

2020-09-09 Thread Richard Scheffenegger
Author: rscheff
Date: Thu Sep 10 00:46:38 2020
New Revision: 365546
URL: https://svnweb.freebsd.org/changeset/base/365546

Log:
  cc_mod: remove unused CCF_DELACK definition
  
  During the DCTCP improvements, use of CCF_DELACK was
  removed. This change is just to rename the unused flag
  bit to prevent use of it, without also re-implementing
  the tcp_input and tcp_output interfaces.
  
  No functional change.
  
  Reviewed by:  chengc_netapp.com, tuexen
  MFC after:2 weeks
  Sponsored by: NetApp, Inc.
  Differential Revision:https://reviews.freebsd.org/D26181

Modified:
  head/sys/netinet/cc/cc.h

Modified: head/sys/netinet/cc/cc.h
==
--- head/sys/netinet/cc/cc.hWed Sep  9 23:11:55 2020(r365545)
+++ head/sys/netinet/cc/cc.hThu Sep 10 00:46:38 2020(r365546)
@@ -96,7 +96,7 @@ struct cc_var {
 /* cc_var flags. */
 #defineCCF_ABC_SENTAWND0x0001  /* ABC counted cwnd worth of 
bytes? */
 #defineCCF_CWND_LIMITED0x0002  /* Are we currently cwnd 
limited? */
-#defineCCF_DELACK  0x0004  /* Is this ack delayed? */
+#defineCCF_UNUSED1 0x0004  /* unused */
 #defineCCF_ACKNOW  0x0008  /* Will this ack be sent now? */
 #defineCCF_IPHDR_CE0x0010  /* Does this packet set CE bit? 
*/
 #defineCCF_TCPHDR_CWR  0x0020  /* Does this packet set CWR 
bit? */
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r365547 - head/sbin/ping6

2020-09-09 Thread Richard Scheffenegger
Author: rscheff
Date: Thu Sep 10 00:50:18 2020
New Revision: 365547
URL: https://svnweb.freebsd.org/changeset/base/365547

Log:
  Add -z "TOS" option to ping6, to test DSCP/ECN values
  
  ping has the option to add the (deprecated) TOS byte
  using the -z option. Adding the same option, with the
  same (deprecated) Traffic Class Byte (nowadays actually
  DSCP and ECN fields) to ping6 to validate proper QoS
  processing in network switches.
  
  Reviewed by:  tuexen
  MFC after:2 weeks
  Sponsored by: NetApp, Inc.
  Differential Revision:https://reviews.freebsd.org/D26384

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

Modified: head/sbin/ping6/ping6.8
==
--- head/sbin/ping6/ping6.8 Thu Sep 10 00:46:38 2020(r365546)
+++ head/sbin/ping6/ping6.8 Thu Sep 10 00:50:18 2020(r365547)
@@ -29,7 +29,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd October 20, 2019
+.Dd September 10, 2020
 .Dt PING6 8
 .Os
 .Sh NAME
@@ -87,6 +87,9 @@ packets to network hosts
 .Op Fl W Ar waittime
 .Ek
 .Bk -words
+.Op Fl z Ar tclass
+.Ek
+.Bk -words
 .Op Ar hops ...
 .Ek
 .Bk -words
@@ -329,6 +332,8 @@ This option is present for backward compatibility.
 has no effect if
 .Fl y
 is specified.
+.It Fl z Ar tclass
+Use the specified traffic class when sending.
 .It Ar hops
 IPv6 addresses for intermediate nodes,
 which will be put into type 0 routing header.

Modified: head/sbin/ping6/ping6.c
==
--- head/sbin/ping6/ping6.c Thu Sep 10 00:46:38 2020(r365546)
+++ head/sbin/ping6/ping6.c Thu Sep 10 00:50:18 2020(r365547)
@@ -229,6 +229,7 @@ static char *hostname;
 static int ident;  /* process id to identify our packets */
 static u_int8_t nonce[8];  /* nonce field for node information */
 static int hoplimit = -1;  /* hoplimit */
+static int tclass = -1;/* traffic class */
 static u_char *packet = NULL;
 static cap_channel_t *capdns;
 
@@ -352,7 +353,7 @@ main(int argc, char *argv[])
 #endif /*IPSEC_POLICY_IPSEC*/
 #endif
while ((ch = getopt(argc, argv,
-   "k:b:c:DdfHe:m:I:i:l:unNop:qaAS:s:OvyYW:t:" ADDOPTS)) != -1) {
+   "k:b:c:DdfHe:m:I:i:l:unNop:qaAS:s:OvyYW:t:z:" ADDOPTS)) != -1) {
 #undef ADDOPTS
switch (ch) {
case 'k':
@@ -585,6 +586,14 @@ main(int argc, char *argv[])
err(1, "setitimer");
}
break;
+   case 'z':   /* traffic class */
+   tclass = strtol(optarg, &e, 10);
+   if (*optarg == '\0' || *e != '\0')
+   errx(1, "illegal traffic class %s", optarg);
+   if (255 < tclass || tclass < -1)
+   errx(1,
+   "illegal traffic class -- %s", optarg);
+   break;
 #ifdef IPSEC
 #ifdef IPSEC_POLICY_IPSEC
case 'P':
@@ -935,6 +944,12 @@ main(int argc, char *argv[])
memcpy(CMSG_DATA(scmsgp), &hoplimit, sizeof(hoplimit));
 
scmsgp = CMSG_NXTHDR(&smsghdr, scmsgp);
+   }
+
+   if (tclass != -1) {
+   if (setsockopt(ssend, IPPROTO_IPV6, IPV6_TCLASS,
+   &tclass, sizeof(tclass)) == -1)
+   err(1, "setsockopt(IPV6_TCLASS)");
}
 
if (argc > 1) { /* some intermediate addrs are specified */
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r365548 - head/sys/powerpc/powernv

2020-09-09 Thread Brandon Bergren
Author: bdragon
Date: Thu Sep 10 01:49:53 2020
New Revision: 365548
URL: https://svnweb.freebsd.org/changeset/base/365548

Log:
  [PowerPC] Fix setting of time in OPAL
  
  There were multiple bugs in the OPAL RTC code which had never been
  discovered, as the default configuration of OPAL machines is to
  have the BMC / FSP control the RTC.
  
  * Fix calling convention for setting the time -- the variables are passed
  directly in CPU registers, not via memory.
  
  * Fix bug in the bcd encoding routines. (from jhibbits)
  
  Tested on POWER9 Talos II (BE) and POWER9 Blackbird (LE).
  
  Reviewed by:  jhibbits (in irc)
  Sponsored by: Tag1 Consulting, Inc.

Modified:
  head/sys/powerpc/powernv/opal_dev.c

Modified: head/sys/powerpc/powernv/opal_dev.c
==
--- head/sys/powerpc/powernv/opal_dev.c Thu Sep 10 00:50:18 2020
(r365547)
+++ head/sys/powerpc/powernv/opal_dev.c Thu Sep 10 01:49:53 2020
(r365548)
@@ -256,15 +256,15 @@ bin2bcd32(int bin)
int tmp;
 
tmp = bin % 100;
-   out += bin2bcd(tmp) * 1;
+   out += bin2bcd(tmp) * 0x1;
bin = bin / 100;
 
tmp = bin % 100;
-   out += bin2bcd(tmp) * 100;
+   out += bin2bcd(tmp) * 0x100;
bin = bin / 100;
 
tmp = bin % 100;
-   out += bin2bcd(tmp) * 1;
+   out += bin2bcd(tmp) * 0x1;
 
return (out);
 }
@@ -297,7 +297,7 @@ opal_gettime(device_t dev, struct timespec *ts)
 
ct.day  = bcd2bin((ymd & 0x00ff) >> 0);
ct.mon  = bcd2bin((ymd & 0xff00) >> 8);
-   ct.year = bcd2bin32((ymd & 0x) >> 16);
+   ct.year = bcd2bin32((ymd & 0x) >> 16);
 
return (clock_ct_to_ts(&ct, ts));
 }
@@ -321,11 +321,12 @@ opal_settime(device_t dev, struct timespec *ts)
hmsm |= ((uint64_t)bin2bcd(ct.min) << 48);
hmsm |= ((uint64_t)bin2bcd(ct.hour) << 56);
 
-   hmsm = htobe64(hmsm);
-   ymd = htobe32(ymd);
-
+   /*
+* We do NOT swap endian here, because the values are being sent
+* via registers instead of indirect via memory.
+*/
do {
-   rv = opal_call(OPAL_RTC_WRITE, vtophys(&ymd), vtophys(&hmsm));
+   rv = opal_call(OPAL_RTC_WRITE, ymd, hmsm);
if (rv == OPAL_BUSY_EVENT) {
rv = opal_call(OPAL_POLL_EVENTS, 0);
pause("opalrtc", 1);
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r365549 - head/bin/cp

2020-09-09 Thread Alan Somers
Author: asomers
Date: Thu Sep 10 02:48:55 2020
New Revision: 365549
URL: https://svnweb.freebsd.org/changeset/base/365549

Log:
  cp: use copy_file_range(2)
  
  This has three advantages over write(2)/read(2):
  
  * Fewer context switches and data copies
  * Mostly preserves a file's sparseness
  * On some file systems (currently NFS 4.2) the file system will perform the
copy in an especially efficient way.
  
  Reviewed by:  rmacklem
  MFC after:2 weeks
  Sponsored by: Axcient
  Differential Revision:https://reviews.freebsd.org/D26377

Modified:
  head/bin/cp/utils.c

Modified: head/bin/cp/utils.c
==
--- head/bin/cp/utils.c Thu Sep 10 01:49:53 2020(r365548)
+++ head/bin/cp/utils.c Thu Sep 10 02:48:55 2020(r365549)
@@ -212,27 +212,16 @@ copy_file(const FTSENT *entp, int dne)
err(1, "Not enough memory");
}
wtotal = 0;
-   while ((rcount = read(from_fd, buf, bufsize)) > 0) {
-   for (bufp = buf, wresid = rcount; ;
-   bufp += wcount, wresid -= wcount) {
-   wcount = write(to_fd, bufp, wresid);
-   if (wcount <= 0)
-   break;
-   wtotal += wcount;
-   if (info) {
-   info = 0;
-   (void)fprintf(stderr,
-   "%s -> %s %3d%%\n",
-   entp->fts_path, to.p_path,
-   cp_pct(wtotal, 
fs->st_size));
-   }
-   if (wcount >= (ssize_t)wresid)
-   break;
-   }
-   if (wcount != (ssize_t)wresid) {
-   warn("%s", to.p_path);
-   rval = 1;
-   break;
+   while ((rcount = copy_file_range(from_fd, NULL,
+   to_fd, NULL, bufsize, 0)) > 0)
+   {
+   wtotal += rcount;
+   if (info) {
+   info = 0;
+   (void)fprintf(stderr,
+   "%s -> %s %3d%%\n",
+   entp->fts_path, to.p_path,
+   cp_pct(wtotal, fs->st_size));
}
}
if (rcount < 0) {
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r365550 - head/sys/contrib/dev/ice

2020-09-09 Thread Eric Joyner
Author: erj
Date: Thu Sep 10 04:00:13 2020
New Revision: 365550
URL: https://svnweb.freebsd.org/changeset/base/365550

Log:
  ice_ddp: Fix 1.3.16.0 package
  
  The version uploaded in the previous commit was far too small. This one
  should be the right size.
  
  MFC after:1 day
  Sponsored by: Intel Corporation

Modified:
  head/sys/contrib/dev/ice/ice-1.3.16.0.pkg

Modified: head/sys/contrib/dev/ice/ice-1.3.16.0.pkg
==
Binary file (source and/or target). No diff available.
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


Re: svn commit: r365517 - head/sys/net/route

2020-09-09 Thread Andriy Gapon
On 10/09/2020 00:45, Alexander V. Chernikov wrote:
> Author: melifaro
> Date: Wed Sep  9 21:45:18 2020
> New Revision: 365517
> URL: https://svnweb.freebsd.org/changeset/base/365517
> 
> Log:
>   Retain marking net.fibs sysctl as a tunable.
>   
>   Suggested by:   avg
> 
> Modified:
>   head/sys/net/route/route_tables.c
> 
> Modified: head/sys/net/route/route_tables.c
> ==
> --- head/sys/net/route/route_tables.c Wed Sep  9 21:44:59 2020
> (r365516)
> +++ head/sys/net/route/route_tables.c Wed Sep  9 21:45:18 2020
> (r365517)
> @@ -140,8 +140,8 @@ sysctl_fibs(SYSCTL_HANDLER_ARGS)
>   return (error);
>  }
>  SYSCTL_PROC(_net, OID_AUTO, fibs,
> -CTLFLAG_VNET | CTLTYPE_U32 | CTLFLAG_MPSAFE, NULL, 0,
> -&sysctl_fibs, "IU",
> +CTLFLAG_VNET | CTLTYPE_U32 | CTLFLAG_RWTUN | CTLFLAG_NOFETCH | 
> CTLFLAG_MPSAFE,
> +NULL, 0, &sysctl_fibs, "IU",
>  "set number of fibs");
>  
>  /*
> 

Just upgraded and this version works perfectly.
Thank you!

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


Re: svn commit: r365521 - head/sys/net/route

2020-09-09 Thread Hartmann, O.
On Wed, 9 Sep 2020 22:07:55 + (UTC)
"Alexander V. Chernikov"  wrote:

> Author: melifaro
> Date: Wed Sep  9 22:07:54 2020
> New Revision: 365521
> URL: https://svnweb.freebsd.org/changeset/base/365521
>
> Log:
>   Update nexthop handling for route addition/deletion in preparation
> for mpath.
>   Currently kernel requests deletion for the certain routes with
> specified gateway, but this gateway is not actually checked. With
> multipath routes, internal gateway checking becomes mandatory. Add
> the logic performing this check.
>   Generalise RTF_PINNED routes to the generic route priorities,
> simplifying the logic.
>   Add lookup_prefix() function to perform exact match search based on
> data in @info.
>   Differential Revision:  https://reviews.freebsd.org/D26356
>
> Modified:
>   head/sys/net/route/route_ctl.c
>   head/sys/net/route/route_var.h
>
> Modified: head/sys/net/route/route_ctl.c
> ==
> --- head/sys/net/route/route_ctl.cWed Sep  9 22:02:30
> 2020  (r365520) +++ head/sys/net/route/route_ctl.cWed
> Sep  9 22:07:54 2020  (r365521) @@ -86,6 +86,10 @@ static int
> change_route(struct rib_head *rnh, struct r static int
> change_route_nhop(struct rib_head *rnh, struct rtentry *rt, struct
> rt_addrinfo *info, struct route_nhop_data *rnd, struct rib_cmd_info
> *rc); +
> +static int rt_unlinkrte(struct rib_head *rnh, struct rt_addrinfo
> *info,
> +struct rib_cmd_info *rc);
> +
>  static void rib_notify(struct rib_head *rnh, enum
> rib_subscription_type type, struct rib_cmd_info *rc);
>
> @@ -172,6 +176,141 @@ get_rnh(uint32_t fibnum, const struct
> rt_addrinfo *inf }
>
>  /*
> + * Check if specified @gw matches gw data in the nexthop @nh.
> + *
> + * Returns true if matches, false otherwise.
> + */
> +static bool
> +match_nhop_gw(const struct nhop_object *nh, const struct sockaddr
> *gw) +{
> +
> + if (nh->gw_sa.sa_family != gw->sa_family)
> + return (false);
> +
> + switch (gw->sa_family) {
> + case AF_INET:
> + return (nh->gw4_sa.sin_addr.s_addr ==
> + ((const struct sockaddr_in
> *)gw)->sin_addr.s_addr);
> + case AF_INET6:
> + {
> + const struct sockaddr_in6 *gw6;
> + gw6 = (const struct sockaddr_in6 *)gw;
> +
> + /*
> +  * Currently (2020-09) IPv6 gws in kernel
> have their
> +  * scope embedded. Once this becomes false,
> this code
> +  * has to be revisited.
> +  */
> + if (IN6_ARE_ADDR_EQUAL(&nh->gw6_sa.sin6_addr,
> + &gw6->sin6_addr))
> + return (true);
> + return (false);
> + }
> + case AF_LINK:
> + {
> + const struct sockaddr_dl *sdl;
> + sdl = (const struct sockaddr_dl *)gw;
> + return (nh->gwl_sa.sdl_index ==
> sdl->sdl_index);
> + }
> + default:
> + return (memcmp(&nh->gw_sa, gw, nh->gw_sa.sa_len) ==
> 0);
> + }
> +
> + /* NOTREACHED */
> + return (false);
> +}
> +
> +/*
> + * Checks if data in @info matches nexhop @nh.
> + *
> + * Returns 0 on success,
> + * ESRCH if not matched,
> + * ENOENT if filter function returned false
> + */
> +int
> +check_info_match_nhop(const struct rt_addrinfo *info, const struct
> rtentry *rt,
> +const struct nhop_object *nh)
> +{
> + const struct sockaddr *gw = info->rti_info[RTAX_GATEWAY];
> +
> + if (info->rti_filter != NULL) {
> + if (info->rti_filter(rt, nh, info->rti_filterdata) == 0)
> + return (ENOENT);
> + else
> + return (0);
> + }
> + if ((gw != NULL) && !match_nhop_gw(nh, gw))
> + return (ESRCH);
> +
> + return (0);
> +}
> +
> +/*
> + * Checks if nexhop @nh can be rewritten by data in @info because
> + *  of higher "priority". Currently the only case for such scenario
> + *  is kernel installing interface routes, marked by RTF_PINNED flag.
> + *
> + * Returns:
> + * 1 if @info data has higher priority
> + * 0 if priority is the same
> + * -1 if priority is lower
> + */
> +int
> +can_override_nhop(const struct rt_addrinfo *info, const struct
> nhop_object *nh) +{
> +
> + if (info->rti_flags & RTF_PINNED) {
> + return (NH_IS_PINNED(nh)) ? 0 : 1;
> + } else {
> + return (NH_IS_PINNED(nh)) ? -1 : 0;
> + }
> +}
> +
> +/*
> + * Runs exact prefix match based on @dst and @netmask.
> + * Returns matched @rtentry if found or NULL.
> + * If rtentry was found, saves nexthop / weight value into @rnd.
> + */
> +static struct rtentry *
> +lookup_prefix_bysa(struct rib_head *rnh, const struct sockaddr *dst,
> +const struct sockaddr *netmask, struct route_nhop_data *rnd)
> +{
> + struct rtentry *rt;
> +
> + RIB_LOCK_ASSERT

svn commit: r365553 - in head: . share/man/man9

2020-09-09 Thread Li-Wen Hsu
Author: lwhsu
Date: Thu Sep 10 06:32:25 2020
New Revision: 365553
URL: https://svnweb.freebsd.org/changeset/base/365553

Log:
  Remove vm_map_create(9) KPI's manpage according to r364302
  
  Submitted by: Ka Ho Ng 
  Reviewed by:  markj
  Sponsored by: The FreeBSD Foundation
  Differential Revision:https://reviews.freebsd.org/D26372

Deleted:
  head/share/man/man9/vm_map_create.9
Modified:
  head/ObsoleteFiles.inc
  head/share/man/man9/Makefile
  head/share/man/man9/vm_map.9

Modified: head/ObsoleteFiles.inc
==
--- head/ObsoleteFiles.inc  Thu Sep 10 04:17:23 2020(r365552)
+++ head/ObsoleteFiles.inc  Thu Sep 10 06:32:25 2020(r365553)
@@ -36,6 +36,9 @@
 #   xargs -n1 | sort | uniq -d;
 # done
 
+# 20200910: remove vm_map_create(9) to sync with the code
+OLD_FILES+=usr/share/man/man9/vm_map_create.9.gz
+
 # 20200820: Removal of the ufm driver.
 OLD_FILES+=usr/share/man/man4/ufm.4.gz
 

Modified: head/share/man/man9/Makefile
==
--- head/share/man/man9/MakefileThu Sep 10 04:17:23 2020
(r365552)
+++ head/share/man/man9/MakefileThu Sep 10 06:32:25 2020
(r365553)
@@ -361,7 +361,6 @@ MAN=accept_filter.9 \
vm_fault_prefault.9 \
vm_map.9 \
vm_map_check_protection.9 \
-   vm_map_create.9 \
vm_map_delete.9 \
vm_map_entry_resize_free.9 \
vm_map_find.9 \

Modified: head/share/man/man9/vm_map.9
==
--- head/share/man/man9/vm_map.9Thu Sep 10 04:17:23 2020
(r365552)
+++ head/share/man/man9/vm_map.9Thu Sep 10 06:32:25 2020
(r365553)
@@ -310,7 +310,6 @@ is backed by a
 .Sh SEE ALSO
 .Xr pmap 9 ,
 .Xr vm_map_check_protection 9 ,
-.Xr vm_map_create 9 ,
 .Xr vm_map_delete 9 ,
 .Xr vm_map_entry_resize_free 9 ,
 .Xr vm_map_find 9 ,
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"