]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
2 years agocrypto: Define POLY1305_BLOCK_LEN constant.
John Baldwin [Thu, 16 Dec 2021 21:47:16 +0000 (13:47 -0800)]
crypto: Define POLY1305_BLOCK_LEN constant.

Reviewed by: markj
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D33485

(cherry picked from commit 47fc04958562e3a1fca06f9321f89bea3d1dcab7)

2 years agoSort libsodium sources by path in sys/modules/crypto/Makefile.
John Baldwin [Thu, 16 Dec 2021 21:47:03 +0000 (13:47 -0800)]
Sort libsodium sources by path in sys/modules/crypto/Makefile.

This matches the order used in sys/conf/files to make it easier to
keep these two files in sync.

Reviewed by: imp
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D33484

(cherry picked from commit 8b4af206f67e93735a5b22921469a2bce63fb6ab)

2 years agoSort libsodium entries by path in sys/conf/files.
John Baldwin [Thu, 16 Dec 2021 21:46:48 +0000 (13:46 -0800)]
Sort libsodium entries by path in sys/conf/files.

Reviewed by: imp
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D33483

(cherry picked from commit eb2d9adb246a7ff184ddd0d3fccfeccbf067985b)

2 years agoRELNOTES: Note support for KTLS RX for TLS 1.3.
John Baldwin [Tue, 14 Dec 2021 19:02:45 +0000 (11:02 -0800)]
RELNOTES: Note support for KTLS RX for TLS 1.3.

Sponsored by: Netflix

(cherry picked from commit 253ecb389e91cd2460ff0ed98b8541ecab7391a0)

2 years agoktls: Support for TLS 1.3 receive offload.
John Baldwin [Tue, 14 Dec 2021 19:01:05 +0000 (11:01 -0800)]
ktls: Support for TLS 1.3 receive offload.

Note that support for TLS 1.3 receive offload in OpenSSL is still an
open pull request in active development.  However, potential changes
to that pull request should not affect the kernel interface.

Reviewed by: hselasky
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D33007

(cherry picked from commit 05a1d0f5d7ac8400975d1eaa30a718a1ff48b139)

2 years agoTLS: Use <machine/tls.h> for libc and rtld.
John Baldwin [Thu, 9 Dec 2021 21:17:54 +0000 (13:17 -0800)]
TLS: Use <machine/tls.h> for libc and rtld.

- Include <machine/tls.h> in MD rtld_machdep.h headers.

- Remove local definitions of TLS_* constants from rtld_machdep.h
  headers and libc using the values from <machine/tls.h> instead.

- Use _tcb_set() instead of inlined versions in MD
  allocate_initial_tls() routines in rtld.  The one exception is amd64
  whose _tcb_set() invokes the amd64_set_fsbase ifunc.  rtld cannot
  use ifuncs, so amd64 inlines the logic to optionally write to fsbase
  directly.

- Use _tcb_set() instead of _set_tp() in libc.

- Use '&_tcb_get()->tcb_dtv' instead of _get_tp() in both rtld and libc.
  This permits removing _get_tp.c from rtld.

- Use TLS_TCB_SIZE and TLS_TCB_ALIGN with allocate_tls() in MD
  allocate_initial_tls() routines in rtld.

Reviewed by: kib, jrtc27 (earlier version)
Differential Revision: https://reviews.freebsd.org/D33353

(cherry picked from commit 8bcdb144ebe391ce243c71caf06cf417d96ce335)

2 years agolibthr: Use <machine/tls.h> for most MD TLS details.
John Baldwin [Thu, 9 Dec 2021 21:17:41 +0000 (13:17 -0800)]
libthr: Use <machine/tls.h> for most MD TLS details.

Note that on amd64 this effectively removes the unused tcb_spare field
from the end of struct tcb since the definition of struct tcb in
<x86/tls.h> does not include that field.

Reviewed by: kib, jrtc27
Sponsored by: The University of Cambridge, Google Inc.
Differential Revision: https://reviews.freebsd.org/D33352

(cherry picked from commit 75395023ff1edaf4832389716338b1ba12121ffe)

2 years agoAdd <machine/tls.h> header to hold MD constants and helpers for TLS.
John Baldwin [Thu, 9 Dec 2021 21:17:13 +0000 (13:17 -0800)]
Add <machine/tls.h> header to hold MD constants and helpers for TLS.

The header exports the following:

- Definition of struct tcb.
- Helpers to get/set the tcb for the current thread.
- TLS_TCB_SIZE (size of TCB)
- TLS_TCB_ALIGN (alignment of TCB)
- TLS_VARIANT_I or TLS_VARIANT_II
- TLS_DTV_OFFSET (bias of pointers in dtv[])
- TLS_TP_OFFSET (bias of "thread pointer" relative to TCB)

Note that TLS_TP_OFFSET does not account for if the unbiased thread
pointer points to the start of the TCB (arm and x86) or the end of the
TCB (MIPS, PowerPC, and RISC-V).

Note also that for amd64, the struct tcb does not include the unused
tcb_spare field included in the current structure in libthr.  libthr
does not use this field, and the existing calls in libc and rtld that
allocate a TCB for amd64 assume it is the size of 3 Elf_Addr's (and
thus do not allocate room for tcb_spare).

A <sys/_tls_variant_i.h> header is used by architectures using
Variant I TLS which uses a common struct tcb.

Reviewed by: kib (older version of x86/tls.h), jrtc27
Sponsored by: The University of Cambridge, Google Inc.
Differential Revision: https://reviews.freebsd.org/D33351

For stable/13 only, sys/arm/include/tls.h includes support for
ARM_TP_ADDRESS which is not present in main.

(cherry picked from commit 1a62e9bc0046bfe20f4dd785561e469ff73fd508)

2 years agolibc: Fix the alignment of the TCB to match rtld for several architectures.
John Baldwin [Thu, 9 Dec 2021 21:16:57 +0000 (13:16 -0800)]
libc: Fix the alignment of the TCB to match rtld for several architectures.

- Use 16 byte alignment rather than 8 for aarch64, powerpc64, and RISC-V.

- Use 8 byte alignment rather than 4 for 32-bit arm, mips, and powerpc.

I suspect that mips64 should be using 16 byte alignment, but both libc
and rtld currently use 8 byte alignment.

Reviewed by: kib, jrtc27
Sponsored by: The University of Cambridge, Google Inc.
Differential Revision: https://reviews.freebsd.org/D33350

(cherry picked from commit 4c2f5bfbfa48b33b11912e7308ebd6f98fb6e647)

2 years agoamd64: Allocate TCB with alignment of 16 rather than 8.
John Baldwin [Thu, 9 Dec 2021 21:16:45 +0000 (13:16 -0800)]
amd64: Allocate TCB with alignment of 16 rather than 8.

This matches the TLS_TCB_ALIGN definition in libc.

Reviewed by: kib, jrtc27
Sponsored by: The University of Cambridge, Google Inc.
Differential Revision: https://reviews.freebsd.org/D33349

(cherry picked from commit 299617496cc3c525a63833894fd8dbdc4e5de6a7)

2 years agomips _libc_get_static_tls_base: Narrow scope of #ifdef.
John Baldwin [Thu, 9 Dec 2021 21:16:34 +0000 (13:16 -0800)]
mips _libc_get_static_tls_base: Narrow scope of #ifdef.

Reviewed by: kib, emaste, jrtc27
Sponsored by: The University of Cambridge, Google Inc.
Differential Revision: https://reviews.freebsd.org/D33348

(cherry picked from commit 9952b82b398968a243909ee3854b1968c3cc8c12)

