]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
2 years agoCAM: Keep periph_links when restoring CCB in camperiphdone().
Alexander Motin [Thu, 28 Apr 2022 01:39:50 +0000 (21:39 -0400)]
CAM: Keep periph_links when restoring CCB in camperiphdone().

While recovery command executed, some other commands from the periph
may complete, that may affect periph_links of this CCB.  So restoring
original CCB we must keep current periph_links as more up to date.

I've found this triggering assertions with debug kernel and suspect
some memory corruptions otherwise when spun down disk receives two
or sometimes more concurrent requests.

MFC after: 1 week
Sponsored by: iXsystems, Inc.

2 years agosubr_unit.c: make userspace tests buildable
Konstantin Belousov [Thu, 28 Apr 2022 00:00:14 +0000 (03:00 +0300)]
subr_unit.c: make userspace tests buildable

by defining a placeholder for UNR_NO_MTX

Sponsored by: The FreeBSD Foundation
MFC after: 1 week

2 years agoFix another race between fork(2) and PROC_REAP_KILL subtree
Konstantin Belousov [Thu, 21 Apr 2022 22:39:58 +0000 (01:39 +0300)]
Fix another race between fork(2) and PROC_REAP_KILL subtree

where we might not yet see a new child when signalling a process.
Ensure that this cannot happen by stopping all reapping subtree,
which ensures that the child is not inside a syscall, in particular
fork(2).

Reported and tested by: pho
Reviewed by: markj
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D35014

2 years agoFix a race between fork(2) and PROC_REAP_KILL subtree
Konstantin Belousov [Wed, 20 Apr 2022 21:33:51 +0000 (00:33 +0300)]
Fix a race between fork(2) and PROC_REAP_KILL subtree

by repeating iteration over the subtree until there are no new processes
to signal.

Reported and tested by: pho
Reviewed by: markj
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D35014

2 years agokern_procctl: add possibility to take stop_all_proc_block() around exec
Konstantin Belousov [Wed, 27 Apr 2022 21:18:34 +0000 (00:18 +0300)]
kern_procctl: add possibility to take stop_all_proc_block() around exec

stop_allo_proc_block() must be taken before proctree_lock.

Reviewed by: markj
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D35014

2 years agoAdd stop_all_proc_block(9)
Konstantin Belousov [Sat, 23 Apr 2022 22:55:04 +0000 (01:55 +0300)]
Add stop_all_proc_block(9)

It allows to have more than one consumer of thread_signle(SIGNLE_ALLPROC) by
serializing them.

Reviewed by: markj
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D35014

2 years agoreap_kill(): split children and subtree killers into helpers
Konstantin Belousov [Wed, 20 Apr 2022 21:12:05 +0000 (00:12 +0300)]
reap_kill(): split children and subtree killers into helpers

Reviewed by: markj
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D35014

2 years agoreap_kill(): rename the reap variable to reaper
Konstantin Belousov [Mon, 25 Apr 2022 22:10:16 +0000 (01:10 +0300)]
reap_kill(): rename the reap variable to reaper

Suggested and reviewed by: markj
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D35014

2 years agoreap_kill(): de-inline LIST_FOREACH(), twice
Konstantin Belousov [Mon, 25 Apr 2022 21:57:13 +0000 (00:57 +0300)]
reap_kill(): de-inline LIST_FOREACH(), twice

Suggested and reviewed by: markj
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D35014

2 years agoreaper_abandon_children(): upgrade proctree_lock assert to exclusive
Konstantin Belousov [Tue, 26 Apr 2022 14:44:48 +0000 (17:44 +0300)]
reaper_abandon_children(): upgrade proctree_lock assert to exclusive

p_reapsibling linkage is protected by proctree_lock, and it is modified
there.

Suggested and reviewed by: markj
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D35014

2 years agounr(9): allow to avoid internal locking
Konstantin Belousov [Wed, 20 Apr 2022 22:14:37 +0000 (01:14 +0300)]
unr(9): allow to avoid internal locking

Reviewed by: markj
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D35014

2 years agoinit_unrhdr(): make it usable by initializing everything
Konstantin Belousov [Wed, 20 Apr 2022 21:58:22 +0000 (00:58 +0300)]
init_unrhdr(): make it usable by initializing everything

Reviewed by: markj
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D35014

2 years agopowerpc pseries xics: Use devclass_find to lookup xicp devclass.
John Baldwin [Wed, 27 Apr 2022 22:08:47 +0000 (15:08 -0700)]
powerpc pseries xics: Use devclass_find to lookup xicp devclass.

Reviewed by: jhibbits
Differential Revision: https://reviews.freebsd.org/D35083

2 years agogpio/qoriq: Recognize another compatible string entry
Justin Hibbits [Wed, 27 Apr 2022 21:55:42 +0000 (16:55 -0500)]
gpio/qoriq: Recognize another compatible string entry

2 years agogpiopower: Fix call to ofw_gpiobus_parse_gpios
Justin Hibbits [Wed, 27 Apr 2022 21:55:28 +0000 (16:55 -0500)]
gpiopower: Fix call to ofw_gpiobus_parse_gpios

Failure is denoted by -1, not non-zero.  A positive integer denotes the
number of pins mapped and configured.

2 years agolacp: short timeout erroneously declares link-flapping
Greg Foster [Tue, 26 Apr 2022 06:38:23 +0000 (23:38 -0700)]
lacp: short timeout erroneously declares link-flapping

