13 hours agoImplement rt_tgsigqueueinfo system call used by glibc for pthread_sigqueue(3). master github/master
dchagin [Sun, 19 Feb 2017 07:38:11 +0000 (07:38 +0000)]
Implement rt_tgsigqueueinfo system call used by glibc for pthread_sigqueue(3).

MFC after: 2 week

14 hours agoMFamd64 r313933: microoptimize pmap_protect_pde().
kib [Sun, 19 Feb 2017 06:14:33 +0000 (06:14 +0000)]
MFamd64 r313933: microoptimize pmap_protect_pde().

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

15 hours agoCapsicum-ize lam(1)
allanjude [Sun, 19 Feb 2017 06:02:41 +0000 (06:02 +0000)]
Capsicum-ize lam(1)

lam(1) is used in portsnap(8), so lock it down

Reviewed by: emaste, cem, jonathan
Sponsored by: ScaleEngine Inc.
Differential Revision:

15 hours agoMissed addition to r313936.
mav [Sun, 19 Feb 2017 05:29:06 +0000 (05:29 +0000)]
Missed addition to r313936.

CTIO waitq present only in ISP_TARGET_MODE.

MFC after: 2 weeks

16 hours agoMove CTIO waitq from per-LUN to per-channel.
mav [Sun, 19 Feb 2017 05:07:02 +0000 (05:07 +0000)]
Move CTIO waitq from per-LUN to per-channel.

All resources lack of which may put CTIO into the queue are either
per-channel or potentially per-queue, but none of them are per-LUN.

This is a first step to fix live LUN disabling.  Before this change
any CTIOs held in a queue in time of disabling were just leaked.

MFC after: 2 weeks

16 hours agoRestore PBA setup for igb(4) class devices.
sbruno [Sun, 19 Feb 2017 05:06:29 +0000 (05:06 +0000)]
Restore PBA setup for igb(4) class devices.

Do no write to PBA register on igb(4) devices unless we need
to make adjustments for the 82575 and jumbo frames.

Remove redundant LPE/~LPE assignments.

Move e1000_lv_jumbo_workaround_ich8lan() invokcation into a block
so that its not executed in the igb case.

Move em(4) class assignments of RCTL values to its own code block.

Adjust a few direct accesses of ifp->mtu to use accessor functions.

PR: 216734
Submitted by: Kaho Toshikazu <>

17 hours agoFix regression in r313898 on i386.
kib [Sun, 19 Feb 2017 03:57:41 +0000 (03:57 +0000)]
Fix regression in r313898 on i386.

Use large enough type for calculation of mtrr physmask.  Typical
cpu_maxphyaddr is 36 or larger.

Reported and tested by: sbruno
Sponsored by: The FreeBSD Foundation
MFC after: 13 days

17 hours agoMicrooptimize amd64/pmap.c pmap_protect_pde().
kib [Sun, 19 Feb 2017 03:33:20 +0000 (03:33 +0000)]
Microoptimize amd64/pmap.c pmap_protect_pde().

For the loop that dirties vm_pages in case superpage was written to,
check the complete condition before the loop.

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

19 hours agoBring back r313037, with fixes for mips:
jah [Sun, 19 Feb 2017 02:03:09 +0000 (02:03 +0000)]
Bring back r313037, with fixes for mips:

Implement get_pcpu() for amd64/sparc64/mips/powerpc, and use it to
replace pcpu_find(curcpu) in MI code.

Reviewed by: andreast, kan, lidl
Tested by: lidl(mips, sparc64), andreast(powerpc)
Differential Revision:

23 hours agolocks: clean up trylock primitives
mjg [Sat, 18 Feb 2017 22:06:03 +0000 (22:06 +0000)]
locks: clean up trylock primitives

In particular thius reduces accesses of the lock itself.

23 hours agoInclude ${LOCALBASE}/bin in $PATH when running "make checkworld"
ngie [Sat, 18 Feb 2017 21:47:32 +0000 (21:47 +0000)]
Include ${LOCALBASE}/bin in $PATH when running "make checkworld"

Some of the tests in devel/atf // devel/kyua rely on the tools being in $PATH,
which means that the tests fail when run via "make checkworld" because $PATH
is restricted to exclude directory elements like "${LOCALBASE}/bin".

MFC after: 1 week
Sponsored by: Dell EMC Isilon

23 hours agoQuote path to doxygen/kyua in test(1) -x check
ngie [Sat, 18 Feb 2017 21:41:50 +0000 (21:41 +0000)]
Quote path to doxygen/kyua in test(1) -x check

This is a basic stopgap against ${LOCALBASE} containing spaces in it

MFC after: 1 week
Sponsored by: Dell EMC Isilon

23 hours agoAdd new catrigl.c (r313761) APIs to include/complex.h
mmokhi [Sat, 18 Feb 2017 21:08:09 +0000 (21:08 +0000)]
Add new catrigl.c (r313761) APIs to include/complex.h

Reviewed by: bde, emaste
Approved by: bde, emaste (src committers)
Differential Revision:

