]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
23 months agoaio: Improve UMA usage
Mark Johnston [Mon, 20 Jun 2022 16:17:11 +0000 (12:17 -0400)]
aio: Improve UMA usage

- Remove the AIO proc zone.  This zone gets one allocation per AIO
  daemon process, which isn't enough to warrant a dedicated zone.  Plus,
  unlike other AIO structures, aiops are small (32 bytes with LP64), so
  UMA doesn't provide better space efficiency than malloc(9).  Change
  one of the malloc types in vfs_aio.c to make it more general.

- Don't set the NOFREE flag on the other AIO zones.  This flag means
  that memory allocated to the AIO subsystem is never freed back to the
  VM, so it's always preferable to avoid using it when possible.  NOFREE
  was set without explanation when AIO was converted to use UMA 20 years
  ago, but it does not appear to be required; all of the structures
  allocated from UMA (per-process kaioinfo, kaiocb, and aioliojob) keep
  track of references and get freed only when none exist.  Plus, these
  structures will contain dangling pointer after they're freed (e.g.,
  the "cred", "fd_file" and "uiop" fields of struct kaiocb), so
  use-after-frees are dangerous even when the structures themselves are
  type-stable.

Reviewed by: asomers
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 9553bc89dbc38a861a750ddc605cec0381788c5d)

23 months agotime: Make realitexpire() local to kern_time.c
Mark Johnston [Wed, 13 Jul 2022 13:57:28 +0000 (09:57 -0400)]
time: Make realitexpire() local to kern_time.c

Sponsored by: The FreeBSD Foundation

(cherry picked from commit ef221ff645322f0ec147c706652744869774e128)

23 months agoAdjust agp_find_device() definition in agp.c to avoid clang 15 warning
Dimitry Andric [Sat, 16 Jul 2022 14:46:21 +0000 (16:46 +0200)]
Adjust agp_find_device() definition in agp.c to avoid clang 15 warning

With clang 15, the following -Werror warning is produced:

    sys/dev/agp/agp.c:910:16: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
    agp_find_device()
                   ^
                    void

This is because agp_find_device() is declared with a (void) argument
list, and defined with an empty argument list. Make the definition match
the declaration.

MFC after: 3 days

(cherry picked from commit c0817e2aba26ceb683e9c649c22d7fcd9a921231)

23 months agoRemove unused but set variable in cxgb_sge
Dimitry Andric [Sat, 16 Jul 2022 18:16:36 +0000 (20:16 +0200)]
Remove unused but set variable in cxgb_sge

Clang 15 warns:

    sys/dev/cxgb/cxgb_sge.c:1290:21: error: variable 'txsd' set but not used [-Werror,-Wunused-but-set-variable]
            struct tx_sw_desc *txsd = &txq->sdesc[txqs->pidx];
                               ^

It appears 'txsd' is a leftover from a previous refactoring (see
3f345a5d09b6), but is no longer used for anything, and can be removed
without any functional change.

MFC after: 3 days
Reviewed by: np
Differential Revision: https://reviews.freebsd.org/D35833

(cherry picked from commit cab040039d6fe1b2a6de8f2ba2cc882c313d3c75)

23 months agoWPA_DISTDIR does not need to end in a slash
Dimitry Andric [Sat, 16 Jul 2022 15:45:26 +0000 (17:45 +0200)]
WPA_DISTDIR does not need to end in a slash

Since all uses of the macro also append a slash, this leads to double
slashes.

MFC after: 3 days

(cherry picked from commit 9917049b60f7cf7345a09d2bc22d51764a477984)

23 months agoAdjust parse() definition in boot2 to avoid clang 15 warning
Dimitry Andric [Fri, 15 Jul 2022 19:15:11 +0000 (21:15 +0200)]
Adjust parse() definition in boot2 to avoid clang 15 warning

With clang 15, the following -Werror warning is produced:

    stand/i386/boot2/boot2.c:358:6: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]

This is because parse() is declared with a (void) argument list, and
defined with an empty argument list. Make the definition match the
declaration.

MFC after: 3 days

(cherry picked from commit e60f6384f9dbe3abe83e59acf0997c591752ff81)

23 months agoMerge fix for zfs readmmap test from CheriBSD
Dimitry Andric [Fri, 15 Jul 2022 19:10:09 +0000 (21:10 +0200)]
Merge fix for zfs readmmap test from CheriBSD

Merge commit 1737d8397a0 by Brooks Davis:

  time() is declared in time.h

This fixes a -Werror warning from clang 15:

  tests/sys/cddl/zfs/bin/readmmap.c:97:9: error: call to undeclared function 'time'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]

Obtained from: https://github.com/CTSRD-CHERI/cheribsd/commit/1737d8397a0
MFC after: 3 days

(cherry picked from commit 47be48457393ba6747cc3144272b1f4d8b9077fb)

23 months agoqat(4): Fix a typo in a source code comment
Gordon Bergling [Sat, 16 Jul 2022 11:47:14 +0000 (13:47 +0200)]
qat(4): Fix a typo in a source code comment

- s/bufer/buffer/

Obtained from: NetBSD

(cherry picked from commit e4a203234add5c57e5081521a4f4018bae7e398d)

23 months agopfctl(8): Fix a typo in a source code comment
Gordon Bergling [Sat, 16 Jul 2022 11:48:30 +0000 (13:48 +0200)]
pfctl(8): Fix a typo in a source code comment

- s/bufer/buffer/

(cherry picked from commit c9856c4ffbda670f3fdc03d4c046a70e3e225f68)

23 months agoqat(4): Fix a typo in a source code comment
Gordon Bergling [Sat, 16 Jul 2022 12:26:24 +0000 (14:26 +0200)]
qat(4): Fix a typo in a source code comment

- s/mirco/micro/

Obtained from: NetBSD

(cherry picked from commit db1c3dbe82953edda57f85f2e6d65ded272e5b0d)

23 months agocrunchide(1): Fix a typo in a comment
Gordon Bergling [Sat, 16 Jul 2022 11:32:47 +0000 (13:32 +0200)]
crunchide(1): Fix a typo in a comment

- s/maek/make/

Obtained from: NetBSD

(cherry picked from commit d34de8d378b36c48b3ae46a0abf8d8eb041877ad)

23 months agolinux(4): Fix a typo in a source code comment
Gordon Bergling [Sat, 16 Jul 2022 11:39:17 +0000 (13:39 +0200)]
linux(4): Fix a typo in a source code comment

- s/alredy/already/

(cherry picked from commit d3d3b76c1b614b54d255e4248c45f43b20d519b8)

23 months agocxgbe(4): Fix a typo in a source code comment
Gordon Bergling [Sat, 16 Jul 2022 11:38:57 +0000 (13:38 +0200)]
cxgbe(4): Fix a typo in a source code comment

- s/alredy/already/

(cherry picked from commit 63303133a7f9cd616eeea410a45fd0ae4eef70e6)

23 months agox86: Check for APIC presence only if DEV_ATPIC is defined
Mark Johnston [Tue, 28 Dec 2021 22:42:12 +0000 (17:42 -0500)]
x86: Check for APIC presence only if DEV_ATPIC is defined

We only attempt to gracefully handle absence of an APIC if "device
atpic" is defined in the kernel configuration.

Suggested by: kib
Reviewed by: jhb, kib
Sponsored by: The FreeBSD Foundation

(cherry picked from commit deca0138dc659747c9edd4648690cdfdb01f58e8)

