]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
3 years agoAdd dtrace SDT probe ipfw:::rule-matched.
ae [Wed, 21 Oct 2020 15:01:33 +0000 (15:01 +0000)]
Add dtrace SDT probe ipfw:::rule-matched.

It helps to reduce complexity with debugging of large ipfw rulesets.
Also define several constants and translators, that can by used by
dtrace scripts with this probe.

Reviewed by: gnn
Obtained from: Yandex LLC
MFC after: 2 weeks
Sponsored by: Yandex LLC
Differential Revision: https://reviews.freebsd.org/D26879

3 years agocache: drop the spurious slash_prefixed argument
mjg [Wed, 21 Oct 2020 05:57:25 +0000 (05:57 +0000)]
cache: drop the spurious slash_prefixed argument

3 years agoMove list_cloners to libifconfig
freqlabs [Wed, 21 Oct 2020 05:27:25 +0000 (05:27 +0000)]
Move list_cloners to libifconfig

Move list_cloners() from ifconfig(8) to libifconfig(3) where it can be
reused by other consumers.

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

3 years agoImprove FPU Tag Word reconstruction on i386 to indicate register states.
kib [Wed, 21 Oct 2020 00:15:12 +0000 (00:15 +0000)]
Improve FPU Tag Word reconstruction on i386 to indicate register states.

Improve the code reconstructing en_tw in struct fpreg32 from FXSAVE
results so that all register states are indicated correctly.  The
previous code unconditionally mapped non-empty register state to
'normalized value' constant.  The new code explicitly distinguishes
the 'zero value' and 'special value' constants as well.  This improves
consistency between real FSAVE and translation from FXSAVE, and
ensures that tests using PT_GETFPREGS can rely on a single correct
value independently of the underlying implementation.

PR: 250454
Sponsored by: The FreeBSD Foundation
Obtained from: Moritz Systems
Submitted by: Michał Górny <mgorny@moritz.systems>
Discussed with: emaste
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D26856

3 years agogeom_ctl.c: remove stale header files
rew [Tue, 20 Oct 2020 20:59:13 +0000 (20:59 +0000)]
geom_ctl.c: remove stale header files

- Remove "opt_geom.h", no kernel options are used.

- Remove <sys/sysctl.h>, no sysctl functionality is used here.

- Remove <sys/bio.h>, requirements for bio moved out in r112534.

- Remove <sys/lock.h> and <sys/mutex.h>, last used by DROP_GIANT() and
  PICKUP_GIANT(), which were removed in r115624.

- Remove <sys/disk.h> and <sys/kernel.h>, not used.

Reviewed by: phk, kevans (mentor)
Approved by: phk, kevans (mentor)
Differential Revision: https://reviews.freebsd.org/D26805

3 years agoarm64: add uhci to GENERIC
emaste [Tue, 20 Oct 2020 20:11:29 +0000 (20:11 +0000)]
arm64: add uhci to GENERIC

uhci is (or, can be) used by VMware ESXi-Arm.

PR: 250308
Reported by: Vincent Milum Jr
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation

3 years agoAdd a kernel crypto driver using assembly routines from OpenSSL.
jhb [Tue, 20 Oct 2020 17:50:18 +0000 (17:50 +0000)]
Add a kernel crypto driver using assembly routines from OpenSSL.

Currently, this supports SHA1 and SHA2-{224,256,384,512} both as plain
hashes and in HMAC mode on both amd64 and i386.  It uses the SHA
intrinsics when present similar to aesni(4), but uses SSE/AVX
instructions when they are not.

Note that some files from OpenSSL that normally wrap the assembly
routines have been adapted to export methods usable by 'struct
auth_xform' as is used by existing software crypto routines.

Reviewed by: gallatin, jkim, delphij, gnn
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D26821

3 years agoFix linprocfs(4) /proc/self/mem semantics to more closely match Linux.
trasz [Tue, 20 Oct 2020 17:24:29 +0000 (17:24 +0000)]
Fix linprocfs(4) /proc/self/mem semantics to more closely match Linux.
Steam's Anti-Cheat might depend on it.

PR: 248223
Analyzed by: Alex S <iwtcex@gmail.com>
Reviewed by: kib
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D26816

3 years agoFix potential race condition in linux stat(2).
trasz [Tue, 20 Oct 2020 17:19:10 +0000 (17:19 +0000)]
Fix potential race condition in linux stat(2).

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

3 years agoMove generated OpenSSL assembly routines into the kernel sources.
jhb [Tue, 20 Oct 2020 17:00:43 +0000 (17:00 +0000)]
Move generated OpenSSL assembly routines into the kernel sources.

Sponsored by: Netflix

3 years agoUse a template assembly file to generate the embedded MFS.
jhb [Tue, 20 Oct 2020 16:48:45 +0000 (16:48 +0000)]
Use a template assembly file to generate the embedded MFS.

This uses the .incbin directive to pull in the MFS image contents.
Using assembly directly ensures that symbols can be defined with the
name and properties (such as .size) desired without having to rename
symbols, etc. via a second objcopy invocation.  Since it is compiled
by the C compiler driver, it also avoids the need for all of the
EMBEDFS* make variables.

Suggested by: jrtc27
Reviewed by: kib, markj
Obtained from: CheriBSD
MFC after: 2 weeks
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D26781

3 years agorealpath(1): Add EXAMPLES section.
fernape [Tue, 20 Oct 2020 13:15:26 +0000 (13:15 +0000)]
realpath(1): Add EXAMPLES section.

Add a small example for this simple command.

Approved by: manpages (gbe@)
Differential Revision: https://reviews.freebsd.org/D26863

