]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
9 months agobsdconfig: remove support for ftp, pkg does not support it anymore
Baptiste Daroussin [Thu, 5 Oct 2023 12:39:13 +0000 (14:39 +0200)]
bsdconfig: remove support for ftp, pkg does not support it anymore

9 months agofortune: use 115200 in serial example
Ed Maste [Thu, 5 Oct 2023 12:11:46 +0000 (08:11 -0400)]
fortune: use 115200 in serial example

Commit 4722ceb7d53e switched the default serial rate to 115200 bps.
Follow suit in the freebsd-tips fortune example.

Reviewed by: bcr
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D41495

9 months agoObsoleteFiles.inc: document the removal of floppy support in bsdconfig
Baptiste Daroussin [Thu, 5 Oct 2023 11:31:26 +0000 (13:31 +0200)]
ObsoleteFiles.inc: document the removal of floppy support in bsdconfig

9 months agobsdconfig: drop support for floppies
Baptiste Daroussin [Thu, 5 Oct 2023 08:37:39 +0000 (10:37 +0200)]
bsdconfig: drop support for floppies

Reviewed by: manu
Differential Revision: https://reviews.freebsd.org/D42083

9 months agogenl: add a monitor subcommand
Baptiste Daroussin [Thu, 5 Oct 2023 10:51:02 +0000 (12:51 +0200)]
genl: add a monitor subcommand

usage:
$ genl monitor <family> <multicats group>

this subcommand allows to monitor the message from a multicast group
of a given family when received.

If it knows how to parse the messages received it will dump the decoded
version, otherwise it will just inform a new message has been received

So far it only knows how to parse nlctrl notify messages, but the plan
to allow to make the parsing extensible via lua scripts

Differential Revision: https://reviews.freebsd.org/D40372

9 months agoif_ovpn tests: fix ra test
Kristof Provost [Thu, 5 Oct 2023 07:41:25 +0000 (09:41 +0200)]
if_ovpn tests: fix ra test

Client one is supposed to be assigend 198.51.100.2, but sometimes it
loses the race and the address ends up assigned to client two. When this
happened one would try to ping itself, which failed because the loopback
interface isn't up.

Ideally we'd generate static address assignments, but that would
complicate the test. Activate loopback interfaces so the test always
passes, and just try to ping both possible addresses.

MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")

9 months agobsdinstall: decouple from the MK_DIALOG option
Baptiste Daroussin [Thu, 5 Oct 2023 07:54:20 +0000 (09:54 +0200)]
bsdinstall: decouple from the MK_DIALOG option

bsdinstall does not depend on libdialog(3) or anything using
libdialog(3) for a while now, it does not need to depend on MK_DIALOG
anymore

9 months agobsdconfig: always build and install
Baptiste Daroussin [Thu, 5 Oct 2023 07:51:16 +0000 (09:51 +0200)]
bsdconfig: always build and install

it does not depend on dialog(1) anymore

9 months agobsdconfig(8): add bsddialog(1) support
Alfonso S. Siciliano [Thu, 5 Oct 2023 07:29:12 +0000 (09:29 +0200)]
bsdconfig(8): add bsddialog(1) support