Panasas was seeing a higher-than-expected number of link-flap events.
After joint debugging with the switch vendor, we determined there were
problems on both sides; either of which might cause the occasional
event, but together caused lots of them.

On the switch side, an internal queuing issue was causing LACP PDUs --
which should be sent every second, in short-timeout mode -- to sometimes
be sent slightly later than they should have been. In some cases, two
successive PDUs were late, but we never saw three late PDUs in a row.

On the FreeBSD side, we saw a link-flap event every time there were two
late PDUs, while the spec says that it takes *three* seconds of downtime
to trigger that event. It turns out that if a PDU was received shortly
before the timer code was run, it would decrement less than a full
second after the PDU arrived. Then two delayed PDUs would cause two
additional decrements, causing it to reach zero less than three seconds
after the most-recent on-time PDU.

The solution is to note the time a PDU arrives, and only decrement if at
least a full second has elapsed since then.

Reported by: Greg Foster <gfoster@panasas.com>
Reviewed by: gallatin
Tested by: Greg Foster <gfoster@panasas.com>
MFC after: 3 days
Sponsored by: Panasas
Differential Revision: https://reviews.freebsd.org/D35070

2 years agofirewire: Initialize firewire_devclass in fw_modevent.
John Baldwin [Wed, 27 Apr 2022 19:26:05 +0000 (12:26 -0700)]
firewire: Initialize firewire_devclass in fw_modevent.

The use of devclass_get_softc() combined with cdev unit numbers is
probably not ideal (probably should be initializing si_drv1 when each
cdev is created instead), but it looks like a bit of a PITA to do, so
just initialize the devclass explicitly instead.

Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D35060

2 years agosetkey(8): Clarify language around AEAD ciphers.
John Baldwin [Wed, 27 Apr 2022 19:18:52 +0000 (12:18 -0700)]
setkey(8): Clarify language around AEAD ciphers.

AEAD ciphers for IPsec combine both encryption and authentication.  As
such, ESP configurations using an AEAD cipher should not use a
seperate authentication algorithm via -A.  However, this was not
apparent from the setkey manpage and 12.x and earlier did not perform
sufficient argument validation permitting users to pair an explicit -A
such as SHA256-HMAC with AES-GCM.  (The result was a non-standard
combination of AES-CTR with the specified MAC, but with the wrong
initial block counter (and thus different keystream) compared to using
AES-CTR as the cipher.)

Attempt to clarify this in the manpage by explicitly calling out AEAD
ciphers (currently only AES-GCM) and noting that AEAD ciphers should
not use -A.

While here, explicitly note which authentication algorithms can be
used with esp vs esp-old.  Also add subsection headings for the
different algorithm lists and tidy some language.

I did not convert the tables to column lists (Bl -column) though that
would probably be more correct than using literal blocks (Bd
-literal).

PR: 263379
Reviewed by: Pau Amma <pauamma@gundo.com>, markj
Differential Revision: https://reviews.freebsd.org/D34947

2 years agoAdd a __witness_used for variables only used under #ifdef WITNESS.
John Baldwin [Wed, 27 Apr 2022 18:46:16 +0000 (11:46 -0700)]
Add a __witness_used for variables only used under #ifdef WITNESS.

__diagused is now solely used for variables only used under INVARIANTS.

Reviewed by: mjg
Differential Revision: https://reviews.freebsd.org/D35085

2 years agortw88: deal with debug messages
Bjoern A. Zeeb [Wed, 27 Apr 2022 15:20:34 +0000 (15:20 +0000)]
rtw88: deal with debug messages

The 'failed to write TX skb to HCI' error message is twice in the code.
Print the function name and along with the message and also the reported
error so it can possibly be helpful.

The 'failed to get tx report from firmware' was purposefully changed
away from debugging in the upstream Linux driver in
584dce175f0461d5d9d63952a1e7955678c91086 . Revert that decision and
extend the logging by the actual queue length so we get an idea how
sever the problem is (see PR for a report).

PR:  248235
Sponsored by: The FreeBSD Foundation
MFC after: 3 days
X-MFC: only to get the reminder for later

2 years agosctp: improve locking
Michael Tuexen [Wed, 27 Apr 2022 14:07:31 +0000 (16:07 +0200)]
sctp: improve locking

While there, do some cleanup.

Reported by: syzbot+f475e054c454310bc26d@syzkaller.appspotmail.com
MFC after: 3 day

2 years agolibcxxrt: Insert padding in __cxa_dependent_exception
Ed Maste [Wed, 27 Apr 2022 13:15:09 +0000 (09:15 -0400)]
libcxxrt: Insert padding in __cxa_dependent_exception

Padding was added to __cxa_exception in 45ca8b19 and
__cxa_dependent_exception needs the same layout.
Add some static_asserts to detect this in the future.

Merge of libcxxrt commit b00c6c564357

2 years agoPatch up __diagused for when only one of INVARIANTS or WITNESS is defined
Mateusz Guzik [Wed, 27 Apr 2022 13:29:12 +0000 (13:29 +0000)]
Patch up __diagused for when only one of INVARIANTS or WITNESS is defined

Reported by: John F Carr<jfc@mit.edu>

2 years agoExport _Unwind_Complete and _Unwind_VRS_Pop from arm's libgcc_s
Dimitry Andric [Wed, 27 Apr 2022 09:04:10 +0000 (11:04 +0200)]
Export _Unwind_Complete and _Unwind_VRS_Pop from arm's libgcc_s

