]> CyberLeo.Net >> Repos - FreeBSD/stable/10.git/log
FreeBSD/stable/10.git
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

6 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

7 years agoMFC: r316782
rmacklem [Thu, 27 Apr 2017 21:27:20 +0000 (21:27 +0000)]
MFC: r316782
Add call to svcpool_close() for the NFSv4 callback pool (svcpool_nfscbd).

A function called svcpool_close() was added to the server side krpc by
r313735, so that a pool could be closed without destroying the data structures.
This little patch adds a call to it for the callback pool (svcpool_nfscbd),
so that the nfscbd daemon can be killed/restarted and continue to work
correctly.

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

7 years agoMFC r315237 (kib): Hide kev_iovlen() definition under #ifdef KTRACE
emaste [Thu, 27 Apr 2017 18:21:38 +0000 (18:21 +0000)]
MFC r315237 (kib): Hide kev_iovlen() definition under #ifdef KTRACE

Fixes build of kernel configs without KTRACE.

Sponsored by: The FreeBSD Foundation

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

7 years agoMFC r317196:
kib [Thu, 27 Apr 2017 12:15:15 +0000 (12:15 +0000)]
MFC r317196:
Write-combine framebuffer writes through user-space mappings, if possible.

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

7 years agoMFC r316777 (by cem)
truckman [Thu, 27 Apr 2017 07:32:07 +0000 (07:32 +0000)]
MFC r316777 (by cem)

dummynet: Use strlcpy to appease static checkers

Some dummynet modules used strcpy() to copy from a larger buffer
(dn_aqm->name) to a smaller buffer (dn_extra_parms->name).  It happens that
the lengths of the strings in the dn_aqm buffers were always hardcoded to be
smaller than the dn_extra_parms buffer ("CODEL", "PIE").

Use strlcpy() instead, to appease static checkers.  No functional change.

Reported by: Coverity
CIDs: 13561631356165
Sponsored by: Dell EMC Isilon

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

7 years agoMFC 317353
sephe [Thu, 27 Apr 2017 02:17:45 +0000 (02:17 +0000)]
MFC 317353

    hyperv/hn: Use channel0, i.e. TX ring0, for TCP SYN/SYN|ACK.

    Hyper-V hot channel effect:
    Operation latency on hot channel is only _half_ of the operation
    latency on cold channels.

    This commit takes the advantage of the above Hyper-V host channel
    effect, and can reduce more than 75% latency and more than 50%
    latency stdev, i.e. lower and more stable/predictable latency,
    for various types of web server workloads.

    Sponsored by:   Microsoft

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

7 years agoMFC: r316745
rmacklem [Wed, 26 Apr 2017 23:24:05 +0000 (23:24 +0000)]
MFC: r316745
Fix the NFS client for "text file modified, process killed" mmap'd case.

When an mmap'd text file is written and then executed immediately
afterwards, it was possible that the modify time would change after the
text file was executing, resulting in the process executing the file
being killed. This was usually only observed when the file system's
times were set to higher resolution, but could have occurred for any
time resolution.
This patch adds a VOP_SET_TEXT() to the NFS client which flushed all
dirty pages to the NFS server and then makes sure that n_mtime is up
to date to avoid this from occurring.
Thanks go to kib@ and pho@ for their help with developing this patch.

The call to ncl_flush() has been removed. If r316532 is merged into stable/10,
this call needs to go back into nfs_set_text().

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

7 years agoMFC: r316719
rmacklem [Wed, 26 Apr 2017 23:01:49 +0000 (23:01 +0000)]
MFC: r316719
Don't throw away Open state when a NFSv4.1 client recovery fails.

If the ExchangeID/CreateSession operations done by an NFSv4.1 client
after the server crashes/reboots fails, it is possible that some process/thread
is waiting for an open_owner lock. If the client state is free'd, this
can cause a crash.
This would not normally happen, but has been observed on a mount of the
AmazonEFS service.

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

7 years agoMFC: r316717
rmacklem [Wed, 26 Apr 2017 22:53:29 +0000 (22:53 +0000)]
MFC: r316717
During a server crash recovery, fix the NFSv4.1 client for a NFSERR_BADSESSION
during recovery.

If the NFSv4.1 client gets a NFSv4.1 NFSERR_BADSESSION reply to an Open/Lock
operation while recovering from the server crash/reboot, allow the opens
to be retained for a subsequent recovery attempt. Since NFSv4.1 servers
should only reply NFSERR_BADSESSION after a crash/reboot that has lost
state, this case should almost never happen.
However, for the AmazonEFS file service, this has been observed when
the client does a fresh TCP connection for RPCs.

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

7 years agoMFC: r316694
rmacklem [Wed, 26 Apr 2017 22:40:08 +0000 (22:40 +0000)]
MFC: r316694
Fix a crash during unmount of an NFSv4.1 mount.

