freebsd.git
3 years agozfs: merge OpenZFS master-9305ff2ed
Martin Matuska [Sun, 14 Mar 2021 01:23:51 +0000 (02:23 +0100)]
zfs: merge OpenZFS master-9305ff2ed

Notable upstream pull request merges:
  #11153 Scalable teardown lock for FreeBSD
  #11651 Don't bomb out when using keylocation=file://
  #11667 zvol: call zil_replaying() during replay
  #11683 abd_get_offset_struct() may allocate new abd
  #11693 Intentionally allow ZFS_READONLY in zfs_write
  #11716 zpool import cachefile improvements
  #11720 FreeBSD: Clean up zfsdev_close to match Linux
  #11730 FreeBSD: bring back possibility to rewind the
         checkpoint from bootloader

Obtained from: OpenZFS
MFC after: 2 weeks

3 years agols(1): Refine the HISTORY within the manual page.
Gordon Bergling [Sat, 13 Mar 2021 18:28:26 +0000 (19:28 +0100)]
ls(1): Refine the HISTORY within the manual page.

A simple find command appeared in Version 1 AT&T UNIX and was removed in
Version 3 AT&T UNIX. It was rewritten for Version 5 AT&T UNIX and later
be enhanced for the Programmer's Workbench (PWB). These changes were
later incorporated in AT&T UNIX v7.

Reviewed by: imp
MFC after: 1 week

3 years agoUpdate vendor/openzfs to master-9305ff2ed
Martin Matuska [Sat, 13 Mar 2021 17:30:04 +0000 (18:30 +0100)]
Update vendor/openzfs to master-9305ff2ed

Notable upstream pull request merges:
  #11153 Scalable teardown lock for FreeBSD
  #11651 Don't bomb out when using keylocation=file://
  #11667 zvol: call zil_replaying() during replay
  #11683 abd_get_offset_struct() may allocate new abd
  #11693 Intentionally allow ZFS_READONLY in zfs_write
  #11716 zpool import cachefile improvements
  #11720 FreeBSD: Clean up zfsdev_close to match Linux
  #11730 FreeBSD: bring back possibility to rewind the
         checkpoint from bootloader

3 years agoFix some common typos in comments
Gordon Bergling [Sat, 13 Mar 2021 17:26:15 +0000 (18:26 +0100)]
Fix some common typos in comments

- occured -> occurred
- normaly -> normally
- controling -> controlling
- fileds -> fields
- insterted -> inserted
- outputing -> outputting

MFC after: 1 week

3 years agoFix a few typos in comments
Gordon Bergling [Sat, 13 Mar 2021 15:37:28 +0000 (16:37 +0100)]
Fix a few typos in comments

- trough -> through

MFC after: 1 week

3 years agoi386: Fix a few typos
Gordon Bergling [Sat, 13 Mar 2021 15:10:01 +0000 (16:10 +0100)]
i386: Fix a few typos

- wheter -> whether
- while here, fix some whitespace issues

MFC after: 1 week

3 years agonet80211: Fix a typo in a comment
Gordon Bergling [Sat, 13 Mar 2021 14:51:30 +0000 (15:51 +0100)]
net80211: Fix a typo in a comment

- destionation -> destination
- while here, fix some whitespace issues

MFC after: 1 week

3 years agoPartially revert libcxxrt changes to avoid _Unwind_Exception change
Dimitry Andric [Sat, 13 Mar 2021 13:54:24 +0000 (14:54 +0100)]
Partially revert libcxxrt changes to avoid _Unwind_Exception change

(Note I am also applying this to main and stable/13, to restore the old
libcxxrt ABI and to avoid having to maintain a compat library.)

After the recent cherry-picking of libcxxrt commits 0ee0dbfb0d26 and
d2b3fadf2db5, users reported that editors/libreoffice packages from the
official package builders did not start anymore. It turns out that the
combination of these commits subtly changes the ABI, requiring all
applications that depend on internal details of struct _Unwind_Exception
(available via unwind-arm.h and unwind-itanium.h) to be recompiled.

However, the FreeBSD package builders always use -RELEASE jails, so
these still use the old declaration of struct _Unwind_Exception, which
is not entirely compatible. In particular, LibreOffice uses this struct
in its internal "uno bridge" component, where it attempts to setup its
own exception handling mechanism.

To fix this incompatibility, go back to the old declarations of struct
_Unwind_Exception, and restore the __LP64__ specific workaround we had
in place before (which was to cope with yet another, older ABI bug).

Effectively, this reverts upstream libcxxrt commits 88bdf6b290da
("Specify double-word alignment for ARM unwind") and b96169641f79
("Updated Itanium unwind"), and reapplies our commit 3c4fd2463bb2
("libcxxrt: add padding in __cxa_allocate_* to fix alignment").

PR: 253840

3 years agozfs: bring back possibility to rewind the checkpoint from
Mariusz Zaborski [Sat, 13 Mar 2021 11:56:17 +0000 (12:56 +0100)]
zfs: bring back possibility to rewind the checkpoint from

Add parsing of the rewind options.

When I was upstreaming the change [1], I omitted the part where we
detect that the pool should be rewind. When the FreeBSD repo has
synced with the OpenZFS, this part of the code was removed.

[1] FreeBSD repo: 277f38abffc6a8160b5044128b5b2c620fbb970c
[2] OpenZFS repo: f2c027bd6a003ec5793f8716e6189c389c60f47a

Originally reviewed by: tsoome, allanjude
Originally reviewed by: kevans (ok from high-level overview)

Signed-off-by: Mariusz Zaborski <oshogbo@vexillium.org>
PR: 254152
Reported by: Zhenlei Huang <zlei.huang at gmail.com>
Obtained from: https://github.com/openzfs/zfs/pull/11730

3 years agozfs: make seqc asserts conditional on replay
Mateusz Guzik [Sat, 13 Mar 2021 09:10:16 +0000 (10:10 +0100)]
zfs: make seqc asserts conditional on replay

Avoids tripping on asserts when doing pool recovery.

3 years ago[ath] do a cold reset if TSFOOR triggers
Adrian Chadd [Sat, 13 Mar 2021 07:30:25 +0000 (23:30 -0800)]
[ath] do a cold reset if TSFOOR triggers

TSFOOR happens if a beacon with a given TSF isn't received within the
programmed/expected TSF value, plus/minus a fudge range. (OOR == out of range.)

If this happens then it could be because the baseband/mac is stuck, or
the baseband is deaf.  So, do a cold reset and resync the beacon to
try and unstick the hardware.

It also happens when a bad AP decides to err, slew its TSF because they
themselves are resetting and they don't preserve the TSF "well."