Add bsddialog(1) to bsdconfig(8). This can be considered an increment not a
replacement, `$DIALOG=dialog' restores dialog(1).

Differential Revision: https://reviews.freebsd.org/D37480

9 months agobectl: fix some `mandoc -Tlint` complaints
Kyle Evans [Thu, 5 Oct 2023 02:26:55 +0000 (21:26 -0500)]
bectl: fix some `mandoc -Tlint` complaints

The EXAMPLES mis-comments caused an obnoxious amount of blank space
above SEE ALSO when rendered by mandoc to a terminal.  The missing
termination of .Xo meant the description of -h ran together with the
subcommand synopsis. The other changes were generally ignored tags due
to context that simply don't need to be there.

Provoked by: grahamperrin

9 months agoTCP: Fix a rack bug that skyzall found which results in a crash.
Randall Stewart [Wed, 4 Oct 2023 19:16:01 +0000 (15:16 -0400)]
TCP: Fix a rack bug that skyzall found which results in a crash.

So when we call the fast_rsm retransmit path, we should always move
snd_nxt back up to snd_max. In fact during ack-processing if snd_nxt
falls behind it should be moved up there as well. Otherwise what
can happen is we have an incorrect mark on snd_nxt and incorrectly
calculate the offset when we go through the  front path (which is
what skzyall was able to do) then when we go to clean up the
send the offset is all wrong and we crash.

Special thanks to Gleb for pointing out the problem and the email
that had the reproducer so I could find the issue.

Reported-by: syzbot+f5061a372f74f021ec02@syzkaller.appspotmail.com
Sponsored by: Netflix Inc

9 months agolinux(4): Fix semid64_ds structure layout
Dmitry Chagin [Wed, 4 Oct 2023 18:21:12 +0000 (21:21 +0300)]
linux(4): Fix semid64_ds structure layout

Unlike x86_64, other 64-bit architectures do not have paddings
for the time fields.

MFC after: 1 week

9 months agolinux(4): Deduplicate SystemV IPC defines from amd64/linux
Dmitry Chagin [Wed, 4 Oct 2023 18:18:45 +0000 (21:18 +0300)]
linux(4): Deduplicate SystemV IPC defines from amd64/linux

MFC after: 1 week

9 months agobhyve: Move the vm_inject_fault() implementation to vmexit.c
Mark Johnston [Wed, 4 Oct 2023 16:29:07 +0000 (12:29 -0400)]
bhyve: Move the vm_inject_fault() implementation to vmexit.c

This function isn't generic and has a different signature on arm64.  No
functional change intended.

Reviewed by: corvink, jhb
MFC after: 1 week
Sponsored by: Innovate UK
Differential Revision: https://reviews.freebsd.org/D40991

9 months agobhyve: Build the HPET ACPI table on amd64 only
Mark Johnston [Wed, 4 Oct 2023 16:28:28 +0000 (12:28 -0400)]
bhyve: Build the HPET ACPI table on amd64 only

There is no HPET on arm64 and vm_get_hpet_capabilities() is not
implemented there.  Move the vm_get_hpet_capabilities() call into
build_hpet(): I cannot see a downside, and doing so eliminates a global
variable and reduces the amount of code that needs to be conditionally
compiled.  No functional change intended.

Reviewed by: corvink, jhb
MFC after: 1 week
Sponsored by: Innovate UK
Differential Revision: https://reviews.freebsd.org/D40990

9 months agobhyve: Move most early initialization into an MD routine
Mark Johnston [Wed, 4 Oct 2023 16:27:54 +0000 (12:27 -0400)]
bhyve: Move most early initialization into an MD routine

Prior to initializing PCI devices, main() calls a number of
initialization routines, many of which are amd64-specific.  Move this
list of calls to bhyverun_machdep.c.  Similarly, add an MD function to
handle late initialization.

No functional change intended.

Reviewed by: corvink, jhb
MFC after: 1 week
Sponsored by: Innovate UK
Differential Revision: https://reviews.freebsd.org/D40989

9 months agobhyve: Move vcpu initialization into a MD source file
Mark Johnston [Wed, 4 Oct 2023 16:27:07 +0000 (12:27 -0400)]
bhyve: Move vcpu initialization into a MD source file

- Make handling of x86 config options, like x86.x2apic, conditional to
  amd64.
- Move fbsdrun_set_capabilities() and spinup_vcpu() to a new file,
  bhyverun_machdep.c.  The moved code is all highly x86 specific.

I'm not sure how best to handle the namespace.  I'm using "bhyve_" for
MD functions called from MI code.  We also have "fbsdrun_" for some MI
routines that are typically called from MD code.  The file name is
prefixed by "bhyverun_".

Reviewed by: corvink
MFC after: 1 week
Sponsored by: Innovate UK
Differential Revision: https://reviews.freebsd.org/D40987

9 months agobhyve: Make gdb support optional
Mark Johnston [Wed, 4 Oct 2023 16:26:36 +0000 (12:26 -0400)]
bhyve: Make gdb support optional

Add a BHYVE_GDB_SUPPORT make variable that can be set by per-arch
makefiles.  When set, BHYVE_GDB is defined and can be used as a
preprocessor predicate.  Use it to guard gdb stub calls in MI code.

The arm64 bhyve port currently does not have a functional gdb stub, but
that's not critical to landing the port, so this mechanism slightly
reduces the friction of adding support for a new platform.

Reviewed by: corvink, jhb
MFC after: 1 week
Sponsored by: Innovate UK
Differential Revision: https://reviews.freebsd.org/D40986

9 months agobhyve: Make most I/O port handling specific to amd64
Mark Johnston [Wed, 4 Oct 2023 16:26:08 +0000 (12:26 -0400)]
bhyve: Make most I/O port handling specific to amd64

- The qemu_fwcfg interface, as implemented, is I/O port-based, but QEMU
  implements an MMIO interface that we'll eventually want to port for
  arm64.
- Retain support for I/O space PCI BARs, simply treat them like MMIO
  BARs for most purposes, similar to what the arm64 kernel does.  Such
  BARs are created by virtio devices.

Reviewed by: corvink, jhb
MFC after: 1 week
Sponsored by: Innovate UK
Differential Revision: https://reviews.freebsd.org/D40741

9 months agobhyve: Conditionally compile framebuffer-related code
Mark Johnston [Wed, 4 Oct 2023 16:25:47 +0000 (12:25 -0400)]
bhyve: Conditionally compile framebuffer-related code

The arm64 port does not implement VGA, so move the device model sources.
Compile framebuffer code only on amd64 for now, but do not move the
sources, as we ought to be able to add support later.

No functional change intended.

Reviewed by: corvink, jhb
MFC after: 1 week
Sponsored by: Innovate UK
Differential Revision: https://reviews.freebsd.org/D40740

9 months agobhyve: Move legacy PCI interrupt handling under amd64/
Mark Johnston [Wed, 4 Oct 2023 16:25:19 +0000 (12:25 -0400)]
bhyve: Move legacy PCI interrupt handling under amd64/

Specifically, move IO-APIC, LPC and PIRQ routing code under amd64/.

Use ifdefs to conditionally compile related code in other files.  In
particular, legacy PCI interrupt handling is now compiled only on amd64.
This is not too invasive, but suggestions for a more modular approach
would be appreciated.

I am not sure why qemu fwcfg handling is tied to LPC, and I suspect it
should be decoupled.  In this commit I just apply an ifdef hammer, but
we will eventually want fwcfg on arm64 as well.

No functional change intended.

Reviewed by: corvink, jhb
MFC after: 1 week
Sponsored by: Innovate UK
Differential Revision: https://reviews.freebsd.org/D40739

9 months agobhyve: Compile some device models only on amd64
Mark Johnston [Wed, 4 Oct 2023 16:24:57 +0000 (12:24 -0400)]
bhyve: Compile some device models only on amd64

These models register legacy PCI interrupts, which won't be supported in
the arm64 port.  In principle it should be possible to make these models
work on arm64 with a bit of effort, so don't move the sources to the
amd64 subdirectory.

No functional change intended.

Reviewed by: corvink, jhb
MFC after: 1 week
Sponsored by: Innovate UK
Differential Revision: https://reviews.freebsd.org/D40738

9 months agobhyve: Move AP startup code to amd64/
Mark Johnston [Wed, 4 Oct 2023 16:24:19 +0000 (12:24 -0400)]
bhyve: Move AP startup code to amd64/

This code is only invoked via MD vmexit handlers.  No functional change
intended.

Reviewed by: corvink, jhb
MFC after: 1 week
Sponsored by: Innovate UK
Differential Revision: https://reviews.freebsd.org/D40737

9 months agobhyve: Move the gvt-d driver to amd64/
Mark Johnston [Wed, 4 Oct 2023 16:24:04 +0000 (12:24 -0400)]
bhyve: Move the gvt-d driver to amd64/

It is amd64-only.  No functional change intended.

Reviewed by: corvink, jhb
MFC after: 1 week
Sponsored by: Innovate UK
Differential Revision: https://reviews.freebsd.org/D40736

9 months agobhyve: Move power management code to amd64/
Mark Johnston [Wed, 4 Oct 2023 16:23:50 +0000 (12:23 -0400)]
bhyve: Move power management code to amd64/

This implements various x86-specific interfaces.  No functional change
intended.

Reviewed by: corvink, jhb
MFC after: 1 week
Sponsored by: Innovate UK
Differential Revision: https://reviews.freebsd.org/D40735

9 months agobhyve: Move the RTC driver to amd64/
Mark Johnston [Wed, 4 Oct 2023 16:23:36 +0000 (12:23 -0400)]
bhyve: Move the RTC driver to amd64/

No functional change intended.

Reviewed by: corvink, jhb
MFC after: 1 week
Sponsored by: Innovate UK
Differential Revision: https://reviews.freebsd.org/D40734

9 months agobhyve: Move MSR emulation into amd64/
Mark Johnston [Wed, 4 Oct 2023 16:23:22 +0000 (12:23 -0400)]
bhyve: Move MSR emulation into amd64/

No functional change intended.

Reviewed by: corvink, jhb
MFC after: 1 week
Sponsored by: Innovate UK
Differential Revision: https://reviews.freebsd.org/D40733

9 months agobhyve: Remove some unneeded includes from snapshot.c
Mark Johnston [Wed, 4 Oct 2023 16:23:07 +0000 (12:23 -0400)]
bhyve: Remove some unneeded includes from snapshot.c

MFC after: 1 week
Sponsored by: Innovate UK

9 months agobhyve: Split vmexit handling into a separate file
Mark Johnston [Wed, 4 Oct 2023 16:22:56 +0000 (12:22 -0400)]
bhyve: Split vmexit handling into a separate file

Put it in amd64, since most of it is MD and won't be used on arm64.  Add
a bit of glue to bhyverun.h to make CPU startup and shutdown work
without having to export more global variables.  AP startup will be
reworked further in a future revision.

This makes bhyverun.c much more machine-independent.

No functional change intended.

Reviewed by: corvink, jhb
MFC after: 1 week
Sponsored by: Innovate UK
Differential Revision: https://reviews.freebsd.org/D40556

9 months agobhyve: Move kernemu to amd64/
Mark Johnston [Wed, 4 Oct 2023 16:22:41 +0000 (12:22 -0400)]
bhyve: Move kernemu to amd64/

This code handles instruction emulation for accesses to various
amd64-specific MMIO regions.

No functional change intended.

Reviewed by: corvink, jhb, emaste
MFC after: 1 week
Sponsored by: Innovate UK
Differential Revision: https://reviews.freebsd.org/D40554

9 months agobhyve: Move more amd64-specific code under amd64/
Mark Johnston [Wed, 4 Oct 2023 16:21:20 +0000 (12:21 -0400)]
bhyve: Move more amd64-specific code under amd64/

mptable and the e820 are both rather amd64-specific and can be moved
easily.

In the case of e820, move the registration with qemu_fwcfg into e820.c,
as it simplifies bhyverun.c a bit and I can't see any downsides.

No functional change intended.

Reviewed by: corvink, jhb, emaste
MFC after: 1 week
Sponsored by: Innovate UK
Differential Revision: https://reviews.freebsd.org/D40552

9 months agobhyve: Move some more amd64-specific drivers to their own subdir
Mark Johnston [Wed, 4 Oct 2023 16:20:57 +0000 (12:20 -0400)]
bhyve: Move some more amd64-specific drivers to their own subdir

No functional change intended.

Reviewed by: corvink, jhb, emaste
MFC after: 1 week
Sponsored by: Innovate UK
Differential Revision: https://reviews.freebsd.org/D40551

9 months agobhyve: Start moving machine-dependent code into subdirectories
Mark Johnston [Wed, 4 Oct 2023 16:20:37 +0000 (12:20 -0400)]
bhyve: Start moving machine-dependent code into subdirectories

In preparation for an arm64 port, make an easy change which puts some
machine-dependent code in its own directory.

Going forward, code which is only used on one platform should live in a
MD directory.  We should strive to layer modules in such a way as to
avoid polluting shared code with lots of ifdefs.  For some existing
files this will take some effort.

task_switch.c and fwctl.c are an easy place to start: the former is very
x86-specific, and the latter provides an I/O port interface which can't
be used on anything other than x86.  (fwcfg as implemented has the same
problem, but QEMU also supports a MMIO fwcfg interface.)  So I propose
that we start by simply making those files conditional.

Reviewed by: corvink, jhb
MFC after: 1 week
Sponsored by: Innovate UK
Differential Revision: https://reviews.freebsd.org/D40501

9 months agobhyve: Improve pcifd function naming
Mark Johnston [Wed, 4 Oct 2023 16:19:58 +0000 (12:19 -0400)]
bhyve: Improve pcifd function naming

read_config() and write_config() are externally visible, so give them
more descriptive names.  No functional change intended.

MFC after: 1 week
Sponsored by: Innovate UK

9 months agomailmap: Fixup a few github nouser emails
Warner Losh [Wed, 4 Oct 2023 16:15:27 +0000 (10:15 -0600)]
mailmap: Fixup a few github nouser emails

Fixup a couple foo@user.noreply.github.com email addresses based other
information (either known FreeBSD user, known other commits with the
correct name, etc)

9 months agobsddialog: import version 1.0
Baptiste Daroussin [Wed, 4 Oct 2023 16:11:36 +0000 (18:11 +0200)]
bsddialog: import version 1.0

9 months agomount.8: Mention tarfs(5)
Jose Luis Duran [Wed, 4 Oct 2023 15:42:40 +0000 (15:42 +0000)]
mount.8: Mention tarfs(5)

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

9 months agobsddialog: Import version 1.0
Baptiste Daroussin [Wed, 4 Oct 2023 15:43:22 +0000 (17:43 +0200)]
bsddialog: Import version 1.0

9 months agoaxge: Add support for AX88179A
Damien Broka [Tue, 19 Sep 2023 16:26:06 +0000 (17:26 +0100)]
axge: Add support for AX88179A

The AX88179A has two firmware modes, one of which is backward
compatible with existing AX88178A/179 driver. The active firmware mode
can be controlled through a register.

Update axge(4) man page to mention 179A support and ensure that, when
bound to a AX88179A, the driver activates the compatible firmware mode.

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

9 months agofreebsd-update: add a note about when files may be deleted
Ed Maste [Fri, 29 Sep 2023 15:47:41 +0000 (11:47 -0400)]
freebsd-update: add a note about when files may be deleted

Files under /var/db/freebsd-update are required during the upgrade
process, and to support rollback.  They may be deleted if no upgrade is
in progress and rollback will not be required.

PR: 273601
Reviewed by: bcr
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D42022

9 months agozfs: merge openzfs/zfs@f795e90a1
Martin Matuska [Wed, 4 Oct 2023 12:02:37 +0000 (14:02 +0200)]
zfs: merge openzfs/zfs@f795e90a1

Notable upstream pull request merges:
 #15322 4e16964e1 Add '-u' - nomount flag for zfs set
 #15331 fe4d055b3 Report ashift of L2ARC devices in zdb
 #15333 249d759ca Fix invalid pointer access in trace_dbuf.h
 #15339 f795e90a1 Add BTI landing pads to the AArch64 SHA2 assembly

Obtained from: OpenZFS
OpenZFS commit: f795e90a11c683d64bacc260fb7feab705b220b1

9 months agoLinuxKPI: remove dummy headers with implementations
Bjoern A. Zeeb [Wed, 4 Oct 2023 10:17:21 +0000 (10:17 +0000)]
LinuxKPI: remove dummy headers with implementations

Both agp_backend.h and utsname.h have an implementation in common/
these days so the dummy headers are no longer needed.

Sponsored by: The FreeBSD Foundation
MFC after: 3 days

9 months agopf: cope with missing rpool.cur
Kristof Provost [Tue, 3 Oct 2023 15:11:44 +0000 (17:11 +0200)]
pf: cope with missing rpool.cur

If we're evaluating a pfsync'd state (and have different rules on both
ends) our state may point to the default rule, which does not have
rpool.cur set. As a result we can end up dereferencing a NULL pointer.

Explicitly check for this when we try to re-construct the route-to interface.

Also add a test case which can trigger this issue.

MFC after: 3 days
See also: https://redmine.pfsense.org/issues/14804
Sponsored by: Rubicon Communications, LLC ("Netgate")

9 months agoAdd BTI landing pads to the AArch64 SHA2 assembly
Andrew Turner [Tue, 3 Oct 2023 22:12:36 +0000 (23:12 +0100)]
Add BTI landing pads to the AArch64 SHA2 assembly

The Arm Branch Target Identification (BTI) extension guards against
branching to an unintended instruction.

To support BTI add the landing pad instructions to the SHA2 functions.
These are from the hint space so are a nop on hardware that lacks BTI
support or if BTI isn't enabled.

Reviewed-by: Allan Jude <allan@klarasystems.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Tino Reichardt <milky-zfs@mcmilk.de>
Signed-off-by: Andrew Turner <andrew.turner4@arm.com>
Closes #14862
Closes #15339

9 months agoLinuxKPI: 802.11: fix re-creation of VAP
Bjoern A. Zeeb [Tue, 3 Oct 2023 21:14:55 +0000 (21:14 +0000)]
LinuxKPI: 802.11: fix re-creation of VAP

After dbf7691999abe (as indicated in that commit message) EEXISTS
errors may be seen.  From current investigation that is due to the
single-VAP support in LinuxKPI 802.11 and the related calls to
mo_start() and mo_stop() and them being disabled in ic_parent()
currently.  Calling mo_stop() in lkpi_ic_vap_delete() seems to
fix the problem and new VAPs (wlan interfaces) can be created again
after being destroyed.

Fixes: dbf7691999abe ("improve lkpi_ic_vap_delete()")
Sponsored by: The FreeBSD Foundation
MFC after: 3 days

9 months agolinuxkpi: Fix uses of `pmap_change_attr()`
Jean-Sébastien Pédron [Wed, 16 Aug 2023 20:32:42 +0000 (22:32 +0200)]
linuxkpi: Fix uses of `pmap_change_attr()`

[Why]
This function takes an offset and a length as argument, not a physical
address and a number of pages.

This misuse caused the `set_memory_*()` and
`arch_io_reserve_memtype_wc()` functions to return EINVAL.

Another problem was the fact that they returned errors as a positive
integer, whereas Linux uses negative integers.

[How]
Physical addresses and number of pages are converted to offset+length in
the `set_memory_*()` functions.

`arch_io_reserve_memtype_wc()` now calls `pmap_change_attr()` directly
instead of using `set_memory_wc()`.

Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D42053

9 months agosbuf.9: Add LIBRARY section
Mateusz Piotrowski [Tue, 3 Oct 2023 17:07:15 +0000 (19:07 +0200)]
sbuf.9: Add LIBRARY section

Sponsored by: Klara, Inc.
MFC after: 3 days

9 months agodtrace: fix fbt regression for aarch64
Igor Ostapenko [Tue, 3 Oct 2023 16:48:00 +0000 (19:48 +0300)]
dtrace: fix fbt regression for aarch64

fbt computes incorrect instruction position for AArch64 kernel module symbol.

The issue is with the for loop, it does an extra increment of instr pointer
after the required instruction is found. Hence, a wrong instruction is
targeted for patching.

Signed-off-by: Igor Ostapenko <pm@igoro.pro>
Fixes: 980746e5cb26 ("fbt: simplify arm64 function-prologue parsing")
Reviewed by: markj
Pull Request: https://github.com/freebsd/freebsd-src/pull/855
MFC after: 1 week

9 months agovfs cache: describe various optimization ideas
Mateusz Guzik [Tue, 3 Oct 2023 13:36:50 +0000 (13:36 +0000)]
vfs cache: describe various optimization ideas

While here report a sample result from running on Sapphire Rapids:

An access(2) loop slapped into will-it-scale, like so:
        while (1) {
                int error = access(tmpfile, R_OK);
                assert(error == 0);

                (*iterations)++;
        }

.. operating on /usr/obj/usr/src/amd64.amd64/sys/GENERIC/vnode_if.c

In operations per second:
lockless: 3462164
locked: 1362376

While the over 3.4 mln may seem like a big number, a critical look shows
it should be significantly higher.

A poor man's profiler, counting how many times given routine was sampled:
dtrace -w -n 'profile:::profile-4999 /execname == "a.out"/ {
@[sym(arg0)] = count(); } tick-5s { system("clear"); trunc(@, 40);
printa("%40a %@16d\n", @); clear(@); }'

[snip]
                    kernel`kern_accessat              231
           kernel`cpu_fetch_syscall_args              324
       kernel`cache_fplookup_cross_mount              340
                            kernel`namei              346
                    kernel`amd64_syscall              352
             kernel`tmpfs_fplookup_vexec              388
                             kernel`vput              467
                      kernel`vget_finish              499
                   kernel`lockmgr_unlock              529
                    kernel`lockmgr_slock              558
                    kernel`vget_prep_smr              571
                       kernel`vput_final              578
                           kernel`vdropl             1070
                           kernel`memcmp             1174
                     kernel`0xffffffff80             2080
                                     0x0             2231
                   kernel`copyinstr_smap             2492
                   kernel`cache_fplookup             9246