Apparently some ports on arm require these symbols, and while they were
available in llvm's libunwind, they were never exported via the arm
specific Symbol.map. Put them in the same version block as gcc does
(GCC_3.5).

Reported by: Robert Clausecker <fuz_at_fuz.su>
MFC after: 3 days

2 years agorpc.tlsservd: Delete set but unused variable
Rick Macklem [Wed, 27 Apr 2022 02:29:01 +0000 (19:29 -0700)]
rpc.tlsservd: Delete set but unused variable

2 years agortsx: Number of tweaks for RTS5260.
Henri Hennebert [Wed, 27 Apr 2022 01:43:17 +0000 (21:43 -0400)]
rtsx: Number of tweaks for RTS5260.

MFC after: 2 weeks

2 years agorelease: fix on-disc pkg binary symbolic links
Glen Barber [Tue, 26 Apr 2022 19:52:40 +0000 (15:52 -0400)]
release: fix on-disc pkg binary symbolic links

PR: 263574
Reported by: loader
MFC after: immediately
Sponsored by: Rubicon Communications, LLC ("Netgate")

2 years agondaasync: sync to SCSI's daasyncs cam_periph_async() calls
Warner Losh [Tue, 26 Apr 2022 17:01:16 +0000 (11:01 -0600)]
ndaasync: sync to SCSI's daasyncs cam_periph_async() calls

Sponsored by: Netflix
Reviewed by: mav
Differential Revision: https://reviews.freebsd.org/D35059

2 years agoadaasync: Harmonize with daasync
Warner Losh [Tue, 26 Apr 2022 17:01:06 +0000 (11:01 -0600)]
adaasync: Harmonize with daasync

We should call cam_periph_async() always, like SCSI does. This routine
is supposed to be more of a catch-all.

cam_periph_async() only does actions for AC_LOST_DEVICE. It ignores all
other events (today), but this may not always be true. So this is a nop
change.

Drop in a 'break' so we don't fall through unnecessarily.

Sponsored by: Netflix
Reviewed by: mav
Differential Revision: https://reviews.freebsd.org/D35057

2 years agoRemove dead code.
Dmitry Chagin [Tue, 26 Apr 2022 16:40:59 +0000 (19:40 +0300)]
Remove dead code.

is_physical_memory() dead since 235a54de.

Reviewed by: markj
Differential revision: https://reviews.freebsd.org/D35056
MFC after: 2 weeks

2 years agolinux(4): Add epoll_pwai2 syscall.
Dmitry Chagin [Tue, 26 Apr 2022 16:35:59 +0000 (19:35 +0300)]
linux(4): Add epoll_pwai2 syscall.

MFC after: 2 weeks

2 years agolinux(4): Regen for epoll_pwait2 syscall.
Dmitry Chagin [Tue, 26 Apr 2022 16:35:58 +0000 (19:35 +0300)]
linux(4): Regen for epoll_pwait2 syscall.

2 years agolinux(4): Change epoll_pwait2 syscall definition to match Linux actual one.
Dmitry Chagin [Tue, 26 Apr 2022 16:35:57 +0000 (19:35 +0300)]
linux(4): Change epoll_pwait2 syscall definition to match Linux actual one.

MFC after: 2 weeks

2 years agolinux(4): Add copyin_sigset() helper.
Dmitry Chagin [Tue, 26 Apr 2022 16:35:57 +0000 (19:35 +0300)]
linux(4): Add copyin_sigset() helper.

MFC after: 2 weeks

2 years agolinux(4): Add linux_epoll_pwait_ts() helper for future use.
Dmitry Chagin [Tue, 26 Apr 2022 16:35:56 +0000 (19:35 +0300)]
linux(4): Add linux_epoll_pwait_ts() helper for future use.

MFC after: 2 weeks

2 years agolinux(4): Copyout pselect timeout.
Dmitry Chagin [Tue, 26 Apr 2022 16:35:56 +0000 (19:35 +0300)]
linux(4): Copyout pselect timeout.

According to pselect6 manual, on error timeout becomes undefined, by fact
Linux modifies the timeout and ignore EFAULT error if so.

MFC after: 2 weeks

2 years agolinux(4): Add a simple rseq syscall implementation.
Dmitry Chagin [Tue, 26 Apr 2022 16:35:56 +0000 (19:35 +0300)]
linux(4): Add a simple rseq syscall implementation.

To avoid annoyng messages from glibc-2.35 test suite add the simple
implementation of rseq syscall which is do nothing for now.

I plan to implement it if and when the API stabilizes.

MFC after: 2 weeks

2 years agolinux(4): Regen for rseq syscall.
Dmitry Chagin [Tue, 26 Apr 2022 16:35:55 +0000 (19:35 +0300)]
linux(4): Regen for rseq syscall.

2 years agolinux(4): Change rseq syscall definition to match Linux actual one.
Dmitry Chagin [Tue, 26 Apr 2022 16:35:54 +0000 (19:35 +0300)]
linux(4): Change rseq syscall definition to match Linux actual one.

MFC after: 2 weeks

2 years agovm_phys: avoid waste in multipage allocation
Doug Moore [Tue, 26 Apr 2022 07:56:23 +0000 (02:56 -0500)]
vm_phys: avoid waste in multipage allocation

