freebsd.git
9 years agoImport libc++ trunk r224926. This fixes a number of bugs, completes
dim [Thu, 15 Jan 2015 21:17:36 +0000 (21:17 +0000)]
Import libc++ trunk r224926.  This fixes a number of bugs, completes
C++14 support[1], adds more C++1z features[2], and fixes the following
LWG issues[3]:

1450: Contradiction in regex_constants
2003: String exception inconsistency in erase.
2075: Progress guarantees, lock-free property, and scheduling
      assumptions
2104: unique_lock move-assignment should not be noexcept
2112: User-defined classes that cannot be derived from
2132: std::function ambiguity
2135: Unclear requirement for exceptions thrown in
      condition_variable::wait()
2142: packaged_task::operator() synchronization too broad?
2182: Container::[const_]reference types are misleadingly specified
2186: Incomplete action on async/launch::deferred
2188: Reverse iterator does not fully support targets that overload
      operator&
2193: Default constructors for standard library containers are explicit
2205: Problematic postconditions of regex_match and regex_search
2213: Return value of std::regex_replace
2240: Probable misuse of term "function scope" in [thread.condition]
2252: Strong guarantee on vector::push_back() still broken with C++11?
2257: Simplify container requirements with the new algorithms
2258: a.erase(q1, q2) unable to directly return q2
2263: Comparing iterators and allocator pointers with different
      const-character
2268: Setting a default argument in the declaration of a member
      function assign of std::basic_string
2271: regex_traits::lookup_classname specification unclear
2272: quoted should use char_traits::eq for character comparison
2278: User-defined literals for Standard Library types
2280: begin / end for arrays should be constexpr and noexcept
2285: make_reverse_iterator
2288: Inconsistent requirements for shared mutexes
2291: std::hash is vulnerable to collision DoS attack
2293: Wrong facet used by num_put::do_put
2299: Effects of inaccessible key_compare::is_transparent type are not
      clear
2301: Why is std::tie not constexpr?
2304: Complexity of count in unordered associative containers
2306: match_results::reference should be value_type&, not const
      value_type&
2308: Clarify container destructor requirements w.r.t. std::array
2313: tuple_size should always derive from integral_constant<size_t, N>
2314: apply() should return decltype(auto) and use decay_t before
      tuple_size
2315: weak_ptr should be movable
2316: weak_ptr::lock() should be atomic
2317: The type property queries should be UnaryTypeTraits returning
      size_t
2320: select_on_container_copy_construction() takes allocators, not
      containers
2322: Associative(initializer_list, stuff) constructors are
      underspecified
2323: vector::resize(n, t)'s specification should be simplified
2324: Insert iterator constructors should use addressof()
2329: regex_match()/regex_search() with match_results should forbid
      temporary strings
2330: regex("meow", regex::icase) is technically forbidden but should
      be permitted
2332: regex_iterator/regex_token_iterator should forbid temporary
      regexes
2339: Wording issue in nth_element
2341: Inconsistency between basic_ostream::seekp(pos) and
      basic_ostream::seekp(off, dir)
2344: quoted()'s interaction with padding is unclear
2346: integral_constant's member functions should be marked noexcept
2350: min, max, and minmax should be constexpr
2356: Stability of erasure in unordered associative containers
2357: Remaining "Assignable" requirement
2359: How does regex_constants::nosubs affect basic_regex::mark_count()?
2360: reverse_iterator::operator*() is unimplementable

[1] http://libcxx.llvm.org/cxx1y_status.html
[2] http://libcxx.llvm.org/cxx1z_status.html
[3] http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html

Exp-run: antoine
MFC after: 1 month

9 years agoEvaluate running userland/kernel version in daily
gjb [Thu, 15 Jan 2015 19:52:19 +0000 (19:52 +0000)]
Evaluate running userland/kernel version in daily
periodic(8) run, taken from uname(1) '-U' and '-K'
flags.

Reviewed by: allanjude, dvl
Differential Revision: https://reviews.freebsd.org/D1541
MFC after: 1 week
Sponsored by: The FreeBSD Foundation

9 years agoloader: implement multiboot support for Xen Dom0
royger [Thu, 15 Jan 2015 16:27:20 +0000 (16:27 +0000)]
loader: implement multiboot support for Xen Dom0

Implement a subset of the multiboot specification in order to boot Xen
and a FreeBSD Dom0 from the FreeBSD bootloader. This multiboot
implementation is tailored to boot Xen and FreeBSD Dom0, and it will
most surely fail to boot any other multiboot compilant kernel.

In order to detect and boot the Xen microkernel, two new file formats
are added to the bootloader, multiboot and multiboot_obj. Multiboot
support must be tested before regular ELF support, since Xen is a
multiboot kernel that also uses ELF. After a multiboot kernel is
detected, all the other loaded kernels/modules are parsed by the
multiboot_obj format.

