Commit graph

141594 commits

Author SHA1 Message Date
John Baldwin
dfbbcea39b wg: Trim compat shims for versions older than current stable/13.
Reviewed by:	kevans, markj, emaste
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D36913

(cherry picked from commit 854d066251)
2022-11-11 13:50:09 -08:00
John Baldwin
fa7b4b9294 wg: Retire now unused support.h.
Reviewed by:	kevans, markj, emaste
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D36912

(cherry picked from commit c640d1af2c)
2022-11-11 13:49:57 -08:00
John Baldwin
4c6b5076b7 wg: Use zfree.
Reviewed by:	kevans, markj, emaste
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D36911

(cherry picked from commit dcf581bb49)
2022-11-11 13:49:44 -08:00
John Baldwin
0d10367122 wg: Use atomic(9) instead of concurrency-kit atomics.
Kernel sanitizers only support atomic(9) operations.

Reviewed by:	kevans, markj, emaste
Reported by:	markj
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D36910

(cherry picked from commit e32e1a160e)
2022-11-11 13:48:50 -08:00
John Baldwin
5ae69e2f10 Import the WireGuard driver from zx2c4.com.
This commit brings back the driver from FreeBSD commit
f187d6dfbf plus subsequent fixes from
upstream.

Relative to upstream this commit includes a few other small fixes such
as additional INET and INET6 #ifdef's, #include cleanups, and updates
for recent API changes in main.

Reviewed by:	pauamma, gbe, kevans, emaste
Obtained from:	git@git.zx2c4.com:wireguard-freebsd @ 3cc22b2
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D36909

(cherry picked from commit 744bfb2131)
2022-11-11 13:44:11 -08:00
John Baldwin
587ab8e019 msk: Use a void cast to mark values of dummy reads as unused.
Note that this required adding missing ()'s around the outermost level
of MSK_READ_MIB*.  Otherwise, the void cast was only applied to the
first register read.  This also meant that MSK_READ_MIB64 was pretty
broken as the uint64_t cast only applied to the first 16-bit register
read in each MSK_READ_MIB32 invocation and the 32-bit shift was only
applied to the second register read of the pair.

Reviewed by:	imp, emaste
Reported by:	GCC -Wunused-value
Differential Revision:	https://reviews.freebsd.org/D36777

(cherry picked from commit ae70e8838c)
2022-11-11 10:18:54 -08:00
John Baldwin
d77e67e9d5 msk: Don't bother reading spare stats registers.
msk_stats_update reads stats registers named "spare" whose values are
discarded.

Reviewed by:	imp, emaste
Differential Revision:	https://reviews.freebsd.org/D36871

(cherry picked from commit aabbe26939)
2022-11-11 10:18:54 -08:00
Warner Losh
2498e94fb6 msk: Remove write only variables, but leave hardware reads in place
Sponsored by:		Netflix

(cherry picked from commit 7e5c042cce)
2022-11-11 10:18:54 -08:00
John Baldwin
44c1914ee6 powerpc_nvram: Fix a bug in the adler32 checksum.
The Adler32 digest consists of two 16-bit words whose values are
calculated modulo 65521 (largest prime < 2^16).  To avoid two division
instructions per byte, this version copies an optimization found in
zlib which defers the modulus until close to the point that the
intermediate sums can overflow 2^32.  (zlib uses NMAX == 5552 for
this, this version uses 5000)

The bug is that in the deferred modulus case, the modulus was
only applied to the high word (and twice at that) but not to
the low word.  The fix is to apply it to both words.

Reviewed by:	jhibbits
Reported by:	Miod Vallat <miod@openbsd.org>
Differential Revision:	https://reviews.freebsd.org/D36798

(cherry picked from commit e0df0dce71)
2022-11-11 10:18:53 -08:00
John Baldwin
32560694f7 Fix various places which cast a pointer to a vm_paddr_t or vice versa.
GCC warns about the mismatched sizes on i386 where vm_paddr_t is 64
bits.

