]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
14 months agoixl: port ice's atomic API to ixl
Piotr Kubaj [Tue, 6 Jun 2023 15:30:18 +0000 (17:30 +0200)]
ixl: port ice's atomic API to ixl

Differential Revision: https://reviews.freebsd.org/D40532
Approved by: erj

14 months agohier(7): remove entry for non-existent /usr/compat
Mitchell Horne [Thu, 6 Jul 2023 14:11:21 +0000 (11:11 -0300)]
hier(7): remove entry for non-existent /usr/compat

This is historical (?), but today /compat is the default according to
linux(4). The only remaining reference to /usr/compat in the src tree is
under tools/test/stress2.

Add a next-level entry for /compat/linux.

PR: 261349
Reviewed by: grahamperrin, karels, dchagin
MFC after: 3 days
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D40876

14 months agostress2: Added a regression test
Peter Holm [Thu, 6 Jul 2023 09:15:13 +0000 (11:15 +0200)]
stress2: Added a regression test

14 months agoddb: Rework macros to make it easier to add new command tables.
John Baldwin [Wed, 5 Jul 2023 23:00:47 +0000 (16:00 -0700)]
ddb: Rework macros to make it easier to add new command tables.

- Add new DB_DEFINE_TABLE and DB_DECLARE_TABLE macros to define new
  command tables.  DB_DECLARE_TABLE is intended for use in headers
  similar to MALLOC_DECLARE and SYSCTL_DECL.

  DB_DEFINE_TABLE takes three arguments, the name of the parent table,
  the command name, and the name of the table itself, e.g.
  DB_DEFINE_TABLE(show, foo, show_foo) defines a new "show foo" table.

- DB_TABLE_COMMAND, DB_TABLE_COMMAND_FLAGS, DB_TABLE_ALIAS, and
  DB_ALIAS_FLAGS allow new commands and aliases to be defined.  These
  are similar to the existing DB_COMMAND, etc. except that they take
  an initial argument giving the name of the parent table, e.g.:

  DB_TABLE_COMMAND(show_foo, bar, db_show_foo_bar)

  defines a new "show foo bar" command.

This provides a cleaner interface than the ad-hoc use of internal
macros like _DB_SET that was required previously (e.g. in cxgbe(4)).

This retires DB_FUNC macro as well as the internal _DB_FUNC macro.

Reviewed by: melifaro, kib, markj
Differential Revision: https://reviews.freebsd.org/D40819

14 months agoddb: Always terminate DB_SHOW_ALIAS_FLAGS with a semi-colon.
John Baldwin [Wed, 5 Jul 2023 23:00:31 +0000 (16:00 -0700)]
ddb: Always terminate DB_SHOW_ALIAS_FLAGS with a semi-colon.

Reviewed by: kib, markj
Differential Revision: https://reviews.freebsd.org/D40818

14 months agoFix the zfsd_autoreplace_001_neg test
Alan Somers [Wed, 5 Jul 2023 22:37:39 +0000 (16:37 -0600)]
Fix the zfsd_autoreplace_001_neg test

It only ever worked by accident.
* Actually set autoreplace=off as stated in the description
* Wait for the removed device to disappear from the pool before
  proceeding.
* In the assertion, verify that the new disk does not get added, as
  described in the description.

MFC after: 2 weeks
Sponsored by: Axcient

14 months agovfs: whack dpunlocked var in vfs_lookup
Mateusz Guzik [Wed, 5 Jul 2023 21:52:07 +0000 (21:52 +0000)]
vfs: whack dpunlocked var in vfs_lookup

It is redundant given the bad_unlocked goto label.

14 months agolibcrypto: group definitions for libcrypto and fips
Pierre Pronchery [Fri, 30 Jun 2023 17:23:57 +0000 (19:23 +0200)]
libcrypto: group definitions for libcrypto and fips

OpenSSL 3 supports a modular architecture, allowing different providers
to bring specific implementations of cryptographical algorithms. This
change makes sure the FIPS module matches build instructions used for
libcrypto.

Sponsored by: The FreeBSD Foundation
Pull Request: https://github.com/freebsd/freebsd-src/pull/787

14 months agolibcrypto: expand the common Makefile for providers
Pierre Pronchery [Fri, 30 Jun 2023 17:20:31 +0000 (19:20 +0200)]
libcrypto: expand the common Makefile for providers

OpenSSL 3 supports a modular architecture, allowing different providers
to bring specific implementations of cryptographical algorithms. This
change adds mandatory source files to every provider.

Sponsored by: The FreeBSD Foundation
Pull Request: https://github.com/freebsd/freebsd-src/pull/787

14 months agolibcrypto: add missing symbols to the fips provider
Pierre Pronchery [Thu, 29 Jun 2023 22:24:33 +0000 (00:24 +0200)]
libcrypto: add missing symbols to the fips provider

OpenSSL 3 supports a modular architecture, allowing different providers
to bring specific implementations of cryptographical algorithms. One
such provider, "fips", ships with OpenSSL 3 directly, and groups
algorithms that can be FIPS 140-2 validated.

The import of OpenSSL 3.0.9 was building this provider incorrectly,
missing symbols required for proper operation.

In addition, without the change in OpenSSL's crypto/bn/bn_const.c, the
FIPS module fails loading: `Undefined symbol "ossl_bignum_modp_1536_p"`.
This change is consistent with crypto/bn/bn_dh.c though.

Sponsored by: The FreeBSD Foundation
Pull Request: https://github.com/freebsd/freebsd-src/pull/787

14 months agolibcrypto: add missing symbols to the legacy provider
Pierre Pronchery [Thu, 29 Jun 2023 21:32:59 +0000 (23:32 +0200)]
libcrypto: add missing symbols to the legacy provider