The layout of the loaded objects in memory is the following; first the
Xen kernel is loaded as a 32bit ELF into memory (Xen will switch to
long mode by itself), after that the FreeBSD kernel is loaded as a RAW
file (Xen will parse and load it using it's internal ELF loader), and
finally the metadata and the modules are loaded using the native
FreeBSD way. After everything is loaded we jump into Xen's entry point
using a small trampoline. The order of the multiboot modules passed to
Xen is the following, the first module is the RAW FreeBSD kernel, and
the second module is the metadata and the FreeBSD modules.

Since Xen will relocate the memory position of the second
multiboot module (the one that contains the metadata and native
FreeBSD modules), we need to stash the original modulep address inside
of the metadata itself in order to recalculate its position once
booted. This also means the metadata must come before the loaded
modules, so after loading the FreeBSD kernel a portion of memory is
reserved in order to place the metadata before booting.

In order to tell the loader to boot Xen and then the FreeBSD kernel the
following has to be added to the /boot/loader.conf file:

xen_cmdline="dom0_mem=1024M dom0_max_vcpus=2 dom0pvh=1 console=com1,vga"
xen_kernel="/boot/xen"

The first argument contains the command line that will be passed to the Xen
kernel, while the second argument is the path to the Xen kernel itself. This
can also be done manually from the loader command line, by for example
typing the following set of commands:

OK unload
OK load /boot/xen dom0_mem=1024M dom0_max_vcpus=2 dom0pvh=1 console=com1,vga
OK load kernel
OK load zfs
OK load if_tap
OK load ...
OK boot

Sponsored by: Citrix Systems R&D
Reviewed by: jhb
Differential Revision: https://reviews.freebsd.org/D517

For the Forth bits:
Submitted by: Julien Grall <julien.grall AT citrix.com>

9 years agoSound: fix typos in user visible messages etc.
bapt [Thu, 15 Jan 2015 16:09:35 +0000 (16:09 +0000)]
Sound: fix typos in user visible messages etc.

Submitted by: Sascha Wildner <saw@online.de>
Obtained from: DragonFly
MFC after: 3 days

9 years agoMajor callout subsystem cleanup and rewrite:
hselasky [Thu, 15 Jan 2015 15:32:30 +0000 (15:32 +0000)]
Major callout subsystem cleanup and rewrite:
- Close a migration race where callout_reset() failed to set the
  CALLOUT_ACTIVE flag.
- Callout callback functions are now allowed to be protected by
  spinlocks.
- Switching the callout CPU number cannot always be done on a
  per-callout basis. See the updated timeout(9) manual page for more
  information.
- The timeout(9) manual page has been updated to reflect how all the
  functions inside the callout API are working. The manual page has
  been made function oriented to make it easier to deduce how each of
  the functions making up the callout API are working without having
  to first read the whole manual page. Group all functions into a
  handful of sections which should give a quick top-level overview
  when the different functions should be used.
- The CALLOUT_SHAREDLOCK flag and its functionality has been removed
  to reduce the complexity in the callout code and to avoid problems
  about atomically stopping callouts via callout_stop(). If someone
  needs it, it can be re-added. From my quick grep there are no
  CALLOUT_SHAREDLOCK clients in the kernel.
- A new callout API function named "callout_drain_async()" has been
  added. See the updated timeout(9) manual page for a complete
  description.
- Update the callout clients in the "kern/" folder to use the callout
  API properly, like cv_timedwait(). Previously there was some custom
  sleepqueue code in the callout subsystem, which has been removed,
  because we now allow callouts to be protected by spinlocks. This
  allows us to tear down the callout like done with regular mutexes,
  and a "td_slpmutex" has been added to "struct thread" to atomically
  teardown the "td_slpcallout". Further the "TDF_TIMOFAIL" and
  "SWT_SLEEPQTIMO" states can now be completely removed. Currently
  they are marked as available and will be cleaned up in a follow up
  commit.
- Bump the __FreeBSD_version to indicate kernel modules need
  recompilation.
- There has been several reports that this patch "seems to squash a
  serious bug leading to a callout timeout and panic".

Kernel build testing: all architectures were built
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D1438
Sponsored by: Mellanox Technologies
Reviewed by: jhb, adrian, sbruno and emaste

9 years agoFix compilation for 32-bit architectures.
hselasky [Thu, 15 Jan 2015 14:47:48 +0000 (14:47 +0000)]
Fix compilation for 32-bit architectures.

PR: 196580
Sponsored by: Mellanox Technologies
MFC after: 3 days

9 years agofcntl F_O{GET,SET}LK take pointer as the arg, handle them properly for
kib [Thu, 15 Jan 2015 10:43:58 +0000 (10:43 +0000)]
fcntl F_O{GET,SET}LK take pointer as the arg, handle them properly for
compat32.

Reported and tested by: Alex Tutubalin <lexa@lexa.ru>
Sponsored by: The FreeBSD Foundation
MFC after: 1 week

9 years agoFix cpsw(4) after r277203 which folded 'struct m_hdr' into 'struct mbuf'.
bz [Thu, 15 Jan 2015 02:22:52 +0000 (02:22 +0000)]
Fix cpsw(4) after r277203 which folded 'struct m_hdr' into 'struct mbuf'.
While in theory this should have been a transparent change (and was for all
other drivers), cpsw(4) never used the proper accessor macros in a few
places but spelt the indirect m_hdr.mh_* out itself.  Convert those to
use m_len and m_data and unbreak the driver build.

9 years agoFix the PMIC node name to match the PMIC i2c address.
loos [Thu, 15 Jan 2015 01:20:56 +0000 (01:20 +0000)]
Fix the PMIC node name to match the PMIC i2c address.

Remove an extra blank line.

No functional changes.

MFC after: 3 days

9 years agoFix the C -> K temperature conversion for the dev.cpu.0.temperature sysctl.
loos [Thu, 15 Jan 2015 01:05:05 +0000 (01:05 +0000)]
Fix the C -> K temperature conversion for the dev.cpu.0.temperature sysctl.

Previous code was discarding the last digit.

Remove the unused temperature conversion macros.

9 years agoCatch a few cases where we need to release memory resources on errors.
loos [Thu, 15 Jan 2015 00:48:53 +0000 (00:48 +0000)]
Catch a few cases where we need to release memory resources on errors.

Place parentheses around variables in macros.

MFC after: 3 days

9 years agoReserve and ignore the a new module metadata type MDT_PNP_INFO for
imp [Thu, 15 Jan 2015 00:46:30 +0000 (00:46 +0000)]
Reserve and ignore the a new module metadata type MDT_PNP_INFO for
associating an optional PNP hint table with this module. In the
future, when these are added, these changes will silently ignore the
new type they would otherwise warn about. It will always be safe to
ignore this data. Get this into the builds today for some future
proofing.

MFC After: 3 days

9 years agoNew MINIMAL kernel config. The goal with this configuration is to
imp [Thu, 15 Jan 2015 00:42:06 +0000 (00:42 +0000)]
New MINIMAL kernel config. The goal with this configuration is to
only compile in those options in GENERIC that cannot be loaded as
modules. ufs is still included because many of its options aren't
present in the kernel module. There's some other exceptions documented
in the file. This is part of some work to get more things
automatically loading in the hopes of obsoleting GENERIC one day.

9 years agoIn order to support ongoing work to implement variable-size mbufs, and
rwatson [Wed, 14 Jan 2015 23:44:00 +0000 (23:44 +0000)]
In order to support ongoing work to implement variable-size mbufs, and
more generally make it easier to extend 'struct mbuf in the future', make
a number of changes to the data structure:

- As we anticipate embedding mbufs headers within variable-size regions of
  memory in the future, change the definitions of byte arrays embedded in
  mbufs to be of size [0] rather than [MLEN] and [MHLEN].  In fact, the
  cxgbe driver already uses 'struct mbuf' on the front of other storage
  sizes, but we would like the global mbuf allocator do be able to do this
  as well.

- Fold 'struct m_hdr' into 'struct mbuf' itself, eliminating a set of
  macros that aliased 'mh_foo' field names to 'm_foo' names such as
  'm_next'.  These present a particular problem as we would like to add
  new mbuf-header fields -- e.g., 'm_size' -- that, if similarly named via
  macros, would introduce collisions with many other variable names in the
  kernel.

- Rename 'struct m_ext' to 'struct struct_m_ext' so that we can add
  compile-time assertions without bumping into the still-extant 'm_ext'
  macro.

- Remove the MSIZE compile-time assertion for 'struct mbuf', but add new
  assertions for alignment of embedded data arrays (64-bit alignment even
  on 32-bit platforms), and for the sizes the mbuf header, packet header,
  and m_ext structure.

- Document that these assertions exist in comments in mbuf.h.

This change is not intended to cause (non-trivial) behavioural
differences, but is a precursor to further mbuf-allocator work.

Differential Revision: https://reviews.freebsd.org/D1483
Reviewed by: bz, gnn, np, glebius ("go ahead, I trust you")
Sponsored by: EMC / Isilon Storage Division

9 years agontpd tries to bind to IPv6 interfaces in 'tentative' state and fails as IPv6 is
hiren [Wed, 14 Jan 2015 23:34:00 +0000 (23:34 +0000)]
ntpd tries to bind to IPv6 interfaces in 'tentative' state and fails as IPv6 is
actually disabled. Fix it by making ntpd ignore such interfaces.

Submitted by: ume
Reviewed by: bz, gnn
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D1527

9 years agoRemove the <netinet/ip_compat.h> include from one of the newly added
dim [Wed, 14 Jan 2015 22:37:11 +0000 (22:37 +0000)]
Remove the <netinet/ip_compat.h> include from one of the newly added
sanitizer sources.  It is apparently unnecessary, and causes trouble for
people using WITHOUT_IPFILTER.

Reported by: Pawel Biernacki <pawel.biernacki@gmail.com>, Kurt Lidl <lidl@pix.net>

9 years agoAvoid race with "dev_rel()" when using the recently added
hselasky [Wed, 14 Jan 2015 22:07:13 +0000 (22:07 +0000)]
Avoid race with "dev_rel()" when using the recently added
"delist_dev()" function. Make sure the character device structure
doesn't go away until the end of the "destroy_dev()" function due to
concurrently running cleanup code inside "devfs_populate()".

MFC after: 1 week
Reported by: dchagin@

9 years agoFix overflow bug from r248577, turning 30s TRIM timeout into ~4s.
mav [Wed, 14 Jan 2015 16:22:00 +0000 (16:22 +0000)]
Fix overflow bug from r248577, turning 30s TRIM timeout into ~4s.

MFC after: 2 weeks

9 years agoelfcopy: Avoid divide-by-0 on section alignment 0
emaste [Wed, 14 Jan 2015 14:49:58 +0000 (14:49 +0000)]
elfcopy: Avoid divide-by-0 on section alignment 0

According to ELF ABI, alignment 0 and 1 has the same meaning: the
section has no alignment constraints.

PR: 196715
Sponsored by: The FreeBSD Foundation

9 years agoAdd a kernel function to delist our kernel character devices, so that
hselasky [Wed, 14 Jan 2015 14:04:29 +0000 (14:04 +0000)]
Add a kernel function to delist our kernel character devices, so that
the device name can be re-used right away in case we are destroying
the character devices in the background.

MFC after: 4 days
Reported by: dchagin@

9 years agoMake sure CAP_BINDAT and CAP_CONNECTAT are part of CAP_ALL0.
ed [Wed, 14 Jan 2015 13:03:03 +0000 (13:03 +0000)]
Make sure CAP_BINDAT and CAP_CONNECTAT are part of CAP_ALL0.

This makes sure that file descriptors of opened directories will
actually get these capabilities. Without this change, bindat() and
connectat() don't seem to work for me.

MFC after: 2 weeks
Reviewed by: rwatson, pjd

9 years agoUpdate the hwpmc driver to have the new type HASWELL_XEON. Also
rrs [Wed, 14 Jan 2015 12:46:58 +0000 (12:46 +0000)]
Update the hwpmc driver to have the new type HASWELL_XEON. Also
go back through HASWELL, IVY_BRIDGE, IVY_BRIDGE_XEON and SANDY_BRIDGE
to straighten out all the missing PMCs. We also add a new pmc tool
pmcstudy, this allows one to run the various formulas from
the documents "Using Intel Vtune Amplifier XE on XXX Generation platforms" for
IB/SB and Haswell. The tool also allows one to postulate your own
formulas with any of the various PMC's. At some point I will enahance
this to work with Brendan Gregg's flame-graphs so we can flamegraph
various PMC interactions. Note the manual page also needs some
work (lots of work) but gnn has committed to help me with that ;-)
Reviewed by: gnn
MFC after:1 month
Sponsored by: Netflix Inc.

