]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
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

4 years agoSome minor tweaks to arch(7).
jhb [Thu, 2 Jan 2020 16:27:15 +0000 (16:27 +0000)]
Some minor tweaks to arch(7).

- Drop mention of _LP64.  FreeBSD's source generally uses __LP64__
  instead of _LP64, and the relevant macros are better covered in the
  "Predefined Macros" section.
- Fix a noun/verb disagreement.

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

4 years agoSince arm/unwind.c s conditionally compiled, only call functions in it
ian [Thu, 2 Jan 2020 15:38:17 +0000 (15:38 +0000)]
Since arm/unwind.c s conditionally compiled, only call functions in it
when one of those conditions is true.  Fixes build failure on kernel
configs with no debugging options active.

4 years agoRemove empty line which was added in r356270 by accident.
tuexen [Thu, 2 Jan 2020 14:04:16 +0000 (14:04 +0000)]
Remove empty line which was added in r356270 by accident.

MFC after: 1 week

4 years agoImprove input validation of the spp_pathmtu field in the
tuexen [Thu, 2 Jan 2020 13:55:10 +0000 (13:55 +0000)]
Improve input validation of the spp_pathmtu field in the
SCTP_PEER_ADDR_PARAMS socket option. The code in the stack assumes
sane values for the MTU.

This issue was found by running an instance of syzkaller.

MFC after: 1 week

4 years agoAdd the missing trailing '/' when setting TARGET_ARCH from TARGET
andrew [Thu, 2 Jan 2020 11:02:09 +0000 (11:02 +0000)]
Add the missing trailing '/' when setting TARGET_ARCH from TARGET

This should fix the build when setting TARGET but not TARGET_ARCH.

Sponsored by: DARPA, AFRL

4 years agoPlug loopback idaddr refcount leak.
melifaro [Thu, 2 Jan 2020 09:08:45 +0000 (09:08 +0000)]
Plug loopback idaddr refcount leak.

Reviewed by: markj
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D22980

4 years agoAdd a compact columnar output format, available by specifying a second '-l'
scottl [Thu, 2 Jan 2020 06:56:28 +0000 (06:56 +0000)]
Add a compact columnar output format, available by specifying a second '-l'
command line option.  Thanks to the removal of unnecessary information and
the organization into columns, this helps the output be more legible on
both 80 column displays and non-80 column displays.  imp@ provided the
idea on this.

4 years agoMove stand/ofw/libofw to stand/libofw.
bdragon [Thu, 2 Jan 2020 04:34:22 +0000 (04:34 +0000)]
Move stand/ofw/libofw to stand/libofw.

Since rS330365, there has been no particular reason for libofw to be in a
subdirectory of ofw. Move libofw up a level to make it fit in better with
the other top level libraries.

Also add a LIBOFWSRC to stand/defs.mk to match what all the other
libraries are doing.

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

4 years agoRemove MACHINE_ARCH arm where appropriate from the tables to reflect armv5's
imp [Thu, 2 Jan 2020 03:25:37 +0000 (03:25 +0000)]
Remove MACHINE_ARCH arm where appropriate from the tables to reflect armv5's
retirement.

4 years agoRemove NOTES.armv5. It's no longer relevant.
imp [Thu, 2 Jan 2020 03:25:32 +0000 (03:25 +0000)]
Remove NOTES.armv5. It's no longer relevant.

4 years agoRemove arm/arm as a valid target.
imp [Thu, 2 Jan 2020 03:25:26 +0000 (03:25 +0000)]
Remove arm/arm as a valid target.

TARGET=arm now defaults to TARGET_ARCH=armv7
TARGET_ARCH=arm is no longer valid.

Bump __FreeBSD_version to 1300073

Tested with make universe. Any stale LINT-V5 config files remaining in the tree
will fail the universe build. However, LINT-V5 was removed in r355119.

