]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
5 years agoMFC r344238-r344241
Ian Lepore [Sun, 21 Apr 2019 22:26:27 +0000 (22:26 +0000)]
MFC r344238-r344241

r344238:
Restore loader(8)'s ability for lsdev to show partitions within a bsd slice.

I'm pretty sure this used to work at one time, perhaps long ago.  It has
been failing recently because if you call disk_open() with dev->d_partition
set to -1 when d_slice refers to a bsd slice, it assumes you want it to
open the first partition within that slice.  When you then pass that open
dev instance to ptable_open(), it tries to read the start of the 'a'
partition and decides there is no recognizable partition type there.

This restores the old functionality by resetting d_offset to the start
of the raw slice after disk_open() returns.  For good measure, d_partition
is also set back to -1, although that doesn't currently affect anything.

I would have preferred to make disk_open() avoid such rude assumptions and
if you ask for partition -1 you get the raw slice.  But the commit history
shows that someone already did that once (r239058), and had to revert it
(r239232), so I didn't even try to go down that road.

r344239:
Use a couple local variables to avoid repetitive long expressions that
cause line-wrapping.

r344240:
Make lsdev -v output line up in neat columns by using a fixed width for
the size field and a tab between the partition type and the size.

Changes this

  disk devices:
        disk0 (MMC)
        disk0s1: DOS/Windows            49MB
        disk0s2: FreeBSD                14GB
        disk0s2a: FreeBSD UFS         14GB
        disk0s2b: Unknown             2048KB
        disk0s2d: FreeBSD UFS         2040KB

to this

  disk devices:
        disk0 (MMC)
        disk0s1: DOS/Windows      49MB
        disk0s2: FreeBSD          14GB
        disk0s2a: FreeBSD UFS     14GB
        disk0s2b: Unknown       2048KB
        disk0s2d: FreeBSD UFS   2040KB

r344241:
Garbage collect no-longer-used constant.

5 years agoMFC r342639:
Ian Lepore [Sun, 21 Apr 2019 22:21:36 +0000 (22:21 +0000)]
MFC r342639:

When allocating a new keyboard at vt_upgrade() time, unwind any cngrabs
done on the old keyboard and then do the corresponding number of grabs
on the new keyboard.

This fixes a race that can leave the system with a non-functioning
keyboard.  It goes like this...

 - The bios claims there is an AT keyboard, atkbd attaches.
 - SI_SUB_INT_CONFIG_HOOKS runs.
 - USB probes devices. Devices begin attaching, including disks.
 - GELI prompts for a password for a just-attached disk, which results
   in a cngrab() while atkbd is the keyboard.
 - A USB keyboard attaches.
 - vt_upgrade() runs and switches the keyboard to the new USB keyboard,
   but because cngrab was never called for it, it's not activated and
   keystrokes are ignored.
 - Now there is no functional keyboard and no way to get one; even
   plugging in a different USB keyboard doesn't help, because the console
   is still grabbed, still waiting for a GELI pw.

5 years agoMFC r341420, r341473, r341651
Ian Lepore [Sun, 21 Apr 2019 22:13:07 +0000 (22:13 +0000)]
MFC r341420, r341473, r341651

r341420:
Eliminate duplicated code and struct member definitions in the handoff
of args data between gptboot/zfsboot and loader(8).

Despite what seems like a lot of changes here, there are no actual
changes in behavior, or in the data layout in the structures involved.
This is just eliminating identical code pasted into multiple locations.

In detail, the changes are...

- Move struct zfs_boot_args definition from libsa/zfs/libzfs.h to
  i386/common/bootargs.h because it is specific to x86 booting and the
  handoff between zfsboot and loader, and has no relation to the zfs
  library code in general.

- The geli_boot_args and zfs_boot_args structs both contain an identical
  set of member variables containing geli information.  Extract this out
  to a new geli_boot_data struct, and embed it in the arg-passing structs.

- Provide new routines geli_import_boot_data() and geli_export_boot_data()
  that can be shared between gptboot, zfsboot, and loader instead of
  pasting identical code into several different .c files.

- Remove some checks for a NULL pointer that can never be true because the
  pointer being tested was set using pointer math (kargs + 1) and that can
  never result in NULL in this code.

r341473:
Fix args cross-threading between gptboot(8) and loader(8) with zfs support.

When loader(8) is built with zfs support enabled, it assumes that any extarg
data present is a zfs_boot_args struct, but if the first-stage loader was
gptboot(8) the extarg data is actually a geli_boot_args struct.  Luckily,
zfsboot(8) and gptzfsboot(8) have always passed KARGS_FLAGS_ZFS along with
KARGS_FLAGS_EXTARG, so we can use KARGS_FLAGS_ZFS to decide whether the
extarg data is a zfs_boot_args struct.

To avoid similar problems in the future, gptboot(8) now passes a new
KARGS_FLAGS_GELI to indicate that extarg data is geli_boot_args.  In
loader(8), if the neither KARGS_FLAGS_ZFS nor KARGS_FLAGS_GELI is set but
extarg data is present (which will be the case for gptboot compiled before
this change), we now check for the known size of the geli_boot_args struct
passed by the older versions of gptboot as a way of confirming what type of
extarg data is present.

In a semi-related tidying up, since loader's main() has already decided
what type of extarg data is present and set the global 'zargs' var
accordingly, don't repeat the check in extract_currdev, just check whether
zargs is NULL or not.

r341651:
Don't reference zfs-specific variables if LOADER_ZFS_SUPPORT is undefined
because the variables will be undefined too.

5 years agoMFC r346312:
Ian Lepore [Sun, 21 Apr 2019 20:55:33 +0000 (20:55 +0000)]
MFC r346312:

Only set up the interrupts that will actually be used in arm generic_timer.

The code previously set up interrupt handlers for all the interrupt
resources available, including for timers that are not in use.  That could
lead to interrupt storms.  For example, if boot firmware enabled the virtual
timer but the kernel is using the physical timer, it could get flooded with
interrupts on the virtual timer which it cannot shut off.  By only setting
up an interrupt handler for the hardware that will actually be used, any
interrupts from other timer units will remain masked in the interrupt
controller.

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

5 years agoMFC r345475-r345476
Ian Lepore [Sun, 21 Apr 2019 20:53:15 +0000 (20:53 +0000)]
MFC r345475-r345476

r345475:
Truncate a too-long interrupt handler name when there is only one handler.

There are only 19 bytes available for the name of an interrupt plus the
name(s) of handlers/drivers using it. There is a mechanism from the days of
shared interrupts that replaces some of the handler names with '+' when they
don't all fit into 19 bytes.

In modern times there is typically only one device on an interrupt, but long
device names are the norm, especially with embedded systems. Also, in systems
with multiple interrupt controllers, the names of the interrupts themselves
can be long. For example, 'gic0,s54: imx6_anatop0' doesn't fit, and
replacing the device driver name with a '+' provides no useful info at all.

When there is only one handler but its name was too long to fit, this
change truncates enough leading chars of the handler name (replacing them
with a '-' char to indicate that some chars are missing) to use all 19
bytes, preserving the unit number typically on the end of the name. Using
the prior example, this results in: 'gic0,s54:-6_anatop0' which provides
plenty of info to figure out which device is involved.

PR: 211946
Reviewed by: gonzo@ (prior version without the '-' char)
Differential Revision: https://reviews.freebsd.org/D19675

r345476:
Revert accidental change that should not have been included in r345475.
I had changed this value as part of a local experiment, and neglected to
change it back before committing the other changes.

5 years agoMFC r345000:
Ian Lepore [Sun, 21 Apr 2019 20:50:55 +0000 (20:50 +0000)]
MFC r345000:

Mark the imx_spi device busy while transfers are in progress, so that the
module can't be unloaded while interrupts are pending.

5 years agoMFC r344260, r344335
Ian Lepore [Sun, 21 Apr 2019 20:46:49 +0000 (20:46 +0000)]
MFC r344260, r344335

r344260:
Allow the u-boot loaderdev env var to be formatted in the "usual" loader(8)
way: device<unit>[s|p]<slice><partition>.  E.g., disk0s2a or disk3p12.
The code first tries to parse the variable in this format using the
standard disk_parsedev().  If that fails, it falls back to parsing the
legacy format that has been supported by ubldr for years.

In addition to 'disk', all the valid uboot device names can also be used:
mmc, sata, usb, ide, scsi. The 'disk' device serves as an alias for all
those types and will match the Nth storage-type device found (where N is
the unit number).