3 years agocompress(1): Add EXAMPLES section
fernape [Tue, 20 Oct 2020 13:05:25 +0000 (13:05 +0000)]
compress(1): Add EXAMPLES section

Add 5 examples showing basic usage.

Approved by: manpages (gbe@)
Differential Revision: https://reviews.freebsd.org/D26865

3 years agoufs: catch up with removal of thread argument from VOP_INACTIVE
mjg [Tue, 20 Oct 2020 09:46:20 +0000 (09:46 +0000)]
ufs: catch up with removal of thread argument from VOP_INACTIVE

3 years agoBump __FreeBSD_version after VOP VPTOCNP and INACTIVE changes
mjg [Tue, 20 Oct 2020 07:19:44 +0000 (07:19 +0000)]
Bump __FreeBSD_version after VOP VPTOCNP and INACTIVE changes

3 years agovfs: drop the de facto curthread argument from VOP_INACTIVE
mjg [Tue, 20 Oct 2020 07:19:03 +0000 (07:19 +0000)]
vfs: drop the de facto curthread argument from VOP_INACTIVE

3 years agovfs: drop spurious cred argument from VOP_VPTOCNP
mjg [Tue, 20 Oct 2020 07:18:27 +0000 (07:18 +0000)]
vfs: drop spurious cred argument from VOP_VPTOCNP

3 years agoFurther refinements of ptsname_r(3) interface:
delphij [Tue, 20 Oct 2020 01:29:45 +0000 (01:29 +0000)]
Further refinements of ptsname_r(3) interface:

 - Hide ptsname_r under __BSD_VISIBLE for now as the specification
   is not finalized at this time.
 - Keep Symbol.map sorted.
 - Avoid the interposing of ptsname_r(3) from an user application
   from breaking ptsname(3) by making the implementation a static
   method and call the static function from ptsname(3) instead.

Reported by: kib
Reviewed by: kib, jilles
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D26845

3 years agoFix build: only set iommu buswide flag if IOMMU code is included.
br [Mon, 19 Oct 2020 22:32:36 +0000 (22:32 +0000)]
Fix build: only set iommu buswide flag if IOMMU code is included.

Sponsored by: Innovate DSbD

3 years agoAdd IOMMU_BUSWIDE ahci quirk.
br [Mon, 19 Oct 2020 21:27:27 +0000 (21:27 +0000)]
Add IOMMU_BUSWIDE ahci quirk.

Some controllers use PCI function 1 as the requester ID for DMA transfers,
but the controllers are not PCI multifunction.

Set the iommu buswide flag for them. This should instruct an IOMMU driver
to use the same translation rule for all the devices and functions of
a bus.

This was discovered on the ARM Neoverse N1 System Development Platform
(ARM N1SDP).

Bug reference: https://bugzilla.kernel.org/show_bug.cgi?id=42679

Reported by: andrew
Reviewed by: kib, mav
Sponsored by: Innovate DSbD
Differential Revision: https://reviews.freebsd.org/D26857

3 years agocxgbe(4): Updates to the drop features from r366532.
np [Mon, 19 Oct 2020 21:11:49 +0000 (21:11 +0000)]
cxgbe(4): Updates to the drop features from r366532.

MFC after: 1 week
Sponsored by: Chelsio Communications

3 years agobuild vmware modules on arm64
emaste [Mon, 19 Oct 2020 20:43:29 +0000 (20:43 +0000)]
build vmware modules on arm64

pvscsi and vmxnet3 build and work.  Exclude vmci for now as it contains
x86-specific assembly.

Reported by: Vincent Milum Jr
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation

3 years agoDestroy cloned interfaces at netif stop, netif restart and shutdown.
cy [Mon, 19 Oct 2020 20:37:38 +0000 (20:37 +0000)]
Destroy cloned interfaces at netif stop, netif restart and shutdown.
This is especially important during shutdown because a child interface
of lagg with WOL enabled will not enable WOL at interface shutdown and
thus no WOL to wake up the device (and machine).

PR: 158734, 109980
Reported by: Antonio Huete Jimenez <tuxillo at quantumachine.net>
Marat N.Afanasyev <marat at zealot.ksu.ru>
reviewed by: kp
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D26797

3 years agoFix fallout from r366811.
trasz [Mon, 19 Oct 2020 20:26:37 +0000 (20:26 +0000)]
Fix fallout from r366811.

PR: 250442
Reported by: lwhsu
Reviewed by: mav
MFC after: 2 weeks
Sponsored by: NetApp, Inc.
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D26855

3 years agoRe-enable receive flow control for TOE TLS sockets.
jhb [Mon, 19 Oct 2020 20:08:50 +0000 (20:08 +0000)]
Re-enable receive flow control for TOE TLS sockets.

Flow control was disabled during initial TOE TLS development to
workaround a hang (and to match the Linux TOE TLS support for T6).
The rest of the TOE TLS code maintained credits as if flow control was
enabled which was inherited from before the workaround was added with
the exception that the receive window was allowed to go negative.
This negative receive window handling (rcv_over) was because I hadn't
realized the full implications of disabling flow control.

To clean this up, re-enable flow control on TOE TLS sockets.  The
existing TPF_FORCE_CREDITS workaround is sufficient for the original
hang.  Now that flow control is enabled, remove the rcv_over
workaround and instead assert that the receive window never goes
negative matching plain TCP TOE sockets.

Reviewed by: np
MFC after: 2 weeks
Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D26799

3 years agocxgbe(4): Fix page fault in t4_get_lb_stats with 2 port T5 cards.
np [Mon, 19 Oct 2020 20:08:47 +0000 (20:08 +0000)]
cxgbe(4): Fix page fault in t4_get_lb_stats with 2 port T5 cards.

