]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
7 years agoOnly set pud settings if this is a pullup or pulldown configuration.
manu [Wed, 17 Aug 2016 13:09:31 +0000 (13:09 +0000)]
Only set pud settings if this is a pullup or pulldown configuration.
This removes the need to set the MMC pins with pullups in our DTS.
Thanks to jmcneill@ for spotting this.

Tested on Orange Pi One (Allwinner H3).

MFC after: 1 week

7 years agoa10_gpio_get_function now returns the whole function not only
manu [Wed, 17 Aug 2016 10:20:36 +0000 (10:20 +0000)]
a10_gpio_get_function now returns the whole function not only
GPIO_INPUT/GPIO_OUTPUT.
a10_gpio_get_pud now returns the whole pud not only PULLDOWN/PULLUP.
Add a10_gpio_get_drv to get the current drive strenght.
During fdt pin configure, avoid setting function/drive/pud if it's already in
the correct value.

Tested on Allwinner H3 and A20

MFC after: 1 week

7 years agoGarbage collect _umtx_lock(2)/_umtx_unlock(2) references removed in r263318.
bdrewery [Wed, 17 Aug 2016 10:20:05 +0000 (10:20 +0000)]
Garbage collect _umtx_lock(2)/_umtx_unlock(2) references removed in r263318.

This has no real impact on the resulting libc.so file.

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

7 years agoAdd fdatasync(2) man page, combined with fsync(2).
kib [Wed, 17 Aug 2016 10:16:42 +0000 (10:16 +0000)]
Add fdatasync(2) man page, combined with fsync(2).

Reviewed by: emaste, rpokala, wblock
Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks
Differential revision: https://reviews.freebsd.org/D7522

7 years agoRemove duplicated code.
kib [Wed, 17 Aug 2016 10:14:22 +0000 (10:14 +0000)]
Remove duplicated code.

aio_aqueue() calls aio_init_aioinfo() as the first action. There is no
need to duplicate the code in kern_aio_fsync().

Also fix indent for aio_aqueue() definition.

Reviewed by: jhb
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D7523

7 years agoImplement userspace gettimeofday(2) with HPET timecounter.
kib [Wed, 17 Aug 2016 09:52:09 +0000 (09:52 +0000)]
Implement userspace gettimeofday(2) with HPET timecounter.

Right now, userspace (fast) gettimeofday(2) on x86 only works for
RDTSC.  For older machines, like Core2, where RDTSC is not C2/C3
invariant, and which fall to HPET hardware, this means that the call
has both the penalty of the syscall and of the uncached hw behind the
QPI or PCIe connection to the sought bridge.  Nothing can me done
against the access latency, but the syscall overhead can be removed.
System already provides mappable /dev/hpetX devices, which gives
straight access to the HPET registers page.

Add yet another algorithm to the x86 'vdso' timehands. Libc is updated
to handle both RDTSC and HPET.  For HPET, the index of the hpet device
to mmap is passed from kernel to userspace, index might be changed and
libc invalidates its mapping as needed.

Remove cpu_fill_vdso_timehands() KPI, instead require that
timecounters which can be used from userspace, to provide
tc_fill_vdso_timehands{,32}() methods.  Merge i386 and amd64
libc/<arch>/sys/__vdso_gettc.c into one source file in the new
libc/x86/sys location.  __vdso_gettc() internal interface is changed
to move timecounter algorithm detection into the MD code.

Measurements show that RDTSC even with the syscall overhead is faster
than userspace HPET access.  But still, userspace HPET is three-four
times faster than syscall HPET on several Core2 and SandyBridge
machines.

Tested by: Howard Su <howard0su@gmail.com>
Sponsored by: The FreeBSD Foundation
MFC after: 1 month
Differential revision: https://reviews.freebsd.org/D7473

7 years agoBy default, allow all to read the HPET registers pages. At the same
kib [Wed, 17 Aug 2016 09:20:04 +0000 (09:20 +0000)]
By default, allow all to read the HPET registers pages.  At the same
time, by, by default disallow writes to the mmaped HPET pages.

Intent is to allow userspace to use HPET as fast (i.e. no-syscall)
timecounter for gettimeofday(2).  Unfortunately, the permission model
does not make it possible to safely unhide /dev/hpet in the jails even
if default mode is set to 0444, because untrusted jailed root may
change device permissions to writeable.

Sponsored by: The FreeBSD Foundation
MFC after: 3 weeks

7 years agohyperv/util: Factor out helper for IC device_probe DEVMETHOD
sephe [Wed, 17 Aug 2016 08:38:49 +0000 (08:38 +0000)]
hyperv/util: Factor out helper for IC device_probe DEVMETHOD

MFC after: 1 week
Sponsored by: Microsoft
Differential Revision: https://reviews.freebsd.org/D7530

7 years agoCorrectly print and cast u_int64_t and off_t.
manu [Wed, 17 Aug 2016 08:29:30 +0000 (08:29 +0000)]
Correctly print and cast u_int64_t and off_t.

Reported by: ed, imp
MFC after: 1 week

7 years agohyperv/util: Don't reference hn_softc in KVP
sephe [Wed, 17 Aug 2016 08:26:08 +0000 (08:26 +0000)]
hyperv/util: Don't reference hn_softc in KVP

hn_softc is private data struct.

MFC after: 1 week
Sponsored by: Microsoft
Differential Revision: https://reviews.freebsd.org/D7519

7 years ago- Add the 'restrict' type qualifier to match function prototype.
kevlo [Wed, 17 Aug 2016 07:25:50 +0000 (07:25 +0000)]
- Add the 'restrict' type qualifier to match function prototype.
- Use .Lb libc rather than libpthread.

Reviewed by: delphij

7 years agohyperv/hn: Get rid of unused bits
sephe [Wed, 17 Aug 2016 05:57:10 +0000 (05:57 +0000)]
hyperv/hn: Get rid of unused bits