r344335:
Fix the handling of legacy-format devices in the u-boot loaderdev variable.
When I added support for the standard loader(8) disk0s2a: type formats,
the parsing of legacy format was broken because it also contains a colon,
but it comes before the slice and partition. That would cause disk_parsedev()
to return success with the slice and partition set to wildcard values.

This change examines the string first, and if it contains spaces, dots, or
a colon at any position other than the end, it must be a legacy-format
string and we don't even try to use disk_parsedev() on it.

5 years agoMFC r344247:
Ian Lepore [Sun, 21 Apr 2019 20:40:49 +0000 (20:40 +0000)]
MFC r344247:

Make uboot_devdesc properly alias disk_devdesc, so that parsing the u-boot
loaderdev variable works correctly.

The uboot_devdesc struct is variously cast back and forth between
uboot_devdesc and disk_devdesc as pointers are handed off through various
opaque interfaces.  uboot_devdesc attempted to mimic the layout of
disk_devdesc by having a devdesc struct, followed by a union of some
device-specific stuff that included a struct that contains the same fields
as a disk_devdesc.  However, one of those fields inside the struct is 64-bit
which causes the entire union to be 64-bit aligned -- 32 bits of padding
is added between the struct devdesc and the union, so the whole mess ends
up NOT properly mimicking a disk_devdesc after all.  (In disk_devdesc there
is also 32 bits of padding, but it shows up immediately before the d_offset
field, rather than before the whole collection of d_* fields.)

This fixes the problem by using an anonymous union to overlay the devdesc
field uboot network devices need with the disk_devdesc that uboot storage
devices need.  This is a different solution than the one contributed with
the PR (so if anything goes wrong, the blame goes to me), but 95% of the
credit for this fix goes to Pawel Worach and Manuel Stuhn who analyzed the
problem and proposed a fix.

PR: 233097

5 years agoMFC r342850: Add a missing \n to a bootverbose printf.
Ian Lepore [Sun, 21 Apr 2019 19:50:30 +0000 (19:50 +0000)]
MFC r342850: Add a missing \n to a bootverbose printf.

5 years agoMFC r342652:
Ian Lepore [Sun, 21 Apr 2019 19:49:15 +0000 (19:49 +0000)]
MFC r342652:

Support the SPI mode and bus clock frequency parameters set by the devices
requesting SPI transfers.

5 years agoMFC r346216:
Konstantin Belousov [Sun, 21 Apr 2019 09:11:22 +0000 (09:11 +0000)]
MFC r346216:
ld-elf.so: make LD_DEBUG always functional.

5 years agoMFC: r345995
Rick Macklem [Sun, 21 Apr 2019 00:11:58 +0000 (00:11 +0000)]
MFC: r345995
Delete the BUGS entry related to failing when jails are enabled.

r345994 has finally fixed the bug that caused the nfsuserd(8) daemon to
fail when jails were enabled, so delete the BUGS entry from the man page.

This is a content change.

5 years agoMFC: r345994
Rick Macklem [Sun, 21 Apr 2019 00:05:12 +0000 (00:05 +0000)]
MFC: r345994
Fix nfsuserd so that it handles the mapped localhost address when jails
are enabled.

The nfsuserd(8) daemon does not function correctly when jails are enabled,
since localhost gets mapped to another IP address and, as such, the upcall
RPC fails.
This patch fixes the problem by doing a getsockname(2) of a socket mapped
to localhost to find out what the correct address is for the comparison
test with the upcall's from IP address.
This patch also adds INET6 support and the required #ifdef's for INET and
INET6. It now uses INET6 by default for the upcalls, if the kernel has
INET6 support and the daemon is also built with INET6 support.

5 years agoMFC: r345992, r346087
Rick Macklem [Sat, 20 Apr 2019 23:46:06 +0000 (23:46 +0000)]
MFC: r345992, r346087
Add INET6 support for the upcalls to the nfsuserd daemon.

The kernel code uses UDP to do upcalls to the nfsuserd(8) daemon to get
updates to the username<->uid and groupname<->gid mappings.
A change to AF_LOCAL last year had to be reverted, since it could result
in vnode locking issues on the AF_LOCAL socket.
This patch adds INET6 support and the required #ifdef INET and INET6
to the code.
This patch also reverts the unused AF_LOCAL socket code.

5 years agoMFC r345996:
Cy Schubert [Sat, 20 Apr 2019 15:06:58 +0000 (15:06 +0000)]
MFC r345996:

Update sqlite3-3.26.0 (3260000) --> sqlite3-3.27.1 (3270100)

5 years agoMFC r345348, r345594:
Mark Johnston [Sat, 20 Apr 2019 11:05:56 +0000 (11:05 +0000)]
MFC r345348, r345594:
Use -fdebug-prefix-map to map auto-generated kernel build paths.

5 years agoMFC r346010:
Mark Johnston [Sat, 20 Apr 2019 11:04:13 +0000 (11:04 +0000)]
MFC r346010:
Fix indentation.

5 years agoMFC r346011:
Mark Johnston [Sat, 20 Apr 2019 11:02:40 +0000 (11:02 +0000)]
MFC r346011:
Stop compiling bhyve(8) with -O0.

5 years agoMFC r345739:
Mark Johnston [Sat, 20 Apr 2019 11:01:47 +0000 (11:01 +0000)]
MFC r345739:
Do not perform DAD on stf(4) interfaces.

5 years agoMFC r345593:
Mark Johnston [Sat, 20 Apr 2019 10:58:33 +0000 (10:58 +0000)]
MFC r345593:
Prepend DW_AT_comp_dir to relative line number directory table entries.

5 years agoMFC r345513:
Mark Johnston [Sat, 20 Apr 2019 10:56:56 +0000 (10:56 +0000)]
MFC r345513:
Reject F_SETLK_REMOTE commands when sysid == 0.

5 years agoMFC: 342657, 345025
Warner Losh [Fri, 19 Apr 2019 20:22:21 +0000 (20:22 +0000)]
MFC: 342657, 345025

Quirks for Chipfancier chips. Their READ CAPACITY 10 and READ CAPACITY
16 values differ, and the default of using RC16 gets the improper one.

5 years agoMFC r344740:
Bjoern A. Zeeb [Fri, 19 Apr 2019 17:28:38 +0000 (17:28 +0000)]
MFC r344740:

  Fix compilation of world with WITHOUT_{INET,INET6}_SUPPORT or both set.

  Buildworld failed when both WITHOUT_INET6_SUPPORT and INET equivalent were set.
  Fix netstat and syslogd by applying appropriate #ifdef INET/INET6 to make world
  compile again.

5 years agoMFC r345757:
Bjoern A. Zeeb [Fri, 19 Apr 2019 15:53:30 +0000 (15:53 +0000)]
MFC r345757:

  Improve debugging options in bcm2835_sdhci.c

  Similar to bcm2835_sdhost.c add a TUNABLE and SYSCTL to selectively
  turn on debugging printfs if debugging is turned on at compile time.

5 years agoMFC r345372:
Bjoern A. Zeeb [Fri, 19 Apr 2019 15:52:09 +0000 (15:52 +0000)]
MFC r345372:

  Whitespace cleanup in sdhci.c

  No functional changes.  Replace whitespace by tabs, indent with 4 spaces,
  coalesce multi-line shorter than 80 characters,

5 years agoMFC r345370:
Bjoern A. Zeeb [Fri, 19 Apr 2019 15:50:51 +0000 (15:50 +0000)]
MFC r345370:

  Align struct sdhci_slot MMCCAM members.

  Whitespace only, no functional change.

5 years agoMFC r344959:
Bjoern A. Zeeb [Fri, 19 Apr 2019 15:48:57 +0000 (15:48 +0000)]
MFC r344959:

  Add two more products found inside a T480 to usbdevs.

  Add an Intel Bluetooth module.
  Add Synaptics as a vendor with a fingerprint reader product.

5 years agoMFC r344700:
Bjoern A. Zeeb [Fri, 19 Apr 2019 15:45:36 +0000 (15:45 +0000)]
MFC r344700:

  Add ushort and ulong to linux/types.h.

  When porting code once written for Linux we find not only uints but also ushort and ulong.
  Provide central typedefs as part of the linuxkpi for those as well.

