MFC r240997:

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)


git-svn-id: svn://svn.freebsd.org/base/stable/9@243308 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
MFC r243032:

Use defined() to test macro definitions.

Approved by:	theraven


git-svn-id: svn://svn.freebsd.org/base/stable/9@243331 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
MFC r243240:
	Use the macro for standard error return values.

	.Dd not bumped because there is no important content change.

Obtained from:	DragonflyBSD
Approved by:	cperciva (implicit)


git-svn-id: svn://svn.freebsd.org/base/stable/9@243350 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
MFC r243241:
	Modernize parts of the ports.7 manual page.

Approved by:	cperciva (implicit)


git-svn-id: svn://svn.freebsd.org/base/stable/9@243355 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
MFC r243000:
	Add support for CIR1000 - Cirrus Logic V34 to the uart driver

Approved by:	cperciva (implicit)


git-svn-id: svn://svn.freebsd.org/base/stable/9@243356 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
MFC r242933:

Redo r242842, now actually fixing the warnings, as follows:
- In sys/ofed/drivers/infiniband/core/cma.c, an enum struct member is
  interpreted as an int, so cast it to an int.
- In sys/ofed/drivers/infiniband/core/ud_header.c, initialize the
  packet_length variable in ib_ud_header_init(), to prevent undefined
  behaviour.
- In sys/ofed/drivers/infiniband/ulp/sdp/sdp_rx.c, call rdma_notify()
  with the correct enum type and value.
- In sys/ofed/include/linux/pci.h, change the PCI_DEVICE and PCI_VDEVICE
  macros to use C99 struct initializers, so additional members can be
  overridden.

Reviewed by:	delphij, Garrett Cooper <yanegomi@gmail.com>


git-svn-id: svn://svn.freebsd.org/base/stable/9@243375 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
MFC r241903:

  Import libc++ trunk r165949.  Among other improvements and bug fixes,
  this has many visibility problems fixed, which should help with
  compiling certain ports that exercise C++11 mode (i.e. Firefox).

  Also, belatedly add the LICENSE.TXT and accompanying CREDITS.TXT files,
  which are referred to in all the source files.

MFC r241907:

  Fix two -Wsystem-header warnings in libc++ that were exposed by the new
  ATF import.  These have also been sent upstream.


git-svn-id: svn://svn.freebsd.org/base/stable/9@243376 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
MFC r243028:
  zoneid has unsigned type.

MFC r243029:
  SCOPE6_LOCK protects V_sid_default, no need to acquire it without
  any access to V_sid_default.

MFC r243031:
  if_afdata lock was converted from mutex to rwlock a long ago, so we can
  replace IF_AFDATA_LOCK() macro depending to the access type.

MFC r243148:
  Reduce the overhead of locking, use IF_AFDATA_RLOCK() when we are doing
  simple lookups.


git-svn-id: svn://svn.freebsd.org/base/stable/9@243382 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
  Partially merge r240494, which moved netinet/ipfw to netpfil/ipfw,
to make it easier to merge ipfw commits back to stable/9.


git-svn-id: svn://svn.freebsd.org/base/stable/9@243401 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
MFC r242766: sh: Fix two issues when an alias is redefined:

 * The last character is not displayed.
 * If the alias ends with itself (as a word), an infinite memory-eating loop
   occurs.

If an alias is defined initially, a space is appended to avoid recursion but
this did not happen when an alias was later modified.

PR:		bin/173418
Submitted by:	Daniel F.


git-svn-id: svn://svn.freebsd.org/base/stable/9@243402 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
MFC r242767,r243252: sh: Add tests for modifying an alias (r242766/r243402).


git-svn-id: svn://svn.freebsd.org/base/stable/9@243403 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
MFC r229848:

  Add aligned_alloc(3).

  The C11 folks reinvented the wheel by introducing an aligned version of
  malloc(3) called aligned_alloc(3), instead of posix_memalign(3). Instead
  of returning the allocation by reference, it returns the address, just
  like malloc(3).

I'm MFCing this now, as it seems aligned_alloc(3) is needed to make the
new version of libc++ work, which was merged back to FreeBSD 9 in r243376.

Requested by:	dim


git-svn-id: svn://svn.freebsd.org/base/stable/9@243405 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
MFC r242744:
Zero the newly allocated md(4) swap-backed page to prevent random
kernel memory leakage to userspace.


