18 hours agohyperv/storvsc: Increase queue depth and rework channel selection. master github/master
sephe [Thu, 25 Aug 2016 05:50:19 +0000 (05:50 +0000)]
hyperv/storvsc: Increase queue depth and rework channel selection.

- Increasing queue depth gives ~100% performance improvement for
  randwrite fio test in Azure.
- New channel selection, which takes LUN id and the current cpuid
  into consideration, gives additional ~20% performance improvement
  for ranwrite fio test in Azure.

Submitted by:   Hongzhang Jiang <honzhan microsoft com>
Modified by:    sephe
MFC after: 1 week
Sponsored by: Microsoft
Differential Revision:

18 hours agohyperv/vmbus: Add function to calculate max # of elements in a bufring.
sephe [Thu, 25 Aug 2016 05:35:51 +0000 (05:35 +0000)]
hyperv/vmbus: Add function to calculate max # of elements in a bufring.

MFC after: 1 week
Sponsored by: Microsoft

18 hours agoBump __FreeBSD_version for r304787 and add a note about it to UPDATING.
np [Thu, 25 Aug 2016 05:28:02 +0000 (05:28 +0000)]
Bump __FreeBSD_version for r304787 and add a note about it to UPDATING.

18 hours agohyperv/ic: Update total message size if negotiate message size grows.
sephe [Thu, 25 Aug 2016 05:24:57 +0000 (05:24 +0000)]
hyperv/ic: Update total message size if negotiate message size grows.

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

18 hours agoMake the iSCSI parameter negotiation more flexible.
np [Thu, 25 Aug 2016 05:22:53 +0000 (05:22 +0000)]
Make the iSCSI parameter negotiation more flexible.

Decouple the send and receive limits on the amount of data in a single
iSCSI PDU.  MaxRecvDataSegmentLength is declarative, not negotiated, and
is direction-specific so there is no reason for both ends to limit
themselves to the same min(initiator, target) value in both directions.

Allow iSCSI drivers to report their send, receive, first burst, and max
burst limits explicitly instead of using hardcoded values or trying to
derive all of them from the receive limit (which was the only limit
reported by the drivers prior to this change).

Display the send and receive limits separately in the userspace iSCSI

Reviewed by: jpaetzel@ (earlier version), trasz@
Sponsored by: Chelsio Communications
Differential Revision:

18 hours agohyperv/ic: Cleanup heartbeat channel callback.
sephe [Thu, 25 Aug 2016 05:11:04 +0000 (05:11 +0000)]
hyperv/ic: Cleanup heartbeat channel callback.

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

18 hours agohyperv/hn: Use vmbus xact for RNDIS initialize.
sephe [Thu, 25 Aug 2016 05:00:41 +0000 (05:00 +0000)]
hyperv/hn: Use vmbus xact for RNDIS initialize.

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

19 hours agohyperv/hn: Add compat code for RNDIS reorganization phase.
sephe [Thu, 25 Aug 2016 04:52:50 +0000 (04:52 +0000)]
hyperv/hn: Add compat code for RNDIS reorganization phase.

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

19 hours agohyperv/hn: Use definition in net/rndis.h for message type and status code.
sephe [Thu, 25 Aug 2016 04:40:51 +0000 (04:40 +0000)]
hyperv/hn: Use definition in net/rndis.h for message type and status code.

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

20 hours agoMake validation of the leap-seconds file unconditional.
cy [Thu, 25 Aug 2016 03:09:23 +0000 (03:09 +0000)]
Make validation of the leap-seconds file unconditional.

MFC after: 1 day

20 hours agoAdd logic to replace the working ntp leap-seconds file in /var/db
cy [Thu, 25 Aug 2016 02:58:41 +0000 (02:58 +0000)]
Add logic to replace the working ntp leap-seconds file in /var/db
if it contains a $FreeBSD$ header. The header will cause the file
to fail checksum of the hash causing ntpd to ignore the file.

MFC after: 1 day

21 hours agoChange the algorithm by which /var/db/leap-seconds is updated.
cy [Thu, 25 Aug 2016 02:45:52 +0000 (02:45 +0000)]
Change the algorithm by which /var/db/leap-seconds is updated.

1. Use the leap-seconds version number (update time) to determine
   whether to update the file or not.

2. If the version numbers of the files is the same, use the later
   expiry date to determine which file to use.

Suggested by: ian@
MFC after: 1 day

21 hours agoRevert r298887 (spelling fix) and remove $FreeBSD$ because text changes
cy [Thu, 25 Aug 2016 02:40:14 +0000 (02:40 +0000)]
Revert r298887 (spelling fix) and remove $FreeBSD$ because text changes
to leap-seconds invaldidates validation hash at the end of the file.

Remove svn:keywords and replace with fbsd:nokeywords=yes to
support this change.

MFC after: 1 day

24 hours agoIncrease the default rotation threshold of log files from 100kb to 1000kb
allanjude [Wed, 24 Aug 2016 23:02:20 +0000 (23:02 +0000)]
Increase the default rotation threshold of log files from 100kb to 1000kb

Submitted by: Sean Kelly <>
Differential Revision:

28 hours agoFlesh out the state and flags args to sccnopen(). Set state flags to
bde [Wed, 24 Aug 2016 18:59:24 +0000 (18:59 +0000)]
Flesh out the state and flags args to sccnopen().  Set state flags to
indicate (potentially partial) success of the open.  Use these to
decide what to close in sccnclose().  Only grab/ungrab use open/close
so far.

Add a per-sc variable to count successful keyboard opens and use
this instead of the grab count to decide if the keyboad state has
been switched.

Start fixing the locking by using atomic ops for the most important
counter -- the grab level one.  Other racy counting will eventually
be fixed by normal mutex or kdb locking in most cases.