OpenSSL 3 supports a modular architecture, allowing different providers
to bring specific implementations of cryptographical algorithms. One
such provider, "legacy", ships with OpenSSL 3 directly, and groups
obsoleted algorithms that can still optionally be used anyway.

The import of OpenSSL 3.0.9 was building this provider incorrectly,
missing symbols required for proper operation.

Sponsored by: The FreeBSD Foundation
Pull Request: https://github.com/freebsd/freebsd-src/pull/787

14 months agolibsecureboot: do not accept certificate we cannot decode
Simon J. Gerraty [Wed, 5 Jul 2023 19:37:14 +0000 (12:37 -0700)]
libsecureboot: do not accept certificate we cannot decode

Although we care more about the CN of a certificate than its status
(for purpose of reporting), we should skip if we have errors decoding.

Reviewed by: stevek
Sponsored by: Juniper Networks, Inc.

14 months agovfs: use __enum_uint8 for vtype and vstate
Mateusz Guzik [Sun, 12 Mar 2023 19:31:27 +0000 (19:31 +0000)]
vfs: use __enum_uint8 for vtype and vstate

This whacks hackery around only reading v_type once.

Bump __FreeBSD_version to 1400093

14 months agoSupport byte-sized enums
Mateusz Guzik [Sun, 12 Mar 2023 19:29:20 +0000 (19:29 +0000)]
Support byte-sized enums

To that end add __enum_uint8_decl and __enum_uint8.

By default enums take 4 bytes, but vast majority of them have values
which would fit in a byte.

One can try to workaround the problem by using bitfields, like so:
enum some_small_enum foo:8;

but that's ugly and runs into trouble when using atomic_load (you can't
take an address of a bitfield, even if it is sized to a multiply of a
byte).

Both gcc 13 and clang support specifying the size, and for older
variants one can fallback to the "packed" attribute.

Names are mangled in order to avoid mix use with plain enum.

Reviewed by:
Differential Revision: https://reviews.freebsd.org/D39031

14 months agovfs: list enums on separate lines
Mateusz Guzik [Fri, 21 Apr 2023 18:06:13 +0000 (18:06 +0000)]
vfs: list enums on separate lines

Requested by: kib

14 months agovfs: compute_lk_cnflags(): Remove unused argument 'cnflags'; Rename
Olivier Certner [Wed, 5 Jul 2023 13:40:22 +0000 (13:40 +0000)]
vfs: compute_lk_cnflags(): Remove unused argument 'cnflags'; Rename

Argument unused since commit 93a0ba8f4990785f.

Rename it to enforce_lkflags(), which seems to more aptly describe what it does.

[mjg: massaged the commit message a little]
Reviewed by: kib, markj
Differential Revision: https://reviews.freebsd.org/D40848

14 months agoMake some arm64 debug monitor functions static
Andrew Turner [Mon, 22 May 2023 13:38:08 +0000 (14:38 +0100)]
Make some arm64 debug monitor functions static

These are only used within debug_monitor.c so can become static.

Sponsored by: Arm Ltd

14 months agoflowctl: low-effort fix to make it compilable with neither inet nor inet6
Mateusz Guzik [Wed, 5 Jul 2023 10:02:03 +0000 (10:02 +0000)]
flowctl: low-effort fix to make it compilable with neither inet nor inet6

14 months agojls: low-effort fix to make it compilable with neither inet nor inet6
Mateusz Guzik [Wed, 5 Jul 2023 10:01:28 +0000 (10:01 +0000)]
jls: low-effort fix to make it compilable with neither inet nor inet6

14 months agoipf: low-effort fix to make it compilable without inet6
Mateusz Guzik [Wed, 5 Jul 2023 10:01:00 +0000 (10:01 +0000)]
ipf: low-effort fix to make it compilable without inet6

14 months agoping: low-effort fix to make it compilable without inet
Mateusz Guzik [Wed, 5 Jul 2023 10:00:44 +0000 (10:00 +0000)]
ping: low-effort fix to make it compilable without inet

14 months agoping: low-effort fix to make it compilable without inet6
Mateusz Guzik [Wed, 5 Jul 2023 09:59:40 +0000 (09:59 +0000)]
ping: low-effort fix to make it compilable without inet6

14 months agoAdd helpers to allocate an arm64 VFP state struct
Andrew Turner [Tue, 16 May 2023 10:09:11 +0000 (11:09 +0100)]
Add helpers to allocate an arm64 VFP state struct

This will be used by bhyve and will allow the size to change, e.g. for SVE.

Reviewed by: markj
Sponsored by: Arm Ltd
Differential Revision: https://reviews.freebsd.org/D40131

14 months agoarm64: Fix a use of update_lower_register
Andrew Turner [Mon, 3 Jul 2023 09:38:10 +0000 (10:38 +0100)]
arm64: Fix a use of update_lower_register

In get_kernel_reg_masked we use update_lower_register to get the lower
value of two registers for a given field. It will return the entire
register value with just the single field updated.

Because of this get_kernel_reg_masked needs to use the returned value
directly rather than ORing each field together. Fix this by updating
the mask and returning that from get_kernel_reg_masked.

Reviewed by: markj
Sponsored by: Arm Ltd
Differential Revision: https://reviews.freebsd.org/D40846

14 months agopci_vendors: update to 2023-06-19
Baptiste Daroussin [Wed, 5 Jul 2023 06:30:42 +0000 (08:30 +0200)]
pci_vendors: update to 2023-06-19

14 months agokern_lockf.c: fix typo
Konstantin Belousov [Tue, 4 Jul 2023 22:23:57 +0000 (01:23 +0300)]
kern_lockf.c: fix typo

Sponsored by: The FreeBSD Foundation
MFC after: 3 days