9 months agovfs cache: s/vfs.cache_fast_lookup/vfs.cache.param.fast_lookup
Mateusz Guzik [Tue, 3 Oct 2023 13:34:32 +0000 (13:34 +0000)]
vfs cache: s/vfs.cache_fast_lookup/vfs.cache.param.fast_lookup

9 months agolinux(4): Actually delete linux_sysproto.h
Dmitry Chagin [Tue, 3 Oct 2023 08:26:17 +0000 (11:26 +0300)]
linux(4): Actually delete linux_sysproto.h

MFC after: 1 week

9 months agoi2c: Add Microcrystal RV3032 RTC driver
Emmanuel Vadot [Wed, 27 Sep 2023 07:58:52 +0000 (09:58 +0200)]
i2c: Add Microcrystal RV3032 RTC driver

This is a simple RTC driver for the rv3032 from Microcrystal.
Just the basic functionality is implemented (no timer, alarm etc ..).

Sponsored by: Beckhoff Automation GmbH & Co. KG
Differential Revision: https://reviews.freebsd.org/D41995

9 months agoi2c: Add cadence iic driver
Emmanuel Vadot [Wed, 27 Sep 2023 05:34:38 +0000 (07:34 +0200)]
i2c: Add cadence iic driver

This IP is found in Xilinx SoC, it only been tested on ZynqMP (arm64)
so only enable it there for now.

