]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
2 years agopcf8591: remove write-only variables
Andriy Gapon [Mon, 13 Dec 2021 11:10:12 +0000 (13:10 +0200)]
pcf8591: remove write-only variables

MFC after: 1 week

2 years agoamdsbwd: always enable watchdog register decoding
Andriy Gapon [Wed, 27 May 2020 10:15:54 +0000 (13:15 +0300)]
amdsbwd: always enable watchdog register decoding

This seems to be required even if the watchdog is accessed via the common
MMIO space.

Tested on:
- Ryzen 3 3200U APU;
- Ryzen 7 5800X CPU with X570 chipset.

MFC after: 2 weeks

2 years agokbdmap: adapt to the new libbsddialog API
Alfonso Siciliano [Mon, 13 Dec 2021 08:06:21 +0000 (09:06 +0100)]
kbdmap: adapt to the new libbsddialog API

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

2 years agotzsetup: adapt for libbsddialog 0.0.1
Alfonso Siciliano [Mon, 13 Dec 2021 08:03:40 +0000 (09:03 +0100)]
tzsetup: adapt for libbsddialog 0.0.1

libbsdialog 0.0.1 provides:
* bsddialog_conf.auto_minwidth:
* menurows is variable with autosize (properly defines max menurows)

Then tzsetup can use BSDDIALOG_AUTOSIZE keeping the dialog behavior:
min 24 cols, max 16 menurows

Differential revision: https://reviews.freebsd.org/D33397

2 years agobsddialog: import version 0.0.1
Baptiste Daroussin [Mon, 13 Dec 2021 08:01:21 +0000 (09:01 +0100)]
bsddialog: import version 0.0.1

2 years agobsddialog: import version 0.0.1
Alfonso Siciliano [Mon, 13 Dec 2021 07:54:07 +0000 (08:54 +0100)]
bsddialog: import version 0.0.1

2 years agoAdd a tool to test AVX context integrity under ctx switches and signals (amd64)
Konstantin Belousov [Mon, 13 Dec 2021 02:31:40 +0000 (04:31 +0200)]
Add a tool to test AVX context integrity under ctx switches and signals (amd64)

Sponsored by: The FreeBSD Foundation
MFC after: 1 week

2 years agonfscl: Fix must_commit handling for mirrored pNFS mounts
Rick Macklem [Sun, 12 Dec 2021 23:40:30 +0000 (15:40 -0800)]
nfscl: Fix must_commit handling for mirrored pNFS mounts

For pNFS mounts to mirrored Flexible File layout pNFS servers,
the "must_commit" component in the nfsclwritedsdorpc
structure must be checked and the "must_commit" argument passed
into nfscl_doiods() must be updated.  Technically, only writes to
the DS with a writeverf change must be redone, but since this
occurrence will be rare, the must_commit argument to nfscl_doiosd()
is set to 1, so all writes to all DSs will be redone.

This bug would affect few, since use of mirrored pNFS servers
is rare and "writeverf" rarely changes. Normally "writeverf"
only changes when a NFS server reboots.

MFC after: 2 weeks

2 years agobhyve: set EV_CLEAR for EVFILT_VNODE mevents
Robert Wing [Sun, 12 Dec 2021 21:39:40 +0000 (12:39 -0900)]
bhyve: set EV_CLEAR for EVFILT_VNODE mevents

When an EVFILT_VNODE filter event is triggered, reset it.

This fixes the issue where a virtio-blk resize event would cause the
mevent thread to consume 100% of the cpu.

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

2 years agoRevert clang change that breaks CTF on aarch64
Dimitry Andric [Sun, 12 Dec 2021 20:11:40 +0000 (21:11 +0100)]
Revert clang change that breaks CTF on aarch64

Revert commit e655e74a318e from llvm git (by Peter Collingbourne):

  AST: Create __va_list in the std namespace even in C.

  This ensures that the mangled type names match between C and C++,
  which is significant when using -fsanitize=cfi-icall. Ideally we
  wouldn't have created this namespace at all, but it's now part of
  the ABI (e.g. in mangled names), so we can't change it.

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

