Commit graph

291708 commits

Author SHA1 Message Date
Dag-Erling Smørgrav 02d98d1850 libdiff: Add a test for the truncation issue.
Sponsored by:	Klara, Inc.
Reviewed by:	allanjude
Differential Revision:	https://reviews.freebsd.org/D45218
2024-05-20 15:26:42 +02:00
Dag-Erling Smørgrav 974ea6b297 libdiff: Detect and recover from file truncation.
If a memory-mapped file is truncated before we get to the end, the
atomizer may catch SIGBUS.  Detect that, reduce the input length to
what we were actually able to read, and set a flag so the caller can
take further action (e.g. warn the user and / or start over).

Sponsored by:	Klara, Inc.
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D45217
2024-05-20 15:26:33 +02:00
Zhenlei Huang 93fbfef0b5 if_vxlan(4): Add checking for loops and nesting of tunnels
User misconfiguration, either tunnel loops, or a large number of
different nested tunnels, can overflow the kernel stack. Prevent that
by using if_tunnel_check_nesting().

PR:		278394
Diagnosed by:	markj
Reviewed by:	kp
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D45197
2024-05-20 20:14:07 +08:00
Warner Losh c7581d76a1 loader: fix stupid typos
Sponsored by:		Netflix
2024-05-19 23:04:18 -06:00
Warner Losh 861f802b3e textvidc: Reindent
Since this is now 'new code' go ahead and reindent for modern project
preferences.

Sponsored by:		Netflix
2024-05-19 22:05:43 -06:00
Warner Losh 4cddd20e1e loader/ofw: Style(9) pass over return statements
Make these consistent. Some files weren't even consistent with
themselves. Make them all either return <space> ( <value> ); or
return;

Sponsored by:		Netflix
2024-05-19 22:05:43 -06:00
Warner Losh 3f012b9508 loader: stlye(9) nit: Space between return and the value
Sponsored by:		Netflix
2024-05-19 22:05:43 -06:00
Warner Losh 2d425b634f loader: c_init returns 0 or 1
c_init returns 0 (success) or 1 (failure). Don't return other values.

Sponsored by:		Netflix
2024-05-19 22:05:42 -06:00
Warner Losh 125b181674 userboot: Use C99 Initializers for each of the consoles here
Sponsored by:		Netflix
2024-05-19 22:05:42 -06:00
Warner Losh 1f180d0a40 ofw: Use C99 initializers for the console struct
Sponsored by:		Netflix
2024-05-19 22:05:42 -06:00
Warner Losh 6e28b4aa15 uboot: Use c99 initializers for the console struct
Sponsored by:		Netflix
2024-05-19 22:05:42 -06:00
Warner Losh b3551da9cd efi_console: Use c99 initializers
Sponsored by:		Netflix
2024-05-19 22:05:42 -06:00
Warner Losh 5e7b0cd93a i386/nullconsole: Use C99 initializers
Sponsored by:		Netflix
2024-05-19 22:05:41 -06:00
Warner Losh 803060b217 i386/spinconsole: Use C99 initializers
Sponsored by:		Netflix
2024-05-19 22:05:41 -06:00
Warner Losh a578e2b896 boot/i386: Use C99 initializer for textvidc
Sponsored by:		Netflix
2024-05-19 22:05:41 -06:00
Warner Losh f989ebd4de kboot: Use C99 initialiers for hostconsole.
Sponsored by:		Netflix
2024-05-19 22:05:41 -06:00
Warner Losh 0111f09ca6 kboot: Initialize hostfs_root sooner (and remove kboot.conf)
Move the initialization of hostfs_root to be a bit sooner. While it
doesn't matter for the default case, we may want to use hostfs files
sooner.

Also, while we're here, remove kboot.conf. It duplicates the command
line and has proven difficult to use. It will be replaced by an early
script that can influence the state of the boot loader before we select
a device to boot from (including strongly suggesting which one to boot
from).

Sponsored by:		Netflix
2024-05-19 22:05:41 -06:00
Warner Losh 68344c9c6c loader: separate lang init from scripting init
Create interp_preinit() to initialize the scripting language to run
scripts. Make sure you can call it multiple times, but only the first
one has effect, After it's call, you can run scripts in the scripting
language. At the moment, no functional change.

