]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
7 years agoAllow Dtrace to be compiled into the kernel again after r313177.
bz [Fri, 10 Feb 2017 16:06:14 +0000 (16:06 +0000)]
Allow Dtrace to be compiled into the kernel again after r313177.

MFC after: 1 week

7 years agoChange mlx4 QP allocation scheme.
hselasky [Fri, 10 Feb 2017 15:28:18 +0000 (15:28 +0000)]
Change mlx4 QP allocation scheme.

When using Blue-Flame, BF, the QPN overrides the VLAN, CV, and SV
fields in the WQE. Thus, BF may only be used for QPNs with bits 6,7
unset.

The current ethernet driver code reserves a TX QP range with 256b
alignment.

This is wrong because if there are more than 64 TX QPs in use, QPNs >=
base + 65 will have bits 6/7 set.

This problem is not specific for the Ethernet driver, any entity that
tries to reserve more than 64 BF-enabled QPs should fail. Also, using
ranges is not necessary here and is wasteful.

The new mechanism introduced here will support reservation for "Eth
QPs eligible for BF" for all drivers: bare-metal, multi-PF, and VFs
(when hypervisors support WC in VMs). The flow we use is:

1. In mlx4_en, allocate Tx QPs one by one instead of a range allocation,
   and request "BF enabled QPs" if BF is supported for the function

2. In the ALLOC_RES FW command, change param1 to:
a. param1[23:0]  - number of QPs
b. param1[31-24] - flags controlling QPs reservation

Bit 31 refers to Eth blueflame supported QPs. Those QPs must have bits
6 and 7 unset in order to be used in Ethernet.

Bits 24-30 of the flags are currently reserved.

When a function tries to allocate a QP, it states the required
attributes for this QP. Those attributes are considered "best-effort".
If an attribute, such as Ethernet BF enabled QP, is a must-have
attribute, the function has to check that attribute is supported
before trying to do the allocation.

In a lower layer of the code, mlx4_qp_reserve_range masks out the bits
which are unsupported. If SRIOV is used, the PF validates those
attributes and masks out unsupported attributes as well. In order to
notify VFs which attributes are supported, the VF uses QUERY_FUNC_CAP
command. This command's mailbox is filled by the PF, which notifies
which QP allocation attributes it supports.

Obtained from: Linux (dual BSD/GPLv2 licensed)
Submitted by: Dexuan Cui @ microsoft . com
Differential Revision: https://reviews.freebsd.org/D8868
MFC after: 2 weeks
Sponsored by: Mellanox Technologies

7 years agoFlexible and asymmetric allocation of EQs and MSI-X vectors for PF/VFs.
hselasky [Fri, 10 Feb 2017 15:22:21 +0000 (15:22 +0000)]
Flexible and asymmetric allocation of EQs and MSI-X vectors for PF/VFs.

Previously, the mlx4 driver queried the firmware in order to get the
number of supported EQs. Under SRIOV, since this was done before the
driver notified the firmware how many VFs it actually needs, the
firmware had to take into account a worst case scenario and always
allocated four EQs per VF, where one was used for events while the
others were used for completions. Now, when the firmware supports the
asymmetric allocation scheme, denoted by exposing num_sys_eqs > 0 (-->
MLX4_DEV_CAP_FLAG2_SYS_EQS), we use the QUERY_FUNC command to query
the firmware before enabling SRIOV. Thus we can get more EQs and MSI-X
vectors per function. Moreover, when running in the new
firmware/driver mode, the limitation that the number of EQs should be
a power of two is lifted.

Obtained from: Linux (dual BSD/GPLv2 licensed)
Submitted by: Dexuan Cui @ microsoft . com
Differential Revision: https://reviews.freebsd.org/D8867
MFC after: 2 weeks
Sponsored by: Mellanox Technologies

7 years agoClean redundant MIN/MAX declarations in some HighPoint drivers.
pfg [Fri, 10 Feb 2017 15:18:41 +0000 (15:18 +0000)]
Clean redundant MIN/MAX declarations in some HighPoint drivers.

The hpt27xx(4), hptnr(4), and hptrr(4) drivers declare MIN() and MAX()
internally which match the macros from sys/param.h.

MIN() is not used, MAX is only used once and can be replaced with the
max() version in libkern.h which operates on u_ints.

MFC after: 2 weeks

7 years agoFix r313495.
kib [Fri, 10 Feb 2017 14:49:04 +0000 (14:49 +0000)]
Fix r313495.

The file type DTYPE_VNODE can be assigned as a fallback if VOP_OPEN()
did not initialized file type.  This is a typical code path used by
normal file systems.

Also, change error returned for inappropriate file type used for
O_EXLOCK to EOPNOTSUPP, as declared in the open(2) man page.

Reported by: cy, dhw, Iblis Lin <iblis@hs.ntnu.edu.tw>
Tested by: dhw
Sponsored by: The FreeBSD Foundation
MFC after: 13 days

7 years agoo Reset mouse selection when new lines reach selection lines.
ray [Fri, 10 Feb 2017 13:28:30 +0000 (13:28 +0000)]
o Reset mouse selection when new lines reach selection lines.
o Fix how selection handled on display.

Submitted by: hselasky
Reviewed by: hselasky, emaste(previous version)
Todo: track mouse select direction.

7 years agoindent(1): add regression test cases
pstef [Fri, 10 Feb 2017 09:31:39 +0000 (09:31 +0000)]
indent(1): add regression test cases

These examples show expected behavior of indent(1). They are meant to be used
together with a regression test mechanism, either Kyua, a Makefile or perhaps
something else. The mechanism should in essence do this:
  indent -P${test}.pro < ${test}.0 > ${test}.0.run
and compare ${test}.0.stdout to ${test}.0.run. If the files differ or the exit
status isn't 0, the test failed.

* ${test}.pro is an indent(1) profile: a list of options passed through a file.
  The program doesn't complain if the file doesn't exist.
* ${test}.0 is a C source file which acts as input for indent(1). It doesn't
  have to have any particular formatting, since it's the output that matters.
* ${test}.0.stdout contains expected output. It doesn't have to be formatted in
  Kernel Normal Form as the point of the tests is to check for regressions in
  the program and not to check that it always produces KNF.