14 months agolibcrypto: Revert recent changes to fix legacy and fips providers
Mark Johnston [Tue, 4 Jul 2023 20:37:21 +0000 (16:37 -0400)]
libcrypto: Revert recent changes to fix legacy and fips providers

They break the !amd64 builds due to an underspecified include path and
will be re-applied once that's fixed.

Reported by: Ronald Klop <ronald-lists@klop.ws>

14 months agorelease/DVD_PACKAGES: Update the names of drm-kmod ports
Li-Wen Hsu [Tue, 4 Jul 2023 20:24:52 +0000 (04:24 +0800)]
release/DVD_PACKAGES: Update the names of drm-kmod ports

Reviewed by: x11 (manu), re (gjb)
MFC after: 3 days
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D40770

14 months agoure(4): add support for Thinkpad Hybrid USB-C with USB-A dock
Joerg Pulz [Tue, 4 Jul 2023 16:08:13 +0000 (18:08 +0200)]
ure(4): add support for Thinkpad Hybrid USB-C with USB-A dock

Add support for LAN port found on Thinkpad Hybrid USB-C with USB-A dock.
While here fix a small typo
  - s/UBS/USB/

Sponsored by: Technical University of Munich
Reviewed by: markj
MFC after: 2 weeks
Pull Request: https://github.com/freebsd/freebsd-src/pull/791

14 months agoman(1): use gzcat for .gz files
Mohamed Akram [Mon, 3 Jul 2023 15:20:51 +0000 (19:20 +0400)]
man(1): use gzcat for .gz files

POSIX zcat appends the .Z suffix to file arguments causing the command to fail
with .gz files.

Signed-off-by: Mohamed Akram <mohd.akram@outlook.com>
Reviewed by: markj
MFC after: 2 weeks
Pull Request: https://github.com/freebsd/freebsd-src/pull/789

14 months agosocket afinet tests: using dynamic ports instead of the same static port
Olivier Cochard [Tue, 4 Jul 2023 19:11:24 +0000 (21:11 +0200)]
socket afinet tests: using dynamic ports instead of the same static port

Allows these tests to be run in parallel.

Approved by: markj
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D40859

14 months agolibcrypto: group definitions for libcrypto and fips
Pierre Pronchery [Fri, 30 Jun 2023 17:23:57 +0000 (19:23 +0200)]
libcrypto: group definitions for libcrypto and fips

OpenSSL 3 supports a modular architecture, allowing different providers
to bring specific implementations of cryptographical algorithms. This
change makes sure the FIPS module matches build instructions used for
libcrypto.

Sponsored by: The FreeBSD Foundation
Pull Request: https://github.com/freebsd/freebsd-src/pull/787

14 months agolibcrypto: expand the common Makefile for providers
Pierre Pronchery [Fri, 30 Jun 2023 17:20:31 +0000 (19:20 +0200)]
libcrypto: expand the common Makefile for providers

OpenSSL 3 supports a modular architecture, allowing different providers
to bring specific implementations of cryptographical algorithms. This
change adds mandatory source files to every provider.

Sponsored by: The FreeBSD Foundation
Pull Request: https://github.com/freebsd/freebsd-src/pull/787

14 months agolibcrypto: add missing symbols to the fips provider
Pierre Pronchery [Thu, 29 Jun 2023 22:24:33 +0000 (00:24 +0200)]
libcrypto: add missing symbols to the fips provider

OpenSSL 3 supports a modular architecture, allowing different providers
to bring specific implementations of cryptographical algorithms. One
such provider, "fips", ships with OpenSSL 3 directly, and groups
algorithms that can be FIPS 140-2 validated.

The import of OpenSSL 3.0.9 was building this provider incorrectly,
missing symbols required for proper operation.

In addition, without the change in OpenSSL's crypto/bn/bn_const.c, the
FIPS module fails loading: `Undefined symbol "ossl_bignum_modp_1536_p"`.
This change is consistent with crypto/bn/bn_dh.c though.

Sponsored by: The FreeBSD Foundation
Pull Request: https://github.com/freebsd/freebsd-src/pull/787

14 months agolibcrypto: add missing symbols to the legacy provider
Pierre Pronchery [Thu, 29 Jun 2023 21:32:59 +0000 (23:32 +0200)]
libcrypto: add missing symbols to the legacy provider

OpenSSL 3 supports a modular architecture, allowing different providers
to bring specific implementations of cryptographical algorithms. One
such provider, "legacy", ships with OpenSSL 3 directly, and groups
obsoleted algorithms that can still optionally be used anyway.

The import of OpenSSL 3.0.9 was building this provider incorrectly,
missing symbols required for proper operation.

Sponsored by: The FreeBSD Foundation
Pull Request: https://github.com/freebsd/freebsd-src/pull/787

14 months agovn_path_to_global_path_hardlink(): initialize len
Konstantin Belousov [Tue, 4 Jul 2023 07:46:15 +0000 (10:46 +0300)]
vn_path_to_global_path_hardlink(): initialize len

before calling vn_fullpath_hardlink().  Otherwise we get random failures
when the len is automatically clipped.

Reported and tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 1 week

14 months agodtrace: move kinst tests to common
Christos Margiolis [Tue, 4 Jul 2023 15:46:59 +0000 (18:46 +0300)]
dtrace: move kinst tests to common

Reviewed by: markj
Approved by: markj (mentor)
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D40414

14 months agoriscv: improve register dumping
Christos Margiolis [Tue, 4 Jul 2023 15:38:37 +0000 (18:38 +0300)]
riscv: improve register dumping

Search for and print kernel symbols in case a register's value is a
kernel address. Also improve column alignment.

Reviewed by: mhorne, jhb
Approved by: markj (mentor)
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D40829

