Commit graph

290629 commits

Author SHA1 Message Date
Mark Johnston 85efb31d50 libvmmapi: Move VM capability names to vmmapi_machdep.c
Add some missing entries while here.

Reviewed by:	corvink, jhb
MFC after:	2 weeks
Sponsored by:	Innovate UK
Differential Revision:	https://reviews.freebsd.org/D41000
2024-04-10 11:17:55 -04:00
Mark Johnston e4656e10d1 libvmmapi: Move some ioctl wrappers to vmmapi_machdep.c
ioctls relating to segments and various x86-specific interrupt
controllers are easy candidates to move to vmmapi_machdep.c.

In vmmapi.h I'm just ifdefing MD prototypes for now.  We could instead
split vmmapi.h into multiple headers, e.g., vmmapi.h and
vmmapi_machdep.h, but it's not obvious to me yet that that's the right
approach.

No functional change intended.

Reviewed by:	corvink, jhb
MFC after:	2 weeks
Sponsored by:	Innovate UK
Differential Revision:	https://reviews.freebsd.org/D40999
2024-04-10 11:17:55 -04:00
Mark Johnston 967264cfcd libvmmapi: Add a subdirectory for amd64-specific code
Move vmmapi_freebsd.c there.  It contains x86-specific code used only by
bhyveload(8).

Move vcpu_reset() into vmmapi_machdep.c.  It is also x86-specific.

No functional change intended.

Reviewed by:	corvink, jhb
MFC after:	2 weeks
Sponsored by:	Innovate UK
Differential Revision:	https://reviews.freebsd.org/D40998
2024-04-10 11:17:55 -04:00
Mark Johnston e497fe8657 bhyve: Use vm_get_highmem_base() instead of hard-coding the value
This reduces the coupling between libvmmapi (which creates the highmem
segment) and bhyve, in preparation for the arm64 port.

No functional change intended.

Reviewed by:	corvink, jhb
MFC after:	2 weeks
Sponsored by:	Innovate UK
Differential Revision:	https://reviews.freebsd.org/D40992
2024-04-10 11:17:55 -04:00
Mark Johnston eaff4c4f92 bhyve: Add FDT building code for arm64
fdt.c provides some basic routines which let platform initialization
code build the FDT that gets passed into the guest.  For now this is not
very generic; we declare info about CPUs, memory, a single UART
(specified by -o console), a PCIe controller (used for virtio devices),
an interrupt controller and the platform timer.

Co-authored-by:	andrew
Reviewed by:	corvink, jhb
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D40996
2024-04-10 11:17:55 -04:00
Mark Johnston d878f72a73 bhyve: Provide optional libfdt linking
The arm64 port currently does not support ACPI, it instead builds up an
FDT which is exported to the guest.  This mechanism will not be used on
amd64 but isn't really arm64-specific either, so provide an opt-in
mechanism to link libfdt.

No functional change intended.

Reviewed by:	corvink, jhb
MFC after:	2 weeks
Sponsored by:	Innovate UK
Differential Revision:	https://reviews.freebsd.org/D40995
2024-04-10 11:17:55 -04:00
Andrew Turner f3003a0dfb bhyve: Add PL011 UART emulation
This will be use for arm64 guests, instead of the existing ns16550 UART
model.

Reviewed by:	corvink, jhb
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D40997
2024-04-10 11:17:55 -04:00
Olivier Certner afc10f8bba
sys_procctl(): Make it clear that negative commands are invalid
An initial reading of the preamble of sys_procctl() gives the impression
that no test prevents a malicious user from passing a negative commands
index (in 'uap->com'), which is soon used as an index into the static
array procctl_cmds_info[].