2 years agomips: Add TLS_DTV_OFFSET to the result of tls_get_addr_common.
John Baldwin [Thu, 9 Dec 2021 21:16:19 +0000 (13:16 -0800)]
mips: Add TLS_DTV_OFFSET to the result of tls_get_addr_common.

Previously TLS_DTV_OFFSET was added to the offset passed to
tls_get_addr_common; however, this approach matches powerpc and RISC-V
and better matches the intention.

Reviewed by: kib, jrtc27
Sponsored by: The University of Cambridge, Google Inc.
Differential Revision: https://reviews.freebsd.org/D33347

(cherry picked from commit 23e0c0e9a3e0c73169c2aa90e26bb5cb35f1aa2f)

2 years agomips: Rename TLS_DTP_OFFSET to TLS_DTV_OFFSET.
John Baldwin [Thu, 9 Dec 2021 21:16:00 +0000 (13:16 -0800)]
mips: Rename TLS_DTP_OFFSET to TLS_DTV_OFFSET.

This is the more standard name for the bias of dtv pointers used on
other platforms.  This also fixes a few other places that were using
the wrong bias previously on MIPS such as dlpi_tls_data in struct
dl_phdr_info and the recently added __libc_tls_get_addr().

Reviewed by: kib, jrtc27
Sponsored by: The University of Cambridge, Google Inc.
Differential Revision: https://reviews.freebsd.org/D33346

(cherry picked from commit 03f6b141068ee7f1004ebfc76242cf951494b7d2)

2 years agolibthr: Remove the DTV_OFFSET macro.
John Baldwin [Thu, 9 Dec 2021 21:15:38 +0000 (13:15 -0800)]
libthr: Remove the DTV_OFFSET macro.

This macro is confusing as it is not related to the similarly named
TLS_DTV_OFFSET.  Instead, replace its one use with the desired
expression which is the same on all platforms.

Reviewed by: kib, emaste, jrtc27
Sponsored by: The University of Cambridge, Google Inc.
Differential Revision: https://reviews.freebsd.org/D33345

(cherry picked from commit 5d8176337e691d3ca3fa7d519bc3eaacf6d9faee)

2 years agortld-elf: Use _get_tp in __tls_get_addr for aarch64 and riscv64.
John Baldwin [Wed, 17 Nov 2021 23:50:55 +0000 (15:50 -0800)]
rtld-elf: Use _get_tp in __tls_get_addr for aarch64 and riscv64.

Reviewed by: kib
Sponsored by: The University of Cambridge, Google Inc.
Differential Revision: https://reviews.freebsd.org/D33047

(cherry picked from commit b928e924f74b0b8f882a9b735611421a93113640)

2 years agoGMAC: Reset initial hash value and counter in AES_GMAC_Reinit().
John Baldwin [Thu, 9 Dec 2021 19:52:42 +0000 (11:52 -0800)]
GMAC: Reset initial hash value and counter in AES_GMAC_Reinit().

Previously, these values were only cleared in AES_GMAC_Init(), so a
second set of operations could reuse the final hash as the initial
hash.  Currently this bug does not trigger in cryptosoft as existing
GMAC and GCM operations always use an on-stack auth context
initialized from a template context.

Reviewed by: markj
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D33315

(cherry picked from commit 356c922f74bfcece1f139026897a79c62adbdf50)

2 years agocrypto: Don't assert for empty output buffers.
John Baldwin [Thu, 9 Dec 2021 19:52:41 +0000 (11:52 -0800)]
crypto: Don't assert for empty output buffers.

It is always valid for crp_payload_output_start to be 0.  However, if
an output buffer is empty (e.g. a decryption request with a tag but an
empty payload), the existing assertion failed since 0 is not less than
0.

Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D33193

(cherry picked from commit ec498562b71a5e2baee3556eed7e22947f7abc5d)

2 years agocryptosoft: Reject AES-CCM/GCM sessions with invalid key lengths.
John Baldwin [Thu, 9 Dec 2021 19:52:41 +0000 (11:52 -0800)]
cryptosoft: Reject AES-CCM/GCM sessions with invalid key lengths.

Reviewed by: markj
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D33195

(cherry picked from commit c172a407fb0d2e6b4389625ebf604b5a2f831054)

2 years agocrypto: Validate AES-GCM IV length in check_csp().
John Baldwin [Thu, 9 Dec 2021 19:52:41 +0000 (11:52 -0800)]
crypto: Validate AES-GCM IV length in check_csp().

This centralizes the check for valid nonce lengths for AES-GCM.

While here, remove some duplicate checks for valid AES-GCM tag lengths
from ccp(4) and ccr(4).

Reviewed by: markj
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D33194

(cherry picked from commit 6e17a2e00d62fd3041e0bb511fe925079ad1c0d7)

2 years agoOnly use OLD_LIBS with shared libraries.
John Baldwin [Fri, 3 Dec 2021 01:30:00 +0000 (17:30 -0800)]
Only use OLD_LIBS with shared libraries.

Use OLD_FILES for a few symbolic links and static libraries previously
included in OLD_LIBS.

Add a missing shared library major number to an old libroken entry.

(cherry picked from commit 60a8277413eca3fa57f85caf331b080aee030fe5)

2 years agoAdd lib32 entries for WITHOUT_PROFILE.
John Baldwin [Wed, 1 Dec 2021 22:25:37 +0000 (14:25 -0800)]
Add lib32 entries for WITHOUT_PROFILE.

Reported by: Mark Millard

(cherry picked from commit 610d908f8a6a2c152bf45dfaf1ada119c513c04b)

2 years agoTrim a couple of duplicate entries from WITHOUT_PROFILE.
John Baldwin [Wed, 1 Dec 2021 22:23:31 +0000 (14:23 -0800)]
Trim a couple of duplicate entries from WITHOUT_PROFILE.

(cherry picked from commit 07c2b29b6ed805bade2751a53274bb3dd3d20edd)

2 years agoAdd various profiled libraries missing from the WITHOUT_PROFILE list.
John Baldwin [Wed, 1 Dec 2021 22:22:29 +0000 (14:22 -0800)]
Add various profiled libraries missing from the WITHOUT_PROFILE list.

Reported by: Mark Millard

(cherry picked from commit 99188582cc9bf37acf1653ad4a0c2b51666d7107)

2 years agoRemove sparc64 lastcomm/sa tests.
John Baldwin [Wed, 1 Dec 2021 22:14:58 +0000 (14:14 -0800)]
Remove sparc64 lastcomm/sa tests.

Reported by: Mark Millard
Fixes: d6dffbae9662 lastcomm/sa: Remove sparc64 tests, they aren't needed.

(cherry picked from commit 22375931e46f469f77f5e94462073aa34076d654)

2 years agokern_utimensat: Update name of last arg in prototype.
John Baldwin [Thu, 4 Nov 2021 18:02:55 +0000 (11:02 -0700)]
kern_utimensat: Update name of last arg in prototype.

The last argument is a mask of AT_* flags, not a namei cnp flag as
'int follow' implies in other kern_* functions.

Obtained from: CheriBSD
Sponsored by: The University of Cambridge, Google Inc.

(cherry picked from commit 3225fd22b2191c7a7a655cb5dacea9148f29c926)

2 years agogeom_vfs: Pre-allocate event for g_vfs_destroy.
John Baldwin [Fri, 30 Jul 2021 00:09:23 +0000 (17:09 -0700)]
geom_vfs: Pre-allocate event for g_vfs_destroy.