14 months agokinst: update LICENSE headers
Christos Margiolis [Tue, 4 Jul 2023 15:38:25 +0000 (18:38 +0300)]
kinst: update LICENSE headers

Reviewed by: markj
Approved by: markj (mentor)
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D40875

14 months agokinst: port to riscv
Christos Margiolis [Tue, 4 Jul 2023 15:38:01 +0000 (18:38 +0300)]
kinst: port to riscv

Reviewed by: markj
Approved by: markj (mentor)
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D39884

14 months agodtrace: cache current probe in kdtrace_thread_t
Christos Margiolis [Tue, 4 Jul 2023 15:37:55 +0000 (18:37 +0300)]
dtrace: cache current probe in kdtrace_thread_t

Needed by the forthcoming RISC-V and ARM64 ports.

Reviewed by: markj
Approved by: markj (mentor)
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D40872

14 months agokinst: accommodate other architectures in Makefile
Christos Margiolis [Tue, 4 Jul 2023 15:37:44 +0000 (18:37 +0300)]
kinst: accommodate other architectures in Makefile

Reviewed by: markj
Approved by: markj (mentor)
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D40871

14 months agoena: Update driver version to v2.6.3
Arthur Kiyanovski [Sun, 28 May 2023 08:42:05 +0000 (08:42 +0000)]
ena: Update driver version to v2.6.3

Bug Fixes:
* Initialize statistics before the interface is available
* Fix driver unload crash

Minor Changes:
* Mechanically convert ena(4) to DrvAPI
* Remove usage of IFF_KNOWSEPOCH

MFC after: 2 weeks
Sponsored by: Amazon, Inc.

14 months agoena: Fix driver unload crash
Arthur Kiyanovski [Sun, 21 May 2023 12:31:54 +0000 (12:31 +0000)]
ena: Fix driver unload crash

When ena_detach is called, we first call ether_ifdetach(),
which destroys internal addresses of ifp. One such address
is ifp->if_addr->ifa_addr. Then during ena_destroy_device(),
if_link_state_change() is called, eventually trying to access
ifp->if_addr->ifa_addr->sa_family. This causes an access
to garbage memory and crashes the kernel.

Ticket [1] was opened to the FreeBSD community to add null
check in the code of if_link_state_change().
A fix was submitted in commit [2], however it was noted
that it is our driver's responsibilty to not call
if_link_state_change() after calling ether_ifdetach().

This commit makes sure if_link_state_change() is not called
after ether_ifdetach().

[1]: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=270813
[2]: https://reviews.freebsd.org/D39614

Fixes: 32f63fa7f975 ("Split ENA reset routine into restore and destroy stages")
MFC after: 2 weeks
Sponsored by: Amazon, Inc.

14 months agoena: Initialize statistics before the interface is available
Osama Abboud [Wed, 18 Jan 2023 13:19:07 +0000 (13:19 +0000)]
ena: Initialize statistics before the interface is available

In [1], the FBSD community exposed a bug in the fbsd/ena driver.

Bug description:
----------------
Current function call order is as follows:

1. ena_attach()
1.1. ena_setup_ifnet()
1.1.1. Registration of ena_get_counter()
1.1.2. ether_ifattach(ifp, adapter->mac_addr);
1.2. Statistics allocation and initialization.

At point 1.1.2, when ether_ifattach() returns, the interface is available,
and stats can be read before they are allocated, leading to kernel panic.

Also fixed a potential memory leak by freeing the stats since they were
not freed in case the following calls failed.

Fix:
----
This commit moves the statistics allocation and initialization to happen
before ena_setup_ifnet()

[1] https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=268934

Fixes: 9b8d05b8ac78 ("Add support for Amazon Elastic Network Adapter (ENA) NIC")
Fixes: 30217e2dff10 ("Rework counting of hardware statistics in ENA driver")
MFC after: 2 weeks
Sponsored by: Amazon, Inc.

14 months agobin/date: Upgrade calculations (take 2)
Pedro F. Giffuni [Tue, 4 Jul 2023 04:39:00 +0000 (23:39 -0500)]
bin/date: Upgrade calculations (take 2)

Use uint64_t instead of long, as this type is not correct for platforms like i386 or armv7.

Pointed out by: imp

14 months agokillpg(): close a race with fork(), part 2
Konstantin Belousov [Fri, 16 Jun 2023 09:52:10 +0000 (12:52 +0300)]
killpg(): close a race with fork(), part 2

When we are sending terminating signal to the group, killpg() needs to
guarantee that all group members are to be terminated (it does not need
to ensure that they are terminated on return from killpg()).  The
pg_killsx change eliminates the largest window there, but still, if a
multithreaded process is signalled, the following could happen:
- thread 1 is selected for the signal delivery and gets descheduled
- thread 2 waits for pg_killsx lock, obtains it and forks
- thread 1 continue executing and terminates the process
This scenario allows the child to escape still.

To fix it, count the number of signals sent to the process with
killpg(2), in p_killpg_cnt variable, which is incremented in killpg()
and decremented after signal handler frame is created or in exit1()
after single-threading.  This way we avoid forking if the termination is
due.

Noted and reviewed by: markj (previous version)
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks
Differential revision: https://reviews.freebsd.org/D40493

14 months agokillpg(2): close a race with fork(2), part1
Konstantin Belousov [Mon, 12 Jun 2023 07:33:43 +0000 (10:33 +0300)]
killpg(2): close a race with fork(2), part1

If the process group member performs fork(), the child could escape
signalling from killpg(). Prevent it by introducing an sx process group
lock pg_killsx which is taken interruptibly shared around fork. If there
is a pending signal, do the trip through userspace with ERESTART to
handle signal ASTs. The lock is taken exclusively during killpg().