23 months agotimecounter: Load the currently selected tc once in tc_windup()
Mark Johnston [Fri, 29 Oct 2021 18:29:22 +0000 (14:29 -0400)]
timecounter: Load the currently selected tc once in tc_windup()

Reported by: Sebastian Huber <sebastian.huber@embedded-brains.de>
Reviewed by: kib
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 26f76aea2d276aacb69a1f9d78558d6107155aed)

23 months agoktls: Zero out TLS_GET_RECORD control messages
Mark Johnston [Thu, 20 Jan 2022 20:42:46 +0000 (15:42 -0500)]
ktls: Zero out TLS_GET_RECORD control messages

Otherwise we end up copying one uninitialized byte into the socket
buffer.

Reported by: KMSAN
Reviewed by: jhb
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 6be8944d96d2cb5938b69c63b483efa616eafb56)

23 months agogeli: Add a chicken switch for unmapped I/O
Mark Johnston [Mon, 18 Apr 2022 21:16:10 +0000 (17:16 -0400)]
geli: Add a chicken switch for unmapped I/O

We have a report of a panic in GELI that appears to go away when
unmapped I/O is disabled.  Add a tunable to make such investigations
easier in the future.  No functional change intended.

PR: 262894
Reviewed by: asomers
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 081b4452a758dd81dcdc68ffb6f7bad901d53e3d)

23 months agorc: Fix quoting in the zpoolreguid script
Mark Johnston [Tue, 31 May 2022 14:51:28 +0000 (10:51 -0400)]
rc: Fix quoting in the zpoolreguid script

Reported by: 0mp
Fixes: 227caacc918a ("rc: Add a zpoolreguid rc.d script")
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 89e58b955cf5d2187af5f2460d11b64f4d229c8a)

23 months agorc: Add a zpoolreguid rc.d script
Mark Johnston [Mon, 30 May 2022 14:43:44 +0000 (10:43 -0400)]
rc: Add a zpoolreguid rc.d script

If one boots up multiple copies of a template VM image containing a
zpool, the pool GUIDs will be identical, making it impossible to, e.g.,
share datasets between them.

This diff introduces a simple workaround for the problem: one can use
the script to, upon first boot, assign a new GUID to one or more zpools.
This will be useful when building ZFS-based VM images from release(7).

Reviewed by: mav, allanjude, asomers
Reviewed by: Pau Amma (docs)
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 227caacc918a8c9b32608cff42116e7d890b9ddc)

23 months agovm_object: Assert that overcommit charge is released in the object dtor
Mark Johnston [Tue, 12 Jul 2022 12:53:05 +0000 (08:53 -0400)]
vm_object: Assert that overcommit charge is released in the object dtor

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

(cherry picked from commit e1979b45b63725972d394562f95d89f8cc9a0bb4)

23 months agovm_map: Simplify a call to vm_object_allocate_anon()
Mark Johnston [Tue, 12 Jul 2022 12:53:17 +0000 (08:53 -0400)]
vm_map: Simplify a call to vm_object_allocate_anon()

vm_object_allocate_anon() automatically sets "charge" to 0 if no cred
reference is provided, so the caller doesn't need any conditional logic.

No functional change intended.

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

(cherry picked from commit 70b2996120a7f96527ce5c676f938886e8aa292d)

23 months agoRevert "bsdinstall: add knob to set ASLR sysctls"
Marcin Wojtas [Fri, 12 Nov 2021 19:32:57 +0000 (20:32 +0100)]
Revert "bsdinstall: add knob to set ASLR sysctls"

This reverts commit 020f4112559ebf7e94665c9a69f89d21929ce82a.

Because now ASLR is enabled by default for 64-bit architectures
and the purpose of the installation menu is to allow choosing
additional 'mitigation'/'hardening' options that are originally
disabled, remove the ASLR knob from bsdinstall.

Discussed with: emaste
Obtained from: Semihalf
Sponsored by: Stormshield

(cherry picked from commit bf410c6eda515364db5f6ed74b765efdec0595ae)

23 months agoEnable ASLR by default for 64-bit executables
Marcin Wojtas [Sun, 24 Oct 2021 14:53:06 +0000 (16:53 +0200)]
Enable ASLR by default for 64-bit executables

Address Space Layout Randomization (ASLR) is an exploit mitigation
technique implemented in the majority of modern operating systems.
It involves randomly positioning the base address of an executable
and the position of libraries, heap, and stack, in a process's address
space. Although over the years ASLR proved to not guarantee full OS
security on its own, this mechanism can make exploitation more difficult.

Tests on the tier 1 64-bit architectures demonstrated that the ASLR is
stable and does not result in noticeable performance degradation,
therefore it should be safe to enable this mechanism by default.
Moreover its effectiveness is increased for PIE (Position Independent
Executable) binaries. Thanks to commit 9a227a2fd642 ("Enable PIE by
default on 64-bit architectures"), building from src is not necessary
to have PIE binaries. It is enough to control usage of ASLR in the
OS solely by setting the appropriate sysctls.

This patch toggles the kernel settings to use address map randomization
for PIE & non-PIE 64-bit binaries. It also disables SBRK, in order
to allow utilization of the bss grow region for mappings. The latter
has no effect if ASLR is disabled, so apply it to all architectures.

As for the drawbacks, a consequence of using the ASLR is more
significant VM fragmentation, hence the issues may be encountered
in the systems with a limited address space in high memory consumption
cases, such as buildworld. As a result, although the tests on 32-bit
architectures with ASLR enabled were mostly on par with what was
observed on 64-bit ones, the defaults for the former are not changed
at this time. Also, for the sake of safety keep the feature disabled
for 32-bit executables on 64-bit machines, too.

The committed change affects the overall OS operation, so the
following should be taken into consideration:
* Address space fragmentation.
* A changed ABI due to modified layout of address space.
* More complicated debugging due to:
  * Non-reproducible address space layout between runs.
  * Some debuggers automatically disable ASLR for spawned processes,
    making target's environment different between debug and
    non-debug runs.

In order to confirm/rule-out the dependency of any encountered issue
on ASLR it is strongly advised to re-run the test with the feature
disabled - it can be done by setting the following sysctls
in the /etc/sysctl.conf file:
kern.elf64.aslr.enable=0
kern.elf64.aslr.pie_enable=0

Co-developed by: Dawid Gorecki <dgr@semihalf.com>
Reviewed by: emaste, kib
Obtained from: Semihalf
Sponsored by: Stormshield
MFC after: 1 month
Differential revision: https://reviews.freebsd.org/D27666

(cherry picked from commit b014e0f15bc73d80ef49b64fd1f8c29f469467cb)

23 months agostand/uboot: setup archsw before probing devices
Albert Jakiela [Tue, 28 Jun 2022 15:28:35 +0000 (17:28 +0200)]
stand/uboot: setup archsw before probing devices

In some cases ubldr would try to mount a disk device before
the archsw struct was filled with functions pointers.
This would result in a NULL pointer derefrence of the arch_getdev field.
Fix that filling the archsw functions earlier.
Note that this matches the EFI behavoiur.

Reviewed by: imp, mw
Sponsored by: Stormshield
Obtained from: Semihalf
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D35670

(cherry picked from commit 1323f0aa9cb0392d2946226bd76f14463e875a60)

23 months agolockstat: Fix construction of comparision predicates
Kornel Dulęba [Mon, 4 Jul 2022 06:48:52 +0000 (08:48 +0200)]
lockstat: Fix construction of comparision predicates

Passing "0x%p" to sprintf results in double "0x" being printed.
This causes a dtrace script compilation failure when "-d" flag
is specified.
Fix that by removing the extraneous "0x".

Reviewed by: markj
Approved by: mw(mentor)
Obtained from: Semihalf
Sponsored by: Alstom
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D35690

(cherry picked from commit 9dbacce2d48abf04b4d65d2994586e1ff44b08fb)

23 months agoe6000sw: Fix direct register write logic
Kornel Dulęba [Mon, 4 Jul 2022 06:53:41 +0000 (08:53 +0200)]
e6000sw: Fix direct register write logic

When accessing a register directly from etherswitchcfg one must specify
a register group(e.g. registers of portN) and the register offset within
the group. The latter is passed as the 5 least significant bits.
Extract the former by dividing the register address by 32, not by 5.

Approved by: mw(mentor)
Obtained from: Semihalf
Sponsored by: Stormshield
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D35672

(cherry picked from commit 66548259075788d2084e9da1c5df7b88f44c4b4d)

23 months agoigc: Change default duplex setting
Kornel Dulęba [Thu, 30 Jun 2022 11:57:58 +0000 (13:57 +0200)]
igc: Change default duplex setting

During media selection through ifconfig one might not specify
the duplex setting through the mediaopt flag.
In that case the igc driver would default to full-duplex.
The problem with this approach is that e1000(em/igb) driver
defaults to half-duplex.
Because of that if one connects both NICs and sets media to
e.g. 100baseTX on both of them no link will be found.
Fix that by matching igc behaviour with what e1000 does.

Reviewed by: grehan
Approved by: mw(mentor)
Obtained from: Semihalf
Sponsored by: Stormshield
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D35673

(cherry picked from commit 3b8d04f845b416d29a258658b8a48d1afb4a2e81)

23 months agoDecode the arm64 SVE ID register
Andrew Turner [Tue, 28 Jun 2022 11:44:49 +0000 (11:44 +0000)]
Decode the arm64 SVE ID register

The field values are only valid when the ID_AA64PFR0_EL1.SVE or
ID_AA64PFR1_EL1.SME vields are non-zero. When this is not the case
the register is reserved as zero so is safe to read, but the SVEver
field will be incorrect so only print the decoded register when
the SVE or SME fields indicate it is valid.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit cb91f112a3dc6cb68fe618623f59cee576ce4d14)

