freebsd.git
2 years agoMFV 45916e7c91ce: libbsdxml (expat) 2.4.7
Xin LI [Mon, 28 Mar 2022 05:22:07 +0000 (22:22 -0700)]
MFV 45916e7c91ce: libbsdxml (expat) 2.4.7
Update contrib/expat from 2.4.6 to 2.4.7.

MFC after: 2 weeks
Relnotes: yes

2 years agoVendor import of expat 2.4.7.
Xin LI [Mon, 28 Mar 2022 05:19:28 +0000 (22:19 -0700)]
Vendor import of expat 2.4.7.

2 years agoDescribe modern time zone handling.
Greg Lehey [Mon, 28 Mar 2022 03:57:37 +0000 (14:57 +1100)]
Describe modern time zone handling.
Reviewed by: peterj@
MFC after: 2 weeks

2 years agosys/stdatomic.h: be nicer to c++
Konstantin Belousov [Sun, 27 Mar 2022 21:16:15 +0000 (00:16 +0300)]
sys/stdatomic.h: be nicer to c++

Use of stdatomic.h is undefined in C++, even the C++ 2020 standard does not
list stdatomic.h as a C library header supported by the language.  More,
there are some subtle differences between the <atomic> C++ header, and
C11+ stdatomic.h provided features.

Nonetheless, it is a quality of the implementation aspect, so let mis-users
mis-use stdatomic.h as they want, by making a compat shim for _Bool.

PR: 262683
Reported by: yuri
Reviewed by: dim, emaste
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D34686

2 years agoypbind(8): Fix a typo in the man page
Gordon Bergling [Sun, 27 Mar 2022 18:42:24 +0000 (20:42 +0200)]
ypbind(8): Fix a typo in the man page

- s/ot/or/

MFC after: 3 days

2 years agonetgraph(4): Fix a typo in a source code comment
Gordon Bergling [Sun, 27 Mar 2022 18:08:44 +0000 (20:08 +0200)]
netgraph(4): Fix a typo in a source code comment

- s/shapshot/snapshot/

MFC after: 3 days

2 years agoclang: Skip attempts to access /proc/self/fd
Mateusz Guzik [Sun, 27 Mar 2022 18:01:38 +0000 (18:01 +0000)]
clang: Skip attempts to access /proc/self/fd

In contrast to Linux it does not provide entries which can be readlinked
-- these are just regular files, not giving the expected outcome. That's
on top of procfs not being mounted by default to begin with.

Reviewed by: dim
Differential Revision: https://reviews.freebsd.org/D34684

2 years agopf(4): Fix a typo in a source code comment
Gordon Bergling [Sun, 27 Mar 2022 17:57:49 +0000 (19:57 +0200)]
pf(4): Fix a typo in a source code comment

- s/seaching/searching/

MFC after: 3 days

2 years agomac_veriexec: Fix a typo in a source code comment
Gordon Bergling [Sun, 27 Mar 2022 17:56:15 +0000 (19:56 +0200)]
mac_veriexec: Fix a typo in a source code comment

- s/seach/search/

MFC after: 3 days

2 years agolibmd: Fix a common typo in the license header
Gordon Bergling [Sun, 27 Mar 2022 17:46:32 +0000 (19:46 +0200)]
libmd: Fix a common typo in the license header

- s/rouines/routines/

Obtained from: NetBSD
MFC after: 3 days

2 years agoath: Fix a typo in a source code comment
Gordon Bergling [Sun, 27 Mar 2022 17:28:49 +0000 (19:28 +0200)]
ath: Fix a typo in a source code comment

- s/ony/only/

MFC after: 3 days

2 years agonfsclient: Fix a typos in source code comments
Gordon Bergling [Sun, 27 Mar 2022 17:27:05 +0000 (19:27 +0200)]
nfsclient: Fix a typos in source code comments

- s/ony/only/

Obtained from: NetBSD
MFC after: 3 days

2 years agovfs: add missing bits to vdropl_impl
Mateusz Guzik [Sun, 27 Mar 2022 14:00:09 +0000 (14:00 +0000)]
vfs: add missing bits to vdropl_impl

This completes the patch which was originally meant to go in.

