]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
4 years agoUpdate libssp paths in various Makefile.depend* files
kevans [Mon, 6 Jan 2020 18:15:55 +0000 (18:15 +0000)]
Update libssp paths in various Makefile.depend* files

I've been advised that the model that uses these are fairly resilient, but
we do know the proper path to use (or remove, in the case of ^/targets/...),
so go ahead and update them to reflect that.

4 years agosrc.conf.5: regen after r356419, reenabling powerpc in universe
emaste [Mon, 6 Jan 2020 18:07:54 +0000 (18:07 +0000)]
src.conf.5: regen after r356419, reenabling powerpc in universe

4 years agoSimplify arguments to signal handlers on mips.
jhb [Mon, 6 Jan 2020 18:02:02 +0000 (18:02 +0000)]
Simplify arguments to signal handlers on mips.

- Use ksi_addr directly as si_addr in the siginfo instead of the
  'badvaddr' register.
- Remove a duplicate assignment of si_code.
- Use ksi_addr as the 4th argument to the old-style handler instead of
  'badvaddr'.

Reviewed by: brooks, kevans
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D23013

4 years agoEnable powerpc in make tinderbox using clang instead of GCC.
jhb [Mon, 6 Jan 2020 17:36:28 +0000 (17:36 +0000)]
Enable powerpc in make tinderbox using clang instead of GCC.

powerpcspe is disabled for now until clang/llvm issues with spe
have been fixed.

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

4 years agoOnly build kernels for enabled TARGET_ARCHes in make universe/tinderbox.
jhb [Mon, 6 Jan 2020 17:34:17 +0000 (17:34 +0000)]
Only build kernels for enabled TARGET_ARCHes in make universe/tinderbox.

Previously, all of the kernels for a given TARGET were built if that
target was enabled.  This was implemented by having each kernel built
via a universe_kernconf_<KERNEL> target that was depended on by a
universe_kernconfs target.  However, this meant that if one did a
build with a limited set of TARGET_ARCH values for a given TARGET,
kernels could be built for which we hadn't built a world or toolchain.
For example, 'make TARGETS=mips TARGET_ARCHES_mips=mips64' would build
mips32 kernels.

Fix this by adding an extra layer of indirection in the kernel make
targets.  universe_kernconf_<KERNEL> is now a dependency of a new
universe_kernconfs_<TARGET_ARCH>.  universe_kernconfs in turn depends
on a list of universe_kernconfs_<target_arch> values, but only the
values enabled in TARGET_ARCHES_<TARGET>.

Reviewed by: imp
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D23031

4 years agoThis catches rack up in the recent changes to ECN and
rrs [Mon, 6 Jan 2020 15:29:14 +0000 (15:29 +0000)]
This catches rack up in the recent changes to ECN and
also commonizes the functions that both the freebsd and
rack stack uses.

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

4 years agoMFV r356415
mm [Mon, 6 Jan 2020 13:21:10 +0000 (13:21 +0000)]
MFV r356415
Sync libarchive with vendor

Relevant vendor changes:
  Issue #1302: Re-do fix for archive_write_client_open()

X-MFC-With: r356212,r356365
MFC after: 1 week

4 years agoThis change adds a small feature to the tcp logging code. Basically
rrs [Mon, 6 Jan 2020 12:48:06 +0000 (12:48 +0000)]
This change adds a small feature to the tcp logging code. Basically
a connection can now have a separate tag added to the id.

Obtained from: Lawrence Stewart
Sponsored by: Netflix Inc
Differential Revision: https://reviews.freebsd.org/D22866

4 years agosysctl: mark more nodes as MPSAFE
kaktus [Mon, 6 Jan 2020 10:52:13 +0000 (10:52 +0000)]
sysctl: mark more nodes as MPSAFE

vm.kvm_size and vm.kvm_free are read only and marked as MPSAFE on i386
already. Mark them as that on amd64 and arm64 too to avoid locking Giant.

Reviewed by: kib (mentor)
Approved by: kib (mentor)
Differential Revision: https://reviews.freebsd.org/D23039

4 years agoAdd own counter for cancelled USB transfers.
hselasky [Mon, 6 Jan 2020 09:49:20 +0000 (09:49 +0000)]
Add own counter for cancelled USB transfers.
Do not count these as errors.

MFC after: 1 week
Sponsored by: Mellanox Technologies

4 years agoFix uma boot pages calculations on NUMA machines that also don't have
jeff [Mon, 6 Jan 2020 02:51:19 +0000 (02:51 +0000)]
Fix uma boot pages calculations on NUMA machines that also don't have
MD_UMA_SMALL_ALLOC.  This is unusual but not impossible.  Fix the alignemnt
of zones while here.  This was already correct because uz_cpu strongly
aligned the zone structure but the specified alignment did not match
reality and involved redundant defines.

Reviewed by: markj, rlibby
Differential Revision: https://reviews.freebsd.org/D23046

4 years agoFix host memory buffer sizes reporting.
mav [Mon, 6 Jan 2020 01:51:23 +0000 (01:51 +0000)]
Fix host memory buffer sizes reporting.

Hardware reports values in 4KB units, not in bytes.

MFC after: 3 days

4 years agoThe fix in r356353 was insufficient. Not every architecture returns 0 for
jeff [Sun, 5 Jan 2020 22:54:25 +0000 (22:54 +0000)]
The fix in r356353 was insufficient.  Not every architecture returns 0 for
EARLY_COUNTER.  Only amd64 seems to.

Suggested by: markj
Reported by: lwhsu
Reviewed by: markj
PR: 243117

4 years agonetgraph/ng_bridge: Reestablish old ABI
bz [Sun, 5 Jan 2020 19:14:16 +0000 (19:14 +0000)]
netgraph/ng_bridge: Reestablish old ABI

In order to be able to merge r353026 bring back support for the old
cookie API for a transition period in 12.x releases (and possibly 13)
before the old API can be removed again entirely.

Suggested by: julian
Submitted by: Lutz Donnerhacke (lutz donnerhacke.de)
PR: 240787
Reviewed by: julian
MFC after: 2 weeks
X-MFC with: r353026
Differential Revision: https://reviews.freebsd.org/D21961

4 years agoarch.7: correct overzealous claims of external binutils use
emaste [Sun, 5 Jan 2020 18:06:32 +0000 (18:06 +0000)]
arch.7: correct overzealous claims of external binutils use

powerpc and powerpcspe still use in-tree ld 2.17.50

4 years agoarch.7: update toolchain table for external ld use
emaste [Sun, 5 Jan 2020 18:03:53 +0000 (18:03 +0000)]
arch.7: update toolchain table for external ld use

As of r356379 and r356381 mips* and sparc64 now use external Binutils
ld as their linker.

