]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
4 years agoMFCr350612
Mariusz Zaborski [Tue, 10 Sep 2019 20:18:06 +0000 (20:18 +0000)]
MFCr350612
  procdesc: fix reparenting when the debugger is attached

  The process is reparented to the debugger while it is attached.
    B          B
   /   ---->   |
  A          A D

  Every time when the process is reparented, it is added to the orphan list
  of the previous parent:

  A->orphan = B
  D->orphan = NULL

  When the A process will close the process descriptor to the B process,
  the B process will be reparented to the init process.
    B            B - init
    |   ---->
  A D          A   D

  A->orphan = B
  D->orphan = B

  In this scenario, the B process is in the orphan list of A and D.

  When the last process descriptor is closed instead of reparenting
  it to the reaper let it stay with the debugger process and set
  our previews parent to the reaper.

  Add test case for this situation.
  Notice that without this patch the kernel will crash with this test case:
  panic: orphan 0xfffff8000e990530 of 0xfffff8000e990000 has unexpected oppid 1

  Reviewed by:  markj, kib
  Differential Revision:        https://reviews.freebsd.org/D20361

4 years agoMFCr350611:
Mariusz Zaborski [Tue, 10 Sep 2019 20:15:52 +0000 (20:15 +0000)]
MFCr350611:
  proc: introduce the proc_add_orphan function

  This API allows adding the process to its parent orphan list.

  Reviewed by:  kib, markj

4 years agoMFCr350610:
Mariusz Zaborski [Tue, 10 Sep 2019 20:14:52 +0000 (20:14 +0000)]
MFCr350610:
  exit1: postpone clearing P_TRACED flag until the proctree lock is acquired

  In case of the process being debugged. The P_TRACED is cleared very early,
  which would make procdesc_close() not calling proc_clear_orphan().
  That would result in the debugged process can not be able to collect
  status of the process with process descriptor.

  Reviewed by:  markj, kib
  Tested by:    pho

4 years agoMFC r351774:
Konstantin Belousov [Tue, 10 Sep 2019 06:47:40 +0000 (06:47 +0000)]
MFC r351774:
Add stackgap control mode to proccontrol(1).

PR: 239894

4 years agoMFC r351773:
Konstantin Belousov [Tue, 10 Sep 2019 06:45:44 +0000 (06:45 +0000)]
MFC r351773:
Add procctl(PROC_STACKGAP_CTL).

PR: 239894

4 years agoMFC r351937:
Johannes Lundberg [Tue, 10 Sep 2019 02:21:17 +0000 (02:21 +0000)]
MFC r351937:
LinuxKPI: Improve sysfs support.

- Add functions for creating and merging sysfs groups.
- Add sysfs_streq function to compare strings ignoring newline from the
  sysctl userland call.
- Add a call to sysfs_create_groups in device_add.
- Remove duplicate header include.
- Bump __FreeBSD_version.

Reviewed by: hselasky
Approved by: imp (mentor), hselasky

4 years agoMFC 351897: nvdimm(4): Add description of NVDIMM Namespace support
D Scott Phillips [Mon, 9 Sep 2019 21:03:08 +0000 (21:03 +0000)]
MFC 351897: nvdimm(4): Add description of NVDIMM Namespace support

Approved by: scottl (mentor)
Sponsored by: Intel Corporation

4 years agoMFC 348757,351225: acpi and nvdimm location_str updates
D Scott Phillips [Mon, 9 Sep 2019 20:49:37 +0000 (20:49 +0000)]
MFC 348757,351225: acpi and nvdimm location_str updates

348757:
nvdimm: Provide nvdimm location information

Provide the acpi handle path as the location string for the nvdimm
children of the nvdimm_root device.

351225:
Don't set the string "unknown" as a device's location_str

Return an empty string when the location is unknown instead of the
string "unknown". This ensures that all location entries are of
the form key=val.

Approved by: scottl (mentor)
Sponsored by: Intel Corporation
Differential Revision: https://reviews.freebsd.org/D20644

4 years agoMFC r351663: ar: use more correct size_t type for loop index
Ed Maste [Mon, 9 Sep 2019 20:04:45 +0000 (20:04 +0000)]
MFC r351663: ar: use more correct size_t type for loop index

Submitted by: cem

4 years agoMFC r351197, r351199:
Vladimir Kondratyev [Mon, 9 Sep 2019 18:57:17 +0000 (18:57 +0000)]
MFC r351197, r351199:

iwmbtfw: Firmware loader for Intel Wireless 8260 based Bluetooth USB devices

Currently supported models are: 8260, 8265, 9560, 9260 and 22161.
Firmware files can be installed with comms/iwmbt-firmware port.

PR: 237083
Reviewed by: hps, emax
Differential Revision: https://reviews.freebsd.org/D21071

4 years agoMFC r351196, r351324, r351326:
Vladimir Kondratyev [Mon, 9 Sep 2019 18:50:38 +0000 (18:50 +0000)]
MFC r351196, r351324, r351326:

ng_ubt(4): do not attach Intel Wireless 8260/8265 in bootloader mode.

Add helper function for synchronous execution of HCI commands at probe
stage and use this function to check firmware state of Intel Wireless
8260/8265 bluetooth devices found in many post 2016 year laptops.

Attempt to initialize FreeBSD bluetooth stack while such a device is in
bootloader mode locks the adapter hardly so it requires power on/off
cycle to restore.

This change blocks ng_ubt attachment unless operational firmware is
loaded thus preventing the lock up.

PR: 237083
Reviewed by: hps, emax
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D21071

4 years agoMFC: r351429,351430,351485,351497,351498
Warner Losh [Mon, 9 Sep 2019 18:27:52 +0000 (18:27 +0000)]
MFC: r351429,351430,351485,351497,351498

Merge changes to turn off -Werror for gcc 4.2.1 by default as part of
the plan to deorbit gcc 4.2.1 from -head before 13.0.

Relnotes: Yes

4 years agoBack out r352087 for now
Kyle Evans [Mon, 9 Sep 2019 18:20:55 +0000 (18:20 +0000)]
Back out r352087 for now

The ancient-gcc -Wno-error series hasn't been MFC'd yet to this branch and
some GCC builds seem to have raised a false-positive that wasn't caught due
to -Wno-error on head. Back it out for now, will reapply when r352092
becomes eligible for MFC...

4 years agobectl(8): fix mis-merge
Kyle Evans [Mon, 9 Sep 2019 18:01:07 +0000 (18:01 +0000)]
bectl(8): fix mis-merge