However, a closer examination leads to the conclusion that the existing
code is technically correct.  Indeed, the comparison of 'uap->com' to
the nitems() expression, which expands to a ratio of sizeof(), leads to
a conversion of 'uap->com' to an 'unsigned int' as per Usual Arithmetic
Conversions/Integer Promotions applied by '<=', because sizeof() returns
'size_t' values, and we define 'size_t' as an equivalent of 'unsigned
int' (which is not mandated by the standard, the latter allowing, e.g.,
integers of lower ranks).

With this conversion, negative values of 'uap->com' are automatically
ruled-out since they are converted to very big unsigned integers which
are caught by the test.  An analysis of assembly code produced by LLVM
16 on amd64 and practical tests confirm that no exploitation is possible.

However, the guard code as written is misleading to readers and might
trip up static analysis tools.  Make sure that negative values are
explicitly excluded so that it is immediately clear that EINVAL will be
returned in this case.

Build tested with clang 16 and GCC 12.

Approved by:    markj (mentor)
MFC after:      1 week
Sponsored by:   The FreeBSD Foundation
2024-04-10 17:15:25 +02:00
Mark Johnston 1d14e88e53 tcp: Make tcp_var.h more self-contained
struct tcpcb embeds a struct osd and a struct callout.  Rather than
forcing all consumers to pull in the same headers, include the headers
directly.

No functional change intended.

Reviewed by:	glebius
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D44685
2024-04-10 08:53:49 -04:00
Minsoo Choo 989a2cf19d vm_reserv_reclaim_contig: Return NULL not false
Reviewed by:	dougm, zlei
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D44667
2024-04-10 08:50:16 -04:00
Konstantin Belousov 1e6db7be69 pciconf(8): dump AMD IOMMU Base Capability
Reviewed by:	emaste
Sponsored by:	Advanced Micro Devices (AMD)
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D44732
2024-04-10 08:28:24 +03:00
Konstantin Belousov 33adb388c7 pcireg.h: Add AMD IOMMU Base Cap definitions
Reviewed by:	emaste
Sponsored by:	Advanced Micro Devices (AMD)
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D44732
2024-04-10 08:28:24 +03:00
Konstantin Belousov 1cd9868f04 pcireg.h: add include guard
Reviewed by:	emaste
Sponsored by:	Advanced Micro Devices (AMD)
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D44732
2024-04-10 08:28:23 +03:00
Graham Perrin 763f5da97d libbe(3): history: fix
'bectl(8) and libbe' (not 'libbe and libbe(3)').

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/857
2024-04-09 22:01:10 -06:00
Graham Perrin 04610d665e libbe(3): consistency, and authors
Consistency with the manual page for bectl(8), including addition of an
AUTHORS section.

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/857
2024-04-09 22:01:06 -06:00
Graham Perrin 20b5e47c93 bectl(8): authors: Kyle Evans: fine-tune
Discussed with Kyle in Discord.

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/857
2024-04-09 22:01:03 -06:00
Graham Perrin 984f503749 bectl(8): authors: be more explicit
Cross-reference (name) the manual page that was written by Bryan
Drewery.

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/857
2024-04-09 22:00:59 -06:00
Graham Perrin 6e3e24d145 bectl(8): HISTORY, AUTHORS: further attention
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/857
2024-04-09 22:00:56 -06:00
Graham Perrin a27e19a223 bectl(8): corrections, changes
beadm(1) no longer exists.

Cross-reference beadm(8).

Aim to improve the HISTORY and AUTHORS sections, including consistency
with the manual pages for beadm(8) and libbe(3).

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/857
2024-04-09 22:00:48 -06:00
rilysh 2a3d453049 exit.3: add the comma after an empty space
exit(3) man page shows __cxa_atexit(3,) instead of __cxa_atexit(3), in a
particular section. It seems the comma gets inside the parenthesis and
with an extra space, it can be viewed as expected.

Signed-off-by: rilysh <nightquick@proton.me>
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1006
2024-04-09 21:38:01 -06:00
Colin Percival 2c01e189ff Reapply "release.sh: Add -jN to make release"
With the latest changes to release/Makefile, it is now possible to
run `make release -jN` without the build failing (at least in my
latest tests).

