]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
6 months agotarg: Handle errors from suword()
Mark Johnston [Thu, 4 Jan 2024 13:34:31 +0000 (08:34 -0500)]
targ: Handle errors from suword()

In targstart() we are already handling an error and have no go way to
signal the failure to upper layers, so ignore the return value of
suword() there.

This is in preparation for annotating copyin() and related functions
with __result_use_check.

MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D43202

6 months agostats: Check for errors from copyout()
Mark Johnston [Thu, 4 Jan 2024 13:33:58 +0000 (08:33 -0500)]
stats: Check for errors from copyout()

This is in preparation for annotating copyin() and related functions
with __result_use_check.

MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D43179

6 months agosysctl: Don't pass CTLFLAG_MPSAFE to SYSCTL_STRING
Mark Johnston [Thu, 4 Jan 2024 13:33:05 +0000 (08:33 -0500)]
sysctl: Don't pass CTLFLAG_MPSAFE to SYSCTL_STRING

It is redundant.  No functional change intended.

MFC after: 1 week

6 months agoidentcpu: Let the hw.model be readable in capability mode
Mark Johnston [Thu, 4 Jan 2024 13:26:53 +0000 (08:26 -0500)]
identcpu: Let the hw.model be readable in capability mode

On some platforms this static information can be derived directly from
the CPU, and there doesn't seem much use in restricting it.

Reviewed by: emaste, imp, kib
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D43281

6 months agolinprocfs: Avoid using a sysctl to get the CPU model string
Mark Johnston [Thu, 4 Jan 2024 13:25:05 +0000 (08:25 -0500)]
linprocfs: Avoid using a sysctl to get the CPU model string

This will fail if the reading process is in capability mode.  Just copy
the string directly.

PR: 276043
Reviewed by: emaste, imp, kib
Reported and tested by: Ricardo Branco <rbranco@suse.com>
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D43281

6 months agox86: Make cpu_model[] public
Mark Johnston [Thu, 4 Jan 2024 13:24:04 +0000 (08:24 -0500)]
x86: Make cpu_model[] public

No functional change intended.

Reviewed by: emaste, imp, kib
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D43281

6 months agofile: Remove the fd parameter to fgetvp_lookup() and fgetvp_lookup_smr()
Mark Johnston [Thu, 4 Jan 2024 13:11:54 +0000 (08:11 -0500)]
file: Remove the fd parameter to fgetvp_lookup() and fgetvp_lookup_smr()

The fd is always obtained from nameidata, so just fetch it from there
instead.  No functional change intended.

Reviewed by: kib
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D43257

6 months agovfs: Simplify vrefact()
Mark Johnston [Thu, 4 Jan 2024 13:11:44 +0000 (08:11 -0500)]
vfs: Simplify vrefact()

refcount_acquire() returns the old value, just use that.  No functional
change intended.

Reviewed by: kib
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D43255

6 months agofrag6: Add another use of frag6_rmqueue()
Mark Johnston [Thu, 4 Jan 2024 13:11:19 +0000 (08:11 -0500)]
frag6: Add another use of frag6_rmqueue()

No functional change intended.

Reviewed by: kp, bz
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D43256

6 months agosys/conf: Add backlight as a dependency to pwm_backlight.c
Oskar Holmlund [Thu, 4 Jan 2024 13:33:13 +0000 (14:33 +0100)]
sys/conf: Add backlight as a dependency to pwm_backlight.c

Approved by: manu
Differential revision: https://reviews.freebsd.org/D43312

6 months agolibthr: thr_attr.c: EINVAL, not ENOTSUP, on invalid arguments
Olivier Certner [Fri, 24 Nov 2023 21:21:16 +0000 (22:21 +0100)]
libthr: thr_attr.c: EINVAL, not ENOTSUP, on invalid arguments

On first read, POSIX may seem ambiguous about the return code for some
scheduling-related pthread functions on invalid arguments.  But a more
thorough reading and a bit of standards archeology strongly suggests
that this case should be handled by EINVAL and that ENOTSUP is reserved
for implementations providing only part of the functionality required by
the POSIX option POSIX_PRIORITY_SCHEDULING (e.g., if an implementation
doesn't support SCHED_FIFO, it should return ENOTSUP on a call to, e.g.,
sched_setscheduler() with 'policy' SCHED_FIFO).

This reading is supported by the second sentence of the very definition
of ENOTSUP, as worded in CAE/XSI Issue 5 and POSIX Issue 6: "The
implementation does not support this feature of the Realtime Feature
Group.", and the fact that an additional ENOTSUP case was added to
pthread_setschedparam() in Issue 6, which introduces SCHED_SPORADIC,
saying that pthread_setschedparam() may return it when attempting to
dynamically switch to SCHED_SPORADIC on systems that doesn't support
that.

glibc, illumos and NetBSD also support that reading by always returning
EINVAL, and OpenBSD as well, since it always returns EINVAL but the
corresponding code has a comment suggesting returning ENOTSUP for
SCHED_FIFO and SCHED_RR, which it effectively doesn't support.

Additionally, always returning EINVAL fixes inconsistencies where EINVAL
would be returned on some out-of-range values and ENOTSUP on others.

Reviewed by:            markj
Approved by:            markj (mentor)
MFC after:              2 weeks
Sponsored by:           The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D43006

6 months agolibthr: thr_attr.c: Clarity, whitespace and style
Olivier Certner [Fri, 24 Nov 2023 16:00:53 +0000 (17:00 +0100)]
libthr: thr_attr.c: Clarity, whitespace and style

Also, remove most comments, which don't add value.

Reviewed by:            emaste
Approved by:            markj (mentor)
MFC after:              2 weeks
Sponsored by:           The FreeBSD Foundation
Differential Revision:  https://reviews.freebsd.org/D43005

6 months agoSetups with digital audio connections like SPDIF and ADAT require
Ruslan Bukin [Thu, 4 Jan 2024 09:35:00 +0000 (09:35 +0000)]
Setups with digital audio connections like SPDIF and ADAT require
a designated master clock to stay in sync. Add a sysctl setting
to control the preferred clock source for each HDSPe sound card.
Complement this by sysctl values to list available clock sources,
show the currently effective clock source and display the sync
status of all connections. Clock sources are named according to
RME user manuals.

Submitted by: Florian Walpen <dev@submerge.ch>
Differential Revision: https://reviews.freebsd.org/D43252

6 months agotail: Do not trust st_size if it equals zero.
Ricardo Branco [Wed, 3 Jan 2024 20:32:47 +0000 (21:32 +0100)]
tail: Do not trust st_size if it equals zero.

PR: bin/276107
MFC after: 1 week

6 months agohexdump: Do not trust st_size if it equals zero.
Ricardo Branco [Wed, 3 Jan 2024 20:17:58 +0000 (21:17 +0100)]
hexdump: Do not trust st_size if it equals zero.