r348296 ("add description for create subcommand") apparently failed to merge
in the SYNOPSIS addition somehow... correct this mistake now.  This is a
direct commit to stable/12 for a misfire on previous MFC.

4 years agoMFC r351938:
Dimitry Andric [Mon, 9 Sep 2019 17:58:26 +0000 (17:58 +0000)]
MFC r351938:

Pull in r371111 from upstream llvm trunk (by Eli Friedman):

  [IfConversion] Fix diamond conversion with unanalyzable branches.

  The code was incorrectly counting the number of identical
  instructions, and therefore tried to predicate an instruction which
  should not have been predicated.  This could have various effects: a
  compiler crash, an assembler failure, a miscompile, or just
  generating an extra, unnecessary instruction.

  Instead of depending on TargetInstrInfo::removeBranch, which only
  works on analyzable branches, just remove all branch instructions.

  Fixes https://bugs.llvm.org/show_bug.cgi?id=43121 and
  https://bugs.llvm.org/show_bug.cgi?id=41121 .

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

This should fix "Unable to predicate BX killed renamable $r0" errors
when building the lang/spidermonkey170 and lang/spidermonkey38 ports for
armv7 and armv6.

PR: 236567

4 years agoMFC r351813: bectl(8): implement sorting for 'bectl list' output
Kyle Evans [Mon, 9 Sep 2019 17:56:14 +0000 (17:56 +0000)]
MFC r351813: bectl(8): implement sorting for 'bectl list' output

Allow 'bectl list' to sort output by a given property name. The property
name is passed in using a command-line flag, '-c' for ascending order and
'-C' for descending order. The properties allowed to sort by are:

- name (the default output, even if '-c' or '-C' are not used)
- creation
- origin
- used
- usedds
- usedsnap
- usedrefreserv

The default output for 'bectl list' is now ascending alphabetical order of
BE name.

To sort by creation time from earliest to latest, the command would be
'bectl list -c creation'

4 years agoMFC r345845-r345846: bectl(8) manpage clarity
Kyle Evans [Mon, 9 Sep 2019 17:53:15 +0000 (17:53 +0000)]
MFC r345845-r345846: bectl(8) manpage clarity

r345845:
bectl.8: Clean up & clarify the create subcommand

- Improve formatting
- Use consistent variable names
- Improve the description of the create subcommand (1)

PR: 235850

r345846:
bectl.8: Bump date after r345845

4 years agoMFC r344555 (sobomax): makefs: Improve error handling
Ed Maste [Mon, 9 Sep 2019 17:44:14 +0000 (17:44 +0000)]
MFC r344555 (sobomax): makefs: Improve error handling

Bail out if one of the files scheduled to go to the FS image we are
making cannot be read (e.g. EPERM).  Previous behaviour of issuing a
warning but still proceeeding and returning success was definitely not
correct: masking out error condition as well as making a slighly
inconsistent FS where attempt to access the file in question ends up in
EBADF.  (More details in review D18584.)

4 years agoMFC r351797: (Optional) Allow more nesting of GEOM partitioning schemes
Kyle Evans [Mon, 9 Sep 2019 17:43:44 +0000 (17:43 +0000)]
MFC r351797: (Optional) Allow more nesting of GEOM partitioning schemes

GEOM is supposed to be topology-agnostic, but the GPT and BSD partition code
has arbitrary restrictions on nesting that are annoying in cases such as
running VMs on raw partitions (since the VM's partitioning scheme is not
visible to the host).

This patch adds sysctls to disable the restrictions except in the case of
BSD label (and similar) partitions with offset 0 (where we need to avoid
recursively recognizing the label).

4 years agoMFC r351681: mips: fix some mcount nits
Kyle Evans [Mon, 9 Sep 2019 17:37:52 +0000 (17:37 +0000)]
MFC r351681: mips: fix some mcount nits

The symbol version for _mcount was removed 12 years ago in r169525 from
gmon/Symbol.map, to be added to the per-arch Symbol.map. mips was overlooked
in this, so _mcount has no symver. Add it back to where it should have been,
rather than where it would go if it were added today, since we're correcting
a historical mistake.

Additionally, _mcount is getting thrown into .mdebug.abi32 in the llvm80/90
world as it's not getting explicitly thrown into .text, so do this now. This
fixes the libc build that was previously failing due to relocations in
.mdebug.abi32. This is specifically due to the way clang's integrated AS
works and that they emit the .mdebug.abiNN section early in the process. An
LLVM bug has been submitted (and since committed) and an agreement has been
made that the mips backend should switch to .text following .mdebug.abiNN
for compatibility.

4 years agoMFC r351396: makefs: diff reduction to sys/fs/msdosfs
Ed Maste [Mon, 9 Sep 2019 17:34:18 +0000 (17:34 +0000)]
MFC r351396: makefs: diff reduction to sys/fs/msdosfs

No functional change.

4 years agoMFC r351347: makefs: Verify that the BPB media descriptor and FAT ID match
Ed Maste [Mon, 9 Sep 2019 17:33:31 +0000 (17:33 +0000)]
MFC r351347: makefs: Verify that the BPB media descriptor and FAT ID match

From r322982 in sys/fs/msdosfs.

4 years agomakefs: add msdosfs (FAT) support
Ed Maste [Mon, 9 Sep 2019 17:32:40 +0000 (17:32 +0000)]
makefs: add msdosfs (FAT) support

MFC r351232: makefs.8: expand description of image size

Submitted by: ryan_freqlabs.com, Siva Mahadevan

MFC r351273: makefs: add msdosfs (FAT) support

Add FAT support to makefs by copying some files from sys/fs/msdosfs/ and
updating others with changes from NetBSD.

The six files copied from sys/fs/msdosfs at r348251 and modified are:
denode.h direntry.h fat.h msdosfs_fat.c msdosfs_lookup.c msdosfsmount.h

I would prefer to avoid the duplication, but reluctance to doing so was
expressed in a previous review (D11197); for now copy the files and
revisit in the future.

Submitted by: Siva Mahadevan

MFC r351275: makefs: avoid "dereferencing 'void *' pointer" warnings

On GCC 4.2.1 archs

MFC r351302: makefs.8: update history

- ported to FreeBSD and first appeared in 8.0
- Christos Zoulas added the FAT support that I imported

MFC r351319: makefs: use `char *` not `void *` for buf b_data, drop casts in msdos

(The kernel uses caddr_t.)

Suggested by: cem

MFC r351415 (delphij): Properly update FSInfo block after generation.

After populating the filesystem, write a FSInfo block with
proper information.