Reviewed by:	imp, markj
Differential Revision:	https://reviews.freebsd.org/D36750

(cherry picked from commit a9fca3b987)
2022-11-11 10:18:53 -08:00
John Baldwin
20125b23ff linux32: binutils as requires %eflags instead of %flags for CFI.
Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D36781

(cherry picked from commit a35572b16e)
2022-11-11 10:18:53 -08:00
John Baldwin
2b4453ad8f zlib crc32: Add prototypes for recently-added static functions.
This appeases -Wstrict-prototypes with GCC.  Using a separate
prototype using the OF macro seems to be consistent with the rest of
this file which still supports pre-ANSI C.

Reviewed by:	imp, emaste
Differential Revision:	https://reviews.freebsd.org/D36755

(cherry picked from commit 7550e242ab)
2022-11-11 10:18:52 -08:00
John Baldwin
3e9a8070f7 ipfilter: Cast uintmax_t values to size_t when adding to a pointer.
GCC warns about the mismatched sizes on 32-bit platforms where
uintmax_t is larger in size than a pointer.

Reviewed by:	imp, cy
Differential Revision:	https://reviews.freebsd.org/D36753

(cherry picked from commit 9c4f7e8234)
2022-11-11 10:18:52 -08:00
John Baldwin
54c65cbb24 ntb: Use uintmax_t casts and %j to print physical addresses.
This fixes -Wint-to-pointer-cast errors with GCC when compiling on
i386 where physical addresses are not the same size as pointers.

Reviewed by:	mav, imp
Differential Revision:	https://reviews.freebsd.org/D36751

(cherry picked from commit 124e46735e)
2022-11-11 10:18:52 -08:00
Gordon Bergling
360741a638 tcp_bbr(4): Fix a typo in a source code comment
- s/retranmitted/retransmitted/

(cherry picked from commit bcf8fb7f03)
2022-11-11 05:34:33 +01:00
Gordon Bergling
3e46bd0672 nfs: Fix common typos in source code comments
- s/attrbute/attribute/

(cherry picked from commit bf31248287)
2022-11-11 05:33:57 +01:00
Vitaliy Gusev
19b7a0cf41 vmm: Cherry pick illumos commit '13361 bhyve should mask RDT cpuid info'
Summary:
    commit  1a5f1879be09d3de900b2510692dd12003784d84
    Author: Patrick Mooney <pmooney@pfmooney.com>
    Date:   2020-12-16T20:02:23.000Z

        13361 bhyve should mask RDT cpuid info
        Reviewed by: Andy Fiddaman <andy@omnios.org>
        Reviewed by: Toomas Soome <tsoome@me.com>
        Approved by: Robert Mustacchi <rm@fingolfin.org>

    https://github.com/illumos/illumos-gate/commit/1a5f1879be09d3de900b2510692dd12003784d8

----

We saw similar warning of GP (on Intel Xeon CPU E5-2630 v4 and VM with Ubuntu 20.04 5.4.0-113-generic)  until this commit is applied:

```
[    1.658880] kernel: unchecked MSR access error: WRMSR to 0xc8f (tried to write 0x0000000000000000) at rIP: 0xffffffffacc735b4 (native_write_msr+0x4/0x30)
[    1.662734] kernel: Call Trace:
[    1.663885] kernel:  ? clear_closid_rmid.isra.0+0x36/0x40
[    1.665501] kernel:  resctrl_online_cpu+0xdc/0x3f0
[    1.666952] kernel:  ? __switch_to_asm+0x40/0x70
[    1.668358] kernel:  ? __switch_to+0x7f/0x480
[    1.669693] kernel:  ? cat_wrmsr+0x70/0x70
[    1.670970] kernel:  cpuhp_invoke_callback+0x9b/0x580
[    1.672541] kernel:  ? __schedule+0x2eb/0x740
[    1.673893] kernel:  cpuhp_thread_fun+0xb8/0x120
[    1.675304] kernel:  smpboot_thread_fn+0xd0/0x170
[    1.676685] kernel:  kthread+0x104/0x140
[    1.677948] kernel:  ? sort_range+0x30/0x30
[    1.679299] kernel:  ? kthread_park+0x90/0x90
[    1.680570] kernel:  ret_from_fork+0x35/0x40
[    1.682000] kernel: *** VALIDATE rdt ***
[    1.683454] kernel: resctrl: L3 monitoring detected
```