As reported by Jessica in https://reviews.llvm.org/D104830#3129527, this
upstream change is implemented in such a way that it breaks DTrace's
CTF. Since a proper fix has not yet been forthcoming, and we are
unaffected by the (CFI-related) problem upstream was trying to address,
revert the change for now.

Requested by: jrtc27
MFC after: 3 days

2 years agoamd64: correct size of the SSE area in the xsave layout
Konstantin Belousov [Sun, 12 Dec 2021 02:49:50 +0000 (04:49 +0200)]
amd64: correct size of the SSE area in the xsave layout

PR: https://github.com/golang/go/issues/46272
Reviewed by: emaste
Sponsored by: The FreeBSD Foundation
MFC after: 3 days

2 years agoexec_elf: use intermediate u_long variable to correct mismatched type
Konstantin Belousov [Sun, 12 Dec 2021 16:47:26 +0000 (18:47 +0200)]
exec_elf: use intermediate u_long variable to correct mismatched type

vm_offset_t * vs. u_long *

Sponsored by: The FreeBSD Foundation
MFC after: 1 week

2 years agobhyve: Support a _VARS.fd file for bootrom
Rebecca Cran [Sun, 28 Nov 2021 16:34:33 +0000 (09:34 -0700)]
bhyve: Support a _VARS.fd file for bootrom

OVMF creates two separate .fd files, a _CODE.fd file containing
the UEFI code, and a _VARS.fd file containing a template of an
empty UEFI variable store.

OVMF decides to write variables to the memory range just below the
boot rom code if it detects a CFI flash device. So here we add
just the barest facsimile of CFI command handling to bootrom.c
that is needed to placate OVMF.

Submitted by: D Scott Phillips <d.scott.phillips@intel.com>
Sponsored by: Intel Corporation
Differential Revision: https://reviews.freebsd.org/D19976
MFC After: 1 week

2 years agoimgact_elf: avoid mapsz overflow
Konstantin Belousov [Wed, 8 Dec 2021 09:33:19 +0000 (11:33 +0200)]
imgact_elf: avoid mapsz overflow

Reported and tested by: pho
Reviewed by: markj
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D33359

2 years agoimgact_elf: check that the alignment of PT_LOAD segment is power of two
Konstantin Belousov [Thu, 9 Dec 2021 15:27:24 +0000 (17:27 +0200)]
imgact_elf: check that the alignment of PT_LOAD segment is power of two

and stop recalculating alignment for PIE base, which was off by one
power of two.

Suggested and reviewed by: markj
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D33359

2 years agoimgact_elf: exclude invalid alignment requests
Konstantin Belousov [Wed, 8 Dec 2021 09:33:57 +0000 (11:33 +0200)]
imgact_elf: exclude invalid alignment requests

Only accept at most superpage alignment, or if the arch does not have
superpages supported, artificially limit it to PAGE_SIZE * 1024.
This is somewhat arbitrary, and e.g. could change what binaries do
we accept between native i386 vs. amd64 ia32 with superpages disabled,
but I do not believe the difference there is affecting anybody with
real (useful) binaries.

Reported and tested by: pho
Reviewed by: markj
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D33359

2 years agornd_elf: add comment explaining the interface
Konstantin Belousov [Thu, 9 Dec 2021 15:22:54 +0000 (17:22 +0200)]
rnd_elf: add comment explaining the interface

Requested and reviewed by: markj
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D33359

2 years agoelf image activator: convert asserts into errors
Konstantin Belousov [Tue, 7 Dec 2021 09:29:53 +0000 (11:29 +0200)]
elf image activator: convert asserts into errors

Invalid (artificial) layout of the loadable ELF segments might result in
triggering the assertion.  This means that the file should not be
executed, regardless of the kernel debug mode.  Change calling
conventions for rnd_elf{32,64} helpers to allow returning an error, and
abort activation with ENOEXEC if its invariants are broken.