Differential Revision: https://reviews.freebsd.org/D41994

9 months agoiicbus: Move opencores i2c driver into controller subdirectory
Emmanuel Vadot [Tue, 19 Sep 2023 10:06:32 +0000 (12:06 +0200)]
iicbus: Move opencores i2c driver into controller subdirectory

Sponsored by: Beckhoff Automation GmbH & Co. KG
Differential Revision: https://reviews.freebsd.org/D41914

9 months agoiicbus: Move i2c sensors drivers into new sensor subdirectory
Emmanuel Vadot [Tue, 19 Sep 2023 09:51:40 +0000 (11:51 +0200)]
iicbus: Move i2c sensors drivers into new sensor subdirectory

No reason that they should live directly under iicbus

Sponsored by:   Beckhoff Automation GmbH & Co. KG
Differential Revision: https://reviews.freebsd.org/D41913

9 months agoiicbus: conf: Fix pcf8574 entry
Emmanuel Vadot [Tue, 19 Sep 2023 08:39:26 +0000 (10:39 +0200)]
iicbus: conf: Fix pcf8574 entry

It lives in the gpio subdirectory

Sponsored by: Beckhoff Automation GmbH & Co. KG
Differential Revision: https://reviews.freebsd.org/D41912

9 months agoiicbus: Move ADC drivers into a new adc subfolder
Emmanuel Vadot [Tue, 19 Sep 2023 08:38:19 +0000 (10:38 +0200)]
iicbus: Move ADC drivers into a new adc subfolder

No reason that they should live directly under iicbus

Sponsored by:   Beckhoff Automation GmbH & Co. KG
Differential Revision: https://reviews.freebsd.org/D41911

9 months agoiicbus: Move adm1030 and adt746x to new pwm subdirectory
Emmanuel Vadot [Tue, 19 Sep 2023 08:04:02 +0000 (10:04 +0200)]
iicbus: Move adm1030 and adt746x to new pwm subdirectory

Those are (mainly) pwm controller so move it under a new subdirectory.

Sponsored by: Beckhoff Automation GmbH & Co. KG
Differential Revision: https://reviews.freebsd.org/D41910

9 months agoiicbus: Move Silergy pmic/regulators under pmic/silergy subdirectory
Emmanuel Vadot [Tue, 19 Sep 2023 07:56:02 +0000 (09:56 +0200)]
iicbus: Move Silergy pmic/regulators under pmic/silergy subdirectory

Sponsored by: Beckhoff Automation GmbH & Co. KG
Differential Revision: https://reviews.freebsd.org/D41909

9 months agoiicbus: Move remaining rtc driver into rtc subfolder
Emmanuel Vadot [Tue, 19 Sep 2023 07:49:45 +0000 (09:49 +0200)]
iicbus: Move remaining rtc driver into rtc subfolder

No reason that they should live directly under iicbus

Sponsored by: Beckhoff Automation GmbH & Co. KG
Differential Revision: https://reviews.freebsd.org/D41908

9 months agoiicbus: Move twsi under a new controller subdirectory
Emmanuel Vadot [Tue, 19 Sep 2023 07:43:37 +0000 (09:43 +0200)]
iicbus: Move twsi under a new controller subdirectory

The folder is a mess so start moving stuff into sub-directories.

Sponsored by: Beckhoff Automation GmbH & Co. KG
Differential Revision: https://reviews.freebsd.org/D41907

9 months agosysent: Trim trailing whitespaces
Dmitry Chagin [Tue, 3 Oct 2023 07:38:03 +0000 (10:38 +0300)]
sysent: Trim trailing whitespaces

MFC after: 1 week

9 months agolinux(4): Deorbit linux_nosys
Dmitry Chagin [Tue, 3 Oct 2023 07:38:03 +0000 (10:38 +0300)]
linux(4): Deorbit linux_nosys

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

9 months agolinux(4): Regen for linux_nosys change
Dmitry Chagin [Tue, 3 Oct 2023 07:38:03 +0000 (10:38 +0300)]
linux(4): Regen for linux_nosys change

MFC after: 1 week

