Commit Graph

145410 Commits

Author SHA1 Message Date
John Baldwin
2ff447ee3b cxgbe: Enable TOE TLS RX when an RX key is provided via setsockopt().
Rather than requiring a socket to be created as a TLS socket from the
get go, switch a TOE socket from "plain" TOE to TLS mode when a
receive key is added to the socket.

The firmware is only able to switch a "plain" TOE connection to TLS
mode if the head of the pending socket data is the start of a TLS
record, so the connection is migrated to TLS mode as a multi-step
process.

When TOE TLS RX is enabled, the associated connection's receive side
is frozen via a flag in the TCB.  The state of the socket buffer is
then examined to determine if the pending data in the socket buffer
ends on a TLS record boundary.  If so, the connection is migrated to
TLS mode and unfrozen.  Otherwise, the connection is unfrozen
temporarily until more data arrives.  Once more data arrives, the
receive queue is frozen again and rechecked.  This continues until the
connection is paused at a record boundary.  Any records received
before TLS mode is enabled are decrypted as software records.

Note that this removes the 'rx_tls_ports' sysctl.  TOE TLS offload for
receive is now enabled automatically on existing TOE connections when
using a KTLS-aware SSL library just as it was previously enabled
automatically for TLS transmit.  This also enables TLS offload for TOE
connections which enable TLS after passing initial data in the clear
(e.g. STARTTLS with SMTP).

Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D37351
2022-11-15 12:08:51 -08:00
John Baldwin
21186bdb2d cxgbe: Various whitespace fixes.
Mostly trailing whitespace and spaces before tabs.

Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D37350
2022-11-15 12:03:57 -08:00
John Baldwin
4e47414648 ktls_ocf: Reject encrypted TLS records using AEAD that are too small.
If a TLS record is too small to contain the required explicit IV,
record_type (TLS 1.3), and MAC, reject attempts to decrypt it with
EMSGSIZE without submitting it to OCF.  OCF drivers may not properly
detect that regions in the crypto request are outside the bounds of
the mbuf chain.  The caller isn't supposed to submit such requests.

Reviewed by:	markj
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D37372
2022-11-15 12:02:57 -08:00
John Baldwin
9a673b7158 ktls: Add software support for AES-CBC decryption for TLS 1.1+.
This is mainly intended to provide a fallback for TOE TLS which may
need to use software decryption for an initial record at the start
of a connection.

Reviewed by:	markj
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D37370
2022-11-15 12:02:03 -08:00
Emmanuel Vadot
b97ee269ea Import device-tree files from Linux 6.0
Sponsored by:   Beckhoff Automation GmbH & Co. KG
2022-11-15 20:02:06 +01:00
Emmanuel Vadot
d5b0e70f7e Import device-tree files from Linux 5.19
Sponsored by:   Beckhoff Automation GmbH & Co. KG
2022-11-15 20:01:13 +01:00
Andrew Turner
8a2adde1e4 Split out the arm64 EL2 exception vectors
These were originally in locore.S as they are only needed so we have
a valid value to put into the vbar_el2 register. As these will soon
be used by bhyve so move them to a new file as we already have with
the EL1 exception vectors in exception.S.

Obtained from:	https://github.com/FreeBSD-UPB/freebsd-src (earlier version)
Sponsored by:	Innovate UK
Sponsored by:	The FreeBSD Foundation
2022-11-15 17:26:52 +00:00
Andrew Turner
2468c61958 Add more arm64 hypervisor registers
These will be used by bhyve.

Sponsored by:	Innovate UK
Sponsored by:	The FreeBSD Foundation
2022-11-15 17:26:52 +00:00
Andrew Turner
ae43a817d3 Put the arm64 vttbr_el2 register into a state
Zero the vttbr_el2 register on each CPU so we can tell if we are
running the host or guest kernel from a hypervisor.

Obtained from:	https://github.com/FreeBSD-UPB/freebsd-src (earlier version)
Sponsored by:	Innovate UK
Sponsored by:	The FreeBSD Foundation
2022-11-15 17:26:52 +00:00
Andrew Turner
80ba994bfa Add the arch field to the arm64 MIDR macros
For completeness add accessors for the MIDR field. As the field is
always 0xf on arm64 it is unneeded in the current MICR handling, but
will be used in the vmm module for bhyve.

Obtained from:	https://github.com/FreeBSD-UPB/freebsd-src (earlier version)
Sponsored by:	The FreeBSD Foundation
2022-11-15 17:26:52 +00:00
Mateusz Guzik
60bae7ec04 mac_lomac: whack giant usage
It does not protect anything, the code looks dodgy regardless.
2022-11-15 14:31:41 +00:00
Mateusz Guzik
c3f1a13902 Retire broken GPROF support from the kernel
The option is not even recognized and with that patched it does not
compile. Even if it did work, it would be prohibitively expensive to
use.