Reported and tested by: pho
Reviewed by: markj
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D33359

2 years agoexec_elf: assert that the image vnode is still locked on return
Konstantin Belousov [Thu, 9 Dec 2021 15:14:46 +0000 (17:14 +0200)]
exec_elf: assert that the image vnode is still locked on return

Suggested and reviewed by: markj
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D33359

2 years agoStyle
Konstantin Belousov [Wed, 8 Dec 2021 15:08:59 +0000 (17:08 +0200)]
Style

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

2 years agonfscl: Fix must_commit/writeverf handling for Direct I/O
Rick Macklem [Sat, 11 Dec 2021 23:00:30 +0000 (15:00 -0800)]
nfscl: Fix must_commit/writeverf handling for Direct I/O

Without this patch, the KASSERT(must_commit == 0,..) can be
triggered by the writeverf in the Direct I/O write reply changing.
This is not a situation that should cause a panic(). Correct
handling is to ignore the change in "writeverf" for Direct
I/O, since it is done with NFSWRITE_FILESYNC.

This patch modifies the semantics of the "must_commit"
argument slightly, allowing an initial value of 2 to indicate
that a change in "writeverf" should be ignored.
It also fixes the KASSERT()s.

This bug would affect few, since Direct I/O is not enabled
by default and "writeverf" rarely changes. Normally "writeverf"
only changes when a NFS server reboots, however I found the
bug when testing against a Linux 5.15.1 kernel nfsd, which
replied to a NFSWRITE_FILESYNC write with a "writeverf" of all
0x0 bytes.

MFC after: 2 weeks

2 years agoloader: framebuffer should only be written into
Toomas Soome [Mon, 6 Dec 2021 17:21:58 +0000 (19:21 +0200)]
loader: framebuffer should only be written into

Reading from Write Combining memory can be very-very slow. Try to use
shadow buffer to avoid such reads.

MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D33305

2 years agostress2: Remove tests from the exclude list
Peter Holm [Sat, 11 Dec 2021 10:45:11 +0000 (10:45 +0000)]
stress2: Remove tests from the exclude list

2 years agostress2: Disable aslr for this test to work
Peter Holm [Sat, 11 Dec 2021 10:43:30 +0000 (10:43 +0000)]
stress2: Disable aslr for this test to work

2 years agostress2: Save a copy of the program file for regression tests
Peter Holm [Sat, 11 Dec 2021 06:07:04 +0000 (06:07 +0000)]
stress2: Save a copy of the program file for regression tests

Suggested by:  kib

2 years agoip_log: remove set-but-not-unused vars
Cy Schubert [Sat, 11 Dec 2021 05:11:45 +0000 (21:11 -0800)]
ip_log: remove set-but-not-unused vars

MFC after: 3 days

2 years agoippool: remove set-but-not-unused vars
Cy Schubert [Sat, 11 Dec 2021 05:01:14 +0000 (21:01 -0800)]
ippool: remove set-but-not-unused vars

Display of stats from a kernel core dump was never fully implemented.
Remove the dangling vars and remove the documentation.

MFC after: 3 days

2 years agoipfcomp: remove set-but-not-unused vars
Cy Schubert [Sat, 11 Dec 2021 04:56:10 +0000 (20:56 -0800)]
ipfcomp: remove set-but-not-unused vars

MFC after: 3 days

2 years agoipfilter printfieldhdr: remove set-but-not-unused vars
Cy Schubert [Sat, 11 Dec 2021 04:51:01 +0000 (20:51 -0800)]
ipfilter printfieldhdr: remove set-but-not-unused vars

MFC after: 3 days

2 years agoipft_tx: remove set-but-not-unused vars
Cy Schubert [Sat, 11 Dec 2021 04:49:22 +0000 (20:49 -0800)]
ipft_tx: remove set-but-not-unused vars

MFC after: 3 days