9 months agolinux(4): Deorbit linux_nosys from syscalls.master
Dmitry Chagin [Tue, 3 Oct 2023 07:38:02 +0000 (10:38 +0300)]
linux(4): Deorbit linux_nosys from syscalls.master

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

9 months agotests: Test that SIGSYS is not delivered if kern.signosys knob is off
Dmitry Chagin [Tue, 3 Oct 2023 07:38:02 +0000 (10:38 +0300)]
tests: Test that SIGSYS is not delivered if kern.signosys knob is off

Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D41979
MFC after: 1 week

9 months agolibfetch: don't rely on ca_root_nss for certificate validation
Michael Osipov [Tue, 3 Oct 2023 05:53:20 +0000 (07:53 +0200)]
libfetch: don't rely on ca_root_nss for certificate validation

Before certctl(8), there was no system trust store, and libfetch
relied on the CA certificate bundle from the ca_root_nss port to
verify peers.

We now have a system trust store and a reliable mechanism for
manipulating it (to explicitly add, remove, or revoke certificates),
but if ca_root_nss is installed, libfetch will still prefer that to
the system trust store.

With this change, unless explicitly overridden, libfetch will rely on
OpenSSL to pick up the default system trust store.

PR: 256902
MFC after: 3 days
Reviewed by: kevans
Differential Revision: https://reviews.freebsd.org/D42059

9 months agocontrib: debian: drop bashcompletion mangling after install
Stoiko Ivanov [Wed, 20 Sep 2023 08:25:37 +0000 (10:25 +0200)]
contrib: debian: drop bashcompletion mangling after install

tested by running:
```
./configure --with-config=user; cp -a contrib/debian .
dpkg-buildpackage -b -uc -us
```
on a Debian 12 based system.

and checking where the completion file got installed.

Reviewed-by: Umer Saleem <usaleem@ixsystems.com>
Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
Closes #15304

9 months agocontrib: debian: switch to dh-sequence-dkms
Stoiko Ivanov [Thu, 21 Sep 2023 13:01:24 +0000 (15:01 +0200)]
contrib: debian: switch to dh-sequence-dkms

Follows b191f9a13d3005621ead9a727b811892264505ef from Debian's
packaging team at:
https://salsa.debian.org/zfsonlinux-team/zfs/

The previous build-dependency is kept as option, to still be able to
build on older Debian based distros (e.g. Ubuntu 20.04).

Without this building on Debian 12/bookworm does not work, as `dkms`
is a virtual package.

Reviewed-by: Umer Saleem <usaleem@ixsystems.com>
Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
Closes #15304

9 months agocontrib: bash_completion.d: make install destination vendor dependent
Stoiko Ivanov [Wed, 20 Sep 2023 17:33:14 +0000 (19:33 +0200)]
contrib: bash_completion.d: make install destination vendor dependent

Certain Linux distributions (Debian/Ubuntu at least) expect
bash-completion snippets to be installed in
/usr/share/bash-completion/completions instead of
/etc/bash_completion.d.

This patch sets the bashcompletiondir variable based on the vendor,
inspired by similar settings for initdir and initconfdir.

It seems that commit 612b8dff5bc3d827efb864a199a62bda1a419254
caused the file to be installed in the first-place (thus the error
when building debian packages only became apparent when testing a
2.2.0-rc4 build)

The change only sets the variable in Makefile context - the
rpm/zfs.spec.in file has the path hardcoded as
%{_sysconfdir}/bash_completion.d/zfs, but since running
```
./configure --sysconfdir=/myetc  ; make rpm
```
also results in all relevant files to be installed in /etc instead of
/myetc I assume this can remain as is.

Reviewed-by: Umer Saleem <usaleem@ixsystems.com>
Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
Closes #15304

9 months agoAdd '-u' - nomount flag for zfs set
Umer Saleem [Mon, 2 Oct 2023 23:58:54 +0000 (04:58 +0500)]
Add '-u' - nomount flag for zfs set

This commit adds '-u' flag for zfs set operation. With this flag,
mountpoint, sharenfs and sharesmb properties can be updated
without actually mounting or sharing the dataset.

Previously, if dataset was unmounted, and mountpoint property was
updated, dataset was not mounted after the update. This behavior
is changed in #15240. We mount the dataset whenever mountpoint
property is updated, regardless if it's mounted or not.

To provide the user with option to keep the dataset unmounted and
still update the mountpoint without mounting the dataset, '-u'
flag can be used.

If any of mountpoint, sharenfs or sharesmb properties are updated
with '-u' flag, the property is set to desired value but the
operation to (re/un)mount and/or (re/un)share the dataset is not
performed and dataset remains as it was before.

Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Umer Saleem <usaleem@ixsystems.com>
Closes #15322

9 months agoFix invalid pointer access in trace_dbuf.h
Chunwei Chen [Mon, 2 Oct 2023 23:58:01 +0000 (16:58 -0700)]
Fix invalid pointer access in trace_dbuf.h

In dnode_destroy, dn_objset is invalidated. However, it will later call
into dbuf_destroy, in which DTRACE_SET_STATE will try to access spa_name
via dn_objset causing illegal pointer access.

Reviewed-by: Brian Atkinson <batkinson@lanl.gov>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Chunwei Chen <david.chen@nutanix.com>
Closes #15333

9 months agoReport ashift of L2ARC devices in zdb
George Amanakis [Mon, 2 Oct 2023 23:57:09 +0000 (01:57 +0200)]
Report ashift of L2ARC devices in zdb

Commit 8af1104f does not actually store the ashift of cache devices in
their label. However, in order to facilitate reporting the ashift
through zdb, we enable this in the present commit. We also document
how the retrieval of the ashift is done.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: George Amanakis <gamanakis@gmail.com>
Closes #15331

9 months agoSIGSYS: add tests
Konstantin Belousov [Mon, 25 Sep 2023 18:40:28 +0000 (21:40 +0300)]
SIGSYS: add tests

Reviewed by: dchagin, markj
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D41976

9 months agolinuxolator: fix nosys() to not send SIGSYS
Konstantin Belousov [Mon, 25 Sep 2023 16:39:48 +0000 (19:39 +0300)]
linuxolator: fix nosys() to not send SIGSYS

Reviewed by: dchagin, markj
Discussed with: jhb
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D41976

9 months agonosys(): add kern.signosys tunable/sysctl to control SIGSYS
Konstantin Belousov [Mon, 25 Sep 2023 16:36:04 +0000 (19:36 +0300)]
nosys(): add kern.signosys tunable/sysctl to control SIGSYS

Reviewed by: dchagin, markj
Discussed with: jhb
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D41976

9 months agosysentvec: add SV_SIGSYS flag
Konstantin Belousov [Mon, 25 Sep 2023 16:33:36 +0000 (19:33 +0300)]
sysentvec: add SV_SIGSYS flag

to allow ABIs to indicate that SIGSYS is needed.  Mark all native
FreeBSD ABIs with the flag.

This implicitly marks Linux' ABIs as not delivering SIGSYS on invalid
syscall.

Reviewed by: dchagin, markj
Discussed with: jhb
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D41976

9 months agosyscalls: fix missing SIGSYS for several ENOSYS errors
Konstantin Belousov [Mon, 25 Sep 2023 16:32:52 +0000 (19:32 +0300)]
syscalls: fix missing SIGSYS for several ENOSYS errors

In particular, when the syscall number is too large, or when syscall is
dynamic.  For that, add nosys_sysent structure to pass fake sysent to
syscall top code.

Reviewed by: dchagin, markj
Discussed with: jhb
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D41976

9 months agoamd64 cpu_fetch_syscall_args_fallback(): fix whitespace
Konstantin Belousov [Tue, 26 Sep 2023 09:20:30 +0000 (12:20 +0300)]
amd64 cpu_fetch_syscall_args_fallback(): fix whitespace