Spotted by: mhorne
Fixes: c35ec1efdcb2978b ("vfs: [1/2] fix stalls in vnode reclaim by not
requeieing from vnlru")

2 years agovfs: assorted tidy ups to lookup
Mateusz Guzik [Sat, 26 Mar 2022 10:26:59 +0000 (10:26 +0000)]
vfs: assorted tidy ups to lookup

No functional changes.

2 years agoLog euid, rgid and jail on listen queue overflow
Alexander Leidinger [Sat, 26 Mar 2022 10:14:16 +0000 (11:14 +0100)]
Log euid, rgid and jail on listen queue overflow

If you have numerous jails with multiple similar services running,
this helps to narrow down which services this log is referring to.

2 years agolibarchive: merge vendor bugfixes
Martin Matuska [Sat, 26 Mar 2022 10:04:36 +0000 (11:04 +0100)]
libarchive: merge vendor bugfixes

Bugfixes:
  IS #1672 and OSS-Fuzz #38766:
    (zip reader) fix possible out-of-bounds read in zipx_lzma_alone_init()
  PR #1676: (mtree reader) remove the unused variable "detected_bytes"
  PR #1674: (doc) fix use of At mdoc(7) macro in cpio.5

MFC after: 3 days

2 years agoUpdate vendor/libarchive to libarchive/libarchive@cfaa28168
Martin Matuska [Sat, 26 Mar 2022 09:46:31 +0000 (10:46 +0100)]
Update vendor/libarchive to libarchive/libarchive@cfaa28168

Bugfixes:
  IS #1672 and OSS-Fuzz #38766:
    (zip reader) fix possible out-of-bounds read in zipx_lzma_alone_init()
  PR #1676: (mtree reader) remove the unused variable "detected_bytes"
  PR #1674: (doc) fix use of At mdoc(7) macro in cpio.5

Obtained from: libarchive
Libarchive commit: cfaa28168a07ea4a53276b63068f94fce37d6aff

2 years agodepend-cleanup.sh: Handle libc bcmp.c moving back to bcmp.S on amd64
Mateusz Guzik [Sat, 26 Mar 2022 09:11:31 +0000 (09:11 +0000)]
depend-cleanup.sh: Handle libc bcmp.c moving back to bcmp.S on amd64

2 years agoamd64: bring back asm bcmp, shared with memcmp
Mateusz Guzik [Fri, 25 Mar 2022 15:04:04 +0000 (15:04 +0000)]
amd64: bring back asm bcmp, shared with memcmp

Turns out clang converts "memcmp(foo, bar, len) == 0" and similar to
bcmp calls.

Reviewed by: emaste (previous version), jhb (previous version)
Differential Revision: https://reviews.freebsd.org/D34673

2 years agojail: handle jailsys parameters in modification permission test
Jamie Gritton [Sat, 26 Mar 2022 02:16:51 +0000 (19:16 -0700)]
jail: handle jailsys parameters in modification permission test

Avoid a null dereference when a value-less jailsys parameter is passed
to "jail -m".  There was already code to handle boolean parameters,
but in reality any parameter could be passed without a value.

2 years agouma_zalloc_domain: call uma_zalloc_debug in multi-domain path
Eric van Gyzen [Mon, 7 Mar 2022 17:12:15 +0000 (11:12 -0600)]
uma_zalloc_domain: call uma_zalloc_debug in multi-domain path

It was only called in the non-NUMA and single-domain paths.
Some of its assertions were duplicated in uma_zalloc_domain,
but some things were missed, especially memguard.

Reviewed by: markj, rstone
MFC after: 1 week
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D34472

2 years agostack_zero is not needed before stack_save
Eric van Gyzen [Mon, 7 Mar 2022 16:01:45 +0000 (10:01 -0600)]
stack_zero is not needed before stack_save

The man page was recently clarified to commit to this contract.

MFC after: 1 week
Sponsored by: Dell EMC Isilon

2 years agostack(9): dynamic allocation is not necessary
Eric van Gyzen [Mon, 7 Mar 2022 01:12:28 +0000 (19:12 -0600)]
stack(9): dynamic allocation is not necessary

The man page said dynamic allocation was required, but struct stack
can be allocated in any way, including on the stack.  Make this clear,
and explain how to initialize the struct.

While I'm here, stack_save does not require any lock.

Reviewed by: markj, Pau Amma <pauamma_gundo.com>
MFC after: 1 week
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D34461

2 years agouma_zalloc: assert M_NOWAIT ^ M_WAITOK
Eric van Gyzen [Fri, 4 Mar 2022 11:23:08 +0000 (05:23 -0600)]
uma_zalloc: assert M_NOWAIT ^ M_WAITOK

The uma_zalloc functions expect exactly one of [M_NOWAIT, M_WAITOK].
If neither or both are passed, print an error and a stack dump.
Only do this ten times, to prevent livelock.  In the future, after
this exposes enough bad callers, this will be changed to a KASSERT().

Reviewed by: rstone, markj
MFC after: 1 month
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D34452

2 years agoksiginfo_alloc: pass M_WAITOK or M_NOWAIT to uma_zalloc
Eric van Gyzen [Fri, 4 Mar 2022 21:01:06 +0000 (15:01 -0600)]
ksiginfo_alloc: pass M_WAITOK or M_NOWAIT to uma_zalloc

It expects exactly one of those flags.  A future commit will assert this.

Reviewed by: rstone
MFC after: 1 month
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D34451

2 years agovm_ksubmap_init: pass M_WAITOK to vmem_init -> uma_zalloc_arg
Eric van Gyzen [Fri, 4 Mar 2022 20:55:12 +0000 (14:55 -0600)]
vm_ksubmap_init: pass M_WAITOK to vmem_init -> uma_zalloc_arg

uma_zalloc_arg expects exactly one of the two WAIT flags.  A future
commit will assert this.

Reviewed by: rstone
MFC after: 1 month
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D34450

2 years agobsdinstall checksum: Replace dialog with bsddialog
Alfonso S. Siciliano [Sat, 26 Mar 2022 00:36:13 +0000 (01:36 +0100)]
bsdinstall checksum: Replace dialog with bsddialog

Replace (LGPL) dialog utility with (BSD-2-Clause) bsddialog utility.

Approved by: bapt (mentor)
Differential Revision: https://reviews.freebsd.org/D34660

2 years agobsdinstall mirrorselect: Replace dialog with bsddialog
Alfonso S. Siciliano [Sat, 26 Mar 2022 00:13:59 +0000 (01:13 +0100)]
bsdinstall mirrorselect: Replace dialog with bsddialog

Replace (LGPL) dialog utility with (BSD-2-Clause) bsddialog utility.

Approved by: bapt (mentor)
Differential Revision: https://reviews.freebsd.org/D34582

2 years agobsdinstall time: Revert dialog title
Alfonso S. Siciliano [Fri, 25 Mar 2022 23:50:03 +0000 (00:50 +0100)]
bsdinstall time: Revert dialog title

Revert dialog title like before dialog(1) replacement
0e5c72c3cc5471dfa8cb42b018d623b1ef15dbe8.

Reported by: jrtc27
Approved by: bapt (mentor)
Differential Revision: https://reviews.freebsd.org/D34647

2 years agobsdinstall services: Replace dialog with bsddialog
Alfonso S. Siciliano [Fri, 25 Mar 2022 23:19:36 +0000 (00:19 +0100)]
bsdinstall services: Replace dialog with bsddialog

Replace (LGPL) dialog utility with (BSD-2-Clause) bsddialog utility.

Approved by: bapt (mentor)
Differential Revision: https://reviews.freebsd.org/D34640

2 years agortsx: Remove update of softc during probe and some var rename.
Henri Hennebert [Fri, 25 Mar 2022 19:23:59 +0000 (15:23 -0400)]
rtsx: Remove update of softc during probe and some var rename.

MFC after: 1 week

2 years agovfs: set cn_namelen when handling degenerate lookups
Mateusz Guzik [Fri, 25 Mar 2022 18:19:36 +0000 (18:19 +0000)]
vfs: set cn_namelen when handling degenerate lookups

Turns out execve looks at it to store binary name, but in order to
trigger the problem one has to be trying to exec '/'. As is the value
would be left uninitialized (or rather set to -1 on debug kernels).

Fixes: 56244d35741a62e7 ("vfs: hoist degenerate path lookups out of the
loop")

2 years agodepend-cleanup.sh: Handle libc bcmp.S moving to bcmp.c on amd64.
John Baldwin [Fri, 25 Mar 2022 18:03:18 +0000 (11:03 -0700)]
depend-cleanup.sh: Handle libc bcmp.S moving to bcmp.c on amd64.

Reviewed by: emaste
Fixes: 5fc3cc2713eff8cd ("amd64: make bcmp in libc just call memcmp")
Differential Revision: https://reviews.freebsd.org/D34676

2 years agoDrop an OBE MP safe comment.
John Baldwin [Fri, 25 Mar 2022 17:01:39 +0000 (10:01 -0700)]
Drop an OBE MP safe comment.

2 years agoarm: Zero padding in mcontext_vfp_t in get_vfpcontext().
John Baldwin [Fri, 25 Mar 2022 16:57:20 +0000 (09:57 -0700)]
arm: Zero padding in mcontext_vfp_t in get_vfpcontext().

This can leak kernel stack data otherwise.

Reviewed by: imp, markj
Sponsored by: The University of Cambridge, Google, Inc.
Differential Revision: https://reviews.freebsd.org/D34594

2 years agoAdd the Ampere and Fujitsu arm64 implementer IDs
D Scott Phillips [Fri, 25 Mar 2022 16:05:22 +0000 (09:05 -0700)]
Add the Ampere and Fujitsu arm64 implementer IDs

Reviewed By: andrew, emaste
MFC after: 3 days
Sponsored by: Ampere Computing
Differential Revision: https://reviews.freebsd.org/D34666

2 years agoarm64: Add explicit barrier after address translation instruction
D Scott Phillips [Fri, 25 Mar 2022 16:04:47 +0000 (09:04 -0700)]
arm64: Add explicit barrier after address translation instruction

Following ARMARM sec D5.2.11, which says:

> Where an instruction results in an update to a System register,
> as is the case with the AT * address translation instructions,
> explicit synchronization must be performed before the result is
> guaranteed to be visible to subsequent direct reads of the
> PAR_EL1.

Reviewed By: andrew
MFC after: 3 weeks
Sponsored by: Ampere Computing
Differential Revision: https://reviews.freebsd.org/D34665

2 years agoarm64: pmap: Mask VA operand in TLBI instructions
D Scott Phillips [Fri, 25 Mar 2022 16:04:11 +0000 (09:04 -0700)]
arm64: pmap: Mask VA operand in TLBI instructions

Bits 43:0 of the TLBI operand are bits 55:12 of the VA.  Leaving
bits 63:55 of the VA in bits 51:44 of the operand might wind up
setting the TTL field (47:44) and accidentally restricting which
translation levels are flushed in the TLB.

Reviewed By: andrew
MFC after: 3 days
Sponsored by: Ampere Computing
Differential Revision: https://reviews.freebsd.org/D34664

2 years agoamd64: remove bcmp.S
Mateusz Guzik [Fri, 25 Mar 2022 14:54:55 +0000 (14:54 +0000)]
amd64: remove bcmp.S

Fixes:  5fc3cc2713eff8cd ("amd64: make bcmp in libc just call memcmp")

2 years agolinux(4): Add AT_NO_AUTOMOUNT to statx.
Dmitry Chagin [Fri, 25 Mar 2022 14:54:23 +0000 (17:54 +0300)]
linux(4): Add AT_NO_AUTOMOUNT to statx.

Specific to Linux AT_NO_AUTOMOUNT flag tells the kernel to not automount the
terminal component of pathname if it is a directory that is an automount point.
As it is the default for FreeBSD silencly ignore this flag.

glibc-2.34 uses this flag in the stat64 system calls which is used by i386.

Reviewed by: trasz
Differential revision:  https://reviews.freebsd.org/D31524
MFC after: 2 weeks

2 years agolinprocfs: Eliminate bogus comment (KSE).
Dmitry Chagin [Fri, 25 Mar 2022 14:53:08 +0000 (17:53 +0300)]
linprocfs: Eliminate bogus comment (KSE).

Reviewed by: trasz, emaste
Differential revision: https://reviews.freebsd.org/D31525
MFC after: 2 weeks

2 years agopf: ether l3 rules can only use addresses
Kristof Provost [Fri, 25 Mar 2022 10:13:47 +0000 (11:13 +0100)]
pf: ether l3 rules can only use addresses

Disallow the use of tables in ethernet rules. Using tables requires
taking the PF_RULES lock. Moreover, the current table code isn't ready
to deal with ethernet rules.

Disallow their use for now.

Sponsored by: Rubicon Communications, LLC ("Netgate")

2 years agocxgbe(4): Handle FORCE_FEC in pcaps correctly.
Navdeep Parhar [Fri, 25 Mar 2022 07:34:54 +0000 (00:34 -0700)]
cxgbe(4): Handle FORCE_FEC in pcaps correctly.

The firmware doesn't report FORCE_FEC in pcaps if the transceiver
plugged in at that time does not support a speed that may use FEC.  It
is incorrect for the driver to assume that the FORCE_FEC value it read
during attach (in init_link_config) is permanent.  Instead, it should
check pcaps just before issuing the L1CFG command.

MFC after: 1 week
Sponsored by: Chelsio Communications

2 years agoLinuxKPI: 802.11: cleanup debugging
Bjoern A. Zeeb [Thu, 24 Mar 2022 19:09:04 +0000 (19:09 +0000)]
LinuxKPI: 802.11: cleanup debugging

Cleanup some debugging.  Rename the global variable to be less
generic.  Hide all debugging behind #ifdef for now and turn off.
Rename the debugging sysctl so we can start adding more to the
subtree.

There is a need to change that wildly grown infrastructure into
something more homogenic soon but this should do for 13.1.

Sponsored by: The FreeBSD Foundation
MFC after: 3 days

2 years agox86: Add a NT_X86_SEGBASES register set.
John Baldwin [Thu, 24 Mar 2022 18:36:19 +0000 (11:36 -0700)]
x86: Add a NT_X86_SEGBASES register set.

This register set contains the values of the fsbase and gsbase
registers.  Note that these registers can already be controlled
individually via ptrace(2) via MD operations, so the main reason for
adding this is to include these register values in core dumps.  In
particular, this will enable looking up the value of TLS variables
from core dumps in gdb.

The value of NT_X86_SEGBASES was chosen to match the value of
NT_386_TLS on Linux.  The notes serve similar purposes, but FreeBSD
will never dump a note equivalent to NT_386_TLS (which dumps a single
segment descriptor rather than a pair of addresses) and picking a
currently-unused value in the NT_X86_* range could result in a future
conflict.

Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D34650

2 years agoLinuxKPI: 802.11: improve hw_scan fallback to sw_scan
Bjoern A. Zeeb [Thu, 24 Mar 2022 17:49:59 +0000 (17:49 +0000)]
LinuxKPI: 802.11: improve hw_scan fallback to sw_scan

Extending what was started in d3ef7fb459ff924911e5276db0c04b13cd8074d9,
when a driver signals that hw_scan is not possible and expects a sw_scan
to be preformed we triggered a sw_scan towards the driver but did not
let net80211 know.
Cancel the initial scan towards net80211.  If we we defer to sw_scan
then clear IEEE80211_FEXT_SCAN_OFFLOAD so net80211 will send probe
requests, and actively start a new scan with net80211.
This may have to be further refined in the future but seems to work
for the moment.

Sponsored by: The FreeBSD Foundation
MFC after: 3 days

2 years agoLinuxKPI: 802.11: remove special handling for (*ic_scan_curchan)
Bjoern A. Zeeb [Thu, 24 Mar 2022 17:32:07 +0000 (17:32 +0000)]
LinuxKPI: 802.11: remove special handling for (*ic_scan_curchan)

Remove the originally disabling of (*ic_scan_curchan), which for iwlwifi
was not needed.  The condition always only was approximate.

A set IEEE80211_FEXT_SCAN_OFFLOAD will still prevent net80211 from sending
probe_reqs if handled by driver/firmware.
ic_scan_curchan will re-arm the timer to switch channels for drivers which
need it (e.g., rtw88, but that again is a NOP for iwlwifi).

So enabling ic_scan_curchan should not have further side effects for iwlwifi
but allow other drivers to work better.

Sponsored by: The FreeBSD Foundation
MFC after: 3 days

2 years agoLinuxKPI: 802.11: check IEEE80211_FEXT_SCAN_OFFLOAD on vap
Bjoern A. Zeeb [Thu, 24 Mar 2022 17:24:47 +0000 (17:24 +0000)]
LinuxKPI: 802.11: check IEEE80211_FEXT_SCAN_OFFLOAD on vap

When checking for IEEE80211_FEXT_SCAN_OFFLOAD, do so on the vap rather
than ic.  This brings us in line with what net80211 does.

Sponsored by: The FreeBSD Foundation
MFC after: 3 days

2 years agoLinuxKPI: 802.11: make lkpi_ic_set_channel() unconditional
Bjoern A. Zeeb [Thu, 24 Mar 2022 16:51:02 +0000 (16:51 +0000)]
LinuxKPI: 802.11: make lkpi_ic_set_channel() unconditional

For (*config)() based drivers not using chanctx we need to use
ic_set_channel() to switch channels.  So far this was disabled
based on scanning flags (as swscan is one of the initial use cases
for this function).  Now make it only dependent on (*config)()
for the moment to save us the work if (*config)() is not supported.

For iwlwifi (*config)() is a NOP so no functional changes there
but for other drivers such as rtw88 this will allow us to scan and
set the channel (which helps to receive on channels other than 1).

Sponsored by: The FreeBSD Foundation
MFC after: 3 days

2 years agokbd: replace vestigial spl calls with Giant assertions
Ed Maste [Tue, 22 Mar 2022 17:48:43 +0000 (13:48 -0400)]
kbd: replace vestigial spl calls with Giant assertions

The keyboard driver was initially protected via spl* interrupt priority
calls but (as part of a comprehensive effort) migrated to use the Giant
lock (mutex).

The spl calls left behind became NOPs but they can be confusing as they
have no bearing on the actual mutual exclusion that is now present.

Remove them from kbd and add assertions that Giant is held.  markj notes
that there is conflation between the "bus topo" lock (which is Giant
under the hood) and Giant.  The assertions could either be addressed as
a small item along with bus topology locking work or they'll be removed
if kbd is decoupled from Giant.

PR: 206680
Reviewed by: markj
MFC after: 3 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D34645

2 years agoLinuxKPI: 802.11: use cfg80211_chandef_create()
Bjoern A. Zeeb [Thu, 24 Mar 2022 15:43:22 +0000 (15:43 +0000)]
LinuxKPI: 802.11: use cfg80211_chandef_create()

Rather than manually setting up a chandef and then effectively forcing
a memcpy, use cfg80211_chandef_create() to do the work for us entirely.
This works here as we do not store the resulting chandef separately
for other use.

While here remove a duplicate assignment in cfg80211_chandef_create().

Sponsored by: The FreeBSD Foundation
MFC after: 3 days

2 years agoLinuxKPI: 802.11: improve lkpi_80211_mo_sta_state() for non (*sta_state)
Bjoern A. Zeeb [Thu, 24 Mar 2022 15:34:57 +0000 (15:34 +0000)]
LinuxKPI: 802.11: improve lkpi_80211_mo_sta_state() for non (*sta_state)

If a driver does not support (*sta_state)() we internally in
lkpi_80211_mo_sta_state() fall back to using (*sta_add/*sta_remove)().
In that case add tracking of both added_to_drv and state fields for the
lsta so that our state machine keeps working and assertions do not fire.

Sponsored by: The FreeBSD Foundation
MFC after: 3 days

2 years agobhyve: Do not remove guest physical addresses from IOMMU host domain
Bjoern A. Zeeb [Fri, 18 Mar 2022 20:39:06 +0000 (20:39 +0000)]
bhyve: Do not remove guest physical addresses from IOMMU host domain

This permits I/O devices on the host to directly access wired memory
dedicated to guests using passthru devices.  Note that wired memory
belonging to guests that do not use passthru devices has always been
accessible by I/O devices on the host.

bhyve maps guest physical addresses into the user address space of
the bhyve process by mmap'ing /dev/vmm/<vmname>.  Device models pass
pointers derived from this mapping directly to system calls such as
preadv() to minimize copies when emulating DMA.  If the backing store
for a device model is a raw host device (e.g. when exporting a raw disk
device such as /dev/ada<n> as a drive in the guest), the host device
driver (e.g. ahci for /dev/ada<n>) can itself use DMA on the host
directly to the guest's memory.  However, if the guest's memory is
not present in the host IOMMU domain, these DMA requests by the host
device will fail without raising an error visible to the host device
driver or to the guest resulting in non-working I/O in the guest.

It is unclear why guest addresses were removed from the IOMMU host domain
initially, especially only for VM's with a passthru device as the
host IOMMU domain does not affect the permissions of passthru devices,
only devices on the host.

A considered alternative was using bounce buffers instead (D34535
is a proof of concept), but that adds additional overhead for unclear
benefit.

This solves a long-standing problem when using passthru devices and
physical disks in the same VM.

Thanks to: grehan (patience and help)
Thanks to: jhb (for improving the commit message)
PR: 260178
Reviewed by: grehan, jhb
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D34607

2 years agoLinuxKPI: allow bsddriver name to be set for PCI
Bjoern A. Zeeb [Thu, 24 Mar 2022 01:45:36 +0000 (01:45 +0000)]
LinuxKPI: allow bsddriver name to be set for PCI

Allow a driver to overwrite the bsddriver name (we use for pci and
for wlan parent devices).  This allows us to to set
.bsddriver.name in struct pci_driver passed to module_pci_driver()
and with that set the BSD driver name while retaining the Linux .name
one.

This is helpful for divers which have different parts depending on
chipset and with that would change driver names which is highly
confusing especially for configuration.   One example is an upcoming
rtw88 driver which would be rtw_8822be or rtw_8822ce depending on
chipset.

Sponsored by: The FreeBSD Foundation
MFC after: 3 days
Reviewed by: emaste, hselasky
Differential Revision: https://reviews.freebsd.org/D34653

2 years agovfs: hoist trailing slash handling out of the loop
Mateusz Guzik [Thu, 24 Mar 2022 13:17:31 +0000 (13:17 +0000)]
vfs: hoist trailing slash handling out of the loop

2 years agoriscv: fix riscv64sf build
Piotr Kubaj [Thu, 24 Mar 2022 14:24:21 +0000 (15:24 +0100)]
riscv: fix riscv64sf build

The library needs to have sf suffix cut off.

MFC after: 3 days
X-MFC with: 3781e77995e9b81afcbf7b3dc84b33b864c48794
Differential revision: https://reviews.freebsd.org/D34561
Reviewed by: dim

2 years agovfs: factor symlink traversal out of namei
Mateusz Guzik [Thu, 24 Mar 2022 12:57:30 +0000 (12:57 +0000)]
vfs: factor symlink traversal out of namei

The intent down the road is to eliminate the loop to begin with,
pushing traversal down to vfs_lookup, all while not allocating the
extra buffer.

2 years agovfs: factor FAILIFEXISTS handling out of vfs_lookup
Mateusz Guzik [Sun, 13 Mar 2022 17:36:51 +0000 (17:36 +0000)]
vfs: factor FAILIFEXISTS handling out of vfs_lookup

2 years agovfs: hoist degenerate path lookups out of the loop
Mateusz Guzik [Fri, 11 Mar 2022 15:51:39 +0000 (15:51 +0000)]
vfs: hoist degenerate path lookups out of the loop

2 years agovfs: retire the NDF_ONLY_PNBUF flag
Mateusz Guzik [Thu, 24 Mar 2022 10:15:54 +0000 (10:15 +0000)]
vfs: retire the NDF_ONLY_PNBUF flag

Consumers should use NDFREE_PNBUF instead.

2 years agovfs: NDFREE(&nd, NDF_ONLY_PNBUF) -> NDFREE_PNBUF(&nd)
Mateusz Guzik [Thu, 24 Mar 2022 10:10:03 +0000 (10:10 +0000)]
vfs: NDFREE(&nd, NDF_ONLY_PNBUF) -> NDFREE_PNBUF(&nd)

2 years agoMerge LLVM commit c03fdd340356 to fix lang/rust on powerpc
Piotr Kubaj [Thu, 24 Mar 2022 00:30:44 +0000 (01:30 +0100)]
Merge LLVM commit c03fdd340356 to fix lang/rust on powerpc

Summary:
Without it building rust fails with:
ld: error: CallSiteSplitting.cpp:(function llvm::SmallVectorImpl<std::__1::pair<llvm::BasicBlock*, llvm::SmallVector<std::__1::pair<llvm::ICmpInst*, unsigned int>, 2u> > >::operator=(llvm::SmallVectorImpl<std::__1::pair<llvm::BasicBlock*, llvm::SmallVector<std::__1::pair<llvm::ICmpInst*, unsigned int>, 2u> > >&&): .text._ZN4llvm15SmallVectorImplINSt3__14pairIPNS_10BasicBlockENS_11SmallVectorINS2_IPNS_8ICmpInstEjEELj2EEEEEEaSEOSB_+0xB0): relocation R_PPC_PLTREL24 out of range: -33582208 is not in [-3355443233554431]\19

This will need to be merged to releng/13.1.

Reviewed by: dim
Differential Revision: https://reviews.freebsd.org/D34652
MFC after: 3 days

2 years agohardware: added Dell H840 raid support
Wojciech Macek [Thu, 24 Mar 2022 06:13:45 +0000 (07:13 +0100)]
hardware: added Dell H840 raid support

Obtained from: Stormshield
Differential revision: https://reviews.freebsd.org/D34623

2 years agoDTrace test: skip flakey common.misc.t_dtrace_contrib.tst_dynopt_d in CI
Li-Wen Hsu [Thu, 24 Mar 2022 03:37:50 +0000 (11:37 +0800)]
DTrace test: skip flakey common.misc.t_dtrace_contrib.tst_dynopt_d in CI

PR: 237641
Sponsored by: The FreeBSD Foundation

2 years agoDTrace test: Add a new keyword SKIPCI to gentest.sh
Li-Wen Hsu [Thu, 24 Mar 2022 03:30:27 +0000 (11:30 +0800)]
DTrace test: Add a new keyword SKIPCI to gentest.sh

This is for marking a test case is flakey and should not be executed in
the CI environment.

Reviewed by: markj
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D34635

2 years agortsx: Display error if rtsx_read()/rtsx_write() fail.
Henri Hennebert [Thu, 24 Mar 2022 01:01:00 +0000 (21:01 -0400)]
rtsx: Display error if rtsx_read()/rtsx_write() fail.

MFC after: 1 week

2 years agortsx: Don't detach during shutdown
Henri Hennebert [Thu, 24 Mar 2022 00:58:38 +0000 (20:58 -0400)]
rtsx: Don't detach during shutdown

MFC after: 1 week

2 years agohda: whitespace fix for realtek pin patches
Ed Maste [Thu, 24 Mar 2022 00:54:51 +0000 (20:54 -0400)]
hda: whitespace fix for realtek pin patches

2 years agosound: test PCM_REGISTERED before PCM_DETACHING
Ed Maste [Mon, 21 Mar 2022 16:15:22 +0000 (12:15 -0400)]
sound: test PCM_REGISTERED before PCM_DETACHING

PCM_REGISTERED(d) tests that d is not NULL, so perform that check first
as we may have cases where devclass_get_softc has a null entry.

PR: 262671
Reviewed by: hselasky
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D34648

2 years agobsdinstall(8): Usage example of tar doesn't work
Farhan Khan [Wed, 23 Mar 2022 20:54:30 +0000 (21:54 +0100)]
bsdinstall(8): Usage example of tar doesn't work

The order of arguments in the example does not work, because tar thinks
the directory is named -C, which does not exist and reports:
tar: Error opening archive: Failed to open '-C'

Approved by: rpokala@ (src) on IRC
Differential Revision: https://reviews.freebsd.org/D34649

2 years agoarm,arm64: Add a NT_ARM_TLS read-only register set.
John Baldwin [Wed, 23 Mar 2022 20:33:06 +0000 (13:33 -0700)]
arm,arm64: Add a NT_ARM_TLS read-only register set.

This register set exposes the per-thread TLS register.  It matches the
layout used by Linux on arm64.  Linux does not implement this note for
32-bit arm.

Reviewed by: andrew, markj
Sponsored by: University of Cambridge, Google, Inc.
Differential Revision: https://reviews.freebsd.org/D34595

2 years agoUse a regset for NT_ARM_VFP.
John Baldwin [Wed, 23 Mar 2022 20:33:06 +0000 (13:33 -0700)]
Use a regset for NT_ARM_VFP.

This includes adding support for NT_ARM_VFP for 32-bit binaries
running under aarch64 kernels both for ptrace(), and coredumps via the
kernel and gcore.

Reviewed by: andrew, markj
Sponsored by: University of Cambridge, Google, Inc.
Differential Revision: https://reviews.freebsd.org/D34448

2 years agoaarch64: Fix get_fpcontext32() to work on non-curthread.
John Baldwin [Wed, 23 Mar 2022 20:33:06 +0000 (13:33 -0700)]
aarch64: Fix get_fpcontext32() to work on non-curthread.

Similar to fill_fpregs(), only invoke vfp_save_state() for curthread.

While here, zero the buffer if FP hasn't been started to avoid leaking
kernel stack memory.

Reviewed by: andrew, markj
Sponsored by: University of Cambridge, Google, Inc.
Differential Revision: https://reviews.freebsd.org/D34525

2 years ago<sys/reg.h>: Add ELF32_REGSET.
John Baldwin [Wed, 23 Mar 2022 20:33:06 +0000 (13:33 -0700)]
<sys/reg.h>: Add ELF32_REGSET.

This permits adding a register set for FREEBSD32 ABIs.

While here, include <sys/linker_set.h> to make this header more
self-contained in the kernel.

Reviewed by: andrew, markj
Sponsored by: The University of Cambridge, Google, Inc.
Differential Revision: https://reviews.freebsd.org/D34536

2 years agocxgbe(4): Allow dump_cimla and dump_devlog to sleep.
Navdeep Parhar [Tue, 22 Mar 2022 20:13:56 +0000 (13:13 -0700)]
cxgbe(4): Allow dump_cimla and dump_devlog to sleep.

This has been safe since e9e7bc82505, which moved parts of error
handling from the ithread to a taskqueue.

MFC after: 1 week
Sponsored by: Chelsio Communications

2 years agoLinuxKPI: 802.11: fix lkpi_lsta_dump() debugging
Bjoern A. Zeeb [Wed, 23 Mar 2022 17:14:03 +0000 (17:14 +0000)]
LinuxKPI: 802.11: fix lkpi_lsta_dump() debugging

Fix two last-minute changes of d9f59799fc3e7940c47aa674c25994e640eae45e:
(1) for consitency name the debugging function lkpi_lsta_dump()
(2) pass in the original node (ni) rather than taking it from the lsta
    to avoid problems realted to bss_update as mentioned in the above
    commit.

No functional changes for users.

Sponsored by: The FreeBSD Foundation
MFC after: 3 days
X-MFC with: d9f59799fc3e7940c47aa674c25994e640eae45e

2 years agoLinuxKPI: skbuff: fix skb_queue_splice_init()
Bjoern A. Zeeb [Wed, 23 Mar 2022 17:05:43 +0000 (17:05 +0000)]
LinuxKPI: skbuff: fix skb_queue_splice_init()

In skb_queue_splice_init() we set a next value and then used that new
value to further update the remaining linking rather than the original
value.  Introduce another temporary variable 'n' to hold the original
value and use that.
While here rename q and h to from and to as otherwise it was too
confusing to read.

Also initialize skb->prev and skb->next to point to skb itself if
for nothing else at least to aid debugging.

Reported by: phk (panic in iwl_txq_reclaim)
Sponsored by: The FreeBSD Foundation
MFC after: 3 days

2 years agoelf: Avoid dumping uninitialized bytes in PRSTATUS core dump notes
Mark Johnston [Wed, 23 Mar 2022 16:52:44 +0000 (12:52 -0400)]
elf: Avoid dumping uninitialized bytes in PRSTATUS core dump notes

elf_prstatus_t contains pad space.

Reported by: KMSAN
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D34606

2 years agocallout: Remove the CS_EXECUTING flag
Mark Johnston [Wed, 23 Mar 2022 16:37:02 +0000 (12:37 -0400)]
callout: Remove the CS_EXECUTING flag

It is now unused.

MFC after: 1 month
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D34626

2 years agosetitimer: Fix exit race
Mark Johnston [Wed, 23 Mar 2022 16:36:12 +0000 (12:36 -0400)]
setitimer: Fix exit race

We use the p_itcallout callout, interlocked by the proc lock, to
schedule timeouts for the setitimer(2) system call.  When a process
exits, the callout must be stopped before the process struct is
recycled.

Currently we attempt to stop the callout in exit1() with the call
_callout_stop_safe(&p->p_itcallout, CS_EXECUTING).  If this call returns
0, then we sleep in order to drain the callout.  However, this happens
only if the callout is not scheduled at all.  If the callout thread is
blocked on the proc lock, then exit1() will not block and the callout
may execute after the process has fully exited, typically resulting in a
panic.

I cannot see a reason to use the CS_EXECUTING flag here.  Instead, use
the regular callout_stop()/callout_drain() dance to halt the callout.

Reported by: ler
Tested by: ler, pho
MFC after: 1 month
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D34625

2 years agobsdinstall time: Replace dialog with bsddialog
Alfonso S. Siciliano [Wed, 23 Mar 2022 15:52:39 +0000 (16:52 +0100)]
bsdinstall time: Replace dialog with bsddialog

Replace (LGPL) dialog utility with (BSD-2-Clause) bsddialog utility,
'dialog --calendar' is replaced by 'bsddialog --datebox' with same
features but different User Interface.

Approved by: bapt (mentor)
Differential Revision: https://reviews.freebsd.org/D34583

2 years agoRemove L2_BLOCK_MASK from arm64
Andrew Turner [Wed, 23 Mar 2022 15:33:05 +0000 (15:33 +0000)]
Remove L2_BLOCK_MASK from arm64

It's unneeded as it was just used to align KERNBASE to a level 2
block start address. KERNBASE was already aligned correctly.

Sponsored by: The FreeBSD Foundation

2 years agoSupport EFIRT on arm64 with a non 4k page size
Andrew Turner [Wed, 23 Mar 2022 15:18:30 +0000 (15:18 +0000)]
Support EFIRT on arm64 with a non 4k page size

When the page size the kernel is built for is not the same as
EFI_PAGE_SIZE we need to increment the page index at a faster rate.

Add this adjustment to the arm64 EFIRT support in preperation for
experimental 16k PAGE_SIZE support.

Sponsored by: The FreeBSD Foundation

2 years agoAdd an implementation of .mcount on arm64
Andrew Turner [Tue, 22 Mar 2022 15:46:15 +0000 (15:46 +0000)]
Add an implementation of .mcount on arm64

To support cc -pg on arm64 we need to implement .mcount. As clang and
gcc think it is function like it just needs to load the arguments
to _mcount and call it.

On gcc the first argument is passed in x0, however this is missing on
clang so we need to load it from the stack. As it's the caller return
address this will be at a known location.

PR: 262709
Reviewed by: emaste (earlier version)
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D34634

2 years agolinuxkpi: Add down_write_nest_lock
Emmanuel Vadot [Tue, 22 Mar 2022 09:28:02 +0000 (10:28 +0100)]
linuxkpi: Add down_write_nest_lock

Simply calls down_write like in Linux (when CONFIG_DEBUG_LOCK_ALLOC isn't
specified)
Needed by drm v5.10

MFC after: 1 month
Reviewed by: hselasky
Sponsored by: Beckhoff Automation GmbH & Co. KG
Differential Revision: https://reviews.freebsd.org/D34642

2 years agolinuxkpi: Add kstrtouint_from_user
Emmanuel Vadot [Tue, 22 Mar 2022 09:22:42 +0000 (10:22 +0100)]
linuxkpi: Add kstrtouint_from_user

Like kstrtoint_from_user but for uint.
Needed by drm v5.10

MFC after: 1 month
Reviewed by: hselasky
Sponsored by: Beckhoff Automation GmbH & Co. KG
Differential Revision: https://reviews.freebsd.org/D34642

2 years agolinuxkpi: Add cond_resched_lock
Emmanuel Vadot [Mon, 21 Mar 2022 10:14:05 +0000 (11:14 +0100)]
linuxkpi: Add cond_resched_lock

If we need to resched it takes the lock, resched, release the lock
and returns 1, otherwise simply returns 0.

Needed by drm v5.9

MFC after: 1 month
Reviewed by: hselasky
Sponsored by: Beckhoff Automation GmbH & Co. KG
Differential Revision: https://reviews.freebsd.org/D34620

2 years agoAdd devices and quirks for some Olympus cameras.
Greg Lehey [Wed, 23 Mar 2022 01:40:28 +0000 (12:40 +1100)]
Add devices and quirks for some Olympus cameras.

Reviewed by: hps@
Fixes:     Problems attaching Olympus cameras.
MFC after: 2 weeks

2 years agobsdinstall hardening: Replace dialog with bsddialog
Alfonso S. Siciliano [Tue, 22 Mar 2022 23:52:22 +0000 (00:52 +0100)]
bsdinstall hardening: Replace dialog with bsddialog

bsdinstall/scripts/hardening: Replace (LGPL) dialog utility with
(BSD-2-CLAUSE) dialog utility.

Approved by: bapt (mentor)
Differential Revision: https://reviews.freebsd.org/D34102

2 years agotest-includes: improve portability
Brooks Davis [Tue, 22 Mar 2022 20:23:22 +0000 (20:23 +0000)]
test-includes: improve portability

FreeBSD's shell permits [^bar] to match characters not in [bar] like
common regular expressions. This is non-portable and '!' should be
used in place of '^' for portability.

Reported by: Nathaniel Wesley Filardo
Issue: https://github.com/CTSRD-CHERI/cheribsd/issues/1321
Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D34597

2 years agoCorrect a handful of typos and grammos.
Jens Schweikhardt [Tue, 22 Mar 2022 20:12:42 +0000 (21:12 +0100)]
Correct a handful of typos and grammos.

2 years agoLinuxKPI: 802.11: rework sta state machine compatibility
Bjoern A. Zeeb [Tue, 22 Mar 2022 18:34:13 +0000 (18:34 +0000)]
LinuxKPI: 802.11: rework sta state machine compatibility

Rework the state machine parts for various reasons:
(1) to add sta tracing to be able to better follow ni and lsta state
(2) factor out/implement lkpi_lsta_remove() to unlink the lsta and
    free the ni reference.
(3) avoid calling lkpi_disassoc() when you would think you should as
    changing BSS_CHANGED_ASSOC setting vif->bss_conf.assoc to false
    triggers a sta removal from firmware in iwlwifi which then triggers
    follow-up errors.  I do not understand why they use flags and state
    and ?? in parallel (too many options and ways to do things?).
(4) when "roaming" (or being disassoc/deauth) from an AP both net80211
    and apparently so mac80211 re-start with a new node/sta.  This
    results in us losing one or the other state in the compat layer
    or not updating firmware appropriately.  To resolve this make use
    of (a) the newly introduced (*iv_update_bss)() and (b) always tear
    a station down to "State 1" (INIT/SCAN/pre-AUTH) and only if needed
    re-create the new one (if we go to AUTH).
    A slightly earlier version has survived a night of wpa_supplicant
    and hostapd fighting each other over disassoc and deauth and
    re-associating/authorizing.

While there update a few comments and typos and do a few minor auxiliary
changes which are hard or not worth to extract.

Sponsored by: The FreeBSD Foundation
MFC after: 3 days

2 years agoLinuxKPI: 802.11: factor out dtim/tsf updates
Bjoern A. Zeeb [Tue, 22 Mar 2022 18:16:56 +0000 (18:16 +0000)]
LinuxKPI: 802.11: factor out dtim/tsf updates

Factor out dtim/tsf setting/updates into lkpi_update_dtim_tsf()
with tracing and add an extra update call.
This avoids some code duplication and puts maintainance into a
single place.

Sponsored by: The FreeBSD Foundation
MFC after: 3 days

2 years agoLinuxKPI: 802.11: factor out lkpi_lsta_alloc() from lkpi_ic_node_alloc()
Bjoern A. Zeeb [Tue, 22 Mar 2022 15:14:31 +0000 (15:14 +0000)]
LinuxKPI: 802.11: factor out lkpi_lsta_alloc() from lkpi_ic_node_alloc()

Split lkpi_ic_node_alloc() into two functions to make the code simpler
and to allow lkpi_lsta_alloc() to be re-used from another part of the
code related to (*iv_update_bss)().

Sponsored by: The FreeBSD Foundation
MFC after: 3 days

2 years agoLinuxKPI: 802.11: implement ieee80211_beacon_loss()
Bjoern A. Zeeb [Tue, 22 Mar 2022 15:02:45 +0000 (15:02 +0000)]
LinuxKPI: 802.11: implement ieee80211_beacon_loss()

Implement ieee80211_beacon_loss() similar to
ieee80211_connection_loss() with different state handling.
While here leave a comment in connection_loss() about the state
change argument.

Sponsored by: The FreeBSD Foundation
MFC after: 3 days

2 years agonet80211: introduce (*iv_update_bss)()
Bjoern A. Zeeb [Tue, 22 Mar 2022 14:46:51 +0000 (14:46 +0000)]
net80211: introduce (*iv_update_bss)()

Introduce (*iv_update_bss)() with a default implementation to allow
drivers to overload/intercept the time when we swap iv_bss.

This helps firmware based drivers to synchronize state with firmware.
Otherwise, for some state changes, we begin with one ni (and in
LinuxKPI lsta) and try to finish with another ni (and a new lsta
in different state) and may no longer have access to the previous state.
This also saves us from constantly checking for ni changes complicating
code.

No functional changes intended.

Sponsored by: The FreeBSD Foundation
MFC after: 3 days
X-MFC: move (*iv_update_bss) to spare area

2 years agonet80211: improve one debug logging
Bjoern A. Zeeb [Tue, 22 Mar 2022 14:40:12 +0000 (14:40 +0000)]
net80211: improve one debug logging

When forcing DEUATH in ieee80211_sta_join1() log the current state
we are coming from as well.  Note this isn't always the state we
are expecting as iv_state was updated already, so contrary to the
comment we usually do not see RUN there.
Leave a comment earlier with regards to this as well.

Sponsored by: The FreeBSD Foundation
MFC after: 3 days

2 years agoRemove the unused arm64 kernel profiling code
Andrew Turner [Tue, 22 Mar 2022 15:48:58 +0000 (15:48 +0000)]
Remove the unused arm64 kernel profiling code

It's unused. Remove it in preperation for userspace support.

Sponsored by: The FreeBSD Foundation

2 years agoneta: split fixed and in-band link status configuration
Sebastien Bini [Tue, 22 Mar 2022 15:44:09 +0000 (16:44 +0100)]
neta: split fixed and in-band link status configuration

Fixed-link mode requires different handling than the in-band
managed connection. Update interrupt, link-up/down and
autonegotiation settings for the former.

Reviewed by: mw
MFC after: 1 week
Obtained from: Stormshield
Differential Revision: https://reviews.freebsd.org/D34394

2 years agoIPv4 multicast: fix netstat -g
Mike Karels [Mon, 21 Mar 2022 19:59:13 +0000 (14:59 -0500)]
IPv4 multicast: fix netstat -g

The vif structure includes fields at the end which are #ifdef KERNEL,
causing a mismatch between the structure sizes between kernel and
user level.  netstat -g failed with an ENOMEM on the sysctl to fetch
the vif table.  Change the vif sysctl code in ip_mroute to copy out
only the user-level-visible portion of each table entry.

Reviewed by: bz, wma
Differential Revision: https://reviews.freebsd.org/D34627