25 hours agoFor translated packets do not adjust UDP checksum if it is zero.
ae [Sat, 18 Feb 2017 19:53:37 +0000 (19:53 +0000)]
For translated packets do not adjust UDP checksum if it is zero.

In case when decrypted and decapsulated packet is an UDP datagram,
check that its checksum is not zero before doing incremental checksum

Reported by: Eugene Grosbein
Tested by: Eugene Grosbein

26 hours agoFix the last case when kldload(8) wasn't printing the name of the module
glebius [Sat, 18 Feb 2017 18:57:29 +0000 (18:57 +0000)]
Fix the last case when kldload(8) wasn't printing the name of the module
that failed to load.

26 hours agoAdd dtb files for Boundary Devices Nitrogen 6 family boards. FreeBSD runs
ian [Sat, 18 Feb 2017 18:31:42 +0000 (18:31 +0000)]
Add dtb files for Boundary Devices Nitrogen 6 family boards.  FreeBSD runs
on a nitrogen6x quad 2gb, and is expected to run on all the imx6 boards in
the nitrogen6 family.

26 hours agoAdd definitions for the IEEE-1588 registers.
ian [Sat, 18 Feb 2017 18:27:28 +0000 (18:27 +0000)]
Add definitions for the IEEE-1588 registers.

26 hours agoChange the naming of imx{5,6} gpio pins to exactly match the names used in
ian [Sat, 18 Feb 2017 18:24:03 +0000 (18:24 +0000)]
Change the naming of imx{5,6} gpio pins to exactly match the names used in
the chip reference manuals: GPIOn_IOnn.

33 hours agoMake fsck(8) default to "ufs", like eg mount(8) does.
trasz [Sat, 18 Feb 2017 11:43:13 +0000 (11:43 +0000)]
Make fsck(8) default to "ufs", like eg mount(8) does.

Approved by: imp
Discussed with: kib
MFC after: 2 weeks
Sponsored by: DARPA, AFRL
Differential Revision:

35 hours agoStyle(9), some XXX comments fix. No functional changes.
dchagin [Sat, 18 Feb 2017 10:01:17 +0000 (10:01 +0000)]
Style(9), some XXX comments fix. No functional changes.

MFC after: 1 week

35 hours agoInitialize cap_rights before use.
dchagin [Sat, 18 Feb 2017 09:39:20 +0000 (09:39 +0000)]
Initialize cap_rights before use.

MFC after: 1 week

37 hours agoFinich r313684.
dchagin [Sat, 18 Feb 2017 07:21:50 +0000 (07:21 +0000)]
Finich r313684.

Convert linux_recv(), linux_send() and linux_accept() system call arguments
to the register_t type too.

PR: 217161
MFC after: 3 days
xMFC with: r313284,r313285,r313684

38 hours agoSpell VMXNET3_LEGACY_TX correctly.
loos [Sat, 18 Feb 2017 06:18:14 +0000 (06:18 +0000)]
Spell VMXNET3_LEGACY_TX correctly.

Obtained from: pfSense
MFC after: 2 weeks
Sponsored by: Rubicon Communications, LLC (Netgate)

39 hours agoChange XCOPY memory allocations.
mav [Sat, 18 Feb 2017 06:03:16 +0000 (06:03 +0000)]
Change XCOPY memory allocations.

Before this change XCOPY code could allocate memory in chunks up to 16-32MB
(VMware does XCOPY in 4MB chunks by default), that could be difficult for
VM subsystem to do due to KVA fragmentation, that sometimes created huge
allocation delays, blocking any I/O for respective LU for that time.

This change limits allocations down to TPC_MAX_IO_SIZE, which is 1MB now.
1MB is also not a cookie, but ZFS also can do that for large blocks, so
it should be less dramatic.  As drawback this increases CPU overhead, but
it still look acceptable comparing to time consumed by ZFS read/write.

MFC after: 1 week

39 hours agoFix panic with unlocked vnode to vrecycle().
bdrewery [Sat, 18 Feb 2017 05:07:53 +0000 (05:07 +0000)]
Fix panic with unlocked vnode to vrecycle().

MFC after: 2 weeks

43 hours agomtx: plug the 'opts' argument when not used
mjg [Sat, 18 Feb 2017 01:52:10 +0000 (01:52 +0000)]
mtx: plug the 'opts' argument when not used

44 hours agoxdev: Fix after libc++ update in r300873.
bdrewery [Sat, 18 Feb 2017 00:08:13 +0000 (00:08 +0000)]
xdev: Fix after libc++ update in r300873.

The xdev build needed the same fixes as libcompat and external toolchain
support needed for handling of --sysroot, -L, -B, etc.

MFC after: 2 weeks
Sponsored by: Dell EMC Isilon

45 hours agoiwi, ral, zyd: fix possible use-after-free.
avos [Fri, 17 Feb 2017 23:20:22 +0000 (23:20 +0000)]
iwi, ral, zyd: fix possible use-after-free.

MFC after: 5 days