Sponsored by:		Netflix
2024-05-19 22:05:40 -06:00
Warner Losh 1d7bdae9ca kboot: Move console, acpi and smbios init
Move the console probing to as early as possible. There's no real
support for anything but hostcons, and setting it up early will show
other error messages.

ACPI and SMBIOS probing can be done just after we have the console, so
move it there. This allows other parts of the early code to use info
from that, as well as overriding and env vars set by these things on the
command line (smbios data may be wrong during initial development phases
as the automated way to populate per-board data may not be established,
etc).

Sponsored by:		Netflix
2024-05-19 22:05:40 -06:00
Zhenlei Huang 68c890b443 linux(4): Add const qualifier to the value parameter of function handle_string()
The content that `value` point to is not going to be altered by function
handle_string().

MFC after:	1 week
2024-05-20 12:02:33 +08:00
Zhenlei Huang 92f2a4c820 compat_freebsd4: Add const qualifier to the local variable s inside function freebsd4_uname()
This local variable s is for iterating characters of global variable
`version`. The content of `version` is not going to be altered by
function freebsd4_uname().

MFC after:	1 week
2024-05-20 12:02:32 +08:00
Konstantin Belousov 6cba29c09a acpidump IVRS table format: change 'IOMMUId' into 'IOMMU DeviceId'
and apply the consistent format for device ids used in other IVRS
elements.  The field seems to be the PCI Device ID of the IOMMU itself,
instead of an abstract unit ID.

Sponsored by:	Advanced Micro Devices (AMD)
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2024-05-20 02:04:45 +03:00
Alan Cox 4f77144279 arm64 pmap: eliminate a redundant variable
Moreover, if we attempt an L2 promotion on the kernel pmap from
pmap_enter_quick_locked(), this change eliminates the recomputation of
the L2 entry's address.

MFC after:	1 week
2024-05-19 14:33:19 -05:00
Alan Somers 3cc1b35bc1 vfs_getopt(9): fix typo
[skip ci]

Reported by:	Claudiu <mscotty@protomail.ch>
MFC after:	2 weeks
2024-05-19 09:49:03 -06:00
Mariusz Zaborski 838d5ae6d8 geli: fix indentation
no functional changes
2024-05-19 15:37:07 +02:00
Mariusz Zaborski 4b3141f5d5 geli: allocate a UMA pool earlier
The functions g_eli_init_uma and g_eli_fini_uma are used to trace
the number of devices in GELI. There is an issue where the g_eli_create
function may fail before g_eli_init_uma is called, however
g_eli_fini_uma is still executed in the fail path. This can
incorrectly decrease the device count to zero, potentially leading to
the UMA pool being freed. Accessing the device after the pool has been
freed causes a system panic.

This commit resolves the issue by ensuring devices count is increassed
eariler.

PR:		278828
Reported by:	Andre Albsmeier <mail@fbsd2.e4m.org>
Reviewed by:	asomers
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D45225
2024-05-19 14:53:17 +02:00
Konstantin Belousov ff4480baf6 nfs client comment typo fix
Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
2024-05-19 01:49:59 +03:00
Alan Somers 3bb5428ad6 rc.conf.5: remove obsolete advice about kld_list
Loading modules via kld_list is no longer substantially faster than via
loader.conf.

[skip ci]

MFC after:	2 weeks
Reviewed by:	imp
Differential Revision: https://reviews.freebsd.org/D45242
2024-05-18 09:51:15 -06:00
Randall Stewart ea916b6412 Remove TCP_SAD optional code now that the sack filter performs this function.
With the commit of D44903 we no longer need the SAD option. Instead all stacks that
use the sack filter inherit its protection against sack-attack.

Reviewed by: tuexen@
 Differential Revision:https://reviews.freebsd.org/D45216
2024-05-18 10:57:04 -04:00
Warner Losh 97aedd3395 devctl: Disable the boottime optimization of suppressing NOMATCH
The usb bus code (uhub) doens't present the same information to devctl
as it does to the NOMATCH events it generats. As such, devmatch fails to
find USB devices on boot when NOMATCH events are optimized out. Since
the savings of boot time is relatively trivial for all but the most
demanding boot environments, disable it by default until this issue is
fixed.

