msdosfs: Assorted fixes from other BSDs.

When truncating cluster chains fix the length of the cluster head.
http://marc.info/?t=140304310700005&r=1&w=2

Avoid infinite loops in cluster chain linked lists.
http://marc.info/?l=openbsd-tech&m=140275150804337&w=2

Avoid off-by-one on FAT12 filesystems.
http://marc.info/?l=openbsd-tech&m=140234174104724&w=2

Obtained from:	NetBSD (from OpenBSD)
MFC after:	1 week
Fix the Zedboard/Zynq ethernet driver to handle media speed changes so
that it can connect to switches at speeds other than 1gb.

This requires changing the reference clock speed.  Since we still don't
have a general clock API that lets a SoC-independant driver manipulate its
own clocks, this change includes a weak reference to a routine named
cgem_set_ref_clk().  The default implementation is a no-op; SoC-specific
code can provide an implementation that actually changes the speed.

Submitted by:	Thomas Skibo <ThomasSkibo@sbcglobal.net>
Manage struct sigacts refcnt with atomics instead of a mutex.

MFC after:	1 week
newfs_msdosfs: Respect FSFIXFAT

Fix some whitespace issues while here.

Obtained from:	NetBSD (rev. 1.9)
MFC after:	3 days
Plug p_pptr null test in do_execve. It is always true.
fortune(8): Search fortune files installed by ports/packages as well as
those supplied by the base system.

PR:		191800
Submitted by:	Andy Kosela
MFC after:	1 week
Add a call to synthesize a C/H/S value for block emulations
that require it (ahci). The algorithm used is from the VHD
specification.
Use the blockif CHS routine to create fake CHS values,
and then populate them in the identity page.

This fixes a divide-by-zero error at probe time with NetBSD.

MFC after:	1 week.
Allow multi-byte reads in the private CHELSIO_T4_GET_I2C ioctl.  The
firmware allows up to 48B to be read this way but the driver limits
itself to 8B at a time to remain compatible with old cxgbetool
binaries.

MFC after:	1 week
Fix an issue with service(8) where utilities such as screen(1) and tmux(1)
would behave differently when utilizing rc-script was invoked manually vs.
service(8). The issue being that these utilities require the TERM environ
variable to be set and service(8) was not passing it down.

Reported by:	Michael Dexter <editor@callfortesting.org>
PR:		bin/191869
Reviewed by:	allanjude
MFC after:	3 days
X-MFC-to:	stable/10, stable/9
libc/gen: small updates to code originating at OpenBSD

arc4random.c
- CVS rev. 1.22
Change arc4random_uniform() to calculate ``2**32 % upper_bound'' as
``-upper_bound % upper_bound''. Simplifies the code and makes it the
same on both ILP32 and LP64 architectures, and also slightly faster on
LP64 architectures by using a 32-bit remainder instead of a 64-bit
remainder.
- CVS rev. 1.23
Spacing

readpassphrase.c
-CVS rev. v 1.24
most obvious unsigned char casts for ctype

Obtained from:	OpenBSD
MFC after:	5 days
Document that listen(2) can fail with EDESTADDRREQ.
libc/stdlib: Minor cleanups to code originating in NetBSD

Mostly ANSIfication and typos.

Obtained from:	NetBSD
MFC after:	5 days
Add image_data() for checking whether a sequence of blocks has data.
Use this for VHD and VMDK to avoid allocating space in the image
for empty sectors.

Note that this negatively affects performance because mkimg uses a
temporary file for the intermediate storage. When mkimg has better
internal book keeping, performance can be significantly improved.
Eliminate repeated calculation of next_bucket in pmap_protect() and
pmap_remove().  Eliminate an unnecessary variable from pmap_remove() and
pmap_advise().
Make amd64 pmap_copy_pages() functional for pages not mapped by DMAP.

Requested and reviewed by:	royger
Tested by:	pho, royger
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Add a comment to explain the EAGAIN is only there for POSIX compliance

Resquested by:	kib
Reviewed by:	des
Fix build with SMP disabled.

CR:		https://phabric.freebsd.org/D407
Reviewed by:	royger
Actually set the "no execute" bit on 1 MB page mappings in pmap_protect().
Previously, the "no execute" bit was being set directly in the PTE, instead
of the local variable in which the new PTE value is being constructed.  So,
when the local variable was finally assigned to the PTE, the "no execute"
bit setting was lost.
Add support for operand size and address size override prefixes in bhyve's
instruction emulation [1].

Fix bug in emulation of opcode 0x8A where the destination is a legacy high
byte register and the guest vcpu is in 32-bit mode. Prior to this change
instead of modifying %ah, %bh, %ch or %dh the emulation would end up
modifying %spl, %bpl, %sil or %dil instead.

Add support for moffsets by treating it as a 2, 4 or 8 byte immediate value
during instruction decoding.

Fix bug in verify_gla() where the linear address computed after decoding
the instruction was not being truncated to the effective address size [2].

Tested by:	Leon Dang [1]
Reported by:	Peter Grehan [2]
Sponsored by:	Nahanni Systems