This reverts commit 7b707e797b.

MFC after:	1 week
2024-04-09 20:29:16 -07:00
Colin Percival a1bff97300 release: Don't reuse disc1/bootonly directories
The disc1 and bootonly directories have files distributed into them
for use in "full" and "mini" images; the former are disc1.iso and
memstick.img, and the latter is bootonly.iso and mini-memstick.img.

Unfortunately the scripts which package a directory tree into an ISO
or memory stick image also modify the directory, for example to
create an appropriate /etc/fstab file; so creating two images at the
same time breaks.

Resolve this by copying disc1 to disc1-disc1 and disc1-memstick,
and copying bootonly to bootonly-bootonly and bootonly-memstick,
before using those directories for constructing the ISO+memstick
images.

MFC after:	1 week
2024-04-09 20:29:16 -07:00
Colin Percival 65c603ed65 release: distributekernel before packagekernel
With these as a single make command, `make -j` breaks when it tries to
package up a kernel which hasn't been distributed yet.

MFC after:	1 week
2024-04-09 20:29:16 -07:00
Colin Percival 93e4813b9a release: make -j compat: cd inside subshell
Place instances of "cd foo && bar" inside subshells for compatibility
with modern make(8) which uses a single shell for the duration of a
makefile target.

MFC after:	1 week
2024-04-09 20:29:16 -07:00
Lexi Winter ac83063d37 bcm2838_xhci: add module
bcm2838_xhci(4) is a shim for the XHCI controller on the Raspberry Pi 4B
SoC.  It loads the controller's firmware before passing control to the
normal xhci(4) driver.

When xhci(4) is built as a module (and not in the kernel), bcm2838_xhci
is not built at all and the RPi4's XHCI controller won't attach due to
missing firmware.

To fix this, build a new module, bcm2838_xhci.ko, which depends on
xhci.ko.  For the dependency to work correctly, also modify xhci to
provide the 'xhci' module in addition to the 'xhci_pci' module it
already provided.

Since bcm2838_xhci is specific to a quirk of the RPi4 SoC, only build
the module for AArch64.

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1142
2024-04-09 21:11:39 -06:00
Jake Freeland 054a472059 tests: Add ktrace regression test for shm_open
Verify that a capability violation is recorded when shm_open(2) is called
with a non-anonymous path.

Approved by:	markj (mentor)
Reviewed by:	markj
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D44733
2024-04-09 21:19:03 -05:00
Jake Freeland b112232e4f uipc_shm: Copyin userpath for ktrace(2)
If userpath is not SHM_ANON, then copy it in early so ktrace(2) can
record it. Without this change, ktrace(2) will attempt to strcpy a
userspace string and trigger a page fault.

Reported by:	syzbot+490b9c2a89f53b1b9779@syzkaller.appspotmail.com
Fixes:		0cd9cde767
Approved by:	markj (mentor)
Reviewed by:	markj
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D44702
2024-04-09 21:17:11 -05:00
Jason A. Harmening b18029bc59 unionfs_lookup(): fix wild accesses to vnode private data
There are a few spots in which unionfs_lookup() accesses unionfs vnode
private data without holding the corresponding vnode lock or interlock.

Reviewed by:		kib, olce
MFC after:		2 weeks
Differential Revision:	https://reviews.freebsd.org/D44601
2024-04-09 17:36:59 -05:00
John Baldwin 8f7105a206 NOTES: Move NVMe entries to MI file
While here, adjust the sample setting for NVME_USE_NVD to use a
non-default setting as is typical in entries in NOTES.

Discussed with:	imp
Reviewed by:	manu
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D44691
2024-04-09 15:02:58 -07:00
John Baldwin 16e846fa1e sys: Enable NVMe drivers on all architectures
The NVMe drivers are portable and are already included statically in
GENERIC on other architectures such as aarch64 and riscv64.