Reviewed by:	markj, jhb
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D35442

(cherry picked from commit 5afcca138f)
2022-11-10 17:48:38 -08:00
John Baldwin
f771c03297 cxgbe: Use secq(9) to manage the timestamp generations.
This is mostly cosmetic, but it also doesn't leave a gap of time where
no structures are valid.  Instead, we permit the ISR to continue to
use the previous structure if the write to update cal_current isn't
yet visible.

Reviewed by:	gallatin
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D36669

(cherry picked from commit cee4fc7cad)
2022-11-10 17:26:44 -08:00
John Baldwin
2800e3a8ae cxgbe: Compute timestamps via sbintime_t.
This uses fixed-point math already used elsewhere in the kernel for
sub-second time values.  To avoid overflows this does require updating
the calibration once a second rather than once every 30 seconds.  Note
that the cxgbe driver already queries multiple registers once a second
for the statistics timers.  This version also uses fewer instructions
with no branches (for the math portion) in the per-packet fast path.

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

(cherry picked from commit 2c74c9dac3)
2022-11-10 17:26:27 -08:00
Navdeep Parhar
4546011557 cxgbe(4): Fix potential integer overflow in t4_tstmp_to_ns.
Coverity flagged this in its latest run but it is not a problem in
practice as the card's core clock would have to be > 4.2GHz for any
overflow to occur.

CID 1498303:  Integer handling issues  (OVERFLOW_BEFORE_WIDEN)
Potentially overflowing expression "sc->params.vpd.cclk * 1000U" with type "unsigned int" (32 bits, unsigned) is evaluated using 32-bit arithmetic, and then used in a context that expects an expression of type "uint64_t" (64 bits, unsigned).

Reported by:	Coverity Scan (CID 1498303)
Sponsored by:	Chelsio Communications

(cherry picked from commit 02fac928ab)
2022-11-10 17:26:17 -08:00
Konstantin Belousov
cbc43d4f1c cxgbe: fix kernel build without TCP_OFFLOAD or RATELIMIT
Reviewed by:	np
Fixes:	e398922eaf
Sponsored by:	Nvidia networking
Differential revision:	https://reviews.freebsd.org/D36648

(cherry picked from commit 8d42019058)
2022-11-10 17:26:05 -08:00
Mateusz Guzik
42e8cd31c1 cxgbe: fix the build after e398922eaf
(cherry picked from commit d0b235c715)
2022-11-10 17:25:57 -08:00
Randall Stewart
fb99512f32 Enable M_TSTMP in Chelsio cxgbe driver by creating a mechanism that can sync the time.
Chelsio has always been recording a timestamp in the mbuf (rcv_tstmp) but
not setting the M_TSTMP bit in the mbuf flags. This is because the timestamp
was just the free running 60bit clock. This change fixes that so that
we keep a synchronization by periodically (every 30 seconds after startup)
getting the timestamp and the current nanosecond time. We always keep
several sets around and the current one we always keep the current pair
and the previous pair of timestamps. This allows us to setup a ratio
between the two so we can correctly translate the time. Note that
we use special care to split the timestamp into seconds (per the clock tick)
and nanoseconds otherwise 64bit math would overflow.

Reviewed by: np
Sponsored by: Netflix Inc
Differential Revision: https://reviews.freebsd.org/D36315