Larry Rosenman reported a crash on freebsd-current@ which was caused by
a premature release of the krpc backchannel socket structure.
I believe this was caused by a race between the SVC_RELEASE() in clnt_vc.c
and the xprt_unregister() in the higher layer (clnt_rc.c), which tried
to lock the mutex in the xprt structure and crashed.
This patch fixes this by removing the xprt_unregister() in the clnt_vc
layer and allowing this to always be done by the clnt_rc (higher reconnect
layer).

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

7 years agoMFC r317169:
gjb [Wed, 26 Apr 2017 16:27:20 +0000 (16:27 +0000)]
MFC r317169:
 Trim trailing '/release/..' when setting _OBJDIR so arm64/aarch64
 boot1.efifat is properly located when creating virtual machine images.

 Note, the underlying issue has no direct impact against stable/10,
 as arm64/aarch64 virtual machine images are not created for 10-STABLE.

Sponsored by: The FreeBSD Foundation

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

7 years agoMFC r316810, r316814, r316816, r316991:
cy [Wed, 26 Apr 2017 02:37:25 +0000 (02:37 +0000)]
MFC r316810, r316814, r316816, r316991:

Keep state incorrectly assumes keep frags. This is counter to the
ipfilter man pages. This also currently restricts keep frags to only when
keep state is used, which is redundant because keep state currently
assumes keep frags. This commit fixes this.

To the user this change means that to maintain the current behaviour
one must add keep frags to any ipfilter keep state rule (as documented
in the man pages).

This patch also allows the flexability to specify and use keep frags
separate from keep state, as documented in an example in ipf.conf.5,
instead of the currently broken behaviour.

MFC suggested by: rgrimes
Relnotes: yes

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

7 years agoMFC: r316692
rmacklem [Wed, 26 Apr 2017 00:03:03 +0000 (00:03 +0000)]
MFC: r316692
Set initial values for nfsstatfs in the NFSv4 client.

The AmazonEFS NFSv4.1 server does not support the FILES_FREE and FILES_TOTAL
attributes. As such, an NFSv4.1 mount to the server would return garbage
for these values. This patch initializes the fields of the nfsstatfs structure,
so that "df" and friends will at least return consistent bogus values.

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

7 years agoMFC: r316669
rmacklem [Tue, 25 Apr 2017 20:34:56 +0000 (20:34 +0000)]
MFC: r316669
Avoid starvation of the server crash recovery thread for the NFSv4 client.

This patch gives a requestor of the exclusive lock on the client state
in the NFSv4 client priority over shared lock requestors. This avoids
the server crash recovery thread being starved out by other threads doing
RPCs.

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

7 years agoMFC: r316667
rmacklem [Tue, 25 Apr 2017 19:48:25 +0000 (19:48 +0000)]
MFC: r316667
Fix the NFSv4 client hndling of a stale write verifier in the Commit operation.

When the NFSv4 client Commit operation encountered a stale write verifier,
it erroneously mapped that to EIO. This could have caused recently written
data to be lost when a server crashes/reboots between an UNSTABLE write
and the subsequent commit. This patch fixes this.
The bug was only for the NFSv4 client and did not affect NFSv3.

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

7 years agoMFC: r316666
rmacklem [Tue, 25 Apr 2017 19:35:13 +0000 (19:35 +0000)]
MFC: r316666
Fix the NFSv4.1 client for NFSERR_BADSESSION recovery via ReclaimComplete.

For the ReclaimComplete operation, the RPC layer should not loop on
NFSERR_BADSESSION. If it does, the recovery thread (nfscl) can get stuck
looping and will not do a recovery.
This patch fixes it so it does not loop. This bug only affects NFSv4.1 and
only when a server reboots.

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

7 years agoMFC r316698:
kib [Tue, 25 Apr 2017 13:17:34 +0000 (13:17 +0000)]
MFC r316698:
Remove debugging printf.

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

7 years agoMFC: r316655
rmacklem [Tue, 25 Apr 2017 12:07:04 +0000 (12:07 +0000)]
MFC: r316655
Fix parsing failure for NFSv4 Setattr operation for failed case.

If an operation that preceeds a Setattr in an NFSv4 compound fails,
there is no bitmap of attributes to parse. Without this patch, the
parsing would fail and return EBADRPC instead of the correct failure
error. This could break recovery from a server crash/reboot.

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

7 years agoMFC: r310491
rmacklem [Tue, 25 Apr 2017 11:36:25 +0000 (11:36 +0000)]
MFC: r310491
Fix NFSv4.1 client recovery from NFS4ERR_BAD_SESSION errors.