PR: 250449
Reported by: freqlabs@
MFC after: 1 week
Sponsored by: Chelsio Communications

3 years agoFix a couple of bugs for asym crypto introduced in r359374.
jhb [Mon, 19 Oct 2020 20:04:03 +0000 (20:04 +0000)]
Fix a couple of bugs for asym crypto introduced in r359374.

- Check for null pointers in the crypto_drivers[] array when checking
  for empty slots in crypto_select_kdriver().

- Handle the case where crypto_kdone() is invoked on a request where
  krq_cap is NULL due to not finding a matching driver.

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

3 years agoEnable SUBDIR_PARALLEL for lib/googletest
arichardson [Mon, 19 Oct 2020 19:51:03 +0000 (19:51 +0000)]
Enable SUBDIR_PARALLEL for lib/googletest

This saves a few seconds in a parallel build since we can build the
gtest_main and gmock subdirectories in parallel.

Reviewed By: ngie
Differential Revision: https://reviews.freebsd.org/D26760

3 years agoMajor improvement to build parallelism for googletest internal tests
arichardson [Mon, 19 Oct 2020 19:50:57 +0000 (19:50 +0000)]
Major improvement to build parallelism for googletest internal tests

Currently the googletest internal tests build after the matching library.
However, each of these is serialized at the top level makefile.
Additionally some of the tests (e.g. the gmock-matches-test) take up to
90 seconds to build with clang -O2. Having to wait for this test to
complete before continuing to the next directory seriously slows down the
parllelism of a -j32 build.
Before this change running `make -C lib/googletest -j32 -s` in buildenv
took 202 seconds, now it's 153 due to improved parallelism.

Reviewed By: emaste (no objection)
Differential Revision: https://reviews.freebsd.org/D26748

3 years agonullfs: ensure correct lock is taken after bypass.
kib [Mon, 19 Oct 2020 19:23:22 +0000 (19:23 +0000)]
nullfs: ensure correct lock is taken after bypass.

If lower VOP relocked the lower vnode, it is possible that nullfs
vnode was reclaimed meantime.  In this case nullfs vnode no longer
shares lock with lower vnode, which breaks locking protocol.

Check for the condition and acquire nullfs vnode lock if detected.

Reported and tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 1 week

3 years agovgonel(): avoid recursing into VOP_INACTIVE().
kib [Mon, 19 Oct 2020 19:20:23 +0000 (19:20 +0000)]
vgonel(): avoid recursing into VOP_INACTIVE().

It is a common pattern for filesystems' VOP_INACTIVE() implementation
to forcibly reclaim the vnode when its state is final.  For instance,
UFS vnode with zero link count is removed, and since it is
inactivated, the last open reference on it is dropped.

On the other hand, vnode might get spurious usecount reference for
many reasons.  If the spurious reference exists while vgonel() checks
for active state of the vnode, it would recurse into VOP_INACTIVE().

Fix it by checking and not doing inactivation when vgone() was called
from inactive VOP.

Reported and tested by: pho
Discussed with: mjg
Sponsored by: The FreeBSD Foundation
MFC after: 1 week

3 years agouma: fix KTR message after r366840
emaste [Mon, 19 Oct 2020 18:54:44 +0000 (18:54 +0000)]
uma: fix KTR message after r366840

Reported by: bz
Sponsored by: The FreeBSD Foundation

3 years agocache: promote negative entries based on more than one hit
mjg [Mon, 19 Oct 2020 18:51:51 +0000 (18:51 +0000)]
cache: promote negative entries based on more than one hit

During tinderbox and similar workloads negative entries get at least one
hit before they get evicted. In the current scheme this avoidably promotes
them.

Be conservative and stick to 2 hits for now.

3 years agoCheck TF_TOE not the tod pointer to determine if TOE is active.
jhb [Mon, 19 Oct 2020 18:24:06 +0000 (18:24 +0000)]
Check TF_TOE not the tod pointer to determine if TOE is active.

The TF_TOE flag is the check used in the rest of the network stack to
determine if TOE is active on a socket.  There is at least one path in
the cxgbe(4) TOE driver that can leave the tod pointer non-NULL on a
socket not using TOE.

Reported by: Sony Arpita Das <sonyarpitad@chelsio.com>
Reviewed by: np
Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D26803

3 years agoMark asymmetric cryptography via OCF deprecated for 14.0.
jhb [Mon, 19 Oct 2020 18:21:41 +0000 (18:21 +0000)]
Mark asymmetric cryptography via OCF deprecated for 14.0.

Only one MIPS-specific driver implements support for one of the
asymmetric operations.  There are no in-kernel users besides
/dev/crypto.  The only known user of the /dev/crypto interface was the
engine in OpenSSL releases before 1.1.0.  1.1.0 includes a rewritten
engine that does not use the asymmetric operations due to lack of
documentation.

Reviewed by: cem, markj
MFC after: 1 week
Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D26810

3 years agoProperly clear PCB_KERNNPX in fpu_kern_leave().
jhb [Mon, 19 Oct 2020 17:35:45 +0000 (17:35 +0000)]
Properly clear PCB_KERNNPX in fpu_kern_leave().

PR: 250423
Reported by: CI
Tested by: lwhsu

3 years agoicmp6: Count packets dropped due to an invalid hop limit
markj [Mon, 19 Oct 2020 17:07:19 +0000 (17:07 +0000)]
icmp6: Count packets dropped due to an invalid hop limit

Pad the icmp6stat structure so that we can add more counters in the
future without breaking compatibility again, last done in r358620.
Annotate the rarely executed error paths with __predict_false while
here.

Reviewed by: bz, melifaro
Sponsored by: NetApp, Inc.
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D26578

