powerpc: Define the sub-word atomic load and store directly
All currently supported powerpc CPUs handle single-copy atomicity for
any size up to the native word size, so load and store operations are
guaranteed for sub-word size that are naturally aligned.
powerpc64: Don't ignore lookup errors in kernel linker
If a lookup fails for a R_PPC_JMP_SLOT (PLT relocation) ignoring errors
results in an address of 0 gets written into the jump slot, leading to a
NULL pointer jump when attempting to call the function it points to.
Fix this with proper error checking so that a module will fail to load
instead of crashing later on.
camcontrol: Fix -Wcast-align errors in the NVMe reservation report
Casting the byte buffer that holds the Reservation Report payload to
the status structures trips -Wcast-align on strict-alignment
architectures, which broke the CI builds there. Put the buffer in a
union with the two status structures instead, so it is properly
aligned and no casts are needed.
Reported by: FreeBSD CI
Fixes: ba75cf05727e ("camcontrol: Support NVMe reservations via the persist subcommand")
Co-authored-by: Claude Fable 5 <noreply at anthropic.com>
MFC after: 1 week
Sponsored by: Spectra Logic
msun: fix behaviour of nextafter*() and nexttoward*() for MAX value
For an edge case at an extreme, e.g., nextafter(-DBL_MAX,-INFINITY)
do not return x+x. Instead, evaluate x+x and assign it to a volatile
to raise an exception, and then fall through to return the correct
result in current rounding mode.
Approved by: re (cperciva)
PR: 299389
MFC after: 6 days (for inclusion into releng/15.2)
(cherry picked from commit 1fb5d8265bc4bbbf1f5bc79cc1d2a7f280b446b2)
(cherry picked from commit 42f926513b74cbac09d4d63a9daf8cb489078671)
contrib/bc: remove vs sub-directory
Some of the files in the vs sub-directory are checked out with CRLF
line breaks via .getattributes. This causes issues when checking out
the source tree with other tools that operate on Git repositories like
"got". Remove the vs sub-directory from the contrib tree, since it is
not required on FreeBSD.
Approved by: re (cperciva)
(cherry picked from commit 94d4ba04a96f495d635bf246e4d5021eb1faab22)
(cherry picked from commit 5b5f93f12e3683b3ba7d2d600384bb5c4ed6e91a)
camdd: Fix the worker startup race
The reader can hand off its first buffer before the writer sets
CAMDD_DEV_FLAG_ACTIVE. camdd_queue_peer_buf() then mistakes the writer
for an exited peer and releases the buffer instead of queueing it. This
can make a copy fail with bytes read but nothing written, without an
error message.
Mark both devices active before creating either worker, leaving the
workers to clear the flag on exit. The work queues and EVFILT_USER
events are already initialized, so queued buffers and their notification
can wait for the writer to start without a startup barrier.
Treat pthread_create() failure as fatal. Returning through the normal
cleanup path can free devices that an already-started worker is still
using, and an unstarted peer cannot consume any queued buffers.
Reviewed by: imp, markj, ken
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D61277
camcontrol: Add a feature subcommand for NVMe Get/Set Features
Add a feature subcommand for the NVMe Get Features and Set Features
commands:
camcontrol feature ndaX -a <get|set> -f feature [-d data]
[-s num] [-U]
There is no transport-specific prefix in the name: SCSI has no
feature command (the closest equivalents are mode pages), and the
ATA SET FEATURES subcommands are already exposed through dedicated
camcontrol subcommands (apm, aam, epc and the power commands), so
the name is unclaimed. The subcommand returns an error for
non-NVMe devices.
Currently, only the hostid feature is fully implemented. The
hostid value for set is specified with -d as a UUID or an integer
in decimal, hex, or octal, and -U outputs the hostid as a UUID on
get.
[36 lines not shown]
camcontrol: Support NVMe namespace formatting via the format subcommand
Support formatting NVMe namespaces through the existing format
subcommand. The format subcommand now dispatches on the device
protocol, in the same way the identify and persist subcommands do,
and issues the NVMe FORMAT NVM command for NVMe devices.
The SCSI syntax and behavior are unchanged. The NVMe-specific
options are -e (secure erase setting), -G (format all namespaces),
-f (LBA format), -l (protection information location), -m (metadata
setting) and -p (protection information type). The -q and -y options
work for both protocols; NVMe formats gain the same confirmation
question that SCSI formats have always had. The -r and -w options
are SCSI only; -r returns an error for NVMe devices and -w has no
effect, since the NVMe format command does not complete until the
format is finished.
The default timeout for NVMe is 30 seconds for a cryptographic erase
and 30 minutes otherwise; the generic -t option overrides it.
[23 lines not shown]
camcontrol: Add support for NVMe namespace Identify
Add a -N argument to camcontrol identify. This will fetch and
display namespace Identify data for NVMe drives, using
nvme_print_namespace() from nvmecontrol(8).
This gets the namespace Identify data via XPT_DEV_ADVINFO (i.e.
data cached in the kernel) like the standard NVMe identify command
does, and so works even on NVMe devices that do not support NVMe
Namespace Management.
sbin/camcontrol/camcontrol.c:
Add a -N argument to camcontrol identify.
Rename nvme_get_cdata() to nvme_get_data(), and give it the
ability to fetch controller or namespace Identify data.
While here, improve its error reporting with
cam_error_print(), and only look at the CAM status bits of
the returned CCB.
[22 lines not shown]
camcontrol: Support NVMe reservations via the persist subcommand
The NVMe reservation model is closely patterned after SCSI Persistent
Reservations, so support NVMe devices through the existing persist
subcommand rather than adding a transport-specific subcommand. The
persist subcommand now dispatches on the device protocol, in the same
way the identify subcommand does.
The SCSI syntax is unchanged. For NVMe devices, the -i modes all map
to the Reservation Report command (read_full_status requests the
extended data structure, which contains 128-bit Host Identifiers), and
the -o service actions map to the corresponding NVMe reservation
operations: register, register_ignore, reserve, preempt,
preempt_abort, release and clear, plus two NVMe-only actions,
unregister and replace. The reservation type names for -T are shared
between SCSI and NVMe. A new -c option gives explicit control over
the NVMe Persist Through Power Loss State; -p is equivalent to
-c enable. SCSI-only options return an error for NVMe devices.
[32 lines not shown]
cam: Add NVMe reservation, format and features CCB building functions
Add NVMe CCB (union ccb / struct ccb_nvmeio) building functions for
the four NVMe reservation opcodes, Format NVM, and Get Features /
Set Features. These use the nvme_command building blocks added to
sys/dev/nvme/nvme.h, and are used by the new camcontrol(8) nvres,
nvformat and nvfeature subcommands that will be added separately.
sys/cam/nvme/nvme_all.c:
Add NVMe CCB building functions for the four NVMe reservation
opcodes: nvme_resv_report(), nvme_resv_register(),
nvme_resv_acquire() and nvme_resv_release(). Data direction
is set internally (CAM_DIR_IN or CAM_DIR_OUT as appropriate),
so no flags parameter is needed.
Add a new nvme_format() CCB building function.
Add nvme_get_feature() and nvme_set_feature() CCB building
functions, along with nvme_get_feature_hostid() and
[16 lines not shown]
nvme: Add reservation, format and features command building support
Add command (struct nvme_command) building functions for the four
NVMe reservation opcodes (Report, Register, Acquire and Release),
Format NVM, and Get Features / Set Features, along with the
enumerations and data structures that go with them. These are
shared between the kernel and userland, and are the underpinnings
for new camcontrol(8) subcommands (nvres, nvformat, nvfeature) that
will be added separately.
The reservation type names are intentionally similar to the SCSI
names for the same reservation types.
sys/dev/nvme/nvme.h:
Add NVMe command building functions for the four NVMe
reservation opcodes: nvme_ns_resv_report_cmd(),
nvme_ns_resv_register_cmd(), nvme_ns_resv_acquire_cmd() and
nvme_ns_resv_release_cmd().
[68 lines not shown]
nvmecontrol: Factor out namespace Identify printing
Move print_namespace() from identify.c to identify_ext.c and rename
it to nvme_print_namespace(), to match nvme_print_controller().
This allows other consumers (notably camcontrol(8)) to print NVMe
namespace Identify data.
No functional changes intended.
sbin/nvmecontrol/identify.c:
Remove print_namespace(), and call nvme_print_namespace()
instead.
sbin/nvmecontrol/identify_ext.c:
Add nvme_print_namespace(), moved here from identify.c.
sbin/nvmecontrol/nvmecontrol.h:
Remove the print_namespace() prototype.
[12 lines not shown]
libthr: require both _Unwind_ForcedUnwind and _Unwind_GetCFA for !PIC
Static linking must bring in both symbols for the unwind to work.
The landing pads added by 2734bbbcba3c reference _Unwind_Resume and
__gcc_personality_v0. In a static link, these pull UnwindLevel1.o
from libgcc_eh.a, which also defines _Unwind_ForcedUnwind, but
not UnwindLevel1-gcc-ext.o, which defines _Unwind_GetCFA. Unless
something else pulls that object in, as libcxxrt does for C++ programs,
thread_unwind_stop() calls a NULL _Unwind_GetCFA on every thread exit.
Reported and tested by: dch
Fixes: 2734bbbcba3c ("libthr: Create landing pad in thr_once in C++ exception")
Sponsored by: The FreeBSD Foundation
ports.7: Add the DEVELOPER make variable
make.conf(5) says make variables that are for the ports tree should
be documented in ports(7). Add this from the porters handbook.
MFC after: 3 days
Reviewed by: alven
Event: FreeBSD 2026 Vendor Summit
Differential Revision: https://reviews.freebsd.org/D61272
contrib/bc: remove vs sub-directory
Some of the files in the vs sub-directory are checked out with CRLF
line breaks via .getattributes. This causes issues when checking out
the source tree with other tools that operate on Git repositories like
"got". Remove the vs sub-directory from the contrib tree, since it is
not required on FreeBSD.
(cherry picked from commit 94d4ba04a96f495d635bf246e4d5021eb1faab22)
iSCSI: Fast and per-session timeouts
Support per-session configurable ping (SCSI NOP) and login timeouts
similar to what is supported in the Linux iSCSI initiator configuration file.
Reduce iscsi timer granularity to 0.1 sec.
For backwards compatibility, when all timers are selected on integer numbers,
all status messages are unchanged. If the higher granularity is used, the
log messages include sub-second granularity.
The sysctl(3) interface has changed from pure int to string, in order to
support fractional seconds in a human-readable, dotted notation.
Reviewed By: #netapp, #manpages, jhb, pauamma_chezdork.com, siderop1_netapp.com
Sponsored by: NetApp, Inc.
Differential Revision: https://reviews.freebsd.org/D32540
openssl: restore removed libcrypto symbols as compat symbols
c01c0a27cb82 (D60397) stopped exporting 52 names from libcrypto.so.35 that
upstream does not export. Binaries and libraries linked against the
earlier libcrypto.so.35 can still import them; the libssl.so.35 from
15.0 and 15.1 imports 15 of them, so it fails to load with the new
libcrypto.
Provide all 52 again as non-default (compat) versions, in the version
nodes they had before: OPENSSL_cpuid_setup at OPENSSL_3_0_9, the others
@OPENSSL_3_5_0. Existing consumers resolve them; new links cannot bind
to them. The default exports do not change and still match upstream.
The wrappers live in a new FreeBSD-only file, compat.c. Remove it at
the next SHLIB_MAJOR bump.
Reviewed by: ngie
Fixes: c01c0a27cb82 ("openssl: make libcrypto export the same symbols as upstream")
MFC after: 2 weeks
[3 lines not shown]
openssl: build legacy provider as upstream does
- Build with libcrypto's compile flags: modules/Makefile.inc now
includes libcrypto's Makefile.inc, which brings in Makefile.common
(NDEBUG, the asm dispatch defines, OPENSSL_PIC, the directory
defines). Before this change, assertions were enabled in legacy.so.
- Use upstream's per-architecture source list: the provider's own CPU
capability code (cpuid asm and armcap.c/ppccap.c, or mem_clr.c
without asm), and the MD5, RC4 and DES asm where upstream uses it.
The provider no longer uses libcrypto's exported RC4, SHA1 and
CRYPTO_*128 functions.
- Drop the objects that upstream's linker leaves out of legacy.so
(fcrypt_b.c, md5_one.c, md5_sha1.c, provider_err.c and
ciphercommon_{ccm,gcm}*.c / ciphercommon_hw.c). Without them,
params_idx.c is not needed either.
- Add a version script, a copy of upstream's providers/legacy.ld, so
that only OSSL_provider_init is exported. Around 209 symbols were
exported before.
[5 lines not shown]
ctfconvert: Make the absence of debug info non-fatal
When compiled with gcc14, subr_ticks.o legitimately doesn't contain any
DWARF sections. Just emit a warning in this case. In general we still
want to run ctfconvert on asm files.
Reviewed by: emaste, des
Fixes: e959f2a7d8a8 ("ctf*: exit with error upon terminate()")
Differential Revision: https://reviews.freebsd.org/D61231
amd64/vmm: Don't advertise AMD PerfMonV2 or performance counters
vmm does not handle CPUID leaf 0x80000022, so a FreeBSD guest on a
Family 19h or later host panics on "kldload hwpmc", which trusts the
PerfMonV2 bit and writes AMD_PMC_GLOBAL_CTL.
Tested by: Osvaldo Janeri Filho <ojanerif at amd.com>
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Reviewed by: markj, kib
Differential Revision: https://reviews.freebsd.org/D61141
hwpmc: Decline the AMD PerfMonV2 path when GLOBAL_CTL is absent
The v2 path writes AMD_PMC_GLOBAL_CTL whenever the PerfMonV2 CPUID bit
is set. bhyve passes that bit through from the host but does not emulate
the register, so loading hwpmc in a guest on a Family 19h or later host
panics the kernel.
amd_v2_hwcheck_cpu() already probes EVSEL MSRs, so probe GLOBAL_CTL
there too, in order to reject the v2 path and fall back to the generic
CPU class.
Fixes: 9d3064010590 ("hwpmc_amd: add PerfMonV2 global-control path")
Tested by: Osvaldo Janeri Filho <ojanerif at amd.com>
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Reviewed by: mhorne, afscoelho at gmail.com
Differential Revision: https://reviews.freebsd.org/D61133
inetd: use snprintf() in inetd_setproctitle()
inetd_setproctitle() formats se_service (the service name taken verbatim
from inetd.conf) and the peer address into an 80-byte buffer with
sprintf(). A long service name can overflow it. Bound both calls with
snprintf().
MFC after: 1 week
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D60879
(cherry picked from commit 9ab2bf0f4296e8bfafe4dc70f2f200265e6933bd)
vm_glue: Use the right type for size arguments to {user,kern}acc()
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
(cherry picked from commit c525db0c44b7db430b67fdd276f0a22c2f8e9f61)