Use a 2-entry per-sc stack of states for grabbing.  2 is just enough
to debug grabbing, e.g., for gets().  gets() grabs once and might not
be able to do a full (or any) state switch.  ddb grabs again and has
a better chance of doing a full state switch and needs a place to
stack the previous state.  For more than 3 levels, grabbing just
changes the count.  Console drivers should try to switch on every i/o
in case lower levels of nesting failed to switch but the current level
succeeds, but then the switch (back) must be completed on every i/o
and this flaps the state unless the switch is null.  The main point
of grabbing is to make it null quite often.  Syscons grabbing also
does a carefully chosen screen focus that is not done on every i/o.

Add a large comment about grabbing.

Restore some small lost comments.

30 hours agoReorganise a little to prepare for locking fixes:
bde [Wed, 24 Aug 2016 17:26:11 +0000 (17:26 +0000)]
Reorganise a little to prepare for locking fixes:
- in sccnopen(), open the keyboard before the screen.  The keyboard
  currently requires Giant (although it must be spinlocked to work
  correctly as a console), so the previous order would be a LOR if
  it has any semblance of locking.
- add a (currently dummy) state arg to scgetc().

30 hours agoDon't build libdevdctl if MK_CXX is no
emaste [Wed, 24 Aug 2016 17:15:32 +0000 (17:15 +0000)]
Don't build libdevdctl if MK_CXX is no

31 hours agoClose a race when making the CPU idle under pHyp. If an interrupt occurs
nwhitehorn [Wed, 24 Aug 2016 16:49:14 +0000 (16:49 +0000)]
Close a race when making the CPU idle under pHyp. If an interrupt occurs
between the beginning of the idle function and actually going idle, the
CPU could go to sleep with pending work.

MFC after: 1 month

31 hours agoUse current locale (f.e. set by thread). It was global locale always
ache [Wed, 24 Aug 2016 16:44:27 +0000 (16:44 +0000)]
Use current locale (f.e. set by thread). It was global locale always

MFC after:      7 days

31 hours agoBug 212038 - svn commit: r304321 broken bhyve zvol VM bhyveload hang 100% WCPU
tsoome [Wed, 24 Aug 2016 16:40:29 +0000 (16:40 +0000)]
Bug 212038 - svn commit: r304321 broken bhyve zvol VM bhyveload hang 100% WCPU

As the support for large blocks was enabled in loader zfs code, the
heap in userboot was left not changed, resulting with failure of detecting
and accessing zfs pools for bhyve virtual machines.

This fix does set the heap to use same amount of memory as the zfsloader
is using. To make it possible to test and verify loader functions, bhyve
is providing very useful option, but it also means, we like to keep feature
parity with [zfs]loader as close as possible.

PR: 212038
Reported by:
Reviewed by: allanjude, grehan
Approved by: allanjude (mentor)
Differential Revision:

31 hours agoBug 212114 - loader: zio_checksum_verify() must test spa for NULL pointer
tsoome [Wed, 24 Aug 2016 16:30:15 +0000 (16:30 +0000)]
Bug 212114 - loader: zio_checksum_verify() must test spa for NULL pointer

The issue was introduced with adding support for salted checksums, and
was revealed by bhyve

During pool discovery the loader is reading pool label from disks, and
at that time the spa structure is not yet set up, so the NULL pointer
is passed for spa. This condition must be checked to avoid the corruption
of the memory and NULL pointer dereference.

PR: 212114
Reported by:
Reviewed by: allanjude
Approved by: allanjude (mentor)
Differential Revision:

32 hours agoBump __FreeBSD_version for LC_*_MASK fix for newlocale(3) and querylocale(3)
ache [Wed, 24 Aug 2016 15:36:48 +0000 (15:36 +0000)]
Bump __FreeBSD_version for LC_*_MASK fix for newlocale(3) and querylocale(3)

32 hours agoFix minor copy/paste bug.
mav [Wed, 24 Aug 2016 15:13:42 +0000 (15:13 +0000)]
Fix minor copy/paste bug.

Submitted by: Dmitry Luhtionov <>
MFC after: 1 week

34 hours agoAllow superpages on arm64 to be enabled. It is disabled for now to allow
andrew [Wed, 24 Aug 2016 13:00:50 +0000 (13:00 +0000)]
Allow superpages on arm64 to be enabled. It is disabled for now to allow
for more testing across more hardware.

Obtained from: ABT Systems Ltd
MFC after: 1 month
Sponsored by: The FreeBSD Foundation

34 hours agoAdd support to promote and demote managed superpages. This is the last part
andrew [Wed, 24 Aug 2016 12:57:40 +0000 (12:57 +0000)]
Add support to promote and demote managed superpages. This is the last part
needed before enabling superpages on arm64. This code is based on the amd64
pmap with changes as needed to handle the differences between the two

Obtained from: ABT Systems Ltd
MFC after: 1 month
Sponsored by: The FreeBSD Foundation

35 hours agoDocument the existence of the cloudabi32 kernel module.
ed [Wed, 24 Aug 2016 12:53:54 +0000 (12:53 +0000)]
Document the existence of the cloudabi32 kernel module.

35 hours agoMFV r304732.
cy [Wed, 24 Aug 2016 12:32:24 +0000 (12:32 +0000)]
MFV r304732.

Update from sqlite3-3.12.1 (3120100) to sqlite3-3.14.1 (3140100).

This commit addresses the tmpdir selection vulnerability fixed in
sqlite3-1.13.0.  See VuXML entry 546deeea-3fc6-11e6-a671-60a44ce6887b.