3 years agolink_elf_obj: Colour VM objects
markj [Mon, 19 Oct 2020 16:57:59 +0000 (16:57 +0000)]
link_elf_obj: Colour VM objects

This will cause the VM to back sufficiently large .text sections, such
as those in zfs.ko or amdgpu.ko on amd64, with superpage mappings when
possible.

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

3 years agouma: Respect uk_reserve in keg_drain()
markj [Mon, 19 Oct 2020 16:57:40 +0000 (16:57 +0000)]
uma: Respect uk_reserve in keg_drain()

When a reserve of free items is configured for a zone, the reserve must
not be reclaimed under memory pressure.  Modify keg_drain() to simply
respect the reserved pool.

While here remove an always-false uk_freef == NULL check (kegs that
shouldn't be drained should set _NOFREE instead), and make sure that the
keg_drain() KTR statement does not reference an uninitialized variable.

Reviewed by: alc, rlibby
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D26772

3 years agouma: Avoid depleting keg reserves when filling a bucket
markj [Mon, 19 Oct 2020 16:55:03 +0000 (16:55 +0000)]
uma: Avoid depleting keg reserves when filling a bucket

zone_import() fetches a free or partially free slab from the keg and
then uses its items to populate an array, typically filling a bucket.
If a single allocation causes the keg to drop below its minimum reserve,
the inner loop ends.  However, if the bucket is still not full and
M_USE_RESERVE is specified, the outer loop will continue to fetch items
from the keg.

If M_USE_RESERVE is specified and the number of free items is below the
reserved limit, we should return only a single item.  Otherwise, if the
bucket size is larger than the reserve, all of the reserved items may
end up in a single per-CPU bucket, invisible to other CPUs.

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

3 years agovmem: Allocate btags before looping in vmem_xalloc()
markj [Mon, 19 Oct 2020 16:54:06 +0000 (16:54 +0000)]
vmem: Allocate btags before looping in vmem_xalloc()

BT_MAXALLOC (4) is the number of boundary tags required to complete an
allocation in the worst case: two to clip a free segment, and two to
import from a parent arena.  vmem_xalloc() preallocates four boundary
tags before attempting a search to simplify the segment allocation code.
It implements a loop that:
1) ensures that BT_MAXALLOC boundary tags are available,
2) attempts to find and clip a free segment satisfying the allocation
   constraints, and failing that,
3) attempts to import a segment.

On !UMA_MD_SMALL_ALLOC platforms the btag zone has to handle recusion:
it needs boundary tags to allocate boundary tags.  Thus we reserve
2 * BT_MAXALLOC * mp_ncpus tags for use when recursing: the factor of 2
is because there are two layers of vmem arenas, the per-domain arena and
global arena.  For a single thread, 2 * BT_MAXALLOC tags should be
sufficient.

Because of the way the loop is structured, BT_MAXALLOC tags are not
sufficient.  The first bt_fill() call may allocate BT_MAXALLOC tags,
then import a segment (consuming two tags), then attempt to top up the
preallocation before carving into the imported free segment, thus
requiring up to six tags in the worst case.  Because we don't
preallocate that many, this bug can cause deadlocks in rare scenarios.

Fix the problem by moving the preallocation out the loop.  This assumes
that only a single import is ever required to satisfy an allocation
request.

Thanks to manu, emaste and lwhsu for helping test debug patches.

Reported by: Jenkins (hardware CI lab)
Reviewed by: alc, kib, rlibby
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D26770

3 years agovmem: Simplify bt_fill() callers a bit
markj [Mon, 19 Oct 2020 16:52:27 +0000 (16:52 +0000)]
vmem: Simplify bt_fill() callers a bit

No functional change intended.

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

3 years agoRemove unused labels from the arm64 casueword*
andrew [Mon, 19 Oct 2020 15:52:42 +0000 (15:52 +0000)]
Remove unused labels from the arm64 casueword*

These are unused so can be removed. While here renumber the remaining label
to be 1.

Sponsored by: Innovate UK

3 years agoAssign the reserved apic region (GAS entry) to the iommu domain msi_entry.
br [Mon, 19 Oct 2020 15:50:58 +0000 (15:50 +0000)]
Assign the reserved apic region (GAS entry) to the iommu domain msi_entry.

Requested by: kib
Reviewed by: kib
Sponsored by: Innovate DSbD
Differential Revision: https://reviews.freebsd.org/D26859

3 years agovmx: Implement pmap (de)activation in C
markj [Mon, 19 Oct 2020 15:24:35 +0000 (15:24 +0000)]
vmx: Implement pmap (de)activation in C

Rewrite the code that maintains pm_active and invalidates EPTP-tagged
TLB entries in C.  Previously this work was done in vmx_enter_guest(),
in assembly, but there is no good reason for that and it makes the TLB
invalidation algorithm for nested page tables harder to review.

No functional change intended.  Now, an error from the invept
instruction results in a kernel panic rather than a vmexit.  Such errors
should occur only as a result of VMM bugs.

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

3 years agoManage MSI iommu pages.
br [Mon, 19 Oct 2020 13:10:21 +0000 (13:10 +0000)]
Manage MSI iommu pages.

This allows the interrupt controller driver only need a small change to
create a map for the page the device will write to raise an interrupt.

Submitted by: andrew
Reviewed by: kib
Sponsored by: Innovate DSbD
Differential Revision: https://reviews.freebsd.org/D26705

3 years agoSplit the common arm64 fu* and su* asm to a macro
andrew [Mon, 19 Oct 2020 12:46:03 +0000 (12:46 +0000)]
Split the common arm64 fu* and su* asm to a macro

As these are mostly identical split out the common code to a macro.

Sponsored by: Innovate UK