Reviewed by: dchagin, markj
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D41976

9 months agolibprocstat: style: space after switch
Brooks Davis [Mon, 2 Oct 2023 21:50:00 +0000 (22:50 +0100)]
libprocstat: style: space after switch

Style demands a space after the switch keyword.

Noticed reviewing code in CheriBSD that propagated the style bug.

Reported by: markj
Sponsored by: DARPA
Reviewed by: kib, markj
Differential Revision: https://reviews.freebsd.org/D42041

9 months agogeli tests: Use shorter passphrases in setkey_passphrase
Mark Johnston [Mon, 2 Oct 2023 20:55:26 +0000 (16:55 -0400)]
geli tests: Use shorter passphrases in setkey_passphrase

There is an undocumented limit on the length of a GELI passphrase, and
the test exceeded that.  Most of the time it worked because a nul
terminator would appear early enough in the string.

Reported by: Jenkins
Fixes: 2b7b09ac9675 ("geli tests: Add a regression test for geli setkey -J")

9 months agologin_cap.c: Don't set errno to ERANGE on memory allocation failure
Olivier Certner [Thu, 25 May 2023 11:48:40 +0000 (13:48 +0200)]
login_cap.c: Don't set errno to ERANGE on memory allocation failure

Modified functions: login_getcaptime(), login_getcapnum(),
login_getcapsize().

They all call cgetstr(), which returns -2 on such conditions and already
sets errno to ENOMEM, arguably the appropriate value for these functions
as well.

No in-tree consumer currently checks for errno on error reported by
these functions, so this change has no other code impact.

Reviewed by:            kib
MFC after:              2 weeks
Sponsored by:           Kumacom SAS
Differential Revision:  https://reviews.freebsd.org/D40342

9 months agosetusercontext(): Fix gap when setting a realtime-class priority
Olivier Certner [Thu, 25 May 2023 07:10:27 +0000 (09:10 +0200)]
setusercontext(): Fix gap when setting a realtime-class priority

The login.conf's "priority" capability allows to set priorities in the
idle or realtime classes in addition to the classical nice values (-20
to 20), through a natural extension where values greater than 20 put the
processes in the idle class (with priority adjusted within RTP_PRIO_MIN
and RTP_PRIO_MAX, 21 being converted to 0, 22 to 1, etc.) and values
lower than -20 put the process in the realtime class (with priority
adjusted within RTP_PRIO_MIN and RTP_PRIO_MAX, -21 being converted to
RTP_PRIO_MAX (31), -22 to 30, etc.).

Before this fix, in the latter case (realtime class), -21 was converted
to 30, and RTP_PRIO_MAX (31) could never be specified.

While here, change the priority computation for the idle-class case to
be symmetrical and use RTP_PRIO_MIN (in practice, this changes nothing
at all, since RTP_PRIO_MIN is 0; but this is the correct theoretical
formula, which would work as well with other values of RTP_PRIO_MIN).

PR:                     271727
Reviewed by:            imp, kib
MFC after:              2 weeks
Sponsored by:           Kumacom SAS
Differential Revision:  https://reviews.freebsd.org/D40339

9 months agox86: AMD Zen2: Zenbleed chicken bit mitigation
Olivier Certner [Mon, 11 Sep 2023 14:18:30 +0000 (16:18 +0200)]
x86: AMD Zen2: Zenbleed chicken bit mitigation

Applies only to bare-metal Zen2 processors.  The system currently
automatically applies it to all of them.

Tunable/sysctl 'machdep.mitigations.zenbleed.enable' can be used to
forcibly enable or disable the mitigation at boot or run-time.  Possible
values are:

    0: Mitigation disabled
    1: Mitigation enabled
    2: Run the automatic determination.

Currently, value 2 is the default and has identical effect as value 1.
This might change in the future if we choose to take into account
microcode revisions in the automatic determination process.

The tunable/sysctl value is simply ignored on non-applicable CPU models,
which is useful to apply the same configuration on a set of machines
that do not all have Zen2 processors.  Trying to set it to any integer
value not listed above is silently equivalent to setting it to value 2
(automatic determination).

The current mitigation state can be queried through sysctl
'machdep.mitigations.zenbleed.state', which returns "Not applicable",
"Mitigation enabled" or "Mitigation disabled".  Note that this state is
not guaranteed to be accurate in case of intervening modifications of
the corresponding chicken bit directly via cpuctl(4) (this includes the
cpucontrol(8) utility).  Resetting the desired policy through
'machdep.mitigations.zenbleed.enable' (possibly to its current value)
will reset the hardware state and ensure that the reported state is
again coherent with it.

Reviewed by: kib
Sponsored by:   The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D41817

9 months agolib/libc/tests/string: expand memcmp test to bcmp, timingsafe_{b,mem}cmp
Robert Clausecker [Wed, 30 Aug 2023 15:30:24 +0000 (15:30 +0000)]
lib/libc/tests/string: expand memcmp test to bcmp, timingsafe_{b,mem}cmp

The four functions more or less perform the same operation.
Reuse the same unit test with slight changes so we can cover
them all.  Constant-time operation is not verified for the
timingsafe_* functions.

Sponsored by: The FreeBSD Foundation
Approved by: ngie
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D41528

9 months agolib/libc/tests/string/memcmp_test.c: extend test to support custom memcmp function
Robert Clausecker [Fri, 14 Jul 2023 11:56:12 +0000 (11:56 +0000)]
lib/libc/tests/string/memcmp_test.c: extend test to support custom memcmp function

Extend the tests to permit loading an external memcmp function
and testing it over using the libc version. This was added by the
example of other tests in the test suite doing the same thing and
helped tremendously in development.

This change was originally part of D41442 but was taken out to
permit separate review as extrapolated from @ngie's request in
D41349.

Sponsored by: FreeBSD Foundation
Approved by: ngie
Differential Revision: https://reviews.freebsd.org/D41528

9 months agoossl: Rebuild the openssl asm
Andrew Turner [Thu, 21 Sep 2023 13:06:54 +0000 (14:06 +0100)]
ossl: Rebuild the openssl asm

This adds the new BTI instructions when needed to the arm64 assembly.

Sponsored by: Arm Ltd

Reviewed by: Pierre Pronchery <pierre@freebsdfoundation.org> (earlier version)
Sponsored by: Arm Ltd
Differential Revision: https://reviews.freebsd.org/D41941

9 months agoaarch64: fix branch target indications in arm64cpuid.pl and keccak1600
Tom Cosgrove [Mon, 7 Feb 2022 14:44:56 +0000 (14:44 +0000)]
aarch64: fix branch target indications in arm64cpuid.pl and keccak1600

Add missing AARCH64_VALID_CALL_TARGET to armv8_rng_probe(). Also add
these to the functions defined by gen_random(), and note that this Perl
sub prints the assembler out directly, not going via the $code xlate
mechanism (and therefore coming before the include of arm_arch.h). So
fix this too.

In KeccakF1600_int, AARCH64_SIGN_LINK_REGISTER functions as
AARCH64_VALID_CALL_TARGET on BTI-only builds, so it needs to come before
the 'adr' line.

Change-Id: If241efe71591c88253a3e36647ced00300c3c1a3

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/17653)

Obtained from: OpenSSL 3a23f01268ec

9 months agoaarch64: support BTI and pointer authentication in assembly
Russ Butler [Sat, 28 Aug 2021 18:57:09 +0000 (13:57 -0500)]
aarch64: support BTI and pointer authentication in assembly

This change adds optional support for
- Armv8.3-A Pointer Authentication (PAuth) and
- Armv8.5-A Branch Target Identification (BTI)
features to the perl scripts.

Both features can be enabled with additional compiler flags.
Unless any of these are enabled explicitly there is no code change at
all.