MFC after: 1 week
Sponsored by: Microsoft
Differential Revision: https://reviews.freebsd.org/D7518

7 years agohyperv/hn: Remove reference to nvsp_status
sephe [Wed, 17 Aug 2016 05:45:57 +0000 (05:45 +0000)]
hyperv/hn: Remove reference to nvsp_status

MFC after: 1 week
Sponsored by: Microsoft
Differential Revision: https://reviews.freebsd.org/D7517

7 years agohyperv/hn: Remove reference to nvsp_msg
sephe [Wed, 17 Aug 2016 05:34:02 +0000 (05:34 +0000)]
hyperv/hn: Remove reference to nvsp_msg

MFC after: 1 week
Sponsored by: Microsoft
Differential Revision: https://reviews.freebsd.org/D7516

7 years agohyperv/hn: Simplify RNDIS RX packets acknowledgement.
sephe [Wed, 17 Aug 2016 05:25:47 +0000 (05:25 +0000)]
hyperv/hn: Simplify RNDIS RX packets acknowledgement.

MFC after: 1 week
Sponsored by: Microsoft
Differential Revision: https://reviews.freebsd.org/D7515

7 years agohyperv/hn: Ignore the useless TX table.
sephe [Wed, 17 Aug 2016 05:14:26 +0000 (05:14 +0000)]
hyperv/hn: Ignore the useless TX table.

MFC after: 1 week
Sponsored by: Microsoft
Differential Revision: https://reviews.freebsd.org/D7514

7 years agohyperv/storvsc: Deliver CAM_SEL_TIMEOUT upon SRB status error.
sephe [Wed, 17 Aug 2016 05:02:18 +0000 (05:02 +0000)]
hyperv/storvsc: Deliver CAM_SEL_TIMEOUT upon SRB status error.

SRB status is set to 0x20 by the hypervisor, if the specified LUN is
unaccessible, and even worse the INQUIRY response will not be set by
the hypervisor at all under this situation.  Additionally, SRB status
is 0x20 too, for TUR on an unaccessible LUN.

Deliver CAM_SEL_TIMEOUT to CAM upon SRB status errors as suggested by
Scott Long, other values seems improper.

This commit fixes the Hyper-V disk hotplug support.

Submitted by: Hongjiang Zhang <honzhan microsoft com>
MFC after: 3 days
Sponsored by: Microsoft
Differential Revision: https://reviews.freebsd.org/D7521

7 years agoAdd support for set/get cam search mode
davidcs [Wed, 17 Aug 2016 02:40:17 +0000 (02:40 +0000)]
Add support for set/get cam search mode

MFC after: 5 days

7 years agoAdd ql_minidump.h
davidcs [Wed, 17 Aug 2016 01:57:58 +0000 (01:57 +0000)]
Add ql_minidump.h

MFC after:5 days

7 years agoUpgrade fw, bootloader and minidump template to version 5.4.58
davidcs [Wed, 17 Aug 2016 01:56:37 +0000 (01:56 +0000)]
Upgrade fw, bootloader and minidump template to version 5.4.58
Add minidump retrieval code

MFC after: 5 days

7 years agoPCIe HotPlug: Detect bridges that are not really HotPlug capable
vangyzen [Wed, 17 Aug 2016 01:24:34 +0000 (01:24 +0000)]
PCIe HotPlug: Detect bridges that are not really HotPlug capable

Some devices report that they have an MRL when they actually
do not.  Since they always report that the MRL is open, child
devices would be ignored.  Try to detect these devices and
ignore their claim of HotPlug support.  Specifically,
if there is an open MRL but the Data Link Layer is active,
the MRL is not real.

Revert r303645 to re-enable HotPlug support for slots with
power controllers, since it works correctly in my testing.

Start the DLL state-change timer if Presence /or/ MRL state changes,
along with other conditions.  Previously, we started the timer iff
Presence changed.  If there is an MRL, it must be closed for power
to be turned on, so Presence is unlikely to change on an MRL-close event.

Add a printf() of interesting registers on HotPlug interrupts and
commands (one from erj@).  These were very useful for debugging.
Guard them with bootverbose, since they're spam in normal operation.

In collaboration with: jhb
Reviewed by: jhb
MFC after: 1 day
Relnotes: yes (re-enable HotPlug support for slots with power controllers)
Sponsored by: Dell Inc.
Differential Revision: https://reviews.freebsd.org/D7509

7 years agoFix a stupid typo (or copy/paste buffer malfunction).
glebius [Tue, 16 Aug 2016 23:00:22 +0000 (23:00 +0000)]
Fix a stupid typo (or copy/paste buffer malfunction).

7 years agoWe should not be allowing a timeout to reset when a drain is in progress on
glebius [Tue, 16 Aug 2016 21:55:34 +0000 (21:55 +0000)]
We should not be allowing a timeout to reset when a drain is in progress on
it (either async or sync drain).

At this moment the only user of drain is TCP, but TCP wouldn't reschedule a
callout after it has drained it, since it drains only when a tcpcb is closed.
This for now the problem isn't observed.

Submitted by: rrs

7 years agobhnd(4): Implement NVRAM support required for PMU bring-up.
landonf [Tue, 16 Aug 2016 21:32:05 +0000 (21:32 +0000)]
bhnd(4): Implement NVRAM support required for PMU bring-up.

- Added a generic bhnd_nvram_parser API, with support for the TLV format
  used on WGT634U devices, the standard BCM NVRAM format used on most
  modern devices, and the "board text file" format used on some hardware
  to supply external NVRAM data at runtime (e.g. via an EFI variable).

- Extended the bhnd_bus_if and bhnd_nvram_if interfaces to support both
  string-based and primitive data type variable access, required for
  common behavior across both SPROM and NVRAM data sources.
- Extended the existing SPROM implementation to support the new
  string-based NVRAM APIs.

- Added an abstract bhnd_nvram driver, implementing the bhnd_nvram_if
  atop the bhnd_nvram_parser API.