Sponsored by: The FreeBSD Foundation

4 years agoMFC r351230: makefs.8: style updates from igor
Ed Maste [Mon, 9 Sep 2019 17:24:24 +0000 (17:24 +0000)]
MFC r351230: makefs.8: style updates from igor

Sponsored by: The FreeBSD Foundation

4 years agoMFC r345281: makefs: Fix "time" mtree attribute handling
Ed Maste [Mon, 9 Sep 2019 17:22:11 +0000 (17:22 +0000)]
MFC r345281: makefs: Fix "time" mtree attribute handling

When processing mtree(5) MANIFEST files, makefs(8) previously threw an
error if it encountered an entry whose "time" attribute contained a
non-zero subsecond component (e.g. time=1551620152.987220000).

Update the handling logic to properly assign the subsecond component if
built with nanosecond support, or silently discard it otherwise.

Also, re-enable the time attribute for the kyua tests.

PR: 194703
Submitted by: mhorne

4 years agoMFC r351701:
Johannes Lundberg [Mon, 9 Sep 2019 16:37:38 +0000 (16:37 +0000)]
MFC r351701:
LinuxKPI: Add sysfs create/remove functions that handles multiple files in one call.

Reviewed by: hps
Approved by: imp (mentor), hps

4 years agoMFC r351935:
Fabien Thomas [Mon, 9 Sep 2019 14:41:39 +0000 (14:41 +0000)]
MFC r351935:
Fix broken window replay check that will allow old packet to be accepted.
This was introduced in r309144.

Submitted by: Jean-Francois HREN <jean-francois.hren@stormshield.eu>
Approved by: ae@

4 years agoMFC r350077
Chuck Tuffli [Mon, 9 Sep 2019 14:16:57 +0000 (14:16 +0000)]
MFC r350077

bhyve: update the NVMe CQ based on the status

Approved by: imp (mentor)

4 years agoMFC r351361, r351363:
Mark Johnston [Sun, 8 Sep 2019 20:53:29 +0000 (20:53 +0000)]
MFC r351361, r351363:
Add lockmgr(9) probes to the lockstat DTrace provider.

4 years agoMFC r351671:
Mark Johnston [Sun, 8 Sep 2019 20:42:55 +0000 (20:42 +0000)]
MFC r351671:
Fix an off-by-one bug in the CPU and domain ID parser.

4 years agoMFC r351624:
Mark Johnston [Sun, 8 Sep 2019 20:42:28 +0000 (20:42 +0000)]
MFC r351624:
Properly check for an interrupted cv_wait_sig().

4 years agoMFC r351573:
Mark Johnston [Sun, 8 Sep 2019 20:41:00 +0000 (20:41 +0000)]
MFC r351573:
Document fetchReqHTTP().

4 years agoMFC r351672:
Mark Johnston [Sun, 8 Sep 2019 20:39:55 +0000 (20:39 +0000)]
MFC r351672:
Restrict the input domain set in cpuset_setdomain(2) to all_domains.

4 years agoMFC r351332:
Mark Johnston [Sun, 8 Sep 2019 20:38:58 +0000 (20:38 +0000)]
MFC r351332:
Unconditionally enable debug.vm_lowmem.

4 years agoMFC r350431:
Mark Johnston [Sun, 8 Sep 2019 20:37:42 +0000 (20:37 +0000)]
MFC r350431:
Centralize the logic in vfs_vmio_unwire() and sendfile_free_page().

4 years agoMFC r351547, r351549:
Mark Johnston [Sun, 8 Sep 2019 20:28:06 +0000 (20:28 +0000)]
MFC r351547, r351549:
Fix several logic issues in domainset_empty_vm().

4 years agoMFC r351614
Jason Helfman [Sun, 8 Sep 2019 16:24:34 +0000 (16:24 +0000)]
MFC r351614

- address missing whitespace for indent

PR: 239727
Submitted by: gbergling@gmail.com
Reviewed by: 0mp@

4 years agoMFC r351889:
Cy Schubert [Sun, 8 Sep 2019 01:58:02 +0000 (01:58 +0000)]
MFC r351889:

Bounds check again after advancing cp, otherwise we have a possible
heap buffer overflow. This was discovered by a Google fuzzer test.
This can lead to remote denial of service. User interaction and
execution privileges are not a prerequisite for exploitation.

Reported by: enh at Google, to FreeBSD by maya@NetBSD.org
Obtained from: enh at Google
See also: NetBSD ns_name.c r1.12
Reviewed by: delphij, ume
MFC after: 3 days
https://android-review.googlesource.com/c/platform/bionic/+/1093130
Differential Revision: https://reviews.freebsd.org/D21523

4 years agoImprove DSACK support:
Michael Tuexen [Sat, 7 Sep 2019 19:58:06 +0000 (19:58 +0000)]
Improve DSACK support:

MFC This is the second in a number of patches needed to
get BBRv1 into the tree. This fixes the DSACK bug but
is also needed by BBR. We have yet to go two more
one will be for the pacing code (tcp_ratelimit.c) and
the second will be for the new updated LRO code that
allows a transport to know the arrival times of packets
and (tcp_lro.c). After that we should finally be able
Improve DSACK support.

MFC r349987 from rrs@:

This is the second in a number of patches needed to
get BBRv1 into the tree. This fixes the DSACK bug but
is also needed by BBR. We have yet to go two more
one will be for the pacing code (tcp_ratelimit.c) and
the second will be for the new updated LRO code that
allows a transport to know the arrival times of packets
and (tcp_lro.c). After that we should finally be able
to get BBRv1 into head.

This required manual tweaking to address merge conflicts.

MFC r351725:

This patch improves the DSACK handling to conform with RFC 2883.
The lowest SACK block is used when multiple Blocks would be elegible as
DSACK blocks ACK blocks get reordered - while maintaining the ordering of
SACK blocks not relevant in the DSACK context is maintained.

This required manual tweaking to address merge conflicts.

MFC r351801:

Fix the SACK block generation in the base TCP stack by bringing it in
sync with the RACK stack.

4 years agoMFC r351631
Sevan Janiyan [Sat, 7 Sep 2019 17:22:25 +0000 (17:22 +0000)]
MFC r351631
Earliest reference to /dev/null I can find is in v4 sh(1) and nulldev in
nsys/ken/subr.c
via TUHS archive
https://minnie.tuhs.org/cgi-bin/utree.pl?file=V4

4 years agoMFC r351655:
Michael Tuexen [Sat, 7 Sep 2019 12:20:47 +0000 (12:20 +0000)]
MFC r351655:

Fix initialization of top_fsn.

4 years agoMFC r351654:
Michael Tuexen [Sat, 7 Sep 2019 12:19:07 +0000 (12:19 +0000)]
MFC r351654:

Improve the handling of state cookie parameters in INIT-ACK chunks.
This fixes problem with parameters indicating a zero length or partial
parameters after an unknown parameter indicating to stop processing. It
also fixes a problem with state cookie parameters after unknown
parametes indicating to stop porcessing.
Thanks to Mark Wodrich from Google for finding two of these issues
by fuzz testing the userland stack and reporting them in
https://github.com/sctplab/usrsctp/issues/351
and
https://github.com/sctplab/usrsctp/issues/352

4 years agoMFC r351641:
Michael Tuexen [Sat, 7 Sep 2019 12:15:23 +0000 (12:15 +0000)]
MFC r351641:
Improve function definition.

4 years agoMFC r351638:
Michael Tuexen [Sat, 7 Sep 2019 12:13:58 +0000 (12:13 +0000)]
MFC r351638:

Improve the handling of illegal sequence number combinations in received
data chunks. Abort the association if there are data chunks with larger
fragement sequence numbers than the fragement sequence of the last
fragment.
Thanks to Mark Wodrich from Google who found this issue by fuzz testing
the userland stack and reporting this issue in
https://github.com/sctplab/usrsctp/issues/355

4 years agoMFC r351511:
Michael Tuexen [Sat, 7 Sep 2019 12:03:13 +0000 (12:03 +0000)]
MFC r351511:

Identify eMAG CPU used in Ampere Computing systems.

Reviewed by: emaste@
Differential Revision: https://reviews.freebsd.org/D21314

4 years agoMFC r350745:
Michael Tuexen [Sat, 7 Sep 2019 12:01:41 +0000 (12:01 +0000)]
MFC r350745:

Fix a typo.

Submitted by: Thomas Dreibholz

4 years agoMFC r350627:
Michael Tuexen [Sat, 7 Sep 2019 12:00:17 +0000 (12:00 +0000)]
MFC r350627:

Reference the RFC instead of the internet draft.

Sponsored by: Netflix, Inc.

4 years agoMFC r350626:
Michael Tuexen [Sat, 7 Sep 2019 11:58:32 +0000 (11:58 +0000)]
MFC r350626:

Fix a locking issue in sctp_accept.

PR: 238520
Reported by: pho@

4 years agoMFC r350625:
Michael Tuexen [Sat, 7 Sep 2019 11:56:43 +0000 (11:56 +0000)]
MFC r350625:

Fix build issues for the userland stack on Raspbian.

4 years agoMFC r350520:
Michael Tuexen [Sat, 7 Sep 2019 11:52:35 +0000 (11:52 +0000)]
MFC r350520:

Fix the reporting of multiple unknown parameters in an received INIT
chunk. This also plugs an potential mbuf leak.
Thanks to Felix Weinrank for reporting this issue found by fuzz-testing
the userland stack.

4 years agoMFC r350508:
Michael Tuexen [Sat, 7 Sep 2019 11:51:07 +0000 (11:51 +0000)]
MFC r350508:

When responding with an ABORT to an INIT chunk containing a
HOSTNAME parameter or a parameter with an illegal length, only
include an error cause indicating why the ABORT was sent.
This also fixes an mbuf leak which could occur.

4 years agoMFC r350488:
Michael Tuexen [Sat, 7 Sep 2019 11:49:41 +0000 (11:49 +0000)]
MFC r350488:

Small cleanup, no functional change intended.

4 years agoMFC r350487:
Michael Tuexen [Sat, 7 Sep 2019 11:48:25 +0000 (11:48 +0000)]
MFC r350487:

Consistently cleanup mbufs in case of other memory errors.

4 years agoMFC r350404:
Michael Tuexen [Sat, 7 Sep 2019 11:46:49 +0000 (11:46 +0000)]
MFC r350404:

When performing after_idle() or post_recovery(), don't disable the
DCTCP specific methods. Also fallthrough NewReno for non ECN capable
TCP connections and improve the integer arithmetic.

Obtained from: Richard Scheffenegger
Differential Revision: https://reviews.freebsd.org/D20550

4 years agoMFC r350403:
Michael Tuexen [Sat, 7 Sep 2019 11:33:27 +0000 (11:33 +0000)]
MFC r350403:

* Improve input validation of sysctl parameters for DCTPC.
* Initialize the alpha parameter to a conservative value (like Linux)
* Improve handling of arithmetic.
* Improve man-page

Obtained from: Richard Scheffenegger
Differential Revision: https://reviews.freebsd.org/D20549

4 years agoMFC r350265:
Michael Tuexen [Sat, 7 Sep 2019 11:31:05 +0000 (11:31 +0000)]
MFC r350265:

Add a sysctl variable ts_offset_per_conn to change the computation
of the TCP TS offset from taking the IP addresses and the TCP port
numbers into account to a version just taking only the IP addresses
into account. This works around broken middleboxes or endpoints.
The default is to keep the behaviour, which is also the behaviour
recommended in RFC 7323.

Reported by: devgs@ukr.net
Reviewed by: rrs@
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D20980

4 years agoMFC r350254:
Michael Tuexen [Sat, 7 Sep 2019 11:24:29 +0000 (11:24 +0000)]
MFC r350254:

Don't hold a mutex while calling sbwait. This was found by syzkaller.

Submitted by: rrs@
Reported by: markj@

4 years agoMFC r350248:
Michael Tuexen [Sat, 7 Sep 2019 11:22:24 +0000 (11:22 +0000)]
MFC r350248:

Fix a LOR in SCTP which was found by running syzkaller.

Submitted by: rrs@
Reported by: markj@

4 years agoMFC r350216:
Michael Tuexen [Sat, 7 Sep 2019 11:19:55 +0000 (11:19 +0000)]
MFC r350216:

Wakeup the application when doing PD-API for unordered DATA chunks.
Work done with rrs@.

4 years agoMFC 350028:
Michael Tuexen [Sat, 7 Sep 2019 10:57:47 +0000 (10:57 +0000)]
MFC 350028:

dd support for ICMPv6 messages indicating a parameter problem related
to an unrecognized next header.

4 years agoMFC 350027:
Michael Tuexen [Sat, 7 Sep 2019 10:56:38 +0000 (10:56 +0000)]
MFC 350027:

Let packet_op() explicitly return the type and code instead of doing
this implicitly by encoding it in a number space.

