]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
6 months agocp: Refactor the core logic.
Dag-Erling Smørgrav [Wed, 13 Dec 2023 23:40:45 +0000 (00:40 +0100)]
cp: Refactor the core logic.

Rewrite `copy_file()` so the lflag and sflag are handled as early as
possible instead of constantly checking that they're not set and then
handling them at the end.  This also opens the door to changing the
failure logic at some future point (for instance, we might decide to
fall back to copying if `errno` indicates that the file system does not
support links).

MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: kevans, allanjude
Differential Revision: https://reviews.freebsd.org/D43055

6 months agocp: Add tests for symbolic link case.
Dag-Erling Smørgrav [Wed, 13 Dec 2023 23:33:29 +0000 (00:33 +0100)]
cp: Add tests for symbolic link case.

MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: kevans, allanjude
Differential Revision: https://reviews.freebsd.org/D43054

6 months agoMake kldxref a bootstrap tool and use unconditionally
Jessica Clarke [Wed, 13 Dec 2023 21:43:10 +0000 (21:43 +0000)]
Make kldxref a bootstrap tool and use unconditionally

Now that kldxref is a generic cross tool and can be built on non-FreeBSD
we can bootstrap it during the build and thus remove the condition for
whether it exists. We also need to make sure to add it to the METALOG
for -DNO_ROOT builds.

Reviewed by: brooks, imp
Differential Revision: https://reviews.freebsd.org/D43051

6 months agoMakefile.inc1: Forward on METALOG and DISTBASE for kernel targets
Jessica Clarke [Wed, 13 Dec 2023 21:43:09 +0000 (21:43 +0000)]
Makefile.inc1: Forward on METALOG and DISTBASE for kernel targets

Currently IMAKE_INSTALL, which includes -M METALOG, is enough for the
sub-makes to work, but using kldxref for -DNO_ROOT builds will require
manually adding linker.hints to the METALOG, and thus both METALOG
itself and DISTBASE need to be exposed directly to the sub-makes, so do
so.

Reviewed by: brooks
Differential Revision: https://reviews.freebsd.org/D43050

6 months agotools/build: Provide sys/linker_set.h when cross-building
Jessica Clarke [Wed, 13 Dec 2023 21:43:09 +0000 (21:43 +0000)]
tools/build: Provide sys/linker_set.h when cross-building

This is needed for kldxref, which will shortly become a bootstrap tool.
Linux can use the same one as FreeBSD (provided the cross-building
sys/cdefs.h is augmented appropriately), whilst macOS needs its own
Mach-O-specific implementation.

Reviewed by: brooks
Differential Revision: https://reviews.freebsd.org/D43049

6 months agocp: Add tests for hard link case.
Dag-Erling Smørgrav [Wed, 13 Dec 2023 21:31:05 +0000 (22:31 +0100)]
cp: Add tests for hard link case.

MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: kevans
Differential Revision: https://reviews.freebsd.org/D43052

6 months agokldxref: Cast rtype to int in ef_aarch64.c in warning
John Baldwin [Wed, 13 Dec 2023 20:17:44 +0000 (12:17 -0800)]
kldxref: Cast rtype to int in ef_aarch64.c in warning

This is consistent with the other architecture-specific relocation
handlers.

Reported by: mjg
Sponsored by: DARPA

6 months agolibicp(_rescue)?: use asm versions for all 32-bit arm flavors
Dimitry Andric [Wed, 13 Dec 2023 18:59:31 +0000 (19:59 +0100)]
libicp(_rescue)?: use asm versions for all 32-bit arm flavors

OpenZFS upstream refactored the asm versions of sha2 to be usable on all
32-bit arm flavors, so it is not necessary to limit this to armv6 and
armv7.

Suggested by: jhb

6 months agolinuxkpi: Add `struct kset` support in <linux/kobject.h>
Jean-Sébastien Pédron [Fri, 8 Dec 2023 21:51:10 +0000 (22:51 +0100)]
linuxkpi: Add `struct kset` support in <linux/kobject.h>

[Why]
The amdgpu DRM driver started to use it in Linux 5.18.

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

6 months agolinuxkpi: Include <linux/string_helpers.h> from <linux/seq_file.h>
Jean-Sébastien Pédron [Sat, 9 Dec 2023 16:28:53 +0000 (17:28 +0100)]
linuxkpi: Include <linux/string_helpers.h> from <linux/seq_file.h>

[Why]
The i915 DRM driver in Linux 5.18 relies on this indirect include.

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

6 months agolinuxkpi: Add <linux/string_helpers.h> and str_yes_no()
Jean-Sébastien Pédron [Mon, 4 Dec 2023 21:16:37 +0000 (22:16 +0100)]
linuxkpi: Add <linux/string_helpers.h> and str_yes_no()

[Why]
This header and str_yes_no() are now used by the i915 DRM driver in
Linux 5.18.

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

6 months agoProactively remove libc++ __tuple header file that became a directory
Dimitry Andric [Wed, 13 Dec 2023 18:53:17 +0000 (19:53 +0100)]
Proactively remove libc++ __tuple header file that became a directory

This was already handled in ObsoleteFiles.inc (see the 20230622 entry),
but some people never run "make delete-old", or want to upgrade directly
from a revision that still had libc++ 15 to the most recent revision.

