]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
4 years agoMFV r354383: 10592 misc. metaslab and vdev related ZoL bug fixes
Andriy Gapon [Thu, 21 Nov 2019 13:35:43 +0000 (13:35 +0000)]
MFV r354383: 10592 misc. metaslab and vdev related ZoL bug fixes

illumos/illumos-gate@555d674d5d4b8191dc83723188349d28278b2431
https://github.com/illumos/illumos-gate/commit/555d674d5d4b8191dc83723188349d28278b2431

https://www.illumos.org/issues/10592
  This is a collection of recent fixes from ZoL:
  8eef997679b Error path in metaslab_load_impl() forgets to drop ms_sync_lock
  928e8ad47d3 Introduce auxiliary metaslab histograms
  425d3237ee8 Get rid of space_map_update() for ms_synced_length
  6c926f426a2 Simplify log vdev removal code
  21e7cf5da89 zdb -L should skip leak detection altogether
  df72b8bebe0 Rename range_tree_verify to range_tree_verify_not_present
  75058f33034 Remove unused vdev_t fields

Portions contributed by: Jerry Jelinek <jerry.jelinek@joyent.com>
Author: Serapheim Dimitropoulos <serapheim@delphix.com>
MFC after: 4 weeks

4 years agoAdd kcsan_md_unsupported from NetBSD.
Andrew Turner [Thu, 21 Nov 2019 13:22:23 +0000 (13:22 +0000)]
Add kcsan_md_unsupported from NetBSD.

It's used to ignore virtual addresses that may have a different physical
address depending on the CPU.

Sponsored by: DARPA, AFRL

4 years agoFix the bus_space functions with KCSAN on arm64.
Andrew Turner [Thu, 21 Nov 2019 13:12:58 +0000 (13:12 +0000)]
Fix the bus_space functions with KCSAN on arm64.

Arm64 doesn't define the bus_space_set_multi_stream and
bus_space_set_region_stream functions. Don't try to define them there.

Sponsored by: DARPA, AFRL

4 years agoFix for style(9): use parentheses around return statements.
Andrew Turner [Thu, 21 Nov 2019 12:29:20 +0000 (12:29 +0000)]
Fix for style(9): use parentheses around return statements.

Reported by: kib
Sponsored by: DARPA, AFRL

4 years agoPort the NetBSD KCSAN runtime to FreeBSD.
Andrew Turner [Thu, 21 Nov 2019 11:22:08 +0000 (11:22 +0000)]
Port the NetBSD KCSAN runtime to FreeBSD.

Update the NetBSD Kernel Concurrency Sanitizer (KCSAN) runtime to work in
the FreeBSD kernel. It is a useful tool for finding data races between
threads executing on different CPUs.

This can be enabled by enabling KCSAN in the kernel config, or by using the
GENERIC-KCSAN amd64 kernel. It works on amd64 and arm64, however the later
needs a compiler change to allow -fsanitize=thread that KCSAN uses.

Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D22315

4 years agoMFV r354382,r354385: 10601 10757 Pool allocation classes
Andriy Gapon [Thu, 21 Nov 2019 08:20:05 +0000 (08:20 +0000)]
MFV r354382,r354385: 10601 10757 Pool allocation classes

illumos/illumos-gate@663207adb1669640c01c5ec6949ce78fd806efae
https://github.com/illumos/illumos-gate/commit/663207adb1669640c01c5ec6949ce78fd806efae

10601 Pool allocation classes
https://www.illumos.org/issues/10601
  illumos port of ZoL Pool allocation classes. Includes at least these two
  commits:
  441709695 Pool allocation classes misplacing small file blocks
  cc99f275a Pool allocation classes

10757 Add -gLp to zpool subcommands for alt vdev names
https://www.illumos.org/issues/10757
  Port from ZoL of
  d2f3e292d Add -gLp to zpool subcommands for alt vdev names
  Note that a subsequent ZoL commit changed -p to -P
  a77f29f93 Change full path subcommand flag from -p to -P

Portions contributed by: Jerry Jelinek <jerry.jelinek@joyent.com>
Portions contributed by: HÃ¥kan Johansson <f96hajo@chalmers.se>
Portions contributed by: Richard Yao <ryao@gentoo.org>
Portions contributed by: Chunwei Chen <david.chen@nutanix.com>
Portions contributed by: loli10K <ezomori.nozomu@gmail.com>
Author: Don Brady <don.brady@delphix.com>

11541 allocation_classes feature must be enabled to add log device

illumos/illumos-gate@c1064fd7ce62fe763a4475e9988ffea3b22137de
https://github.com/illumos/illumos-gate/commit/c1064fd7ce62fe763a4475e9988ffea3b22137de

https://www.illumos.org/issues/11541
  After the allocation_classes feature was integrated, one can no longer add a
  log device to a pool unless that feature is enabled. There is an explicit check
  for this, but it is unnecessary in the case of log devices, so we should handle
  this better instead of forcing the feature to be enabled.

Author: Jerry Jelinek <jerry.jelinek@joyent.com>

FreeBSD notes.
I faithfully added the new -g, -L, -P flags, but only -g does something:
vdev GUIDs are displayed instead of device names.  -L, resolve symlinks,
and -P, display full disk paths, do nothing at the moment.
The use of special vdevs is backward compatible for read-only access, so
root pools should be bootable, but exercise caution.

MFC after: 4 weeks

4 years agoInclude MACHINE in the which variable selection to use section.
Warner Losh [Thu, 21 Nov 2019 06:48:30 +0000 (06:48 +0000)]
Include MACHINE in the which variable selection to use section.

4 years agoAdd table for MACHINE_CPUARCH
Warner Losh [Thu, 21 Nov 2019 06:44:19 +0000 (06:44 +0000)]
Add table for MACHINE_CPUARCH

Add table and also some additional verbage of which one to use.