In vm_phys_alloc_contig, for an allocation bigger than the size of any
buddy queue free block, avoid examining any maximum-size free block
more than twice, by only starting to consider a sequence of adjacent
max-blocks starting at a max-block that does not follow another
max-block.  If that first max-block follows adjacent blocks of smaller
size, and if together they provide enough memory to reduce by one the
number of max-blocks required for this allocation, use them as part of
this allocation.

Reviewed by: markj
Tested by: pho
Discussed with: alc
Differential Revision: https://reviews.freebsd.org/D34815

2 years agoxen: Use devclass_find to lookup devclasses in identify.
John Baldwin [Mon, 25 Apr 2022 18:55:30 +0000 (11:55 -0700)]
xen: Use devclass_find to lookup devclasses in identify.

While here, use driver->name instead of hardcoding the xenpv and
xen_et strings both for devclass_find() and BUS_ADD_CHILD().

Reviewed by: Elliott Mitchell <ehem+freebsd@m5p.com>, imp, royger
Differential Revision: https://reviews.freebsd.org/D35001

2 years agoada: Eliminate dead code
Warner Losh [Mon, 25 Apr 2022 18:54:37 +0000 (12:54 -0600)]
ada: Eliminate dead code

We never use the cgd that we get from the XPT_GDEV_TYPE call. Prior to
9a6844d55fe33 we used it to determine if READ AHEAD or WRITE CACHING was
supported. However, all that information was moved into adasetflags so
we no longer need to this since it's cached in the softc and updated
with the IDENTIFY data changes automatically.

Sponsored by: Netflix
Reviewed by: mav
Differential Revision: https://reviews.freebsd.org/D35039

2 years agocam: Small reorg of ata xpt async code
Warner Losh [Mon, 25 Apr 2022 18:54:26 +0000 (12:54 -0600)]
cam: Small reorg of ata xpt async code

Use a switch rather than a nested if to simplify the async event
processing code. No functional changes intended.

Sponsored by: Netflix
Reviewed by: mav
Differential Revision: https://reviews.freebsd.org/D35038

2 years agosched_getaffinity(3): more compatibility with Linux
Konstantin Belousov [Sun, 24 Apr 2022 22:10:18 +0000 (01:10 +0300)]
sched_getaffinity(3): more compatibility with Linux

Report EINVAL instead of EDEADLK when impossible cpu mask is set.

Noted by: dchagin
Reviewed by: dchagin (previous version), markj
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D35045

2 years agoASAN: reduce verbosity
Baptiste Daroussin [Mon, 25 Apr 2022 09:23:23 +0000 (11:23 +0200)]
ASAN: reduce verbosity

When running binaries compiled with libasan in PIE and with ALSR on,
the previous code always print the WARNING message, the new code only
printed it if the run is made with the right verbosity

Before this change, many unit test will always fail because of the extra
message which is printed

Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D35055
MFC after: 2 weeks

2 years agolinuxkpi: Mitigate a seqlock livelock
Mark Johnston [Mon, 25 Apr 2022 13:13:03 +0000 (09:13 -0400)]
linuxkpi: Mitigate a seqlock livelock

Disable preemption in seqlock write sections when using the _irqsave
variant.  This ensures that a writer can't be preempted and subsequently
starved by a reader running in a callout handler on the same CPU.

This fixes occasional display hangs seen when using the i915 driver.

Tested by: emaste, wulf
Reviewed by: wulf, hselasky
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D35021

2 years agoman3: Add links for some bitstring(3) routines
Mark Johnston [Mon, 25 Apr 2022 13:08:19 +0000 (09:08 -0400)]
man3: Add links for some bitstring(3) routines

MFC after: 1 week
Sponsored by: The FreeBSD Foundation

2 years agoFix build after 128b9bf9
Dmitry Chagin [Mon, 25 Apr 2022 11:45:05 +0000 (14:45 +0300)]
Fix build after 128b9bf9

MFC after: 2 weeks

2 years agoLinuxKPI: 802.11 ieee80211_sn_sub() fix
Bjoern A. Zeeb [Mon, 25 Apr 2022 11:35:57 +0000 (11:35 +0000)]
LinuxKPI: 802.11 ieee80211_sn_sub() fix

In ieee80211_sn_sub() we need to shift the mask before applying it.
This fixes the logic from 978f25e840fe4975f243e6077a764842f0e9d3eb.

Reported by: J.R. Oldroyd (fbsd opal.com)
MFC after: 3 days
Sponsored by: The FreeBSD Foundation

2 years agoAdd tests for sigwait family syscalls.
Dmitry Chagin [Mon, 25 Apr 2022 10:20:12 +0000 (13:20 +0300)]
Add tests for sigwait family syscalls.

MFC after: 2 weeks

2 years agosigtimedwait: Prevent timeout math overflows.
Dmitry Chagin [Mon, 25 Apr 2022 07:23:15 +0000 (10:23 +0300)]
sigtimedwait: Prevent timeout math overflows.

Our kern_sigtimedwait() calculates absolute sleep timo value as 'uptime+timeout'.
So, when the user specifies a big timeout value (LONG_MAX), the calculated
timo can be less the the current uptime value.
In that case kern_sigtimedwait() returns EAGAIN instead of EINTR, if
unblocked signal was caught.

While here switch to a high-precision sleep method.

Reviewed by: mav, kib
In collaboration with: mav
Differential revision: https://reviews.freebsd.org/D34981
MFC after: 2 weeks