5 years agoMFC r340494:
Bjoern A. Zeeb [Fri, 19 Apr 2019 15:33:54 +0000 (15:33 +0000)]
MFC r340494:

  Improve the comment for arpresolve_full() in if_ether.c.
  No functional changes.

5 years agoMFC r346275:
Glen Barber [Fri, 19 Apr 2019 13:23:41 +0000 (13:23 +0000)]
MFC r346275:
 Remove INDEX-10 reference, as 10.x is now EoL.

Sponsored by: The FreeBSD Foundation

5 years agoMFC r345966, r345968:
Konstantin Belousov [Fri, 19 Apr 2019 12:54:05 +0000 (12:54 +0000)]
MFC r345966, r345968:
Implement devctl(8) command 'reset', using DEV_RESET /dev/devctl2 ioctl.

5 years agoMFC r345965:
Konstantin Belousov [Fri, 19 Apr 2019 12:50:25 +0000 (12:50 +0000)]
MFC r345965:
Add DEV_RESET /dev/devctl2 ioctl.

5 years agoMFC r345963, r345997:
Konstantin Belousov [Fri, 19 Apr 2019 12:48:17 +0000 (12:48 +0000)]
MFC r345963, r345997:
Implement resets for PCI buses and PCIe bridges.

5 years agoMFC r345960:
Konstantin Belousov [Fri, 19 Apr 2019 12:45:45 +0000 (12:45 +0000)]
MFC r345960:
Provide newbus infrastructure for initiating device reset.

5 years agoMFC r345964:
Konstantin Belousov [Fri, 19 Apr 2019 12:38:48 +0000 (12:38 +0000)]
MFC r345964:
Remove single-use DEV_RESET() macro.

5 years agoMFC r345959:
Konstantin Belousov [Fri, 19 Apr 2019 12:33:16 +0000 (12:33 +0000)]
MFC r345959:
Add __BEGIN_DECLS/__END_DECLS braces to libdevctl header.

5 years agoMFC r346158:
Konstantin Belousov [Fri, 19 Apr 2019 12:30:15 +0000 (12:30 +0000)]
MFC r346158:
Do not access mutex memory after unlock.

PR: 237195

5 years agoMFC r346161: Fix SCSI sense data pass through.
Alexander Motin [Fri, 19 Apr 2019 03:47:23 +0000 (03:47 +0000)]
MFC r346161: Fix SCSI sense data pass through.

5 years agoMFC r346159: Fix thread name buffer overflow.
Alexander Motin [Fri, 19 Apr 2019 03:46:35 +0000 (03:46 +0000)]
MFC r346159: Fix thread name buffer overflow.

5 years agoMFC: r345866
Rick Macklem [Thu, 18 Apr 2019 02:32:04 +0000 (02:32 +0000)]
MFC: r345866
Fix malloc stats for the RPCSEC_GSS server code when DEBUG is enabled.

The code enabled when "DEBUG" is defined uses mem_alloc(), which is a
malloc(.., M_RPC, M_WAITOK | M_ZERO), but then calls gss_release_buffer()
which does a free(.., M_GSSAPI) to free the memory.
This patch fixes the problem by replacing mem_alloc() with a
malloc(.., M_GSSAPI, M_WAITOK | M_ZERO).
This bug affects almost no one, since the sources are not normally built
with "DEBUG" defined.

5 years agoMFC r345312
Eric Joyner [Wed, 17 Apr 2019 23:09:06 +0000 (23:09 +0000)]
MFC r345312

iflib: mark isc_driver_version as constant

From Jake:
The iflib core never modifies the isc_driver_version string. Allow
drivers to safely assign pointers to constant buffers by marking this
parameter const.

(Additional comment by erj: This also adds a new sysctl_add_oid macro,
SYSCTL_ADD_CONST_STRING, for displaying const strings).

Submitted by:   Jacob Keller <jacob.e.keller@intel.com>
Reviewed by:    erj@, gallatin@, jhb@
Sponsored by:   Intel Corporation
Differential Revision:  https://reviews.freebsd.org/D19577

5 years agoMFC r345303, r345305, r345657, r345658
Eric Joyner [Wed, 17 Apr 2019 23:02:37 +0000 (23:02 +0000)]
MFC r345303, r345305, r345657, r345658

Includes:
- iflib: prevent possible infinite loop in iflib_encap
- iflib: expose the Rx mbuf buffer size to drivers
- iflib: hold the CTX lock in iflib_pseudo_register
- iflib: return ENETDOWN when the network device is down

5 years agoMFC r344817
Eric Joyner [Wed, 17 Apr 2019 22:45:19 +0000 (22:45 +0000)]
MFC r344817

Remove references to CONTIGMALLOC_WORKS in iflib and em

From Jake:
"The iflib_fl_setup() function tries to pick various buffer sizes based
on the max_frame_size value defined by the parent driver. However, this
code was wrapped under CONTIGMALLOC_WORKS, which was never actually
defined anywhere.

This same code pattern was used in if_em.c, likely trying to match
what iflib uses.

Since CONTIGMALLOC_WORKS is not defined, remove this dead code from
iflib_fl_setup and if_em.c

Given that various iflib drivers appear to be using a similar
calculation, it might be worth making this buffer size a value that the
driver can peek at in the future."

Submitted by:   Jacob Keller <jacob.e.keller@intel.com>
Reviewed by:    shurd@
Sponsored by:   Intel Corporation
Differential Revision:  https://reviews.freebsd.org/D19199

5 years agoMFC r344643 and r345306
Eric Joyner [Wed, 17 Apr 2019 22:41:27 +0000 (22:41 +0000)]
MFC r344643 and r345306

Includes two ixgbe/ixv fixes:
ixgbe(4): Fix panic triggered by assertion from interrupt
ixv(4): Add missing IFLIB_IS_VF flag in iflib shared ctx

Sponsored by: Intel Corporation

5 years agoAfter r346168, also merge build infrastructure for LLVM libomp.
Dimitry Andric [Wed, 17 Apr 2019 20:08:01 +0000 (20:08 +0000)]
After r346168, also merge build infrastructure for LLVM libomp.

MFC r345235:

Add lib/libomp, with a Makefile, and generated configuration headers.
Not connected to the main build yet, as there is still the issue of the
GNU omp.h header conflicting with the LLVM one.  (That is, if MK_GCC is
enabled.)

PR: 236062

MFC r345236:

Connect lib/libomp to the build.

* Set MK_OPENMP to yes by default only on amd64, for now.
* Bump __FreeBSD_version to signal this addition.
* Ensure gcc's conflicting omp.h is not installed if MK_OPENMP is yes.
* Update OptionalObsoleteFiles.inc to cope with the conflicting omp.h.
* Regenerate src.conf(5) with new WITH/WITHOUT fragments.

Relnotes: yes
PR: 236062

MFC r345242:

Explicitly link libomp.so against -lpthread, as it depends on pthread
functionality.  This should make example OpenMP programs work out of the
box.

Reported by: jbeich
PR: 236062, 236581

MFC r345278:

Also explicitly link libomp.so against -lm, as it transitively depends
on scalbn and a few other math functions, via libcompiler-rt.  This
should allow OpenMP programs to link with BFD linkers too.

Reported by: jbeich
PR: 236062, 236581

MFC r345282:

Remove --as-needed from the linker flags for libomp.so, as these
actually prevent the transitive dependency on libm.

Reported by: jbeich
PR: 236062, 236581

MFC r345291:

Turn on MK_OPENMP for i386 by default, now that it can build.

Noticed by: jbeich
PR: 236062, 236582

5 years agoMFC r345855: cpsw: use `phy-handle` in FDT to find PHY address
Ed Maste [Wed, 17 Apr 2019 17:19:19 +0000 (17:19 +0000)]
MFC r345855: cpsw: use `phy-handle` in FDT to find PHY address

In r337703 DTS files were updated to Linux 4.18, including Linux commit
4d8b032d3c03f4e9788a18bbb51b10e6c9e8a56b which removed the `phy_id`
property from am335x-bone-common (as the property was deprecated).

Use `phy-handle` via fdt_get_phyaddr, keeping the existing code as a
fallback for old DTBs.

PR: 236624
Submitted by: manu, Gerald Aryeetey <aryeeteygerald_rogers.com>
Reported by: Gerald Aryeetey
Reviewed by: manu
Sponsored by: The FreeBSD Foundation