Reviewed by: ngie
Approved by: pfg (mentor)
Differential Revision: https://reviews.freebsd.org/D9007

7 years ago[ath] sigh, how'd I miss this.
adrian [Fri, 10 Feb 2017 07:16:56 +0000 (07:16 +0000)]
[ath] sigh, how'd I miss this.

7 years agoUse proper value for socket option on IPv6
eri [Fri, 10 Feb 2017 06:20:27 +0000 (06:20 +0000)]
Use proper value for socket option on IPv6

Reported-by: ohartmann@walstatt.org
7 years agoFix build after r313524
eri [Fri, 10 Feb 2017 06:01:47 +0000 (06:01 +0000)]
Fix build after r313524

Reported-by: ohartmann@walstatt.org
7 years agoRevert r313527
eri [Fri, 10 Feb 2017 05:58:16 +0000 (05:58 +0000)]
Revert r313527

Heh svn is not git

7 years agoCorrect missed variable name.
eri [Fri, 10 Feb 2017 05:51:39 +0000 (05:51 +0000)]
Correct missed variable name.

Reported-by: ohartmann@walstatt.org
7 years agoThe patch provides the same socket option as Linux IP_ORIGDSTADDR.
eri [Fri, 10 Feb 2017 05:16:14 +0000 (05:16 +0000)]
The patch provides the same socket option as Linux IP_ORIGDSTADDR.
Unfortunately they will have different integer value due to Linux value being already assigned in FreeBSD.

The patch is similar to IP_RECVDSTADDR but also provides the destination port value to the application.

This allows/improves implementation of transparent proxies on UDP sockets due to having the whole information on forwarded packets.

Sponsored-by: rsync.net
Differential Revision: D9235
Reviewed-by: adrian
7 years agoWhen patching USDT probes, use non-unique names for aliases of weak symbols.
markj [Fri, 10 Feb 2017 02:01:32 +0000 (02:01 +0000)]
When patching USDT probes, use non-unique names for aliases of weak symbols.

Aliases are normally given names that include a key that's unique for each
input object file. This, for example, ensures that aliases for identically
named local symbols in different object files don't conflict. However, in
some cases the static linker will leave an undefined alias after merging
identical weak symbols, resulting in a link error. A non-unique name allows
the aliases to be merged as well.

PR: 216871
X-MFC With: r313262

7 years agoixl(4): Update to 1.7.12-k
erj [Fri, 10 Feb 2017 01:04:11 +0000 (01:04 +0000)]
ixl(4): Update to 1.7.12-k

Refresh upstream driver before impending conversion to iflib.

Major new features:

- Support for Fortville-based 25G adapters
- Support for I2C reads/writes

(To prevent getting or sending corrupt data, you should set
dev.ixl.0.debug.disable_fw_link_management=1 when using I2C
[this will disable link!], then set it to 0 when done. The driver implements
the SIOCGI2C ioctl, so ifconfig -v works for reading I2C data,
but there are read_i2c and write_i2c sysctls under the .debug sysctl tree
[the latter being useful for upper page support in QSFP+]).

- Addition of an iWARP client interface (so the future iWARP driver for
  X722 devices can communicate with the base driver).
  - Compiling this option in is enabled by default, with "options IXL_IW" in
    GENERIC.

Differential Revision: https://reviews.freebsd.org/D9227
Reviewed by: sbruno
MFC after: 2 weeks
Sponsored by: Intel Corporation

7 years agoIncrease a chance of devfs_close() calling d_close cdevsw method.
kib [Thu, 9 Feb 2017 23:36:50 +0000 (23:36 +0000)]
Increase a chance of devfs_close() calling d_close cdevsw method.

If a file opened over a vnode has an advisory lock set at close,
vn_closefile() acquires additional vnode use reference to prevent
freeing the vnode in vn_close().  Side effect is that for device
vnodes, devfs_close() sees that vnode reference count is greater than
one and refuses to call d_close().  Create internal version of
vn_close() which can avoid dropping the vnode reference if needed, and
use this to execute VOP_CLOSE() without acquiring a new reference.

Note that any parallel reference to the vnode would still prevent
d_close call, if the reference is not from an opened file, e.g. due to
stat(2).

Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks

7 years agoDo not establish advisory locks when doing open(O_EXLOCK) or open(O_SHLOCK)
kib [Thu, 9 Feb 2017 23:35:57 +0000 (23:35 +0000)]
Do not establish advisory locks when doing open(O_EXLOCK) or open(O_SHLOCK)
for files which do not have DTYPE_VNODE type.

Both flock(2) and fcntl(2) syscalls refuse to acquire advisory lock on
a file which type is not DTYPE_VNODE.  Do the same when lock is
requested from open(2).

Restructure the block in vn_open_vnode() which handles O_EXLOCK and
O_SHLOCK open flags to make it easier to quit its execution earlier
with an error.

Tested by: pho (previous version)
Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks

7 years agoHandle protected symbols in rtld.
kib [Thu, 9 Feb 2017 23:33:06 +0000 (23:33 +0000)]
Handle protected symbols in rtld.

Protected symbol reference in GOT of the defining object must be
resolved to itself, same as -Bsymbolic globally.

Discussed with: emaste
Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks
Differential revision: https://reviews.freebsd.org/D9317

7 years agoDefine ELF_ST_VISIBILITY().
kib [Thu, 9 Feb 2017 23:32:03 +0000 (23:32 +0000)]
Define ELF_ST_VISIBILITY().

Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks

7 years ago[net80211] don't bother doing fragmentation if the driver supports fragmentation...
adrian [Thu, 9 Feb 2017 23:29:57 +0000 (23:29 +0000)]
[net80211] don't bother doing fragmentation if the driver supports fragmentation offload.

Tested:

* ath10k, which does its own fragmentation in firmware.

7 years ago[ath_hal] implement NULL methods for ah_setQuiet for AR5210, AR5211.
adrian [Thu, 9 Feb 2017 23:20:55 +0000 (23:20 +0000)]
[ath_hal] implement NULL methods for ah_setQuiet for AR5210, AR5211.

Tested:

* "crap, I didn't bring my cardbus collection and T400 with me" compile
  tested.