Reviewed by:	imp
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D44690
2024-04-09 15:02:58 -07:00
John Baldwin a508f5d92a NOTES: Tidy entries for SATA controllers
- Add typical comments after device entries (copied from amd64
  GENERIC)

- Add an entry for 'device ada'.  Normally this is pulled in via
  'device sd', but is documented in ada(4) and can be used to include
  ATA/SATA disk support in a kernel without SCSI disk support.

Reviewed by:	imp
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D44689
2024-04-09 15:02:58 -07:00
John Baldwin 76f22e353f NOTES: Add devices for iSCSI support
Reviewed by:	imp
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D44688
2024-04-09 15:02:58 -07:00
John Baldwin 60bb979b3c iser: Add kernel build glue
'device iser' is documented in iser(4) but not supported.  Hook it up
to the build.

Reviewed by:	imp
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D44687
2024-04-09 15:02:58 -07:00
John Baldwin 973d3a8209 NOTES: Move OFED options to MI NOTES
Disable in armv7 NOTES to match sys/modules/Makefile

Reviewed by:	imp
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D44686
2024-04-09 15:02:58 -07:00
Lexi Winter 493908c4b4 periodic/daily/801.trim-zfs: Add a daily zfs trim script
As mentioned in zpoolprops(7), on some SSDs, it may not be desirable to
use ZFS autotrim because a large number of trim requests can degrade
disk performance; instead, the pool should be manually trimmed at
regular intervals.

Add a new daily periodic script for this purpose, 801.trim-zfs.  If
enabled (daily_trim_zfs_enable=YES; the default is NO), it will run a
'zpool trim' operation on all online pools, or on the pools listed in
'daily_trim_zfs_pools'.

The trim is not started if the pool is degraded (which matches the
behaviour of the existing 800.scrub-zfs script) or if a trim is already
running on that pool.  Having autotrim enabled does not inhibit the
periodic trim; it's sometimes desirable to run periodic trims even with
autotrim enabled, because autotrim can elide trims for very small
regions.

PR:		275965
MFC after:	1 week
Reviewed by:	imp
Pull Request:	https://github.com/freebsd/freebsd-src/pull/956
2024-04-09 15:55:11 -06:00
John Baldwin 03713f805a pci_host_generic: Tolerate range resource allocation failures
QEMU for armv7 includes a PCI memory range whose CPU address is
greater than 4GB.  This falls outside the range of armv7's global
mem_rman used by the nexus driver.  As a result, pcib0 fails to
attach blocking all PCI devices.

Instead, change the driver to be a bit more tolerant.  If allocating a
resource for a range fails, don't fail attaching the entire driver,
but do skip adding the associated PCI range to the relevant rman in
the pcib driver.  This will prevent child devices from using BARs that
allocate from this range.  In the case of QEMU on armv7 devices can
still allocate from an earlier PCI memory range that is within the
32-bit address space (and in fact none of the firmware-assigned memory
BARs use addresses from the upper range).

While here, reorder the operations on I/O ranges a bit: 1) print the
range under bootverbose first (rather than last) so that the range is
printed before any relevant errors for the range, 2) move
rman_manage_region last after the parent resource has been set and
allocated.

Reported by:	markj, Jenkins
Reviewed by:	markj
Fixes:		d79b6b8ec2 pci_host_generic: Don't rewrite resource start address for translation
Differential Revision:	https://reviews.freebsd.org/D44698
2024-04-09 14:55:40 -07:00
Gleb Smirnoff 5716d902ae Revert "unix: new implementation of unix/stream & unix/seqpacket"
The regressions in aio(4) and kernel RPC aren't a 5 minute problem.