5 years agoMFC r345316, r345317, r345858:
Colin Percival [Wed, 17 Apr 2019 07:47:03 +0000 (07:47 +0000)]
MFC r345316, r345317, r345858:

r345316: Register ARM64 EC2 AMIs as being for the ARM64 architecture.

r345317: Don't install amazon-ssm-agent package into ARM64 AMIs.

r345858: Add support for cross-building cloudware images.

With these changes it is possible to build ARM64 EC2 AMIs on stable/12 --
said images do not *work* yet, however.

5 years agoMFC r345519: DTS/DTSO makeoptions
Kyle Evans [Tue, 16 Apr 2019 21:09:57 +0000 (21:09 +0000)]
MFC r345519: DTS/DTSO makeoptions

Allow kernel config to specify DTS/DTSO to build, and out-of-tree support

This allows for directives such as

makeoptions DTS+=/out/of/tree/myboard.dts
# in tree! Same rules applied as if this were in a dtb/ module
makeoptions DTS+=otherboard.dts

to be specified in config(5) and have these built/installed alongside th
kernel. The assumption that overlays live in an overlays/ directory is only
made for in-tree DTSO, but we still make the assumption that out-of-tree
arm64 DTS will be in vendored directories (for now).

This lowers the cost to hacking on an overlay or dts by being able to
quickly throw it in a custom config, especially if it doesn't fit one of the
current dtb/modules quite appropriately or it's not intended for commit
there.

The build/install targets were split out of dtb.mk to centralize the build
logic and leave out the all/realinstall/CLEANFILES additions... it was
believed that we didn't want to pollute the kernel build with these.

The build rules were converted to suffix rules at the suggestion of Ian to
clean things up a little bit in a world where we can have mixed
in-tree/out-of-tree DTS/DTSO specified.

5 years agoMFC r345192-r345194: if_bridge(4): Drop pointless rtflush
Kyle Evans [Tue, 16 Apr 2019 21:02:41 +0000 (21:02 +0000)]
MFC r345192-r345194: if_bridge(4): Drop pointless rtflush

r345192:
if_bridge(4): Drop pointless rtflush

At this point, all routes should've already been dropped by removing all
members from the bridge. This condition is in-fact KASSERT'd in the line
immediately above where this nop flush was added.

r345193:
Revert r345192: Too many trees in play for bridge(4) bits

An accidental appendage was committed that has not undergone review yet.

r345194:
if_bridge(4): Drop pointless rtflush

At this point, all routes should've already been dropped by removing all
members from the bridge. This condition is in-fact KASSERT'd in the line
immediately above where this nop flush was added.

5 years agoMFC r346132: stand: refactor overlay loading a little bit
Kyle Evans [Tue, 16 Apr 2019 21:01:07 +0000 (21:01 +0000)]
MFC r346132: stand: refactor overlay loading a little bit

It was pointed out that manually loading a .dtb to be used rather than
relying on platform-specific method for loading .dtb will result in overlays
not being applied. This was true because overlay loading was hacked into
fdt_platform_load_dtb, rather than done in a way more independent from how
the .dtb is loaded.

Instead, push overlay loading (for now) out into an
fdt_platform_load_overlays. This method easily allows ubldr to pull in any
fdt_overlays specified in the ub env, and omits overlay-checking on
platforms where they're not tested and/or not desired (e.g. powerpc). If we
eventually stop caring about fdt_overlays from ubenv (if we ever cared),
this method should get chopped out in favor of just calling
fdt_load_dtb_overlays() directly.

5 years agoMFC r346082: libbe(3): use libzfs name validation for datasets/snapshot names
Kyle Evans [Tue, 16 Apr 2019 20:59:57 +0000 (20:59 +0000)]
MFC r346082: libbe(3): use libzfs name validation for datasets/snapshot names

Our home-rolled solution didn't quite capture all of the details, and we
didn't actually validate snapshot names at all. zfs_name_valid captures the
important details, but it doesn't necessarily expose the errors that we're
wanting to see in the be_validate_* functions. Validating lengths
independently, then the names, should make this a non-issue.

5 years agoMFC r345180, r345187: if_bridge(4): Fix module teardown
Kyle Evans [Tue, 16 Apr 2019 20:56:51 +0000 (20:56 +0000)]
MFC r345180, r345187: if_bridge(4): Fix module teardown

r345180: if_bridge(4): Fix module teardown

bridge_rtnode_zone still has outstanding allocations at the time of
destruction in the current model because all of the interface teardown
happens in a VNET_SYSUNINIT, -after- the MOD_UNLOAD has already been
processed.  The SYSUNINIT triggers destruction of the interfaces, which then
attempts to free the memory from the zone that's already been destroyed, and
we hit a panic.

Solve this by virtualizing the uma_zone we allocate the rtnodes from to fix
the ordering. bridge_rtable_fini should also take care to flush any
remaining routes that weren't taken care of when dynamic routes were flushed
in bridge_stop.

r345187: bridge: Fix STP-related panic

After r345180 we need to have the appropriate vnet context set to delete an
rtnode in bridge_rtnode_destroy().
That's usually the case, but not when it's called by the STP code (through
bstp_notify_rtage()).

We have to set the vnet context in bridge_rtable_expire() just as we do in the
other STP callback bridge_state_change().

5 years agoMFC r345805: Unify SCSI_STATUS_BUSY retry handling with other cases.
Alexander Motin [Tue, 16 Apr 2019 18:31:40 +0000 (18:31 +0000)]
MFC r345805: Unify SCSI_STATUS_BUSY retry handling with other cases.

 - Do not retry if periph was invalidated.
 - Do not decrement retry_count if already zero.
 - Report action_string when applicable.

5 years agoMFC r346065:
Konstantin Belousov [Tue, 16 Apr 2019 17:55:54 +0000 (17:55 +0000)]
MFC r346065:
Add vn_fsync_buf().

5 years agoMFC r346064:
Konstantin Belousov [Tue, 16 Apr 2019 17:54:51 +0000 (17:54 +0000)]
MFC r346064:
Fix dirty buf exhaustion easily triggered with msdosfs.

5 years agoMFC r345425, r345514, r345799, r345800, r345803, r346157:
Konstantin Belousov [Tue, 16 Apr 2019 17:33:08 +0000 (17:33 +0000)]
MFC r345425, r345514, r345799, r345800, r345803, r346157:
Enable tmpfs rw->ro remounts.

5 years agoMFC r346062:
Konstantin Belousov [Tue, 16 Apr 2019 17:16:18 +0000 (17:16 +0000)]
MFC r346062:
pci_cfgreg.c: Use io port config access for early boot time.

PR: 236838

5 years agoMFC r346054: libc: update strstr implementation to match musl
Ed Maste [Tue, 16 Apr 2019 11:30:41 +0000 (11:30 +0000)]
MFC r346054: libc: update strstr implementation to match musl

musl commits:
122d67f846cb0be2c9e1c3880db9eb9545bbe38c
0239cd0681e889a269fb7691f60e81ef8d081e6b
8f5a820d147da36bcdbddd201b35d293699dacd8

Submitted by: David CARLIER <devnexen_gmail.com>
Obtained from: musl
MFC after: 1 week

5 years agoMFC: r345818, r345828
Rick Macklem [Tue, 16 Apr 2019 02:12:38 +0000 (02:12 +0000)]
MFC: r345818, r345828
Fix a race in the RPCSEC_GSS server code that caused crashes.

When a new client structure was allocated, it was added to the list
so that it was visible to other threads before the expiry time was
initialized, with only a single reference count.
The caller would increment the reference count, but it was possible
for another thread to decrement the reference count to zero and free
the structure before the caller incremented the reference count.
This could occur because the expiry time was still set to zero when
the new client structure was inserted in the list and the list was
unlocked.

This patch fixes the race by initializing the reference count to two
and initializing all fields, including the expiry time, before inserting
it in the list.

5 years agoMFC r345644,r346061:
Enji Cooper [Tue, 16 Apr 2019 01:03:38 +0000 (01:03 +0000)]
MFC r345644,r346061:

r345644 (by olivier):

Skip this test if if_tap module is not available

PR: 236842

r346061:

Polish netmap(4) testcases a bit

1. Not all kernels have netmap(4) support. Check for netmap(4) support before
   attempting to run the tests via the `PLAIN_REQUIRE_KERNEL_MODULE(..)` macro.
2. Libraries shouldn't be added to LDFLAGS; they should be added to LIBADD
   instead. This allows the build system to evaluate dependencies for sanity.