7 years ago[ath] initial station side quiet IE support.
adrian [Thu, 9 Feb 2017 23:15:11 +0000 (23:15 +0000)]
[ath] initial station side quiet IE support.

This implements hardware assisted quiet IE support.  Quiet time is
an optional interval on DFS channels (but doesn't have to be DFS
only channels! sigh) where the station and AP can be quiet in order
to allow for channel utilisation measurements.  Typically that's
stuff like radar detection, spectral scan, other-BSS frame sniffing,
checking how busy the air is, etc.

The hardware implements it as one of the generic timers, which is
supplied a period, offset from the trigger period and duration
to stay quiet.  The AP can announce quiet time configurations which
change, and so this code also tracks that.

Implementation details:

* track the current quiet time IE
* compare the new one against the previous one - if only the TBTT
  counter changes, don't update things
* If tbttcount=1 then program it into the hardware - that is when
  it is easiest to program the correct starting offset (one TBTT +
  configured offset).
* .. later on check to see if it can be done on any tbttcount
* If the IE goes away then remove the quiet timer and clear the
  config
* Upon reset, state change, new beacon - clear quiet time IE
  and just let it resync from the next beacon.

History:

This was work done initially by sibridgetech.com in 2011/2012/2013
as part of some FreeBSD wifi DFS contracting work they had for a
third party.  They implemented the net80211 quiet time IE pieces
and had some test code for the station side which didn't entirely
use the timers correctly.

I figured out how to use the timers correctly without stopping/starting
the transmit DMA engine each time. When done correctly, the timer
just needs to be programmed once and left alone until the next
configuration change.

So, thanks to Himali Patel and Parthiv Shah for their work way
back then.  I finally figured it out and finished it!

TODO:

* Now, I'd rather net80211 did the quiet time IE tracking and parsing,
  pushing configurations into the driver is needed.  I'll look at
  doing that in a subsequent update.

* This doesn't handle multiple quiet time IEs, which will currently
  just mess things up.  I'll look into supporting that in the future
  (at least by only obeying "one" of them, and then ignoring
  subsequent IEs in a beacon/probe frame.)

* This also implements the STA side and not the AP side - the AP
  side will come later, and involves taking various other intervals
  into account (eg the beacon offset for multi-VAP modes, the
  SWBA time, etc, etc) as well as obtaining the configuration when
  a beacon is configured/generated rather than "hearing" an IE.

* .. investigate supporting quiet IE in mesh, tdma, ibss modes

* .. investigate supporting quiet IE for non-DFS channels
  (so this can be done for say, 2GHz channels.)

* Chances are i should commit NULL methods for the ar5210, ar5211 HALs..

Tested:

* AR9380, STA mode - announcing quiet, removing quiet, changing quite
  time config, whilst doing iperf testing;
* AR9380, AP mode.

7 years agoFix setting birthtime in ZFS
asomers [Thu, 9 Feb 2017 21:30:53 +0000 (21:30 +0000)]
Fix setting birthtime in ZFS

sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c
* In zfs_freebsd_setattr, if the caller wants to set the birthtime,
  set the bits that zfs_settattr expects

* In zfs_setattr, if XAT_CREATETIME is set, set xoa_createtime,
  expected by zfs_xvattr_set.  The two levels of indirection seem
  excessive, but it minimizes diffs vs OpenZFS.

* In zfs_setattr, check for overflow of va_birthtime (from delphij)

* Remove red herring in zfs_getattr

sys/cddl/contrib/opensolaris/uts/common/sys/vnode.h
* Un-booby-trap some macros

New tests are under review at https://github.com/pjd/pjdfstest/pull/6

Reviewed by: avg
MFC after: 3 weeks
Sponsored by: Spectra Logic Corp
Differential Revision: https://reviews.freebsd.org/D9353

7 years agoCleanup on usr.sbin/arp/arp.c
garga [Thu, 9 Feb 2017 19:58:12 +0000 (19:58 +0000)]
Cleanup on usr.sbin/arp/arp.c

* 'blackhole' and 'reject' are mutually exclusive, replace printf() by errx()
  when both are selected.
* 'trail' option is no longer supported since first import of arp from 4.4BSD.
  XXX message was added 13 years ago in r128192. I believe it's time to remove
  it.
* Use warnx() to print some informative messages instead of printf()
* Replace strncmp() by strcmp() when validating parameters and exit when invalid
  parameter is found

Reviewed by: allanjude, vangyzen, cem
Approved by: allanjude
MFC after: 1 week
Sponsored by: Rubicon Communications (Netgate)
Differential Revision: https://reviews.freebsd.org/D9504

7 years agoAdd support for the Intel 82572EI back to em(4), it seems it was dropped
andrew [Thu, 9 Feb 2017 17:48:33 +0000 (17:48 +0000)]
Add support for the Intel 82572EI back to em(4), it seems it was dropped
when oving to iflib.

Reviewed by: sbruno
Sponsored by: ABT Systems Ltd
Differential Revision: https://reviews.freebsd.org/D9511

7 years agoufs: Use UFS_MAXNAMLEN constant
cem [Thu, 9 Feb 2017 17:47:01 +0000 (17:47 +0000)]
ufs: Use UFS_MAXNAMLEN constant

(like NFS, EXT2FS, SVR4, IBCS2) instead of redefining the MAXNAMLEN
constant.

No functional change.

Reviewed by: kib@, markj@
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D9500

7 years agoAdd I2C device hints for Onion Omega
allanjude [Thu, 9 Feb 2017 15:16:08 +0000 (15:16 +0000)]
Add I2C device hints for Onion Omega

This allows you to control up to 8 relay expansions from FreeBSD

https://github.com/freebsd/freebsd-wifi-build/wiki/Onion-Omega#controlling-the-relay-expansion

Reviewed by: adrian, mizhka
MFC after: 1 week
Sponsored by: ScaleEngine Inc.
Differential Revision: https://reviews.freebsd.org/D9503

7 years agorwlock: fix r313454
mjg [Thu, 9 Feb 2017 13:32:19 +0000 (13:32 +0000)]
rwlock: fix r313454

The runlock slow path would update wrong variable before restarting the
loop, in effect corrupting the state.

Reported by: pho

