]> CyberLeo.Net >> Repos - FreeBSD/stable/10.git/log
FreeBSD/stable/10.git
6 years agoMFC r315793:
ngie [Mon, 22 May 2017 06:06:48 +0000 (06:06 +0000)]
MFC r315793:

intro(3): fix markup

- Use `Em` with `.It` macro when referring to other libraries, instead of
  `Xr`.
- Use `.Em` instead of `.Xr` when referring to libraries.
- Remove commented out lines.

git-svn-id: svn://svn.freebsd.org/base/stable/10@318611 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

6 years agoMFC r317160:
ngie [Mon, 22 May 2017 06:05:14 +0000 (06:05 +0000)]
MFC r317160:

Clean up trailing whitespace

No functional changes

git-svn-id: svn://svn.freebsd.org/base/stable/10@318609 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

6 years agoMFC r317154:
ngie [Mon, 22 May 2017 06:04:20 +0000 (06:04 +0000)]
MFC r317154:

Print out the signal number on exit in terminate(..) if WARMSTART is compiled
into rpcbind.

The signal number can provide helpful diagnostic info.

Obtained from: Isilon OneFS

git-svn-id: svn://svn.freebsd.org/base/stable/10@318608 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

6 years agoMFC 318512
sephe [Mon, 22 May 2017 02:30:15 +0000 (02:30 +0000)]
MFC 318512

    net/vlan: Revert 305177

    Miss read the parentheses.

    Reported by:    oleg@
    Reviewed by:    hps@
    Sponsored by:   Microsoft

git-svn-id: svn://svn.freebsd.org/base/stable/10@318605 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

6 years agoMFC r317505:
hselasky [Fri, 19 May 2017 13:04:09 +0000 (13:04 +0000)]
MFC r317505:
Don't free uninitialized sysctl contexts in the mlx4en driver. This
can cause NULL pointer panics during failed device attach.

Differential Revision: https://reviews.freebsd.org/D8876
Sponsored by: Mellanox Technologies

git-svn-id: svn://svn.freebsd.org/base/stable/10@318540 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

6 years agoMFC r313555:
hselasky [Fri, 19 May 2017 12:53:50 +0000 (12:53 +0000)]
MFC r313555:
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
Sponsored by: Mellanox Technologies

git-svn-id: svn://svn.freebsd.org/base/stable/10@318536 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

6 years agoMFC r313556:
hselasky [Fri, 19 May 2017 12:39:35 +0000 (12:39 +0000)]
MFC r313556:
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
Sponsored by: Mellanox Technologies

git-svn-id: svn://svn.freebsd.org/base/stable/10@318533 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

6 years agoMFC r318243:
kib [Fri, 19 May 2017 10:16:51 +0000 (10:16 +0000)]
MFC r318243:
Do not wake up sleeping thread in reschedule_signals() if the signal
is blocked.  The spurious wakeup might result in spurious EINTR.

PR: 219228

git-svn-id: svn://svn.freebsd.org/base/stable/10@318529 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

6 years agoMFC r318150:
eugen [Fri, 19 May 2017 07:31:48 +0000 (07:31 +0000)]
MFC r318150:

Fix translation of transit PPtP/GRE connections for ipfw nat/natd "global" case.

PR:             218968
Approved by:    ae, vsevolod (mentor)

git-svn-id: svn://svn.freebsd.org/base/stable/10@318519 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

6 years agoMFC r314693
rgrimes [Fri, 19 May 2017 02:12:10 +0000 (02:12 +0000)]
MFC r314693
  Change /etc/rmt symlink from absolute to relative path,
  correcting the mistake made in r6499

Approved by: grehan (mentor)

git-svn-id: svn://svn.freebsd.org/base/stable/10@318513 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

6 years agoPersistently store NIC's hardware MAC address, and add a way to retrive it
rpokala [Thu, 18 May 2017 23:41:34 +0000 (23:41 +0000)]
Persistently store NIC's hardware MAC address, and add a way to retrive it

jhb pointed out that (struct ifnet) is part of the network driver KBI, and
thus the offsets of internal fields must not change. Therefore, move the new
"if_hw_addr" field to the end, and consume one of the "if_pspare"s; that's
what they're there for. Because netmap on stable/10 uses "if_pspare[0]", the
new field replaces the *last* element of that array; that way,
offsetof(if_pspare) is unchanged compared to before r318430.

PR: 194386
Reviewed by: jhb
Pointyhat to: rpokala
Sponsored by: Panasas

git-svn-id: svn://svn.freebsd.org/base/stable/10@318505 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

6 years agoMFC: r314345, r318276
marius [Thu, 18 May 2017 21:09:31 +0000 (21:09 +0000)]
MFC: r314345, r318276

- Add ID for NEC uPD720202 xHCI controller.
- Describe Intel Apollo Lake and Braswell USB 3.0 controllers.

git-svn-id: svn://svn.freebsd.org/base/stable/10@318499 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

6 years agoMFC: r318282
marius [Thu, 18 May 2017 21:00:53 +0000 (21:00 +0000)]
MFC: r318282

- Unlike as in the PCI case, when attached to ACPI, Intel Bay Trail
  and Braswell eMMC and SDXC controllers share the same IDs. Like in
  the PCI case, Braswell eMMC needs the SDHCI_QUIRK_DATA_TIMEOUT_1MHZ
  quirk (see r311794 for the corresponding change to the sdhci(4) PCI
  PCI front-end), though. However, due to the shared ACPI IDs, this
  is trickier to do.