3 years agoMove the arm64 userspace access checks to macros
andrew [Mon, 19 Oct 2020 12:06:16 +0000 (12:06 +0000)]
Move the arm64 userspace access checks to macros

In the functions that copy between userspace and kernel space we check the
user space address is valid before performing the copy. These are mostly
identical within each type of function so create two macros to perform the
check.

Obtained from: CheriBSD
Sponsored by: Innovate UK

3 years agoefibootmgr: Use returned error code for error message, not errno
freqlabs [Mon, 19 Oct 2020 10:38:40 +0000 (10:38 +0000)]
efibootmgr: Use returned error code for error message, not errno

efivar_unix_path_to_device_path returns the error code, it does not set errno.

Reviewed by: imp
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D26852

3 years agocache: refactor negative promotion/demotion handling
mjg [Mon, 19 Oct 2020 09:52:52 +0000 (09:52 +0000)]
cache: refactor negative promotion/demotion handling

This will simplify policy changes.

3 years agoUse asprintf instead of sbuf
bapt [Mon, 19 Oct 2020 07:26:42 +0000 (07:26 +0000)]
Use asprintf instead of sbuf

3 years agoAdd more explicit instructions about updating motd
imp [Mon, 19 Oct 2020 01:16:39 +0000 (01:16 +0000)]
Add more explicit instructions about updating motd

Not that you can regenerate the motd by editing motd.template and
running 'service motd restart' rather than rebooting.

Small wordsmithing by me, and updated the example from FreeBSD 2.1.6.1
release to 12.1 release.

Submitted by: Dan Mack

3 years agolibbe(3): install MLINKS for all of the functions provided
kevans [Sun, 18 Oct 2020 23:58:40 +0000 (23:58 +0000)]
libbe(3): install MLINKS for all of the functions provided

MFC after: 1 week

3 years agolibbe(3): document be_snapshot()
kevans [Sun, 18 Oct 2020 23:42:00 +0000 (23:42 +0000)]
libbe(3): document be_snapshot()

While toying around with lua bindings for libbe(3), I discovered that I
apparently never documented this, despite having documented
be_is_auto_snapshot_name that references it.

MFC after: 1 week

3 years agolibbe(3): const'ify a couple arguments
kevans [Sun, 18 Oct 2020 23:32:47 +0000 (23:32 +0000)]
libbe(3): const'ify a couple arguments

libbe will never need to mutate these as we either process them into a local
buffer or we just don't touch them and write to a separate out argument.

MFC after: 1 week

3 years ago[zfs] Remove a non-existent directory in the build infra
adrian [Sun, 18 Oct 2020 22:37:58 +0000 (22:37 +0000)]
[zfs] Remove a non-existent directory in the build infra

This directory doesn't exist and causes gcc-6.4 to complain about
a non-existent include directory

Approved by: kevans, imp
Differential Revision: https://reviews.freebsd.org/D26846

3 years agonet80211: factor out the priv(9) checks into OS specifc code.
bz [Sun, 18 Oct 2020 21:34:04 +0000 (21:34 +0000)]
net80211: factor out the priv(9) checks into OS specifc code.

Factor out the priv(9) checks into OS specifc code so other OSes can equally
implement them.  This sorts out those XXX in the net80211 code.
We provide 3 arguments (cmd, vap, ifp) where available to the functions, in
order to allow other OSes to use that data but also in case we'd add auditing
to these check to have the information available. For now the arguments are
marked __unused.

PR: 249403
Reported by: martin(NetBSD)
Reviewed by: adrian, martin(NetBSD)
MFC after: 10 days
Sponsored by: Rubicon Communications, LLC (d/b/a "Netgate")
Differential Revision: https://reviews.freebsd.org/D26541

3 years agoSignificantly speed up mkimg_test
arichardson [Sun, 18 Oct 2020 18:35:23 +0000 (18:35 +0000)]
Significantly speed up mkimg_test

It turns out that the majority of the test time for the mkimg tests isn't
mkimg itself but rather the use of jot and hexdump which can be quite slow
on emulated platforms such as QEMU.

On QEMU-RISC-V this reduces the time for `kyua test mkimg_test` from 655
seconds to 200. And for CheriBSD on QEMU-CHERI this saves 4-5 hours (25%
of the time for the entire testsuite!) since jot ends up triggering slow
functions inside the QEMU emulation a lot.

Reviewed By: lwhsu
Differential Revision: https://reviews.freebsd.org/D26796

3 years ago[libcxx] Fix atomic type for mips32 on gcc to work w/out needing libatomic
adrian [Sun, 18 Oct 2020 17:31:10 +0000 (17:31 +0000)]
[libcxx] Fix atomic type for mips32 on gcc to work w/out needing libatomic

When compiling this for mips32 on gcc-6.x, we'd hit issues where we
don't have 64 bit atomics on mips32.

gcc implements this using libatomic, which we don't currently include
in our freebsd-gcc compiler packages.

So for now add this work around so mips32 works.  It's also fine for
mips64.  We can fix this later once we get libatomic included.

Approved by: dim
Differential Revision: https://reviews.freebsd.org/D26774

3 years agoImplement flowid calculation for outbound connections to balance
melifaro [Sun, 18 Oct 2020 17:15:47 +0000 (17:15 +0000)]
Implement flowid calculation for outbound connections to balance
 connections over multiple paths.

Multipath routing relies on mbuf flowid data for both transit
 and outbound traffic. Current code fills mbuf flowid from inp_flowid
 for connection-oriented sockets. However, inp_flowid is currently
 not calculated for outbound connections.

This change creates simple hashing functions and starts calculating hashes
 for TCP,UDP/UDP-Lite and raw IP if multipath routes are present in the
 system.