7 years agolocks: tidy up unlock fallback paths
mjg [Thu, 9 Feb 2017 08:19:30 +0000 (08:19 +0000)]
locks: tidy up unlock fallback paths

Update comments to note these functions are reachable if lockstat is
enabled.

Check if the lock has any bits set before attempting unlock, which saves
an unnecessary atomic operation.

7 years agoSet GDMA1 Frames Destination Port to Port 0 (CPU)
sgalabov [Thu, 9 Feb 2017 07:29:07 +0000 (07:29 +0000)]
Set GDMA1 Frames Destination Port to Port 0 (CPU)

Some U-Boot versions do not initialize MT7620's Frame Engine.
Then it is not possible to receive packets from the network.
Setting GDMA1 Frames Destination Port to Port 0 (CPU) in GDM Forwarding
Configuration register solves this issue.

Submitted by: Hiroki Mori (yamori813@yahoo.co.jp)
Reviewed by: adrian mizhka (previous version)
Differential Revision: https://reviews.freebsd.org/D9301

7 years ago[net80211] quiet IE handling improvements
adrian [Thu, 9 Feb 2017 04:07:30 +0000 (04:07 +0000)]
[net80211] quiet IE handling improvements

* on the station side, only call the quiet time IE method if we have a
  quiet IE - otherwise call the NULL method once, and then don't waste
  time calling NULL

* on the beacon generation side - force a beacon regeneration each time
  quiet time is enabled/disabled.  Without this, enabling/disabling quiet
  time IE would cause the beacon contents to be corrupted since none of
  the "move contents around" logic (like for CSA and TIM handling) is implemented.

This changes the size of ieee80211_node so it requires a kernel recompile,
but no userland recompile.

Tested:

* AR9380, AP mode, enabling/disabling quiet time IE
* AR9380, STA mode, with upcoming driver changes.

7 years agoDon't decrypt a core if a vmcore file already exists by default.
def [Wed, 8 Feb 2017 23:17:23 +0000 (23:17 +0000)]
Don't decrypt a core if a vmcore file already exists by default.
Allow to change this behaviour using the -f flag.

Approved by: pjd (mentor)

7 years agolld: Allow arbitrary code alignment in .eh_frame
emaste [Wed, 8 Feb 2017 20:31:54 +0000 (20:31 +0000)]
lld: Allow arbitrary code alignment in .eh_frame

According to the specification, CIE code alignment factor is an
arbitrary unsigned LEB128 encoded value.

PR: 216908
Reported by: Wolfgang Meyer
Obtained from: Upstream LLD r277105
MFC after: 1 week

7 years agoFix style(9)
garga [Wed, 8 Feb 2017 20:21:29 +0000 (20:21 +0000)]
Fix style(9)

Reviewed by: vangyzen, allanjude, cem
Approved by: allanjude
MFC after: 1 week
Sponsored by: Rubicon Communications (Netgate)
Differential Revision: https://reviews.freebsd.org/D9494

7 years agosx: implement slock/sunlock fast path
mjg [Wed, 8 Feb 2017 19:29:34 +0000 (19:29 +0000)]
sx: implement slock/sunlock fast path

See r313454.

7 years agorwlock: implemenet rlock/runlock fast path
mjg [Wed, 8 Feb 2017 19:28:46 +0000 (19:28 +0000)]
rwlock: implemenet rlock/runlock fast path

This improves singlethreaded throughput on my test machine from ~247 mln
ops/s to ~328 mln.

It is mostly about avoiding the setup cost of lockstat.

Reviewed by: jhb (previous version)

7 years agoImplement LOCKSTAT_OOL_PROFILE_ENABLED
mjg [Wed, 8 Feb 2017 19:25:58 +0000 (19:25 +0000)]
Implement LOCKSTAT_OOL_PROFILE_ENABLED

For use in uninlined locking primitives to decide whether lockstat
or profiling needs to be taken care of.

7 years agoloader: possible NULL pointer dereference in bcache.c
tsoome [Wed, 8 Feb 2017 18:32:53 +0000 (18:32 +0000)]
loader: possible NULL pointer dereference in bcache.c

Coverity detected the possible NULL pointer dereference case.
Also updated comment as was suggested in illumos review.

CID: 1371008
Reported by: Coverity
Reviewed by: allanjude
Approved by: allanjude (mentor)
Differential Revision: https://reviews.freebsd.org/D9496

7 years agoTrim trailing whitespace (mostly introduced in r313407).
jhb [Wed, 8 Feb 2017 17:45:23 +0000 (17:45 +0000)]
Trim trailing whitespace (mostly introduced in r313407).

Sponsored by: DARPA / AFRL

7 years agobsdinstall: Make sure chroot filesystems are umounted after use
garga [Wed, 8 Feb 2017 17:03:52 +0000 (17:03 +0000)]
bsdinstall: Make sure chroot filesystems are umounted after use

* DISTDIR_IS_UNIONFS is set every time BSDINSTALL_DISTDIR is mounted inside
  BSDINSTALL_CHROOT. Use this flag to decide if it needs to be umounted
* BSDINSTALL_CHROOT/dev is mounted when 'bsdinstall mount' is called, there is
  no need to mount it again when user goes to shell after installation

Reviewed by: allanjude
Obtained from: pfSense
MFC after: 1 week
Sponsored by: Rubicon Communications (Netgate)
Differential Revision: https://reviews.freebsd.org/D8573

7 years agoEnsure the idle thread's loop services interrupts in a timely way when
jtl [Wed, 8 Feb 2017 16:46:57 +0000 (16:46 +0000)]
Ensure the idle thread's loop services interrupts in a timely way when
using the ACPI C1/mwait sleep method.

Previously, the mwait instruction would return when an interrupt was
pending; however, the idle loop did not actually enable interrupts when
this occurred. This led to a situation where the idle loop could quickly
spin through the C1/mwait sleep method a number of times when an interrupt
was pending. (Eventually, the situation corrected itself when something
other than an interrupt triggered the idle loop to either enable interrupts
or schedule another thread.)

Reviewed by: kib, imp (earlier version)
Input from: jhb
MFC after: 1 week
Sponsored by: Netflix

