]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
2 years agoveriexec: Fix veriexec -i's confusion between loaded and locked states
Stephane Rochoy [Thu, 23 Sep 2021 08:53:56 +0000 (10:53 +0200)]
veriexec: Fix veriexec -i's confusion between loaded and locked states

Calling veriexec -i locked return the state of loaded and vice-versa.

Differential revision: https://reviews.freebsd.org/D30952
Reviewed by: sjg,imp
Obtained from: Stromshield

2 years agosh: Add -o verify to use O_VERIFY when sourcing scripts
Stephane Rochoy [Thu, 23 Sep 2021 08:40:59 +0000 (10:40 +0200)]
sh: Add -o verify to use O_VERIFY when sourcing scripts

Add -o verify to sh to make it use O_VERIFY when
sourcing scripts and reading profiles.

Useful in conjunction with mac_veriexec to help protect at
least some parts of the boot sequence, e.g., /etc/rc*.

Differential revision: https://reviews.freebsd.org/D30464
Reviewed by: jilles, sjg
Obtained from: Stormshield

2 years agoUPDATING: Fix spelling.
Hans Petter Selasky [Thu, 23 Sep 2021 07:49:01 +0000 (09:49 +0200)]
UPDATING: Fix spelling.

Submitted by: gljennjohn@gmail.com
Differential Revision: https://reviews.freebsd.org/D31636
Sponsored by: NVIDIA Networking

2 years agokern: random: collect ~16x less from fast-entropy sources
Kyle Evans [Mon, 20 Sep 2021 05:46:21 +0000 (00:46 -0500)]
kern: random: collect ~16x less from fast-entropy sources

Previously, we were collecting at a base rate of:

64 bits x 32 pools x 10 Hz = 2.5 kB/s

This change drops it to closer to 64-ish bits per pool per second, to
work a little better with entropy providers in virtualized environments
without compromising the security goals of Fortuna.

Reviewed by: #csprng (cem, delphij, markm)
Differential Revision: https://reviews.freebsd.org/D32021

2 years agokern: random: drop read_rate and associated functionality
Kyle Evans [Mon, 20 Sep 2021 04:59:09 +0000 (23:59 -0500)]
kern: random: drop read_rate and associated functionality

Refer to discussion in PR 230808 for a less incomplete discussion, but
the gist of this change is that we currently collect orders of magnitude
more entropy than we need.