When an active g_vfs is orphaned due to an underlying disk going away
the destroy is deferred until the filesystem is unmounted in
g_vfs_done().  However, g_vfs_done() is invoked from a non-sleepable
context and cannot use M_WAITOK to allocate the event.  Instead,
allocate the event in g_vfs_orphan() and save it in the softc to be
retrieved by the last call to g_vfs_done().

Reported by: Jithesh Arakkan @ Chelsio
Reviewed by: imp
Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D31354

(cherry picked from commit 419d406e4ee068644218fb881bc80f79f8191970)

2 years agoUse a more specific type for geom_disk.d_event.
John Baldwin [Thu, 29 Jul 2021 23:34:46 +0000 (16:34 -0700)]
Use a more specific type for geom_disk.d_event.

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

(cherry picked from commit 5b5d78897c8b1ec6b6e1dd8dd9cdbf19fee32149)

2 years agofusefs: fix two bugs regarding VOP_RECLAIM of the root inode
Alan Somers [Sat, 2 Apr 2022 19:31:24 +0000 (13:31 -0600)]
fusefs: fix two bugs regarding VOP_RECLAIM of the root inode

* We never send FUSE_LOOKUP for the root inode, since its inode number
  is hard-coded to 1.  Therefore, we should not send FUSE_FORGET for it,
  lest the server see its lookup count fall below 0.

* During VOP_RECLAIM, if we are reclaiming the root inode, we must clear
  the file system's vroot pointer.  Otherwise it will be left pointing
  at a reclaimed vnode, which will cause future VOP_LOOKUP operations to
  fail.  Previously we only cleared that pointer during VFS_UMOUNT.  I
  don't know of any real-world way to trigger this bug.

Reviewed by: pfg
Differential Revision: https://reviews.freebsd.org/D34753

(cherry picked from commit 32273253667b941c376cf08383006b3a0cbc5ca2)

2 years agoamd64, i386: remove profile directive from NOTES
Kyle Evans [Thu, 28 Apr 2022 03:59:02 +0000 (22:59 -0500)]
amd64, i386: remove profile directive from NOTES

Support for this directive has been removed in config(8) on main,
which leaves us unable to build LINT with newer config(8).  It's
believed that mcount-based profiling didn't really work on modern
systems anyways, so the value of testing this is low.

We avoid providing limited backwards compatibility here to continue and
warn folks that may somehow be deploying real-world configs with `profile`
specified.

This is a direct commit to stable/13, but a partial MFC of aa3ea612be36.

2 years agoctfdump: Remove definitions of warn() and vwarn()
Mark Johnston [Thu, 21 Apr 2022 14:49:22 +0000 (10:49 -0400)]
ctfdump: Remove definitions of warn() and vwarn()

The presence of the latter causes a link error when building a
statically linked ctfdump(1) because libc defines the same symbol.
libc's warn() is defined as a weak symbol and so does not cause the same
problem, but let's just use libc's version.

Reported by: stephane rochoy <stephane.rochoy@stormshield.eu>
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 45dd2eaac379e5576f745380260470204c49beac)

2 years agoctf: Link CTF toolchain man pages to ctf.5
Mark Johnston [Thu, 21 Apr 2022 14:56:03 +0000 (10:56 -0400)]
ctf: Link CTF toolchain man pages to ctf.5

Also expand the CTF acronym to provide a bit of context.

PR: 259790
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 5727eceabc93e218f0dd369a66d06d619e7fa080)

2 years agomld6: Ensure that mld_domifattach() always succeeds
Mark Johnston [Thu, 21 Apr 2022 17:22:09 +0000 (13:22 -0400)]
mld6: Ensure that mld_domifattach() always succeeds

mld_domifattach() does a memory allocation under the global MLD mutex
and so can fail, but no error handling prevents a null pointer
dereference in this case.  The mutex is only needed when updating the
global softc list; the allocation and static initialization of the softc
does not require this mutex.  So, reduce the scope of the mutex and use
M_WAITOK for the allocation.

PR: 261457
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 5d691ab4f03d436d38f46777c3c117cf5a27f1bc)

2 years agoxhci(4): Ensure the so-called data toggle gets properly reset.
Hans Petter Selasky [Thu, 21 Apr 2022 14:59:09 +0000 (16:59 +0200)]
xhci(4): Ensure the so-called data toggle gets properly reset.

Use the drop and enable endpoint context commands to force a reset of
the data toggle for USB 2.0 and USB 3.0 after:
 - clear endpoint halt command (when the driver wishes).
 - set config command (when the kernel or user-space wants).
 - set alternate setting command (only affected endpoints).

Some XHCI HW implementations may not allow the endpoint reset command when
the endpoint context is not in the halted state.

Reported by: Juniper and Gary Jennejohn
Sponsored by: NVIDIA Networking

(cherry picked from commit cda31e734925346328fd2369585ab3f6767ec225)

2 years agoe1000: Try auto-negotiation for fixed 100 or 10 configuration
J.R. Oldroyd [Wed, 13 Apr 2022 16:11:30 +0000 (09:11 -0700)]
e1000: Try auto-negotiation for fixed 100 or 10 configuration

Currently if an e1000 interface is set to a fixed media configuration,
for gigabit, it will participate in auto-negotiation as required by
IEEE 802.3-2018 Clause 37. However, if set to fixed media configuration
for 100 or 10, it does NOT participate in auto-negotiation.

By my reading of Clauses 28 and 37, while auto-negotiation is optional
for 100 and 10, it is not prohibited and is, in fact, "highly
recommended".

This patch enables auto-negotiation for fixed 100 and 10 media
configuration, in a similar manner to that already performed for 1000.
I.e., the patch enables advertising of just the manually configured
settings with the goal of allowing the remote end to match the manually
configured settings if it has them available.

To be clear, this patch does NOT allow an em(4) interface that has been
manually configured with specific media settings to respond to
auto-negotiation by then configuring different parameters to those that
were manually configured. The intent of this patch is to fully comply
with the requirements of Clause 37, but for 100 and 10.

The need for this has arisen on an em(4) link where the other end is
under a different administrative control and is set to full
auto-negotiation. Due to the cable length GigE is not working well. It
is desired to set the em(4) end to "media 100baseTX mediatype
full-duplex" which does work when both ends are configured that way.
Currently, because em(4) does not participate in autoneg for this
setting, the remote defaults to half-duplex - i.e., there's a duplex
mismatch and things don't work. With this patch, em(4) would inform the
remote that it has only 100baseTX full, the remote would match that and
it will work.

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

(cherry picked from commit 9ab4dfce8feda8cf3545be0c3c7569095b1fcd24)

2 years agoe1000: Update mc filter before RCTL flags
Kevin Bowling [Wed, 13 Apr 2022 16:01:19 +0000 (09:01 -0700)]
e1000: Update mc filter before RCTL flags

Update mc filter array before changing RCTL flags as in 5a3eb6207a35

Approved by: grehan

(cherry picked from commit 07ede751612f8879675e2970b3875ea3831e2b9c)

2 years agoixgbe: Update mc filter before FCTRL flags
Kevin Bowling [Wed, 13 Apr 2022 15:59:21 +0000 (08:59 -0700)]
ixgbe: Update mc filter before FCTRL flags

Update mc filter array before changing FCTRL flags, similar to 5a3eb6207a35

Approved by: grehan

(cherry picked from commit 395cc55d896654b8f75071e71e856b22aed87da5)

2 years agolibcxxrt: Insert padding in __cxa_dependent_exception
Ed Maste [Wed, 27 Apr 2022 13:15:09 +0000 (09:15 -0400)]
libcxxrt: Insert padding in __cxa_dependent_exception