- Intel Apollo Lake eMMC and SDXC controllers are affected by the
  APL18 ("Using 32-bit Addressing Mode With SD/eMMC Controller May
  Lead to Unpredictable System Behavior") silicon bug. When this
  erratum hits, typically both SDHCI and XHCI controllers wedge.
  According to Intel, using ADMA2 with 64-bit addressing and 96-bit
  descriptors serves as a workaround. Until such times when sdhci(4)
  has ADMA2 support, flag DMA as broken for affected interfaces.
  This turns out to work around the problem, too, at the cost of
  performance.
- In the sdhci(4) ACPI front-end, probe the Intel Apollo Lake eMMC
  and SDXC controllers, too.

git-svn-id: svn://svn.freebsd.org/base/stable/10@318497 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

6 years agoMFC: r315598
marius [Thu, 18 May 2017 20:46:27 +0000 (20:46 +0000)]
MFC: r315598

o Add support for eMMC DDR bus speed mode up to 52 MHz to sdhci(4)
  and mmc(4). Given that support for DDR52 is not denoted by SDHCI
  capability registers, availability of that timing is indicated by
  a new quirk SDHCI_QUIRK_MMC_DDR52 and only enabled for Intel SDHCI
  controllers so far.

  Compared to 50 MHz at SDR high speed typically yielding ~45 MB/s
  read throughput with the eMMC chips tested, read performance goes
  up to ~80 MB/s at DDR52.

  As a side-effect, this change also fixes communication with some
  eMMC devices at SDR high speed mode due to the signaling voltage
  and UHS bits in the SDHCI controller no longer being left in an
  inappropriate state.

o In sdhci(4), add two tunables hw.sdhci.quirk_clear as well as
  hw.sdhci.quirk_set, which (when hooked up in the front-end)
  allow to set/clear sdhci(4) quirks for debugging and testing
  purposes. However, especially for SDHCI controllers on the
  PCI bus which have no specific support code so far and, thus,
  are picked up as generic SDHCI controllers, hw.sdhci.quirk_set
  allows for setting the necessary quirks (if required).

o In mmc(4), check and handle the return values of some more
  function calls instead of assuming that everything went right.
  In case failures actually are not problematic, indicate that
  by casting the return value to void.

git-svn-id: svn://svn.freebsd.org/base/stable/10@318495 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

6 years agoMFC r317782,318181:
mm [Thu, 18 May 2017 19:50:15 +0000 (19:50 +0000)]
MFC r317782,318181:

MFC r317782 (mm):
  Sync libarchive with vendor

  Vendor changes (FreeBSD-related):
    PR 897: add test for ZIP archives with invalid EOCD headers
    PR 901: fix invalid renaming of sparse files
    OSS-Fuzz issue 497: remove fallback tree in LZX decoder
    OSS-Fuzz issue 527: rewrite expressions in lz4 filter
    OSS-Fuzz issue 577: fix integer overflow in cpio reader
    OSS-Fuzz issue 862: fix numerc parsing in mtree reader
    OSS-Fuzz issue 1097: fix undefined shift in rar reader
    cpio: various optimizations and memory leak fixes

MFC r318181 (ngie) (2):
  cpio/tests/test_option_lz4: fix a use after free in the failure case

Reported by: Coverity (2)
Sponsored by: Dell EMC Isilon (2)

git-svn-id: svn://svn.freebsd.org/base/stable/10@318483 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

6 years agoMFC r318294:
gjb [Thu, 18 May 2017 12:27:41 +0000 (12:27 +0000)]
MFC r318294:
 Correct the URL to instructions for updating system sources.

PR: 219303
Sponsored by: The FreeBSD Foundation

git-svn-id: svn://svn.freebsd.org/base/stable/10@318447 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

6 years agoRevert the partial MFC of r313045 which broke dtrace
smh [Thu, 18 May 2017 03:32:01 +0000 (03:32 +0000)]
Revert the partial MFC of r313045 which broke dtrace

This removes the mbuf to ipinfo_t translator and switches tcp_autorcvbuf to
use the older mtod macro.

This was originally merged to stable/10 as part of r317375.

Reported by: markj
Reviewed by: markj, hiren
Sponsored by: Multiplay
Differential Revision:  https://reviews.freebsd.org/D10769

git-svn-id: svn://svn.freebsd.org/base/stable/10@318438 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

6 years agoMFC 317783
sephe [Thu, 18 May 2017 01:42:55 +0000 (01:42 +0000)]
MFC 317783
    hyperv/kvp: Fix pool direcrory and file permission

    PR: 209385
    Sponsored by: Microsoft

git-svn-id: svn://svn.freebsd.org/base/stable/10@318435 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

6 years agoMFC r318160, 318176: Persistently store NIC's hardware MAC address, and add
rpokala [Wed, 17 May 2017 22:29:25 +0000 (22:29 +0000)]
MFC r318160, 318176: Persistently store NIC's hardware MAC address, and add
a way to retrive it

NOTE: Due to restructuring, the merges didn't apply cleanly; the resulting
change is almost identical to what went into stable/11, but in some cases in
different locations.

The MAC address reported by `ifconfig ${nic} ether' does not always match
the address in the hardware, as reported by the driver during attach. In
particular, NICs which are components of a lagg(4) interface all report the
same MAC.

When attaching, the NIC driver passes the MAC address it read from the
hardware as an argument to ether_ifattach(). Keep a second copy of it, and
create ioctl(SIOCGHWADDR) to return it. Teach `ifconfig' to report it along
with the active MAC address.

PR: 194386

git-svn-id: svn://svn.freebsd.org/base/stable/10@318430 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

6 years agoMFC 318136
sephe [Wed, 17 May 2017 02:40:06 +0000 (02:40 +0000)]
MFC 318136

    hyperv/vmbus: Reorganize vmbus device tree

    For GEN1 Hyper-V, vmbus is attached to pcib0, which contains the
    resources for PCI passthrough and SR-IOV.  There is no
    acpi_syscontainer0 on GEN1 Hyper-V.

    For GEN2 Hyper-V, vmbus is attached to acpi_syscontainer0, which
    contains the resources for PCI passthrough and SR-IOV.  There is
    no pcib0 on GEN2 Hyper-V.

    The ACPI VMBUS device now only holds its _CRS, which is empty as
    of this commit; its existence is mainly for upward compatibility.

    Device tree structure is suggested by jhb@.

    Tested-by: dexuan@
    Collabrated-wth: dexuan@
    Sponsored by: Microsoft
    Differential Revision: https://reviews.freebsd.org/D10565

git-svn-id: svn://svn.freebsd.org/base/stable/10@318393 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

6 years agoMFC r318283:
cy [Wed, 17 May 2017 01:45:26 +0000 (01:45 +0000)]
MFC r318283:

As of r318281 in HEAD (r318390 [in stable/10 & stable/11]), there is no
need to put a colon (:) in the message string.

git-svn-id: svn://svn.freebsd.org/base/stable/10@318391 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

6 years agoMFC r318281:
cy [Wed, 17 May 2017 01:38:32 +0000 (01:38 +0000)]
MFC r318281:

Separate the ipfilter function/static string from the error with a
colon (:) in error messages to assist the user in parsing out the error
from where or which object the error message refers to.

git-svn-id: svn://svn.freebsd.org/base/stable/10@318390 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

6 years agoMFC r318259:
dim [Tue, 16 May 2017 18:54:25 +0000 (18:54 +0000)]
MFC r318259:

Silence a -Wunused warning about the junk variable being used to raise
an inexact floating point exception.  The variable cannot be eliminated,
unfortunately, otherwise the desired addition triggering the exception
will be emitted neither by clang, nor by gcc.

Reviewed by: Steve Kargl, bde

git-svn-id: svn://svn.freebsd.org/base/stable/10@318365 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

6 years agoMFC r317660, r317710
brooks [Mon, 15 May 2017 23:13:49 +0000 (23:13 +0000)]
MFC r317660, r317710

r317660:
Support clnt_raw's use of FD_SETSIZE as a fake file descriptor.

Accomplish this by allocating space for it in __svc_xports and allowing
it to be registered.  The failure to allocate space was causing an
out-of-bounds read in svc_getreq_common().  The failure to register
caused PR 211804.

The bug was found with CHERI bounds checking.

PR: 211804
Obtained from: CheriBSD
Sponsored by: DARPA, AFRL
Reviewed by: ngie
Differential Revision: https://reviews.freebsd.org/D10528

r317710:
Remove expected failure now that it was fixed in r317660.

PR: 211804
Reviewed by: ngie
Obtained from: CheriBSD
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D10576

git-svn-id: svn://svn.freebsd.org/base/stable/10@318327 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

6 years agoMFC r317845-r317846
brooks [Mon, 15 May 2017 22:50:54 +0000 (22:50 +0000)]
MFC r317845-r317846

r317845:
Provide a freebsd32 implementation of sigqueue()

The previous misuse of sys_sigqueue() was sending random register or
stack garbage to 64-bit targets.  The freebsd32 implementation preserves
the sival_int member of value when signaling a 64-bit process.

Document the mixed ABI implementation of union sigval and the
incompability of sival_ptr with pointer integrity schemes.

Reviewed by: kib, wblock
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D10605

r317846:
Regen post r317845.

MFC with: r317845
Sponsored by: DARPA, AFRL

git-svn-id: svn://svn.freebsd.org/base/stable/10@318323 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

6 years agoMFC r317658:
bdrewery [Mon, 15 May 2017 18:41:12 +0000 (18:41 +0000)]
MFC r317658:

  Redo r288270: Hookup mkcsmapper_static and mkesdb_static for 'make clean'

git-svn-id: svn://svn.freebsd.org/base/stable/10@318311 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

6 years agoMFC r317996
davidcs [Mon, 15 May 2017 18:21:36 +0000 (18:21 +0000)]
MFC r317996
    Fix bug where MTX_DEF lock was held while taskqueue_drain() was invoked.
    Check IFF_DRV_RUNNING flag is set prior to calling ql_hw_set_multi()

git-svn-id: svn://svn.freebsd.org/base/stable/10@318308 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

6 years agoMFC r318126
davidcs [Mon, 15 May 2017 17:48:58 +0000 (17:48 +0000)]
MFC r318126
    llh_func_filter needs to be configured for 100G

git-svn-id: svn://svn.freebsd.org/base/stable/10@318301 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

6 years agoMFC r318185:
ken [Mon, 15 May 2017 15:27:59 +0000 (15:27 +0000)]
MFC r318185:

  Add LTO-8 density codes.

  lib/libmt/mtlib.c:
   Add the LTO-8 density code to the density table in libmt.

  usr.bin/mt/mt.1:
   Add the LTO-8 density code, tracks, bpmm, and bpi to the density
   table in the mt(1) man page.

Sponsored by: Spectra Logic

git-svn-id: svn://svn.freebsd.org/base/stable/10@318295 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

6 years agoMFC: r317982
marius [Sun, 14 May 2017 14:21:11 +0000 (14:21 +0000)]
MFC: r317982

- Also outside of the KOBJOPLOOKUP macro - which in turn is used by
  the code auto-generated for *.m - kobj_lookup_method(9) is useful;
  for example in back-ends or base class device drivers in order to
  determine whether a default method has been overridden. Thus, allow
  for the kobj_method_t pointer argument - used by KOBJOPLOOKUP in
  order to update the cache entry - of kobj_lookup_method(9), to be
  NULL. Actually, that pointer is redundant as it's just set to the
  same kobj_method_t that the kobj_lookup_method(9) function returns
  in the first place, but probably it serves to reduce the number of
  instructions generated for KOBJOPLOOKUP.
- For the same reason, move updating kobj_lookup_{hits,misses} (if
  KOBJ_STATS is defined) from kobj_lookup_method(9) to KOBJOPLOOKUP.
  As a side-effect, this gets rid of the convoluted approach of always
  incrementing kobj_lookup_hits in KOBJOPLOOKUP and then in case of
  a cache miss, decrementing it in kobj_lookup_method(9) again.

git-svn-id: svn://svn.freebsd.org/base/stable/10@318275 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

6 years agoMFC: r317578
marius [Sun, 14 May 2017 14:04:32 +0000 (14:04 +0000)]
MFC: r317578

Fix a bug introduced as part of r287726 (MFCed to stable/10 in
r292789); use the right device_t for determining the softc of
the bridge in psycho_route_interrupt(). [1]
While at it, update the corresponding comment that the code in
question is also necessary for U30s in addition to E450s (a fact
that has been known for ages).

PR: 218478 [1]
Submitted by: Yoshihiko Iwama [1]

git-svn-id: svn://svn.freebsd.org/base/stable/10@318273 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

6 years agoMFC: r317343
marius [Sun, 14 May 2017 13:59:40 +0000 (13:59 +0000)]
MFC: r317343

In fill_ip6(), the value of the pointer av changes before it is
free(3)ed. Thus, introduce a new variable to track the original
value.

git-svn-id: svn://svn.freebsd.org/base/stable/10@318271 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

6 years agoMFC r317908:
kib [Sun, 14 May 2017 12:00:00 +0000 (12:00 +0000)]
MFC r317908:
Remove spl() calls from UFS code.

git-svn-id: svn://svn.freebsd.org/base/stable/10@318267 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

6 years agoMFC r318190:
gjb [Sun, 14 May 2017 10:15:04 +0000 (10:15 +0000)]
MFC r318190:
 Update release/scripts/atlas-upload.sh to account for API changes
 made recently by Atlas Hashicorp.  The data returned from GET and
 POST requests has changed, which caused a number of regex patterns
 to fail to be properly identified as 'success' or 'failure', which
 ended up in upload/publish failures.

Sponsored by: The FreeBSD Foundation

git-svn-id: svn://svn.freebsd.org/base/stable/10@318264 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

6 years agoMFC: r317576
rmacklem [Sun, 14 May 2017 00:23:27 +0000 (00:23 +0000)]
MFC: r317576
Modify the NFSv4.1/pNFS client to ask for a maximum length of layout.

The code specified the length of a layout as INT64_MAX instead of
UINT64_MAX. This could result in getting a layout for less than the
full file for extremely large files. Although having little practical
effect, this patch corrects this in the code.
Detected during recent testing of the pNFS server.

git-svn-id: svn://svn.freebsd.org/base/stable/10@318261 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

6 years agoMFC 317786
sephe [Fri, 12 May 2017 03:44:20 +0000 (03:44 +0000)]
MFC 317786

    pcicfg: Fix direct calls of pci_cfg{read,write} on systems w/o PCI host bridge.

    Reported by:    dexuan@
    Reviewed by:    jhb@
    Sponsored by:   Microsoft
    Differential Revision: https://reviews.freebsd.org/D10564

git-svn-id: svn://svn.freebsd.org/base/stable/10@318208 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

6 years agoMFC 317830:
cy [Fri, 12 May 2017 02:32:01 +0000 (02:32 +0000)]
MFC 317830:

Ifdef out a redundant if statement when INET6 is disabled.

git-svn-id: svn://svn.freebsd.org/base/stable/10@318206 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

6 years agoRevert r318203: Neglected to put "MFC 318203:" in the log.
cy [Fri, 12 May 2017 02:26:39 +0000 (02:26 +0000)]
Revert r318203: Neglected to put "MFC 318203:" in the log.

Pointy hat to: cy

git-svn-id: svn://svn.freebsd.org/base/stable/10@318205 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

6 years agoIfdef out a redundant if statement when INET6 is disabled.
cy [Fri, 12 May 2017 02:12:03 +0000 (02:12 +0000)]
Ifdef out a redundant if statement when INET6 is disabled.

git-svn-id: svn://svn.freebsd.org/base/stable/10@318203 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

6 years agoMFC: r315431
marius [Thu, 11 May 2017 21:13:06 +0000 (21:13 +0000)]
MFC: r315431

- Adds macros for the content of SDHCI_ADMA_ERR and SDHCI_HOST_CONTROL2
  registers.
- Add slot type capability bits. These bits should allow recognizing
  removable card slots, embedded cards and shared buses (shared bus
  supposedly is always comprised of non-removable cards).
- Dump CAPABILITIES2, ADMA_ERR, HOST_CONTROL2 and ADMA_ADDRESS_LO
  registers in sdhci_dumpregs().
- The drive type support flags in the CAPABILITIES2 register are for
  drive types A,C,D, drive type B is the default setting (value 0) of
  the drive strength field in the SDHCI_HOST_CONTROL2 register.

Obtained from: DragonFlyBSD (9e3c8f63455bd1b1)

git-svn-id: svn://svn.freebsd.org/base/stable/10@318200 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

6 years agoMFC: r292180 (partial), r297127 (partial), r311911, r311923, r312939,
marius [Thu, 11 May 2017 21:01:02 +0000 (21:01 +0000)]
MFC: r292180 (partial), r297127 (partial), r311911, r311923, r312939,
     r313250, r313712, r314811 (partial), r314887 (partial), r315430,
     r317981, r315466

o Move the DRIVER_MODULE() statements that declare mmc(4) to be a child
  of the various bridge drivers out of dev/mmc.c and into the bridge
  drivers.

o Add ACPI platform support for SDHCI driver.

o Fix some overly long lines, whitespace and other bugs according to
  style(9) as well as spelling etc. in mmc(4), mmcsd(4) and sdhci(4).

o In the mmc(4) bridges and sdhci(4) (bus) front-ends:
  - Remove redundant assignments of the default bus_generic_print_child
    device method,
  - use DEVMETHOD_END,
  - use NULL instead of 0 for pointers.

o Trim/adjust includes.

o Add and use a MMC_DECLARE_BRIDGE macro for declaring mmc(4) bridges
  as kernel drivers and their dependency onto mmc(4).

o Add support for eMMC "partitions". Besides the user data area, i. e.
  the default partition, eMMC v4.41 and later devices can additionally
  provide up to:
  1 enhanced user data area partition
  2 boot partitions
  1 RPMB (Replay Protected Memory Block) partition
  4 general purpose partitions (optionally with a enhanced or extended
    attribute)

  Besides simply subdividing eMMC devices, some Intel NUCs having UEFI
  code in the boot partitions etc., another use case for the partition
  support is the activation of pseudo-SLC mode, which manufacturers of
  eMMC chips typically associate with the enhanced user data area and/
  or the enhanced attribute of general purpose partitions.

  CAVEAT EMPTOR: Partitioning eMMC devices is a one-time operation.

o Now that properly issuing CMD6 is crucial (so data isn't written to
  the wrong partition for example), make a step into the direction of
  correctly handling the timeout for these commands in the MMC layer.
  Also, do a SEND_STATUS when CMD6 is invoked with an R1B response as
  recommended by relevant specifications.

o Add an IOCTL interface to mmcsd(4); this is sufficiently compatible
  with Linux so that the GNU mmc-utils can be ported to and used with
  FreeBSD (note that due to the remaining deficiencies outlined above
  SANITIZE operations issued by/with `mmc` currently most likely will
  fail). These latter have been added to ports as sysutils/mmc-utils.
  Among others, the `mmc` tool of mmc-utils allows for partitioning
  eMMC devices (tested working).

o For devices following the eMMC specification v4.41 or later, year 0
  is 2013 rather than 1997; so correct this for assembling the device
  ID string properly.

o Let mmcsd.ko depend on mmc.ko. Additionally, bump MMC_VERSION as at
  least for some of the above a matching pair is required.

git-svn-id: svn://svn.freebsd.org/base/stable/10@318198 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

6 years agoMFC 313407,313449: Copy ELF machine/flags from binaries to core dumps.
jhb [Thu, 11 May 2017 17:26:34 +0000 (17:26 +0000)]
MFC 313407,313449: Copy ELF machine/flags from binaries to core dumps.

313407:
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).