9 years agoClean some dead code.
glebius [Wed, 14 Jan 2015 12:46:38 +0000 (12:46 +0000)]
Clean some dead code.

9 years agoMention /net in hier(7).
trasz [Wed, 14 Jan 2015 11:53:41 +0000 (11:53 +0000)]
Mention /net in hier(7).

MFC after: 1 month
Sponsored by: The FreeBSD Foundation

9 years agoImprove wording.
trasz [Wed, 14 Jan 2015 11:26:03 +0000 (11:26 +0000)]
Improve wording.

MFC after: 1 month
Sponsored by: The FreeBSD Foundation

9 years agoUse newly added GEOM notifications to discard autofs caches.
trasz [Wed, 14 Jan 2015 11:18:45 +0000 (11:18 +0000)]
Use newly added GEOM notifications to discard autofs caches.

MFC after: 1 month
Sponsored by: The FreeBSD Foundation

9 years agoAdd devd(8) notifications for creation and destruction of GEOM devices.
trasz [Wed, 14 Jan 2015 11:15:57 +0000 (11:15 +0000)]
Add devd(8) notifications for creation and destruction of GEOM devices.

Differential Revision: https://reviews.freebsd.org/D1211
MFC after: 1 month
Sponsored by: The FreeBSD Foundation

9 years agoReimplement TRIM throttling added in r248577.
mav [Wed, 14 Jan 2015 09:39:57 +0000 (09:39 +0000)]
Reimplement TRIM throttling added in r248577.