46 hours agoxdev: Build yacc which is needed for recent libpcap updates.
bdrewery [Fri, 17 Feb 2017 22:51:34 +0000 (22:51 +0000)]
xdev: Build yacc which is needed for recent libpcap updates.

MFC after: 2 weeks
Sponsored by: Dell EMC Isilon

46 hours agoMETA_MODE+xdev: Don't rebuild build-tools during normal build.
bdrewery [Fri, 17 Feb 2017 22:51:21 +0000 (22:51 +0000)]
META_MODE+xdev: Don't rebuild build-tools during normal build.

See r297997 for more information.

MFC after: 1 week
Sponsored by: Dell EMC Isilon

46 hours agoRely on CPUID feature only to enable attaching. MTRR are architectural
kib [Fri, 17 Feb 2017 22:50:41 +0000 (22:50 +0000)]
Rely on CPUID feature only to enable attaching. MTRR are architectural
and there is no reason to check cpu family or vendor.

Noted by:   royger
Reviewed by: jhb
Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks
Differential revision:

46 hours agosmp_rendezvous() works for UP case as well, reduce duplicated
kib [Fri, 17 Feb 2017 22:49:52 +0000 (22:49 +0000)]
smp_rendezvous() works for UP case as well, reduce duplicated
code.  Also fix cast and remove unneeded XXX in comment.

Noted and reviewed by: jhb
Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks
Differential revision:

46 hours agosx: fix mips builld after r313855
mjg [Fri, 17 Feb 2017 22:09:55 +0000 (22:09 +0000)]
sx: fix mips builld after r313855

The namespace in this file really needs cleaning up. In the meantime
let inline primitives be defined as long as LOCK_DEBUG is not enabled.

Reported by: kib

47 hours agoPush max_frame_len back into iflib so that jumbo frame sizes work.
sbruno [Fri, 17 Feb 2017 21:30:16 +0000 (21:30 +0000)]
Push max_frame_len back into iflib so that jumbo frame sizes work.

Reported by: pho

47 hours agoEnable capsicum on MALTA kernels.
brooks [Fri, 17 Feb 2017 21:25:24 +0000 (21:25 +0000)]
Enable capsicum on MALTA kernels.

This adds less that 10K to the kernel and should probably be done in the
other std.* configs.

47 hours agoMerge i386 and amd64 mtrr drivers.
kib [Fri, 17 Feb 2017 21:08:32 +0000 (21:08 +0000)]
Merge i386 and amd64 mtrr drivers.

Reviewed by: royger, jhb
Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks
Differential revision:

2 days agoext2fs: Remove unused assignment.
pfg [Fri, 17 Feb 2017 20:56:43 +0000 (20:56 +0000)]
ext2fs: Remove unused assignment.

Value is re-assigned a few lines later without being read.

Found by: Clang static analyzer
MFC after: 1 week

2 days agoMake ctl(4) build with CTL_IO_DELAY defined.
ken [Fri, 17 Feb 2017 20:15:27 +0000 (20:15 +0000)]
Make ctl(4) build with CTL_IO_DELAY defined.

In ctl_datamove(), inside CTL_IO_DELAY, add a lun variable and fill
it in before trying to dereference it.

MFC after: 3 days
Sponsored by: Spectra Logic

2 days agoAdd task attribute support to camcontrol(8).
ken [Fri, 17 Feb 2017 20:04:22 +0000 (20:04 +0000)]
Add task attribute support to camcontrol(8).

Users can use the new generic argument, -Q task_attr, to specify a task
attribute (simple, ordered, head of queue, aca) for the commands issued.
The the default is simple, which works with all SCSI devices that support
tagged queueing.

This will mostly be useful for debugging target behavior in certain

You can try it out by compiling CTL with CTL_IO_DELAY turned on (in
sys/cam/ctl/ctl_io.h) and then do something like this with one of the CTL

ctladm delay 0:0 -l done -t 10
camcontrol tur da34 -v

And at then before the 10 second timer is up, in another terminal:

camcontrol inquiry da34 -Q ordered -v

The Inquiry should complete just after the TUR completes.  Ordinarily
it would complete first because of the delay injection, but because the
task attribute is set to ordered in this case, CTL holds it up until the
previous command has completed.

Add the new generic argument, -Q, which allows the user to specify
a SCSI task attribute.  The user can specify task attributes by
name or numerically.

Add a new task_attr arguments to SCSI sub-functions.

Add the new task_attr argument to SCSI sub-functions.

Document the new -Q option, and add an example.

Sponsored by: Spectra Logic
MFC after: 1 week

2 days agoUpdate OLD_DIRS for various targets so that some of the branches of
sbruno [Fri, 17 Feb 2017 20:02:40 +0000 (20:02 +0000)]
Update OLD_DIRS for various targets so that some of the branches of
directories are pruned when the appropriate knobs are turned.

Specifically, turning off bsdconfig, locales, examples, i18n, man,
ntp, syscons.  It may not seem like a lot, but it helps when trying
to keep an x86 image under 96MB for MFSRoot netbooting.