313449:
Trim trailing whitespace (mostly introduced in r313407).

Sponsored by: DARPA / AFRL

git-svn-id: svn://svn.freebsd.org/base/stable/10@318192 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

6 years agoMFC r317584:
hselasky [Thu, 11 May 2017 13:50:16 +0000 (13:50 +0000)]
MFC r317584:
Correct manual page link to usbdi(9).

git-svn-id: svn://svn.freebsd.org/base/stable/10@318187 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

6 years agoMFC 313999: Consolidate statements to initialize files.
jhb [Thu, 11 May 2017 04:29:20 +0000 (04:29 +0000)]
MFC 313999: Consolidate statements to initialize files.

Previously, the first lines of various generated files from system call
tables were generated in two sections.  Some of the initialization was
done in BEGIN, and the rest was done when the first line was encountered.
The main reason for this split before r313564 was that most of the
initialization done in the second section depended on the $FreeBSD$ tag
extracted from the system call table.  Now that the $FreeBSD$ tag is no
longer used, consolidate all of the file initialization in the BEGIN
section.

This change was tested by confirming that the content of generated files
did not change.

git-svn-id: svn://svn.freebsd.org/base/stable/10@318172 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

6 years agoMFC 316493: Assert that the align parameter to uma_zcreate() is valid.
jhb [Thu, 11 May 2017 03:37:05 +0000 (03:37 +0000)]
MFC 316493: Assert that the align parameter to uma_zcreate() is valid.