Previous throttling implementation approached problem from the wrong side.
It significantly limited useful delaying of TRIM requests and aggregation
potential, while not so much controlled TRIM burstiness under heavy load.

With this change random 4K write benchmarks (probably the worst case for
TRIM) show me IOPS increase by 20%, average latency reduction by 30%, peak
TRIM bursts reduction by 3 times and same peak TRIM map size (memory usage).

Also the new logic does not force map size down so heavily, really allowing
to keep deleted data for 32 TXG or 30 seconds under moderate load.  It was
practically impossible with old throttling logic, which pushed map down to
only 64 segments.

Reviewed by: smh
MFC after: 2 weeks
Sponsored by: iXsystems, Inc.

9 years agoFix typo (missing comma).
neel [Wed, 14 Jan 2015 07:18:51 +0000 (07:18 +0000)]
Fix typo (missing comma).

MFC after: 3 days

9 years agoMake use of the new Altivec ptrace support, to save the Altivec registers in
jhibbits [Wed, 14 Jan 2015 07:02:21 +0000 (07:02 +0000)]
Make use of the new Altivec ptrace support, to save the Altivec registers in
gcore.

MFC after: 2 weeks
Relnotes: yes

9 years agoAdd Altivec/VMX register support to ptrace.
jhibbits [Wed, 14 Jan 2015 07:01:21 +0000 (07:01 +0000)]
Add Altivec/VMX register support to ptrace.

MFC after: 2 weeks
Relnotes: yes

9 years agoFix spelling.
hselasky [Wed, 14 Jan 2015 06:46:25 +0000 (06:46 +0000)]
Fix spelling.

9 years agoVarious interrelated fixes to make suspend / resume work better. We now
imp [Wed, 14 Jan 2015 05:41:33 +0000 (05:41 +0000)]
Various interrelated fixes to make suspend / resume work better. We now
can suspend / resume and unload / load cbb and cardbus without errors
on my Lenovo T400, which wasn't possible before. Cards suspending
and resuming in the CardBus slot not yet tested.
o Enable memory cycles to the bridge early (as part of the new
  cbb_pci_bridge_init). This fixes the Bad VCC errors which were
  caused by the code accessing the device registers with this
  cleared. The suspend / resume process clears it.
o Refactor suspend / resume into bus specific code (though the ISA
  code is just stubbed). This isn't strictly necessary, but makes
  the initializaiton code more uniform and should be more bullet
  proof in the face of variant behavior among cardbus bridges.
o Fixup comments in the power-up sequence to reflect reality. These
  comments were written for one regime of power-up, but not updated
  as things were revised.
o Add a paranoid small delay (100ms) to cover noisy cards powering
  down.
o Fix some debugging prints to be easier to grep from dmesg.

Sponsored by: Netflix

9 years agoAdd a rather obnoxious warning if you don't have NEW_PCIB defined
imp [Wed, 14 Jan 2015 05:41:31 +0000 (05:41 +0000)]
Add a rather obnoxious warning if you don't have NEW_PCIB defined
since it's a total crap shoot if things will work.

9 years agoOn x86 force NEW_PCIB, since that's the default. While this option
imp [Wed, 14 Jan 2015 05:41:28 +0000 (05:41 +0000)]
On x86 force NEW_PCIB, since that's the default. While this option
would be picked up for kernel builds, it isn't picked up for
old-fashioned builds. Without this option, PCI bus numbers are busted
for modules build iteratively.

9 years agoRemove the prison flags PR_IP4_DISABLE and PR_IP6_DISABLE, which have been
jamie [Wed, 14 Jan 2015 04:50:28 +0000 (04:50 +0000)]
Remove the prison flags PR_IP4_DISABLE and PR_IP6_DISABLE, which have been
write-only for as long as they've existed.

9 years agoDon't set prison's pr_ip4s or pr_ip6s to -1.
jamie [Wed, 14 Jan 2015 03:52:41 +0000 (03:52 +0000)]
Don't set prison's pr_ip4s or pr_ip6s to -1.

PR: 196474
MFC after: 3 days

9 years agoDo not remap Open Firmware mappings covered by the direct map. It's
nwhitehorn [Wed, 14 Jan 2015 02:18:29 +0000 (02:18 +0000)]
Do not remap Open Firmware mappings covered by the direct map. It's
pointless and wastes resources.

MFC after: 1 week

9 years agoCorrect cpu type, it was rather Cortex A12 R0.
ganbold [Wed, 14 Jan 2015 01:23:50 +0000 (01:23 +0000)]
Correct cpu type, it was rather Cortex A12 R0.

Approved by:    stas (mentor)

9 years agoCleanup some bogus code in the RSS config, and add the include
jfv [Tue, 13 Jan 2015 22:13:30 +0000 (22:13 +0000)]
Cleanup some bogus code in the RSS config, and add the include
for the rss option file. And bump the version.

MFC after: 1 week

9 years ago'struct vm_exception' was intended to be used only as the collateral for the
neel [Tue, 13 Jan 2015 22:00:47 +0000 (22:00 +0000)]
'struct vm_exception' was intended to be used only as the collateral for the
VM_INJECT_EXCEPTION ioctl. However it morphed into other uses like keeping
track pending exceptions for a vcpu. This in turn causes confusion because
some fields in 'struct vm_exception' like 'vcpuid' make sense only in the
ioctl context. It also makes it harder to add or remove structure fields.