Security: VuXML 546deeea-3fc6-11e6-a671-60a44ce6887b
Security: CVE-2016-6153

35 hours agoTeach the parts of the arm64 pmap that need to iterate over pages to also
andrew [Wed, 24 Aug 2016 12:32:18 +0000 (12:32 +0000)]
Teach the parts of the arm64 pmap that need to iterate over pages to also
iterate over superpages. We don't yet create these, but soon will.

Obtained from: ABT Systems Ltd
MFC after: 1 month
Sponsored by: The FreeBSD Foundation

36 hours agoAdd a Makefile for building the cloudabi32 kernel module.
ed [Wed, 24 Aug 2016 11:35:49 +0000 (11:35 +0000)]
Add a Makefile for building the cloudabi32 kernel module.

Where the cloudabi64 kernel can be used to execute 64-bit CloudABI
binaries, this one should be used for 32-bit binaries. Right now it
works on i386 and amd64.

37 hours agoMake execution of 32-bit CloudABI executables work on amd64.
ed [Wed, 24 Aug 2016 10:51:33 +0000 (10:51 +0000)]
Make execution of 32-bit CloudABI executables work on amd64.

A nice thing about requiring a vDSO is that it makes it incredibly easy
to provide full support for running 32-bit processes on 64-bit systems.
Instead of letting the kernel be responsible for composing/decomposing
64-bit arguments across multiple registers/stack slots, all of this can
now be done in the vDSO. This means that there is no need to provide
duplicate copies of certain system calls, like the sys_lseek() and
freebsd32_lseek() we have for COMPAT_FREEBSD32.

This change imports a new vDSO from the CloudABI repository that has
automatically generated code in it that copies system call arguments
into a buffer, padding them to eight bytes and zero-extending any
pointers/size_t arguments. After returning from the kernel, it does the
inverse: extracting return values, in the process truncating
pointers/size_t values to 32 bits.

Obtained from:

37 hours agoRemove an unused header file.
ed [Wed, 24 Aug 2016 10:36:52 +0000 (10:36 +0000)]
Remove an unused header file.

The native CloudABI data types header file used to be pulled in by the
vDSOs when they were still written in C. Since they are now all
rewritten in assembly, this can go away.

37 hours agoConvert pointers obtained from the threadattr_t structure with TO_PTR().
ed [Wed, 24 Aug 2016 10:13:18 +0000 (10:13 +0000)]
Convert pointers obtained from the threadattr_t structure with TO_PTR().

In all of these source files, the userspace pointer size corresponds
with the kernelspace pointer size, meaning that casting directly works.
As I'm planning on making 32-bit execution on 64-bit systems work as
well, use TO_PTR() here as well, so that the changes between source
files remain minimal.

37 hours agoSkip ls tests that use sparse files if these are not supported.
jmmv [Wed, 24 Aug 2016 10:10:26 +0000 (10:10 +0000)]
Skip ls tests that use sparse files if these are not supported.

Some of the ls(1) tests create really large sparse files to validate
the number formatting features of ls(1).  Unfortunately, those tests fail
if the underlying test file system does not support sparse files, as is the
case when /tmp is mounted on tmpfs.

Before running these tests, check if the test file system supports sparse
files by using getconf(1) and skip them if not.  Note that the support for
this query was just added to getconf(1) in r304694.

Reviewed by: ngie
Differential Revision:

37 hours agoAdd missing header dependency.
ed [Wed, 24 Aug 2016 09:57:19 +0000 (09:57 +0000)]
Add missing header dependency.

This header depends on sigaltstack32 being declared.

41 hours agoWhen aborting an association, send the ABORT before notifying the upper
tuexen [Wed, 24 Aug 2016 06:22:53 +0000 (06:22 +0000)]
When aborting an association, send the ABORT before notifying the upper
layer. For the kernel this doesn't matter, for the userland stack, it does.
While there, silence a clang warning when compiling it in userland.

42 hours agoFix key delay and repeat, part 2.
bde [Wed, 24 Aug 2016 05:54:11 +0000 (05:54 +0000)]
Fix key delay and repeat, part 2.

Use sbintime_t timeouts with precision control to get very accurate
timing.  It costs little to always ask for about 1% accuracy, and the
not so new event timer implementation usual delivers that, and when
it can't it gets much closer than our previous coarse timeouts and
buggy simple countdown.

The 2 fastest atkbd repeat rates have periods 34 and 38 msec, and ukbd
pretended to support rates in between these.  This requires
sub-microsecond precision and accuracy even to handle the 4 msec
difference very well, but ukbd asked the timeout subsystem for timeouts
of 25 msec and the buggy simple countdown of this gave a a wide range
of precisions and accuracies depending on HZ and other timer
configuration (sometimes better than 25 msec but usually more like 50
msec).  We now ask for and usually get precision and accuracy of about
1% for each repeat and much better on average.

The 1% accuracy is overkill.  Rounding of 30 cps to 34 msec instead of
33 already gives an error of +2% instead of -1%, and ut AT keyboards on
PS/2 interfaces have similar errors.

A timeout is now scheduled for every keypress and release.  This allows
some simplifications that are not done.  It allows removing the timeout
scheduling for exiting polled mode where it was unsafe in ddb mode.  This
is done.  Exiting polled mode had some problems with extra repeats.  Now
exiting polled mode lets an extra timeout fire and the state is fudged
so that the timeout handler does very little.

The sc->time_ms variable is unsigned to avoid overflow.  Differences of
it need to be signed.  Signed comparisons were emulated by testing an
emulated sign bits.  This only works easily for '<' comparisonss, but
we now need a '<=' comparison.  Change the difference variable to
signed and use a signed comparison.  Using unsigned types here didn't
prevent overflow bugs but just reduced them.  Overflow occurs with
n repeats at the silly repeat period of [U]INT_MAX / n.  The old countdown
had an off by 1 error, and the simplifications would simply count down
1 to 0 and not need to accumulate possibly-large repeat repeats.

