]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
3 years agosyslogd: Stop trying to send remote messages through special sockets
bdrewery [Sat, 7 Nov 2020 17:18:44 +0000 (17:18 +0000)]
syslogd: Stop trying to send remote messages through special sockets

Specifically this was causing the /dev/klog fd and the signal pipe
handling fd to get a sendmsg(2) called on them and always returned
[ENOTSOCK].

r310350 combined these sockets into the main socket list and properly
skipped AF_UNSPEC at the sendmsg(2) call but later in r344739 it was
broken such that these special sockets were no longer excluded since
the AF_UNSPEC check specifically excluded these special sockets. Only
these special sockets have sl_sa = NULL. The sl_family checks should
be redundant now but are left in case of future changes so the intent
is clearer.

MFC after: 2 weeks

3 years agozfs: remove 2 assertions that teardown lock is not held
mjg [Sat, 7 Nov 2020 16:58:38 +0000 (16:58 +0000)]
zfs: remove 2 assertions that teardown lock is not held

They are not very useful and hard to implement with rms.

This has a side effect of simplying the code.

3 years agorms: several cleanups + debug read lockers handling
mjg [Sat, 7 Nov 2020 16:57:53 +0000 (16:57 +0000)]
rms: several cleanups + debug read lockers handling

This adds a dedicated counter updated with atomics when INVARIANTS
is used. As a side effect one can reliably determine the lock is held
for reading by at least one thread, but it's still not possible to
find out whether curthread has the lock in said mode.

This should be good enough in practice.

Problem spotted by avg.

3 years agoimgact_binmisc: reorder members of struct imgact_binmisc_entry (NFC)
kevans [Sat, 7 Nov 2020 16:41:59 +0000 (16:41 +0000)]
imgact_binmisc: reorder members of struct imgact_binmisc_entry (NFC)

This doesn't change anything at the moment since the out-of-order elements
were a pair of uint32_t, but future additions may have caused unnecessary
padding by following the existing precedent.

MFC after: 1 week

3 years agovt: resolve conflict between VT_ALT_TO_ESC_HACK and DBG
kevans [Sat, 7 Nov 2020 15:38:01 +0000 (15:38 +0000)]
vt: resolve conflict between VT_ALT_TO_ESC_HACK and DBG

When using the ALT+CTRL+ESC sequence to break into kdb, the keyboard is
completely borked when you return. watch(8) shows that it's working, but
it's inserting escape sequences.

Further investigation revealed that VT_ALT_TO_ESC_HACK is the default and
directly conflicts with this sequence, so upon return from the debugger
ALKED is set.

If they triggered the break to debugger, it's safe to assume they didn't
mean to use VT_ALT_TO_ESC_HACK, so just unset it to reduce the surprise when
the keyboard seems non-functional upon return.

Reviewed by: tsoome
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D27109

3 years agoAdd a method to determine whether given interrupt is per CPU or not.
mmel [Sat, 7 Nov 2020 14:58:01 +0000 (14:58 +0000)]
Add a method to determine whether given interrupt is per CPU or not.

MFC after: 2 weeks

3 years agoMove TDB_USERWR check under 'if (traced)'.
trasz [Sat, 7 Nov 2020 13:09:51 +0000 (13:09 +0000)]
Move TDB_USERWR check under 'if (traced)'.

If we hadn't been traced in the first place when syscallenter()
started executing, we can ignore TDB_USERWR.  TDB_USERWR can get set,
sure, but if it does, it's because the debugger raced with the syscall,
and it cannot depend on winning that race.

Reviewed by: kib
MFC after: 2 weeks
Sponsored by: EPSRC
Differential Revision: https://reviews.freebsd.org/D26585

3 years agoimgact_binmisc: abstract away the list lock (NFC)
kevans [Sat, 7 Nov 2020 05:10:46 +0000 (05:10 +0000)]
imgact_binmisc: abstract away the list lock (NFC)

This module handles relatively few execs (initial qemu-user-static, then
qemu-user-static handles exec'ing itself for binaries it's already running),
but all execs pay the price of at least taking the relatively expensive
sx/slock to check for a match when this module is loaded. Future work will
almost certainly swap this out for another lock, perhaps an rmslock.

The RLOCK/WLOCK phrasing was chosen based on what the callers are really
wanting, rather than using the verbiage typically appropriate for an sx.

MFC after: 1 week

3 years agoAdd a periodic script to backup output generated from `gmirror list`.
rew [Sat, 7 Nov 2020 04:15:24 +0000 (04:15 +0000)]
Add a periodic script to backup output generated from `gmirror list`.

Disabled by default.

PR:             86388
Submitted by:   Miroslav Lachman <000.fbsd@quip.cz>
Reviewed by:    allanjude, gbe
Approved by:    allanjude (mentor)
MFC after:      4 weeks
Event:          July 2020 Bugathon
Differential Revision:  https://reviews.freebsd.org/D25631

3 years agoimgact_binmisc: validate flags coming from userland
kevans [Sat, 7 Nov 2020 04:10:23 +0000 (04:10 +0000)]
imgact_binmisc: validate flags coming from userland

We may want to reserve bits in the future for kernel-only use, so start
rejecting any that aren't the two that we're currently expecting from
userland.

MFC after: 1 week

3 years agobinmiscctl(8): miscellaneous cleanup
kevans [Sat, 7 Nov 2020 03:43:45 +0000 (03:43 +0000)]
binmiscctl(8): miscellaneous cleanup

- Bad whitespace in Makefile.
- Reordered headers, sys/ first.
- Annotated fatal/usage __dead2 to help `make analyze` out a little bit.
- Spell a couple of sizeof constructs as "nitems" and "howmany" instead.