Reviewed by: ngie
Differential Revision:

2 days agosort(1): Remove unneeded initializations.
pfg [Fri, 17 Feb 2017 19:53:20 +0000 (19:53 +0000)]
sort(1): Remove unneeded initializations.

Found by: Clang static analyzer

2 days ago[asmc] Add support for MacBook Pro 11,2
adrian [Fri, 17 Feb 2017 18:49:18 +0000 (18:49 +0000)]
[asmc] Add support for MacBook Pro 11,2

This patch will add support for MacBookPro 11.2.
For the macros, the MBP11_* macros (for the existing MacBookPro11.3) did not
match so they have been renamed to MBP113_* and a new MBP112_* has been
added (modified copy of MBP11_*).

Some trailing whitespaces may have been removed automatically.

PR: kern/214836
Obtained from: Johannes Lundberg <

2 days agoMVF: 313876
jpaetzel [Fri, 17 Feb 2017 17:52:12 +0000 (17:52 +0000)]
MVF: 313876

7504 kmem_reap hangs spa_sync and administrative tasks


  We see long spa_sync(). We are waiting to hold dp_config_rwlock for writer. Some
  other thread holds dp_config_rwlock for reader, then calls arc_get_data_buf(),
  which finds that arc_is_overflowing()==B_TRUE. So it waits (while holding
  dp_config_rwlock for reader) for arc_reclaim_thread to signal arc_reclaim_waiters_cv.
  Before signaling, arc_reclaim_thread does arc_kmem_reap_now(), which takes ~seconds.

Author: Matthew Ahrens <>
Reviewed by: George Wilson <>
Reviewed by: Prakash Surya <>
Approved by: Dan McDonald <>

2 days agomtx: get rid of file/line args from slow paths if they are unused
mjg [Fri, 17 Feb 2017 15:40:24 +0000 (15:40 +0000)]
mtx: get rid of file/line args from slow paths if they are unused

This denotes changes which went in by accident in r313877.

On most production kernels both said parameters are zeroed and have nothing
reading them in either __mtx_lock_sleep or __mtx_unlock_sleep. Thus this change
stops passing them by internal consumers which this is the case.

Kernel modules use _flags variants which are not affected kbi-wise.

2 days agomtx: restrict r313875 to kernels without LOCK_PROFILING
mjg [Fri, 17 Feb 2017 15:34:40 +0000 (15:34 +0000)]
mtx: restrict r313875 to kernels without LOCK_PROFILING

2 days agomtx: microoptimize lockstat handling in __mtx_lock_sleep
mjg [Fri, 17 Feb 2017 14:55:59 +0000 (14:55 +0000)]
mtx: microoptimize lockstat handling in __mtx_lock_sleep

This saves a function call and multiple branches after the lock is acquired.

2 days agoMake inline lockstat checks just inspect lockstat_enabled
mjg [Fri, 17 Feb 2017 14:05:57 +0000 (14:05 +0000)]
Make inline lockstat checks just inspect lockstat_enabled

There is no correctness issue and this lets the kernel just test one typically
false variable.

2 days agoPublish fp[get][set]sticky() for ARMv6.
mmel [Fri, 17 Feb 2017 13:49:46 +0000 (13:49 +0000)]
Publish fp[get][set]sticky() for ARMv6.

Although fp[get][set]sticky() functions are obsolete, they are still
required for GNU fortran49 library.

MFC after: 2 months
Reviewed by: kib
Differential Revision:

2 days agoImplement GFP_DMA32 flag in the LinuxKPI.
hselasky [Fri, 17 Feb 2017 13:31:11 +0000 (13:31 +0000)]
Implement GFP_DMA32 flag in the LinuxKPI.
Define all FreeBSD native GFP bits as GFP_NATIVE_MASK.

Obtained from: kmacy @
MFC after: 1 week
Sponsored by: Mellanox Technologies

2 days agox86: fix MTRR initialization if EARLY_AP_STARTUP is used
royger [Fri, 17 Feb 2017 12:47:51 +0000 (12:47 +0000)]
x86: fix MTRR initialization if EARLY_AP_STARTUP is used

MTRR handlers are set in {amd64/i686}_mem_drvinit, which is called at
SI_SUB_DRIVERS, and that's too late when EARLY_AP_STARTUP is set because APs
have already started at this point. {amd64/i686}_mrinit is also called too late
for the BSP, since that happens when the memory device is attached, also after
APs have already started.

Move the position to SI_SUB_CPU, and also initialize the state for the BSP, so
that the APs can correctly get to the same state as the BSP.

Sponsored by: Citrix Systems R&D
MFC after: 1 week
Reviewed by: jhb, kib
Differential Revision:

2 days agoUse full name for the month
bapt [Fri, 17 Feb 2017 11:31:27 +0000 (11:31 +0000)]
Use full name for the month

Reported by: brueffer