Fix for hexdump -s not being able to skip files residing in
pseudo-filesystems that advertise a zero size value.

Historically, many pseudofs-based filesystems (e.g., procfs) report
a va_size of 0 for numerous files classified as regular files.
Typically, the contents of these files are generated on demand
from kernel data as sbuf(9) strings at the time they are read.
Accurately reporting the size of these files is challenging, as it
often involves generating their contents. These pseudofs implementations
frequently report the size as 0. This is a historical behavior and also
aligns with Linux behavior. To maintain compatibility, we have chosen
to preserve the existing behavior and address it in the userland
application, rather than modifying it in the kernel (by updating the
correct value for va_size).

PR: bin/276106
MFC after: 1 week

6 months agobhyveload: fix non -l use
Kyle Evans [Thu, 4 Jan 2024 01:36:06 +0000 (19:36 -0600)]
bhyveload: fix non -l use

explicit_loader_fd should have been initialized to -1, not 0, but my
last round of testing was only with -l...

Fixes: bf7c4fcbbb ("bhyveload: hold /boot and do relative [...]")
Pointy hat: kevans

6 months agobhyveload: enter capability mode after we setup the vcpu
Kyle Evans [Wed, 3 Jan 2024 22:18:00 +0000 (16:18 -0600)]
bhyveload: enter capability mode after we setup the vcpu

Reviewed by: allanjude (earlier version), emaste, markj
Differential Revision: https://reviews.freebsd.org/D43286

6 months agobhyveload: hold /boot and do relative lookups for the loader
Kyle Evans [Wed, 3 Jan 2024 22:17:59 +0000 (16:17 -0600)]
bhyveload: hold /boot and do relative lookups for the loader

The next change will push bhyveload into capability mode right after we
allocate vcpu state, before we've setup or entered the loader, to limit
the surface area that a rogue loader script can touch.

With an explicit -l loader, we don't need to preopen /boot because
changing interpreters isn't allowed.  We'll just dlopen() entirely in
advance in that case to eliminate some complexity.

Reviewed by: allanjude (earlier version), markj
Differential Revision: https://reviews.freebsd.org/D43285

6 months agobhyveload: use a dirfd to support -h
Kyle Evans [Wed, 3 Jan 2024 22:17:59 +0000 (16:17 -0600)]
bhyveload: use a dirfd to support -h

Don't allow lookups from the loader scripts, which in rare cases may be
in guest control depending on the setup, to leave the specified host
root.  Open the root dir and strictly do RESOLVE_BENEATH lookups from
there.

cb_open() has been restructured a bit to work nicely with this, using
fdopendir() in the directory case and just using the fd we already
opened in the regular file case.

hostbase_open() was split out to provide an obvious place to apply
rights(4) if that's something we care to do.

Reviewed by: allanjude (earlier version), markj
Differential Revision: https://reviews.freebsd.org/D43284

6 months agosetfib.2: Consistently capitalize "FIB"
Mark Johnston [Wed, 3 Jan 2024 20:19:41 +0000 (15:19 -0500)]
setfib.2: Consistently capitalize "FIB"

MFC after: 1 week
Sponsored by: Klara, Inc.

6 months agocxgbe(4): Fix virtual interface reattach.
Navdeep Parhar [Tue, 2 Jan 2024 21:20:45 +0000 (13:20 -0800)]
cxgbe(4): Fix virtual interface reattach.

Replace the DOOMED flag with a transient DETACHING flag that is cleared
when VI is detached.  This fixes VI reattach when only the VI and not
the parent nexus is detached.  The old flag was never cleared and
prevented subsequent synch op's related to the VI.

PR: 275260
Reviewed by: jhb
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D43287
Sponsored by: Chelsio Communications

6 months agomake_check: Deobit fmake support
Warner Losh [Tue, 2 Jan 2024 16:47:10 +0000 (09:47 -0700)]
make_check: Deobit fmake support

We don't need make_check to work in a fmake world anymore (nor have we
in the past decade). Just remove it here.

Note in passing it's been 10 years since we've added a new test here and
maybe we're past the need for this part of the build (or need to revamp
it to include all the features added to bmake since 2016 that the build
system silently depends on).

Sponsored by: Netflix
Reviewed by: brooks
Pull Request: https://github.com/freebsd/freebsd-src/pull/980

6 months agosys.mk: Remove support for building with fmake on modern systems.
Warner Losh [Tue, 2 Jan 2024 16:43:44 +0000 (09:43 -0700)]
sys.mk: Remove support for building with fmake on modern systems.

We used to exclude a lot of extra hooks to allow for local
customizations of the build which couldn't be done outside of sys.mk,
but excluded that support for fmake. Remove those hacks.

Sponsored by: Netflix
Reviewed by: brooks
Pull Request: https://github.com/freebsd/freebsd-src/pull/980

6 months agobsd.port.mk: No need to support fmake anymore
Warner Losh [Tue, 2 Jan 2024 16:38:27 +0000 (09:38 -0700)]
bsd.port.mk: No need to support fmake anymore

There's no need to support fmake anymore. Always assume we can use
bmake's :tA modifier. The ports tree hasn't supported fmake in about a
decade anyway. Simplify here.

Sponsored by: Netflix
Reviewed by: brooks, emaste
Pull Request: https://github.com/freebsd/freebsd-src/pull/980

6 months agobsd.own.mk: Assume a modern make
Warner Losh [Tue, 2 Jan 2024 16:33:19 +0000 (09:33 -0700)]
bsd.own.mk: Assume a modern make

Commit 83cb5bae966d7 added a check for MAKE_VERSION being new enough to
handle CTFCONVERT_CMD being an empty string since fmake of the time
didn't support it until just a few commits before 83cb5bae966d7. Later,
it was augmented with a check for .PARSEDIR to see if bmake was
running. fmake and boostrapping from fmake haven't worked in maybe 6 or
8 years, so we can remove the check here. If you want to update from
your FreeBSD 7 or FreeBSD 8 systems, you're even more out of luck than
you were before and must jump to an older version before jumping to
current for the source upgrade path.

Sponsored by: Netflix
Reviewed by: brooks, emaste
Pull Request: https://github.com/freebsd/freebsd-src/pull/980

6 months agoMakefile: Deorbit fmake support
Warner Losh [Tue, 2 Jan 2024 16:17:21 +0000 (09:17 -0700)]
Makefile: Deorbit fmake support

fmake has been out of the tree for 10 years / 5 major releases now. The
need to bootstrap from it has been gone for at least 6 if not 8
years. While we may still need to bootstrap bmake, we don't need to do
it from fmake, so only retail the infrastructure to update from bmake to
bmake. Retain, for now, the WANT_MAKE_VERSION stuff, though we're always
up to date when building from supported and quasi-supported platforms.