MFC after: 1 week

3 years agoepoch: support non-preemptible epochs checking in_epoch()
kevans [Sat, 7 Nov 2020 03:29:04 +0000 (03:29 +0000)]
epoch: support non-preemptible epochs checking in_epoch()

Previously, non-preemptible epochs could not check; in_epoch() would always
fail, usually because non-preemptible epochs don't imply THREAD_NO_SLEEPING.

For default epochs, it's easy enough to verify that we're in the given
epoch: if we're in a critical section and our record for the given epoch
is active, then we're in it.

This patch also adds some additional INVARIANTS bookkeeping. Notably, we set
and check the recorded thread in epoch_enter/epoch_exit to try and catch
some edge-cases for the caller. It also checks upon freeing that none of the
records had a thread in the epoch, which may make it a little easier to
diagnose some improper use if epoch_free() took place while some other
thread was inside.

This version differs slightly from what was just previously reviewed by the
below-listed, in that in_epoch() will assert that no CPU has this thread
recorded even if it *is* currently in a critical section. This is intended
to catch cases where the caller might have somehow messed up critical
section nesting, we can catch both if they exited the critical section or if
they exited, migrated, then re-entered (on the wrong CPU).

Reviewed by: kib, markj (both previous version)
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D27098

3 years agoimgact_binmisc: minor re-organization of imgact_binmisc_exec exits
kevans [Sat, 7 Nov 2020 03:28:32 +0000 (03:28 +0000)]
imgact_binmisc: minor re-organization of imgact_binmisc_exec exits

Notably, streamline error paths through the existing 'done' label, making it
easier to quickly verify correct cleanup.

Future work might add a kernel-only flag to indicate that a interpreter uses
#a. Currently, all executions via imgact_binmisc pay the penalty of
constructing sname/fname, even if they will not use it. qemu-user-static
doesn't need it, the stock rc script for qemu-user-static certainly doesn't
use it, and I suspect these are the vast majority of (if not the only)
current users.

MFC after: 1 week

3 years agomalloc: tweak the version check in r367432 to include type name
mjg [Sat, 7 Nov 2020 01:32:16 +0000 (01:32 +0000)]
malloc: tweak the version check in r367432 to include type name

While here fix a whitespace problem.

3 years agoUpdate copies of ioctl structures to match recent changes in head.
jhb [Fri, 6 Nov 2020 23:37:59 +0000 (23:37 +0000)]
Update copies of ioctl structures to match recent changes in head.

- Update for C99 types and void pointers.
- Update example algorithms to not use removed algorithms.

3 years agoAdd a periodic script to backup output generated from `zfs list`, `zfs get`,
rew [Fri, 6 Nov 2020 22:58:31 +0000 (22:58 +0000)]
Add a periodic script to backup output generated from `zfs list`, `zfs get`,
`zpool list`, and `zpool get` commands.

Disabled by default.

PR:             86388
Submitted by:   Miroslav Lachman <000.fbsd@quip.cz>
Reviewed by:    allanjude, 0mp
Approved by:    allanjude (mentor)
MFC after:      4 weeks
Event:          July 2020 Bugathon
Differential Revision:  https://reviews.freebsd.org/D25638

3 years agousb_hub: giving up port reset - device vanished
bz [Fri, 6 Nov 2020 22:40:00 +0000 (22:40 +0000)]
usb_hub: giving up port reset - device vanished

Improve the output of the recently often experienced debug message in order
to gather further data.

PR: 237666
Reviewed by: hselasky
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D27108

3 years agofix up docs, if signature checking is enabled, the file MUST exist...
jmg [Fri, 6 Nov 2020 22:11:05 +0000 (22:11 +0000)]
fix up docs, if signature checking is enabled, the file MUST exist...

3 years agolinux(4): Fix loadable modules after r367395
cem [Fri, 6 Nov 2020 22:04:57 +0000 (22:04 +0000)]
linux(4): Fix loadable modules after r367395

Move dtrace SDT definitions into linux_common module code.  Also, build
linux_dummy.c into the linux_common kld -- we don't need separate
versions of these stubs for 32- and 64-bit emulation.

Reported by: several
PR: 250897
Discussed with: emaste, trasz
Tested by: John Kennedy, Yasuhiro KIMURA, Oleg Sidorkin
X-MFC-With: r367395
Differential Revision: https://reviews.freebsd.org/D27124

3 years agomalloc: move malloc_type_internal into malloc_type
mjg [Fri, 6 Nov 2020 21:33:59 +0000 (21:33 +0000)]
malloc: move malloc_type_internal into malloc_type

According to code comments the original motivation was to allow for
malloc_type_internal changes without ABI breakage. This can be trivially
accomplished by providing spare fields and versioning the struct, as
implemented in the patch below.

The upshots are one less memory indirection on each alloc and disappearance
of mt_zone.

Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D27104

3 years agoefifb: vt_generate_cons_palette() takes max color, not mask
tsoome [Fri, 6 Nov 2020 21:27:54 +0000 (21:27 +0000)]
efifb: vt_generate_cons_palette() takes max color, not mask

vt_generate_cons_palette() does take max values of RGB component colours, not
mask. Also we need to set info->fb_cmsize, or vt_fb_init() will re-initialize
the info->fb_cmap.

3 years agoMake powerpc use MAXARGS (defined as 8) instead of hardcoding '10'.
trasz [Fri, 6 Nov 2020 19:27:27 +0000 (19:27 +0000)]
Make powerpc use MAXARGS (defined as 8) instead of hardcoding '10'.
This brings its 'struct syscall_args' in sync with other architectures.

Reviewed by: bdragon, jhibbits
MFC after: 2 weeks
Sponsored by: EPSRC
Differential Revision: https://reviews.freebsd.org/D26605