The extensions are briefly described below. Please read the appropriate
chapters of the Arm Architecture Reference Manual for the complete
specification.

Scope
-----

This change only affects generated assembly code.

Armv8.3-A Pointer Authentication
--------------------------------

Pointer Authentication extension supports the authentication of the
contents of registers before they are used for indirect branching
or load.

PAuth provides a probabilistic method to detect corruption of register
values. PAuth signing instructions generate a Pointer Authentication
Code (PAC) based on the value of a register, a seed and a key.
The generated PAC is inserted into the original value in the register.
A PAuth authentication instruction recomputes the PAC, and if it matches
the PAC in the register, restores its original value. In case of a
mismatch, an architecturally unmapped address is generated instead.

With PAuth, mitigation against ROP (Return-oriented Programming) attacks
can be implemented. This is achieved by signing the contents of the
link-register (LR) before it is pushed to stack. Once LR is popped,
it is authenticated. This way a stack corruption which overwrites the
LR on the stack is detectable.

The PAuth extension adds several new instructions, some of which are not
recognized by older hardware. To support a single codebase for both pre
Armv8.3-A targets and newer ones, only NOP-space instructions are added
by this patch. These instructions are treated as NOPs on hardware
which does not support Armv8.3-A. Furthermore, this patch only considers
cases where LR is saved to the stack and then restored before branching
to its content. There are cases in the code where LR is pushed to stack
but it is not used later. We do not address these cases as they are not
affected by PAuth.

There are two keys available to sign an instruction address: A and B.
PACIASP and PACIBSP only differ in the used keys: A and B, respectively.
The keys are typically managed by the operating system.

To enable generating code for PAuth compile with
-mbranch-protection=<mode>:

- standard or pac-ret: add PACIASP and AUTIASP, also enables BTI
  (read below)
- pac-ret+b-key: add PACIBSP and AUTIBSP

Armv8.5-A Branch Target Identification
--------------------------------------

Branch Target Identification features some new instructions which
protect the execution of instructions on guarded pages which are not
intended branch targets.

If Armv8.5-A is supported by the hardware, execution of an instruction
changes the value of PSTATE.BTYPE field. If an indirect branch
lands on a guarded page the target instruction must be one of the
BTI <jc> flavors, or in case of a direct call or jump it can be any
other instruction. If the target instruction is not compatible with the
value of PSTATE.BTYPE a Branch Target Exception is generated.

In short, indirect jumps are compatible with BTI <j> and <jc> while
indirect calls are compatible with BTI <c> and <jc>. Please refer to the
specification for the details.

Armv8.3-A PACIASP and PACIBSP are implicit branch target
identification instructions which are equivalent with BTI c or BTI jc
depending on system register configuration.

BTI is used to mitigate JOP (Jump-oriented Programming) attacks by
limiting the set of instructions which can be jumped to.

BTI requires active linker support to mark the pages with BTI-enabled
code as guarded. For ELF64 files BTI compatibility is recorded in the
.note.gnu.property section. For a shared object or static binary it is
required that all linked units support BTI. This means that even a
single assembly file without the required note section turns-off BTI
for the whole binary or shared object.

The new BTI instructions are treated as NOPs on hardware which does
not support Armv8.5-A or on pages which are not guarded.

To insert this new and optional instruction compile with
-mbranch-protection=standard (also enables PAuth) or +bti.

When targeting a guarded page from a non-guarded page, weaker
compatibility restrictions apply to maintain compatibility between
legacy and new code. For detailed rules please refer to the Arm ARM.

Compiler support
----------------

Compiler support requires understanding '-mbranch-protection=<mode>'
and emitting the appropriate feature macros (__ARM_FEATURE_BTI_DEFAULT
and __ARM_FEATURE_PAC_DEFAULT). The current state is the following:

-------------------------------------------------------
| Compiler | -mbranch-protection | Feature macros     |
+----------+---------------------+--------------------+
| clang    | 9.0.0               | 11.0.0             |
+----------+---------------------+--------------------+
| gcc      | 9                   | expected in 10.1+  |
-------------------------------------------------------

Available Platforms
------------------

Arm Fast Model and QEMU support both extensions.

https://developer.arm.com/tools-and-software/simulation-models/fast-models
https://www.qemu.org/

Implementation Notes
--------------------

This change adds BTI landing pads even to assembly functions which are
likely to be directly called only. In these cases, landing pads might
be superfluous depending on what code the linker generates.
Code size and performance impact for these cases would be negligible.

Interaction with C code
-----------------------

Pointer Authentication is a per-frame protection while Branch Target
Identification can be turned on and off only for all code pages of a
whole shared object or static binary. Because of these properties if
C/C++ code is compiled without any of the above features but assembly
files support any of them unconditionally there is no incompatibility
between the two.

Useful Links
------------

To fully understand the details of both PAuth and BTI it is advised to
read the related chapters of the Arm Architecture Reference Manual
(Arm ARM):
https://developer.arm.com/documentation/ddi0487/latest/

Additional materials:

"Providing protection for complex software"
https://developer.arm.com/architectures/learn-the-architecture/providing-protection-for-complex-software

Arm Compiler Reference Guide Version 6.14: -mbranch-protection
https://developer.arm.com/documentation/101754/0614/armclang-Reference/armclang-Command-line-Options/-mbranch-protection?lang=en

Arm C Language Extensions (ACLE)
https://developer.arm.com/docs/101028/latest

Addional Notes
--------------

This patch is a copy of the work done by Tamas Petz in boringssl. It
contains the changes from the following commits:

aarch64: support BTI and pointer authentication in assembly
    Change-Id: I4335f92e2ccc8e209c7d68a0a79f1acdf3aeb791
    URL: https://boringssl-review.googlesource.com/c/boringssl/+/42084
aarch64: Improve conditional compilation
    Change-Id: I14902a64e5f403c2b6a117bc9f5fb1a4f4611ebf
    URL: https://boringssl-review.googlesource.com/c/boringssl/+/43524
aarch64: Fix name of gnu property note section
    Change-Id: I6c432d1c852129e9c273f6469a8b60e3983671ec
    URL: https://boringssl-review.googlesource.com/c/boringssl/+/44024

Change-Id: I2d95ebc5e4aeb5610d3b226f9754ee80cf74a9af

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/16674)

Reviewed by: emaste, Pierre Pronchery <pierre@freebsdfoundation.org>
Obtained from: OpenSSL 19e277dd19f2
Differential Revision: https://reviews.freebsd.org/D41940

9 months agonvme: Fix memory leak in pt ioctl commands
David Sloan [Thu, 7 Sep 2023 16:22:21 +0000 (10:22 -0600)]
nvme: Fix memory leak in pt ioctl commands

When running nvme passthrough commands through the ioctl interface
memory is mapped with vmapbuf() but not unmapped. This results in leaked
memory whenever a process executes an nvme passthrough command with a
data buffer. This can be replicated with a simple c function (error
checks skipped for brevity):

void leak_memory(int nvme_ns_fd, uint16_t nblocks) {
struct nvme_pt_command pt = {
.cmd = {
.opc = NVME_OPC_READ,
.cdw12 = nblocks - 1,
},
.len = nblocks * 512, // Assumes devices with 512 byte lba
.is_read = 1, // Reads and writes should both trigger leak
}
void *buf;

posix_memalign(&buf, nblocks * 512);
pt.buf = buf;
ioctl(nvme_ns_fd, NVME_PASSTHROUGH_COMMAND, &pt);
free(buf);
}

Signed-off-by: David Sloan <david.sloan@eideticom.com>
PR: 273626
Reviewed by: imp, markj
MFC after: 1 week

