MFC r258039:
Avoid overflow for the page counts.

MFC r258365:
Revert back to use int for the page counts.
Rearrange the checks to correctly handle overflowing address arithmetic.
MFC r258088:
Add check for buflen overflow by comparing the buflen with both offset
and resid.

MFC r258397:
Redo r258088 to avoid relying on signed arithmetic overflow.
MFC r258311

  opensolaris/uts/common/dtrace/fasttrap.c
          Fix several problems that can cause panics on kldload and kldunload.

          * kproc_create(fasttrap_pid_cleanup_cb, ...) gets called before
            fasttrap_provs.fth_table gets allocated.  This can lead to a panic
            on module load, because fasttrap_pid_cleanup_cb references
            fasttrap_provs.fth_table.  Move kproc_create down after the point
            that fasttrap_provs.fth_table gets allocated, and modify the error
            handling accordingly.

          * dtrace_fasttrap_{fork,exec,exit} weren't getting NULLed until
            after fasttrap_provs.fth_table got freed.  That caused panics on
            module unload because fasttrap_exec_exit calls
            fasttrap_provider_retire, which references
            fasttrap_provs.fth_table.  NULL those function pointers earlier.

          * There wasn't any code to destroy the
            fasttrap_{tpoints,provs,procs}.fth_table mutexes on module unload,
            leading to a resource leak when WITNESS is enabled.  Destroy those
            mutexes during fasttrap_unload().

Sponsored by: Spectra Logic Corporation
MFC r254224, r254294, r254328, r258307, r258309, r258310, r258314,
    r258317, r258319, r258320, r258669, r258786, r258853, r258949,
    r259079, r259246:

r254224:
  Update the wrapper script to 'release.sh', as used by the
  FreeBSD Release Engineering Team as of 9.2-RELEASE.

  Document that a cross-build release is possible by setting
  the TARGET and TARGET_ARCH variables.

  Include an example of using release.sh with and without the
  optional configuration file.

  Document the supported release.sh configuration file variables.

  Update the 'cdrom' target output file to disc1.iso.

  Update the 'memstick' target output file to memstick.img.

  Add attributions for the last major updates to this manual page.

  Fix some mdoc(7) style nits.

r254294:
  Remove the defaults for TARGET/TARGET_ARCH.

  Note that WORLD_FLAGS and KERNEL_FLAGS set the number of
  make(1) jobs only on SMP-capable systems.

r254328:
  Remove the {SRC,DOC,PORT}REVISION variables from release(7), and
  update the default {SRC,DOC,PORT}BRANCH defaults.

r258307:
  Add a script and configuration files to fetch pre-built packages
  from pkg.FreeBSD.org for inclusion on release medium (dvd1.iso).

  The script sources ${.CURDIR}/${TARGET}/pkg-stage.conf, which sets
  several environment variables, such as the pkg(8) ABI, PACKAGESITE,
  PKG_DBDIR, and PKG_CACHEDIR.  PKG_CACHEDIR is set to the directory
  on the release medium used by bsdconfig(8) (/packages/${ABI}).  ABI
  is determined by output of 'make -C /usr/src/release -V REVISION'.
  See pkg.conf(5) for descripton on other variables set here.

  The list of packages to include are set within the configuration
  file.

  The script and configuration files are intended to be run by the
  'make dvd' target within the release directory, and assume the
  release is built within a chroot environment (such as by using
  release.sh).

r258309:
  Set the PKG_CACHEDIR directory to 'dvd/' instead of 'release/'
  in preparation of adding a 'dvd1.iso' target.

r258310:
  Add the 'dvd1.iso' target.  This mimics the 'release.iso' target,
  with the additional step of fetching packages for inclusion on the
  dvd image.

  The 'pkg-stage' target is used to run 'scripts/pkg-stage.sh' if
  the '${TARGET}/pkg-stage.conf' configuration file exists (currently
  only amd64 and i386).

  Allow dvd1.iso to be skipped if NODVD=1.

r258314:
  Fix how ABI is evaluated so it matches more than a dot-zero
  case.

r258317:
  Document the 'dvdrom' target.

r258319:
  Remove WITHOUT_PROFILE=1 for the dvd1.iso medium.

r258320:
  Simplify PKG_ABI for pkg-stage.sh.

r258669:
  Document the dvdrom target and NODVD variable.

r258786:
  Move OPTIONS_UNSET outside of the PBUILD_FLAGS variable, otherwise
  the textproc/docproj port build fails.

r258853:
  Turn off the dvdrom target by default.  dvd1.iso is now built by
  specifying 'WITH_DVD=1' during 'make release'.