23 months agoAllow use of the arm64 unnamed register form
Andrew Turner [Wed, 29 Jun 2022 16:34:41 +0000 (17:34 +0100)]
Allow use of the arm64 unnamed register form

On arm64 all registers have a name that encodes op0, op1, CRn, CRm, and
op2 that are used to encode the register in the instruction. As some
registers we need to access may not be supportedby older compilers, or
are only supported when specific extensions are enabled support this
alternative form.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit 66ba742d2e6c950611fa3d557512133b0216daa7)

23 months agoSplit out vfp_new_thread
Andrew Turner [Fri, 24 Jun 2022 11:53:15 +0000 (11:53 +0000)]
Split out vfp_new_thread

To keep the vfp thread creation code in one place move into vfp.c. This
will also help with adding SVE support as it depends on VFP.

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

(cherry picked from commit baf8f20a4af43283a1fbee49b0c2ad906074f20f)

23 months agoAdd the SVE reigster definitions
Andrew Turner [Fri, 24 Jun 2022 11:51:26 +0000 (11:51 +0000)]
Add the SVE reigster definitions

Sponsored by: The FreeBSD Foundation

(cherry picked from commit 2f317e7312971812bde8b8b0d9da21a2c1d378a3)

23 months agoTrap SVE instructions until we have SVE support
Andrew Turner [Fri, 24 Jun 2022 11:50:28 +0000 (11:50 +0000)]
Trap SVE instructions until we have SVE support

When running on hardware that supports SVE send the correct signal when
an SVE instruction is run.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit ffa5bf8b600a77838be8fbf383382a2e7bafedc6)

23 months agoAdd the arm64 FPAC exception value
Andrew Turner [Mon, 4 Jul 2022 08:30:49 +0000 (09:30 +0100)]
Add the arm64 FPAC exception value

This is currently unused, but is useful to reduce conflicts when MFCing
patches from main.

Extracted from 85b7c566f15 ("Add arm64 pointer authentication support").

Sponsored by: The FreeBSD Foundation

23 months agoRemove PAGE_SIZE from the kcov tests
Andrew Turner [Wed, 20 Apr 2022 17:33:00 +0000 (17:33 +0000)]
Remove PAGE_SIZE from the kcov tests

To allow for a dynamic page size on arm64 remove the static valud from
the kcov tests

Sponsored by: The FreeBSD Foundation

(cherry picked from commit 2ff6e4ee9762526ed1e924da838a760423271978)

23 months agoRemove PAGE_SIZE from hastd
Andrew Turner [Tue, 3 May 2022 13:59:33 +0000 (14:59 +0100)]
Remove PAGE_SIZE from hastd

It may not be known at compile time so we should detect it at run time.

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

(cherry picked from commit ea578b34cb35505e7253c4d8f279fed1d38380ee)

23 months agoClean up in the pci host generic driver
Andrew Turner [Mon, 23 May 2022 09:41:36 +0000 (10:41 +0100)]
Clean up in the pci host generic driver

Add clean up on failure and a detach function to the pci host generic
driver.

Reviewed by: jhb (earlier version)
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D35291

(cherry picked from commit d843dd0e1addd2aa69a78be99e251147aafcfd80)

23 months agoAdd arm64 CnP support
Andrew Turner [Wed, 25 May 2022 09:55:40 +0000 (10:55 +0100)]
Add arm64 CnP support

Set the Common not Private bit in the ttbr registers when supported on
arm64. This tells the hardware it can share the translation table
entries on multiple CPUs.

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

(cherry picked from commit 9e0716f4610158936c0b9cec1a9930c4ebe924fb)

23 months agoDecode all Arm GIC feature ID bits
Andrew Turner [Tue, 24 May 2022 10:03:13 +0000 (11:03 +0100)]
Decode all Arm GIC feature ID bits

The AWS Graviton3 CPU features a GIC 4.1 CPU Interface. Teach the CPU
identift code to decode it.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit 477204e70b658c518064a02203a2050d5a0841be)

23 months agoAdd more Arm CPU IDs
Andrew Turner [Tue, 24 May 2022 10:01:15 +0000 (11:01 +0100)]
Add more Arm CPU IDs

Add more CPU main ID register values for Arm Cortex and Neoverse CPUs

Sponsored by: The FreeBSD Foundation

(cherry picked from commit 969da7c749ebf05a2a9b10e32b5d6d7c3f270dbb)

23 months agoAdd SPLIT_KERNEL_DEBUG knob
Ed Maste [Tue, 7 Jun 2022 14:20:39 +0000 (10:20 -0400)]
Add SPLIT_KERNEL_DEBUG knob

Prior to 9b6edf364eb0 WITHOUT_KERNEL_SYMBOLS split kernel debug data
into standalone debug files at build time, but did not install those
files.  As of 9b6edf364eb0 it stopped splitting the debug data, leaving
it in the kernel and modules (the default kernel configs include
DEBUG=-g).

Revert 9b6edf364eb0 and introduce a new build-time SPLIT_KERNEL_DEBUG
knob, as some people rely on the pre-9b6edf364eb0 WITHOUT_KERNEL_SYMBOLS
behaviour and that was imp's original intent.

PR: 264433
Reviewed by: eugen, imp
MFC after: 3 weeks
Relnotes: yes
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D35437