This reverts commit d80a97def9.
This reverts commit d1cbb17a87.
This reverts commit fb8a8333b4.
2024-04-09 13:15:47 -07:00
Stephen J. Kiernan 22ca6db50f config.mk: Add MK_VIMAGE knob
Default to VIMAGE as yes.
Add VIMAGE to __DEFAULT_DEPENDENT_OPTIONS (to define VIMAGE_SUPPORT)

Only output VIMAGE to opt_global.h when VIMAGE support is wanted.

Obtained from:	Juniper Networks, Inc.
Differential Revision:	https://reviews.freebsd.org/D39636
2024-04-09 13:05:56 -04:00
Alan Cox 841cf52595 arm64 pmap: Add ATTR_CONTIGUOUS support [Part 2]
Create ATTR_CONTIGUOUS mappings in pmap_enter_object().  As a result,
when the base page size is 4 KB, the read-only data and text sections
of large (2 MB+) executables, e.g., clang, can be mapped using 64 KB
pages.  Similarly, when the base page size is 16 KB, the read-only
data section of large executables can be mapped using 2 MB pages.

Rename pmap_enter_2mpage().  Given that we have grown support for 16 KB
base pages, we should no longer include page sizes that may vary, e.g.,
2mpage, in pmap function names.  Requested by: andrew

Co-authored-by: Eliot Solomon <ehs3@rice.edu>
Differential Revision:	https://reviews.freebsd.org/D44575
2024-04-09 11:21:08 -05:00
Gleb Smirnoff e205fd318a rpc: use new macros to lock socket buffers
Fixes:	d80a97def9
2024-04-09 09:17:19 -07:00
Stephen J. Kiernan cb20a74ca0 vm: add macro to mark arguments used when NUMA is defined
This fixes compiler warnings when -Wunused-arguments is enabled and
not quieted.

Reviewed by:	kib, markj
Obtained from:	Juniper Networks, Inc.
Differential Revision:	https://reviews.freebsd.org/D44623
2024-04-09 10:23:47 -04:00
Zhenlei Huang f6f67f58c1 ng_socket: Treat EEXIST from kern_kldload() as success
EEXIST is possible in a race condition.