- Added a CFE-based bhnd_nvram driver to provide read-only access to
  NVRAM data on MIPS SoCs, pending implementation of a flash-aware
  bhnd_nvram driver.

Approved by: adrian (mentor)
Differential Revision: https://reviews.freebsd.org/D7489

7 years agobhndb(4): Drop MIPS-incompatible __builtin_ctz dependency.
landonf [Tue, 16 Aug 2016 21:20:05 +0000 (21:20 +0000)]
bhndb(4): Drop MIPS-incompatible __builtin_ctz dependency.

This replaces the bitfield representation of the bhndb register window
freelist with the bitstring API, eliminating a dependency on
(MIPS-unsupported) __builtin_ctz().

Approved by: adrian (mentor)
Differential Revision: https://reviews.freebsd.org/D7495

7 years agoBug 211013 reports that a write error to a UFS filesystem running
mckusick [Tue, 16 Aug 2016 21:02:30 +0000 (21:02 +0000)]
Bug 211013 reports that a write error to a UFS filesystem running
with softupdates panics the kernel. The problem that has been pointed
out is that when there is a transient write error on certain metadata
blocks, specifically directory blocks (PAGEDEP), inode blocks
(INODEDEP), indirect pointer blocks (INDIRDEPS), and cylinder group
(BMSAFEMAP, but only when journaling is enabled), we get a panic
in one of the routines called by softdep_disk_io_initiation that
the I/O is "already started" when we retry the write.

These dependency types potentially need to do roll-backs when called
by softdep_disk_io_initiation before doing a write and then a
roll-forward when called by softdep_disk_write_complete after the
I/O completes.  The panic happens when there is a transient error.
At the top of softdep_disk_write_complete we check to see if the
write had an error and if an error occurred we just return.  This
return is correct most of the time because the main role of the routines
called by softdep_disk_write_complete is to process the now-completed
dependencies so that the next I/O steps can happen.

But for the four types listed above, they do not get to do their
rollback operations. This causes the panic when softdep_disk_io_initiation
gets called on the second attempt to do the write and the roll-back
routines find that the roll-backs have already been done. As an
aside I note that there is also the problem that the buffer will
have been unlocked and thus made visible to the filesystem and to
user applications with the roll-backs in place.

The way to resolve the problem is to add a flag to the routines called
by softdep_disk_write_complete for the four dependency types noted
that indicates whether the write was successful (WRITESUCCEEDED).
If the write does not succeed, they do just the roll-backs and then
return. If the write was successful they also do their usual
processing of the now-completed dependencies.

The fix was tested by selectively injecting write errors for buffers
holding dependencies of each of the four types noted above and then
verifying that the kernel no longer paniced and that following the
successful retry of the write that the filesystem could be unmounted
and successfully checked cleanly.

PR: 211013
Reviewed by: kib

7 years agoOnly expect :encode_tv_random_million to fail on 64-bit platforms
ngie [Tue, 16 Aug 2016 20:35:36 +0000 (20:35 +0000)]
Only expect :encode_tv_random_million to fail on 64-bit platforms

It passes on i386

MFC after: 1 week
Sponsored by: EMC / Isilon Storage Division

7 years agoRemove prototypes missed in r303951.
markj [Tue, 16 Aug 2016 19:43:17 +0000 (19:43 +0000)]
Remove prototypes missed in r303951.

7 years agoIn UFS_BALLOC(), invalidate pages of indirect buffers on failed block
kib [Tue, 16 Aug 2016 17:30:58 +0000 (17:30 +0000)]
In UFS_BALLOC(), invalidate pages of indirect buffers on failed block
allocation unwinding.

Dandling buffers are released on UFS_BALLOC() failure to ensure that
later attempt to allocate blocks in close range do not find the blocks
with invalid content, since possible partial block allocations are
unwound.  As such, it is not enough to just release the buffers, the
pages must also invalidated and removed from the vnode vm_object
queue.  Otherwise the pages might be found later and used to
reconstruct indirect buffers when doing allocations at offset close to
the failure point, and their stale content compromise the filesystem
integrity.

Note that just marking the buffer as B_INVAL is not enough, B_NOCACHE
is required.  To be sure, clear the B_CACHE flag as well.  This
complements the r174973, which started releasing buffers.

Reported and tested by: pho
Reviewed by: mckusick
Sponsored by: The FreeBSD Foundation
MFC after: 1 week

7 years agoOn unwind after failed block allocation in ffs_balloc_ufs{1,2}, assert
kib [Tue, 16 Aug 2016 17:18:38 +0000 (17:18 +0000)]
On unwind after failed block allocation in ffs_balloc_ufs{1,2}, assert
that recorded allocated blocks numbers match the physical block
numbers of dandling buffers which are released.

When finally freeing the blocks during unwind, assert that dandling
buffers where not re-allocated.  They shouldn't, because the vnode lock
is owned exclusive.

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

7 years agoAdd two new macros, SLIST_CONCAT and LIST_CONCAT. Note in both the
mckusick [Tue, 16 Aug 2016 17:07:48 +0000 (17:07 +0000)]
Add two new macros, SLIST_CONCAT and LIST_CONCAT. Note in both the
queue.h header file and in the queue.3 manual page that they are O(n)
so should be used only in low-usage paths with short lists (otherwise
an STAILQ or TAILQ should be used).

Reviewed by: kib

7 years agoWhen looking up dandling buffers for unwing after failing block
kib [Tue, 16 Aug 2016 17:05:15 +0000 (17:05 +0000)]
When looking up dandling buffers for unwing after failing block
allocation in UFS_BALLOC(), there is no need to map them.

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

7 years agoWhen block allocation fails in UFS_BALLOC(), and the volume does not
kib [Tue, 16 Aug 2016 16:50:48 +0000 (16:50 +0000)]
When block allocation fails in UFS_BALLOC(), and the volume does not
have SU enabled, there is no point in calling softdep_request_cleanup().

