]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
3 years agocache: elide vhold/vdrop around promoting negative entry
mjg [Fri, 16 Oct 2020 00:55:57 +0000 (00:55 +0000)]
cache: elide vhold/vdrop around promoting negative entry

3 years agocache: dedup code for negative promotion
mjg [Fri, 16 Oct 2020 00:55:31 +0000 (00:55 +0000)]
cache: dedup code for negative promotion

3 years agocache: neglist -> nl; negstate -> ns
mjg [Fri, 16 Oct 2020 00:55:09 +0000 (00:55 +0000)]
cache: neglist -> nl; negstate -> ns

No functional changes.

3 years agoBump the ISO EFI partition size from 1024 to 2048, following r366732.
gjb [Thu, 15 Oct 2020 23:05:13 +0000 (23:05 +0000)]
Bump the ISO EFI partition size from 1024 to 2048, following r366732.

Suggested by: imp
Sponsored by: Rubicon Communications, LLC (netgate.com)

3 years agoSimplify preload_dump() condition
mhorne [Thu, 15 Oct 2020 20:21:15 +0000 (20:21 +0000)]
Simplify preload_dump() condition

Hiding this feature behind RB_VERBOSE is gratuitous. The tunable is enough
to limit its use to only those who explicitly request it.

Suggested by: kevans

3 years agokldxref: Avoid buffer overflows in parse_pnp_list
jrtc27 [Thu, 15 Oct 2020 18:03:14 +0000 (18:03 +0000)]
kldxref: Avoid buffer overflows in parse_pnp_list

We convert a string like "W32:vendor/device" into "I:vendor;I:device",
where the output is longer than the input, but only allocate space equal
to the length of the input, leading to a buffer overflow.

Instead use open_memstream so we get a safe dynamically-grown buffer.

Found by: CHERI
Reviewed by: imp, jhb (mentor)
Approved by: imp, jhb (mentor)
Obtained from: CheriBSD
Differential Revision: https://reviews.freebsd.org/D26637

3 years agocache: split hotlist between existing negative lists
mjg [Thu, 15 Oct 2020 17:44:17 +0000 (17:44 +0000)]
cache: split hotlist between existing negative lists

This simplifies the code while allowing for concurrent negative eviction
down the road.

Cache misses increased slightly due to higher rate of evictions allowed by
the change.

The current algorithm remains too aggressive.

3 years agocache: make neglist an array given the static size
mjg [Thu, 15 Oct 2020 17:42:22 +0000 (17:42 +0000)]
cache: make neglist an array given the static size

3 years agoDrop unsolicited responses to the still attaching CODECs.
mav [Thu, 15 Oct 2020 17:40:02 +0000 (17:40 +0000)]
Drop unsolicited responses to the still attaching CODECs.

It is reported to fix kernel panics when early unsolicited responses
delivered to the CODEC device not having driver attached yet.

PR: 250248
Reported by: Rajeev Pillai <rajeev_v_pillai@yahoo.com>
Reviewed by: avg
MFC after: 2 weeks

3 years agoIncrease the amd64 ISO ESP file size from 800KB to 1024KB.
gjb [Thu, 15 Oct 2020 17:12:58 +0000 (17:12 +0000)]
Increase the amd64 ISO ESP file size from 800KB to 1024KB.

At some poing over the last week, the bootx64.efi file has grown
past the 800KB threshold, resulting in being unable to copy it to
the EFI/BOOT directory.

 # stat -f %z efiboot.znWo7m
 819200
 # stat -f %z stand-test.PIEugN/EFI/BOOT/bootx64.efi
 842752

The comment in the script that creates the ISOs suggests that 800KB
is the maximum allowed for the boot code, however I was able to
boot an ISO with a 1024KB boot partition.  Additionally, I verified
against an ISO from OtherOS, where the boot EFI partition is 2.4MB.

Sponsored by: Rubicon Communications, LLC (netgate.com)

3 years agophysio: Don't store user addresses in bio_data
brooks [Thu, 15 Oct 2020 17:05:21 +0000 (17:05 +0000)]
physio: Don't store user addresses in bio_data

Only assign the address from the iovec to bio_data if it is a kernel
address.  This was the single place where bio_data stored (however
briefly) a userspace pointer.

Reviewed by: imp, markj
Obtained from: CheriBSD
MFC after: 1 week
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D26783

3 years agoFix nvmecontrol logpage -i parameter.
mav [Thu, 15 Oct 2020 15:36:08 +0000 (15:36 +0000)]
Fix nvmecontrol logpage -i parameter.

MFC after: 3 days

3 years ago[pfctl_tests] Add missing void to empty function declaration
adrian [Thu, 15 Oct 2020 14:56:51 +0000 (14:56 +0000)]
[pfctl_tests] Add missing void to empty function declaration

Our gcc-6.4 flags require non-empty function declarations.
Fix this to match the rest of the codebase.

Tested:

* compiled on gcc-6.4 for amd64

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

3 years ago[tests] Fix itimer test warning-errors on gcc-6.4
adrian [Thu, 15 Oct 2020 14:55:07 +0000 (14:55 +0000)]
[tests] Fix itimer test warning-errors on gcc-6.4

This fixes a "suggested parens" compile warning-into-error
that shows up on gcc-6.4.

Reviewed by: ngie
Differential Revision: https://reviews.freebsd.org/D26789

3 years agomove vmware pv drivers to sys/conf/files
emaste [Thu, 15 Oct 2020 14:37:51 +0000 (14:37 +0000)]
move vmware pv drivers to sys/conf/files

VMware now has arm64 support; move these to MI files in advance of
building them on arm64.

PR: 250308
Reported by: Vincent Milum Jr
MFC after: 1 week
Sponsored by: The FreeBSD Foundation

3 years agoFix formatting of SYNOPSIS
0mp [Thu, 15 Oct 2020 14:17:45 +0000 (14:17 +0000)]
Fix formatting of SYNOPSIS

There was an unnecessary newline being added before Nm.

MFC after: 3 days

3 years agoSplit-out Guest Address Space (GAS) macroses to a separate header.
br [Thu, 15 Oct 2020 13:47:52 +0000 (13:47 +0000)]
Split-out Guest Address Space (GAS) macroses to a separate header.

Sponsored by: Innovate DSbD

3 years agoProvide a slightly more-tolerant set of thermal parameters for PowerMac
nwhitehorn [Thu, 15 Oct 2020 13:43:43 +0000 (13:43 +0000)]
Provide a slightly more-tolerant set of thermal parameters for PowerMac
motherboard temperatures. In particular, the U4 northbridge die is very
hard to cool or heat effectively with fans and is not responsive to load.
It generally sits around 64C, where it seems happy, so (like Linux) just
declare that to be its target temperature.