(cherry picked from commit e398922eaf)
2022-11-10 17:25:52 -08:00
John Baldwin
56dad65305 cxgbe TOE TLS: Simplify a few routines.
Remove a few more remnants from the old pre-KTLS support and instead
assume that each work request sends a single TLS record.

Sponsored by:	Chelsio Communications

(cherry picked from commit c6b3a3772c)
2022-11-10 16:36:01 -08:00
John Baldwin
034af6afc5 cxgbe: Handle requests for TLS key allocations with no TLS key storage.
If an adapter advertises support for TLS keys but an empty TLS key
storage area in on-board memory, fail the request rather than invoking
vmem_alloc on an uninitialized vmem.

Sponsored by:	Chelsio Communications

(cherry picked from commit 1ca4f45ea8)
2022-11-10 16:35:47 -08:00
John Baldwin
38168ab37f cxgbe: Rename t4_kern_tls.c to t6_kern_tls.c.
This implementation of NIC TLS is specific to T6 adapters.

Sponsored by:	Chelsio Communications

(cherry picked from commit bbb2f53715)
2022-11-10 16:35:35 -08:00
John Baldwin
e0f86b61a0 cxgbe: De-duplicate some of the code for managing TLS key contexts.
The NIC TLS and TOE TLS modes in cxgbe(4) both work with TLS key
contexts.  Previously, TOE TLS supported TLS key contexts created by
two different methods, and NIC TLS had a separate bit of code copied
from NIC TLS but specific to KTLS.  Now that TOE TLS only supports
KTLS, pull common code for creating TLS key contexts and programming
them into on-card memory into t4_keyctx.c.

Sponsored by:	Chelsio Communications

(cherry picked from commit 18c69734e9)
2022-11-10 16:16:53 -08:00
John Baldwin
93cec8fde7 cxgbe tom: Remove orphaned function max_imm_tls_space().
Reported by:	markj
Fixes:		789f2d4b3f cxgbe tom: Remove support for non-KTLS TLS offload.
Sponsored by:	Chelsio Communications

(cherry picked from commit 6e26b4f8f4)
2022-11-10 16:16:05 -08:00
John Baldwin
9395c3cd96 cxgbe tom: Remove support for non-KTLS TLS offload.
TOE TLS offload was first supported via a customized OpenSSL developed
by Chelsio with proprietary socket options prior to KTLS being present
either in FreeBSD or upstream OpenSSL.  With the addition of KTLS in
both places, cxgbe's TOE driver was extended to support TLS offload
via KTLS as well.  This change removes the older interface leaving
only the KTLS bindings for TOE TLS.

Since KTLS was added to TOE TLS second, it was somehat shoe-horned
into the existing code.  In addition to removing the non-KTLS TLS
offload, refactor and simplify the code to assume KTLS, e.g. not
copying keys into a helper structure that mimic'ed the non-KTLS mode,
but using the KTLS session object directly when constructing key
contexts.

This also removes some unused code to send TX keys inline in work
requests for TOE TLS.  This code was never enabled, and was arguably
sending the wrong thing (it was not sending the raw key context as we
do for NIC TLS when using inline keys).

Sponsored by:	Chelsio Communications

(cherry picked from commit 789f2d4b3f)
2022-11-10 16:15:52 -08:00
John Baldwin
2c273cf4ce cxgbei: Return limits for the specific adapter the socket is on.
Reviewed by:	mav
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D34929

(cherry picked from commit 43d5661a9d)
2022-11-10 13:48:36 -08:00
John Baldwin
73c8e321ad iscsi: Fetch limits based on a socket rather than assuming global limits.
cxgbei needs the ability to return different limits based on the
connection (e.g. if the connection is over a T5 adapter or a T6
adapter as well as factoring in the MTU).