(cherry picked from commit 92fc5822a8301d0c20d292e97d1661b25f5035bc)
(cherry picked from commit e3709cfe6a2a1f7d345db2870be175c9cf2a8979)
(cherry picked from commit a7bd57de86372d834cf9312fcc4c39070653e009)

23 months agoeventtimer: Pass a pcpu state pointer to getnext(cpu)event()
Mark Johnston [Mon, 11 Jul 2022 19:38:43 +0000 (15:38 -0400)]
eventtimer: Pass a pcpu state pointer to getnext(cpu)event()

Callers have already loaded the pointer, so these functions don't need
to fetch it again.

No functional change intended.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit ebb3cb61958da8bcc3c28ec3b20dc3a6b8168952)

23 months agosched_ule: Fix a typo in a comment
Mark Johnston [Mon, 11 Jul 2022 19:33:20 +0000 (15:33 -0400)]
sched_ule: Fix a typo in a comment

PR: 226107

(cherry picked from commit ba71333f6049ee76b0023b3b9e8444d5ccb1a7ff)

23 months agosched_ule: Eliminate a superfluous local variable in tdq_move()
Mark Johnston [Mon, 4 Jul 2022 23:05:59 +0000 (19:05 -0400)]
sched_ule: Eliminate a superfluous local variable in tdq_move()

No functional change intended.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit 35dd6d6cb56209b49c055253dac549d8426f1003)

23 months agosched_ule: Purge an obsolete comment
Mark Johnston [Mon, 4 Jul 2022 23:07:51 +0000 (19:07 -0400)]
sched_ule: Purge an obsolete comment

The referenced bitmask was removed in commit 62fa74d95a1.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit ef80894c9d01b13f6507abd6e5a0508dbb64d73b)

23 months agolibvmm: add __BEGIN_DECLS/__END_DECLS for linking with c++ binaries
Vitaliy Gusev [Mon, 11 Jul 2022 19:25:43 +0000 (15:25 -0400)]
libvmm: add __BEGIN_DECLS/__END_DECLS for linking with c++ binaries

Reviewed by: jhb, markj, imp
Sponsored by: vStack

(cherry picked from commit 1228a047aa653e7e9067bdcff4a9a62657df2c15)

23 months agodwc3: add ACPI attachment
Bjoern A. Zeeb [Tue, 5 Jul 2022 01:07:07 +0000 (01:07 +0000)]
dwc3: add ACPI attachment

Split the current FDT-only implementation up into an FDT and an
ACPI part reusing and sharing as much code as possible (thanks mw!).

This makes the Synopsis XHCI root hubs attach correctly on SolidRun's
HoenyComb instead of just the generic XHCI root and this means we
are also doing proper chip setup and applying the quirk needed there [1].

There is one problem with ACPI attachment in that it uses the generic
XHCI PNP ID.  So we need to do extra checks in order to not claim
all xhci, which means we check for a known quirk to be present
in acpi_probe.  Long term this isn't scaling and this was discussed
in SolidRun's Discord Channel in 2021 with the intend that "jnettlet"
will take this to a steering committee.  Since then ACPI has kind-of
become a technology non grata (due to not getting changes into Linux
timely) so it is unclear if this will ever happen.  If there will be
further hardware with dwc3/ACPI we should go and make sure this problem
gets solved.

[1] https://github.com/SolidRun/edk2-platforms/blob/24698f90b79facfbbfc4067b39a4ddf8c7fdfa88/Silicon/NXP/LX2160A/AcpiTables/Dsdt/Usb.asl

Reviewed by: manu, mw
Differential Revision: https://reviews.freebsd.org/D32256

(cherry picked from commit fbb5cb66f74cd9e7c2b1491dee6f5a3df72aea7a)

23 months agodwc3: improve debugging
Bjoern A. Zeeb [Sat, 2 Jul 2022 21:10:00 +0000 (21:10 +0000)]
dwc3: improve debugging

Rather than hiding behind #if 0, hide the debugging behind DWC3_DEBUG
so it can be turned on with a single define.  Require bootverbose
to print anything so we can still avoid spamming the console if DWC3_DEBUG
is on.
Harmonize the format string in snsp_dwc3_dump_regs() to always print the
full register and also print the XHCI quirks.
Call snsp_dwc3_dump_regs() twice, before and after generic XHCI attachment
and initialisation as this may have an effect on the confirgumation state.

Obtained from: an old debug patch
Reviewed by: mw
Differential Revision: https://reviews.freebsd.org/D35700

(cherry picked from commit 11a7d5e5d906f691558e06d4bb93b892de31b446)

23 months agodwc3: add more quirks and checks
Bjoern A. Zeeb [Sat, 2 Jul 2022 20:56:07 +0000 (20:56 +0000)]
dwc3: add more quirks and checks

Rather than just printing the Global SNPS ID Register store it as well
so we can do a version check later.
In addition, for debugging purposes, read the Global Hardware Parameters
Registers and print them.

Based on the snpsid disable an XHCI feature using a quirk prepared
in 447c418da03454a2a00bc115a69c62055a6d5272.
Add the "snps,dis_u3_susphy_quirk" quirk and handle Suspend USB3.0 SS PHY
after power-on-reset/during core initialization (suggested to be cleared)
based on the DWC3_GHWPARAMS0 register.

Obtained from: an old debugging patch
Reviewed by: mw (earlier version), mmel
Differential Revision: https://reviews.freebsd.org/D35699

(cherry picked from commit 09cdf4878c621be4cd229fa88cdccdcdc8c101f7)
(cherry picked from commit ec32fc2af52530e49d8a522ae29bf20b2e57603b)

23 months agodwc3: uncondinationally enable Host IN Auto Retry
Bjoern A. Zeeb [Sat, 2 Jul 2022 19:14:39 +0000 (19:14 +0000)]
dwc3: uncondinationally enable Host IN Auto Retry

Enable dwc3's auto retry feature. For IN transfers with crc errors
or internal overruns this will make the host reply with a
non-terminating retry ACK.  I believe the hope was to improve
reliability after seeing occasional hiccups.

Obtained from: an old debugging patch
Reviewed by: mw
Differential Revision: https://reviews.freebsd.org/D35698

(cherry picked from commit cec0a5ec6b1074d253a7ba30226d1f99e0c18d4e)

23 months agodwc3: fix snps,dis-del-phy-power-chg-quirk
Bjoern A. Zeeb [Sat, 2 Jul 2022 18:17:13 +0000 (18:17 +0000)]
dwc3: fix snps,dis-del-phy-power-chg-quirk