Also remove all the checks to see if .PARSEDIR is defined. It is always
defined and was an early, fail-safe way to tell fmake from bmake during
the transition.

Adjust comments that refer to old fmake and remove those no longer
relevant.

Sponsored by: Netflix
Reviewed by: brooks
Pull Request: https://github.com/freebsd/freebsd-src/pull/980

6 months agobin/timeout: remove unreachable break after usage()
rilysh [Wed, 3 Jan 2024 19:03:52 +0000 (12:03 -0700)]
bin/timeout: remove unreachable break after usage()

Signed-off-by: rilysh <nightquick@proton.me>
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/872

6 months agobin/setfacl: remove unreachable break after usage()
rilysh [Wed, 3 Jan 2024 19:03:52 +0000 (12:03 -0700)]
bin/setfacl: remove unreachable break after usage()

Signed-off-by: rilysh <nightquick@proton.me>
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/872

6 months agobin/cp: remove unreachable break
rilysh [Wed, 3 Jan 2024 19:03:51 +0000 (12:03 -0700)]
bin/cp: remove unreachable break

Signed-off-by: rilysh <nightquick@proton.me>
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/872

6 months agocapsicum(4): add cross-ref to capsicum_helpers(3)
Ed Maste [Wed, 3 Jan 2024 18:31:55 +0000 (13:31 -0500)]
capsicum(4): add cross-ref to capsicum_helpers(3)

Sponsored by: The FreeBSD Foundation

6 months agotraceroute: Implement ECN bleaching detection
Jose Luis Duran [Sat, 28 Oct 2023 00:28:52 +0000 (00:28 +0000)]
traceroute: Implement ECN bleaching detection

Explicit Congestion Notification (ECN) is a mechanism that allows
end-to-end notification of network congestion without dropping packets
by explicitly setting the ECN code point (2 bits).

Per RFC 8087, section 3.5, network devices should not be configured to
change the ECN code point in the packets that they forward, except to
set the CE (Congestion Experienced) code point ('11') to signal
incipient congestion.

The current commit adds an -E flag to traceroute that crafts a packet
with an ECT(1) code point ('01').

If the packet is received back with a zero ECN code point ('00'), it
outputs that the hop in question erases or "bleaches" the ECN code point
values.  Bleaching may occur for various reasons (including normalizing
packets to hide which equipment supports ECN).  This policy prevents the
use of ECN by applications.

If the packet is received back with an all-ones ECN code point ('11'),
it outputs that the hop in question is experiencing "congestion".

If the packet is received back with a different ECN code point ('10'),
it outputs that the hop in question changes or "mangles" the ECN code
point values.

If the packet is received with the same ECN code point that was sent
('01'), it outputs that the hop has "passed" the ECN bits appropriately.

Inspired by: Darwin
Reviewed by: imp, markj
MFC after: 1 month
Pull Request: https://github.com/freebsd/freebsd-src/pull/879

6 months agotraceroute6: Implement ECN bleaching detection
Jose Luis Duran [Fri, 27 Oct 2023 23:59:28 +0000 (23:59 +0000)]
traceroute6: Implement ECN bleaching detection

Explicit Congestion Notification (ECN) is a mechanism that allows
end-to-end notification of network congestion without dropping packets
by explicitly setting the ECN code point (2 bits).

Per RFC 8087, section 3.5, network devices should not be configured to
change the ECN code point in the packets that they forward, except to
set the CE (Congestion Experienced) code point ('11') to signal
incipient congestion.

The current commit adds an -E flag to traceroute6 that crafts a packet
with an ECT(1) code point ('01').

If the packet is received back with a zero ECN code point ('00'), it
outputs that the hop in question erases or "bleaches" the ECN code point
values.  Bleaching may occur for various reasons (including normalizing
packets to hide which equipment supports ECN).  This policy prevents the
use of ECN by applications.

If the packet is received back with an all-ones ECN code point ('11'),
it outputs that the hop in question is experiencing "congestion".

If the packet is received back with a different ECN code point ('10'),
it outputs that the hop in question changes or "mangles" the ECN code
point values.

If the packet is received with the same ECN code point that was sent
('01'), it outputs that the hop has "passed" the ECN bits appropriately.

Inspired by: Darwin
Reviewed by: imp, markj
MFC after: 1 month
Pull Request: https://github.com/freebsd/freebsd-src/pull/879

6 months agonetinet: Define IPv6 ECN mask
Jose Luis Duran [Sat, 28 Oct 2023 02:50:18 +0000 (02:50 +0000)]
netinet: Define IPv6 ECN mask

Define a mask for the code point used for ECN in the Traffic Class field
(2 bits) of an IPv6 header.

     BE:    0       0       3       0       0       0       0       0
    Bit: 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
        +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
        |Version| Traffic Class |           Flow Label                  |
        +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
        |                              ...                              |

For BE (Big Endian), or network-byte order, this corresponds to 0x00300000.
For Little Endian, it corresponds to 0x00003000.

Reviewed by: imp, markj
MFC after: 1 week
Pull Request: https://github.com/freebsd/freebsd-src/pull/879

6 months agotraceroute: style(9) fixes
Jose Luis Duran [Sat, 28 Oct 2023 00:13:19 +0000 (00:13 +0000)]
traceroute: style(9) fixes

No functional change intended.

Reviewed by: imp, markj
MFC after: 1 week
Pull Request: https://github.com/freebsd/freebsd-src/pull/879

6 months agotraceroute6: style(9) fixes
Jose Luis Duran [Fri, 27 Oct 2023 23:53:44 +0000 (23:53 +0000)]
traceroute6: style(9) fixes

No functional change intended.

Reviewed by: imp, markj
MFC after: 1 week
Pull Request: https://github.com/freebsd/freebsd-src/pull/879

6 months agotraceroute: Remove the $FreeBSD$ pattern
Jose Luis Duran [Sat, 28 Oct 2023 00:20:22 +0000 (00:20 +0000)]
traceroute: Remove the $FreeBSD$ pattern

Reviewed by: imp, markj
MFC after: 1 week
Pull Request: https://github.com/freebsd/freebsd-src/pull/879

6 months agoposixshm largepage_mmap: fix a racy test
Brooks Davis [Wed, 3 Jan 2024 16:39:53 +0000 (16:39 +0000)]
posixshm largepage_mmap: fix a racy test

You can't ever safely map a single page and then map a superpage sized
mapping over it with MAP_FIXED.  Even in a single-threaded program, ASLR
might mean you land too close to another mapping and on CheriBSD we
don't allow the initial reservation to grow because doing so requires
program changes that are hard to automate.

To avoid this, map the entire region we want to use upfront.

Reviewed by: markj
Obtained from: CheriBSD
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D43282

6 months agoacl_equiv_mode_np: zero mode on just inited ACL
Brooks Davis [Wed, 3 Jan 2024 16:34:39 +0000 (16:34 +0000)]
acl_equiv_mode_np: zero mode on just inited ACL

