Initialize the num variable to avoid uninitialized data.
This fixes the bug introduced by r238378.

Reviewed by:	pfg


git-svn-id: svn://svn.freebsd.org/base/head@240982 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Implementing pmap_kextract(va) as pmap_extract(kernel_pmap, va) is
problematic because some callers to pmap_kextract() expect its
implementation to be lock-less.  In particular, uma_dbg_alloc() implicitly
requires this.  Otherwise, lock-order reversals occur between pmap locks and
UMA zone locks.  So, this change introduces a lock-less implementation of
pmap_kextract().

Disable recursion on the pvh global lock in the new armv6 pmap.  While
recursion on this locks occurs in the old arm pmap, it thankfully doesn't
occur in the armv6 pmap.

Tested by:	jmg


git-svn-id: svn://svn.freebsd.org/base/head@240983 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Track the last ANI TX/RX sample correctly.

This doesn't specifically fix the issue(s) i'm seeing in this 2GHz
environment (where setting/increasing spur immunity causes OFDM restart
errors to skyrocket through the roof; but leaving it at 0 would leave
the environment cleaner..)

Pointy-hat-to:	me, for committing this broken code in the first place.


git-svn-id: svn://svn.freebsd.org/base/head@240984 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Fix bug in TCP_KEEPCNT setting, which slipped in in the last round
of reviewing of r231025.

Unlike other options from this family TCP_KEEPCNT doesn't specify
time interval, but a count, thus parameter supplied doesn't need
to be multiplied by hz.

Reported & tested by:	amdmi3


git-svn-id: svn://svn.freebsd.org/base/head@240985 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Fix several build failures for !COMPAT_FREEBSD32 and
!COMPAT_FREEBSD* kernels introduced by r240981.

Pointy hat to:	sobomax


git-svn-id: svn://svn.freebsd.org/base/head@240990 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Fix zillions of style(9) and spacing bugs introduced by r240981.

Pointy hat to:	sobomax


git-svn-id: svn://svn.freebsd.org/base/head@240992 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Remove useless NULL checks after M_WAITOK allocations.


git-svn-id: svn://svn.freebsd.org/base/head@240993 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Kernel and modules have "set_vnet" linker set, where virtualized
global variables are placed. When a module is loaded by link_elf
linker its variables from "set_vnet" linker set are copied to the
kernel "set_vnet" ("modspace") and all references to these variables
inside the module are relocated accordingly.

The issue is when a module is loaded that has references to global
variables from another, previously loaded module: these references are
not relocated so an invalid address is used when the module tries to
access the variable. The example is V_layer3_chain, defined in ipfw
module and accessed from ipfw_nat.

The same issue is with DPCPU variables, which use "set_pcpu" linker
set.

Fix this making the link_elf linker on a module load recognize
"external" DPCPU/VNET variables defined in the previously loaded
modules and relocate them accordingly. For this set_pcpu_list and
set_vnet_list are used, where the addresses of modules' "set_pcpu" and
"set_vnet" linker sets are stored.

Note, archs that use link_elf_obj (amd64) were not affected by this
issue.

Reviewed by:	jhb, julian, zec (initial version)
MFC after:	1 month


git-svn-id: svn://svn.freebsd.org/base/head@240997 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Make sure we record NAK tokens in the TD structure for IN direction.
Improve host channel disabling. Wait two times 125us for channel to be
disabled. The DWC OTG doesn't like when channels are re-used too early.


git-svn-id: svn://svn.freebsd.org/base/head@240998 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Make sure the "wMaxPacketSize" limitations are respected.


git-svn-id: svn://svn.freebsd.org/base/head@240999 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Revert r240931, as the previous comment was actually in sync with POSIX.

I have to note that POSIX is simply stupid in how it describes O_EXEC/fexecve
and friends. Yes, not only inconsistent, but stupid.

In the open(2) description, O_RDONLY flag is described as:

	O_RDONLY	Open for reading only.

Taken from:

	http://pubs.opengroup.org/onlinepubs/9699919799/functions/open.html