Interested parties can use pmcstat or dtrace instead.
2022-11-15 14:17:10 +00:00
Mateusz Guzik
a72edfea57 dtrace: avoid kinst warn when not used
Reviewed by:	markj
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2022-11-15 13:40:31 +00:00
Bjoern A. Zeeb
5d310ea8c5 LinuxKPI: add memset_startat macro
Add a memset_startat() macro which sets a pattern from a struct member
to the end of the struct.   Needed by a wireless driver.

MFC after:	3 days
Reviewed by:	emaste
Differential Revision: https://reviews.freebsd.org/D37389
2022-11-15 12:52:10 +00:00
Andrew Turner
386a5e3ae6 Rename the arm64 pmap_invalidate_* functions
These all work on stage 1 tables. Rename them so we can add similar
functions that operate on stage 2 tables.

Reviewed by:	alc, markj, kib
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D37302
2022-11-15 12:33:39 +00:00
Andrew Turner
0b976be033 Disable superpage use for stage 2 arm64 mappings
When modifying a stage 2 mapping we may need to call into the
hypervisor to invalidate the TLB. Until it is known if the cost of
this operation is less than the performance gains superpages offers
disable their use.

Reviewed by:	kib. markj
Sponsored by:	Innovate UK
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D37299
2022-11-15 12:33:39 +00:00
Andrew Turner
ba2bbac4c1 Revert "Check alignment of fp in unwind_frame"
Fix the build as is_aligned doesn't exist in FreeBSD.

This reverts commit 40e0fa10f5.
2022-11-15 12:33:39 +00:00
Kristof Provost
48767d8734 pfsync: fix memory leak
The recent refactoring to prepare for pfsync over IPv6 introduced a
memory leak.
If we don't have a sync peer configured we return early (without sending
out a packet), but failed to free the newly allocated packet.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
2022-11-15 12:13:11 +01:00
Mateusz Guzik
c1f48e62dc proc: retire 2 unused lock annotations 2022-11-15 10:50:39 +00:00
Kristof Provost
5246f8fade if_ovpn: pass control packets through the socket
Rather than passing control packets through the ioctl interface allow
them to pass through the normal UDP socket flow.
This simplifies both kernel and userspace, and matches the approach
taken (or the one that will be taken) on the Linux side of things.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D37317
2022-11-15 10:01:18 +01:00
Wanpeng Qian
8ab99dbea1
bhyve: abort and return FEATURE_NOT_SAVEABLE while set feature with a save flag for NVMe controller.
Currently bhyve's NVMe controller cannot save feature values cross
reboot. It should return a FEATURE_NOT_SAVEABLE error when the command
specifies a save flag.

Quote from NVMe specification, page 205:

https://nvmexpress.org/wp-content/uploads/NVM-Express-1_4-2019.06.10-Ratified.pdf

If the Feature Identifier specified in the Set Features command is not
saveable by the controller and the controller receives a Set Features
command with the Save bit set to one, then the command shall be aborted
with a status of Feature Identifier Not Saveable.

Reviewed by:		chuck (older version)
Approved by:		manu (mentor)
MFC after:		1 week
Differential Revision:	https://reviews.freebsd.org/D32767
2022-11-15 07:48:24 +01:00
Dapeng Gao
40e0fa10f5 Check alignment of fp in unwind_frame
A misaligned frame pointer is certainly not a valid frame pointer and
with strict alignment enabled (as on CHERI) can cause panics when it is
loaded from later in the code.

Reviewed By:	jhb
Differential Revision: https://reviews.freebsd.org/D34646
2022-11-15 00:25:46 +00:00
Mark Johnston
db494ceb65 virtio: Silence a -Wunused warning
Remove virtio_swap_endian().  htole*() are nops on little-endian
platforms.  No functional change intended.

MFC after:	1 week
Reviewed by:	corvink, jhb
Differential Revision:	https://reviews.freebsd.org/D37298
2022-11-14 15:07:34 -05:00
Dag-Erling Smørgrav
1854fb8fd8 ipfw: Spell PFIL_PASS correctly.
Sponsored by:	Netapp
Sponsored by:	Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D37375
2022-11-14 12:20:19 +01:00
Kristof Provost
6905fd01cb if_ovpn: ensure we're in vnet context when calling sorele()
We reference count to ensure we don't release the socket while we still
have data in flight. That means that we can end up releasing the socket
from ovpn_encrypt_tx_cb().

We must have a vnet context set when calling sorele() (which asserts
this from within sofree()), so move the CURVNET_SET()/CURVNET_RESTORE()
to ensure this is the case.