Padding was added to __cxa_exception in 45ca8b19 and
__cxa_dependent_exception needs the same layout.
Add some static_asserts to detect this in the future.

Merge of libcxxrt commit b00c6c564357

(cherry picked from commit c40e4349889b32500e51e60f9529dbcc080f468b)

Approved by: re (gjb, accelerated MFC)

2 years agoBump __FreeBSD_version after linuxkpi mfc
Emmanuel Vadot [Wed, 27 Apr 2022 17:15:15 +0000 (19:15 +0200)]
Bump __FreeBSD_version after linuxkpi mfc

2 years agolinuxkpi: Add for_each_sgtable_dma_sg and for_each_sgtable_dma_page
Emmanuel Vadot [Tue, 29 Mar 2022 11:02:25 +0000 (13:02 +0200)]
linuxkpi: Add for_each_sgtable_dma_sg and for_each_sgtable_dma_page

Variants of for_each_sg/for_each_sg_dma_page but they operate on sgtable
structs.
Needed by drm v5.10

MFC after: 1 week
Sponsored by: Beckhoff Automation GmbH & Co. KG

(cherry picked from commit 1aca8a6ec61cce1a4673a8f7b5412b106e366aff)

2 years agolinuxkpi: Implement dma_max_mapping_size
Emmanuel Vadot [Tue, 29 Mar 2022 11:01:31 +0000 (13:01 +0200)]
linuxkpi: Implement dma_max_mapping_size

Simply returns SCATTERLIST_MAX_SEGMENT.
Needed by drm v5.10

MFC after: 1 week
Sponsored by: Beckhoff Automation GmbH & Co. KG

(cherry picked from commit 1acf9b27704cebfcf14cd896264be29c1d27c4c3)

2 years agolinuxkpi: Change irq_work_queue to return a bool
Emmanuel Vadot [Mon, 28 Mar 2022 13:27:27 +0000 (15:27 +0200)]
linuxkpi: Change irq_work_queue to return a bool

This was changed in Linux v5.10

MFC after: 1 week
Sponsored by: Beckhoff Automation GmbH & Co .KG

(cherry picked from commit 2192bc32554ab94900d644e2af197c700c81692d)

2 years agolinuxkpi: Add llnode member in struct irq_work
Emmanuel Vadot [Mon, 28 Mar 2022 12:48:28 +0000 (14:48 +0200)]
linuxkpi: Add llnode member in struct irq_work

This was added in Linux v5.8 and started to be used in drm code in v5.9

MFC after: 1 week
Sponsored by: Beckhoff Automation GmbH & Co. KG

(cherry picked from commit 17ee6aca65c8dfb5f041b3229655ce12b0f37372)

2 years agolinuxkpi: Add down_write_nest_lock
Emmanuel Vadot [Tue, 22 Mar 2022 09:28:02 +0000 (10:28 +0100)]
linuxkpi: Add down_write_nest_lock

Simply calls down_write like in Linux (when CONFIG_DEBUG_LOCK_ALLOC isn't
specified)
Needed by drm v5.10

MFC after: 1 month
Reviewed by: hselasky
Sponsored by: Beckhoff Automation GmbH & Co. KG
Differential Revision: https://reviews.freebsd.org/D34642

(cherry picked from commit f9413897cb84499c76be140312e6ef2d24488040)

2 years agolinuxkpi: Add kstrtouint_from_user
Emmanuel Vadot [Tue, 22 Mar 2022 09:22:42 +0000 (10:22 +0100)]
linuxkpi: Add kstrtouint_from_user

Like kstrtoint_from_user but for uint.
Needed by drm v5.10

MFC after: 1 month
Reviewed by: hselasky
Sponsored by: Beckhoff Automation GmbH & Co. KG
Differential Revision: https://reviews.freebsd.org/D34642

(cherry picked from commit 8e587a5f13ce676d7763ffa920148fe31bc3bfae)

2 years agolinuxkpi: Add cond_resched_lock
Emmanuel Vadot [Mon, 21 Mar 2022 10:14:05 +0000 (11:14 +0100)]
linuxkpi: Add cond_resched_lock

If we need to resched it takes the lock, resched, release the lock
and returns 1, otherwise simply returns 0.

Needed by drm v5.9

MFC after: 1 month
Reviewed by: hselasky
Sponsored by: Beckhoff Automation GmbH & Co. KG
Differential Revision: https://reviews.freebsd.org/D34620

(cherry picked from commit 9b8016548ef61e2c42271c7dce35d0322540d2f1)

2 years agohpet: Allow a MMIO window smaller than 1K
John F. Carr [Sat, 19 Mar 2022 22:51:43 +0000 (18:51 -0400)]
hpet: Allow a MMIO window smaller than 1K

Some new AMD systems provide a HPET MMIO region smaller than the 1KB
specified, and a correspondingly small number of timers.  Handle this in
the HPET driver rather than requiring a 1KB window.  This allows the
HPET driver to attach on such systems.

PR: 262638
Reviewed by: markj

(cherry picked from commit 964bf2f902c5e05381018532e5d9d456979d4bf7)

2 years agoif_bnxt: Allow bnxt interfaces to use vlans
Misho [Thu, 21 Apr 2022 08:24:04 +0000 (09:24 +0100)]
if_bnxt: Allow bnxt interfaces to use vlans

When VLAN HW filter is disabled, the NIC does not pass any vlan tagged
traffic. Setting these flags on the device allows vlan tagged traffic to
pass.

PR: 236983
Tested by: pi
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D34824

(cherry picked from commit 0c6a2fa33e36ac0b5d51cbae39a9c5564ad61788)

2 years agopf: counter argument to pfr_pool_get() may never be NULL
Kristof Provost [Thu, 21 Apr 2022 12:53:05 +0000 (14:53 +0200)]
pf: counter argument to pfr_pool_get() may never be NULL

Coverity points out that if counter was NULL when passed to
pfr_pool_get() we could potentially end up dereferencing it.
Happily all users of the function pass a non-NULL pointer. Enforce this
by assertion and remove the pointless NULL check.

Reported by: Coverity (CID 273309)
MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")

(cherry picked from commit efc64d02a62f3254ecc0b22fcbcb8f73a079669f)

2 years agopfsync: NULL check before dereference
Kristof Provost [Thu, 21 Apr 2022 12:40:32 +0000 (14:40 +0200)]
pfsync: NULL check before dereference

Move the use of 'sc' to after the NULL check.
It's very unlikely that we'd actually hit this, but Coverity is correct
that it's not a good idea to dereference the pointer and only then NULL
check it.

Reported by: Coverity (CID 1398362)
MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")

(cherry picked from commit 43020350635150eeb439c035f608ec9e78ddff8f)

2 years agopf: remove pointless NULL check
Kristof Provost [Thu, 21 Apr 2022 12:33:48 +0000 (14:33 +0200)]
pf: remove pointless NULL check

pfi_kkif_attach() always returns non-NULL, and we dereference the
pointer before we check it, so that's pointless.

Reported by: Coverity (CID 1007345)
MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")

(cherry picked from commit ed6287c14168de409c5f333bda59896c8109eb70)

2 years agocallout: fix using shared rmlocks
Kristof Provost [Tue, 19 Apr 2022 15:01:25 +0000 (17:01 +0200)]
callout: fix using shared rmlocks

15b1eb142c changed the callout code to store the CALLOUT_SHAREDLOCK flag
in c_iflags (where it used to be c_flags), but failed to update the
check in softclock_call_cc(). This resulted in the callout code always
taking the write lock, even if a read lock had been requested (with
the CALLOUT_SHAREDLOCK flag in callout_init_rm()).