git-svn-id: svn://svn.freebsd.org/base/stable/10@318169 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

6 years agoMFC 314894: Fix a couple of typos and reword some sentences in bsd.README.
jhb [Wed, 10 May 2017 23:14:09 +0000 (23:14 +0000)]
MFC 314894: Fix a couple of typos and reword some sentences in bsd.README.

git-svn-id: svn://svn.freebsd.org/base/stable/10@318165 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

6 years agoMFC 313564:
jhb [Wed, 10 May 2017 23:09:17 +0000 (23:09 +0000)]
MFC 313564:
Drop the "created from" line from files generated by makesyscalls.sh.

This information is less useful when the generated files are included in
source control along with the source.  If needed it can be reconstructed
from the $FreeBSD$ tag in the generated file.  Removing this information
from the generated output permits committing the generated files along
with the change to the system call master list without having inconsistent
metadata in the generated files.

Regenerate the affected files along with the MFC.

git-svn-id: svn://svn.freebsd.org/base/stable/10@318164 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

6 years agoMFC: r287013 (partial), r294616, r314097 (partial)
marius [Wed, 10 May 2017 21:42:16 +0000 (21:42 +0000)]
MFC: r287013 (partial), r294616, r314097 (partial)

- Allow overriding the FDT slicer with a custom slicer.
- Teach the flashmap code about SPI flash.
- Allow different slicers for different flash types to be registered
  with geom_flashmap(4) and teach it about MMC for slicing enhanced
  user data area partitions. The FDT slicer still is the default for
  CFI, NAND and SPI flash on FDT-enabled platforms.
- In addition to a device_t, also pass the name of the GEOM provider
  in question to the slicers as a single device may provide more than
  one provider.
- Build a geom_flashmap.ko.
- Use MODULE_VERSION() so other modules can depend on geom_flashmap(4).
- Remove redundant/superfluous GEOM routines that either do nothing
  or provide/just call default GEOM (slice) functionality.
- Trim/adjust includes

git-svn-id: svn://svn.freebsd.org/base/stable/10@318159 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

6 years agoMFC: r292420
marius [Wed, 10 May 2017 21:11:15 +0000 (21:11 +0000)]
MFC: r292420

Make SYSCTL hw.mmc.debug tunable, since often you want to debug the
bus probing during system startup.

git-svn-id: svn://svn.freebsd.org/base/stable/10@318157 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

6 years agoMFC: r311817
marius [Wed, 10 May 2017 20:46:59 +0000 (20:46 +0000)]
MFC: r311817

In dummynet(4), random chunks of memory are casted to struct dn_*,
potentially leading to fatal unaligned accesses on architectures with
strict alignment requirements. This change fixes dummynet(4) as far
as accesses to 64-bit members of struct dn_* are concerned, tripping
up on sparc64 with accesses to 32-bit members happening to be correctly
aligned there. In other words, this only fixes the tip of the iceberg;
larger parts of dummynet(4) still need to be rewritten in order to
properly work on all of !x86.
In principle, considering the amount of code in dummynet(4) that needs
this erroneous pattern corrected, an acceptable workaround would be to
declare all struct dn_* packed, forcing compilers to do byte-accesses
as a side-effect. However, given that the structs in question aren't
laid out well either, this would break ABI/KBI.
While at it, replace all existing bcopy(9) calls with memcpy(9) for
performance reasons, as there is no need to check for overlap in these
cases.

PR: 189219

git-svn-id: svn://svn.freebsd.org/base/stable/10@318155 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

6 years agoMFC: r310712
marius [Wed, 10 May 2017 20:29:01 +0000 (20:29 +0000)]
MFC: r310712

- Use correct offsets into the keys set array. As the elements of this
  zero-length array are dynamically sized at run-time based on the use
  of hints, compilers can't be expected to figure out these offsets on
  their own. [1]
- Fix incorrect comparison in cmp_nans(). [2]

PR: 204571 [1], 202301 [2]
Submitted by: David Binderman [2]

git-svn-id: svn://svn.freebsd.org/base/stable/10@318152 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

6 years agoMFC: r293642
marius [Wed, 10 May 2017 20:12:23 +0000 (20:12 +0000)]
MFC: r293642

- Add support for Advantech PCI-1602 Rev. B1 and PCI-1603 cards. [1]
- Add a description of Advantech PCI-1602 Rev. A boards. [1]
- Properly set up REG_ACR also for PCI-1602 Rev. A based on what the
  Advantech-supplied Linux driver does.
- Additionally use the macros of <dev/ic/ns16550.h> to replace existing
  magic values and get rid of trivial comments.
- Fix the style of some comments.

PR: 205359 [1]
Submitted by: Jan Mikkelsen (original patch) [1]