git-svn-id: svn://svn.freebsd.org/base/stable/9@243408 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Fix multiple Denial of Service vulnerabilities with named(8).

Fix insufficient message length validation for EAP-TLS messages.

Fix Linux compatibility layer input validation error.

Security:	FreeBSD-SA-12:06.bind
Security:	FreeBSD-SA-12:07.hostapd
Security:	FreeBSD-SA-12:08.linux
Security:	CVE-2012-4244, CVE-2012-5166, CVE-2012-4445, CVE-2012-4576
Approved by:	re
Approved by:	security-officer


git-svn-id: svn://svn.freebsd.org/base/stable/9@243417 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Sync lagg(4) with head, merging r240742, r241619:

  r240742 | glebius | 2012-09-20 14:05:10 +0400 (чт, 20 сен 2012) | 4 lines

  Convert lagg(4) to use if_transmit instead of if_start.

  In collaboration with:  thompsa, sbruno, fabient

  r241619 | emax | 2012-10-17 02:43:14 +0400 (ср, 17 окт 2012) | 5 lines

  report total number of ports for each lagg(4) interface
  via net.link.lagg.X.count sysctl


git-svn-id: svn://svn.freebsd.org/base/stable/9@243436 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Merge r241037 from head:
  The drbr(9) API appeared to be so unclear, that most drivers in
  tree used it incorrectly, which lead to inaccurate overrated
  if_obytes accounting. The drbr(9) used to update ifnet stats on
  drbr_enqueue(), which is not accurate since enqueuing doesn't
  imply successful processing by driver. Dequeuing neither mean
  that. Most drivers also called drbr_stats_update() which did
  accounting again, leading to doubled if_obytes statistics. And
  in case of severe transmitting, when a packet could be several
  times enqueued and dequeued it could have been accounted several
  times.

  o Thus, make drbr(9) API thinner. Now drbr(9) merely chooses between
    ALTQ queueing or buf_ring(9) queueing.
    - It doesn't touch the buf_ring stats any more.
    - It doesn't touch ifnet stats anymore.
    - drbr_stats_update() no longer exists.

  o buf_ring(9) handles its stats itself:
    - It handles br_drops itself.
    - br_prod_bytes stats are dropped. Rationale: no one ever
      reads them but update of a common counter on every packet
      negatively affects performance due to excessive cache
      invalidation.
    - buf_ring_enqueue_bytes() reduced to buf_ring_enqueue(), since
      we no longer account bytes.

  o Drivers handle their stats theirselves: if_obytes, if_omcasts.

  o mlx4(4), igb(4), em(4), vxge(4), oce(4) and  ixv(4) no longer
    use drbr_stats_update(), and update ifnet stats theirselves.

  o bxe(4) was the most correct driver, it didn't call
    drbr_stats_update(), thus it was the only driver accurate under
    moderate load. Now it also maintains stats itself.

  o ixgbe(4) had already taken stats from hardware, so just
    - drop software stats updating.
    - take multicast packet count from hardware as well.

  o mxge(4) just no longer needs NO_SLOW_STATS define.

  o cxgb(4), cxgbe(4) need no change, since they obtain stats
    from hardware.

  Reviewed by:  jfv, gnn


git-svn-id: svn://svn.freebsd.org/base/stable/9@243440 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Merge r242467 from head:
  - If DRM_DEBUG_DEFAULT_ON is defined, then initialize drm_debug_flagi to
    all supported debugging bits.
  - If DRM_DEBUG_DEFAULT_ON isn't defined, then initialize drm_debug_flag
    to zero.

  DRM_DEBUG_DEFAULT_ON is defined when module is build with -DDEBUG_DRM
  or if kernel config has 'options DEBUG_DRM'.

  Reviewed by:  kib


git-svn-id: svn://svn.freebsd.org/base/stable/9@243442 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
MFC: r242864

  i386 comconsole: don't loop forever if hardware doesn't respond.


git-svn-id: svn://svn.freebsd.org/base/stable/9@243444 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
MFC: r242863

  add detection of serial console presence to btx and boot2-like blocks.


git-svn-id: svn://svn.freebsd.org/base/stable/9@243445 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
MFC: r242855, r242865

  - use -march=i386 for both i386 and amd64 builds.
  - cosmetic changes to reduce diffs against i386.


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