Commit graph

266440 commits

Author SHA1 Message Date
Marcin Wojtas
87ffe59470 Upgrade ENA to v2.4.0
ena: change ENA C++-style comment into C-style

According to man style(9), only C-style comments should be used.

Submitted by: Michal Krawczyk <mk@semihalf.com>
Obtained from: Semihalf
MFC after: 2 weeks
Sponsored by: Amazon, Inc.

(cherry picked from commit 438c9e3cf8)

ena: add support for the large LLQ headers in ENA

Default LLQ (Low-latency queue) maximum header size is 96 bytes and can
be too small for some types of packets - like IPv6 packets with multiple
extension. This can be fixed, by using large LLQ headers.

If the device supports larger LLQ headers, the user can activate this
feature by setting sysctl tunable 'hw.ena.force_large_llq_header' to '1'
in the /boot/loader.conf file.

In case the device isn't supporting this feature, the default value (96B)
will be used.

Submitted by: Michal Krawczyk <mk@semihalf.com>
Obtained from: Semihalf
MFC after: 2 weeks
Sponsored by: Amazon, Inc.

(cherry picked from commit beaadec9ea)

ena: remove surplus NULL checks when freeing ENA resources

Calling free on a NULL pointer is valid, as appropriate check is already
done internally:

/* free(NULL, ...) does nothing */
if (addr == NULL)
    return;

Submitted by: Artur Rojek <ar@semihalf.com>
Obtained from: Semihalf
MFC after: 2 weeks
Sponsored by: Amazon, Inc.

(cherry picked from commit ddec69e6a7)

ena: hide sysctl nodes for unused ENA queues

IO queue related attributes are registered statically at driver attach
with the rest of the ENA specific sysctl nodes. However, the number of
queues can be changed at runtime via the `ena_sysctl_io_queues_nb`
request, leading to a potential exposure of attributes for non-existing
queues.

Introduce a new `ena_sysctl_update_queue_node_nb` function, which
updates the sysctl nodes after the number of queues is altered.
This happens by either registering or unregistering node specific oids,
based on a delta between the previous and current queue count.

NOTE: All unregistered oids must be registered again before the driver
detach, e.g. by another call to this function.

Submitted by: Artur Rojek <ar@semihalf.com>
Obtained from: Semihalf
MFC after: 2 weeks
Sponsored by: Amazon, Inc.

(cherry picked from commit 0e7d31f63b)

Merge tag 'vendor/ena-com/2.4.0'

Update the driver in order not to break its compilation
and make use of the new ENA logging system

Migrate platform code to the new logging system provided by ena_com
layer.

Make ENA_INFO the new default log level.

Remove all explicit use of `device_printf`, all new logs requiring one
of the log macros to be used.

(cherry picked from commit 3fc5d816f8)

Update ENA driver man page

Bring the obsolete man page up to date:
* update diagnostic error messages
* add documentation of loader tunables
* document netmap support
* add a driver history section
* update the contact information

Submitted by: Artur Rojek <ar@semihalf.com>
Submitted by: Michal Krawczyk <mk@semihalf.com>
Obtained from: Semihalf
MFC after: 2 weeks
Sponsored by: Amazon, Inc.

(cherry picked from commit e34856a2c4)

Update ENA version to v2.4.0

Some of the changes in this release:
* Large LLQ headers,
* Bug/stability fixes,
* Change of the README/Documentation.

Submitted by: Michal Krawczyk <mk@semihalf.com>
Obtained from: Semihalf
MFC after: 2 weeks
Sponsored by: Amazon, Inc.

