Commit Graph

142791 Commits

Author SHA1 Message Date
Konstantin Belousov
e4ce431e2a 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
2022-04-28 02:27:34 +03:00
Konstantin Belousov
b9294a3e15 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
2022-04-28 02:27:34 +03:00
Konstantin Belousov
e59b940dcb 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
2022-04-28 02:27:34 +03:00
Konstantin Belousov
c4be460e84 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
2022-04-28 02:27:34 +03:00
John Baldwin
e4a38f5407 powerpc pseries xics: Use devclass_find to lookup xicp devclass.
Reviewed by:	jhibbits
Differential Revision:	https://reviews.freebsd.org/D35083
2022-04-27 15:08:47 -07:00
Justin Hibbits
e089492574 gpio/qoriq: Recognize another compatible string entry 2022-04-27 17:00:49 -05:00
Justin Hibbits
de6353ad8f 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.
2022-04-27 17:00:32 -05:00
Greg Foster
00a80538b4 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
2022-04-27 12:41:30 -07:00
John Baldwin
fa160738bd 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
2022-04-27 12:26:05 -07:00
John Baldwin
1431239494 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
2022-04-27 11:46:16 -07:00
Bjoern A. Zeeb
e140d551b7 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
2022-04-27 15:20:34 +00:00
Michael Tuexen
490a0f77de sctp: improve locking
While there, do some cleanup.

Reported by:	syzbot+f475e054c454310bc26d@syzkaller.appspotmail.com
MFC after:	3 day
2022-04-27 16:07:31 +02:00
Mateusz Guzik
b40c0db6f6 Patch up __diagused for when only one of INVARIANTS or WITNESS is defined
Reported by:	John F Carr<jfc@mit.edu>
2022-04-27 13:29:12 +00:00
Henri Hennebert
8290c14420 rtsx: Number of tweaks for RTS5260.
MFC after:	2 weeks
2022-04-26 21:43:17 -04:00
Warner Losh
e4b1ae2147 ndaasync: sync to SCSI's daasyncs cam_periph_async() calls
Sponsored by:		Netflix
Reviewed by:		mav
Differential Revision:	https://reviews.freebsd.org/D35059
2022-04-26 11:01:39 -06:00
Warner Losh
ae1955cd67 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
2022-04-26 11:01:39 -06:00
Dmitry Chagin
fe2c9f83a6 Remove dead code.
is_physical_memory() dead since 235a54de.

Reviewed by:		markj
Differential revision:	https://reviews.freebsd.org/D35056
MFC after:		2 weeks
2022-04-26 19:40:59 +03:00
Dmitry Chagin
e00aad1042 linux(4): Add epoll_pwai2 syscall.
MFC after:	2 weeks
2022-04-26 19:35:59 +03:00
Dmitry Chagin
df377f1fb8 linux(4): Regen for epoll_pwait2 syscall. 2022-04-26 19:35:58 +03:00
Dmitry Chagin
81b0b7dc0c linux(4): Change epoll_pwait2 syscall definition to match Linux actual one.
MFC after:	2 weeks
2022-04-26 19:35:57 +03:00
Dmitry Chagin
3923e63209 linux(4): Add copyin_sigset() helper.
MFC after:	2 weeks
2022-04-26 19:35:57 +03:00
Dmitry Chagin
27a25179c8 linux(4): Add linux_epoll_pwait_ts() helper for future use.
MFC after:	2 weeks
2022-04-26 19:35:56 +03:00
Dmitry Chagin
5171ed79f6 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
2022-04-26 19:35:56 +03:00
Dmitry Chagin
ee55d560e8 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
2022-04-26 19:35:56 +03:00
Dmitry Chagin
75e409495f linux(4): Regen for rseq syscall. 2022-04-26 19:35:55 +03:00
Dmitry Chagin
f202f35db0 linux(4): Change rseq syscall definition to match Linux actual one.
MFC after:	2 weeks
2022-04-26 19:35:54 +03:00
Doug Moore
fa8a6585c7 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
2022-04-26 02:56:23 -05:00
John Baldwin
651a887f4e 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
2022-04-25 11:55:30 -07:00
Warner Losh
ccaec73d0b ada: Eliminate dead code
We never use the cgd that we get from the XPT_GDEV_TYPE call. Prior to
9a6844d55f 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
2022-04-25 12:55:04 -06:00
Warner Losh
9d899bbcb7 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
2022-04-25 12:55:04 -06:00
Mark Johnston
efb8f0b8db 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
2022-04-25 09:13:03 -04:00
Bjoern A. Zeeb
b3e7f403a5 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 978f25e840.

Reported by:	J.R. Oldroyd (fbsd opal.com)
MFC after:	3 days
Sponsored by:	The FreeBSD Foundation
2022-04-25 11:35:57 +00:00
Dmitry Chagin
4a700f3c32 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
2022-04-25 10:23:15 +03:00
Dmitry Chagin
6201a50d0d 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
2022-04-25 10:22:51 +03:00
Dmitry Chagin
fe894a3705 linux(4): Check that the thread tid in the thread group pid in linux_tdfind().
MFC after:		2 weeks
2022-04-25 10:21:51 +03:00
Dmitry Chagin
bbddd5881d linux(4): Microoptimize bsd_to_linux_sockaddr().
Differential Revision:	https://reviews.freebsd.org/D34725
MFC after:		2 weeks
2022-04-25 10:21:20 +03:00
Dmitry Chagin
91e7bdcdcf Add timespecvalid_interval macro and use it.
Reviewed by:		jhb, imp (early rev)
Differential revision:	https://reviews.freebsd.org/D34848
MFC after:		2 weeks
2022-04-25 10:20:54 +03:00
Kevin Lo
5586515ab1 Add a new RDC phy
Reviewed by:	jhb
Obtained from:	NetBSD via Andrius V
Differential Revision:	https://reviews.freebsd.org/D35034
2022-04-25 10:00:58 +08:00
Kevin Lo
8f216d282c 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
2022-04-25 09:56:20 +08:00
Warner Losh
b43cfe7171 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
2022-04-24 15:11:56 -06:00
Warner Losh
48ae3f4f64 ata/nvme: Add comment
Steal the comment from daonninvalidate about the call to disk_gone().

Sponsored by:		Netflix
2022-04-24 15:11:52 -06:00
Warner Losh
347a8e93fe 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 e8827f4094. 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
2022-04-24 14:01:33 -06:00
Warner Losh
e8827f4094 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
2022-04-24 14:01:08 -06:00
Warner Losh
f58385f3da geom_vfs: make sc_orphaned a bool
Differential Revision:	https://reviews.freebsd.org/D35036
Sponsored by:		Netflix
2022-04-24 14:01:08 -06:00
Warner Losh
965e919506 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
2022-04-24 14:01:08 -06:00
Warner Losh
c08ceddbf7 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
2022-04-23 20:31:46 -06:00
Alexander Motin
38f8addaab CAM: Replicate e0ceec676d from da to ada and nda.
MFC after:	1 week
2022-04-23 20:15:17 -04:00
John Baldwin
a8280123e4 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
2022-04-22 15:52:50 -07:00
John Baldwin
663ae8f7f9 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
2022-04-22 15:52:27 -07:00
John Baldwin
a4c5d490f6 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
2022-04-22 15:52:12 -07:00