No functional change intended.

This is done as a preparation to add support for ICMPv6 mesages
indicating a parameter problem related to the next header.

4 years agoMFC r350026:
Michael Tuexen [Sat, 7 Sep 2019 10:55:12 +0000 (10:55 +0000)]
MFC r350026:

Whitespace change. No functional change.

4 years agoMFC r349999:
Michael Tuexen [Sat, 7 Sep 2019 10:53:29 +0000 (10:53 +0000)]
MFC r349999:

Add support for MSG_EOR and MSG_EOF in sendmsg() for SCTP.

This is an FreeBSD extension, not covered by Posix.

This issue was found by running syzkaller.

4 years agoMFC r349998:
Michael Tuexen [Sat, 7 Sep 2019 10:51:33 +0000 (10:51 +0000)]
MFC r349998:

Fix socket state handling when freeing an SCTP endpoint.

This issue was found by runing syzkaller.

4 years agoMFC r349989:
Michael Tuexen [Sat, 7 Sep 2019 10:49:37 +0000 (10:49 +0000)]
MFC r349989:

Improve the input validation for l_linger.
When using the SOL_SOCKET level socket option SO_LINGER, the structure
struct linger is used as the option value. The component l_linger is of
type int, but internally copied to the field so_linger of the structure
struct socket. The type of so_linger is short, but it is assumed to be
non-negative and the value is used to compute ticks to be stored in a
variable of type int.

Therefore, perform input validation on l_linger similar to the one
performed by NetBSD and OpenBSD.

Thanks to syzkaller for making me aware of this issue.

Thanks to markj@ for pointing out that a similar check should be added
to so_linger_set().

Reviewed by: markj@
Differential Revision: https://reviews.freebsd.org/D20948

4 years agoMFC r349986:
Michael Tuexen [Sat, 7 Sep 2019 10:47:43 +0000 (10:47 +0000)]
MFC r349986:

When calling sctp_initialize_auth_params(), the inp must have at
least a read lock. To avoid more complex locking dances, just
call it in sctp_aloc_assoc() when the write lock is still held.

4 years agoMFC r349968:
Michael Tuexen [Sat, 7 Sep 2019 10:45:44 +0000 (10:45 +0000)]
MFC r349968:

r348494 fixes a race in udp_output(). The same race exists in
udp_output6(), therefore apply a similar patch to IPv6.

Reviewed by: bz@, markj@
Differential Revision: https://reviews.freebsd.org/D20936

4 years agoMFC r349228:
Michael Tuexen [Sat, 7 Sep 2019 10:39:49 +0000 (10:39 +0000)]
MFC r349228:

The variable names in the description of the port number usage is
inconsistent. This patch fixes that and improves the precision of
the description.
Thanks to Tom Marcoen for reporting the issue and providing an
initial patch, on which this change is based.

PR: 237723
Reviewed by: bcr@
Differential Revision: https://reviews.freebsd.org/D20708

4 years agoMFC r351379 r351385 r351592:
Mike Karels [Fri, 6 Sep 2019 21:53:04 +0000 (21:53 +0000)]
MFC r351379 r351385 r351592:

Change w(1) to compute FROM (host) field size dynamically

It's nice to be able to display a full IPv6 host address if
needed, but it's also nice to display more than 3 characters of a command
line. Compute the needed size for the FROM column in an earlier pass,
and determine the maximum, then print what fits for the command.

Fix address annotation in xml output from w

The libxo xml feature of adding an annotation with the "original"
address from the utmpx file if it is different than the final "from"
field was broken by r351379. This was pointed out by the gcc error
that save_p might be used uninitialized. Save the original address
as needed in each entry, don't just use the last one from the previous
loop.

Reviewed by:    marcel@
Differential Revision:  https://reviews.freebsd.org/D21211
Differential Revision:  https://reviews.freebsd.org/D21390

4 years agoMFC r350858-r350859, r350987, r351170
Alan Somers [Fri, 6 Sep 2019 20:16:08 +0000 (20:16 +0000)]
MFC r350858-r350859, r350987, r351170

r350858:
ping6: Add missing static keyword for a global variable

This fixes -Wmissing-variable-declarations error when compiled with
WARNS=6.

Submitted by: Ján Sučan <sucanjan@gmail.com>
Sponsored by: Google, inc. (Google Summer of Code 2019)
Differential Revision: https://reviews.freebsd.org/D21214

r350859:
ping6: Remove unnecessary level of indirection from dnsdecode() parameter

The `sp' pointer doesn't need to be modified in the caller of
dnsdecode().

This fixes -Wcast-qual error (`must have all intermediate pointers
const qualified to be safe') when compiled with WARNS=6.

Submitted by: Ján Sučan <sucanjan@gmail.com>
Sponsored by: Google, inc. (Google Summer of Code 2019)
Differential Revision: https://reviews.freebsd.org/D21215

r350987:
ping6: Fix data type of a variable for a packet sequence number

Submitted by:   Ján Sučan <sucanjan@gmail.com>
Sponsored by:   Google, inc. (Google Summer of Code 2019)
Differential Revision:  https://reviews.freebsd.org/D21218

r351170:
ping6: Fix dnsdecode() bug introduced by r350859

Revision 350859 removed level of indirection that was needed for setting the
caller's `cp' pointer. dnsdecode() uses return value to indicate error or
success. It returns pointer to a buffer holding a decompressed DNS name or
NULL. The caller uses that value only to find out the result, not for accessing
the buffer.