3 years agoRemove 'struct trapframe' pointer from mips64's 'struct syscall_args'.
trasz [Fri, 6 Nov 2020 19:19:51 +0000 (19:19 +0000)]
Remove 'struct trapframe' pointer from mips64's 'struct syscall_args'.
While here, use MAXARGS.  This brings its 'struct syscall_args' in sync
with most other architectures.

Reviewed by: arichardson, brooks
MFC after: 2 weeks
Sponsored by: EPSRC
Differential Revision: https://reviews.freebsd.org/D26619

3 years agocxgbe(4): Update firmwares to 1.25.0.40.
np [Fri, 6 Nov 2020 19:04:20 +0000 (19:04 +0000)]
cxgbe(4):  Update firmwares to 1.25.0.40.

This fixes a potential crash in firmware 1.25.0.0 on the passive open
side during TOE operation.

Obtained from: Chelsio Communications
MFC after: 1 week
Sponsored by: Chelsio Communications

3 years agoFix powerpc and LINT builds
luporl [Fri, 6 Nov 2020 18:50:00 +0000 (18:50 +0000)]
Fix powerpc and LINT builds

Fix build errors introduced by r367417 and r367390:

- Guard label reached only by powerpc64
- Guard vm_reserv_level_iffullpop call, that is not defined on powerpc
  variants that don't support superpages
- Add missing hwpmc file, for when hwpmc is built into kernel

3 years agoUse void * in place of caddr_t.
jhb [Fri, 6 Nov 2020 18:09:52 +0000 (18:09 +0000)]
Use void * in place of caddr_t.

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

3 years agoGroup session management routines together before first use.
jhb [Fri, 6 Nov 2020 18:05:29 +0000 (18:05 +0000)]
Group session management routines together before first use.

- Rename cse*() to cse_*() to more closely match other local APIs in
  this file.

- Merge the old csecreate() into cryptodev_create_session() and rename
  the new function to cse_create().

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

3 years agoAdd support for the new mountd -R option.
rmacklem [Fri, 6 Nov 2020 16:33:42 +0000 (16:33 +0000)]
Add support for the new mountd -R option.

r376026 added a new "-R" option to mountd, which tells it to
not support the Mount protocol (not used by NFSv4) and not
register with rpcbind.
Rpcbind is considered a security issue by some sites now.

This patch adds a new yes/no variable called nfsv4_server_only.
When that is set, make vfs.nfsd.server_min_vers=4 and set "=R"
for mountd.
Setting vfs.nfsd.server_min_vers=4 tells nfsd to not register with rpcbind.
While here, add a check for "load_kld nfsd" failing to nfsd.

Reviewed by: 0mp
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D26938

3 years agoAdd firmware modules for qat(4), take two
markj [Fri, 6 Nov 2020 16:12:06 +0000 (16:12 +0000)]
Add firmware modules for qat(4), take two

My script to convert git commits to svn patch does not handle binary
files correctly, and r367387 committed a set of empty files as a result.

MFC with: r367387
Sponsored by: Rubicon Communications, LLC (Netgate)

3 years agoUse Cm macros instead of Ar when referring to a specific memory disk type
0mp [Fri, 6 Nov 2020 15:55:13 +0000 (15:55 +0000)]
Use Cm macros instead of Ar when referring to a specific memory disk type

MFC after: 3 days

3 years agoFix a typo and remove Xr's to vn(4) and vnconfig(4)
0mp [Fri, 6 Nov 2020 15:38:51 +0000 (15:38 +0000)]
Fix a typo and remove Xr's to vn(4) and vnconfig(4)

"mandoc -Tlint" complained about the Xr to vnconfig, which was removed in
r238202.  I am not sure but maybe it's time to do the same to vn(4).

MFC after: 2 weeks

3 years agopkgbase: Remove %VCS_REVISION% from utilities comments
manu [Fri, 6 Nov 2020 15:21:53 +0000 (15:21 +0000)]
pkgbase: Remove %VCS_REVISION% from utilities comments

We don't do that on other packages so be consistent.
It also don't work when building from git.

3 years agoImplement superpages for PowerPC64 (HPT)
luporl [Fri, 6 Nov 2020 14:12:45 +0000 (14:12 +0000)]
Implement superpages for PowerPC64 (HPT)

This change adds support for transparent superpages for PowerPC64
systems using Hashed Page Tables (HPT). All pmap operations are
supported.

The changes were inspired by RISC-V implementation of superpages,
by @markj (r344106), but heavily adapted to fit PPC64 HPT architecture
and existing MMU OEA64 code.

While these changes are not better tested, superpages support is disabled by
default. To enable it, use vm.pmap.superpages_enabled=1.

In this initial implementation, when superpages are disabled, system
performance stays at the same level as without these changes. When
superpages are enabled, buildworld time increases a bit (~2%). However,
for workloads that put a heavy pressure on the TLB the performance boost
is much bigger (see HPC Challenge and pgbench on D25237).

Reviewed by: jhibbits
Sponsored by: Eldorado Research Institute (eldorado.org.br)
Differential Revision: https://reviews.freebsd.org/D25237

3 years ago[POWERPC] Floating-Point Exception trap support
alfredo [Fri, 6 Nov 2020 13:34:30 +0000 (13:34 +0000)]
[POWERPC] Floating-Point Exception trap support

Add support for Floating-Point Exception traps on 32 and 64 bit platforms.
Also make sure to clean FPSCR on EXEC and thread exit

Author of initial version: Renato Riolino <renato.riolino@eldorad.org.br>

Reviewed by: jhibbits
Sponsored by: Eldorado Research Institute (eldorado.org.br)
Differential Revision: https://reviews.freebsd.org/D23623