42 hours agoImport sqlite3-3.14.1 (3140100)
cy [Wed, 24 Aug 2016 04:57:29 +0000 (04:57 +0000)]
Import sqlite3-3.14.1 (3140100)

43 hours agohyperv/ic: Redefine IC version negotiate message.
sephe [Wed, 24 Aug 2016 04:36:04 +0000 (04:36 +0000)]
hyperv/ic: Redefine IC version negotiate message.

And stringent input IC version negotiate message checks.

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

43 hours agohyperv/hn: Log a warning for RESET_CMPLT.
sephe [Wed, 24 Aug 2016 04:21:15 +0000 (04:21 +0000)]
hyperv/hn: Log a warning for RESET_CMPLT.

RESET is not used by the hn(4) at all, and RESET_CMPLT does not even
have a rid to match with the pending requests.  So, let's put it
onto an independent switch branch and log a warning about it.

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

44 hours agoFix system hang when large FDT is in use
jhibbits [Wed, 24 Aug 2016 03:51:40 +0000 (03:51 +0000)]
Fix system hang when large FDT is in use

Kernel maps only one page of FDT. When FDT is more than one page in size, data
TLB miss occurs on memmove() when FDT is moved to kernel storage
(sys/powerpc/booke/booke_machdep.c, booke_init())

This introduces a pmap_early_io_unmap() to complement pmap_early_io_map(), which
can be used for any early I/O mapping, but currently is only used when mapping
the fdt.

Submitted by: Ivan Krivonos <>
Differential Revision:

44 hours agoBring datasheet URL up to date.
kevlo [Wed, 24 Aug 2016 03:44:16 +0000 (03:44 +0000)]
Bring datasheet URL up to date.

44 hours agohyperv/hn: Remove the redundant rid setting for RNDIS HALT.
sephe [Wed, 24 Aug 2016 03:28:58 +0000 (03:28 +0000)]
hyperv/hn: Remove the redundant rid setting for RNDIS HALT.

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

44 hours agonet/rndis: Fix RNDIS_STATUS_PENDING definition.
sephe [Wed, 24 Aug 2016 03:16:25 +0000 (03:16 +0000)]
net/rndis: Fix RNDIS_STATUS_PENDING definition.

While I'm here, sort the RNDIS status in ascending order.

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

44 hours agonet/rndis: Add canonical RNDIS major/minor version as of today.
sephe [Wed, 24 Aug 2016 03:08:13 +0000 (03:08 +0000)]
net/rndis: Add canonical RNDIS major/minor version as of today.

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

45 hours agoFixup man page formatting.
cy [Wed, 24 Aug 2016 02:41:24 +0000 (02:41 +0000)]
Fixup man page formatting.

Submitted by: Steve Kargl <>
Discussed with: bjk@
MFC after: 3 days

47 hours agoFix L2 caching for UDP over IPv6
karels [Wed, 24 Aug 2016 00:52:30 +0000 (00:52 +0000)]
Fix L2 caching for UDP over IPv6

ip6_output() was missing cache invalidation code analougous to
ip_output.c. r304545 disabled L2 caching for UDP/IPv6 as a workaround.
This change adds the missing cache invalidation code and reverts

Reviewed by: gnn
Approved by: gnn (mentor)
Tested by: peter@, Mike Andrews
MFC after: 3 weeks
Differential Revision:

47 hours agoAvoid a redecleartion of __getosreldate().
brooks [Wed, 24 Aug 2016 00:02:20 +0000 (00:02 +0000)]
Avoid a redecleartion of __getosreldate().

Sponsored by: DARPA, AFRL

47 hours agoSpell MIPS more traditionally in "bfd_elf32_ntradbigmips_vec".
brooks [Wed, 24 Aug 2016 00:00:54 +0000 (00:00 +0000)]
Spell MIPS more traditionally in "bfd_elf32_ntradbigmips_vec".

Sponsored by: DAPRA, AFRL

2 days agoAllwinner: Add thermal sensor driver for A10/A20
manu [Tue, 23 Aug 2016 22:26:50 +0000 (22:26 +0000)]
Allwinner: Add thermal sensor driver for A10/A20
The thermal sensor lives in the touch screen controller. Touch screen part
isn't done for now.
Temperature is read every ~2 seconds and exposed via sysctl.

2 days agoLC_*_MASK bit shifting order was partially broken from the initial commit
ache [Tue, 23 Aug 2016 20:33:56 +0000 (20:33 +0000)]
LC_*_MASK bit shifting order was partially broken from the initial commit
time at year 2012. Only LC_COLLATE_MASK and LC_CTYPE_MASK are in the
right order.

The order here should match XLC_* from "xlocale_private.h" which, in turn,
match LC_* publicly visible order from <locale.h> which determines how
locale components are stored in the structure.
LC_*_MASK -> XLC_* translation done as "ffs(mask) - 1" in the querylocale()
and equivalent shift loop in the newlocale(), so mapped to some wrong
components (excluding two mentioned above).

Formally the fix is ABI breakage, but old code using those masks
never works properly in any case.
Only newlocale() and querylocale() are affected.

MFC after:      7 days