Fixes: 6437872c1d
MFC After: 1 minute
Sponsored by:		Netflix
2024-05-18 07:07:16 -06:00
Ed Maste fb623aab39 diff: honour -B flag with -q
PR:		278988
Reviewed by:	bapt
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D45220
2024-05-17 20:03:56 -04:00
Navdeep Parhar 64a00f877f cxgbe(4): Consolidate all mk_set_tcb_field_ulp in one place.
MFC after:      1 week
Sponsored by:   Chelsio Communications
2024-05-17 15:52:33 -07:00
Navdeep Parhar cca3506dc1 cxgbe(4): sc->port is indexed by port_id and not tx_chan.
MFC after:	1 week
Sponsored by:	Chelsio Communications
2024-05-17 15:42:23 -07:00
Brooks Davis 61ad1ddc5a Improve broken-on-gcc checks
Mark powerpc* and riscv broken.

Refactor and add a TRY_GCC_BROKEN option to build anyway.  This
simplifies things for people trying to get gcc builds working
while letting other developers know that they aren't expected to work.

Reviewed by:	jhb, emaste
Improves:	4c0dfd5959 arm: fail early on gcc builds
Differential Revision:	https://reviews.freebsd.org/D45230
2024-05-17 21:50:57 +01:00
Brooks Davis 1062db3070 libcxxrt: allow build with gcc13 and --no-undefined-version
GCC 13 supports _Float16 and __int128 on fewer architectures than clang
and thus libcxxrt compiled with gcc13 is sometimes missing related
symbols.  Hack around this by explicitly appending --undefined-version
to LDFLAGS in problematic cases.

Reviewed by:	theraven, dim
Differential Revision:	https://reviews.freebsd.org/D45233
2024-05-17 21:50:57 +01:00
Pierre Pronchery f7d45c5443 bhyve: avoid side effect in assertion
An assert() was setting the error variable instead of checking it.

Reported by:	Coverity Scan
CID:		1521431
Reviewed by:	jhb
Sponsored by:	The FreeBSD Foundation
Pull Request:	https://github.com/freebsd/freebsd-src/pull/1244
2024-05-17 15:45:18 -04:00
Brooks Davis 25db7bd2fa libgcc_s: fix nonsense defines
These symbols are present on amd64 or i386.

Reported by:	kaktus, jhibbits
Fixes:		98c8caafff libgcc_s: 80-bit long double function are x86-only
2024-05-17 20:05:36 +01:00
Marko Zec 42b3c16e30 fib_dxr: code hygiene, prune old code, no functional changes
The !DXR2 code corresponds to the original DXR encoding proposal from
2012 with a single direct-lookup stage, which is inferior to the more
recent (DXR2) variant with two-stage trie both in terms of memory
footprint of the lookup structures, and in terms of overall lookup
througput.

I'm axing the old code chunks to (hopefully) somewhat improve readability,
as well as to simplify future maintenance and updates.

MFC after:	1 week
2024-05-17 18:57:25 +02:00
Marko Zec 19bd24caa4 fib_dxr: do not leak memory if FIB constellation hits structural limit
DXR lookup table encoding has an inherent structural limit on the amount
of binary search ranges it can accomodate.  With the current IPv4 BGP views
(circa 1 M prefixes) and default DXR encoding we are only at around 5% of
that limit, so far, far away from hitting it.  Just in case it ever gets
hit, make sure we free the allocated structures, instead of leaking it.

MFC after:	1 week
2024-05-17 18:46:41 +02:00
Pierre Pronchery e9806d2128 bhyve: avoid resource leak in error path
In e820_finalize(), the e820_fwcfg_item variable, containing the
etc/e820 file (for the e820 table from the BIOS) is not free()'d when it
could not be added to the QEMU firmware configuration device (fw_cfg).

Reported by:	Coverity Scan
CID:		1522761
Reviewed by:	corvink, jhb
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D45223
2024-05-17 12:26:27 -04:00
Marko Zec 4ab122e8ef fib_dxr: check if cached fib_data matches the new request in dxr_init()
When calling dxr_init(), the FIB_ALGO infrastructure may provide a
pointer to a previous dxr instance, which permits reuse of auxiliary
dxr structures, i.e. incremental lookup structure updates.  For dxr this
is a crucial feature provided by FIB_ALGO, since dxr incremental updates
are typically several orders of magnitude faster than full lookup table
rebuilds.