(cherry picked from commit 93f0df457b)
2021-10-07 18:10:21 +02:00
Marcin Wojtas
fb5eed2c43 mmc_fdt_helper: correct typo in DT property name
'no-1-8-v' is a proper name according to the DT binding
documentation
(https://www.kernel.org/doc/Documentation/devicetree/bindings/mmc/mmc-controller.yaml).

Fixes: e63fbd7bb7

Submitted by: Bartlomiej Grzesik <bag@semihalf.com>
Sponsored by: Semihalf

(cherry picked from commit d8789cd0ae)
2021-10-07 18:09:50 +02:00
Mateusz Guzik
6004dc8bc3 hpen(4): removed leftover hpen_final_digi_cb declaration
(cherry picked from commit 007724cbca)
2021-10-07 10:00:13 -04:00
Mark Johnston
160ed20e62 socket: Avoid clearing SS_ISCONNECTING if soconnect() fails
This behaviour appears to date from the 4.4 BSD import.  It has two
problems:

1. The update to so_state is not protected by the socket lock, so
   concurrent updates to so_state may be lost.
2. Suppose two threads race to call connect(2) on a socket, and one
   succeeds while the other fails.  Then the failing thread may
   incorrectly clear SS_ISCONNECTING, confusing the state machine.

Simply remove the update.  It does not appear to be necessary:
pru_connect implementations which call soisconnecting() only do so after
all failure modes have been handled.  For instance, tcp_connect() and
tcp6_connect() will never return an error after calling soisconnected().
However, we cannot correctly assert that SS_ISCONNECTED is not set after
an error from soconnect() since the socket lock is not held across the
pru_connect call, so a concurrent connect(2) may have set the flag.

Sponsored by:	The FreeBSD Foundation

(cherry picked from commit a8aa6f1f78)
2021-10-07 09:57:27 -04:00
Mark Johnston
f983298883 socket: Rename sb(un)lock() and interlock with listen(2)
In preparation for moving sockbuf locks into the containing socket,
provide alternative macros for the sockbuf I/O locks:
SOCK_IO_SEND_(UN)LOCK() and SOCK_IO_RECV_(UN)LOCK().  These operate on a
socket rather than a socket buffer.  Note that these locks are used only
to prevent concurrent readers and writters from interleaving I/O.

When locking for I/O, return an error if the socket is a listening
socket.  Currently the check is racy since the sockbuf sx locks are
destroyed during the transition to a listening socket, but that will no
longer be true after some follow-up changes.

Modify a few places to check for errors from
sblock()/SOCK_IO_(SEND|RECV)_LOCK() where they were not before.  In
particular, add checks to sendfile() and sorflush().

Reviewed by:	tuexen, gallatin
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit f94acf52a4)
2021-10-07 09:56:47 -04:00
Eugene Grosbein
7cf79c60fe syslogd: undo regression after r326573
Restore ability for our syslogd to collect pre-RFC3164 formatted
messages from remote hosts that was broken with r326573.

Note that parsing of RFC5424 format not changed.

(cherry picked from commit 3b4cc56e52)
2021-10-07 10:07:32 +07:00
Ian Lepore
b1cca74367 Fix busdma resource leak on usb device detach.
When a usb device is detached, usb_pc_dmamap_destroy() called
bus_dmamap_destroy() while the map was still loaded. That's harmless on x86
architectures, but on all other platforms it causes bus_dmamap_destroy() to
return EBUSY and leak away any memory resources (including bounce buffers)
associated with the mapping, as well as any allocated map structure itself.

This change introduces a new is_loaded flag to the usb_page_cache struct to
track whether a map is loaded or not. If the map is loaded,
bus_dmamap_unload() is called before bus_dmamap_destroy() to avoid leaking
away resources.

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

(cherry picked from commit dc91a9715f)
2021-10-06 09:36:02 -06:00
Kristof Provost
4747ec0839 pf tests: Basic adaptive mode syncookie test
MFC after:	1 week
Sponsored by:	Modirum MDPay
Differential Revision:	https://reviews.freebsd.org/D32139

(cherry picked from commit 2f20d80692)
2021-10-06 10:46:54 +02:00
Kristof Provost
767b29877e pf tests: Basic syncookie test
MFC after:	1 week
Sponsored by:	Modirum MDPay
Differential Revision:	https://reviews.freebsd.org/D32138