3 years agoMove cryptof_ioctl() below the routines it calls.
jhb [Fri, 6 Nov 2020 00:15:52 +0000 (00:15 +0000)]
Move cryptof_ioctl() below the routines it calls.

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

3 years agoSplit logic to create new sessions into a separate function.
jhb [Fri, 6 Nov 2020 00:10:58 +0000 (00:10 +0000)]
Split logic to create new sessions into a separate function.

This simplifies cryptof_ioctl as it now a wrapper around functions that
contain the bulk of the per-ioctl logic.

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

3 years agoMove cryptodev_cb earlier before it is used.
jhb [Thu, 5 Nov 2020 23:42:36 +0000 (23:42 +0000)]
Move cryptodev_cb earlier before it is used.

This is consistent with cryptodevkey_cb being defined before it is used
and removes a prototype in the middle of the file.

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

3 years agoCheck cipher key lengths during probesession.
jhb [Thu, 5 Nov 2020 23:31:58 +0000 (23:31 +0000)]
Check cipher key lengths during probesession.

OCF drivers in general should perform as many session parameter checks
as possible during probesession rather than when creating a new
session.  I got this wrong for aesni(4) in r359374.  In addition,
aesni(4) was performing the check for digest-only requests and failing
to create digest-only sessions as a result.

Reported by: jkim
Tested by: jkim
Sponsored by: Chelsio Communications

3 years agoStyle fixes for function prototypes and definitions.
jhb [Thu, 5 Nov 2020 23:28:05 +0000 (23:28 +0000)]
Style fixes for function prototypes and definitions.

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

3 years agoDon't modify the destination pointer in ioctl requests.
jhb [Thu, 5 Nov 2020 23:26:02 +0000 (23:26 +0000)]
Don't modify the destination pointer in ioctl requests.

This breaks the case where the original pointer was NULL but an
in-line IV was used.

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

3 years agonvme: change namei_request_zone into a malloc type
mjg [Thu, 5 Nov 2020 21:44:58 +0000 (21:44 +0000)]
nvme: change namei_request_zone into a malloc type

Both the size (128 bytes) and ephemeral nature of allocations make it a great
fit for malloc.

A dedicated zone unnecessarily avoids sharing buckets with 128-byte objects.

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

3 years agosnmpmod(3): fix typo under the COMMUNITIES section
ngie [Thu, 5 Nov 2020 21:37:24 +0000 (21:37 +0000)]
snmpmod(3): fix typo under the COMMUNITIES section

"recipte" should be spelled like "receipt".

.Dd is intentionally not being bumped for the change.

MFC after: 1 week
Sponsored by: DellEMC

3 years agoSuspend all writeable local filesystems on power suspend.
kib [Thu, 5 Nov 2020 20:52:49 +0000 (20:52 +0000)]
Suspend all writeable local filesystems on power suspend.

This ensures that no writes are pending in memory, either metadata or
user data, but not including dirty pages not yet converted to fs writes.

Only filesystems declared local are suspended.

Note that this does not guarantee absence of the metadata errors or
leaks if resume is not done: for instance, on UFS unlinked but opened
inodes are leaked and require fsck to gc.

Reviewed by: markj
Discussed with: imp
Tested by: imp (previous version), pho
Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks
Differential revision: https://reviews.freebsd.org/D27054

3 years agoFix powerpc and powerpcspe builds
luporl [Thu, 5 Nov 2020 20:18:00 +0000 (20:18 +0000)]
Fix powerpc and powerpcspe builds

This change fixes 32-bit PowerPC builds, that r367390 broke
(shift count >= width of type).

3 years agolinux(4): Deduplicate unimpl/dummy syscall handlers
cem [Thu, 5 Nov 2020 19:30:31 +0000 (19:30 +0000)]
linux(4): Deduplicate unimpl/dummy syscall handlers

No functional change.

Reviewed by: emaste, trasz
Differential Revision: https://reviews.freebsd.org/D27099

3 years agoRemove the 'nap' field from ARM's 'struct syscall_args', to bring it
trasz [Thu, 5 Nov 2020 18:10:03 +0000 (18:10 +0000)]
Remove the 'nap' field from ARM's 'struct syscall_args', to bring it
in sync with (most) other architectures.  No functional changes.

Reviewed by: manu
Tested by: mmel
MFC after: 2 weeks
Sponsored by: EPSRC
Differential Revision: https://reviews.freebsd.org/D26604

3 years agoVirtIO: Make sure the guest knows the TRIM alignment requirements
allanjude [Thu, 5 Nov 2020 17:10:14 +0000 (17:10 +0000)]
VirtIO: Make sure the guest knows the TRIM alignment requirements

If bhyve is used to emulate 512e access in guest OS, then discard addresses should be properly aligned.
Otherwise ioctl DIOCGDELETE fails for 512b requires on devices with 4K sector size.
see g_dev_ioctl() in sys/geom/geom_dev.c

Submitted by: Vitaliy Gusev <gusev.vitaliy@gmail.com>
MFC after: 1 week
Sponsored by: vStack.com
Differential Revision: https://reviews.freebsd.org/D27075

3 years agopmcstat: fix PPC kernel symbol resolution
luporl [Thu, 5 Nov 2020 16:47:23 +0000 (16:47 +0000)]
pmcstat: fix PPC kernel symbol resolution

PowerPC kernel is of DYN type and it has a base address where it is
initially loaded, before being relocated. As the start address passed to
pmcstat_image_link() is where the kernel was relocated to, but the symbols
always use the original base address, we need to subtract it to get the
correct offset.

Reviewed by: jhibbits
Sponsored by: Eldorado Research Institute (eldorado.org.br)
Differential Revision: https://reviews.freebsd.org/D26114