4 years agoRevert r354896, r354899, r354900:
Glen Barber [Thu, 21 Nov 2019 04:12:08 +0000 (04:12 +0000)]
Revert r354896, r354899, r354900:
 Fix build.

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

4 years agomark arm.arm (v4/v5) kernels as NO_UNIVERSE for now
Ed Maste [Thu, 21 Nov 2019 03:10:02 +0000 (03:10 +0000)]
mark arm.arm (v4/v5) kernels as NO_UNIVERSE for now

r354290 removed arm.arm from universe, but arm.arm kernels were still
found and built during the kernel stage.  I'm not aware of a better way
to address this at the moment, but since there aren't many arm.arm
kernels anyhow just add an explicit NO_UNIVERSE to them.

Reported by: rpokala

4 years agobcm2835_sdhci: clean up DMA segments in error handling path
Kyle Evans [Thu, 21 Nov 2019 02:49:41 +0000 (02:49 +0000)]
bcm2835_sdhci: clean up DMA segments in error handling path

Later parts assume that this would've been done if interrupts are enabled,
but this is the only case in which that wouldn't have been true. This commit
also reorders operations such that we're done touching slot/slot->intmask
before we call back into the SDHCI framework and exit.

4 years agobcm2835_sdhci: roll back r354823
Kyle Evans [Thu, 21 Nov 2019 02:47:55 +0000 (02:47 +0000)]
bcm2835_sdhci: roll back r354823

r354823 kicked DATA_END handling out of the DMA interrupt path "to make
things easy", but this was likely a mistake -- if we know we're done after
we've finished pending DMA operations, we should go ahead and acknowledge
it rather than waiting for the controller to finalize it. If it's not ready,
we'll simply re-enable interrupts and wait for it anyways, to be re-entered
in sdhci_data_intr.

4 years agoRevert r354930: wrong diff, right message.
Kyle Evans [Thu, 21 Nov 2019 02:44:05 +0000 (02:44 +0000)]
Revert r354930: wrong diff, right message.

4 years agobcm2835_sdhci: clean up DMA segments in error handling path
Kyle Evans [Thu, 21 Nov 2019 02:41:22 +0000 (02:41 +0000)]
bcm2835_sdhci: clean up DMA segments in error handling path

Later parts assume that this would've been done if interrupts are enabled,
but this is the only case in which that wouldn't have been true. This commit
also reorders operations such that we're done touching slot/slot->intmask
before we call back into the SDHCI framework and exit.

4 years agoRemove sio(4).
Gleb Smirnoff [Thu, 21 Nov 2019 01:24:49 +0000 (01:24 +0000)]
Remove sio(4).
It had been disconnected from build in r181233 in 2008.

Reviewed by: imp

4 years agoAvoid relying on pollution from libcasper.h.
Mark Johnston [Thu, 21 Nov 2019 00:17:14 +0000 (00:17 +0000)]
Avoid relying on pollution from libcasper.h.

Reported by: sjg
Sponsored by: The FreeBSD Foundation

4 years agoAdd --esp/-E argument to print the currently booted ESP
Warner Losh [Wed, 20 Nov 2019 23:58:36 +0000 (23:58 +0000)]
Add --esp/-E argument to print the currently booted ESP

Add code to decode the BootCurrent and BootXXXX variable it points at
to deduce the ESP used to boot the system. By default, it prints the
path to that device. With --unix-path (-p) it will instead print the
current mount point for the ESP, if any (or an error). With
--device-path (-d) it wil print the UEFI device path for the ESP.

Note: This is the best guess based on the UEFI variables. If the ESP
is part of a gmirror, etc, that won't be reported. If by some weird
chance there was a complicated series of chain boots, this may not be
what you want. For setups that don't add layers on top of the raw
devices, it is accurate.

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

4 years agoMFV 354917, 354918, 354919
Pedro F. Giffuni [Wed, 20 Nov 2019 23:56:20 +0000 (23:56 +0000)]
MFV 354917, 354918, 354919
openresolv: update to version 3.9.2

MFC after: 3 weeks

4 years agoCreate /etc/os-release file.
Warner Losh [Wed, 20 Nov 2019 23:45:31 +0000 (23:45 +0000)]
Create /etc/os-release file.