2 years agoipft_pc: remove set-but-not-unused vars
Cy Schubert [Sat, 11 Dec 2021 04:48:17 +0000 (20:48 -0800)]
ipft_pc: remove set-but-not-unused vars

MFC after: 3 days

2 years agoipft_hx: remove set-but-not-unused vars
Cy Schubert [Sat, 11 Dec 2021 04:46:11 +0000 (20:46 -0800)]
ipft_hx: remove set-but-not-unused vars

MFC after: 3 days

2 years agoMake msgbuf_peekbytes() not return leading zeroes.
Alexander Motin [Sat, 11 Dec 2021 04:18:52 +0000 (23:18 -0500)]
Make msgbuf_peekbytes() not return leading zeroes.

Introduce new MSGBUF_WRAP flag, indicating that buffer has wrapped
at least once and does not keep zeroes from the last msgbuf_clear().
It allows msgbuf_peekbytes() to return only real data, not requiring
every consumer to trim the leading zeroes after doing pointless copy.
The most visible effect is that kern.msgbuf sysctl now always returns
proper zero-terminated string, not only after the first buffer wrap.

MFC after: 1 week
Sponsored by: iXsystems, Inc.

2 years agoif_epair: fix module build outside of kernel build environment
Eugene Grosbein [Sat, 11 Dec 2021 04:07:50 +0000 (11:07 +0700)]
if_epair: fix module build outside of kernel build environment

MFC after: 3 days

2 years agorc.conf.5: Fix a typo
Mateusz Piotrowski [Fri, 10 Dec 2021 22:36:38 +0000 (23:36 +0100)]
rc.conf.5: Fix a typo

2 years agovfs: annotate all unused MNTK_ flags
Mateusz Guzik [Fri, 10 Dec 2021 20:06:28 +0000 (20:06 +0000)]
vfs: annotate all unused MNTK_ flags

2 years agovfs: retire MNTK_NOKNOTE and VV_NOKNOTE
Mateusz Guzik [Fri, 10 Dec 2021 14:08:26 +0000 (15:08 +0100)]
vfs: retire MNTK_NOKNOTE and VV_NOKNOTE

MNTK_NOKNOTE was introduced in 679985d03a64f5dfb4355538ae6e3b70f8347f38
(dated 2005), VV_NOKNOTE in 34cc826ae8999f454dd6cb9c77d17ce83b169f92 few
months later.

Neither was ever used by anything in the tree.

2 years agolibkvm: fix kvm_walk_pages
Bora Özarslan [Thu, 25 Nov 2021 19:09:26 +0000 (14:09 -0500)]
libkvm: fix kvm_walk_pages

Correct bitmap operations in _kvm_bitmap_next.

Reviewed by: jhb
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D19183

2 years agomips: Turn off LLVM MIPS targets by default
Warner Losh [Fri, 10 Dec 2021 18:31:07 +0000 (11:31 -0700)]
mips: Turn off LLVM MIPS targets by default

Now that MIPS isn't a recognized target for buildworld, move llvm mips
to off by default.

Sponsored by: Netflix
Reviewed by: dim
Differential Revision: https://reviews.freebsd.org/D33364

2 years agostand: remove mips support
Warner Losh [Fri, 10 Dec 2021 18:04:48 +0000 (11:04 -0700)]
stand: remove mips support

As part of decommissioning mips support, remove the boot loader
support. Do this in advance of other boot loader work to limit the
amount of work that will be thrown away.

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

2 years agoloader.mk: Simplify a little bit
Warner Losh [Fri, 10 Dec 2021 18:04:37 +0000 (11:04 -0700)]
loader.mk: Simplify a little bit

The elf loader needs to know how to reach into the gfx_fb code, so
simplify how we include files to find that stuff.

Sponsored by: Netflix
Reviewed by: manu, tsoome
Differential Revision: https://reviews.freebsd.org/D33376