The excess comes from bytes being read out of /dev/*random.  The default
rate at which we collect entropy without the read_rate increase is
already more than we need to recover from a compromise of an internal
state.

Reviewed by: #csprng (cem, delphij, markm)
Differential Revision: https://reviews.freebsd.org/D32021

2 years agohwpmc: fix performance issues
Wojciech Macek [Mon, 20 Sep 2021 11:08:32 +0000 (13:08 +0200)]
hwpmc: fix performance issues

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

Avoid using atomics as it_wait is guarded by td_lock.

Report threshold calculation is done only if at least one PMC hook
is installed

Fixes:
* avoid unnecessary branching (if frame != null ...)
  by having PMC_HOOK_INSTALLED_ANY
  condition on the top of them, which should hint
  the core not to execute speculatively anything
  which us underneath;
* access intr_hwpmc_waiting_report_threshold cacheline
  only if at least one hook is loaded;

2 years agopmc: intr pmc.soft(3) update
Wojciech Macek [Wed, 22 Sep 2021 07:52:42 +0000 (09:52 +0200)]
pmc: intr pmc.soft(3) update

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

2 years agocheck-links.sh: treat PIE executable as elf files
Baptiste Daroussin [Thu, 23 Sep 2021 02:48:50 +0000 (04:48 +0200)]
check-links.sh: treat PIE executable as elf files

2 years agotests/sys/fs/fusefs/read.cc: fix build on powerpc64
Konstantin Belousov [Wed, 22 Sep 2021 22:47:10 +0000 (01:47 +0300)]
tests/sys/fs/fusefs/read.cc: fix build on powerpc64

There sig_atomic_t is shorter than void *.
As result, it cannot keep pointer.

Assigning to void * is actually safe for us in a signal handler.

Reviewed by: asomers
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Fixes: 4f917847c9037d
Differential revision: https://reviews.freebsd.org/D32064

2 years agosysdecode.3: Remove documentation of CloudABI ABIs.
John Baldwin [Thu, 23 Sep 2021 00:02:17 +0000 (17:02 -0700)]
sysdecode.3: Remove documentation of CloudABI ABIs.

Fixes: cf0ee8738e31 Drop cloudabi

2 years agotruss: Decode correctly 64bits arguments on 32bits arm.
Olivier Houchard [Wed, 22 Sep 2021 23:23:07 +0000 (01:23 +0200)]
truss: Decode correctly 64bits arguments on 32bits arm.

Mostly revert ebbc3140ca0d7eee154f7a67ccdae7d3d88d13fd.
We don't need to special-case anything for arm64, the check for the pointer
size is already done for us, just keep the bits about having arm and arm64
having to add padding for 32bits binaries.

MFC after: 1 week

2 years agoEliminate an unnecessary rerun request in fsck_ffs.
Kirk McKusick [Wed, 22 Sep 2021 23:16:39 +0000 (16:16 -0700)]
Eliminate an unnecessary rerun request in fsck_ffs.

When fsck_ffs is running in preen mode and finds a zero-length directory,
it deletes that directory. In doing this operation, it unnecessary set
its internal flag saying that fsck_ffs needed to be rerun. This patch
deletes the rerun request for this case.

Reported by:  Mark Johnson
PR:           246962
MFC after:    1 week
Sponsored by: Netflix

2 years agotruss: Decode correctly 64bits arguments on 32bits arm.
Olivier Houchard [Wed, 22 Sep 2021 22:45:42 +0000 (00:45 +0200)]
truss: Decode correctly 64bits arguments on 32bits arm.

When decoding 32bits arm syscall, make sure we account for the padding when
decoding 64bits args. Do it too when using a 64bits truss on a 32bits binary.

MFC After: 1 week
PR: 256199

2 years agolibsysdecode: Decode FreeBSD32 syscalls on arm64.
Olivier Houchard [Wed, 22 Sep 2021 22:22:30 +0000 (00:22 +0200)]
libsysdecode: Decode FreeBSD32 syscalls on arm64.

Add aarch64 to the list of architectures that can run 32bits FreeBSD binaries,
so that truss works correctly with an arm32 binary.
The same should probably be done with mips.

MFC After: 1 week

2 years agosh: try to avoid overwriting HISTFILE produced by other shells
Piotr Pawel Stefaniak [Wed, 22 Sep 2021 16:42:41 +0000 (18:42 +0200)]
sh: try to avoid overwriting HISTFILE produced by other shells

If an attempt to load history from an existing history file was
unsuccessful, do not try to save command history to that file on exit.

2 years agosh: improve command completion
Piotr Pawel Stefaniak [Wed, 22 Sep 2021 16:23:29 +0000 (18:23 +0200)]
sh: improve command completion

When there are many matches, find the longest common substring starting
from the beginning of each command and use that to replace input.

As an example: on my system, llv<tab> will be autocompleted to llvm-
and another <tab> will print all matching llvm commands.

2 years agoRevert "linux32: add a hack to avoid redefining the type of the savefpu tag"
Konstantin Belousov [Wed, 22 Sep 2021 18:54:39 +0000 (21:54 +0300)]
Revert "linux32: add a hack to avoid redefining the type of the savefpu tag"

This reverts commit 0f6829488ef32142b9ea1c0806fb5ecfe0872c02.
Also it changes the type of md_usr_fpu_save struct mdthread member
to void *, which is what uncovered this trouble.  Now the save area
is untyped, but since it is hidden behind accessors, it is not too
significant.  Since apparently there are consumers affected outside
the tree, this hack is better than one from the reverted revision.

PR: 258678
Reported by: cy
Reviewed by: cy, kevans, markj
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D32060

2 years agorc.d/mixer: Use -o flag instead of -s flag to get current mixer state.
Hans Petter Selasky [Wed, 22 Sep 2021 20:09:23 +0000 (22:09 +0200)]
rc.d/mixer: Use -o flag instead of -s flag to get current mixer state.

Submitted by: christos@
Differential Revision: https://reviews.freebsd.org/D31636
Sponsored by: NVIDIA Networking

2 years agomixer(3) and mixer(8): Update manual pages.
Hans Petter Selasky [Wed, 22 Sep 2021 20:01:12 +0000 (22:01 +0200)]
mixer(3) and mixer(8): Update manual pages.

- Use correct e-mail address.
- Set FreeBSD 14.0 as introduction for the updated mixer(8) utility.

Submitted by: christos@
Differential Revision: https://reviews.freebsd.org/D31636
Sponsored by: NVIDIA Networking

2 years agomixer(8): Compile fix for when the "char" type is unsigned.
Hans Petter Selasky [Wed, 22 Sep 2021 18:56:34 +0000 (20:56 +0200)]
mixer(8): Compile fix for when the "char" type is unsigned.

Differential Revision: https://reviews.freebsd.org/D31636
Sponsored by: NVIDIA Networking

2 years agoUPDATING: Add new entry about mixer(8) usage.
Hans Petter Selasky [Wed, 22 Sep 2021 14:47:25 +0000 (16:47 +0200)]
UPDATING: Add new entry about mixer(8) usage.

Differential Revision: https://reviews.freebsd.org/D31636
Sponsored by: NVIDIA Networking

2 years agoImplement and use new mixer(3) library for FreeBSD.
Hans Petter Selasky [Wed, 22 Sep 2021 13:42:51 +0000 (15:42 +0200)]
Implement and use new mixer(3) library for FreeBSD.

Wiki article: https://wiki.freebsd.org/SummerOfCode2021Projects/SoundMixerImprovements
This project was part of Google Summer of Code 2021.

Submitted by: christos@
Differential Revision: https://reviews.freebsd.org/D31636
Sponsored by: NVIDIA Networking

2 years agoFix false device_set_unit() error.
Alexander Motin [Wed, 22 Sep 2021 12:42:36 +0000 (08:42 -0400)]
Fix false device_set_unit() error.

It should silently succeed if the current unit number is the same as
requested, not fail immediately.

MFC after: 1 week

2 years agoObsoleteFiles.inc: Add sponge(1) command and man-page
Stefan Eßer [Wed, 22 Sep 2021 11:59:01 +0000 (13:59 +0200)]
ObsoleteFiles.inc: Add sponge(1) command and man-page

The sponge command has been imported on 2017-12-05 but the import has
been reverted the next day.

A script failed and I found that it was due to the left-over broken
sponge binary in base being prefered over the port version. To prevent
a known non-working binary to persist in /usr/bin, I'm adding sponge
to the obsolete files list even though it could only be installed on
a single day in 2017.

I do not plan to MFC this change since the issue will only exist on
systems installed from -CURRENT sources in 2017, and I do assume that
such systems are not running -STABLE today

2 years agodma: make the version exposed reflect the new version
Baptiste Daroussin [Wed, 22 Sep 2021 09:12:04 +0000 (11:12 +0200)]
dma: make the version exposed reflect the new version

2 years agodma: import snapshot 2021-07-10
Baptiste Daroussin [Wed, 22 Sep 2021 09:09:27 +0000 (11:09 +0200)]
dma: import snapshot 2021-07-10

2 years agosh: reset sh bindings on bind -e, bind -v
Piotr Pawel Stefaniak [Sun, 19 Sep 2021 20:17:01 +0000 (22:17 +0200)]
sh: reset sh bindings on bind -e, bind -v

Until this change, any bindings set in histedit() were lost on calls to
bindcmd().

Only bind -e and bind -v call libedit's keymacro_reset(). Currently you
cannot fool libedit/map.c:map_bind() by trying something like bind -le
as when p[0] == '-', it does a switch statement on p[1].

2 years agodma: import git snapshot 2021-07-10
Baptiste Daroussin [Wed, 22 Sep 2021 08:52:34 +0000 (10:52 +0200)]
dma: import git snapshot 2021-07-10

2 years agosh: remove emacs improvements that are now defaults in libedit
Baptiste Daroussin [Wed, 22 Sep 2021 08:27:10 +0000 (10:27 +0200)]
sh: remove emacs improvements that are now defaults in libedit

2 years agolibedit: import snapshot 2021-09-10
Baptiste Daroussin [Wed, 22 Sep 2021 08:19:43 +0000 (10:19 +0200)]
libedit: import snapshot 2021-09-10

2 years agolibedit: import version snapshot 2021-09-10
Baptiste Daroussin [Wed, 22 Sep 2021 08:11:18 +0000 (10:11 +0200)]
libedit: import version snapshot 2021-09-10

2 years agopci_vendors: update to 2021.09.19
Baptiste Daroussin [Wed, 22 Sep 2021 07:36:43 +0000 (09:36 +0200)]
pci_vendors: update to 2021.09.19

2 years agoFix build without SMP.
Alexander Motin [Wed, 22 Sep 2021 02:13:33 +0000 (22:13 -0400)]
Fix build without SMP.

MFC after: 1 month

2 years agosched_ule(4): Improve long-term load balancer.
Alexander Motin [Tue, 21 Sep 2021 22:14:22 +0000 (18:14 -0400)]
sched_ule(4): Improve long-term load balancer.

Before this change long-term load balancer was unable to migrate
running threads, only ones waiting on run queues.  But with growing
number of CPU cores it is quite typical now for system to not have
many waiting threads.  But same time if due to some coincidence two
long-running CPU-bound threads ended up sharing same physical CPU
core, they could suffer from the SMT penalty indefinitely, and the
load balancer couldn't help.

Improve that by teaching the load balancer to hint running threads
to migrate by marking them with TDF_NEEDRESCHED and new TDF_PICKCPU
flag, making sched_pickcpu() to search for better CPU later, when
it is convenient.

Fix CPU search logic when balancing to limit round-robin migrations
in case of almost equal load to the group of physical cores.  The
previous code bounced threads across all the system, that should be
pretty bad for caches and NUMA affinity, while additional fairness
was almost invisible, diminishing with number of cores in the group.

MFC after: 1 month

2 years agoarm: Handle thumb2 thread entry point.
Olivier Houchard [Tue, 21 Sep 2021 21:19:46 +0000 (23:19 +0200)]
arm: Handle thumb2 thread entry point.

In cpu_set_upcall(), if the thread startup routine is a thumb routine, make
sure to set PSR_T, so that the CPU will run in thumb mode.

MFC After:      1 week

2 years agoarm64: Handle thumb2 thread entry point.
Olivier Houchard [Tue, 21 Sep 2021 21:17:53 +0000 (23:17 +0200)]
arm64: Handle thumb2 thread entry point.

In cpu_set_upcall(), if the thread startup routine is a thumb routine, make
sure to set PSR_T, so that the CPU will run in thumb mode.

MFC After: 1 week

2 years agoRemove SV_CAPSICUM
Konstantin Belousov [Mon, 13 Sep 2021 09:49:13 +0000 (12:49 +0300)]
Remove SV_CAPSICUM

It was only needed for cloudabi

Reviewed by: emaste
Sponsored by: The FreeBSD Foundation
Differential revision: https://reviews.freebsd.org/D31923

2 years agoDrop cloudabi
Konstantin Belousov [Sun, 12 Sep 2021 22:50:39 +0000 (01:50 +0300)]
Drop cloudabi

According to https://github.com/NuxiNL/cloudlibc:
CloudABI is no longer being maintained. It was an awesome experiment,
but it never got enough traction to be sustainable.

There is no reason to keep it in FreeBSD.

Approved by: ed (private mail)
Reviewed by: emaste
Sponsored by: The FreeBSD Foundation
Differential revision: https://reviews.freebsd.org/D31923

2 years agoia32_get_fpcontext(): xfpusave can be legitimately NULL
Konstantin Belousov [Tue, 21 Sep 2021 21:09:34 +0000 (00:09 +0300)]
ia32_get_fpcontext(): xfpusave can be legitimately NULL

Reported by: cy
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Fixes: bd9e0f5df681da8b5ef05

2 years agonvmecontrol: Display Metadata and Sanitize capabilities of the device
Allan Jude [Tue, 21 Sep 2021 21:14:20 +0000 (21:14 +0000)]
nvmecontrol: Display Metadata and Sanitize capabilities of the device

Determine if a device supports "Extended" or "Separate" metadata, and
what the current metadata setting is (None, Extended, Separate)

Also determine if the device supports:
  - Sanitize Crypto Erase
  - Sanitize Block Erase
  - Sanitize Overwrite

Reviewed by: chuck
Sponsored by: NetApp, Inc.
Sponsored by:  Klara, Inc.
X-NetApp-PR: #49
Differential Revision: https://reviews.freebsd.org/D31067

2 years agopowerpc64: fix loader regression
Leandro Lupori [Tue, 21 Sep 2021 20:22:42 +0000 (17:22 -0300)]
powerpc64: fix loader regression

After b4cb3fe0e39a, loader started crashing on PowerPC64, with a
Program Exception (700) error. The problem was that archsw was
used before being initialized, with the new mount feature. This
change fixes the issue by initializing archsw earlier, before
setting currdev, that triggers the mount.

Reviewed by: tsoome
MFC after: 1 month
X-MFC-With: b4cb3fe0e39a
Sponsored by: Instituto de Pesquisas Eldorado (eldorado.org.br)
Differential Revision: https://reviews.freebsd.org/D32027

2 years agosched_ule(4): Fix interactive threads stealing.
Alexander Motin [Tue, 21 Sep 2021 19:56:49 +0000 (15:56 -0400)]
sched_ule(4): Fix interactive threads stealing.

In scenarios when first thread in the queue can migrate to specified
CPU, but later ones can't runq_steal_from() incorrectly returned NULL.

MFC after: 2 weeks

2 years agofusefs: don't panic if FUSE_GETATTR fails durint VOP_GETPAGES
Alan Somers [Thu, 16 Sep 2021 19:19:21 +0000 (13:19 -0600)]
fusefs: don't panic if FUSE_GETATTR fails durint VOP_GETPAGES

During VOP_GETPAGES, fusefs needs to determine the file's length, which
could require a FUSE_GETATTR operation.  If that fails, it's better to
SIGBUS than panic.

MFC after: 1 week
Sponsored by: Axcient
Reviewed by:  markj, kib
Differential Revision: https://reviews.freebsd.org/D31994

2 years agoRevert "cpuset(9): Add CPU_FOREACH_IS(SET|CLR) and modify consumers to use it"
Mark Johnston [Tue, 21 Sep 2021 17:51:42 +0000 (13:51 -0400)]
Revert "cpuset(9): Add CPU_FOREACH_IS(SET|CLR) and modify consumers to use it"

This reverts commit 9068f6ea697b1b28ad1326a4c7a9ba86f08b985e.

The underlying macro needs to be reworked to avoid problems with control
flow statements.

Reported by: rlibby

2 years agoamd64: consistently use uprintf() to report weird situations in sigreturn
Konstantin Belousov [Thu, 16 Sep 2021 13:48:27 +0000 (16:48 +0300)]
amd64: consistently use uprintf() to report weird situations in sigreturn

Reviewed by: jhb
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D31954

2 years agoamd64: eliminate td_md.md_fpu_scratch
Konstantin Belousov [Wed, 15 Sep 2021 18:37:47 +0000 (21:37 +0300)]
amd64: eliminate td_md.md_fpu_scratch

For signal send, copyout from the user FPU save area directly.

For sigreturn, we are in sleepable context and can do temporal
allocation of the transient save area.  We cannot copying from userspace
directly to user save area because XSAVE state needs to be validated,
also partial copyins can corrupt it.

Requested by: jhb
Reviewed by: jhb, markj
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D31954

2 years agoamd64: stop using top of the thread' kernel stack for FPU user save area
Konstantin Belousov [Mon, 13 Sep 2021 21:05:47 +0000 (00:05 +0300)]
amd64: stop using top of the thread' kernel stack for FPU user save area

Instead do one more allocation at the thread creation time.  This frees
a lot of space on the stack.

Also do not use alloca() for temporal storage in signal delivery sendsig()
function and signal return syscall sys_sigreturn().  This saves equal
amount of space, again by the cost of one more allocation at the thread
creation time.

A useful experiment now would be to reduce KSTACK_PAGES.

Reviewed by: jhb, markj
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D31954

2 years agolinux32: add a hack to avoid redefining the type of the savefpu tag
Konstantin Belousov [Mon, 13 Sep 2021 21:40:02 +0000 (00:40 +0300)]
linux32: add a hack to avoid redefining the type of the savefpu tag

when compiling in amd64 kernel environment with -m32.  This is a temporal
workaround for some future proper (but unclear) fix.

Reviewed by: jhb, markj
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D31954

2 years agoexec_machdep.c: some style, use ANSI C definition for sys_sigreturn()
Konstantin Belousov [Mon, 13 Sep 2021 20:37:26 +0000 (23:37 +0300)]
exec_machdep.c: some style, use ANSI C definition for sys_sigreturn()

Reviewed by: jhb, markj
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D31954

2 years agoamd64: move signal handling and register structures manipulations into exec_machdep.c
Konstantin Belousov [Mon, 13 Sep 2021 20:33:37 +0000 (23:33 +0300)]
amd64: move signal handling and register structures manipulations into exec_machdep.c

from machdep.c which is too large pile of unrelated things.
Some ptrace functions are moved from machdep.c to ptrace_machdep.c.

Now machdep.c contains code mostly related to the low level initialization
and regular low level operation of the architecture, while signal MD code
and registers handling is placed in exec_machdep.c.

Reviewed by: jhb, markj
Discussed with: jrtc27
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D31954

2 years agoamd64: centralize definitions of CS_SECURE and EFL_SECURE
Konstantin Belousov [Tue, 14 Sep 2021 16:07:31 +0000 (19:07 +0300)]
amd64: centralize definitions of CS_SECURE and EFL_SECURE

Requested by markj
Reviewed by: jhb, markj
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D31954

2 years agoipsec: enter epoch before calling into ipsec_run_hhooks
Mateusz Guzik [Fri, 17 Sep 2021 12:00:20 +0000 (14:00 +0200)]
ipsec: enter epoch before calling into ipsec_run_hhooks

pfil_run_hooks which eventually can get called asserts on it.

Reviewed by: ae
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D32007

2 years agodwmmc: Remove dwmmc_setup_bus call from start_cmd
Emmanuel Vadot [Tue, 21 Sep 2021 15:52:38 +0000 (17:52 +0200)]
dwmmc: Remove dwmmc_setup_bus call from start_cmd

There is no need to re-setup the bus before each commands.
Tested-on:  Rock64, RockPro64
Reported by:     avg

2 years agodwmmc: Properly implement power_off/power_up
Emmanuel Vadot [Tue, 21 Sep 2021 14:10:11 +0000 (16:10 +0200)]
dwmmc: Properly implement power_off/power_up

Write to the PWREN register should be done in update_ios based
on the power_mode value in the ios struct.
Also none of the manual (RockChip and Altera) and Linux talks about
the needed for an inverted PWREN value so just remove this.
This fixes eMMC (and possibly SD) when u-boot didn't setup the controller.

Reported by: avg
Tested-on: Rock64, RockPro64

2 years agoefi loader: Typo
Mark Johnston [Tue, 21 Sep 2021 16:09:55 +0000 (12:09 -0400)]
efi loader: Typo

MFC after: 3 days

2 years agoclang-format: Add bitset loop macros
Mark Johnston [Tue, 21 Sep 2021 15:39:49 +0000 (11:39 -0400)]
clang-format: Add bitset loop macros

MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation

2 years agocpuset(9): Add CPU_FOREACH_IS(SET|CLR) and modify consumers to use it
Mark Johnston [Tue, 21 Sep 2021 15:36:55 +0000 (11:36 -0400)]
cpuset(9): Add CPU_FOREACH_IS(SET|CLR) and modify consumers to use it

This implementation is faster and doesn't modify the cpuset, so it lets
us avoid some unnecessary copying as well.  No functional change
intended.

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

2 years agobitset(9): Introduce BIT_FOREACH_ISSET and BIT_FOREACH_ISCLR
Mark Johnston [Tue, 21 Sep 2021 15:32:23 +0000 (11:32 -0400)]
bitset(9): Introduce BIT_FOREACH_ISSET and BIT_FOREACH_ISCLR

These allow one to non-destructively iterate over the set or clear bits
in a bitset.  The motivation is that we have several code fragments
which iterate over a CPU set like this:

while ((cpu = CPU_FFS(&cpus)) != 0) {
cpu--;
CPU_CLR(cpu, &cpus);
<do something>;
}

This is slow since CPU_FFS begins the search at the beginning of the
bitset each time.  On amd64 and arm64, CPU sets have size 256, so there
are four limbs in the bitset and we do a lot of unnecessary scanning.

A second problem is that this is destructive, so code which needs to
preserve the original set has to make a copy.  In particular, we have
quite a few functions which take a cpuset_t parameter by value, meaning
that each call has to copy the 32 byte cpuset_t.

The new macros address both problems.

Reviewed by: cem, kib
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D32028

2 years agosyslog.conf.5: Fix the message priority order
Felix Guest [Tue, 21 Sep 2021 15:29:39 +0000 (11:29 -0400)]
syslog.conf.5: Fix the message priority order

PR: 219942
MFC after: 1 week

2 years agosctp: Simplify stream scheduler usage
Michael Tuexen [Tue, 21 Sep 2021 15:13:57 +0000 (17:13 +0200)]
sctp: Simplify stream scheduler usage

Callers are getting the stcb send lock, so just KASSERT that.
No need to signal this when calling stream scheduler functions.
No functional change intended.

MFC after: 1 week

2 years agoarm64: Handle 32bits breakpoint exception.
Olivier Houchard [Tue, 21 Sep 2021 13:49:45 +0000 (15:49 +0200)]
arm64: Handle 32bits breakpoint exception.

A different exception is raised when we hit a 32bits breakpoint, rather than
a 64bits one, so handle those as well when COMPAT_FREEBSD32 is defined.
This should fix SIGBUS at least when using breakpoints with thumb2 code.

PR: 256468
MFC After: 1 week

2 years agoFix the arm64 L2_BLOCK_MASK definition
Andrew Turner [Tue, 21 Sep 2021 13:46:10 +0000 (13:46 +0000)]
Fix the arm64 L2_BLOCK_MASK definition

It was missing the top 16 bits.

Sponsored by: The FreeBSD Foundation

2 years agobcm2835_sdhci: don't use DMA for kernel dumps
Mitchell Horne [Thu, 9 Sep 2021 18:07:06 +0000 (15:07 -0300)]
bcm2835_sdhci: don't use DMA for kernel dumps

When handling a data irq, the sdhci driver calls the
sdhci_platform_will_handle() method, to determine if it should allow the
platform driver to handle the transfer or fall back to programmed I/O.
While dumping, the data irq path may be invoked directly (not from an
interrupt context), which the bcm2835_sdhci DMA code is not prepared to
handle. Return early in this case, to force the fallback to PIO.

Otherwise, the KASSERT that follows will be triggered, and the dump will
fail. On non-INVARIANTS kernels, the system will hang, waiting for a DMA
interrupt that will never arrive.

Reviewed by: kevans
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D31893

2 years agosctp: improve consistency when calling stream scheduler
Michael Tuexen [Mon, 20 Sep 2021 22:54:13 +0000 (00:54 +0200)]
sctp: improve consistency when calling stream scheduler

Hold always the stcb send lock when calling sctp_ss_init() and
sctp_ss_remove_from_stream().

MFC after: 1 week

2 years agomvneta: split to FDT and generic part
Wojciech Macek [Tue, 14 Sep 2021 07:11:15 +0000 (09:11 +0200)]
mvneta: split to FDT and generic part

Split some missing routines.

Obtained from: Semihalf

2 years agoendian.h: Use the __bswap* versions
Warner Losh [Tue, 21 Sep 2021 04:02:35 +0000 (22:02 -0600)]
endian.h: Use the __bswap* versions

Make it possible to have all these macros work without bswap* being
defined. bswap* is part of the application namespace and applications
are free to redefine those functions.

Reviewed by: emaste,jhb,markj
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D31964

2 years agocamcontrol: depop command
Warner Losh [Fri, 17 Sep 2021 22:30:06 +0000 (16:30 -0600)]
camcontrol: depop command

Implement and document the new depop command. This command manages drive elements
for drives that support it. Storage elements are typically heads. Element status
can be discovered. Elements may be removed or restored. And the status of any
current depop operation can be assessed.

depop -d elm will remove element elm and truncate available capacity.
depop -l will list the current drive elements and their current status.
depop -r elm will try to restore all retired elements and rebuild capacity.

Changing storage elements may reinitialize the drive. This operation will lose
data and may take hours to complete. Use the drive provided timeout for
operations by default.

Reviewed by: gbe (manpages)
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D29018

2 years agolibcam: Define depop structures and introduce scsi_wrap
Warner Losh [Fri, 17 Sep 2021 22:29:22 +0000 (16:29 -0600)]
libcam: Define depop structures and introduce scsi_wrap

Define structures related to the depop set of commands (GET PHYSICAL ELEMENT
STATUS, REMOVE ELEMENT AND TRUNCATE, and RESTORE ELEMENT AND REBUILD) as
well as the CDB construction routines.

Also create scsi_wrap.c. This will have convenience routines that will do all
the elements of allocating the ccb, generating the CDB, sending the command
(looping as necessary for cases where data is returned, but it's size isn't
known up front), etc. As this functionality is fleshed out, calling many
camcontrol commands programatically gets much easier.

Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D29017

2 years agoaio_fsync_vnode: handle ERELOOKUP after VOP_FSYNC()
Konstantin Belousov [Mon, 20 Sep 2021 09:32:28 +0000 (12:32 +0300)]
aio_fsync_vnode: handle ERELOOKUP after VOP_FSYNC()

Reported by: tmunro
Reviewed by: jhb, tmunro
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D32023

2 years agoaio_fsync_vnode: use for(;;) loop instead of label
Konstantin Belousov [Mon, 20 Sep 2021 09:30:54 +0000 (12:30 +0300)]
aio_fsync_vnode: use for(;;) loop instead of label

Reviewed by: jhb, tmunro
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D32023

2 years agovt: call driver's postswitch when panicking on ttyv0
Greg V [Sat, 24 Apr 2021 11:53:34 +0000 (14:53 +0300)]
vt: call driver's postswitch when panicking on ttyv0

In vt_kms, the postswitch callback restores fbdev mode when
panicking or entering the debugger. This ensures that even when
a graphical applicatino was running on the first tty, simple framebuffer
mode would be restored and the panic would be visible instead
of the frozen GUI. But vt wouldn't call the postswitch callback
when we're already on the first tty, so running a GUI on it
would prevent you from reading any panics.

Reviewed by: tsoome
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D29961

2 years agoopencrypto: Allow kern.crypto.allow_soft to be specified as a tunable
Mark Johnston [Mon, 20 Sep 2021 16:07:29 +0000 (12:07 -0400)]
opencrypto: Allow kern.crypto.allow_soft to be specified as a tunable

MFC after: 1 week
Sponsored by: The FreeBSD Foundation

2 years agommc: switch mmc_helper to device_ api
Bartlomiej Grzesik [Mon, 2 Aug 2021 14:27:23 +0000 (16:27 +0200)]
mmc: switch mmc_helper to device_ api

Add generic mmc_helper which uses newly introduced device_*_property
api. Thanks to this change the sd/mmc drivers will be capable
of parsing both DT and ACPI description.

Ensure backward compatibility for all mmc_fdt_helper users.

Reviewed by: manu, mw
Sponsored by: Semihalf
Differential revision: https://reviews.freebsd.org/D31598

2 years agodevice: add device_get_property and device_has_property
Bartlomiej Grzesik [Fri, 30 Jul 2021 08:57:06 +0000 (10:57 +0200)]
device: add device_get_property and device_has_property

Generialize bus specific property accessors. Those functions allow driver code
to access device specific information.

Currently there is only support for FDT and ACPI buses.

Reviewed by: manu, mw
Sponsored by: Semihalf
Differential revision: https://reviews.freebsd.org/D31597

2 years agoacpica: add ACPI_GET_PROPERTY to access Device Specific Data (DSD)
Bartlomiej Grzesik [Tue, 27 Jul 2021 12:39:31 +0000 (14:39 +0200)]
acpica: add ACPI_GET_PROPERTY to access Device Specific Data (DSD)

Add lazy acquiring of DSD package, which allows accessing Device
Specific Data.

Reviewed by: manu, mw
Sponsored by: Semihalf
Differential revision: https://reviews.freebsd.org/D31596

2 years agosctp: use a valid outstream when adding it to the scheduler
Michael Tuexen [Mon, 20 Sep 2021 13:52:10 +0000 (15:52 +0200)]
sctp: use a valid outstream when adding it to the scheduler

Without holding the stcb send lock, the outstreams might get
reallocated if the number of streams are increased.

Reported by: syzbot+4a5431d7caa666f2c19c@syzkaller.appspotmail.com
Reported by: syzbot+aa2e3b013a48870e193d@syzkaller.appspotmail.com
Reported by: syzbot+e4368c3bde07cd2fb29f@syzkaller.appspotmail.com
Reported by: syzbot+fe2f110e34811ea91690@syzkaller.appspotmail.com
Reported by: syzbot+ed6e8de942351d0309f4@syzkaller.appspotmail.com
MFC after: 1 week

2 years agoAdd ELF macros found in the aaelf64 spec
Andrew Turner [Mon, 20 Sep 2021 08:55:44 +0000 (08:55 +0000)]
Add ELF macros found in the aaelf64 spec

The arm64 aaelf64 spec [0] has DT_AARCH64_ that could be used with
dynamic linking. It also adds GNU_PROPERTY_AARCH64_FEATURE_1_AND used
to tell the kernel which CPU features the binary is compatible with,
but does not require to execute correctly.

Add these values so the kernel and elf tools can make use of them.

[0] https://github.com/ARM-software/abi-aa/blob/2021Q1/aaelf64/aaelf64.rst

Sponsored by: The FreeBSD Foundation

2 years agoif_mvneta: Build the driver as a kernel module
Hubert Mazur [Mon, 13 Sep 2021 09:44:31 +0000 (11:44 +0200)]
if_mvneta: Build the driver as a kernel module

Fix device detach and attach routine. Add required Makefile
to build as a module. Remove entry from GENERIC, since now
it can be loaded automatically.

Tested on EspressoBin.

Obtained from: Semihalf
Reviewed by: manu
Differential revision: https://reviews.freebsd.org/D31581

2 years agostress2: Update test to ensure propper cleanup of fifo files
Peter Holm [Mon, 20 Sep 2021 07:36:27 +0000 (07:36 +0000)]
stress2: Update test to ensure propper cleanup of fifo files

2 years agoUpdate leap-seconds to leap-seconds.3676924800.
Xin LI [Mon, 20 Sep 2021 05:26:22 +0000 (22:26 -0700)]
Update leap-seconds to leap-seconds.3676924800.

Obtained from: ftp://ftp.nist.gov/pub/time/leap-seconds.3676924800.
MFC after: 3 days

2 years agoThe linux rc.d script mounts several filesystems related to Linux ABI
Xin LI [Mon, 20 Sep 2021 05:25:23 +0000 (22:25 -0700)]
The linux rc.d script mounts several filesystems related to Linux ABI
compatibility layer.  When /compat is located on a ZFS other than /,
mount would fail because they were not mounted.

Solve this by moving `linux` to depend on `zfs` which mounts all ZFS
filesystems.

Differential Revision: https://reviews.freebsd.org/D31848
MFC after: 2 weeks

2 years ago[fib_algo][dxr] Merge adjacent empty range table chunks.
Marko Zec [Mon, 20 Sep 2021 04:30:45 +0000 (06:30 +0200)]
[fib_algo][dxr] Merge adjacent empty range table chunks.

MFC after: 3 days

2 years agostyle: Fix leading whitespace in bcache.c
Colin Percival [Sun, 19 Sep 2021 22:24:00 +0000 (15:24 -0700)]
style: Fix leading whitespace in bcache.c

MFC after: 2 weeks
X-MFC-with: Further bcache changes to come

2 years agovm_page_startup: correct calculation of the starting page
Konstantin Belousov [Fri, 17 Sep 2021 18:48:42 +0000 (21:48 +0300)]
vm_page_startup: correct calculation of the starting page

Also avoid unneded calculations when phys segment end is the phys_avail[]
start.

Submitted by: alc
Reviewed by: markj
MFC after: 1 week
Fixes: 181bfb42fd01bfa9f46
Differential revision: https://reviews.freebsd.org/D32009

2 years agociss(4): Fix typo.
Alexander Motin [Sun, 19 Sep 2021 18:01:40 +0000 (14:01 -0400)]
ciss(4): Fix typo.

2 years agociss(4): Properly handle data underrun.
Alexander Motin [Sun, 19 Sep 2021 17:45:51 +0000 (13:45 -0400)]
ciss(4): Properly handle data underrun.

For SCSI data underrun is a part of normal life.  It should not be
reported as error.  This fixes MODE SENSE used by modern CAM.

MFC after: 1 month

2 years agofreebsd32: Fix a double copyin in sendmsg() and recvmsg()
Mark Johnston [Sun, 19 Sep 2021 17:45:09 +0000 (13:45 -0400)]
freebsd32: Fix a double copyin in sendmsg() and recvmsg()

freebsd32_sendmsg() and freebsd32_recvmsg() both copyin the message
header twice, once directly and once in freebsd32_copyinmsghdr().  The
iovec length from the former is used when copying in msg_iov, but the
rest of the kernel uses the iovec length from the latter.  When
kern_sendit() and kern_recvit() iterate over the iovec to compute the
residual for I/O, they can therefore end up walking past the end of the
copied in iovec, either resulting in a system call error, userspace
memory corruption from uiomove() with invalid iovecs, or a kernel page
fault if the copied-in iovec is followed by an unmapped KVA region.

Reported by: syzbot+7cc64cd0c49605acd421@syzkaller.appspotmail.com
Reviewed by: kib, emaste
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D32010

2 years agofreebsd32: Provide an ANSI definition for freebsd32_recvmsg()
Mark Johnston [Sun, 19 Sep 2021 17:41:43 +0000 (13:41 -0400)]
freebsd32: Provide an ANSI definition for freebsd32_recvmsg()

Fix style in the freebsd32_sendmsg() definition.

MFC after: 1 week
Sponsored by: The FreeBSD Foundation

2 years agols(1): Allow LSCOLORS to specify an underline
Cameron Katri [Sun, 19 Sep 2021 11:36:41 +0000 (13:36 +0200)]
ls(1): Allow LSCOLORS to specify an underline

Allows capitalizing the background color character to enable an
underline instead of bold, capitalizing the foreground color char will
still do bold.

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

2 years agofstyp: bump WARNS to default and work around warnings
Piotr Pawel Stefaniak [Tue, 17 Aug 2021 15:46:08 +0000 (17:46 +0200)]
fstyp: bump WARNS to default and work around warnings

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

2 years agosh: improve command completion
Piotr Pawel Stefaniak [Sat, 18 Sep 2021 11:26:51 +0000 (13:26 +0200)]
sh: improve command completion

When multiple matches are found, we keep the provided string on the
input line and print unique matches as suggestions.

But the multiple matches might be the same command found in different
directories, so we should deduplicate the matches first and then decide
whether to autocomplete the command or not, based on the number of
unique matches.

2 years agosctp: fix FCFS stream scheduler
Michael Tuexen [Sun, 19 Sep 2021 09:56:26 +0000 (11:56 +0200)]
sctp: fix FCFS stream scheduler

Reported by: syzbot+c6793f0f0ce698bce230@syzkaller.appspotmail.com
MFC after: 1 week

2 years agoEliminate snaplk / bufwait LOR when creating UFS snapshots
Kirk McKusick [Sat, 18 Sep 2021 23:51:07 +0000 (16:51 -0700)]
Eliminate snaplk / bufwait LOR when creating UFS snapshots

Each vnode has an embedded lock that controls access to its contents.
However vnodes describing a UFS snapshot all share a single snapshot
lock to coordinate their access and update. As part of creating a
new UFS snapshot, it has to have its individual vnode lock replaced
with the filesystem's snapshot lock.

The lock order for regular vnodes with respect to buffer locks is that
they must first acquire the vnode lock, then a buffer lock. The order
for the snapshot lock is reversed: a buffer lock must be acquired before
the snapshot lock.

When creating a new snapshot, the snapshot file must retain its vnode
lock until it has allocated all the blocks that it needs before
switching to the snapshot lock. This update moves one final piece of
the initial snapshot block allocation so that it is done before the
newly created snapshot is switched to use the snapshot lock.

Reported by:  Witness code
MFC after:    1 week
Sponsored by: Netflix

2 years agonfscl: Use vfs.nfs.maxalloclen to limit Deallocate RPC RTT
Rick Macklem [Sat, 18 Sep 2021 21:38:43 +0000 (14:38 -0700)]
nfscl: Use vfs.nfs.maxalloclen to limit Deallocate RPC RTT

Unlike Copy, the NFSv4.2 Allocate and Deallocate operations do not
allow a reply with partial completion.  As such, the only way to
limit the time the operation takes to provide a reasonable RPC RTT
is to limit the size of the allocation/deallocation in the NFSv4.2
client.

This patch uses the sysctl vfs.nfs.maxalloclen to set
the limit on the size of the Deallocate operation.
There is no way to know how long a server will take to do an
deallocate operation, but 64Mbytes results in a reasonable
RPC RTT for the slow hardware I test on.

For an 8Gbyte deallocation, the elapsed time for doing it in 64Mbyte
chunks was the same (within margin of variability) as the
elapsed time taken for a single large deallocation
operation for a FreeBSD server with a UFS file system.

2 years agovfs: add missing VIRF_MOUNTPOINT in vfs_mountroot_shuffle
Mateusz Guzik [Sat, 18 Sep 2021 08:13:33 +0000 (10:13 +0200)]
vfs: add missing VIRF_MOUNTPOINT in vfs_mountroot_shuffle

Reported by: mav

2 years agovfs: add the missing vnode interlock in vfs_mountroot_shuffle
Mateusz Guzik [Sat, 18 Sep 2021 08:12:27 +0000 (10:12 +0200)]
vfs: add the missing vnode interlock in vfs_mountroot_shuffle

Around v_mountedhere assignment.

2 years agounix: Fix a use-after-free in unp_drop()
Mark Johnston [Sat, 18 Sep 2021 14:38:39 +0000 (10:38 -0400)]
unix: Fix a use-after-free in unp_drop()

We need to load the socket pointer after locking the PCB, otherwise
the socket may have been detached and freed by the time that unp_drop()
sets so_error.

This previously went unnoticed as the socket zone was _NOFREE.

Reported by: pho
MFC after: 1 week

2 years agopf: always log nat rule and do it pre-rewrite
Franco Fichtner [Sat, 18 Sep 2021 11:42:43 +0000 (13:42 +0200)]
pf: always log nat rule and do it pre-rewrite

See also https://github.com/opnsense/core/issues/5005

Reviewed by: kp
Differential Revision: https://reviews.freebsd.org/D31504

2 years agolockmgr: fix lock profiling of face adaptive spinning
Mateusz Guzik [Sat, 11 Sep 2021 18:23:51 +0000 (18:23 +0000)]
lockmgr: fix lock profiling of face adaptive spinning

2 years agocache: count vnodes in cache_purgevfs
Mateusz Guzik [Sat, 18 Sep 2021 08:30:15 +0000 (10:30 +0200)]
cache: count vnodes in cache_purgevfs