Fix this by using 'struct vm_exception' only to communicate information
from userspace to vmm.ko when injecting an exception.

Also, add a field 'restart_instruction' to 'struct vm_exception'. This
field is set to '1' for exceptions where the faulting instruction is
restarted after the exception is handled.

MFC after:      1 week

9 years agoSince the merge of file 5.21 in r276415 and r276416, stable/9 and
dim [Tue, 13 Jan 2015 20:37:57 +0000 (20:37 +0000)]
Since the merge of file 5.21 in r276415 and r276416, stable/9 and
stable/10 cannot be built from FreeBSD 8.x.  This is because the
build-tools stage requires libmagic, but lib/libmagic/config.h was
generated on head, and it now enables using the xlocale.h APIs, which
are not supported on 8.x (and on 9.x before __FreeBSD_version 900506).

See also the start of this thread on -stable:
https://lists.freebsd.org/pipermail/freebsd-stable/2015-January/081521.html

To fix this, conditionalize the use of xlocale.h APIs to make
bootstrapping from older FreeBSD versions work correctly.

Reviewed by: delphij
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D1518

9 years agoConnect libclang_rt to the build, for specific architectures. This
dim [Tue, 13 Jan 2015 19:54:47 +0000 (19:54 +0000)]
Connect libclang_rt to the build, for specific architectures.  This
contains the libraries for Address Sanitizer (asan), Undefined Behavior
Sanitizer (ubsan) and Profile Guided Optimization.

ASan is a fast memory error detector. It can detect the following types
of bugs:

    Out-of-bounds accesses to heap, stack and globals
    Use-after-free
    Use-after-return (to some extent)
    Double-free, invalid free
    Memory leaks (experimental)

Typical slowdown introduced by AddressSanitizer is 2x.

UBSan is a fast and compatible undefined behavior checker. It enables a
number of undefined behavior checks that have small runtime cost and no
impact on address space layout or ABI.

PLEASE NOTE: the sanitizers still have some rough edges on FreeBSD,
particularly on i386.  These will hopefully be smoothed out in the
coming time.

Differential Revision: https://reviews.freebsd.org/D1505

9 years agoComplete the RX side RSS code: parse the encoded portion of the RX
jfv [Tue, 13 Jan 2015 18:56:29 +0000 (18:56 +0000)]
Complete the RX side RSS code: parse the encoded portion of the RX
descriptor to determine the correct hash type.

MFC after:1 week

9 years agoResolve a special case deadlock: When two or more threads are
hselasky [Tue, 13 Jan 2015 16:37:43 +0000 (16:37 +0000)]
Resolve a special case deadlock: When two or more threads are
simultaneously detaching kernel drivers on the same USB device we can
get stuck in the "usb_wait_pending_ref_locked()" function because the
conditions needed for allowing detach are not met. The "destroy_dev()"
function waits for all system calls involving the given character
device to return. Character device system calls may lock the USB
enumeration lock, which is also held when "destroy_dev()" is
called. This can sometimes lead to a deadlock not noticed by
WITNESS. The current solution is to ensure the calling thread is the
only one holding the USB enumeration lock and prevent other threads
from getting refs while a USB device detach is ongoing. This turned
out not to be sufficient. To solve this deadlock we could use
"destroy_dev_sched()" to schedule the device destruction in the
background, but then we don't know when it is safe to free() the
private data of the character device. Instead a callback function is
executed by the USB explore process to kill off any leftover USB
character devices synchronously after the USB device explore code is
finished and the USB enumeration lock is no longer locked. This makes
porting easier and also ensures us that character devices must
eventually go away after a USB device detach.

While at it ensure that "flag_iserror" is only written when "priv_mtx"
is locked, which is protecting it.

MFC after: 5 days

9 years agocxgbe/iw_cxgbe: fix whitespace nit in r277102.
np [Tue, 13 Jan 2015 16:18:31 +0000 (16:18 +0000)]
cxgbe/iw_cxgbe: fix whitespace nit in r277102.

Reported by: stefanf@

9 years agoAdd new USB template to the USB bootloader module.
hselasky [Tue, 13 Jan 2015 16:06:38 +0000 (16:06 +0000)]
Add new USB template to the USB bootloader module.

9 years agolibdwarf: add missing break
emaste [Tue, 13 Jan 2015 15:18:54 +0000 (15:18 +0000)]
libdwarf: add missing break

Reported by: Coverity
CID: 1193315
MFC after: 1 week
Sponsored by: The FreeBSD Foundation

9 years agoRename Exynos UART driver. No functional change.
br [Tue, 13 Jan 2015 15:04:28 +0000 (15:04 +0000)]
Rename Exynos UART driver. No functional change.

Submitted by: Michal Meloun <meloun@miracle.cz>

9 years agoAdd new USB template to the USB template module.
hselasky [Tue, 13 Jan 2015 14:26:05 +0000 (14:26 +0000)]
Add new USB template to the USB template module.

9 years agoMove the vsi variable outside of the #ifdef block to unbreak NOIP kernels
bz [Tue, 13 Jan 2015 14:15:00 +0000 (14:15 +0000)]
Move the vsi variable outside of the #ifdef block to unbreak NOIP kernels
after r277084.

MFC after: 6 days
X-MFC with: r277084

9 years agoAdd usb template SERIALNET allowing us to have both USB CDC Ethernet
br [Tue, 13 Jan 2015 14:03:56 +0000 (14:03 +0000)]
Add usb template SERIALNET allowing us to have both USB CDC Ethernet
and USB CDC Modem same time by single cable.

Reviewed by: hselasky@

9 years agoFix detection of ext2/ext3 filesystems that lack labels.
trasz [Tue, 13 Jan 2015 13:59:48 +0000 (13:59 +0000)]
Fix detection of ext2/ext3 filesystems that lack labels.

MFC after: 1 month
Sponsored by: The FreeBSD Foundation