4 years agosrc.conf.5: regen after r356381, disable BINUTILS_BOOTSTRAP more widely
emaste [Sun, 5 Jan 2020 18:01:52 +0000 (18:01 +0000)]
src.conf.5: regen after r356381, disable BINUTILS_BOOTSTRAP more widely

4 years agosrc.opts.mk: disable BINUTILS_BOOTSTRAP on all mips* and sparc64
emaste [Sun, 5 Jan 2020 18:01:15 +0000 (18:01 +0000)]
src.opts.mk: disable BINUTILS_BOOTSTRAP on all mips* and sparc64

Extend r356379 to include 32-bit mips and sparc64.  Using a decade-old
binutils linker with a contemporary compiler (either Clang or GCC) is
a combination unlikely to be used by anyone else, and it's not going
to be a good use of our time investigating and addressing any issues
that arise.  Expect that all architectures newly migrated to external
GCC will also use external binutils.

4 years agosrc.conf.5: regen after r356379, disable BINUTILS_BOOTSTRAP on mips64*
emaste [Sun, 5 Jan 2020 17:12:41 +0000 (17:12 +0000)]
src.conf.5: regen after r356379, disable BINUTILS_BOOTSTRAP on mips64*

4 years agosrc.opts.mk: disable BINUTILS_BOOTSTRAP on mips64*
emaste [Sun, 5 Jan 2020 16:59:24 +0000 (16:59 +0000)]
src.opts.mk: disable BINUTILS_BOOTSTRAP on mips64*

After GCC was disabled by default in r356367, mips and sparc64 started
relying external GCC.  However, the in-tree Binutils ld 2.17.50 is not
compatible with GCC for some mips64 targets, so turn off
BINUTILS_BOOTSTRAP and rely on external binutils (linker) as well.

4 years agoDon't make the sendall iterator as being up if it could not be started.
tuexen [Sun, 5 Jan 2020 14:08:01 +0000 (14:08 +0000)]
Don't make the sendall iterator as being up if it could not be started.

MFC after: 1 week

4 years agoReturn -1 consistently if an error occurs.
tuexen [Sun, 5 Jan 2020 14:06:40 +0000 (14:06 +0000)]
Return -1 consistently if an error occurs.

MFC after: 1 week

4 years agoEnsure that we don't miss a trigger for kicking off the SCTP iterator.
tuexen [Sun, 5 Jan 2020 13:56:32 +0000 (13:56 +0000)]
Ensure that we don't miss a trigger for kicking off the SCTP iterator.

Reported by: nwhitehorn@
MFC after: 1 week

4 years agolocks: add default delay struct
mjg [Sun, 5 Jan 2020 12:48:19 +0000 (12:48 +0000)]
locks: add default delay struct

Use it for all primitives. This makes everything fit in 8 bytes.

4 years agolocks: convert delay times to u_short
mjg [Sun, 5 Jan 2020 12:47:29 +0000 (12:47 +0000)]
locks: convert delay times to u_short

int is just a waste of space for this purpose.

4 years agoMark mtxpool_sleep as read mostly, not frequently.
mjg [Sun, 5 Jan 2020 12:46:35 +0000 (12:46 +0000)]
Mark mtxpool_sleep as read mostly, not frequently.

The latter is not justified.

4 years agoshm: correct KPI mistake introduced around memfd_create
kevans [Sun, 5 Jan 2020 04:06:40 +0000 (04:06 +0000)]
shm: correct KPI mistake introduced around memfd_create

When file sealing and shm_open2 were introduced, we should have grown a new
kern_shm_open2 helper that did the brunt of the work with the new interface
while kern_shm_open remains the same. Instead, more complexity was
introduced to kern_shm_open to handle the additional features and consumers
had to keep changing in somewhat awkward ways, and a kern_shm_open2 was
added to wrap kern_shm_open.

Backpedal on this and correct the situation- kern_shm_open returns to the
interface it had prior to file sealing being introduced, and neither
function needs an initial_seals argument anymore as it's handled in
kern_shm_open2 based on the shmflags.

4 years agoshmfd/mmap: restrict maxprot with MAP_SHARED + F_SEAL_WRITE
kevans [Sun, 5 Jan 2020 03:15:16 +0000 (03:15 +0000)]
shmfd/mmap: restrict maxprot with MAP_SHARED + F_SEAL_WRITE

If a write seal is set on a shared mapping, we must exclude VM_PROT_WRITE as
the fd is effectively read-only. This was discovered by running
devel/linux-ltp, which mmap's with acceptable protections specified then
attempts to raise to PROT_READ|PROT_WRITE with mprotect(2), which we
allowed.

Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D22978

4 years agoarch.7: update to show mips* and sparc64 use external GCC after r356367
emaste [Sun, 5 Jan 2020 03:07:59 +0000 (03:07 +0000)]
arch.7: update to show mips* and sparc64 use external GCC after r356367

4 years agosrc.conf.5: regen after r356367, default to GCC off
emaste [Sun, 5 Jan 2020 03:03:34 +0000 (03:03 +0000)]
src.conf.5: regen after r356367, default to GCC off

4 years agoAdjust WITH_/WITHOUT_ descriptions for GCC options after r356367
emaste [Sun, 5 Jan 2020 03:00:26 +0000 (03:00 +0000)]
Adjust WITH_/WITHOUT_ descriptions for GCC options after r356367

The options default to NO on all archs now, and will be removed before
FreeBSD 13.

Sponsored by: The FreeBSD Foundation

4 years agoDo not build GCC 4.2.1 by default for any CPU architecture
emaste [Sun, 5 Jan 2020 02:47:56 +0000 (02:47 +0000)]
Do not build GCC 4.2.1 by default for any CPU architecture

By default set to NO:

GCC
GCC_BOOTSTRAP
GNUCXX

As described by imp@ on the freebsd-arch mailing list Aug 13, 2019 with
Subject: Gcc 4.2.1 to be removed before FreeBSD 13, a firm timeline
https://lists.freebsd.org/pipermail/freebsd-arch/2019-August/019674.html

Reviewed by: jhb, imp
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D23026

4 years agoMFV r356365:
mm [Sun, 5 Jan 2020 01:42:21 +0000 (01:42 +0000)]
MFV r356365:
Sync libarchive with vendor

Relevant vendor changes:
  Issue #1302: Plug memory leak on failure of archive_write_client_open()

4 years agovfs: factor out avoidable branches in _vn_lock
mjg [Sun, 5 Jan 2020 01:00:11 +0000 (01:00 +0000)]
vfs: factor out avoidable branches in _vn_lock

4 years agovfs: drop thread argument from vinactive
mjg [Sun, 5 Jan 2020 00:59:47 +0000 (00:59 +0000)]
vfs: drop thread argument from vinactive

