Revise hardlink handling.

Allow the code to handle hardlinks to non-regular files correctly.

Track whether the file content has already been dumped to the snapshot.
Stop relying on tn_dirent_hint, which is not guaranteed to be set at all.
This change also allows us to rely on the behaviour that the file &
content is always before the zero-sized hardlinks to resolve ambiguities
during the streaming read of a snapshot.

with input from and ok pedro@
libcrypto: create manpages for Bitrig, not OpenBSD

found by drahn@ ok natano@
missing argument; found by mfriedl@genua.de

ok haesbaert@ patrick@ natano@
Fix cut-and-paste error message.

Imported from FreeBSD by patrick@
The, currently undocumented, -i option takes an argument.

Imported from FreeBSD by patrick@
dtc: don't crash if the argument is a directory.

Imported from FreeBSD by patrick@
dtc: ignore lines starting with #.

This is necessary because we use the C pre-processor to parse #include lines
and cpp adds line markings that start with #.

Imported from FreeBSD by patrick@
Remove unused SIZEOF_INT #define.

ok pedro@
Replace various macros with nitems() from <sys/param.h>.

ok pedro@
Revert a part of r1.98 if_run.c which caused a regression on older gen
run(4) devices.

ok stsp@

imported to Bitrig by patrick@, ok'd by pedro@
Add the -d flag (limit display depth) for compatibility with FreeBSD,
DragonFly, NetBSD and GNU coreutils, even though it's not POSIX.
Actually, this simplifies the code rather than complicating it.

Because -a and -d need not be mutually exclusive (as observed by
millert@) and -s is identical to -d 0, -a and -s are no longer
mutually exclusive, but -as and -sa are now the same as -s.
That is explicitly allowed by POSIX.

Based on a patch from William Orr <will at worrbase dot com>,
but extensively massaged and HISTORY added by me.

feedback and ok millert@

imported to Bitrig by patrick@, ok'd by pedro@
Don't assume that ep_taddr and ep_daddr are page-aligned.  It is possible to
construct ELF executables for which ep_daddr ends up not being properly
aligned.  Sanitize the addresses before setting up the address space for the
new executable.  Should fix the panic discovered by Alejandro Hernandez.

ok miod@

imported to Bitrig by patrick@, ok'd by pedro@
Disable SSLv3 in response to POODLE attack.

ok pedro@
arm: drain the write buffer on every pte sync

Currently we keep the pagetables uncached.  This means that we
don't need to take care of flushing the L1- and L2-Caches when
we change something there.  But what we forgot is that the write
buffer has to be emptied manually if we want to make sure the
changes get to the memory as soon as possible.

What happens at the moment is that when we change something in
the pagetables, we do not make sure it hits memory ASAP.

Therefore, drain the writebuf every time we call PTE_SYNC.

This fixes the issues seen when trying to boot Allwinner A20
based systems.

ok drahn@
remove trailing whitespace
Simple cleanups for amd64 pmap

- use __func__ in panics/printfs (fixes some out of sync function names)
- tell the compiler that code paths where we print diagnostics are unlikely
- use pmap_valid_entry() in some places
- remove KERNSPACE, which is not used anywhere

OK guenther@ mlarkin@ kettenis@
Move some hibernate #defines to pte.h and eliminate some duplicate defines
from hibernate code that were already defined in pte.h (with different
names). No functional change.

ok sf@, deraadt@
Make amd64 pmap more efficient on multi-processor

With the current implementation, when accessing an inactive pmap, its
ptes are mapped in the APTE range. This has the problem that the APTE
range is mapped on all CPUs and changes to the APTE must therefore be
followed by a remote TLB flush on all CPUs. This is very inefficient
because the costs increase quadratically with the number of CPUs.

Therefore, the code is changed to remove the APTE mechanism completely
and instead switch the pmap locally. A remote TLB flush is then only
done if the pmap is in use on the remote CPU. In the common case, this
will replace one TLB flush on all CPUs with two local TLB flushes.

An additional optimization is done in cases where only a single PTE of
an inactive pmap is accessed: The requested PTE is found by walking the
page tables manually via the direct mapping. This makes some more TLB
flushes unnecessary.

Furthermore, some code is reordered so that the TLB-shootdown-IPIs are
sent first, then more local processing takes place, and only afterwards
the CPU waits for the remote TLB-shootdowns to finish.

This diff is based on a patch for i386 by Artur Grabowski <art blahonga org>
from 2008. Some additional bits were taken from a different patch by
Artur from 2005.

Tested by many. OK mlarkin@

Adaptation to Bitrig + locking bits by pedro@

No objections.
in usage() and SYNOPSIS, sort options as suggested by jmc@
rearrange -d, again, after giving ingo some dodgy advice;
ok ingo