r258949:
  Ensure WITH_DVD is not empty to prevent 'WITH_DVD= ' from evaluating
  to true.

r259079:
  Add WITH_DVD to RELEASE_RMAKEFLAGS, otherwise it is not actually
  passed to 'make release'.

r259246:
  Prevent release build errors found during snapshot builds where if
  NOPORTS=1, pkg-stage.sh cannot build the ports-mgmt/pkg port if
  WITH_DVD=1.

Tested against:	stable/9@r259512
Sponsored by:	The FreeBSD Foundation
MFC	r258731:

gcc: Make use of TREE_OVERFLOW_P.

While it was brought in r258179 only to fix a build issue,
bringing the rest of the change has the advantage of fixing
GCC/19978.

Obtained from:	gcc 4.3 (rev. 120505; GPLv2)
MFC r258363:

Add alternate ID for Novatel MiFi 2200 CDMA, which is used by my
Virgin Mobile branded device.  It needs the U3GINIT_SCSIEJECT quirk.
Regenerate after
	r248085 (if_ipheth)
	r247474, r250288 (uftdi)
	r250842 (if_rum)
	r244956, r255345 (ng_ubt)
	r248085, r250847, r257042, r259457 (if_run)
	r245727, r250845, r253292, r259593 (u3g)
	r252444 (if_axe)
MFC r259023 and r259095:
Improve the XHCI command timeout recovery handling code.
Fix some typos while at it.
MFC r258629, 258662:

r258629:
  Mention that devd will kldload the driver when the device is connected.

  Mention that the automatic mode switch from umass to u3g needed by some
  devices does not work unless the driver is loaded before the device is
  connected.

r258662 (by joel):
  mdoc: sort sections.
MFC r259248 and r259462:
Set chain bit correctly. This will fix some problems sending and
receiving Zero Length Packets, ZLPs. See comment in code for more
information.
MFC r255194 and prerequisites r229494,229496:

  Introduce internal macros for __U/INT64_C to define the U/INT64_MAX/MIN
  values properly. The previous definition only worked if __STDC_LIMIT_MACROS
  and __STDC_CONSTANT_MACROS were defined at the same time.

  Newer versions of gcc define __INT64_C and __UINT64_C, so avoid
  redefining them if gcc provides them.

Applying r255194 fixes stable/9 host to allow source upgrading to the newer
versions with usr.bin/dtc included in bootstrap tools.

Approved by:	imp (MFC to stable/9)
Improve compatibility with earlier parts of the 9 branch by defaulting
to MK_CLANG_IS_CC is no when it isn't otherwise defined. Also,
bsd.compiler.mk wasn't present in 9.0, so don't require it. With these
changes, you can compile a tip of 9.x kernel and modules old-school on
a 9.0 system.

# Direct commit since this isn't relevant to 10 or current.
MFC of 259626, tzdata2013i:

Removed support for solar-time-based time zones
Jordan stays at summer time this year.
Fix historical data for Cuba
MFC r259498:

Pull in r197399 from upstream clang trunk:

  Add bit_FXSAVE as an alias for bit_FXSR, for gcc compat.
Honor WITHOUT_SYSINSTALL=1.

This is a direct commit to stable/9.

PR:		176263
Submitted by:	Sayetsky Anton  (vsjcfm gmail com)
Sponsored by:	The FreeBSD Foundation
MFC	r258017, r258429, r258748, r258817:

Merge updates from FSF pre4.3 GCC inspired on Apple's gcc:

  Updates to libiberty and mangling.
  New align attribute.
  Merge Apple updates to libstdc++.
MFC	r258651, r258943:
gcc: Altivec register adjustments from Apple.
gcc: On rs6000 update sp_offset depending only on size.

Tested by:		Justin Hibbits
Obtained from:		gcc pre-4.3 (rev. 124763, 125116; GPLv2)
MFC r259108:
When comparing device IDs, make sure that they have the same type
(like NAA assigned) and identify the same entity (like device or port).
Otherwise there can be false positives since at least some models of
Seagate disks use same IDs for the whole device and one of its ports.
Direct Commit of mountroot> prompt fix r259748 (since there's no sane
branching relationship between that branch and this one and since the
more general fix in head may be too risky for a stbale branch this
mature):

 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.
MFC r256060,r256650: kldxref: Do not depend on the directory order.

Sort the filenames to get a consistent result between machines of the same
architecture.

Also, sort FTS_D entries after other entries so kldxref -R works properly in
the uncommon case that a directory contains both subdirectories and modules.
Previously, this may have happened to work, depending on the order of files
in the directory.

PR:		bin/182098
Submitted by:	Derek Schrock (original version)
Tested by:	Derek Schrock