If snps,dis-del-phy-power-chg-quirk is set, the register bit should be
cleared not ored on (it's the "dis" version).

Reviewed by: mw
Differential Revision: https://reviews.freebsd.org/D35697

(cherry picked from commit 0084212bfdfbcd662f3e823636b40173e828509d)

23 months agoUSB: dwc3: use device_{has,get}_property()
Bjoern A. Zeeb [Mon, 29 Nov 2021 19:26:52 +0000 (19:26 +0000)]
USB: dwc3: use device_{has,get}_property()

Switch the driver to use device based functions which will work not
only with FDT but also ACPI.

While here make dr_mode a local variable as it is only used during
probe and not needed later in the softc.

Reviewed by: mw
Differential Revision: https://reviews.freebsd.org/D33170

(cherry picked from commit b11f52f4db4420f69da537e5ed9b54b7c4fef093)

23 months agopca954x: harmonize pca9547 and pca954x and add pca9540 support
Bjoern A. Zeeb [Sat, 2 Jul 2022 23:33:32 +0000 (23:33 +0000)]
pca954x: harmonize pca9547 and pca954x and add pca9540 support

The two implementations for the pca9548 switch and the pca9547 mux
seemed close enough so we can put them together and with a bit more
abstraction add pca9540 support.

While here apply a bit of consistency in variable and driver naming and
use device_has_property instead of the FDT-only OF_ variant.

This disconnects pca9547 from the build but does not yet delete it.

Reviewed by: mmel (earlier version), avg
Sponsored by: Traverse Technologies (providing Ten64 HW for testing)
Differential Revision: https://reviews.freebsd.org/D35701

(cherry picked from commit 97dbd37753ae1bf9c4f6a23e46e21f0a9f408c82)

23 months agotca6416: add support for tca9539
Bjoern A. Zeeb [Sun, 3 Jul 2022 00:51:13 +0000 (00:51 +0000)]
tca6416: add support for tca9539

Programming-wise tca6416 and tca9539 seem identical so all we have to
do is add the extra ofw_compat_data line.

Reviewed by: mw
Sponsored by: Traverse Technologies (providing Ten64 HW for testing)
Differential Revision: https://reviews.freebsd.org/D35702

(cherry picked from commit c4b98101c5b1dc34d077f078d04d777df3cf9e38)

23 months agoarm64: NXP add LS1088a clockgen support
Bjoern A. Zeeb [Tue, 28 Jun 2022 00:02:17 +0000 (00:02 +0000)]
arm64: NXP add LS1088a clockgen support

Add a driver for NXP LS1088a clockgen support which passes
configuration information to QorIQ clockgen class.
The implementaiton started off as copy of ls1028 support and was
adjusted accordingly.

Reviewed by: dgr_semihalf.com (earlier), mmel
Sponsored by: Traverse Technologies (providing Ten64 HW for testing)
Differential Revision: https://reviews.freebsd.org/D35617

(cherry picked from commit 8154df37a55948aca8358ade68b659d1aa71b755)

23 months agoACPI: change arguments to internal acpi_find_dsd()
Bjoern A. Zeeb [Thu, 23 Jun 2022 00:17:14 +0000 (00:17 +0000)]
ACPI: change arguments to internal acpi_find_dsd()

acpi_find_dsd() is not a bus function and we only need the acpi_device (ad).
The only caller has already looked up the ad (from ivars) for us.
Directly pass the ad to acpi_find_dsd() instead of bus, dev and remove
the extra call to device_get_ivars(); the changed argument also means we
now call AcpiEvaluateObject directly on the handle.

This optimisation was done a while ago while debugging a driver which
ended up with a bad bus, dev combination making the old version fail.

Reviewed by: mw
Differential Revision: https://reviews.freebsd.org/D35558

(cherry picked from commit 945eaca155fc0d48da8d11fc41b8b00f17254d90)

23 months agofile: upgrade to 5.42.
Xin LI [Mon, 4 Jul 2022 00:07:28 +0000 (17:07 -0700)]
file: upgrade to 5.42.

(cherry picked from commit a4d6d3b8910f3805eebcd8703e11e066aad2e2a1)

23 months agolibmagic: Remove support for older FreeBSD where xlocale was not available.
Xin LI [Mon, 3 Jan 2022 02:05:08 +0000 (18:05 -0800)]
libmagic: Remove support for older FreeBSD where xlocale was not available.

The MINIMUM_SUPPORTED_OSREL is 1002501 (FreeBSD 10.3), and xlocale is
supported there.

While I'm there, explicitly use config.h generated with --disable-bzlib
--disable-xzlib instead of deleting them manually.

(cherry picked from commit 90266521018938b7b9f0003ba9a383b6920859e9)

file: Turns out we need xlocal.h protection

It turns out that we still need xlocal.h protection for when we're
cross building on Linux. Linux doesn't have this file, but os/x
does. Before, we'd assume we didn't have it, like old FreeBSD, when
cross compiling. After the latest update, all that code was removed so
cross compiling needs to be handled separaetly. Do so by defining
HAVE_XLOCALE_H only when we're not building on linux. This allows us
to build the mkmagic build tool needed to build file(1).

Sponsored by: Netflix
Reviewed by: jrtc27
Differential Revision: https://reviews.freebsd.org/D33741

(cherry picked from commit f3d7ace4b235422e5ccff0315f2965ac935241d8)

23 months agomount_nfs.8: Update BUGS section for NFSv4.1/4.2
Rick Macklem [Sun, 3 Jul 2022 20:37:23 +0000 (13:37 -0700)]
mount_nfs.8: Update BUGS section for NFSv4.1/4.2

If the "intr" and/or "soft" mount options are used for
NFSv4 mounts, the protocol can be broken when the
operation returns without waiting for the RPC reply.
The likelyhood of failure increases for NFSv4.1/4.2
mounts, since the session slot will be broken when
an RPC reply is not processed.

This is mentioned in the BUGS section of "man mount_nfs",
but there was no specific mention of the session slot
problem.  This patch adds a sentence for this case.

PR: 260011

(cherry picked from commit aba7a81ab71ebef1bb20404634bc3c58ba615310)

23 months agoBootstrap crunchgen after removing -dc from linker invocation
Dimitry Andric [Thu, 14 Jul 2022 21:13:41 +0000 (23:13 +0200)]
Bootstrap crunchgen after removing -dc from linker invocation

In ec81497cc726 crunchgen was updated to remove -dc from the linker
invocations in its generated makefile output, as this flag is no longer
necessary, and is going to be an error with lld 15.

Update the BOOTSTRAPPING conditions for copying the crunchgen binary
from the host, or actually bootstrapping it when necessary. Since
ec81497cc726 did not bump __FreeBSD_version, I have chosen the nearest
values.

Fixes: ec81497cc726
MFC after: 3 days

(cherry picked from commit 93f5ab129a3d46f4f434a13306fc99f476456c00)

23 months agoRevert "build(7): fix references to svn(1) and svnlite(1)"
Ed Maste [Sun, 17 Jul 2022 17:57:24 +0000 (13:57 -0400)]
Revert "build(7): fix references to svn(1) and svnlite(1)"

This reverts commit 830d566254d3f4e5204f849cb2d2c70d9afffb8f.
The content change was already cherry-picked, and 830d566254d3 served
only to introduce a typo.

Reported by: mhorne

23 months agocrypto: Validate return values from CRYPTODEV_PROCESS()
Mark Johnston [Fri, 1 Jul 2022 15:09:39 +0000 (11:09 -0400)]
crypto: Validate return values from CRYPTODEV_PROCESS()

Errors are always handled by the completion callback, so we should check
that they're not also passed back to the caller.

No functional change intended.

Reviewed by: kp, mav, jhb
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 99df914899f56efe63afd9e0fef79148fa6ca162)

23 months agoloader: Relax the check in is_kernphys_relocatable()
Mark Johnston [Wed, 15 Jun 2022 14:47:13 +0000 (10:47 -0400)]
loader: Relax the check in is_kernphys_relocatable()

The check fails in kernels compiled with KASAN because AddressSanitizer
inserts redzones around global variables, so the size of the "kernphys"
symbol is 32 rather than 8.  Thus we fall back to copying even though
it's not necessary.

Simply remove the size check.  I didn't want to extend the symbol size
check since there's no guarantee that AddressSanitizer will always emit
32 bytes for "kernphys".

Reviewed by: kib
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 9a964ad56182740ea09b87f7e6db4197c6756e48)

23 months agomsun: Rewrite function definitions with identifier lists
Yi Kong [Tue, 12 Jul 2022 05:17:47 +0000 (13:17 +0800)]
msun: Rewrite function definitions with identifier lists