2 days agoAlso add vsevolod@ in the authors
bapt [Fri, 17 Feb 2017 11:26:03 +0000 (11:26 +0000)]
Also add vsevolod@ in the authors

2 days agoAdd history and Authors section in the manpage
bapt [Fri, 17 Feb 2017 11:17:56 +0000 (11:17 +0000)]
Add history and Authors section in the manpage

Submitted by: dteske
MFC after: 2 days
Differential Revision:

2 days agoPublish __aeabi_uidiv and __aeabi_idiv as compatible symbols from libc.
mmel [Fri, 17 Feb 2017 11:16:19 +0000 (11:16 +0000)]
Publish __aeabi_uidiv and __aeabi_idiv as compatible symbols from libc.

Due to bug[1] in libcompiler_rt, all symbols declared by
DEFINE_AEABI_FUNCTION_ALIAS() are not hidden. All these but two
are explicitly exported from libc and don't causes problems.

Remaining two, __aeabi_uidiv and __aeabi_idiv, infecting all
non-versioned shared libraries. And these symbols are consumed
by many (if not all) packages[2].

As workaround, export these from libc as compatible symbols,
in global namespace. With this, these are still visible for
rtld, but static linker doesn't use then.

DEFINE_AEABI_FUNCTION_ALIAS() macro uses '.set' directive for
declaration of aliased symbol. Unfortunately, '.set' doesn't
inherit visibility of base symbol, and macro don't explicitly
sets visibility for aliased one.

Given symbols are exported from non-versioned libraries only if
library itself uses them. So, if world is built for CPU with
HW divide, these function are not used and given symbols are
not exported. By this, contents of these libraries is not stable,
and all packages fails to run.

Note: Due to r313823 I'm forced to commit this too early, without
leave enough time for proper review.

MFC after: 1 month
Differential Revision:

2 days agosx: fix compilation on UP kernels after r313855
mjg [Fri, 17 Feb 2017 10:58:12 +0000 (10:58 +0000)]
sx: fix compilation on UP kernels after r313855

sx primitives use inlines as opposed to macros. Change the tested condition
to LOCK_DEBUG which covers the case, but is slightly overzelaous.

Reported by: kib

2 days agoAdd documentations related to new APIs of r313761
mmokhi [Fri, 17 Feb 2017 08:25:48 +0000 (08:25 +0000)]
Add documentations related to new APIs of r313761

PR: 216850 216851 216852 216856 216857 216858
Submitted by:
Reported by:
Reviewed by: bde emaste hselasky
Approved by: bde emaste hselasky
Differential Revision:

2 days agoFix building of r313761 on platforms that
mmokhi [Fri, 17 Feb 2017 08:22:32 +0000 (08:22 +0000)]
Fix building of r313761 on platforms that
`long double` is alias of `double` (MIPS, etc)

PR: 216850 216851 216852 216856 216857 216858
Reported by: emsate
Reviewed by: bde emaste hselasky
Approved by: bde emaste hselasky
Differential Revision:

2 days agoRemove ahb references as well as 1640 info in aha.4
imp [Fri, 17 Feb 2017 06:49:54 +0000 (06:49 +0000)]
Remove ahb references as well as 1640 info in aha.4

2 days agoRemove residuals of mca support
imp [Fri, 17 Feb 2017 06:49:46 +0000 (06:49 +0000)]
Remove residuals of mca support

2 days agoIntroduce SCHEDULER_STOPPED_TD for use when the thread pointer was already read
mjg [Fri, 17 Feb 2017 06:45:04 +0000 (06:45 +0000)]
Introduce SCHEDULER_STOPPED_TD for use when the thread pointer was already read

Sprinkle in few places.

2 days agoBump FreeBSD_version to 1200021 for removal of EISA and MCA.
imp [Fri, 17 Feb 2017 06:22:05 +0000 (06:22 +0000)]
Bump FreeBSD_version to 1200021 for removal of EISA and MCA.

2 days agoNote EISA and MCA bus removal
imp [Fri, 17 Feb 2017 06:22:00 +0000 (06:22 +0000)]
Note EISA and MCA bus removal

2 days agoRemove EISA build option
imp [Fri, 17 Feb 2017 06:13:49 +0000 (06:13 +0000)]
Remove EISA build option

2 days agolocks: let primitives for modules unlock without always goging to the slsow path
mjg [Fri, 17 Feb 2017 05:39:40 +0000 (05:39 +0000)]
locks: let primitives for modules unlock without always goging to the slsow path

It is only needed if the LOCK_PROFILING is enabled. It has to always check if
the lock is about to be released which requires an avoidable read if the option
is not specified..

2 days agoChange the way MaxCmdSN is used.
mav [Fri, 17 Feb 2017 05:22:58 +0000 (05:22 +0000)]
Change the way MaxCmdSN is used.

Before this change MaxCmdSN was reported as CmdSN + delta, that made it
limit number of requests in transmission from the initiator to target,
that was pretty useless.  After this change MaxCmdSN limits number of
requests queued to CTL, i.e. maximal queue depth for the initiator.
The default limit is 256 outstanding requests per initiator at a time.

