]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
4 years agoMFC r356004:
Dimitry Andric [Tue, 7 Jan 2020 20:01:59 +0000 (20:01 +0000)]
MFC r356004:

Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
9.0.1 final release c1a0a213378a458fbea1a5c77b315c7dce08fd05.

Release notes for llvm, clang, lld and libc++ 9.0.1 will become
available here:

https://releases.llvm.org/9.0.1/docs/ReleaseNotes.html
https://releases.llvm.org/9.0.1/tools/clang/docs/ReleaseNotes.html
https://releases.llvm.org/9.0.1/tools/lld/docs/ReleaseNotes.html
https://releases.llvm.org/9.0.1/projects/libcxx/docs/ReleaseNotes.html

PR: 240629

4 years agoMFC r355948:
Dimitry Andric [Tue, 7 Jan 2020 19:54:29 +0000 (19:54 +0000)]
MFC r355948:

Bootstrap mergeinfo for contrib/llvm-project

Merge (record-only) the following paths to contrib/llvm-project:
* ^/vendor/llvm-project/master
* ^/vendor/llvm-project/release-8.x
* ^/vendor/llvm-project/release-9.x

MFC r355951:

Merge empty dir updates from r355950 in vendor/llvm-project.

MFC r355957:

Merge diff elimination updates from r355953 into vendor/llvm-project.

MFC r355959:

Consolidate FREEBSD-Xlist files of different llvm sub-projects into one.

4 years agoMFC r355940:
Dimitry Andric [Tue, 7 Jan 2020 19:49:10 +0000 (19:49 +0000)]
MFC r355940:

Move all sources from the llvm project into contrib/llvm-project.

This uses the new layout of the upstream repository, which was recently
migrated to GitHub, and converted into a "monorepo".  That is, most of
the earlier separate sub-projects with their own branches and tags were
consolidated into one top-level directory, and are now branched and
tagged together.

Updating the vendor area to match this layout is next.

4 years agoMerge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
Dimitry Andric [Tue, 7 Jan 2020 18:08:09 +0000 (18:08 +0000)]
Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
9.0.0 final release r372316.

(NOTE: This does not yet consolidate all the llvm project sources under
contrib/llvm-project (e.g., MFC r355940), due to Subversion limitations.
It will be done in a follow-up MFC.)

MFC r348610 (by emaste):

build llvm-ar and llvm-nm with Clang (promote out of CLANG_EXTRAS)

To facilitate experimentation with LTO we require an ar that supports
LLVM IR, and to a lesser degree also an nm.  As a first step always
install llvm-ar and llvm-nm.

Sponsored by: The FreeBSD Foundation

MFC r350467 (by luporl):

[PPC64] Backport fix for missing IRELATIVE relocations

This is a backport of LLVM commit 8331f61a51a7a0a1efbf5ed398e181593023d151,
llvm-svn: 353981:

ELF: Allow GOT relocs pointing to non-preemptable ifunc to resolve to an
IRELATIVE where possible.

This is needed in order to make ifuncs work correctly on PPC64.

It fixes an issue with lld, in which it would skip emitting necessary IRELATIVE
relocations.  Without this change, indirect calls to ifuncs would result in a
segmentation fault, in static binaries or when defined in the main binary
(outside shared libraries).

This change also reverts the local
"Preserve relocations against ifuncs when -zifunc-noplt" commit and
replaces it by its upstream version, as part of the merge.

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

MFC r351662 (by emaste):

lldb: shorten thread names to make logs easier to follow

lldb prepends the thread name to log entries, and the existing thread
name for the FreeBSD ProcessMonitor thread was longer than the kernel's
supported thread name length, and so was truncated.  This made logs hard
to read, as the truncated thread name ran into the log message.  Shorten
"lldb.process.freebsd.operation" to just "freebsd.op" so that logs are
more readable.

(Upstreaming to lldb still to be done).

MFC r352095 (by emaste):

compiler-rt: use more __sanitizer_time_t on FreeBSD

A few structs were using long for time_t members.

Obtained from: LLVM r370755

MFC r352096 (by emaste):

compiler-rt: use 64-bit time_t for all FreeBSD archs except i386

Obtained from: LLVM r370756

MFC r352167 (by imp):

Remove dir empty since r276851

MFC r352168 (by imp):

Remove dirs empty since r280031

MFC r352169 (by imp):

Remove dir empty since r314564

MFC r352170 (by imp):

Remove dir empty since r327952

MFC r352171 (by imp):

Remove dirs (and their now-empty parents) empty since r344779

MFC r352792 (by emaste):

compiler-rt: correct RISC-V struct_kernel_stat64_sz

The value of struct_kernel_stat64_sz introduced by review D5021 for
RISC-V was incorrect.

Also add a __riscv_xlen == 64 conditional as the 32-bit ABI is not yet
finalized.

Submitted by: Luís Marques
Differential Revision: https://reviews.freebsd.org/D21684

MFC r353018 (by kevans):

clang: use -mxgot for 32-bit mips