The lock is also locked exclusive when the process changes group
membership, to avoid escaping a signal by this means, by ensuring that
the process group is stable during fork.

Note that the new lock is before proctree lock, so in some situations we
could only do trylocking to obtain it.

This relatively simple approach cannot work for REAP_KILL, because
process potentially belongs to more than one reaper tree by having
sub-reapers.

Reported by: dchagin
Tested by: dchagin, pho
Reviewed by: markj
Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks
Differential revision: https://reviews.freebsd.org/D40493

14 months agokillpg1(): update the herald comment
Konstantin Belousov [Fri, 16 Jun 2023 09:02:04 +0000 (12:02 +0300)]
killpg1(): update the herald comment

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

14 months agovn_path_to_global_path_hardlink(): avoid freeing non-initialized pointer
Konstantin Belousov [Mon, 3 Jul 2023 17:22:33 +0000 (20:22 +0300)]
vn_path_to_global_path_hardlink(): avoid freeing non-initialized pointer

Reported by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 1 week

14 months agobin/date: Upgrade calculations
Pedro F. Giffuni [Mon, 3 Jul 2023 02:32:10 +0000 (21:32 -0500)]
bin/date: Upgrade calculations

Use long instead of int for numerous calculations, fixing a number of
date calculation overflow issues.

Obtained from: DragonflyBSD
Git log: 4238ce6f0c6df33ce677ae298b245c62cd60fb43 (only partial)

14 months agolib/libc/string: replace ffs/fls implementations with clang builtins
Robert Clausecker [Fri, 23 Jun 2023 16:22:54 +0000 (18:22 +0200)]
lib/libc/string: replace ffs/fls implementations with clang builtins

Most architectures we support (except for riscv64) have instructions
to compute these functions very quickly.  Replace old code with the
ffs and clz builtin functions, allowing clang to generate good code
for all architectures.

As a consequence, toss out arm and i386 ffs() implementations.

Sponsored by: FreeBSD Foundation
Approved by: mhorne
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D40730

14 months agolib/libc/tests/string: add unit tests for ffs, ffsl, ffsll, fls, flsl, and flsll
Robert Clausecker [Fri, 23 Jun 2023 17:26:44 +0000 (19:26 +0200)]
lib/libc/tests/string: add unit tests for ffs, ffsl, ffsll, fls, flsl, and flsll

Also supply CFLAGS+=-fno-builtin to ensure our unit tests
actually test libc functions and not clang's builtins.

Sponsored by: FreeBSD Foundation
Approved by: kevans
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D40729

14 months agopf tests: test double-pass codel
Kristof Provost [Mon, 3 Jul 2023 17:06:06 +0000 (19:06 +0200)]
pf tests: test double-pass codel

Build a setup where a given packet will be passed through the codel code
twice. This used to trigger issues with double-free on mtags.

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

14 months agoaltq codel: do not insert the same mtag twice
Kristof Provost [Mon, 3 Jul 2023 17:02:23 +0000 (19:02 +0200)]
altq codel: do not insert the same mtag twice

If we're called on an mbuf that's passed through codel before it may
already contain the MTAG_CODEL tag. The code accounts for this and does
not allocate a new mtag. However, it inserts the mtag unconditionally.
That is, it inserts the existing mtag a second time.

When the mbuf later gets freed we iterate over the list of mtags to fee
them one by one, and we'll end up freeing an mtag that's already been
freed.

Only insert the mtag if we've allocated a new one. If we found one
there's no need to insert it again.

See also: https://redmine.pfsense.org/issues/14497
Sponsored by: Rubicon Communications, LLC ("Netgate")

14 months agorelease: update GCE configuration for python3
Glen Barber [Mon, 3 Jul 2023 19:28:33 +0000 (15:28 -0400)]
release: update GCE configuration for python3

Reported by: asomers
PR: 272354
MFC after: 3 days
Sponsored by: GoFundMe https://www.gofundme.com/f/gjbbsd

14 months agoStop removing OpenSSL man pages that were revived in 3.0.9
Dimitry Andric [Mon, 3 Jul 2023 16:58:11 +0000 (18:58 +0200)]
Stop removing OpenSSL man pages that were revived in 3.0.9

PR: 271615
Fixes: b077aed33b7b ("Merge OpenSSL 3.0.9")

14 months agosyslog.3: document ident[N] format
Eugene Grosbein [Mon, 3 Jul 2023 12:35:37 +0000 (19:35 +0700)]
syslog.3: document ident[N] format

When libc switched to generation of logs as per RFC 5424,
that change broke application ability to insert specific process id
using ident[N] format, the feature existed for decades.
Some processes rely on it (including logger and syslogd).

Later the regression was fixed but the feature remained undocumented.
This change documents it.

MFC after: 1 week

14 months agodtrace: improve siftr probe
Michael Tuexen [Sun, 2 Jul 2023 01:08:51 +0000 (03:08 +0200)]
dtrace: improve siftr probe

Improve consistency of the field names with tcpsinfo_t:
* Use mss instead of max_seg_size.
* Use lport and rport instead of tcp_localport and tcp_foreignport.

Use t_flags instead of flags to improve consistency with t_flags2.

Add laddr and raddr, since the addresses were missing when compared
to the output of siftr.

Reviewed by: cc
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D40834

14 months agodumpdev: respect kenv for stable branches
Eugene Grosbein [Sun, 2 Jul 2023 07:54:57 +0000 (14:54 +0700)]
dumpdev: respect kenv for stable branches

We have somewhat twisted logic to determine actions for dumpdev
considering three sources of information:

* kenv "dumpdev" tunnable supposed to point to specific device;
* /etc/defaults/rc.conf "dumpdev" variable;
* /etc/rc.conf that may be unset or set to "NO", "AUTO" or device name.