This has fixed a bunch of weird corner cases on my 2GHz AP radio upstairs
here where it occasionally goes deaf due to how much 2GHz noise is up
here (and ANI gets a little sideways) and this unsticks the station
VAP.

For AP modes a hung baseband/mac usually ends up as a stuck beacon
and those have been addressed for a long time by just resetting the
hardware.  But similar hangs in station mode didn't have a similar
recovery mechanism.

Tested:

* AR9380, STA mode, 2GHz/5GHz
* AR9580, STA mode, 5GHz
* QCA9344 SoC w/ on-board wifi (TL-WDR4300/3600 devices); 2GHz
  STA mode

3 years ago[ath] validate ts_antenna before updating tx statistics
Adrian Chadd [Sat, 13 Mar 2021 01:29:09 +0000 (17:29 -0800)]
[ath] validate ts_antenna before updating tx statistics

Right now ts_antenna is either 0 or 1 in each supported HAL so
this is purely a sanity check.

Later on if I ever get magical free time I may add some extensions
for the NICs that can have slightly more complicated antenna switches
for transmit and I'd like this to not bust memory.

3 years agoarm64: Add support for the RK805/RK808 RTC
Peter Jeremy [Fri, 12 Mar 2021 22:06:04 +0000 (09:06 +1100)]
arm64: Add support for the RK805/RK808 RTC

Implement a driver for the RTC embedded in the RK805/RK808 power
management system used for RK3328 and RK3399 SoCs.

Based on experiments on my RK808, setting the time doesn't alter the
internal/inaccessible sub-second counter, therefore there's no point
in calling clock_schedule().

Based on an earlier revision by andrew.

Reviewed by: manu
Differential Revision: https://reviews.freebsd.org/D22692
Sponsored by: Google
MFC after: 1 week

3 years agocam: Run all XPT_ASYNC ccbs in a dedicated thread
Warner Losh [Fri, 12 Mar 2021 20:20:52 +0000 (13:20 -0700)]
cam: Run all XPT_ASYNC ccbs in a dedicated thread

Queue all XPT_ASYNC ccb's and run those in a new cam async thread. This thread
is allowed to sleep for things like memory. This should allow us to make all the
registration routines for cam periph drivers simpler since they can assume they
can always allocate memory. This is a separate thread so that any I/O that's
completed in xpt_done_td isn't held up.

This should fix the panics for WAITOK alloations that are elsewhere in the
storage stack that aren't so easy to convert to NOWAIT. Additional future work
will convert other allocations in the registration path to WAITOK should
detailed analysis show it to be safe.

Reviewed by: chs@, rpokala@
Differential Revision: https://reviews.freebsd.org/D29210

3 years agoccr: Disable requests on port 1 when needed to workaround a firmware bug.
John Baldwin [Fri, 12 Mar 2021 18:35:56 +0000 (10:35 -0800)]
ccr: Disable requests on port 1 when needed to workaround a firmware bug.

Completions for crypto requests on port 1 can sometimes return a stale
cookie value due to a firmware bug.  Disable requests on port 1 by
default on affected firmware.

Reviewed by: np
Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D26581

3 years agoccr: Add per-port stats of queued and completed requests.
John Baldwin [Fri, 12 Mar 2021 18:35:32 +0000 (10:35 -0800)]
ccr: Add per-port stats of queued and completed requests.

Reviewed by: np
Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D29176

3 years agoccr: Set the RX channel ID correctly in work requests.
John Baldwin [Fri, 12 Mar 2021 18:35:05 +0000 (10:35 -0800)]
ccr: Set the RX channel ID correctly in work requests.

These fixes are only relevant for requests on the second port.  In
some cases, the crypto completion data, completion message, and
receive descriptor could be written in the wrong order.

- Add a separate rx_channel_id that is a copy of the port's rx_c_chan
  and use it when an RX channel ID is required in crypto requests
  instead of using the tx_channel_id.

- Set the correct rx_channel_id in the CPL_RX_PHYS_ADDR used to write
  the crypto result.

- Set the FID to the first rx queue ID on the adapter rather than the
  queue ID of the first rx queue for the port.

- While here, use tx_chan to set the tx_channel_id though this is
  identical to the previous value.

Reviewed by: np
Reported by: Chelsio QA
Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D29175

3 years agolib/msun: Fix x86 GCC6 build after 221622ec0c8e184
Alex Richardson [Fri, 12 Mar 2021 18:44:42 +0000 (18:44 +0000)]
lib/msun: Fix x86 GCC6 build after 221622ec0c8e184

Apparently GCC only supports arithmetic expressions that use static
const variables in initializers starting with GCC8. To keep older
versions happy use a macro instead.

Fixes: 221622ec0c ("lib/msun: Avoid FE_INEXACT for x86 log2l/log10l")
Reported by: Jenkins
Reviewed By: imp
Differential Revision: https://reviews.freebsd.org/D29233

3 years agoFetch the sigfastblock value in syscalls that wait for signals
Jonathan T. Looney [Fri, 12 Mar 2021 18:14:17 +0000 (18:14 +0000)]
Fetch the sigfastblock value in syscalls that wait for signals

We have seen several cases of processes which have become "stuck" in
kern_sigsuspend(). When this occurs, the kernel's td_sigblock_val
is set to 0x10 (one block outstanding) and the userspace copy of the
word is set to 0 (unblocked). Because the kernel's cached value
shows that signals are blocked, kern_sigsuspend() blocks almost all
signals, which means the process hangs indefinitely in sigsuspend().

It is not entirely clear what is causing this condition to occur.
However, it seems to make sense to add some protection against this
case by fetching the latest sigfastblock value from userspace for
syscalls which will sleep waiting for signals. Here, the change is
applied to kern_sigsuspend() and kern_sigtimedwait().

Reviewed by: kib
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D29225

3 years agox86: Update some stale comments in cpu_fork() and cpu_copy_thread().
John Baldwin [Fri, 12 Mar 2021 17:48:49 +0000 (09:48 -0800)]
x86: Update some stale comments in cpu_fork() and cpu_copy_thread().

Neither of these routines allocate stacks.

Reviewed by: kib
MFC after: 1 week
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D29227

3 years agox86: Always use clean FPU and segment base state for new kthreads.
John Baldwin [Fri, 12 Mar 2021 17:48:36 +0000 (09:48 -0800)]
x86: Always use clean FPU and segment base state for new kthreads.

Reviewed by: kib
MFC after: 1 week
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D29208

3 years agoSet TDP_KTHREAD before calling cpu_fork() and cpu_copy_thread().
John Baldwin [Fri, 12 Mar 2021 17:48:20 +0000 (09:48 -0800)]
Set TDP_KTHREAD before calling cpu_fork() and cpu_copy_thread().