git-svn-id: svn://svn.freebsd.org/base/stable/10@318151 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

6 years agoMFC r317740:
ken [Wed, 10 May 2017 18:59:20 +0000 (18:59 +0000)]
MFC r317740:

  Correct loop mode CRN resets to adhere to FCP-4 section 4.10

  Prior to this change, the CRN (Command Reference Number) is reset on any
  firmware LIP, LOOP DOWN, or LOOP RESET event in violation of FCP-4 which
  specifies that the CRN should only be reset in response to a LIP Reset
  (LIPyx) primitive. FCP-4 also indicates PLOGI/LOGO and PRLI/PRLO ELS
  actions as conditions for resetting the CRN for the associated initiator
  port.

  These violations manifest themselves when the HBA is removed from the
  loop, or a target device is removed (especially during an outstanding
  command) without power cycling. If the HBA and and the target device
  determine upon re-establishing the loop that no PLOGI or PRLI is
  required, and the target does not issue a LIPxy to the initiator, the
  CRN for the target will have been improperly reset by the isp driver. As
  a result, the target port will silently ignore all FCP commands issued
  during the device probe (which will time out) preventing the device from
  attaching.

  This change corrects thie CRN reset behavior in response to loop state
  changes, also introduces CRN resets for the above mentioned ELS actions
  as encountered through async PDB change events.

  This change also adds cleanup of outstanding commands in isp_loop_dead()
  that was previously missing.

  sys/dev/isp/isp.c
   Add the last login state to debug output when syncing the pdb

  sys/dev/isp/isp_freebsd.c
   Replace binary statement setting aborted ccb status in
   isp_watchdog() with the XS_SETERR macro used elsewhere

   In isp_loop_dead(), abort or complete pending commands as done
   in isp_watchdog()

   In isp_async(), segregate the ISPASYNC_LOOP_RESET action from
   ISPASYNC_LIP, ISPASYNC_LOOP_DOWN, and ISPASYNC_LOOP_UP
   fallthroughs, and only reset the CRN in the RESET case. Also add
   checks to handle false LOOP RESET actions that do not have a
   proper associated LIP primitive, and log the primitive in the
   debug messages

   In isp_async(), remove the goto from ISP_ASYNC_DEV_STAYED, and
   only reset the CRN in the DEV_CHANGED action

   In isp_async(), when processing an ISPASYNC_CHANGE_PDB status,
   reset CRN(s) for the associated nphdl (or all ports) if the
   change reason is some form of ELS login/logout. Also remove
   assignment to fc since it is not used in the scope

  sys/dev/isp/ispmbox.h
   Add macro definition for the global N-Port handle, and correct a
   macro typo 'PDB24XX_AE_PRLI_DONJE'

  sys/dev/isp/ispvar.h
   Add macros FCP_AL_DA_ALL, FCP_AL_PA, and FCP_IS_DEST_ALPD for
   more legible code when determining if an AL_PD port matches the
   portid for a given struct fcparam* by value or by virtue of the
   AL_PD port being 0xFF

Submitted by: Reid Linnemann
Sponsored by: Spectra Logic

git-svn-id: svn://svn.freebsd.org/base/stable/10@318149 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

6 years agoMFC 313409: Defer startup of gjournal switcher kproc.
jhb [Wed, 10 May 2017 16:32:12 +0000 (16:32 +0000)]
MFC 313409: Defer startup of gjournal switcher kproc.

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

git-svn-id: svn://svn.freebsd.org/base/stable/10@318145 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

6 years agoMFC r317775:
ken [Wed, 10 May 2017 15:20:39 +0000 (15:20 +0000)]
MFC r317775:

  Fix error recovery behavior in the pass(4) driver.

  After FreeBSD SVN revision 236814, the pass(4) driver changed from
  only doing error recovery when the CAM_PASS_ERR_RECOVER flag was
  set on a CCB to sometimes doing error recovery if the passed in
  retry count was non-zero.

  Error recovery would happen if two conditions were met:

  1.  The error recovery action was simply a retry.  (Which is most
      cases.)
  2.  The retry_count is non-zero. (Which happened a lot because of
      cut-and-pasted code.)

  This explains a bug I noticed in with camcontrol:

  # camcontrol tur da34 -v
  Unit is ready
  # camcontrol reset da34
  Reset of 1:172:0 was successful

  At this point, there should be a Unit Attention:

  # camcontrol tur da34 -v
  Unit is ready

  No Unit Attention.

  Try it again:

  # camcontrol reset da34
  Reset of 1:172:0 was successful

  Now set the retry_count to 0 for the TUR:

  # camcontrol tur da34 -v -C 0
  Unit is not ready
  (pass42:mps1:0:172:0): TEST UNIT READY. CDB: 00 00 00 00 00 00
  (pass42:mps1:0:172:0): CAM status: SCSI Status Error
  (pass42:mps1:0:172:0): SCSI status: Check Condition
  (pass42:mps1:0:172:0): SCSI sense: UNIT ATTENTION asc:29,2 (SCSI bus reset
  occurred)
  (pass42:mps1:0:172:0): Field Replaceable Unit: 2

  There is the unit attention. camcontrol(8) has a default
  retry_count of 1, in case someone sets the -E flag without
  setting -C.

  The CAM_PASS_ERR_RECOVER behavior was only broken with the
  CAMIOCOMMAND ioctl, which is the synchronous pass(4) API.  It has
  worked as intended (error recovery is only done when the flag
  is set) in the asynchronous API (CAMIOQUEUE ioctl).

  sys/cam/scsi/scsi_pass.c:
   In passsendccb(), when calling cam_periph_runccb(), only
   specify the error routine when CAM_PASS_ERR_RECOVER is set.

  share/man/man4/pass.4:
   Document that CAM_PASS_ERR_RECOVER is needed to enable
   error recovery.

Reported by: Terry Kennedy <TERRY@glaver.org>
PR: kern/218572
Sponsored by: Spectra Logic

git-svn-id: svn://svn.freebsd.org/base/stable/10@318140 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

6 years agoMFC: r317465
rmacklem [Wed, 10 May 2017 01:39:21 +0000 (01:39 +0000)]
MFC: r317465
Fix handling of a NFSv4.1 callback reply from the session cache.

The nfsv4_seqsession() call returns NFSERR_REPLYFROMCACHE when it has a
reply in the session, due to a requestor retry. The code erroneously
assumed a return of 0 for this case. This patch fixes this and adds
a KASSERT(). This would be an extremely rare occurrence. It was found
during code inspection during the pNFS server development.

git-svn-id: svn://svn.freebsd.org/base/stable/10@318128 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

6 years agoDocument SA-17:04.
gjb [Tue, 9 May 2017 23:28:42 +0000 (23:28 +0000)]
Document SA-17:04.

Sponsored by: The FreeBSD Foundation

git-svn-id: svn://svn.freebsd.org/base/stable/10@318120 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

6 years agoMFC r303450:
bdrewery [Tue, 9 May 2017 19:14:26 +0000 (19:14 +0000)]
MFC r303450:

  Pull a copy of the input string before calling basename() and dirname().

git-svn-id: svn://svn.freebsd.org/base/stable/10@318096 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

6 years agoMFC r306771:
bdrewery [Tue, 9 May 2017 18:15:29 +0000 (18:15 +0000)]
MFC r306771:

  Improve grammar.

git-svn-id: svn://svn.freebsd.org/base/stable/10@318071 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

6 years agoMFC r317888 and two upstream prerequisites:
dim [Tue, 9 May 2017 16:58:08 +0000 (16:58 +0000)]
MFC r317888 and two upstream prerequisites:

Pull in r227097 from upstream libc++ trunk (by Marshall Clow):

  Fix PR21428. Buffer was one byte too small in octal formatting case.
  Add test

Pull in r268009 from upstream libc++ trunk (by Eric Fiselier):

  Fix PR21428 for long. Buffer was one byte too small in octal
  formatting case. Rename previously added test