4 years agovfs: patch up vnode count assertions to report found value
mjg [Sun, 5 Jan 2020 00:59:16 +0000 (00:59 +0000)]
vfs: patch up vnode count assertions to report found value

4 years agovfs: predict VN_IS_DOOMED as false
mjg [Sun, 5 Jan 2020 00:58:20 +0000 (00:58 +0000)]
vfs: predict VN_IS_DOOMED as false

The macro is used everywhere.

4 years agokern_mmap: restore character deleted in transit
kevans [Sat, 4 Jan 2020 23:51:44 +0000 (23:51 +0000)]
kern_mmap: restore character deleted in transit

Pointy hat to: kevans
X-MFC-With: r356359

4 years agokern_mmap: add a variant that allows caller to inspect fp
kevans [Sat, 4 Jan 2020 23:39:58 +0000 (23:39 +0000)]
kern_mmap: add a variant that allows caller to inspect fp

Linux mmap rejects mmap() on a write-only file with EACCES.
linux_mmap_common currently does a fun dance to grab the fp associated with
the passed in fd, validates it, then drops the reference and calls into
kern_mmap(). Doing so is perhaps both fragile and premature; there's still
plenty of chance for the request to get rejected with a more appropriate
error, and it's prone to a race where the file we ultimately mmap has
changed after it drops its referenced.

This change alleviates the need to do this by providing a kern_mmap variant
that allows the caller to inspect the fp just before calling into the fileop
layer. The callback takes flags, prot, and maxprot as one could imagine
scenarios where any of these, in conjunction with the file itself, may
influence a caller's decision.

The file type check in the linux compat layer has been removed; EINVAL is
seemingly not an appropriate response to the file not being a vnode or
device. The fileop layer will reject the operation with ENODEV if it's not
supported, which more closely matches the common linux description of
mmap(2) return values.

If we discover that we're allowing an mmap() on a file type that Linux
normally wouldn't, we should restrict those explicitly.

Reviewed by: kib
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D22977

4 years agolibssp: fix FORTIFY_SOURCE stub declarations
kevans [Sat, 4 Jan 2020 22:05:00 +0000 (22:05 +0000)]
libssp: fix FORTIFY_SOURCE stub declarations

The LSB 4.1 that I referenced omitted the varargs, and I failed to catch it.
The __vsnprintf_chk error was from just downright misreading the page. GCC6
caught all of these, but I had only tested GCC4.2.

X-MFC-With: r356356

4 years agoMake the message size limit used for SCTP_SENDALL configurable via
tuexen [Sat, 4 Jan 2020 20:33:12 +0000 (20:33 +0000)]
Make the message size limit used for SCTP_SENDALL configurable via
a sysctl variable instead of a compiled in constant.

This is based on a patch provided by nwhitehorn@.

4 years agoProvide libssp based on libc
kevans [Sat, 4 Jan 2020 20:19:25 +0000 (20:19 +0000)]
Provide libssp based on libc

For libssp.so, rebuild stack_protector.c with FORTIFY_SOURCE stubs that just
abort built into it.

For libssp_nonshared.a, steal stack_protector_compat.c from
^/lib/libc/secure and massage it to maintain that __stack_chk_fail_local
is a hidden symbol.

libssp is now built unconditionally regardless of {WITH,WITHOUT}_SSP in the
build environment, and the gcclibs version has been disconnected from the
build in favor of this one.

PR: 242950 (exp-run)
Reviewed by: kib, emaste, pfg, Oliver Pinter (earlier version)
Also discussed with: kan
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D22943

4 years agossp: knock out some trivial warnings that come up with WARNS=6
kevans [Sat, 4 Jan 2020 20:07:11 +0000 (20:07 +0000)]
ssp: knock out some trivial warnings that come up with WARNS=6

A future commit will rebuild this as part of libssp. The exact warnings are
fairly trivially fixed:
- No previous declaration for __stack_chk_guard
- idx is the wrong type, nitems yields a size_t
- Casting away volatile on the tmp_stack_chk_guard directly is a no-no.

Reviewed by: kib, emaste, pfg, Oliver Pinter (earlier version)
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D22943

4 years agoWhen a copy-on-write fault occurs, pmap_enter() is called on to replace the
alc [Sat, 4 Jan 2020 19:50:25 +0000 (19:50 +0000)]
When a copy-on-write fault occurs, pmap_enter() is called on to replace the
mapping to the old read-only page with a mapping to the new read-write page.
To destroy the old mapping, pmap_enter() must destroy its page table and PV
entries and invalidate its TLB entry.  This change simply invalidates that
TLB entry a little earlier, specifically, on amd64 and arm64, before the PV
list lock is held.

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

4 years agoFix an assertion introduced in r356348. On architectures without
jeff [Sat, 4 Jan 2020 19:29:25 +0000 (19:29 +0000)]
Fix an assertion introduced in r356348.  On architectures without
UMA_MD_SMALL_ALLOC vmem has a more complicated startup sequence that
violated the new assert.  Resolve this by rewriting the COLD asserts to
look at the per-cpu allocation counts for evidence of api activity.

Discussed with: rlibby
Reviewed by: markj
Reported by: lwhsu

4 years agolio_listio_empty_nowait_thread sometimes does *not* hang.
bdrewery [Sat, 4 Jan 2020 18:59:46 +0000 (18:59 +0000)]
lio_listio_empty_nowait_thread sometimes does *not* hang.

The other tests consistently do hang though.

Sponsored by: DellEMC

4 years agoUMA NUMA flag day. UMA_ZONE_NUMA was a source of confusion. Make the names
jeff [Sat, 4 Jan 2020 18:48:13 +0000 (18:48 +0000)]
UMA NUMA flag day.  UMA_ZONE_NUMA was a source of confusion.  Make the names
more consistent with other NUMA features as UMA_ZONE_FIRSTTOUCH and
UMA_ZONE_ROUNDROBIN.  The system will now pick a select a default depending
on kernel configuration.  API users need only specify one if they want to
override the default.

Remove the UMA_XDOMAIN and UMA_FIRSTTOUCH kernel options and key only off
of NUMA.  XDOMAIN is now fast enough in all cases to enable whenever NUMA
is.

Reviewed by: markj
Discussed with: rlibby
Differential Revision: https://reviews.freebsd.org/D22831

4 years agoSort cross-domain frees into per-domain buckets before inserting these
jeff [Sat, 4 Jan 2020 07:56:28 +0000 (07:56 +0000)]
Sort cross-domain frees into per-domain buckets before inserting these
onto their respective bucket lists.  This is a several order of magnitude
improvement in contention on the keg lock under heavy free traffic while
requiring only an additional bucket per-domain worth of memory.

Discussed with: markj, rlibby
Differential Revision: https://reviews.freebsd.org/D22830