This permits these routines to use special logic for initializing MD
kthread state.

For the kproc case, this required moving the logic to set these flags
from kproc_create() into do_fork().

Reviewed by: kib
MFC after: 1 week
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D29207

3 years agoDon't pass RFPROC to kproc_create(), it is redundant.
John Baldwin [Fri, 12 Mar 2021 17:48:10 +0000 (09:48 -0800)]
Don't pass RFPROC to kproc_create(), it is redundant.

Reviewed by: tuexen, kib
MFC after: 1 week
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D29206

3 years agoRemove unused wrappers around kproc_create() and kproc_exit().
John Baldwin [Fri, 12 Mar 2021 17:47:58 +0000 (09:47 -0800)]
Remove unused wrappers around kproc_create() and kproc_exit().

Reviewed by: imp, kib
MFC after: 1 week
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D29205

3 years agox86: Copy the FPU/XSAVE state from the creating thread to new threads.
John Baldwin [Fri, 12 Mar 2021 17:47:41 +0000 (09:47 -0800)]
x86: Copy the FPU/XSAVE state from the creating thread to new threads.

POSIX states that new threads created via pthread_create() should
inherit the "floating point environment" from the creating thread.

Discussed with: kib
MFC after: 1 week
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D29204

3 years agoamd64: Cleanups to setting TLS registers for Linux binaries.
John Baldwin [Fri, 12 Mar 2021 17:47:31 +0000 (09:47 -0800)]
amd64: Cleanups to setting TLS registers for Linux binaries.

- Use update_pcb_bases() when updating FS or GS base addresses to
  permit use of FSBASE and GSBASE in Linux processes.  This also sets
  PCB_FULL_IRET.  linux32 was setting PCB_32BIT which should be a
  no-op (exec sets it).

- Remove write-only variables to construct unused segment descriptors
  for linux32.

Reviewed by: kib
MFC after: 1 week
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D29026

3 years agoamd64: Only update fsbase/gsbase in pcb for curthread.
John Baldwin [Fri, 12 Mar 2021 17:45:18 +0000 (09:45 -0800)]
amd64: Only update fsbase/gsbase in pcb for curthread.

Before the pcb is copied to the new thread during cpu_fork() and
cpu_copy_thread(), the kernel re-reads the current register values in
case they are stale.  This is done by setting PCB_FULL_IRET in
pcb_flags.

This works fine for user threads, but the creation of kernel processes
and kernel threads do not follow the normal synchronization rules for
pcb_flags.  Specifically, new kernel processes are always forked from
thread0, not from curthread, so adjusting pcb_flags via a simple
instruction without the LOCK prefix can race with thread0 running on
another CPU.  Similarly, kthread_add() clones from the first thread in
the relevant kernel process, not from curthread.  In practice, Netflix
encountered a panic where the pcb_flags in the first kthread of the
KTLS process were trashed due to update_pcb_bases() in
cpu_copy_thread() running from thread0 to create one of the other KTLS
threads racing with the first KTLS kthread calling fpu_kern_thread()
on another CPU.  In the panicking case, the write to update pcb_flags
in fpu_kern_thread() was lost triggering an "Unregistered use of FPU
in kernel" panic when the first KTLS kthread later tried to use the
FPU.

Reported by: gallatin
Discussed with: kib
MFC after: 1 week
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D29023

3 years agotests/sys/netgraph/ng_macfilter_test: Fix invalid TAP output
Alex Richardson [Fri, 12 Mar 2021 17:35:24 +0000 (17:35 +0000)]
tests/sys/netgraph/ng_macfilter_test: Fix invalid TAP output

This should allow the test to pass in Jenkins. Testing it locally now
reports "passed" instead of "invalid TAP data".

While touching this file also fix some shellcheck warnings that were
pointed out by my IDE.

Reviewed By: lwhsu, afedorov
Differential Revision: https://reviews.freebsd.org/D29054

3 years agoAllow using sanitizers for ssp tests with out-of-tree compiler
Alex Richardson [Fri, 12 Mar 2021 17:15:00 +0000 (17:15 +0000)]
Allow using sanitizers for ssp tests with out-of-tree compiler

With an out-of-tree Clang, we can use the -resource-dir flag when linking
to point it at the runtime libraries from the current SYSROOT.
This moves the path to the clang-internal library directory to a separate
.mk file that can be used by Makefiles that want to find the sanitizer
libraries. I intend to re-use this .mk file for my upcoming changes that
allow building the entire base system with ASAN/UBSAN/MSAN.

Reviewed By: dim
Differential Revision: https://reviews.freebsd.org/D28852

3 years agocapsicum-test: Update for O_BENEATH removal
Alex Richardson [Fri, 12 Mar 2021 17:12:10 +0000 (17:12 +0000)]
capsicum-test: Update for O_BENEATH removal

Update the tests to check O_RESOLVE_BENEATH instead.
If this looks reasonable, I'll try to upstream this change.
This keeps a compat fallback for O_BENEATH since the Linux port still
has/had O_BENEATH with "no .., no absolute paths" semantics.

Test Plan: `/usr/tests/sys/capsicum/capsicum-test -u 977` passes and
runs the O_RESOLVE_BENEATH tests.
Reviewed By: markj
Differential Revision: https://reviews.freebsd.org/D29016

3 years agoSave all fpcr/fpsr bits in the AArch64 fenv_t
Alex Richardson [Fri, 12 Mar 2021 17:01:37 +0000 (17:01 +0000)]
Save all fpcr/fpsr bits in the AArch64 fenv_t

The existing code masked off all bits that it didn't know about. To be
future-proof, we should save and restore the entire fpcr/fpsr registers.
Additionally, the existing fesetenv() was incorrectly setting the rounding
mode in fpsr instead of fpcr.

This patch stores fpcr in the high 32 bits of fenv_t and fpsr in the low
bits instead of trying to interleave them in a single 32-bit field.

Technically, this is an ABI break if you re-compile parts of your code or
pass a fenv_t between DSOs that were compiled with different versions
of fenv.h. However, I believe we should fix this since the existing code
was broken and passing fenv_t across DSOs should rarely happen.

Reviewed By: andrew
Differential Revision: https://reviews.freebsd.org/D29160

3 years agoImprove the wording for showing the brightness level
Brad Davis [Fri, 12 Mar 2021 16:43:33 +0000 (09:43 -0700)]
Improve the wording for showing the brightness level

Reviewed by: allanjude

3 years agorelease: Move the vagrant.vmx config out to its own file to match vbox
Brad Davis [Tue, 26 Jan 2021 17:02:57 +0000 (10:02 -0700)]
release: Move the vagrant.vmx config out to its own file to match vbox