2 days agoThe -f check here is used to determine whether we have a single kernel
glebius [Tue, 23 Aug 2016 20:04:23 +0000 (20:04 +0000)]
The -f check here is used to determine whether we have a single kernel
config or a list of them.  Put the variable into quotes, to avoid syntax
error from [ in case of list.  Without this change list is still working,
but an error is reported in the build log file.

Reviewed by: imp

2 days agoFix key delay and repeat, part 1.
bde [Tue, 23 Aug 2016 19:50:16 +0000 (19:50 +0000)]
Fix key delay and repeat, part 1.

kbdcontrol -r fast is documented to give a non-emulated atkbd's fastest
rate of 250.34, but is misimplemented to request this as 0.0.  ukbd
supports many nonstandard rates, although it is currently too inaccurate
by a factor of several hundred for non-huge nonstandard rates to be
useful.  It mapped 0.0 to 200.0.  A repeat delay of 0 means a rate of
infinity which is quite fast, but physical constraints limit this to
a few MHz and the inaccuracies made it almost usable.

Convert 0.0 to the documented 250.34.

Also convert negative args and small args to the 250.34 minimal ones,
like atkbd does.  This is for KDSETREPEAT -- the 2 versions of the
deprecated KDSETRAD have bounds checking.  Keep not doing any bounds
checking or conversions for upper limits since nonstandard large
delays are useful for testing.

The inaccuracies are dependent on HZ and the timeout implementation.
With the old timeout implementation and HZ = 1000, 200.0 probably
worked better to emulate 250.34 than 250.34 itself.  HZ = 100 gives
roundoff errors that accidentally reduce the inaaccuracies, and
event timers reduce the inaccuracies even more, so 200.0 was giving
more like itself (perhaps 215.15 on average but sometimes close to
10 msec repeat which is noticebly too fast).  This commit makes 0.0
noticeably too slow, like 250.34 always was.

2 days agoAdd support for _PC_ACL_NFS4 as TRUSTEDBSD_ACL_NFS4
ngie [Tue, 23 Aug 2016 19:41:49 +0000 (19:41 +0000)]
Add support for _PC_ACL_NFS4 as TRUSTEDBSD_ACL_NFS4

The TRUSTEDBSD prefix was chosen for consistency with the other
related `_PC_ACL*` prefixed variables.

MFC after: 3 days
Sponsored by: EMC / Isilon Storage Division

2 days agoFAST_DEPEND: Fix 'make all install' not properly rebuilding based on .depend.* files.
bdrewery [Tue, 23 Aug 2016 19:37:18 +0000 (19:37 +0000)]
FAST_DEPEND: Fix 'make all install' not properly rebuilding based on .depend.* files.

An optimization is in place to skip reading the .depend.* files with
'make install'.  This was too strong and broke 'make all install' and
'make foo.o foo install'.  Now only skip reading the dependency files
if all make targets ran are install targets.

The problem comes about because headers are only added in as a guessed
dependency if .depend.* files do not yet exist.  If they do exist, even
if being skipped from being read, then the header dependencies are not
applied.  This applies to all #included files, and not just headers.

Reported by: kib
MFC after: 1 day
Sponsored by: EMC / Isilon Storage Division

2 days agoIn addition to creating subdirectories under .OBJDIR for SRCS with
dim [Tue, 23 Aug 2016 19:31:43 +0000 (19:31 +0000)]
In addition to creating subdirectories under .OBJDIR for SRCS with
relative paths, also create them for DPSRCS.  This is needed for builds
that generate files during the depend stage, which cannot be compiled by
themselves, since those have to be put in DPSRCS.

2 days agoFix in-tree GCC builds after r304681.
bdrewery [Tue, 23 Aug 2016 19:29:37 +0000 (19:29 +0000)]
Fix in-tree GCC builds after r304681.

There were a few issues.
- In-tree GCC won't have X_COMPILER_TYPE defined but will have
  WANT_COMPILER_TYPE==gcc set from the SYSTEM_COMPILER logic that can
  be used.  Make the clang check specific to clang as well to ensure
  -target doesn't leak into a GCC build.
- When using a cross-compiler GCC (with a default sysroot or arch) and also
  passing --sysroot, it basically forgets all internal paths for
  libraries.  We've already worked around this quite a bit for
  the external toolchains.  Now for the in-tree bootstrap cross-compiler
  GCC, also pass in the needed -B${WORLDTMP}/usr/lib to find the crt
  object files, but also -isystem and -L to fix the paths.  This creates
  quite a spammy build log, but it is clear and still achieves the goals
  and stays consistent between internal and external build flags.
  Reducing the spam by using the '=' prefix feature will help and be
  done later.

MFC after: 3 days
X-MFC-With: r304681
Reported by: bz
Pointyhat to: bdrewery
Sponsored by: EMC / Isilon Storage Division

2 days agoAdd `MIN_HOLE_SIZE` pathconf(2) support to getconf
ngie [Tue, 23 Aug 2016 19:28:01 +0000 (19:28 +0000)]
Add `MIN_HOLE_SIZE` pathconf(2) support to getconf

This allows shell programs to programmatically determine whether
or not a filesystem supports sparse files

MFC after: 3 days
Sponsored by: EMC / Isilon Storage Division

2 days agoClean up trailing whitespace
ngie [Tue, 23 Aug 2016 19:15:01 +0000 (19:15 +0000)]
Clean up trailing whitespace

MFC after: 3 days
Sponsored by: EMC / Isilon Storage Division

2 days agobhndb(4): Fix unsigned integer underflow in dynamic register window
landonf [Tue, 23 Aug 2016 19:03:11 +0000 (19:03 +0000)]
bhndb(4): Fix unsigned integer underflow in dynamic register window
handling. This resulted in the window target being left uninitialized
when an underflow occured.

Approved by: adrian (mentor)
Differential Revision:

2 days agobspatch: apply style(9)
emaste [Tue, 23 Aug 2016 17:42:03 +0000 (17:42 +0000)]
bspatch: apply style(9)

Make style changes (and trivial refactoring of open calls) now in order
to reduce noise in diffs for future capsicum changes.

Reviewed by: oshogbo
No objection: cperciva
Sponsored by: The FreeBSD Foundation
Differential Revision:

2 days agoAlso adjust the virtual address passed to vm_page_pa_tryrelock.
andrew [Tue, 23 Aug 2016 16:37:34 +0000 (16:37 +0000)]
Also adjust the virtual address passed to vm_page_pa_tryrelock.

Reported by: alc
Obtained from: ABT Systems Ltd
MFC after: 1 month
Sponsored by: The FreeBSD Foundation

2 days agoMap memory as read-only in pmap_enter_quick_locked as is done in other
andrew [Tue, 23 Aug 2016 16:20:56 +0000 (16:20 +0000)]
Map memory as read-only in pmap_enter_quick_locked as is done in other
pmap implementations.

Obtained from: ABT Systems Ltd
MFC after: 1 month
Sponsored by: The FreeBSD Foundation

2 days agoIf we find we have a superpage in pmap_enter_quick_locked return without
andrew [Tue, 23 Aug 2016 16:12:25 +0000 (16:12 +0000)]
If we find we have a superpage in pmap_enter_quick_locked return without
trying to add a new level 3 page.

Obtained from: ABT Systems Ltd
MFC after: 1 month
Sponsored by: The FreeBSD Foundation

2 days agoindent(1): have the memset invocation somewhat more canonical.
pfg [Tue, 23 Aug 2016 15:49:31 +0000 (15:49 +0000)]
indent(1): have the memset invocation somewhat more canonical.

While correct, the previous invocation was somewhat more error prone.

Pointed out by: delphij, bde

2 days agoInclude the offset the virtual address is within an L1 or L2 block when
andrew [Tue, 23 Aug 2016 15:48:27 +0000 (15:48 +0000)]
Include the offset the virtual address is within an L1 or L2 block when
finding the vm_page_t in pmap_extract_and_hold. Previously it would return
the vm_page_t of the first page in a block. This would cause issues when,
for example, fsck reads from a device into the middle of a superpage. In
this case the read call would write to the start of the block, and not to
the buffer passed in.

Obtained from: ABT Systems Ltd
MFC after: 1 month
Sponsored by: The FreeBSD Foundation

2 days agoindent(1): remove dead assignments.
pfg [Tue, 23 Aug 2016 15:46:20 +0000 (15:46 +0000)]
indent(1): remove dead assignments.

Taken from: Piotr Sephaniak

2 days agoRegenerate
bdrewery [Tue, 23 Aug 2016 15:31:53 +0000 (15:31 +0000)]

bdrewery [Tue, 23 Aug 2016 15:22:17 +0000 (15:22 +0000)]

This was disabled in r301468 due to -target/--sysroot sometimes being used in
the build and other times not being used.  Now that it is always used since
r304681, it is safe to combine the features.

MFC after: 3 days
Sponsored by: EMC / Isilon Storage Division

2 days agoAlways pass in -target and --sysroot flags for the build.
bdrewery [Tue, 23 Aug 2016 15:20:32 +0000 (15:20 +0000)]
Always pass in -target and --sysroot flags for the build.

The internal bootstrap compiler has a default sysroot set by TOOLS_PREFIX
and target set by TARGET/TARGET_ARCH.  However, there are several needs to
always pass an explicit --sysroot and -target.
- External compiler needs sysroot and target flags.
- External ld needs sysroot.
- To be clear about the use of a sysroot when using the internal compiler.
- Easier debugging.
- Allowing WITH_SYSTEM_COMPILER+WITH_META_MODE to work together due to
  the flip-flopping build command when sometimes using external and
  sometimes using internal.
- Allow using no lld which has support for default paths.

The default sysroot in the bootstrap compiler is not changed.  The
buildenv compiler will still work with its default and will also
include -target/--sysroot from CC in the environment.

MFC after: 3 days
Discussed with: emaste, brooks (BSDCam)
Reviewed by: emaste
Sponsored by: EMC / Isilon Storage Division

2 days agoEFI loader: only open/close on the net device with tftpfs
bapt [Tue, 23 Aug 2016 13:53:38 +0000 (13:53 +0000)]
EFI loader: only open/close on the net device with tftpfs

It prevents issuing a dhcp request before each file open
As a consequence netbooting over tftpfs is significantly faster

Sponsored by:

2 days agoUse roundup2() from sys/param.h.
araujo [Tue, 23 Aug 2016 13:43:43 +0000 (13:43 +0000)]
Use roundup2() from sys/param.h.

2 days agoAdd tftpfs support for the EFI loader
bapt [Tue, 23 Aug 2016 13:35:48 +0000 (13:35 +0000)]
Add tftpfs support for the EFI loader

Allow netbooting on efi without having to setup any NFS server by rebuilding the
loader with LOADER_TFTP_SUPPORT like for the i386 pxeloader

Sponsored by:

2 days agoFix calloc(3) argument order.
araujo [Tue, 23 Aug 2016 13:19:42 +0000 (13:19 +0000)]
Fix calloc(3) argument order.

MFC after: 4 weeks.

2 days agointpm: add support for SB800
avg [Tue, 23 Aug 2016 10:40:53 +0000 (10:40 +0000)]
intpm: add support for SB800

This code should be able to support later AMD chipsets as well, but that
hasn't been tested.

SB800 supports accessing several different SMBus buses using the same
set of constrol registeirs plus special PMIO registers that control which
bus is selected.  This could be exposed to consumers as several smb devices
each talking to its bus.  This feature is not implemented yet.

MFC after: 2 weeks

2 days agotlb1_init() can be called twice on BookE
jhibbits [Tue, 23 Aug 2016 04:37:03 +0000 (04:37 +0000)]
tlb1_init() can be called twice on BookE

There is no need to call tlb1_init() twice. Now it is called first time from
booke_init() and second time from powerpc_init() (where it is under BOOKE
switch). Although this does not cause immediate problems in the mainline kernel,
this can lead to undesirable side effects like two TLB entries with the same VA
in the TLB1. Presence of two TLB entries with the same VA can hang CPU.

Test Plan:
Add initial mapping for UART to the tlb1_init(), build and boot the kernel,
ensure that mapping presents only once (most convinient way - through Lauterbah
or similar hardware debugger)

Submitted by: Ivan Krivonos <>
Differential Revision:

2 days agoTake into account mas7/8 when reading/writing TLB entries on e6500
jhibbits [Tue, 23 Aug 2016 04:26:30 +0000 (04:26 +0000)]
Take into account mas7/8 when reading/writing TLB entries on e6500

Summary: Current booke/pmap code ignores mas7 and mas8 on e6500 CPU.

Submitted by: Ivan Krivonos <>
Differential Revision:

2 days agonet: Split RNDIS protocol structs/macros out of dev/usb/net/if_urndisreg.h
sephe [Tue, 23 Aug 2016 02:54:06 +0000 (02:54 +0000)]
net: Split RNDIS protocol structs/macros out of dev/usb/net/if_urndisreg.h

So that Hyper-V can leverage them instead of rolling its own definition.

Discussed with: hps
Reviewed by: hps
MFC after: 1 week
Sponsored by: Microsoft
Differential Revision:

2 days agoindent(1): Fix off-by-one in control flow leading dead code.
pfg [Tue, 23 Aug 2016 02:07:08 +0000 (02:07 +0000)]
indent(1): Fix off-by-one in control flow leading dead code.

Coverity correctly reported that it's impossible for /comparison/ to be 0
here, because the only way for the for loop to end is by /comparison/
being < 0.

Fortunately the consequences of this bug weren't severe; for duplicated
entries in the typedef names file it would unnecessarily duplicate strings
with strdup(), but pointers to those would replace existing ones. So this
was a memory leak at worst.

CID:  1361477
Obtained from:  Piotr Stephaniak

2 days agoFix missing substitution of @SBINDIR@ in resolvconf scripts
badger [Tue, 23 Aug 2016 02:06:20 +0000 (02:06 +0000)]
Fix missing substitution of @SBINDIR@ in resolvconf scripts

Certain features, such as resolv_conf_passthrough=NULL, do not work
correctly due to this missing substitution.

Also remove the @PREFIX@ substitution, which is no longer needed.

Reviewed by: pfg
Approved by: vangyzen (mentor)
MFC after: 1 week
Sponsored by: Dell Inc.
Differential Revision:

2 days agoindent(1): add some comments to quiet down Coverity.
pfg [Tue, 23 Aug 2016 01:58:02 +0000 (01:58 +0000)]
indent(1): add some comments to quiet down Coverity.

Hopefully adding comments should help explain the code to both static
checkers and humans.

CID: 976543, 976544, 976545
Obtained from: Piotr Stephaniak

2 days agoindent(1): Fix memory leaks pointed out by clang-analyzer.
pfg [Tue, 23 Aug 2016 01:40:45 +0000 (01:40 +0000)]
indent(1): Fix memory leaks pointed out by clang-analyzer.

Shift the responsibility of allocating memory for the string duplicate
from the caller (set_option, add_typedefs_from_file) to the callee
(add_typename) as it has more knowledge about when the duplication
actually needs to occur.

Taken from: Piotr Stefaniak

2 days agoDo not include file from dt-bindings and simply use the already present defines.
manu [Tue, 23 Aug 2016 00:46:22 +0000 (00:46 +0000)]
Do not include file from dt-bindings and simply use the already present defines.

Reported by: jmcneill
MFC after: 1 week

3 days agoRename ORDERED to BOOTSTRAP since no order is respected in the list.
bdrewery [Mon, 22 Aug 2016 22:51:10 +0000 (22:51 +0000)]
Rename ORDERED to BOOTSTRAP since no order is respected in the list.

The directories in SUBDIR_ORDERED are built in parallel, so the name is

MFC after: 3 days
Sponsored by: EMC / Isilon Storage Division

3 days agoFor 'make <directory>' hook into the all_subdir_<directory> targets.
bdrewery [Mon, 22 Aug 2016 22:51:07 +0000 (22:51 +0000)]
For 'make <directory>' hook into the all_subdir_<directory> targets.

This fixes parallel build issues when trying to depend on ${SUBDIR}.  An
example of this in share/i18n/csmapper/Makefile where mapper.dir depends
on ${SUBDIR} having been traversed and built already.  Before this
change running make in that directory would build the subdirectories
twice.  This led to obscure build races.  While reworking that build
may be possible, the framework should not so easily allow creating such

Now depending on <directory> will properly redirect to the
all_subdir_<directory> target rather than invoking the inline shell.

This also makes 'make -jX <directory>' now respect any
SUBDIR_DEPEND_<directory> statements when SUBDIR_PARALLEL is defined.
This is not entirely intended and may be changed later.

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

3 days agoAlways define the various <target>_subdir_<directory> targets, even if not used.
bdrewery [Mon, 22 Aug 2016 22:51:04 +0000 (22:51 +0000)]
Always define the various <target>_subdir_<directory> targets, even if not used.

This is part of an effort to cleanup handling of some edge cases
involving 'make <directory>'.  It also provides the targets for
other uses.

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

3 days agoStop using _SUBDIR internally for non-SUBDIR_PARALLEL builds.
bdrewery [Mon, 22 Aug 2016 22:51:01 +0000 (22:51 +0000)]
Stop using _SUBDIR internally for non-SUBDIR_PARALLEL builds.

This is unifying more of the logic.  Rather than create targets such
as 'all: all_subdir_foo' when using SUBDIR_PARALLEL and using
'all: _SUBDIR' when not using SUBDIR_PARALLEL, always use the
expanded out <target>_subdir_<directory> pattern.  When not using
SUBDIR_PARALLEL, have each directory-target depend on the previously
defined targets as to respect the *order* of SUBDIR.

Using 'make -N' now prints all directory traversals individually rather
than using a loop, since a loop is no longer used to traverse.

This is part of an effort to cleanup handling of some edge cases
involving 'make <directory>' and making it simpler in the sense
that the pattern used to build is the same for all modes.

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

3 days agoFix building on read-only source trees.
bdrewery [Mon, 22 Aug 2016 22:50:58 +0000 (22:50 +0000)]
Fix building on read-only source trees.

This partially reverts r296702 and reworks the original check to only
look in .CURDIR.  This avoids ever trying to rebuild a .src file that is
already in the source tree as an override.

PR: 211952
MFC after: 3 days
Sponsored by: EMC / Isilon Storage Division

3 days ago1) Back out r304607 case 2). fgetwln() as its pair fgetln() supposed to
ache [Mon, 22 Aug 2016 22:28:41 +0000 (22:28 +0000)]
1) Back out r304607 case 2). fgetwln() as its pair fgetln() supposed to
return partial line on any errors. See the comment in fgetln.c.
Add corresponding comment to fgetwln() too.
2) Rewrite r304607 case 1).
3) Remove "Fast path" from __fgetwc_mbs() since it can't detect encoding
errors and ignores them all.