(cherry picked from commit dc0636636b)
2021-10-06 10:46:54 +02:00
Kristof Provost
45a2a438f1 pf.conf: document syncookies
Reviewed by:	bcr
Obtained from:	OpenBSD
MFC after:	1 week
Sponsored by:	Modirum MDPay
Differential Revision:	https://reviews.freebsd.org/D32137

(cherry picked from commit 20f015f08d)
2021-10-06 10:46:54 +02:00
Kristof Provost
c5a340e864 pfctl: userspace adaptive syncookies configration
Hook up the userspace bits to configure syncookies in adaptive mode.

MFC after:	1 week
Sponsored by:	Modirum MDPay
Differential Revision:	https://reviews.freebsd.org/D32136

(cherry picked from commit 5062afff9d)
2021-10-06 10:46:54 +02:00
Kristof Provost
66b6528015 pf: hook up adaptive mode configuration
The kernel side of pf syncookie adaptive mode configuration.

MFC after:	1 week
Sponsored by:	Modirum MDPay
Differential Revision:	https://reviews.freebsd.org/D32135

(cherry picked from commit 955460d41e)
2021-10-06 10:46:53 +02:00
Kristof Provost
dc23abfdea pf: implement adaptive mode
Use atomic counters to ensure that we correctly track the number of half
open states and syncookie responses in-flight.
This determines if we activate or deactivate syncookies in adaptive
mode.

MFC after:	1 week
Sponsored by:	Modirum MDPay
Differential Revision:	https://reviews.freebsd.org/D32134

(cherry picked from commit bf8637181a)
2021-10-06 10:46:53 +02:00
Kyle Evans
045612012e tcp_wrappers: get rid of duplicate fgets declarations
This is declared in stdio.h, no need for this one.

(cherry picked from commit 4dbd8c72d3)
2021-10-06 02:14:43 -05:00
Kyle Evans
a663c839ff libc: ssp: sprinkle around some __dead2
This is consistent with, e.g., NetBSD's implementation, which declares
these as noreturn in ssp/ssp.h.

(cherry picked from commit 5487294d79)
2021-10-06 02:14:42 -05:00
Kyle Evans
d330c24cc0 bootp: remove the USE_BFUNCS knob
We'd likely be better served by converting these to the equivalent mem*
calls, but just kill the knob for now. The b* macros being defined get
in the way of _FORTIFY_SOURCE.

(cherry picked from commit cfb9be5062)
2021-10-06 02:14:39 -05:00
Kyle Evans
188c088fe3 jail(3lua): add jail.attach()/jail.remove() methods
These aren't a part of or use libjail(3), but rather are direct
syscalls.  Still, they seem like good additions, allowing us to attach
to already-running jails.

(cherry picked from commit a6499c56ab)
2021-10-06 02:13:27 -05:00
Kyle Evans
44175ec8ce jail(3lua): add a jail.list() method
This is implemented as an iterator, reusing parts of the earlier logic
to populate jailparams from a passed in table.

The user may request any number of parameters to pull in while we're
searching, but we'll force jid and name to appear at a minimum.

(cherry picked from commit 6a7647eccd)
2021-10-06 02:13:23 -05:00
Kyle Evans
bd4ee4ead1 modules: iichid: needs opt_acpi.h
This fixes the standalone build.

(cherry picked from commit 335c4f8edb)
2021-10-06 02:10:54 -05:00
Kyle Evans
38e0682c8c modules: netflow: need opt_inet.h
This fixes the standalone build.

(cherry picked from commit 6caae81d93)
2021-10-06 02:10:20 -05:00
Kyle Evans
7610a6b150 modules: acpi_video: need opt_evdev.h
This fixes the standalone build.

(cherry picked from commit 58ca99d116)
2021-10-06 02:09:58 -05:00
Kyle Evans
b7e90b290a kqueue: document how timers with low/past timeouts are handled
(cherry picked from commit 4b5554cebb)
2021-10-06 02:04:00 -05:00
Kyle Evans
121740e185 kqueue: don't arbitrarily restrict long-past values for NOTE_ABSTIME
NOTE_ABSTIME values are converted to values relative to boottime in
filt_timervalidate(), and negative values are currently rejected.  We
don't reject times in the past in general, so clamp this up to 0 as
needed such that the timer fires immediately rather than imposing what
looks like an arbitrary restriction.