Silly to have all these echos and makes this easier to use in other tooling.

Reviewed by: gjb (re)

3 years agoautofs: best effort to maintain mounttab and mountdtab
Robert Wing [Wed, 17 Feb 2021 07:51:38 +0000 (22:51 -0900)]
autofs: best effort to maintain mounttab and mountdtab

When an automounted filesystem is successfully unmounted, call
rpc.umntall(8) with the -k flag.

rpc.umntall(8) is used to clean up /var/db/mounttab on the client and
/var/db/mountdtab on the server. This is only useful for NFSv3.

PR:     251906
Reviewed by: trasz
Differential Revision:  https://reviews.freebsd.org/D27801

3 years agolinux(4): make getcwd(2) return ERANGE instead of ENOMEM
Edward Tomasz Napierala [Fri, 12 Mar 2021 15:31:37 +0000 (15:31 +0000)]
linux(4): make getcwd(2) return ERANGE instead of ENOMEM

For native FreeBSD binaries, the return value from __getcwd(2)
doesn't really matter, as the libc wrapper takes over and returns
the proper errno.

PR: kern/254120
Reported By: Alex S <iwtcex@gmail.com>
Reviewed By: kib
Sponsored By: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D29217

3 years agopf: Fully remove interrupt events on vnet cleanup
Kristof Provost [Wed, 10 Mar 2021 21:56:11 +0000 (22:56 +0100)]
pf: Fully remove interrupt events on vnet cleanup

swi_remove() removes the software interrupt handler but does not remove
the associated interrupt event.
This is visible when creating and remove a vnet jail in `procstat -t
12`.

We can remove it manually with intr_event_destroy().

PR: 254171
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D29211

3 years agopf: Simplify cleanup
Kristof Provost [Wed, 10 Mar 2021 14:15:16 +0000 (15:15 +0100)]
pf: Simplify cleanup

We can now counter_u64_free(NULL), so remove the checks.

MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D29190

3 years agoDocument that uma_zfree_pcpu() allows NULL now
Kristof Provost [Thu, 11 Mar 2021 08:32:01 +0000 (09:32 +0100)]
Document that uma_zfree_pcpu() allows NULL now

While here also document that for counter_u64_free().

Reviewed by: rpokala@
MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D29215

3 years agouma: allow uma_zfree_pcu(..., NULL)
Kristof Provost [Wed, 10 Mar 2021 14:11:59 +0000 (15:11 +0100)]
uma: allow uma_zfree_pcu(..., NULL)

We already allow free(NULL) and uma_zfree(..., NULL). Make
uma_zfree_pcpu(..., NULL) work as well.
This also means that counter_u64_free(NULL) will work.

These make cleanup code simpler.

MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D29189

3 years agoWhitespace cleanup
Li-Wen Hsu [Fri, 12 Mar 2021 11:57:30 +0000 (19:57 +0800)]
Whitespace cleanup

3 years agoUpdate doc links in README
Li-Wen Hsu [Fri, 12 Mar 2021 11:55:56 +0000 (19:55 +0800)]
Update doc links in README

3 years agonull_vput_pair(): release use reference on dvp earlier
Konstantin Belousov [Sun, 7 Mar 2021 21:08:38 +0000 (23:08 +0200)]
null_vput_pair(): release use reference on dvp earlier

We might own the last use reference, and then vrele() at the end would
need to take the dvp vnode lock to inactivate, which causes deadlock
with vp. We cannot vrele() dvp from start since this might unlock ldvp.

Handle it by holding the vnode and dropping use ref after lowerfs
VOP_VPUT_PAIR() ended.  This effectivaly requires unlock of the vp vnode
after VOP_VPUT_PAIR(), so the call is changed to set unlock_vp to true
unconditionally.  This opens more opportunities for vp to be reclaimed,
if lvp is still alive we reinstantiate vp with null_nodeget().

Reported and tested by: pho
Reviewed by: mckusick
Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks
Differential revision: https://reviews.freebsd.org/D29178

3 years agovlrureclaim: only skip vnode with resident pages if it own the pages
Konstantin Belousov [Sat, 6 Mar 2021 21:09:16 +0000 (23:09 +0200)]
vlrureclaim: only skip vnode with resident pages if it own the pages

Nullfs vnode which shares vm_object and pages with the lower vnode should
not be exempt from the reclaim just because lower vnode cached a lot.
Their reclamation is actually very cheap and should be preferred over
real fs vnodes, but this change is already useful.

Reported and tested by: pho
Reviewed by: mckusick
Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks
Differential revision: https://reviews.freebsd.org/D29178

3 years agosoftdep_unmount: assert that no dandling dependencies are left
Konstantin Belousov [Sat, 6 Mar 2021 09:52:10 +0000 (11:52 +0200)]
softdep_unmount: assert that no dandling dependencies are left

Reviewed by: mckusick
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks
Differential revision: https://reviews.freebsd.org/D29178

3 years agoFFS: assign fully initialized struct mount_softdeps to um_softdep
Konstantin Belousov [Wed, 3 Mar 2021 22:02:30 +0000 (00:02 +0200)]
FFS: assign fully initialized struct mount_softdeps to um_softdep

Other threads observing the non-NULL um_softdep can assume that it is
safe to use it. This is important for ro->rw remounts where change from
read-only to read-write status cannot be made atomic.

Reviewed by: mckusick
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks
Differential revision: https://reviews.freebsd.org/D29178

3 years agoAssert that um_softdep is NULL on free(ump), i.e. softdep_unmount() was called
Konstantin Belousov [Wed, 3 Mar 2021 19:40:34 +0000 (21:40 +0200)]
Assert that um_softdep is NULL on free(ump), i.e. softdep_unmount() was called

Reviewed by: mckusick
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks
Differential revision: https://reviews.freebsd.org/D29178

3 years agoffs_mount: when remounting ro->rw and sbupdate failed, cleanup softdeps
Konstantin Belousov [Wed, 3 Mar 2021 18:02:13 +0000 (20:02 +0200)]
ffs_mount: when remounting ro->rw and sbupdate failed, cleanup softdeps

Reviewed by: mckusick
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks
Differential revision: https://reviews.freebsd.org/D29178

3 years agosoftdep_unmount: handle spurious wakeups
Konstantin Belousov [Sun, 28 Feb 2021 22:46:21 +0000 (00:46 +0200)]
softdep_unmount: handle spurious wakeups

Reviewed by: mckusick
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks
Differential revision: https://reviews.freebsd.org/D29178