7 years agoloader: possible NULL pointer dereference in efipart.c
tsoome [Wed, 8 Feb 2017 15:52:09 +0000 (15:52 +0000)]
loader: possible NULL pointer dereference in efipart.c

Fix bugs found by Coverity in efipart.c.

The Issue is that efi_devpath_last_node() can return NULL pointer, and
therefore we should check for it. In real life we really do not
expect to see it to happen, so we will just error out from the test.

CID: 1371004
Reported by: Coverity
Reviewed by: allanjude
Approved by: allanjude (mentor)
Differential Revision: https://reviews.freebsd.org/D9490

7 years agoMerge content from ^/projects/netbsd-tests-upstream-01-2017 into ^/head
ngie [Wed, 8 Feb 2017 09:46:15 +0000 (09:46 +0000)]
Merge content from ^/projects/netbsd-tests-upstream-01-2017 into ^/head

The primary end-goal of this drop is ease future merges with NetBSD and
collaborate further with the NetBSD project.

The goal was (largely, not completely as some items are still oustanding
in the NetBSD GNATS system) achieved by doing the following:
- Pushing as many changes required to port contrib/netbsd-tests
  back to NetBSD as possible, then pull the upstream applied changes
  back in to FreeBSD.
- Diff reduce with upstream where possible by:
-- Improving libnetbsd header, etc compat glue.
-- Using _SED variables to modify test scripts on the fly for items
   that could not be upstreamed to NetBSD.

As a bonus for this work, this change also introduces testcases for
uniq(1).

Many thanks to Christos for working with me to get many of the changes
back into the NetBSD project.

In collaboration with: Christos Zoulas <christos@netbsd.org>
MFC after: 1 month
Sponsored by: Dell EMC Isilon

7 years agoClean up trailing and leading whitespace for variables to make it
ngie [Wed, 8 Feb 2017 09:24:25 +0000 (09:24 +0000)]
Clean up trailing and leading whitespace for variables to make it
consistent with the rest of the file and style.Makefile(9) a bit
more

MFC after: 3 weeks
Sponsored by: Dell EMC Isilon

7 years agoCreate link from hexdump(3) to sbuf_hexdump(9) as the manpage describes
ngie [Wed, 8 Feb 2017 09:22:35 +0000 (09:22 +0000)]
Create link from hexdump(3) to sbuf_hexdump(9) as the manpage describes
sbuf_hexdump(9)'s behavior

MFC after: 3 weeks
Sponsored by: Dell EMC Isilon

7 years agoClarify #includes for hexdump(3) vs sbuf_hexdump(9)
ngie [Wed, 8 Feb 2017 09:19:49 +0000 (09:19 +0000)]
Clarify #includes for hexdump(3) vs sbuf_hexdump(9)

hexdump(3) only requires libutil.h, whereas sbuf_hexdump(9) requires
sys/types.h (for ssize_t) and sys/sbuf.h

MFC after: 3 weeks
Sponsored by: Dell EMC Isilon

7 years agoMFhead@r313433
ngie [Wed, 8 Feb 2017 08:55:05 +0000 (08:55 +0000)]
MFhead@r313433

7 years ago[iwm] Remove 1s delay after fw loading. Can't reproduce issues on AC8260.
adrian [Wed, 8 Feb 2017 07:09:10 +0000 (07:09 +0000)]
[iwm] Remove 1s delay after fw loading. Can't reproduce issues on AC8260.

The 1s delay was added in the update to version 16 fw, where Family 8000
support was added.

Obtained from: DragonflyBSD commit bb480ca679a7ea530bdca6e41082d5755e9751dc

7 years ago[iwm] SCAN_ABORT_UMAC response doesn't use a wide id
adrian [Wed, 8 Feb 2017 07:08:13 +0000 (07:08 +0000)]
[iwm] SCAN_ABORT_UMAC response doesn't use a wide id

Obtained from: DragonflyBSD commit cef47a9cbb0a3ce5f18369fed9403d2764884bc2

7 years ago[iwm] back this out to version 16 for now.
adrian [Wed, 8 Feb 2017 07:07:23 +0000 (07:07 +0000)]
[iwm] back this out to version 16 for now.

Since I'm manually playing the dragonflybsd iwm/iwmfw commits forward, I'm ..
well, this.  This right here.

7 years ago[iwm] Recognize the IWM_UCODE_TLV_FW_MEM_SEG firmware section type.
adrian [Wed, 8 Feb 2017 07:05:56 +0000 (07:05 +0000)]
[iwm] Recognize the IWM_UCODE_TLV_FW_MEM_SEG firmware section type.

* Will be needed for loading version 22 of 7265D firmware.

Obtained from: DragonflyBSD commit 1d244c8133cf15d00d46836bc48958188cf9f510

7 years ago[iwm] bump firmware to version 17.
adrian [Wed, 8 Feb 2017 07:04:06 +0000 (07:04 +0000)]
[iwm] bump firmware to version 17.

7 years ago[iwm] add version 17 firmware.
adrian [Wed, 8 Feb 2017 07:03:52 +0000 (07:03 +0000)]
[iwm] add version 17 firmware.

7 years ago[iwm] add this 3 megabyte firmware image.
adrian [Wed, 8 Feb 2017 07:03:09 +0000 (07:03 +0000)]
[iwm] add this 3 megabyte firmware image.

7 years ago[iwm] add version 17 firmware.
adrian [Wed, 8 Feb 2017 07:02:09 +0000 (07:02 +0000)]
[iwm] add version 17 firmware.

7 years ago[iwm] add version 17 firmware.
adrian [Wed, 8 Feb 2017 07:01:58 +0000 (07:01 +0000)]
[iwm] add version 17 firmware.

7 years ago[iwm] add version 17 firmware.
adrian [Wed, 8 Feb 2017 07:01:31 +0000 (07:01 +0000)]
[iwm] add version 17 firmware.

7 years ago[iwm] Recognize IWM_DTS_MEASUREMENT_NOTIF_WIDE notification.
adrian [Wed, 8 Feb 2017 06:57:21 +0000 (06:57 +0000)]
[iwm] Recognize IWM_DTS_MEASUREMENT_NOTIF_WIDE notification.

* Add the command groups enum, and the iwm_phy_ops_subcmd_ids enum
  to if_iwmreg.h definitions.

