7 days agoaibs / atk0110: add support for querying sensors via GGRP and GITM master github/master
avg [Sat, 15 Oct 2016 09:10:35 +0000 (09:10 +0000)]
aibs / atk0110: add support for querying sensors via GGRP and GITM

Comparing to the Linux driver there is still one missing feature.
The Linux driver finds and enables "Embedded Controller" item in
the 0x11 group if it's not enabled yet.

I tested the new method, Torfinn Ingolfsen tested the old method
and helped to fix several bugs in the earlier versions of the patch.

Tested by: Torfinn Ingolfsen <>
Reviewed by: rpaulo
MFC after: 3 weeks
Differential Revision:

7 days agoImprove phrasing of the STANDARDS section.
ed [Sat, 15 Oct 2016 08:09:55 +0000 (08:09 +0000)]
Improve phrasing of the STANDARDS section.

Reported by: wblock
MFC after: 1 month
Differential Revision:

7 days agoImplement -t. Use symbolic names in place of the magical 0x7.
imp [Sat, 15 Oct 2016 06:16:35 +0000 (06:16 +0000)]
Implement -t. Use symbolic names in place of the magical 0x7.

Submitted by: ambrisko@

7 days agoCreate a pcibios-version environment FORTH word. This allows one to
imp [Sat, 15 Oct 2016 05:53:09 +0000 (05:53 +0000)]
Create a pcibios-version environment FORTH word. This allows one to
conditionally compile forth code before using the pcibios- words.

7 days agoFix cases where the TFO pending counter would leak references, and eventually, memory.
pkelsey [Sat, 15 Oct 2016 01:41:28 +0000 (01:41 +0000)]
Fix cases where the TFO pending counter would leak references, and eventually, memory.

Also renamed some tfo labels and added/reworked comments for clarity.

Based on an initial patch from jtl.

PR: 213424
Reviewed by: jtl
MFC after: 1 week
Differential Revision:

7 days agor307082 added the TCP_HHOOK kernel option and made some existing code only
jtl [Sat, 15 Oct 2016 00:29:15 +0000 (00:29 +0000)]
r307082 added the TCP_HHOOK kernel option and made some existing code only
compile when that option is configured. In tcp_destroy(), the error
variable is now only used in code enclosed in an '#ifdef TCP_HHOOK' block.
This broke the build for VNET images.

Enclose the error variable itself in an #ifdef block.

Submitted by: Shawn Webb <shawn.webb at>
Reported by: Shawn Webb <shawn.webb at>
PointyHat to: jtl

7 days agoMake BRCM2837 port conform FreeBSD/ARM64 guidelines
gonzo [Fri, 14 Oct 2016 22:23:03 +0000 (22:23 +0000)]
Make BRCM2837 port conform FreeBSD/ARM64 guidelines

- Rename SOC_BCM2837 to SOC_BRCM_BCM2837, put it to opt_soc.h
- do not use files.XXX files, just move required sources to
    conf/files.arm64 and make them depend on soc_brcm_bcm2837

Suggested by: andrew

7 days agoCreate macros for the MAIR memory attributes. While here add an uncached
andrew [Fri, 14 Oct 2016 22:20:14 +0000 (22:20 +0000)]
Create macros for the MAIR memory attributes. While here add an uncached
memory type, however the VM code still needs to be taught about this.

MFC after: 1 week
Sponsored by: ABT Systems Ltd

7 days agoReprogram I/O APIC interrupt pins when registering an I/O APIC.
jhb [Fri, 14 Oct 2016 21:51:50 +0000 (21:51 +0000)]
Reprogram I/O APIC interrupt pins when registering an I/O APIC.

All I/O APIC pins are masked when an I/O APIC is first probed.  The
APIC enumerator (MP Table or MADT) then parses its associated tables to
configure individual pins to set custom delivery modes or alternate
routing (e.g. routing IRQ 0 to intpin 2).  Pins for regular interrupt
pins are left masked until the first interrupt is assigned.  However,
pins with unusual settings (e.g. NMI or SMI) are never assigned an
interrupt and thus never re-programmed.  The I/O APIC code used to
reprogram all interrupt pins during registration but this was lost in

In theory, this is mostly a no-op as the ACPI APIC table does not
include a way to enumerate NMI or SMI pins for the I/O APIC, so only
systems using an MP Table would be affected.

Reported by: avg
MFC after: 1 month

7 days agoDrop support for using mmap() with /dev/kmem.
jhb [Fri, 14 Oct 2016 20:01:07 +0000 (20:01 +0000)]
Drop support for using mmap() with /dev/kmem.

Using the device pager with /dev/kmem is not stable since KVA mappings
are transient, but the device pager caches the PA associated with a
given offset forever.  Interestingly, mips' implementation of
memmap() already refused requests for /dev/kmem.

Note that kvm_read/kvm_write do not use mmap, but use read and write on
/dev/kmem, so this should not affect libkvm users.

Reviewed by: kib
MFC after: 2 months

8 days agoRemove redundant kern_clocksource.c. It is already in conf/files.arm64
gonzo [Fri, 14 Oct 2016 17:40:48 +0000 (17:40 +0000)]
Remove redundant kern_clocksource.c. It is already in conf/files.arm64

Reported by: andrew

8 days agoUpdate i386 build of loader.efi (but leave it disabled) so that we at
sbruno [Fri, 14 Oct 2016 17:25:29 +0000 (17:25 +0000)]
Update i386 build of loader.efi (but leave it disabled) so that we at
least build it now.

Reviewed by: emaste
Differential Revision:

8 days agoIn UEFI mode expose the SMBIOS anchor base address via kenv so the kernel
ambrisko [Fri, 14 Oct 2016 17:10:53 +0000 (17:10 +0000)]
In UEFI mode expose the SMBIOS anchor base address via kenv so the kernel
etc. can find out where the SMBIOS entry point is located.  In pure
UEFI mode the BIOS is not mapped into the standard address space so the
SMBIOS table might not appear between 0xf0000 and 0xfffff.  The
UEFI environment can report this the location of the anchor.  If it is
reported then expose it as hint.smbios.0.mem.  This can then be used
by other tools.  However, we should make smbios(4) useful and have it
take this value and provide accesor function so ipmi(4) etc. don't
have to parse and figure things about the SMBIOS table.  I have some
simple patches to smbios(4) to expose this address as sysctl and
for ipmi(4) to get the base address.  However, the real fix is to
have ipmi(4) ask smbios(4) for what it wants and have smbios(4)
parse it out and return it.  This would make smbios(4) useful and reduce
duplicated code.  If this address doesn't point to the anchor then
finding SMBIOS info. will fail as if this didn't exist.  So there should
be no harm.

With this change and the following hack, dmidecode works on a bunch of
UEFI machines that I tested:

  if kenv hint.smbios.0.mem > /dev/null
        mkdir -p /sys/firmware/efi
        mount -t tmpfs -o size=8k tmpfs /sys/firmware/efi
        echo "SMBIOS=`kenv hint.smbios.0.mem`" > /sys/firmware/efi/systab

Linux exposes this information via the /sys/firmware/efi/systab file which
dmidecode looks at.  We should update dmidecode to do this the FreeBSD
way when we determine what that is!

Reviewed by: jhb

8 days agoSimplify logic for libproc and librtld_db in lib/Makefile
emaste [Fri, 14 Oct 2016 17:04:07 +0000 (17:04 +0000)]
Simplify logic for libproc and librtld_db in lib/Makefile

8 days agoCreate a new linker set, Xficl_compile_set which contains a list of
imp [Fri, 14 Oct 2016 16:23:12 +0000 (16:23 +0000)]
Create a new linker set, Xficl_compile_set which contains a list of
functions to call at the appropriate time to register new forth
words. In the past we've done this with ifdef soup, but now if the
file is included in the build, we'll get the new forth words.

Use this new functionality to move the pci bios stuff out of loader.c
by moving it to biospci.c.

Move the pnp functionality to common/pnp.c.

Move the inb/outb forth words to the i386 sysdep.c file where their
implementation is defined.

Adjust the efi linker scripts and build machinery to cope.

his should be an invisible change to forth scripts and user

Differential Revision:

8 days agoRemove fetching of pInterp. Currently, there's no actual effect other
imp [Fri, 14 Oct 2016 16:23:05 +0000 (16:23 +0000)]
Remove fetching of pInterp. Currently, there's no actual effect other
than to store the location of a forth word that is subsequently never
used. It was last used before the 2.03 ficl upgrade in r51786. It was
only used from r43614 (so Feb-Sept 1999) on head and in the 3.x branch
(merged r43715 3.1 -> EOL). Remove it since nobody cared enough to
report the bug in the last 18 years rather than fix it. It's need
seems to have passed in the 2.03 ficl update.

Differential Revision:

8 days agoThe file /boot/boot.conf existed for the 3.0 release (r38764). It was
imp [Fri, 14 Oct 2016 16:05:44 +0000 (16:05 +0000)]
The file /boot/boot.conf existed for the 3.0 release (r38764). It was
replaced by /boot/loader.rc for 3.1 (r42682). In May 2000, this was
documented as deprecated (r61942) (between FreeBSD 4.0 and
4.1). Remove it since it's not been the preferred method in 17 years
and has been deprecated for 16.

Differential Revision:

8 days agoRework how we store the VFP registers in the pcb. This will be used when
andrew [Fri, 14 Oct 2016 15:53:48 +0000 (15:53 +0000)]
Rework how we store the VFP registers in the pcb. This will be used when
creating a floating-point context within the kernel without having to move
the stored values in memory.

Sponsored by: The FreeBSD Foundation

8 days agoadjust picobsd script to work with HEAD
luigi [Fri, 14 Oct 2016 15:16:44 +0000 (15:16 +0000)]
adjust picobsd script to work with HEAD

8 days agoThe code currently resets the keepalive timer each time a packet is
jtl [Fri, 14 Oct 2016 14:57:43 +0000 (14:57 +0000)]
The code currently resets the keepalive timer each time a packet is
received on a TCP session that has entered the ESTABLISHED state. This
results in a lot of calls to reset the keepalive timer.

This patch changes the behavior so we set the keepalive timer for the
keepalive idle time (TP_KEEPIDLE). When the keepalive timer fires, it will
first check to see if the session has been idle for TP_KEEPIDLE ticks. If
not, it will reschedule the keepalive timer for the time the session will
have been idle for TP_KEEPIDLE ticks.

For a session with regular communication, the keepalive timer should fire
approximately once every TP_KEEPIDLE ticks. For sessions with irregular
communication, the keepalive timer might fire more often. But, the
disruption from a periodic keepalive timer should be less than the regular
cost of resetting the keepalive timer on every packet.

(FWIW, this change saved approximately 1.73% of the busy CPU cycles on a
particular test system with a heavy TCP output load. Of course, the
actual impact is very specific to the particular hardware and workload.)

Reviewed by: gallatin, rrs
MFC after: 2 weeks
Sponsored by: Netflix
Differential Revision:

8 days agoMFV r307314:
mav [Fri, 14 Oct 2016 12:03:04 +0000 (12:03 +0000)]
MFV r307314:
6988 spa_sync() spends half its time in dmu_objset_do_userquota_updates

Using a benchmark which creates 2 million files in one TXG, I observe
that the thread running spa_sync() is on CPU almost the entire time we
are syncing, and therefore can be a performance bottleneck. About 50% of
the time in spa_sync() is in dmu_objset_do_userquota_updates().