3 years agosoftdep_flush(): do not access ump after we acked FLUSH_EXIT and unlocked SU lock
Konstantin Belousov [Sun, 28 Feb 2021 22:45:04 +0000 (00:45 +0200)]
softdep_flush(): do not access ump after we acked FLUSH_EXIT and unlocked SU lock

otherwise we might follow a pointer in the freed memory.

Reviewed by: mckusick
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks
Differential revision: https://reviews.freebsd.org/D29178

3 years agoffs: clear MNT_SOFTDEP earlier when remounting rw to ro
Konstantin Belousov [Sun, 28 Feb 2021 18:55:35 +0000 (20:55 +0200)]
ffs: clear MNT_SOFTDEP earlier when remounting rw to ro

Suppose that we remount rw->ro and in parallel some reader tries to
instantiate a vnode, e.g. during lookup.  Suppose that softdep_unmount()
already started, but we did not cleared the MNT_SOFTDEP flag yet.
Then ffs_vgetf() calls into softdep_load_inodeblock() which accessed
destroyed hashes and freed memory.

Set/clear fs_ronly simultaneously (WRT to files flush) with MNT_SOFTDEP.
It might be reasonable to move the change of fs_ronly to under MNT_ILOCK,
but no readers take it.

Reported and tested by: pho
Reviewed by: mckusick
Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks
Differential revision: https://reviews.freebsd.org/D29178

3 years agoRework MOUNTED/DOING SOFTDEP/SUJ macros
Konstantin Belousov [Wed, 3 Mar 2021 17:43:17 +0000 (19:43 +0200)]
Rework MOUNTED/DOING SOFTDEP/SUJ macros

Now MNT_SOFTDEP indicates that SU are active in any variant +-J, and
SU+J is indicated by MNT_SOFTDEP | MNT_SUJ combination.  The reason is
that unmount will be able to easily hide SU from other operations by
clearing MNT_SOFTDEP while keeping the record of the active journal.

Reviewed by: mckusick
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks
Differential revision: https://reviews.freebsd.org/D29178

3 years agoffs softdep: clear ump->um_softdep on softdep_unmount()
Konstantin Belousov [Wed, 3 Mar 2021 17:42:24 +0000 (19:42 +0200)]
ffs softdep: clear ump->um_softdep on softdep_unmount()

Reviewed by: mckusick
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks
Differential revision: https://reviews.freebsd.org/D29178

3 years agoffs_extern.h: Add comments for ffs_vgetf() flags
Konstantin Belousov [Thu, 11 Mar 2021 07:02:16 +0000 (09:02 +0200)]
ffs_extern.h: Add comments for ffs_vgetf() flags

Requested and reviewed by: mckusick
Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks
Differential revision: https://reviews.freebsd.org/D29178

3 years agoAdd FFSV_FORCEINODEDEP flag for ffs_vgetf()
Konstantin Belousov [Wed, 3 Mar 2021 17:40:56 +0000 (19:40 +0200)]
Add FFSV_FORCEINODEDEP flag for ffs_vgetf()

It will be used to allow SU flush code to sync the volume while external
consumers see that SU is already disabled on the filesystem.  Use it where
ffs_vgetf() called by SU code to process dependencies.

Reviewed by: mckusick
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks
Differential revision: https://reviews.freebsd.org/D29178

3 years agosimplify journal_mount: move the out label after success block
Konstantin Belousov [Thu, 4 Mar 2021 18:55:33 +0000 (20:55 +0200)]
simplify journal_mount: move the out label after success block

This removes the need to check for error == 0.

Reviewed by: mckusick
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks
Differential revision: https://reviews.freebsd.org/D29178

3 years agoDo not complain about incorrect cylinder group check-hashes when
Kirk McKusick [Fri, 12 Mar 2021 06:44:33 +0000 (22:44 -0800)]
Do not complain about incorrect cylinder group check-hashes when
asked to add them to a filesystem.

MFC after:    3 days
Sponsored by: Netflix

3 years agoHyper-V: hn: Enable vSwitch RSC support in hn netvsc driver
Wei Hu [Fri, 12 Mar 2021 04:35:16 +0000 (04:35 +0000)]
Hyper-V: hn: Enable vSwitch RSC support in hn netvsc driver

Receive Segment Coalescing (RSC) in the vSwitch is a feature available in
Windows Server 2019 hosts and later. It reduces the per packet processing
overhead by coalescing multiple TCP segments when possible. This happens
mostly when TCP traffics are among different guests on same host.
This patch adds netvsc driver support for this feature.

The patch also updates NVS version to 6.1 as needed for RSC
enablement.

MFC after: 2 weeks
Sponsored by: Microsoft
Differential Revision: https://reviews.freebsd.org/D29075

3 years agoreadme: Link to COPYRIGHT file
Warner Losh [Fri, 12 Mar 2021 00:55:16 +0000 (17:55 -0700)]
readme: Link to COPYRIGHT file

3 years agoFix arch rendering
Warner Losh [Fri, 12 Mar 2021 00:52:13 +0000 (17:52 -0700)]
Fix arch rendering

3 years agoreadme: update style
Warner Losh [Fri, 12 Mar 2021 00:21:16 +0000 (17:21 -0700)]
readme: update style

Update the style to one sentence per line, as is currently used in the FreeBSD
document project. Make the links to the handbook clickable.

3 years agoRemove README in favor of README.md
Warner Losh [Fri, 12 Mar 2021 00:11:28 +0000 (17:11 -0700)]
Remove README in favor of README.md

Complete the transition to README.md I started 3 years ago. Remove the
now-redundant README file. It's currently just README.md w/o the light markup
and adds no real value. This also allows us to use additional MarkDown
markup as we see fit w/o worrying about keeping things in sync.

3 years agoSPDX: Spell 4 clause BSD license correctly
Warner Losh [Thu, 11 Mar 2021 20:25:55 +0000 (13:25 -0700)]
SPDX: Spell 4 clause BSD license correctly

3 years agogmirror: Pre-allocate the timeout event structure
Mark Johnston [Thu, 11 Mar 2021 20:43:04 +0000 (15:43 -0500)]
gmirror: Pre-allocate the timeout event structure

We can't call malloc(M_WAITOK) in a callout handler.

Reviewed by: imp
Reported by: pho
Tested by: pho
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D29223

3 years agodevelopment(7): update to reflect Git transition
Edward Tomasz Napierala [Thu, 11 Mar 2021 20:03:30 +0000 (20:03 +0000)]
development(7): update to reflect Git transition

Reviewed By: debdrup, imp (earlier version)
Sponsored By: EPSRC
Differential Revision: https://reviews.freebsd.org/D28939

3 years agoman: Remove obsolete info from hosts man page
Warner Losh [Thu, 11 Mar 2021 18:46:10 +0000 (11:46 -0700)]
man: Remove obsolete info from hosts man page