For CURRENT without any setting in kenv or /etc/rc.conf
the default is "AUTO". For STABLE branches the default is "NO".

Current implementation breaks for STABLE branches if kenv points
to specific device but /etc/rc.conf does not set "dumpdev" at all.

Let us fix it commenting out "dumpdev" in /etc/defaults/rc.conf
for STABLE branches and making the code to consult kenv
if "dumpdev" is not set elsewhere.

MFC-after: 1 month

14 months agomodules: bzero the modspecific_t
Ka Ho Ng [Sat, 1 Jul 2023 19:41:53 +0000 (15:41 -0400)]
modules: bzero the modspecific_t

Per https://reviews.llvm.org/D68115, only the first field is
zero-initialized, meanwhile other fields are undef.

The pattern can be observed on clang as well, that when
-ftrivial-auto-var-init=pattern is specified 0xaa is filled for
non-active fields, otherwise they are zero-initialized.
Technically both are acceptable when using clang. However it
would be good to simply bzero the modspecific_t in such case to
be strict to the standard.

MFC with: 2cab2d43b83b
MFC after: 1 day
Sponsored by: Juniper Networks, Inc.
Reviewed by: delphij
Differential Revision: https://reviews.freebsd.org/D40830

14 months agolibkern: Trim OBE comment from divmoddi routines.
John Baldwin [Sat, 1 Jul 2023 21:43:53 +0000 (14:43 -0700)]
libkern: Trim OBE comment from divmoddi routines.

-1/2 is defined to be 0 in modern C.

Reviewed by: jrtc27
Differential Revision: https://reviews.freebsd.org/D40833

14 months agodivmoddi4: Handle negative remainders.
John Baldwin [Sat, 1 Jul 2023 21:43:41 +0000 (14:43 -0700)]
divmoddi4: Handle negative remainders.

The sign of the remainder matches the sign of the numerator in C.

Reported by: jrtc27
Reviewed by: jrtc27
Differential Revision: https://reviews.freebsd.org/D40832

14 months agoCreate correct engines debug directory after OpenSSL 3.0.9 merge
Dimitry Andric [Sat, 1 Jul 2023 20:59:23 +0000 (22:59 +0200)]
Create correct engines debug directory after OpenSSL 3.0.9 merge

PR: 271656
Fixes: b077aed33b7b ("Merge OpenSSL 3.0.9")

14 months agordrand_rng: Build with -fPIC on i386 when using GCC.
John Baldwin [Sat, 1 Jul 2023 19:23:00 +0000 (12:23 -0700)]
rdrand_rng: Build with -fPIC on i386 when using GCC.

ld.bfd requires an R_386_PLT32 relocation for calls to ifuncs
rather than R_386_PC32.  (lld permits R_386_PC32.)

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

14 months agosys: Add [u]divmoddi4 intrinsics on i386.
John Baldwin [Sat, 1 Jul 2023 19:22:44 +0000 (12:22 -0700)]
sys: Add [u]divmoddi4 intrinsics on i386.

GCC 12 uses these in several places when building the i386 kernel.
They are very similar to [u]divdiv3 except that they return both
the quotient and the remainder.

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

14 months agosys: Switch the kernel's C standard from C99 to GNU99.
John Baldwin [Sat, 1 Jul 2023 19:21:13 +0000 (12:21 -0700)]
sys: Switch the kernel's C standard from C99 to GNU99.

This matches the default used in userland, and the kernel already
depends on various GNU extensions to standard C that are supported by
both clang and GCC.

This should be a no-op for clang, but for GCC it enables some GNU
extensions that aren't otherwise enabled.  It also enables GCC for
i386 to avoid the need for a floatundidf intrinsic in libkern.

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

14 months agosyscalls: fix modspecific_t stack content leak
Ka Ho Ng [Tue, 27 Jun 2023 19:33:46 +0000 (15:33 -0400)]
syscalls: fix modspecific_t stack content leak

Zero-initialize the whole modspecific_t so that there would
not be kernel stack content leak in the unused part.

Sponsored by: Juniper Networks, Inc.
MFC after: 1 days
Differential Revision: https://reviews.freebsd.org/D40815

14 months agonctgpio: Populate the cache earlier
Stéphane Rochoy [Sat, 1 Jul 2023 17:19:44 +0000 (11:19 -0600)]
nctgpio: Populate the cache earlier

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/719

14 months agosuperio+ncthwm: Add hardware monitoring support
Stéphane Rochoy [Sat, 1 Jul 2023 17:19:44 +0000 (11:19 -0600)]
superio+ncthwm: Add hardware monitoring support

Add support for the following chips:
- Nuvoton NCT6779D
- Nuvoton NCT6796D-E

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/719

14 months agosuperio+nctgpio: Add support for new (weird) chips
Stéphane Rochoy [Sat, 1 Jul 2023 17:19:44 +0000 (11:19 -0600)]
superio+nctgpio: Add support for new (weird) chips

Add support for the following chips:
- Nuvoton NCT5585D
- Nuvoton NCT6796D-E
- Nuvoton NCT6779
- Nuvoton NCT6116D
- and Winbond 83627DHG

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/719

14 months agosuperio+nctgpio: Prepare to support some new (weird) chips
Stéphane Rochoy [Sat, 1 Jul 2023 17:19:44 +0000 (11:19 -0600)]
superio+nctgpio: Prepare to support some new (weird) chips

- Increase verbosity to direct i/o code path (iores != 0)
- Fix pin inversion configuration
- Allow forcing the use of indirect access channel via hint.gpio.0.flags=2
- Document the PREFER_INDIRECT_CHANNEL tunable in nctgpio(4)

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/719