This syntax is removed in C2x proposal N2432.

Reviewed by: pfg
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D35771

(cherry picked from commit 7e06f4708cbe8a8ace21d6629cb4b9c8c9340152)

23 months agomount_nfs: Warn that intr, soft are not safe for NFSv4
Rick Macklem [Fri, 1 Jul 2022 21:43:17 +0000 (14:43 -0700)]
mount_nfs: Warn that intr, soft are not safe for NFSv4

If the "intr" and/or "soft" mount options are used for
NFSv4 mounts, the protocol can be broken when the
operation returns without waiting for the RPC reply.
The likelyhood of failure increases for NFSv4.1/4.2
mounts, since the session slot will be broken when
an RPC reply is not processed.

This is mentioned in the BUGS section of "man mount_nfs",
but more needs to be done.  This patch adds code that
generates a warning message when the mount is done.

PR: 260011
(cherry picked from commit c0d14b0220ae22d25462cef191f20e9f04c5e87e)

23 months agoipfilter: Support only jails in VNET
Cy Schubert [Thu, 17 Mar 2022 18:05:05 +0000 (11:05 -0700)]
ipfilter: Support only jails in VNET

Jails without VNET have complete access to the ipfilter rules, NAT,
pools and logs. This is insecure. Only allow jails to manipulate
ipfilter rules, NAT tables and ippools if the jail has its own VNET.
Otherwise a jail can affect the global system.

This patch brings ipfilter in line with ipfw's support of VNET jails and
non-support of non-VNET jails.

(cherry picked from commit c47db49ba4aa7e74afe22591a62fbda95317932d)

23 months agopipe: Use a distinct wait channel for I/O serialization
Mark Johnston [Tue, 14 Jun 2022 14:52:03 +0000 (10:52 -0400)]
pipe: Use a distinct wait channel for I/O serialization

Suppose a thread tries to read from an empty pipe.  pipe_read() does the
following:

1. pipelock(), possibly sleeping
2. check for buffered data
3. pipeunlock()
4. set PIPE_WANTR and sleep
5. goto 1

pipelock() is an open-coded mutex; if a thread blocks in pipelock(), it
sleeps until the lock holder calls pipeunlock().

Both sleeps use the same wait channel.  So if there are multiple threads
in pipe_read(), a thread T1 in step 3 can wake up a thread T2 sleeping
in step 4.  Then T1 goes to sleep in step 4, and T2 acquires and
releases the pipelock, waking up T1 again.  This can go on indefinitely,
livelocking the process (and potentially starving a would-be writer).

Fix the problem by using a separate wait channel for pipelock().

Reported by: Paul Floyd <paulf2718@gmail.com>
Reviewed by: mjg, kib
PR: 264441
Sponsored by: The FreeBSD Foundation

(cherry picked from commit e8955bd643ee852d70a0b065f2a0d1bb3fa99df2)

23 months agopf: Make sure that pfi_update_status() always zeros counters
Mark Johnston [Thu, 30 Jun 2022 14:19:23 +0000 (10:19 -0400)]
pf: Make sure that pfi_update_status() always zeros counters

pfi_update_status() can return early if the status interface doesn't
exist.  But in this case pf_getstatus() was copying uninitialized stack
memory into the output nvlist.

Reported by: Jenkins (KMSAN job)
Reviewed by: kp
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 333670372ffe2f1c562e1088a7779eb709006ba2)

23 months agopf: Ensure that pfiio_name is always nul terminated
Mark Johnston [Thu, 30 Jun 2022 14:18:50 +0000 (10:18 -0400)]
pf: Ensure that pfiio_name is always nul terminated

Reported by: syzkaller
Reviewed by: kp
Sponsored by: The FreeBSD Foundation

(cherry picked from commit bc83b3592241a6bcb18e1537fcd27a8eb342a701)

23 months agoipfw: add support radix tables and table lookup for MAC addresses
Arseny Smalyuk [Sat, 4 Jun 2022 16:12:29 +0000 (19:12 +0300)]
ipfw: add support radix tables and table lookup for MAC addresses

By analogy with IP address matching, add a way to use ipfw radix
tables for MAC matching. This is implemented using new ipfw table
with mac:radix type. Also there are src-mac and dst-mac lookup
commands added.

Usage example:
  ipfw table 1 create type mac
  ipfw table 1 add 11:22:33:44:55:66/48
  ipfw add skipto tablearg src-mac 'table(1)'
  ipfw add deny src-mac 'table(1, 100)'
  ipfw add deny lookup dst-mac 1

Note: sysctl net.link.ether.ipfw=1 should be set to enable ipfw
filtering on L2.

Reviewed by: melifaro
Obtained from: Yandex LLC
Relnotes: yes
Sponsored by: Yandex LLC
Differential Revision: https://reviews.freebsd.org/D35103

(cherry picked from commit 81cac3906eb9c14f81e03b7bcb6893b8d30e5432)