9 years agoDon't use POLLNVAL as a return value from the client side poll
hselasky [Tue, 13 Jan 2015 13:32:18 +0000 (13:32 +0000)]
Don't use POLLNVAL as a return value from the client side poll
function. Many existing clients don't understand POLLNVAL and instead
relies on an error code from the read(), write() or ioctl() system
call. Also make sure we wakeup any client pollers before the cuse
server is closing, so they don't wait forever for an event.

9 years agoComplete r277100: add AHCI_Q_ABAR0 tp AHCI_Q_BIT_STRING.
kib [Tue, 13 Jan 2015 09:50:15 +0000 (09:50 +0000)]
Complete r277100: add AHCI_Q_ABAR0 tp AHCI_Q_BIT_STRING.

Noted and reviewed by: smh
MFC after: 6 days

9 years agoAdd CPU ID for ARM Cortex A17.
ganbold [Tue, 13 Jan 2015 07:49:07 +0000 (07:49 +0000)]
Add CPU ID for ARM Cortex A17.

Approved by:    stas (mentor)

9 years agoRemove unused variables.
glebius [Tue, 13 Jan 2015 06:56:04 +0000 (06:56 +0000)]
Remove unused variables.

CID: 1262431
CID: 1262430

9 years ago- Remove unused variable.
glebius [Tue, 13 Jan 2015 06:22:55 +0000 (06:22 +0000)]
- Remove unused variable.
- Wrap long line.

9 years agoRemove unused fields.
glebius [Tue, 13 Jan 2015 06:22:24 +0000 (06:22 +0000)]
Remove unused fields.

9 years agoUse the common codepath to handle SIOCGIFADDR.
delphij [Tue, 13 Jan 2015 05:32:51 +0000 (05:32 +0000)]
Use the common codepath to handle SIOCGIFADDR.

Before this change, the current code handles SIOCGIFADDR the same
way with SIOCSIFADDR, which involves full arp_ifinit, et al.  They
should be unnecessary for SIOCGIFADDR case.

Differential Revision: https://reviews.freebsd.org/D1508
Reviewed by: glebius
MFC after: 2 weeks

9 years agocxgbe/iw_cxgbe: allow any size during the initial MPA exchange.
np [Tue, 13 Jan 2015 01:40:12 +0000 (01:40 +0000)]
cxgbe/iw_cxgbe: allow any size during the initial MPA exchange.

MFC after: 1 month

9 years agoExplain a bit of tricky code dealing with trims and how it prevents
imp [Tue, 13 Jan 2015 00:20:35 +0000 (00:20 +0000)]
Explain a bit of tricky code dealing with trims and how it prevents
starvation. These side effects aren't obvious without extremely
careful study, and are important to do just so.

9 years agoAdd quirk to override default BAR(5) rid for AHCI.
kib [Tue, 13 Jan 2015 00:11:56 +0000 (00:11 +0000)]
Add quirk to override default BAR(5) rid for AHCI.
Use it for Cavium AHCI.

Submitted by: Michaе┌ Stanek
Reviewed by: imp (previous version)
MFC after: 1 week

9 years agoReplace __inline GNUism with the standard inline.
pfg [Tue, 13 Jan 2015 00:04:22 +0000 (00:04 +0000)]
Replace __inline GNUism with the standard inline.

MFC after: 1 week

9 years agoIntroduce ofw_bus_reg_to_rl() to replace part of common bus code
zbb [Tue, 13 Jan 2015 00:00:09 +0000 (00:00 +0000)]
Introduce ofw_bus_reg_to_rl() to replace part of common bus code

Instead of reusing the same reg parsing code, create one, common function
that puts reg contents to the resource list. Address cells and size cells
are passed rather than acquired here so that any bus can have different
default values.

Obtained from:   Semihalf
Reviewed by:     andrew, ian, nwhitehorn
Sponsored by:    The FreeBSD Foundation

9 years agofix IV size of XTS to be correct at 8 bytes.. That is what both the
jmg [Mon, 12 Jan 2015 23:33:40 +0000 (23:33 +0000)]
fix IV size of XTS to be correct at 8 bytes.. That is what both the
AES-NI code and the software code expects..

9 years agoSkip extra bcopy() when scrubbing vdev without redundancy.
mav [Mon, 12 Jan 2015 22:38:55 +0000 (22:38 +0000)]
Skip extra bcopy() when scrubbing vdev without redundancy.

According to profiler, this bcopy() can use about 10% of CPU time.

MFC after: 2 weeks

9 years agoIn miibus(4) drivers provide functions that allow to get NIC
glebius [Mon, 12 Jan 2015 22:27:38 +0000 (22:27 +0000)]
In miibus(4) drivers provide functions that allow to get NIC
driver name and NIC driver softc via the device(9) tree,
instead of going dirty through the ifnet(9) layer.

Differential Revision: D1506
Reviewed by: imp, jhb

9 years agoANSIfy msdosfs
emaste [Mon, 12 Jan 2015 21:55:48 +0000 (21:55 +0000)]
ANSIfy msdosfs

Add a few cases and style(9) fixes missed in r276887

Sponsored by: The FreeBSD Foundation

9 years agoPull in r225610 from upstream compiler-rt trunk (by Roman Divacky):
dim [Mon, 12 Jan 2015 21:28:10 +0000 (21:28 +0000)]
Pull in r225610 from upstream compiler-rt trunk (by Roman Divacky):

  Add FreeBSD support for __clear_cache.

9 years agoMissing RSS support added, this fixes the build, but the code
jfv [Mon, 12 Jan 2015 20:59:07 +0000 (20:59 +0000)]
Missing RSS support added, this fixes the build, but the code
in the RX side was complicated by recent changes and will need
some further tweaking.

9 years agoFix a typo in the FFS maxbpg option, it was erroneously spelled maxbpf.
brueffer [Mon, 12 Jan 2015 19:26:31 +0000 (19:26 +0000)]
Fix a typo in the FFS maxbpg option, it was erroneously spelled maxbpf.

The error exists in the NetBSD upstream version as well and will be reported back.

PR: 196598
Submitted by: Dan McGregor
MFC after: 1 week