3 years agolibpmc: add support for POWER8/9 PMCs
luporl [Thu, 5 Nov 2020 16:41:28 +0000 (16:41 +0000)]
libpmc: add support for POWER8/9 PMCs

This change adds support for POWER8/9 performance counters.

Reviewed by: jhibbits
Sponsored by: Eldorado Research Institute (eldorado.org.br)
Differential Revision: https://reviews.freebsd.org/D26113

3 years ago[PowerPC] hwpmc: add support for POWER8/9 PMCs
luporl [Thu, 5 Nov 2020 16:36:39 +0000 (16:36 +0000)]
[PowerPC] hwpmc: add support for POWER8/9 PMCs

This change adds support for POWER8 and POWER9 PMCs (bare metal and
pseries).
All PowerISA 2.07B non-random events are supported.

Implementation was based on that of PPC970.

Reviewed by: jhibbits
Sponsored by: Eldorado Research Institute (eldorado.org.br)
Differential Revision: https://reviews.freebsd.org/D26110

3 years agomalloc: add a helper returning size allocated for given request
mjg [Thu, 5 Nov 2020 16:21:21 +0000 (16:21 +0000)]
malloc: add a helper returning size allocated for given request

Sample usage: kernel modules can decide whether to stick to malloc or
create their own zone.

Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D27097

3 years agocryptotest: Add qat(4) coverage
markj [Thu, 5 Nov 2020 16:00:57 +0000 (16:00 +0000)]
cryptotest: Add qat(4) coverage

MFC after: 3 days
Sponsored by: Rubicon Communications, LLC (Netgate)

3 years agoAdd firmware modules for qat(4)
markj [Thu, 5 Nov 2020 16:00:30 +0000 (16:00 +0000)]
Add firmware modules for qat(4)

MFC after: 3 days
Sponsored by: Rubicon Communications, LLC (Netgate)

3 years agoAdd qat(4)
markj [Thu, 5 Nov 2020 15:55:23 +0000 (15:55 +0000)]
Add qat(4)

This provides an OpenCrypto driver for Intel QuickAssist devices.  The
driver was initially ported from NetBSD and comes with a few
improvements:
- support for GMAC/AES-GCM, AES-CTR and AES-XTS, and support for
  SHA/HMAC-authenticated encryption
- support for detaching the driver
- various bug fixes
- DH895X support

Discussed with: jhb
MFC after: 3 days
Sponsored by: Rubicon Communications, LLC (Netgate)
Differential Revision: https://reviews.freebsd.org/D26963

3 years agoRationalize per-cpu zones.
mjg [Thu, 5 Nov 2020 15:08:56 +0000 (15:08 +0000)]
Rationalize per-cpu zones.

The 2 provided zones had inconsistent naming between each other
("int" and "64") and other allocator zones (which use bytes).

Follow malloc by naming them "pcpu-" + size in bytes.

This is a step towards replacing ad-hoc per-cpu zones with
general slabs.

3 years ago[PowerPC] Make PPC 970 PMC SPRs the standard ones
luporl [Thu, 5 Nov 2020 14:15:50 +0000 (14:15 +0000)]
[PowerPC] Make PPC 970 PMC SPRs the standard ones

And add a _74XX suffix to 74XX SPRs.

This is a preparation for adding support to POWER8/9 PMCs, which have most
SPRs equal to 970 ones.

Reviewed by: jhibbits
Sponsored by: Eldorado Research Institute (eldorado.org.br)
Differential Revision: https://reviews.freebsd.org/D26532

3 years agopoll/select: change selfd_zone into a malloc type
mjg [Thu, 5 Nov 2020 12:24:37 +0000 (12:24 +0000)]
poll/select: change selfd_zone into a malloc type

On a sample box vmstat -z shows:

ITEM                   SIZE  LIMIT     USED     FREE      REQ
64:                      64,      0, 10437844367538,3698187229
selfd:                   64,      0,    1520,   13726,182729008

But at the same time:
vm.uma.selfd.keg.domain.1.pages: 121
vm.uma.selfd.keg.domain.0.pages: 121

Thus 242 pages got pulled even though the malloc zone would likely accomodate
the load without using extra memory.

3 years agovfs: change nt_zone into a malloc type
mjg [Thu, 5 Nov 2020 12:06:50 +0000 (12:06 +0000)]
vfs: change nt_zone into a malloc type

Elements are small in size and allocated for short periods.

3 years agotmpfs: reorder struct tmpfs_node to shrink it by 8 bytes
mjg [Thu, 5 Nov 2020 11:24:45 +0000 (11:24 +0000)]
tmpfs: reorder struct tmpfs_node to shrink it by 8 bytes

The reduction (232 -> 224 bytes) allows UMA to fit one more item (17 -> 18)
per slab as reported in vm.uma.TMPFS_node.keg.ipers.

3 years agoStop trying to bounce in memory allocated by bus dma
andrew [Thu, 5 Nov 2020 09:55:55 +0000 (09:55 +0000)]
Stop trying to bounce in memory allocated by bus dma

Memory allocated by bus_dmamem_alloc will take into account any alignment
requirements of the CPU it's running on. Stop trying to bounce in this case
as there is no bounce zone allocated.

Reported by: manu, tuexen
Tested by: manu
Sponsored by: Innovate UK

3 years agoRestrict locale settings to the file they occur in
se [Thu, 5 Nov 2020 08:58:21 +0000 (08:58 +0000)]
Restrict locale settings to the file they occur in

This prevents LANG= in an included file from affecting the interpretation
of month and day names in the including file.

Make the internal pre-processor accept white space between the "#" at
the start of the line and the keyword for better compatibility with cpp.