While here also add a couple of assertions to make this more obvious,
and to ease future debugging.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D37326
2022-11-14 09:36:44 +01:00
Kirk McKusick
78f4129876 Enable taking snapshots on UFS/FFS filesystems using journaled soft updates.
All the needed infrastructure updates have been made to allow
snapshots to be taken on UFS/FFS filesystems that are using journaled
soft updates. The most immediate benefit is the ability to use a
snapshot to take a consistent filesystem dump on a live filesystem
using the -L option to dump(8).

Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D36491
2022-11-12 22:56:03 -08:00
John Baldwin
5920f99d21 ktls: Inline ktls_cleanup() into ktls_destroy().
Reviewed by:	gallatin, markj
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D37353
2022-11-11 16:01:02 -08:00
John Baldwin
d01db2b837 ktls: Don't leak ktls session objects for certain errors.
ktls_cleanup() does not free ktls session objects, it merely
cleans (and frees) members of the object.

Change callers to use ktls_free() instead.

Reviewed by:	gallatin, markj
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D37352
2022-11-11 16:00:37 -08:00
John Baldwin
573bd1fcf5 wg: Drop the compat shim for sbcreatecontrol().
I had to make a few other changes when merging the driver to stable/13
anyway, so adjusting this as well isn't really a big deal.

MFC after:	3 days
2022-11-11 14:18:48 -08:00
Jean-Sébastien Pédron
208d02fd5d
linuxkpi: Define ZERO_OR_NULL_PTR() in <linux/slab.h>
On Linux, the `kmalloc()` family of functions returns a special value if
the size of the allocation is zero. This macro verifies if the pointer
is NULL (the allocation failed) or the size is 0 (the allocation was not
performed AFAIU). This special value can be passed to `kfree()`.

On FreeBSD, our `malloc(9)` functions don't return a special value for
0-size allocations. Therefore we can simply compare the result against
NULL.

Reviewed by:	manu
Approved by:	manu
Differential Revision:	https://reviews.freebsd.org/D37367
2022-11-11 21:03:25 +01:00
Jean-Sébastien Pédron
86a1c5d129
linuxkpi: Define pci_reset_function() in <linux/pci.h>
Currently, it always returns an error on FreeBSD.

Reviewed by:	bz manu
Approved by:	bz manu
Differential Revision:	https://reviews.freebsd.org/D37366
2022-11-11 21:00:36 +01:00
Jean-Sébastien Pédron
42bb586116
linuxkpi: Include <linux/list.h> and <linux/kernel.h> from <linux/mutex.h>
They are not really used in this header. However they are included in
Linux and at least the DRM drivers unfortunately rely on this namespace
pollution.

Reviewed by:	manu
Approved by:	manu
Differential Revision:	https://reviews.freebsd.org/D37365
2022-11-11 20:59:40 +01:00
Jean-Sébastien Pédron
24c7853f39
linuxkpi: Add <linux/mman.h> which includes <linux/smp.h>
This is used by `i915_gem.c` in the i915 DRM driver to get access to
`wbinvd_on_all_cpus()`.

Reviewed by:	manu
Approved by:	manu
Differential Revision:	https://reviews.freebsd.org/D36970
2022-11-11 20:57:46 +01:00
Jean-Sébastien Pédron
708a570255
linuxkpi: Add <linux/page-flags.h>
It just provides a `PageHighMem()` macro stub.

Reviewed by:	manu
Approved by:	manu
Differential Revision:	https://reviews.freebsd.org/D36961
2022-11-11 20:56:42 +01:00
Kyle Evans
753a23ac15 arm64: add a spin-table implementation for Apple Silicon
The M1 has no EL3, so we're limited to a spin-table implementation if we
want to eventually use bhyve on it.  Implement spin-table now, but note
that we still prefer PSCI where possible.

Reviewed by:	mmel
Differential Revision:	https://reviews.freebsd.org/D34661
2022-11-11 13:50:29 -06:00
Mitchell Horne
03d6764b38 ddb: don't limit pindex output in 'show vmopag'
This command already prints a tremendous amount of output, and properly
obeys the pager. It no longer makes sense to arbitrarily limit the pages
that are printed, as the reader will not be aware that this has
happened.

