MFStable-10 r259301

  MFC r256657,r257018,r257347,r257423,r257729,r257767,
      r257933,r258609,r258614,r258668,r258673,r258855

  Pull in some minor bugfixes and functionality enhancements
  from CURRENT. These are candidates to be moved to 10.0-release.

  r258855
  mdoc: quote string properly.

  r258673
  Don't create an initial value for the host filesystem of "/".

  r258668
  Allow bhyve and bhyveload to attach to tty devices.

  r258614
  The 22-bit Data Byte Count (DBC) field of a Physical Region Descriptor was
  being read as a 32-bit quantity by the bhyve AHCI driver.

  r258609
  Fix discrepancy between the IOAPIC ID advertised by firmware tables and the
  actual value read by the guest.

  r257933
  Route the legacy timer interrupt (IRQ0) to pin 2 of the IOAPIC.

  r257767
  Fix an off-by-one error when iterating over the emulated PCI BARs.

  r257729
  Add the VM name to the process name with setproctitle().

  r257423
  Make the virtual ioapic available unconditionally in a bhyve virtual machine.

  r257347
  Update copyright to include the author of the LPC bridge emulation code.

  hand-merge r257018
  Tidy usage messages for bhyve and bhyveload.

  r256657
  Add an option to bhyveload(8) that allows setting a loader environment variable
  from the command line.

Approved by:	re@ (gjb)
MF10 259465:
Add new sysctl, kern.supported_archs, containing the list of FreeBSD
MACHINE_ARCH values whose binaries this kernel can run. This patch provides
a feature requested for implementing pkgng ABI identifiers in a robust
way.

The list is designed to indicate whether, say, an i386 package can be run on
the current system. If kern.supported_abis contains "i386", then the answer
is yes. Otherwise, the answer is no.

At the moment, this only supports MACHINE_ARCH and MACHINE_ARCH32. As we
gain support for more interesting combinations, this needs to become more
flexible, possibily through the sysent framework, along with the
hw.machine_arch emulation immediately preceding this code in kern_mib.c.

Reviewed by:	imp
Approved by:	re (glebius)
MFC r259426, r259427:

r259426:
  Add a pkg(8) repository configuration file for cdrom-based package
  installation.

  As part of the 'pkg-stage' target, copy the configuration file
  to the 'packages/repos/' directory on the DVD filesystem.

r259427:
  Export 'REPOS_DIR' when the selected source medium for package
  installation is cdrom.  This enables bsdconfig(8) to make use
  of the on-disc pkg(8) repository configuration, which fixes
  package selection and installation from the dvd installer.

Approved by:	re (delphij, glebius)
Sponsored by:	The FreeBSD Foundation
Set PACKAGESITE to 'release/0' for the pkg-stage target to pull
the release set of packages.

This is a direct commit to releng/10.0/.

Approved by:	re (rodrigc)
Sponsored by:	The FreeBSD Foundation
MFS r259613:

  Fix multi-repository support by properly respecting 'enabled' flag.

  This will read the REPOS_DIR env/config setting (default is /etc/pkg
  and /usr/local/etc/pkg/repos) and use the last enabled repository.

  This can be changed in the environment using a comma-separated list,
  or in /usr/local/etc/pkg.conf with JSON array syntax of:
      REPOS_DIR: ["/etc/pkg", "/usr/local/etc/pkg/repos"]

Approved by:	bapt (mentor)
Approved by:	re (gjb)
Defer start/stop port to workqueues.
MF10: r259608

Approved by:	re
Merge r259622:
cxgbe.4: Belated update to the man page to reflect T5 support.

Approved by:	re (gjb)
Merge r259541 from stable/10:

  Merge r256868,257276-257277,257515,257913 from head. These are fixes
  required to make Xen buildable w/o INET.

Approved by:	re (delphij)
MFStable r259536
  MFC r259302,r259413

  r259302
    bhyve(8) man page

  r259413
    mdoc: sort SEE ALSO

Approved by:	re@ (glebius)
MFS10 SVN r259621:

MFC r259276,259468-259470,259472,259474,259476-259478,259480-259481,259570,
259572, and 259597-259598...

r259276: Fix bug in `services' script in adding dumpdev comment to rc.conf
r259468: Ignore spurious escape generated by VMware's Ctrl-Cmd combination
r259469: Mask errors in `config' script from newaliases(1) about non-FQHN
r259470: Set atime=on for /var/mail zfsboot dataset to support mail server
r259472: Accept NULL input for zfsboot SWAP to indicate SWAP of zero bytes
r259474: Multiple changes, including bug-fixes and debugging improvements
r259476: Change default ZFS disk layout, making it easier to resize
r259477: fletcher4 is now the default (zfsboot related)
r259478: De-uglify the geli(8)-setup infobox (zfsboot related)
r259480: Fix ghosted zroot issue by always performing labelclear on swap
r259481: Auto-enable 4k sector alignmet when geli(8) is enabled (zfsboot)
r259570: Fix numerical comparison error (zfsboot)
r259572: Mask spurious rm error in bsdinstall_log from `auto' script
r259597: Fix zfsboot regression when installing to 3+ disks
r259598: Set cachefile property of bootpool so it imports to new system

Approved by:    re (gjb)
MFC r259734:

MFV r258923: 4188 assertion failed in dmu_tx_hold_free(): dn_datablkshift != 0

illumos/illumos-gate@bb411a08b05466bfe0c7095b6373bbc1587e259a

Approved by:	re (gjb)
Merge from stable/10 r259380:

MFC r259038, r259039:

 Bump the maximum VM space from 3 * memory size to a fixed
 256MB. That's all we have room for since we map the hardware registers
 starting at 0xd0000000. This allows my 64MB AT91SAM9G20 to boot again
 after the unmmaped I/O changes were MFC'd at r251897. Other
 subplatforms may need similar treatment.

 Although not strictly required to boot a 64MB board, bump
 vm_max_virtual_address to be KERNVIRTADDR + 256MB. This allows some
 future shock protection since the KVA requirements have gone up since
 the unmapped changes have gone in, as well as preventing us from
 overlapping with the hardware devices, which we map at 0xd0000000,
 which we'd hit with anything more than 85MB...

Approved by:	re@ (gjb@)
Merge from stable/10 r259381:

MFC r259212, r259220:

 Fix one race and one fence post error. When the TX buffer was
 completely full, we'd not complete any of the mbufs due to the fence
 post error (this creates a large leak). When this is fixed, we still
 leak, but at a much smaller rate due to a race between ateintr and
 atestart_locked as well as an asymmetry where atestart_locked is
 called from elsewhere.  Ensure that we free in-flight packets that
 have completed there as well. Also remove needless check for NULL on
 mb, checked earlier in the loop and simplify a redundant if.

Approved by:	re@ (gjb@)
Direct commit: not relevant to other branches.

Fix mountroot> prompt eating most of the characters by not enabling
RXRDY interrupts in the attach routine. Instead, defer this until the
first interrupt we see after the device is opened. Given the console
use case, we're guaranteed to get a TXRDY interrupt before any reads
are posted due to boot messages, which makes this work.

The real fix is to use cngrab/cnungrab function pointers to disable
RXRDY interrupts while grabbed. However, that touches the MI uart
code, so was disallowed for 10.0 due to the lateness of the hour this
fix was proposed. It works for mountroot, the most common atmel kernel
prompt use cases, but wouldn't work for GELI since it prompts later in
the boot process.

Approved by:	re@ (gjb@)
Merge from stable/10, r259741:

vga_pci: Improve boot display detection

The previous code was checking the "VGA Enable" bit on the video card's
parent PCI-to-PCI bridge only. This didn't work for the case where the
video card is attached to the root PCI bus (ie. the card has no parent
PCI-to-PCI bridge).

Now, the new code:
    1. checks the "VGA Enable" bit on the parent bridge only if it's a
       PCI-to-PCI bridge;
    2. always checks the "I/O" and "Memory address space decoding" bits
       on the video card itself.

However, vendor-specific bits are not used.

This fixes the use of many integrated Radeon cards: without this patch,
we fail to detect them as the boot display and, when radeonkms looks for
the Video BIOS, it skips the shadow copy made by the System BIOS. It
then fails to fully initialize the card, because the shadow copy is the
only way to read the Video BIOS in these situations. A workaround was to
force the boot display selection using the "hw.pci.default_vgapci_unit"
tunable.

A previous version of this patch added a new function doing the checks.
Now, the vga_pci_is_boot_display() function is used to perform the
checks (only until the boot display is found) and return if the given
device is the boot display or not.

Furthermore, vga_pci_attach() logs "Boot video device" if the card being
attached it the Chosen One:
    vgapci0: <VGA-compatible display> [...]
    vgapci0: Boot video device

Reviewed by:	kib@, jhb@ (both a previous version)
Tested by:	lunatic_ (#freebsd-xorg, integrated Radeon card,
		xmj (#freebsd-xorg, i915+NVIDIA cards)
Approved by:	re (gjb)
Merge from stable/10, r259742:

drm/ttm, drm/radeon: Replace EINTR/ERESTART by ERESTARTSYS...

... for msleep/cv_*wait() return values, where wait_event*() is used
on Linux. ERESTARTSYS is the return code expected by callers when the
operation was interrupted.

For instance, this is the case of radeon_cs_ioctl() (radeon_cs.c): if
an error occurs, and the code isn't ERESTARTSYS (eg. EINTR), it logs an
error.

Note that ERESTARTSYS is defined as ERESTART, but this keeps callers'
code close to Linux.

Submitted by:	avg@ (previous version)
Approved by:	re (gjb)
Merge from stable/10, r259745:

drm: Lower priority of "EDID checksum is invalid" message

The priority goes from "error" to "debug".

Connectors are polled every 10 seconds. Reading EDID is part of this
polling. However, when an invalid EDID is returned, this error message
is logged. When using Newcons for instance, having a kernel message
every 10 seconds is getting annoying.

Now that it's a debug message, it'll be logged only if hw.dri.debug is
enabled. This fix console spamming for some users.

Tested by:	Larry Rosenman <ler@lerctr.org>
Approved by:	re (gjb)
Revert one line from r248885, which uncovered several bugs in processing
interaction between ksocket_incoming2() and soreceive().

This is direct commit to releng/10.0. A conservative solution for releng
branch. Proper fix in head is r259681.

PR:		184601
Sponsored by:	Nginx, Inc.
Approved by:	re (gjb)
MFS r249447:
  Apply patch from upstream Heimdal for encoding fix

  RFC 4402 specifies the implementation of the gss_pseudo_random()
  function for the krb5 mechanism (and the C bindings therein).
  The implementation uses a PRF+ function that concatenates the output
  of individual krb5 pseudo-random operations produced with a counter
  and seed.  The original implementation of this function in Heimdal
  incorrectly encoded the counter as a little-endian integer, but the
  RFC specifies the counter encoding as big-endian.  The implementation
  initializes the counter to zero, so the first block of output (16 octets,
  for the modern AES enctypes 17 and 18) is unchanged.  (RFC 4402 specifies
  that the counter should begin at 1, but both existing implementations
  begin with zero and it looks like the standard will be re-issued, with
  test vectors, to begin at zero.)

  This is upstream's commit f85652af868e64811f2b32b815d4198e7f9017f6,
  from 13 October, 2013:
  % Fix krb5's gss_pseudo_random() (n is big-endian)
  %
  % The first enctype RFC3961 prf output length's bytes are correct because
  % the little- and big-endian representations of unsigned zero are the
  % same.  The second block of output was wrong because the counter was not
  % being encoded as big-endian.
  %
  % This change could break applications.  But those applications would not
  % have been interoperating with other implementations anyways (in
  % particular: MIT's).

Approved by:	re (gjb)
Update releng/10.0 to -RC3 as part of the 10.0-RELEASE cycle.

Approved by:	re (implicit)
Sponsored by:	The FreeBSD Foundation