Each boot, regenerate /var/run/os-release based on the currently running
system. Create a /etc/os-release symlink pointing to this file (so that this
doesn't create a new reason /etc can not be mounted read-only).

This is compatible with what other systems do and is what the sysutil/os-release
port attempted to do, but in an incomplete way. Linux, Solaris and DragonFly all
implement this natively as well. The complete standard can be found at
https://www.freedesktop.org/software/systemd/man/os-release.html

Moving this to the base solves both the non-standard location problem with the
port, as well as the lack of update of this file on system update.

Bump __FreeBSD_version to 1300060

PR: 238953
Differential Revision:  https://reviews.freebsd.org/D22271

4 years agoImport openresolv 3.9.0
Pedro F. Giffuni [Wed, 20 Nov 2019 22:13:14 +0000 (22:13 +0000)]
Import openresolv 3.9.0

More information at: https://roy.marples.name/projects/openresolv

4 years agoStandardize EFI's ESP mount point.
Warner Losh [Wed, 20 Nov 2019 21:06:29 +0000 (21:06 +0000)]
Standardize EFI's ESP mount point.

Mount the UEFI ESP on /boot/efi. No current system uses this by default, but
there are many ad-hoc schemes that do this in /efi or /esp or /uefi and adding a
new directory at the top-level would have a much higher likelihood of
collision. Document this in /etc/mtree/BSD.root.mtree and create EFIDIR and
related variables in bsd.own.mk.

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

4 years agoSet handling for some "Logical unit not ready" errors.
Alexander Motin [Wed, 20 Nov 2019 20:00:03 +0000 (20:00 +0000)]
Set handling for some "Logical unit not ready" errors.

MFC after: 2 weeks
Sponsored by: iXsystems, Inc.

4 years agorandom/ivy: Trivial refactoring
Conrad Meyer [Wed, 20 Nov 2019 19:55:43 +0000 (19:55 +0000)]
random/ivy: Trivial refactoring

It is clearer to me to return success/error (true/false) instead of some
retry count linked to the inline assembly implementation.

No functional change.

Approved by: core(csprng) => csprng(markm)
Differential Revision: https://reviews.freebsd.org/D22454

4 years agoRe-apply fixed r354847
Conrad Meyer [Wed, 20 Nov 2019 19:43:34 +0000 (19:43 +0000)]
Re-apply fixed r354847

unifdef(1): Improve worst-case bound on symbol resolution

Use RB_TREE to make some algorithms O(lg N) and O(N lg N) instead of O(N)
and O(N^2).

While here, remove arbitrarily limit on number of macros understood.

Reverts r354877 and r354878, which disabled the (correct) test.

PR: 242095
Reported by: lwhsu

4 years agoRevert r354847 for now
Conrad Meyer [Wed, 20 Nov 2019 19:07:22 +0000 (19:07 +0000)]
Revert r354847 for now

It was broken.

PR: 242095
Reported by: lwhsu

4 years agoFix typo: deprected -> deprecated.
Dimitry Andric [Wed, 20 Nov 2019 19:07:08 +0000 (19:07 +0000)]
Fix typo: deprected -> deprecated.

4 years agoMake the warning for deprecated NO_ variables an error.
Brooks Davis [Wed, 20 Nov 2019 18:36:58 +0000 (18:36 +0000)]
Make the warning for deprecated NO_ variables an error.

Support for NO_CTF, NO_DEBUG_FILES, NO_INSTALLLIB, NO_MAN, NO_PROFILE,
and NO_WARNS as deprecated in 2014 with a warning added for each one
found. Turn these into error in preperation for removal of compatability
support before FreeBSD 13.

Reviewed by: imp
Relnotes: yes
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D22448

4 years agoAdd explanatory comments for the different SRCS_xxx variables used in
Dimitry Andric [Wed, 20 Nov 2019 18:12:01 +0000 (18:12 +0000)]
Add explanatory comments for the different SRCS_xxx variables used in
the Makefiles for libllvm and libclang.  While here, cleanup a commented
out SRCS entry in libllvmminimal's Makefile.

MFC after: 3 days

4 years agoAs with r354905 use uint16_t to store aflags on the stack and as function
Andrew Turner [Wed, 20 Nov 2019 18:00:43 +0000 (18:00 +0000)]
As with r354905 use uint16_t to store aflags on the stack and as function
arguments as the aflags size in vm_page_t has increased.

Sponsored by: DARPA, AFRL

4 years agosrc.conf.5: regen for several recent changes
Ed Maste [Wed, 20 Nov 2019 17:57:46 +0000 (17:57 +0000)]
src.conf.5: regen for several recent changes

r354289 armv6: Switch to LLD by default
r354290 Take arm.arm (armv5) out of universe
r354348 armv6, armv7: Switch to llvm-libunwind by default
r354660 Enable the RISC-V LLVM backend by default.

as well as lib32 changes

Sponsored by: The FreeBSD Foundation

4 years agoUse atomic_load_16 to load aflags as it's a uint16_t after r354820.
Andrew Turner [Wed, 20 Nov 2019 17:49:58 +0000 (17:49 +0000)]
Use atomic_load_16 to load aflags as it's a uint16_t after r354820.

Sponsored by: DARPA, AFRL

4 years agosrc.conf.5: regen after r354902, WITHOUT_AMD by default
Ed Maste [Wed, 20 Nov 2019 17:49:32 +0000 (17:49 +0000)]
src.conf.5: regen after r354902, WITHOUT_AMD by default

4 years agoAdd description for WITH_AMD
Ed Maste [Wed, 20 Nov 2019 17:45:31 +0000 (17:45 +0000)]
Add description for WITH_AMD

WITHOUT_AMD is now the default as of r354902.

Sponsored by: The FreeBSD Foundation

4 years agodisable amd(8) by default
Ed Maste [Wed, 20 Nov 2019 17:37:45 +0000 (17:37 +0000)]
disable amd(8) by default

As of FreeBSD 10.1 the autofs(5) is available for automounting, and the
amd man page has indicated that the in-tree copy of amd is obsolete.
Disable it by default for now, with the expectation that it will be
removed before FreeBSD 13.0.

Reviewed by: kevans
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D22460

4 years agoAllow boostrapping xinstall on Linux
Alex Richardson [Wed, 20 Nov 2019 17:24:49 +0000 (17:24 +0000)]
Allow boostrapping xinstall on Linux

Linux does not have st_flags so we have to avoid using it there.

Reviewed By: emaste, imp
Differential Revision: https://reviews.freebsd.org/D22446

4 years agoUse the correct variable, also limit the scope to bfd
Li-Wen Hsu [Wed, 20 Nov 2019 16:54:21 +0000 (16:54 +0000)]
Use the correct variable, also limit the scope to bfd

PR: 242109
Reported by: jhb
Sponsored by: The FreeBSD Foundation

4 years agoLimit the workaround to riscv only
Li-Wen Hsu [Wed, 20 Nov 2019 16:35:58 +0000 (16:35 +0000)]
Limit the workaround to riscv only

PR: 242109
Sponsored by: The FreeBSD Foundation

4 years agoUntil every possible root cause for an "invalid ASID" assertion failure is
Alan Cox [Wed, 20 Nov 2019 16:32:13 +0000 (16:32 +0000)]
Until every possible root cause for an "invalid ASID" assertion failure is
resolved, assign every pmap a valid ASID when it is first initialized.

4 years agosshd: make getpwclass wrapper MON_ISAUTH not MON_AUTH
Ed Maste [Wed, 20 Nov 2019 16:30:37 +0000 (16:30 +0000)]
sshd: make getpwclass wrapper MON_ISAUTH not MON_AUTH

In r339216 a privsep wrapper was added for login_getpwclass to address
PR 231172.  Unfortunately the change used the MON_AUTH flag in the
wrapper, and MON_AUTH includes MON_AUTHDECIDE which triggers an
auth_log() on each invocation.  getpwclass() does not participate in the
authentication decision, so should be MON_ISAUTH instead.

PR: 234793
Submitted by: Henry Hu
Reviewed by: Yuichiro NAITO
MFC after: 1 week

4 years agoWorkaround riscv64 build when using binutils 2.33.1
Li-Wen Hsu [Wed, 20 Nov 2019 16:20:49 +0000 (16:20 +0000)]
Workaround riscv64 build when using binutils 2.33.1

PR: 242109
Reviewed by: bapt
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D22457

4 years agoInstead of looking up a predecessor or successor to the current map
Doug Moore [Wed, 20 Nov 2019 16:06:48 +0000 (16:06 +0000)]
Instead of looking up a predecessor or successor to the current map
entry, when that entry has been seen already, keep the
already-looked-up value in a variable and use that instead of looking
it up again.

Approved by: alc, markj (earlier version), kib (earlier version)
Differential Revision: https://reviews.freebsd.org/D22348

4 years agoImport the NetBSD Kernel Concurrency Sanitizer (KCSAN) runtime.
Andrew Turner [Wed, 20 Nov 2019 14:37:48 +0000 (14:37 +0000)]
Import the NetBSD Kernel Concurrency Sanitizer (KCSAN) runtime.

KCSAN is a tool to find concurrent memory access that may race each other.
After a determined number of memory accesses a cell is created, this
describes the current access. It will then delay for a short period
to allow other CPUs a chance to race. If another CPU performs a memory
access to an overlapping region during this delay the race is reported.

This is a straight import of the NetBSD code, it will be adapted to
FreeBSD in a future commit.

Sponsored by: DARPA, AFRL

4 years agocache: minor stat cleanup
Mateusz Guzik [Wed, 20 Nov 2019 12:08:32 +0000 (12:08 +0000)]
cache: minor stat cleanup

Remove duplicated stats and move numcachehv from debug to vfs.cache.

4 years agovfs: perform a more racy check in vfs_notify_upper
Mateusz Guzik [Wed, 20 Nov 2019 12:07:54 +0000 (12:07 +0000)]
vfs: perform a more racy check in vfs_notify_upper

Locking mp does not buy anything interms of correctness and only contributes to
contention.

4 years agolinux: avoid overhead of P_CONTROLT checks if possible
Mateusz Guzik [Wed, 20 Nov 2019 12:06:29 +0000 (12:06 +0000)]
linux: avoid overhead of P_CONTROLT checks if possible

Sponsored by: The FreeBSD Foundation

4 years agovfs: change si_usecount management to count used vnodes
Mateusz Guzik [Wed, 20 Nov 2019 12:05:59 +0000 (12:05 +0000)]
vfs: change si_usecount management to count used vnodes

Currently si_usecount is effectively a sum of usecounts from all associated
vnodes. This is maintained by special-casing for VCHR every time usecount is
modified. Apart from complicating the code a little bit, it has a scalability
impact since it forces a read from a cacheline shared with said count.

There are no consumers of the feature in the ports tree. In head there are only
2: revoke and devfs_close. Both can get away with a weaker requirement than the
exact usecount, namely just the count of active vnodes. Changing the meaning to
the latter means we only need to modify it on 0<->1 transitions, avoiding the
check plenty of times (and entirely in something like vrefact).

Reviewed by: kib, jeff
Tested by: pho
Differential Revision: https://reviews.freebsd.org/D22202

4 years agoamd64: in double fault handler, do not rely on sane gsbase value.
Konstantin Belousov [Wed, 20 Nov 2019 11:12:19 +0000 (11:12 +0000)]
amd64: in double fault handler, do not rely on sane gsbase value.

Typical reasons for doublefault faults are either kernel stack
overflow or bugs in the code that manipulates protection CPU state.
The later code is the code which often has to set up gsbase for
kernel.  Switching to explicit load of GSBASE MSR in the fault handler
makes it more probable to output a useful information.

Now all IST handlers have nmi_pcpu structure on top of their stacks.

It would be even more useful to save gsbase value at the moment of the
fault.  I did not this because I do not want to modify PCB layout now.

Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 1 week

4 years agozpool.8: remove a paragraph about quorum disks
Andriy Gapon [Wed, 20 Nov 2019 08:56:01 +0000 (08:56 +0000)]
zpool.8: remove a paragraph about quorum disks

FreeBSD has no such thing.
illumos and ZoL manuals do not talk about quorum disks either.
Only Oracle ZFS mentions them.

MFC after: 1 week

4 years agofix up r354804, resolve merge conflicts in zpool.8
Andriy Gapon [Wed, 20 Nov 2019 08:49:13 +0000 (08:49 +0000)]
fix up r354804, resolve merge conflicts in zpool.8

Somehow I managed to commit the manual page with unresolved conflicts in
it.

While here, I also replaced .sp with .Pp.

MFC after: 3 weeks
X-MFC with: r354804

4 years agoOnly skip failing test case in CI.
Li-Wen Hsu [Wed, 20 Nov 2019 05:34:02 +0000 (05:34 +0000)]
Only skip failing test case in CI.

PR: 242095
Sponsored by: The FreeBSD Foundation

4 years agoTemporarily skip the failing test case usr.bin.unifdef.basic_test.basic
Li-Wen Hsu [Wed, 20 Nov 2019 05:30:31 +0000 (05:30 +0000)]
Temporarily skip the failing test case usr.bin.unifdef.basic_test.basic

PR: 242095
Sponsored by: The FreeBSD Foundation

4 years agobcm2835_vcbus: add compatibility name for ^/sys/contrib/vchiq
Kyle Evans [Wed, 20 Nov 2019 05:04:44 +0000 (05:04 +0000)]
bcm2835_vcbus: add compatibility name for ^/sys/contrib/vchiq

It's unclear how this didn't get caught in my last iteration, but the fix is
easy- the interface is still compatible, it was just gratuituously renamed
to match my arbitrary definition of consistency... VCBUS, the BCM2835 name,
represents an address on the VideoCore CPU Bus.

In a similar fashion, while it is a physical address, the ARMC portion
represents that these are addresses as seen by the ARM CPU.

To make things even more fun, the BCM2711 peripheral documentation describes
not virtual address space vs. physical address space, but instead the 32-bit
address map vs. the address map in "Low Peripheral" mode. The latter of
these is what the *ARMC* macros translate to/from.

4 years agobcm2835: push address mapping conversion for DMA/mailbox to runtime
Kyle Evans [Wed, 20 Nov 2019 03:57:46 +0000 (03:57 +0000)]
bcm2835: push address mapping conversion for DMA/mailbox to runtime

We could maintain the static conversions for the !AArch64 Raspberry Pis, but
I'm not sure it's worth it -- we'll traverse the platform list exactly once
(of which there are only two for armv7), then every conversion there-after
traverses the memory map listing of which there are at-most two entries for
these boards: sdram and peripheral space.

Detecting this at runtime is necessary for the AArch64 SOC, though, because
of the distinct IO windows being otherwise not discernible just from support
compiled into the kernel. We currently select the correct window based on
/compatible in the FDT.

We also use a similar mechanism to describe the DMA restrictions- the RPi 4
can have up to 4GB of RAM while the DMA controller and mailbox mechanism can
technically, kind of, only access the lowest 1GB. See the comment in
bcm2835_vcbus.h for a fun description/clarification of this.

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

4 years agoWhen we set OFFPAGE to limit fragmentation we should also set VTOSLAB
Jeff Roberson [Wed, 20 Nov 2019 01:57:33 +0000 (01:57 +0000)]
When we set OFFPAGE to limit fragmentation we should also set VTOSLAB
so that we avoid the hashtables.  The hashtable is now only required if
a zone is created with OFFPAGE specified initially, not internally.  This
flag signals to UMA that it can't touch the allocated memory and so
can't store a slab pointer in the containing page.

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

4 years agoWhite space cleanup. No functional change.
Kirk McKusick [Wed, 20 Nov 2019 01:14:22 +0000 (01:14 +0000)]
White space cleanup. No functional change.

Sponsored by: Netflix

4 years agoAdd some KASSERTs. Reacquire a mutex after a kernel printf rather
Kirk McKusick [Wed, 20 Nov 2019 01:10:01 +0000 (01:10 +0000)]
Add some KASSERTs. Reacquire a mutex after a kernel printf rather
than holding it during the printf. White space cleanup.

Sponsored by: Netflix

4 years agoOnly keep anonymous objects on shadow lists. This eliminates locking of
Jeff Roberson [Wed, 20 Nov 2019 00:31:14 +0000 (00:31 +0000)]
Only keep anonymous objects on shadow lists.  This eliminates locking of
globally visible objects when they are part of a backing chain.

Reviewed by: kib, markj
Differential Revision: https://reviews.freebsd.org/D22423

4 years agoRemove unnecessary object locking from the vnode pager. Recent changes to
Jeff Roberson [Tue, 19 Nov 2019 23:30:09 +0000 (23:30 +0000)]
Remove unnecessary object locking from the vnode pager.  Recent changes to
busy/valid/dirty locking make these acquires redundant.

Reviewed by: kib, markj
Differential Revision: https://reviews.freebsd.org/D22186

4 years agoSimplify anonymous memory handling with an OBJ_ANON flag. This eliminates
Jeff Roberson [Tue, 19 Nov 2019 23:19:43 +0000 (23:19 +0000)]
Simplify anonymous memory handling with an OBJ_ANON flag.  This eliminates
reudundant complicated checks and additional locking required only for
anonymous memory.  Introduce vm_object_allocate_anon() to create these
objects.  DEFAULT and SWAP objects now have the correct settings for
non-anonymous consumers and so individual consumers need not modify the
default flags to create super-pages and avoid ONEMAPPING/NOSPLIT.

Reviewed by: alc, dougm, kib, markj
Tested by: pho
Differential Revision: https://reviews.freebsd.org/D22119

4 years agobcm2835_sdhci: various refactoring of DMA path
Kyle Evans [Tue, 19 Nov 2019 23:12:43 +0000 (23:12 +0000)]
bcm2835_sdhci: various refactoring of DMA path

This round of refactoring is mostly about streamlining the interrupt handler
to make it easier to verify and reason about operations taking place while
trying to bring FreeBSD up on the RPi4.

4 years agonetmap: check if we already ran mmap before we attempt it
Vincenzo Maffione [Tue, 19 Nov 2019 21:29:49 +0000 (21:29 +0000)]
netmap: check if we already ran mmap before we attempt it

Submitted by: neel@neelc.org
Reviewed by: vmaffione
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D22390

4 years agoin6: move include
Bjoern A. Zeeb [Tue, 19 Nov 2019 21:14:15 +0000 (21:14 +0000)]
in6: move include

Move the include for sysctl.h out of the middle of the file to the
includes at the beginning.  This is will make it easier to add new
sysctls.

No functional changes.

MFC after: 3 weeks
Sponsored by: Netflix

4 years agobhyve: virtio-net: disable receive until features are negotiated
Vincenzo Maffione [Tue, 19 Nov 2019 21:10:44 +0000 (21:10 +0000)]
bhyve: virtio-net: disable receive until features are negotiated

This patch fixes a race condition where the receive callback is called
while the device is being reset. Since the rx_merge variable may change
during reset, the receive callback may operate inconsistently with what
the guest expects.
Also, get rid of the unused rx_vhdrlen variable.

PR: 242023
Reported by: aleksandr.fedorov@itglobal.com
Reviewed by: markj, jhb
MFC with: r354552
Differential Revision: https://reviews.freebsd.org/D22440

4 years agond6: sysctl
Bjoern A. Zeeb [Tue, 19 Nov 2019 21:08:18 +0000 (21:08 +0000)]
nd6: sysctl

Move the SYSCTL_DECL to the top of the file.  Move the sysctl function
before SYSCTL_PROC so that we don't need an extra function declaration in
the middle of the file.

No functional changes.

MFC after: 3 weeks
Sponsored by: Netflix

4 years agond6: make nd6_timer_ch static
Bjoern A. Zeeb [Tue, 19 Nov 2019 20:54:17 +0000 (20:54 +0000)]
nd6: make nd6_timer_ch static

nd6_timer_ch is only used in file local context.  There is no need to
export it, so make it static.

MFC after: 3 weeks
Sponsored by: Netflix

4 years agond6_rtr: re-sort functions
Bjoern A. Zeeb [Tue, 19 Nov 2019 20:34:33 +0000 (20:34 +0000)]
nd6_rtr: re-sort functions

Resort functions within file in a way that they depend on each other as
that makes it easier to rework various things.
Also allows us to remove file local function declarations.

No functional changes.

MFC after: 3 weeks
Sponsored by: Netflix

4 years agoAchieve two goals at once: (1) Avoid an unnecessary broadcast TLB
Alan Cox [Tue, 19 Nov 2019 19:05:05 +0000 (19:05 +0000)]
Achieve two goals at once: (1) Avoid an unnecessary broadcast TLB
invalidation in reclaim_pv_chunk(). (2) Prevent an "invalid ASID" assertion
failure in reclaim_pv_chunk().  The detailed explanation for this change is
provided by r354792.

X-MFC with: r354792

4 years agoWITH_SYSTEM_LINKER: Fix rebuilding lld every time.
Bryan Drewery [Tue, 19 Nov 2019 16:40:46 +0000 (16:40 +0000)]
WITH_SYSTEM_LINKER: Fix rebuilding lld every time.

This is due to LLD_REVISION_STRING being renamed to LLD_REVISION in
r351442 and the value being moved to another location in r351965.

`make test-system-linker` can be used to see the values being used here.

Reported by: ler

4 years agoFix the byte order of IPv4 address parsed from begemotSnmpdTransInetStatus
Andrey V. Elsukov [Tue, 19 Nov 2019 16:29:47 +0000 (16:29 +0000)]
Fix the byte order of IPv4 address parsed from begemotSnmpdTransInetStatus
config option.

An address is already in network byte order, there is no need to do
htonl().

PR: 242056
MFC after: 1 week

4 years agoReduce the vnet_set module size of ip_mroute to allow loading as a module.
Bjoern A. Zeeb [Tue, 19 Nov 2019 15:38:55 +0000 (15:38 +0000)]
Reduce the vnet_set module size of ip_mroute to allow loading as a module.

With VIMAGE kernels modules get special treatment as they need
to also keep the original values and make copies for each instance.
For that a few pages of vnet modspace are provided and the
kernel-linker and the VNET framework know how to deal with things.
When the modspace is (almost) full, other modules which would
overflow the modspace cannot be loaded and kldload will fail.

ip_mroute uses a lot of variable space, mostly be four big arrays:
set_vnet 0000000000000510 vnet_entry_multicast_register_if
set_vnet 0000000000000700 vnet_entry_viftable
set_vnet 0000000000002000 vnet_entry_bw_meter_timers
set_vnet 0000000000002800 vnet_entry_bw_upcalls

Dynamically malloc the three big ones for each instance we need
and free them again on vnet teardown (the 4th is an ifnet).
That way they only need module space for a single pointer and
allow a lot more modules using virtualized variables to be loaded
on a VNET kernel.

PR: 206583
Reviewed by: hselasky, kp
MFC after: 3 weeks
Differential Revision: https://reviews.freebsd.org/D22443

4 years agomld: fix epoch assertion
Bjoern A. Zeeb [Tue, 19 Nov 2019 14:53:13 +0000 (14:53 +0000)]
mld: fix epoch assertion

in6ifa_ifpforlinklocal() asserts the net epoch.  The test case from r354832
revealed code paths where we call into the function without having
acquired the net epoch first and consequently we hit the assert.
This happens in certain MLD states during VNET shutdown and most people
normaly not notice this.

For correctness acquire the net epoch around calls to
mld_v1_transmit_report() in all cases to avoid the assertion firing.

MFC after: 2 weeks
Sponsored by: Netflix

4 years agoDon't sanitize linker_set
David Bright [Tue, 19 Nov 2019 14:46:28 +0000 (14:46 +0000)]
Don't sanitize linker_set

The assumptions of linker_set don't play nicely with
AddressSanitizer. AddressSanitizer adds a 'redzone' of zeros around
globals (including those in named sections), whereas linker_set
assumes they are all packed consecutively like a pointer array. So:
let's annotate linker_set so that AddressSanitizer ignores it.

Submitted by: Matthew Bryan <matthew.bryan@isilon.com>
Reviewed by: kib, rang_acm.org
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D22239

4 years agoReturn 0 from ptrace_set_pc as it now completes successfully.
Andrew Turner [Tue, 19 Nov 2019 13:28:59 +0000 (13:28 +0000)]
Return 0 from ptrace_set_pc as it now completes successfully.

Sponsored by: DARPA, AFRL

4 years agoAllow ptrace to set the probram counter on arm64.
Andrew Turner [Tue, 19 Nov 2019 13:25:46 +0000 (13:25 +0000)]
Allow ptrace to set the probram counter on arm64.

Sponsored by: DARPA, AFRL

4 years agoFix the definition of bus_space_read_stream_8 on arm64.
Andrew Turner [Tue, 19 Nov 2019 10:57:44 +0000 (10:57 +0000)]
Fix the definition of bus_space_read_stream_8 on arm64.

This is currently unused, however will be when the Kernel Concurrency
Sanitizer (KCSAN) is imported from NetBSD.

Sponsored by: DARPA, AFRL

4 years agoDrop the extra argument from swp_pager_meta_ctl and have it do lookup
Doug Moore [Tue, 19 Nov 2019 08:06:31 +0000 (08:06 +0000)]
Drop the extra argument from swp_pager_meta_ctl and have it do lookup
only.  Rename it swp_pager_meta_lookup.  Stop checking for obj->type
== swap there and assert it instead.  Make the caller responsible for
the obj->type check.

Move the meta_ctl 'pop' functionality to swap_pager_unswapped, the
only place that uses it, and assume obj->type == swap there too.

Assisted by: ota_j.email.ne.jp
Reviewed by: kib
Tested by: pho
Differential Revision: https://reviews.freebsd.org/D22437

4 years agohyperv/storvsc: stash a pointer to hv_storvsc_request in ccb
Andriy Gapon [Tue, 19 Nov 2019 07:20:59 +0000 (07:20 +0000)]
hyperv/storvsc: stash a pointer to hv_storvsc_request in ccb

A SIM-private field is used for that.
The pointer can be useful when examining a state of a queued ccb.
E.g., a ccb on a da_softc.pending_ccbs.

MFC after: 2 weeks

4 years agounifdef(1): Improve worst-case bound on symbol resolution
Conrad Meyer [Tue, 19 Nov 2019 04:30:23 +0000 (04:30 +0000)]
unifdef(1): Improve worst-case bound on symbol resolution

Use RB_TREE to make some algorithms O(lg N) and O(N lg N) instead of O(N)
and O(N^2).  Because N is typically small and the former linear array also has
great constant factors (as a property of CPU caching), this doesn't provide
material benefit most or all of the time.

While here, remove arbitrarily limit on number of macros understood.

4 years agobcm2835_sdhci: formalize DMA tag/segment scaling requirements
Kyle Evans [Tue, 19 Nov 2019 04:23:57 +0000 (04:23 +0000)]
bcm2835_sdhci: formalize DMA tag/segment scaling requirements

This allows easy and care-free scaling of NUM_DMA_SEGS with proper-ish
calculations to make sure we can actually handle the number of segments we'd
like to handle on average so that performance comparisons can be easily made
at different values if/once we can actually handle it. It also makes it
helps the untrained reader understand more quickly the reasoning behind the
choice of maxsize/maxsegs/maxsegsize.

4 years agobcm2835_sdhci: some style cleanup, no functional change
Kyle Evans [Tue, 19 Nov 2019 03:45:41 +0000 (03:45 +0000)]
bcm2835_sdhci: some style cleanup, no functional change

4 years agobcm2835_sdhci: drop an assert in start_dma_seg
Kyle Evans [Tue, 19 Nov 2019 03:40:17 +0000 (03:40 +0000)]
bcm2835_sdhci: drop an assert in start_dma_seg

Trivial change to clarify locking expectations... no functional change.

4 years agounifdef(1): Kill totally useless header
Conrad Meyer [Tue, 19 Nov 2019 03:15:06 +0000 (03:15 +0000)]
unifdef(1): Kill totally useless header

No functional change.

4 years agoELF toolchain: Add PowerPC VMX and VSX note decode to readelf
Justin Hibbits [Tue, 19 Nov 2019 02:11:00 +0000 (02:11 +0000)]
ELF toolchain: Add PowerPC VMX and VSX note decode to readelf

Summary: A follow-on to r276634, which added the VMX note to userland cores,
and r334538 for VSX notes.

Copied from note_type_linux_core().

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

4 years agoAdd ioat_get_domain() to ioat(4) KPI.
Alexander Motin [Tue, 19 Nov 2019 02:09:04 +0000 (02:09 +0000)]
Add ioat_get_domain() to ioat(4) KPI.

This allows NUMA-aware consumers to reduce inter-domain traffic.

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

4 years agoCall bus_dma_dmar_set_buswide(9) added in r354830.
Alexander Motin [Tue, 19 Nov 2019 02:03:10 +0000 (02:03 +0000)]
Call bus_dma_dmar_set_buswide(9) added in r354830.

PLX NTB sends translated DMA requests not only from itsels, but from all
slots and functions of its bus.  By default DMAR blocks those additional.

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

4 years agopowerpc/pmap: Remove an unused error from moea64_pvo_enter()
Justin Hibbits [Tue, 19 Nov 2019 02:00:13 +0000 (02:00 +0000)]
powerpc/pmap: Remove an unused error from moea64_pvo_enter()

ENOENT is leftover from mmu_oea.c's moea_pvo_enter(), where it's used to
syncicache() on the first new mapping of a page.  This sync is done
differently in OEA64.

4 years agopowerpc/booke pmap: Use the right 'tlbilx' form to invalidate TIDs
Justin Hibbits [Tue, 19 Nov 2019 01:28:06 +0000 (01:28 +0000)]
powerpc/booke pmap: Use the right 'tlbilx' form to invalidate TIDs

'tlbilxpid' is 'tlbilx 1, 0', while the existing form is 'tlbilx 0, 0',
which translates to 'tlbilxlpid', invalidating a LDPID.  This effectively
invalidates the entire TLB, causing unnecessary reloads.

4 years agoflua: newer GCC complains about format-nonliteral at WARNS=2
Kyle Evans [Tue, 19 Nov 2019 00:02:56 +0000 (00:02 +0000)]
flua: newer GCC complains about format-nonliteral at WARNS=2

Disable that one, too.

4 years agosysent: regenerate after r354835
Kyle Evans [Mon, 18 Nov 2019 23:31:12 +0000 (23:31 +0000)]
sysent: regenerate after r354835

The lua-based makesyscalls produces slightly different output than its
makesyscalls.sh predecessor, all whitespace differences more closely
matching the source syscalls.master.

4 years agoConvert in-tree sysent targets to use new makesyscalls.lua
Kyle Evans [Mon, 18 Nov 2019 23:28:23 +0000 (23:28 +0000)]
Convert in-tree sysent targets to use new makesyscalls.lua

flua is bootstrapped as part of the build for those on older
versions/revisions that don't yet have flua installed. Once upgraded past
r354833, "make sysent" will again naturally work as expected.

Reviewed by: brooks
Differential Revision: https://reviews.freebsd.org/D21894

4 years agobsnmp: Fix operator precedence in error check in table_check_response
Justin Hibbits [Mon, 18 Nov 2019 23:23:38 +0000 (23:23 +0000)]
bsnmp: Fix operator precedence in error check in table_check_response

Summary:
The ?: operator has a lower precedence than == and &&, so the result will always
be recorded as true.  Found by gcc8.

Reviewed by: ngie, ae
Differential Revision: https://reviews.freebsd.org/D22427

4 years agoAdd flua to the base system, install to /usr/libexec
Kyle Evans [Mon, 18 Nov 2019 23:21:13 +0000 (23:21 +0000)]
Add flua to the base system, install to /usr/libexec

FreeBSDlua ("flua") is a FreeBSD-private lua, flavored with whatever
extensions we need for base system operations. We currently support a subset
of lfs and lposix that are used in the rewrite of makesyscall.sh into lua,
added in r354786.

flua is intentionally written such that one can install standard lua and
some set of lua modules from ports and achieve the same effect.

linit_flua is a copy of linit.c from contrib/lua with lfs and lposix added
in. This is similar to what we do in stand/. linit.c has been renamed to
make it clear that this has flua-specific bits.

luaconf has been slightly obfuscated to make extensions more difficult. Part
of the problem is that flua is already hard enough to use as a bootstrap
tool because it's not in PATH- attempting to do extension loading would
require a special bootstrap version of flua with paths changed to protect
the innocent.

src.lua.mk has been added to make it easy for in-tree stuff to find flua,
whether it's bootstrap-flua or relying on PATH frobbing by Makefile.inc1.

Reviewed by: brooks, emaste (both earlier version), imp
Differential Revision: https://reviews.freebsd.org/D21893

4 years agoicmpv6: Fix mbuf change in mld
Bjoern A. Zeeb [Mon, 18 Nov 2019 21:59:47 +0000 (21:59 +0000)]
icmpv6: Fix mbuf change in mld

After r354748 mld_input() can change the mbuf.  The new pointer
is never returned to icmp6_input() and when passed to
icmp6_rip6_input() the mbuf may no longer valid leading to
a panic.
Pass a pointer to the mbuf to mld_input() so we can return an
updated version in the non-error case.

Add a test sending an MLD packet case which will trigger this bug.

Pointyhat to: bz
Reported by: gallatin, thj
MFC After: 2 weeks
X-MFC with: r354748
Sponsored by: Netflix

4 years agoipv6 tests
Bjoern A. Zeeb [Mon, 18 Nov 2019 21:54:29 +0000 (21:54 +0000)]
ipv6 tests

Add a simple ping6 test as well.

MFC after: 2 weeks
Sponsored by: Netflix

4 years agobus_dma_dmar_set_buswide(9): KPI to indicate that the whole dmar
Konstantin Belousov [Mon, 18 Nov 2019 20:56:59 +0000 (20:56 +0000)]
bus_dma_dmar_set_buswide(9): KPI to indicate that the whole dmar
context should share page tables.

Practically it means that dma requests from any device on the bus are
translated according to the entries loaded for the bus:0:0 device.
KPI requires that the slot and function of the device be 0:0, and that
no tags for other devices on the bus were used.

The intended use are NTBs which pass TLPs from the downstream to the
host with slot:func of the downstream originator.

Reviewed and tested by: mav
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D22434

4 years agoAdd a "B" suffix to memory quantities in top(1) output.
Mark Johnston [Mon, 18 Nov 2019 20:55:01 +0000 (20:55 +0000)]
Add a "B" suffix to memory quantities in top(1) output.

Otherwise small quantities look nonsensical.  For instance, when
swapping in a single page we would print "4096 In".

Fix code indentation while here.

MFC after: 1 week
Sponsored by: The FreeBSD Foundation

4 years agoAdd x86 msr tweak KPI.
Konstantin Belousov [Mon, 18 Nov 2019 20:53:57 +0000 (20:53 +0000)]
Add x86 msr tweak KPI.

Use the KPI to tweak MSRs in mitigation code.

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

4 years agoCheck for errors from copyout() and suword*() in sv_copyout_args/strings.
John Baldwin [Mon, 18 Nov 2019 20:07:43 +0000 (20:07 +0000)]
Check for errors from copyout() and suword*() in sv_copyout_args/strings.

Reviewed by: brooks, kib
Tested on: amd64 (amd64, i386, linux64), i386 (i386, linux)
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D22401

4 years agoSet MALLOC_DEBUG_MAXZONES=1 in GENERIC-NODEBUG configurations.
Mark Johnston [Mon, 18 Nov 2019 20:03:28 +0000 (20:03 +0000)]
Set MALLOC_DEBUG_MAXZONES=1 in GENERIC-NODEBUG configurations.

The purpose of this option is to make it easier to track down memory
corruption bugs by reducing the number of malloc(9) types that might
have recently been associated with a given chunk of memory.  However, it
increases fragmentation and is disabled in release kernels.

MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation

4 years agobcm2835_sdhci: use a macro for interrupts we handle
Kyle Evans [Mon, 18 Nov 2019 19:28:09 +0000 (19:28 +0000)]
bcm2835_sdhci: use a macro for interrupts we handle

This is just further simplification, very little functional change. In the
DMA interrupt handler, we *do* now acknowledge both DATA_AVAIL | SPACE_AVAIL
every time -- these operations are mutually exclusive, so while this is a
functional change, it's effectively a nop. Removing the 'mask' local allows
us to further simplify in a future change.