2 years agolinux(4): Refactor signal send methods.
Dmitry Chagin [Mon, 25 Apr 2022 07:22:51 +0000 (10:22 +0300)]
linux(4): Refactor signal send methods.

Created a couple of helpers to send signals to the specific thread or to
the whole process. Use helpers in the corresponding syscalls.
This fixes the confusion where a signal destined for a whole process
was sent to a specific thread and vice versa.
There is an exclusion for the linux_kill() syscall that takes a pid
argument and should send a signal to the whole process, but I know
at least one example where kill() takes tid.

MFC after: 2 weeks

2 years agolinux(4): Check that the thread tid in the thread group pid in linux_tdfind().
Dmitry Chagin [Mon, 25 Apr 2022 07:21:51 +0000 (10:21 +0300)]
linux(4): Check that the thread tid in the thread group pid in linux_tdfind().

MFC after: 2 weeks

2 years agolinux(4): Microoptimize bsd_to_linux_sockaddr().
Dmitry Chagin [Mon, 25 Apr 2022 07:21:20 +0000 (10:21 +0300)]
linux(4): Microoptimize bsd_to_linux_sockaddr().

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

2 years agoAdd timespecvalid_interval macro and use it.
Dmitry Chagin [Mon, 25 Apr 2022 07:20:54 +0000 (10:20 +0300)]
Add timespecvalid_interval macro and use it.

Reviewed by: jhb, imp (early rev)
Differential revision: https://reviews.freebsd.org/D34848
MFC after: 2 weeks

2 years agoAdd a new RDC phy
Kevin Lo [Mon, 25 Apr 2022 02:00:58 +0000 (10:00 +0800)]
Add a new RDC phy
Reviewed by: jhb
Obtained from: NetBSD via Andrius V
Differential Revision: https://reviews.freebsd.org/D35034

2 years agoRestore original MDC speed control register value after MAC reset, if it
Kevin Lo [Mon, 25 Apr 2022 01:56:20 +0000 (09:56 +0800)]
Restore original MDC speed control register value after MAC reset, if it
wasn't default

Since vte_reset changes register value to MDCSC_DEFAULT value, which may not
be the original value, thus causing some phy registers read failures.
Restoring VTE_MDCSC value to original after reset solves the link state
flapping issue.

Thanks to jhb ("the code looks ok") for his review.
Reviewed by: jhb
Obtained from: NetBSD via Andrius V
Differential Revision: https://reviews.freebsd.org/D34956

2 years agoada/da: Borrow comment from nda about cleanup
Warner Losh [Sun, 24 Apr 2022 21:11:56 +0000 (15:11 -0600)]
ada/da: Borrow comment from nda about cleanup

Remove a XXX comment and replace it with a more accurate comment about
what happens to I/O queued to the hardware.

Sponsored by: Netflix

2 years agoata/nvme: Add comment
Warner Losh [Sun, 24 Apr 2022 21:11:52 +0000 (15:11 -0600)]
ata/nvme: Add comment

Steal the comment from daonninvalidate about the call to disk_gone().

Sponsored by: Netflix

2 years agog_vfs_done: Only report ENXIO once
Warner Losh [Sun, 24 Apr 2022 19:54:29 +0000 (13:54 -0600)]
g_vfs_done: Only report ENXIO once

The contract with the lower layers is that once ENXIO is reported, all
further I/O to the device is not possible. This is reported when the
device departs for good or changes in some material manner out from
underneath the system. Since the lower layers terminate all pending I/O
when this is detected with ENXIO, reporting more than one provides no
extra value. ENXIO suppression done with atomics due to race described
in e8827f4094cb. It's on the error path and a rare event, so this won't affect
performance.

Sponsored by: Netflix
Reviewed by: mckusick, kib
Differential Revision: https://reviews.freebsd.org/D35034

2 years agog_vfs_done: Report when we switch on ENXIO conversion
Warner Losh [Sun, 24 Apr 2022 19:54:20 +0000 (13:54 -0600)]
g_vfs_done: Report when we switch on ENXIO conversion

On the 0 -> 1 transition of sc_enxio_active, report that we're doing
this. This is a rare, but interesting, event. Convert to using atomics
to set this field to prevent a rare race:

    In CAM, when we invalidate a device, one thread (T1) will start the
    process in error processing called from *dadone
    (cam_periph_error). This routine will queue work to xpt_async_td
    (T2) and indicate to *dadone to call biodone(ENXIO) for the bio. T2
    wakes up and basically waits to acquire the periph lock. T2 will do
    so when T1 drops the periph lock just before T1's call to
    biodone. T2 acquires the lock and calls biodone(ENXIO) on all
    pending bios. These two threads will race and we could lose the
    printf or get two in rare cases. Since we only touch sc_enxio_active
    in an error path that's infrequent, the extra atomic traffic will be
    rare but will ensure robustness.

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

2 years agogeom_vfs: make sc_orphaned a bool
Warner Losh [Sun, 24 Apr 2022 19:54:15 +0000 (13:54 -0600)]
geom_vfs: make sc_orphaned a bool

Differential Revision: https://reviews.freebsd.org/D35036
Sponsored by: Netflix

2 years agobio: Add the speedup flags to PRINT_BIO_FLAGS
Warner Losh [Sun, 24 Apr 2022 19:54:10 +0000 (13:54 -0600)]
bio: Add the speedup flags to PRINT_BIO_FLAGS