* The IWM_DTS_MEASUREMENT_NOTIF_WIDE notification will be generated by
  version 17 firmware.

Taken-From: Linux iwlwifi

Obtained from: DragonflyBSD commit 4d8d6f9def2ffb60aaf2d88f72f069a96c0b4e3f

7 years ago[iwm] Very basic DTS thermal sensor support (prints temp as debug msg).
adrian [Wed, 8 Feb 2017 06:56:28 +0000 (06:56 +0000)]
[iwm] Very basic DTS thermal sensor support (prints temp as debug msg).

* Adds IWM_DEBUG_TEMP debug message type, for printing messages related
  to temperature sensors and thermal/TDP infos.

* The firmware regularly sends us DTS measurement notifications, so just
  print the temperature value as a debugging message.

(Adrian's addition):

* Eventually this can be used by the driver to limit transmit rate / power to
  try and do some thermal throttling.

Obtained from: DragonflyBSD commit efb7d4eb5c3140889a8880e12fd83c7bbfd0059d

7 years ago[iwm] Only for family 7000 power-down busmaster DMA clocks when stopping.
adrian [Wed, 8 Feb 2017 06:54:08 +0000 (06:54 +0000)]
[iwm] Only for family 7000 power-down busmaster DMA clocks when stopping.

Taken-From: Linux iwlwifi

Obtained from: DragonflyBSD commit 4c45994fcc77373ae2fb0901db15368c9731f641

7 years ago[iwm] Implement apmg_wake_up_wa workaround properly for 7000 family.
adrian [Wed, 8 Feb 2017 06:53:23 +0000 (06:53 +0000)]
[iwm] Implement apmg_wake_up_wa workaround properly for 7000 family.

* Add iwm_pcie_set_cmd_in_flight() and iwm_pcie_clear_cmd_in_flight()
  helper methods.

* Use ring->queued tracking in the command queue to set/clear the
  cmd_hold_nic_awake bit at the right points.

Taken-From: Linux iwlwifi

Obtained from: DragonflyBSD commit ce43f57f5308b579ea21e8a5a29969114ba2247d

7 years ago[iwm] Use iwm_mvm_scan_stop_wait to properly abort scans.
adrian [Wed, 8 Feb 2017 06:50:59 +0000 (06:50 +0000)]
[iwm] Use iwm_mvm_scan_stop_wait to properly abort scans.

* Add IWM_FLAG_SCAN_RUNNING to sc->sc_flags to track whether the firmware
  is currently running a scan, in order to decide wheter iwm_scan_end
  needs to abort a running scan.

* In iwm_scan_end, if the scan is still running, we now abort it, in order
  to keep the firmware scanning state in sync.

* Try to make things a bit simpler, by reacting on the
  IWM_SCAN_OFFLOAD_COMPLETE and IWM_SCAN_COMPLETE_UMAC notifications,
  instead of IWM_SCAN_ITERATION_COMPLETE and
  IWM_SCAN_ITERATION_COMPLETE_UMAC. This should be fine since we always
  only tell the firmware to do a single scan iteration anyway.

Obtained from: DragonflyBSD commit 1f249c981c4e89e7cde1836a75b61cac36dc7ac5

7 years ago[iwm] Add scan abort functions, to properly cancel a running scan.
adrian [Wed, 8 Feb 2017 06:44:50 +0000 (06:44 +0000)]
[iwm] Add scan abort functions, to properly cancel a running scan.

* Uses the notification wait api to wait for the corresponding scan
  complete notification after sending the abort command.

Taken-From: Linux iwlwifi

Obtained from: DragonflyBSD commit b484d09d54301740f036ddf02008117f563960c2

7 years ago[iwm] Get rid of iwm_disable_rx_dma, just use iwm_pcie_rx_stop directly.
adrian [Wed, 8 Feb 2017 06:43:02 +0000 (06:43 +0000)]
[iwm] Get rid of iwm_disable_rx_dma, just use iwm_pcie_rx_stop directly.

* This also fixes one of many small nic lock handling bugs, and matches
  iwlwifi's code.

Obtained from: DragonflyBSD git 50787d03cd0a0366c9cc4a055bb6977e5f65c85d

7 years agoAdd elf*-powerpc-freebsd targets to the elftoolchain target list
jhibbits [Wed, 8 Feb 2017 03:21:29 +0000 (03:21 +0000)]
Add elf*-powerpc-freebsd targets to the elftoolchain target list

FreeBSD uses the full target triple when generating embedded rootfs images
(MFS_IMAGE= make option).  Without this change objcopy errors out with:

objcopy: elf64-poewrpc-freebsd: invalid target name

MFC after: 2 weeks

7 years agoFix indentation (only line in file w/ 8-space indent rather than hard-tab).
rpokala [Wed, 8 Feb 2017 00:02:54 +0000 (00:02 +0000)]
Fix indentation (only line in file w/ 8-space indent rather than hard-tab).

MFH: 1 week

7 years agoDefer startup of gjournal switcher kproc.
jhb [Tue, 7 Feb 2017 22:45:59 +0000 (22:45 +0000)]
Defer startup of gjournal switcher kproc.

Don't start switcher kproc until the first GEOM is created.

Reviewed by: pjd
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D8576

7 years agoCopy the e_machine and e_flags fields from the binary into an ELF core dump.
jhb [Tue, 7 Feb 2017 20:34:03 +0000 (20:34 +0000)]
Copy the e_machine and e_flags fields from the binary into an ELF core dump.

In the kernel, cache the machine and flags fields from ELF header to use in
the ELF header of a core dump. For gcore, the copy these fields over from
the ELF header in the binary.

This matters for platforms which encode ABI information in the flags field
(such as o32 vs n32 on MIPS).

Reviewed by: kib
Sponsored by: DARPA / AFRL
Differential Revision: https://reviews.freebsd.org/D9392

7 years agoMFhead@r313404
ngie [Tue, 7 Feb 2017 19:47:30 +0000 (19:47 +0000)]
MFhead@r313404

7 years agoRemove placeholder compat header for stdio.h
ngie [Tue, 7 Feb 2017 19:47:04 +0000 (19:47 +0000)]
Remove placeholder compat header for stdio.h

In the end, dealing with fparseln was more bikeshed worthy than I
anticipated, and polling stdio.h with libutil.h caused me more
grief than necessary. Keeping the compat header around for no
reason other than include_next'ing the stdio.h header in FreeBSD
makes no sense.

7 years agoImprove libnetbsd compatibility with NetBSD
ngie [Tue, 7 Feb 2017 19:42:41 +0000 (19:42 +0000)]
Improve libnetbsd compatibility with NetBSD

This change is being made to diff reduce/reduce duplication in
contrib/netbsd-tests and to facilitate further porting of software from
NetBSD

Add the following headers:
- sys/event.h:
-- sys/types.h is required for kqueue on FreeBSD, but not NetBSD.
- sys/types.h:
-- NBBY is defined in sys/param.h on FreeBSD, not sys/types.h like on NetBSD.
   Pull in sys/param.h to have parity with NetBSD.
- sys/wait.h:
-- Define wrusage as __wrusage for parity with NetBSD typedef.
- glob.h
-- Define __gl_stat_t as "struct stat" for parity with NetBSD typedef.
- pthread.h:
-- Pull in pthread_np.h for _np functions defined separately on FreeBSD.

Improve compatibility with NetBSD in the following headers:

- sha1.h:
-- define SHA1_CTX as SHA_CTX
-- define SHA1Final as SHA1_Final
- sha2.h:
-- #include sha384 to pick up all of the SHA 384 bit macros and definitions.
- util.h:
-- Add sys/types.h to util.h to pollute the header for types used in
   flags_to_string and string_to_flags (u_long) as NetBSD doesn't require them
   for the functions.

MFC after:      2 weeks
Sponsored by:   Dell EMC Isilon

7 years agoRename timer.c to a10_timer.c
manu [Tue, 7 Feb 2017 19:28:32 +0000 (19:28 +0000)]
Rename timer.c to a10_timer.c

Requested by: andrew

7 years agoOops... put the atf_tc_expect_fail in the testcase definition, not the
ngie [Tue, 7 Feb 2017 19:02:59 +0000 (19:02 +0000)]
Oops... put the atf_tc_expect_fail in the testcase definition, not the
test suite definition

7 years agoFix garbage IP addresses in UDP log_in_vain messages
vangyzen [Tue, 7 Feb 2017 18:57:57 +0000 (18:57 +0000)]
Fix garbage IP addresses in UDP log_in_vain messages

If multiple threads emit a UDP log_in_vain message concurrently,
the IP addresses could be garbage due to concurrent usage of a
single string buffer inside inet_ntoa().  Use inet_ntoa_r() with
two stack buffers instead.

Reported by: Mark Martinec <Mark.Martinec+freebsd@ijs.si>
MFC after: 3 days
Relnotes: yes
Sponsored by: Dell EMC

7 years agoExpect the t_precision long double checks to fail on FreeBSD/i386
ngie [Tue, 7 Feb 2017 18:57:52 +0000 (18:57 +0000)]
Expect the t_precision long double checks to fail on FreeBSD/i386

There are some potential issues with the test (as brd@ has pointed out
elsewhere) with precision, etc not being set before the test, but as
always, more research is required.

7 years agoMFhead@r313398
ngie [Tue, 7 Feb 2017 18:47:16 +0000 (18:47 +0000)]
MFhead@r313398

7 years agoApply r274475's to expr.oxout.tab.c to fix the test on FreeBSD
ngie [Tue, 7 Feb 2017 18:37:46 +0000 (18:37 +0000)]
Apply r274475's to expr.oxout.tab.c to fix the test on FreeBSD

YYINT on FreeBSD is int, not short

I'll work with the upstream maintainer or come up with a build
method of modifying their definitions on install instead of
having to modify tests to match our forked YYINT definition.

PR: 216891
Sponsored by: Dell EMC Isilon

7 years agoDon't expect :inplace_symlink_src to fail anymore (post-r313277)
ngie [Tue, 7 Feb 2017 18:23:44 +0000 (18:23 +0000)]
Don't expect :inplace_symlink_src to fail anymore (post-r313277)

The S_ISREG check was restored, such that the code will again fail with
in-place replacements on symlinks

MFC after: 12 days
X-MFC with: r313277
Sponsored by: Dell EMC Isilon

7 years agoPush reading of ESR_EL1 to assembly. Among other uses this will allow us
andrew [Tue, 7 Feb 2017 18:19:11 +0000 (18:19 +0000)]
Push reading of ESR_EL1 to assembly. Among other uses this will allow us
to expose this to signal handlers, e.g. for the clang sanitizers.

Sponsored by: DARPA, AFRL

7 years agoAdd fibs_test:udp_dontroute6, another IPv6 multi-FIB test
asomers [Tue, 7 Feb 2017 17:40:59 +0000 (17:40 +0000)]
Add fibs_test:udp_dontroute6, another IPv6 multi-FIB test

PR: 196361
MFC after: 3 weeks
Sponsored by: Spectra Logic Corp

7 years agosubr_sfbus.c need sys/proc.h for struct thread definition.
manu [Tue, 7 Feb 2017 17:31:24 +0000 (17:31 +0000)]
subr_sfbus.c need sys/proc.h for struct thread definition.
This fixes kernel build for armv6.

Discussed with: kib

7 years agoSwitch to the Linux device tree upstream names for Allwinner boards.
manu [Tue, 7 Feb 2017 17:15:13 +0000 (17:15 +0000)]
Switch to the Linux device tree upstream names for Allwinner boards.
Newer u-boot that uses the u-boot-master port uses these names.

7 years agorwlock: implement RW_LOCK_WRITER_RECURSED bit
mjg [Tue, 7 Feb 2017 17:04:31 +0000 (17:04 +0000)]
rwlock: implement RW_LOCK_WRITER_RECURSED bit

This moves recursion handling out of the inlined wunlock path and in
particular saves a read and a branch.

Discussed with:

7 years agoBump struct thread alignment to 32.
mjg [Tue, 7 Feb 2017 17:03:22 +0000 (17:03 +0000)]
Bump struct thread alignment to 32.

This gives additional bits to use in locking primitives which store
the lock thread pointer in the lock value.

Discussed with: kib

7 years agolocks: follow up r313386
mjg [Tue, 7 Feb 2017 16:01:07 +0000 (16:01 +0000)]
locks: follow up r313386

Unfinished diff was committed by accident. The loop in lock_delay
was changed to decrement, but the loop iterator was still incrementing.

7 years agoefipart is also using the '%S' printf format, add -Wno-format for it.
manu [Tue, 7 Feb 2017 15:16:01 +0000 (15:16 +0000)]
efipart is also using the '%S' printf format, add -Wno-format for it.
This fix building for armv6.

7 years agolocks: change backoff to exponential
mjg [Tue, 7 Feb 2017 14:49:36 +0000 (14:49 +0000)]
locks: change backoff to exponential

Previous implementation would use a random factor to spread readers and
reduce chances of starvation. This visibly reduces effectiveness of the
mechanism.

Switch to the more traditional exponential variant. Try to limit starvation
by imposing an upper limit of spins after which spinning is half of what
other threads get. Note the mechanism is turned off by default.

Reviewed by: kib (previous version)

7 years agoAdd support for PLATFORM and PLATFORM_SMP to the Altera SOCFPGA SoC. This
andrew [Tue, 7 Feb 2017 12:04:04 +0000 (12:04 +0000)]
Add support for PLATFORM and PLATFORM_SMP to the Altera SOCFPGA SoC. This
will help with moving it to GENERIC.

Reviewed by: br
Sponsored by: ABT Systems Ltd
Differential Revision: https://reviews.freebsd.org/D9461

7 years agoAdd #else case in run(..) to fix test on non-{amd64,arm64,mips} after
ngie [Tue, 7 Feb 2017 06:34:02 +0000 (06:34 +0000)]
Add #else case in run(..) to fix test on non-{amd64,arm64,mips} after
recent refactoring to the test

7 years agoMFhead@r313380
ngie [Tue, 7 Feb 2017 06:04:13 +0000 (06:04 +0000)]
MFhead@r313380

7 years agoExpect :int_within_limits to fail when ptrdiff_t/*intmax_t differ in base type
ngie [Tue, 7 Feb 2017 05:39:00 +0000 (05:39 +0000)]
Expect :int_within_limits to fail when ptrdiff_t/*intmax_t differ in base type

The %t{d,u} (ptrdiff_t) tests fail for the following reasons:
- ptrdiff_t is by definition int32_t on !LP64 architectures and int64_t on
  LP64 architectures.
- intmax_t is by definition fixed to int64_t on all architectures.
- Some of the code in lib/libc/stdio/... is promoting ptrdiff_t to *intmax_t
  when parsing/representing the value.

PR: 191674
MFC after: 1 week
Sponsored by: Dell EMC Isilon

7 years agoWrap strcmp/wcscmp calls with ATF_CHECK_MSG and drop atf_tc_fail use
ngie [Tue, 7 Feb 2017 04:25:21 +0000 (04:25 +0000)]
Wrap strcmp/wcscmp calls with ATF_CHECK_MSG and drop atf_tc_fail use

The reasoning here was the same as what was done in r313376:
- Gather as many results as possible instead of failing early and
  not testing the rest of the cases.
- Simplify logic when checking test inputs vs outputs and printing
  test result.

MFC after: 1 week
Sponsored by: Dell EMC Isilon

7 years agoExpect :floatunditf to fail on FreeBSD/i386
ngie [Tue, 7 Feb 2017 04:15:41 +0000 (04:15 +0000)]
Expect :floatunditf to fail on FreeBSD/i386

The precision error on FreeBSD/i386 doesn't match the expected output in
long double form.

MFC after: 1 week
Sponsored by: Dell EMC Isilon

7 years agoFix :hexadecimal_floating_point on i386
ngie [Tue, 7 Feb 2017 03:46:48 +0000 (03:46 +0000)]
Fix :hexadecimal_floating_point on i386

Don't exclude i386 from LDBL_MANT_DIG == 64; it works properly in
that case.

While here, replace strcmp + atf_tc_fail with ATF_CHECK_MSG for 2
reasons:
- Gather as many results as possible instead of failing early and
  not testing the rest of the cases.
- Simplify logic when checking test inputs vs outputs and printing
  test result.

Tested on: amd64, i386
MFC after:  1 week
Sponsored by: Dell EMC Isilon

7 years agoExpect :hsearch_r_nonexistent to fail on FreeBSD
ngie [Tue, 7 Feb 2017 02:57:11 +0000 (02:57 +0000)]
Expect :hsearch_r_nonexistent to fail on FreeBSD

The docs and the behavior mismatch; as noted in the bug, the behavior
for hsearch_r matches Linux, whereas the docs seem to match NetBSD
requirements wise.

PR: 216872

7 years agohcreate(3): fix the ERRORS section and bump .Dd
ngie [Tue, 7 Feb 2017 02:32:49 +0000 (02:32 +0000)]
hcreate(3): fix the ERRORS section and bump .Dd

- Add missing comma between functions that trigger ENOMEM error.
- Fix the description for ESRCH. The action that triggers this error is
  FIND, not SEARCH (SEARCH does not exist).

MFC after: 1 week
Sponsored by: Dell EMC Isilon

7 years ago[ath] prepare for station side quiet time support.
adrian [Tue, 7 Feb 2017 02:21:34 +0000 (02:21 +0000)]
[ath] prepare for station side quiet time support.

* Track the current quiet time configuration in the ath_vap struct.
* Add an accessor method for calling the quiet time HAL method.

7 years agoUncomment more of the hsearch_r testcases
ngie [Tue, 7 Feb 2017 02:00:14 +0000 (02:00 +0000)]
Uncomment more of the hsearch_r testcases

Call hdestroy/hdestroy_r on FreeBSD instead of hdestroy(1?)(_r).

All but hdestroy_r_nonexistent pass as-is.

7 years agoMFhead@r313360
ngie [Tue, 7 Feb 2017 01:33:39 +0000 (01:33 +0000)]
MFhead@r313360

7 years agoSort sys/ #includes some more
ngie [Tue, 7 Feb 2017 01:28:55 +0000 (01:28 +0000)]
Sort sys/ #includes some more

MFC after: 1 week
X-MFC with: r313358
Sponsored by: Dell EMC Isilon