This code uses existing cs_outstanding_ctl_pdus counter to track queue
depth.  It's semantics doen't perfectly match, but close enough to not
add another counter.  Just don't set the maxtags below 2.

MFC after: 2 weeks

2 days agolocks: remove SCHEDULER_STOPPED checks from primitives for modules
mjg [Fri, 17 Feb 2017 05:09:51 +0000 (05:09 +0000)]
locks: remove SCHEDULER_STOPPED checks from primitives for modules

They all fallback to the slow path if necessary and the check is there.

This means a panicked kernel executing code from modules will be able to
succeed doing actual lock/unlock, but this was already the case for core code
which has said primitives inlined.

2 days agoFreeze CAM SIM when request is postponed due to MaxCmdSN.
mav [Fri, 17 Feb 2017 04:34:17 +0000 (04:34 +0000)]
Freeze CAM SIM when request is postponed due to MaxCmdSN.

This allows to avoid resource allocation (especially offload) for requests
that can not be executed at this time any way.

MFC after: 2 weeks

2 days agoFix tight loop spinning on postponed requests.
mav [Fri, 17 Feb 2017 04:29:23 +0000 (04:29 +0000)]
Fix tight loop spinning on postponed requests.

MFC after: 2 weeks

2 days agoDirectly include needed headers rather than relying on pollution.
markj [Fri, 17 Feb 2017 03:27:20 +0000 (03:27 +0000)]
Directly include needed headers rather than relying on pollution.

We get machine/cpu.h via kmem.h -> proc.h -> _vm_domain.h -> seq.h.

Reported by: Ryan Libby
Sponsored by: Dell EMC Isilon
X-MFC with: r313841

2 days agoRemove EISA reference here
imp [Thu, 16 Feb 2017 23:38:30 +0000 (23:38 +0000)]
Remove EISA reference here

2 days agoPrevent CPU migration when checking the DTrace nofault flag on x86.
markj [Thu, 16 Feb 2017 23:05:20 +0000 (23:05 +0000)]
Prevent CPU migration when checking the DTrace nofault flag on x86.

dtrace_trap() consumes page and protection faults triggered by code running
in DTrace probe context. Such faults occur with interrupts disabled and are
detected using a per-CPU flag. Regular faults cause dtrace_trap() to be
called with interrupts enabled, and nothing was ensuring that the flag was
read from the correct CPU. This may result in dtrace_trap() consuming
unrelated page and protection faults when DTrace is enabled, causing the
fault handler to return without actually having handled the fault.

Diagnosed by: Ryan Libby <>
MFC after: 3 days
Sponsored by: Dell EMC Isilon

2 days agoFix the hardware.html build.
gjb [Thu, 16 Feb 2017 22:29:37 +0000 (22:29 +0000)]
Fix the hardware.html build.

Sponsored by: The FreeBSD Foundation

2 days agoRemove EISA bus support for add-in cards. Remove related kernel and
imp [Thu, 16 Feb 2017 21:57:35 +0000 (21:57 +0000)]
Remove EISA bus support for add-in cards. Remove related kernel and
compile options. Remove doxygen pointers to now deleted files. Remove
EISA and VME as examples in bus_space.9.

Retained EISA mode code for IO PIC and MPTABLES because that's not
EISA bus, per se, and some people have abused EISA to mean "EISA-like
behavior as opposed to ISA" rather than using it for EISA add-in

Relnotes: yes

2 days agoRemove PCI/EISA bridge support. But keep knowing that a chip is this
imp [Thu, 16 Feb 2017 21:57:30 +0000 (21:57 +0000)]
Remove PCI/EISA bridge support. But keep knowing that a chip is this
kind of bridge since we know for other types of unsupported bridges as

2 days agoRemove EISA support from Buslogic (bt) cards. Remove known models form
imp [Thu, 16 Feb 2017 21:57:25 +0000 (21:57 +0000)]
Remove EISA support from Buslogic (bt) cards. Remove known models form
man page. Tweak comments to not refer to EISA scenarios now that it is
no longer supported. Remove unused enum.

2 days agoRemove EISA support from ahc driver. The AIC-7770 chip can be on ISA,
imp [Thu, 16 Feb 2017 21:57:19 +0000 (21:57 +0000)]
Remove EISA support from ahc driver. The AIC-7770 chip can be on ISA,
VesaLocalBus or EISA. Internally, EISA and ISA are handled the same,
with VL being handled slightly differently. To avoid too much code
churn, retain the EISA name, despite it being used only for ISA
bus. When it is on the ISA bus, weird gymnastics are required with
EISA-space address accesses as well. Remove known models from the ahc
man page. Remove ahc_eisa module.

2 days agoRemove EISA support from dpt. Remove known EISA models from
imp [Thu, 16 Feb 2017 21:57:13 +0000 (21:57 +0000)]
Remove EISA support from dpt. Remove known EISA models from
dpt.4. Remove EISA-only bits from dpt_scsi.c.