The call cannot produce free blocks, but we unecessarily lock ufsmount
and do inode block write.  Usual point of not doing optimizations for
the corner case of the full volume is not applicable there, the work
is easily avoidable, and the addition CPU and disk io load do not lead
to succeeding retry.

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

7 years agoIn ffs_balloc_ufs{1,2} routines, assert that unwind records do not
kib [Tue, 16 Aug 2016 16:49:56 +0000 (16:49 +0000)]
In ffs_balloc_ufs{1,2} routines, assert that unwind records do not
overflow local arrays.  This is not immediately obvious from the
static code inspection, due to retry logic.

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

7 years agoUse nitems() from sys/param.h.
araujo [Tue, 16 Aug 2016 15:53:05 +0000 (15:53 +0000)]
Use nitems() from sys/param.h.

MFC after: 2 weeks.

7 years agoUse nitems() from sys/param.h.
araujo [Tue, 16 Aug 2016 15:52:10 +0000 (15:52 +0000)]
Use nitems() from sys/param.h.

MFC after: 2 weeks.

7 years agoA few more wording tweaks as suggested (with some modifications
rrs [Tue, 16 Aug 2016 15:17:36 +0000 (15:17 +0000)]
A few more wording tweaks as suggested (with some modifications
as well) by Ravi Pokala. Thanks for the comments :-)
Sponsored by: Netflix Inc.

7 years agoHere we update the modular tcp to be able to switch to an
rrs [Tue, 16 Aug 2016 15:11:46 +0000 (15:11 +0000)]
Here we update the  modular tcp to be able to switch to an
alternate TCP stack in other then the closed state (pre-listen/connect).
The idea is that *if* that is supported by the alternate stack, it
is asked if its ok to switch. If it approves the "handoff" then we
allow the switch to happen. Also the fini() function now gets a flag
to tell if you are switching away *or* the tcb is destroyed. The
init() call into the alternate stack is moved to the end so the
tcb is more fully formed before the init transpires.

Sponsored by: Netflix Inc.
Differential Revision: D6790

7 years agoOnly use WaitForKeys event if it exists, this is not the case in u-boot efi implement...
manu [Tue, 16 Aug 2016 14:33:25 +0000 (14:33 +0000)]
Only use WaitForKeys event if it exists, this is not the case in u-boot efi implementation.

Reviewed by: jhb, emaste
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D6781

7 years agoUse %ju modifier for u_int64_t and %jd modifier for off_t.
manu [Tue, 16 Aug 2016 14:23:35 +0000 (14:23 +0000)]
Use %ju modifier for u_int64_t and %jd modifier for off_t.
off_t is long long on arm32 and long on amd64

MFC after: 1 week

7 years agotty: Use proper definition of exit status code and stdin macro
sbz [Tue, 16 Aug 2016 14:15:09 +0000 (14:15 +0000)]
tty: Use proper definition of exit status code and stdin macro

Reviewed by: bapt, bdrewery
Differential Revision: https://reviews.freebsd.org/D6828

7 years agoComments describing how to properly use the new lock_add functions
rrs [Tue, 16 Aug 2016 13:08:03 +0000 (13:08 +0000)]
Comments describing how to properly use the new lock_add functions
and its respective companion.

Sponsored by: Netflix Inc.

7 years agoThis cleans up the timer code in TCP and also makes it so we do not
rrs [Tue, 16 Aug 2016 12:40:56 +0000 (12:40 +0000)]
This cleans up the timer code in TCP and also makes it so we do not
take the INFO lock *unless* we are really going to delete the TCB.

Differential Revision: D7136

7 years agoTrim unneeded bootstrap after r301470 made 9.1 the minimum supported release.
bdrewery [Tue, 16 Aug 2016 12:13:12 +0000 (12:13 +0000)]
Trim unneeded bootstrap after r301470 made 9.1 the minimum supported release.

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

7 years agoDon't conflate enum nss_status return values values with int (NS_SUCCESS,
brooks [Tue, 16 Aug 2016 11:38:45 +0000 (11:38 +0000)]
Don't conflate enum nss_status return values values with int (NS_SUCCESS,
NS_RETURN) values.

Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D6046

7 years agoThe fdatasync(2) call must be cancellation point.
kib [Tue, 16 Aug 2016 08:27:03 +0000 (08:27 +0000)]
The fdatasync(2) call must be cancellation point.

Sponsored by: The FreeBSD Foundation
MFC after: 13 days

7 years ago[mips] fix use-before-initialised.
adrian [Tue, 16 Aug 2016 07:51:05 +0000 (07:51 +0000)]
[mips] fix use-before-initialised.

Found by: gcc-5.3

7 years agohyperv/hn: Simplify RNDIS message checks on RX path.
sephe [Tue, 16 Aug 2016 07:45:35 +0000 (07:45 +0000)]
hyperv/hn: Simplify RNDIS message checks on RX path.

MFC after: 1 week
Sponsored by: Microsoft
Differential Revision: https://reviews.freebsd.org/D7502

7 years agohyperv/hn: Simplify RNDIS NVS message sending.
sephe [Tue, 16 Aug 2016 07:37:02 +0000 (07:37 +0000)]
hyperv/hn: Simplify RNDIS NVS message sending.

MFC after: 1 week
Sponsored by: Microsoft
Differential Revision: https://reviews.freebsd.org/D7501

7 years agohyperv/hn: Factor out hn_nvs_send/hn_nvs_send_sglist
sephe [Tue, 16 Aug 2016 07:26:53 +0000 (07:26 +0000)]
hyperv/hn: Factor out hn_nvs_send/hn_nvs_send_sglist

Avoid unnecessary message type setting and centralize the send context
to transaction id cast.

MFC after: 1 week
Sponsored by: Microsoft
Differential Revision: https://reviews.freebsd.org/D7500