This makes the PowerMac G5 much less loud, with no change in the
temperatures of any system components.

MFC after: 2 weeks

3 years agoWith some popular multiplayer games (such as Counter-Strike: Global
trasz [Thu, 15 Oct 2020 12:48:30 +0000 (12:48 +0000)]
With some popular multiplayer games (such as Counter-Strike: Global
Offensive) the Linux Steam client likes to occasionally scan the game
process memory, presumably as part anti-cheat measures. Turns out
the client also expects each inode entry to be followed by a space
character, otherwise the parsing code crashes.

PR: 248216
Submitted by: Alex S <iwtcex@gmail.com>
MFC after: 2 weeks

3 years agoHyper-V: hn: Relinquish cpu in HN_LOCK to avoid deadlock
whu [Thu, 15 Oct 2020 11:44:28 +0000 (11:44 +0000)]
Hyper-V: hn: Relinquish cpu in HN_LOCK to avoid deadlock

The try lock loop in HN_LOCK put the thread spinning on cpu if the lock
is not available. It is possible to cause deadlock if the thread holding
the lock is sleeping. Relinquish the cpu to work around this problem even
it doesn't completely solve the issue. The priority inversion could cause
the livelock no matter how less likely it could happen. A more complete
solution may be needed in the future.

Reported by: Microsoft, Netapp
MFC after: 2 weeks
Sponsored by: Microsoft

3 years agoHyper-V: pcib: Check revoke status during device attach
whu [Thu, 15 Oct 2020 05:57:20 +0000 (05:57 +0000)]
Hyper-V: pcib: Check revoke status during device attach

It is possible that the vmbus pcib channel is revoked during attach path.
The attach path could be waiting for response from host and this response will never
arrive since the channel has already been revoked from host point of view. Check
this situation during wait complete and return failed if this happens.

Reported by: Netapp
MFC after: 2 weeks
Sponsored by: Microsoft
Differential Revision: https://reviews.freebsd.org/D26486

3 years agoBump __FreeBSD_version after addition of VOP_EAGAIN
mjg [Thu, 15 Oct 2020 05:11:16 +0000 (05:11 +0000)]
Bump __FreeBSD_version after addition of VOP_EAGAIN

3 years agozfs: g/c unused vop_vector zfsctl_ops_shares_dir
mjg [Thu, 15 Oct 2020 05:04:57 +0000 (05:04 +0000)]
zfs: g/c unused vop_vector zfsctl_ops_shares_dir

3 years agozfs: add missing fplookup vops
mjg [Thu, 15 Oct 2020 04:49:34 +0000 (04:49 +0000)]
zfs: add missing fplookup vops

Some vnodes come with a hack which inherits the fplookup flag despite having vops
which don't provide the routine.

Reported by: YAMAMOTO Shigeru <shigeru@os-hackers.jp>

3 years agovfs: add VOP_EAGAIN
mjg [Thu, 15 Oct 2020 04:48:14 +0000 (04:48 +0000)]
vfs: add VOP_EAGAIN

Can be used to stub fplookup for example.

3 years agoarm64: Increase NIRQ to 16k
scottph [Thu, 15 Oct 2020 03:12:00 +0000 (03:12 +0000)]
arm64: Increase NIRQ to 16k

Ampere Altra in a dual socket configuration has 12 ITSes for the
12 PCIe root complexes. The NIRQ interrupts are statically split
between each child of the gic bus, so here we increase that
value. 16k is enough for

  (#cpus * #its * max_pcie_bifurcation) LPIs + (#SPIs and #PPIs)

Reviewed by: jhb
Approved by: scottl (implicit)
MFC after: 1 week
Sponsored by: Ampere Computing
Differential Revision: https://reviews.freebsd.org/D26766

3 years agoFix for mis-interpretation of PCB_KERNFPU.
kib [Wed, 14 Oct 2020 23:01:41 +0000 (23:01 +0000)]
Fix for mis-interpretation of PCB_KERNFPU.

RIght now PCB_KERNFPU is used both as indication that kernel prepared
hardware FPU context to use and that the thread is fpu-kern
thread.  This also breaks fpu_kern_enter(FPU_KERN_NOCTX), since
fpu_kern_leave() then clears PCB_KERNFPU.

Introduce new flag PCB_KERNFPU_THR which indicates that the thread is
fpu-kern.  Do not clear PCB_KERNFPU if fpu-kern thread leaves noctx
fpu region.

Reported and tested by: jhb (amd64)
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D25511

3 years agoLimit workaround for errata E400 to appropriate AMD cpus.
kib [Wed, 14 Oct 2020 22:57:50 +0000 (22:57 +0000)]
Limit workaround for errata E400 to appropriate AMD cpus.

From Linux sources and several datasheets I looked at, it seems that
the workaround is only needed on families 0xf and 0x10.  For instance,
Ryzens do not implement the accessed MSR at all, it is documented as
reserved.  Also, hypervisors should not allow guest to put CPU into
idle state, so activate workaround only when on bare hardware.

While there, style the code:
    move MSR defines to specialreg.h
    move identification to initcpu.c

Reported by: whu
Reviewed by: avg
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D26470

3 years agoAvoid dump_avail[] redefinition.
kib [Wed, 14 Oct 2020 22:51:40 +0000 (22:51 +0000)]
Avoid dump_avail[] redefinition.

Move dump_avail[] extern declaration and inlines into a new header
vm/vm_dumpset.h.  This fixes default gcc build for mips.

Reviewed by: alc, scottph
Tested by: kevans (previous version)
Sponsored by: The FreeBSD Foundation
Differential revision: https://reviews.freebsd.org/D26741

3 years agoSplit-out iommu type definitions to a separate header.
br [Wed, 14 Oct 2020 21:22:23 +0000 (21:22 +0000)]
Split-out iommu type definitions to a separate header.

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

3 years ago[skein] Fix compile issue with unknown symbol SKEIN_ASM_UNROLL1024
adrian [Wed, 14 Oct 2020 20:55:31 +0000 (20:55 +0000)]
[skein] Fix compile issue with unknown symbol SKEIN_ASM_UNROLL1024

Weirdly, I needed to sprinkle more parens here to get gcc-as in 6.4
to correctly generate things.

Without them, I'd get an unknown variable reference to SKEIN_ASM_UNROLL1024.

This at least links now, but I haven't run any test cases against it.
It may be worthwhile doing it in case gcc-as demands we liberally sprinkle
more brackets around variables in .if statements.

Thanks to ed for the suggestion of just sprinkling more brackets to
see if that helped.

Reviewed by: emaste

3 years agoRewrite pfctl_test in C to reduce testsuite run time
arichardson [Wed, 14 Oct 2020 17:39:50 +0000 (17:39 +0000)]
Rewrite pfctl_test in C to reduce testsuite run time

The new C test takes 25 seconds on QEMU-RISC-V, wheras the shell version
takes 332 seconds.

Even with the latest optimizations to atf-sh this test still takes a few
seconds to startup in QEMU. Re-writing it in C reduces the runtime for a
single test from about 2-3 seconds to less than .5 seconds. Since there
are ~80 tests, this adds up to about 3-4 minutes.
This may not seem like a big speedup, but before the recent optimizations
to avoid atf_get_srcdir, each test took almost 100 seconds on QEMU RISC-V
instead of 3. This also significantly reduces the time it takes to list
the available test cases, which speeds up running the tests via kyua:

```
root@qemu-riscv64-alex:~ # /usr/bin/time kyua test -k /usr/tests/sbin/pfctl/Kyuafile pfctl_test_old
...
158/158 passed (0 failed)
      332.08 real        42.58 user       286.17 sys
root@qemu-riscv64-alex:~ # /usr/bin/time kyua test -k /usr/tests/sbin/pfctl/Kyuafile pfctl_test
158/158 passed (0 failed)
       24.96 real         9.75 user        14.26 sys

root@qemu-riscv64-alex:/usr/tests/sbin/pfctl # /usr/bin/time ./pfctl_test pf1001
pfctl_test: WARNING: Running test cases outside of kyua(1) is unsupported
pfctl_test: WARNING: No isolation nor timeout control is being applied; you may get unexpected failures; see atf-test-case(4)
Running pfctl -o none -nvf /usr/tests/sbin/pfctl/./files/pf1001.in
---
binat on em0 inet6 from fc00::/64 to any -> fc00:0:0:1::/64
binat on em0 inet6 from any to fc00:0:0:1::/64 -> fc00::/64
---
passed
        0.17 real         0.06 user         0.08 sys
root@qemu-riscv64-alex:/usr/tests/sbin/pfctl # /usr/bin/time ./pfctl_test_old pf1001
pfctl_test_old: WARNING: Running test cases outside of kyua(1) is unsupported
pfctl_test_old: WARNING: No isolation nor timeout control is being applied; you may get unexpected failures; see atf-test-case(4)
Id  Refs Name
141    1 pf
Executing command [ pfctl -o none -nvf - ]
passed
        1.73 real         0.25 user         1.41 sys
root@qemu-riscv64-alex:/usr/tests/sbin/pfctl # /usr/bin/time ./pfctl_test_old -l > /dev/null
       24.36 real         2.26 user        21.86 sys
root@qemu-riscv64-alex:/usr/tests/sbin/pfctl # /usr/bin/time ./pfctl_test -l > /dev/null
        0.04 real         0.02 user         0.01 sys
```

The speedups are even more noticeable on CHERI-RISC-V (since QEMU runs
slower when emulating CHERI instructions):
```
root@qemu-cheri-alex:/usr/tests/sbin/pfctl # /usr/bin/time ./pfctl_test_new -l > /dev/null
        0.51 real         0.49 user         0.00 sys
root@qemu-cheri-alex:/usr/tests/sbin/pfctl # /usr/bin/time ./pfctl_test -l > /dev/null
       34.20 real        32.69 user         0.16 sys
root@qemu-cheri-alex:/usr/tests/sbin/pfctl # /usr/bin/time ./pfctl_test pf1001
pfctl_test: WARNING: Running test cases outside of kyua(1) is unsupported
pfctl_test: WARNING: No isolation nor timeout control is being applied; you may get unexpected failures; see atf-test-case(4)
Id  Refs Name
147    1 pf
Executing command [ pfctl -o none -nvf - ]
passed
        5.74 real         5.41 user         0.03 sys
root@qemu-cheri-alex:/usr/tests/sbin/pfctl # /usr/bin/time ./pfctl_test_new pf1001
pfctl_test_new: WARNING: Running test cases outside of kyua(1) is unsupported
pfctl_test_new: WARNING: No isolation nor timeout control is being applied; you may get unexpected failures; see atf-test-case(4)
Running pfctl -o none -nvf /usr/tests/sbin/pfctl/./files/pf1001.in
---
binat on em0 inet6 from fc00::/64 to any -> fc00:0:0:1::/64
binat on em0 inet6 from any to fc00:0:0:1::/64 -> fc00::/64
---
passed
        0.68 real         0.66 user         0.00 sys
root@qemu-cheri-alex:/usr/tests/sbin/pfctl #
```

Reviewed By: kp
Differential Revision: https://reviews.freebsd.org/D26779

3 years agoUse RTD3 Entry Latency value as shutdown timeout.
mav [Wed, 14 Oct 2020 15:50:28 +0000 (15:50 +0000)]
Use RTD3 Entry Latency value as shutdown timeout.

This field was not in specs when the driver was written, but now there
are SSDs with the reported latency of 10s, where hardcoded value of 5s
seems to be not enough sometimes, causing shutdown timeout messages.

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

3 years agoRemove direct user access from the arm64 copyinstr
andrew [Wed, 14 Oct 2020 15:31:42 +0000 (15:31 +0000)]
Remove direct user access from the arm64 copyinstr

These already use the load variant that simulates userspace access.
Remove the macros that enable normal loads and stores from userspace
as they are unneeded.

Sponsored by: Innovate UK

3 years agoAdd a per-each macro IOMMU_DOMAIN_UNLOAD_SLEEP which allows to sleep
br [Wed, 14 Oct 2020 14:51:11 +0000 (14:51 +0000)]
Add a per-each macro IOMMU_DOMAIN_UNLOAD_SLEEP which allows to sleep
during iommu guest address space entries unload.

Suggested by: kib
Sponsored by: Innovate DSbD
Differential Revision: https://reviews.freebsd.org/D26722

3 years ago[skein] Fix compilation on gnu assembler with gcc-6 and gcc-9
adrian [Wed, 14 Oct 2020 14:29:56 +0000 (14:29 +0000)]
[skein] Fix compilation on gnu assembler with gcc-6 and gcc-9

For some reason I don't want to really understand, the following
happens with gnu as.

/home/adrian/git/freebsd/src/sys/crypto/skein/amd64/skein_block_asm.S: Assembler messages:
/home/adrian/git/freebsd/src/sys/crypto/skein/amd64/skein_block_asm.S:466: Error: found '(', expected: ')'
/home/adrian/git/freebsd/src/sys/crypto/skein/amd64/skein_block_asm.S:466: Error: junk at end of line, first unrecognized character is `('
/home/adrian/git/freebsd/src/sys/crypto/skein/amd64/skein_block_asm.S:795: Error: found '(', expected: ')'
/home/adrian/git/freebsd/src/sys/crypto/skein/amd64/skein_block_asm.S:795: Error: junk at end of line, first unrecognized character is `('
/home/adrian/git/freebsd/src/sys/crypto/skein/amd64/skein_block_asm.S:885: Error: non-constant expression in ".if" statement
/home/adrian/git/freebsd/src/sys/crypto/skein/amd64/skein_block_asm.S:885: Error: non-constant expression in ".if" statement
/home/adrian/git/freebsd/src/sys/crypto/skein/amd64/skein_block_asm.S:885: Error: non-constant expression in ".if" statement
/home/adrian/git/freebsd/src/sys/crypto/skein/amd64/skein_block_asm.S:885: Error: non-constant expression in ".if" statement
/home/adrian/git/freebsd/src/sys/crypto/skein/amd64/skein_block_asm.S:885: Error: non-constant expression in ".if" statement
/home/adrian/git/freebsd/src/sys/crypto/skein/amd64/skein_block_asm.S:885: Error: non-constant expression in ".if" statement

After an exhaustive search and experimentation at 11pm, I discovered that
putting them in parentheses fixes the compilation.

Ed pointed out that I could likely fix this in a bunch of other
locations but I'd rather leave these alone until other options
are enabled.

Tested:

* gcc-6, amd64

Reviewed by: emaste

3 years agoAdd iommu_get_ctx_domain() that allows to get iommu domain for a given
br [Wed, 14 Oct 2020 14:12:15 +0000 (14:12 +0000)]
Add iommu_get_ctx_domain() that allows to get iommu domain for a given
iommu context.

Submitted by: andrew
Sponsored by: Innovate DSbD

3 years agoRename a header protection macro.
br [Wed, 14 Oct 2020 13:39:50 +0000 (13:39 +0000)]
Rename a header protection macro.

Sponsored by: DARPA, AFRL

3 years agoAdd 'netserver' command to EFI loader.
mmel [Wed, 14 Oct 2020 13:13:14 +0000 (13:13 +0000)]
Add 'netserver' command to EFI loader.

In some environments is difficult to access bootp/dhcp
configuration as "standard user". Add a command that allows to set
or display the URI of the network server used as "net:" device.
Currently only tftp and nfs protocols are supported.

Typical usage pattern is:
netserver tftp://192.168.168.1/path_to_obj_dir/arm.armv7/sys/GENERIC/
boot net:kernel

Reviewed by: imp, kevans
MFC after: 4 weeks
Differential Revision: https://reviews.freebsd.org/D26736

3 years agoFix more -Wundef warnings during bootstrap
arichardson [Wed, 14 Oct 2020 12:28:54 +0000 (12:28 +0000)]
Fix more -Wundef warnings during bootstrap

3 years agoDon't build the malo module with clang 10
arichardson [Wed, 14 Oct 2020 12:28:48 +0000 (12:28 +0000)]
Don't build the malo module with clang 10

Compiling it with LLVM 10 triggers https://bugs.llvm.org/show_bug.cgi?id=44351
While LLVM 11 is the default compiler, I regularly build with
CROSS_TOOLCHAIN=llvm10 or use system packages for clang on Linux/macOS and
those have not been updated to 11 yet.

3 years agoinstall(1): Avoid unncessary fstatfs() calls and use mmap() based on size
arichardson [Wed, 14 Oct 2020 12:28:41 +0000 (12:28 +0000)]
install(1): Avoid unncessary fstatfs() calls and use mmap() based on size

According to git blame the trymmap() function was added in 1996 to skip
mmap() calls for NFS file systems. However, nowadays mmap() should be
perfectly safe even on NFS. Importantly, onl ufs and cd9660 file systems
were whitelisted so we don't use mmap() on ZFS. It also prevents the use
of mmap() when bootstrapping from macOS/Linux since on those systems the
trymmap() function was always returning zero due to the missing MFSNAMELEN
define.

This change keeps the trymmap() function but changes it to check whether
using mmap() can reduce the number of system calls that are required.
Using mmap() only reduces the number of system calls if we need multiple read()
syscalls, i.e. if the file size is > MAXBSIZE. However, mmap() is more expensive
than read() so this sets the threshold at 4 fewer syscalls. Additionally, for
larger file size mmap() can significantly increase the number of page faults,
so avoid it in that case.

It's unclear whether using mmap() is ever faster than a read with an appropriate
buffer size, but this change at least removes two unnecessary system calls
for every file that is installed.

Reviewed By: markj
Differential Revision: https://reviews.freebsd.org/D26041

3 years agocxgbe(4): Do not request FEC when requesting speeds that don't have FEC.
np [Wed, 14 Oct 2020 10:12:39 +0000 (10:12 +0000)]
cxgbe(4): Do not request FEC when requesting speeds that don't have FEC.

MFC after: 1 week
Sponsored by: Chelsio Communications

3 years agoImplement SIOCGIFALIAS.
ae [Wed, 14 Oct 2020 09:22:54 +0000 (09:22 +0000)]
Implement SIOCGIFALIAS.

It is lightweight way to check if an IPv4 address exists.

Submitted by: Roy Marples
Reviewed by: gnn, melifaro
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D26636

3 years agocxgbe(4): unimplemented cudbg routines should return the correct
np [Wed, 14 Oct 2020 08:04:39 +0000 (08:04 +0000)]
cxgbe(4): unimplemented cudbg routines should return the correct
internal error code and not an errno.

Submitted by: Krishnamraju Eraparaju @ Chelsio
MFC after: 1 week
Sponsored by: Chelsio Communications

3 years agoaxgbe: fix tinderbox build
mjg [Wed, 14 Oct 2020 02:23:49 +0000 (02:23 +0000)]
axgbe: fix tinderbox build

3 years ago[traceroute6] Don't do the casper bits when we're not doing casper
adrian [Wed, 14 Oct 2020 00:01:17 +0000 (00:01 +0000)]
[traceroute6] Don't do the casper bits when we're not doing casper

This with the previous patch I committed makes traceroute6/traceroute
compile fine when libcasper isn't enabled.

This complains strongly with unused variables and such when compiled
with gcc-6 on mips32.

Tested:

* compiled/run on mips32 hardware (AR9344)

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

3 years agoFix sbuf_finish() error code check in user-space.
mav [Tue, 13 Oct 2020 23:29:06 +0000 (23:29 +0000)]
Fix sbuf_finish() error code check in user-space.

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

3 years ago[libcasper] Update cap_dns API to not trigger unused variable warnings when disabled
adrian [Tue, 13 Oct 2020 22:49:43 +0000 (22:49 +0000)]
[libcasper] Update cap_dns API to not trigger unused variable warnings when disabled

When compiling without casper these API calls result in unused variable warnings.
Using #defines was lovely in the past but unfortunately it triggers warnings
which can cascade into errors.

Instead, just inline with some fallthrough functions and keep things happy.

Tested:

* gcc-6 targeting mips32, with casper disabled

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

3 years agoFix various warnings with higher WARNS.
jhb [Tue, 13 Oct 2020 22:20:03 +0000 (22:20 +0000)]
Fix various warnings with higher WARNS.

- Rename global 'crid' to 'requested_crid' to avoid shadowing.
- Remove some unused function arguments.
- Use __DECONST().

3 years agoAllow IP over IB to work with multiple FIBs.
rpokala [Tue, 13 Oct 2020 20:41:51 +0000 (20:41 +0000)]
Allow IP over IB to work with multiple FIBs.

Call M_SETFIB() to make sure the IPoIB packet is directed to the correct
interface-specific FIB.

This was sufficient to allow general-purpose routing using the default FIB,
and a separate FIB for routing between IPoIB on ib0 and IPoEthernet on mce0.

Reviewed by: hselasky
Obtained from: Anmol Kumar <anmolk at panasas dot com>
MFC after: 1 week
Sponsored by: Panasas
Differential Revision: https://reviews.freebsd.org/D25239

3 years agoFreeBSD: fix panic due to tqid overflow
mjg [Tue, 13 Oct 2020 20:40:09 +0000 (20:40 +0000)]
FreeBSD: fix panic due to tqid overflow

The 32-bit counter eventually wraps to 0 which is a sentinel for invalid
id.

Make it 64-bit on LP64 platforms and 0-check otherwise.

Note: Linux counterpart uses id stored per queue instead of a global.
I did not check going that way is feasible with the goal being the
minimal fix doing the job.

Reported by: YAMAMOTO Shigeru <shigeru@os-hackers.jp>
Reviewed by: mav
Differential Revision: https://reviews.freebsd.org/D26759

3 years agoRemove --ld-path=* from _LDFLAGS
brooks [Tue, 13 Oct 2020 20:04:13 +0000 (20:04 +0000)]
Remove --ld-path=* from _LDFLAGS

It makes no sense to pass --ld-path to direct ${LD} invocations.

This was missed in r366270 due to not doing a clean build.

3 years agoMerge commit 35ecc7fe4 from llvm git (by Hubert Tong):
dim [Tue, 13 Oct 2020 19:42:22 +0000 (19:42 +0000)]
Merge commit 35ecc7fe4 from llvm git (by Hubert Tong):

  [clang][Sema] Fix PR47676: Handle dependent AltiVec C-style cast

  Fix premature decision in the presence of type-dependent expression
  operands on whether AltiVec vector initializations from single
  expressions are "splat" operations.

  Verify that the instantiation is able to determine the correct cast
  semantics for both the scalar type and the vector type case.

  Note that, because the change only affects the single-expression case
  (and the target type is an AltiVec-style vector type), the
  replacement of a parenthesized list with a parenthesized expression
  does not change the semantics of the program in a program-observable
  manner.

  Reviewed By: aaron.ballman

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

This should fix 'Assertion failed: (isScalarType()), function
getScalarTypeKind, file /usr/src/contrib/llvm-project/clang/lib/AST
/Type.cpp, line 2146', when building the graphics/opencv-core port for
powerpc64le.

Requested by: pkubaj
MFC after: 4 weeks
X-MFC-With: r364284

3 years agoJoin to AllHosts multicast group again when adding an existing IPv4 address.
ae [Tue, 13 Oct 2020 19:34:36 +0000 (19:34 +0000)]
Join to AllHosts multicast group again when adding an existing IPv4 address.

When SIOCAIFADDR ioctl configures an IPv4 address that is already exist,
it removes old ifaddr. When this IPv4 address is only one configured on
the interface, this also leads to leaving from AllHosts multicast group.
Then an address is added again, but due to the bug, this doesn't lead
to joining to AllHosts multicast group.

Submitted by: yannis.planus_alstomgroup.com
Reviewed by: gnn
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D26757

3 years agoAdd IPv4 fragments reassembling to NAT64LSN.
ae [Tue, 13 Oct 2020 18:57:42 +0000 (18:57 +0000)]
Add IPv4 fragments reassembling to NAT64LSN.

NAT64LSN requires the presence of upper level protocol header
in a IPv4 datagram to find corresponding state to make translation.
Now it will be handled automatically by nat64lsn instance.

Reviewed by: melifaro
Obtained from: Yandex LLC
MFC after: 1 week
Sponsored by: Yandex LLC
Differential Revision: https://reviews.freebsd.org/D26758

3 years ago[ath] Set WARNS to 0 here for now
adrian [Tue, 13 Oct 2020 18:36:35 +0000 (18:36 +0000)]
[ath] Set WARNS to 0 here for now

There are still more warnings to fix here, but gcc on mips treats a lot
of these as failures.

So stop it stopping me for now whilst I fix them.

3 years ago[athdebug] Fix warnings generated by gcc on mips
adrian [Tue, 13 Oct 2020 18:35:43 +0000 (18:35 +0000)]
[athdebug] Fix warnings generated by gcc on mips

* commented out currently unused/dead code; need to see what it was once
  used for
* remove unused variable
* fix typing

3 years agoeliminate possible race in parallel TLB shootdown IPI
tychon [Tue, 13 Oct 2020 18:28:48 +0000 (18:28 +0000)]
eliminate possible race in parallel TLB shootdown IPI

On the target side TLB shootdown IPI handler, prevent the compiler
from performing a forward store optimization which may mask a
subsequent update to the scoreboard by the initiator.

Reported by: Max Laier, Anton Rang
Discussed with: kib
Sponsored by: Dell EMC Isilon

3 years agoAdd support to the KTLS OCF module for AES-CBC MTE ciphersuites.
jhb [Tue, 13 Oct 2020 18:04:19 +0000 (18:04 +0000)]
Add support to the KTLS OCF module for AES-CBC MTE ciphersuites.

This is a simplistic approach which encrypts each TLS record in two
separate passes: one to generate the MAC and a second to encrypt.
This supports TLS 1.0 connections with implicit IVs as well as TLS
1.1+ with explicit IVs.

Reviewed by: gallatin
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D26730

3 years agoctl.conf(5): fix LUN size in UCL format example.
rew [Tue, 13 Oct 2020 18:00:23 +0000 (18:00 +0000)]
ctl.conf(5): fix LUN size in UCL format example.

Remove quotes around size in the LUN section and change the suffix to 'GB'. The
UCL format does recognize 'G' on its own, which uses a base 10 multiplier where
'GB' uses a 2 power multiplier.

Document the difference between valid suffixes when using ctl.conf(5) in the
general syntax form or in UCL format.

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

3 years agoPermit sending empty fragments for TLS 1.0.
jhb [Tue, 13 Oct 2020 17:30:34 +0000 (17:30 +0000)]
Permit sending empty fragments for TLS 1.0.

Due to a weakness in the TLS 1.0 protocol, OpenSSL will periodically
send empty TLS records ("empty fragments").  These TLS records have no
payload (and thus a page count of zero).  m_uiotombuf_nomap() was
returning NULL instead of an empty mbuf, and a few places needed to be
updated to treat an empty TLS record as having a page count of "1" as
0 means "no work to do" (e.g. nothing to encrypt, or nothing to mark
ready via sbready()).

Reviewed by: gallatin
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D26729

3 years agoAdd support for FPU_KERN_NOCTX.
jhb [Tue, 13 Oct 2020 17:27:37 +0000 (17:27 +0000)]
Add support for FPU_KERN_NOCTX.

This mirrors the implementation on amd64.

Reviewed by: kib
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D26754

3 years agoAdd a <machine/fpu.h> for i386 that includes <machine/npx.h>.
jhb [Tue, 13 Oct 2020 17:26:12 +0000 (17:26 +0000)]
Add a <machine/fpu.h> for i386 that includes <machine/npx.h>.

arm64 has a similar wrapper.  This permits defining <machine/fpu.h> as
the standard header for fpu_kern_*.

Reviewed by: kib
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D26753

3 years agolibgssapi: modernize static string array use
brooks [Tue, 13 Oct 2020 17:14:30 +0000 (17:14 +0000)]
libgssapi: modernize static string array use

Use designated initializers to document positions in the arrays rather
than requiring counting. Use nitems() rather than rolling it by hand to
count elements.

Also, passify a Clang 12 warning about suspcious string concatenation
within an array initializer by adding parentheses.

Reviewed by: emaste
MFC after: 1 week
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D26592

3 years agoUse adrp in the arm64 efi loader
andrew [Tue, 13 Oct 2020 16:51:05 +0000 (16:51 +0000)]
Use adrp in the arm64 efi loader

On startup the arm64 efi loaders need to know PC-relative addresses.
Previously we used the adr instruction to find this address, however this
instruction is limited to +/- 1MiB.

Switch to adrp to find the 4k page the address is within and an add to
set the bottom 12 bits. This lets us address +/- 4GiB which should be
large enough for now.

Reported by: imp
MFC after: 2 weeks
Sponsored by: Innovate UK

3 years agoImplement more RCU list functions in the LinuxKPI.
hselasky [Tue, 13 Oct 2020 16:19:21 +0000 (16:19 +0000)]
Implement more RCU list functions in the LinuxKPI.

This also fixes a bug in the existing list_add_rcu() where the
prev->prev pointer was updated to the new element instead of
next->prev. Currently this function is not widely used.

MFC after: 1 week
Sponsored by: Mellanox Technologies // NVIDIA Networking

3 years agoBring the request_descriptor union into harmony internally. No
scottl [Tue, 13 Oct 2020 14:10:49 +0000 (14:10 +0000)]
Bring the request_descriptor union into harmony internally.  No
functional change.

3 years agopf: do not remove kifs that are referenced by rules
kp [Tue, 13 Oct 2020 11:04:00 +0000 (11:04 +0000)]
pf: do not remove kifs that are referenced by rules

Even if a kif doesn't have an ifp or if_group pointer we still can't delete it
if it's referenced by a rule. In other words: we must check rulerefs as well.

While we're here also teach pfi_kif_unref() not to remove kifs with flags.

Reported-by: syzbot+b31d1d7e12c5d4d42f28@syzkaller.appspotmail.com
MFC after:   2 weeks

3 years agoBump __FreeBSD_version for the fix to arm64 write-only mappings
andrew [Tue, 13 Oct 2020 10:31:12 +0000 (10:31 +0000)]
Bump __FreeBSD_version for the fix to arm64 write-only mappings

Sponsored by: Innovate UK

3 years agoFix write only mappings on arm64
andrew [Tue, 13 Oct 2020 10:26:15 +0000 (10:26 +0000)]
Fix write only mappings on arm64

When trapping on a wrote access to a buffer the kernel has mapped as write
only we should only pass the VM_PROT_WRITE flag. Previously the call to
vm_fault_trap as the VM_PROT_READ flag was unexpected.

Reported by: manu
Sponsored by: Innovate UK

3 years agoStop using -O instead of -O2 for MIPS
arichardson [Tue, 13 Oct 2020 08:14:33 +0000 (08:14 +0000)]
Stop using -O instead of -O2 for MIPS

Until clang 11 that was equivalent to -O2, but clang changed it to -O1 so
generated MIPS code will now be unnecessarily slow. It also removes a weird
special case from sys.mk.
This is similar to the D26471 change for debug kernels and should not change
anything since everything was previously building MIPS code at -O2 until the
clang 11 update.

Reviewed By: trasz
Differential Revision: https://reviews.freebsd.org/D26749

3 years agoDocument /boot/config as well as /boot.config
imp [Tue, 13 Oct 2020 05:39:43 +0000 (05:39 +0000)]
Document /boot/config as well as /boot.config

Add a note about /boot/config being an alternative location for this
information. Correct description of -P.

3 years agodevmatch: First appeared in 12.0
imp [Tue, 13 Oct 2020 05:32:00 +0000 (05:32 +0000)]
devmatch: First appeared in 12.0

Document that devmatch first appeared in FreeBSD 12.0. Also can't -> can not. But
it doesn't help the sentence much.

MFC After: 3 days

3 years agoDocument the rather suprising behavior with ' inside action rules.
imp [Tue, 13 Oct 2020 05:19:00 +0000 (05:19 +0000)]
Document the rather suprising behavior with ' inside action rules.

To prevent issues with odd shell characters appearing in, a surprising
shell feature is used. Document it and a workaround for it.

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

3 years agoForce __BMI__ experimental instructions off.
imp [Tue, 13 Oct 2020 04:37:57 +0000 (04:37 +0000)]
Force __BMI__ experimental instructions off.

The OpenZFS code that uses the BMI instructions is broken. Forcibly
disable them to prevent their use. When enabled, the build breaks.
This fixes the build when compiled for a core with BMI instructions.
This is the same fix committed in r364777, for the same issue.

Submitted by: Jung-uk Kim

3 years agoAdd back org.freebsd:zstd_compress to features_for_read
imp [Tue, 13 Oct 2020 03:49:12 +0000 (03:49 +0000)]
Add back org.freebsd:zstd_compress to features_for_read

This list is the of features that are allowed on the whole pool,
not the list of features that are implemented.

3 years agoTurn off zstd on aarch64
imp [Tue, 13 Oct 2020 02:36:16 +0000 (02:36 +0000)]
Turn off zstd on aarch64

loader support for zstd and zfs doesn't work for aarch64. Disable it
to unbreak the build.

3 years agoAdd zstd support to the boot loader.
imp [Mon, 12 Oct 2020 22:19:07 +0000 (22:19 +0000)]
Add zstd support to the boot loader.

Add support to the _STANDALONE environment enough bits of the kernel
that we can compile it. We still have a small zstd_shim.c since there
were 3 items that were a bit hard to nail down and may be cleaned up
in the future. These go hand in hand with a number of commits to
sys/sys in the past weeks, should this need be MFCd.

Discussed with: mmacy (in review and on IRC/Slack)
Reviewed by: freqlabs (on openzfs repo)
Differential Revision: https://reviews.freebsd.org/D26218

3 years agonewbus: use ssize_t to match sb's len and size, fix ordering of space check
imp [Mon, 12 Oct 2020 22:07:44 +0000 (22:07 +0000)]
newbus: use ssize_t to match sb's len and size, fix ordering of space check

Both s_len and s_size are ssize_t, so their differece is also more
properly a ssize_t not a size_t. Also, assert that len is <= size when
we enter. This should always be the case. Ensure that we have that one
byte that we write to the end of the buffer before we do so, though
the error should already be set on the buffer if not, and the only
times we supply 'partial' buffers they should be plenty large.

Reviewed by: cem, jhb (prior version, I did cem's suggestion)
Differential Revsion: https://reviews.freebsd.org/D26752

3 years agoMerge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
dim [Mon, 12 Oct 2020 21:35:29 +0000 (21:35 +0000)]
Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
release/11.x llvmorg-11.0.0-0-g176249bd673 (aka 11.0.0 release).

MFC after: 4 weeks
X-MFC-With: r364284

3 years agoBug fixes for the ads111x driver... make configurable gain and sample rate
ian [Mon, 12 Oct 2020 18:02:51 +0000 (18:02 +0000)]
Bug fixes for the ads111x driver... make configurable gain and sample rate
hints work on per-channel basis as documented, rather than chip-wide.  Also,
when configured via hints, return BUS_PROBE_NOWILDCARD on successful hints
match, so that the hints don't bogusly match other types of i2c chips.

3 years agopf tests: Test that 'set skip on <group>' works on new group members
kp [Mon, 12 Oct 2020 12:41:10 +0000 (12:41 +0000)]
pf tests: Test that 'set skip on <group>' works on new group members

There's a know issue where new group members don't get the 'set skip on'
applied until the rules are re-loaded.

Do this by setting rules that block all traffic, but skip members of the
'epair' group. If we can communicate over the epair interface we know the set
skip rule took effect, even if the rule was set before the interface was
created.

MFC after: 2 weeks

3 years agopf: create a kif for flags
kp [Mon, 12 Oct 2020 12:39:37 +0000 (12:39 +0000)]
pf: create a kif for flags

If userspace tries to set flags (e.g. 'set skip on <ifspec>') and <ifspec>
doesn't exist we should create a kif so that we apply the flags when the
<ifspec> does turn up.

Otherwise we'd end up in surprising situations where the rules say the
interface should be skipped, but it's not until the rules get re-applied.

Reviewed by: Lutz Donnerhacke <lutz_donnerhacke.de>
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D26742

3 years agoLink efi programs with -pie rather than -shared
arichardson [Mon, 12 Oct 2020 11:27:08 +0000 (11:27 +0000)]
Link efi programs with -pie rather than -shared

This was causing build failures in CheriBSD where we were passing -pie
already by default.

Reviewed By: andrew
Differential Revision: https://reviews.freebsd.org/D24787

3 years agoEnable SUBDIR_PARELLEL in lib/libclang_rt
arichardson [Mon, 12 Oct 2020 10:42:33 +0000 (10:42 +0000)]
Enable SUBDIR_PARELLEL in lib/libclang_rt

I noticed that this part of the build was taking much longer than
expected. Turns out it's due to not running the subdirs in parallel.
Reduces `make all` inside lib/libclang_rt time from 63s to 20s with -j32.

Reviewed By: dim
Differential Revision: https://reviews.freebsd.org/D26623

3 years agoFix build with -DBOOTSTRAP_ALL_TOOLS
arichardson [Mon, 12 Oct 2020 10:42:28 +0000 (10:42 +0000)]
Fix build with -DBOOTSTRAP_ALL_TOOLS

sbin/sysctl can no longer be bootstrapped on FreeBSD 12 after r366465,
so create a symlink to the host tool instead of trying to build it.

3 years agoFix buildworld on Linux/macOS after nvi update
arichardson [Mon, 12 Oct 2020 10:42:24 +0000 (10:42 +0000)]
Fix buildworld on Linux/macOS after nvi update

This re-applies r365941 which was lost in the nvi update.

3 years agoDon't use install(1) for the library symlinks in the build directory
arichardson [Mon, 12 Oct 2020 10:42:19 +0000 (10:42 +0000)]
Don't use install(1) for the library symlinks in the build directory

It appears this was changed from ln to use install in rS245752. I noticed
this because my buildenv was setting INSTALL=install -U -M //METALOG
and then these links fail to be created with the following error:
install: open //METALOG: Permission denied

Reviewed By: brooks
Differential Revision: https://reviews.freebsd.org/D26618

3 years agoFix building on Linux/macOS after r366622
arichardson [Mon, 12 Oct 2020 10:42:14 +0000 (10:42 +0000)]
Fix building on Linux/macOS after r366622

We have to bootstrap arc4random.c, so guard the FenestrasX code to avoid
using it on Linux/macOS.

Reviewed By: cem
Differential Revision: https://reviews.freebsd.org/D26738

3 years agoloader: edd_device_path_v3 is too small
tsoome [Mon, 12 Oct 2020 09:34:50 +0000 (09:34 +0000)]
loader: edd_device_path_v3 is too small

The EDD v3[1], see table 13, page 33, does define device path as double
qword, that is, 16 bytes, we have only qword.

Also remove edd_device_path_v4 and edd_params_v4 because those are not used,
and there is no size difference in v3 versus v4.

[1] http://www.t13.org/documents/UploadedDocuments/docs2004/d1572r3-EDD3.pdf

MFC after: 2 weeks

3 years agosystm.h: forward declare ucred for _STANDALONE too
imp [Mon, 12 Oct 2020 05:56:29 +0000 (05:56 +0000)]
systm.h: forward declare ucred for _STANDALONE too

There's a number of types we forward declare for the kernel. We need
struct ucred for the ZSTD ZFS integration, so go ahead and forward
declare it here too.

3 years ago10Gigabit Ethernet driver for AMD SoC
manu [Sun, 11 Oct 2020 16:01:16 +0000 (16:01 +0000)]
10Gigabit Ethernet driver for AMD SoC

This patch has the driver for 10Gigabit Ethernet controller in AMD
SoC. This driver is written compatible to the Iflib framework. The
existing driver is for the old version of hardware. The submitted
driver here is for the recent versions of the hardware where the Ethernet
controller is PCI-E based.

Submitted by: Rajesh Kumar <rajesh1.kumar@amd.com>
MFC after: 1 month
Relnotes: yes
Differential Revision: https://reviews.freebsd.org/D25793

3 years agoThe nextboot(8) manual page currently says that the loader(8) would delete
danfe [Sun, 11 Oct 2020 10:40:11 +0000 (10:40 +0000)]
The nextboot(8) manual page currently says that the loader(8) would delete
the /boot/nextboot.conf file or its contents which is 1) not the most user-
friendly way of working with custom configurations, and 2) simply not true
for both Forth and Lua implementations: they would not delete it, but just
change the setting to "NO", that is, disable it.

While at it, add one missing serial (Oxford) comma and fix some bogus line
wraps along the way.

Approved by: bcr (manpages)
Differential Revision: https://reviews.freebsd.org/D25971

3 years agoip_mroute: fix the viftable export sysctl
bz [Sun, 11 Oct 2020 00:01:00 +0000 (00:01 +0000)]
ip_mroute: fix the viftable export sysctl

It seems that in r354857 I got more than one thing wrong.
Convert the SYSCTL_OPAQUE to a SYSCTL_PROC to properly export the these
days allocated and not longer static per-vnet viftable array.
This fixes a problem with netstat -g which would show bogus information
for the IPv4 Virtual Interface Table.

PR: 246626
Reported by: Ozkan KIRIK (ozkan.kirik gmail.com)
MFC after: 3 days

3 years agorandom(4) FenestrasX: Push root seed version to arc4random(3)
cem [Sat, 10 Oct 2020 21:52:00 +0000 (21:52 +0000)]
random(4) FenestrasX: Push root seed version to arc4random(3)

Push the root seed version to userspace through the VDSO page, if
the RANDOM_FENESTRASX algorithm is enabled.  Otherwise, there is no
functional change.  The mechanism can be disabled with
debug.fxrng_vdso_enable=0.

arc4random(3) obtains a pointer to the root seed version published by
the kernel in the shared page at allocation time.  Like arc4random(9),
it maintains its own per-process copy of the seed version corresponding
to the root seed version at the time it last rekeyed.  On read requests,
the process seed version is compared with the version published in the
shared page; if they do not match, arc4random(3) reseeds from the
kernel before providing generated output.

This change does not implement the FenestrasX concept of PCPU userspace
generators seeded from a per-process base generator.  That change is
left for future discussion/work.

Reviewed by: kib (previous version)
Approved by: csprng (me -- only touching FXRNG here)
Differential Revision: https://reviews.freebsd.org/D22839

3 years agoarc4random(9): Integrate with RANDOM_FENESTRASX push-reseed
cem [Sat, 10 Oct 2020 21:48:06 +0000 (21:48 +0000)]
arc4random(9): Integrate with RANDOM_FENESTRASX push-reseed

There is no functional change for the existing Fortuna random(4)
implementation, which remains the default in GENERIC.

In the FenestrasX model, when the root CSPRNG is reseeded from pools due to
an (infrequent) timer, child CSPRNGs can cheaply detect this condition and
reseed.  To do so, they just need to track an additional 64-bit value in the
associated state, and compare it against the root seed version (generation)
on random reads.

This revision integrates arc4random(9) into that model without substantially
changing the design or implementation of arc4random(9).  The motivation is
that arc4random(9) is immediately reseeded when the backing random(4)
implementation has additional entropy.  This is arguably most important
during boot, when fenestrasX is reseeding at 1, 3, 9, 27, etc., second
intervals.  Today, arc4random(9) has a hardcoded 300 second reseed window.
Without this mechanism, if arc4random(9) gets weak entropy during initial
seed (and arc4random(9) is used early in boot, so this is quite possible),
it may continue to emit poorly seeded output for 5 minutes.  The FenestrasX
push-reseed scheme corrects consumers, like arc4random(9), as soon as
possible.

Reviewed by: markm
Approved by: csprng (markm)
Differential Revision: https://reviews.freebsd.org/D22838

3 years agoAdd "Fenestras X" alternative /dev/random implementation
cem [Sat, 10 Oct 2020 21:45:59 +0000 (21:45 +0000)]
Add "Fenestras X" alternative /dev/random implementation

Fortuna remains the default; no functional change to GENERIC.

Big picture:
- Scalable entropy generation with per-CPU, buffered local generators.
- "Push" system for reseeding child generators when root PRNG is
  reseeded.  (Design can be extended to arc4random(9) and userspace
  generators.)
- Similar entropy pooling system to Fortuna, but starts with a single
  pool to quickly bootstrap as much entropy as possible early on.
- Reseeding from pooled entropy based on time schedule.  The time
  interval starts small and grows exponentially until reaching a cap.
  Again, the goal is to have the RNG state depend on as much entropy as
  possible quickly, but still periodically incorporate new entropy for
  the same reasons as Fortuna.

Notable design choices in this implementation that differ from those
specified in the whitepaper:
- Blake2B instead of SHA-2 512 for entropy pooling
- Chacha20 instead of AES-CTR DRBG
- Initial seeding.  We support more platforms and not all of them use
  loader(8).  So we have to grab the initial entropy sources in kernel
  mode instead, as much as possible.  Fortuna didn't have any mechanism
  for this aside from the special case of loader-provided previous-boot
  entropy, so most of these sources remain TODO after this commit.

Reviewed by: markm
Approved by: csprng (markm)
Differential Revision: https://reviews.freebsd.org/D22837

3 years agopnfsdsfile(8): Remove dublicate word 'the'
gbe [Sat, 10 Oct 2020 14:38:01 +0000 (14:38 +0000)]
pnfsdsfile(8): Remove dublicate word 'the'

MFC after: 1 week

3 years agocxgbetool(8): Remove dublicate word 'whether'
gbe [Sat, 10 Oct 2020 14:36:16 +0000 (14:36 +0000)]
cxgbetool(8): Remove dublicate word 'whether'

MFC after: 1 week