Reviewed by:	markj
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D37361
2022-11-11 14:25:39 -04:00
Jean-Sébastien Pédron
58cf3a69a5
linuxkpi: Define boot_cpu_data.x86_max_cores
Reviewed by:	manu
Approved by:	manu
Differential Revision:	https://reviews.freebsd.org/D36971
2022-11-11 18:43:07 +01:00
Jean-Sébastien Pédron
c4163160e4
linuxkpi: Add dev_warn_once() in <linux/device.h>
Reviewed by:	manu
Approved by:	manu
Differential Revision:	https://reviews.freebsd.org/D36968
2022-11-11 18:42:31 +01:00
Jean-Sébastien Pédron
23ebeac87f
linuxkpi: Add list_for_each_entry_from_rcu() in <linux/rculist.h>
Reviewed by:	manu
Approved by:	manu
Differential Revision:	https://reviews.freebsd.org/D36967
2022-11-11 18:42:10 +01:00
Jean-Sébastien Pédron
d3584f9283
linuxkpi: Define typeof_member() in <linux/kernel.h>
Reviewed by:	manu
Approved by:	manu
Differential Revision:	https://reviews.freebsd.org/D36964
2022-11-11 18:41:36 +01:00
Jean-Sébastien Pédron
0e5569a08c
linuxkpi: Add <linux/dma-buf-map.h>
I took the implementation from OpenBSD, commit
d55ef580b1748517027c3eabdb715316ca5b1442.

The only difference is the addition of `dma_buf_map_is_equal()`.

Reviewed by:	manu
Approved by:	manu
Differential Revision:	https://reviews.freebsd.org/D36963
2022-11-11 18:40:57 +01:00
Jean-Sébastien Pédron
c9c1255012
linuxkpi: Add <linux/mmzone.h>
It provides the `MAX_ORDER` constant.

Reviewed by:	emaste manu
Approved by:	emaste manu
Differential Revision:	https://reviews.freebsd.org/D36962
2022-11-11 18:39:48 +01:00
Jean-Sébastien Pédron
1676c97d5d
linuxkpi: Add <acpi/actbl.h>
It simply includes the same header in FreeBSD (which is located
elsewhere).

Reviewed by:	manu
Approved by:	manu
Differential Revision:	https://reviews.freebsd.org/D36960
2022-11-11 18:38:06 +01:00
Jean-Sébastien Pédron
1ad6b2b1da
linuxkpi: Add krealloc_array()
In FreeBSD, this is a wrapper on top of `realloc()`.

V2: Check if `n * size` would overflow and return `NULL` if that's the
    case. Suggested by hselasky@ and emaste@.

Reviewed by:	manu
Approved by:	manu
Differential Revision:	https://reviews.freebsd.org/D36959
2022-11-11 18:37:34 +01:00
Jean-Sébastien Pédron
0b8a423d07
linuxkpi: Introduce module_param() of type hexint
In Linux, this affects how the value is formatted. In FreeBSD, this
remains an unsigned integer.

Reviewed by:	manu
Approved by:	manu
Differential Revision:	https://reviews.freebsd.org/D36958
2022-11-11 18:36:46 +01:00
Jean-Sébastien Pédron
c72dd0aabe
linuxkpi: Introduce vma_set_file()
This code was moved from the i915 driver in Linux 5.11.

Reviewed by:	manu
Approved by:	manu
Differential Revision:	https://reviews.freebsd.org/D36957
2022-11-11 18:36:00 +01:00
Jean-Sébastien Pédron
415ca4d27d
linuxkpi: Include <linux/shinker.h> in <linux/mm.h>
This is done like this in Linux.

Reviewed by:	emaste manu
Approved by:	emaste manu
Differential Revision:	https://reviews.freebsd.org/D36956
2022-11-11 18:34:19 +01:00
Jean-Sébastien Pédron
f021c5c4a1
linuxkpi: Update struct irq_work
The previous `llnode` field is moved inside another field `node`.

This `node` field is a `struct __call_single_node` in Linux. Here, we
simply add an anonymous struct with the `llnode` field inside. That
field's new name is `llist` now.

V2: Use an anonymous union to keep the structure backward compatible
    with drivers using the previous `llnode` field. This was suggested
    by wufl@ and hselasky@. Thank you!

Reviewed by:	manu
Approved by:	manu
Differential Revision:	https://reviews.freebsd.org/D36955
2022-11-11 18:32:58 +01:00
Jean-Sébastien Pédron
bfe6bfd79e
linuxkpi: Add __GFP_NOMEMALLOC kmalloc flag
Reviewed by:	manu
Approved by:	manu
Differential Revision:	https://reviews.freebsd.org/D36954
2022-11-11 18:30:31 +01:00
Konrad Witaszczyk
f0d1225734
Remove dead code in the cscope target
arm64 is the only currently supported architecture that has
${MACHINE_CPUARCH} set to a different value (aarch64) than ${MACHINE}
(arm64), as described in arch(7). However, there is no source directory
associated with arm64 that has a name set to ${MACHINE_CPUARCH}.

Remove the dead code that adds a directory with a name set to
${MACHINE_CPUARCH} to a list of directories indexed with cscope.
This change allows to use the cscope target on arm64.

Discussed with:	jhb
Reviewed by:	imp jhb
Approved by:	oshogbo (mentor)
Differential Revision:	https://reviews.freebsd.org/D36402
2022-11-11 15:53:57 +00:00