7 years agotcp/lro: Make # of LRO entries tunable
sephe [Tue, 16 Aug 2016 06:40:27 +0000 (06:40 +0000)]
tcp/lro: Make # of LRO entries tunable

Reviewed by: hps, gallatin
Obtained from: rrs, gallatin
MFC after: 2 weeks
Sponsored by: Netflix (rrs, gallatin), Microsoft (sephe)
Differential Revision: https://reviews.freebsd.org/D7499

7 years agoRegenerate DTrace tests.
markj [Tue, 16 Aug 2016 02:34:25 +0000 (02:34 +0000)]
Regenerate DTrace tests.

7 years agoMFV r304057:
markj [Tue, 16 Aug 2016 02:30:19 +0000 (02:30 +0000)]
MFV r304057:
7085 add support for "if" and "else" statements in dtrace

illumos/illumos-gate@c3bd3abd8856e8e75d820f65c58031cd6cbac818

Add syntactic sugar to dtrace: "if" and "else" statements. The sugar is
baked down to standard dtrace features by adding additional clauses with
the appropriate predicates.

Reviewed by: Adam Leventhal <ahl@delphix.com>
Reviewed by: Sebastien Roy <sebastien.roy@delphix.com>
Reviewed by: Paul Dagnelie <pcd@delphix.com>
Reviewed by: Bryan Cantrill <bryan@joyent.com>
Approved by: Richard Lowe <richlowe@richlowe.net>
Author: Matthew Ahrens <mahrens@delphix.com>

MFC after: 2 weeks
Relnotes: yes

7 years agoMFV r301526:
markj [Tue, 16 Aug 2016 02:25:19 +0000 (02:25 +0000)]
MFV r301526:
7035 string-related subroutines should validate input earlier

Reviewed by: Alex Wilson <alex.wilson@joyent.com>
Reviewed by: Bryan Cantrill <bryan@joyent.com>
Approved by: Matthew Ahrens <mahrens@delphix.com>
Author: Patrick Mooney <pmooney@pfmooney.com>

illumos/illumos-gate@771e39c3b1d6e2e0ba230442d782d83c60098296

MFC after: 2 weeks

7 years agoMFV r301525:
markj [Tue, 16 Aug 2016 02:20:02 +0000 (02:20 +0000)]
MFV r301525:
7033 ustack helper should fault on bad return values

Reviewed by: Patrick Mooney <patrick.mooney@joyent.com>
Reviewed by: Bryan Cantrill <bryan@joyent.com>
Approved by: Matthew Ahrens <mahrens@delphix.com>
Author: Alex Wilson <alex.wilson@joyent.com>

illumos/illumos-gate@a2f72b65ebc430aaf277ad797e554bb4deba9b95

MFC after: 2 weeks

7 years agoMFV r301524:
markj [Tue, 16 Aug 2016 02:18:34 +0000 (02:18 +0000)]
MFV r301524:
7034 negative record sizes should be rejected

Reviewed by: Patrick Mooney <patrick.mooney@joyent.com>
Reviewed by: Bryan Cantrill <bryan@joyent.com>
Approved by: Matthew Ahrens <mahrens@delphix.com>
Author: Alex Wilson <alex.wilson@joyent.com>

illumos/illumos-gate@0b8049bfb0e291160e960697b554596289d7f0bc

MFC after: 2 weeks

7 years agoMFV r296989:
markj [Tue, 16 Aug 2016 02:16:54 +0000 (02:16 +0000)]
MFV r296989:
6734 dtrace_canstore_statvar() fails for some valid static variables

Reviewed by: Dan McDonald <danmcd@omniti.com>
Approved by: Richard Lowe <richlowe@richlowe.net>
Author: Bryan Cantrill <bryan@joyent.com>

illumos/illumos-gate@d65f2bb4e50559c6c375a2aa9f728cbc34379015

MFC after: 2 weeks

7 years agoMFV r304056:
markj [Tue, 16 Aug 2016 02:14:36 +0000 (02:14 +0000)]
MFV r304056:
5396 fix longjmp clobbering errors

illumos/illumos-gate@67a4bb8f9ad4c49e9aa9e21e2114a7c093c3a73a

Reviewed by: Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
Reviewed by: Igor Kozhukhov <ikozhukhov@gmail.com>
Approved by: Richard Lowe <richlowe@richlowe.net>
Author: Gary Mills <gary_mills@fastmail.fm>

7 years agoFix r304026 so that it builds for gcc.
rmacklem [Tue, 16 Aug 2016 00:48:13 +0000 (00:48 +0000)]
Fix r304026 so that it builds for gcc.

Reported by: np
Tested by: np
MFC after: 1 month

7 years agoFix ko_KR, zh_CN, zh_HK, and zh_TW locales. r304045 did not fully revert
jkim [Tue, 16 Aug 2016 00:15:15 +0000 (00:15 +0000)]
Fix ko_KR, zh_CN, zh_HK, and zh_TW locales.  r304045 did not fully revert
date/time formats for these locales.

7 years agoelfcopy: correct comment typo in r304151
emaste [Mon, 15 Aug 2016 23:20:55 +0000 (23:20 +0000)]
elfcopy: correct comment typo in r304151

7 years agoRemove the mcd(4) driver for Mitsumi CD-ROM players.
jhb [Mon, 15 Aug 2016 20:38:02 +0000 (20:38 +0000)]
Remove the mcd(4) driver for Mitsumi CD-ROM players.