14 months agosuperio: Handle conflicting devid via prefer/extid
Stéphane Rochoy [Sat, 1 Jul 2023 17:19:44 +0000 (11:19 -0600)]
superio: Handle conflicting devid via prefer/extid

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/719

14 months agosysctl: Document formats for uint8_t and uint16_t in sysctl(9)
Stéphane Rochoy [Sat, 1 Jul 2023 17:19:44 +0000 (11:19 -0600)]
sysctl: Document formats for uint8_t and uint16_t in sysctl(9)

Was missing from c3220d0b6d72a1ed0ccfa188f0dfceef74421ab9.

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/719

14 months agosuperio: Add superio_ldn_read and superio_ldn_write
Stéphane Rochoy [Sat, 1 Jul 2023 17:19:44 +0000 (11:19 -0600)]
superio: Add superio_ldn_read and superio_ldn_write

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/719

14 months agonctgpio(4): Document supported Nuvoton chips
Stéphane Rochoy [Sat, 1 Jul 2023 17:19:44 +0000 (11:19 -0600)]
nctgpio(4): Document supported Nuvoton chips

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/719

14 months agosuperio(4): Document supported Nuvoton and Winbond chips
Stéphane Rochoy [Sat, 1 Jul 2023 17:19:43 +0000 (11:19 -0600)]
superio(4): Document supported Nuvoton and Winbond chips

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/719

14 months agoStand: Silence undefined symbols check command
VexedUXR [Sat, 1 Jul 2023 17:16:44 +0000 (11:16 -0600)]
Stand: Silence undefined symbols check command

No need to print this...

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/786

14 months agobios: Don't keep sending BIO_FLUSH after first ENOTSUPP.
santhoshkumar-mani [Sat, 1 Jul 2023 17:11:57 +0000 (11:11 -0600)]
bios: Don't keep sending BIO_FLUSH after first ENOTSUPP.

When a storage device reports that it does not support cache flush, the
GEOM disk layer by default returns ENOTSUPP in response to a BIO_FLUSH
command.

On AWS, local volumes do not advertise themselves as having write-cache
enabled.  When they are selected for L3 on all HDD nodes, the L3
subsystem may inadvertently kick these L3 devices if a BIO_FLUSH command
fails with an ENOTSUPP return code.  The fix is to make GEOM disk return
success (0) when this condition occurs and add a sysctl to make this
error handling config-driven

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/710

14 months agoqlnxe: remove unused variable from ecore_ll2.c
Mark O'Donovan [Sat, 1 Jul 2023 17:06:51 +0000 (11:06 -0600)]
qlnxe: remove unused variable from ecore_ll2.c

Signed-off-by: Mark O'Donovan <shiftee@posteo.net>
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/779

14 months agoqlnxe: add driver to amd64 NOTES
Mark O'Donovan [Sat, 1 Jul 2023 17:06:51 +0000 (11:06 -0600)]
qlnxe: add driver to amd64 NOTES

Signed-off-by: Mark O'Donovan <shiftee@posteo.net>
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/779

14 months agoqlnxe: Fix building as in-kernel component
Mark O'Donovan [Sat, 1 Jul 2023 17:06:51 +0000 (11:06 -0600)]
qlnxe: Fix building as in-kernel component

Add some extra files for building the driver as part of the kernel.
Change some #defines to match those used when building as a module.

PR: 268354

Signed-off-by: Mark O'Donovan <shiftee@posteo.net>
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/779

14 months agoqlnxe: Fix unused but set variable warning
Mark O'Donovan [Sat, 1 Jul 2023 17:06:51 +0000 (11:06 -0600)]
qlnxe: Fix unused but set variable warning

Signed-off-by: Mark O'Donovan <shiftee@posteo.net>
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/779

14 months agoqlnxe: Remove #ifdef ECORE_PACKAGE
Mark O'Donovan [Sat, 1 Jul 2023 17:06:50 +0000 (11:06 -0600)]
qlnxe: Remove #ifdef ECORE_PACKAGE

I do not know why this is here but it blocks compilation.
Removing it makes the builtin option the same as the module build

Signed-off-by: Mark O'Donovan <shiftee@posteo.net>
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/779

14 months agoqlnxe: Fix too many args in call to internal_ram_wr()
Mark O'Donovan [Sat, 1 Jul 2023 17:06:50 +0000 (11:06 -0600)]
qlnxe: Fix too many args in call to internal_ram_wr()

internal_ram_wr() only takes 3 args when ECORE_CONFIG_DIRECT_HWFN
is defined

Signed-off-by: Mark O'Donovan <shiftee@posteo.net>
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/779

14 months agoqlnxe: Move sriov includes to qlnx_os.c
Mark O'Donovan [Sat, 1 Jul 2023 17:06:50 +0000 (11:06 -0600)]
qlnxe: Move sriov includes to qlnx_os.c

SRIOV is being enabled in ecore.h but by then
the qlnx_os.h header has been processed and not
included the relevant headers

Signed-off-by: Mark O'Donovan <shiftee@posteo.net>
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/779

14 months agoqlnxe: Remove -Wno-case-qual from module build
Mark O'Donovan [Sat, 1 Jul 2023 17:06:50 +0000 (11:06 -0600)]
qlnxe: Remove -Wno-case-qual from module build

Signed-off-by: Mark O'Donovan <shiftee@posteo.net>
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/779

14 months agozfs: merge openzfs/zfs@009d3288d
Martin Matuska [Sat, 1 Jul 2023 10:32:38 +0000 (12:32 +0200)]
zfs: merge openzfs/zfs@009d3288d