This change plumbs through the changes in the ioctls without changing
any of the backends.  The limits callback passed to icl_register now
accepts a second socket argument which holds the integer file
descriptor.  To support ABI compatiblity for old binaries, the
callback should return "global" values if the socket fd is zero.

The CTL_ISCSI_LIMITS argument used with CTL_ISCSI by ctld(8) now
accepts the socket fd in a field that was previously part of a
reserved spare field.  Old binaries zero this request which results in
passing a socket fd of 0 to the limits callback.

The ISCSIDREQUEST ioctl no longer returns limits.  Instead, iscsid(8)
invokes a new ISCSIDLIMITS ioctl after establishing the connection via
connect(2).  For ABI compat, if the old ISCSIDREQUEST is invoked, the
global limits are still fetched (with a socket fd of 0) and returned.

Reviewed by:	mav
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D34928

(cherry picked from commit 7b02c1e8c6)
2022-11-10 13:48:36 -08:00
John Baldwin
f5858d5551 arm64 hwpmc: Support restricting counters to user or kernel mode.
Support the "usr" and "os" qualifiers on arm64 events to restrict
event counting to either usermode or the kernel, respectively.  If
neither qualifier is given, events are counted in both.

Reviewed by:	emaste
Sponsored by:	University of Cambridge, Google, Inc.
Differential Revision:	https://reviews.freebsd.org/D34527

(cherry picked from commit 6bb7ba4aa1)
2022-11-10 13:04:56 -08:00
John Baldwin
8a8747f5c9 aarch64: Add constants for fields in the PMEVTYPERn_EL0 event registers.
Reviewed by:	andrew
Sponsored by:	University of Cambridge, Google, Inc.
Differential Revision:	https://reviews.freebsd.org/D34526

(cherry picked from commit 456d57a66d)
2022-11-10 13:04:49 -08:00
Andrew Turner
3bcf60e101 Add more arm64 register op* and CR* values
These will be used by bhyve/arm64.

Sponsored by:	Innovate UK

(cherry picked from commit 4dc815608e)
2022-11-10 13:04:45 -08:00
Andrew Turner
ffe741c4bd Sort the M* and P* arm64 registers
Sponsored by:	Innovate UK

(cherry picked from commit 2abeef7300)
2022-11-10 13:04:39 -08:00
John Baldwin
5fbf51588d Remove a write-only variable.
While refactoring an earlier series of changes during review, the
'saved_data' variable stopped being used at the bottom of if_ioctl().

Suggested by:	brooks
Reviewed by:	brooks, imp, kib
Fixes:		d17e0940f7 Rework compat shims in ifioctl().
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D30197

(cherry picked from commit ed93deba11)
2022-11-10 10:26:22 -08:00
John Baldwin
7affe1db37 Group all compat shim structures together to consolidate #ifdef's.
Reviewed by:	brooks, kib
Obtained from:	CheriBSD
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D29894

(cherry picked from commit 9c87db4b3c)
2022-11-10 10:26:14 -08:00
John Baldwin
e4f4273d05 Use thunks for compat ioctls using struct ifgroupreq.
Reviewed by:	brooks, kib
Obtained from:	CheriBSD
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D29893

(cherry picked from commit 01e9cbc4c5)
2022-11-10 10:26:06 -08:00
John Baldwin
2de8035704 Add freebsd32 compat shims for SIOC[GS]DRVSPEC.
Reviewed by:	brooks, kib
Obtained from:	CheriBSD
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D29892

(cherry picked from commit d61d98f4ed)
2022-11-10 10:25:58 -08:00
John Baldwin
a88b9a2d1f Rework compat shims in ifioctl().
Centralize logic for handling compat ioctls into two blocks of code at
the start and end of the ioctl routine.  This avoids the conversion
logic being spread out both in multiple blocks in ifioctl as well as
various helper functions.

Reviewed by:	brooks, kib
Obtained from:	CheriBSD
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D29891