Various bits in usr.bin/clang/* will fail to compile without -mxgot due to
truncated relocations. -mxgot entails a speed penalty, but I suspect we
don't care as much about compiler performance in 32-bit mips land.

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

MFC r353358:

Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
9.0.0 final release r372316.

Release notes for llvm, clang, lld and libc++ 9.0.0 are available here:

https://releases.llvm.org/9.0.0/docs/ReleaseNotes.html
https://releases.llvm.org/9.0.0/tools/clang/docs/ReleaseNotes.html
https://releases.llvm.org/9.0.0/tools/lld/docs/ReleaseNotes.html
https://releases.llvm.org/9.0.0/projects/libcxx/docs/ReleaseNotes.html

PR: 240629

MFC r353363:

Put in a band-aid fix for lldb 9 exiting with "Expected<T> must be
checked before access or destruction" when launching executables, while
we sort this out with upstream.

Reported by: jbeich
PR: 241137

MFC r353415:

Revert r353363 in preparation for applying upstream fix:

Put in a band-aid fix for lldb 9 exiting with "Expected<T> must be
checked before access or destruction" when launching executables, while
we sort this out with upstream.

PR: 241137

MFC r353416:

Pull in r374444 from upstream lldb trunk (by me):

  Fix process launch failure on FreeBSD after r365761

  Summary:
  After rLLDB365761, and with `LLVM_ENABLE_ABI_BREAKING_CHECKS`
  enabled, launching any process on FreeBSD crashes lldb with:

  ```
  Expected<T> must be checked before access or destruction.
  Expected<T> value was in success state. (Note: Expected<T> values in
  success mode must still be checked prior to being destroyed).
  ```

  This is because `m_operation_thread` and `m_monitor_thread` were
  wrapped in `llvm::Expected<>`, but this requires the objects to be
  correctly initialized before accessing them.

  To fix the crashes, use `llvm::Optional<>` for the members (as
  indicated by labath), and use local variables to store the return
  values of `LaunchThread` and `StartMonitoringChildProcess`.  Then,
  only assign to the member variables after checking if the return
  values indicated success.

  Reviewers: devnexen, emaste, MaskRay, mgorny

  Reviewed By: devnexen

  Subscribers: jfb, labath, krytarowski, lldb-commits

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

PR: 241137

MFC r353579 (by jhb):

Use __FreeBSD_version to determine if gets() has been removed.

GCC compilers set __FreeBSD__ statically to a build-time determined
targeted version (which in ports always matches the build host's
version).  This means that when building any version (12 or 13, etc.)
of riscv or some other architecture via GCC on a 12.x host,
__FreeBSD__ will always be set to 12.  As a result, __FreeBSD__ cannot
be used to reliably detect the target FreeBSD version being built.
Instead, __FreeBSD_version from either <sys/param.h> (in the kernel)
or <osreldate.h> (in userland) should be used.

This changes the gets() test in libc++ to use __FreeBSD_version from
<osreldate.h>.

Reported by: jenkins (riscv64 and amd64-gcc)
Reviewed by: dim, imp
Differential Revision: https://reviews.freebsd.org/D22034

MFC r353711 (by mhorne):

Fix build of LLVM RISC-V backend

Reviewed by: dim
MFC with: r353358
Differential Revision: https://reviews.freebsd.org/D21963

MFC r353738:

Pull in r372651 from upstream lld trunk (by Simon Atanasyan):

  [mips] Support elf32btsmipn32_fbsd / elf32ltsmipn32_fbsd emulations

  Patch by Kyle Evans.

Requested by: kevans

MFC r353739:

Pull in r374154 from upstream clang trunk (by Simon Atanasyan):

  [mips] Set default float ABI to "soft" on FreeBSD

  Initial patch by Kyle Evans.

  Fix PR43596

Requested by: kevans

MFC r353936:

Bump clang's default target CPU for the i386 architecture (aka "x86") to
i686, as per the discussion on the freebsd-arch mailing list.  Earlier
in r352030, I had already bumped it to i586, to work around missing
atomic 64 bit functions for the i386 architecture.

Relnotes: yes

MFC r354097:

Pull in r372186 from upstream llvm trunk (by Eli Friedman):

  [ARM] VFPv2 only supports 16 D registers.

  r361845 changed the way we handle "D16" vs. "D32" targets; there used
  to be a negative "d16" which removed instructions from the
  instruction set, and now there's a "d32" feature which adds
  instructions to the instruction set.  This is good, but there was an
  oversight in the implementation: the behavior of VFPv2 was changed.
  In particular, the "vfp2" feature was changed to imply "d32". This is
  wrong: VFPv2 only supports 16 D registers.

  In practice, this means if you specify -mfpu=vfpv2, the compiler will
  generate illegal instructions.

  This patch gets rid of "vfp2d16" and "vfp2d16sp", and fixes "vfp2"
  and "vfp2sp" so they don't imply "d32".

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

Pull in r372187 from upstream clang trunk (by Eli Friedman):

  [ARM] Update clang for removal of vfp2d16 and vfp2d16sp

  Matching fix for https://reviews.llvm.org/D67375 (r372186).

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

This should fix clang generating invalid opcodes for floating point
operations on armv6.

Requested by: mmel

MFC r354146:

Pull in r373338 from upstream llvm trunk (by Simon Pilgrim):

  Revert rL349624 : Let TableGen write output only if it changed,
  instead of doing so in cmake, attempt 2

  Differential Revision: https://reviews.llvm.org/D55842
  -----------------
  As discussed on PR43385 this is causing Visual Studio msbuilds to
  perpetually rebuild all tablegen generated files

Pull in r373664 from upstream llvm trunk (by Nico Weber):

  Reland r349624: Let TableGen write output only if it changed, instead
  of doing so in cmake

  Move the write-if-changed logic behind a flag and don't pass it with
  the MSVC generator. msbuild doesn't have a restat optimization, so
  not doing write-if-change there doesn't have a cost, and it should
  fix whatever causes PR43385.

This should fix the scenario where an incremental build from before
r353358 (the clang 9.0.0 upgrade) to r353358 or later fails to update
the timestamp of the generated lib/clang/headers/arm_fp16.h header.

After such a build, installing world from read-only source and object
directories would attempt to generate the header again, leading to
"clang-tblgen: error opening arm_fp16.h.d:Read-only file system".

Reported by: avg, np
PR: 241402

MFC r354339:

Merge commit 97e362607 from llvm git (by Nemanja Ivanovic):

  [PowerPC] Do not emit HW loop if the body contains calls to
  lrint/lround

  These two intrinsics are lowered to calls so should prevent the
  formation of CTR loops. In a subsequent patch, we will handle all
  currently known intrinsics and prevent the formation of HW loops if
  any unknown intrinsics are encountered.

  Differential revision: https://reviews.llvm.org/D68841

This should fix an "invalid CRT loop" assertion when building the
www/node port for powerpc64.

Requested by: Alfredo Dal'Ava Júnior <alfredo.junior@eldorado.org.br>

MFC r354347 (by cem):

Fix llvm-libunwind userspace build on ARM

GCC's libgcc exports a few ARM-specific symbols for ARM EABI, AEABI, or
EHABI or whatever it's called.  Export the same ones from LLVM-libunwind's
libgcc_s, on ARM.  As part of this, convert libgcc_s from a direct
Version.map to one constructed from component Symbol.map files.  This allows
the ARM-specific Symbol.map to be included only on ARM.

Fix ARM-only oddities in struct name/aliases in LLVM-libunwind to match
non-ARM definitions and ARM-specific expectations in libcxxrt /
libcompiler_rt.

No functional change intended for non-ARM architectures.

This commit does not actually flip the switch for ARM defaults from libgcc
to llvm-libunwind, but makes it possible (to compile, anyway).

MFC r354418 (by cem):

clang: Enable unwind tables on !amd64

There doesn't seem to be much sense in defaulting "on" unwind tables on
amd64 and not on other arches.  It causes surprising differences between
platforms, such as the PR below.

Prior to this change, FreeBSD inherited the default implementation of the
method from the Gnu.h Generic_Elf => Generic_GCC parent class, which
returned true only for amd64 targets.  Override that and opt on always,
similar to, e.g., NetBSD.

PR: 241562
Reported by: lwhsu
Reviewed by: dim
Discussed with: emaste
Relnotes: yes
Differential Revision: https://reviews.freebsd.org/D22252

MFC r354429:

Merge commit 8e34dd941 from llvm git (by Sanjay Patel):

  [x86] avoid crashing when splitting AVX stores with non-simple type
  (PR43916)

  The store splitting transform was assuming a simple type (MVT), but
  that's not necessarily the case as shown in the test.

This should fix 'Assertion failed: (isSimple() && "Expected a
SimpleValueType!")' when building the security/openssl111 port targeting
a CPU that supports AVX, but not AVX2, such as sandybridge.

PR: 241747

MFC r354469:

Merge commit f596f4507 from llvm git (by Sam Elliott):

  [RISCV] Add Custom Parser for Atomic Memory Operands

  Summary:
  GCC Accepts both (reg) and 0(reg) for atomic instruction memory
  operands. These instructions do not allow for an offset in their
  encoding, so in the latter case, the 0 is silently dropped.

  Due to how we have structured the RISCVAsmParser, the easiest way to
  add support for parsing this offset is to add a custom AsmOperand and
  parser. This parser drops all the parens, and just keeps the
  register.

  This commit also adds a custom printer for these operands, which
  matches the GCC canonical printer, printing both `(a0)` and `0(a0)`
  as `(a0)`.

  Reviewers: asb, lewis-revill

  Reviewed By: asb

  Subscribers: s.egerton, hiraditya, rbar, johnrusso, simoncook,
  apazos, sabuasal, niosHD, kito-cheng, shiva0217, jrtc27, MaskRay,
  zzheng, edward-jones, rogfer01, MartinMosbeck, brucehoult, the_o,
  rkruppe, jfb, PkmX, jocewei, psnobl, benna, Jim, llvm-commits

  Tags: #llvm

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

  llvm-svn: 367553

Merge commit f596f4507 from llvm git (by Sam Elliott):

  [RISCV] Add FreeBSD targets

  Reviewers: asb

  Reviewed By: asb

  Subscribers: simoncook, s.egerton, lenary, psnobl, benna, mhorne,
  emaste, kito-cheng, shiva0217, rogfer01, rkruppe, cfe-commits

  Tags: #clang

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

  Patch by James Clarke (jrtc27)

  llvm-svn: 367557

Merge commit f596f4507 from llvm git (by Hsiangkai Wang):

  [DebugInfo] Generate fixups as emitting DWARF .debug_frame/.eh_frame.

  It is necessary to generate fixups in .debug_frame or .eh_frame as
  relaxation is enabled due to the address delta may be changed after
  relaxation.

  There is an opcode with 6-bits data in debug frame encoding. So, we
  also need 6-bits fixup types.

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

  llvm-svn: 366524

Merge commit f596f4507 from llvm git (by Hsiangkai Wang):

  [DebugInfo] Some fields do not need relocations even relax is enabled.

  In debug frame information, some fields, e.g., Length in CIE/FDE and
  Offset in FDE are attributes to describe the structure of CIE/FDE.
  They are not related to the relaxed code. However, these attributes
  are symbol differences. So, in current design, these attributes will
  be filled as zero and LLVM generates relocations for them.

  We only need to generate relocations for symbols in executable
  sections.  So, if the symbols are not located in executable sections,
  we still evaluate their values under relaxation.

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

  llvm-svn: 366531

Merge commit f596f4507 from llvm git (by Alex Bradbury):

  [RISCV] Don't force absolute FK_Data_X fixups to relocs

  The current behavior of shouldForceRelocation forces relocations for
  the majority of fixups when relaxation is enabled. This makes sense
  for fixups which incorporate symbols but is unnecessary for simple
  data fixups where the fixup target is already resolved to an absolute
  value.

  Differential Revision: https://reviews.llvm.org/D63404
  Patch by Edward Jones.

  llvm-svn: 369257

Merge commit f596f4507 from llvm git (by Alex Bradbury):

  [RISCV] Implement getExprForFDESymbol to ensure RISCV_32_PCREL is
  used for the FDE location

  Follow binutils in using RISCV_32_PCREL for the FDE initial location.
  As explained in the relevant binutils commit
  <https://github.com/riscv/riscv-binutils-gdb/commit/a6cbf936e3dce68114d28cdf60d510a3f78a6d40>,
  the ADD/SUB pair of relocations is problematic in the presence of
  linker relaxation.

  This patch has the same end goal as D64715 but includes test changes
  and avoids adding a new global VariantKind to MCExpr.h (preferring
  RISCVMCExpr VKs like the rest of the RISC-V backend).

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

  llvm-svn: 369375

This series of merges will permit riscv64 kernels and riscv64sf worlds
to build with clang instead of gcc (but still using the bfd linker).

Requested by: jhb
Obtained from: https://github.com/freebsd/freebsd/compare/master...bsdjhb:riscv_clang

MFC r354662 (by jhb):

Sync target triple generation with the version in Makefile.inc1.

Reviewed by: dim
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D22333

MFC r354692 (by emaste):

llvm: use AT_EXECPATH from ELF auxiliary vectors for getExecutablePath

/proc/curproc/file and the KERN_PROC_PATHNAME sysctl may not return the
desired path if there are multiple hardlinks to the file.

PR: 241932
Tested by: ler
Sponsored by: The FreeBSD Foundation

MFC r354707 (by emaste):

llvm: use elf_aux_info to get executable's path, if available

Obtained from: LLVM a0a38b81ea
MFC with: r354692
Sponsored by: The FreeBSD Foundation

MFC r354979:

Merge commit 7bed381ea from llvm git (by Simon Atanasyan):

  [mips] Implement Octeon+ `saa` and `saad` instructions

  `saa` and `saad` are 32-bit and 64-bit store atomic add instructions.

     memory[base] = memory[base] + rt

  These instructions are available for "Octeon+" CPU. The patch adds
  support for both instructions to MIPS assembler and diassembler and
  introduces new CPU type - "octeon+".

  Next patches will implement `.set arch=octeon+` directive and
  `AFL_EXT_OCTEONP` ISA extension flag support.

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

This is one of the upstream changes needed for adding support for the
OCTEON+ CPU type, so that we can test Clang builds using the most
commonly available FreeBSD/mips64 reference platform, the Edge Router
Lite.

Requested by: kevans

MFC r354980:

Merge commit 3718102d4 from llvm git (by Simon Atanasyan):

  [mips] Support `octeon+` CPU in the `.set arch=` directive

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

This is one of the upstream changes needed for adding support for the
OCTEON+ CPU type, so that we can test Clang builds using the most
commonly available FreeBSD/mips64 reference platform, the Edge Router
Lite.

Requested by: kevans

MFC r354981:

Merge commit bf996f761 from llvm git (by Simon Atanasyan):

  [mips] Write `AFL_EXT_OCTEONP` flag to the `.MIPS.abiflags` section

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

This is one of the upstream changes needed for adding support for the
OCTEON+ CPU type, so that we can test Clang builds using the most
commonly available FreeBSD/mips64 reference platform, the Edge Router
Lite.

Requested by: kevans

MFC r354982:

Merge commit 3552d3e0f from llvm git (by Simon Atanasyan):

  [mips] Add `octeon+` to the list of CPUs accepted by the driver

This is one of the upstream changes needed for adding support for the
OCTEON+ CPU type, so that we can test Clang builds using the most
commonly available FreeBSD/mips64 reference platform, the Edge Router
Lite.

Requested by: kevans

MFC r354983:

Merge commit e578d0fd2 from llvm git (by Simon Atanasyan):

  [mips] Fix `__mips_isa_rev` macros value for Octeon CPU

This is one of the upstream changes needed for adding support for the
OCTEON+ CPU type, so that we can test Clang builds using the most
commonly available FreeBSD/mips64 reference platform, the Edge Router
Lite.

Requested by: kevans

MFC r354984:

Merge commit 0d14656b9 from llvm git (by Simon Atanasyan):

  [mips] Set __OCTEON__ macros

This is one of the upstream changes needed for adding support for the
OCTEON+ CPU type, so that we can test Clang builds using the most
commonly available FreeBSD/mips64 reference platform, the Edge Router
Lite.

Requested by: kevans

MFC r354985:

Merge commit a751f557d from llvm git (by Simon Atanasyan):

  [mips] Set macros for Octeon+ CPU

This is one of the upstream changes needed for adding support for the
OCTEON+ CPU type, so that we can test Clang builds using the most
commonly available FreeBSD/mips64 reference platform, the Edge Router
Lite.

Requested by: kevans

MFC r355397:

Merge commit 241cbf201 from llvm git (by Nemanja Ivanovic):

  [PowerPC] Fix crash in peephole optimization

  When converting reg+reg shifts to reg+imm rotates, we neglect to
  consider the CodeGenOnly versions of the 32-bit shift mnemonics. This
  means we produce a rotate with missing operands which causes a crash.

  Committing this fix without review since it is non-controversial that
  the list of mnemonics to consider should include the 64-bit aliases
  for the exact mnemonics.

  Fixes PR44183.

This should fix "Assertion failed: (idx < size()), function operator[],
file /usr/src/contrib/llvm/include/llvm/ADT/SmallVector.h, line 153"
when building the graphics/mesa-dri port for the PowerPC64 ELFv2 ABI.

Reported by: Alfredo Dal'Ava Júnior <alfredo.junior@eldorado.org.br>

MFC r355602:

Add a few missed source files to libllvm, for the MK_LLVM_TARGET_BPF=yes
case.  Otherwise, linking of clang and other llvm based executables
would complain about missing symbols.

Reported by: rstone

MFC r355645 (by cem):

arm: libgcc_s: Fix ABI breakage introduced in r354347

Provide the symbol version for llvm-libunwind's _Unwind_Backtrace that libgcc
has historically provided on arm, in addition to the (default) standard version
used on all other arch.

Reported by: mmel

MFC r355803 (by mmel):

Fix LLVM libunwnwind _Unwind_Backtrace symbol version for ARM.
In original  GNU libgcc, _Unwind_Backtrace is published with GCC_3.3 version
for all architectures but ARM. For ARM should be publishes with GCC_4.3.0
version. This was originally omitted in r255095, fixed in r318024 and omitted
aging in LLVM libunwind implementation in r354347.

For ARM _Unwind_Backtrace should be published as default with GCC_4.3.0
version , (because this is right original version) and again as
normal(not-default) with GCC_3.3 version (to maintain ABI compatibility
compiled/linked with wrong pre r318024 libgcc)

PR: 233664

4 years agoMFC r355070:
Bjoern A. Zeeb [Tue, 7 Jan 2020 16:58:39 +0000 (16:58 +0000)]
MFC r355070:

  Allow kernel to compile without BPF.

  r297816 added some bpf magic for VIMAGE unconditionally which no longer
  allows kernels to compile without bpf (but with other networking).
  Add the missing ifdef checks and allow a kernel to compile without bpf
  again.

  PR: 242136
  Reported by: dave mischler.com

4 years agoMFC r354639:
Bjoern A. Zeeb [Tue, 7 Jan 2020 16:54:43 +0000 (16:54 +0000)]
MFC r354639:

  netstat: igmp stats, error on unexpected information, not only warn

  The igmp stats tend to print two lines of warning for an unexpected
  version and length.  Despite an invalid version and struct size it
  continues to try to do something with the data.  Do not try to parse
  the remainder of the struct and error on warning.

  Note the underlying issue of the data not being available properly
  is still there and needs to be fixed seperately.

  Reported by: test cases, lwhsu

4 years agoMFC r354572:
Bjoern A. Zeeb [Tue, 7 Jan 2020 16:52:05 +0000 (16:52 +0000)]
MFC r354572:

  libipsec: correct a typo

  Correct a typo in the ipsec_errlist and replicated in a comment.
  No functional changes.

4 years agoMFC r354416:
Bjoern A. Zeeb [Tue, 7 Jan 2020 16:49:50 +0000 (16:49 +0000)]
MFC r354416:

  m_pulldown(): Change an if () panic() into a KASSERT().

  If we pass in a NULL mbuf to m_pulldown() we are in a bad situation
  already.  There is no point in doing that check for production code.
  Change the if () panic() into a KASSERT.

4 years agoMFC r351329:
Bjoern A. Zeeb [Tue, 7 Jan 2020 16:47:25 +0000 (16:47 +0000)]
MFC r351329:

  gprof: disable building of a.out components

  On arm64, riscv, and s390x disable building of aout components.
  This allows gprof to build on these architectures which never supported
  the legacy a.out binary format.

Note: there might be more work needed for arm64 or risv and the MACHINE_
checks are based on what was use elsewhere in the tree at that time.  Other
will fix these parts with follow-up work.

4 years agoMFC r351327:
Bjoern A. Zeeb [Tue, 7 Jan 2020 16:44:19 +0000 (16:44 +0000)]
MFC r351327:

  athhal: disable unused function (big endian only)

  Disable ar9300_swap_tx_desc() for the moment.  It is an unused
  function only tried to compile on big endian systems.

4 years agoMFC r356216: Don't spin on cleanup_lock if we are not interrupt.
Alexander Motin [Tue, 7 Jan 2020 00:54:23 +0000 (00:54 +0000)]
MFC r356216: Don't spin on cleanup_lock if we are not interrupt.

If somebody else holds that lock, it will likely do the work for us.
If it won't, then we return here later and retry.

Under heavy load it allows to avoid lock congestion between interrupt and
polling threads.

4 years agoMFC of 356063
Kirk McKusick [Mon, 6 Jan 2020 21:14:27 +0000 (21:14 +0000)]
MFC of 356063

Do not ask to use journal in fsck_ffs if journal is out of date

4 years agoMFC r356201:
Hans Petter Selasky [Mon, 6 Jan 2020 09:50:44 +0000 (09:50 +0000)]
MFC r356201:
Fix spelling.

PR: 242891
Sponsored by: Mellanox Technologies

4 years agoMFC r356137:
Hans Petter Selasky [Mon, 6 Jan 2020 09:23:54 +0000 (09:23 +0000)]
MFC r356137:
Implement dump_stats command for usbconfig(8).

This command is useful when debugging USB device issues.

Sponsored by: Mellanox Technologies

4 years agoMFC r356136:
Hans Petter Selasky [Mon, 6 Jan 2020 09:20:04 +0000 (09:20 +0000)]
MFC r356136:
Implement new libusb v2.0 API function, libusb20_dev_get_stats().

This function is useful when debugging USB device issues.

Sponsored by: Mellanox Technologies

4 years agoMFC r356135:
Hans Petter Selasky [Mon, 6 Jan 2020 09:07:57 +0000 (09:07 +0000)]
MFC r356135:
Make USB statistics per device instead of per bus.

Bump the FreeBSD version due to structure change to
force recompilation of external USB modules.

Sponsored by: Mellanox Technologies

4 years agoMFC r356042: Make pass(4) handle misaligned buffers of MAXPHYS size.
Alexander Motin [Mon, 6 Jan 2020 01:12:15 +0000 (01:12 +0000)]
MFC r356042: Make pass(4) handle misaligned buffers of MAXPHYS size.

Since we are already using malloc()+copyin()/copyout() for smaller data
blocks, and since new asynchronous API does it always, I see no reason
to keep this ugly artificial size/alignment limitation in old API.

Tape applications suffer enough from the MAXPHYS limitations by itself,
and additional alignment requirement, often halving effectively usable
block size, does not help.

It would be good to use unmapped I/O here instead, but it require some
HBA drivers polishing first to support non-BIO unmapped buffers.

4 years agoMFC further inetd(8) cleanup: r356204, r356215, r356217-r356218,
Kyle Evans [Sun, 5 Jan 2020 21:35:02 +0000 (21:35 +0000)]
MFC further inetd(8) cleanup: r356204, r356215, r356217-r356218,
r356246-r356248, r356254, r356318

r356204:
inetd: don't leak `policy` on return

sep->se_policy gets a strdup'd version of policy, so we don't need it to
stick around afterwards.

While here, remove a couple of NULL checks prior to free(policy).

r356215:
inetd: knock out some clang analyze warnings

chargen_dg: clang-analyze is convinced that endring could be non-NULL at
entry, and thus wants to assume that rs == NULL. Just independently
initialize rs if it's NULL to appease the analyzer.

getconfigent: policy leaks on return

free_connlist: reorganize the loop to make it clear that we're not going to
access `conn` after it's been freed.

cpmip/hashval: left-shifts performed will result in UB as we take
signed 0xABC3D20F and left shift it by 5.

r356217:
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.

r356218:
inetd: prefer strlcpy to strlen(3) check + strcpy(3), NFC

This is again functionally equivalent but more concise.

r356246:
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.

r356247:
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.

r356248:
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.

r356254:
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.

r356318:
inetd: fix WITHOUT_TCP_WRAPPERS build after r356248

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

4 years agoMFC r356186:
Mark Johnston [Sun, 5 Jan 2020 18:15:41 +0000 (18:15 +0000)]
MFC r356186:
Add ARMv8 static relocation types used for control flow instructions.

4 years agoMFC r349720, r356228
Cy Schubert [Sat, 4 Jan 2020 00:51:03 +0000 (00:51 +0000)]
MFC r349720, r356228

r349720 (des):
Upgrade Unbound to 1.9.2.

r356228:
MFV r356143:

Update unbound 1.9.2 --> 1.9.6.

Security: CVE-2019-18934 (fixed by 1.9.5)

4 years agoMFC r355988-r355990
Cy Schubert [Sat, 4 Jan 2020 00:41:22 +0000 (00:41 +0000)]
MFC r355988-r355990

r355988:
MFV r353141 (by phillip):

Update libpcap from 1.9.0 to 1.9.1.

r355989:
MFV r353143 (phillip):

Update tcpdump from 4.9.2 to 4.9.3.

r355990:
MFV r355890:

Fix libpcap issue #893: check for invalid IPv4 addresses.

This fixes errors such as:

tcpdump -i lagg0 net 999.999.999.999

This was originally discovered on a Red Hat 7.7 server and verified
to also be a bug on FreeBSD.

Obtained from: https://github.com/the-tcpdump-group/libpcap/commit/ \
07070918d5e81a515315b395f334e52589fe0fb
Fixed by: https://github.com/guyharris

4 years agoMFC r356126:
Konstantin Belousov [Fri, 3 Jan 2020 01:21:15 +0000 (01:21 +0000)]
MFC r356126:
ufs: do not leave non-reclaimed vnodes with zero i_mode around.

MFC note: this should be a nop on stable/12.

4 years agoMFC r356107:
Mark Johnston [Fri, 3 Jan 2020 00:29:09 +0000 (00:29 +0000)]
MFC r356107:
Plug some ifaddr refcount leaks.

PR: 242746

4 years agoMFC r355942:
Mark Johnston [Fri, 3 Jan 2020 00:28:34 +0000 (00:28 +0000)]
MFC r355942:
Deduplicate code between if_delgroup() and if_delgroups().

4 years agoMFC r355055: Fix gcc build for bitstring_test by specifying "-fno-strict-overflow"
Eric Joyner [Thu, 2 Jan 2020 23:18:43 +0000 (23:18 +0000)]
MFC r355055: Fix gcc build for bitstring_test by specifying "-fno-strict-overflow"

Sponsored by: Intel Corporation

4 years agoMFC r354977: bitstring: add functions to find contiguous set/unset bit sequences
Eric Joyner [Thu, 2 Jan 2020 23:16:27 +0000 (23:16 +0000)]
MFC r354977: bitstring: add functions to find contiguous set/unset bit sequences

This MFC also includes extra commits that improve on the original:
r355032: bitstring: Fix error messages in tests for area functions
r355377: Improve bit_ffc_area and bit_ffs_area_at implementation
r355400: bitstring: avoid gcc -Wsign-compare

Sponsored by: Intel Corporation

4 years agoMFC r354975: bitstring: exit early if _start is past size of the bitstring
Eric Joyner [Thu, 2 Jan 2020 23:05:48 +0000 (23:05 +0000)]
MFC r354975: bitstring: exit early if _start is past size of the bitstring

This fixes a possible buffer read overflow.

Sponsored by: Intel Corporation

4 years agoMFC isc_pause_frame field fixes to Intel ethernet drivers
Eric Joyner [Thu, 2 Jan 2020 22:57:21 +0000 (22:57 +0000)]
MFC isc_pause_frame field fixes to Intel ethernet drivers

This MFC includes: r353656, r353657, r353658, and r353661

Sponsored by: Intel Corporation

4 years agoMFC r354344: iflib: properly release memory allocated for DMA
Eric Joyner [Thu, 2 Jan 2020 22:47:10 +0000 (22:47 +0000)]
MFC r354344: iflib: properly release memory allocated for DMA

Prevents M_DEVBUF memory from leaking due to iflib DMA allocations.

Sponsored by: Intel Corporation

4 years agoMFC r354207: iflib: cleanup memory leaks on driver detach
Eric Joyner [Thu, 2 Jan 2020 22:44:38 +0000 (22:44 +0000)]
MFC r354207: iflib: cleanup memory leaks on driver detach

Sponsored by: Intel Corporation

4 years agoMFC r353967: iflib: call ether_ifdetach and netmap_detach before stop
Eric Joyner [Thu, 2 Jan 2020 22:42:18 +0000 (22:42 +0000)]
MFC r353967: iflib: call ether_ifdetach and netmap_detach before stop

This prevents a possible page fault resulting from a race condition.

Sponsored by: Intel Corporation

4 years agoMFC r351153: net: Update SFF-8024 definitions and strings with values from rev 4.6
Eric Joyner [Thu, 2 Jan 2020 21:58:34 +0000 (21:58 +0000)]
MFC r351153: net: Update SFF-8024 definitions and strings with values from rev 4.6

This will let ifconfig -v's SFF eeprom read functionality recognize more
module types.

Sponsored by: Intel Corporation

4 years agoMFC r349586 (by rlibby): g_eli_create: only dec g_access acw if we inc'd it
Alexander Motin [Thu, 2 Jan 2020 20:33:56 +0000 (20:33 +0000)]
MFC r349586 (by rlibby): g_eli_create: only dec g_access acw if we inc'd it

4 years agoMFC r355860:
Ian Lepore [Thu, 2 Jan 2020 19:55:09 +0000 (19:55 +0000)]
MFC r355860:

Remove unnecessary MODULE_DEPEND() from imx_i2c.c, and also from rk_i2c
where it got copied to.

4 years agoMFC r347828 (by cem):
Ian Lepore [Thu, 2 Jan 2020 19:52:01 +0000 (19:52 +0000)]
MFC r347828 (by cem):

xdma(4): Fix invalid pointer use (breaks arm.SOCFPGA build)

In xdma_handle_mem_node(), vmem_size_t and vmem_addr_t pointers were passed to
an FDT API that emits u_long values to the output parameter pointer.  This
broke on systems with both xdma and 32-bit vmem size/addr types (SOCFPGA).

Reported by: tinderbox
Sponsored by: Dell EMC Isilon

4 years agoMFC r356184:
Mark Johnston [Thu, 2 Jan 2020 14:39:37 +0000 (14:39 +0000)]
MFC r356184:
powerd(8): Fix a memory leak when we fail to read frequency levels.

PR: 242967

4 years agoMFC: r356066
Rick Macklem [Tue, 31 Dec 2019 18:10:34 +0000 (18:10 +0000)]
MFC: r356066
Fix nfsmount() so that it will return NFSERR_MINORVERMISMATCH.

If nfsrpc_getdirpath() returns NFSERR_MINORVERMISMATCH, it would erroneously
get mapped to EIO. This was not particularily harmful, but would make it
hard for sysadmins to diagnose why an NFSv4 mount is failing.

mount_nfs.c still needs to be fixed so that it does not report
NFSERR_MINORVERMISMATCH as an unknown error 10021.

4 years agoMFC r356230:
Glen Barber [Tue, 31 Dec 2019 16:04:16 +0000 (16:04 +0000)]
MFC r356230:
 Happy New Year 2020!

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

4 years agoMFC r356039:
Konstantin Belousov [Mon, 30 Dec 2019 00:49:49 +0000 (00:49 +0000)]
MFC r356039:
Fix undefined behavior: left-shifting into the sign bit.

4 years agoMFC r356103: cron(8): use proper variable to determine mailer process status
Kyle Evans [Mon, 30 Dec 2019 00:16:58 +0000 (00:16 +0000)]
MFC r356103: cron(8): use proper variable to determine mailer process status

While the mailer is normally opened/set if the mailto is set, this is not
the case if the grandchild actually didn't produce any output. This change
corrects the situation to only attempt to kill/close the mail process if it
was actually opened in the first place.

The reporter initially stumbled on the -n (suppress mail on success) flag
leading to a SIGKILL of the process group, but simultaneously
discovered/reported the behavior with !-n jobs if MAILTO was set and no
output happened.

All of these places that are checking mailto should actually be checking
whether mail is set, so do that for consistency+correctness.

This set of bugs were introduced by r352668.

4 years agoMFC: r355530
Rick Macklem [Mon, 30 Dec 2019 00:04:17 +0000 (00:04 +0000)]
MFC: r355530
Delete an unused external declaration.

Since nfsv4_opflag is no longer used in nfs_clcomsubs.c, delete the
external declaration of it. Found during NFSv4.2 code merge.

4 years agoMFC: r355509
Rick Macklem [Sun, 29 Dec 2019 23:48:48 +0000 (23:48 +0000)]
MFC: r355509
Fix kernel handling of a NFSERR_MINORVERSMISMATCH NFSv4 server reply.

When an NFSv4 server replies NFSERR_MINORVERSMISMATCH, it does not generate
a status result for the first operation in the compound. Without this
patch, this will result in a bogus EBADXDR error return.
Returning EBADXDR is relatively harmless, but a correct reply of
NFSERR_MINORVERSMISMATCH is needed by the pNFS client to select the correct
minor version to use for a File Layout DS now that there can be NFSv4.2
DS servers.

mount_nfs.c still needs to be fixed for this, although how the mount fails
is only useful to help sysadmins isolate why a mount fails.

Found during testing of the NFSv4.2 client and server.

4 years agoMFC: r355194
Rick Macklem [Sat, 28 Dec 2019 22:24:16 +0000 (22:24 +0000)]
MFC: r355194
Fix two races while handling nfsuserd daemon start/stop.

A crash was reported where the nr_client field was NULL during an upcall
to the nfsuserd daemon. Since nr_client == NULL only occurs when the
nfsuserd daemon is being shut down, it appeared to be caused by a race
between doing an upcall and the daemon shutting down.
By inspection two races were identified:
1 - The nfsrv_nfsuserd variable is used to indicate whether or not the
    daemon is running. However it did not handle the intermediate phase
    where the daemon is starting or stopping.

    This was fixed by making nfsrv_nfsuserd tri-state and having the
    functions that are called during start/stop to obey the intermediate
    state.

2 - nfsrv_nfsuserd was checked to see that the daemon was running at
    the beginning of an upcall, but nothing prevented the daemon from
    being shut down while an upcall was still in progress.
    This race probably caused the crash.

    The patch fixes this by adding a count of upcalls in progress and
    having the shut down function delay until this count goes to zero
    before getting rid of nr_client and related data used by an upcall.

4 years agoMFC r355718: Fix $() handling, broken since the beginning at r108014.
Alexander Motin [Fri, 27 Dec 2019 18:52:43 +0000 (18:52 +0000)]
MFC r355718: Fix $() handling, broken since the beginning at r108014.

Due to off-by-one error in brackets counting it consumed the rest of the
string, preventing later variables expansions.

4 years agoMFC r355913
Doug Moore [Fri, 27 Dec 2019 17:41:41 +0000 (17:41 +0000)]
MFC r355913
Allow #include<sys/tmpfs.h> to compile when _KERNEL is not #defined.

4 years agoMFC r355936, r356045: remove unused kbd drivers
Kyle Evans [Fri, 27 Dec 2019 03:00:18 +0000 (03:00 +0000)]
MFC r355936, r356045: remove unused kbd drivers

r355936:
Kill off dummy kbd drivers

As far as I can tell, these are an artifact of times when linker sets
couldn't be empty, otherwise the kernel build would fail due to unresolved
symbols. hselasky fixed this in r268138, and I've audited the kbd portions
to make sure nothing would blow up due to the empty linker set and
successfully compiled+ran a kernel with no keyboard support at all.

Kill them off now since they're no longer required.

r356045:
terasic_mtl: kill off final dummy keyboard driver

The rest were removed in r355936, which speculated that the cause of this
phenomenon was due to an inability to have an empty linker set. The comment
included with this one shows that this was, in fact, not the reason.

Regardless, syscons no longer seems to have an issue with not having any
keyboard drivers and in-fact ignores the keyboard probe anyways.

4 years agoMFC r355941:
Mark Johnston [Fri, 27 Dec 2019 00:49:49 +0000 (00:49 +0000)]
MFC r355941:
mii(4): Fix ivars leak when the bus device or bus children detach.

PR: 242727

4 years agoMFC r355650:
Andrey V. Elsukov [Thu, 26 Dec 2019 18:05:38 +0000 (18:05 +0000)]
MFC r355650:
  Follow RFC 4443 p2.2 and always use own addresses for reflected ICMPv6
  datagrams.

  Previously destination address from original datagram was used. That
  looked confusing, especially in the traceroute6 output.
  Also honor IPSTEALTH kernel option and do TTL/HLIM decrementing only
  when stealth mode is disabled.

  Reported by: Marco van Tol <marco at tols org>
  Sponsored by: Yandex LLC
  Differential Revision: https://reviews.freebsd.org/D22631

4 years agoMFC r356047:
Mark Johnston [Thu, 26 Dec 2019 16:56:42 +0000 (16:56 +0000)]
MFC r356047:
oce: Disallow the passthrough ioctl for unprivileged users.

4 years agoMFC r352878:
Aleksandr Rybalko [Wed, 25 Dec 2019 22:19:23 +0000 (22:19 +0000)]
MFC r352878:

Initialize baseaddr to suppres warning.

4 years agoMFC r352875:
Aleksandr Rybalko [Wed, 25 Dec 2019 22:07:24 +0000 (22:07 +0000)]
MFC r352875:

Put sections into expected offset in binary format.
Calculate binary file offset using address field, bacause software know only offset to known data, not where to load segment.
With that patch, kernel .data section can have any alignment/offset - kernel boor fine.

PR: 235391
Reviewed by: markj
Differential Revision: D21827

4 years agoMFC r355447:
Hans Petter Selasky [Wed, 25 Dec 2019 09:32:55 +0000 (09:32 +0000)]
MFC r355447:
Fix compilation issue with mlx5core and sparc64 (gcc48):

sys/dev/mlx5/mlx5_en/mlx5_en_tx.c:335: error: requested alignment is not a constant

Sponsored by: Mellanox Technologies

4 years agoMFC r355800:
Hans Petter Selasky [Wed, 25 Dec 2019 09:28:06 +0000 (09:28 +0000)]
MFC r355800:
Install missing pcap(3) manual pages and add missing manpage
section substitutions.

Submitted by: Martin Beran <martin@mber.cz>
PR: 237893
Sponsored by: Mellanox Technologies

4 years agoMFC r355881:
Hans Petter Selasky [Wed, 25 Dec 2019 09:25:20 +0000 (09:25 +0000)]
MFC r355881:
Leave multicast group before reaping and committing state for both
IPv4 and IPv6.

This fixes a regression issue after r349369. When trying to exit a
multicast group before closing the socket, a multicast leave packet
should be sent.

Differential Revision: https://reviews.freebsd.org/D22848
PR: 242677
Reviewed by: bz (network)
Tested by: Aleksandr Fedorov <aleksandr.fedorov@itglobal.com>
Sponsored by: Mellanox Technologies

4 years agoMFC r356030:
Mark Johnston [Wed, 25 Dec 2019 05:51:47 +0000 (05:51 +0000)]
MFC r356030:
Compile uart_cpu_acpi.c, added in r348195, into uart.ko.

PR: 242771

4 years agoMFC of 355995
Kirk McKusick [Wed, 25 Dec 2019 05:00:50 +0000 (05:00 +0000)]
MFC of 355995

Fix manual page typo.

4 years agoMFC r355935: vt: fix post-boot keyboard attachment
Kyle Evans [Mon, 23 Dec 2019 20:19:23 +0000 (20:19 +0000)]
MFC r355935: vt: fix post-boot keyboard attachment

With absolutely no keyboards attached and no kbdmux in kernel, we descend
down this error path. 0 is a valid keyboard index, so leaving
vd->vd_keyboard at 0 when there's no keyboard found is objectively wrong as
later attachment of a keyboard will fail -- it gets index 0, and vt thinks
it's already using that keyboard.

This is decidedly the corniest of corner cases, but it's easy enough to get
correct that we should do so.

Tested in a kernel without atkbdc, atkbd, psm, kbdmux, ukbd, hyperv then
loading ukbd post-boot and attaching a usb keyboard.

4 years agoMFC r355938:
Mark Johnston [Mon, 23 Dec 2019 16:34:39 +0000 (16:34 +0000)]
MFC r355938:
Fix a memory leak in if_delgroups() introduced in r334118.

PR: 242712

4 years agoMFC r355712:
Andrey V. Elsukov [Mon, 23 Dec 2019 10:02:55 +0000 (10:02 +0000)]
MFC r355712:
  Make TCP options parsing stricter.

  Rework tcpopts_parse() to be more strict. Use const pointer. Add length
  checks for specific TCP options. The main purpose of the change is
  avoiding of possible out of mbuf's data access.

  Reported by: Maxime Villard

4 years agoMFC r355844:
Toomas Soome [Sun, 22 Dec 2019 20:36:57 +0000 (20:36 +0000)]
MFC r355844:
loader.efi: efi_readkey_ex needs to key despite the shift status or toggle status

From UEFI specification 2.8, page 434:
"It should also be noted that certain input devices may not be able to produce
shift or toggle state information, and in those cases the high order bit in
the respective Toggle and Shift state fields should not be active."

But we still need to check for ScanCode and UnicodeChar.

PR:             242660

4 years agoMFC r355777:
Ian Lepore [Sun, 22 Dec 2019 20:34:15 +0000 (20:34 +0000)]
MFC r355777:

Support --all-repeats in uniq(1) for compatibility with gnu coreutils.

This adds a new -D/--all-repeats option to uniq(1), which outputs each copy
of any repeated lines (as opposed to a single copy of a repeated line). You
can specify a separator option to output a blank line before or after each
group of repeated lines. This adds compatibility with the GNU coreutils
version of uniq(1).

This change also re-groups the -c, -d, -D, -u options in the usage display
and man page to indicate that they are mutally exclusive of each other. This
matches the posix/opengroup definition of uniq(1) command line args. Note
that this change does NOT actually enforce the mutual exclusion in the code,
for now, it simply documents that the arguments should be considered
exclusive with each other.

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

4 years agoMFC r355685:
Ian Lepore [Sun, 22 Dec 2019 20:06:08 +0000 (20:06 +0000)]
MFC r355685:

Clean up some of my copyrights; add SPDX tag and remove All rights reserved.

4 years agoMFC r355688:
Ian Lepore [Sun, 22 Dec 2019 20:04:35 +0000 (20:04 +0000)]
MFC r355688:

If device_delete_children() returns an error, bail on the rest of the
detach work and return the error.  Especially don't call iicbus_reset()
since the most likely cause of failing to detach children is that one
of them has IO in progress.

4 years agoMFC r355598, r355727, r355735, r355858
Ian Lepore [Sun, 22 Dec 2019 19:30:13 +0000 (19:30 +0000)]
MFC r355598, r355727, r355735, r355858

r355598:
Do not attach children of owc_gpiobus until interrupts are working.

The children of the bus need to do IO on the bus to probe for hardware
presence.  Doing IO means timing the bus states using sbinuptime(), and
that requires working timecounters, which are not initialized until after
device attachment has completed.

PR: 242526

r355727 (by imp):
Create new wrapper function: bus_delayed_attach_children()

Delay the attachment of children, when requested, until after interrutps are
running. This is often needed to allow children to run transactions on i2c or
spi busses. It's a common enough idiom that it will be useful to have its own
wrapper.

Reviewed by: ian
Differential Revision: https://reviews.freebsd.org/D21465

r355735 (by imp):
Be consistent about checking return value from bus_delayed_attach_children.

Most places checked, but a couple last minute changes didn't. Make them all use
the return value.

Noticed by: rpokala@

r355858:
Update owc_gpiobus (one-wire over gpio) to the modern gpio_pin interface.

It used to be required that a device be a child of gpiobus(4) to manipulate
gpio pins. That requirement didn't work well for FDT-based systems with many
cross-hierarchy users of gpio, so a more modern framework was created that
removed the old hierarchy requirement.

These changes adapt the owc_gpiobus driver to use the newer gpio_pin_*
functions to acquire, release, and manipulate gpio pins. This allows a
single driver to work for both hinted-attachment and fdt-based systems, and
removes the requirement that any one-wire fdt nodes must appear at the root
of the devicetree.

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

4 years agoMFC r355932: VERSATILEPB: also use default get_fkeystr/diag
Kyle Evans [Sun, 22 Dec 2019 19:14:33 +0000 (19:14 +0000)]
MFC r355932: VERSATILEPB: also use default get_fkeystr/diag

In head/, this config was broken from the defaulting commits, but in stable
branches we left the genkbd_* defaults exposed. Do this anyways.

4 years agoMFC r355206, r355212, r355257, r355271: tty nits
Kyle Evans [Sun, 22 Dec 2019 19:06:45 +0000 (19:06 +0000)]
MFC r355206, r355212, r355257, r355271: tty nits

r355206: tty_pts: don't rely on tty header pollution for sys/mutex.h
r355212: tty_rel_gone: add locking assertion
r355257: usb: remove some extraneous tty.h includes
r355271: Remove more needless <sys/tty.h> includes

4 years agoMFC r355572:
Ian Lepore [Sun, 22 Dec 2019 18:55:09 +0000 (18:55 +0000)]
MFC r355572:

Allow baud rates of 1,228,800 and 1,843,200 on CP2101/2/3 usb-serial adapters.

The datasheets for these chips claim the maximum is 921,600, but testing
shows these two higher rates also work (but no rates above 921,600 other
than these two work; these represent dividing the base buad clock by 3 and 2
respectively).

4 years agoMFC r355467, r355499, r355531-r355533, r355535, r355540, r355548-r355551, r355565
Ian Lepore [Sun, 22 Dec 2019 18:51:05 +0000 (18:51 +0000)]
MFC r355467, r355499, r355531-r355533, r355535, r355540, r355548-r355551, r355565

r355467:
Implement bus_rescan for gpiobus(4).  This allows on-the-fly reconfiguration
of gpio devices by using kenv to add hints for a new device and then do
'devctl rescan gpiobus4' to make the new device(s) attach.

It's not particularly easy to detect whether the 'at' hint has been deleted
for a child device that's currently attached, so this doesn't handle that.
But the user can use devctl commands to manually detach an existing device.

r355499:
Add module build stuff for gpioths(4), a driver for DHT11/DHT22 sensors.

r355531:
Several small fixes for the gpioths (temp/humidity sensor) driver.

At the end of a read cycle, set the gpio pin to INPUT rather than OUTPUT.
The state of the single-wire "bus" when idle should be high; setting the
pin to input allows the external pullup to pull the line high.  Setting it
to output (and leaving it driving low) was leading a good read cycle followed
by one that would fail, and it just continued like that forever, effectively
reading the sensor once every 10 seconds instead of 5.

In the attach function, do an initial read from the device before registering
the sysctls for accessing the last-read values, to prevent reading spurious
values for the first 5 seconds after the driver attaches.

Do a callout_drain() in the detach function to prevent crashes after
unloading the module.

r355532:
Simplify sysctl stuff in the gpioths driver.  There is no need to use local
functions to handle the sysctls, they all just access simple readonly
integer variables.  There's no need to track the oids of the ones we add,
since the teardown is done by newbus code, not the driver itself.

Also remove the DDB code, because it just provides access to the same data
that the sysctls already provide.

r355533:
Add support for more chips to the gpioths driver.

Previously the driver supported the DHT11 sensor.  Now it supports

 DHT11, DHT12, DHT21, DHT22, AM3201, AM3202.

All these chips are similar, differing primarily in supported temperature
and humidity ranges and accuracy (and, presumably, cost).  There are two
basic data formats reported by the various chips, and it is possible to
figure out at runtime which format to use for decoding the data based on
the range of values in a single byte of the humidity measurement. (which
is detailed in a comment block, so I won't recapitulate it here).

r355535:
Add a MODULE_DEPEND() for the gpioths driver. Also, note that the prior commit
changed the sysctl format for the temperature from "I" to "IK", and
correspondingly changed the units from integer degrees C to decikelvin.
For access via sysctl(8) the output will be the same except that now
decimal fractions will be shown when available.

r355540:
Add FDT support to the gpioths driver.  It now uses the newer gpio_pin_*()
API and can attach based on either hints or fdt data.

r355548:
Add a man page for the gpioths(4) driver.

r355549:
Add myself to the copyright list.  Also add an SPDX tag.  And finally, fix
a missing word and a spelling error in a comment.

r355550:
Paste things correctly so that I'm added to the *end* of the copyright list.

r355551:
Connect the gpioths(4) manpage to the build.

r355565:
Switch gpioths(4) from using a callout to a taskqueue for periodic polling
of the sensor hardware.  Part of the polling process involves signalling
the chip then waiting 20 milliseconds.  This was being done with DELAY(),
which is a pretty rude thing to do in a callout.  Now a taskqueue_thread
task is scheduled to do the polling, and because sleeping is allowed in
the task context, pause_sbt() replaces DELAY() for the 20ms wait.

4 years agoMFC r355738:
Ian Lepore [Sun, 22 Dec 2019 18:11:57 +0000 (18:11 +0000)]
MFC r355738:

Include ofw_bus_if.h in SRCS only on systems configured with the FDT option.

4 years agoMFC r355547: Fix a typo: the sysctl command is in chapter 8 of the manual.
Ian Lepore [Sun, 22 Dec 2019 18:10:01 +0000 (18:10 +0000)]
MFC r355547: Fix a typo: the sysctl command is in chapter 8 of the manual.

4 years agoMFC r355411:
Ian Lepore [Sun, 22 Dec 2019 17:59:24 +0000 (17:59 +0000)]
MFC r355411:

Fix a trivial typo and add a missing word.

4 years agoMFC r355100:
Ian Lepore [Sun, 22 Dec 2019 17:57:59 +0000 (17:57 +0000)]
MFC r355100:

Allow opt-out of automatic ntpd leapfile checking/fetching.

When a system has no internet connection, or when it is configured to obtain
ntpd leapfiles from some source other than the internet, or even when the
sysadmin has decided for some reason to customize ntp.conf to eliminate use
of the leapfile, the rc.d/ntpd script emits various error messages related
to the file.

This change allows setting the rc var ntp_db_leapfile to NONE to disable all
automatic processing related to that file in rc.d/ntpd.

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

4 years agoMFC r355796-r355797, r355799: kbd: defaults for get_fkeystr/diag
Kyle Evans [Sun, 22 Dec 2019 17:15:48 +0000 (17:15 +0000)]
MFC r355796-r355797, r355799: kbd: defaults for get_fkeystr/diag

The genkbd version of these remains exposed for stable branches, but
keyboard drivers that just want to use the defaults can simply not provide
their own. There shouldn't be any unset in the wild.

r355796:
kbd: provide default implementations of get_fkeystr/diag

Most keyboard drivers are using the genkbd implementations as it is;
formally use them for any that aren't set.

r355797:
chrome_kb: remove default get_fkeystr/diag implementations

This file was missed in r355796, but no harm would have come from this.

r355799:
kbd: patch linker set methods, too

This is needed after r355796. Some double-registration of kbd drivers needs
to be sorted out, then this sysinit will simply add these drivers into the
normal list and kill off any other bits in the driver that are aware of the
linker set, for simplicity.

4 years agoMFC r355793: kbd drivers: use kbdd_* indirection for diag invocation
Kyle Evans [Sun, 22 Dec 2019 17:06:56 +0000 (17:06 +0000)]
MFC r355793: kbd drivers: use kbdd_* indirection for diag invocation

4 years agoFix kbdd_diag definition
Kyle Evans [Sun, 22 Dec 2019 17:04:16 +0000 (17:04 +0000)]
Fix kbdd_diag definition

This is a direct commit to stable branches as these have been converted to
inline functions in head, which will likely not get MFC'd due to limited
utility -- follow up locking assertions likely cannot be done in stable
branches.

The use of 'level' in the macro definition was truncated to 'leve', which
makes the macro unusable.

4 years agoMFC r355788: Properly detect ATA sanitize errors.
Alexander Motin [Sun, 22 Dec 2019 17:00:53 +0000 (17:00 +0000)]
MFC r355788: Properly detect ATA sanitize errors.

It seems I read specifications not careful enough.  There are devices not
setting successful completion bit, causing previous code report false error.

4 years agoMFC r355842: kbd: const'ify a couple of keyboard_driver fields
Kyle Evans [Sun, 22 Dec 2019 16:57:19 +0000 (16:57 +0000)]
MFC r355842: kbd: const'ify a couple of keyboard_driver fields

4 years agoMFC r355794: keyboard switch definitions: standardize on c99 initializers
Kyle Evans [Sun, 22 Dec 2019 16:04:12 +0000 (16:04 +0000)]
MFC r355794: keyboard switch definitions: standardize on c99 initializers

4 years agoMFC r355867, r355875: rpi mapping detection fixes
Kyle Evans [Sun, 22 Dec 2019 15:55:52 +0000 (15:55 +0000)]
MFC r355867, r355875: rpi mapping detection fixes

r355867: arm: add SOC_BRCM_BCM2837 option, include it in GENERIC
r355875: bcm2835_vcbus: add legacy compat mappings

4 years agoMFC r354283, r354323, r354363, r354364, r354593, r355773, r355786:
Toomas Soome [Sun, 22 Dec 2019 08:22:02 +0000 (08:22 +0000)]
MFC r354283, r354323, r354363, r354364, r354593, r355773, r355786:

loader: we do not support booting from pool with log device
loader: factor out label and uberblock load from vdev_probe, add MMP checks
loader: populate nvl with data even when label_txg is 0
loader: clean up the noise around log device
loader: memory leak in vdev_label_read_config()
loader: zfsimpl.c cstyle cleanup
loader: rewrite zfs vdev initialization

In some cases the pool discovery will get stuck in infinite loop while setting
up the vdev children.

To fix, we split the vdev setup into two parts, first we create vdevs based on
configuration we do get from pool label, then, we process pool config from MOS
and update the pool config if needed.

This patch bundle is work leading to and including fix for issue when
in some cases the pool configuration build does end up in infinite loop.

PR: 241118
Reported by: Ryan Moeller

4 years agoMFC r355318, r355513
Xin LI [Sun, 22 Dec 2019 05:39:26 +0000 (05:39 +0000)]
MFC r355318, r355513

r355318:
Explicitly exit() instead of return in main().

r355513:
Fix a couple of minor issues with newfs_msdos:

 - Do not unnecessarily strdup().
 - Check return value of getdiskinfo(), if it failed, bail out.

4 years agoMFC r354291 - r354322, r354327, r355596
Vladimir Kondratyev [Sun, 22 Dec 2019 00:46:07 +0000 (00:46 +0000)]
MFC r354291 - r354322, r354327, r355596

r354291:
[ig4] Give common name to PCI and ACPI device drivers

r354292:
[ig4] Handle controller startup errors

Obtained from: DragonflyBSD (509820b)

r354293:
[ig4] Only enable interrupts when we want them. Otherwise keep mask at 0.

Obtained from: DragonflyBSD (d7c8555)

r354294:
[ig4] Drop driver's internal RX FIFO

r354295:
[ig4] Do not wait for interrupts in set_controller() routine

r354296:
[ig4] Reduce scope of io_lock

r354297:
[ig4] Ignore stray interrupts

r354298:
[ig4] We actually need to set the Rx threshold register one smaller.

Obtained from: DragonflyBSD (02f0bf2)

r354299:

[ig4] Stop I2C controller after checking that it's kind of functional.

Obtained from: DragonfliBSD (0b3eedb)

r354300:
[ig4] disable controller before initialization of clock counters

r354301:
[ig4] Add support for polled mode

r354302:
[ig4] Allow enabling of polled mode from iicbus allocation callback

r354303:
[ig4] Do not wait until interrupts are enabled at attach stage

r354304:
[cyapa] Postpone start of the polling thread until sleep is available

r354305:
[ig4] dump IG4_REG_COMP_PARAM1 and IG4_REG_COMP_VER registers unconditionally

r354306:
[ig4] Set clock registers based on controller model

r354307:
[ig4] Implement burst mode for data reads

r354308:
[ig4] Add suspend/resume support

PR: 238037

r354309:
[ig4] Remove dead code inherited from DragonflyBSD

r354310:
[ig4] Rewrite ig4iic_write routine to use TX_EMPTY status flag

r354311:
[ig4] Convert last remaining usage of TX_NOTFULL status to TX_EMPTY

r354312:
[ig4] Use interrupts for waiting for empty TX FIFO

r354313:
[ig4] Convert polling loop from status-based to interrupt-based

r354314:
[ig4] Improve error detection

r354315:
[ig4] Set STOP condition and flush TX/RX FIFOs on error

r354316:
[ig4] On SkyLake controllers issue reset on attach unconditionally.

r354317:
[ig4] wait for bus stop condition after stop command issued

r354318:
[ig4] Minor improvement of write pipelining

r354319:
[ig4] Add generic resource methods to bus interface

r354320:
[ig4] Add support for CannonLake controllers

PR: 240485
Submitted by: Neel Chauhan <neel@neelc.org>

r354321:
[ig4] Enable additional registers support on Appolo Lake controllers

r354322:
[ig4] Convert ithread interrupt handler to filter based one.

r354327:
[ig4] Try to workaround MIPS namespace pollution issue

r355596:
[ig4] Remove unused methods from bus interface

Suggested by: jhb

Reviewed by: imp (previous version)
Differential Revision: https://reviews.freebsd.org/D22016

4 years agoMFC r355885:
Mark Johnston [Sat, 21 Dec 2019 18:50:25 +0000 (18:50 +0000)]
MFC r355885:
oce: Tighten input validation in the SIOCGI2C handler.

4 years agoMFC r355887:
Mark Johnston [Sat, 21 Dec 2019 16:16:43 +0000 (16:16 +0000)]
MFC r355887:
vnic: Relax PHY node matching after r336281.

PR: 242654

4 years agoMFC r354824:
Mark Johnston [Sat, 21 Dec 2019 16:08:34 +0000 (16:08 +0000)]
MFC r354824:
Fix grammar in gpart.8.

PR: 241973

4 years agoMFC r355500:
Konstantin Belousov [Sat, 21 Dec 2019 15:33:19 +0000 (15:33 +0000)]
MFC r355500:
Only return EPERM from kill(-pid) when no process was signalled.

4 years agoMFC r355828:
Pedro F. Giffuni [Sat, 21 Dec 2019 02:40:40 +0000 (02:40 +0000)]
MFC r355828:
Double the size of ARG_MAX on LP64 platforms.

As modern software keeps growing in size, we get requests to update the
value of ARG_MAX in order to link the resulting object files. Other OSs
have much higher values but increasiong ARG_MAX has a multiplied effect on
KVA, so just bumping this value is dangerous in some archs like ARM32 that
can exhaust KVA rather easily.

While it would be better to have a unique value for all archs, other OSs
(Illumos in particular) can have different ARG_MAX limits depending on the
platform,  For now we want to be really conservative so we are avoidng
the change on ILP32 and in the alternative case we only double it since that
seems to work well enough for recent Code Aster.

Bump the _FreeBSD_version for this change.

PR: 241710

4 years agoMFC: r355157, r355161
Rick Macklem [Fri, 20 Dec 2019 22:53:23 +0000 (22:53 +0000)]
MFC: r355157, r355161
Add a cap on credential lifetime for Kerberized NFS.

The kernel RPCSEC_GSS code sets the credential (called a client) lifetime
to the lifetime of the Kerberos ticket, which is typically several hours.
As such, when a user's credentials change such as being added to a new group,
it can take several hours for this change to be recognized by the NFS server.
This patch adds a sysctl called kern.rpc.gss.lifetime_max which can be set
by a sysadmin to put a cap on the time to expire for the credentials, so that
a sysadmin can reduce the timeout.
It also fixes a bug, where time_uptime is added twice when GSS_C_INDEFINITE
is returned for a lifetime. This has no effect in practice, since Kerberos
never does this.

4 years agoMFC r355830:
Brooks Davis [Fri, 20 Dec 2019 22:07:05 +0000 (22:07 +0000)]
MFC r355830:

Avoid a tautological bitwise compare.

This looks like a bit of debugging code that sliped into the initial
import of the sos@ ATA framework.  This changes the behavior to omit a
line of output that appears to have been intended for omission.

Reviewed by: mav
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D22845

4 years agoMFC r355864:
Mark Johnston [Fri, 20 Dec 2019 16:04:26 +0000 (16:04 +0000)]
MFC r355864:
an(4): Require privileges for all SIOCGAIRONET requests.

4 years agoMFC r355702:
Toomas Soome [Fri, 20 Dec 2019 08:15:55 +0000 (08:15 +0000)]
MFC r355702:
loader: vdisk dereference after free

print out the information and then free the memory used.

4 years agoMFC r355703:
Toomas Soome [Fri, 20 Dec 2019 08:12:44 +0000 (08:12 +0000)]
MFC r355703:
loader: clean up devopen and devclose a bit

devopen should undo setup of f->f_dev in case of error.
devclose can just call free().

4 years agoMFC r355713:
Toomas Soome [Fri, 20 Dec 2019 07:40:28 +0000 (07:40 +0000)]
MFC r355713:
loader: cd9660_open() warn: is 'buf' large enough for 'struct iso_primary_descriptor'?

We do allocate amount of memory (void * or char *), and then assign this
buffer to struct iso_primary_descriptor *vd. Make sure we do
allocate enough bytes.

In fact we do allocate enough, but it is good idea to make sure this really
is so.

4 years agoMFC r355676:
Konstantin Belousov [Fri, 20 Dec 2019 01:00:18 +0000 (01:00 +0000)]
MFC r355676:
rtld: make checks for mmap(2) failures compliant with documentation.

4 years agoMFC r355457: Make devstat_end_transaction_bio() count BIO_ORDERED.
Alexander Motin [Fri, 20 Dec 2019 00:25:56 +0000 (00:25 +0000)]
MFC r355457: Make devstat_end_transaction_bio() count BIO_ORDERED.

4 years agoAdd Makefile.depend.options
Simon J. Gerraty [Thu, 19 Dec 2019 04:58:11 +0000 (04:58 +0000)]
Add Makefile.depend.options

Leaf directories that have dependencies impacted
by options need a Makefile.depend.options file
to avoid churn in Makefile.depend

DIRDEPS for cases such as OPENSSL, TCP_WRAPPERS etc
can be set in local.dirdeps-options.mk
which can add to those set in Makefile.depend.options

See share/mk/dirdeps-options.mk

Also update affected Makefile.depend files.

MFC of r355616 and r355617

Reviewed by:  bdrewery
Sponsored by:   Juniper Networks
Differential Revision:  https://reviews.freebsd.org/D22469

4 years agoUpdate dirdeps.mk and gendirdeps.mk
Simon J. Gerraty [Thu, 19 Dec 2019 04:49:34 +0000 (04:49 +0000)]
Update dirdeps.mk and gendirdeps.mk

The env space consumed by exporting all libc's .meta files
left little room for command line,
so unexport when done.

Update dirdeps.mk to latest and add
dirdeps-targets.mk to simplify/update targets/Makefile

Makefile changes to go with Makefile.depend changes in D22494

MFC of r355618

Reviewed by:  bdrewery
Sponsored by:   Juniper Networks
Differential Revision:  https://reviews.freebsd.org/D22495

4 years agoMFC r339955, r355590: sed test fix + \r, \n, \t
Kyle Evans [Thu, 19 Dec 2019 02:29:15 +0000 (02:29 +0000)]
MFC r339955, r355590: sed test fix + \r, \n, \t

r339955:
usr.bin/sed/tests: fix one of the regression test cases by adding its
results file to the build.

r355590:
sed: process \r, \n, and \t

This is both reasonable and a common GNUism that a lot of ported software
expects.

Universally process \r, \n, and \t into carriage return, newline, and tab
respectively. Newline still doesn't function in contexts where it can't
(e.g. BRE), but we process it anyways rather than passing
UB \n (escaped ordinary) through to the underlying regex engine.

Adding a --posix flag to disable these was considered, but sed.1 already
declares this version of sed a super-set of POSIX specification and this
behavior is the most likely expected when one attempts to use one of these
escape sequences in pattern space.

This differs from pre-r197362 behavior in that we now honor the three
arguably most common escape sequences used with sed(1) and we do so outside
of character classes, too.

Other escape sequences, like \s and \S, will come later when GNU extensions
are added to libregex; sed will likely link against libregex by default,
since the GNU extensions tend to be fairly un-intrusive.

4 years agoMFC r355761: <unistd.h>: remove redundant __BSD_VISIBLE
Kyle Evans [Thu, 19 Dec 2019 02:19:04 +0000 (02:19 +0000)]
MFC r355761: <unistd.h>: remove redundant __BSD_VISIBLE

This bit is already inside of a larger __BSD_VISIBLE block.

4 years agoMFC r355643: __FreeBSD__version bumps for sigsetops
Kyle Evans [Thu, 19 Dec 2019 02:14:49 +0000 (02:14 +0000)]
MFC r355643: __FreeBSD__version bumps for sigsetops