Add support for the cpp keywords #warning and #error.

MFC after: 3 days

3 years agoAdd sbuf streaming mode to pseudofs(9), use in linprocfs(5)
cem [Thu, 5 Nov 2020 06:48:51 +0000 (06:48 +0000)]
Add sbuf streaming mode to pseudofs(9), use in linprocfs(5)

Add a pseudofs node flag 'PFS_AUTODRAIN', which automatically emits sbuf
contents to the caller when the sbuf buffer fills.  This is only
permissible if the corresponding PFS node fill function can sleep
whenever it appends to the sbuf.

linprocfs' /proc/self/maps node happens to meet this requirement.
Streaming out the file as it is composed avoids truncating the output
and also avoids preallocating a very large buffer.

Reviewed by: markj; earlier version: emaste, kib, trasz
Differential Revision: https://reviews.freebsd.org/D27047

3 years agoimgact_binmisc: fix up some minor nits
kevans [Thu, 5 Nov 2020 04:19:48 +0000 (04:19 +0000)]
imgact_binmisc: fix up some minor nits

- Removed a bunch of redundant headers
- Don't explicitly initialize to 0
- The !error check prior to setting imgp->interpreter_name is redundant, all
  error paths should and do return or go to 'done'. We have larger problems
  otherwise.

3 years agozfs: lz4: add optional kmem_alloc support
mjg [Thu, 5 Nov 2020 03:25:23 +0000 (03:25 +0000)]
zfs: lz4: add optional kmem_alloc support

lz4 port from illumos to Linux added a 16KB per-CPU cache to accommodate for
the missing 16KB malloc. FreeBSD supports this size, making the extra cache
harmful as it can't share buckets.

3 years agofd: make all f_count uses go through refcount_*
mjg [Thu, 5 Nov 2020 02:12:33 +0000 (02:12 +0000)]
fd: make all f_count uses go through refcount_*

3 years agofd: hide _fdrop 0 count check behind INVARIANTS
mjg [Thu, 5 Nov 2020 02:12:08 +0000 (02:12 +0000)]
fd: hide _fdrop 0 count check behind INVARIANTS

While here use refcount_load and make sure to report the tested value.

3 years agoriscv: set kernel_pmap hart mask more precisely
mhorne [Thu, 5 Nov 2020 00:52:52 +0000 (00:52 +0000)]
riscv: set kernel_pmap hart mask more precisely

In pmap_bootstrap(), we fill kernel_pmap->pm_active since it is
invariably active on all harts. However, this marks it as active even
for harts that don't exist in the system, which can cause issue when the
mask is passed to the SBI firmware via sbi_remote_sfence_vma().
Specifically, the SBI spec allows SBI_ERR_INVALID_PARAM to be returned
when an invalid hart is set in the mask.

The latest version of OpenSBI does not have this issue, but v0.6 does,
and this is triggering a recently added KASSERT in CI. Switch to only
setting bits in pm_active for harts that enter the system.

Reported by: Jenkins
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D27080

3 years agoFix UMA alignment for COP2 context structure.
jhibbits [Wed, 4 Nov 2020 23:29:27 +0000 (23:29 +0000)]
Fix UMA alignment for COP2 context structure.

UMA alignment needs specified as (power-of-2) - 1, not power-of-2.

Discussed with: gonzo
MFC after: 3 days

3 years agofix the docs, this was always wrong... In some cases, DISTDIR is set
jmg [Wed, 4 Nov 2020 23:26:15 +0000 (23:26 +0000)]
fix the docs, this was always wrong...  In some cases, DISTDIR is set
automatically by tools via /etc/make.conf, so remind people (me) where
to find where it's set..

It would be nice for someone to document what DISTDIR is better than:
where the file for a distribution gets installed

3 years agopipe: whitespace nit in previous
mjg [Wed, 4 Nov 2020 23:17:41 +0000 (23:17 +0000)]
pipe: whitespace nit in previous

3 years agopipe: fix POLLHUP handling if no events were specified
mjg [Wed, 4 Nov 2020 23:11:54 +0000 (23:11 +0000)]
pipe: fix POLLHUP handling if no events were specified

Linux allows polling without any events specified and it happens to be the case
in FreeBSD as well. POLLHUP has to be delivered regardless of the event mask
and this works fine if the condition is already present. However, if it is
missing, selrecord is only called if the eventmask has relevant bits set. This
in particular leads to a conditon where pipe_poll can return 0 events and
neglect to selrecord, while kern_poll takes it as an indication it has to go to
sleep, but then there is nobody to wake it up.

While the problem seems systemic to *_poll handlers the least we can do is fix
it up for pipes.

Reported by: Jeremie Galarneau <jeremie.galarneau at efficios.com>
Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D27094

3 years agoMake the tests work without COMPAT_FREEBSD12 in kernel.
jkim [Wed, 4 Nov 2020 22:41:54 +0000 (22:41 +0000)]
Make the tests work without COMPAT_FREEBSD12 in kernel.

sysctl 'kern.cryptodevallowsoft' was renamed to 'kern.crypto.allow_soft' in
r359374 and the prevous one is only available in kernel built with
"options COMPAT_FREEBSD12".

3 years agoAdd regression tests for conditions and comments
se [Wed, 4 Nov 2020 22:29:01 +0000 (22:29 +0000)]
Add regression tests for conditions and comments

Fix one case where #else was not corerctly processed and simplify the
conditions logic.

Fix parsing of day and month names in the locale specified in the calendar
file. The previous version would expect those names to match the locale of
the user.

Mention that comments are now correctly processed and that // is supported
in addition to /* ... */.

MFC after: 3 days