4 years agoUse per-domain keg locks. This provides both a lock and separate space
jeff [Sat, 4 Jan 2020 03:30:08 +0000 (03:30 +0000)]
Use per-domain keg locks.  This provides both a lock and separate space
accounting for each NUMA domain.  Independent keg domain locks are important
with cross-domain frees.  Hashed zones are non-numa and use a single keg
lock to protect the hash table.

Reviewed by: markj, rlibby
Differential Revision: https://reviews.freebsd.org/D22829

4 years agoUse a separate lock for the zone and keg. This provides concurrency
jeff [Sat, 4 Jan 2020 03:15:34 +0000 (03:15 +0000)]
Use a separate lock for the zone and keg.  This provides concurrency
between populating buckets from the slab layer and fetching full buckets
from the zone layer.  Eliminate some nonsense locking patterns where
we lock to fetch a single variable.

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

4 years agoUse atomics for the zone limit and sleeper count. This relies on the
jeff [Sat, 4 Jan 2020 03:04:46 +0000 (03:04 +0000)]
Use atomics for the zone limit and sleeper count.  This relies on the
sleepq to serialize sleepers.  This patch retains the existing sleep/wakeup
paradigm to limit 'thundering herd' wakeups.  It resolves a missing wakeup
in one case but otherwise should be bug for bug compatible.  In particular,
there are still various races surrounding adjusting the limit via sysctl
that are now documented.

Discussed with: markj
Reviewed by: rlibby
Differential Revision: https://reviews.freebsd.org/D22827

4 years agopowerpc: Remove 'sec' device from QORIQ64 config
jhibbits [Sat, 4 Jan 2020 01:13:00 +0000 (01:13 +0000)]
powerpc: Remove 'sec' device from QORIQ64 config

The SEC crypto engine, as implemented in this driver, does not exist on any
64-bit SoC, so don't bother compiling it in.

4 years agoUse the freebsd-gcc6 toolchains instead of powerpc64-xtoolchain-gcc.
jhb [Sat, 4 Jan 2020 00:59:47 +0000 (00:59 +0000)]
Use the freebsd-gcc6 toolchains instead of powerpc64-xtoolchain-gcc.

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

4 years agovfs: remove CTASSERT from VOP_UNLOCK_FLAGS
mjg [Sat, 4 Jan 2020 00:44:53 +0000 (00:44 +0000)]
vfs: remove CTASSERT from VOP_UNLOCK_FLAGS

gcc does not like it and it's not worth working around just for that
compiler.

4 years agoSet correct lib32 MACHINE_ARCH for mips64el*.
jhb [Fri, 3 Jan 2020 23:31:38 +0000 (23:31 +0000)]
Set correct lib32 MACHINE_ARCH for mips64el*.

Use "mipsel" instead of "mips" as the 32-bit MACHINE_ARCH when
building lib32 for little-endian 64-bit MIPS targets.  This fixes an
error where some objects were compiled as LE and others compiled as BE
causing a link error for rtld32.

Reviewed by: emaste
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D23028

4 years agovfs: add a file missed in r356337
mjg [Fri, 3 Jan 2020 22:47:31 +0000 (22:47 +0000)]
vfs: add a file missed in r356337

4 years agovfs: drop the mostly unused flags argument from VOP_UNLOCK
mjg [Fri, 3 Jan 2020 22:29:58 +0000 (22:29 +0000)]
vfs: drop the mostly unused flags argument from VOP_UNLOCK

Filesystems which want to use it in limited capacity can employ the
VOP_UNLOCK_FLAGS macro.

Reviewed by: kib (previous version)
Differential Revision: https://reviews.freebsd.org/D21427

4 years agounionfs: fix up VOP_UNLOCK use after flags stopped being supported
mjg [Fri, 3 Jan 2020 22:12:25 +0000 (22:12 +0000)]
unionfs: fix up VOP_UNLOCK use after flags stopped being supported

For the most part the code was passing the LK_RELEASE flag.
The 2 cases which did not use the VOP_UNLOCK_FLAGS macro.

This fixes a panic when stacking unionfs on top of e.g., tmpfs when
debug is enabled.

Note there are latent bugs which prevent unionfs from working with debug
regardless of this change.

PR: 243064
Reported by: Mason Loring Bliss

4 years agovfs: add VOP_UNLOCK_FLAGS
mjg [Fri, 3 Jan 2020 22:10:11 +0000 (22:10 +0000)]
vfs: add VOP_UNLOCK_FLAGS

The flags argument from VOP_UNLOCK is about to be removed and some
filesystems unlock the interlock as a convienience with it.

Add a helper to retain the behavior for the few cases it is needed.

4 years agoMakefile.inc1: remove libcompiler_rt from _startup_libs
kevans [Fri, 3 Jan 2020 21:40:32 +0000 (21:40 +0000)]
Makefile.inc1: remove libcompiler_rt from _startup_libs

libcompiler_rt is already present in _prereq_libs, which will get built just
before _startup_libs and in advance of shared libc. Dedupe.