Notable upstream pull request merges:
  #14654 Pack our DDT ZAPs a bit denser
  #14979 Again fix race between zil_commit() and zil_suspend()
  #14985 Some ZIO micro-optimizations
  #15000 Fix remount when setting multiple properties
  #15004 ddt_addref: remove unnecessary phys fill when refcount is 0
  #15007 Do not report bytes skipped by scan as issued
  #15023 Enable tuning of ZVOL open timeout value

Obtained from: OpenZFS
OpenZFS commit: 009d3288dea524c7ad373b04b65bee8bb6f0bfea
OpenZFS tag: zfs-2.2.0-rc1

14 months agosiftr: unbreak dtrace support
Michael Tuexen [Sat, 1 Jul 2023 07:50:54 +0000 (09:50 +0200)]
siftr: unbreak dtrace support

This patch adds back some fields needed by the siftr probe, which were
removed in
https://cgit.freebsd.org/src/commit/?id=aa61cff4249c92689d7a1f15db49d65d082184cb

With this fix, you can run dtrace scripts again when the siftr
module is loaded. And the siftr probe works again.

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

14 months agocsu: Add the prologue and epilogue to the _init and _fini on x86_64
Dmitry Chagin [Sat, 1 Jul 2023 07:52:10 +0000 (10:52 +0300)]
csu: Add the prologue and epilogue to the _init and _fini on x86_64

Normally, modern unwinders uses Dwarf information to unwind stack,
however in case when the code is not annotated by Dwarf instructions,
unwinders fallbacks to a frame-pointer based algorithm.

That is allows libunwind to unwind stack from global constructors and
destructors. Also it makes gdb happy as it printed nonexistent frame
before.

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

14 months agortld: Add a stop indicator to rtld_start to satisfy unwinders on x86_64
Dmitry Chagin [Sat, 1 Jul 2023 07:51:35 +0000 (10:51 +0300)]
rtld: Add a stop indicator to rtld_start to satisfy unwinders on x86_64

The right unwinding stop indicator should be CFI-undefined PC.
https://dwarfstd.org/doc/Dwarf3.pdf - page 118:
If a Return Address register is defined in the virtual unwind table,
and its rule is undefined (for example, by DW_CFA_undefined), then
there is no return address and no call address, and the virtual
unwind of stack activations is complete.

That is allows gdb and libunwind successfully stop when unwinding stack
from global constructors and destructors.

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

14 months agodtrace: third update to the siftr probe
Michael Tuexen [Sat, 1 Jul 2023 07:27:31 +0000 (09:27 +0200)]
dtrace: third update to the siftr probe

This adds the changes corresponding to
https://cgit.freebsd.org/src/commit/?id=60167184abd54ca12c6bf7ab60f2a08b41342f84
to the siftr probe.
This concludes the series up updates.

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

14 months agonetinet[6]: make in[6]_control use ucred instead of td.
Alexander V. Chernikov [Thu, 29 Jun 2023 07:02:46 +0000 (07:02 +0000)]
netinet[6]: make in[6]_control use ucred instead of td.

Reviewed by: markj, zlei
Differential Revision: https://reviews.freebsd.org/D40793
MFC after: 2 weeks

14 months agodtrace: another update of the siftr probe
Michael Tuexen [Sat, 1 Jul 2023 00:45:16 +0000 (02:45 +0200)]
dtrace: another update of the siftr probe

This adds the changes corresponding to
https://cgit.freebsd.org/src/commit/?id=d090464ecd4af5cd400ef5cbbfe8409d019eac34
to the siftr probe.

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

14 months agodtrace: update siftr probe
Michael Tuexen [Sat, 1 Jul 2023 00:26:52 +0000 (02:26 +0200)]
dtrace: update siftr probe

This adds the changes corresponding to
https://cgit.freebsd.org/src/commit/?id=1241e8e7aed5d709a6cf62024e9ae750981c03ae
to the siftr probe.

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

14 months agosiftr: document siftr probe to man page of the tcp provider
Michael Tuexen [Fri, 30 Jun 2023 22:13:00 +0000 (00:13 +0200)]
siftr: document siftr probe to man page of the tcp provider

This man page documents what is currently implemented in siftr.d.
It doesn't work right now in head, but in stable/13. Follow-up
commits will fix it for head.

Reviewed by: cc, pauamma_gundo.com
MFC after: 3 days
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D40809

14 months agotest: remove remainder of testfloat
Marius Strobl [Fri, 30 Jun 2023 20:36:39 +0000 (22:36 +0200)]
test: remove remainder of testfloat

These bits are unused since the sparc64-specific glue has been deleted
in f33b14f0.

14 months agodtrace: fix constants used by the siftr probe
Michael Tuexen [Fri, 30 Jun 2023 20:15:47 +0000 (22:15 +0200)]
dtrace: fix constants used by the siftr probe

The constants used in the C code were changed in
https://svnweb.freebsd.org/changeset/base/343646
but changing them also in the dtrace translator was missed.

Reviewed by: cc, rscheff
MFC after: 3 days
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D40805

14 months agosiftr: provide dtrace with the correct pointer to data
Michael Tuexen [Fri, 30 Jun 2023 20:03:04 +0000 (22:03 +0200)]
siftr: provide dtrace with the correct pointer to data

This fixes a bug which was introduced in the commit
https://svnweb.freebsd.org/changeset/base/282276

Reviewed by: cc, rscheff
MFC after: 3 days
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D40806

14 months agoTag 2.2.0-rc1
Brian Behlendorf [Fri, 30 Jun 2023 18:42:14 +0000 (11:42 -0700)]
Tag 2.2.0-rc1

New features:
- Fully adaptive ARC eviction (#14359)
- Block cloning (#13392)
- Scrub error log (#12812, #12355)
- Linux container support (#14070, #14097, #12263)
- BLAKE3 Checksums (#12918)
- Corrective "zfs receive" (#9372)

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>