You can't return 0 and not write the mode if mode_p is non-NULL.  That
violates the API contract and in common usage leaves stack trash in
*mode_p.

The acl_equiv_mode_test test passed by accident.

Reviewed by: kevans, markj
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D43278

6 months agocxgbe(4): Destroy the tick mutex during VI detach.
Navdeep Parhar [Wed, 27 Dec 2023 21:00:29 +0000 (13:00 -0800)]
cxgbe(4): Destroy the tick mutex during VI detach.

This avoids a mutex reinitialization when the VI is detached and
reattached.

Fixes: 516fe911a6b7 cxgbe(4): Always use the per-VI callout to read interface stats.
MFC after: 1 week
Sponsored by: Chelsio Communications

6 months agovm_page_reclaim_contig(): update comment to chase recent changes
Jason A. Harmening [Tue, 2 Jan 2024 21:33:59 +0000 (15:33 -0600)]
vm_page_reclaim_contig(): update comment to chase recent changes

Commit 2619c5ccfe ("Avoid waiting on physical allocations that can't
possibly be satisfied") changed the return value from bool to errno.
Adjust the function description to match reality.

6 months agoi386: Always bounce DMA requests above 4G for !PAE kernels
John Baldwin [Tue, 2 Jan 2024 21:15:13 +0000 (13:15 -0800)]
i386: Always bounce DMA requests above 4G for !PAE kernels

i386 kernels without 'options PAE' will still use PAE page tables if
the CPU supports PAE both to support larger amounts of RAM and for
PG_NX permissions.  However, to avoid changing the API, bus_addr_t and
related constants (e.g. BUS_SPACE_MAXADDR) are still limited to
32 bits.

To cope with this, the x86 bus_dma code included an extra check to
bounce requests for addresses above BUS_SPACE_MAXADDR.  This check was
elided (probably because it looks always-true on its face and had no
comment explaining its purpose) in recent refactoring.  To fix,
restore a custom address-validation function for i386 kernels without
options PAE that includes this check.

Reported by: ci.freebsd.org
Reviewed by: markj
Fixes: 3933ff56f9b6 busdma: tidy bus_dma_run_filter() functions
Differential Revision: https://reviews.freebsd.org/D43277

6 months agonetlink: remove stale comment
Gleb Smirnoff [Tue, 2 Jan 2024 21:09:37 +0000 (13:09 -0800)]
netlink: remove stale comment

Fixes: ff5ad900d2a0793659241eee96be53e6053b5081

6 months agonetlink: refactor control data generation for recvmsg(2)
Gleb Smirnoff [Tue, 2 Jan 2024 21:05:46 +0000 (13:05 -0800)]
netlink: refactor control data generation for recvmsg(2)

Netlink should return a very simple control data on every recvmsg(2)
syscall.  This data is associated with a syscall, not with an nlmsg,
neither with internal our internal representation (nl_bufs).  There is
no need to pre-allocate it in non-sleepable context and attach to
nl_buf.  Allocate right in the syscall with M_WAITOK.  This also
shaves lots of code and simplifies things.

Reviewed by: melifaro
Differential Revision: https://reviews.freebsd.org/D42989

6 months agonetlink: improve nl_soreceive()
Gleb Smirnoff [Tue, 2 Jan 2024 21:05:25 +0000 (13:05 -0800)]
netlink: improve nl_soreceive()

The previous commit conservatively mimiced operation of soreceive_generic().
The new code does two things:
- parses Netlink message headers and always returns at least one full nlmsg
- hides nl_buf boundaries from the userland, copying out several at once
More details can be found in the large comment block added.

Reviewed by: melifaro
Differential Revision: https://reviews.freebsd.org/D42785

6 months agonetlink: use protocol specific receive buffer
Gleb Smirnoff [Tue, 2 Jan 2024 21:04:01 +0000 (13:04 -0800)]
netlink: use protocol specific receive buffer

Implement Netlink socket receive buffer as a simple TAILQ of nl_buf's,
same part of struct sockbuf that is used for send buffer already.
This shaves a lot of code and a lot of extra processing.  The pcb rids
of the I/O queues as the socket buffer is exactly the queue.  The
message writer is simplified a lot, as we now always deal with linear
buf.  Notion of different buffer types goes away as way as different
kinds of writers.  The only things remaining are: a socket writer and
a group writer.
The impact on the network stack is that we no longer use mbufs, so
a workaround from d18715475071 disappears.

Note on message throttling.  Now the taskqueue throttling mechanism
needs to look at both socket buffers protected by their respective
locks and on flags in the pcb that are protected by the pcb lock.
There is definitely some room for optimization, but this changes tries
to preserve as much as possible.

Note on new nl_soreceive().  It emulates soreceive_generic().  It
must undergo further optimization, see large comment put in there.

Note on tests/sys/netlink/test_netlink_message_writer.py. This test
boiled down almost to nothing with mbufs removed.  However, I left
it with minimal functionality (it basically checks that allocating N
bytes we get N bytes) as it is one of not so many examples of ktest
framework that allows to test KPIs with python.

Note on Linux support. It got much simplier: Netlink message writer
loses notion of Linux support lifetime, it is same regardless of
process ABI.  On socket write from Linux process we perform
conversion immediately in nl_receive_message() and on an output
conversion to Linux happens in in nl_send_one(). XXX: both
conversions use M_NOWAIT allocation, which used to be the case
before this change, too.

Reviewed by: melifaro
Differential Revision: https://reviews.freebsd.org/D42524

6 months agotests/netlink: add netlink socket buffer test
Gleb Smirnoff [Tue, 2 Jan 2024 21:03:49 +0000 (13:03 -0800)]
tests/netlink: add netlink socket buffer test

With upcoming protocol specific socket buffer for Netlink we need some
additional tests that cover basic socket operations, w/o much of actual
Netlink knowledge.  Following tests are performed:

1) Overflow.  If an application keeps sending messages to the kernel,
but doesn't read out the replies, then first the receive buffer shall
fill and after that further messages from applications will be queued
on the send buffer until it is filled.  After that socket operations
should block.  However, reading from the receive buffer some data should
wake up the taskqueue and the send buffer should start draining again.

2) Peek & trunc.  Check that socket correctly reports amount of readable
data with MSG_PEEK & MSG_TRUNC.  This is typical pattern of Netlink apps.

3) Sizes. Check that zero size read doesn't affect the socket, undersize
read will return one truncated message and the message is removed from
the buffer.  Check that large buffer will be filled in one read, without
any boundaries imposed by internal representation of the buffer.  Check
that any meaningful read is amended with control data if requested so.

Reviewed by: melifaro
Differential Revision: https://reviews.freebsd.org/D42525