We use the return value to propagate the new value of `cp' pointer to
the caller instead of using an output argument.

Submitted by: Ján Sučan <sucanjan@gmail.com>
MFC-With: 350859
Sponsored by: Google, Inc (Google Summer of Code 2019)
Differential Revision: https://reviews.freebsd.org/D21266

4 years agoMFC r350556:
Alan Somers [Fri, 6 Sep 2019 19:46:27 +0000 (19:46 +0000)]
MFC r350556:

Capsicumize ping6

Add capsicum support to ping6, mostly copying the strategy used for ping.

Submitted by: Ján Sučan <jansucan@gmail.com>
Reviewed by: markj
Sponsored by: Google, inc. (Google Summer of Code 2019)
Differential Revision: https://reviews.freebsd.org/D21050

4 years agoMFC r350453:
Alan Somers [Fri, 6 Sep 2019 19:36:41 +0000 (19:36 +0000)]
MFC r350453:

Add a CXXWARNFLAGS variable

Some warning flags are valid for C++ but not C. GCC 8 complains if you pass
such flags when building a C file. Using a separate variable for these
flags allows building both C and C++ files in the same directory (such as
the fusefs tests) under GCC.

Reviewed by: cem, emaste
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D21116

4 years agoMFC r350426:
Alan Somers [Fri, 6 Sep 2019 19:29:02 +0000 (19:29 +0000)]
MFC r350426:

sendfile: don't panic when VOP_GETPAGES_ASYNC returns an error

This is a partial merge of 350144 from projects/fuse2

PR: 236466
Reviewed by: markj
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D21095

4 years agoMFC r350386, r350390
Alan Somers [Fri, 6 Sep 2019 19:22:33 +0000 (19:22 +0000)]
MFC r350386, r350390

r350386:
Add v_inval_buf_range, like vtruncbuf but for a range of a file

v_inval_buf_range invalidates all buffers within a certain LBA range of a
file. It will be used by fusefs(5). This commit is a partial merge of
r346162, r346606, and r346756 from projects/fuse2.

Reviewed by: kib
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D21032

r350390:
Better comments for vlrureclaim

Sponsored by: The FreeBSD Foundation

4 years agoMFC r350314:
Alan Somers [Fri, 6 Sep 2019 19:07:34 +0000 (19:07 +0000)]
MFC r350314:

special-case getvfsbyname(3) for fusefs(5)

fusefs file systems may have a fsname subtype (set by mount_fusefs's "-o
subtype" option) that gets appended to the fsname as returned by statfs(2).
The subtype is set on a per-mount basis so it isn't part of the struct
vfsconf. Special-case getvfsbyname to match either the full "fusefs.foobar"
or short "fusefs" fsname.

This is a merge of r348007, r348054, and r350093 from projects/fuse2

Reviewed by: kib
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D21043

4 years agoMFC r350291:
Alan Somers [Fri, 6 Sep 2019 18:23:00 +0000 (18:23 +0000)]
MFC r350291:

Add c++14 and c++17 to COMPILER_FEATURES

This will be used to gate the fusefs tests. It's a partial merge of r348281
from projects/fuse2.

Reviewed by: kib, emaste
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D21044

4 years agoMFC r350268:
Alan Somers [Fri, 6 Sep 2019 18:14:14 +0000 (18:14 +0000)]
MFC r350268:

VOP_FSYNC.9: update copyright after r345677

MFC-With: r345677
Sponsored by: The FreeBSD Foundation

4 years agoMFC r350227:
Alan Somers [Fri, 6 Sep 2019 18:11:39 +0000 (18:11 +0000)]
MFC r350227:

[skip ci] Fix the comment for cache_purge(9)

This is a merge of r348738 from projects/fuse2

Reviewed by: kib
Sponsored by: The FreeBSD Foundation

4 years agoMFC r346186:
Alan Somers [Fri, 6 Sep 2019 18:10:03 +0000 (18:10 +0000)]
MFC r346186:

fusefs: add a fusefs(5) man page

PR: 233393
Reported by: tech-lists@zyxst.net
Reviewed by: cem
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D19651

4 years agoMFC r345986:
Alan Somers [Fri, 6 Sep 2019 18:08:13 +0000 (18:08 +0000)]
MFC r345986:

fusefs: fix a panic on mount

Don't page fault if the file descriptor provided with "-o fd" is invalid.
This is a merge of r345419 from the projects/fuse2 branch.

Reviewed by: ngie
Tested by: Marek Zarychta <zarychtam@plan-b.pwste.edu.pl>
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D19836

4 years agoMFC r345675, r345689
Alan Somers [Fri, 6 Sep 2019 18:02:58 +0000 (18:02 +0000)]
MFC r345675, r345689

r345675:
fusefs: convert debug printfs into dtrace probes

fuse(4) was heavily instrumented with debug printf statements that could
only be enabled with compile-time flags. They fell into three basic groups:

1. Totally redundant with dtrace FBT probes. These I deleted.
2. Print textual information, usually error messages. These I converted to
   SDT probes of the form fuse:fuse:FILE:trace. They work just like the old
   printf statements except they can be enabled at runtime with dtrace. They
   can be filtered by FILE and/or by priority.
3. More complicated probes that print detailed information. These I
   converted into ad-hoc SDT probes.

Also, de-inline fuse_internal_cache_attrs.  It's big enough to be a regular
function, and this way it gets a dtrace FBT probe.

This commit is a merge of r345304, r344914, r344703, and r344664 from
projects/fuse2.

Reviewed by: cem
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D19667

r345689:
fix the GENERIC-NODEBUG build after r345675

Submitted by: cy
Reported by: cy, Michael Butler <imb@protected-networks.net>
X-MFC-With: 345675

4 years agoMFC r344183-r344187, r344333-r344334, r344407, r344857, r344865 (by cem)
Alan Somers [Fri, 6 Sep 2019 17:56:24 +0000 (17:56 +0000)]
MFC r344183-r344187, r344333-r344334, r344407, r344857, r344865 (by cem)

r344183:
FUSE: Respect userspace FS "do-not-cache" of file attributes

The FUSE protocol demands that kernel implementations cache user filesystem
file attributes (vattr data) for a maximum period of time in the range of
[0, ULONG_MAX] seconds.  In practice, typical requests are for 0, 1, or 10
seconds; or "a long time" to represent indefinite caching.

Historically, FreeBSD FUSE has ignored this client directive entirely.  This
works fine for local-only filesystems, but causes consistency issues with
multi-writer network filesystems.

For now, respect 0 second cache TTLs and do not cache such metadata.
Non-zero metadata caching TTLs in the range [0.000000001, ULONG_MAX] seconds
are still cached indefinitely, because it is unclear how a userspace
filesystem could do anything sensible with those semantics even if
implemented.

In the future, as an optimization, we should implement notify_inval_entry,
etc, which provide userspace filesystems a way of evicting the kernel cache.

One potentially bogus access to invalid cached attribute data was left in
fuse_io_strategy.  It is restricted behind the undocumented and non-default
"vfs.fuse.fix_broken_io" sysctl or "brokenio" mount option; maybe these are
deadcode and can be eliminated?

Some minor APIs changed to facilitate this:

1. Attribute cache validity is tracked in FUSE inodes ("fuse_vnode_data").

2. cache_attrs() respects the provided TTL and only caches in the FUSE
inode if TTL > 0.  It also grows an "out" argument, which, if non-NULL,
stores the translated fuse_attr (even if not suitable for caching).

3. FUSE VTOVA(vp) returns NULL if the vnode's cache is invalid, to help
avoid programming mistakes.

4. A VOP_LINK check for potential nlink overflow prior to invoking the FUSE
link op was weakened (only performed when we have a valid attr cache).  The
check is racy in a multi-writer network filesystem anyway -- classic TOCTOU.
We have to trust any userspace filesystem that rejects local caching to
account for it correctly.

PR: 230258 (inspired by; does not fix)

r344184:
FUSE: Respect userspace FS "do-not-cache" of path components

The FUSE protocol demands that kernel implementations cache user filesystem
path components (lookup/cnp data) for a maximum period of time in the range
of [0, ULONG_MAX] seconds.  In practice, typical requests are for 0, 1, or
10 seconds; or "a long time" to represent indefinite caching.

Historically, FreeBSD FUSE has ignored this client directive entirely.  This
works fine for local-only filesystems, but causes consistency issues with
multi-writer network filesystems.

For now, respect 0 second cache TTLs and do not cache such metadata.
Non-zero metadata caching TTLs in the range [0.000000001, ULONG_MAX] seconds
are still cached indefinitely, because it is unclear how a userspace
filesystem could do anything sensible with those semantics even if
implemented.

Pass fuse_entry_out to fuse_vnode_get when available and only cache lookup
if the user filesystem did not set a zero second TTL.

PR: 230258 (inspired by; does not fix)

r344185:
FUSE: Only "dirty" cached file size when data is dirty

Most users of fuse_vnode_setsize() set the cached fvdat->filesize and update
the buf cache bounds as a result of either a read from the underlying FUSE
filesystem, or as part of a write-through type operation (like truncate =>
VOP_SETATTR).  In these cases, do not set the FN_SIZECHANGE flag, which
indicates that an inode's data is dirty (in particular, that the local buf
cache and fvdat->filesize have dirty extended data).

PR: 230258 (related)

r344186:
FUSE: The FUSE design expects writethrough caching

At least prior to 7.23 (which adds FUSE_WRITEBACK_CACHE), the FUSE protocol
specifies only clean data to be cached.

Prior to this change, we implement and default to writeback caching.  This
is ok enough for local only filesystems without hardlinks, but violates the
general design contract with FUSE and breaks distributed filesystems or
concurrent access to hardlinks of the same inode.

In this change, add cache mode as an extension of cache enable/disable.  The
new modes are UC (was: cache disabled), WT (default), and WB (was: cache
enabled).

For now, WT caching is implemented as write-around, which meets the goal of
only caching clean data.  WT can be better than WA for workloads that
frequently read data that was recently written, but WA is trivial to
implement.  Note that this has no effect on O_WRONLY-opened files, which
were already coerced to write-around.

Refs:
  * https://sourceforge.net/p/fuse/mailman/message/8902254/
  * https://github.com/vgough/encfs/issues/315

PR: 230258 (inspired by)

r344187:
FUSE: Refresh cached file size when it changes (lookup)

The cached fvdat->filesize is indepedent of the (mostly unused)
cached_attrs, and we failed to update it when a cached (but perhaps
inactive) vnode was found during VOP_LOOKUP to have a different size than
cached.

As noted in the code comment, this can occur in distributed filesystems or
with other kinds of irregular file behavior (anything is possible in FUSE).

We do something similar in fuse_vnop_getattr already.

PR: 230258 (as reported in description; other issues explored in
comments are not all resolved)
Reported by: MooseFS FreeBSD Team <freebsd AT moosefs.com>
Submitted by: Jakub Kruszona-Zawadzki <acid AT moosefs.com> (earlier version)

r344333:
fuse: add descriptions for remaining sysctls

(Except reclaim revoked; I don't know what that goal of that one is.)

r344334:
Fuse: whitespace and style(9) cleanup

Take a pass through fixing some of the most egregious whitespace issues in
fs/fuse.  Also fix some style(9) warts while here.  Not 100% cleaned up, but
somewhat less painful to look at and edit.

No functional change.

r344407:
fuse: Fix a regression introduced in r337165

On systems with non-default DFLTPHYS and/or MAXBSIZE, FUSE would attempt to
use a buf cache block size in excess of permitted size.  This did not affect
most configurations, since DFLTPHYS and MAXBSIZE both default to 64kB.
The issue was discovered and reported using a custom kernel with a DFLTPHYS
of 512kB.

PR: 230260 (comment #9)
Reported by: ken@

r344857:
FUSE: Prevent trivial panic

When open(2) was invoked against a FUSE filesystem with an unexpected flags
value (no O_RDONLY / O_RDWR / O_WRONLY), an assertion fired, causing panic.

For now, prevent the panic by rejecting such VOP_OPENs with EINVAL.

This is not considered the correct long term fix, but does prevent an
unprivileged denial-of-service.

PR: 236329
Reported by: asomers
Reviewed by: asomers
Sponsored by: Dell EMC Isilon

r344865:
fuse: switch from DFLTPHYS/MAXBSIZE to maxcachebuf

On GENERIC kernels with empty loader.conf, there is no functional change.
DFLTPHYS and MAXBSIZE are both 64kB at the moment.  This change allows
larger bufcache block sizes to be used when either MAXBSIZE (custom kernel)
or the loader.conf tunable vfs.maxbcachebuf (GENERIC) is adjusted higher
than the default.

Suggested by: ken@

4 years agoMFC r350685:
Edward Tomasz Napierala [Fri, 6 Sep 2019 17:54:51 +0000 (17:54 +0000)]
MFC r350685:

Add cdceem(4) driver, for virtual ethernet devices compliant
with Communication Device Class Ethernet Emulation Model (CDC EEM).
The driver supports both the device, and host side operation; there
is a new USB template (#11) for the former.

This enables communication with virtual USB NIC provided by iLO 5,
as found in new HPE Proliant servers.

Reviewed by: hselasky
Relnotes: yes
Sponsored by: Hewlett Packard Enterprise

4 years agoMFC r350225:
Alan Somers [Fri, 6 Sep 2019 17:43:00 +0000 (17:43 +0000)]
MFC r350225:

Remove the USE_RFC2292BIS option and reap dead code

This option was imported as part of the KAME project in r62627 (in 2000).
It was turned on unconditionally in r121472 (in 2003) and has been on ever
since. The old alternative code has bitrotted. Reap the dead code.

Reported by: Ján Sučan <jansucan@gmail.com>
Differential Revision: https://reviews.freebsd.org/D20938

4 years agoMFC r345350, r346441, r346765
Alan Somers [Fri, 6 Sep 2019 17:21:21 +0000 (17:21 +0000)]
MFC r345350, r346441, r346765

r345350:
Rename fuse(4) to fusefs(4)

This makes it more consistent with other filesystems, which all end in "fs",
and more consistent with its mount helper, which is already named
"mount_fusefs".

Reviewed by: cem, rgrimes
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D19649

r346441:
Use symlinks for kernel modules rather than hardlinks

When aliasing a kernel module to a different name (ie if_igb for if_em),
it's better to use symlinks than hard links. kldxref will omit entries for
the links, ensuring that the loaded module has the correct name.

Reviewed by: imp
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D19979

r346765:
Don't symlink fusefs.ko to fuse.ko on PPC

Some PPC systems (PowerNV) use msdosfs for /boot, which can't handle either
symlinks or hardlinks. So on PPC, copy the module instead. This change fixes
installkernel on such systems after r345350.

Reported by: Brandon Bergren <git_bdragon.rtk0.net>
Reviewed by: jhibbits, rgrimes
MFC-With: 345350, 346441
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D19993

4 years agoMFC r351593: zfs_ioc_snapshot: check user-prop permissions on snapshotted datasets
Andriy Gapon [Fri, 6 Sep 2019 12:27:47 +0000 (12:27 +0000)]
MFC r351593: zfs_ioc_snapshot: check user-prop permissions on snapshotted datasets

4 years agoMFC r351413,351459,351467: unbreak last(1) for 8-bit locales
Eugene Grosbein [Fri, 6 Sep 2019 05:30:06 +0000 (05:30 +0000)]
MFC r351413,351459,351467: unbreak last(1) for 8-bit locales

Ouput format of last's broken for non UTF-8 locales
since it got libxo(3) support. It uses strftime(3) that produces
non UTF-8 strings passed to xo_emit(3) with wrong %s format -
it should be %hs in this case, so xo_emit(3) produces empty output.

This change is basically no-op when locale is of UTF-8 type,
f.e. en_GB.UTF-8 or ru_RU.UTF-8 or sr_RS.UTF-8@latin.
Also it is no-op for C/POSIX locale that's a subset of UTF-8.

It fixes output for other locales.

4 years agoRename stable/12 to 12.1-PRERELEASE, marking the start of the
Glen Barber [Fri, 6 Sep 2019 00:00:13 +0000 (00:00 +0000)]
Rename stable/12 to 12.1-PRERELEASE, marking the start of the
12.1 release cycle.

Approved by: re (implicit)
Sponsored by: Rubicon Communications, LLC (Netgate)

4 years agoMFC r349845:
Warner Losh [Thu, 5 Sep 2019 23:54:44 +0000 (23:54 +0000)]
MFC r349845:

  Work around devices which return all zeros for reads of existing MSI-X table
  VCTRL registers.

Note: This is confirmed to fix the nvme lost interrupt issues, seen on both
virtual and real cards.
PR: 211713

4 years agoMFC r351747:
Warner Losh [Thu, 5 Sep 2019 23:40:38 +0000 (23:40 +0000)]
MFC r351747:

  Implement nvme suspend / resume for pci attachment

Note: this is merged ~9 hours early due to a desire to have it in before feature
freeze in 20 minutes. Several reports of it working in current (and one that it
worked in -stable after copying all of -current's nvme driver) gives me
confidence that bending the rules a little here is the right trade-off.

PR: 240340
Relnotes: Yes

4 years agoMFC r343755:
Warner Losh [Thu, 5 Sep 2019 23:27:59 +0000 (23:27 +0000)]
MFC r343755:

  Regularize the Netflix copyright

4 years agoRevert r351902 ... it didn't properly exclude rack.c changes
Warner Losh [Thu, 5 Sep 2019 23:24:43 +0000 (23:24 +0000)]
Revert r351902 ... it didn't properly exclude rack.c changes

4 years agoMFC r351706:
Warner Losh [Thu, 5 Sep 2019 23:13:44 +0000 (23:13 +0000)]
MFC r351706:

  In nvme_completion_poll, add a sanity check to make sure that we complete the
  polling within a second. Panic if we don't. All the commands that use this
  interface should typically complete within a few tens to hundreds of
  microseconds. Panic rather than return ETIMEDOUT because if the command
  somehow does later complete, it will randomly corrupt memory. Also, it helps
  to get a traceback from where the unexpected failure happens, rather than an
  infinite loop.

4 years agoMFC r351705:
Warner Losh [Thu, 5 Sep 2019 23:12:56 +0000 (23:12 +0000)]
MFC r351705:

  In all the places that we use the polled for completion interface, except
  crash dump support code, move the while loop into an inline function. These
  aren't done in the fast path, so if the compiler choses to not inline, any
  performance hit is tiny.

4 years agoMFC r351704:
Warner Losh [Thu, 5 Sep 2019 23:12:06 +0000 (23:12 +0000)]
MFC r351704:

  Add a brief comment explaining why we can return ETIMEDOUT from the call to
  the polled interface. Normally this would have the potential to corrupt stack
  memory because the completion routines would run after we return. In this
  case, however, we're doing a dump so it's safe for reasons explained in the
  comment.

4 years agoMFC r351406,r351447:
Warner Losh [Thu, 5 Sep 2019 23:09:50 +0000 (23:09 +0000)]
MFC r351406,r351447:

  r351406:
    We need to define version 1 of nvme, not nvme_foo. Otherwise nvd won't load
    and people who pull in nvme/nvd from modules can't load nvd.ko since it
    depends on nvme, not nvme_foo. The duplicate doesn't matter since kldxref
    properly handles that case.
  r351447:
    It turns out the duplication is only mostly harmless.

4 years agoMFC r351411:
Warner Losh [Thu, 5 Sep 2019 23:07:57 +0000 (23:07 +0000)]
MFC r351411:

  When we have errors resetting the device before we allocate the queues, don't
  try to tear them down in the ctrlr_destroy path. Otherwise, we dereference
  queue structures that are NULL and we trap.

4 years agoMFC r351403:
Warner Losh [Thu, 5 Sep 2019 23:04:37 +0000 (23:04 +0000)]
MFC r351403:

  Move releasing of resources to later

4 years agoMFC r351376:
Warner Losh [Thu, 5 Sep 2019 23:03:37 +0000 (23:03 +0000)]
MFC r351376:

  Remove stray line that was duplicated.

4 years agoMFC r351356:
Warner Losh [Thu, 5 Sep 2019 23:02:08 +0000 (23:02 +0000)]
MFC r351356:

  Create a AHCI attachment for nvme.