3 years agoatkbdc(4): Add quirk for "System76 lemur Pro" laptops.
wulf [Wed, 4 Nov 2020 21:52:10 +0000 (21:52 +0000)]
atkbdc(4): Add quirk for "System76 lemur Pro" laptops.

Currently atkbdc(4) assumes all coreboot BIOSes belonging to Chromebooks
and unconditionally sets a number of quirks to workaround known issues.

Exclude "System76" laptops from this set as they appeared to be a
traditional hardware ("lemur Pro" is a rebranded Clevo chassis) with
coreboot firmware on board. KBDC_QUIRK_KEEP_ACTIVATED quirk activated for
Chromebook platform makes keyboard on this devices inoperable.

"Purism Librem" laptops may require the same exclusion too.

PR: 250711
Reported by: nick.lott@gmail.com
MFC after: 2 weeks

3 years agoUnbreak buildworld after r367339.
trasz [Wed, 4 Nov 2020 21:39:04 +0000 (21:39 +0000)]
Unbreak buildworld after r367339.

MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation

3 years agoBump __FreeBSD_version after rms changes
mjg [Wed, 4 Nov 2020 21:23:25 +0000 (21:23 +0000)]
Bump __FreeBSD_version after rms changes

3 years agozfs: use rms lock for teardown handling
mjg [Wed, 4 Nov 2020 21:22:41 +0000 (21:22 +0000)]
zfs: use rms lock for teardown handling

This deserializes otherwise non-contending operations.

The previous scheme of using 17 locks hashed by curthread runs into
conflicts very quickly.

3 years agozfs: macroify teardown handling
mjg [Wed, 4 Nov 2020 21:19:54 +0000 (21:19 +0000)]
zfs: macroify teardown handling

3 years agozfs: rename teardown inactive macros to mimick rrm convention
mjg [Wed, 4 Nov 2020 21:19:25 +0000 (21:19 +0000)]
zfs: rename teardown inactive macros to mimick rrm convention

3 years agozfs: add branch prediction to ZFS_ENTER and ZFS_VERIFY_ZP macros
mjg [Wed, 4 Nov 2020 21:18:51 +0000 (21:18 +0000)]
zfs: add branch prediction to ZFS_ENTER and ZFS_VERIFY_ZP macros

They are expected to fail only in corner cases.

3 years agozfs: even up assert
mjg [Wed, 4 Nov 2020 21:18:27 +0000 (21:18 +0000)]
zfs: even up assert

3 years agorms: fixup concurrent writer handling and add more features
mjg [Wed, 4 Nov 2020 21:18:08 +0000 (21:18 +0000)]
rms: fixup concurrent writer handling and add more features

Previously the code had one wait channel for all pending writers.
This could result in a buggy scenario where after a writer switches
the lock mode form readers to writers goes off CPU, another writer
queues itself and then the last reader wakes up the latter instead
of the former.

Use a separate channel.

While here add features to reliably detect whether curthread has
the lock write-owned. This will be used by ZFS.

3 years agodtb/rockchip: Add rockpi-4 to the build
manu [Wed, 4 Nov 2020 20:15:14 +0000 (20:15 +0000)]
dtb/rockchip: Add rockpi-4 to the build

We boot on this board to add the dtb to the build.

Requested by: Daniel Engberg <daniel.engberg.lists@pyret.net>

3 years agoAdd linux_to_bsd_errtbl[], mapping Linux errnos to their BSD counterparts.
trasz [Wed, 4 Nov 2020 19:54:18 +0000 (19:54 +0000)]
Add linux_to_bsd_errtbl[], mapping Linux errnos to their BSD counterparts.
This will be used by fuse(4).

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

3 years agoPlug minor memory leak in dwc3 USB2/USB3 controller.
manu [Wed, 4 Nov 2020 18:23:59 +0000 (18:23 +0000)]
Plug minor memory leak in dwc3 USB2/USB3 controller.

OF_getprop_alloc called earlier requires corresponding OF_prop_free to release allocated memory.

Submitted by: kjopek@gmail.com
Differential Revision: https://reviews.freebsd.org/D27085

3 years agoMake vector-related functions in libcxxrt's demangler static
dim [Wed, 4 Nov 2020 17:51:09 +0000 (17:51 +0000)]
Make vector-related functions in libcxxrt's demangler static

Follow-up to r367323 by re-adding static to a number of the functions
copied from elftc's libelftc_vstr.c. This was requested by upstream.

PR: 250702
MFC after: 3 days

3 years agoamd64: Make it easier to configure exception stack sizes
markj [Wed, 4 Nov 2020 16:42:20 +0000 (16:42 +0000)]
amd64: Make it easier to configure exception stack sizes

The amd64 kernel handles certain types of exceptions on a dedicated
stack.  Currently the sizes of these stacks are all hard-coded to
PAGE_SIZE, but for at least NMI handling it can be useful to use larger
stacks.  Add constants to intr_machdep.h to make this easier to tweak.

No functional change intended.

Reviewed by: kib
MFC after: 1 week
Sponsored by: NetApp, Inc.
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D27076

3 years agovmspace: Convert to refcount(9)
markj [Wed, 4 Nov 2020 16:30:56 +0000 (16:30 +0000)]
vmspace: Convert to refcount(9)

This is mostly mechanical except for vmspace_exit().  There, use the new
refcount_release_if_last() to avoid switching to vmspace0 unless other
processes are sharing the vmspace.  In that case, upon switching to
vmspace0 we can unconditionally release the reference.

Remove the volatile qualifier from vm_refcnt now that accesses are
protected using refcount(9) KPIs.

Reviewed by: alc, kib, mmel
MFC after: 1 month
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D27057