3. Sort some of the Makefile variables per bsd.README.

1., in particular, will resolve failures when running this testcase on kernels
lacking netmap(4) support, e.g., the i386 GENERIC kernels on ^/stable/11 and
^/stable/12.

PR: 237129

5 years agoMFC r344736 (by imp): Add ABORTED_BY_REQUEST to the list of things we look
Alexander Motin [Mon, 15 Apr 2019 15:09:25 +0000 (15:09 +0000)]
MFC r344736 (by imp): Add ABORTED_BY_REQUEST to the list of things we look
at DNR bit and tell why to comment (code already does this)

5 years agoMFC r344642 (by imp):
Alexander Motin [Mon, 15 Apr 2019 15:02:18 +0000 (15:02 +0000)]
MFC r344642 (by imp):
Unconditionally support unmapped BIOs. This was another shim for
supporting older kernels. However, all supported versions of FreeBSD
have unmapped I/Os (as do several that have gone EOL), remove it. It's
unlikely the driver would work on the older kernels anyway at this
point.

5 years agoMFC r344640 (by imp):
Alexander Motin [Mon, 15 Apr 2019 15:01:32 +0000 (15:01 +0000)]
MFC r344640 (by imp):
Remove #ifdef code to support FreeBSD versions that haven't been
supported in years. A number of changes have been made to the driver
that likely wouldn't work on those older versions that aren't properly
ifdef'd and it's project policy to GC such code once it is stale.

5 years agoMFC r342862 (by chuck): Add NVMe drive to NOIOB quirk list
Alexander Motin [Mon, 15 Apr 2019 15:00:13 +0000 (15:00 +0000)]
MFC r342862 (by chuck): Add NVMe drive to NOIOB quirk list

Dell-branded Intel P4600 NVMe drives benefit from NVMe 1.3's NOIOB
feature. Unfortunately just like Intel DC P4500s, they don't advertise
themselves as benefiting from this...

This changes adds P4600s to the existing list of old drives which
benefit from striping.

PR: 233969

5 years agoMFC r341710 (by imp):
Alexander Motin [Mon, 15 Apr 2019 14:58:40 +0000 (14:58 +0000)]
MFC r341710 (by imp):
Even though they are reserved, cdw2 and cdw3 can be set via nvme-cli
(and soon nvmecontrol). Go ahead and copy them into rsvd2 and rsvd3.

5 years agoMFC r340481 (by imp): Remove do-nothing nvme_modevent.
Alexander Motin [Mon, 15 Apr 2019 14:57:50 +0000 (14:57 +0000)]
MFC r340481 (by imp): Remove do-nothing nvme_modevent.

nvme_modevent no longer does anything interesting, remove it.

5 years agoMFC r340412 (by imp): Use atomic_load_acq_int() here too to poll done,
Alexander Motin [Mon, 15 Apr 2019 14:56:59 +0000 (14:56 +0000)]
MFC r340412 (by imp): Use atomic_load_acq_int() here too to poll done,
ala r328521

5 years agoMFC r339775 (by imp): Put a workaround in for command timeout malfunctioning
Alexander Motin [Mon, 15 Apr 2019 14:54:48 +0000 (14:54 +0000)]
MFC r339775 (by imp): Put a workaround in for command timeout malfunctioning

At least one NVMe drive has a bug that makeing the Command Time Out
PCIe feature unreliable. The workaround is to disable this
feature. The driver wouldn't deal correctly with a timeout anyway.
Only do this for drives that are known bad.

5 years agoMFC r346038:
Konstantin Belousov [Mon, 15 Apr 2019 12:24:19 +0000 (12:24 +0000)]
MFC r346038:
Exercise some care before sending SIGHUP to mountd.

5 years agoMFC r346031:
Konstantin Belousov [Mon, 15 Apr 2019 12:23:33 +0000 (12:23 +0000)]
MFC r346031:
Handle races when remounting UFS volume from ro to rw.

5 years agoMFC of 345758
Kirk McKusick [Mon, 15 Apr 2019 12:07:41 +0000 (12:07 +0000)]
MFC of 345758

Properly flush outstanding I/Os when forcibly deleteing a memory disk device.

Sponsored by: Netflix

5 years agoMFC r345319:
Andrey V. Elsukov [Sun, 14 Apr 2019 13:17:40 +0000 (13:17 +0000)]
MFC r345319:
  Use NET_EPOCH instead of allocating separate one.

  The code was modified to fix incompatibility that was introduced
  in r342872.

5 years agoMFC r345293:
Andrey V. Elsukov [Sun, 14 Apr 2019 13:08:18 +0000 (13:08 +0000)]
MFC r345293:
    Update NAT64LSN implementation:

    o most of data structures and relations were modified to be able support
      large number of translation states. Now each supported protocol can
      use full ports range. Ports groups now are belong to IPv4 alias
      addresses, not hosts. Each ports group can keep several states chunks.
      This is controlled with new `states_chunks` config option. States
      chunks allow to have several translation states for single alias address
      and port, but for different destination addresses.
    o by default all hash tables now use jenkins hash.
    o ConcurrencyKit and epoch(9) is used to make NAT64LSN lockless on fast path.
    o one NAT64LSN instance now can be used to handle several IPv6 prefixes,
      special prefix "::" value should be used for this purpose when instance
      is created.
    o due to modified internal data structures relations, the socket opcode
      that does states listing was changed.

  Obtained from: Yandex LLC
  Sponsored by: Yandex LLC

MFC r345294:
  Remove extra spaces.

5 years agoMFC r344665 (by trhodes):
Andrey V. Elsukov [Sun, 14 Apr 2019 12:11:45 +0000 (12:11 +0000)]
MFC r344665 (by trhodes):
  Grammar tweaks in ipfw manual page.

5 years agoFix the build. Include net/pfil.h to be able use IPFW_WLOCK().
Andrey V. Elsukov [Sun, 14 Apr 2019 11:19:08 +0000 (11:19 +0000)]
Fix the build. Include net/pfil.h to be able use IPFW_WLOCK().
In head/ after r343619 it is not required, but this change was not MFCed.

5 years agoMFC r345264:
Andrey V. Elsukov [Sun, 14 Apr 2019 10:44:06 +0000 (10:44 +0000)]
MFC r345264:
  Add NAT64 CLAT implementation as defined in RFC6877.

  CLAT is customer-side translator that algorithmically translates 1:1
  private IPv4 addresses to global IPv6 addresses, and vice versa.
  It is implemented as part of ipfw_nat64 kernel module. When module
  is loaded or compiled into the kernel, it registers "nat64clat" external
  action. External action named instance can be created using `create`
  command and then used in ipfw rules. The create command accepts two
  IPv6 prefixes `plat_prefix` and `clat_prefix`. If plat_prefix is ommitted,
  IPv6 NAT64 Well-Known prefix 64:ff9b::/96 will be used.

    # ipfw nat64clat CLAT create clat_prefix SRC_PFX plat_prefix DST_PFX
    # ipfw add nat64clat CLAT ip4 from IPv4_PFX to any out
    # ipfw add nat64clat CLAT ip6 from DST_PFX to SRC_PFX in

  Obtained from: Yandex LLC
  Submitted by: Boris N. Lytochkin
  Relnotes: yes
  Sponsored by: Yandex LLC

5 years agoMFC r345263:
Andrey V. Elsukov [Sun, 14 Apr 2019 10:40:43 +0000 (10:40 +0000)]
MFC r345263:
  Add SPDX-License-Identifier and update year in copyright.

5 years agoMFC r345262:
Andrey V. Elsukov [Sun, 14 Apr 2019 10:38:50 +0000 (10:38 +0000)]
MFC r345262:
  Modify struct nat64_config.

  Add second IPv6 prefix to generic config structure and rename another
  fields to conform to RFC6877. Now it contains two prefixes and length:
  PLAT is provider-side translator that translates N:1 global IPv6 addresses
  to global IPv4 addresses. CLAT is customer-side translator (XLAT) that
  algorithmically translates 1:1 IPv4 addresses to global IPv6 addresses.
  Use PLAT prefix in stateless (nat64stl) and stateful (nat64lsn)
  translators.

  Modify nat64_extract_ip4() and nat64_embed_ip4() functions to accept
  prefix length and use plat_plen to specify prefix length.

  Retire net.inet.ip.fw.nat64_allow_private sysctl variable.
  Add NAT64_ALLOW_PRIVATE flag and use "allow_private" config option to
  configure this ability separately for each NAT64 instance.

  Obtained from: Yandex LLC
  Sponsored by: Yandex LLC