They would then encounter a failure during installworld, similar to:

  install: target directory `/usr/include/c++/v1/__tuple/' does not exist

Therefore, clean it up in the distrib-cleanup phase, similar to the
earlier instance of the libc++ __string header file that became a
directory.

PR: 273753
MFC after: 1 month

6 months agolinuxkpi: Add support for `suspend_noirq` callback in `struct dev_pm_ops`
Jean-Sébastien Pédron [Sat, 9 Dec 2023 16:24:20 +0000 (17:24 +0100)]
linuxkpi: Add support for `suspend_noirq` callback in `struct dev_pm_ops`

[Why]
This callback is being used by the amdgpu DRM driver in Linux 5.18.

[How]
The callback is called after `suspend_late()`.

Reviewed by: emaste, manu
Approved by: emaste, manu
Differential Revision: https://reviews.freebsd.org/D43029

6 months agolinuxkpi: Add <video/of_display_timing.h> to dummy headers
Jean-Sébastien Pédron [Sat, 9 Dec 2023 14:40:10 +0000 (15:40 +0100)]
linuxkpi: Add <video/of_display_timing.h> to dummy headers

[Why]
This header is being used by DRM drivers in Linux 5.18.

Reviewed by: emaste, manu
Approved by: emaste, manu
Differential Revision: https://reviews.freebsd.org/D43028

6 months agolinuxkpi: Fix `__ATTR_RO()` in <linux/sysfs.h>
Jean-Sébastien Pédron [Fri, 8 Dec 2023 21:57:24 +0000 (22:57 +0100)]
linuxkpi: Fix `__ATTR_RO()` in <linux/sysfs.h>

[Why]
The passed structure may not have a `.store` field. This is the case in
the amdgpu DRM driver starting with Linux 5.18.

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

6 months agolinuxkpi: Add `sysfs_create_link()` in <linux/sysfs.h>
Jean-Sébastien Pédron [Fri, 8 Dec 2023 21:54:29 +0000 (22:54 +0100)]
linuxkpi: Add `sysfs_create_link()` in <linux/sysfs.h>

[Why]
The amdgpu DRM driver started to use it in Linux 5.18.

[How]
The function is a no-op as I'm not sure how to implement this with
sysctls yet.

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

6 months agolinuxkpi: Add `list_for_each_prev_safe()` in <linux/list.h>
Jean-Sébastien Pédron [Fri, 8 Dec 2023 21:53:21 +0000 (22:53 +0100)]
linuxkpi: Add `list_for_each_prev_safe()` in <linux/list.h>

[Why]
The amdgpu DRM driver started to use it in Linux 5.18.

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

6 months agolinuxkpi: Move `struct kobject` code to `linux_kobject.c`
Jean-Sébastien Pédron [Fri, 8 Dec 2023 17:58:03 +0000 (18:58 +0100)]
linuxkpi: Move `struct kobject` code to `linux_kobject.c`

[Why]
`linux_compat.c` is already too long. I will need to add `struct kset`
in a follow-up commit, so let's move the existing `struct kobject` code
to its own file.

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

6 months agolinuxkpi: Move `invalidate_mapping_pages()` to <linux/pagemap.h>
Jean-Sébastien Pédron [Fri, 8 Dec 2023 17:07:00 +0000 (18:07 +0100)]
linuxkpi: Move `invalidate_mapping_pages()` to <linux/pagemap.h>

[Why]
This is consistent with Linux.

[How]
The definition is moved from <linux/shmem_fs.h> to <linux/pagemap.h> and
the latter is included from the former. This is how it is done on Linux.

Prototypes are also expanded with argument names. I got a build failure
in the DRM 5.18 drivers because the compiler considered that the
`pgoff_t` argument was there twice.

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

6 months agolinuxkpi: Include <linux/types.h> from <linux/cc_platform.h>
Jean-Sébastien Pédron [Mon, 4 Dec 2023 22:02:02 +0000 (23:02 +0100)]
linuxkpi: Include <linux/types.h> from <linux/cc_platform.h>

[Why]
We need this for the `bool` type.

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

6 months agoMakefile.inc1: Reinstate building sbin/md5 for BOOTSTRAP_ALL_TOOLS
Jessica Clarke [Wed, 13 Dec 2023 18:02:45 +0000 (18:02 +0000)]
Makefile.inc1: Reinstate building sbin/md5 for BOOTSTRAP_ALL_TOOLS

The sha256 and sha512 binaries are used when building release images.
Bootstrapping them used to be gated on MK_BOOT, which wasn't quite right
but in practice worked, at least in our use cases downstream. Add back
bootstrapping sbin/md5 and its aliases for this purpose to fix building
release images on Linux and macOS.

Fixes: f213da893ca8 ("Makefile.inc1: Remove beri straggler")

6 months agoloader: lua: remove the default kernel if it doesn't exist
Kyle Evans [Wed, 13 Dec 2023 16:52:14 +0000 (10:52 -0600)]
loader: lua: remove the default kernel if it doesn't exist

The `kernel` env var provides the default kernel, usually "kernel".  It
may be the case that the user doesn't have a "kernel" kernel, just
"kernel.*" kernels, but have left `kernel` to the default because we
autodetect entries by default anyways.

If we're doing autodetection, take note of whether the default kernel
exists or not and remove it from the list if it doesn't and we had found
any other kernels.  We avoid it in the #kernels == 1 case because
something fishy has likely happened and we should just trust the
configuration.

Reviewed by: imp, manu
Differential Revision: https://reviews.freebsd.org/D42967

6 months agokdump: use print_mask_arg0 appropriately
Kyle Evans [Wed, 13 Dec 2023 16:49:03 +0000 (10:49 -0600)]
kdump: use print_mask_arg0 appropriately

Some callers are using print_mask_arg() when they should be using
print_mask_arg0(); the latter should be used when all flags are optional
and there's not a flag to be decoded with a 0-mask.  This turns:

nmount(0x6991e009000,0x8,0<><invalid>0)

into:

nmount(0x6991e009000,0x8,0)

Reviewed by: jhb
Differential Revision: https://reviews.freebsd.org/D43007

6 months agoqat: Update firmware for 4xxx devices to version 1.1.20
Michal Gulbicki [Mon, 20 Nov 2023 15:25:57 +0000 (16:25 +0100)]
qat: Update firmware for 4xxx devices to version 1.1.20

Key features:
- added zeropadding feature for compression
- added partial decompression support
- added DC rate limiting support
- added Admin ME capabilities reporting
- added Hash+Compress chaining support

MFC after: 2 weeks
Sponsored by: Intel Corporation
Differential Revision: https://reviews.freebsd.org/D42864

6 months agokldxref: fix build on 32 bits arches
Baptiste Daroussin [Wed, 13 Dec 2023 08:19:18 +0000 (09:19 +0100)]
kldxref: fix build on 32 bits arches

6 months agoCirrus-CI: stop forcibly installing pkg
Ed Maste [Sat, 9 Dec 2023 22:12:33 +0000 (17:12 -0500)]
Cirrus-CI: stop forcibly installing pkg

Updated pkg is now in quarterly and there is no need to forcibly
install a specific version.

This reverts commit 1c376684c7441a90e64f082c19e3da7942716ad1.
This reverts commit 3c097b06a71715ec9ae86430ee94e25e954a1e36.

Reported by: bapt
Sponsored by: The FreeBSD Foundation

6 months agokldxref: Make use of libelf to be a portable cross tool
John Baldwin [Tue, 12 Dec 2023 23:43:00 +0000 (15:43 -0800)]
kldxref: Make use of libelf to be a portable cross tool

This allows kldxref to operate on kernel objects from any
architecture, not just the native architecture.  In particular, this
will permit generating linker.hints files as part of a cross-arch
release build.

- elf.c is a new file that includes various wrappers around libelf
  including routines to read ELF data structures such as program and
  section headers and ELF relocations into the "generic" forms
  described in <gelf.h>.  This file also provides routines for
  converting a linker set into an array of addresses (GElf_Addr)
  as well as reading architecture-specific mod_* structures and
  converting them into "generic" Gmod_* forms where pointers are
  replaced with addresses.

- The various architecture-specific reloc handlers now use GElf_*
  types for most values (including GElf_Rel and GElf_Rela for
  relocation structures) and use routines from <sys/endian.h> to read
  and write target values.  A new linker set matches reloc handlers
  to specific ELF (class, encoding, machine) tuples.

- The bits of kldxref.c that write out linker.hints now use the
  encoding (ELFDATA2[LM]SB) of the first file encountered in a
  directory to set the endianness of the output file.  Input files
  with a different architecture in the same directory are skipped with
  a warning.  In addition, the initial version record for the file
  must be deferred until the first record is finished since the
  architecture of the output file is not known until then.

- Various places that used 'sizeof(void *)' throughout now use
  'elf_pointer_size()' to determine the size of a pointer in the
  target architecture.

Tested by: amd64 binary on both amd64 and i386 /boot/kernel
Reviewed by: imp
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D42966

6 months agokldxref: Refactor PNP entry parsing, no functional change
John Baldwin [Tue, 12 Dec 2023 23:30:16 +0000 (15:30 -0800)]
kldxref: Refactor PNP entry parsing, no functional change

- Add a free_pnp_list to complement parse_pnp_list.  Add freeing
  of 'new_desc' which was previously leaked.

- Move body of loop that checked a single pnp list element against a
  table entry into a parse_pnp_entry function to reduce indentation
  and split parse_entry into a smaller function.

- Similarly, split out a record_pnp_info function from parse_entry
  which builds the pnp_list and walks a table.

Reviewed by: imp
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D42965

6 months agoStop #defining FREEBSD_ELF
John Baldwin [Tue, 12 Dec 2023 23:30:00 +0000 (15:30 -0800)]
Stop #defining FREEBSD_ELF

This was originally used (along with FREEBSD_AOUT) to prefer the use
of ELF in various tools instead of a.out as part of the a.out to ELF
transition in the 3.x days.  The last use of it was removed from
<link.h> in commit 66422f5b7a1a6055f0b2358268eb902aab6e2e3e back in
2002, but various files still #define it.

Reviewed by: kevans, imp, emaste
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D42964

6 months agokldxref: Add a copyright and license statement to ef.h
John Baldwin [Tue, 12 Dec 2023 23:29:43 +0000 (15:29 -0800)]
kldxref: Add a copyright and license statement to ef.h

This uses the statement from other files in kldxref when the tool was
first imported in commit 9c6f92408c29a8980e7aec26a2590087c3b3d8ed.

Reviewed by: kevans
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D42963

6 months agobhyve: refactor gdbstub to enable single-stepping on AMD CPUs
Bojan Novković [Tue, 12 Dec 2023 23:28:59 +0000 (15:28 -0800)]
bhyve: refactor gdbstub to enable single-stepping on AMD CPUs

This patch refactors the existing Intel-specific single-stepping
mechanism in bhyve's GDB stub to work with both AMD and Intel CPUs.

Reviewed by: jhb
Sponsored by: Google, Inc. (GSoC 2022)
Differential Revision: https://reviews.freebsd.org/D42298

6 months agolibc/i386/SYS.h: Remove unused LCALL macro
Brooks Davis [Tue, 12 Dec 2023 22:53:09 +0000 (22:53 +0000)]
libc/i386/SYS.h: Remove unused LCALL macro

It appears that the only user of this macro was removed
with support for building a.out binaries in 2002 by commit
66422f5b7a1a6055f0b2358268eb902aab6e2e3e.

Reviewed by: imp, kib
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D42997

6 months agolibc/*/SYS.h: remove SYCALL macro
Brooks Davis [Tue, 12 Dec 2023 22:52:41 +0000 (22:52 +0000)]
libc/*/SYS.h: remove SYCALL macro

This has not been a univerally available interface since it was removed
from amd64 by commit efbef97de9805dec95db09953426f0b21bb2964f in 2004.
I removed the last consumers in 2016 when I replaced pipe(2) with
pipe2(2) in commit b60998c6331e2be21f1fc29fa6c82d94a1f72ef0.

Reviewed by: imp, jhibbits
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D42996

6 months agonetlink: fix snl_writer and linear_buffer re-allocation logic
Igor Ostapenko [Tue, 12 Dec 2023 18:26:21 +0000 (19:26 +0100)]
netlink: fix snl_writer and linear_buffer re-allocation logic

- Use the correct base pointer after re-allocation to avoid buffer
  overflows.

- Maintain correct snl_writer.size, which avoids redundant memory
  allocation, e.g. a need for ~1k bytes may end up with ~32k
  linear_buffer actually allocated.

This fixes a pfctl regression at least for armv7 after the addrule logic
migration to netlink:
  ffbf25951e7b ("pf: convert rule addition to netlink")

The add rule command creates a bigger than default size netlink requests
which triggers the re-allocation logic.

Reviewed by: kp
MFC after: 2 weeks
Differnetial Revision: https://reviews.freebsd.org/D43003

6 months agonfsclient: Propagate copyin() errors from nfsm_uiombuf()
Mark Johnston [Tue, 12 Dec 2023 01:04:56 +0000 (20:04 -0500)]
nfsclient: Propagate copyin() errors from nfsm_uiombuf()

Approved by: so
Security: SA-23:18.nfsclient
Reviewed by: rmacklem
Sponsored by: The FreeBSD Foundation

6 months agoocs_fc: IO timeout handling and error reporting fix.
Ram Kishore Vegesna [Tue, 12 Dec 2023 15:22:58 +0000 (10:22 -0500)]
ocs_fc: IO timeout handling and error reporting fix.

Hardware timeout uses a 8-bit timeout value and expects the timeout to
be less than 255 seconds. Added software timer implemetation to timeout
and abort the IOs with timeout more than 255 seconds.

Fix the timeout problem by dividing CAM timeouts by 1000 as hardware
expects timeout value in seconds.  Before this change, CAM timeouts in
milliseconds were getting truncated to 8 bits and converted to seconds.
So the actual timeout used when going down to the card would depend on
the bottom 8 bits of the timeout used.

Add the mapping of ocs_fc error status to CAM status.

Reported by: ken
Reviewed by: ken
Tested by: ken, ram
Approved by: ken
MFC after: 1 week

6 months agotcp stacks: in kernel BBR and RACK require in kernel HPTS
Michael Tuexen [Tue, 12 Dec 2023 11:01:37 +0000 (12:01 +0100)]
tcp stacks: in kernel BBR and RACK require in kernel HPTS

Compiling the BBR or RACK stack into the kernel requires HPTS to be
compiled into the kernel.

Reviewed by: glebius, rscheff
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D42998

6 months agojevents: fix bootstrapping on Linux with Clang 16
Alex Richardson [Tue, 12 Dec 2023 05:10:14 +0000 (21:10 -0800)]
jevents: 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.

Reviewed By: imp, emaste
Differential Revision: https://reviews.freebsd.org/D43000

6 months agomandoc: fix bootstrapping on Linux with Clang 16
Alex Richardson [Tue, 12 Dec 2023 05:08:38 +0000 (21:08 -0800)]
mandoc: fix bootstrapping on Linux with Clang 16

It appears that Clang 16 errors by default for the mismatched function
pointer types that are triggered by the fts callback (since glibc has a
callback type without the second const qualifier).
Fortunately, there is already code to handle glibc inside mandoc, we
just have to edit the checked-in config.h.

Reviewed By: imp, emaste
Differential Revision: https://reviews.freebsd.org/D42999

6 months agocam.4: Modernize examples
Warner Losh [Tue, 12 Dec 2023 05:08:55 +0000 (22:08 -0700)]
cam.4: Modernize examples

Use mpr1 instead of ahd1 and ahci1 instead of ahc1. ahc and ahd haven't
been relevant for a while. Also update the transfer size HBAs can do
from from 64k to 1MB.

Sponsored by: Netflix

6 months agocam: Virtual SIMs communicate via the network too
Warner Losh [Tue, 12 Dec 2023 04:50:26 +0000 (21:50 -0700)]
cam: Virtual SIMs communicate via the network too

A virutal SIM can also be connected via the network for iSCSI or NVM
over fabrics.

Sponsored by: Netflix

6 months agoif_tun: check device name
Konstantin Belousov [Tue, 12 Dec 2023 00:13:59 +0000 (02:13 +0200)]
if_tun: check device name

to avoid panic if the name already exists, which is possible with the
interface renaming.

PR: 266999
Reviewed by: kevans
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D43001

6 months agosocket.9: Catch up with commit cfb1e92912b4c
Mark Johnston [Mon, 11 Dec 2023 22:13:21 +0000 (17:13 -0500)]
socket.9: Catch up with commit cfb1e92912b4c

Fixes: cfb1e92912b4 ("sockets: don't malloc/free sockaddr memory on accept(2)")
Reported by: Mina Galić <freebsd@igalic.co>

6 months agopf: fix memory leak on rule add parse failure
Kristof Provost [Mon, 11 Dec 2023 19:43:20 +0000 (20:43 +0100)]
pf: fix memory leak on rule add parse failure

Reported by: Igor Ostapenko <pm@igoro.pro>
Reviewed by: Igor Ostapenko <pm@igoro.pro>
Sponsored by: Rubicon Communications, LLC ("Netgate")

6 months agolibc: expose execvpe for Linux compat
Brooks Davis [Mon, 11 Dec 2023 19:24:53 +0000 (19:24 +0000)]
libc: expose execvpe for Linux compat

We already implemented execvpe internally with an _ prefix in libc so
go ahead and expose it for compatibility with Linux.

This reverts c605eea952146348e5e1ad5cab6c127d7a1bd164.

Bump __FreeBSD_version for the addition and add definitions to supress
compat shims in libzfs (zfs changes were merged from upstream).

PR: 275370 (request and exp-run (thanks antoine!))
Reviewed by: kevans
Differential Revision: https://reviews.freebsd.org/D42846

6 months agolook(1): Correct the example's description
Raghu Ranganathan [Thu, 30 Nov 2023 12:57:35 +0000 (20:57 +0800)]
look(1): Correct the example's description

Remove an extra 'e' in the example command.  It is a prefix, not a typo.

This is from the Advanced UNIX Programming Course (Fall’23) at NTHU.

MFC after: 3 days
Pull Request: https://github.com/freebsd/freebsd-src/pull/913

6 months agolibpfctl: remove stray debug printf()
Kristof Provost [Mon, 11 Dec 2023 13:35:42 +0000 (14:35 +0100)]
libpfctl: remove stray debug printf()

Sponsored by: Rubicon Communications, LLC ("Netgate")

6 months agotty: Avoid a kernel memory discloure via kern.ttys
Mark Johnston [Mon, 11 Dec 2023 14:19:09 +0000 (09:19 -0500)]
tty: Avoid a kernel memory discloure via kern.ttys

Four pad bytes at the end of each xtty structure were not being cleared
before being copied out.  Fix this by clearing the whole structure
before populating fields.

MFC after: 3 days
Reported by: KMSAN

6 months agoarm: Disable the VFP during boot
Mark Johnston [Mon, 11 Dec 2023 14:08:49 +0000 (09:08 -0500)]
arm: Disable the VFP during boot

The VFP code expects the kernel to boot with VFP disabled, but some
boards will boot with it enabled.  Make sure that vfp_init() disables
the VFP on each CPU during boot.

PR: 273752
Reviewed by: andrew
Diagnosed by: Thomas Skibo <thomas-bsd@skibo.net>
MFC after: 1 week

6 months agoarm: Handle VFP exceptions from the kernel
Mark Johnston [Mon, 11 Dec 2023 14:08:34 +0000 (09:08 -0500)]
arm: Handle VFP exceptions from the kernel

vfp_bounce() is called when handling an undefined instruction exception,
to see if we need to enable the VFP.  Previously it would
unconditionally panic if the exception came from the kernel, which was
simply wrong, and it did not permit lazy initialization of VFP state in
the kernel.  However, this functionality can be useful and is supported
by arm's fpu_kern_enter() implementation.  Thus, relax assertions and
consume the exception if the thread was in an FPU section.

Based on a patch from Stormshield.

Reviewed by: andrew
MFC after: 2 weeks
Sponsored by: Klara, Inc.
Sponsored by: Stormshield
Differential Revision: https://reviews.freebsd.org/D42971

6 months agoarm: Fix handling of undefined instructions in kernel mode
Mark Johnston [Mon, 11 Dec 2023 14:08:08 +0000 (09:08 -0500)]
arm: Fix handling of undefined instructions in kernel mode

Only panic if no undefined instruction handler matched the exception.
This can arise in practice if the VFP is enabled lazily.

While here, fix the panic string to not include a newline.

Reviewed by: andrew
Obtained from: Stormshield
Sponsored by: Klara, Inc.
Sponsored by: Stormshield
Differential Revision: https://reviews.freebsd.org/D42970

6 months agoarm: Add fpu_kern_alloc_ctx()
Mark Johnston [Mon, 11 Dec 2023 14:07:55 +0000 (09:07 -0500)]
arm: Add fpu_kern_alloc_ctx()

This enables the use of some out-of-tree crypto libraries on arm.
No functional change intended, there are no callers of this function in
the tree currently.

Reviewed by: andrew
MFC after: 1 week
Sponsored by: Klara, Inc.
Sponsored by: Stormshield
Differential Revision: https://reviews.freebsd.org/D42969

6 months agoarm: Compile vfp.c conditionally rather than using an ifdef
Mark Johnston [Mon, 11 Dec 2023 14:07:40 +0000 (09:07 -0500)]
arm: Compile vfp.c conditionally rather than using an ifdef

No functional change intended.

MFC after: 1 week

6 months agocapsicum: introduce cap_rights_is_empty Function
Mariusz Zaborski [Mon, 11 Dec 2023 11:09:31 +0000 (12:09 +0100)]
capsicum: introduce cap_rights_is_empty Function

Before this commit, we only had the capability to check if a specific
capability was set (using cap_rights_is_set function). However, there
was no efficient method to determine if a cap_rights_t structure doesn't
contain any capability. The cap_rights_is_empty function addresses
this gap.

PR: 275330
Reported by: vini.ipsmaker@gmail.com
Reviewed by: emaste, markj
Differential Revision: https://reviews.freebsd.org/D42780

6 months agoeqos: Call init earlier
Emmanuel Vadot [Mon, 11 Dec 2023 10:29:51 +0000 (11:29 +0100)]
eqos: Call init earlier

Call the subclassed IF_EQOS_INIT before trying to read the mac, clocks
and reset needs to dealt with before we can read the registers.

6 months agoeqos: Unbreak fdt support
Emmanuel Vadot [Mon, 11 Dec 2023 10:29:16 +0000 (11:29 +0100)]
eqos: Unbreak fdt support

We need to enable the clocks and deassert the resets for eqos to work
correctly.

6 months agoeqos: Remove extra x in printf
Emmanuel Vadot [Mon, 11 Dec 2023 10:28:33 +0000 (11:28 +0100)]
eqos: Remove extra x in printf

No functional changes intended.

6 months agostrfmon.c: Use the restrict keyword directly
Konstantin Belousov [Sat, 9 Dec 2023 01:21:02 +0000 (03:21 +0200)]
strfmon.c: Use the restrict keyword directly

libc sources assume C99 or even C11 compiler already, unlike headers.
There is no reason to obfuscate the basic C constructs.

Sponsored by: The FreeBSD Foundation
MFC after: 1 week

6 months agostrfmon: style fixes
Jose Luis Duran [Thu, 30 Nov 2023 23:28:21 +0000 (23:28 +0000)]
strfmon: style fixes

Check style(9) with checkstyle9.pl and clang-format.
No functional change intended.

MFC after: 1 week

6 months agolibsecureboot: be more verbose about validation failures
Stéphane Rochoy [Mon, 4 Dec 2023 09:57:43 +0000 (10:57 +0100)]
libsecureboot: be more verbose about validation failures

Reviewed by: imp, sjg
Pull Request: https://github.com/freebsd/freebsd-src/pull/916

6 months agoendian.h: Remove duplicate words
Jose Luis Duran [Sun, 10 Dec 2023 16:35:56 +0000 (16:35 +0000)]
endian.h: Remove duplicate words

Reviewed by: emaste
Pull Request: https://github.com/freebsd/freebsd-src/pull/920

6 months agostress2: Only extract the allocation with the exact name "pts"
Peter Holm [Sun, 10 Dec 2023 08:34:38 +0000 (09:34 +0100)]
stress2: Only extract the  allocation with the exact name "pts"

6 months agokthread: Set *newtdp earlier in kthread_add1()
Mark Johnston [Sat, 9 Dec 2023 15:22:06 +0000 (10:22 -0500)]
kthread: Set *newtdp earlier in kthread_add1()

syzbot reported a single boot-time crash in g_event_procbody(), a page
fault when dereferencing g_event_td.  g_event_td is initialized by the
kproc_kthread_add() call which creates the GEOM event thread:

  kproc_kthread_add(g_event_procbody, NULL, &g_proc, &g_event_td,
      RFHIGHPID, 0, "geom", "g_event");

I believe that the caller of kproc_kthread_add() was preempted after
adding the new thread to the scheduler, and before setting *newtdp,
which is equal to g_event_td.  Thus, since the first action of the GEOM
event thread is to lock itself, it ended up dereferencing a NULL
pointer.

Fix the problem simply by initializing *newtdp earlier.  I see no harm
in that, and it matches kproc_create1().  The scheduler provides
sufficient synchronization to ensure that the store is visible to the
new thread, wherever it happens to run.

Reported by: syzbot+5397f4d39219b85a9409@syzkaller.appspotmail.com
Reviewed by: kib
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D42986

6 months agopkgbase: pass --recurse-submodules to `git ls-files`
Ed Maste [Sat, 9 Dec 2023 00:59:58 +0000 (19:59 -0500)]
pkgbase: pass --recurse-submodules to `git ls-files`

When generating source packages.  Although submodules are not used by
FreeBSD itself they may be used by downstream projects.  By default
for submodules `git ls-files` just emits the submodule directory name,
which resulted in:

    pkg: pkg_checksum_hash_sha256_file(read failed): Is a directory

Passing --recurse-submodules lists all of the files in each submodule
(which is desired when submodules are in use), and has no effect when
submodules are not present.

Reviewed by: bapt, manu
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D42983

6 months agoCirrus-CI: Use HTTPS to fetch pkg
Mark Johnston [Fri, 8 Dec 2023 21:33:01 +0000 (16:33 -0500)]
Cirrus-CI: Use HTTPS to fetch pkg

Discussed with: Jose Luis Duran <jlduran@gmail.com>
Fixes: 3c097b06a717 ("Cirrus-CI: forcably upgrade pkg to latest")

6 months agotcp: tcp: allow SOL_SOCKET-level socket options via sysctl interface
Michael Tuexen [Sat, 9 Dec 2023 11:57:19 +0000 (12:57 +0100)]
tcp: tcp: allow SOL_SOCKET-level socket options via sysctl interface

When using the sysctl interface for setting a SOL_SOCKET-level socket
option, the TCP handler refers to the IP handler, which only handles
SO_SETFIB and SO_MAX_PACING_RATE.
So call sosetopt(), which handles all SOL_SOCKET-level options.
Then you can use tcpsso with SOL_SOCKET-level socket options as
expected.

Reported by: rscheff
Reviewed by: glebius, rscheff
MFC after: 1 week
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D42985

6 months agolibicp_rescue: unbreak for armv6 after recent OpenZFS import
Dimitry Andric [Sat, 9 Dec 2023 11:51:50 +0000 (12:51 +0100)]
libicp_rescue: unbreak for armv6 after recent OpenZFS import

Similar to fb17dfa0c83c, fix libicp_rescue to include asm versions of
sha2 on armv6, to unbreak the build of rescue.

Fixes: 3494f7c019fc

6 months agopkgbase: Move tr(1) to runtime
Emmanuel Vadot [Mon, 27 Nov 2023 14:35:32 +0000 (15:35 +0100)]
pkgbase: Move tr(1) to runtime

Since f7d16a627efa ("certctl: Convert line endings before inspecting files.")
certctl is using tr(1). Add it to FreeBSD-runtime so we can have certctl working
without having the bloated FreeBSD-utilities.

Sponsored by: Beckhoff Automation GmbH & Co. KG

6 months agostrfmon: Silence scan-build warning
Jose Luis Duran [Thu, 30 Nov 2023 23:30:50 +0000 (23:30 +0000)]
strfmon: Silence scan-build warning

The value stored to 'value' is never read.

Reported by: Jenkins (scan-build)
MFC after: 1 week

6 months agostrfmon.3: Cleanup example code
Jose Luis Duran [Fri, 1 Dec 2023 06:50:24 +0000 (06:50 +0000)]
strfmon.3: Cleanup example code

- xlocale.h would have been required if using strfmon_l().  Here,
  setlocale() just requires locale.h.
- ANSIfy function declaration.
- Add a final return().

MFC after: 1 week

6 months agolibicp: unbreak for armv6 after recent OpenZFS import
Dimitry Andric [Fri, 8 Dec 2023 23:09:36 +0000 (00:09 +0100)]
libicp: unbreak for armv6 after recent OpenZFS import

The following upstream commit:
727497ccdfcc module/icp/asm-arm/sha2: enable non-SIMD asm kernels on armv5/6

does indeed enable sha2 asm for earlier arm CPUs, but since libicp's
Makefile was not updated, this leads to:

  ld: error: undefined reference due to --no-allow-shlib-undefined: zfs_sha256_block_armv7

Fix it by compiling sha256-armv7.S and sha512-armv7.S for armv6 too.

Fixes: 3494f7c019fc

6 months agoloader: lua: assume late ACPI detection if the feature isn't enabled
Kyle Evans [Fri, 8 Dec 2023 21:36:06 +0000 (15:36 -0600)]
loader: lua: assume late ACPI detection if the feature isn't enabled

While we're here, enable the feature in the places we detect ACPI.  This
lets us side-step the existing issues and provide a path forward for
folks upgrading from previous releases that haven't updated their ESP
yet.

Let's also fix core.setACPI: the hint already indicates that the
user's disabled it more consistently than loader.acpi_disabled_by_user.
Even more, the latter is wrong because we set it by default if we did
not detect ACPI.  The ACPI hint remains even when we're setting defaults
because ACPI loaded into the kernel will make some noise if it's not
hinted off, even when we didn't detect it.

imp notes that this will result in some relatively harmless noise on
platforms that don't support ACPI but aren't using the UEFI loader, as
we would enable the ACPI module for loading on them and then loader
would not be able to find it.  These are non-fatal, but should probably
be fixed by just declaring support for EARLY_ACPI in those loaders since
we know they won't have ACPI early on -- punting on this for the time
being, though, in favor of providing a safer upgrade path sooner.

Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D42727

6 months agoloader: provide a features table for binary compatibility advertisement
Kyle Evans [Fri, 8 Dec 2023 21:36:06 +0000 (15:36 -0600)]
loader: provide a features table for binary compatibility advertisement

liblua now provides a loader.has_feature() function to probe the loader
binary for features advertised.  name => desc mappings are provided in
loader.features to get a list of all of the features loader *can*
support.  core.hasFeature is provided as a shim to loader.has_feature
so that individual consumers don't need to think about the logic of the
loader module not providing has_feature; we know that means the feature
isn't enabled.

The first consumer of this will be EARLY_ACPI to advertise that the
loader binary probes for ACPI presence before the interpreter has
started, so that we know whether we can trust the presence of acpi.rsdp
as relatively authoritative.  In general, it's intended to be used to
avoid breaking new scripts on older loaders within reason.

This will be used in lua as `core.hasFeature("EARLY_ACPI")`, while the
C bits of loader will `feature_enable(FEATURE_EARLY_ACPI)`.

Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D42695

6 months agoObsoleteFiles.inc: remove old libufs.so.7 after bump
Dimitry Andric [Fri, 8 Dec 2023 21:21:59 +0000 (22:21 +0100)]
ObsoleteFiles.inc: remove old libufs.so.7 after bump

Fixes: 772430dd6795

6 months agoObsoleteFiles.inc: fix dates after llvm 17.0.6 merge.
Dimitry Andric [Fri, 8 Dec 2023 21:20:03 +0000 (22:20 +0100)]
ObsoleteFiles.inc: fix dates after llvm 17.0.6 merge.

PR: 273753
MFC after: 1 month

6 months agoBump __FreeBSD_version for llvm 17.0.6 merge
Dimitry Andric [Fri, 8 Dec 2023 17:36:40 +0000 (18:36 +0100)]
Bump __FreeBSD_version for llvm 17.0.6 merge

PR: 273753
MFC after: 1 month

6 months agoMerge commit 158f4f30adb4 from llvm git (by Corentin Jabot):
Dimitry Andric [Thu, 7 Dec 2023 12:47:54 +0000 (13:47 +0100)]
Merge commit 158f4f30adb4 from llvm git (by Corentin Jabot):

  [Clang] Do not change the type of captured vars when checking lambda constraints

  When checking the constraint of a lambda, we need to respect the constness
  of the call operator when establishing the type of capture variables.

  In D124351, this was done by adding const to the captured variable...
  However, that would change the type of the variable outside of the scope
  of the lambda, which is clearly not the desired outcome.

  Instead, to ensure const-correctness, we need to populate
  a LambdaScopeInfo with the capture variables before checking the
  constraints of a generic lambda.

  There is no changelog as I'd like to tentatively propose we backport
  this change to RC3 as it is a regression introduced in the Clang 17
  cycle.

  Fixes #61267

  Reviewed By: aaron.ballman, #clang-language-wg

  Differential Revision: https://reviews.llvm.org/D158433

Merge commit 3ed9e9e3ace6 from llvm git (by Corentin Jabot):

  [Clang] Add captures to the instantiation scope of lambda call operators

  Like concepts checking, a trailing return type of a lambda
  in a dependent context may refer to captures in which case
  they may need to be rebuilt, so the map of local decl
  should include captures.

  This patch reveal a pre-existing issue.
  `this` is always recomputed by TreeTransform.

  `*this` (like all captures) only become `const`
  after the parameter list.

  However, if try to recompute the value of `this` (in a parameter)
  during template instantiation while determining the type of the call operator,
  we will determine  it to be const (unless the lambda is mutable).

  There is no good way to know at that point that we are in a parameter
  or not, the easiest/best solution is to transform the type of this.

  Note that doing so break a handful of HLSL tests.
  So this is a prototype at this point.

  Fixes #65067
  Fixes #63675

  Reviewed By: erichkeane

  Differential Revision: https://reviews.llvm.org/D159126

This fixes 'Assertion failed: (isa<LabelDecl>(D) && "declaration not
instantiated in this scope"), function findInstantiationOf' error when
building databases/mongodb44.

PR: 273753
MFC after: 1 month

6 months agoMerge llvm-project release/17.x llvmorg-17.0.6-0-g6009708b4367
Dimitry Andric [Thu, 30 Nov 2023 20:06:52 +0000 (21:06 +0100)]
Merge llvm-project release/17.x llvmorg-17.0.6-0-g6009708b4367

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-17.0.6-0-g6009708b4367.

PR: 273753
MFC after: 1 month

6 months agoMerge llvm-project release/17.x llvmorg-17.0.5-0-g98bfdac5ce82
Dimitry Andric [Thu, 16 Nov 2023 21:58:12 +0000 (22:58 +0100)]
Merge llvm-project release/17.x llvmorg-17.0.5-0-g98bfdac5ce82

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-17.0.5-0-g98bfdac5ce82.

PR: 273753
MFC after: 1 month

6 months agoMerge llvm-project release/17.x llvmorg-17.0.3-0-g888437e1b600
Dimitry Andric [Sat, 21 Oct 2023 13:31:11 +0000 (15:31 +0200)]
Merge llvm-project release/17.x llvmorg-17.0.3-0-g888437e1b600

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-17.0.3-0-g888437e1b600.

PR: 273753
MFC after: 1 month

6 months agoMerge llvm-project release/17.x llvmorg-17.0.2-0-gb2417f51dbbd
Dimitry Andric [Wed, 4 Oct 2023 18:24:05 +0000 (20:24 +0200)]
Merge llvm-project release/17.x llvmorg-17.0.2-0-gb2417f51dbbd

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-17.0.2-0-gb2417f51dbbd.

PR: 273753
MFC after: 1 month

6 months agoMerge llvm-project release/17.x llvmorg-17.0.1-25-g098e653a5bed
Dimitry Andric [Fri, 29 Sep 2023 18:51:44 +0000 (20:51 +0200)]
Merge llvm-project release/17.x llvmorg-17.0.1-25-g098e653a5bed

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-17.0.1-25-g098e653a5bed.

PR: 273753
MFC after: 1 month

6 months agoMerge llvm-project release/17.x llvmorg-17.0.0-rc4-10-g0176e8729ea4
Dimitry Andric [Mon, 11 Sep 2023 18:37:24 +0000 (20:37 +0200)]
Merge llvm-project release/17.x llvmorg-17.0.0-rc4-10-g0176e8729ea4

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvmorg-17.0.0-rc4-10-g0176e8729ea4.

PR: 273753
MFC after: 1 month

6 months agoMerge llvm-project main llvmorg-17-init-19304-gd0b54bb50e51
Dimitry Andric [Sat, 2 Sep 2023 21:17:18 +0000 (23:17 +0200)]
Merge llvm-project main llvmorg-17-init-19304-gd0b54bb50e51

This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
openmp to llvm-project main llvmorg-17-init-19304-gd0b54bb50e51, the
last commit before the upstream release/17.x branch was created.

PR: 273753
MFC after: 1 month

6 months agolibcasper: document that most libcasper functions are not thread-safe
Alan Somers [Tue, 5 Dec 2023 23:24:28 +0000 (16:24 -0700)]
libcasper: document that most libcasper functions are not thread-safe

And neither are most libcasper services' functions, because internally
they all use cap_xfer_nvlist.  cap_xfer_nvlist sends and then receives
data over a unix domain socket and associated with the cap_channel_t
argument.  So absent synchronization, two threads may not use the same
cap_channel_t argument or they risk receiving the other's reply.

MFC after: 2 weeks
Sponsored by: Axcient
Reviewed by: oshogbo
Differential Revision: https://reviews.freebsd.org/D42928

6 months agoNotable upstream pull request merges:
Martin Matuska [Fri, 8 Dec 2023 08:32:30 +0000 (09:32 +0100)]
Notable upstream pull request merges:
 #15539 687e4d7f9 Extend import_progress kstat with a notes field
 #15544 c7b611926 Allow block cloning across encrypted datasets
 #15553 adcea23cb ZIO: Add overflow checks for linear buffers
 #15593 5f2700eee zpool: flush output before sleeping
 #15609 3e4bef52b Only provide execvpe(3) when needed
 #15610 735ba3a7b Use uint64_t instead of u_int64_t
 #15612 bcd83ccd2 ZIL: Remove TX_CLONE_RANGE replay for ZVOLs
 #15617 55b764e06 ZIL: Do not clone blocks from the future
 #15623 727497ccd module/icp/asm-arm/sha2: enable non-SIMD asm kernels
                  on armv5/6
 #15625 9743d0963 BRT: Limit brt_vdev_dump() to only one vdev
 #15629 f9765b182 zdb: Dump encrypted write and clone ZIL records
 #15634 2aa3a482a ZIL: Remove 128K into 2x68K LWB split optimization
 #15639 11656234b FreeBSD: Ensure that zfs_getattr() initializes the
                  va_rdev field
 #15647 4836d293c zfs_refcount_remove: explictly ignore returns
 #15649 f0cb6482e setproctitle: fix ununitialised variable
 #15650 450f2d0b0 import: ignore return on hostid lookups

Obtained from: OpenZFS
OpenZFS commit: 450f2d0b08e73cfb057d0e301a813418b70d64b9

6 months agovmstat: Rely on libxo for numbers humanization
Alexander Motin [Fri, 8 Dec 2023 02:21:35 +0000 (21:21 -0500)]
vmstat: Rely on libxo for numbers humanization

This makes code cleaner, plus fixes such nonsense as humanized JSON
and XML, making all numbers raw without quotes, spaces, suffixes, etc.

MFC after:      2 weeks

6 months agovmm: implement VM_CAP_MASK_HWINTR on AMD CPUs
Bojan Novković [Thu, 7 Dec 2023 23:08:58 +0000 (15:08 -0800)]
vmm: implement VM_CAP_MASK_HWINTR on AMD CPUs

This patch implements the interrupt blocking VM capability on AMD
CPUs.  Implementing this capability allows the GDB stub to single-step
a virtual machine without landing inside interrupt handlers.

Reviewed by: jhb, corvink
Sponsored by:   Google, Inc. (GSoC 2022)
Differential Revision: https://reviews.freebsd.org/D42299

6 months agovmm: implement single-stepping for AMD CPUs
Bojan Novković [Thu, 7 Dec 2023 23:00:31 +0000 (15:00 -0800)]
vmm: implement single-stepping for AMD CPUs

This patch implements single-stepping for AMD CPUs using the RFLAGS.TF
single-stepping mechanism.  The GDB stub requests single-stepping
using the VM_CAP_RFLAGS_TF capability.  Setting this capability will
set the RFLAGS.TF bit on the selected vCPU, activate DB exception
intercepts, and activate POPF/PUSH instruction intercepts.  The
resulting DB exception is then caught by the IDT_DB vmexit handler and
bounced to userland where it is processed by the GDB stub.  This patch
also makes sure that the value of the TF bit is correctly updated and
that it is not erroneously propagated into memory.  Stepping over PUSHF
will cause the vm_handle_db function to correct the pushed RFLAGS
value and stepping over POPF will update the shadowed TF bit copy.

Reviewed by: jhb
Sponsored by: Google, Inc. (GSoC 2022)
Differential Revision: https://reviews.freebsd.org/D42296

6 months agovmm: enable software breakpoints for AMD CPUs
Bojan Novković [Thu, 7 Dec 2023 22:46:31 +0000 (14:46 -0800)]
vmm: enable software breakpoints for AMD CPUs

This patch adds support for software breakpoint vmexits on AMD SVM.
It implements the VM_CAP_BPT_EXIT used to enable software breakpoints.
When enabled, breakpoint vmexits are passed to userspace where they
are handled by the GDB stub.

Reviewed by: jhb
Sponsored by: Google, Inc. (GSoC 2022)
Differential Revision: https://reviews.freebsd.org/D42295

6 months agovmm: refactor event reflection in AMD SVM
Bojan Novković [Thu, 7 Dec 2023 22:40:28 +0000 (14:40 -0800)]
vmm: refactor event reflection in AMD SVM

This patch refactors AMD SVM event reflection to allow events to be
propagated to userland, rather than always reflected into the guest.

This is necessary to implement some capabilities that request VMEXITs
when a specific exception occurs (e.g. VM_CAP_BPT_EXIT).

Reviewed by: jhb
Sponsored by: Google, Inc. (GSoC 2022)
Differential Revision: https://reviews.freebsd.org/D42405

6 months agotcp_hpts: let tcp_hpts_init() set a random CPU only once
Gleb Smirnoff [Thu, 7 Dec 2023 22:41:43 +0000 (14:41 -0800)]
tcp_hpts: let tcp_hpts_init() set a random CPU only once

After d2ef52ef3dee the tcp_hpts_init() function can be called multiple
times on a tcpcb if it is switched there and back between two TCP stacks.
First, this makes existing assertion in tcp_hpts_init() incorrect.  Second,
it creates possibility to change a randomly set t_hpts_cpu to a different
random value, while a tcpcb is already in the HPTS wheel, triggering other
assertions later in tcp_hptsi().

The best approach here would be to work on the stacks to really clear a
tcpcb out of HPTS wheel in tfb_tcp_fb_fini, draining the IHPTS_MOVING
state.  But that's pretty intrusive change, so let's just get back to the
old logic (pre d2ef52ef3dee) where t_hpts_cpu was set to a random value
only once in a CPU lifetime and a newly switched stack inherits t_hpts_cpu
from the previous stack.

Reviewed by: rrs, tuexen
Differential Revision: https://reviews.freebsd.org/D42946
Reported-by: syzbot+fab29fe1ab089c52998d@syzkaller.appspotmail.com
Reported-by: syzbot+ca5f2aa0fda15dcfe6d7@syzkaller.appspotmail.com
Fixes: 2b3a77467dd3d74a7170f279fb25f9736b46ef8a

6 months agotcp: stop stack timers in tcp_switch_back_to_default()
Gleb Smirnoff [Thu, 7 Dec 2023 22:41:36 +0000 (14:41 -0800)]
tcp: stop stack timers in tcp_switch_back_to_default()

This funcion is an alternative code path that detaches an alternative
TCP stack, missed in d2ef52ef3dee38cccb7f54d33ecc2a4b944dad9d.

Reviewed by: rrs, tuexen
Differential Revision: https://reviews.freebsd.org/D42917
Reported-by: syzbot+186130be9f0ca5557d4e@syzkaller.appspotmail.com
Fixes: d2ef52ef3dee38cccb7f54d33ecc2a4b944dad9d

6 months agoCirrus CI: Add manual jobs for amd64 and aarch64 using GCC 13
John Baldwin [Thu, 7 Dec 2023 22:32:08 +0000 (14:32 -0800)]
Cirrus CI: Add manual jobs for amd64 and aarch64 using GCC 13

Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D42840

6 months agoRevert "linuxkpi: `GFP_KERNEL` equals `M_NOWAIT` now"
Jean-Sébastien Pédron [Thu, 7 Dec 2023 18:45:25 +0000 (19:45 +0100)]
Revert "linuxkpi: `GFP_KERNEL` equals `M_NOWAIT` now"

This change seems to break some drivers such as the mlx5*(4) drivers.

As kib@ says:
> According to the 'official' Linux kernel documentation, the GFP_KERNEL
> flag implies sleepable context.

It was introduced while working on the new vt(4)/DRM integration [1].
During this work, doing sleepable allocations broke vt(4) and the DRM
drivers. However, I made further improvements and some locking-related
fixed to the new integration without revisiting the need for it.

After more testing, the improvements to the integration mentionned above
seems to make the change to `GFP_KERNEL` unneeded now. I can thus
revert it to restore expectations of other drivers.

This reverts commit 14dcd40983748596d116d91acb934a8a95ac76bc.

[1] https://github.com/freebsd/drm-kmod/pull/243

Reviewed by: kib
Approved by: kib
Differential Revision: https://reviews.freebsd.org/D42962

6 months agobuild: use bare (and portable) echo instead of echo -n
Warner Losh [Thu, 7 Dec 2023 20:27:27 +0000 (13:27 -0700)]
build: use bare (and portable) echo instead of echo -n

There's no need to use echo -n here. A single echo will do nicely.
This fixes the post-buildworld output on a macos build, where echo -n
is implemented like System V instead of BSD (so you get two lines
first one starting with -n).

Sponsored by: Netflix
Reviewed by: jrtc27, emaste
Differential Revision: https://reviews.freebsd.org/D42869

6 months agosort: Only build FreeBSD-specific ALTMON_x stuff when ATLMON_1 is defined
Warner Losh [Thu, 7 Dec 2023 20:27:07 +0000 (13:27 -0700)]
sort: Only build FreeBSD-specific ALTMON_x stuff when ATLMON_1 is defined

On MacOS, we bootstrap sort. Since ALTMON_* are not defined there, the
build blows up. Since we don't need this feature for the FreeBSD build
process, and since we won't use it unless we actually install the NL
files that have this data in it, just #ifdef it out for now. In the
extremely unlikely event that the FreeBSD bootstrap/build process grows
this dependency, we can evaluate the best solution then (which most
likely is going to be not depend on the local's month names).

Fixes: 3d44dce90a69 (MacOS builds and github CI)
Sponsored by: Netflix
Reviewed by: jrtc27, jlduran@gmail.com, markj
Differential Revision: https://reviews.freebsd.org/D42868

6 months agocp: Don't warn for chflags() failing with EOPNOTSUPP if flags == 0
Warner Losh [Thu, 7 Dec 2023 19:32:30 +0000 (12:32 -0700)]
cp: Don't warn for chflags() failing with EOPNOTSUPP if flags == 0

From NetBSD's utils.c 1.5 importing importing BSDI change, with light
formatting changes:
    Author: cgd <cgd@NetBSD.org>
    Date:   Wed Feb 26 14:40:51 1997 +0000

    Patch from BSDI (via Keith Bostic):
    >NFS doesn't support chflags; ignore errors unless there's reason
    >to believe we're losing bits.  (Note, this still won't be right
    >if the server supports flags and we were trying to *remove* flags
    >on a file that we copied, i.e., that we didn't create.)

    CVS Info: utils.c 1.6

Obtained from: NetBSD
Sponsored by: Netflix

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

6 months agocp: Add -N flag, inspired by NetBSD's similar flag
Warner Losh [Thu, 7 Dec 2023 19:32:27 +0000 (12:32 -0700)]
cp: Add -N flag, inspired by NetBSD's similar flag

Add -N to supress copying of file flags when -p is specified (explicitly
or implicitly). Often times we don't care about the flags or wish to be
able to copy to NFS, and this comes in handy for that. FreeBSD's and
NetBSD's cp are somewhat different, so I had to reimplement all but one
of the patch hunks...

Obtained from: NetBSD (cp.1 1.25, cp.c 1.37, utils.c 1.28 by elad)
Sponsored by: Netflix

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

6 months agocamcontrol: One file per line in Makefile
Warner Losh [Fri, 1 Dec 2023 03:07:53 +0000 (20:07 -0700)]
camcontrol: One file per line in Makefile

We have enough files now that moving to one file per line makes sense.

Sponsored by: Netflix