The NIC no longer provides a host database, and hasn't for quite some
time. Remove that paragraph, it's not been relevant for many years. Also, hosts
appeared in 4.1c, not 4.2, so correct that too.

Noticed by: Henry Bent

3 years agonvme: use config_intrhook_drain to avoid removable card races
Warner Losh [Thu, 11 Mar 2021 15:42:44 +0000 (08:42 -0700)]
nvme: use config_intrhook_drain to avoid removable card races

nvme drives are configured early in boot. However, a number of the configuration
steps takes which take a while, so we defer those to a config intrhook that runs
before the root filesystem is mounted. At the same time, the PCI hot plug wakes
up and tests the status of the card. It may decide that the card has gone away
and deletes the child. As part of that process nvme_detach is called. If this
call happens after the config_intrhook starts to run, but before it is finished,
there's a race where we can tear down the device's soft state while the
config_intrhook is still using it. Use the new config_intrhook_drain to
disestablish the hook. Either it will be removed w/o running, or the routine
will wait for it to finish. This closes the race and allows safe hotplug at any
time, even very early in boot.

Sponsored by: Netflix, Inc
Reviewed by: jhb, mav
Differential Revision: https://reviews.freebsd.org/D29006

3 years agoconfig_intrhook: provide config_intrhook_drain
Warner Losh [Thu, 11 Mar 2021 15:42:09 +0000 (08:42 -0700)]
config_intrhook: provide config_intrhook_drain

config_intrhook_drain will remove the hook from the list as
config_intrhook_disestablish does if the hook hasn't been called.  If it has,
config_intrhook_drain will wait for the hook to be disestablished in the normal
course (or expedited, it's up to the driver to decide how and when
to call config_intrhook_disestablish).

This is intended for removable devices that use config_intrhook and might be
attached early in boot, but that may be removed before the kernel can call the
config_intrhook or before it ends. To prevent all races, the detach routine will
need to call config_intrhook_train.

Sponsored by: Netflix, Inc
Reviewed by: jhb, mav, gde (in D29006 for man page)
Differential Revision: https://reviews.freebsd.org/D29005

3 years agolinsysfs: create /sys/bus/ and /sys/subsystem/
Edward Tomasz Napierala [Mon, 8 Mar 2021 20:55:44 +0000 (20:55 +0000)]
linsysfs: create /sys/bus/ and /sys/subsystem/

This looks like a no-op, but it prevents udevadm(8) with failing
loudly, which in turn unbreaks installation of libfprint-2-2, which
in Focal is a dependency for make-4.2.1-1.2.

One might wonder why installing a build utility involves messing
with device handling...

Sponsored By: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D29133

3 years agovm_reserv: Fix list locking in vm_reserv_reclaim_contig()
Mark Johnston [Thu, 11 Mar 2021 15:34:28 +0000 (10:34 -0500)]
vm_reserv: Fix list locking in vm_reserv_reclaim_contig()

The per-domain partpop queue is locked by the combination of the
per-domain lock and individual reservation mutexes.
vm_reserv_reclaim_contig() scans the queue looking for partially
populated reservations that can be reclaimed in order to satisfy the
caller's allocation.

During the scan, we drop the per-domain lock.  At this point, the rvn
pointer may be invalidated.  Take care to load rvn after re-acquiring
the per-domain lock.

While here, simplify the condition used to check whether a reservation
was dequeued while the per-domain lock was dropped.

Reviewed by: alc, kib
Reported by: gallatin
MFC after: 3 days
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D29203

3 years agousb: tiny formatting nit
Warner Losh [Thu, 11 Mar 2021 15:23:32 +0000 (08:23 -0700)]
usb: tiny formatting nit

Format 300 baud like all the others here. No functional change.

3 years agopf: Remove redundant kif != NULL checks
Kristof Provost [Wed, 10 Mar 2021 14:50:42 +0000 (15:50 +0100)]
pf: Remove redundant kif != NULL checks

pf_kkif_free() already checks for NULL, so we don't have to check before
we call it.

Reviewed by: melifaro@
MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D29195

3 years agopf: Factor out pf_krule_free()
Kristof Provost [Wed, 10 Mar 2021 10:10:04 +0000 (11:10 +0100)]
pf: Factor out pf_krule_free()

Reviewed by: melifaro@
MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D29194

3 years agousr.sbin/pwm/pwm add support for flags
Oskar Holmund [Thu, 11 Mar 2021 08:55:23 +0000 (09:55 +0100)]
usr.sbin/pwm/pwm add support for flags

The pwm utility cant set the only flag defined (PWM_POLARITY_INVERTED) so this
patch add the option -I (capital letter i) to send it to the drivers.

None of existing PWM driver have implemented support for flags.
But soon:ish I will put up an review of a pwm driver using TI OMAP DMTimer.

Differential Revision: https://reviews.freebsd.org/D29137
MFC after:   2 weeks

3 years agoshare/man/man9/pwmbus.9 fix types in arguments
Oskar Holmund [Thu, 11 Mar 2021 08:53:26 +0000 (09:53 +0100)]
share/man/man9/pwmbus.9 fix types in arguments

Fix the types of period and duty in share/man/man9/pwmbus.9 to match the one in sys/dev/pmw/pwmbus.c.

Reviewed By: rpokala
Differential Revision: https://reviews.freebsd.org/D29139
MFC after:   3 days

3 years agokern.mk: fix -Wno-error style to fix build with Clang 12
Greg V [Wed, 10 Mar 2021 22:17:09 +0000 (17:17 -0500)]
kern.mk: fix -Wno-error style to fix build with Clang 12

Clang 12 no longer supports -Wno-error-..., only the -Wno-error=...
style (which is already used everywhere else in the tree).

Differential Revision: https://reviews.freebsd.org/D29157

3 years agoFlush remaining routes from the routing table during VNET shutdown.
Alexander V. Chernikov [Mon, 8 Mar 2021 21:35:41 +0000 (21:35 +0000)]
Flush remaining routes from the routing table during VNET shutdown.

Summary:
This fixes rtentry leak for the cloned interfaces created inside the
 VNET.

PR: 253998
Reported by: rashey at superbox.pl
MFC after: 3 days

Loopback teardown order is `SI_SUB_INIT_IF`, which happens after `SI_SUB_PROTO_DOMAIN` (route table teardown).
Thus, any route table operations are too late to schedule.
As the intent of the vnet teardown procedures to minimise the amount of effort by doing global cleanups instead of per-interface ones, address this by adding a relatively light-weight routing table cleanup function, `rib_flush_routes()`.
It removes all remaining routes from the routing table and schedules the deletion, which will happen later, when `rtables_destroy()` waits for the current epoch to finish.