2 years agohdda: Remove extra topo_unlock
Warner Losh [Fri, 10 Dec 2021 17:00:20 +0000 (10:00 -0700)]
hdda: Remove extra topo_unlock

Reported by: Taku YAMAMOTO
Sponsored by: Netflix

2 years agopcf85063: Fix real time clock
Hubert Mazur [Fri, 10 Dec 2021 15:07:25 +0000 (16:07 +0100)]
pcf85063: Fix real time clock

Previosuly real time clock driver always set time format to 12-hour
mode. Fix this by choosing hour mode depending on HW register.

2 years agogmultipath.8: Fix a typo
Mateusz Piotrowski [Fri, 10 Dec 2021 13:32:33 +0000 (14:32 +0100)]
gmultipath.8: Fix a typo

It's Word Wide Port Name, not World Word Port Name.

MFC after: 3 days

2 years agoFix a set but not used warning in the arm GIC driver
Andrew Turner [Fri, 10 Dec 2021 12:30:01 +0000 (12:30 +0000)]
Fix a set but not used warning in the arm GIC driver

Sponsored by: Innovate UK

2 years agoFix set but not used warnings in arm64 rockchip
Andrew Turner [Fri, 10 Dec 2021 12:23:21 +0000 (12:23 +0000)]
Fix set but not used warnings in arm64 rockchip

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

2 years agobxe: plug some of set-but-not-used vars
Mateusz Guzik [Fri, 10 Dec 2021 12:19:16 +0000 (12:19 +0000)]
bxe: plug some of set-but-not-used vars

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

2 years agoFix set but not used warnings in arm64 core code
Andrew Turner [Fri, 10 Dec 2021 12:06:25 +0000 (12:06 +0000)]
Fix set but not used warnings in arm64 core code

2 years agoFix a set but not used warning in the arm64 pmap
Andrew Turner [Tue, 7 Dec 2021 14:32:11 +0000 (14:32 +0000)]
Fix a set but not used warning in the arm64 pmap

In pmap_ts_referenced we read the virtual address from pv->pv_va,
but then continue to use the pv struct to get the same value later
in the function.

Use the virtual address value we initially read rather than loading
from the pv struct each time.

2 years agohn: plug set-but-not-unused vars
Mateusz Guzik [Fri, 10 Dec 2021 12:09:26 +0000 (12:09 +0000)]
hn: plug set-but-not-unused vars

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

2 years agoctl: plug set-but-not-unused var
Mateusz Guzik [Fri, 10 Dec 2021 12:06:48 +0000 (12:06 +0000)]
ctl: plug set-but-not-unused var

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

2 years agobfe: plug a set-but-not-unused var
Mateusz Guzik [Fri, 10 Dec 2021 12:02:05 +0000 (12:02 +0000)]
bfe: plug a set-but-not-unused var

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

2 years agox86: plug a set-but-not-unused var in native_lapic_ipi_free
Mateusz Guzik [Fri, 10 Dec 2021 11:55:03 +0000 (11:55 +0000)]
x86: plug a set-but-not-unused var in native_lapic_ipi_free

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

2 years agonfe: plug set-but-not-unused vars
Mateusz Guzik [Fri, 10 Dec 2021 11:53:38 +0000 (11:53 +0000)]
nfe: plug set-but-not-unused vars

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

2 years agoalc: plug set-but-not-unused vars
Mateusz Guzik [Fri, 10 Dec 2021 11:48:42 +0000 (11:48 +0000)]
alc: plug set-but-not-unused vars

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

2 years agoasmc: plug set-but-not-unused vars
Mateusz Guzik [Fri, 10 Dec 2021 11:45:36 +0000 (11:45 +0000)]
asmc: plug set-but-not-unused vars

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

2 years agoxdma: Fix another -Wunused-but-set-variable warning previously missed
Jessica Clarke [Fri, 10 Dec 2021 05:06:54 +0000 (05:06 +0000)]
xdma: Fix another -Wunused-but-set-variable warning previously missed