4 years agoMerge commit 189b7393d from llvm git (by John Baldwin):
dim [Fri, 3 Jan 2020 20:29:54 +0000 (20:29 +0000)]
Merge commit 189b7393d from llvm git (by John Baldwin):

  [lld][RISCV] Use an e_flags of 0 if there are only binary input files.

  Summary:
  If none of the input files are ELF object files (for example, when
  generating an object file from a single binary input file via "-b
  binary"), use a fallback value for the ELF header flags instead of
  crashing with an assertion failure.

  Reviewers: MaskRay, ruiu, espindola

  Reviewed By: MaskRay, ruiu

  Subscribers: kevans, grimar, emaste, arichardson, asb, rbar,
  johnrusso, simoncook, sabuasal, niosHD, kito-cheng, shiva0217,
  zzheng, edward-jones, rogfer01, MartinMosbeck, brucehoult, the_o,
  rkruppe, PkmX, jocewei, psnobl, benna, Jim, lenary, s.egerton,
  pzheng, sameer.abuasal, apazos, luismarques, llvm-commits, jrtc27

  Tags: #llvm

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

This is a prerequisite for building and linking hard- and soft-float
riscv worlds with clang and lld.

Requested by: jhb
MFC after: 1 week
X-MFC-With: r353358

4 years agoMerge commit d7be3eab5 from llvm git (by Luís Marques):
dim [Fri, 3 Jan 2020 20:28:06 +0000 (20:28 +0000)]
Merge commit d7be3eab5 from llvm git (by Luís Marques):

  [RISCV] Handle fcopysign(f32, f64) and fcopysign(f64, f32)

  Summary: Adds tablegen patterns to explicitly handle fcopysign where
  the magnitude and sign arguments have different types, due to the
  sign value casts being removed the by DAGCombiner. Support for RV32IF
  follows in a separate commit. Adds tests for all relevant scenarios
  except RV32IF.

  Reviewers: lenary
  Reviewed By: lenary
  Tags: #llvm
  Differential Revision: https://reviews.llvm.org/D70678

This is a prerequisite for building and linking hard- and soft-float
riscv worlds with clang and lld.

Requested by: jhb
MFC after: 1 week
X-MFC-With: r353358

4 years agoMerge commit c6b09bff5 from llvm git (by Luís Marques):
dim [Fri, 3 Jan 2020 20:19:17 +0000 (20:19 +0000)]
Merge commit c6b09bff5 from llvm git (by Luís Marques):

  [RISCV] Fix wrong CFI directives

  Summary: Removes CFI CFA directives that could incorrectly propagate
  beyond the basic block they were inteded for. Specifically it removes
  the epilogue CFI directives. See the branch_and_tail_call test for an
  example of the issue. Should fix the stack unwinding issues caused by
  the incorrect directives.

  Reviewers: asb, lenary, shiva0217
  Reviewed By: lenary
  Tags: #llvm
  Differential Revision: https://reviews.llvm.org/D69723

This is a prerequisite for building and linking hard- and soft-float
riscv worlds with clang and lld.

Requested by: jhb
MFC after: 1 week
X-MFC-With: r353358

4 years agoMerge commit da7b129b1 from llvm git (by James Clarke):
dim [Fri, 3 Jan 2020 20:11:40 +0000 (20:11 +0000)]
Merge commit da7b129b1 from llvm git (by James Clarke):

  [RISCV] Don't force Local Exec TLS for non-PIC

  Summary:

  Forcing Local Exec TLS requires the use of copy relocations. Copy
  relocations need special handling in the runtime linker when being
  used against TLS symbols, which is present in glibc, but not in
  FreeBSD nor musl, and so cannot be relied upon. Moreover, copy
  relocations are a hack that embed the size of an object in the ABI
  when it otherwise wouldn't be, and break protected symbols (which are
  expected to be DSO local), whilst also wasting space, thus they
  should be avoided whenever possible. As discussed in D70398, RISC-V
  should move away from forcing Local Exec, and instead use Initial
  Exec like other targets, with possible linker relaxation to follow.
  The RISC-V GCC maintainers also intend to adopt this
  more-conventional behaviour (see
  https://github.com/riscv/riscv-elf-psabi-doc/issues/122).

  Reviewers: asb, MaskRay

  Reviewed By: MaskRay

  Subscribers: emaste, krytarowski, hiraditya, rbar, johnrusso,
  simoncook, sabuasal, niosHD, kito-cheng, shiva0217, zzheng,
  edward-jones, rogfer01, MartinMosbeck, brucehoult, the_o, rkruppe,
  PkmX, jocewei, psnobl, benna, Jim, lenary, s.egerton, pzheng,
  sameer.abuasal, apazos, llvm-commits, bsdjhb

  Tags: #llvm

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

This is a prerequisite for building and linking hard- and soft-float
riscv worlds with clang and lld.

Requested by: jhb
MFC after: 1 week
X-MFC-With: r353358

4 years agoMerge commit 41449c58c from llvm git (by Roger Ferrer Ibanez):
dim [Fri, 3 Jan 2020 20:09:38 +0000 (20:09 +0000)]
Merge commit 41449c58c from llvm git (by Roger Ferrer Ibanez):

  [RISCV] Fix evaluation of %pcrel_lo

  The following testcase

    function:
    .Lpcrel_label1:
          auipc   a0, %pcrel_hi(other_function)
          addi    a1, a0, %pcrel_lo(.Lpcrel_label1)
          .p2align        2          # Causes a new fragment to be emitted

          .type   other_function,@function
    other_function:
          ret

  exposes an odd behaviour in which only the %pcrel_hi relocation is
  evaluated but not the %pcrel_lo.

    $ llvm-mc -triple riscv64 -filetype obj t.s | llvm-objdump  -d -r -

    <stdin>:      file format ELF64-riscv

    Disassembly of section .text:
    0000000000000000 function:
           0:     17 05 00 00     auipc   a0, 0
           4:     93 05 05 00     mv      a1, a0
                  0000000000000004:  R_RISCV_PCREL_LO12_I other_function+4

    0000000000000008 other_function:
           8:     67 80 00 00     ret

  The reason seems to be that in RISCVAsmBackend::shouldForceRelocation
  we only consider the fragment but in RISCVMCExpr::evaluatePCRelLo we
  consider the section. This usually works but there are cases where
  the section may still be the same but the fragment may be another
  one. In that case we end forcing a %pcrel_lo relocation without any
  %pcrel_hi.

  This patch makes RISCVAsmBackend::shouldForceRelocation use the
  section, if any, to determine if the relocation must be forced or
  not.

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

This is a prerequisite for building and linking hard- and soft-float
riscv worlds with clang and lld.

Requested by: jhb
MFC after: 1 week
X-MFC-With: r353358

4 years agomips !o32: fix csu build
kevans [Fri, 3 Jan 2020 20:01:36 +0000 (20:01 +0000)]
mips !o32: fix csu build

Pointy hat to: kevans

4 years agomips: csu: fix compilation w/ LLVM
kevans [Fri, 3 Jan 2020 19:59:42 +0000 (19:59 +0000)]
mips: csu: fix compilation w/ LLVM

GCC issues the warning, but with LLVM it is fatal- no matching .cprestore
with .cpload. Reserve some place on the stack and and add the proper
.cprestore to pair it with.

nop added in the !o32 branch to fill out delay slot instruction, just in
case.

Reviewed by: arichardson
Differential Revision: https://reviews.freebsd.org/D21697

4 years agoFix a page leak in the md(4) swap I/O path.
markj [Fri, 3 Jan 2020 18:48:53 +0000 (18:48 +0000)]
Fix a page leak in the md(4) swap I/O path.

r356147 removed a vm_page_activate() call, but this is required to
ensure that pages end up in the page queues in the first place.

Restore the pre-r356157 logic.  Now, without the page lock, the
vm_page_active() check is racy, but this race is harmless.

Reviewed by: alc, kib
Reported and tested by: pho
Differential Revision: https://reviews.freebsd.org/D23024

4 years agoemulated atomic64: disable interrupts as the lock mechanism on !SMP
kevans [Fri, 3 Jan 2020 18:29:20 +0000 (18:29 +0000)]
emulated atomic64: disable interrupts as the lock mechanism on !SMP

Reviewed by: jhibbits, bdragon
Differential Revision: https://reviews.freebsd.org/D23015

4 years agosrc.conf.5: regen after r356322 and r356323
emaste [Fri, 3 Jan 2020 18:21:00 +0000 (18:21 +0000)]
src.conf.5: regen after r356322 and r356323

For SVNLITE dependency on FILE and GOOGLETEST dependency on CXX.

4 years agosrc.opts.mk: SVNLITE requires FILE
emaste [Fri, 3 Jan 2020 18:20:03 +0000 (18:20 +0000)]
src.opts.mk: SVNLITE requires FILE

Reported by: Build Options Survey run by Michael Dexter

4 years agosrc.opts.mk: GOOGLETEST requires CXX
emaste [Fri, 3 Jan 2020 18:11:55 +0000 (18:11 +0000)]
src.opts.mk: GOOGLETEST requires CXX

Reported by: Build Options Survey run by Michael Dexter

4 years agoTake the ifnet's address lock in igmp_v3_cancel_link_timers().
markj [Fri, 3 Jan 2020 17:03:10 +0000 (17:03 +0000)]
Take the ifnet's address lock in igmp_v3_cancel_link_timers().

inm_rele_locked() may remove the multicast address associated with inm.

Reported by: syzbot+871c5d1fd5fac6c28f52@syzkaller.appspotmail.com
Reviewed by: hselasky
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D23009

4 years agosrc.opts.mk: switch LLD_BOOTSTRAP and LLD_IS_LD to opt-out
emaste [Fri, 3 Jan 2020 16:28:10 +0000 (16:28 +0000)]
src.opts.mk: switch LLD_BOOTSTRAP and LLD_IS_LD to opt-out

More MACHINE_CPUARCH/MACHINE_ARCH cases enable these options than
disable them, and several of them have work in progress to switch over.
Thus, invert the sense of the test and list cases not using LLD as the
exceptions.

4 years agosrc.opts.mk: simplify after arm/arm retirement
emaste [Fri, 3 Jan 2020 16:06:41 +0000 (16:06 +0000)]
src.opts.mk: simplify after arm/arm retirement

There were a few special cases for arm v5, such as disabling LLDB due to
the lack of 64-bit atomic operations.  Now that arm has been retired (as
of r356263) we can simplify the options logic somewhat.

4 years agoinetd: fix WITHOUT_TCP_WRAPPERS build after r356248
emaste [Fri, 3 Jan 2020 15:29:32 +0000 (15:29 +0000)]
inetd: fix WITHOUT_TCP_WRAPPERS build after r356248

After increasing WARNS, building WITHOUT_TCP_WRAPPERS failed because of
some unused variables.

Reported by: Cirrus-CI (against my WIP branch)
MFC with: r356248
Sponsored by: The FreeBSD Foundation

4 years agomount_smbfs: Issue a warning when .nsmbrc section name contains lowercase characters.
arrowd [Fri, 3 Jan 2020 12:54:14 +0000 (12:54 +0000)]
mount_smbfs: Issue a warning when .nsmbrc section name contains lowercase characters.

PR: 231656
Approved by: bapt
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D22289

4 years agoAdd the 8 and 16 bit atomic load/store functions with a barrier on arm64.
andrew [Fri, 3 Jan 2020 10:03:36 +0000 (10:03 +0000)]
Add the 8 and 16 bit atomic load/store functions with a barrier on arm64.

Reviewed by: cem
MFC after: 2 weeks
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D22966

4 years agoAvoid duplicate I/O statistics accounting.
mav [Fri, 3 Jan 2020 04:37:47 +0000 (04:37 +0000)]
Avoid duplicate I/O statistics accounting.

Alike to geom_disk free the provider statistics structure and point GEOM
toward local statistics.  It allows to save some CPU time.

MFC after: 2 weeks

4 years agoReduce memory footprint of fsck_msdosfs.
delphij [Fri, 3 Jan 2020 00:31:48 +0000 (00:31 +0000)]
Reduce memory footprint of fsck_msdosfs.

This is a re-apply r356249 with changes to make GCC happy.

This utility was initially written for FAT12/16, which were inherently
small. When FAT32 support was added, the old data structure and
algorithms remain used with minimal changes.

With growing size of FAT32 media, the current data structure that
requires 4 32-bit variables per each FAT32 table entry would consume up
to 4 GiB of RAM, which can be too big for systems with limited RAM
available.

Address this by taking a different approach of validating the FAT.

The FAT is essentially a set of linked lists of chains that was
referenced by directory entries, and the checker needs to make sure that
the linked chains of clusters do not have cross-linked chains, and every
chain were referenced by one and only one directory entry.  Instead of
keeping track of the chain's 'head' cluster number, the size of the
chain, the used status of the chain and the "next" pointer which is
content of the FAT table, we create accessors for the FAT table data
for the "next" pointer, and keep only one bit to indicate if the
current cluster is a 'head' node of a cluster chain, in a bitmap.

We further overhaul the FAT checker to find out the possible head nodes
by excluding ones that are not (in other words, nodes that have some
other nodes claiming them as the next node) instead of marking the head
nodes for each node on the chain.  This approach greatly reduced the
complexiety of computation from O(N^2) worst case, to an O(N) scan for
worst case.  The file (cluster chain) length is not useful for the FAT
checker, so don't bother to calculate them in the FAT checker and
instead leave the task to the directory structure check, at which point
we would have non-crossed cluster chains, and we are guaranteed that
each cluster will be visited for at most one time.

When checking the directory structures, we use the head node indicator
to as the visited (used) flag: every cluster chain can only be
referenced by one directory entry, so we clear them when calculating
the length of the chain, and we can immediately tell if there are
anomalies in the directory entry.

As a result, the required RAM size is now 1 bit per each entry of
the FAT table, plus memory needed to hold the FAT table in memory,
instead of 16 bytes (=128 bits) per each entry.  For FAT12 and FAT16,
we will load the whole FAT table into memory as they are smaller than
128KiB, and for FAT32, we first attempt to mmap() it into memory, and
when that fails, we would fall back to a simple LRU cache of 4 MiB of
RAM.

sbin/fsck_msdosfs/boot.c:

 - Added additional sanity checks for valid FAT32/FAT16/FAT12 cluster
   number.
 - FAT32: check if root directory starts with a valid cluster number,
   moved from dir.c.  There is no point to proceed if the filesystem
   is already damaged beyond repair.

sbin/fsck_msdosfs/check.c:

 - Combine phase 1 and phase 2, now that the readfat() is able to
   detect cross chains.

sbin/fsck_msdosfs/dir.c:

 - Refactor code to use FAT accessor instead of accessing the internal
   representation of FAT table.
 - Make use of the cluster chain head bitmap.
 - Clarify and simplify directory entry check, remove unnecessary
   checks that are would be done at a later time (for example, whether
   the directory's second cluster is a valid one, which is examined
   more throughly in a later checkchain() and does not prevent us
   from proceeding further).

sbin/fsck_msdosfs/dosfs.h:

 - Remove internal representation of FAT table, which is replaced by
   the head bitmap that is opaque to other code.
 - Added a special CLUST_DEAD cluster type to indicate errors.

sbin/fsck_msdosfs/ext.h:

 - Added a flag that overrides mmap(2) setting.  The corresponding
   command line option, -M is intentionally undocumented as we do not
   expect users to need it.
 - Added accessors for FAT table and convert existing interface to use
   it.

sbin/fsck_msdosfs/fat.c:

 - Added head bitmap to represent whether a cluster is a head cluster.
 - Converted FAT internal representation to accessors.
 - Implemented a LRU cache for FAT32 when mmap(2) should not or can not
   be used.
 - _readfat: Attempt a mmap(2) and fall back to regular read for
   non-FAT32 file systems; use the LRU cache for FAT32 and prepopulate
   the cache with the first 4MiB of the entries.
 - readfat: Added support of head bitmap and use the population scan to
   detect bogus chains.
 - clusterdiff: removed, FATs are copied from the checked copy via
   writefat()/copyfat().
 - checkchain: calculates the length of a cluster chain and make sure
   that it ends with a valid EOF marker.
 - clearchain: follow and clear a chain and maintain the free cluster
   count.
 - checklost: convert to use head bitmap. At the end of all other scans,
   the remaining 'head' nodes are leaders of lost cluster chains.

sbin/fsck_msdosfs/fat.c:

 - Added a new -M option which is intentionally undocumented, to disable
   the use of mmap().

Reviewed by: kevlo
MFC after: 1 month
Relnotes: yes
Differential Revision: https://reviews.freebsd.org/D22965

4 years agoiflib: Prevent watchdog from resetting idle queues
erj [Thu, 2 Jan 2020 23:35:06 +0000 (23:35 +0000)]
iflib: Prevent watchdog from resetting idle queues

While changing link state in iflib_link_state_change(), queues are
marked as IFLIB_QUEUE_IDLE to disable watchdog. Currently, iflib_timer()
watchdog does not check for previous queue status before marking it as
IFLIB_QUEUE_HUNG.

This patch adds check of queue status before marking it as hung.

Signed-off-by: Piotr Pietruszewski <piotr.pietruszewski@intel.com>
PR: 239240
Submitted by: Piotr Pietruszewski <piotr.pietruszewski@intel.com>
Reported by: ultima@
Reviewed by: gallatin@, erj@
MFC after: 3 days
Sponsored by: Intel Corporation
Differential Revision: https://reviews.freebsd.org/D21712

4 years agoixl: prevent non-privileged access to NVM update interface
erj [Thu, 2 Jan 2020 23:24:57 +0000 (23:24 +0000)]
ixl: prevent non-privileged access to NVM update interface

Add a privilege check to the ixl_handle_nvmupd_cmd function, ensuring
that only privileged users are allowed to access the NVM update
interface.

Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
Submitted by: Jacob Keller <jacob.e.keller@intel.com>
Reported by: markj@
Reviewed by: markj@, erj@, jeffrey.e.pieper@intel.com
MFC after: 3 days
Sponsored by: Intel Corporation
Differential Revision: https://reviews.freebsd.org/D22870

4 years ago[PowerPC] [MIPS] Implement 32-bit kernel emulation of atomic64 operations
bdragon [Thu, 2 Jan 2020 23:20:37 +0000 (23:20 +0000)]
[PowerPC] [MIPS] Implement 32-bit kernel emulation of atomic64 operations

This is a lock-based emulation of 64-bit atomics for kernel use, split off
from an earlier patch by jhibbits.

This is needed to unblock future improvements that reduce the need for
locking on 64-bit platforms by using atomic updates.

The implementation allows for future integration with userland atomic64,
but as that implies going through sysarch for every use, the current
status quo of userland doing its own locking may be for the best.

Submitted by: jhibbits (original patch), kevans (mips bits)
Reviewed by: jhibbits, jeff, kevans
Differential Revision: https://reviews.freebsd.org/D22976

4 years agocapsicum_helpers: split stream cap bits out of caph_limit_stream()
kevans [Thu, 2 Jan 2020 23:07:45 +0000 (23:07 +0000)]
capsicum_helpers: split stream cap bits out of caph_limit_stream()

The goal here is to make it so applications can take the rights one would
normally get by calling caph_limit_stream() on a descriptor and build on
them as needed.

The tentatively planned use-case is an application that takes a socket and
hooks it up to std{err,out,in} for a fork()d child. It may be feasible to
apply limitations to such descriptors as long as it's a superset of those
normally applied to stdio.

Reviewed by: markj, oshobo (prior version; sans manpage addition)
Differential Revision: https://reviews.freebsd.org/D22993

4 years agoiicoc: limit fdt attachment to EXT_RESOURCES platforms
kevans [Thu, 2 Jan 2020 23:00:52 +0000 (23:00 +0000)]
iicoc: limit fdt attachment to EXT_RESOURCES platforms

The fdt attachment for this heavily relies on extres for clk work. This
unbreaks the build for mips XLPN32/XLP, which have pci/fdt but no need for
this fdt attachment.

4 years agosys/dev/cfi: include sys/types.h as well
kevans [Thu, 2 Jan 2020 22:52:31 +0000 (22:52 +0000)]
sys/dev/cfi: include sys/types.h as well

This will soon be a dependency for machine/atomic.h on mips with the
introduction of 64-bit atomics; the scope here is pretty narrow, so throw it
here in the header just before systm.h, which includes machine/atomic.h

4 years agoFix AT_EXECPATH for direct exec mode.
kib [Thu, 2 Jan 2020 22:48:08 +0000 (22:48 +0000)]
Fix AT_EXECPATH for direct exec mode.

When activated in direct exec mode, kernel-provided AT_EXECPATH points
to the interpreter.  We need to recalculate auxv to point to the
string with the path to the executable which is actually executed.

The somewhat problematic case is when the executable path is relative
and either $PATH use is not enabled or it contains '/' so $PATH search
is not performed. In this case resulting AT_EXECPATH is relative, I
might fix this later.

Reported and reviewed by: rstone
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D22894

4 years agobhyve: terminate waiting loops if thread suspension is requested.
kib [Thu, 2 Jan 2020 22:37:04 +0000 (22:37 +0000)]
bhyve: terminate waiting loops if thread suspension is requested.

PR: 242724
Reviewed by: markj
Reported and tested by: Aleksandr Fedorov <aleksandr.fedorov@itglobal.com>
 (previous version)
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D22881

4 years agoAdd the xdma framework and pl330 dma drivers to arm and arm64 lint builds.
ian [Thu, 2 Jan 2020 22:26:54 +0000 (22:26 +0000)]
Add the xdma framework and pl330 dma drivers to arm and arm64 lint builds.

4 years agoExplicitly include sys/rman.h instead of relying on getting it via some
ian [Thu, 2 Jan 2020 22:14:44 +0000 (22:14 +0000)]
Explicitly include sys/rman.h instead of relying on getting it via some
other header.

4 years agoRename umtxq_check_susp() to thread_check_susp()
kib [Thu, 2 Jan 2020 22:13:59 +0000 (22:13 +0000)]
Rename umtxq_check_susp() to thread_check_susp()

and make it usable outside of kern_umtx.c.  To be used in several
future changes.

Discussed with: markj
Sponsored by: The FreeBSD Foundation
MFC after: 1 week

4 years agoStyle: remove trailing spaces/tabs.
kib [Thu, 2 Jan 2020 22:07:03 +0000 (22:07 +0000)]
Style: remove trailing spaces/tabs.

Sponsored by: The FreeBSD Foundation
MFC after: 1 week

4 years agoLook for cross toolchain makefiles in /usr/share/toolchains.
jhb [Thu, 2 Jan 2020 21:34:44 +0000 (21:34 +0000)]
Look for cross toolchain makefiles in /usr/share/toolchains.

The freebsd-binutils and freebsd-gcc* packages install toolchain
makefiles to /usr/share/toolchains rather than LOCALBASE.

Reviewed by: bapt
Differential Revision: https://reviews.freebsd.org/D22985

4 years agoRemove extra check for provider being closed.
mav [Thu, 2 Jan 2020 20:30:53 +0000 (20:30 +0000)]
Remove extra check for provider being closed.

We already checked for that earlier, and since we hold topology lock
it could not change.

MFC after: 1 week

4 years agoRemove set_page_dirty_lock().
markj [Thu, 2 Jan 2020 19:29:14 +0000 (19:29 +0000)]
Remove set_page_dirty_lock().

Its use of the page lock is incorrect, and it is not used by the DRM
modules.

Reviewed by: hselasky
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D23002

4 years agoClear queue operation flags when migrating a page to another queue.
markj [Thu, 2 Jan 2020 19:26:04 +0000 (19:26 +0000)]
Clear queue operation flags when migrating a page to another queue.

The page daemon loops may move pages back to the active queue if
references are detected.  In this case we must take care to clear
existing queue operation flags.  In particular, PGA_REQUEUE_HEAD may be
set, and that flag is only valid if the page belongs to the inactive
queue.

Also fix a bug in the active queue scan where we were updating "old"
instead of "new".  This would only have been hit in rare cases where the
page moved out of the active queue after the beginning of the scan.

Reported by: Bob Prohaska, Idwer Vollering
Tested by: Idwer Vollering
Reviewed by: alc, kib
Differential Revision: https://reviews.freebsd.org/D23001

4 years agolibbe(3): promote dependent clones when destroying an environment
kevans [Thu, 2 Jan 2020 18:46:33 +0000 (18:46 +0000)]
libbe(3): promote dependent clones when destroying an environment

When removing a boot environment iterate over the dependents and process the
snapshots by grabbing any clones. Promote the clones we found and then
remove the target environment.

This fixes the ability to destroy a boot environment when it has been used
to spawn one or more other boot environments.

PR: 242592
Submitted by: Wes Maag <jwmaag gmail com> (with changes by myself)
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D22953

4 years agoAdd support for i2c bus mux hardware.
ian [Thu, 2 Jan 2020 17:51:49 +0000 (17:51 +0000)]
Add support for i2c bus mux hardware.

An i2c bus can be divided into segments which can be selectively connected
and disconnected from the main bus. This is usually done to enable using
multiple slave devices having the same address, by isolating the devices
onto separate bus segments, only one of which is connected to the main bus
at once.

There are several types of i2c bus muxes, which break down into two general
categories...

 - Muxes which are themselves i2c slaves. These devices respond to i2c
   commands on their upstream bus, and based on those commands, connect
   various downstream buses to the upstream. In newbus terms, they are both
   a child of an iicbus and the parent of one or more iicbus instances.
 - Muxes which are not i2c devices themselves. Such devices are part of the
   i2c bus electrically, but in newbus terms their parent is some other
   bus. The association with the upstream bus must be established by
   separate metadata (such as FDT data).

In both cases, the mux driver has one or more iicbus child instances
representing the downstream buses. The mux driver implements the iicbus_if
interface, as if it were an iichb host bridge/i2c controller driver. It
services the IO requests sent to it by forwarding them to the iicbus
instance representing the upstream bus, after electrically connecting the
upstream bus to the downstream bus that hosts the i2c slave device which
made the IO request.

The net effect is automatic mux switching which is transparent to slaves on
the downstream buses. They just do i2c IO they way they normally do, and the
bus is electrically connected for the duration of the IO and then idled when
it is complete.

The existing iicbus_if callback() method is enhanced so that the parameter
passed to it can be a struct which contains a device_t for the requesting
bus and slave devices. This change is done by adding a flag that indicates
the extra values are present, and making the flags field the first field of
a new args struct. If the flag is set, the iichb or mux driver can recast
the pointer-to-flags into a pointer-to-struct and access the extra
fields. Thus abi compatibility with older drivers is retained (but a mux
cannot exist on the bus with the older iicbus driver in use.)

A new set of core support routines exists in iicbus.c. This code will help
implement mux drivers for any type of mux hardware by supplying all the
boilerplate code that forwards IO requests upstream. It also has code for
parsing metadata and instantiating the child iicbus instances based on it.

Two new hardware mux drivers are added. The ltc430x driver supports the
LTC4305/4306 mux chips which are controlled via i2c commands. The
iic_gpiomux driver supports any mux hardware which is controlled by
manipulating the state of one or more gpio pins.  Test Plan

Tested locally using a variety of mux'd bus configurations involving both
ltc4305 and a homebrew gpio-controlled mux. Tested configurations included
cascaded muxes (unlikely in the real world, but useful to prove that 'it all
just works' in terms of the automatic switching and upstream forwarding of
IO requests).

4 years agoarm64: rockchip: Add a module for rk_spi
manu [Thu, 2 Jan 2020 17:44:41 +0000 (17:44 +0000)]
arm64: rockchip: Add a module for rk_spi

The spi node doesn't lives under a simple-bus compatible node so we need
OFWBUS_PNP_INFO instead of SIMPLEBUS_PNP_INFO.

4 years agoarm: allwinner: aw_spi: Call bus_generic_attach
manu [Thu, 2 Jan 2020 17:39:21 +0000 (17:39 +0000)]
arm: allwinner: aw_spi: Call bus_generic_attach

This is needed when the driver is compiled into the kernel.
When compiled as a module this will be called from another
code path as we also depend on ofw_spibus.

MFC after: 1 week