MFC r252894:
Add SDT_PROBE_DEFINE0 for consistency with SDT_PROBE0.

MFC r253022:
Also define SDT_PROBE_DEFINE0 for the !KDTRACE_HOOKS case.

MFC r254266:
Add event handlers for module load and unload events. The load handlers are
called after the module has been loaded, and the unload handlers are called
before the module is unloaded. Moreover, the module unload handlers may
return an error to prevent the unload from proceeding.

MFC r254267:
Remove some unused fields from struct linker_file. They were added in
r172862 for use by the DTrace SDT framework but don't seem to have ever
been used.

MFC r254268:
FreeBSD's DTrace implementation has a few problems with respect to handling
probes declared in a kernel module when that module is unloaded. In
particular,

* Unloading a module with active SDT probes will cause a panic. [1]
* A module's (FBT/SDT) probes aren't destroyed when the module is unloaded;
  trying to use them after the fact will generally cause a panic.

This change fixes both problems by porting the DTrace module load/unload
handlers from illumos and registering them with the corresponding
EVENTHANDLER(9) handlers. This allows the DTrace framework to destroy all
probes defined in a module when that module is unloaded, and to prevent a
module unload from proceeding if some of its probes are active. The latter
problem has already been fixed for FBT probes by checking lf->nenabled in
kern_kldunload(), but moving the check into the DTrace framework generalizes
it to all kernel providers and also fixes a race in the current
implementation (since a probe may be activated between the check and the
call to linker_file_unload()).

Additionally, the SDT implementation has been reworked to define SDT
providers/probes/argtypes in linker sets rather than using SYSINIT/SYSUNINIT
to create and destroy SDT probes when a module is loaded or unloaded. This
simplifies things quite a bit since it means that pretty much all of the SDT
code can live in sdt.ko, and since it becomes easier to integrate SDT with
the DTrace framework. Furthermore, this allows FreeBSD to be quite flexible
in that SDT providers spanning multiple modules can be created on the fly
when a module is loaded; at the moment it looks like illumos' SDT
implementation requires all SDT probes to be statically defined in a single
kernel table.

MFC r254309:
Use kld_{load,unload} instead of mod_{load,unload} for the linker file load
and unload event handlers added in r254266.

MFC r254350:
Specify SDT probe argument types in the probe definition itself rather than
using SDT_PROBE_ARGTYPE(). This will make it easy to extend the SDT(9) API
to allow probes with dynamically-translated types.
MFC: r255216
Crashes have been observed for NFSv4.1 mounts when the system
is being shut down which were caused by the nfscbd_pool being
destroyed before the backchannel is disabled. This patch is
believed to fix the problem, by simply avoiding ever destroying
the nfscbd_pool. Since the NFS client module cannot be unloaded,
this should not cause a memory leak.
MFC: r255284
It was reported via email that the cu_sent field used by the
krpc client side UDP was observed as way out of range and
caused the rpc.lockd daemon to hang trying to do an RPC.
Inspection of the code found two places where the RPC request
is re-queued, but the value of cu_sent was not incremented.
Since cu_sent is always decremented when the RPC request is
dequeued, I think this could have caused cu_sent to go out of
range. This patch adds lines to increment cu_sent for these
two cases.
MFC: r255333
Intermittent crashes in the NLM (rpc.lockd) code during system
shutdown was reporetd via email. The crashes occurred because the
client side NLM would attempt to use its socket after it had been
destroyed. Looking at the code, it would soclose() once the reference
count on the socket handling structure went to 0. Unfortunately,
nlm_host_get_rpc() will simply allocate a new socket handling structure
when none exists and use the now soclose()d socket. Since there doesn't
seem to be a safe way to determine when the socket is no longer needed,
this patch modifies the code so that it never soclose()es the socket.
Since there is only one socket ever created, this does not introduce a
leak when the rpc.lockd is stopped/restarted. The patch also disables
unloading of the nfslockd module, since it is not safe to do so (and
has never been safe to do so, from what I can see).
MFC r255174:
Add missing opt_* header dependencies.
MFC r255607:
In pmap_copy(), when the copied region is mapped with superpage but does
not cover entire superpage, avoid copying.