Reviewed by: glebius (previous version),ae
Differential Revision: https://reviews.freebsd.org/D26523

3 years agoIf the SIM freezes the queue at exactly the wrong moment, after
trasz [Sun, 18 Oct 2020 16:30:49 +0000 (16:30 +0000)]
If the SIM freezes the queue at exactly the wrong moment, after
another thread has started to send in a CCB and already checked
the queue wasn't frozen, we would end up with iscsi_action()
being called despite the queue is now frozen.

Add a check to make sure this doesn't happen . Perhaps this should
be fixed at the CAM level instead, but given how the send queue and
SIM are governed by two separate mutexes, it is somewhat hard to do.

Reviewed by: imp, mav
MFC after: 2 weeks
Sponsored by: NetApp, Inc.
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D26750

3 years agoMake g_attach() return ENXIO for orphaned providers; update various
trasz [Sun, 18 Oct 2020 16:24:08 +0000 (16:24 +0000)]
Make g_attach() return ENXIO for orphaned providers; update various
classes to add missing error checking.

Reviewed by: imp
MFC after: 2 weeks
Sponsored by: NetApp, Inc.
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D26658

3 years agoStop calling set_syscall_retval() from linux_set_syscall_retval().
trasz [Sun, 18 Oct 2020 16:16:22 +0000 (16:16 +0000)]
Stop calling set_syscall_retval() from linux_set_syscall_retval().
The former clobbers some registers that shouldn't be touched.

Reviewed by: kib (earlier version)
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D26406

3 years agoAdd compat.linux.dummy_rlimits, and disable by default.
trasz [Sun, 18 Oct 2020 15:58:16 +0000 (15:58 +0000)]
Add compat.linux.dummy_rlimits, and disable by default.

Turns out the dummy rlimits fix prlimit(1), but break su(8)
(login-1:4.5-1ubuntu2) - although not sudo(8), for some reason.

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

3 years agoSlightly tweak linux ptrace(2) debug message; no functional changes.
trasz [Sun, 18 Oct 2020 15:56:47 +0000 (15:56 +0000)]
Slightly tweak linux ptrace(2) debug message; no functional changes.

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

3 years agoSimplify NET_EPOCH_EXIT in inp_join_group().
melifaro [Sun, 18 Oct 2020 12:03:36 +0000 (12:03 +0000)]
Simplify NET_EPOCH_EXIT in inp_join_group().

Suggested by: kib

3 years agoAdd new USB quirk.
hselasky [Sun, 18 Oct 2020 08:58:14 +0000 (08:58 +0000)]
Add new USB quirk.

PR: 250422
Submitted by: vidwer+fbsdbugs@gmail.com
MFC after: 1 week
Sponsored by: Mellanox Technologies // NVIDIA Networking

3 years agoCorrect location and date of the Boston Shoemakers' organization,
grog [Sun, 18 Oct 2020 03:01:26 +0000 (03:01 +0000)]
Correct location and date of the Boston Shoemakers' organization,
which significantly predated the USA.

Reference: http://www.famousdaily.com/history/boston-shoemakers-form-first-us-labor-organization.html

3 years agonet80211: update for (more) VHT160 support
bz [Sun, 18 Oct 2020 00:27:20 +0000 (00:27 +0000)]
net80211: update for (more) VHT160 support

Implement two macros IEEE80211_VHTCAP_SUPP_CHAN_WIDTH_IS_160MHZ()
and its 80+80 counter part to check in vhtcaps for appropriate
levels of support and use the macros throughout the code.

Add vht160_chan_ranges/is_vht160_valid_freq and handle analogue
to vht80 in various parts of the code.

Add ieee80211_add_channel_cbw() which also takes the CBW flag
fields and make the former ieee80211_add_channel() a wrapper to it.
With the CBW flags we can add HT/VHT channels passing them to
getflags() for the 2/5ghz functions.

In ifconfig(8) add the regdomain_addchans() support for VHT160
and VHT80P80.

With this (+ regdoain.xml updates) VHT160 channels can be
configured, listed, and pass regdomain where appropriate.

Tested with: iwlwifi
Reviewed by: adrian
MFC after: 10 days
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D26712

3 years agoclk: fix indentation
bz [Sat, 17 Oct 2020 23:42:33 +0000 (23:42 +0000)]
clk: fix indentation

Just fix indentation of an if() clause.
No functional changes intended.

MFC after: 3 days

3 years agoddb: add show sysinit command
bz [Sat, 17 Oct 2020 22:47:08 +0000 (22:47 +0000)]
ddb: add show sysinit command

Add a show sysinit command to ddb (similar to show vnet_sysinit) which
proved to be helpful to debug some ordering issues on early-mid kernel
start panics.

3 years agocache: shorten names of debug stats
mjg [Sat, 17 Oct 2020 21:30:46 +0000 (21:30 +0000)]
cache: shorten names of debug stats

3 years agocache: don't automatically evict negative entries if usage is low
mjg [Sat, 17 Oct 2020 21:22:40 +0000 (21:22 +0000)]
cache: don't automatically evict negative entries if usage is low

The previous scheme only looked at negative entry count in relation to the
total count, leading to tons of spurious evictions if the cache is not
significantly populated.

Instead, only try the above if negative entry count goes beyond namecache
capacity.

3 years agoFix sleepq_add panic happening with too wide net epoch in mcast control.
melifaro [Sat, 17 Oct 2020 20:33:09 +0000 (20:33 +0000)]
Fix sleepq_add panic happening with too wide net epoch in mcast control.

PR: 250413
Reported by: Christopher Hall <hsw at bitmark.com>
Reviewed by: ae
Differential Revision: https://reviews.freebsd.org/D26827