PR:     212033
MFC after:      7 days

3 days agoPrefer C-style comments in assembly sources.
jkim [Mon, 22 Aug 2016 21:49:17 +0000 (21:49 +0000)]
Prefer C-style comments in assembly sources.

3 days agoFix white spaces in assembly sources.
jkim [Mon, 22 Aug 2016 21:30:59 +0000 (21:30 +0000)]
Fix white spaces in assembly sources.

3 days agoFix build for !SMP kernels after the Xen MSIX workaround.
jhb [Mon, 22 Aug 2016 21:23:17 +0000 (21:23 +0000)]
Fix build for !SMP kernels after the Xen MSIX workaround.

Move msix_disable_migration under #ifdef SMP since it doesn't make sense
for !SMP kernels.

PR: 212014
Reported by: Glyn Grinstead <>
MFC after: 3 days

3 days agoBuild OpenSSL assembly sources for arm. Tested with Raspberry Pi 2 Model B.
jkim [Mon, 22 Aug 2016 20:59:34 +0000 (20:59 +0000)]
Build OpenSSL assembly sources for arm.  Tested with Raspberry Pi 2 Model B.

MFC after: 1 week

3 days agoRemove support for SSH1 as it is already disabled in our OpenSSH.
roberto [Mon, 22 Aug 2016 20:48:46 +0000 (20:48 +0000)]
Remove support for SSH1 as it is already disabled in our OpenSSH.