MFC after: 1 week

2 years agoriscv: Fix PLIC -Wunused-but-set-variable warnings
Jessica Clarke [Fri, 10 Dec 2021 04:51:32 +0000 (04:51 +0000)]
riscv: Fix PLIC -Wunused-but-set-variable warnings

2 years agoxdma: Fix -Wunused-but-set-variable warnings
Jessica Clarke [Fri, 10 Dec 2021 04:48:51 +0000 (04:48 +0000)]
xdma: Fix -Wunused-but-set-variable warnings

MFC after: 1 week

2 years agobusdma: Remove outdated comments about Giant.
Alexander Motin [Fri, 10 Dec 2021 03:17:54 +0000 (22:17 -0500)]
busdma: Remove outdated comments about Giant.

MFC after: 2 weeks

2 years agoAdd idle priority scheduling privilege group to MAC/priority
Florian Walpen [Fri, 10 Dec 2021 01:35:38 +0000 (03:35 +0200)]
Add idle priority scheduling privilege group to MAC/priority

Add an idletime user group that allows non-root users to run processes
with idle scheduling priority. Privileges are granted by a MAC policy in
the mac_priority module. For this purpose, the kernel privilege
PRIV_SCHED_IDPRIO was added to sys/priv.h (kernel module ABI change).

Deprecate the system wide sysctl(8) knob
security.bsd.unprivileged_idprio which lets any user run idle priority
processes, regardless of context. While the knob is still working, it is
marked as deprecated in the description and in the man pages.

MFC after: 2 weeks
Differential revision: https://reviews.freebsd.org/D33338

2 years agoAdd PRIV_SCHED_IDPRIO
Florian Walpen [Fri, 10 Dec 2021 01:43:12 +0000 (03:43 +0200)]
Add PRIV_SCHED_IDPRIO

The privilege allows the holder to assign idle priority type to thread
or process.

MFC after: 2 weeks
Differential revision: https://reviews.freebsd.org/D33338

2 years agoahc: Mark sysctls with CTLFLAG_MPSAFE.
Alexander Motin [Fri, 10 Dec 2021 02:36:21 +0000 (21:36 -0500)]
ahc: Mark sysctls with CTLFLAG_MPSAFE.

MFC after: 2 weeks

2 years agofxp: Mark sysctls with CTLFLAG_MPSAFE.
Alexander Motin [Fri, 10 Dec 2021 02:16:16 +0000 (21:16 -0500)]
fxp: Mark sysctls with CTLFLAG_MPSAFE.

MFC after: 2 weeks

2 years agowbwd: Mark sysctls with CTLFLAG_MPSAFE.
Alexander Motin [Fri, 10 Dec 2021 02:13:10 +0000 (21:13 -0500)]
wbwd: Mark sysctls with CTLFLAG_MPSAFE.

MFC after: 2 weeks

2 years agosmist: Remove unneeded Giant from bus_dma_tag_create().
Alexander Motin [Fri, 10 Dec 2021 01:54:22 +0000 (20:54 -0500)]
smist: Remove unneeded Giant from bus_dma_tag_create().

bus_dmamap_load() call uses BUS_DMA_NOWAIT.

MFC after: 2 weeks

2 years agohptiop: Remove Giant locking around ioctls.
Alexander Motin [Fri, 10 Dec 2021 01:35:21 +0000 (20:35 -0500)]
hptiop: Remove Giant locking around ioctls.

The methods have their own locking and don't require Giant.

MFC after: 2 weeks

2 years agohpt27xx: Remove FreeBSD 9.x support including Giant.
Alexander Motin [Fri, 10 Dec 2021 01:24:29 +0000 (20:24 -0500)]
hpt27xx: Remove FreeBSD 9.x support including Giant.

MFC after: 2 weeks

2 years agofxp: Remove unneeded Giant from bus_dma_tag_create().
Alexander Motin [Fri, 10 Dec 2021 01:09:48 +0000 (20:09 -0500)]
fxp: Remove unneeded Giant from bus_dma_tag_create().