23 months agoBump __FreeBSD_version for new <crypto/*.h> headers.
John Baldwin [Tue, 18 Jan 2022 22:49:24 +0000 (14:49 -0800)]
Bump __FreeBSD_version for new <crypto/*.h> headers.

This bump covers the addition of both <crypto/chacha20_poly1305.h> and
<crypto/curve25519.h>.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit dd2f7a4b45eb1285e710cfce60cb77f7c11f8075)
(cherry picked from commit 2c4b65cc3d227f31864e183c15f6c42e2c596cd9)

23 months agocrypto: Add an API supporting curve25519.
John Baldwin [Mon, 24 Jan 2022 23:27:39 +0000 (15:27 -0800)]
crypto: Add an API supporting curve25519.

This adds a wrapper around libsodium's curve25519 support matching
Linux's curve25519 API.  The intended use case for this is WireGuard.

Note that this is not integrated with OCF as it is not related to
symmetric operations on data.

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

(cherry picked from commit 0c6274a819ffdf6d5a3713b2c0f7014840f01703)

23 months agocrypto: Add a simple API for [X]ChaCha20-Poly1035 on flat buffers.
John Baldwin [Tue, 18 Jan 2022 22:47:13 +0000 (14:47 -0800)]
crypto: Add a simple API for [X]ChaCha20-Poly1035 on flat buffers.

This is a synchronous software API which wraps the existing software
implementation in libsodium.  This is different from the code in main
in that this uses libsodium directly.  The version in main uses the
software backend shared with OCF, but main required changes that break
the ABI of struct enc_xform that cannot be merged to stable/13.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit e71680049bb8ff395aeaa144377dd9e49331f45e)

23 months agocrypto.ko: Add hchacha20 from libsodium.
John Baldwin [Tue, 11 Jan 2022 22:15:51 +0000 (14:15 -0800)]
crypto.ko: Add hchacha20 from libsodium.

This was added to 'device crypto' in the kernel in
bbb7a2c7c329494e0148026f8568c0da4d8db085 but was missing from the
module.

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

(cherry picked from commit 7df4c50643cfeecdd42b8e55c38709bf84b1b002)

23 months agousr.bin/dtc: Include <limits> for std::numeric_limits<>.
John Baldwin [Thu, 9 Jun 2022 17:20:03 +0000 (10:20 -0700)]
usr.bin/dtc: Include <limits> for std::numeric_limits<>.

This is needed when building natively as a cross-tool on hosts such as
Linux using more recent versions of libstdc++.

Co-authored-by: Alexander Richardson <arichardson@FreeBSD.org>
Obtained from: CheriBSD

(cherry picked from commit 1c44d2bf86834a7214e0cc7bde7c956b5b02fd21)

23 months ago.github: Add a build on Ubuntu 22.04 using llvm 14.
John Baldwin [Thu, 9 Jun 2022 17:20:03 +0000 (10:20 -0700)]
.github: Add a build on Ubuntu 22.04 using llvm 14.

Reviewed by: uqs
Pull Request: https://github.com/freebsd/freebsd-src/pull/599

(cherry picked from commit 74536fca79facf0e4fdbaf833b94d82e92bb9f77)

23 months ago.github: Cross-build aarch64 as well as amd64 kernels.
John Baldwin [Thu, 9 Jun 2022 17:20:03 +0000 (10:20 -0700)]
.github: Cross-build aarch64 as well as amd64 kernels.

This required adding an explicit os list to the matrix.

Reviewed by: uqs
Pull Request: https://github.com/freebsd/freebsd-src/pull/599

(cherry picked from commit 3491ed652e0af484b8357ba67e45af17a0e54173)

23 months ago.github: Update compilers used for cross-build testing.
John Baldwin [Thu, 9 Jun 2022 17:20:02 +0000 (10:20 -0700)]
.github: Update compilers used for cross-build testing.

- Drop clang 9 build, and switch the remaining ubuntu build to
  the more modern clang 12.

- Update the label for the macos-latest builds which are now using
  clang 13 rather than clang 12.

Reviewed by: uqs
Pull Request: https://github.com/freebsd/freebsd-src/pull/599

(cherry picked from commit 49335eda0f5d80e9c86754b5ed95a285b49ef166)

23 months agoMake it clear we're running clang-12 for the GH actions
Ulrich Spörlein [Mon, 19 Jul 2021 08:25:58 +0000 (10:25 +0200)]
Make it clear we're running clang-12 for the GH actions

This chases a homebrew change in the default clang version.

Reviewed by: arichardson
Differential Revision: https://reviews.freebsd.org/D31231

(cherry picked from commit 2f677dcedf3b70bf97a51c2b0fd9927b67c666ff)

23 months agorelease: increase IMAGE_SIZE for arm, arm64, riscv
Glen Barber [Wed, 13 Jul 2022 18:36:22 +0000 (14:36 -0400)]
release: increase IMAGE_SIZE for arm, arm64, riscv

Related to:  PR 264032
Sponsored by: Rubicon Communications, LLC ("Netgate")

(cherry picked from commit 1dfcff294e44d4b45813288ef4095c36abb22f0e)

23 months agoetcupdate: Preserve permissions when installing a resolved file.
John Baldwin [Wed, 25 May 2022 21:20:40 +0000 (14:20 -0700)]
etcupdate: Preserve permissions when installing a resolved file.

Similar to the change in 1a04446f088c79cc2cf85fd86e60ebcc228d3075, use
cat to overwrite the contents of the existing file rather than cp so
that metadata of the existing file such as permissions and ownership
is preserved.

PR: 255514
Reported by: uqs

(cherry picked from commit f8287caae48246e34d6a7af5446df3c36127b7f0)

23 months agoetcupdate: Don't rotate trees for a dry run.
John Baldwin [Wed, 25 May 2022 21:02:51 +0000 (14:02 -0700)]
etcupdate: Don't rotate trees for a dry run.

When performing a dry run, remove the temporary tree created rather
than rotating the trees.  Rotating the trees meant that etcupdate
thought the latest changes were already merged and would not merge
them on the next real run.

PR: 260281
Reported by: Tomoaki AOKI <junchoon@dec.sakura.ne.jp>
Fixes: 0611aec3cf3a etcupdate: Always extract to a temporary tree.

(cherry picked from commit 431944fb5ffff5ad56e720b75b7beecdc4878e0e)

23 months agocrypto: Fix assertions for digest-only sessions with separate output.
John Baldwin [Thu, 30 Jun 2022 17:10:00 +0000 (10:10 -0700)]
crypto: Fix assertions for digest-only sessions with separate output.

Digest-only sessions do not generate modified payload as an output, so
don't bother asserting anything about the payload with respect to the
output buffer other than the payload output start being zero.

In addition, a verify request on a digest-only session doesn't
generate any output at all so should never have a separate output
buffer.

PR: 252316
Reviewed by: markj
Co-authored-by: Jeremy Faulkner <gldisater@gmail.com>
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D35578

(cherry picked from commit c71f2370c5d480cf70f12ee276e044681c57aefc)

23 months agogcore: Use PT_GETREGSET for NT_THRMISC and NT_PTLWPINFO.
John Baldwin [Thu, 30 Jun 2022 17:04:19 +0000 (10:04 -0700)]
gcore: Use PT_GETREGSET for NT_THRMISC and NT_PTLWPINFO.

This avoids the need for dealing with converting lwpinfo for alternate
ABIs in gcore itself.

Reviewed by: markj
MFC after: 2 weeks
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D35667

(cherry picked from commit d95657a1a758e8d993a0eb92259f8c860a309207)

23 months agoAdd register sets for NT_THRMISC and NT_PTLWPINFO.
John Baldwin [Thu, 30 Jun 2022 17:04:02 +0000 (10:04 -0700)]
Add register sets for NT_THRMISC and NT_PTLWPINFO.

For the kernel this is mostly a non-functional change.  However, this
will be useful for simplifying gcore(1).

Reviewed by: markj
MFC after: 2 weeks
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D35666

(cherry picked from commit 0288d4277faf77c37d23efce73883eb3ef1a353c)

23 months agogcore: Remove unused typedefs.
John Baldwin [Thu, 30 Jun 2022 17:03:32 +0000 (10:03 -0700)]
gcore: Remove unused typedefs.

These are no longer needed after commit 4965ac059da1 which used
PT_GETREGSET to fetch NT_PRSTATUS and NT_FPREGSET.

Reviewed by: markj, emaste
MFC after: 2 weeks
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D35665

(cherry picked from commit d2a3c30a511d4802412a102e9fa44f810605a872)

23 months agox86 mptable: Include <x86/legacvar.h> for legacy_get_pcibus().
John Baldwin [Thu, 23 Jun 2022 22:00:12 +0000 (15:00 -0700)]
x86 mptable: Include <x86/legacvar.h> for legacy_get_pcibus().

Fixes: b076d8d54c2f mptable_hostb: Use legacy_get_pcibus() to fetch PCI bus number.

(cherry picked from commit 15a6642da6b0b97de580e06349706cf7e660986c)

23 months agomptable_hostb: Use legacy_get_pcibus() to fetch PCI bus number.
John Baldwin [Thu, 23 Jun 2022 17:49:09 +0000 (10:49 -0700)]
mptable_hostb: Use legacy_get_pcibus() to fetch PCI bus number.

The mptable_hostb driver is a child of legacy0 and has legacy bus
ivars, not PCI or PCI bridge ivars.

PR: 264819
Reported by: Dennis Clarke <dclarke@blastwave.org>
Diagnosed by: avg
Reviewed by: avg
Differential Revision: https://reviews.freebsd.org/D35548

(cherry picked from commit b076d8d54c2fd91a35aad6931d0bfa2aa0122036)

23 months agopmcannotate: Don't increment end address passed to objdump -d.
John Baldwin [Tue, 14 Jun 2022 17:52:54 +0000 (10:52 -0700)]
pmcannotate: Don't increment end address passed to objdump -d.

libpmc already returns an end address that is after the end of the
last instruction of a function (on both amd64 and arm64) as the end
address written to the annotate map file is computed as the start
address of the symbol plus the size.

Adding one could result in a curious failure where an entire
function's contents in assembly was reduced instead to only the first
instruction.  The reason is that when the end instruction is bumped by
one, objdump -d can append the first instruction of the next function
in its output.  However, since pmcannotate concatenates all of the
objdump -d output from various functions into a single file which it
then searches to find the assembly for a given file, if this
additional trailer was earlier in the file than the full function, the
trailer was chosen to represent the entire function resulting in the
truncated listing of the function.

Sponsored by: University of Cambridge, Google, Inc.
Differential Revision: https://reviews.freebsd.org/D35399

(cherry picked from commit 73702c398046d8e01e6a0f5860b7e75cd37a9518)

23 months agonewvers.sh: Don't use return to exit.
John Baldwin [Tue, 14 Jun 2022 17:51:39 +0000 (10:51 -0700)]
newvers.sh: Don't use return to exit.

Commit acfb506b3d00 replaced an exit 0 when using -V with a return
instead.  FreeBSD's sh treats a return outside of a function like
exit, but this is a non-portable extension.  Other Bourne shells only
permit return to be used within a function and continue execution
(possibly with a warning).

To fix, don't reuse VARS_ONLY (which is intended to be set by other
scripts before sourcing newvers.sh directly) and instead use a new
variable (VARS_ONLY_EXIT) to restore the use of exit for the
non-sourced case.

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

(cherry picked from commit 6ab35c78fb5af66d586d4846e2d81e020331ad3f)

23 months agofirmware: Map '@' in filenames to '_' in symbols.
John Baldwin [Tue, 14 Jun 2022 17:50:51 +0000 (10:50 -0700)]
firmware: Map '@' in filenames to '_' in symbols.

'@' is not a valid character in symbol names and can sometimes appear
in path names.

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

(cherry picked from commit 628a4156a761d3daac8a4adc0e675c6e6064fd5a)

23 months agorc.d/ntpd: Restart ntpd when resuming from sleep.
John Baldwin [Tue, 14 Jun 2022 17:42:51 +0000 (10:42 -0700)]
rc.d/ntpd: Restart ntpd when resuming from sleep.

ntpd does not always gracefully handle clock steps during resume.
This is probably most useful in conjunction with
ntpd_sync_on_start=YES which will work around any clock skew while
suspended.

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

(cherry picked from commit 1442fed7e25e9856464a0b0ce522ffc8cb473593)

23 months agoktls_test: Permit an option to skip tests not using ifnet TLS.
John Baldwin [Tue, 14 Jun 2022 17:35:01 +0000 (10:35 -0700)]
ktls_test: Permit an option to skip tests not using ifnet TLS.

If ktls.require_ifnet is set to true, then check the TLS offload mode
for tests sending and receiving records and skip the test if the
offload mode is not ifnet mode.

This can be used along with ktls.host to run KTLS tests against a NIC
supporting ifnet TLS and verify that expected cipher suites and
directions used ifnet TLS rather than software TLS.  Receive tests may
result in a false positive as receive ifnet TLS can use software as a
fallback.

Reviewed by: markj
Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D35427

(cherry picked from commit ea4ebdcb4da94a30fae53da74eda302aaa4ff1f3)

23 months agoktls_test: Permit connecting to a remote echo server for tests.
John Baldwin [Tue, 14 Jun 2022 17:34:51 +0000 (10:34 -0700)]
ktls_test: Permit connecting to a remote echo server for tests.

Previously ktls tests always executed over a local socket pair.
ktls.host can be set to a host to connect to with a single socket
instead.  The remote end is expected to echo back any data received
(such as the echo service).  The port can be set with ktls.port which
defaults to "echo".

This is primarily useful to permit testing NIC TLS offload use cases
where the traffic needs to transit the NIC.

Note that the variables must be set via
'kyua -v test_suites.FreeBSD.ktls.host=host'.

Reviewed by: markj
Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D35426

(cherry picked from commit 2400a7b18f984664638cbf978687e6d2c00da2e7)

23 months agoktls_test: Add a helper function to close sockets.
John Baldwin [Tue, 14 Jun 2022 17:34:38 +0000 (10:34 -0700)]
ktls_test: Add a helper function to close sockets.

Reviewed by: markj
Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D35425

(cherry picked from commit 2c1052053340af562e3121a41545419fa71e65f7)

23 months agohwpmc: Permit the minimum sampling count to be set as a sysctl.
John Baldwin [Thu, 9 Jun 2022 18:05:34 +0000 (11:05 -0700)]
hwpmc: Permit the minimum sampling count to be set as a sysctl.

A rarely occurring event (e.g. an event that occurs less than 1000
times during execution of a program) may require a lower minimum
threshold than 1000.  Replace the hardcoded 1000 with a sysctl that
the administrator can use to permit smaller sampling count values.

Reviewed by: mhorne, mav
Sponsored by: University of Cambridge, Google, Inc.
Differential Revision: https://reviews.freebsd.org/D35400

(cherry picked from commit ca341f3cf52f8cb036d93cd611d8f3f5b552ea8e)

23 months agogcore: Don't hardcode VM write permissions.
John Baldwin [Mon, 6 Jun 2022 23:43:02 +0000 (16:43 -0700)]
gcore: Don't hardcode VM write permissions.

This ensures read-only PT_LOAD segments are not marked as writable in
the phdr flags.

Reviewed by: markj
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D35398

(cherry picked from commit 81c857dd7e6a83924a8e45684fb94024fc3c929b)

23 months agogcore: Remove unused elf_note_arm_vfp function.
John Baldwin [Mon, 6 Jun 2022 18:06:49 +0000 (11:06 -0700)]
gcore: Remove unused elf_note_arm_vfp function.

Fixes: add00c381e5c Use a regset for NT_ARM_VFP.
(cherry picked from commit ad52a7bb0393163eb4e749005be0f6ca3c2c51c0)

23 months agovmm: Destroy character devices synchronously.
John Baldwin [Fri, 20 May 2022 16:53:43 +0000 (09:53 -0700)]
vmm: Destroy character devices synchronously.

This fixes a userland race where bhyveload or bhyve can fail to reuse
a VM name after bhyvectl --destroy has returned.

Reported by: Michael Dexter
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D35186

(cherry picked from commit 7a0c23da4eaa63f00e53aa18f3ab1f2bb32f593a)

23 months agoDon't implicitly pull in most of 'device crypto' for 'options IPSEC'.
John Baldwin [Mon, 24 Jan 2022 23:27:39 +0000 (15:27 -0800)]
Don't implicitly pull in most of 'device crypto' for 'options IPSEC'.

options IPSEC is already documented as requiring 'device crypto' and
duplicating the dependencies is harder to read and not always
consistent.

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

(cherry picked from commit 1d95c6f9c0f20ac287c50e0d31e909b35f28a05f)

23 months agocheck/delete-old: Auto-generate lib32 entries for libraries.
John Baldwin [Thu, 20 Jan 2022 22:09:57 +0000 (14:09 -0800)]
check/delete-old: Auto-generate lib32 entries for libraries.

- Add usr/lib32/libfoo.so.N for lib/libfoo.so.N.

- Add usr/lib32/foo for usr/lib/foo.

- Treat casper libraries special since they are installed to
  /usr/lib32 instead of /usr/lib32/casper and thus map
  usr/lib/casper/foo to usr/lib32/foo.

Note that OLD_DIRS and MOVED_LIBS entries are not duplicated, only
OLD_FILES and OLD_LIBS.

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

(cherry picked from commit 77da558ceb0949b60b566da61cb8d9b9634ca862)