This retirement has been planned since last summer. The armv5 port is fragile:
it works OK for some peeople, and fails badly for others. There's a number of
subtle bugs in busdma, pmap and other MD parts of thee system that present
themselves under load or in unusual circumstances (like fsck after a
crash). stable/8, branched 10 years ago, was the last reliable release.  Since
the support burden is larger then the benefit, the consensus view is armv5
should be removed from the tree.

Discussed with: arm@ mailing list and arm developer community.

4 years agosysctl: hide 2.x era compat node
kaktus [Thu, 2 Jan 2020 01:23:43 +0000 (01:23 +0000)]
sysctl: hide 2.x era compat node

r23081 introduced kern.dummy oid as a semi ABI compat for kern.maxsockbuf
that was moved to a new namespace.  It never functioned as an alias of any
kind and was just returning 0 unconditionally, hence it was probably
provided to keep some 3rd party programmes happy about sysctl(3) not
reporting an error because of non-existing oid.
After nearly 23 years it seems reasonable to just hide it from sysctl(8)
list not to cause unnecessary confusion as for its purpose.

Reported by: Antranig Vartanian <antranigv@freebsd.am>
Reviewed by: kib (mentor)
Approved by: kib (mentor)
Differential Revision: https://reviews.freebsd.org/D22982

4 years agovfs: drop an always-false check from vlrureclaim
mjg [Wed, 1 Jan 2020 22:51:17 +0000 (22:51 +0000)]
vfs: drop an always-false check from vlrureclaim

The vnode gets held few lines prior, making the VI_FREE condition
illegal.

4 years agomsdos: vgone unconstructed vnode before vputing it
mjg [Wed, 1 Jan 2020 22:50:23 +0000 (22:50 +0000)]
msdos: vgone unconstructed vnode before vputing it

Otherwise someone else may race to start using it. Race window
was opened by r351748 ("vfs: implement usecount implying holdcnt").

Noted by: kib

4 years agomsdosfs: add a missing MNT_VNODE_FOREACH_ALL_ABORT to msdosfs_sync
mjg [Wed, 1 Jan 2020 22:47:00 +0000 (22:47 +0000)]
msdosfs: add a missing MNT_VNODE_FOREACH_ALL_ABORT to msdosfs_sync

4 years agoMerge commit 468a0cb5f from llvm git (by Craig Topper):
dim [Wed, 1 Jan 2020 19:45:00 +0000 (19:45 +0000)]
Merge commit 468a0cb5f from llvm git (by Craig Topper):

  [X86] Add X87 FCMOV support to X86FlagsCopyLowering.

  Fixes PR44396

Merge commit 86f48999f from llvm git (by Craig Topper):

  [X86] Fix typo in getCMovOpcode.

  The 64-bit HasMemoryOperand line was using CMOV32rm instead of
  CMOV64rm. Not sure how to test this. We have no test coverage that
  passes true for HasMemoryOperand.

This fixes 'Assertion failed: (MI.findRegisterDefOperand(X86::EFLAGS) &&
"Expected a def of EFLAGS for this instruction!"), function
runOnMachineFunction' when compiling the misc/gpsim port for i386.

Reported by: yuri
Upstream PR: https://bugs.llvm.org/show_bug.cgi?id=44396
MFC after: 1 week

4 years agoinetd: final round of trivial cleanup, NFC
kevans [Wed, 1 Jan 2020 18:49:57 +0000 (18:49 +0000)]
inetd: final round of trivial cleanup, NFC

Highlights:
- Use MAX() for maxsock raising; small readability improvement IMO
- malloc(3) + memset(3) -> calloc(3) where appropriate
- stop casting the return value of malloc(3)
- mallloc(3) -> reallocarray(3) where appropriate

A future change may enter capability mode when forking for some of the
built-in handlers.

4 years agoIn r343631 error code for a packet blocked by a firewall was
glebius [Wed, 1 Jan 2020 17:32:20 +0000 (17:32 +0000)]
In r343631 error code for a packet blocked by a firewall was
changed from EACCES to EPERM.  This change was not intentional,
so fix that.  Return EACCESS if a firewall forbids sending.

Noticed by: ae