9 months agonet80211 / drivers: remove public use of ieee80211_node_incref()
Bjoern A. Zeeb [Mon, 2 Oct 2023 14:44:29 +0000 (14:44 +0000)]
net80211 / drivers: remove public use of ieee80211_node_incref()

ieee80211_node_incref() is the FreeBSD implementation of
ieee80211_ref_node().  Not being interested in the node returned
it was used as a shortcut in 3 drivers (ath, uath, wpi).
Replace the call with the public KPI of ieee80211_ref_node() and
ignore the result.
This leaves us with the single internal call going
ieee80211_ref_node() -> ieee80211_node_incref() and that should
help increasing portability but also limiting the places to trace
for node reference operations.

Sponsored by: The FreeBSD Foundation
MFC after: 4 weeks

9 months agonet80211: make ieee80211_alloc_node() private
Bjoern A. Zeeb [Mon, 2 Oct 2023 13:57:45 +0000 (13:57 +0000)]
net80211: make ieee80211_alloc_node() private

Looking through the allocation/free and reference cycle of nodes we have
a few (publicly) (almost) unused macros and functions.
Start making them private and reducing the amount of entry paths to the
same/similar functionality.
First is to make ieee80211_alloc_node() static as it is nowhere used
in the tree outside this file.

Sponsored by: The FreeBSD Foundation
X-MFC: no

9 months agonet80211: improve ddb output for sta and rate
Bjoern A. Zeeb [Mon, 2 Oct 2023 13:53:33 +0000 (13:53 +0000)]
net80211: improve ddb output for sta and rate

Add more missing fields to the ddb output of sta (including spares so
people will notice if they use them to adjust ddb as well).
There are still more missing fields (some left as reminder in an
uncompiled __notyet__ block).

Add _db_show_rate() to print iv_rate as well optionally including
function pointers.

Sponsored by: The FreeBSD Foundation
MFC after: 3 days

9 months agoofwdump: install dependent on MK_FDT
Mitchell Horne [Mon, 2 Oct 2023 13:40:18 +0000 (10:40 -0300)]
ofwdump: install dependent on MK_FDT

The utility depends on the presence of the openfirm(4) pseudo-device,
which is gated by the FDT kernel option. The MK_FDT knob is correctly
set to "yes" for FDT/OFW-enabled platforms (powerpc* included); use it
to install the utility and eliminate the arch-specific Makefile logic.

No functional change intended.

Reviewed by: emaste, pkubaj
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D41977

9 months agonetdump: Check the return value of ifunit_ref()
Mark Johnston [Mon, 2 Oct 2023 12:08:20 +0000 (08:08 -0400)]
netdump: Check the return value of ifunit_ref()

We may fail to match if the specific interface doesn't exist or was
renamed.

PR: 273715
Reported by: grembo
MFC after: 1 week

9 months agoswap_pager: Fix a race in swap_pager_swapoff_object()
Mark Johnston [Mon, 2 Oct 2023 11:49:27 +0000 (07:49 -0400)]
swap_pager: Fix a race in swap_pager_swapoff_object()

When we disable swapping to a device, we scan the full VM object list
looking for objects with swap trie nodes that reference the device in
question.  The pages corresponding to those nodes are paged in.

While paging in, we drop the VM object lock.  Moreover, we do not hold a
reference for the object; swap_pager_swapoff_object() merely bumps the
paging-in-progress counter.  vm_object_terminate() waits for this
counter to drain before proceeding and freeing pages.

However, swap_pager_swapoff_object() decrements the counter before
re-acquiring the VM object lock, which means that vm_object_terminate()
can race to acquire the lock and free the pages.  Then,
swap_pager_swapoff_object() ends up unbusying a freed page.  Fix the
problem by acquiring the lock before waking up sleepers.

PR: 273610
Reported by: Graham Perrin <grahamperrin@gmail.com>
Reviewed by: kib
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D42029

10 months agoObsoleteFiles.inc: only leave ofwdump.8.gz when WITH_FDT is set
Piotr Kubaj [Sun, 1 Oct 2023 21:36:37 +0000 (23:36 +0200)]
ObsoleteFiles.inc: only leave ofwdump.8.gz when WITH_FDT is set

Approved by: mhorne
Differential Revision: https://reviews.freebsd.org/D41905
MFC after: 3 days

10 months agomakefs/zfs: fix build with gcc 12 after b5a2bf512dbe
Dimitry Andric [Sat, 30 Sep 2023 18:27:20 +0000 (20:27 +0200)]
makefs/zfs: fix build with gcc 12 after b5a2bf512dbe

Due to integer promotion rules, dn_nlevels (uint8_t) gets promoted to a
plain int, resulting in -Werror warnings with gcc 12:

  In file included from /workspace/src/usr.sbin/makefs/zfs.c:35:
  /workspace/src/usr.sbin/makefs/zfs.c: In function '_dnode_cursor_flush':
  /workspace/src/usr.sbin/makefs/zfs.c:684:23: error: comparison of integer expressions of different signedness: 'unsigned int' and 'int' [-Werror=sign-compare]
    684 |         assert(levels <= c->dnode->dn_nlevels - 1);
        |                       ^~
  /workspace/src/usr.sbin/makefs/zfs.c:691:27: error: comparison of integer expressions of different signedness: 'unsigned int' and 'int' [-Werror=sign-compare]
    691 |                 if (level == c->dnode->dn_nlevels - 1) {
        |                           ^~
  /workspace/src/usr.sbin/makefs/zfs.c: In function 'dnode_cursor_next':
  /workspace/src/usr.sbin/makefs/zfs.c:739:41: error: comparison of integer expressions of different signedness: 'unsigned int' and 'int' [-Werror=sign-compare]
    739 |                 for (levels = 0; levels < c->dnode->dn_nlevels - 1; levels++) {
        |                                         ^

Fix it by subtracting 1U instead of 1.

Fixes: b5a2bf512dbe
MFC after: 3 days

10 months agoLinuxKPI: 802.11: improve lkpi_ic_vap_delete()
Bjoern A. Zeeb [Sat, 30 Sep 2023 15:20:53 +0000 (15:20 +0000)]
LinuxKPI: 802.11: improve lkpi_ic_vap_delete()

Changing the order of cleanup in lkpi_ic_vap_delete() will avoid
firmware crashes or a direct panic as observed as ieee80211_vap_detach()
will do most cleanup for us and get us into the correct state.

The solution is not fully developed yet and one may not be able
to create a new vap (lkpi_ic_vap_create may fail with error 17)
afterwards.  It is supposed to be a step towards more stability
for now.

Sponsored by: The FreeBSD Foundation
MFC after: 3 days
PR:  269842

10 months agoLinuxKPI: 802.11: fix problem removing sta
Bjoern A. Zeeb [Sat, 30 Sep 2023 07:59:48 +0000 (07:59 +0000)]
LinuxKPI: 802.11: fix problem removing sta

Move the call to lkpi_disassoc() before the state change to
IEEE80211_STA_NOTEXIST which will remove the sta (from firmware).
Based on a comment it seems that originally we had to do it the
other way round.
iwlwifi(4) has a check and will silently not remove the sta from
the firmware when vif->cfg.assoc is still set (see iwl_mvm_sta_del()).
This leads to the LinuxKPI 802.11 code thinking the sta is gone as
downward state changes by the mac80211 op (*sta_state)() may not fail.
Once we try to assoc with a newly added station later, iwlwifi firmware
will run into an assert having two ap_sta set on the same vif.
We can observe that problem in iwlwifi(4) having __le32 sta_id = 1
instead of sta_id = 0 in iwl_mvm_sta_cfg_cmd{} on the HCMD.

This should fix one of the most seen problems with iwlwifi(4), e.g.,
when running service netif restart wlan0 or
service wpa_supplicant restart wlan0.

Sponsored by: The FreeBSD Foundation
MFC after: 3 days