However, the auxiliary dxr structure caches a pointer to struct fib_data and
relies upon it for performing incremental updates.  Apparently, incremental
rebuild requests from FIB_ALGO, i.e. a calls to dxr_init() with a pointer
old_data set, may (under not yet fully understood circumstances) be invoked
within a different fib_data context than the one cached in the previous
version of dxr auxiliary structures.  In such (rare) events, we ignore the
offered old dxr context, and proceed with a full lookup structure rebuild
instead of attempting an incremental one using a fib_data context which
may or may not no longer be valid, and thus lead to a system crash.

PR:		278422
MFC after:	1 week
2024-05-17 18:21:54 +02:00
Andrew Turner 457fa0f69c arm64: Support break and watch points in VHE
When booting the kernel with VHE it will be running at EL2. The current
config register values only enable the reaces at EL1 when tracing the
kernel.

Set the HMC flag to also trap from EL2.

Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D45121
2024-05-17 16:07:16 +00:00
Andrew Turner e72c417723 arm: Use the correct irq when in the hypervisor
When booting in the hypervisor state we need to use the hypervisor
interrupt in the generic timer. In this case the registers we access
in the kernel are remapped to the EL2 versions, however this causes
an unexpected interrupt to trigger.

Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D43975
2024-05-17 16:07:16 +00:00
Andrew Turner f715e95461 arm: Add a missing interrupt to the generic timer
The ACPI generic timer attachment added 3 interrupts, but missed the
hypervisor physical interrupt. As the field is present in all versions
of the GTDT ACPI table and isn't an optional interrupts we can add it
to the interrupts provided to the driver.

Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D43974
2024-05-17 16:07:15 +00:00
Andrew Turner 097bd33dd7 uart: DBG2 support to find the debug uart
The Debug Port Table 2 (DBG2) contains information on which devices
can be used for debugging purposes.

Add support to the uart driver to use the DBG2 table when enabled from
loader.

Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D44359
2024-05-17 16:07:15 +00:00
Brooks Davis d316de24fa zfs: Avoid a gcc -Wint-to-pointer-cast warning
On 32-bit platforms long long is generally 64-bits.  Sufficiently modern
versions of gcc (13 in my testing) complains when casting a pointer to
an integer of a different width so cast to uintptr_t first to avoid the
warning.

Fix i386 gcc builds while we wait for this to be merged to OpenZFS.

Sponsored by:	DARPA, AFRL
Pull Request:	https://github.com/openzfs/zfs/pull/16203
2024-05-17 17:01:19 +01:00
Brooks Davis 4c0dfd5959 arm: fail early on gcc builds
Since at least 2022 (see https://reviews.freebsd.org/D36754), it has
not been possible to build armv6/armv7 with gcc due to atomics macros
gcc doesn't like.  Prevent developers doing due diligance from wasting
time and CPU cycles on this combination as it just fails to build in
libc.

Reviewed by:	imp, andrew
Differential Revision:	https://reviews.freebsd.org/D45193
2024-05-17 17:01:19 +01:00
Brooks Davis 16d8dfde0c aarch64: disable LIB32 with gcc
gcc doesn't have -m32 support on aarch64 so mark LIB32 broken there.

We have to check both COMPILER_TYPE and X_COMPILER_TYPE becuase
X_COMPILER_TYPE is only conditionally set and COMPILER_TYPE is the host
compiler in Makefile.inc1.

Reviewed by:	emaste
Differential Revision:	https://reviews.freebsd.org/D45089
2024-05-17 17:01:18 +01:00
Zachary Leaf 4f8ba1c9dd arm64: add CONTEXTIDR_EL1 reg
CONTEXTIDR_EL1 is used in debug and trace features to identify the
current process or context.

Reviewed by:	andrew
Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D45173
2024-05-17 15:46:27 +01:00
Zachary Leaf 10b3eac88d arm64: add PMBSR_MSS_{BSC,FSC} status code field
Bits [5:0] of PMBSR_MSS encodes either Buffer Status Code (BSC) or Fault
Status Code (FSC) depending on PMBSR_EC value.

Add PMBSR_MSS_{BSC,FSC} to cover this field.

Reviewed by:	andrew
Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D45172
2024-05-17 15:46:00 +01:00