Test Plan:
```
set_skip:set_skip_group_lo  ->  passed  [0.053s]
tail -n 200 /var/log/messages | grep rtentry
```

Reviewers: #network, kp, bz

Reviewed By: kp

Subscribers: imp, ae

Differential Revision: https://reviews.freebsd.org/D29116

3 years agoktls: Fix non-inplace TLS 1.3 encryption.
John Baldwin [Wed, 10 Mar 2021 19:07:40 +0000 (11:07 -0800)]
ktls: Fix non-inplace TLS 1.3 encryption.

Copy the iovec for the trailer from the proper place.  This is the same
fix for CBC encryption from ff6a7e4ba6bf.

Reported by: gallatin
Reviewed by: gallatin, markj
Fixes: 49f6925ca
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D29177

3 years agoMove time math out of disabled interrupts sections.
Alexander Motin [Wed, 10 Mar 2021 18:39:15 +0000 (13:39 -0500)]
Move time math out of disabled interrupts sections.

We don't need the result before next sleep time, so no reason to
additionally increase interrupt latency.

While there, remove extra PM ticks to microseconds conversion, making
C2/C3 sleep times look 4 times smaller than really.  The conversion
is already done by AcpiGetTimerDuration().  Now I see reported sleep
times up to 0.5s, just as expected for planned 2 wakeups per second.

MFC after: 1 month

3 years agoarm64: Fix COMPAT_FREEBSD32.
Olivier Houchard [Wed, 10 Mar 2021 18:01:41 +0000 (19:01 +0100)]
arm64: Fix COMPAT_FREEBSD32.

The ENTRY() macro was modified by commit
28d945204ea1014d7de6906af8470ed8b3311335 to add an optional NOP instruction
at the beginning of the function. It is of course an arm64 instruction, so
unsuitable for the 32bits sigcode. So just use EENTRY() instead for
aarch32_sigcode. This should fix receiving signals when running 32bits
binaries on FreeBSD/arm64.

MFC After: 1 week

3 years agoFix post-start check when unbound.conf has moved.
Dag-Erling Smørgrav [Wed, 10 Mar 2021 14:18:59 +0000 (14:18 +0000)]
Fix post-start check when unbound.conf has moved.

Reported by: phk@
MFC after: 1 week

3 years agoFix local-unbound setup for some IPv6 deployments.
Dag-Erling Smørgrav [Wed, 10 Mar 2021 14:01:38 +0000 (14:01 +0000)]
Fix local-unbound setup for some IPv6 deployments.

PR: 250984
MFC after: 1 week

3 years agons8250: don't drop IER_TXRDY on bus_grab/ungrab
Mitchell Horne [Wed, 10 Mar 2021 14:57:12 +0000 (10:57 -0400)]
ns8250: don't drop IER_TXRDY on bus_grab/ungrab

It has been observed that some systems are often unable to resume from
ddb after entering with debug.kdb.enter=1. Checking the status further
shows the terminal is blocked waiting in tty_drain(), but it never makes
progress in clearing the output queue, because sc->sc_txbusy is high.

I noticed that when entering polling mode for the debugger, IER_TXRDY is
set in the failure case. Since this bit is never tracked by the softc,
it will not be restored by ns8250_bus_ungrab(). This creates a race in
which a TX interrupt can be lost, creating the hang described above.
Ensuring that this bit is restored is enough to prevent this, and resume
from ddb as expected.

The solution is to track this bit in the sc->ier field, for the same
lifetime that TX interrupts are enabled.

PR: 223917, 240122
Reviewed by: imp, manu
Tested by: bz
MFC after: 5 days
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D29130

3 years agoArch64: Clear VFP state on execve()
Alex Richardson [Tue, 9 Mar 2021 19:11:40 +0000 (19:11 +0000)]
Arch64: Clear VFP state on execve()

I noticed that many of the math-related tests were failing on AArch64.
After a lot of debugging, I noticed that the floating point exception flags
were not being reset when starting a new process. This change resets the
VFP inside exec_setregs() to ensure no VFP register state is leaked from
parent processes to children.

This commit also moves the clearing of fpcr that was added in 65618fdda0f27
from fork() to execve() since that makes more sense: fork() can retain
current register values, but execve() should result in a well-defined
clean state.

Reviewed By: andrew
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D29060

3 years agoAllocating the LinuxKPI current structure from a software interrupt thread
Hans Petter Selasky [Wed, 10 Mar 2021 12:26:09 +0000 (13:26 +0100)]
Allocating the LinuxKPI current structure from a software interrupt thread
must be done using the M_NOWAIT flag after 1ae20f7c70ea .

MFC after: 1 week
Sponsored by: Mellanox Technologies // NVIDIA Networking

3 years agoUse the word "LinuxKPI" instead of "Linux compatibility", to not confuse with
Hans Petter Selasky [Wed, 10 Mar 2021 11:21:01 +0000 (12:21 +0100)]
Use the word "LinuxKPI" instead of "Linux compatibility", to not confuse with
user-space Linux compatibility support. No functional change.

MFC after: 1 week
Sponsored by: Mellanox Technologies // NVIDIA Networking

3 years agoAllocating the LinuxKPI current structure from an interrupt thread must be
Hans Petter Selasky [Wed, 10 Mar 2021 09:50:01 +0000 (10:50 +0100)]
Allocating the LinuxKPI current structure from an interrupt thread must be
done using the M_NOWAIT flag after 1ae20f7c70ea .

MFC after: 1 week
Sponsored by: Mellanox Technologies // NVIDIA Networking

3 years agowg(4): note the persistent-keepalive ifconfig(8) option
Kyle Evans [Tue, 9 Mar 2021 14:50:38 +0000 (08:50 -0600)]
wg(4): note the persistent-keepalive ifconfig(8) option

MFC after: 3 days
Fixes: b3dac3913dc9

3 years agoImplement basic support for allocating memory from a specific numa node
Hans Petter Selasky [Fri, 5 Mar 2021 11:44:06 +0000 (12:44 +0100)]
Implement basic support for allocating memory from a specific numa node
in the LinuxKPI.

Differential Revision: https://reviews.freebsd.org/D29077
Reviewed by: markj@ and kib@
MFC after: 1 week
Sponsored by: Mellanox Technologies // NVIDIA Networking

3 years agoif_wg: export tx_bytes, rx_bytes, and last_handshake
Kyle Evans [Tue, 9 Mar 2021 10:57:01 +0000 (04:57 -0600)]
if_wg: export tx_bytes, rx_bytes, and last_handshake