Inspired by:	ffc72591b1 (Don't worry if a module is already loaded ...)
Reviewed by:	glebius
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D44633
2024-04-09 18:04:47 +08:00
Rick Macklem cce11997a0 mountd.8: Document the new -A mountd option
Commit fefb7c399b added warning messages noting
that administrative controls that exported directories
that are not local server file system mount points actually
export the entire local server file system.
This commit also added a new command line option "-A' that
silences these warnings.

This patch documents the new "-A' mountd option.

This is a content change.

Reviewed by:	markj, pauamma_gundo.com (manpages)
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D44692
2024-04-08 18:58:40 -07:00
Stephen J. Kiernan 81b4d1c4d4 sockets: Add hhook in sonewconn for inheriting OSD specific data
Added HHOOK_SOCKET_NEWCONN and bumped HHOOK_SOCKET_LAST

Reviewed by:	glebius, tuexen
Obtained from:	Juniper Networks, Inc.
Differential Revision:	https://reviews.freebsd.org/D44632
2024-04-08 21:31:34 -04:00
Gleb Smirnoff fb8a8333b4 unix: return immediately on MSG_OOB
Jumping to cleanup routines will work on uninitialized stack mc.

Fixes:	d80a97def9
Reported-by:	syzbot+4adf0b37849ea7723586@syzkaller.appspotmail.com
2024-04-08 17:09:16 -07:00
Gleb Smirnoff d1cbb17a87 unix: fix the ad hoc STAILQ_PREPEND()
If there is nothing to prepend, don't try STAILQ_INSERT_HEAD().

Fixes:	d80a97def9
Reported-by: syzbot+bb7f3d07c79b5faf8de8@syzkaller.appspotmail.com
2024-04-08 17:02:00 -07:00
Gleb Smirnoff f7c4d12bcd icmp: correct the assertion that checks limit + jitter
Fixes:	4399e055ea
2024-04-08 16:54:19 -07:00
Dag-Erling Smørgrav 0729d1e8fd cp: Never follow symbolic links in destination.
Historically, BSD cp has followed symbolic links in the destination
when copying recursively, while GNU cp has not.  POSIX is somewhat
vague on the topic, but both interpretations are within bounds.  In
33ad990ce9, cp was changed to apply the same logic for symbolic
links in the destination as for symbolic links in the source: follow
if not recursing (which is moot, as this situation can only arise
while recursing) or if the `-L` option was given.  There is no support
for this in POSIX.  We can either switch back, or go all the way.

Having carefully weighed the kind of trouble you can run into by
following unexpected symlinks up against the kind of trouble you can
run into by not following symlinks you expected to follow, we choose
to go all the way.

Note that this means we need to stat the destination twice: once,
following links, to check if it is or references the same file as the
source, and a second time, not following links, to set the dne flag
and determine the destination's type.

While here, remove a needless complication in the dne logic.  We don't
need to explicitly reject overwriting a directory with a non-directory,
because it will fail anyway.

Finally, add test cases for copying a directory to a symlink and
overwriting a directory with a non-directory.

MFC after:	never
Relnotes: 	yes
Sponsored by:	Klara, Inc.
Reviewed by:	kevans
Differential Revision:	https://reviews.freebsd.org/D44578
2024-04-09 00:41:33 +02:00
Gleb Smirnoff d80a97def9 unix: new implementation of unix/stream & unix/seqpacket
Provide protocol specific pr_sosend and pr_soreceive for PF_UNIX
SOCK_STREAM sockets and implement SOCK_SEQPACKET sockets as an extension
of SOCK_STREAM.  The change meets three goals: get rid of unix(4) specific
stuff in the generic socket code, provide a faster and robust unix/stream
sockets and bring unix/seqpacket much closer to specification.  Highlights
follow:

- The send buffer now is truly bypassed.  Previously it was always empty,
but the send(2) still needed to acquire its lock and do a variety of
tricks to be woken up in the right time while sleeping on it.  Now the
only two things we care about in the send buffer is the I/O sx(9) lock
that serializes operations and value of so_snd.sb_hiwat, which we can read
without obtaining a lock.  The sleep of a send(2) happens on the mutex of
the receive buffer of the peer.  A bulk send/recv of data with large
socket buffers will make both syscalls just bounce between owning the
receive buffer lock and copyin(9)/copyout(9), no other locks would be
involved.

- The implementation uses new mchain structure to manipulate mbuf chains.
Note that this required converting to mchain two functions that are shared
with unix/dgram: unp_internalize() and unp_addsockcred() as well as adding
a new shared one uipc_process_kernel_mbuf().  This induces some non-
functional changes in the unix/dgram code as well.  There is a space for
improvement here, as right now it is a mix of mchain and manually managed
mbuf chains.

- unix/seqpacket previously marked as PR_ADDR & PR_ATOMIC and thus treated
as a datagram socket by the generic socket code, now becomes a true stream
socket with record markers.

- unix/stream loses the sendfile(2) support.  This can be brought back,
but requires some work.  Let's first see if there is any interest in this
feature, except purely academical.

Reviewed by:		markj, tuexen
Differential Revision:	https://reviews.freebsd.org/D44151
2024-04-08 13:16:51 -07:00
Gleb Smirnoff aba79b0f4a mbuf: provide mc_uiotomc() a function to copy from uio(9) to mchain
Implement m_uiotombuf() as a wrapper around mc_uiotomc().  The M_EXTPG is
left untouched.  The m_uiotombuf() is left as a compat KPI.  New code
should use either mc_uiotomc() or m_uiotombuf_nomap().

Reviewed by:		markj, tuexen
Differential Revision:	https://reviews.freebsd.org/D44150
2024-04-08 13:16:51 -07:00