Reviewed by: markj
MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D34959

(cherry picked from commit a879e40ca2a9e95b3e3dc4810127d3cf105ec0d3)

2 years agosyscons: silent 'set but unused' warning in some configurations
Konstantin Belousov [Wed, 20 Apr 2022 22:11:24 +0000 (01:11 +0300)]
syscons: silent 'set but unused' warning in some configurations

(cherry picked from commit d282bb42c341d1a58afd1c66f85321aed6d67a45)

2 years agorelease: fix on-disc pkg binary symbolic links
Glen Barber [Tue, 26 Apr 2022 19:52:40 +0000 (15:52 -0400)]
release: fix on-disc pkg binary symbolic links

Approved by: re (kib)
PR: 263574
Reported by: loader
MFC after: immediately
Sponsored by: Rubicon Communications, LLC ("Netgate")

(cherry picked from commit 68b0a79b7c7ab75597e2511f880238fbf8cfad32)

2 years agossh: remove duplicate setting of MAIL env var
Ed Maste [Mon, 18 Apr 2022 23:57:48 +0000 (19:57 -0400)]
ssh: remove duplicate setting of MAIL env var

We already set it earlier in do_setup_env().

Fixes: 19261079b743 ("openssh: update to OpenSSH v8.7p1")
MFC after: 1 week
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 19780592633e50efca39454d1ecf029bd7d87868)

2 years agocapsicum: briefly describe capabilities in man page
Ed Maste [Tue, 19 Apr 2022 19:44:46 +0000 (15:44 -0400)]
capsicum: briefly describe capabilities in man page

Provide a very brief introduction to capabilities, using a couple of
sentences from David Chisnall's mailing list response[1] to a question
about Linux capabilities and Capsicum.

Mailing list subject (in case the archive URL changes) was
Re: Linux capabilities to Capsicum

[1] https://lists.freebsd.org/archives/freebsd-hackers/2022-April/001032.html

Reviewed by: oshogbo
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D34945

(cherry picked from commit 1f568792c6156988d357ea31a36d77ed11cc9a2d)

2 years agolibexec/rc.d/hostapd: Down/up interface when interface is specified
Cy Schubert [Fri, 22 Apr 2022 16:03:08 +0000 (09:03 -0700)]
libexec/rc.d/hostapd: Down/up interface when interface is specified

When no interface is specified results in a syntax error in the rc
script. Only execute poststart when an interface has been specified.

PR: 263358
Submitted by: markj
Reported by: Joshua Kinard <freebsd@kumba.dev>
Fixes: 0da2c91e64528d896f69d36670e25b4b4a140579

(cherry picked from commit 1452bfcd9bbcb2f5bbb89fa38d01ce51dd9b6d44)

2 years agopath_test: Verify that operations on unlinked files work
Mark Johnston [Mon, 18 Apr 2022 21:46:04 +0000 (17:46 -0400)]
path_test: Verify that operations on unlinked files work

Sponsored by: The FreeBSD Foundation

(cherry picked from commit b13ac678420292f5994b0b6e0f27995b9399268b)

2 years agossh: apply style(9) to version_addendum
Ed Maste [Mon, 18 Apr 2022 21:20:25 +0000 (17:20 -0400)]
ssh: apply style(9) to version_addendum

Reported by: allanjude (in review D29953)
Fixes: 462c32cb8d7a ("Upgrade OpenSSH to 6.1p1.")
MFC after: 1 week
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 613b4b79713e294140757270f02a8aa6273be3d4)

2 years agopsci: finish psci_present implementation
Kyle Evans [Sat, 19 Mar 2022 03:03:44 +0000 (22:03 -0500)]
psci: finish psci_present implementation

This was already declared in psci.h, but it was never defined/set.  Do
this now, so we can use it to decide if enable-method in /cpus FDT nodes
should be inspected later on.  While we're here, convert it to a
boolean.

Reviewed by: andrew (slightly earlier version)

(cherry picked from commit 2218070b2c3c32b1574f3f3b2d0579b2d4826554)

2 years agostand: zfs: handle holes at the tail end correctly
Kyle Evans [Thu, 21 Apr 2022 19:57:24 +0000 (14:57 -0500)]
stand: zfs: handle holes at the tail end correctly

This mirrors dmu_read_impl(), zeroing out the tail end of the buffer and
clipping the read to what's contained by the block that exists.

This fixes an issue that arose during the 13.1 release process; in
13.1-RC1 and later, setting up GELI+ZFS will result in a failure to
boot.  The culprit is this, which causes us to fail to load geom_eli.ko
as there's a residual portion after the single datablk that should be
zeroed out.

PR: 263407
Reviewed by: tsoome

(cherry picked from commit 914dc91d12198352b7878a88d30e2a6373a936e1)

2 years agocp: fix -R recursion detection
Kyle Evans [Wed, 6 Apr 2022 01:40:53 +0000 (20:40 -0500)]
cp: fix -R recursion detection

The correct logic is a lot simpler than the previous iteration.  We
record the base fts_name to avoid having to worry about whether we
needed the root symlink name or not (as applicable), then we can simply
shift all of that logic to after path translation to make it less
fragile.

If we're copying to DNE, then we'll have swapped out the NULL root_stat
pointer and then attempted to recurse on it.  The previously nonexistent
directory shouldn't exist at all in the new structure, so just back out
from that tree entirely and move on.