(cherry picked from commit d17e0940f7)
2022-11-10 10:25:35 -08:00
Mark Johnston
28cfced85b in6: Consolidate IN6_ARE_ADDR_EQUAL definitions
It is ok to use memcmp() in the kernel.  No functional change intended.

Reviewed by:	glebius, melifaro
MFC after:	1 week
Sponsored by:	Modirum MDPay
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D37028

(cherry picked from commit 0d5d356b36)
2022-11-10 12:03:03 -05:00
Gordon Bergling
d1e77e8fca mpt(4): Fix two typos in debug statements
- s/Intermidiate/Intermediate/

Obtained from:	NetBSD

(cherry picked from commit 00b0158d2c)
2022-11-10 09:02:02 +01:00
Richard Scheffenegger
02751c6321 ipfw: Have NAT steal the TH_RES1 bit, instead of the TH_AE bit
The NAT module use of the tcphdr.th_x2 field now collides with the
use of this TCP header flag as AccECN (AE) bit. Use the topmost
bit instead to allow negotiation of AccECN across a NAT device.

Event:			IETF 115 Hackathon
Reviewed By:		#transport, tuexen
MFC after:		3 days
Approved by:		re (gjb, early-MFC)
Sponsored by:		NetApp, Inc.
Differential Revision:	https://reviews.freebsd.org/D37300

(cherry picked from commit 0b00b80149)
2022-11-09 23:17:35 +01:00
Konstantin Belousov
5aab578e3e vmm: do not leak halted_cpus bit after suspension
PR:	267468

(cherry picked from commit 4d447b30f7)
2022-11-09 00:08:25 +02:00
Kristof Provost
efec2d18a3 netgraph/ng_bridge: add missing array terminator
PR:		267457
Reported by:	Robert Morris <rtm@lcs.mit.edu>
MFC after:	1 week

(cherry picked from commit 23559c9d0d)
2022-11-08 09:54:13 +01:00
Gordon Bergling
bf72896aae smartpqi(4): Fix two typos in kernel error messages
- s/runnning/running/

(cherry picked from commit d53e97bb54)
2022-11-08 08:06:34 +01:00
Mitchell Horne
3e00f4ab10 ddb: print the actual syscall name
Some architectures will pretty-print a system call trap in the
backtrace. Rather than printing the symbol, use the syscallname()
function to pull the string from the sv_syscallnames array corresponding
to the process. This simplifies the function somewhat.

Mostly, this will result in dropping the "sys" prefix, e.g. "sys_exit"
will now be printed simply as "exit".

Make two minor tweaks to the function signature: use a u_int for the
syscall number since this is a more correct type (see the 'code' member
of struct syscall_args), and make the thread pointer the first argument.
The latter is more natural and conventional.

Suggested by:   jrtc27
Reviewed by:	jrtc27, markj, jhb
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D37200

(cherry picked from commit aba921bd9e)
2022-11-06 10:54:46 -04:00
Mitchell Horne
d96eebfdb3 linux: populate sv_syscallnames in each sysentvec
This allows the syscallname() function to give a usable result for Linux
ABIs.

Reported by:	jrtc27
Reviewed by:	jrtc27, markj, jhb
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D37199

(cherry picked from commit 1da65dcb1c)
(cherry picked from commit f396f9b6c9)
2022-11-06 10:54:46 -04:00
Mitchell Horne
9dc3a403c3 linux, linux64: improve SRCS formatting
Sort the entries alphabetically, and list them with one entry per line.
This makes the diffs much cleaner when adding or removing a new entry,
as I will do in the next commit.

MFC after:	1 week
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit 3317848808)
2022-11-06 10:54:46 -04:00
Mitchell Horne
e14f67dfed riscv: decode syscall in ddb backtrace
This presents the existing information in a slightly more readable way.

Reviewed by:	jrtc27, markj, jhb
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D36565

(cherry picked from commit 791bfa60e8)
2022-11-06 10:54:46 -04:00