The names are self-explanatory; these are currently only used by the
wg(8) tool, but they are handy data points to have.

Reviewed by: grehan
MFC after: 3 days
Discussed with: decke
Differential Revision: https://reviews.freebsd.org/D29143

3 years agoiflib: allow clone detach if not yet init
Kyle Evans [Tue, 9 Mar 2021 12:13:31 +0000 (06:13 -0600)]
iflib: allow clone detach if not yet init

If we hit an error during init, then we'll unwind our state and attempt
to detach the device -- don't block it.

This was discovered by creating a wg0 with missing parameters; said
failure ended up leaving this orphaned device in place and ended up
panicking the system upon enumeration of the dev.* sysctl space.

Reviewed by: gallatin, markj
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D29145

3 years agoif_wg: wg_input: remove a couple locals (NFC)
Kyle Evans [Tue, 9 Mar 2021 10:59:21 +0000 (04:59 -0600)]
if_wg: wg_input: remove a couple locals (NFC)

We have no use for the udphdr or this hlen local, just spell out the
addition inline.

MFC after: 3 days
Reviewed by: grehan, markj
Differential Revision: https://reviews.freebsd.org/D29142

3 years agoamd64 pmap: convert to counter(9), add PV and pagetable page counts
Jason A. Harmening [Thu, 25 Feb 2021 05:08:42 +0000 (21:08 -0800)]
amd64 pmap: convert to counter(9), add PV and pagetable page counts

This change converts most of the counters in the amd64 pmap from
global atomics to scalable counter(9) counters.  Per discussion
with kib@, it also removes the handrolled per-CPU PCID save count
as it isn't considered generally useful.

The bulk of these counters remain guarded by PV_STATS, as it seems
unlikely that they will be useful outside of very specific debugging
scenarios.  However, this change does add two new counters that
are available without PV_STATS.  pt_page_count and pv_page_count
track the number of active physical-to-virtual list pages and page
table pages, respectively.  These will be useful in evaluating
the memory footprint of pmap structures under various workloads,
which will help to guide future changes in this area.

Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D28923

3 years agoofwfb: fix boot on LE
Leandro Lupori [Tue, 9 Mar 2021 15:11:58 +0000 (12:11 -0300)]
ofwfb: fix boot on LE

Some framebuffer properties obtained from the device tree were not being
properly converted to host endian.
Replace OF_getprop calls by OF_getencprop where needed to fix this.

This fixes boot on PowerPC64 LE, when using ofwfb as the system console.

Reviewed by:    bdragon
Sponsored by:   Eldorado Research Institute (eldorado.org.br)
MFC after:      1 week
Differential Revision:  https://reviews.freebsd.org/D27475

3 years agoRevert "rc: implement parallel boot"
Baptiste Daroussin [Tue, 9 Mar 2021 13:25:32 +0000 (14:25 +0100)]
Revert "rc: implement parallel boot"

This is not ready yet for prime time

This reverts commit 763db58932874bb47fc6f9322ab81cc947f80991.
This reverts commit f1ab799927c8e93e8f58e5039f287a2ca45675ec.
This reverts commit 6e822e99570fdf4c564be04840a054bccc070222.
This reverts commit 77e1ccbee3ed6c837929e4e232fd07f95bfc8294.

3 years agoifconfig: allow displaying/setting persistent-keepalive
Kyle Evans [Mon, 8 Mar 2021 01:00:58 +0000 (19:00 -0600)]
ifconfig: allow displaying/setting persistent-keepalive

The kernel-side already accepted a persistent-keepalive-interval, so
just add a verb to ifconfig(8) for it and start exporting it so that
ifconfig(8) can view it.

PR: 253790
MFC after: 3 days
Discussed with: decke

3 years agoifconfig: wg: stop requiring peer endpoints
Kyle Evans [Mon, 8 Mar 2021 01:04:24 +0000 (19:04 -0600)]
ifconfig: wg: stop requiring peer endpoints

The way that wireguard is designed does not actually require all peers
to have endpoints. In an architecture that might mimic a traditional
VPN server <-> client, the wg interface on a server would have a number
of peers without set endpoints -- the expectation is that the "clients"
will connect to the "server" peer, which will authenticate the
connection as a known peer and learn the endpoint from there.

MFC after: 3 days
Discussed with: decke, grehan (independently)

3 years agokern: malloc: fix panic on M_WAITOK during THREAD_NO_SLEEPING()
Kyle Evans [Mon, 8 Mar 2021 06:16:27 +0000 (00:16 -0600)]
kern: malloc: fix panic on M_WAITOK during THREAD_NO_SLEEPING()

Simple condition flip; we wanted to panic here after epoch_trace_list().

Reviewed by: glebius, markj
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D29125

3 years agoif_wg: avoid sleeping under the net epoch
Kyle Evans [Mon, 8 Mar 2021 06:06:28 +0000 (00:06 -0600)]
if_wg: avoid sleeping under the net epoch

No sleeping allowed here, so avoid it.  Collect the subset of data we
want inside of the epoch, as we'll need extra allocations when we add
items to the nvlist.

Reviewed by: grehan (earlier version), markj
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D29124

3 years agoif_wg: return to m_defrag() of incoming mbuf, sans leak
Kyle Evans [Tue, 9 Mar 2021 10:44:31 +0000 (04:44 -0600)]
if_wg: return to m_defrag() of incoming mbuf, sans leak

This partially reverts df55485085 but still fixes the leak. It was
overlooked (sigh) that some packets will exceed MHLEN and cannot be
physically contiguous without clustering, but we don't actually need
it to be. m_defrag() should pull up enough for any of the headers that
we do need to be accessible.

Fixes: df55485085
Pointy hat; kevans

3 years agomountd(8): generate a syslog message when the "V4:" line is missing
Rick Macklem [Tue, 9 Mar 2021 00:08:02 +0000 (16:08 -0800)]
mountd(8): generate a syslog message when the "V4:" line is missing

Daniel reported that NFSv4 mounts were not working despite having
set "nfsv4_server_enable=YES" in /etc/rc.conf.  Mountd was logging a
message that there was no /etc/exports file.
He noted that creating a /etc/exports file with a "V4:" line in it
was needed make NFSv4 mounts work.
At least one "V4:" line in one of the exports(5) file(s) is needed to
make NFSv4 mounts work. This patch fixes mountd.c so that it logs a
message indicting that there is no "V4:" line in any exports(5)
file when NFSv4 mounts are enabled.
To avoid this message being generated erroneously, /etc/rc.d/mountd
is updated to make sure vfs.nfsd.server_max_nfsvers is properly set
before mountd(8) is started.

Reported by: debdrup
PR: 253901
MFC after: 2 weeks