Pull in r302362 from upstream libc++ trunk (by me):

  Ensure showbase does not overflow do_put buffers

  Summary:
  In https://bugs.freebsd.org/207918, Daniel McRobb describes how using
  std::showbase with ostreams can cause truncation of unsigned long long
  when output format is octal.  In fact, this can even happen with
  unsigned int and unsigned long.

  To ensure this does not happen, add one additional character to the
  do_put buffers if std::showbase is on.  Also add a test case.

  Reviewers: EricWF, mclow.lists

  Reviewed By: EricWF

  Subscribers: cfe-commits, emaste

  Differential Revision: https://reviews.llvm.org/D32670

PR: 207918

git-svn-id: svn://svn.freebsd.org/base/stable/10@318031 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

6 years agoMFC r317707:
brooks [Tue, 9 May 2017 16:29:06 +0000 (16:29 +0000)]
MFC r317707:

Correct an out-of-bounds read in regcomp when the RE is bad.

When passed the invalid regular expression "a**", the error is
eventually detected and seterr() is called. It sets p->error
appropriatly and p->next and p->end to nuls which is a never used char
nuls[10] which is zeros due to .bss initialization. Unfortunatly,
p_ere_exp() and p_simp_re() both have fall through cases where they set
the error, decrement p->next and access it which means a read from
whatever .bss variable comes before nuls.

Found with regex_test:repet_multi and CHERI bounds checking.

Reviewed by: ngie, pfg, emaste
Obtained from: CheriBSD
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D10541

git-svn-id: svn://svn.freebsd.org/base/stable/10@318030 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

6 years agoixv(4): Fix more tinderbox builds by adding missing declarations.
erj [Tue, 9 May 2017 00:51:10 +0000 (00:51 +0000)]
ixv(4): Fix more tinderbox builds by adding missing declarations.

Sponsored by: Intel Corporation

git-svn-id: svn://svn.freebsd.org/base/stable/10@317995 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

6 years agoMFC r317180
davidcs [Mon, 8 May 2017 22:41:13 +0000 (22:41 +0000)]
MFC r317180
  Cleanup QLA_LOCK/QLA_UNLOCK macros
  remove unused QLA_TX_LOCK/QLA_TX_UNLOCK macros
  format qla_error_recovery()

git-svn-id: svn://svn.freebsd.org/base/stable/10@317991 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

6 years agoMFC: r317382
rmacklem [Mon, 8 May 2017 21:58:29 +0000 (21:58 +0000)]
MFC: r317382
Allow use of a write open stateid for reading in the NFSv4 server.

The NFSv4 RFCs give a server the option of allowing the use of an open
stateid for write access to be used for a Read operation.
This patch enables this by default and adds a sysctl to disable it,
for anyone who does not want this capability.
Allowing this is particularily useful for a pNFS Data Server (DS), since
they are not permitted to allow the use of special stateids.
Discovered during recent testing of the pNFS server under development.

git-svn-id: svn://svn.freebsd.org/base/stable/10@317986 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

6 years agoMFC: r317345
rmacklem [Mon, 8 May 2017 21:40:42 +0000 (21:40 +0000)]
MFC: r317345
Make the NFSv4 client to use a write open for reading if allowed by the server.

An NFSv4 server has the option of allowing a Read to be done using a Write
Open. If this is not allowed, the server will return NFSERR_OPENMODE.
This patch attempts the read with a write open and then disables this
if the server replies NFSERR_OPENMODE.
This change will avoid some uses of the special stateids. This will be
useful for pNFS/DS Reads, since they cannot use special stateids.
It will also be useful for any NFSv4 server that does not support reading
via the special stateids. It has been tested against both types of NFSv4 server.

git-svn-id: svn://svn.freebsd.org/base/stable/10@317984 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

6 years agoMFC: r317305
rmacklem [Mon, 8 May 2017 20:30:30 +0000 (20:30 +0000)]
MFC: r317305
Fix the NFSv4.1/pNFS client return layout on close.

The "return layout on close" case in the pNFS client was badly broken.
Fortunately, extant pNFS servers that I have tested against do not
do this. This patch fixes it. It also changes the way the layout stateid.seqid
is set for LayoutReturn. I think this change is correct w.r.t. the RFC,
but I am not 100% sure.
This was found during recent testing of the pNFS server under development.

git-svn-id: svn://svn.freebsd.org/base/stable/10@317978 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

6 years agoMFC: r317296
rmacklem [Mon, 8 May 2017 19:57:43 +0000 (19:57 +0000)]
MFC: r317296
Fix some krpc leaks for the NFSv4.1/pNFS client.

The NFSv4.1/pNFS client wasn't doing a newnfs_disconnect() call for the
connection to the Data Server (DS) under some circumstances. The main
effect of this was a leak of malloc'd structures in the krpc. This patch
adds the newnfs_disconnect() calls to fix this.
Detected during recent testing against the pNFS server under development.

git-svn-id: svn://svn.freebsd.org/base/stable/10@317975 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

6 years agoMFC r317854:
ken [Mon, 8 May 2017 18:30:56 +0000 (18:30 +0000)]
MFC r317854:

  When editing a mode page on a tape drive, do not clear the device
  specific parameter.

  Tape drives include write protect (WP), Buffered Mode and Speed
  settings in the device-specific parameter.  Clearing this
  parameter on a mode select can have the effect of turning off
  write protect or buffered mode, or changing the speed setting of
  the tape drive.

  Disks report DPO/FUA support via the device specific parameter
  for MODE SENSE, but the bit is reserved for MODE SELECT.  So we
  clear this for disks (and other non-tape devices) to avoid
  potential errors from the target device.

  sbin/camcontrol/modeedit.c:
   Clear the device-specific parameter in the mode page
   header if we're not operating on a tape drive.

Sponsored by: Spectra Logic

git-svn-id: svn://svn.freebsd.org/base/stable/10@317966 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

6 years agoMFC r317848:
ken [Mon, 8 May 2017 17:55:51 +0000 (17:55 +0000)]
MFC r317848:

  Add basic programmable early warning error injection to the sa(4) driver.

  This will help application developers simulate end of tape conditions.

  To inject an error in sa0:

  sysctl kern.cam.sa.0.inject_eom=1

  This will return the next read or write request queued with 0 bytes
  written.  Any subsequent writes or reads will go along as usual.

  This will also cause the early warning position flag to get set
  for the next position query.  So, 'mt status' will show the BPEW
  (Beyond Programmable Early Warning) flag on the first query after
  an error injection.  After that, the position flags will be as they
  are in the underlying tape drive.

  Also, update the sa(4) man page to describe tape parameters,
  which can be set via 'mt param'.

  sys/cam/scsi/scsi_sa.c:
   In saregister(), create the inject_eom sysctl variable.

   In sastart(), check to see whether inject_eom is set.  If
   so, return the read or write with 0 bytes written to
   indicate EOM.  Set the set_pews_status flag so that we
   fake PEWS status in the next position call for reads, and the
   next 3 calls for writes.  This allows the user to see the BPEW
   flag one time via 'mt status'.

   In sagetpos(), check the set_pews_status flag and fake
   PEWS status and decrement the counter if it is set.

  share/man/man4/sa.4:
   Document the inject_eom sysctl variable.

   Document all of the parameters currently supported via
   'mt param'.

  usr.bin/mt/mt.1:
   Point the user to the sa(4) man page for more details on
   supported parameters.

Sponsored by: Spectra Logic

git-svn-id: svn://svn.freebsd.org/base/stable/10@317964 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

6 years agoMFC r317799:
ken [Mon, 8 May 2017 17:21:57 +0000 (17:21 +0000)]
MFC r317799:

  Add the SCSI Solid State Media Log page (0x11) definition.

  sys/cam/scsi/scsi_all.h:
   Add the SCSI Solid State Media log page (0x11) structure
   definition.  This gives the percentage used (in terms of
   lifetime flash wear) of an SSD.