The BIO_SPEEDUP_WRITE and BIO_SPEEDUP_TRIM bits are part of the flags
word, so print them as such.

Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D35035

2 years agovnode_pager_purge_range.9: "content" is an uncountable noun
Ka Ho Ng [Sun, 24 Apr 2022 16:57:16 +0000 (12:57 -0400)]
vnode_pager_purge_range.9: "content" is an uncountable noun

2 years agobase64: ignore -i as promised
Piotr Pawel Stefaniak [Thu, 21 Apr 2022 16:54:36 +0000 (18:54 +0200)]
base64: ignore -i as promised

2 years agoAdd a quoted-printable encoder/decoder
Piotr Pawel Stefaniak [Fri, 15 Apr 2022 13:25:30 +0000 (15:25 +0200)]
Add a quoted-printable encoder/decoder

As an example:
printf 'We don=27t know what to do with other=20worlds.=0D=0A' \
| bintrans qp -u

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

Reviewed by: debdrup (manpage)

2 years agobintrans: adjust mmencode.c to style(9)
Piotr Pawel Stefaniak [Fri, 15 Apr 2022 13:00:36 +0000 (15:00 +0200)]
bintrans: adjust mmencode.c to style(9)

2 years agobintrans: make mmencode.c compilable
Piotr Pawel Stefaniak [Fri, 15 Apr 2022 12:26:31 +0000 (14:26 +0200)]
bintrans: make mmencode.c compilable

Also remove MSDOS code, base64 code and commented out code.

2 years agobintrans: import mmencode.c for quoted-printable en/de-coding
Piotr Pawel Stefaniak [Fri, 15 Apr 2022 12:08:05 +0000 (14:08 +0200)]
bintrans: import mmencode.c for quoted-printable en/de-coding

This is a preliminary commit in preparation for exposing
a quoted-printable encoder and decoder through the new command bintrans.

2 years agonda: Fix comment
Warner Losh [Sat, 23 Apr 2022 23:08:39 +0000 (17:08 -0600)]
nda: Fix comment

Fix a comment that was left over from the orignial
implementation. Explain how pending transactions in hardware are
completed/aborted in the SIM prior to ndacleanup being called.

Sponsored by: Netflix

2 years agoCAM: Replicate e0ceec676dc8 from da to ada and nda.
Alexander Motin [Sun, 24 Apr 2022 00:14:10 +0000 (20:14 -0400)]
CAM: Replicate e0ceec676dc8 from da to ada and nda.

MFC after: 1 week

2 years agossh: use upstream SSH_OPENSSL_VERSION macro
Ed Maste [Sat, 23 Apr 2022 19:52:03 +0000 (15:52 -0400)]
ssh: use upstream SSH_OPENSSL_VERSION macro

With the upgrade to OpenSSH 6.7p1 in commit a0ee8cc636cd we replaced
WITH_OPENSSL ifdefs with an OPENSSL_VERSION macro, later changing it
to OPENSSL_VERSION_STRING.

A few years later OpenSSH made an equivalent change (with a different
macro name), in commit 4d94b031ff88.  Switch to the macro name they
chose.

MFC after: 1 week
Sponsored by: The FreeBSD Foundation

2 years agoUpdate dirdeps.mk
Simon J. Gerraty [Sat, 23 Apr 2022 21:44:17 +0000 (14:44 -0700)]
Update dirdeps.mk

Latest dirdeps.mk is far more efficient when generating
DIRDEPS_CACHE.

Update dirdeps-options.mk to allow DEP_RELDIR to factor
into option processing. This is not very interesting if all
options are global.

2 years agossh: drop $FreeBSD$ from crypto/openssh
Ed Maste [Fri, 22 Apr 2022 23:05:44 +0000 (19:05 -0400)]
ssh: drop $FreeBSD$ from crypto/openssh

After we moved to git $FreeBSD$ is no longer expanded and serves no
purpose.  Remove them from OpenSSH to reduce diffs against upstream.

Sponsored by: The FreeBSD Foundation

2 years agoKTLS: Add a new recrypt operation to the software backend.
John Baldwin [Fri, 22 Apr 2022 22:52:50 +0000 (15:52 -0700)]
KTLS: Add a new recrypt operation to the software backend.

When using NIC TLS RX, packets that are dropped and retransmitted are
not decrypted by the NIC but are passed along as-is.  As a result, a
received TLS record might contain a mix of encrypted and decrypted
data.  If this occurs, the already-decrypted data needs to be
re-encrypted so that the resulting record can then be decrypted
normally.

Add support for this for sessions using AES-GCM with TLS 1.2 or TLS
1.3.  For the recrypt operation, allocate a temporary buffer and
encrypt the the payload portion of the TLS record with AES-CTR with an
initial IV constructed from the AES-GCM nonce.  Then fixup the
original mbuf chain by copying the results from the temporary buffer
back into the original mbufs for any mbufs containing decrypted data.

Once it has been recrypted, the mbuf chain can then be decrypted via
the normal software decryption path.

Co-authored by: Hans Petter Selasky <hselasky@FreeBSD.org>
Reviewed by: hselasky
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D35012

2 years agoKTLS: Construct IV directly in crp.crp_iv for TLS 1.3 AEAD encryption.
John Baldwin [Fri, 22 Apr 2022 22:52:27 +0000 (15:52 -0700)]
KTLS: Construct IV directly in crp.crp_iv for TLS 1.3 AEAD encryption.