3 years agorefcount(9): Add refcount_release_if_last() and refcount_load()
markj [Wed, 4 Nov 2020 16:30:30 +0000 (16:30 +0000)]
refcount(9): Add refcount_release_if_last() and refcount_load()

The former is intended for use in vmspace_exit().  The latter is to
encourage use of explicit loads rather than relying on the volatile
qualifier.  This works better with kernel sanitizers, which can
intercept atomic(9) calls, and makes tricky lockless code easier to read
by not forcing the reader to remember which variables are declared
volatile.

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

3 years agopmcstat: Fix a typo in the usage message
0mp [Wed, 4 Nov 2020 15:44:59 +0000 (15:44 +0000)]
pmcstat: Fix a typo in the usage message

Reviewed by: emaste
Approved by: emaste
Differential Revision: https://reviews.freebsd.org/D26082

3 years agoFix bad libbxo format strings in jls
arichardson [Wed, 4 Nov 2020 14:31:52 +0000 (14:31 +0000)]
Fix bad libbxo format strings in jls

The existing format string for the empty case was trying to read varargs
values that weren't passed to xo_emit. This appears to work on x86 (since
the next argument is probably a pointer an empty string), but for CHERI
we can bound variadic arguments and detect a read past the end.

While touching these lines also use the libxo 'a' modifier to avoid having to
construct the libxo format string using asprintf.

Found by: CHERI
Reviewed By: allanjude
Differential Revision: https://reviews.freebsd.org/D26885

3 years agoacpi_video(4): mention that acpi_video should be loaded after any drm driver
manu [Wed, 4 Nov 2020 13:43:34 +0000 (13:43 +0000)]
acpi_video(4): mention that acpi_video should be loaded after any drm driver

When not adhering to this order, brightness sysctl's do not show up on some
laptop.

Submitted by:  driesm.michiels@gmail.com
Reviewed by: uqs
Differential Revision: https://reviews.freebsd.org/D26073

3 years agoarm64: implement bs_sr_<N>
bz [Wed, 4 Nov 2020 12:11:50 +0000 (12:11 +0000)]
arm64: implement bs_sr_<N>

Implement the bs_sr_<N> generic functions based on the generic
mips implementation calling the generic bs_w_<N> functions in a loop.

ral(4) (rt2860.c) panics in RAL_SET_REGION_4() because bs_sr_4()
is NULL.  It seems ral(4) and ti(4) might be the only consumers of
these functions I could find quickly so keeping them in C rather than asm.

Reported by: Steve Wheeler (https://redmine.pfsense.org/issues/11021)
Reviewed by: mmel
MFC after: 3 days

3 years agonet80211: fix a typo
bz [Wed, 4 Nov 2020 12:07:33 +0000 (12:07 +0000)]
net80211: fix a typo

Correct a typo referring to the wrong flags in a comment.
No functional changes.

MFC after: 3 days
Sponsored by: Rubicon Communications, LLC (d/b/a "Netgate")

3 years agoAdd the pmap.h changes missed in r367320
andrew [Wed, 4 Nov 2020 11:48:08 +0000 (11:48 +0000)]
Add the pmap.h changes missed in r367320

Reported by: bz
Sponsored by: Innovate UK

3 years agoTurn on WITH_LLVM_CXXFILT by default
dim [Wed, 4 Nov 2020 11:23:19 +0000 (11:23 +0000)]
Turn on WITH_LLVM_CXXFILT by default

LLVM's demangler supports more modern C++ constructs such as lambdas and
unnamed types, and is actively maintained. The command line tool is
usable as a drop-in replacement for GNU c++filt, or elftoolchain's
cxxfilt. The latter is still available by using WITHOUT_LLVM_CXXFILT, if
needed.

PR: 250702
MFC after: 2 weeks

3 years agoUpdate libcxxrt's private copy of elftoolchain demangler
dim [Wed, 4 Nov 2020 11:13:36 +0000 (11:13 +0000)]
Update libcxxrt's private copy of elftoolchain demangler

This updates the private copy of libelftc_dem_gnu3.c in libcxxrt with
the most recent version from upstream r3877. Similar to r367322, this
fixes a number of possible assertions, and allows it to correctly
demangle several names that it could not handle before.

PR: 250702
MFC after: 3 days

3 years agoMerge elftoolchain r3877 (by jkoshy):
dim [Wed, 4 Nov 2020 11:02:05 +0000 (11:02 +0000)]
Merge elftoolchain r3877 (by jkoshy):

  Incorporate fixes from Dimitry Andric:

  - Use a BUFFER_GROW() macro to avoid rounding errors in capacity
    calculations.
  - Fix a bug introduced in [r3531].
  - Fix handling of nested template parameters.

  Ticket: #581

This should fix a number of assertions on elftoolchain's cxxfilt, and
allow it to correctly demangle several names that it could not handle
before.

Obtained from: https://sourceforge.net/p/elftoolchain/code/3877/
PR: 250702
MFC after: 3 days

3 years agoFix a typo
0mp [Wed, 4 Nov 2020 10:38:25 +0000 (10:38 +0000)]
Fix a typo

3 years agoAllow the creation of 3 level page tables on arm64
andrew [Wed, 4 Nov 2020 10:21:30 +0000 (10:21 +0000)]
Allow the creation of 3 level page tables on arm64

The stage 2 arm64 page tables may need to start at a lower level. This
is because we may only be able to map a limited IPA range and trying
to use a full 4 levels will cause the CPU to fault in an unrecoverable
way.

To simplify the code we still allocate the full 4 levels, however level 0
will only ever be used to find the level 1 table used as the base. Handle
this by creating a dummy entry in the level 0 table to point to the level 1
table.

Sponsored by: Innovate UK
Differential Revision: https://reviews.freebsd.org/D26066