3 years agoriscv: zero reserved PTE bits for L2 PTEs
mhorne [Sat, 17 Oct 2020 17:31:06 +0000 (17:31 +0000)]
riscv: zero reserved PTE bits for L2 PTEs

As was done for L3 PTEs in r362853, mask out the reserved bits when
extracting the physical address from an L2 PTE. Future versions of the
spec or custom implementations may make use of these reserved bits, in
which case the resulting physical address could be incorrect.

Submitted by: Nathaniel Filardo <nwf20@cl.cam.ac.uk>
Reviewed by: kp, mhorne
Differential Revision: https://reviews.freebsd.org/D26607

3 years agocache: erwork sysctl vfs.cache tree
mjg [Sat, 17 Oct 2020 13:06:29 +0000 (13:06 +0000)]
cache: erwork sysctl vfs.cache tree

Split everything into neg, debug, param and stat categories.

The legacy nchstats sysctl (queried e.g., by systat) remains untouched.

While here rename some vars to be easier on the eye.

3 years agocache: factor negative lookup out of cache_fplookup_next
mjg [Sat, 17 Oct 2020 13:04:46 +0000 (13:04 +0000)]
cache: factor negative lookup out of cache_fplookup_next

3 years agocache: avoid smr in cache_neg_evict in favoro of the already held bucket lock
mjg [Sat, 17 Oct 2020 13:04:25 +0000 (13:04 +0000)]
cache: avoid smr in cache_neg_evict in favoro of the already held bucket lock

3 years agocache: rework parts of negative entry management
mjg [Sat, 17 Oct 2020 08:48:58 +0000 (08:48 +0000)]
cache: rework parts of negative entry management

- declutter sysctl vfs.cache by moving relevant entries into
vfs.cache.neg
- add a little more parallelism to eviction by replacing the
global lock with an atomically modified counter
- track more statistics

The code needs further effort.

3 years agocache: remove entries before trying to add new ones, not after
mjg [Sat, 17 Oct 2020 08:48:32 +0000 (08:48 +0000)]
cache: remove entries before trying to add new ones, not after

Should allow positive entries to replace negative ones in case
the cache is full.

3 years agovfs: annotate mountlist_mtx with __exclusive_cache_line
mjg [Sat, 17 Oct 2020 08:47:08 +0000 (08:47 +0000)]
vfs: annotate mountlist_mtx with __exclusive_cache_line

3 years agoBump __FreeBSD_version after ptsname_r addition.
delphij [Sat, 17 Oct 2020 04:14:46 +0000 (04:14 +0000)]
Bump __FreeBSD_version after ptsname_r addition.

3 years agoImplement ptsname_r.
delphij [Sat, 17 Oct 2020 04:14:38 +0000 (04:14 +0000)]
Implement ptsname_r.

MFC after: 2 weeks
PR: 250062
Reviewed by: jilles, 0mp, Ray <i maskray me>
Differential Revision: https://reviews.freebsd.org/D26647

3 years agoUpdate OpenZFS to 2.0.0-rc3-gfc5966
mmacy [Sat, 17 Oct 2020 01:06:04 +0000 (01:06 +0000)]
Update OpenZFS to 2.0.0-rc3-gfc5966

- fix panic due to tqid overflow
- Improve libzfs_error_init messages
- Expose zfetch_max_idistance tunable
- Make dbufstat work on FreeBSD
- Fix EIO after resuming receive of new dataset over an existing one

3 years agoImport tzdata 2020c
philip [Sat, 17 Oct 2020 00:44:04 +0000 (00:44 +0000)]
Import tzdata 2020c

Changes: https://github.com/eggert/tz/blob/2020c/NEWS

MFC after: 1 day

3 years agocache: add a probe reporting addition of duplicate entries
mjg [Sat, 17 Oct 2020 00:27:26 +0000 (00:27 +0000)]
cache: add a probe reporting addition of duplicate entries

3 years agoUpdate OpenZFS to 2.0.0-rc3-gbd565f
mmacy [Sat, 17 Oct 2020 00:05:34 +0000 (00:05 +0000)]
Update OpenZFS to 2.0.0-rc3-gbd565f

3 years agoTry to enable multipath routing in flowid tests.
melifaro [Fri, 16 Oct 2020 21:51:17 +0000 (21:51 +0000)]
Try to enable multipath routing in flowid tests.

3 years agobhyve: Update TX descriptor base address and host mapping on change
freqlabs [Fri, 16 Oct 2020 20:27:20 +0000 (20:27 +0000)]
bhyve: Update TX descriptor base address and host mapping on change

bhyve sometimes segfaults when using an e1000 NIC with a Windows guest.

We are only updating our tdba and cached host mapping when the low address
register is written and when tx is set enabled, but not when the high address
or length registers are written. It is observed that Windows 10 is occasionally
enabling tx first then writing the registers in the order low, high, len. This
leaves us with a bogus base address and mapping, which causes a segfault later
when we try to copy from a descriptor that has unpredictable garbage in a
pointer.

Updating the address and mapping when any of those registers change seems to fix
that particular issue.

Reviewed by: mav, grehan (bhyve)
MFC after: 1 week
Sponsored by: iXsystems, Inc.
Differential Revision: https://reviews.freebsd.org/D26798

3 years agolibc: typo fix (s/involes/involves)
kevans [Fri, 16 Oct 2020 17:51:09 +0000 (17:51 +0000)]
libc: typo fix (s/involes/involves)

Reported by: Masahiko Sawada via twitter
MFC after: 3 days

3 years agoMFC r366760: lua: update to 5.3.6
kevans [Fri, 16 Oct 2020 17:03:27 +0000 (17:03 +0000)]
MFC r366760: lua: update to 5.3.6