Sponsored by: Spectra Logic

git-svn-id: svn://svn.freebsd.org/base/stable/10@317962 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

6 years agoMFC r317774, r317776
ken [Mon, 8 May 2017 17:02:03 +0000 (17:02 +0000)]
MFC r317774, r317776

r317774:
  Add the ability to rescan or reset devices specified by peripheral
  name and unit number in camcontrol(8).

  Previously camcontrol(8) only supported rescanning or resetting
  devices specified by bus:target:lun.  This is because for
  rescanning at least, you don't have a peripheral name and unit
  number (e.g. da4) for devices that don't exist yet.

  That is still the case after this change, but in other cases, when
  the device does exist in the CAM EDT (Existing Device Table), we
  do a careful lookup of the bus/target/lun if the user supplies a
  peripheral name and unit number to find the bus:target:lun and then
  issue the requested reset or rescan.

  The lookup is done without actually opening the device in question,
  since a rescan is often done to make a device go away after it has
  been pulled.  (This is especially true for busses/controllers, like
  parallel SCSI controllers, that don't automatically detect changes
  in topology.)  Opening a device that is no longer there to
  determine the bus/target/lun might result in error recovery actions
  when the user really just wanted to make the device go away.

  sbin/camcontrol/camcontrol.c:
   In dorescan_or_reset(), if the use hasn't specified a
   numeric argument, assume he has specified a device.  Lookup
   the pass(4) instance for that device using the transport
   layer CAMGETPASSTHRU ioctl.  If that is successful, we can
   use the returned bus:target:lun to rescan or reset the
   device.

   Under the hood, resetting a device using XPT_RESET_DEV is
   actually sent via the pass(4) device anyway.  But this
   provides a way for the user to specify devices in a more
   convenient way, and can work on device rescans when the
   device is going away, assuming it still exists in the EDT.

  sbin/camcontrol/camcontrol.8:
   Update the man page for the rescan and reset subcommands
   to reflect that you can now use a device name and unit
   number with them.

Sponsored by: Spectra Logic

r317776:
  Bump the camcontrol(8) man page date.

Sponsored by: Spectra Logic

git-svn-id: svn://svn.freebsd.org/base/stable/10@317947 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