The tests have been amended to indicate our expectations better with
subdirectory recursion.  If we copy A to A/B, then we expect to copy
everything from A/B/* into A/B/A/B, with exception to the A that we
create in A/B.

Reviewed by: bapt
Sponsored by: Klara, Inc.

(cherry picked from commit f00f8b4fbd268a212687984e44daa3e0d0a16b87)

2 years agocp: fix some cases with infinite recursion
Kyle Evans [Thu, 27 Jan 2022 18:02:17 +0000 (12:02 -0600)]
cp: fix some cases with infinite recursion

As noted in the PR, cp -R has some surprising behavior.  Typically, when
you `cp -R foo bar` where both foo and bar exist, foo is cleanly copied
to foo/bar.  When you `cp -R foo foo` (where foo clearly exists), cp(1)
goes a little off the rails as it creates foo/foo, then discovers that
and creates foo/foo/foo, so on and so forth, until it eventually fails.

POSIX doesn't seem to disallow this behavior, but it isn't very useful.
GNU cp(1) will detect the recursion and squash it, but emit a message in
the process that it has done so.

This change seemingly follows the GNU behavior, but it currently doesn't
warn about the situation -- the author feels that the final product is
about what one might expect from doing this and thus, doesn't need a
warning.  The author doesn't feel strongly about this.

PR: 235438
Reviewed by: bapt
Sponsored by: Klara, Inc.

(cherry picked from commit 848263aad129c8f9de75b58a5ab9a010611b75ac)

2 years agocam: don't send scsi commands on shutdown when reboot method RB_NOSYNC
Wojciech Macek [Mon, 20 Dec 2021 05:32:51 +0000 (06:32 +0100)]
cam: don't send scsi commands on shutdown when reboot method RB_NOSYNC

Don't send the SCSI comand SYNCHRONIZE CACHE on devices that are still
open when RB_NOSYNC is the reboot method. This may avoid recursive panics
when doadump is called due to a SCSI/CAM/USB error/bug.

Obtained from: Semihalf
Sponsored by: Stormshield
Reviewed by: imp
Differential revision: https://reviews.freebsd.org/D31549

(cherry picked from commit e0ceec676dc86ddca960a9858ae5e3a4e0c8390d)

2 years agomountd: Delay starting mountd until after mountlate
Rick Macklem [Sun, 23 Jan 2022 22:17:40 +0000 (14:17 -0800)]
mountd: Delay starting mountd until after mountlate

PR#254282 reports a problem where nullfs mounts cannot be
exported via mountd for FreeBSD 13.0.

The problem seems to be that, to do the nullfs mounts in
/etc/fstab, they require the "late" mount option, so that the
underlying filesystem is mounted (ZFS for the PR).

Adding "mountlate" to the REQUIRE list in /etc/rc.d/mountd
fixes the problem, but that results in a dependency cycle
because /etc/rc.d/lockd specifies:

REQUIRE: nfsd
BEFORE: DAEMON
--> which forces mountd to preceed DAEMON.

This patch removes "nfsd" from REQUIRE for lockd and statd,
then adds mountlate to REQUIRE for mountd, to fix this
problem.  Having lockd REQUIRE nfsd was done in the NetBSD
code when it was pulled into FreeBSD and there does not
seem to be a need for this.

In case this causes problems, a long MFC has been specified.

PR: 254282
(cherry picked from commit f72926eab00ccd956298e44831b519daa704a868)

2 years agolibsa: Fix a typo in a panic message
Gordon Bergling [Wed, 20 Apr 2022 10:56:52 +0000 (12:56 +0200)]
libsa: Fix a typo in a panic message

- s/occured/occurred/

(cherry picked from commit 746cc38ec358f743d3be3fa0b6eeecbf520a38be)

2 years agooce(4): Fix a typo in a sysctl description
Gordon Bergling [Wed, 20 Apr 2022 10:51:52 +0000 (12:51 +0200)]
oce(4): Fix a typo in a sysctl description

- s/interupt/interrupt/

(cherry picked from commit 88cdccff3f76cb3f5f2656bfe5676538e9e569ab)

2 years agoiicbus(4): Fix two typos in kernel error messages
Gordon Bergling [Wed, 20 Apr 2022 10:55:44 +0000 (12:55 +0200)]
iicbus(4): Fix two typos in kernel error messages

- s/occured/occurred/

(cherry picked from commit 7fad3ed8e9bdba1ad81a141a47544cd0481da8b9)

2 years agotslog(4): Fix a typo in the manual page
Gordon Bergling [Wed, 20 Apr 2022 10:33:00 +0000 (12:33 +0200)]
tslog(4): Fix a typo in the manual page

- s/schedulling/scheduling/

(cherry picked from commit cebd29c950dc68cc416b9bd55ad62b9e7e25c077)

2 years agosed(1): Fix a typo in the manual page
Gordon Bergling [Wed, 20 Apr 2022 11:00:42 +0000 (13:00 +0200)]
sed(1): Fix a typo in the manual page

- s/occurances/occurrences/

(cherry picked from commit 583bb9c530b2316c83017fc51517d3acad1ed9dd)

2 years agolibsysdecode: Add regression tests for sysdecode_cap_rights(3)
Mark Johnston [Fri, 15 Apr 2022 14:23:32 +0000 (10:23 -0400)]
libsysdecode: Add regression tests for sysdecode_cap_rights(3)

Reviewed by: jhb, emaste
Sponsored by: The FreeBSD Foundation

(cherry picked from commit d0f245d21f47c55ed40b34a17d5caf08aba1952f)

2 years agolibsysdecode: Include required headers in sysdecode.h
Mark Johnston [Fri, 15 Apr 2022 14:22:29 +0000 (10:22 -0400)]
libsysdecode: Include required headers in sysdecode.h

Make sysdecode.h self-contained rather than forcing all consumers to
include dependencies.  No functional change intended.

Reviewed by: pauamma_gundo.com, jhb, emaste
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 354efc4c94078c3c83ea45d467c6377f3f92926e)

2 years agolibsysdecode: Fix decoding of Capsicum rights
Mark Johnston [Wed, 13 Apr 2022 14:47:08 +0000 (10:47 -0400)]
libsysdecode: Fix decoding of Capsicum rights

Capsicum rights are a bit tricky since some of them are subsets of
others, and one can have rights R1 and R2 such that R1 is a subset of
R2, but there is no collection of named rights whose union is R2.  So,
they don't behave like most other flag sets.  sysdecode_cap_rights(3)
does not handle this properly and so can emit misleading decodings.

Try to fix all of these problems:
- Include composite rights in the caprights table.
- Use a constructor to sort the caprights table such that "larger"
  rights appear first and thus are matched first.
- Don't print rights that are a subset of rights already printed, so as
  to minimize the length of the output.
- Print a trailing message if some of the specific rights are not
  matched by the table.

PR: 263165
Reviewed by: pauamma_gundo.com (doc), jhb, emaste
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 869199d9922c7dee92c1c24f95b90f1d1319433e)

2 years agocallout: Remove the CS_EXECUTING flag
Mark Johnston [Wed, 23 Mar 2022 16:37:02 +0000 (12:37 -0400)]
callout: Remove the CS_EXECUTING flag

It is now unused.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit 7524994da0bb7b4eb003bc5ac465a316925d40ed)

2 years agosetitimer: Fix exit race
Mark Johnston [Wed, 23 Mar 2022 16:36:12 +0000 (12:36 -0400)]
setitimer: Fix exit race

We use the p_itcallout callout, interlocked by the proc lock, to
schedule timeouts for the setitimer(2) system call.  When a process
exits, the callout must be stopped before the process struct is
recycled.

Currently we attempt to stop the callout in exit1() with the call
_callout_stop_safe(&p->p_itcallout, CS_EXECUTING).  If this call returns
0, then we sleep in order to drain the callout.  However, this happens
only if the callout is not scheduled at all.  If the callout thread is
blocked on the proc lock, then exit1() will not block and the callout
may execute after the process has fully exited, typically resulting in a
panic.

I cannot see a reason to use the CS_EXECUTING flag here.  Instead, use
the regular callout_stop()/callout_drain() dance to halt the callout.

Reported by: ler
Tested by: ler, pho
Sponsored by: The FreeBSD Foundation

(cherry picked from commit b319171861464f6c445905e7649cb43bf9bc78be)

2 years agovideomode: Fix a typo in an kernel message
Gordon Bergling [Tue, 19 Apr 2022 15:09:52 +0000 (17:09 +0200)]
videomode: Fix a typo in an kernel message

- s/Seperate/Separate/

Obtained from: NetBSD

(cherry picked from commit f45f90c5d6f0f0d53998476281d42d857adf98c7)

2 years agodiff: tests: loosen up requirements for report_identical
Kyle Evans [Tue, 19 Apr 2022 04:04:13 +0000 (23:04 -0500)]
diff: tests: loosen up requirements for report_identical

This test cannot run without an unprivileged_user being specified
anyways, so just run as the unprivileged user.  Revoking read permisions
works just as well if you're guaranteed non-root.

Reviewed by: pstef
Sponsored by: Klara, Inc.

(cherry picked from commit efba49ee5a64f8f56f49e58887484284d785d542)

2 years agoloader: userboot: provide a getsecs() implementation
Kyle Evans [Wed, 13 Apr 2022 00:29:54 +0000 (19:29 -0500)]
loader: userboot: provide a getsecs() implementation

We don't need it for userboot, but it avoids issues with BIND_NOW, so
just provide it.  time(3) isn't defined but ends up being provided by
libc linked into the host process, which is generally fine.

PR: 262920
Reviewed by: imp, jhb

(cherry picked from commit 660c1892d5c90500d37f98185326c6287b2b61be)

2 years agostand: libefi: swap /Pci() printing around
Kyle Evans [Wed, 13 Apr 2022 00:29:54 +0000 (19:29 -0500)]
stand: libefi: swap /Pci() printing around

Printing device followed by interface matches, e.g., edk2.  Note that
this is only a fallback, many firmware implementations will provide the
protocol that we'll use to format device paths.

Reviewed by: imp, tsoome
Sponsored by: Ampere Computing
Submitted by: Klara, Inc.

(cherry picked from commit 454630c72556d45e401f29f56b3317c2fb0499a0)

2 years agogenet: fix problems with interface down/up
Mike Karels [Mon, 11 Apr 2022 19:44:49 +0000 (14:44 -0500)]
genet: fix problems with interface down/up

The genet interface did not resume operation correctly after doing
ifconfig down then up.  The down/reset procedure did not clear the
RUNNING flag, and did not reset enough of the hardware state.  This
patch is modeled on OpenBSD code, with a call to gen_reset added
to reset the controller completely.  Regularize the parameter to
gen_dma_disable() while here.

PR:             263091
Submitted by: jiahali@blackberry.com

(cherry picked from commit 8f45652b6bccc258eb58f8721dea10184f1aaa17)

2 years agovm: Move the "vm_wait in early boot" assertion to the proper place
Mark Johnston [Thu, 14 Apr 2022 19:45:54 +0000 (15:45 -0400)]
vm: Move the "vm_wait in early boot" assertion to the proper place

The assertion was added in commit 1771e987ca6a.  After that, vm_wait()
and friends were refactored such that the actual sleep happens
elsewhere.  Now the assertion condition is not checked when
vm_wait_doms() is called directly, and it is checked even if we are not
going to sleep (because vm_page_count_min_set(wdoms) is false).

Reviewed by: alc, kib
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 6fb7c42d593d13eba8b72f6cdf434a7cb23fa828)

2 years agovm: Initialize the transient buffer mapping arena with M_WAITOK
Mark Johnston [Thu, 14 Apr 2022 19:46:14 +0000 (15:46 -0400)]
vm: Initialize the transient buffer mapping arena with M_WAITOK

The wait flag is passed to UMA when allocating boundary tags for the
initial span, and UMA expects either M_WAITOK or M_NOWAIT to be present.

Reported by: cperciva
Sponsored by: The FreeBSD Foundation

(cherry picked from commit f82177b8cfd2269aed060fe72e672ad4115ec8c3)

2 years agotime(3): Refine history in the manual page
Gordon Bergling [Thu, 14 Apr 2022 08:04:14 +0000 (10:04 +0200)]
time(3): Refine history in the manual page

The time() system call first appeared in Version 1 AT&T UNIX.  Through
the Version 3 AT&T UNIX, it returned 60 Hz ticks since an epoch that
changed occasionally, because it was a 32-bit value that overflowed in a
little over 2 years.

In Version 4 AT&T UNIX the granularity of the return value was reduced to
whole seconds, delaying the aforementioned overflow until 2038.

Version 7 AT&T UNIX introduced the ftime() system call, which returned
time at a millisecond level, though retained the gtime() system call
(exposed as time() in userland).  time() could have been implemented as a
wrapper around ftime(), but that wasn't done.

4.1cBSD implemented a higher-precision time function gettimeofday() to
replace ftime() and reimplemented time() in terms of that.

Since FreeBSD 9 the implementation of time() uses
clock_gettime(CLOCK_SECOND) instead of gettimeofday() for performance
reasons.

With most valuable input from Warner (imp@).

Reviewed by: 0mp, jilles, imp
Differential Revision: https://reviews.freebsd.org/D34751

(cherry picked from commit 3e0f3678eca7c3f296b9f702992737356f1792da)

2 years agopath_test: Correct the kevent test
Mark Johnston [Mon, 18 Apr 2022 15:45:45 +0000 (11:45 -0400)]
path_test: Correct the kevent test

Perhaps surprisingly, and contrary to the expectations of
path_test:path_event, NOTE_LINK events are not raised when a file is
unlinked.  Prior to commit bf13db086b84, the test happened to work
because unlinking the file would cause the vnode to be recycled, and
EVFILT_VNODE knotes deliver an event with EV_EOF set when the vnode is
doomed.  Since the test did not verify the note type, the test
succeeded.  After commit bf13db086b84, the vnode is not recycled after
being unlinked and so the test hangs.

Fix the test by waiting for NOTE_DELETE instead, and check that we got
the note that we expected.

Reported by: Jenkins
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 333f668468f0675e1e001f6fcc506e901e58c36e)

2 years agoif_axgbe: properly release resource in error case
Tong Zhang [Mon, 11 Apr 2022 13:51:53 +0000 (09:51 -0400)]
if_axgbe: properly release resource in error case

PR: 262899
Reviewed by: markj

(cherry picked from commit 57f7a82fbb4299a255c2c20ec812258004a90631)

2 years agossh-agent: move -x description to correct spot in man page
Ed Maste [Sun, 17 Apr 2022 20:53:12 +0000 (16:53 -0400)]
ssh-agent: move -x description to correct spot in man page

MFC after: 3 days
Sponsored by: The FreeBSD Foundation

(cherry picked from commit eb45bc6829157b4bd8367a7fac96acc0e740f116)

2 years agoRevert rest of a5970a529c2d95271: use vrefact() when working on fp->f_vnode
Konstantin Belousov [Wed, 13 Apr 2022 23:39:57 +0000 (02:39 +0300)]
Revert rest of a5970a529c2d95271: use vrefact() when working on fp->f_vnode

(cherry picked from commit 362ff9867e9f0856a0f24f91e5fc6b9b3ecff8e9)

2 years agoMostly revert a5970a529c2d95271: Make files opened with O_PATH to not block non-force...
Konstantin Belousov [Wed, 13 Apr 2022 00:47:45 +0000 (03:47 +0300)]
Mostly revert a5970a529c2d95271: Make files opened with O_PATH to not block non-forced unmount

(cherry picked from commit bf13db086b84c29ce901145f2800c561dcbf4d1e)

2 years agoMerge libcxxrt commit 45ca8b1942090226ba9368caeeeabc0d4ee41ad6
Dimitry Andric [Tue, 19 Apr 2022 16:11:11 +0000 (18:11 +0200)]
Merge libcxxrt commit 45ca8b1942090226ba9368caeeeabc0d4ee41ad6

  Insert padding in __cxa_exception struct for compatibility

  Similar to https://github.com/llvm/llvm-project/commit/f2a436058fcb, the
  addition of __attribute__((__aligned__)) to _Unwind_Exception (in commit
  b9616964) causes implicit padding to be inserted before the unwindHeader
  field in __cxa_exception.

  Applications attempt to get at the earlier fields in __cxa_exception, so
  preserve the same negative offsets in __cxa_exception, by moving the
  padding to the beginning of the struct.

  The assumption here is that if the ABI is not aware of the padding
  before unwindHeader and put the referenceCount/primaryException in
  there, no padding should exist before unwindHeader.

This should make libreoffice's custom exception handling mechanisms work
correctly, even if it was built against an older cxxabi.h/unwind.h pair.

PR: 263370
Approved by:    re (gjb, early MFC)
MFC after: immediately

(cherry picked from commit 434215c26da3c6acf2423ab93ff2b41b2d823cc8)

2 years agoFix a sign mismatch warning in the physmem code
Andrew Turner [Mon, 28 Mar 2022 10:29:42 +0000 (11:29 +0100)]
Fix a sign mismatch warning in the physmem code

Make sure both sides of a comparison are unsigned. As the values being
compared are size_t make the the value in the for loop size_t too.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit f461b95561fff9d7f39942f7a9aba37ba69ed1fe)

2 years agoSupport EFIRT on arm64 with a non 4k page size
Andrew Turner [Wed, 23 Mar 2022 15:18:30 +0000 (15:18 +0000)]
Support EFIRT on arm64 with a non 4k page size

When the page size the kernel is built for is not the same as
EFI_PAGE_SIZE we need to increment the page index at a faster rate.

Add this adjustment to the arm64 EFIRT support in preperation for
experimental 16k PAGE_SIZE support.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit 863f3220d09716ea2e570fadc6b19dcb6e4c2191)

2 years agoAdd an implementation of .mcount on arm64
Andrew Turner [Tue, 22 Mar 2022 15:46:15 +0000 (15:46 +0000)]
Add an implementation of .mcount on arm64

To support cc -pg on arm64 we need to implement .mcount. As clang and
gcc think it is function like it just needs to load the arguments
to _mcount and call it.

On gcc the first argument is passed in x0, however this is missing on
clang so we need to load it from the stack. As it's the caller return
address this will be at a known location.

PR: 262709
Reviewed by: emaste (earlier version)
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D34634

(cherry picked from commit 16d5f9a1649e6a3e5841c6c41d6af9430ed9f064)

2 years agoAdd support for arm64 nGnRE device memory
Andrew Turner [Fri, 5 Feb 2021 10:50:29 +0000 (10:50 +0000)]
Add support for arm64 nGnRE device memory

On arm64 we can select how strongly we order device memory. Currently
we use the strongest type of non-Gathering, non-Reordering, no Early
write acknowledgement. This is equivalent to VM_MEMATTR_SO in the 32-bit
arm code.

Create a new memory type to remove the no Early write acknowledgement
option to create a memory attribute that is equivalent to the arm
VM_MEMATTR_DEVICE.

Keep the the old nGnRnE memory as what we provide for VM_MEMATTR_DEVICE
until we can test nGnRE on more hardware. A method for dynamically
switching back may be needed as at least one vendor is known to have
broken nGnRE memory.

Sponsored by: Innovate UK

(cherry picked from commit 13ec5a6da04b14c4d40d3b37335dfaef7469aeb5)

2 years agotty: Remove an incorrect assertion from ttyinq_line_iterate()
Mark Johnston [Tue, 12 Apr 2022 21:30:04 +0000 (17:30 -0400)]
tty: Remove an incorrect assertion from ttyinq_line_iterate()

We may legitimately have tib == NULL if we're at the very end of the
queue.

PR: 215373
Reported by: pho
Sponsored by: The FreeBSD Foundation

(cherry picked from commit d769609620931a62ebacbd4f1f5fd048c7e3d7c0)

2 years agoRemove 11.x ABI compat for kernel dump ioctls
Mitchell Horne [Thu, 14 Apr 2022 22:44:02 +0000 (19:44 -0300)]
Remove 11.x ABI compat for kernel dump ioctls

This code was marked gone_in(13), so its time has passed.

The only consumer of this interface is dumpon(8). We do not maintain
strict backwards compatibility for this utility because a) it
can't/shouldn't be used from a jail or chroot and b) it is highly
specific interface unique to FreeBSD. The host's (presumably more
up-to-date) copy of dumpon(8) should be used to configure kernel dump
devices.

Reviewed by: markj, emaste
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D34913

(cherry picked from commit 9c90bfcd319c4342fd55310d876976399184a910)

2 years agoLinuxKPI: 802.11: start adding rate control to ieee80211_tx_status()
Bjoern A. Zeeb [Fri, 15 Apr 2022 13:39:38 +0000 (13:39 +0000)]
LinuxKPI: 802.11: start adding rate control to ieee80211_tx_status()

Start adding rate control feedback in ieee80211_tx_status() in order
for net80211 to be able to report something back (which may not
yet be the view of the firmware).  iwlwifi is reporting back an MSC 0
even with HT disabled (to be investigated) so we cannot (yet) use
the firmware/driver rate feedback directly.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit 383b3e8f509f9658329d33d7da5473b881c37349)

2 years agoLinuxKPI: 802.11: implement ieee80211_probereq_get()
Bjoern A. Zeeb [Fri, 15 Apr 2022 12:53:06 +0000 (12:53 +0000)]
LinuxKPI: 802.11: implement ieee80211_probereq_get()

Implement ieee80211_probereq_get() needed by Realtek drivers.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit ade774b19f9a7b35f01cbca68e51a768d1dd0773)

2 years agoLinuxKPI: skbuff: start implementing skb_copy()
Bjoern A. Zeeb [Fri, 15 Apr 2022 12:30:51 +0000 (12:30 +0000)]
LinuxKPI: skbuff: start implementing skb_copy()

Implement skb_copy() with omissions of fragments and possibly other fields
for now.  Should we hit frags at any point a log message will let us know.
For the few cases we need this currently this is enough.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit 349b042b90057c1e9dbb64dfdb894fe03ea20a1d)

2 years agoLinuxKPI: 802.11: improve hw_scan
Bjoern A. Zeeb [Fri, 15 Apr 2022 14:55:40 +0000 (14:55 +0000)]
LinuxKPI: 802.11: improve hw_scan

Initially we were using the IEs from ieee80211_probereq_ie() of net80211
and put them into the common_ies field.  Start by manually building the
per-band and common IE parts as drivers put them back together.
This also involves allocating the req.ie as one buffer for all IEs over
all bands and setting req.ie_len correctly based on how many bytes we
put in.

Manually building per-band scan IEs we still use the net80211 routines
to add IEs to the buffer (mostly).

This is needed by Realtek drivers but will equally used by others.
Realtek would simply panic due to skbs being allocated with the wrong
length.

Longer-term this will help us, e.g., when not supporting VHT on 2Ghz
and we would have to do this anyway.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit d9945d7821b9baf724a704d37d33b9adcad70030)

2 years agoLinuxKPI: skbuff: dev_kfree_skb_irq() and improvements
Bjoern A. Zeeb [Fri, 15 Apr 2022 12:25:39 +0000 (12:25 +0000)]
LinuxKPI: skbuff: dev_kfree_skb_irq() and improvements

While it is currently unclear if we will have to defer work in
dev_kfree_skb_irq() to call dev_kfree_skb().
We only have one caller which seems to be fine on FreeBSD by calling
it directly for now.

While here shortcut skb_put()/skb_put_data() saving us work if there
are no adjustments to do.
Also adjust the logging in skb_is_gso() to avoid getting spammed by it.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit 952643ea452655a8e80d1b5e1cc2cae35cb73870)

2 years agoLinuxKPI: 802.11: use an sx lock to protect the list of vifs
Bjoern A. Zeeb [Fri, 15 Apr 2022 14:22:43 +0000 (14:22 +0000)]
LinuxKPI: 802.11: use an sx lock to protect the list of vifs

Use an sx lock to protect the list of vifs.  We could use the
linux mutex compat for this but our current implementation may
re-acquire the lock recursively so allow this.  The change is
mainly motivated by the fact that some callers may sleep in the
interator function called.  Recursiveness is needed because we
see find_sta_by_ifaddr() being called from an iterator function
from iterate_interfaces().

Sponsored by: The FreeBSD Foundation

(cherry picked from commit 8891c45563f8d3b657a876197c66e00e75214909)