6 months agonetlink: uninline some KPI functions that work with struct nl_writer
Gleb Smirnoff [Tue, 2 Jan 2024 21:03:40 +0000 (13:03 -0800)]
netlink: uninline some KPI functions that work with struct nl_writer

These functions work with a buffer embedded into nl_writer, which
is going to go opaque with upcoming changes.  Make them private to
the netlink module.  No functional change intended.

Reviewed by: melifaro
Differential Revision: https://reviews.freebsd.org/D42523

6 months agonetlink: use domain specific send buffer
Gleb Smirnoff [Tue, 2 Jan 2024 21:03:21 +0000 (13:03 -0800)]
netlink: use domain specific send buffer

Instead of using generic socket code, create Netlink specific socket
buffer.  It is a simple TAILQ of writes that came from userland.  This
saves us one memory allocation that could fail and one memory copy.

Reviewed by: melifaro
Differential Revision: https://reviews.freebsd.org/D42522

6 months agokldxref: fix bootstrapping on Linux with Clang 16
Alex Richardson [Tue, 2 Jan 2024 19:06:51 +0000 (11:06 -0800)]
kldxref: fix bootstrapping on Linux with Clang 16

The glibc fts_open() callback type does not have the second const
qualifier and it appears that Clang 16 errors by default for mismatched
function pointer types. Add an ifdef to handle this case.

6 months agovmrun.sh: allow device name arguments in pci-passthru option
Christos Margiolis [Tue, 2 Jan 2024 18:20:42 +0000 (20:20 +0200)]
vmrun.sh: allow device name arguments in pci-passthru option

This is more intuitive than having to run `pciconf -l` and figure out
the bus/slot/func entry manually.

Reviewed by: markj
Sponsored by; The FreeBSD Foundation
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D43270

6 months agovmrun.sh: add missing options in usage message
Christos Margiolis [Tue, 2 Jan 2024 18:20:08 +0000 (20:20 +0200)]
vmrun.sh: add missing options in usage message

Reviewed by: markj
Sponsored by; The FreeBSD Foundation
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D43269

6 months agoFix typos in man pages under /share/man
Benedict Reuschling [Tue, 2 Jan 2024 17:53:25 +0000 (17:53 +0000)]
Fix typos in man pages under /share/man

Found using: devel/py-proselint

6 months agorelease: Add missing /var/crash ZFS dataset
Jose Luis Duran [Tue, 2 Jan 2024 17:38:55 +0000 (17:38 +0000)]
release: Add missing /var/crash ZFS dataset

This matches the layout from bsdinstall.

MFC after: 1 week
Fixes: 89585511cc05 ("release: Add support for creating ZFS-based VM images")
Pull Request: https://github.com/freebsd/freebsd-src/pull/981

6 months agomakefs: Fix ZFS cross-reference sections
Jose Luis Duran [Tue, 2 Jan 2024 13:30:29 +0000 (13:30 +0000)]
makefs: Fix ZFS cross-reference sections

MFC after: 1 week
Fixes: 240afd8c1fcc ("makefs: Add ZFS support")
Pull Request: https://github.com/freebsd/freebsd-src/pull/979

6 months agostress2: Handle the new output format of vmstat(8)
Peter Holm [Tue, 2 Jan 2024 13:43:46 +0000 (14:43 +0100)]
stress2: Handle the new output format of vmstat(8)

6 months agoFix udp IPv4-mapped address
Richard Kümmel [Fri, 15 Dec 2023 11:49:45 +0000 (12:49 +0100)]
Fix udp IPv4-mapped address

Do not use the cached route if the destination isn't the same.
This fix a problem where an UDP packet will be sent via the wrong route
and interface if a previous one was sent via them.

PR: 275774
Reviewed by: glebius, tuexen
Sponsored by: Beckhoff Automation GmbH & Co. KG

6 months agoctfconvert: Handle DW_AT_data_bit_offset
Mark Johnston [Tue, 2 Jan 2024 04:12:29 +0000 (23:12 -0500)]
ctfconvert: Handle DW_AT_data_bit_offset

This attribute is new in DWARF 4 and supersedes DW_AT_bit_offset.

PR: 276059
Reported by: rscheff
Tested by: rscheff
MFC after: 1 week

6 months agolibdtrace: Fix TCP data offset handling in the tcpinfo_t translator
Mark Johnston [Mon, 1 Jan 2024 21:33:30 +0000 (16:33 -0500)]
libdtrace: Fix TCP data offset handling in the tcpinfo_t translator

The header gives an offset in 32-bit words, and the translator is
supposed to convert that to a byte count.  But, the conversion was
incorrect.

Reviewed by: tuexen, rscheff
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D43264

6 months agozfs: Fix SPA sysctl handlers
Mark Johnston [Mon, 1 Jan 2024 18:54:15 +0000 (13:54 -0500)]
zfs: Fix SPA sysctl handlers

sbuf_cpy() resets the sbuf state, which is wrong for sbufs allocated by
sbuf_new_for_sysctl().  In particular, this code triggers an assertion
failure in sbuf_clear().

Simplify by just using sysctl_handle_string() for both reading and
setting the tunable.

Apply to FreeBSD directly since this bug causes "sysctl -a" to crash the
kernel.

PR: 276039
Reported by: pho
Reviewed by: mav
Pull Request: https://github.com/openzfs/zfs/pull/15719

6 months agocopyright: Bump the copyright date.
Warner Losh [Mon, 1 Jan 2024 06:15:08 +0000 (23:15 -0700)]
copyright: Bump the copyright date.

Sponsored by: Netflix

6 months agotest-includes: Add -ansi to the compile line to catch problems
Warner Losh [Mon, 1 Jan 2024 06:12:54 +0000 (23:12 -0700)]
test-includes: Add -ansi to the compile line to catch problems

We support C89 files, but compile everything in the tree with C99 or
newer. By compiling these -ansi, that will force C89 which doesn't
understand inline. All our header files must use __inline instead of
inline when they define inline functions.

Sponsored by: Netflix
Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D43235

6 months agonanobsd: Revert back to 1G (really 927M) partitions for rescue.
Warner Losh [Mon, 1 Jan 2024 06:12:42 +0000 (23:12 -0700)]
nanobsd: Revert back to 1G (really 927M) partitions for rescue.

The last bump to 8G was caused by all the new symbols and debug info we
install by default. Turning those off gets us back to a reasonable size:

Filesystem     Size    Used   Avail Capacity  Mounted on
/dev/md1s1a    927M    771M     83M    90%    /mnt

Sponsored by: Netflix
Reviewed by: jlduran@gmail.com
Differential Revision: https://reviews.freebsd.org/D43232

6 months agoisp: Fix endianness conversion in isp_read_flash_data()
Mark Johnston [Sun, 31 Dec 2023 23:52:52 +0000 (18:52 -0500)]
isp: Fix endianness conversion in isp_read_flash_data()