6 years agoMFC r317745:
ken [Mon, 8 May 2017 14:48:39 +0000 (14:48 +0000)]
MFC r317745:

  Don't bother retrying errors for encrypted drives that are locked.

  sys/cam/scsi/scsi_all.c:
   In the asc_table, if we get a 0x20,0x02 error ("Access denied -
   no access rights"), don't bother retrying.  Instead, immediately
   fail the command.

   This is the error returned by Self Encrypting Drives (SED) when
   they are locked.

Sponsored by: Spectra Logic

git-svn-id: svn://svn.freebsd.org/base/stable/10@317941 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

6 years agoMFC: r317276
rmacklem [Sun, 7 May 2017 22:18:05 +0000 (22:18 +0000)]
MFC: r317276
Don't set ND_NOMOREDATA for a failed Setattr operation (NFSv4).

The NFSv4 Setattr operation always has reply data even when it fails,
so don't set the ND_NOMOREDATA for it. This would only affect unusual
cases where Setattr fails and the RPC code wants to parse the rest of
the compound. Detected during recent development related to the pNFS server.

git-svn-id: svn://svn.freebsd.org/base/stable/10@317930 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

6 years agoMFC: r317275, r317344
rmacklem [Sun, 7 May 2017 21:57:46 +0000 (21:57 +0000)]
MFC: r317275, r317344
Don't create a backchannel for a DS connection.

An NFSv4.1 client connection to a Data Server (DS) should not have a
backchannel. This patch fixes the NFSv4.1/pNFS client to not do a backchannel
for this case.
Found during recent testing with the pNFS server under development.

git-svn-id: svn://svn.freebsd.org/base/stable/10@317927 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

6 years agoMFC: r317272
rmacklem [Sun, 7 May 2017 21:32:55 +0000 (21:32 +0000)]
MFC: r317272
Add checks for failed operations to the NFSv4 client function nfscl_mtofh().

The nfscl_mtofh() function didn't check for failed operations and, as such,
would have returned EBADRPC for these cases, due to parsing failure.
This patch adds checks, so that it returns with ND_NOMOREDATA set.
This is needed for future use in the pNFS server and acts as a safety
belt in the meantime.

git-svn-id: svn://svn.freebsd.org/base/stable/10@317925 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

6 years agoMFC: r317270
rmacklem [Sun, 7 May 2017 21:06:23 +0000 (21:06 +0000)]
MFC: r317270
Get rid of bogus statement in the nfsuserd.8 man page.

The nfsuserd.8 man page stated that a usertimeout of 0 would disable
the cache timeout. This was simply not true, so this patch deletes
the sentence.

This is a content change.

git-svn-id: svn://svn.freebsd.org/base/stable/10@317922 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

6 years agoMFC: r317350
rmacklem [Sun, 7 May 2017 20:50:32 +0000 (20:50 +0000)]
MFC: r317350
Fix the default uid/gid values in nfsuserd.c

This patch sets the default uid/gid values for "nobody" and "nogroup"
to the values in the password and group databases. Normally nfsuserd(8)
will override these with whatever is in the password/group databases,
so these values are only used when the databases entries aren't available.
It would be nice to use the definitions in sys/conf.h, but those are
in the _KERNEL section of the file.

git-svn-id: svn://svn.freebsd.org/base/stable/10@317920 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

6 years agoMFC: r317269
rmacklem [Sun, 7 May 2017 20:21:59 +0000 (20:21 +0000)]
MFC: r317269
Set default uid/gid to nobody/nogroup for NFSv4 mapping.

The default uid/gid for NFSv4 are set by the nfsuserd(8) daemon.
However, they were 0 until the nfsuserd(8) was run. Since it is
possible to use NFSv4 without running the nfsuserd(8) daemon, set them
to nobody/nogroup initially.
Without this patch, the values would be set by the nfsuserd(8) daemon
and left changed even if the nfsuserd(8) daemon was killed. The default
values of 0 meant that setting a group to "wheel" would fail even when
done by root.
It also adds a definition of GID_NOGROUP to sys/conf.h.

git-svn-id: svn://svn.freebsd.org/base/stable/10@317917 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

6 years agoMFC: r317236
rmacklem [Sun, 7 May 2017 19:57:45 +0000 (19:57 +0000)]
MFC: r317236
Fix the setting of atime for Linux client NFSv4 mounts.

The FreeBSD NFSv4 server did not set the attribute bit for TimeAccess in
the reply to an Open with exclusive_create, as required by the RFCs.
(This is required since the FreeBSD NFS server stores the create_verifier
 in the va_atime attribute.)
As such, the Linux NFSv4 client did not set the TimeAccess (atime) in
the Setattr done in an RPC after the one with the Open/exclusive_create.
This patch fixes the server to set the TimeAccess bit in the reply.

I believe that storing the create_verifier in an extended attribute for
file systems that support extended attributes might be a good idea,
but I will wait for a discussion of this on the freebsd-fs@ email list
before considering committing a patch to do this.

git-svn-id: svn://svn.freebsd.org/base/stable/10@317914 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

6 years agoMFC: r317591
nyan [Sun, 7 May 2017 11:11:51 +0000 (11:11 +0000)]
MFC: r317591

  Add TUNABLE_INT to radeonkms driver parameters.
  They are required by PowerMac G5 DP.

  PR:           217852
  Submitted by: Hiroo Ono

git-svn-id: svn://svn.freebsd.org/base/stable/10@317903 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

6 years agoMFC r317611:
kib [Sun, 7 May 2017 08:02:28 +0000 (08:02 +0000)]
MFC r317611:
Make semaphore names list mutex non-recursive.

git-svn-id: svn://svn.freebsd.org/base/stable/10@317900 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

6 years agoMFC r317610:
kib [Sun, 7 May 2017 08:01:29 +0000 (08:01 +0000)]
MFC r317610:
Restructure normal (non-error) control flow in sem_close().

git-svn-id: svn://svn.freebsd.org/base/stable/10@317899 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

6 years agoMFC r317606:
kib [Sun, 7 May 2017 08:00:34 +0000 (08:00 +0000)]
MFC r317606:
Style.

git-svn-id: svn://svn.freebsd.org/base/stable/10@317898 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

6 years agoMFC r317680:
ken [Fri, 5 May 2017 20:25:31 +0000 (20:25 +0000)]
MFC r317680:

  Add the SCSI SSC Manufacturer assigned serial number VPD page.

  This is current as of SSC-5r03.

Submitted by: Sam Klopsch
Sponsored by: Spectra Logic

git-svn-id: svn://svn.freebsd.org/base/stable/10@317851 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

6 years agoMFC r317388:
brooks [Fri, 5 May 2017 17:28:49 +0000 (17:28 +0000)]
MFC r317388:

Use the approved syntax to build no man pages.

Sponsored by: DARPA, AFRL

git-svn-id: svn://svn.freebsd.org/base/stable/10@317841 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

6 years agoMFC r317566:
brooks [Fri, 5 May 2017 16:24:35 +0000 (16:24 +0000)]
MFC r317566:

Don't pass size_t arguments to setsockopt(SO_SNDBUF/SO_RCVBUF).

These commands take an int. The tests work by accident on little-endian,
64-bit systems.

PR: 218919
Tested with: qemu-cheri and CheriBSD built for mips64
Reviewed by: asomers, ngie
Obtained from: CheriBSD
Sponsored by: DARPA, AFRL

git-svn-id: svn://svn.freebsd.org/base/stable/10@317834 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

6 years agoMFC r317568:
hselasky [Fri, 5 May 2017 13:23:23 +0000 (13:23 +0000)]
MFC r317568:

Improve sysadmin visibility of physical port error counters in the
mlx5en driver.

Sponsored by: Mellanox Technologies

git-svn-id: svn://svn.freebsd.org/base/stable/10@317826 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

6 years agoMFC 317821
sephe [Fri, 5 May 2017 06:00:32 +0000 (06:00 +0000)]
MFC 317821
    hyperv/kbd: Channel read expects non-NULL channel argument.

    Sponsored by: Microsoft

git-svn-id: svn://svn.freebsd.org/base/stable/10@317823 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

6 years agoMFC r317596:
pfg [Thu, 4 May 2017 14:55:07 +0000 (14:55 +0000)]
MFC r317596:
mixer(8): Prevent possible sscanf() overflow.

Fix %s buffer sizes in sscanf().

Obtained from: DragonflyBSD (git dab952e2)

git-svn-id: svn://svn.freebsd.org/base/stable/10@317796 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

6 years agoMFC r317583:
pfg [Thu, 4 May 2017 14:50:25 +0000 (14:50 +0000)]
MFC r317583:
Fix some cases where an index was used before its limits check.

Obtained from: DragonFlyBSD (git 799ba435)

git-svn-id: svn://svn.freebsd.org/base/stable/10@317794 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

6 years agoMFC r317436:
kib [Wed, 3 May 2017 09:54:37 +0000 (09:54 +0000)]
MFC r317436:
getpagesize(3) cannot fail.

git-svn-id: svn://svn.freebsd.org/base/stable/10@317735 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

6 years agoixgbe(4): Fix build issue when compiling with netmap enabled
erj [Tue, 2 May 2017 22:57:27 +0000 (22:57 +0000)]
ixgbe(4): Fix build issue when compiling with netmap enabled

Sponsored by: Intel Corporation

git-svn-id: svn://svn.freebsd.org/base/stable/10@317711 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

6 years agoMFC r317356: Switch isp_reset to scratchpad not requiring ISP_MBOXDMASETUP.
mav [Mon, 1 May 2017 06:05:04 +0000 (06:05 +0000)]
MFC r317356: Switch isp_reset to scratchpad not requiring ISP_MBOXDMASETUP.

git-svn-id: svn://svn.freebsd.org/base/stable/10@317636 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

6 years agoMFC r317064: Optimize pathologic case of telldir() for Samba.
mav [Mon, 1 May 2017 06:03:44 +0000 (06:03 +0000)]
MFC r317064: Optimize pathologic case of telldir() for Samba.

When application reads large directory, calling telldir() for each entry,
like Samba does, it creates exponential performance drop as number of
entries reach tenths to hundreds of thousands.  It is caused by full search
through the internal list, that never finds matches in that scenario, but
creates O(n^2) delays.  This patch optimizes that search, limiting it to
entries of the same buffer, turning time closer to O(n) in case of linear
directory scan.

git-svn-id: svn://svn.freebsd.org/base/stable/10@317634 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

7 years agoMFC r317214:
dim [Sat, 29 Apr 2017 23:26:36 +0000 (23:26 +0000)]
MFC r317214:

Turn off llvm/clang's ENABLE_BACKTRACES setting, since it never worked
properly anyway.  (Upstream has reorganized this somewhat in the mean
time, but for proper backtraces we would need llvm-symbolizer in base.)

MFC r317215:

Add function and data sections when building llvm, clang, lld and lldb,
and allow the linker to garbage collect them.  This shaves off up to a
few MB from the final executables.

git-svn-id: svn://svn.freebsd.org/base/stable/10@317599 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

7 years agoMFC: r316829
rmacklem [Sat, 29 Apr 2017 01:04:39 +0000 (01:04 +0000)]
MFC: r316829
Remove unused "cred" argument to ncl_flush().

The "cred" argument of ncl_flush() is unused and it was confusing to have
the code passing in NULL for this argument in some cases. This patch deletes
this argument.
There is no semantic change because of this patch.

git-svn-id: svn://svn.freebsd.org/base/stable/10@317579 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

7 years agoRevert r314937 as anonymous unions in GCC don't seem to work.
pfg [Thu, 27 Apr 2017 23:14:01 +0000 (23:14 +0000)]
Revert r314937 as anonymous unions in GCC don't seem to work.

This has been breaking the powerpc(LINT64 at least) for quite a while now.

Reported by: emaste

git-svn-id: svn://svn.freebsd.org/base/stable/10@317532 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

7 years agoMove td_sigqueue to the end of struct thread
badger [Thu, 27 Apr 2017 22:28:49 +0000 (22:28 +0000)]
Move td_sigqueue to the end of struct thread

In order to preserve KBI in stable branches, replace the existing
td_sigqueue slot with padding and move the expanded (as of r315949)
td_sigqueue to the end of the struct.

Reported by: jhb
Suggested by: kib
Reviewed by: jhb, kib, vangyzen
Sponsored by: Dell EMC
Differential Revision: https://reviews.freebsd.org/D10515

git-svn-id: svn://svn.freebsd.org/base/stable/10@317529 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

7 years agoMFC: r316793
rmacklem [Thu, 27 Apr 2017 21:45:50 +0000 (21:45 +0000)]
MFC: r316793
Document the "oneopenown" option added by r316792.

This is a content change.

git-svn-id: svn://svn.freebsd.org/base/stable/10@317526 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f

7 years agoMFC: r316792
rmacklem [Thu, 27 Apr 2017 21:37:39 +0000 (21:37 +0000)]
MFC: r316792
Add an NFSv4.1 mount option for "use one openowner".

Some NFSv4.1 servers such as AmazonEFS can only support a small fixed number
of open_owner4s. This patch adds a mount option called "oneopenown" that
can be used for NFSv4.1 mounts to make the client do all Opens with the
same open_owner4 string. This option can only be used with NFSv4.1 and
may not work correctly when Delegations are is use.

Differential Revision: https://reviews.freebsd.org/D8988

git-svn-id: svn://svn.freebsd.org/base/stable/10@317525 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f