The problem is that dmu_objset_do_userquota_updates() calls
zap_increment_int(DMU_USERUSED_OBJECT) once for every file that was
modified (or created). In this benchmark, all the files are owned by the
same user/group, so all 2 million calls to zap_increment_int() are
modifying the same entry in the zap. The same issue exists for the

We should keep an in-memory map from user to space delta while we are
syncing, and when we finish, iterate over the in-memory map and modify
the ZAP once per entry. This reduces the number of calls to
zap_increment_int() from "number of objects modified" to "number of
owners/groups of modified files".

This reduced the time spent in spa_sync() in the file create benchmark
by ~33%, from 11 seconds to 7 seconds.

Closes #107

Reviewed by: George Wilson <>
Reviewed by: Steve Gonczi <>
Reviewed by: Ned Bass <>
Reviewed by: Jinshan Xiong <>
Author: Matthew Ahrens <>


8 days agoMFV r307313:
mav [Fri, 14 Oct 2016 12:01:33 +0000 (12:01 +0000)]
MFV r307313:
5120 zfs should allow large block/gzip/raidz boot pool (loader project)

Reviewed by: George Wilson <>
Reviewed by: Yuri Pankov <>
Reviewed by: Andrew Stormont <>
Reviewed by: Matthew Ahrens <>
Approved by: Robert Mustacchi <>
Author: Toomas Soome <>


FreeBSD still does not support booting from gzip-compressed datasets,
so keep one chunk of this commit out.

8 days agoFix build WITHOUT_FORTH
bapt [Fri, 14 Oct 2016 11:57:08 +0000 (11:57 +0000)]

MFC after: 1 week
Sponsored by:

8 days agohyperv/vmbus: Add __FBSDID
sephe [Fri, 14 Oct 2016 05:47:59 +0000 (05:47 +0000)]
hyperv/vmbus: Add __FBSDID

Sponsored by: Microsoft

8 days agohyperv/hn: Management parts always need suspend and resume.
sephe [Fri, 14 Oct 2016 05:41:51 +0000 (05:41 +0000)]
hyperv/hn: Management parts always need suspend and resume.

MFC after: 3 days
Sponsored by: Microsoft

8 days agohyperv/stor: Fix off-by-one bug; this brings back TRIM support.
sephe [Fri, 14 Oct 2016 05:32:47 +0000 (05:32 +0000)]
hyperv/stor: Fix off-by-one bug; this brings back TRIM support.

Submitted by: Hongjiang Zhang <honzhan microsoft com>
Reported by: Lili Deng <v-lide microsoft com>
MFC after: 3 days
Sponsored by: Microsoft
Differential Revision:

8 days agoAdd initial Raspberry Pi 3 support
gonzo [Fri, 14 Oct 2016 03:37:35 +0000 (03:37 +0000)]
Add initial Raspberry Pi 3 support

RPI3 kernel config builds kernel compatible with latest upstream device
tree and firmware:
As of today it's 597c662a613df1144a6bc43e5f4505d83bd748ca

Default console is PL01x, so pi3-disable-bt dt overlay should be configured
in config.txt and stock U-Boot should be patched to use proper serial port.

Yet unsupported: SMP, VCHIQ, RNG driver. RNG requires some work due to
upstream device tree incompatibility.

Multiple people contributed to this work over time: db@, loos@, manu@

8 days agoMake bcm2835_machdep.c optional
gonzo [Fri, 14 Oct 2016 03:00:53 +0000 (03:00 +0000)]
Make bcm2835_machdep.c optional

bcm2835_machdep.c contains only bits enabled by "options PLATFORM", this
option available only on ARM, not ARM64

8 days agopartially convert lib/Makefile to SUBDIR.${MK_FOO} style
emaste [Fri, 14 Oct 2016 01:53:15 +0000 (01:53 +0000)]
partially convert lib/Makefile to SUBDIR.${MK_FOO} style

Cases other than MK_* (e.g. ${MACHINE_CPUARCH} == "i386") have been left
as is.

Reviewed by: imp
Sponsored by: The FreeBSD Foundation
Differential Revision:

8 days agoDo not set FB_FLAG_MEMATTR if VM_MEMATTR_WRITE_COMBINING is not available
gonzo [Fri, 14 Oct 2016 01:23:21 +0000 (01:23 +0000)]

Pintyhat to: gonzo
Spotted by: jmallett

8 days agoFix BCM238x framebuffer driver build for ARM64
gonzo [Fri, 14 Oct 2016 00:42:08 +0000 (00:42 +0000)]
Fix BCM238x framebuffer driver build for ARM64

VM_MEMATTR_WRITE_COMBINING can be undefined for some platforms, use it only
if it's defined

8 days agoFix BCM283x(Raspberry Pi) SDHCI driver for ARM64 build
gonzo [Thu, 13 Oct 2016 23:29:24 +0000 (23:29 +0000)]
Fix BCM283x(Raspberry Pi) SDHCI driver for ARM64 build

- Revert BUS_SPACE_PHYSADDR back to rman_get_start. BUS_SPACE_PHYSADDR was
    introduced in 2013 as temporary wrapper until proper solution appears.
    It's ARM only and since we need this file for ARM64 build and no proper
    API has been introduced - just revert the change and make sure it's
    going to appear when people grep for BUS_SPACE_PHYSADDR in sources.

- Fix printf format for size_t variables

8 days agoStop closing the network device when netbooting for loaders using the common
bapt [Thu, 13 Oct 2016 22:43:49 +0000 (22:43 +0000)]
Stop closing the network device when netbooting for loaders using the common
dev_net.c code.

The NETIF_OPEN_CLOSE_ONCE flag was added in r201932 to prevent that behaviour
on some architectures (sparc64 and powerpc64) the default was left to always
open and close the device for each open and close of a file by the loader
because it was necessary for u-boot on arm.