Reported by: Jenkins
Fixes: 10ed63fc06cb ("isp(4): Rework firmware handling/loading")

6 months agovfs_vnops.c: Fix vn_generic_copy_file_range() for truncation
Rick Macklem [Sun, 31 Dec 2023 23:55:24 +0000 (15:55 -0800)]
vfs_vnops.c: Fix vn_generic_copy_file_range() for truncation

When copy_file_range(2) was first being developed,
*inoffp + len had to be <= infile_size or an error was
returned. This semantic (as defined by Linux) changed
to allow *inoffp + len to be greater than infile_size and
the copy would end at *inoffp + infile_size.

Unfortunately, the code that decided if the outfd should
be truncated in length did not get updated for this
semantics change.
As such, if a copy_file_range(2) is done, where infile_size - *inoffp
is less that outfile_size but len is large, the outfd file is truncated
when it should not be. (The semantics for this for Linux is to not
truncate outfd in this case.)

This patch fixes the problem. I believe the calculation is safe
for all non-negative values of outsize, *outoffp, *inoffp and insize,
which should be ok, since they are all guaranteed to be non-negative.

Note that this bug is not observed over NFSv4.2, since it truncates
len to infile_size - *inoffp.

PR: 276045
Reviewed by: asomers, kib
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D43258

6 months agolibdtrace: decode all tcp header flags and add
Richard Scheffenegger [Sun, 31 Dec 2023 14:00:21 +0000 (15:00 +0100)]
libdtrace: decode all tcp header flags and add
decoding capability of TH_AE to dtrace, including
the example provided with tcpdebug.

MFC after:             1 week
Reviewed By:           markj, mav
Sponsored by:          NetApp, Inc.
Differential Revision: https://reviews.freebsd.org/D43243

6 months agorc.initdiskless: Remove bogus plus sign
Jose Luis Duran [Sun, 31 Dec 2023 18:39:37 +0000 (13:39 -0500)]
rc.initdiskless: Remove bogus plus sign

Reviewed by: imp, dab
Fixes: Fixes: 93b7818226cf ("libexec/rc/rc.initdiskless: make tar's path flexible")
Differential Revision: https://reviews.freebsd.org/D43241

6 months agolibdtrace: Fix line number reporting in error messages
Mark Johnston [Sun, 31 Dec 2023 17:37:06 +0000 (12:37 -0500)]
libdtrace: Fix line number reporting in error messages

MFC after: 1 week

6 months agogtaskqueue: Fix a typo
Mark Johnston [Sun, 31 Dec 2023 16:36:12 +0000 (11:36 -0500)]
gtaskqueue: Fix a typo

This is a no-op in practice since gtaskqueue_thread_enqueue() and
taskqueue_thread_enqueue() are identical, and while _gtaskqueue_create()
compares the enqueue callback pointer with gtaskqueue_thread_enqueue(),
the result has no effect since TQ_FLAGS_UNLOCKED_ENQUEUE was copied
directly from subr_taskqueue.c and is unused in the gtaskqueue code.

Fix it anyway since it's a bug.  More generally we really need to
consolidate subr_taskqueue.c and subr_gtaskqueue.c.

PR: 270661
MFC after: 1 week

6 months agofrag6 tests: Serialize
Mark Johnston [Sun, 18 Jun 2023 18:14:43 +0000 (14:14 -0400)]
frag6 tests: Serialize

I'm not sure exactly why, but these tests consistently fail when run in
parallel.  Serialize them for now.

MFC after: 1 week

6 months agofrag6: Reduce code duplication
Mark Johnston [Sun, 31 Dec 2023 16:15:48 +0000 (11:15 -0500)]
frag6: Reduce code duplication

The code which removes a fragment queue from the per-VNET hash table was
duplicated three times.  Factor it out into a function.  No functional
change intended.

Reviewed by: kp, bz
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D43228

6 months agofrag6: Drop unneeded casts from malloc calls
Mark Johnston [Sun, 31 Dec 2023 16:15:22 +0000 (11:15 -0500)]
frag6: Drop unneeded casts from malloc calls

No functional change intended.

MFC after: 1 week

6 months agoperiodic: Make daily diff(1) output as small is possible
Michael Osipov [Fri, 24 Nov 2023 09:26:41 +0000 (10:26 +0100)]
periodic: Make daily diff(1) output as small is possible

Make, by default, daily diff(1) ignore whitespace changes and the unified output
a context of zero (0) lines. This reduces output of unrelated lines in e-mails
delivered to root.

PR: 270266
Approved by: jrm (mentor), karels
MFC after: 1 month
Relnotes: yes
Differential Revision: https://reviews.freebsd.org/D42762

6 months agoperiodic: Make daily diff(1) flags configurable with daily_diff_flags
Michael Osipov [Fri, 24 Nov 2023 09:26:41 +0000 (10:26 +0100)]
periodic: Make daily diff(1) flags configurable with daily_diff_flags

PR: 270266
Approved by: jrm (mentor), karels
MFC after: 1 month
Relnotes: yes
Differential Revision: https://reviews.freebsd.org/D42900

6 months agoperiodic: Make security diff(1) output as small is possible
Michael Osipov [Fri, 24 Nov 2023 09:26:41 +0000 (10:26 +0100)]
periodic: Make security diff(1) output as small is possible

Make, by default, security diff(1) produce a unified output with a context of
zero (0) lines. This reduces output of unrelated lines in e-mails delivered
to root.

PR: 270266
Approved by: jrm (mentor), karels
MFC after: 1 month
Relnotes: yes
Differential Revision: https://reviews.freebsd.org/D43071

6 months agobsd.man.mk allow staging compressed pages
Simon J. Gerraty [Sat, 30 Dec 2023 17:10:03 +0000 (09:10 -0800)]
bsd.man.mk allow staging compressed pages

In the DIRDEPS_BUILD we use staging.
The staging logic in bsd.man.mk was in the wrong place, shift it
and add compressed man pages to the stage set if appropriate.

Reviewed by: stevek
Differential Revision: https://reviews.freebsd.org/D43238

6 months agotcp: fix ports
Michael Tuexen [Sat, 30 Dec 2023 02:28:13 +0000 (03:28 +0100)]
tcp: fix ports

inline is only support in C99 and newer. To support also C89, use
__inline instead as suggested by dim.

Reported by: eduardo
Reviewed by: rscheff, markj, dim, imp
Tested by: eduardo
Fixes: a8b70cf26030 ("netpfil: Use accessor functions and named constants for all tcphdr flags")
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D43231

6 months agokern: Introduce kern.pid_max_limit sysctl.
Pawel Jakub Dawidek [Sat, 30 Dec 2023 06:15:17 +0000 (22:15 -0800)]
kern: Introduce kern.pid_max_limit sysctl.