Another possible scenario is that the system clock had to be adjusted
by ~minutes or ~hours and we have less than that in terms of uptime,
making a reasonable short-timeout suddenly invalid. Firing it is still
a valid choice in this scenario so that applications can at least
expect a consistent behavior.

(cherry picked from commit 9c999a259f)
(cherry picked from commit 2f4dbe279f)
2021-10-06 02:03:53 -05:00
Kyle Evans
06248c8215 kern: random: collect ~16x less from fast-entropy sources
Previously, we were collecting at a base rate of:

64 bits x 32 pools x 10 Hz = 2.5 kB/s

This change drops it to closer to 64-ish bits per pool per second, to
work a little better with entropy providers in virtualized environments
without compromising the security goals of Fortuna.

(cherry picked from commit 5e79bba562)
2021-10-06 01:44:07 -05:00
Kyle Evans
40f9f2279c kern: random: drop read_rate and associated functionality
Refer to discussion in PR 230808 for a less incomplete discussion, but
the gist of this change is that we currently collect orders of magnitude
more entropy than we need.

The excess comes from bytes being read out of /dev/*random.  The default
rate at which we collect entropy without the read_rate increase is
already more than we need to recover from a compromise of an internal
state.

For stable/13, the read_rate_increment symbol remains as a stub to avoid
breaking loadable random modules.

(cherry picked from commit 6895cade94)
2021-10-06 01:41:18 -05:00
Gordon Bergling
3637d2a183 cam: Fix a typo in a comment
- s/perorming/performing/

(cherry picked from commit 15c5f657a0)
2021-10-06 08:21:29 +02:00
Gordon Bergling
7172006900 smsc(4): Fix a typo in a comment
- s/setings/settings/

(cherry picked from commit 9599d8141f)
2021-10-06 08:21:05 +02:00
Gordon Bergling
d00fdb9736 vnic: Fix a typo in a comment
- s/setings/settings/

(cherry picked from commit fafb1c574d)
2021-10-06 08:20:41 +02:00
Gordon Bergling
d58ccf3ba4 evdev: Fix a typo in a commit
- s/prefered/preferred/

(cherry picked from commit efd8749fe5)
2021-10-06 08:20:20 +02:00
Gordon Bergling
badbe6a4a8 netvsc: Fix a typo in a comment
- s/prefered/preferred/

(cherry picked from commit 9ebd651b58)
2021-10-06 08:19:58 +02:00
Cy Schubert
0ab6ecd1dd wpa: Fix EAP/PEAP MSCHAPv2 authentication SIGSEGV
25ecdc7d52 (MFCed by
13f32ff71e) introduced a link error
causing a SIGSEGV when using EAP/PEAP MSCHAPv2 authentication. It was
subsequently addressed by c1d255d3ff,
discovered by build time link errors not experienced during testing of
25ecdc7d52. This commit MFCs a portion
of c1d255d3ff addressing only the
SIGSEGV. The rest of c1d255d3ff will
be MFCed in November 2021.

This is a direct commit to stable/13.

PR:		258527
Reported by:	Marek Zarychta <zarychtam@plan-b.pwste.edu.pl>
Tested by:	Marek Zarychta <zarychtam@plan-b.pwste.edu.pl>
2021-10-05 15:12:38 -07:00
Ed Maste
9130e0ace0 mgb: sync with version in main
This is a combination of 7 commits.

mgb: update Microchip URLs

Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 6b25b4a73f)

mgb: enable multicast in mgb_init

Receive Filtering Engine (RFE) configuration is not yet implemented,
and mgb intended to enable all broadcast, multicast, and unicast.
However, MGB_RFE_ALLOW_MULTICAST was missed (MGB_RFE_ALLOW_UNICAST was
included twice).

MFC after:	1 week
Fixes:		8890ab7758 ("Introduce if_mgb driver...")
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit ecac5c2928)

mgb: Do not KASSERT on error in mgb_init

There's not much we can do if mii_mediachg() fails, but KASSERT is not
appropriate.

MFC after:	1 week
Fixes:		8890ab7758 ("Introduce if_mgb driver...")
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 8b889b8953)

mgb: Staticize devclass and iflib structs (as is typical)

MFC after:	1 week
Fixes:		8890ab7758 ("Introduce if_mgb driver...")
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit c83ae596f3)

mgb: Apply some style(9)

Add parens around return values, rewrap lines

MFC after:	1 week
Fixes:		8890ab7758 ("Introduce if_mgb driver...")
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 820da5820e)

mgb: Fix DEBUG (and LINT) build

Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 5f07d7fe40)

mgb: Fix nop admin interrupt handling

Previously mgb_admin_intr printed a diagnostic message if no interrupt
status bits were set, but it's not valid to call device_printf() from a
filter.  Just drop the message as it has no user-facing value.

Also return FILTER_STRAY in this case - there is nothing further for
the driver to do.

Reviewed by:	kbowling
MFC after:	1 week
Fixes:		8890ab7758 ("Introduce if_mgb driver...")
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D32231

(cherry picked from commit 1ad2d87778)
2021-10-05 14:57:21 -04:00
Alexander Motin
b3fb4c60c5 sched_ule(4): Fix interactive threads stealing.
In scenarios when first thread in the queue can migrate to specified
CPU, but later ones can't runq_steal_from() incorrectly returned NULL.

MFC after:	2 weeks

(cherry picked from commit bd84094a51)
2021-10-04 22:28:33 -04:00
Mitchell Horne
68628f4620 boot(9): update to match reality
This function was renamed to kern_reboot() in 2010, but the man page has
failed to keep in sync. Bring it up to date on the rename, add the
shutdown hooks to the synopsis, and document the (obvious) fact that
kern_reboot() does not return.

Fix an outdated reference to the old name in kern_reboot(), and leave a
reference to the man page so future readers might find it before any
large changes.

Reviewed by:	imp, markj
MFC after:	3 days
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D32085

(cherry picked from commit 800e74955d)
2021-10-04 11:11:06 -03:00
Elliott Mitchell
8e43767b31 rman: fix overflow in rman_reserve_resource_bound()
If the default range of [0, ~0] is given, then (~0 - 0) + 1 == 0. This
in turn will cause any allocation of non-zero size to fail. Zero-sized
allocations are prohibited, so add a KASSERT to this effect.

History indicates it is part of the original rman code.  This bug may in
fact be older than some contributors.

Reviewed by:	mhorne
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D30280

(cherry picked from commit bcddaadbef)
2021-10-04 11:11:06 -03:00
David Bright
52e1406947 ntb_hw_intel: fix xeon NTB gen3 bar disable logic
In NTB gen3 driver, it was supposed to disable NTB bar access by
default, but due to incorrect register access method, the bar disable
logic does not work as expected. Those registers should be modified
through NTB bar0 rather than PCI configuration space.

Besides, we'd better to protect ourselves from a bad buddy node so
ingress disable logic should be implemented together.

Submitted by:   Austin Zhang (austin.zhang@dell.com)
Sponsored by:   Dell EMC

(cherry picked from commit e3cf7ebc1d)
2021-10-04 06:53:26 -07:00
Marcin Wojtas
c0b0325109 Disable stack gap for ntpd during build.
When starting, ntpd calls setrlimit(2) to limit maximum size of its
stack. The stack limit chosen by ntpd is 200K, so when stack gap
is enabled, the stack gap is larger than this limit, which results
in ntpd crashing.

Submitted by: Dawid Gorecki <dgr@semihalf.com>
Reviewed by: cy, imp
Obtained from: Semihalf
Sponsored by: Stormshield
Differential Revision: https://reviews.freebsd.org/D29553

(cherry picked from commit af949c590b)
2021-10-04 06:12:03 -07:00
Cy Schubert
e81cf0e1bb ipfilter: Print the correct TCP sequence index number
TCP sequence numbers in the FTP proxy are maintained in a two dimensional
array. The debug message prints the same seq[N] for both. Fix that.

(cherry picked from commit df38343e71)
2021-10-03 20:56:58 -07:00
Cy Schubert
889c5c50d8 ipfilter: Correct a comment
Correct a comment's grammar and while at it clarify its meaining.

(cherry picked from commit aa6cfcc820)
2021-10-03 20:56:58 -07:00
Cy Schubert
2fc27a1ceb ipfilter: Locking sysctls here is not required
Locking of data structures touched by sysctls is more finely locked
in ipflter therefore higher level locks are redundant.

(cherry picked from commit 1605eaa6d2)
2021-10-03 20:56:58 -07:00
Cy Schubert
ffcdbc35a6 ipfilter: Avoid a null if-then-else blocks
When WITHOUT_INET6 is selected we generate a null if-then-else blocks
due to incorrect placment of #if statments. Move the #if statements
reducing unnecessary runtime comparisons WITHOUT_INET6.

(cherry picked from commit 73db3b64f1)
2021-10-03 20:56:58 -07:00
Greg V
c39bfe4713 vt: call driver's postswitch when panicking on ttyv0
In vt_kms, the postswitch callback restores fbdev mode when
panicking or entering the debugger. This ensures that even when
a graphical applicatino was running on the first tty, simple framebuffer
mode would be restored and the panic would be visible instead
of the frozen GUI. But vt wouldn't call the postswitch callback
when we're already on the first tty, so running a GUI on it
would prevent you from reading any panics.

Reviewed by:	tsoome
Differential Revision: https://reviews.freebsd.org/D29961

(cherry picked from commit c937a405bd)
2021-10-04 00:46:49 +03:00
Alexander Motin
e6e348e49c Unify console output.
Without this change when virtual console enabled depending on buffer
presence and state different parts of output go to different consoles.

MFC after:	1 month

(cherry picked from commit a264594d4f)
2021-10-03 21:15:03 -04:00
Alexander Motin
c15b8196ba Re-implement virtual console (constty).
Protect conscallout with tty lock instead of Giant.  In addition to
Giant removal it also closes race on console unset.

Introduce additional lock to protect against concurrent console sets.

Remove consbuf free on console unset as unsafe, making impossible to
change buffer size after first allocation.  Instead increase default
buffer size from 8KB to 64KB and processing rate from 5Hz to 10-15Hz
to make the output more smooth.

MFC after:	1 month

(cherry picked from commit bd6085c6ae)
2021-10-03 21:15:02 -04:00
Alexander Motin
b7fde5e82b ioat(4): Remove Giant from ioat_test enable/disable.
MFC after:	1 month

(cherry picked from commit 71bf3900b7)
2021-10-03 21:14:25 -04:00
Alexander Motin
36e67f5bad pcib(4): Switch from callout to timeout_task.
This allows to avoid blocking on Giant in callout context, moving to
already existing dedicated taskqueue_pci_hp thread.

MFC after:	1 month

(cherry picked from commit fa3b03d378)
2021-10-03 21:13:24 -04:00
Alexander Motin
03d748e924 vt(4): Mark callouts MP-safe.
The code explicitly takes Giant when it accesses keyboard, and I see
no reason to take it globally by callout(9).

MFC after:	1 month

(cherry picked from commit da69c67526)
2021-10-03 21:11:59 -04:00
Alexander Motin
50570c6479 bnxt(4): Mark sysctls MP-safe.
MFC after:	1 month

(cherry picked from commit 9895a2073f)
2021-10-03 21:10:43 -04:00
Alexander Motin
d2f4b7bc1c bxe(4): Mark sysctls and callout MP-safe.
MFC after:	1 month

(cherry picked from commit 4081c895e5)
2021-10-03 21:10:02 -04:00
Alexander Motin
fe830ad79a mge(4): Mark sysctls and callout MP-safe.
MFC after:	1 month

(cherry picked from commit 6b2ff27cb9)
2021-10-03 21:09:24 -04:00