4 years agoIn r343631 error code for a packet blocked by a firewall was
glebius [Wed, 1 Jan 2020 17:31:43 +0000 (17:31 +0000)]
In r343631 error code for a packet blocked by a firewall was
changed from EACCES to EPERM.  This change was not intentional,
so fix that.  Return EACCESS if a firewall forbids sending.

Noticed by: ae

4 years agosh: Fix rare memory leak with SIGINT
jilles [Wed, 1 Jan 2020 12:06:37 +0000 (12:06 +0000)]
sh: Fix rare memory leak with SIGINT

If getcwd() failed earlier on but later succeeded in the pwd builtin,
there was no INTOFF protection between calling savestr() and storing its
result.

It is quite rare for getcwd() to fail, and rarer for it to succeed later in
the same directory.

Found via code inspection for changing ckmalloc() and similar to assert
INTOFF protection instead of applying it directly (which protects against
corrupting malloc's internal state but allows memory leaks or double frees).

MFC after: 1 week

4 years agoRevert r356249 for now as it broke GCC builds.
delphij [Wed, 1 Jan 2020 09:22:06 +0000 (09:22 +0000)]
Revert r356249 for now as it broke GCC builds.

4 years agoReduce memory footprint of fsck_msdosfs.
delphij [Wed, 1 Jan 2020 07:43:08 +0000 (07:43 +0000)]
Reduce memory footprint of fsck_msdosfs.

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 agoinetd: convert remaining bzero(3) to memset(3), NFC
kevans [Wed, 1 Jan 2020 04:29:08 +0000 (04:29 +0000)]
inetd: convert remaining bzero(3) to memset(3), NFC

This change is purely in the name of noise reduction from static analyzers
that want to complain that bzero(3) is obsolete in favor of memset(3).

With this, clang-analyze at least is now noise free. WARNS= 6 also appears
to have been OK for some time now, so drop the current setting and opt for
the default.

4 years agoinetd: track all child pids, regardless of maxchild spec
kevans [Wed, 1 Jan 2020 04:22:04 +0000 (04:22 +0000)]
inetd: track all child pids, regardless of maxchild spec

Currently, child pids are only tracked if maxchildren is specified. As a
consequence, without a maxchild limit we do not get a notice in syslog on
children aborting abnormally. This turns out to be a great debugging aide at
times.

Children are now tracked in a LIST; the management interface is decidedly
less painful when there's no upper bound on the number of entries we may
have at the cost of one small allocation per connection.

PR: 70335

4 years agoinetd: add some macros for checking child limits, NFC
kevans [Wed, 1 Jan 2020 03:59:54 +0000 (03:59 +0000)]
inetd: add some macros for checking child limits, NFC

The main point here is capturing the maxchild > 0 check. A future change to
inetd will start tracking all of the child pids so that it can give proper
and consistent notification of process exit/signalling.

4 years agovmgenid(4): Integrate as a random(4) source
cem [Wed, 1 Jan 2020 00:35:02 +0000 (00:35 +0000)]
vmgenid(4): Integrate as a random(4) source

The number is public and has no "entropy," but should be integrated quickly
on VM rewind events to avoid duplicate sequences.

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

4 years agoUpdate the man page to reflect that "-M" and "-N" are deprecated and ignored.
rmacklem [Tue, 31 Dec 2019 22:25:06 +0000 (22:25 +0000)]
Update the man page to reflect that "-M" and "-N" are deprecated and ignored.

r356242 updated nfsstat.c to report that the "-M" and "-N" options were
being ignored. These options have never had any meaning for the new NFS
code (which is now the only NFS code).
This patch updates the man page to reflect this.

This is a content change.

4 years agoThe map-entry clipping functions modify start and end entries of an
dougm [Tue, 31 Dec 2019 22:20:54 +0000 (22:20 +0000)]
The map-entry clipping functions modify start and end entries of an
entry in the vm_map, making invariants related to the max_free entry
field invalid. Move the clipping work into vm_map_entry_link, so that
linking is okay when the new entry clips a current entry, and the
vm_map doesn't have to be briefly corrupted. Change assertions and
conditions in SPLAY_{LEFT,RIGHT}_STEP since the max_free invariants
can now be trusted in all cases.

Tested by: pho
Reviewed by: alc
Differential Revision: https://reviews.freebsd.org/D22897

4 years agoGet rid of old nfsstat options no longer used.
rmacklem [Tue, 31 Dec 2019 22:19:33 +0000 (22:19 +0000)]
Get rid of old nfsstat options no longer used.

The "-M" and "-N" options for nfsstat were used by the old NFS code and
have never done anything for the new NFS code.
This patch replaces code that assigns values to variables that are never
used with printf()s noting the options are ignored.
This has the side effect that it gets rid of warnings w.r.t. these
variables being assigned but never used, that occur for some builds.

Noticed during integration of the NFSv4.2 code.

4 years agoAdd basic getcpu(2) support to linuxulator. The purpose of this
trasz [Tue, 31 Dec 2019 22:01:08 +0000 (22:01 +0000)]
Add basic getcpu(2) support to linuxulator.  The purpose of this
syscall is to query the CPU number and the NUMA domain the calling
thread is currently running on.  The third argument is ignored.
It doesn't do anything regarding scheduling - it's literally
just a way to query the current state, without any guarantees
you won't get rescheduled an opcode later.

This unbreaks Java from CentOS 8
(java-11-openjdk-11.0.5.10-0.el8_0.x86_64).

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

4 years agoRelax locking of carp_forus().
mav [Tue, 31 Dec 2019 18:58:29 +0000 (18:58 +0000)]
Relax locking of carp_forus().

This fixes deadlock between CARP and bridge.  Bridge calls this function
taking CARP lock while holding bridge lock.  Same time CARP tries to send
its announcements via the bridge while holding CARP lock.

Use of CARP_LOCK() here does not solve anything, since sc_addr is constant
while race on sc_state is harmless and use of the lock does not close it.

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

4 years agoFix NOINET6 build broken by r356236.
melifaro [Tue, 31 Dec 2019 17:57:12 +0000 (17:57 +0000)]
Fix NOINET6 build broken by r356236.

MFC after: 2 weeks

4 years agoSplit gigantic rtsock route_output() into smaller functions.
melifaro [Tue, 31 Dec 2019 17:26:53 +0000 (17:26 +0000)]
Split gigantic rtsock route_output() into smaller functions.

Amount of changes to the original code has been intentionally minimised
to ease diffing.
The changes are mostly mechanical, with the following exceptions:

* lltable handler is now called directly based of RTF_LLINFO flag presense.
* "report" logic for updating rtm in RTM_GET/RTM_DELETE has been simplified,
  fixing several potential use-after-free cases in rt_addrinfo.
* llable asserts has been replaced with error-returning, preventing kernel
  crashes when lltable gw af family is invalid (root required).

MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D22864

4 years agoFix delayed ACK generation for DCTCP.
tuexen [Tue, 31 Dec 2019 16:15:47 +0000 (16:15 +0000)]
Fix delayed ACK generation for DCTCP.

Submitted by: Richard Scheffenegger
Reviewed by: chengc@netapp.com, rgrimes@, tuexen@
Differential Revision: https://reviews.freebsd.org/D22644

4 years agoRegen after r356233.
trasz [Tue, 31 Dec 2019 16:07:12 +0000 (16:07 +0000)]
Regen after r356233.

MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation

4 years agoSigh, add getcpu(2) chunk missed in r356229.
trasz [Tue, 31 Dec 2019 16:05:07 +0000 (16:05 +0000)]
Sigh, add getcpu(2) chunk missed in r356229.

MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation

4 years agoRegen after r356229.
trasz [Tue, 31 Dec 2019 16:01:37 +0000 (16:01 +0000)]
Regen after r356229.

MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation

4 years agoHappy New Year 2020!
gjb [Tue, 31 Dec 2019 16:01:36 +0000 (16:01 +0000)]
Happy New Year 2020!

MFC after: 1 minute
Sponsored by: Rubicon Communications, LLC (netgate.com)

4 years agoFix definitions for Linux getcpu(2).
trasz [Tue, 31 Dec 2019 15:57:29 +0000 (15:57 +0000)]
Fix definitions for Linux getcpu(2).

MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation

4 years agoMFV r356143:
cy [Tue, 31 Dec 2019 15:50:41 +0000 (15:50 +0000)]
MFV r356143:

Update unbound 1.9.2 --> 1.9.6.

MFC after: 3 days
Security: CVE-2019-18934 (fixed by 1.9.5)

4 years agoAdd flags for upcoming patches related to improved ECN handling.
tuexen [Tue, 31 Dec 2019 14:32:48 +0000 (14:32 +0000)]
Add flags for upcoming patches related to improved ECN handling.
No functional change.
Submitted by: Richard Scheffenegger
Reviewed by: rgrimes@, tuexen@
Differential Revision: https://reviews.freebsd.org/D22429

4 years agoClear the flag indicating that the last received packet was marked CE also
tuexen [Tue, 31 Dec 2019 14:23:52 +0000 (14:23 +0000)]
Clear the flag indicating that the last received packet was marked CE also
in the case where a packet not marked was received.

Submitted by: Richard Scheffenegger
Reviewed by: rgrimes@, tuexen@
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D19143

4 years agopsm: properly check for atkbdc_open failure
kevans [Tue, 31 Dec 2019 13:56:48 +0000 (13:56 +0000)]
psm: properly check for atkbdc_open failure

atkbdc_open can return NULL if the unit's out of bounds or the softc isn't
setup. Check it to be safe.

4 years agoAdd curly braces missed in https://svnweb.freebsd.org/changeset/base/354773
tuexen [Tue, 31 Dec 2019 12:29:01 +0000 (12:29 +0000)]
Add curly braces missed in https://svnweb.freebsd.org/changeset/base/354773

Sponsored by: Netflix, Inc.
CID: 1407649

4 years agoriscv: Remove unused variable
kp [Tue, 31 Dec 2019 11:45:19 +0000 (11:45 +0000)]
riscv: Remove unused variable

Fix the build that was broken by r356221. Pointy hat to myself.

4 years agosifive: uart driver
kp [Tue, 31 Dec 2019 10:54:13 +0000 (10:54 +0000)]
sifive: uart driver

Implement support for the UART as found on the SiFive FU540. It should
also work on, but has not been tested with, the FU310.

Reviewed by: philip
Sponsored by: Axiado

4 years agoriscv: Remove pointless loop
kp [Tue, 31 Dec 2019 10:53:03 +0000 (10:53 +0000)]
riscv: Remove pointless loop

There's no point in checking for absent CPUs if we're not going to do anything
about either the present or absent case. This loop can just be removed.

Reviewed by: philip
Sponsored by: Axiado

4 years agortld(1): Do booleans like C99
cem [Tue, 31 Dec 2019 05:41:47 +0000 (05:41 +0000)]
rtld(1): Do booleans like C99

Reviewed by: kib, rlibby
Differential Revision: https://reviews.freebsd.org/D22964

4 years agoSwitch r356210 to use gone_in() instead of printf().
rmacklem [Tue, 31 Dec 2019 05:39:27 +0000 (05:39 +0000)]
Switch r356210 to use gone_in() instead of printf().

Suggested by: cem

4 years agoinetd: prefer strlcpy to strlen(3) check + strcpy(3), NFC
kevans [Tue, 31 Dec 2019 04:53:50 +0000 (04:53 +0000)]
inetd: prefer strlcpy to strlen(3) check + strcpy(3), NFC

This is again functionally equivalent but more concise.

4 years agoinetd: prefer strtonum(3) to strspn(3)+atoi(3), NFC
kevans [Tue, 31 Dec 2019 04:36:14 +0000 (04:36 +0000)]
inetd: prefer strtonum(3) to strspn(3)+atoi(3), NFC

strtonum(3) does effectively the same validation as we had, but it's more
concise.