This release contains some minor bugfixes; notably:
- 2x minor Makefile fixes (not used in base)
- Long brackets with a huge number of '=' overflow some internal buffer
  arithmetic.
- Joining an upvalue with itself can cause a use-after-free crash.

See here for examples: http://www.lua.org/bugs.html#5.3.5

MFC after: 2 weeks

3 years agoamd64 pmap.h: explicitly provide constants values instead of relying
kib [Fri, 16 Oct 2020 16:22:32 +0000 (16:22 +0000)]
amd64 pmap.h: explicitly provide constants values instead of relying
on some more advanced C features.

This fixes gcc-toolchain build of exception.S.

Reported and tested by: kevans
Sponsored by: The FreeBSD Foundation
MFC after: 1 week

3 years agoUpdate arcmsr(4) to 1.50.00.00:
delphij [Fri, 16 Oct 2020 15:55:06 +0000 (15:55 +0000)]
Update arcmsr(4) to 1.50.00.00:

Add support for ARC-1886, NVMe/SAS/SATA controller.

Many thanks to Areca for continuing to support FreeBSD.

Submitted by:   黃清隆 <ching2048 areca com tw>
MFC after:      2 weeks

3 years agoMakefile: add a small blurb about building with gcc xtoolchain
kevans [Fri, 16 Oct 2020 15:16:23 +0000 (15:16 +0000)]
Makefile: add a small blurb about building with gcc xtoolchain

The key details are to install the appropriate flavor of devel/freebsd-gcc9
and pass CROSS_TOOLCHAIN while building.

Suggested by: kib

3 years ago This fixes some fun type size truncation that shows up giving errors like
adrian [Fri, 16 Oct 2020 14:28:13 +0000 (14:28 +0000)]
 This fixes some fun type size truncation that shows up giving errors like
" changes value from '287948901175001088' to '0' "

.. which turns out is a known issue with later gcc's.

eg - https://lists.gnu.org/archive/html/bug-gnulib/2012-03/msg00154.html

It was fixed up upstream corelib/gnulib in commit hash
252b52457da7887667c036d18cc5169777615bb0
(eg in https://github.com/coreutils/gnulib/commit/252b52457da7887667c036d18cc5169777615bb0)

TEST PLAN
  - compiled/run for gcc-6.4 on amd64

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

3 years agoarm64: export a few more HWCAPs
mhorne [Fri, 16 Oct 2020 13:37:58 +0000 (13:37 +0000)]
arm64: export a few more HWCAPs

These were missed in the previous pass. The extensions (partially)
supported by this change are:
 - ARMv8.2-FHM, Floating-point multiplication variant
 - ARMv8.4-LSE, Large System Extensions
 - ARMv8.4-DIT, Data Independent Timing instructions

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

3 years agoUpdate the ID_AA64MMFR2_EL1 register definitions
mhorne [Fri, 16 Oct 2020 13:35:29 +0000 (13:35 +0000)]
Update the ID_AA64MMFR2_EL1 register definitions

This brings these definitions in sync with the ARMv8.6 version of the
architecture reference manual.

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

3 years agoTrigger soft lifetime expiration on sequence number
mw [Fri, 16 Oct 2020 11:27:01 +0000 (11:27 +0000)]
Trigger soft lifetime expiration on sequence number

This patch adds 80% of UINT32_MAX limit on sequence number.
When sequence number reaches limit kernel sends SADB_EXPIRE message to
IKE daemon which is responsible to perform rekeying.

Submitted by:           Patryk Duda <pdk@semihalf.com>
Reviewed by:            ae
Differential revision:  https://reviews.freebsd.org/D22370
Obtained from:          Semihalf
Sponsored by:           Stormshield

3 years agoAdd support for IPsec ESN and pass relevant information to crypto layer
mw [Fri, 16 Oct 2020 11:25:45 +0000 (11:25 +0000)]
Add support for IPsec ESN and pass relevant information to crypto layer

Implement support for including IPsec ESN (Extended Sequence Number) to
both encrypt and authenticate mode (eg. AES-CBC and SHA256) and combined
mode (eg. AES-GCM). Both ESP and AH protocols are updated. Additionally
pass relevant information about ESN to crypto layer.

For the ETA mode the ESN is stored in separate crp_esn buffer because
the high-order 32 bits of the sequence number are appended after the
Next Header (RFC 4303).

For the AEAD modes the high-order 32 bits of the sequence number
[e.g.  RFC 4106, Chapter 5 AAD Construction] are included as part of
crp_aad (SPI + ESN (32 high order bits) + Seq nr (32 low order bits)).

Submitted by:           Grzegorz Jaszczyk <jaz@semihalf.com>
                        Patryk Duda <pdk@semihalf.com>
Reviewed by:            jhb, gnn
Differential revision:  https://reviews.freebsd.org/D22369
Obtained from:          Semihalf
Sponsored by:           Stormshield

3 years agoImplement anti-replay algorithm with ESN support
mw [Fri, 16 Oct 2020 11:24:12 +0000 (11:24 +0000)]
Implement anti-replay algorithm with ESN support

As RFC 4304 describes there is anti-replay algorithm responsibility
to provide appropriate value of Extended Sequence Number.

This patch introduces anti-replay algorithm with ESN support based on
RFC 4304, however to avoid performance regressions window implementation
was based on RFC 6479, which was already implemented in FreeBSD.

To keep things clean and improve code readability, implementation of window
is kept in seperate functions.

Submitted by:           Grzegorz Jaszczyk <jaz@semihalf.com>
                        Patryk Duda <pdk@semihalf.com>
Reviewed by:            jhb
Differential revision:  https://reviews.freebsd.org/D22367
Obtained from:          Semihalf
Sponsored by:           Stormshield