For most NFSv4.1 servers, a NFS4ERR_BAD_SESSION error is a rare failure
that indicates that the server has lost session/open/lock state.
However, recent testing by cperciva@ against the AmazonEFS server found
several problems with client recovery from this due to it generating this
failure frequently.
Briefly, the problems fixed are:
- If all session slots were in use at the time of the failure, some processes
  would continue to loop waiting for a slot on the old session forever.
- If an RPC that doesn't use open/lock state failed with NFS4ERR_BAD_SESSION,
  it would fail the RPC/syscall instead of initiating recovery and then
  looping to retry the RPC.
- If a successful reply to an RPC for an old session wasn't processed
  until after a new session was created for a NFS4ERR_BAD_SESSION error,
  it would erroneously update the new session and corrupt it.
- The use of the first element of the session list in the nfs mount
  structure (which is always the current metadata session) was slightly
  racey. With changes for the above problems it became more racey, so all
  uses of this head pointer was wrapped with a NFSLOCKMNT()/NFSUNLOCKMNT().
- Although the kernel malloc() usually allocates more bytes than requested
  and, as such, this wouldn't have caused problems, the allocation of a
  session structure was 1 byte smaller than it should have been.
  (Null termination byte for the string not included in byte count.)

There are probably still problems with a pNFS data server that fails
with NFS4ERR_BAD_SESSION, but I have no server that does this to test
against (the AmazonEFS server doesn't do pNFS), so I can't fix these yet.

Although this patch is fairly large, it should only affect the handling
of NFS4ERR_BAD_SESSION error replies from an NFSv4.1 server.
Thanks go to cperciva@ for the extension testing he did to help isolate/fix
these problems.

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

7 years agoMFC r316768:
brooks [Mon, 24 Apr 2017 22:44:59 +0000 (22:44 +0000)]
MFC r316768:

Fix an out-of-bounds write when a zero-length buffer is passed.

Found with ttyname_test and CHERI bounds checking.

Reviewed by: emaste
Obtained from: CheriBSD
Sponsored by: DARPA, AFRL

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

7 years agoMFC r316766:
brooks [Mon, 24 Apr 2017 21:41:04 +0000 (21:41 +0000)]
MFC r316766:

Correct an out of bounds read with HN_AUTOSCALE and very large numbers.

The maximum scale is 6 (K, M, G, T, P, E) (B is 0).

Overly large explict scales were checked correctly, but for sufficently
large numbers HN_AUTOSCALE would get to 7 resulting in an out of bounds
read.

Found with humanize_number_test and CHERI bounds checking.

Reviewed by: emaste
Obtained from: CheriBSD
Sponsored by: DARPA, AFRL

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

7 years agoPartial MFC r316676 and the required r313045
smh [Mon, 24 Apr 2017 16:31:28 +0000 (16:31 +0000)]
Partial MFC r316676 and the required r313045

MFC r316676:

Use estimated RTT for receive buffer auto resizing instead of timestamps.
This is a partial MFC as stable/10 doesn't include the TCP stack
modularisation.

MFC r313045:

Add an mbuf to ipinfo_t translator to finish cleanup of mbuf passing to TCP
probes. This is a partial MFC (missing debug__output & debug__drop changes)
due to the massive amount of additional dtrace changes that would be
required for a full MFC.

Relnotes: Yes
Sponsored by: Multiplay

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

7 years agoMFC r315913: Add brackets to fix incorrect macro expansion.
mav [Mon, 24 Apr 2017 11:22:06 +0000 (11:22 +0000)]
MFC r315913: Add brackets to fix incorrect macro expansion.

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

7 years agoMFC r315908: Unify initiator and target DMA setup and command sending.
mav [Mon, 24 Apr 2017 11:21:32 +0000 (11:21 +0000)]
MFC r315908: Unify initiator and target DMA setup and command sending.

The code is so alike that it is pointless to keep it separate.

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

7 years agoMFC r315870: isp field in struct isp_pcmd is also unused.
mav [Mon, 24 Apr 2017 11:20:55 +0000 (11:20 +0000)]
MFC r315870: isp field in struct isp_pcmd is also unused.

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

7 years agoMFC r315869: Remove write-only crn field from struct isp_pcmd.
mav [Mon, 24 Apr 2017 11:20:21 +0000 (11:20 +0000)]
MFC r315869: Remove write-only crn field from struct isp_pcmd.

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

7 years agoMFC r315708: Cleanup response queue processing.
mav [Mon, 24 Apr 2017 11:19:47 +0000 (11:19 +0000)]
MFC r315708: Cleanup response queue processing.

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

7 years agoMFC r316677: Do not register in CTL portal groups without portals.
mav [Mon, 24 Apr 2017 06:33:08 +0000 (06:33 +0000)]
MFC r316677: Do not register in CTL portal groups without portals.

From config synthax point of view such portal groups are not incorrect,
but they are useless since can not receive any connection.  And since
CTL port resource is very limited, it is good to save it.

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

7 years agoMFC r317186
kp [Sun, 23 Apr 2017 08:59:57 +0000 (08:59 +0000)]
MFC r317186

pf: Fix possible incorrect IPv6 fragmentation

When forwarding pf tracks the size of the largest fragment in a fragmented
packet, and refragments based on this size.
It failed to ensure that this size was a multiple of 8 (as is required for all
but the last fragment), so it could end up generating incorrect fragments.

For example, if we received an 8 byte and 12 byte fragment pf would emit a first
fragment with 12 bytes of payload and the final fragment would claim to be at
offset 8 (not 12).

We now assert that the fragment size is a multiple of 8 in ip6_fragment(), so
other users won't make the same mistake.

Reported by:    Antonios Atlasis <aatlasis at secfu net>

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

7 years agoMFC r316652: Fix few minor issues found by Clang Analyzer.
mav [Sun, 23 Apr 2017 07:37:14 +0000 (07:37 +0000)]
MFC r316652: Fix few minor issues found by Clang Analyzer.

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

7 years agoMFC r316653: Fix few minor issues found by Clang Analyzer.
mav [Sun, 23 Apr 2017 07:35:51 +0000 (07:35 +0000)]
MFC r316653: Fix few minor issues found by Clang Analyzer.

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

7 years agoMFC r316993, r316994, r316997 as follows:
cy [Sun, 23 Apr 2017 03:16:38 +0000 (03:16 +0000)]
MFC r316993, r316994, r316997 as follows:

r316993:

Fix CID 1372601 in ipfilter/lib/parsefields.c, possible NULL pointer
dereference should reallocarray() fail.

Reported by: Coverity CID 1372601

r316994:

Fix CID 1372600 in ipfilter/tools/ipf_y.y, possible NULL pointer
dereference should reallocarray() fail.

Reported by: Coverity CID 1372600

r316997:

Use warnx() to issue error message.

Reported by: cem

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

7 years agoMFC: r314694
rgrimes [Sat, 22 Apr 2017 22:05:23 +0000 (22:05 +0000)]
MFC: r314694

  Make vmrun.sh passthrough -u and -w to bhybe

PR: 214273
Submitted by: Martin Birgmeier <la5lb...@aon.at>
Approved by: grehan (mentor)

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

7 years agoMFC: r314691
rgrimes [Sat, 22 Apr 2017 21:57:26 +0000 (21:57 +0000)]
MFC: r314691

Document 3 more src/ directories

Approved by: grehan (mentor)

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

7 years agoDocument EN-17:01 through EN-17:05, SA-16:39 through SA-17:03
gjb [Fri, 21 Apr 2017 19:41:33 +0000 (19:41 +0000)]
Document EN-17:01 through EN-17:05, SA-16:39 through SA-17:03

Sponsored by: The FreeBSD Foundation

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

7 years agoMFC r316852:
kib [Fri, 21 Apr 2017 10:16:34 +0000 (10:16 +0000)]
MFC r316852:
In fsck_ffs pass1, prevent the inosused variable from wrapping.

PR: 218592

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

7 years agoMFC r317139 for real.
cy [Fri, 21 Apr 2017 02:11:44 +0000 (02:11 +0000)]
MFC r317139 for real.

Restore prototype accidently removed by r316811.  Also remove $NetBSD$
accidentally added.

Reported by:    hps, lwhsu
Pointy hat to: cy

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

7 years agoMFC r316811, r317139:
cy [Fri, 21 Apr 2017 02:02:52 +0000 (02:02 +0000)]
MFC r316811, r317139:

Add missing free()'s after calls to randomize().

PR: NetBSD PR/50559
Obtained from: Netbsd radix_ipf.c r1.6

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

7 years agoMFC r316809:
cy [Fri, 21 Apr 2017 01:51:49 +0000 (01:51 +0000)]
MFC r316809:

Fix a use after free panic in ipfilter's fragment processing.
Memory is malloc'd, then a search for a match in the fragment table
is made and if the fragment matches, the wrong fragment table is
freed, causing a use after free panic. This commit fixes this.

A symptom of the problem is a kernel page fault in bcopy() called by
ipf_frag_lookup() at line 715 in ip_frag.c. Another symptom is a
kernel page fault in ipf_frag_delete() when called by ipf_frag_expire()
via ipf_slowtimer().

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

7 years agoMFC r316183
davidcs [Thu, 20 Apr 2017 04:33:47 +0000 (04:33 +0000)]
MFC r316183
Upgrade firmware and other related files to version 5.4.64

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

7 years agoMFC r316739:
kib [Wed, 19 Apr 2017 10:57:57 +0000 (10:57 +0000)]
MFC r316739:
Fix reporting of _SC_SEM_NSEMS_MAX and _SC_SEM_VALUE_MAX.

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