2 days agoRemove EISA attachment (fea) from pdq driver. Remove vestiges of
imp [Thu, 16 Feb 2017 21:57:08 +0000 (21:57 +0000)]
Remove EISA attachment (fea) from pdq driver. Remove vestiges of
TurboChannel and Q-Bus support while I'm here. Remove obsolete
diagnostics from man page.

2 days agoRemove EISA support from adv driver. Remove references to it from man
imp [Thu, 16 Feb 2017 21:57:02 +0000 (21:57 +0000)]
Remove EISA support from adv driver. Remove references to it from man
page. Remove comment about EISA dual channel card. Remove trivial
references in advlib to avoid false positives with grep. Remove stray
MCA reference not worth a seperate commit.

2 days agoRemove support for EISA in the ida driver. Remove references to
imp [Thu, 16 Feb 2017 21:56:57 +0000 (21:56 +0000)]
Remove support for EISA in the ida driver. Remove references to
EISA-only registers. Remove known EISA cards from man page.

2 days agoRemove EISA support for ep driver. Left in place EISA strings that are
imp [Thu, 16 Feb 2017 21:56:51 +0000 (21:56 +0000)]
Remove EISA support for ep driver. Left in place EISA strings that are
still relevant (ISA cards can still be in EISA mode, and we're still
ignoring those in the identify routine). Notes about cards in EISA
mode have been left in the manual since they aren't relevant to EISA
support, but instruct how to properly configure an ISA card in a mode
when it is in a ISA bus slot.

2 days agoRemove references to EISA support from the vx driver, along with EISA
imp [Thu, 16 Feb 2017 21:56:46 +0000 (21:56 +0000)]
Remove references to EISA support from the vx driver, along with EISA
support. Fix a comment block that's shared with both vx and ep. Remove
obsolete refernce to statically compiling a kernel with a fixed number
of vx devices. Have not removed EISA from the title of the document
the register definitions were originally derived from (though no doubt
more recent docments were also consulted).

2 days agoRemove references to C-Bus support in the le(4) driver. Support for
imp [Thu, 16 Feb 2017 21:56:41 +0000 (21:56 +0000)]
Remove references to C-Bus support in the le(4) driver. Support for
these devices were removed when pc98 was removed.

2 days agoRemove stray reference to EISA bus support that was never in FreeBSD.
imp [Thu, 16 Feb 2017 21:56:36 +0000 (21:56 +0000)]
Remove stray reference to EISA bus support that was never in FreeBSD.

2 days agoRemove references to EISA support in mlx. The driver never supported
imp [Thu, 16 Feb 2017 21:56:32 +0000 (21:56 +0000)]
Remove references to EISA support in mlx. The driver never supported
the EISA cards and EISA bus support is being removed.

2 days agoRemove the ahb driver for the EISA Adaptec 174x.
imp [Thu, 16 Feb 2017 21:56:27 +0000 (21:56 +0000)]
Remove the ahb driver for the EISA Adaptec 174x.

2 days agoRemove stale MCA comment now that the MCA bus support is gone.
imp [Thu, 16 Feb 2017 21:56:21 +0000 (21:56 +0000)]
Remove stale MCA comment now that the MCA bus support is gone.

Relnotes: yes

2 days agoRevert r313814 and r313816
rstone [Thu, 16 Feb 2017 21:18:31 +0000 (21:18 +0000)]
Revert r313814 and r313816

Something evidently got mangled in my git tree in between testing and
review, as an old and broken version of the patch was apparently submitted
to svn.  Revert this while I work out what went wrong.

Reported by: tuexen
Pointy hat to: rstone

3 days agoPull in r285478 from upstream compiler-rt trunk (by Saleem Abdulrasool):
dim [Thu, 16 Feb 2017 21:03:43 +0000 (21:03 +0000)]
Pull in r285478 from upstream compiler-rt trunk (by Saleem Abdulrasool):

  build: give aliases the same visibility

  ARM EABI also uses function aliases.  Ensure that those aliased
  functions are given proper visibility annotations.

Reported by: mmel
MFC after: 3 days
Differential Revision:

3 days agoRemove inet_ntoa() from the kernel
vangyzen [Thu, 16 Feb 2017 20:50:01 +0000 (20:50 +0000)]
Remove inet_ntoa() from the kernel

inet_ntoa() cannot be used safely in a multithreaded environment
because it uses a static local buffer.  Remove it from the kernel.

Suggested by: glebius, emaste
Reviewed by: gnn
MFC after: never
Sponsored by: Dell EMC
Differential Revision:

3 days agoUse inet_ntoa_r() instead of inet_ntoa() throughout the kernel
vangyzen [Thu, 16 Feb 2017 20:47:41 +0000 (20:47 +0000)]
Use inet_ntoa_r() instead of inet_ntoa() throughout the kernel

inet_ntoa() cannot be used safely in a multithreaded environment
because it uses a static local buffer. Instead, use inet_ntoa_r()
with a buffer on the caller's stack.