Previously this used a temporary nonce[] buffer.  The decrypt hook for
TLS 1.3 as well as the hooks for TLS 1.2 already constructed the IV
directly in crp.crp_iv.

Reviewed by: hselasky
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D35027

2 years agoKTLS: Move OCF function pointers out of ktls_session.
John Baldwin [Fri, 22 Apr 2022 22:52:12 +0000 (15:52 -0700)]
KTLS: Move OCF function pointers out of ktls_session.

Instead, create a switch structure private to ktls_ocf.c and store a
pointer to the switch in the ocf_session.  This will permit adding an
additional function pointer needed for NIC TLS RX without further
bloating ktls_session.

Reviewed by: hselasky
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D35011

2 years agoamd64 NOTES: Add entries for qlxgb, glxgbe, and glxge.
John Baldwin [Fri, 22 Apr 2022 22:18:06 +0000 (15:18 -0700)]
amd64 NOTES: Add entries for qlxgb, glxgbe, and glxge.

2 years agoamd64 NOTES: Sort the axp entry.
John Baldwin [Fri, 22 Apr 2022 22:18:06 +0000 (15:18 -0700)]
amd64 NOTES: Sort the axp entry.

2 years agoqlxgb/qlxgbe/qlxge: Fix build without INET and/or without INET6.
John Baldwin [Fri, 22 Apr 2022 22:18:05 +0000 (15:18 -0700)]
qlxgb/qlxgbe/qlxge: Fix build without INET and/or without INET6.

This is in preparation for adding these drivers to amd64 NOTES.

2 years agoiwm: plug set-but-not-used vars
Mateusz Guzik [Fri, 22 Apr 2022 22:16:25 +0000 (22:16 +0000)]
iwm: plug set-but-not-used vars

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

2 years agoMerge bmake-20220418
Simon J. Gerraty [Fri, 22 Apr 2022 20:40:29 +0000 (13:40 -0700)]
Merge bmake-20220418

        o ignore '.POSIX:' if not in first non-comment line
        of Makefile as specified by POSIX.
        add unit-tests for above.

Merge commit '92bfae0e6bd53a7a0d6fe55e70a916d86cf26e8b'

2 years agoAdd -m to post.sh
Simon J. Gerraty [Fri, 22 Apr 2022 20:38:42 +0000 (13:38 -0700)]
Add -m to post.sh

2 years agoImport bmake-20220418
Simon J. Gerraty [Fri, 22 Apr 2022 20:34:55 +0000 (13:34 -0700)]
Import bmake-20220418

Most relevant change:

o ignore '.POSIX:' if not in first non-comment line
of Makefile as specified by POSIX.
add unit-tests for above.

2 years agoBump __FreeBSD_version for udp_tun_func_t() prototype change
Kristof Provost [Fri, 22 Apr 2022 18:04:38 +0000 (20:04 +0200)]
Bump __FreeBSD_version for udp_tun_func_t() prototype change

742e7210d0 changed the prototype of udp_tun_func_t(). Bump
__FreeBSD_version so that external modules can #ifdef for it as
required.

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

2 years agopf: Add per-rule timestamps for rule and eth_rule
Reid Linnemann [Fri, 22 Apr 2022 11:54:51 +0000 (13:54 +0200)]
pf: Add per-rule timestamps for rule and eth_rule

Similar to ipfw rule timestamps, these timestamps internally are
uint32_t snaps of the system time in seconds. The timestamp is CPU local
and updated each time a rule or a state associated with a rule or state
is matched.

Reviewed by: kp
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D34970

2 years agolibexec/rc.d/hostapd: Down/up interface when interface is specified
Cy Schubert [Fri, 22 Apr 2022 16:03:08 +0000 (09:03 -0700)]
libexec/rc.d/hostapd: Down/up interface when interface is specified

When no interface is specified results in a syntax error in the rc
script. Only execute poststart when an interface has been specified.

PR: 263358
Submitted by: markj
Reported by: Joshua Kinard <freebsd@kumba.dev>
Fixes: 0da2c91e64528d896f69d36670e25b4b4a140579
MFC after: 3 days

2 years agoudp6: allow udp_tun_func_t() to indicate it did not eat the packet
Kristof Provost [Fri, 22 Apr 2022 14:11:31 +0000 (16:11 +0200)]
udp6: allow udp_tun_func_t() to indicate it did not eat the packet

Implement the same filter feature we implemented for UDP over IPv6 in
742e7210d. This was missed in that commit.

Pointed out by: markj
Sponsored by: Rubicon Communications, LLC ("Netgate")

2 years agopci: recognize "non-essential instrumentation" devices
John F. Carr [Fri, 22 Apr 2022 14:28:34 +0000 (16:28 +0200)]
pci: recognize "non-essential instrumentation" devices

Some AMD EPYC VCPUs generated boot message of the type:

     pci4: <unknown> at device 0.0 (no driver attached)

These are displayed for device class 0x13 devices, e.g.:

none8@pci0:130:0:0: class=0x130000 rev=0x00 hdr=0x00 vendor=0x1022 \
device=0x148a subvendor=0x1022 subdevice=0x148a
    vendor     = 'Advanced Micro Devices, Inc. [AMD]'
    device     = 'Starship/Matisse PCIe Dummy Function'
    class      = non-essential instrumentation

Since these devices serve no purpose (no driver attaches) I have
enabled the reporting of suich devices only for verbose boots (a
diversion from the patch provided in the PR).