The kern.pid_max_limit will hold the PID_MAX value the kernel was
compiled with. The existing kern.pid_max sysctl can be modified and
doesn't really represent maximum PID number in the system, as there
may still be processes created with higher PIDs before kern.pid_max
was lowered.

Reivewed by: kib, zlei
Approved by: oshogbo
Differential Revision: https://reviews.freebsd.org/D43077

6 months agocopy_file_range.2: Clarify that only regular files work
Rick Macklem [Fri, 29 Dec 2023 22:59:00 +0000 (14:59 -0800)]
copy_file_range.2: Clarify that only regular files work

PR#273962 reported that copy_file_range(2) did not work
on shared memory objects and returned EINVAL.
Although the reporter felt this was incorrect, it is what
the Linux copy_file_range(2) syscall does.

Since there was no collective agreement that the FreeBSD
semantics should be changed to no longer be Linux compatible,
copy_file_range(2) still works on regular files only.

This man page update clarifies that. If, someday, copy_file_range(2)
is changed to support non-regular files, then the man page will
need to be updated to reflect that.

PR: 273962
Reviewed by: karels, pauamma_gundo.com (manpages)
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D43227

6 months agobhyve: verify that user provided fbuf values fall within limits
Robert Wing [Fri, 29 Dec 2023 19:18:15 +0000 (10:18 -0900)]
bhyve: verify that user provided fbuf values fall within limits

The upper limits for height/width are already checked, this commit
enforces the lower limit as well.

The behavior is also changed such that, the framebuffer fails to
initialize if the provided values don't parse cleanly.

Reviewed by: corvink, jhb
Differential Revision: https://reviews.freebsd.org/D42692

6 months agobsdinstall: rename "Live CD" to "Live System"
Pierre Pronchery [Fri, 29 Dec 2023 18:23:48 +0000 (19:23 +0100)]
bsdinstall: rename "Live CD" to "Live System"

This uses more generic wording in the FreeBSD installer, when offering
the user to use the system booted without running the installer.

The updated wording is also reflected in freebsd-version(1).

Reviewed by: emaste
Sponsored by: The FreeBSD Foundation
Differential revision: https://reviews.freebsd.org/D43233