Submitted by: vangyzen
MFC after: 2 weeks

3 days agoDon't separate the status stage of the XHCI USB control transfers into
hselasky [Mon, 22 Aug 2016 19:32:50 +0000 (19:32 +0000)]
Don't separate the status stage of the XHCI USB control transfers into
its own job because this breaks the simplified QEMU XHCI TRB parser,
which expects the complete USB control transfer as a series of back to
back TRBs. The old behaviour is kept under #ifdef in case this change
breaks enumeration of any USB devices.

PR: 212021
MFC after: 1 week

3 days agoAdd support for Ed25519 keys.
roberto [Mon, 22 Aug 2016 19:27:20 +0000 (19:27 +0000)]
Add support for Ed25519 keys.

Reported by: mwlucas
MFH: 2 weeks

3 days agoFix the arm64 non-SMP build, active_irq is a uint64_t so cast it through
andrew [Mon, 22 Aug 2016 19:05:11 +0000 (19:05 +0000)]
Fix the arm64 non-SMP build, active_irq is a uint64_t so cast it through
a uintmax_t.

Obtained from: ABT Systems Ltd
MFC after: 1 week
Sponsored by: The FreeBSD Foundation

3 days agoRemove duplicate symbol from libhx509
emaste [Mon, 22 Aug 2016 18:50:57 +0000 (18:50 +0000)]
Remove duplicate symbol from libhx509

Upstream commit r21331 (7758a5d0) added semiprivate function
_hx509_request_to_pkcs10 twice. This change has been committed upstream
as 8ef0071d.

3 days agoFix building for ARM kernel that have FLASHADDR, PHYSADDR and LOADERRAMADDR defined.
manu [Mon, 22 Aug 2016 18:33:56 +0000 (18:33 +0000)]
Fix building for ARM kernel that have FLASHADDR, PHYSADDR and LOADERRAMADDR defined.

Pointy Hat: myself

Reported by: bz

3 days agoEnsure map is valid, even before userland exists and the fault address
andrew [Mon, 22 Aug 2016 18:19:46 +0000 (18:19 +0000)]
Ensure map is valid, even before userland exists and the fault address
register points to an address in the userland range.

Obtained from: ABT Systems Ltd
MFC after: 1 week
Sponsored by: the FreeBSD Foundation

3 days agoRemove cross references to el(4) and ie(4).
jhb [Mon, 22 Aug 2016 18:17:29 +0000 (18:17 +0000)]
Remove cross references to el(4) and ie(4).