Since it has been added, the flag was turned on for every arches including the
u-boot loader for arm.

This also fixes netbooting on RPi3 (tested by gonzo@)

For the loader.efi it greatly speeds up netbooting

Reviewed by: emaste, gonzo, tsoome
Approved by: gonzo
MFC after: 1 month
Sponsored by:
Differential Revision:

8 days agogarbage collect _libatm, missed in r179308
emaste [Thu, 13 Oct 2016 21:35:48 +0000 (21:35 +0000)]
garbage collect _libatm, missed in r179308

8 days agoPlug a potential vnode lock leak in vm_fault_hold().
markj [Thu, 13 Oct 2016 20:39:34 +0000 (20:39 +0000)]
Plug a potential vnode lock leak in vm_fault_hold().

Reviewed by: alc, kib
MFC after: 1 week
Sponsored by: Dell EMC Isilon
Differential Revision:

8 days agopf: port extended DSCP support from OpenBSD
kp [Thu, 13 Oct 2016 20:34:44 +0000 (20:34 +0000)]
pf: port extended DSCP support from OpenBSD

Ignore the ECN bits on 'tos' and 'set-tos' and allow to use
DCSP names instead of having to embed their TOS equivalents
as plain numbers.

Obtained from: OpenBSD
Sponsored by: OPNsense
Differential Revision:

8 days ago- Revert r300854, r303657 which tried to fix regression from r297225.
glebius [Thu, 13 Oct 2016 20:15:47 +0000 (20:15 +0000)]
- Revert r300854, r303657 which tried to fix regression from r297225.
- Fix the regression proper way using RO_RTFREE().

Submitted by: ae

8 days agocxgbe(4): Allow the interface MTU to be set as high as the actual
np [Thu, 13 Oct 2016 19:40:21 +0000 (19:40 +0000)]
cxgbe(4): Allow the interface MTU to be set as high as the actual
hardware limit.

Submitted by: jpaetzel@
Differential Revision:

8 days agoFix panic() message reporting ufs instead of nandfs
martymac [Thu, 13 Oct 2016 19:33:07 +0000 (19:33 +0000)]
Fix panic() message reporting ufs instead of nandfs

PR: 213438
Approved by: kib

8 days agolibgcc_s: add libm dependencies from div{d,s,x}c3
emaste [Thu, 13 Oct 2016 19:18:00 +0000 (19:18 +0000)]
libgcc_s: add libm dependencies from div{d,s,x}c3

compiler-rt's complex division support routines contain calls to
compiler builtins such as `__builtin_scalbnl`.  Unfortunately Clang
turns these back into a call to `scalbnl`.

For now link libm's C version of the required support routines.

Reviewed by: ed
Sponsored by: The FreeBSD Foundation
Differential Revision:

8 days agoIntroduce lib/libgcc_eh and lib/libgcc_s for LLVM's implementation
emaste [Thu, 13 Oct 2016 18:57:18 +0000 (18:57 +0000)]
Introduce lib/libgcc_eh and lib/libgcc_s for LLVM's implementation

They are not yet connected to the build, but I am adding them to allow
for easier testing, ports exp-runs, etc.

Reviewed by: ed
Sponsored by: The FreeBSD Foundation
Differential Revision:

8 days agoImprove typing of POSIX search tree functions.
ed [Thu, 13 Oct 2016 18:25:40 +0000 (18:25 +0000)]
Improve typing of POSIX search tree functions.

Back in 2015 when I reimplemented these functions to use an AVL tree, I
was annoyed by the weakness of the typing of these functions. Both tree
nodes and keys are represented by 'void *', meaning that things like the
documentation for these functions are an absolute train wreck.

To make things worse, users of these functions need to cast the return
value of tfind()/tsearch() from 'void *' to 'type_of_key **' in order to
access the key. Technically speaking such casts violate aliasing rules.
I've observed actual breakages as a result of this by enabling features
like LTO.

I've filed a bug report at the Austin Group. Looking at the way the bug
got resolved, they made a pretty good step in the right direction. A new
type 'posix_tnode' has been added to correspond to tree nodes. It is
still defined as 'void' for source-level compatibility, but in the very
far future it could be replaced by a proper structure type containing a
key pointer.

MFC after: 1 month
Differential Revision:

8 days agoWith build without TCP_HHOOK and with INVARIANTS. Before mutex.h came
glebius [Thu, 13 Oct 2016 18:02:29 +0000 (18:02 +0000)]
With build without TCP_HHOOK and with INVARIANTS.  Before mutex.h came
via sys/hhook.h -> sys/rmlock.h -> sys/mutex.h.

9 days agoFix octeon model comparison in Cavium SDK
emaste [Thu, 13 Oct 2016 17:16:32 +0000 (17:16 +0000)]
Fix octeon model comparison in Cavium SDK

buildkernel failed with GCC 5.3 with
error: comparison of constant '852736' with boolean expression is always true

Sponsored by: The FreeBSD Foundation

9 days ago'b' is short for --binary, it isn't 'a'.
imp [Thu, 13 Oct 2016 17:03:54 +0000 (17:03 +0000)]
'b' is short for --binary, it isn't 'a'.

PR: 213437
Submitted by: Ganael LAPLANCHE

9 days agoConvert ­ U+00AD soft hyphen to - in Cavium Octeon SDK
emaste [Thu, 13 Oct 2016 16:57:19 +0000 (16:57 +0000)]
Convert ­ U+00AD soft hyphen to - in Cavium Octeon SDK

Linux's copy of the Cavium SDK does not have these non-ASCII characters
and this reduces noise in diffs when comparing the two.

Sponsored by: The FreeBSD Foundation

9 days ago[net80211] remove now duplicate copy of the QOSDATA check macro.
adrian [Thu, 13 Oct 2016 16:45:01 +0000 (16:45 +0000)]
[net80211] remove now duplicate copy of the QOSDATA check macro.