9 years agoIntel I40E driver updates:
jfv [Mon, 12 Jan 2015 18:43:34 +0000 (18:43 +0000)]
Intel I40E driver updates:
if_ixl to version 1.3.0, if_ixlv to version 1.2.0
- Major change in both drivers is to add RSS support
- In ixl fix some interface speed related issues, dual
  speed was not changing correctly, KR/X media was not
  displaying correctly (this has a workaround until a
  more robust media handling is in place)
- Add a warning when using Dell NPAR and the speed is
  less than 10G
- Wrap a queue hung message in IXL_DEBUG, as it is non-fatal,
  and without tuning can display excessively

MFC after: 1 week

9 years agoUpdate to the shared code for Intel I40E drivers in preparation
jfv [Mon, 12 Jan 2015 18:32:45 +0000 (18:32 +0000)]
Update to the shared code for Intel I40E drivers in preparation
for the ixl 1.3.0 and ixlv 1.2.0 revisions.

MFC after: 1 week

9 years agoRemove duplicate copies of trivial getcontextx.c
emaste [Mon, 12 Jan 2015 18:13:38 +0000 (18:13 +0000)]
Remove duplicate copies of trivial getcontextx.c

Only i386 and amd64 provide a non-trivial __getcontextx(). Use a common
trivial implementation in gen/ for other architectures, rather than
copying the file to each MD subdirectory.

Reviewed by: kib
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D1472

9 years agoDo not go one layer down to check ifqueue length. First, not all drivers
glebius [Mon, 12 Jan 2015 18:06:22 +0000 (18:06 +0000)]
Do not go one layer down to check ifqueue length. First, not all drivers
use ifqueue at all. Second, there is no point in this lockless check.
Either positive or negative result of the check could be incorrect after
a tick.

Reviewed by: tuexen
Sponsored by: Nginx, Inc.

9 years agoDo not go one layer down to check ifqueue length. First, not all drivers
glebius [Mon, 12 Jan 2015 14:52:43 +0000 (14:52 +0000)]
Do not go one layer down to check ifqueue length. First, not all drivers
use ifqueue at all. Second, there is no point in this lockless check.
Either positive or negative result of the check could be incorrect after
a tick.

Sponsored by: Nginx, Inc.

9 years agoMdoc markup and style cleanup.
brueffer [Mon, 12 Jan 2015 10:40:28 +0000 (10:40 +0000)]
Mdoc markup and style cleanup.

9 years agoWhen the node receives NGM_FLOW_COOKIE update the if_link_state, instead
glebius [Mon, 12 Jan 2015 09:50:42 +0000 (09:50 +0000)]
When the node receives NGM_FLOW_COOKIE update the if_link_state, instead
of playing with almost dead IFF_DRV_RUNNING flag.

Sponsored by: Nginx, Inc.

9 years agoRemove the support for NGM_CISCO_GET_IPADDR message from ng_iface(4). The
glebius [Mon, 12 Jan 2015 09:48:45 +0000 (09:48 +0000)]
Remove the support for NGM_CISCO_GET_IPADDR message from ng_iface(4).  The
legitimacy of removal is proved by the fact that implementation contained
a critical bug: the response allocated was sizeof(pointer), while should
had been 2*sizeof(struct ng_cisco_ipaddr).  The reason for ng_iface(4) to
support ng_cisco(4) message isn't explained anywhere, and code comes from
original Whistle import.

Sponsored by: Nginx, Inc.

9 years agoMFV (r277045): merge upstream version of the local socket patch.
des [Mon, 12 Jan 2015 09:46:49 +0000 (09:46 +0000)]
MFV (r277045): merge upstream version of the local socket patch.

9 years agoRemove incorrect layering violating code that:
glebius [Mon, 12 Jan 2015 09:41:12 +0000 (09:41 +0000)]
Remove incorrect layering violating code that:
a) assumed that ifqueue length is measured in bytes, instead of packets
b) assumed that any interface has working ifqueue
c) incremented global counter instead of ifi_oqdrops

Sponsored by: Nginx, Inc.

9 years agoRevert r263475: TDP_DEVMEMIO no longer needed, since amd64 /dev/kmem
kib [Mon, 12 Jan 2015 08:58:07 +0000 (08:58 +0000)]
Revert r263475: TDP_DEVMEMIO no longer needed, since amd64 /dev/kmem
does not access kernel mappings directly.

Reviewed by: alc
Sponsored by: The FreeBSD Foundation
MFC after: 1 week

9 years agoDCTCP (Data Center TCP) implementation.
hiren [Mon, 12 Jan 2015 08:33:04 +0000 (08:33 +0000)]
DCTCP (Data Center TCP) implementation.

DCTCP congestion control algorithm aims to maximise throughput and minimise
latency in data center networks by utilising the proportion of Explicit
Congestion Notification (ECN) marked packets received from capable hardware as a
congestion signal.

Highlights:
Implemented as a mod_cc(4) module.
ECN (Explicit congestion notification) processing is done differently from
RFC3168.
Takes one-sided DCTCP into consideration where only one of the sides is using
DCTCP and other is using standard ECN.

IETF draft: http://tools.ietf.org/html/draft-bensley-tcpm-dctcp-00
Thesis report by Midori Kato: https://eggert.org/students/kato-thesis.pdf

Submitted by: Midori Kato <katoon@sfc.wide.ad.jp> and
Lars Eggert <lars@netapp.com>
with help and modifications from
hiren
Differential Revision: https://reviews.freebsd.org/D604
Reviewed by: gnn

9 years agoRemove dead code.
tuexen [Mon, 12 Jan 2015 07:55:16 +0000 (07:55 +0000)]
Remove dead code.

Reported by: Coverity
CID: 748664
MFC after: 1 week

9 years agoRevert r276600: PHYS_TO_DMAP_RAW() and DMAP_TO_PHYS_RAW() are no
kib [Mon, 12 Jan 2015 07:50:55 +0000 (07:50 +0000)]
Revert r276600: PHYS_TO_DMAP_RAW() and DMAP_TO_PHYS_RAW() are no
longer used, remove them.