5 years agoMFC r343666, r343861-r343862, r343923, r343968, r345660, and r345810.
Navdeep Parhar [Sat, 13 Apr 2019 19:23:11 +0000 (19:23 +0000)]
MFC r343666, r343861-r343862, r343923, r343968, r345660, and r345810.

r343666:
cxgbe(4): Improved error reporting and diagnostics.

"slow" interrupt handler:
- Expand the list of INT_CAUSE registers known to the driver.
- Add decode information for many more bits but decouple it from the
  rest of intr_info so that it is entirely optional.
- Call t4_fatal_err exactly once, and from the top level PL intr handler.

t4_fatal_err:
- Use t4_shutdown_adapter from the common code to stop the adapter.
- Stop servicing slow interrupts after the first fatal one.

Driver/firmware interaction:
- CH_DUMP_MBOX: note whether the mailbox being dumped is a command or a
  reply or something else.
- Log the raw value of pcie_fw for some errors.
- Use correct log levels (debug vs. error).

Sponsored by: Chelsio Communications

r343861:
cxgbe(4): Auto-dump the device log on a mailbox timeout or when the
firmware reports an error in pcie_fw.

Sponsored by: Chelsio Communications

r343862:
cxgbe(4): Auto-dump the CIM block's logic analyzer on a TIMER0 interrupt.

Sponsored by: Chelsio Communications

r343923:
cxgbe(4): Delay the panic due to a fatal error by 30s.

This lets information logged by the interrupt handler reach the system
log before the system goes down.

r343968:
cxgbe(4): Ignore unused interrupts.

Sponsored by: Chelsio Communications

r345660:
cxgbe(4): Count and clear interrupts generated at the software's request.

An interrupt can be requested by setting the F_SWINT bit in PL_PF_CTL.

Sponsored by: Chelsio Communications

r345810:
cxgbe(4): Add a flag to indicate that bits in interrupt cause but not in
interrupt enable are not fatal.

The firmware sets up all the interrupt enables based on run time
configuration, which means the information in the enables is more
accurate than what's compiled into the driver.  This change also allows
the fatal bits to be updated without any changes in the driver in some
cases.

Sponsored by: Chelsio Communications

5 years agoRevert r344898 (by kib), now that clang 8 has been merged:
Dimitry Andric [Sat, 13 Apr 2019 11:09:42 +0000 (11:09 +0000)]
Revert r344898 (by kib), now that clang 8 has been merged:

Disable WITH_RETPOLINE on stable/12.

It is known that clang 7 generates broken ifunc calls when retpoline is
enabled. Since libc uses ifuncs, mark WITH_RETPOLINE as always broken
and disabled. To be removed after clang 8 MFC.

This is a direct commit to the branch.

Reported by: many
Tested by: Nikola Mihaylov <c.source.code@gmail.com>
Reviewed by: emaste
Sponsored by: The FreeBSD Foundation

5 years agoMFC r345450:
Andrey V. Elsukov [Sat, 13 Apr 2019 08:55:49 +0000 (08:55 +0000)]
MFC r345450:
  Add ability to automatically load ipfw_nat64, ipfw_nptv6 and ipfw_pmod

  modules by declaring corresponding variables in rc.conf. Also document
  them in rc.conf(5).

  Submitted by: Dries Michiels
  Differential Revision: https://reviews.freebsd.org/D19673

MFC r345985:
  Add firewall_[nat64|nptv6|pmod]_enable variables to /etc/defaults/rc.conf

5 years agoAfter r346168, put the actual commit dates into UPDATING and
Dimitry Andric [Sat, 13 Apr 2019 08:52:52 +0000 (08:52 +0000)]
After r346168, put the actual commit dates into UPDATING and
ObsoleteFiles.inc.  I completely forgot about those, sorry.

This is a direct commit to stable/12.

5 years agoAfter r346168, put the actual commit dates into UPDATING and
Dimitry Andric [Sat, 13 Apr 2019 08:50:41 +0000 (08:50 +0000)]
After r346168, put the actual commit dates into UPDATING and
ObsoleteFiles.inc.  I completely forgot about those, sorry.

This is a direct commit to stable/12.

5 years agoRegenerate src.conf.5 for recent changes.
Simon J. Gerraty [Fri, 12 Apr 2019 20:35:11 +0000 (20:35 +0000)]
Regenerate src.conf.5 for recent changes.

5 years agoMerge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
Dimitry Andric [Fri, 12 Apr 2019 20:03:27 +0000 (20:03 +0000)]
Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
8.0.0 final release r356365.

MFC r340287 (by emaste):

Consolidate gcov entries in OptionalObsoleteFiles

Sponsored by: The FreeBSD Foundation

MFC r340289 (by emaste):

llvm-cov: also install as gcov (if GNU gcov is disabled)

llvm-cov provides a gcov-compatible interface when invoked as gcov.

Reviewed by: dim, markj
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D17923

MFC r340296 (by emaste):

Move llvm-profdata build into MK_LLVM_COV block

llvm-profdata is used with llvm-cov for code coverage (although llvm-cov
can also operate independently in a gcov-compatible mode).
Although llvm-profdata can be used independently of llvm-cov it makes
sense to group these under one option.

Also handle these in OptionalObsoleteFiles.inc while here.

Sponsored by: The FreeBSD Foundation

MFC r340300 (by emaste):

libllvm: Move SampleProfWriter to SRCS_MIN

It is required by llvm-profdata, now built by default under the
LLVM_COV knob.  The additional complexity that would come from avoiding
building it if CLANG_EXTRAS and LLVM_COV are both disabled is not worth
the small savings in build time.

Sponsored by: The FreeBSD Foundation

MFC r340972 (by emaste):

llvm-objdump: initial man page

Based on llvm-objdump's online documentation and usage information.
This serves as a starting point; additional detail and cleanup still
required.

Also being submitted upstream in LLVM review D54864.  I expect to use
this bespoke copy while we have LLVM 6.0 or 7.0 in FreeBSD; when we
update to LLVM 8.0 it should be upstream and we will switch to it.

PR: 233437
Reviewed by: bcr (man formatting)
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D18309

MFC r340973 (by emaste):

llvm-objdump.1: remove invalid options

Some options appear in llvm-objdump's usage information as a side effect
of its option parsing implementation and are not actually llvm-objdump
options.  Reported in LLVM review https://reviews.llvm.org/D54864.

Reported by: Fangrui Song
Sponsored by: The FreeBSD Foundation

MFC r340975 (by emaste):

llvm-objdump.1: fix igor / mandoc -Tlint warnings

Accidentally omitted from r340972.

MFC r341055 (by emaste):

llvm-objdump.1: remove more unintentional options

Some options come from static constructors in LLVM libraries and are
automatically added to llvm's usage output.  They're not really supposed
to be llvm-objdump options.

Reported by: Fangrui Song in LLVM review D54864
Sponsored by: The FreeBSD Foundation

MFC r344779:

Upgrade our copies of clang, llvm, lld, lldb, compiler-rt and libc++ to
the upstream release_80 branch r355313 (effectively, 8.0.0 rc3).  The
release will follow very soon, but no more functional changes are
expected.

Release notes for llvm, clang and lld 8.0.0 will soon be available here:
<https://releases.llvm.org/8.0.0/docs/ReleaseNotes.html>
<https://releases.llvm.org/8.0.0/tools/clang/docs/ReleaseNotes.html>
<https://releases.llvm.org/8.0.0/tools/lld/docs/ReleaseNotes.html>

PR: 236062
Relnotes: yes

MFC r344798 (by emaste):

libllvm: promote WithColor and xxhash to SRCS_MIN

The armv6 build failed in CI due to missing symbols (from these two
source files) in the bootstrap Clang.

This affected only armv6 because other Clang-using archs are using LLD
as the bootstrap linker, and thus include SRCS_MIW via LLD_BOOTSTRAP.

Reported by: CI, via lwhsu
Sponsored by: The FreeBSD Foundation

MFC r344825:

Add a few missed files to the MK_LLVM_TARGET_BPF=yes case, otherwise
clang and various other executables will fail to link with undefined
symbols.

Reported by: O. Hartmann <ohartmann@walstatt.org>

MFC r344852:

Put in a temporary workaround for what is likely a gcc 6 bug (it does
not occur with gcc 7 or later).  This should prevent the following error
from breaking the head-amd64-gcc CI builds:

In file included from /workspace/src/contrib/llvm/tools/lldb/source/API/SBMemoryRegionInfo.cpp:14:0:
/workspace/src/contrib/llvm/tools/lldb/include/lldb/Target/MemoryRegionInfo.h:128:54: error: 'template<class _InputIterator> lldb_private::MemoryRegionInfos::MemoryRegionInfos(_InputIterator, _InputIterator, const allocator_type&)' inherited from 'std::__1::vector<lldb_private::MemoryRegionInfo>'
   using std::vector<lldb_private::MemoryRegionInfo>::vector;
                                                      ^~~~~~
/workspace/src/contrib/llvm/tools/lldb/include/lldb/Target/MemoryRegionInfo.h:128:54: error: conflicts with version inherited from 'std::__1::vector<lldb_private::MemoryRegionInfo>'

Reported by: CI

MFC r344896:

Pull in r354937 from upstream clang trunk (by Jörg Sonnenberger):

  Fix inline assembler constraint validation

  The current constraint logic is both too lax and too strict. It fails
  for input outside the [INT_MIN..INT_MAX] range, but it also
  implicitly accepts 0 as value when it should not. Adjust logic to
  handle both correctly.

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

Pull in r355491 from upstream clang trunk (by Hans Wennborg):

  Inline asm constraints: allow ICE-like pointers for the "n"
  constraint (PR40890)

  Apparently GCC allows this, and there's code relying on it (see bug).

  The idea is to allow expression that would have been allowed if they
  were cast to int. So I based the code on how such a cast would be
  done (the CK_PointerToIntegral case in
  IntExprEvaluator::VisitCastExpr()).

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

These should fix assertions and errors when using the inline assembly
"n" constraint in certain ways.

In case of devel/valgrind, a pointer was used as the input for the
constraint, which lead to "Assertion failed: (isInt() && "Invalid
accessor"), function getInt".

In case of math/secp256k1, a very large integer value was used as input
for the constraint, which lead to "error: value '4624529908474429119'
out of range for constraint 'n'".

PR:             236216, 236194

MFC r344951:

Merge llvm, clang, compiler-rt, libc++, lld, and lldb release_80 branch
r355677 (effectively, 8.0.0 rc4), resolve conflicts, and bump version
numbers.

PR: 236062

MFC r345018:

Merge LLVM libunwind trunk r351319, from just before upstream's
release_80 branch point.  Afterwards, we will merge the rest of the
changes in the actual release_80 branch.

PR: 236062

MFC r345019:

Merge LLVM libunwind release_80 branch r355677 (effectively, 8.0.0 rc4).

PR: 236062

MFC r345021:

Pull in r355854 from upstream llvm trunk (by Jonas Paulsson):

  [RegAlloc]  Avoid compile time regression with multiple copy hints.

  As a fix for https://bugs.llvm.org/show_bug.cgi?id=40986 ("excessive
  compile time building opencollada"), this patch makes sure that no
  phys reg is hinted more than once from getRegAllocationHints().

  This handles the case were many virtual registers are assigned to the
  same physreg. The previous compile time fix (r343686) in
  weightCalcHelper() only made sure that physical/virtual registers are
  passed no more than once to addRegAllocationHint().

  Review: Dimitry Andric, Quentin Colombet
  https://reviews.llvm.org/D59201

This should fix a hang when compiling certain generated .cpp files in
the graphics/opencollada port.

PR: 236313

MFC r345068 (by jhb):

Move libunwind out of contrib/llvm/projects.

Move LLVM's libunwind to its own contrib/ directory similar to other
runtime libraries like libc++ and libcxxrt.

Reviewed by: dim, emaste
Differential Revision: https://reviews.freebsd.org/D19534

MFC r345073:

Revert r308867 (which was originally committed in the clang390-import
project branch):

  Work around LLVM PR30879, which is about a bad interaction between
  X86 Call Frame Optimization on i386 and libunwind, by disallowing the
  optimization for i386-freebsd12.

  This should fix some instances of broken exception handling when
  frame pointers are omitted, in particular some unittests run during
  the build of editors/libreoffice.

  This hack will be removed as soon as upstream has implemented a more
  permanent fix for this problem.

And indeed, after r345018 and r345019, which updated LLVM libunwind to
the most recent version, the above workaround is no longer needed.  The
upstream commit which fixed this is:

  https://llvm.org/viewvc/llvm-project?view=revision&revision=292723

Specifically, 32 bit (i386-freebsd) executables optimized with omitted
frame pointers and Call Frame Optimization should now behave correctly
when a C++ exception is thrown, and the stack is unwound.

Upstream PR: https://llvm.org/bugs/show_bug.cgi?id=30879
PR: 236062

MFC r345152:

Merge llvm, clang, compiler-rt, libc++, libunwind, lld, and lldb
release_80 branch r356034 (effectively, 8.0.0 rc5), resolve conflicts,
and bump version numbers.

PR: 236062

MFC r345231:

Add LLVM openmp trunk r351319 (just before the release_80 branch point)
to contrib/llvm.  This is not yet connected to the build, the glue for
that will come in a follow-up commit.

PR: 236062

MFC r345232:

Bootstrap svn:mergeinfo on contrib/openmp.

PR: 236062

MFC r345233:

Merge openmp release_80 branch r356034 (effectively, 8.0.0 rc5).

PR: 236062

MFC r345234:

Add openmp __kmp_gettid() wrapper, using pthread_getthreadid_np(3).
This has also been submitted upstream.

PR:           236062

MFC r345283:

Enable building libomp.so for 32-bit x86.  This is done by selectively
enabling the functions that save and restore MXCSR, since access to this
register requires SSE support.

Note that you may run into other issues with OpenMP on i386, since this
*not* yet supported upstream, and certainly not extensively tested.

PR: 236062, 236582

MFC r345345:

Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
8.0.0 final release r356365.  There were no functional changes since the
most recent merge, of 8.0.0 rc5.

Release notes for llvm, clang, lld and libc++ 8.0.0 are now available:

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

PR: 236062

MFC r345349:

Pull in r352826 from upstream lld trunk (by Fangrui Song):

  [ELF] Support --{,no-}allow-shlib-undefined

  Summary:
  In ld.bfd/gold, --no-allow-shlib-undefined is the default when
  linking an executable. This patch implements a check to error on
  undefined symbols in a shared object, if all of its DT_NEEDED entries
  are seen.

  Our approach resembles the one used in gold, achieves a good balance
  to be useful but not too smart (ld.bfd traces all DSOs and emulates
  the behavior of a dynamic linker to catch more cases).

  The error is issued based on the symbol table, different from
  undefined reference errors issued for relocations. It is most
  effective when there are DSOs that were not linked with -z defs (e.g.
  when static sanitizers runtime is used).

  gold has a comment that some system libraries on GNU/Linux may have
  spurious undefined references and thus system libraries should be
  excluded (https://sourceware.org/bugzilla/show_bug.cgi?id=6811). The
  story may have changed now but we make --allow-shlib-undefined the
  default for now. Its interaction with -shared can be discussed in the
  future.

  Reviewers: ruiu, grimar, pcc, espindola

  Reviewed By: ruiu

  Subscribers: joerg, emaste, arichardson, llvm-commits

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

Pull in r352943 from upstream lld trunk (by Fangrui Song):

  [ELF] Default to --no-allow-shlib-undefined for executables

  Summary:
  This follows the ld.bfd/gold behavior.

  The error check is useful as it captures a common type of ld.so
  undefined symbol errors as link-time errors:

      // a.cc => a.so (not linked with -z defs)
      void f(); // f is undefined
      void g() { f(); }

      // b.cc => executable with a DT_NEEDED entry on a.so
      void g();
      int main() { g(); }

      // ld.so errors when g() is executed (lazy binding) or when the program is started (-z now)
      // symbol lookup error: ... undefined symbol: f

  Reviewers: ruiu, grimar, pcc, espindola

  Reviewed By: ruiu

  Subscribers: llvm-commits, emaste, arichardson

  Tags: #llvm

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

Together, these add support for --no-allow-shlib-undefined, and make it
the default for executables, so they will fail to link if any symbols
from needed shared libraries are undefined.

Reported by: jbeich
PR: 236062, 236141

MFC r345449:

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

  [ARM] Don't form "ands" when it isn't scheduled correctly.

  In r322972/r323136, the iteration here was changed to catch cases at
  the beginning of a basic block... but we accidentally deleted an
  important safety check.  Restore that check to the way it was.

  Fixes https://bugs.llvm.org/show_bug.cgi?id=41116

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

This should fix "Assertion failed: (LiveCPSR && "CPSR liveness tracking
is wrong!"), function UpdateCPSRUse" errors when building the devel/xwpe
port for armv7.

PR: 236062, 236568

5 years agoMFC r345703:
Konstantin Belousov [Fri, 12 Apr 2019 15:12:08 +0000 (15:12 +0000)]
MFC r345703:
Fix initial exec TLS mode for dynamically loaded shared objects.

5 years agoMFC r345955:
Konstantin Belousov [Fri, 12 Apr 2019 15:00:42 +0000 (15:00 +0000)]
MFC r345955:
vn_vmap_seekhole(): align running offset to the block boundary.

5 years agoMFC r345702,r345954:
Konstantin Belousov [Fri, 12 Apr 2019 14:59:28 +0000 (14:59 +0000)]
MFC r345702,r345954:
Eliminate adj_free field from vm_map_entry.

5 years agoMFC r345647:
Xin LI [Fri, 12 Apr 2019 02:24:06 +0000 (02:24 +0000)]
MFC r345647:

Distinguish between lseek errors and read errores.

5 years agoAdd support for loader veriexec
Simon J. Gerraty [Fri, 12 Apr 2019 01:03:00 +0000 (01:03 +0000)]
Add support for loader veriexec

Also sbin/veriexec for mac_veriexec

MFC r343281,344564-344568,344780,344784,345289,346070

5 years agoMFC r345693, 345694: rtld: attempt to fix reloc_nonplt_object TLS allocation
Ed Maste [Fri, 12 Apr 2019 00:31:22 +0000 (00:31 +0000)]
MFC r345693, 345694: rtld: attempt to fix reloc_nonplt_object TLS allocation

on arm and mips

allocate_tls_offset returns true on success.  This still needs more
testing and review, but this change is consistent with other archs.

PR: 236880
Reported by: Andrew Gierth <andrew@tao11.riddles.org.uk> (arm)
Sponsored by: The FreeBSD Foundation

5 years agoMFC r344936: MFV/ZoL: Disable LBA weighting on files and SSDs
Alexander Motin [Thu, 11 Apr 2019 13:20:48 +0000 (13:20 +0000)]
MFC r344936: MFV/ZoL: Disable LBA weighting on files and SSDs

The LBA weighting makes sense on rotational media where the outer tracks
have twice the bandwidth of the inner tracks. However, it is detrimental
on nonrotational media such as solid state disks, where the only effect
is to ensure that metaslabs enter the best-fit allocation behavior
sooner, which is detrimental to performance. It also makes no sense on
files where the underlying filesystem can arrange things however it
wants.

Author: Richard Yao <ryao@gentoo.org>
Signed-off-by: Richard Yao <ryao@gentoo.org>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #3712
zfsonlinux/zfs@fb40095f5f0853946f8150481ca22602d1334dfe

To reduce code divergence this merge replaces equivalent but different
FreeBSD code detecting non-rotating medium vdevs.

5 years agoMFC r344934, r345014: Add separate aggregation limit for non-rotating media.
Alexander Motin [Thu, 11 Apr 2019 13:19:26 +0000 (13:19 +0000)]
MFC r344934, r345014: Add separate aggregation limit for non-rotating media.

Before sequential scrub patches ZFS never aggregated I/Os above 128KB.
Sequential scrub bumped that to 1MB, which motivation I understand for
spinning disks, since it should reduce number of head seeks.  But for
SSDs it makes much less sense to me, especially on FreeBSD, where due
to MAXPHYS limitation device will likely still see bunch of 128KB I/Os
instead of one large.  Having more strict aggregation limit allows to
avoid allocation of large memory buffer and memcpy to/from it, that is
a serious problem when bandwidth reaches few GB/s.

Sponsored by: iXsystems, Inc.

5 years agoMFC r344926:
Alexander Motin [Thu, 11 Apr 2019 13:17:51 +0000 (13:17 +0000)]
MFC r344926:
MFV/ZoL: Fix zfs_vdev_aggregation_limit bounds checking

Update the bounds checking for zfs_vdev_aggregation_limit so that
it has a floor of zero and a maximum value of the supported block
size for the pool.

Additionally add an early return when zfs_vdev_aggregation_limit
equals zero to disable aggregation.  For very fast solid state or
memory devices it may be more expensive to perform the aggregation
than to issue the IO immediately.

Author: Brian Behlendorf <behlendorf1@llnl.gov>
zfsonlinux/zfs@a58df6f53687ac6d1dee21f60de41b2552a43201

MFV/ZoL: Cap maximum aggregate IO size

Commit 8542ef8 allowed optional IOs to be aggregated beyond
the specified aggregation limit.  Since the aggregation limit
was also used to enforce the maximum block size, setting
`zfs_vdev_aggregation_limit=16777216` could result in an
attempt to allocate an ABD larger than 16M.

Author: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed-by: George Melikov <mail@gmelikov.ru>
Reviewed-by: Giuseppe Di Natale <dinatale2@llnl.gov>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #6259
Closes #6270
zfsonlinux/zfs@2d678f779aba26a93314c8ee1142c3985fa25cb6

5 years agoMFC r345850: Fix typos in r345849.
Alexander Motin [Thu, 11 Apr 2019 13:12:25 +0000 (13:12 +0000)]
MFC r345850: Fix typos in r345849.

5 years agoMFC r345849: List few more ATA commands.
Alexander Motin [Thu, 11 Apr 2019 13:11:20 +0000 (13:11 +0000)]
MFC r345849: List few more ATA commands.

5 years agoMFC r345887:
Guangyuan Yang [Thu, 11 Apr 2019 00:41:07 +0000 (00:41 +0000)]
MFC r345887:

Rewrite intro(4) man page.

- Remove issues that no longer apply thanks to devfs
- Add language pointing out devfs's role and referencing its config
- Add a "historical notes" section and move discussion of block vs character devs to it, including pointing out the removal of block devs
- Modernize some examples

PR: 236970
Submitted by: andrew@tao173.riddles.org.uk
Reviewed by: 0mp
Differential Revision: https://reviews.freebsd.org/D19799

5 years agoMFC r345497:
Martin Matuska [Wed, 10 Apr 2019 21:45:23 +0000 (21:45 +0000)]
MFC r345497:
Sync libarchive with vendor.

Relevant vendor changes:
  PR #1153: fixed 2 bugs in ZIP reader [1]
  PR #1143: ensure archive_read_disk_entry_from_file() uses ARCHIVE_READ_DISK
  Changes to file flags code, support more file flags on FreeBSD:
    UF_OFFLINE, UF_READONLY, UF_SPARSE, UF_REPARSE, UF_SYSTEM
    UF_ARCHIVE is not supported by intention (yet)

PR: 236300 [1]

5 years agoMFC r345847:
Konstantin Belousov [Wed, 10 Apr 2019 08:34:17 +0000 (08:34 +0000)]
MFC r345847:
msdosfs: zero tail of the last block on truncation for VREG vnodes as well.

5 years agoMFC r344662:
Enji Cooper [Tue, 9 Apr 2019 16:35:23 +0000 (16:35 +0000)]
MFC r344662:

Remove references to pdwait4(2) and `CAP_PDWAIT` from rights(4)

@cem removed references to pdwait4(2) (a nonexistent syscall) in
r320058.

This change removes references to pdwait4(2) and `CAP_PDWAIT` in
rights(4) to not mislead the user into thinking that pdwait4(2)/`CAP_PDWAIT` is
actually implemented in the stock FreeBSD kernel.

The goal of this functionality was to simplify monitoring/manipulating
processes started with `pdfork`, et al, and avoid races with waiting on pids.
The syscall was never completed though--just discussed on the capsicum mailing
list back in 2015:
https://lists.cam.ac.uk/pipermail/cl-capsicum-discuss/2015-May/msg00012.html
. That being said, there are members of the project (@rwatson, etc) who
have longterm goals to implement this syscall to better secure pdfork(2)
calls.

PR: 235871
Approved by: emaste (mentor)
Differential Revision: https://reviews.freebsd.org/D19805