Suggested by: glebius, emaste
Reviewed by: gnn
MFC after: 2 weeks
Sponsored by: Dell EMC
Differential Revision:

3 days agopf: use inet_ntoa_r() instead of inet_ntoa(); maybe fix IPv6 OS fingerprinting
vangyzen [Thu, 16 Feb 2017 20:44:44 +0000 (20:44 +0000)]
pf: use inet_ntoa_r() instead of inet_ntoa(); maybe fix IPv6 OS fingerprinting

inet_ntoa() cannot be used safely in a multithreaded environment
because it uses a static local buffer. Instead, use inet_ntoa_r()
with a buffer on the caller's stack.

This code had an INET6 conditional before this commit, but opt_inet6.h
was not included, so INET6 was never defined.  Apparently, pf's OS
fingerprinting hasn't worked with IPv6 for quite some time.
This commit might fix it, but I didn't test that.

Reviewed by: gnn, kp
MFC after: 2 weeks
Relnotes: yes (if I/someone can test pf OS fingerprinting with IPv6)
Sponsored by: Dell EMC
Differential Revision:

3 days agoRemove outdated claim.
pfg [Thu, 16 Feb 2017 20:30:55 +0000 (20:30 +0000)]
Remove outdated claim.

Despite wishful thinking the removal of these old function hasn't
happened yet.

MFC after: 3 days

3 days agoSmall inclusion guard comment fix.
pfg [Thu, 16 Feb 2017 20:28:30 +0000 (20:28 +0000)]
Small inclusion guard comment fix.

3 days agoacpica: remove a superfluous NULL check
vangyzen [Thu, 16 Feb 2017 20:27:22 +0000 (20:27 +0000)]
acpica: remove a superfluous NULL check

The address-of operator can't produce NULL (in practice).
Remove an unnecessary NULL check.

MFC after: 3 days
Sponsored by: Dell EMC

3 days agoFix a typo in my previous commit
rstone [Thu, 16 Feb 2017 20:06:21 +0000 (20:06 +0000)]
Fix a typo in my previous commit

Somehow in the late stages of testing my sched_ule patch, a character was
accidentally deleted from the file.  Correct this.

While I'm committing anyway, the previous commit message requires some
clarification: in the normal case of unlending priority after releasing
a mutex, the thread that was doing the lending will be woken up and
immediately become the highest-priority thread, and in that case no
priority inversion would take place.  However, if that thread is pinned
to a different CPU, then the currently running thread that just had its
priority lowered will not be preempted and then priority inversion can

Reported by: O. Hartmann (typo), jhb (scheduler clarification)
MFC after: 1 month
Pointy hat to: rstone

3 days agoAdd 0-8 as shortcuts for jumping to menu items in the hardening menu.
robak [Thu, 16 Feb 2017 19:58:02 +0000 (19:58 +0000)]
Add 0-8 as shortcuts for jumping to menu items in the hardening menu.

Submitted by: skreuzer
Reviewed by: allanjude, robak
Approved by: allanjude
Differential Revision:

3 days agoCheck for preemption after lowering a thread's priority
rstone [Thu, 16 Feb 2017 19:41:13 +0000 (19:41 +0000)]
Check for preemption after lowering a thread's priority

When a high-priority thread is waiting for a mutex held by a
low-priority thread, it temporarily lends its priority to the
low-priority thread to prevent priority inversion.  When the mutex
is released, the lent priority is revoked and the low-priority
thread goes back to its original priority.

When the priority of that thread is lowered (through a call to
sched_priority()), the schedule was not checking whether
there is now a high-priority thread in the run queue.  This can
cause threads with real-time priority to be starved in the run
queue while the low-priority thread finishes its quantum.

Fix this by explicitly checking whether preemption is necessary
when a thread's priority is lowered.

Sponsored by: Dell EMC Isilon
Obtained from: Sandvine Inc
Differential Revision:
Reviewed by: Jeff Roberson (ule)
MFC after: 1 month

3 days agoMFV 313786
jpaetzel [Thu, 16 Feb 2017 19:00:09 +0000 (19:00 +0000)]
MFV 313786

7500 Simplify dbuf_free_range by removing dn_unlisted_l0_blkid

  With the integration of:

    commit 0f6d88aded0d165f5954688a9b13bac76c38da84
    Author: Alex Reece <>
    Date:   Sat Jul 26 13:40:04 2014 -0800
    4873 zvol unmap calls can take a very long time for larger datasets

  the dnode's dn_bufs field was changed from a list to a tree. As a result,
  the dn_unlisted_l0_blkid field is no longer necessary.

Author: Stephen Blinick <>
Reviewed by: Matthew Ahrens <>
Reviewed by: Dan Kimmel <>
Approved by: Gordon Ross <>

3 days agoAllow container_of() to be used with constant data pointers.
hselasky [Thu, 16 Feb 2017 14:13:36 +0000 (14:13 +0000)]
Allow container_of() to be used with constant data pointers.

Obtained from: kmacy @
MFC after: 1 week
Sponsored by: Mellanox Technologies