Note "for reading only". Not "for reading or executing"!

In the fexecve(2) description you can find:

	The fexecve() function shall fail if:

	[EBADF]
		The fd argument is not a valid file descriptor open for executing.

Taken from:

	http://pubs.opengroup.org/onlinepubs/9699919799/functions/exec.html

As you can see the function shall fail if the file was not open with O_EXEC!

And yet, if you look closer you can find this mess in the exec.html:

	Since execute permission is checked by fexecve(), the file description
	fd need not have been opened with the O_EXEC flag.

Yes, O_EXEC flag doesn't have to be specified after all. You can open a file
with O_RDONLY and you still be able to fexecve(2) it.


git-svn-id: svn://svn.freebsd.org/base/head@241000 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
sigaction(2),sigwait(2),sigwaitinfo(2): Remove [EFAULT] error condition.

Passing an invalid pointer results in undefined behaviour.

The wrappers in libthr access some of the data pointed to by the arguments
in userland, so that an invalid pointer will cause a signal and not an
[EFAULT] error return.

Furthermore, if the [EFAULT] error occurs when the kernel is writing, it is
not a proper error in the sense that the call still commits (changing the
signal disposition or accepting the signal).

MFC after:	1 week


git-svn-id: svn://svn.freebsd.org/base/head@241001 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Fix pseudo checksum calculation.

This fixes ipfilter w/ network controllers that implement only
partial rx csum offloading.

PR:			106438
Obtained from:		upstream
MFC after:		1 week


git-svn-id: svn://svn.freebsd.org/base/head@241002 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Complete revert of r239963:

The attempt to merge changes from the linux libtirpc caused
rpc.lockd to exit after startup under unclear conditions.

After many hours of selective experiments and inconsistent results
the conclusion is that it's better to just revert everything and
restart in a future time with a much smaller subset of the
changes.
____

MFC after:	3 days
Reported by:	David Wolfskill
Tested by:	David Wolfskill


git-svn-id: svn://svn.freebsd.org/base/head@241007 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Complete revert of r239963:

The attempt to merge changes from the linux libtirpc caused
rpc.lockd to exit after startup under unclear conditions.

After many hours of selective experiments and inconsistent results
the conclusion is that it's better to just revert everything and
restart in a future time with a much smaller subset of the
changes.
____

MFC after:	3 days
Reported by:	David Wolfskill
Tested by:	David Wolfskill


git-svn-id: svn://svn.freebsd.org/base/head@241008 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Ensure that all cases that enqueue a netgraph item for delivery by a
ngthread properly set the item's depth to 1.  In particular, prior to this
change if ng_snd_item failed to acquire a lock on a node, the item's depth
would not be set at all.  This fix ensures that the error code from rcvmsg/
rcvdata is properly passed back to the apply callback.  For example, this
fixes a bug where an error from rcvmsg/rcvdata would not previously
propagate back to a libnetgraph consumer when the message was queued.

Reviewed by:	mav
MFC after:	1 month
Sponsored by:	Sandvine Incorporated


git-svn-id: svn://svn.freebsd.org/base/head@241009 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
libc/fts: Use O_CLOEXEC for internal file descriptors.

Because fts keeps internal file descriptors open across calls, making such
descriptors close-on-exec helps not only multi-threaded applications but
also single-threaded applications.

In particular, this prevents passing a temporary file descriptor for saving
the current directory to processes created via find -exec.


git-svn-id: svn://svn.freebsd.org/base/head@241010 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Fix up kernel sources to be ready for a 64-bit ino_t.

Original code by:	Gleb Kurtsou


git-svn-id: svn://svn.freebsd.org/base/head@241011 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Fix fsck_ffs build with a 64-bit ino_t.

Original code by:	Gleb Kurtsou


git-svn-id: svn://svn.freebsd.org/base/head@241012 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Fix sbin/ build with a 64-bit ino_t.

Original code by:	Gleb Kurtsou


git-svn-id: svn://svn.freebsd.org/base/head@241013 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f