6 months agoMerge commit c97a7675eea4 from llvm git (by Qiu Chaofan):
Dimitry Andric [Fri, 29 Dec 2023 19:30:45 +0000 (20:30 +0100)]
Merge commit c97a7675eea4 from llvm git (by Qiu Chaofan):

  [PowerPC] Expand FSINCOS of fp128 (#76494)

This fixes "fatal error: error in backend: Cannot select: 0x6d420285c0:
f128,f128 = fsincos 0x6d4202b6f0" when compiling s_cpowl.c for
powerpc64le.

Upstream ticket: https://github.com/llvm/llvm-project/issues/76442

Reported by: pkubaj
MFC after: 3 days

6 months agocamcontrol: add support for Toshiba drive firmware update
Kenneth D. Merry [Fri, 29 Dec 2023 19:23:51 +0000 (14:23 -0500)]
camcontrol: add support for Toshiba drive firmware update

Thanks to Toshiba for providing the SCSI spec for their latest
generation drives so I could confirm how they operate.

The firmware download works in a pretty standard way, so this
is a straightforward table addition.

sbin/camcontrol/camcontrol.8:
Document that Toshiba drives are supported for fwdownload,
and that it was tested on TOSHIBA MG10SFA22TE 22TB drives.

sbin/camcontrol/fwdownload.c:
Add TOSHIBA to the known SCSI vendors list for fwdownload.

Sponsored by: Spectra Logic
MFC after: 3 days

6 months agollvm: Support: don't block signals around close if it can be avoided
Mateusz Guzik [Fri, 29 Dec 2023 18:51:56 +0000 (18:51 +0000)]
llvm: Support: don't block signals around close if it can be avoided

Signal blocking originally showed up in 51c2afc4b65b2782 ("Support:
Don't call close again if we get EINTR"), but it was overzealous --
there are systems where the error is known to be fine.

This commit elides signal blocking for said systems (the list is
incomplete though).

Note close() can still fail for other reasons (like ENOSPC), in which
case an error will be returned while the fd slot is cleared up.

Reviewed by: dim
Differential Revision: https://reviews.freebsd.org/D42984

6 months agovmm: MTRR should be saved/restored
Vitaliy Gusev [Fri, 29 Dec 2023 18:03:20 +0000 (09:03 -0900)]
vmm: MTRR should be saved/restored

This fixes restoring a Linux VM if it was suspended while in the GRUB
menu.

Adding MTTR increases the kernel dump size by 256 bytes per vCPU.

Sponsored by:   vStack
Reviewed by:    markj, rew
Differential Revision:  https://reviews.freebsd.org/D43226

6 months agobhyve: increase SNAPSHOT_BUFFER_SIZE
Vitaliy Gusev [Fri, 29 Dec 2023 17:37:43 +0000 (08:37 -0900)]
bhyve: increase SNAPSHOT_BUFFER_SIZE

After commit fb51ddb20d57, suspending a vm fails with the error:
    vm_snapshot_buf: buffer too small

Sponsored by:   vStack
Reviewed by:    markj, rew
Fixes: fb51ddb20d57 ("bhyve: increase fbuf display resolution limit")
Differential Revision: https://reviews.freebsd.org/D43218

6 months agotegra210: change to UTF-8 (from ISO-8859)
Ed Maste [Fri, 29 Dec 2023 03:53:16 +0000 (22:53 -0500)]
tegra210: change to UTF-8 (from ISO-8859)

Prompted by Phabricator's complaint that a C source file was a binary
file, in D43192.

Reviewed by: mmel
Differential Revision: https://reviews.freebsd.org/D43229

6 months agoindent: make the URL of the manpage two characters longer so that the test is successful
Wolfram Schneider [Fri, 29 Dec 2023 09:37:43 +0000 (09:37 +0000)]
indent: make the URL of the manpage two characters longer so that the test is successful

6 months agoDocument the two recent newsyslog(8) change (-c option and <compress>
Xin LI [Fri, 29 Dec 2023 08:45:52 +0000 (00:45 -0800)]
Document the two recent newsyslog(8) change (-c option and <compress>
configuration option).

6 months agonewsyslog(8): Add support of specifying compression method in configuration file.
Xin LI [Mon, 25 Dec 2023 07:47:36 +0000 (23:47 -0800)]
newsyslog(8): Add support of specifying compression method in configuration file.

Administrators can now specify a global compression method directly
at the beginning of the newsyslog.conf file, for example:

<compress> none

Relnotes: yes
Reviewed by: dvl
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D43174

6 months agonetmap: fix unit tests
Vincenzo Maffione [Fri, 29 Dec 2023 07:46:46 +0000 (07:46 +0000)]
netmap: fix unit tests

After ad874544d9f018bf8eef4053b5ca7b856c4674cb, interface name
validation has been removed, resulting in two unit tests failures.
Drop the failing tests since they no longer apply.

Reported by: markj

6 months agoEC2: Bump AMI size to 6 GB
Colin Percival [Thu, 28 Dec 2023 22:23:52 +0000 (14:23 -0800)]
EC2: Bump AMI size to 6 GB

This week's cloud-init ZFS snapshots ran out of disk space.

6 months agoOptionalObsoleteFiles.inc: Add libnss_tacplus_p.a as an old profiled library
John Baldwin [Thu, 28 Dec 2023 22:20:54 +0000 (14:20 -0800)]
OptionalObsoleteFiles.inc: Add libnss_tacplus_p.a as an old profiled library

Noticed this was still present after upgrading a 12.x stable host to
14.0 stable.

6 months agocamcontrol: Add a sense subcommand
Kenneth D. Merry [Thu, 28 Dec 2023 21:23:16 +0000 (16:23 -0500)]
camcontrol: Add a sense subcommand

As the name suggests, this sends a SCSI REQUEST SENSE to a device,
and prints out decoded sense information.  It can also print out a
hexdump of the sense data.

sbin/camcontrol/camcontrol.c:
Add the new sense subcommand.

sbin/camcontrol/camcontrol.8:
Document camcontrol sense.

Sponsored by: Spectra Logic
Reviewed by: mav
MFC after: 3 days
Differential Revision:  https://reviews.freebsd.org/D43225

6 months agonfsstat: make -q work without -e/-E
Lexi Winter [Thu, 28 Dec 2023 12:56:57 +0000 (12:56 +0000)]
nfsstat: make -q work without -e/-E

MFC after: 2 weeks
Pull Request: https://github.com/freebsd/freebsd-src/pull/961

6 months agoatrtc: Add a required include
Mark Johnston [Thu, 28 Dec 2023 20:16:39 +0000 (15:16 -0500)]
atrtc: Add a required include

PR: 275867
MFC after: 1 week

6 months agosys: Style fix for M_EXT | M_EXTPG
John Baldwin [Thu, 28 Dec 2023 19:17:59 +0000 (11:17 -0800)]
sys: Style fix for M_EXT | M_EXTPG

Add a space around the | operator in places testing for either M_EXT
or M_EXTPG.

Reviewed by: imp, glebius
Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D43216

6 months agombuf.9: Document mtodo
John Baldwin [Thu, 28 Dec 2023 19:17:22 +0000 (11:17 -0800)]
mbuf.9: Document mtodo

mtodo() accepts an mbuf and offset and returns a void * pointer to the
requested offset into the mbuf's associated data.  Similar to mtod(),
no bounds checking is performed.

Reviewed by: imp, markj
Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D43215

6 months agoisp(4): Rework firmware handling/loading
Joerg Pulz [Fri, 27 Oct 2023 15:27:37 +0000 (17:27 +0200)]
isp(4): Rework firmware handling/loading

Correctly identify the active firmware in flash on adapters with
primary and secondary firmware region in flash.
Correctly identify the active NVRAM on adapters with primary
and secondary NVRAM region in flash.

Loading ispfw(4) moved from isp_pci_attach() to isp_reset().
Drop the reference to ispfw(4) after using it so one can kldunload(8) it.
New isp_load_ram() function to load either ispfw(4) or flash firmware
into RISC's RAM.
New functions to read data from flash. The old ones will be removed later.
A bunch of new helper functions to identify and validate active flash
regions for firmware, auxiliary and NVRAM.
Overhaul ISP_FW_* macros and make use of it when comparing firmware
versions. We can handle firmware versions up to 255.255.255.

Firmware load priority slightly changed:
For 27xx and newer adapters:
- load ispfw(4) firmware
- request (active) flash firmware information
- compare version numbers of ispfw(4) and flash firmware
- load firmware with highest version into RISC's RAM
- if loading ispfw(4) is disabled or failed - load firmware from flash
- if everything else fails use MBOX_LOAD_FLASH_FIRMWARE as fallback

For 26xx and older adapters nothing changed:
- load ispfw(4) firmware and load it into RISC's RAM
- if loading ispfw(4) is disabled or failed use MBOX_EXEC_FIRMWARE
- for 26xx a preceding MBOX_LOAD_FLASH_FIRMWARE is used

New read only sysctl(8)'s:
 dev.isp.N.fw_version_run: the firmware version actually running
 dev.isp.N.fw_version_ispfw: the firmware version provided by ispfw(4)
 dev.isp.N.fw_version_flash: the (active) firmware version in flash

While here:
  - firmware attribute handling/parsing reworked
    + renamed defines from ISP2400_FW_ATTR_* to ISP_FW_ATTR_*
    + changed values to match new handling/parsing
    + added some more attributes
  - enable FLT support on 26xx based adapters
  - log level adjustments
  - new function return status codes (some for now, some for later use)
  - some minor style changes

Tested and approved to work on real hardware with:
  - Qlogic ISP 2532 (QLogic QLE2560 8Gb FC Adapter)
  - Qlogic ISP 2031 (QLogic QLE2662 16Gbit 2Port FC Adapter)
  - Qlogic ISP 2722 (QLogic QLE2690 16Gb FC Adapter)
  - Qlogic ISP 2812 (QLogic QLE2772 32Gbit 2Port FC Adapter)

PR: 273263
Reviewed by: mav
Pull Request: https://github.com/freebsd/freebsd-src/pull/877
MFC after: 1 month
Sponsored by: Technical University of Munich

6 months agoispfw(4): Update and add firmware
Joerg Pulz [Fri, 27 Oct 2023 14:02:07 +0000 (16:02 +0200)]
ispfw(4): Update and add firmware

Update 25xx firmware: version 8.8.207
Add 26xx firmware: version 8.8.231
Add 27xx firmware: version 9.12.0
Add 28xx firmware: version 9.12.1

Remove BUGS section from manpage as we now have firmware for
all supported controllers.

PR: 273263
MFC after: 1 month
Pull Request: https://github.com/freebsd/freebsd-src/pull/877
Sponsored by: Technical University of Munich

6 months agocam: Let cam_periph_unmapmem() return an error
Mark Johnston [Thu, 28 Dec 2023 17:08:04 +0000 (12:08 -0500)]
cam: Let cam_periph_unmapmem() return an error

As of commit b059686a71c8, cam_periph_unmapmem() can legitimately fail
if the copyout() operation fails.  However, this failure was never
signaled to upper layers.  In practice it is unlikely to occur
since cap_periph_mapmem() would most likely fail in such
circumstances anyway, but an error is nonetheless possible.

However, some code reading revealed a few paths where the return value
of cam_periph_mapmem() is not checked, and this is definitely a bug.
Add error checking there and let cam_periph_unmapmem() return errors
from copyout().

Reviewed by: dab, mav
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D43201