A verbose boot will now display such devices as:

  pci4: <non-essential instrumentation> at device 0.0 (no driver attached)

PR: 263469
Reported by: jfc@mit.edu (John F. Carr)
MFC after: 1 week

2 years agofreebsd-update.8: Note availability of updates for ALPHA, BETA, and RC
Mateusz Piotrowski [Fri, 22 Apr 2022 12:28:04 +0000 (14:28 +0200)]
freebsd-update.8: Note availability of updates for ALPHA, BETA, and RC

While here, restructure the section about the binary updates
availability.

MFC after: 1 week

2 years agofreebsd-update.8: Add --currently-running to synopsis
Mateusz Piotrowski [Thu, 21 Apr 2022 14:31:51 +0000 (16:31 +0200)]
freebsd-update.8: Add --currently-running to synopsis

While here, sort flags in synopsis.

MFC after: 3 days

2 years agoAdd nullfs specific nocache option.
Alexander Leidinger [Fri, 22 Apr 2022 08:22:26 +0000 (10:22 +0200)]
Add nullfs specific nocache option.

2 years agonet80211: Fix traffic hang on STA/AP VAPs on a multi-VAP interface
Adrian Chadd [Tue, 12 Apr 2022 20:20:28 +0000 (13:20 -0700)]
net80211: Fix traffic hang on STA/AP VAPs on a multi-VAP interface

This took an embarrasingly long time to find.

The state changes for a radio with a STA /and/ AP VAP gets a bit messy.
The AP maps are marked as waiting, waiting for the STA AP to find a
channel to use before the AP VAPs become active.

However, the code path that clears the OACTIVE flag on a VAP only runs
during a successful run of ieee80211_newstate_cb().

So here is how it goes:

* the STA VAP goes down and needs to scan;
* the AP vap goes RUN->INIT; but it doesn't YET call ieee80211_newstate_cb();
* meanwhile - a send on the AP VAP causes the VAP to set the OACTIVE flag here;
* then the STA VAP finishes scan and goes to RUN;
* which will call wakeupwaiting() as part of the STA VAP transition to RUN;
* .. then the AP VAP goes INIT->RUN directly via a call to hostap_newstate
  in wakeupwaiting rather than it being through the deferred path;
* /then/ the ieee80211_newstate_cb() is called, but it sees the state go
  RUN->RUN;
* .. which results in the OACTIVE flag never being cleared.

This clears the OACTIVE flag when a VAP transitions RUN->RUN; the
driver layer or net80211 layer can set it if required in a subsequent
transmit.

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

Reviewed by: bz

2 years agostress2: Added a syzkaller reproducer
Peter Holm [Fri, 22 Apr 2022 04:20:14 +0000 (06:20 +0200)]
stress2: Added a syzkaller reproducer

2 years agopowerpc: add GENERIC64LE-NODEBUG config and improve GENERIC64-NODEBUG
Piotr Kubaj [Thu, 21 Apr 2022 23:04:36 +0000 (01:04 +0200)]
powerpc: add GENERIC64LE-NODEBUG config and improve GENERIC64-NODEBUG

Also remove whitespace from GENERIC-NODEBUG.

Approved by: jhibbits (src)
Differential review: https://reviews.freebsd.org/D34785

2 years agoqlxge: Inline the one use of a variable only used in a debug trace.
John Baldwin [Thu, 21 Apr 2022 21:01:02 +0000 (14:01 -0700)]
qlxge: Inline the one use of a variable only used in a debug trace.

The other QL_DPRINT*() invocations in qls_init_hw_if() all used the
expanded form instead of the local variable.  The module build always
defines QL_DBG in CFLAGS so doesn't trip over this, but adding qlxge
to a kernel config builds without QL_DBG.

Reported by: olivier

2 years agopsm: Swap the unit member in the softc for a device_t.
John Baldwin [Thu, 21 Apr 2022 20:52:48 +0000 (13:52 -0700)]
psm: Swap the unit member in the softc for a device_t.

This entails various changes to make this driver more "modern"
(new-bus vs pre-new-bus) using device_log() and device_printf() rather
than psm%d.  It also fixes the device_busy/unbusy calls to use sc->dev
directly rather than looking the device_t up via the devclass and
unit.

Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D35006

2 years agoKTLS: Free the MAC session when destroying AES-CBC software sessions.
John Baldwin [Thu, 21 Apr 2022 20:49:40 +0000 (13:49 -0700)]
KTLS: Free the MAC session when destroying AES-CBC software sessions.

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

2 years agostand: zfs: handle holes at the tail end correctly
Kyle Evans [Thu, 21 Apr 2022 19:57:24 +0000 (14:57 -0500)]
stand: zfs: handle holes at the tail end correctly

This mirrors dmu_read_impl(), zeroing out the tail end of the buffer and
clipping the read to what's contained by the block that exists.

This fixes an issue that arose during the 13.1 release process; in
13.1-RC1 and later, setting up GELI+ZFS will result in a failure to
boot.  The culprit is this, which causes us to fail to load geom_eli.ko
as there's a residual portion after the single datablk that should be
zeroed out.

PR: 263407
Reviewed by: tsoome
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D35019

2 years agobusdma_bounce: Batch bounce page free operations when possible.
John Baldwin [Thu, 21 Apr 2022 19:01:55 +0000 (12:01 -0700)]
busdma_bounce: Batch bounce page free operations when possible.

Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D34968