9 days ago[net80211] add some more QoS frame subtypes.
adrian [Thu, 13 Oct 2016 16:41:34 +0000 (16:41 +0000)]
[net80211] add some more QoS frame subtypes.

9 days agoFix typos: use correct string format and value to compare.
br [Thu, 13 Oct 2016 15:26:51 +0000 (15:26 +0000)]
Fix typos: use correct string format and value to compare.

Sponsored by: DARPA, AFRL
Sponsored by: HEIF5
Differential Revision:

9 days agoFix strchr, strrchr implementation: convert c to char
br [Thu, 13 Oct 2016 15:23:53 +0000 (15:23 +0000)]
Fix strchr, strrchr implementation: convert c to char
(according to standard).

Discussed with: andrew
Reviewed by: emaste
Sponsored by: DARPA, AFRL
Sponsored by: HEIF5
Differential Revision:

9 days agoFix a race in vm_page_busy_sleep(9).
kib [Thu, 13 Oct 2016 14:41:05 +0000 (14:41 +0000)]
Fix a race in vm_page_busy_sleep(9).

Suppose that we have an exclusively busy page, and a thread which can
accept shared-busy page.  In this case, typical code waiting for the
page xbusy state to pass is
if (vm_page_xbusied(m)) {
  VM_OBJECT_WUNLOCK(object);    <---1
vm_page_busy_sleep(p, "vmopax");
  goto again;

Suppose that the xbusy state owner locked the object, unbusied the
page and unlocked the object after we are at the line [1], but before we
executed the load of the busy_lock word in vm_page_busy_sleep().  If it
happens that there is still no waiters recorded for the busy state,
the xbusy owner did not acquired the page lock, so it proceeded.

More, suppose that some other thread happen to share-busy the page
after xbusy state was relinquished but before the m->busy_lock is read
in vm_page_busy_sleep().  Again, that thread only needs vm_object lock
to proceed.  Then, vm_page_busy_sleep() reads busy_lock value equal to

In this case, all tests in vm_page_busy_sleep(9) pass and we are going
to sleep, despite the page being share-busied.

Update check for m->busy_lock == VPB_UNBUSIED in vm_page_busy_sleep(9)
to also accept shared-busy state if we only wait for the xbusy state to

Merge sequential if()s with the same 'then' clause in

Note that the current code does not share-busy pages from parallel
threads, the only way to have more that one sbusy owner is right now
is to recurse.

Reported and tested by: pho (previous version)
Reviewed by: alc, markj
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision:

9 days agoMark the socket as un-writable when it is 1-to-1 and the SCTP association
tuexen [Thu, 13 Oct 2016 13:53:01 +0000 (13:53 +0000)]
Mark the socket as un-writable when it is 1-to-1 and the SCTP association
is freed.

MFC after: 1 month

9 days agoWhitespace changes.
tuexen [Thu, 13 Oct 2016 13:38:14 +0000 (13:38 +0000)]
Whitespace changes.

MFC after: 1 month

9 days agoMFV r307214:
mm [Thu, 13 Oct 2016 11:40:34 +0000 (11:40 +0000)]
MFV r307214:
Sync libarchive with vendor. Style and tests fixes.

Important vendor bugfixes (relevant to FreeBSD):
#801: FreeBSD Coverity report: resource leak in libarchive/tar/test/main.c

MFC after: 1 week

9 days agoMove printing the AArch64 ID registers to a new SYSINIT, the previous
andrew [Thu, 13 Oct 2016 09:06:29 +0000 (09:06 +0000)]
Move printing the AArch64 ID registers to a new SYSINIT, the previous
location only prints them when booting on SMP with multiple cores.

MFC after: 1 week
Sponsored by: DARPA, AFRL

9 days agoChange atf_skip call to atf_expect_fail to make it clear that a failure is
ngie [Thu, 13 Oct 2016 08:35:08 +0000 (08:35 +0000)]
Change atf_skip call to atf_expect_fail to make it clear that a failure is

MFC after: 2 weeks
PR: 212861
Suggested by: jmmv
Sponsored by: Dell EMC Isilon

9 days agoExpect :large to fail on FreeBSD
ngie [Thu, 13 Oct 2016 08:27:19 +0000 (08:27 +0000)]
Expect :large to fail on FreeBSD

FreeBSD doesn't appear to validate large -o size values like
NetBSD does

MFC after: 2 weeks
PR: 212862
Sponsored by: Dell EMC Isilon

9 days agoPort contrib/netbsd-tests/fs/tmpfs/h_tools.c to FreeBSD
ngie [Thu, 13 Oct 2016 07:32:25 +0000 (07:32 +0000)]
Port contrib/netbsd-tests/fs/tmpfs/h_tools.c to FreeBSD

- Add inttypes.h #include for PRId64 macro
- Use FreeBSD's copy of getfh(2), which doesn't include a `fh_size` parameter.
  Use sizeof(fhandle_t) instead as the size of fhp is always fixed as
  fhandle_t, unlike NetBSD's copy of fhp, which is void*.

MFC after: 2 weeks
Sponsored by: EMC / Isilon Storage Division

9 days agoconvert iicsmb to use iicbus_transfer for all operations
avg [Thu, 13 Oct 2016 07:25:18 +0000 (07:25 +0000)]
convert iicsmb to use iicbus_transfer for all operations

Previously the driver used more low level operations like iicbus_start
and iicbus_write.  The problem is that those operations are not
implemented by iicbus(4) and the calls were effectively routed to
a driver to which the bus is attached.
But not all of the controllers implement such low level operations
while all of the drivers are expected to have iicbus_transfer.

While there fix incorrect implementation of iicsmb_bwrite and iicsmb_bread.
The former should send a byte count before the actual bytes, while the
latter should first receive the byte count and then receive the bytes.

I have tested only these commands:
- quick (r/w)
- send byte
- receive byte
- read byte
- write byte

MFC after: 1 month
Differential Revision:

9 days agoAlso, remove etc/rc.d/zfsbe when MK_ZFS == no
ngie [Thu, 13 Oct 2016 07:12:20 +0000 (07:12 +0000)]
Also, remove etc/rc.d/zfsbe when MK_ZFS == no

X-MFC with: r307182, r307191
Sponsored by: Dell EMC Isilon

9 days agoInstall etc/rc.d/zfsbe when MK_ZFS != no
ngie [Thu, 13 Oct 2016 07:10:27 +0000 (07:10 +0000)]
Install etc/rc.d/zfsbe when MK_ZFS != no

X-MFC with: r307182
Sponsored by: Dell EMC Isilon

9 days agoSkip :uchg on FreeBSD
ngie [Thu, 13 Oct 2016 07:02:54 +0000 (07:02 +0000)]
Skip :uchg on FreeBSD

Unfortunately removing files with uchg set always succeeds with root on
FreeBSD. Unfortunately running the test as an unprivileged user isn't doable
because mounting tmpfs requires root

PR: 212861
Sponsored by: Dell EMC Isilon

9 days agoFix building on i386 and arm. But 'public domain' headers on the files
imp [Thu, 13 Oct 2016 06:56:23 +0000 (06:56 +0000)]
Fix building on i386 and arm. But 'public domain' headers on the files
with no creative content. Include "lost" changes from git:
o Use /dev/efi instead of /dev/efidev
o Remove redundant NULL checks.

Submitted by: kib@, dim@, zbb@, emaste@

9 days agorc.d/zfsbe: a new script designed for boot environment support
avg [Thu, 13 Oct 2016 06:19:54 +0000 (06:19 +0000)]
rc.d/zfsbe: a new script designed for boot environment support

Currently zfsbe ensures that subordinate filesystems are mounted at the
right mount points.
The script assumes that the subordinate filesystems of a boot environment
have their canmount property set to noauto, so that they are not
automatically mounted on boot.  Whereas the root filesystem is mounted
by the kernel, there was nothing to mount its subordinates.
rc.d/zfsbe fills that gap.

Discussed with: allanjude, will
MFC after: 3 weeks
Differential Revision:

9 days agokern_linker: Handle module-loading failures in preloaded .ko files
cem [Thu, 13 Oct 2016 02:06:23 +0000 (02:06 +0000)]
kern_linker: Handle module-loading failures in preloaded .ko files

The runtime kernel loader, linker_load_file, unloads kernel files that
failed to load all of their modules. For consistency, treat preloaded
(loader.conf loaded) kernel files in the same way.

Reviewed by: kib
Sponsored by: Dell EMC Isilon
Differential Revision:

9 days agoMany shops still prefer rc.conf(5) based jail configuration(s). In-part
dteske [Wed, 12 Oct 2016 20:50:17 +0000 (20:50 +0000)]
Many shops still prefer rc.conf(5) based jail configuration(s). In-part
because they can use sysrc in conjunction with ssh and xargs to perform
en-masse changes in a large distribution with lots of jails spread over
many hosts on a LAN/WAN.

Provide a mechanism for disabling the warning eschewed by /etc/rc.d/jail
in said situation. If jail_confwarn="NO" is in rc.conf(5) (default "YES")
skip the warning that per-jail configurations are obsolete and that the
user should migrate to jail.conf(5).

Reviewed by: jelischer
MFC after: 3 days
Sponsored by: FIS Global, Inc.
Differential Revision:

9 days agonet80211: convert all ieee80211_input_mimo*() consumers
avos [Wed, 12 Oct 2016 20:50:13 +0000 (20:50 +0000)]
net80211: convert all ieee80211_input_mimo*() consumers
to ieee80211_add_rx_params() + drop last (ieee80211_rx_stats) parameter

Note: there is an additional check for ieee80211_get_rx_params()
return value (which does not exist in the original diff).

Reviewed by: adrian
Differential Revision:

9 days agoTemporarily disconnect efivar to fix arm and i386 builds
emaste [Wed, 12 Oct 2016 20:25:03 +0000 (20:25 +0000)]
Temporarily disconnect efivar to fix arm and i386 builds

9 days agoMFportsnap r264740: Use case insensitive match when parsing host(1) output.
cperciva [Wed, 12 Oct 2016 20:24:33 +0000 (20:24 +0000)]
MFportsnap r264740: Use case insensitive match when parsing host(1) output.

Some DNS caches turn "" into "", which was causing
the printed SRV records to not match our regex.

PR: 170503
MFC after: 2 weeks

9 days ago[fdt] Add one more heuristic to determine MAC address of the SMSC device
gonzo [Wed, 12 Oct 2016 19:53:10 +0000 (19:53 +0000)]
[fdt] Add one more heuristic to determine MAC address of the SMSC device

- If check for net,ethernet/usb,device compatible node fails, try to find
    .../usb/hub/ethernet, where ... is bus path that can depend on actual HW.
    net,ethernet/usb,device compatibity strings are FreeBSD custom invention
    that is used only in RPi DTBs and since there is no other way to tie USB
    device to FDT node we just do our best effort here to work with upstream
    device tree

- Use -1 value to indicate invalid phandle_t, 0 is valid phandle value and
    shouldn't be used as error signal

9 days agoThe TFO server-side code contains some changes that are not conditioned on
jtl [Wed, 12 Oct 2016 19:06:50 +0000 (19:06 +0000)]
The TFO server-side code contains some changes that are not conditioned on
the TCP_RFC7413 kernel option. This change removes those few instructions
from the packet processing path.

While not strictly necessary, for the sake of consistency, I applied the
new IS_FASTOPEN macro to all places in the packet processing path that
used the (t_flags & TF_FASTOPEN) check.

Reviewed by: hiren
Sponsored by: Netflix
Differential Revision:

9 days agoAdd COMPAT_FREEBSD10 to the MIPS ERL kernel config
emaste [Wed, 12 Oct 2016 18:49:30 +0000 (18:49 +0000)]
Add COMPAT_FREEBSD10 to the MIPS ERL kernel config

As of r302092, pipe is a wrapper around pipe2 and the pipe syscall is no
longer used. It is included only with the COMPAT_FREEBSD10 kernel option.
Add the compat option to support upgrades from systems with an earlier

MFC after: 1 week

10 days agoINTRNG: Propagate IRQ activation error to API consumer
gonzo [Wed, 12 Oct 2016 17:10:59 +0000 (17:10 +0000)]
INTRNG: Propagate IRQ activation error to API consumer

Keep resource state consistent with INTRNG state - if intr_activate_irq
fails - deactivate resource and propagate error to calling function

Reviewed by: mmel

10 days agoAvoid using 'head' in generating groff doc date
emaste [Wed, 12 Oct 2016 15:49:20 +0000 (15:49 +0000)]
Avoid using 'head' in generating groff doc date

It may not be available in certain cross build cases.

Note that this is a slight change in functionality, in that now only the
first line of the source ChangeLog file is processed. This is acceptable
as groff will be retired and we won't encounter a possibly-different
ChangeLog format.

Reported by: jhibbits
Tested by: jhibbits

10 days agoUse the armv6 GENERIC kernel in the release images on hardware this kernel
andrew [Wed, 12 Oct 2016 15:29:22 +0000 (15:29 +0000)]
Use the armv6 GENERIC kernel in the release images on hardware this kernel
config supports.

Approved by: gjb
Sponsored by: ABT Systems Ltd
Differential Revision:

10 days agoAdd comment on use of abort() in libc
emaste [Wed, 12 Oct 2016 13:56:14 +0000 (13:56 +0000)]
Add comment on use of abort() in libc

Suggested by: jonathan (in review D8133)

10 days agoKeep in-sync MK_SSP=no option both with kernel and userspace.
br [Wed, 12 Oct 2016 13:51:41 +0000 (13:51 +0000)]
Keep in-sync MK_SSP=no option both with kernel and userspace.

Pointed out by: emaste
Sponsored by: DARPA, AFRL
Sponsored by: HEIF5

10 days agoAdd different libc ldscript: the one without libssp --
br [Wed, 12 Oct 2016 13:19:21 +0000 (13:19 +0000)]
Add different libc ldscript: the one without libssp --
we don't have it when MK_SSP==no.

This fixes compilation on MIPS.

Reviewed by: imp
Sponsored by: DARPA, AFRL
Sponsored by: HEIF5
Differential Revision:

10 days agoUse M_WAITOK in PIO_KEYMAP ioctl
emaste [Wed, 12 Oct 2016 12:56:18 +0000 (12:56 +0000)]

The malloc return value is not checked.

Submitted by: CTurt <>
MFC after: 1 week

10 days agoremove a few stray spaces from sys/param.h
avg [Wed, 12 Oct 2016 11:17:10 +0000 (11:17 +0000)]
remove a few stray spaces from sys/param.h

10 days agobump __FreeBSD_version for libzfs_core.h
avg [Wed, 12 Oct 2016 11:12:31 +0000 (11:12 +0000)]
bump __FreeBSD_version for libzfs_core.h

10 days agoUse copyout() instead of pointing sbuf to user-space buffer.
mav [Wed, 12 Oct 2016 08:25:13 +0000 (08:25 +0000)]
Use copyout() instead of pointing sbuf to user-space buffer.

MFC after: 2 weeks

10 days agoinstall header files required development with libzfs_core
avg [Wed, 12 Oct 2016 07:08:32 +0000 (07:08 +0000)]
install header files required development with libzfs_core

libzfs_core provides a rather limited but committed (stable) interface
for working with ZFS.  We install libzfs_core shared library but we do
not install header files required for developing programs that use
the library.  This change is to install the required header files
libzfs_core.h, libnvpair.h and sys/nvpair.h.

The headers are installed into the same locations as on illumos.

Reviewed by: mav, markj
Differential Revision:

10 days agosmbus: allow child devices to be added via hints
avg [Wed, 12 Oct 2016 06:58:01 +0000 (06:58 +0000)]
smbus: allow child devices to be added via hints

This will allow to add slave drivers in the same fashion as for iicbus.

Also, allow other code to add a child device and set its 'addr' ivar.
The ivar can only be set if it's unset, it can not be changed.
That could be used, for example, by a platform driver that has
a precise description of the hardware and, thus, knows what drivers
can handle what slaves.

The slave auto-probing code is unsafe and broken because it uses
7-bit slave addresses.  It's going to be removed.

Note: internally the driver uses address of zero as an unset address
while smbus_get_addr() returns it as -1 for compatibility reasons.
The address is expected to be unset only for children that do not
work with slaves like, for example, smb(4).

Reviewed by: jhb
Differential Revision:

10 days agoFix typo in comment
gonzo [Wed, 12 Oct 2016 05:35:57 +0000 (05:35 +0000)]
Fix typo in comment

Spotted by: loos

10 days agoMake BCM28x USB driver compatible with upstream device tree
gonzo [Wed, 12 Oct 2016 03:36:46 +0000 (03:36 +0000)]
Make BCM28x USB driver compatible with upstream device tree

This should have been committed in r307093: resource allocation depends
on source of the device tree. upstream dts has extra interrupt that we can

10 days agoMake VCHI driver compatible with upstream DT
gonzo [Wed, 12 Oct 2016 03:08:58 +0000 (03:08 +0000)]
Make VCHI driver compatible with upstream DT

- Add compatibility string
- Compensate difference in base address between our custom DTB and upstream one

10 days agoMake BCM283x USB driver compatible with upstream DT
gonzo [Wed, 12 Oct 2016 03:07:49 +0000 (03:07 +0000)]
Make BCM283x USB driver compatible with upstream DT

- Make resource allocation logic depend on compatibility string
    to check what format of DTS node should be used - FreeBSD's or upstream

10 days agoMake BCM2835 GPIO driver compatible with upstream DT
gonzo [Wed, 12 Oct 2016 03:06:05 +0000 (03:06 +0000)]
Make BCM2835 GPIO driver compatible with upstream DT

- Add compatibility string
- Make reserverd and read-only properties optional

10 days agoAdd compatibility string from upstream DT
gonzo [Wed, 12 Oct 2016 03:03:55 +0000 (03:03 +0000)]
Add compatibility string from upstream DT

10 days agoMake framebuffer driver compatible with upstream DT
gonzo [Wed, 12 Oct 2016 03:03:05 +0000 (03:03 +0000)]
Make framebuffer driver compatible with upstream DT

- Add compatibility string
- Add simplebus as possible parent bus

10 days agoAdd compatible strings used in upstream dts files
gonzo [Wed, 12 Oct 2016 03:00:42 +0000 (03:00 +0000)]
Add compatible strings used in upstream dts files

10 days agoMake sure intc is attached before interrupt consumers
gonzo [Wed, 12 Oct 2016 02:58:27 +0000 (02:58 +0000)]
Make sure intc is attached before interrupt consumers

If pass order is not specified devices are attached in the order they are
defined in dts. Some interrupt consumers may be defined before intc. Also
make sure intc interrupt-parent local_intc is attached before intc itself.

10 days agoCurrently, when tcp_input() receives a packet on a session that matches a
jtl [Wed, 12 Oct 2016 02:30:33 +0000 (02:30 +0000)]
Currently, when tcp_input() receives a packet on a session that matches a
TCPCB, it checks (so->so_options & SO_ACCEPTCONN) to determine whether or
not the socket is a listening socket. However, this causes the code to
access a different cacheline. If we first check if the socket is in the
LISTEN state, we can avoid accessing so->so_options when processing packets
received for ESTABLISHED sessions.

If INVARIANTS is defined, the code still needs to access both variables to
check that so->so_options is consistent with the state.

Reviewed by: gallatin
MFC after: 1 week
Sponsored by: Netflix

10 days agoIn the TCP stack, the hhook(9) framework provides hooks for kernel modules
jtl [Wed, 12 Oct 2016 02:16:42 +0000 (02:16 +0000)]
In the TCP stack, the hhook(9) framework provides hooks for kernel modules
to add actions that run when a TCP frame is sent or received on a TCP
session in the ESTABLISHED state. In the base tree, this functionality is
only used for the h_ertt module, which is used by the cc_cdg, cc_chd, cc_hd,
and cc_vegas congestion control modules.

Presently, we incur overhead to check for hooks each time a TCP frame is
sent or received on an ESTABLISHED TCP session.

This change adds a new compile-time option (TCP_HHOOK) to determine whether
to include the hhook(9) framework for TCP. To retain backwards
compatibility, I added the TCP_HHOOK option to every configuration file that
already defined "options INET". (Therefore, this patch introduces no
functional change. In order to see a functional difference, you need to
compile a custom kernel without the TCP_HHOOK option.) This change will
allow users to easily exclude this functionality from their kernel, should
they wish to do so.

Note that any users who use a custom kernel configuration and use one of the
congestion control modules listed above will need to add the TCP_HHOOK
option to their kernel configuration.

Reviewed by: rrs, lstewart, hiren (previous version), sjg (makefiles only)
Sponsored by: Netflix
Differential Revision:

10 days agoifnet: Use if_link_state snapshot to invoke ifnet_link_event
sephe [Wed, 12 Oct 2016 01:52:29 +0000 (01:52 +0000)]
ifnet: Use if_link_state snapshot to invoke ifnet_link_event

So that everyone in this task have consistent view of link state.

Reviewed by: ae
MFC after: 1 week
Sponsored by: Microsoft
Differential Revision:

10 days agoUse correct size type in do_setopt_accept_filter
emaste [Wed, 12 Oct 2016 00:56:49 +0000 (00:56 +0000)]
Use correct size type in do_setopt_accept_filter

Submitted by:

10 days agoExtract suffix rules into bsd.suffixes[-posix].mk.
jonathan [Wed, 12 Oct 2016 00:42:46 +0000 (00:42 +0000)]
Extract suffix rules into bsd.suffixes[-posix].mk.

Refactor make suffix rules into separate files (one for POSIX and one not),
and rationalise the rules so that can contain only those rules
that are library-specific (.c.po and .c.pico).

This can be accomplished by adding ${STATIC_CFLAGS} to the .c.o rule
unconditionally. STATIC_CFLAGS are only defined for use by rules in
lib/libpam/ (see r227797), so it should be safe to include
them unconditionally in's .c.o rule (tested by make universe and a
ports exp-run).

Reviewed by: bdrewery, sjg
Approved by: rwatson (mentor)
Sponsored by: DARPA, AFRL
Differential Revision:

10 days agoInclude stubs even on the platforms we don't support so libsysdecode
imp [Tue, 11 Oct 2016 22:54:29 +0000 (22:54 +0000)]
Include stubs even on the platforms we don't support so libsysdecode
continues to build.

10 days agoProperly include the 802.11n PHY support files when the BWM_GPL_PHY
imp [Tue, 11 Oct 2016 22:32:12 +0000 (22:32 +0000)]
Properly include the 802.11n PHY support files when the BWM_GPL_PHY
option is included. Remove the comment suggesting that people
uncomment things because it is OBE.