This is a driver for a pre-ATAPI ISA CD-ROM adapter.  As noted in
the manpage, this driver is only useful as a backend to cdcontrol to
play audio CDs since it doesn't use DMA, so its data performance is
"abysmal" (and that was true in the mid 90's).

7 years agoClean up the new sc cn open and close functions (old sc cn grab and ungrab
bde [Mon, 15 Aug 2016 20:17:48 +0000 (20:17 +0000)]
Clean up the new sc cn open and close functions (old sc cn grab and ungrab
functions).  Mainly, spell sc as itself instead of as scp->sc.

7 years agoEliminate use of sys_fsync() and sys_fdatasync().
ed [Mon, 15 Aug 2016 20:11:52 +0000 (20:11 +0000)]
Eliminate use of sys_fsync() and sys_fdatasync().

Make the kern_fsync() function public, so that it can be used by other
parts of the kernel. Fix up existing consumers to make use of it.

Requested by: kib

7 years agosem_post(): wake up the sleeper only after adjusting has_waiters
badger [Mon, 15 Aug 2016 20:09:09 +0000 (20:09 +0000)]
sem_post(): wake up the sleeper only after adjusting has_waiters

If the caller of sem_post() wakes up a thread sleeping via sem_wait()
before it clears the has_waiters flag, the caller of sem_wait() has no way of
knowing when it is safe to destroy the semaphore and reuse the memory. This is
because the caller of sem_post() may be interrupted between the wake step and
the clearing of has_waiters. It will then write into the has_waiters flag in
userspace after being preempted for some unknown amount of time.

Reviewed by: jhb, kib, vangyzen
Approved by: kib (mentor), vangyzen (mentor)
MFC after: 2 weeks
Sponsored by: Dell Inc.
Differential Revision: https://reviews.freebsd.org/D7505

7 years agodtraceUtil/tst.DataModel32.d.ksh passes on amd64.
markj [Mon, 15 Aug 2016 19:47:04 +0000 (19:47 +0000)]
dtraceUtil/tst.DataModel32.d.ksh passes on amd64.

7 years agoLet CloudABI use fdatasync() as well.
ed [Mon, 15 Aug 2016 19:42:21 +0000 (19:42 +0000)]
Let CloudABI use fdatasync() as well.

Now that FreeBSD supports fdatasync() natively, we can tidy up
CloudABI's equivalent system call to use that instead.

7 years agoRestructure the grabbing functions into mere wrappers of new open and
bde [Mon, 15 Aug 2016 19:37:18 +0000 (19:37 +0000)]
Restructure the grabbing functions into mere wrappers of new open and
close functions.  Scattered calls to sc_cnputc() and sc_cngetc() were
broken by turning the semi-reentrant inline context-switching code in
these functions into the grabbing functions.  cncheckc() calls for
panic dumps are the main broken case.  The grabbing functions have
special behaviour (mainly screen switching in sc_cngrab()) which makes
them unsuitable as replacements for the inline code.

7 years agoImplement VOP_FDATASYNC() for UFS.
kib [Mon, 15 Aug 2016 19:22:23 +0000 (19:22 +0000)]
Implement VOP_FDATASYNC() for UFS.

Reviewed by: mckusick
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks
Differential revision: https://reviews.freebsd.org/D7471

7 years agoImplement VOP_FDATASYNC() for msdosfs.
kib [Mon, 15 Aug 2016 19:17:00 +0000 (19:17 +0000)]
Implement VOP_FDATASYNC() for msdosfs.

Standard VOP_FSYNC() implementation just syncs data buffers, and due
to this, is the correct and efficient implementation for msdosfs or
any other filesystem which uses bufer cache trivially.  Provide
globally visible wrapper vop_stdfdatasync_buf() for future consumption
by other filesystems.

Reviewed by: mckusick
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks
Differential revision: https://reviews.freebsd.org/D7471

7 years agoRegen after r304176, fdatasync(2) addition.
kib [Mon, 15 Aug 2016 19:15:46 +0000 (19:15 +0000)]
Regen after r304176, fdatasync(2) addition.

7 years agoAdd an implementation of fdatasync(2).
kib [Mon, 15 Aug 2016 19:08:51 +0000 (19:08 +0000)]
Add an implementation of fdatasync(2).

The syscall is a trivial wrapper around new VOP_FDATASYNC(), sharing
code with fsync(2).  For all filesystems, this commit provides the
implementation which delegates the work of VOP_FDATASYNC() to
VOP_FSYNC().  This is functionally correct but not efficient.

This is not yet POSIX-compliant implementation, because it does not
ensure that queued AIO requests are completed before returning.

Reviewed by: mckusick
Discussed with: avg (ZFS), jhb (AIO part)
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks
Differential revision: https://reviews.freebsd.org/D7471

7 years agoDisable tests for non-standard behaviour of dirname(3)/basename(3).
ed [Mon, 15 Aug 2016 19:05:41 +0000 (19:05 +0000)]
Disable tests for non-standard behaviour of dirname(3)/basename(3).

The NetBSD ATF tests explicitly check that these functions do not modify
their input. These tests are NetBSD-specific. They test for something
that is not part of POSIX.

PR: 211873
Reviewed by: ngie
Differential Revision: https://reviews.freebsd.org/D7506

7 years agoVOP_FSYNC() does not take cred as an argument. Correct comment.
kib [Mon, 15 Aug 2016 18:55:33 +0000 (18:55 +0000)]
VOP_FSYNC() does not take cred as an argument.  Correct comment.

Sponsored by: The FreeBSD Foundation
MFC after: 1 week

7 years agoFix restoring the kbd_mode part of the keyboard state in grab/ungrab.
bde [Mon, 15 Aug 2016 18:02:37 +0000 (18:02 +0000)]
Fix restoring the kbd_mode part of the keyboard state in grab/ungrab.
Simply change the mode to K_XLATE using a local variable and use the
grab level as a flag to tell screen switches not to change it again,
so that we don't need to switch scp->kbd_mode.  We did the latter,
but didn't have the complications to update the keyboard mode switch
for every screen switch.  sc->kbd_mode remains at its user setting
for all scp's and ungrabbing restores to it.

7 years agoAdd support for register dumps on VF devices.
jhb [Mon, 15 Aug 2016 17:42:54 +0000 (17:42 +0000)]
Add support for register dumps on VF devices.

- Add handling of VF register sets to t4_get_regs_len() and t4_get_regs().
- While here, use t4_get_regs_len() in the ioctl handler for regdump
  instead of inlining it.

Reviewed by: np
Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D7484

7 years agoUpdate mailbox writes to work with VF devices.
jhb [Mon, 15 Aug 2016 17:41:34 +0000 (17:41 +0000)]
Update mailbox writes to work with VF devices.

- Use alternate register locations for the data and control registers for
  VFs.
- Do a dummy read to force the writes to the  mailbox data registers to
  post before the write to the control register on VFs.
- Do not check the PCI-e firmware register for errors on VFs.

Reviewed by: np
Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D7483

7 years agoMake SGE parameter handling more VF-friendly.
jhb [Mon, 15 Aug 2016 17:40:05 +0000 (17:40 +0000)]
Make SGE parameter handling more VF-friendly.

Add fields to hold the SGE control register and free list buffer sizes to
the sge_params structure.  Populate these new fields in
t4_init_sge_params() for PF devices and change t4_read_chip_settings() to
pull these values out of the params structure instead of reading
registers directly.  This will permit t4_read_chip_settings() to be reused
for VF devices which cannot read SGE registers directly.

While here, move the call to t4_init_sge_params() to
get_params__post_init().  The VF driver will populate the SGE parameters
structure via a different method before calling t4_read_chip_settings().

Reviewed by: np
Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D7476

7 years ago[Oops, the previous commit was missing the update to syscons.h.]
bde [Mon, 15 Aug 2016 17:11:05 +0000 (17:11 +0000)]
[Oops, the previous commit was missing the update to syscons.h.]

Like scr_lock, the grab count needs to be per-physical-device to work.

This bug corrupted the grab count on both vtys if the ungrabbed vty is
different from the console, and failed to restore the keyboard state
on the ungrabbed vty, but not restoring it usually left the keyboard
mode part of the keyboard state uncorrupted at 1 (K_XLATE), while
after this fix the keyboard mode part is usually corrupted to 0 (K_RAW).

While here, rename the grab count from grabbed to grab_level.

7 years agoLike scr_lock, the grab count needs to be per-physical-device to work.
bde [Mon, 15 Aug 2016 17:08:25 +0000 (17:08 +0000)]
Like scr_lock, the grab count needs to be per-physical-device to work.

This bug corrupted the grab count on both vtys if the ungrabbed vty is
different from the console, and failed to restore the keyboard state
on the ungrabbed vty, but not restoring the latter usually left the
keyboard mode part of it uncorrupted at 1 (K_XLATE), while after this
fix the keyboard mode part is usually corrupted to 0 (K_RAW).

While here, rename the grab count from 'grabbed' to grab_level.

7 years agoDisable some more unsafe things in (low level) console mode:
bde [Mon, 15 Aug 2016 15:34:53 +0000 (15:34 +0000)]
Disable some more unsafe things in (low level) console mode:
- never call up to the tty layer to restart output for keyboard input in
  console mode.  This was already disallowed in kdb mode.  Other cases
  are rarely reached.
- disable the reboot, halt and powerdown keys in console mode.  The suspend,
  standby and panic keys are still allowed, and aren't even conditonal
  on excessive configuration options.  Some of these actions are still
  available in ddb mode as ddb commands which are equally unsafe.  Some
  are useful at input prompts and should be restored when the locking is
  fixed.
- disallow bells in kdb mode (should be in console mode, but the flag for
  that is not available).  Visual bell gives very alarming behaviour by
  trying to use callouts which don't work in kdb mode.  Audio bell uses
  timeouts and hardware resources with mutexes that can deadlock in
  reasonable use of ddb.

Screen switches in kdb mode are not very safe, but they are important
functionality and there is a lot of code to make them sort of work.

7 years agoDecrease the anti-congestion sleep in 480.leapfile-ntpd to 1 hour
asomers [Mon, 15 Aug 2016 14:58:25 +0000 (14:58 +0000)]
Decrease the anti-congestion sleep in 480.leapfile-ntpd to 1 hour

24 hours is too long. Periodic scripts are executed serially, so when
combined with the sleep in 410.pkg-audit periodic could actually take more
than 24 hours and block the next invocation.

Reviewed by: cy
MFC after: 4 weeks
Sponsored by: Spectra Logic Corp
Differential Revision: https://reviews.freebsd.org/D7481

7 years agoChange all uses of 'debugger' to kdb_active and remove this variable. This
bde [Mon, 15 Aug 2016 14:28:16 +0000 (14:28 +0000)]
Change all uses of 'debugger' to kdb_active and remove this variable.  This
restores avoidance of doing dangerous things like calling wakeup() and
callouts while in ddb.

Initialization of 'debugger' was broken by removing the cndbctl() console
method that was used mainly in this driver to initialize 'debugger' and
switch to the console screen on entry to ddb.  The screen switch was
restored using the cngrab() method, but cngrab() is more general so it
should not initialize 'debugger' and never did.  'debugger' was just
an over-engineered alias for kdb_active anyway.  It existed because
kdb_active (when it was named ddb_active) was considered as a private
kdb variable, and there are ordering problems initializing the variables
atomically with the state that they represent, but an extra variable and
method to set it increased these problems.

The bug caused LORs, but WITNESS is normally misconfigured with
WITNESS_SKIPSIN so it doesn't check the spinlocks used by wakeup() and
callouts.

7 years agoelfcopy: add elf64-littleaarch64 output target support
emaste [Mon, 15 Aug 2016 14:28:08 +0000 (14:28 +0000)]
elfcopy: add elf64-littleaarch64 output target support

Sponsored by: The FreeBSD Foundation

7 years agoFix command: ipfw set (enable|disable) N (where N > 4).
oleg [Mon, 15 Aug 2016 13:06:29 +0000 (13:06 +0000)]
Fix command: ipfw set (enable|disable) N (where N > 4).
enable_sets() expects set bitmasks, not set numbers.

MFC after: 3 days

7 years agoQuick fix for locking fixes in r172250. The lock added there was per-
bde [Mon, 15 Aug 2016 12:56:45 +0000 (12:56 +0000)]
Quick fix for locking fixes in r172250.  The lock added there was per-
virtual-device, but needs to be per-physical-device so that it protects
shared data.  Usually, scp->sc->write_in_progress got corrupted first
and further corruption was limited when this variable was left at nonzero
with no write in progress.

Attempt to fix missing lock destruction in r162285.  Put it with the
lock destruction for r172250 after moving the latter.  Both might be
unreachable.

To demonstrate the bug, find a buggy syscall or sysctl that calls
printf(9) and run this often.  Run hd /dev/zero >/dev/ttyvN for any
N != 0.  The console spam goes to ttyv0 and the non-console spam goes
to ttyvN, so the lock provided no protection (but it helped for
N == 0).

7 years agopf: Add missing byte-order swap to pf_match_addr_range
kp [Mon, 15 Aug 2016 12:13:14 +0000 (12:13 +0000)]
pf: Add missing byte-order swap to pf_match_addr_range

Without this, rules using address ranges (e.g. "10.1.1.1 - 10.1.1.5") did not
match addresses correctly on little-endian systems.

PR: 211796
Obtained from: OpenBSD (sthen)
MFC after: 3 days

7 years agoelfcopy: silence GCC 5.3 unitialized variable warning
emaste [Mon, 15 Aug 2016 11:54:39 +0000 (11:54 +0000)]
elfcopy: silence GCC 5.3 unitialized variable warning

Although it's a false positive there is little cost to initializing it
always.

Submitted by: adrian

7 years agoe1000: Add support for Kaby Lake IDs
sbruno [Mon, 15 Aug 2016 11:24:30 +0000 (11:24 +0000)]
e1000:  Add support for Kaby Lake IDs

Fixup some errors when transitioning to/from low power states.

Submitted by: erj
Reviewed by: Jeffery Piper (jeffrey.e.piper@intel.com)
MFC after: 3 days
Relnotes: yes
Sponsored by: Intel Corporation
Differential Revision: https://reviews.freebsd.org/D7478

7 years agoRemove duplicate definition of get_pcb_td(). gcc works for detecting
bde [Mon, 15 Aug 2016 10:46:33 +0000 (10:46 +0000)]
Remove duplicate definition of get_pcb_td().  gcc works for detecting
this error.

7 years agoEnsure that sctp_it_ctl.cur_it does not point to a free object (during
tuexen [Mon, 15 Aug 2016 10:16:08 +0000 (10:16 +0000)]
Ensure that sctp_it_ctl.cur_it does not point to a free object (during
a small time window).
Thanks to Byron Campen for reporting the issue and
suggesting a fix.

MFC after: 3 days

7 years agoEnsure that the sector size is a multiple of 4096 to avoid creating
des [Mon, 15 Aug 2016 09:30:21 +0000 (09:30 +0000)]
Ensure that the sector size is a multiple of 4096 to avoid creating
unaligned partitions when the actual sector size is hidden from us.

PR: 211361
MFC after: 3 days

7 years agoAdd the ARMv8.1 identification registers to the list we print when booting.
andrew [Mon, 15 Aug 2016 09:23:08 +0000 (09:23 +0000)]
Add the ARMv8.1 identification registers to the list we print when booting.

MFC after: 1 week
Sponsored by: ABT Systems Ltd

7 years agohyperv/hn: Switch to vmbus xact APIs for sub-channel alloc request.
sephe [Mon, 15 Aug 2016 05:08:41 +0000 (05:08 +0000)]
hyperv/hn: Switch to vmbus xact APIs for sub-channel alloc request.

MFC after: 1 week
Sponsored by: Microsoft
Differential Revision: https://reviews.freebsd.org/D7480

7 years agohyperv/hn: Simplify chimney sending buffer disconnection.
sephe [Mon, 15 Aug 2016 05:00:37 +0000 (05:00 +0000)]
hyperv/hn: Simplify chimney sending buffer disconnection.

MFC after: 1 week
Sponsored by: Microsoft
Differential Revision: https://reviews.freebsd.org/D7479

7 years agoUnbreak LINT build.
sephe [Mon, 15 Aug 2016 04:59:38 +0000 (04:59 +0000)]
Unbreak LINT build.

Sponsored by: Microsoft

7 years agoAdd timingsafe_bcmp and timingsafe_memcmp.
delphij [Sun, 14 Aug 2016 23:38:50 +0000 (23:38 +0000)]
Add timingsafe_bcmp and timingsafe_memcmp.

Obtained from: OpenBSD
Reviewed by: trasz
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D7280

7 years agoEliminate unneeded vm_page_xbusy() and vm_page_xunbusy() operations when
alc [Sun, 14 Aug 2016 22:00:45 +0000 (22:00 +0000)]
Eliminate unneeded vm_page_xbusy() and vm_page_xunbusy() operations when
neither vm_pager_has_page() nor vm_pager_get_pages() is called.

Reviewed by: kib, markj
MFC after: 3 weeks

7 years ago[mips] convert over =v to =r for the inline assembly.
adrian [Sun, 14 Aug 2016 19:04:37 +0000 (19:04 +0000)]
[mips] convert over =v to =r for the inline assembly.

Later gcc and clang have deprecated =v (which maps to a specific temp
register) and instead we should just use =r to have the assembler
(hopefully!) save/restore things appropriately after choosing
a register.

Tested:

* AR9344 SoC, with userreg support
* AR9331 SoC, with no userreg support

Sponsored by: Sponsored by: DARPA, AFRL (MIPS TLS user register work)

7 years agoAdd an ability to attach comment to check-state rules.
ae [Sun, 14 Aug 2016 18:34:16 +0000 (18:34 +0000)]
Add an ability to attach comment to check-state rules.

MFC after: 1 week