MFC r255620:
Merge the change r255607 from amd64 to i386.
MFC r255501

This is slightly modified from the FreeBSD/head version, to include
version checks for the scanning changes for not only FreeBSD/head
(1000039 and higher) but also stable/9 (902502 and higher).

  ------------------------------------------------------------------------
  r255501 | ken | 2013-09-12 16:06:12 -0600 (Thu, 12 Sep 2013) | 18 lines

  Fix an issue that caused Integrated RAID volumes on LSI mps(4) controllers
  to not get scanned on boot.

  The problem originated in change 253549.  With the change to the mps(4)
  driver to scan only targets that it knows it has (as opposed to scanning
  the entire bus), scanning RAID volumes on boot was omitted.

  So, for versions of FreeBSD that have the scanning changes
  (__FreeBSD_version 1000039 and higher), scan RAID volumes that are added
  whether or not we're booting.

  PR:             kern/181784
  Reported by:    Xiguang Wang <kurapica@gmail.com>
  Tested by:      Dennis Glatting <dg@pki2.com>
  Sponsored by:   Spectra Logic

PR:		kern/181784
MFC r254135:

Don't dereference null pointer should acl_alloc() be passed M_NOWAIT
and allocation failed.  Nothing in the tree passed M_NOWAIT.
MFC r254215:

In su(1), fix option ordering and clarify that the login class specified
must be defined in login.conf.
MFC r250706: A library function shall not set errno to 0.
MFC 240424,244582:
Improve check coverage about idle threads.

Idle threads are not allowed to acquire any lock but spinlocks.
Deny any attempt to do so by panicing at the locking operation
when INVARIANTS is on. Then, remove the check on blocking on a
turnstile.
The check in sleepqueues is left because they are not allowed to use
tsleep() either which could happen still.

On entering KDB backends, the hijacked thread to run
interrupt context can still be idlethread. At that point, without the
panic condition, it can still happen that idlethread then will try to
acquire some locks to carry on some operations.

Skip the idlethread check on block/sleep lock operations when KDB is
active.
MFC: r254005

- Fix a bug in the MSI allocation logic so an MSI is also employed if a
  controller supports only a single message. I haven't seen such an adapter
  out in the wild, though, so this change likely is a NOP.
  While at it, further simplify the MSI allocation logic; there's no need
  to check the number of available messages on our own as pci_alloc_msi(9)
  will just fail if it can't provide us with the single message we want.
- Nuke the unused softc of aacch(4).
MFC r255273,255282:

Align stacks of kernel threads correctly at 16-byte boundaries rather than
making sure they are all misaligned at +8 bytes. This fixes clang builds
of powerpc64 kernels (aside from a required increase in KSTACK_PAGES which
will come later).
release/9.2.0 has been created; call stable/9 'STABLE' again.
Update for when we hope to have 9.2-RELEASE ready.
MFC 249028:

The CTL block backend is broken without this.

  Fix sending virtual scatter/gather lists from the CTL CAM frontend
  peripheral.

  Sponsored by:	Spectra Logic
MFC r255844:
Ensure that the ERESTART return from the syscall reloads the registers,
to make the restarted syscall instruction pass the correct arguments.

PR:	kern/182161
MFC 244015:
  ------------------------------------------------------------------------
  r244015 | ken | 2012-12-07 21:16:07 -0700 (Fri, 07 Dec 2012) | 17 lines

  Fix the CTL OOA queue dumping code so that it does not hold a mutex
  while doing a copyout.  That can cause a panic, because copyout
  can trigger VM faults, and we can't handle VM faults while holding
  a mutex.

  The solution here is to malloc a separate buffer to hold the OOA
  queue entries, so that we don't risk a VM fault while filling up
  the buffer and we don't have to drop the lock.  The other solution
  would be to wire the user's memory while filling their buffer with
  copyout, but that would have been a little more complex.

  Also fix a debugging parenthesis issue in ctl_abort_task() pointed
  out by Chuck Tuffli.

  Sponsored by:   Spectra Logic Corporation
MFC r255566:
If the last page of the file is partially full and whole valid
portion is invalidated, invalidate the whole page.
MFC r255891:

Import NetBSD readline.c,v 1.104: do not crash with add_history(NULL).