Reviewed by: alc
Sponsored by: The FreeBSD Foundation
MFC after: 1 week

9 years agoFix several issues with /dev/mem and /dev/kmem devices on amd64.
kib [Mon, 12 Jan 2015 07:48:22 +0000 (07:48 +0000)]
Fix several issues with /dev/mem and /dev/kmem devices on amd64.

For /dev/mem, when requested physical address is not accessible by the
direct map, do temporal remaping with the caching attribute
'uncached'.  Limit the accessible addresses by MAXPHYADDR, since the
architecture disallowes writing non-zero into reserved bits of ptes
(or setting garbage into NX).

For /dev/kmem, only access existing kernel mappings for direct map
region.  For all other addresses, obtain a physical address of the
mapping and fall back to the /dev/mem mechanism.  This ensures that
/dev/kmem i/o does not fault even if the accessed region is changed in
parallel, by using either direct map or temporal mapping.

For both devices, operate on one page by iteration.  Do not return
error if any bytes were moved around, return the (partial) bytes count
to userspace.

Reviewed by: alc
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 1 week

9 years agoReceive filter configuration is done in nge_rxfilter(). Remove
yongari [Mon, 12 Jan 2015 07:43:19 +0000 (07:43 +0000)]
Receive filter configuration is done in nge_rxfilter().  Remove
unnecessary filter configuration code in nge_init_locked().
While I'm here add a check for driver running state for multicast
filter handling.  Also remove unnecessary assignment to error
variable since it is cleared in the function entry.

Suggested by: brad@OpenBSD.org

9 years agoRemove dead code.
tuexen [Mon, 12 Jan 2015 07:39:52 +0000 (07:39 +0000)]
Remove dead code.

Reported by: Coverity
CID: 1018052
MFC after: 1 week

9 years agoEnable receive filter in sis_rxfilter().
yongari [Mon, 12 Jan 2015 07:37:06 +0000 (07:37 +0000)]
Enable receive filter in sis_rxfilter().
While I'm here add a check for driver running state for multicast
filter handling.

Suggested by: brad@OpenBSD.org

9 years agoFor x86, read MAXPHYADDR, defined in SDM vol 3 4.1.4 Enumeration of Paging
kib [Mon, 12 Jan 2015 07:36:25 +0000 (07:36 +0000)]
For x86, read MAXPHYADDR, defined in SDM vol 3 4.1.4 Enumeration of Paging
Features by CPUID as CPUID.80000008H:EAX[7:0], into variable cpu_maxphyaddr.

Reviewed by: alc
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 1 week

9 years agoRemove dead code.
tuexen [Mon, 12 Jan 2015 07:29:35 +0000 (07:29 +0000)]
Remove dead code.

Reported by: Coverity
CID: 1018053
MFC after: 1 week

9 years agoIncrease the maximum number of dynamic USB quirks. USB memory stick
hselasky [Mon, 12 Jan 2015 06:34:23 +0000 (06:34 +0000)]
Increase the maximum number of dynamic USB quirks. USB memory stick
devices which don't support the synchronize cache SCSI command are
likely to also not support the prevent-allow medium removal SCSI
command.

PR: 185747
MFC after: 1 week

9 years agoAdd PCI ID for the Oxford Semiconductor OXPCIe952 device.
grehan [Mon, 12 Jan 2015 03:39:56 +0000 (03:39 +0000)]
Add PCI ID for the Oxford Semiconductor OXPCIe952 device.

Seen on the StarTech "1 Port Native ExpressCard RS232 Serial AdapterCard
 with 16950 UART"

Reported and tested by: Michael Dexter
MFC after: 1 week

9 years agoAdd support to turn off Beaglebone with poweroff(8) or shutdown(8) -p.
loos [Mon, 12 Jan 2015 03:23:16 +0000 (03:23 +0000)]
Add support to turn off Beaglebone with poweroff(8) or shutdown(8) -p.

To cut off the power we need to start the shutdown sequence by writing
the OFF bit on PMIC.

Once the PMIC is programmed the SoC needs to toggle the PMIC_PWR_ENABLE
pin when it is ready for the PMIC to cut off the power.  This is done by
triggering the ALARM2 interrupt on SoC RTC.

The RTC driver only works in power management mode which means it won't
provide any kind of time keeping functionality.  It only implements a way
to trigger the ALARM2 interrupt when requested.

Differential Revision: https://reviews.freebsd.org/D1489
Reviewed by: rpaulo
MFC after: 2 weeks

9 years agoAdd ELF Tool Chain release notes
emaste [Mon, 12 Jan 2015 03:06:29 +0000 (03:06 +0000)]
Add ELF Tool Chain release notes

Most recent import in r276398 and switch to ELF Tool Chain tools by
default in r276796.

Reviewed by: gjb
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D1501

9 years agoHandle dma mappings with more than one segment for rpi sdhci.
ian [Mon, 12 Jan 2015 02:42:33 +0000 (02:42 +0000)]
Handle dma mappings with more than one segment for rpi sdhci.

The driver inherently does dma in 512 byte chunks, but it's possible that
such a buffer can span two physically discontiguous pages (such as when
a userland program does IO on the raw /dev/mmcsdN devices).  Now the driver
can handle a buffer that's split across two pages.

It could in theory handle any number of segments now, but as long as IO is
being done in 512 byte blocks it will never need more than two.

9 years agoEnable ALT_BREAK_TO_DEBUGGER for rpi.
ian [Mon, 12 Jan 2015 02:29:23 +0000 (02:29 +0000)]
Enable ALT_BREAK_TO_DEBUGGER for rpi.

9 years agoSplit the <orgname> tag out of being a single-line.
gjb [Mon, 12 Jan 2015 02:10:45 +0000 (02:10 +0000)]
Split the <orgname> tag out of being a single-line.

Sponsored by: The FreeBSD Foundation

9 years agoDocument r276881, libedit UTF-8 support and sh(1) unicode
gjb [Mon, 12 Jan 2015 02:08:13 +0000 (02:08 +0000)]
Document r276881, libedit UTF-8 support and sh(1) unicode
support.

Sponsored by: The FreeBSD Foundation