All bus_dmamap_load() calls here use BUS_DMA_NOWAIT.

MFC after: 2 weeks

2 years agoacpi_cpu: Replace Giant with bus_topo_lock.
Alexander Motin [Fri, 10 Dec 2021 01:08:25 +0000 (20:08 -0500)]
acpi_cpu: Replace Giant with bus_topo_lock.

2 years agoed: Remove options
Warner Losh [Fri, 10 Dec 2021 00:41:39 +0000 (17:41 -0700)]
ed: Remove options

ed(4) was removed some time ago, but these options relevant to only it
weren't GC'd at the time. Remove them.

Sponsored by: Netflix

2 years agohda: Push giant / newbus topo lock down a layer
Warner Losh [Thu, 9 Dec 2021 23:52:55 +0000 (16:52 -0700)]
hda: Push giant / newbus topo lock down a layer

Rather than picking up Giant at the start of these sysctl handlers, push
acquiring Giant down a layer to protect walking the children and also
to add/delete children for the reconfigure.

Sponsored by: Netflix
Reviewed by: mav, jhb
Differential Revision: https://reviews.freebsd.org/D33057

2 years agonewbus: add bus_topo_assert
Warner Losh [Thu, 9 Dec 2021 23:52:44 +0000 (16:52 -0700)]
newbus: add bus_topo_assert

Add bus_topo_assert() and implmement it as GIANT_REQUIRED for the
moment. This will allow us to change more easily to a newbus-specific
lock int he future.

Sponsored by: Netflix
Reviewed by: wulf, mav, jhb
Differential Revision: https://reviews.freebsd.org/D31833

2 years agobus: mark sysctls MPSAFE
Warner Losh [Thu, 9 Dec 2021 23:52:34 +0000 (16:52 -0700)]
bus: mark sysctls MPSAFE

Mark the sysctls MPSAFE and pickup the bus topo lock while processing
them.

Sponsored by: Netflix
Reviewed by: mav, jhb
Differential Revision: https://reviews.freebsd.org/D31832

2 years agoCreate wrapper for Giant taken for newbus
Warner Losh [Fri, 10 Dec 2021 00:04:45 +0000 (17:04 -0700)]
Create wrapper for Giant taken for newbus

Create a wrapper for newbus to take giant and for busses to take it too.
bus_topo_lock() should be called before interacting with newbus routines
and unlocked with bus_topo_unlock(). If you need the topology lock for
some reason, bus_topo_mtx() will provide that.

Sponsored by: Netflix
Reviewed by: mav
Differential Revision: https://reviews.freebsd.org/D31831

2 years agonfscl: Check for an error return from nfsrv_getattrbits()
Rick Macklem [Thu, 9 Dec 2021 22:32:22 +0000 (14:32 -0800)]
nfscl: Check for an error return from nfsrv_getattrbits()

There were two places where the client code did not check
for a parse error return from nfsrv_getattrbits().

This patch fixes both of these cases.

Reported by: rtm@lcs.mit.edu
Tested by: rtm@lcs.mit.edu
PR: 260272
MFC after: 2 weeks

2 years agonfscl: Sanity check the callback tag length
Rick Macklem [Thu, 9 Dec 2021 22:15:48 +0000 (14:15 -0800)]
nfscl: Sanity check the callback tag length

The sanity check for tag length in a callback request
was broken in two ways:

It checked for a negative value, but not a large positive
value.

It did not set taglen to -1, to indicate to the code that
it should not be used.

This patch fixes both of these issues.

Reported by: rtm@lcs.mit.edu
Tested by: rtm@lcs.mit.edu
PR: 260266
MFC after: 2 weeks

2 years agopseudofs: Destroy vncache hashtbl on pseudofs module unload.
Dmitry Chagin [Thu, 9 Dec 2021 21:41:08 +0000 (21:41 +0000)]
pseudofs: Destroy vncache hashtbl on pseudofs module unload.

Reviewed by: mjg, kib
Differential Revision: https://reviews.freebsd.org/D31605
MFC after: 2 weeks

2 years agolibc: Remove _get_tp() and _set_tp().
John Baldwin [Thu, 9 Dec 2021 21:19:33 +0000 (13:19 -0800)]
libc: Remove _get_tp() and _set_tp().

Their uses have been replaced by _tcb_get() and _tcb_set() from
<machine/tls.h>.

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

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

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

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

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

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

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

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

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

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

2 years agonet/if.c: plug set-but-not-unused vars
Mateusz Guzik [Thu, 9 Dec 2021 20:39:40 +0000 (20:39 +0000)]
net/if.c: plug set-but-not-unused vars

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

2 years agoioat: plug set-but-not-unused vars
Mateusz Guzik [Thu, 9 Dec 2021 20:21:16 +0000 (20:21 +0000)]
ioat: plug set-but-not-unused vars

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

2 years agoBump __FreeBSD_version for software crypto changes.
John Baldwin [Thu, 9 Dec 2021 19:53:07 +0000 (11:53 -0800)]
Bump __FreeBSD_version for software crypto changes.

- enc_xform now supports AEAD ciphers.
- The Blake-2S/B auth transforms now support Init before
  Setkey like other auth transforms.

2 years agocryptosoft: Stop single-threading requests within a session.
John Baldwin [Thu, 9 Dec 2021 19:52:43 +0000 (11:52 -0800)]
cryptosoft: Stop single-threading requests within a session.

All of the request handlers no longer modify session state, so remove
the mutex limiting operations to one per session.  In addition, change
the pointer to the session state passed to process callbacks to const.

Suggested by: mjg
Reviewed by: mjg, markj
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D33317

2 years agocryptosoft: Fully support per-operation keys for auth algorithms.
John Baldwin [Thu, 9 Dec 2021 19:52:42 +0000 (11:52 -0800)]
cryptosoft: Fully support per-operation keys for auth algorithms.

Only pre-allocate auth contexts when a session-wide key is provided or
for sessions without keys.  For sessions with per-operation keys,
always initialize the on-stack context directly rather than
initializing the session context in swcr_authprepare (now removed) and
then copying that session context into the on-stack context.

This approach permits parallel auth operations without needing a
serializing lock.  In addition, the previous code assumed that auth
sessions always provided an initial key unlike cipher sessions which
assume either an initial key or per-op keys.

While here, fix the Blake2 auth transforms to function like other auth
transforms where Setkey is invoked after Init rather than before.

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

2 years agocryptosoft: Allocate cipher contexts on the stack during operations.
John Baldwin [Thu, 9 Dec 2021 19:52:42 +0000 (11:52 -0800)]
cryptosoft: Allocate cipher contexts on the stack during operations.

As is done with authentication contexts, allocate cipher contexts on
the stack while completing requests.  This permits safely dispatching
concurrent requests on a single session.  The cipher context in the
session is now only allocated when a session key is provided during
session setup to serve as a template to initialize the on-stack
context similar to auth operations.

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

2 years agocryptosoft: Rename sw_kschedule member to sw_ctx.
John Baldwin [Thu, 9 Dec 2021 19:52:42 +0000 (11:52 -0800)]
cryptosoft: Rename sw_kschedule member to sw_ctx.

The cipher context isn't always a key schedule, so use a more generic
name.

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

2 years agocrypto: Refactor software support for AEAD ciphers.
John Baldwin [Thu, 9 Dec 2021 19:52:42 +0000 (11:52 -0800)]
crypto: Refactor software support for AEAD ciphers.

Extend struct enc_xform to add new members to handle auth operations
for AEAD ciphers.  In particular, AEAD operations in cryptosoft no
longer use a struct auth_hash.  Instead, the setkey and reinit methods
of struct enc_xform are responsible for initializing both the cipher
and auth state.

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

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

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

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

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