]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
6 years agoMFC r306325, r306329-r306330, r306333, r306620-r306622, r307387, r307544, r307550...
manu [Wed, 7 Feb 2018 15:32:31 +0000 (15:32 +0000)]
MFC r306325, r306329-r306330, r306333, r306620-r306622, r307387, r307544, r307550, r318137, r319125, r319295

r306325 by marcel:
Replace the use of linker sets with constructors for both the
formats and schemes.  Formats and schemes are registered at
runtime now, rather than collected at link time.

r306329 by marcel:
Eliminate the use of EDOOFUS.  The error code was used to signal
programming errors, but is really a poor substitute for assert.
And less portable as well.

r306330 by marcel:
Avoid depending on the <sys/endian.h> header for le*enc and be*enc.
Not only is the header unportable, the encoding/decoding functions
are as well.  Instead, duplicate the handful of small inlines we
need into a private header called endian.h.

Aside: an alternative approach is to move the encoding/decoding
functions to a separate system header.  While the header is still
nonportable, such an approach would make it possible to re-use the
definitions by playing games with include paths. This may be the
preferred approach if more (build) utilities need this.  This
change does not preclude that.  In fact, it makes it easier.

r306333 by marcel:
Portability changes:
1.  macOS nor Linux have MAP_NOCORE nor MAP_NOSYNC. Define as 0.
2.  macOS doesn't have SEEK_DATA nor SEEK_HOLE. Define as -1
    so that lseek will return -1 (with errno set to EINVAL).
3.  gcc correctly warns that error is assigned but not used in
    image_copyout_region().  Fix by returning on the first error.

r306620 by marcel:
Replace STAILQ with TAILQ. TAILQs are portable enough that they can
be used on both macOS and Linux. STAILQs are not. In particular,
STAILQ_LAST does not next on Linux. Since neither STAILQ_FOREACH_SAFE
nor TAILQ_FOREACH_SAFE exist on Linux, replace its use with a regular
TAILQ_FOREACH. The _SAFE variant was only used for having the next
pointer in a local variable.

r306621 by marcel:
Prefer <stdint.h> over <sys/types.h>. While here remove redundant
inclusion of <sys/queue.h>.

Move the inclusion of the disk partitioning headers out of order
and inbetween standard headers and local header. They will change
in a subsequent commit.

r306622 by marcel:
Replace OFF_MAX with INT64_MAX. The former is defined on Linux.

r307387 by marcel:
Switch to using the portable partition scheme headers.

r307544 by marcel:
 o  Provide a private definition for UUIDs (mkimg_uuid_t) because
    UUIDs are not portable.
 o  Move mkimg_uuid() to a new file and merge both gpt_uuid_enc()
    and vhd_uuid_enc() into a single mkimg_uuid_enc() that lives
    in the same file.
 o  Move the OS-specific implementation of generating a UUID to
    osdep_uuidgen() and provide the implementations for FreeBSD,
    macOS and Linux.
 o  Expect the partitioning scheme headers to be found by having
    a search to the directory in which the headers live. This
    avoids conflicts on non-FreeBSD machines.

r307550 by imp:
Add a new flag to mkimg (-a num) to specify the active partition for
those partitioning schemes that have this concept. Implement it as an
override for mbr's setting 0x80 in the flags for the first partition
when we have boot code.

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

r318137:
mkimg: Add -C argument to specify maximum capacity

Add a -C option to specify a maximum capacity for the final image file.
It is useful to control the size of the generated image for sdcard or
when we will add dynamic size partition.

Add --capacity which is a shorthand to define min and max capacity at
the same time.

Reviewed by: bapt, marcel, wblock (manpages)
Sponsored by: Gandi.net
Differential Revision: https://reviews.freebsd.org/D10509

r319125:
mkimg: Correct an off by one error in the PMBR size

The PMBR last sector should be number of sector - 1 (As stated in UEFI Spec
2.6 page 118 table 17).
This fixes warning printed by linux tools like parted or fdisk.

Sponsored by: Gandi.net

r319295 by ngie:
Update the usr.bin/mkimg golden test output files after ^/head@r319125

^/head@r319125 changed the location of the backup pmbr, requiring the
output files to be regenerated, since they're binary disk dumps.

The output files were regenerated with "make rebase"--fixed in
^/head@r319294.

MFC with: r319125, r319294
PR: 219673
Sponsored by: Dell EMC Isilon

6 years agoMFC r328237:
hselasky [Wed, 7 Feb 2018 15:06:54 +0000 (15:06 +0000)]
MFC r328237:
Use the __alloc_size2 attribute where relevant.

This follows the documented use in GCC. It is basically only relevant for
calloc(3), reallocarray(3) and  mallocarray(9).

NOTE: Without this change clang 5.0.1 can produce incorrect optimisation
code for static processing of data using the allocated object. For example
this has been seen compiling the mlx4 core module, which allocates a
fixed size array which is then sorted by a fixed order loop. The
optimised result, -O2, is incorrect unless this patch is in place.

Suggested by: Mark Millard
Reference: https://docs.freebsd.org/cgi/mid.cgi?9DE674C6-EAA3-4E8A-906F-446E74D82FC4

6 years agoMFC r328326:
ae [Wed, 7 Feb 2018 09:28:23 +0000 (09:28 +0000)]
MFC r328326:
  When IPv6 packet is handled by O_REJECT opcode, convert ICMP code
  specified in the arg1 into ICMPv6 destination unreachable code according
  to RFC7915.

  Obtained from: Yandex LLC
  Sponsored by: Yandex LLC

6 years agoMFC r324821:
mmel [Wed, 7 Feb 2018 06:29:07 +0000 (06:29 +0000)]
MFC r324821:

  Fix spelling.

6 years agoMFC r325438:
mmel [Wed, 7 Feb 2018 06:27:29 +0000 (06:27 +0000)]
MFC r325438:

  All CP15 registers are bit fields or counters, don't use signed type when
  accessing them.

6 years agoMFC r325364,r326794:
mmel [Wed, 7 Feb 2018 06:24:34 +0000 (06:24 +0000)]
MFC r325364,r326794:

  r325364:
    Add alignment support to __libc_allocate_tls().
  r326794:
    Rework alignment handling in __libc_allocate_tls() for Variant I of TLS
    layout.

6 years agoAdjust MFC in r328944 to stable/11.
kib [Tue, 6 Feb 2018 23:50:02 +0000 (23:50 +0000)]
Adjust MFC in r328944 to stable/11.
This is a direct commit to the branch.

Sponsored by: The FreeBSD Foundation

6 years agoMFC of 328647.
mckusick [Tue, 6 Feb 2018 19:17:05 +0000 (19:17 +0000)]
MFC of 328647.

avoid segment fault in g_journal

6 years agoMFC of 328643.
mckusick [Tue, 6 Feb 2018 19:13:44 +0000 (19:13 +0000)]
MFC of 328643.

fix vn_printf listing of its union

6 years agoMFC of 328304 and 328382.
mckusick [Tue, 6 Feb 2018 19:09:03 +0000 (19:09 +0000)]
MFC of 328304 and 328382.

Do not dedup egid (group entry 0)

6 years agoMFC r308774: loader: beri_sdcard_disk_print() needs to return int.
kevans [Tue, 6 Feb 2018 18:01:41 +0000 (18:01 +0000)]
MFC r308774: loader: beri_sdcard_disk_print() needs to return int.

r308434 did change the return type for dv_print callbacks, but the return
type for beri_sdcard_disk_print() was left unchanged, causing compile errors.

6 years agoMFC r325116,r325515: Stop masking errors during buildenv
kevans [Tue, 6 Feb 2018 14:04:39 +0000 (14:04 +0000)]
MFC r325116,r325515: Stop masking errors during buildenv

MFC r325116(imp): Return proper status from buildenv.

make buildenv BUILDENV_SHELL=<some command> more useful. Remove '||
true' from the command line so that errors are properly
returned. There appears to be no reason for it, and it dates back to
the original commit by ru@.

MFC r325515 (imp): Note interactive shell errors for make buildenv and add a
warning for people tempted to add back the || true to get rid of them.

6 years agoMFC r328273 (kevlo): Document how to load nmdm(4) from a kernel module.
delphij [Tue, 6 Feb 2018 07:47:22 +0000 (07:47 +0000)]
MFC r328273 (kevlo): Document how to load nmdm(4) from a kernel module.

6 years agoMFC r342882,r324979,r325115: sys/boot test scripts
kevans [Mon, 5 Feb 2018 21:29:27 +0000 (21:29 +0000)]
MFC r342882,r324979,r325115: sys/boot test scripts

[Note: arm/armv7 has been removed in the interest of not having a failing
architecture from the start]

MFC r342882: Create a shell script to build sys/boot on all the
architectures.

MFC r324979: Do a chdir to SRCTOP/sys/boot before starting the run.

MFC r325115: Fix parallel build issues and add MK_ZFS=no case

6 years agoMFC r328552
vangyzen [Mon, 5 Feb 2018 18:56:34 +0000 (18:56 +0000)]
MFC r328552

ND6: Set the correct state for new neighbor cache entries

Restore state 6.  Many of the UNH tests end up exercising this
state, where we have a new neighbor cache entry and a new link-layer
entry is being created for it.  The link-layer address is currently
unknown so the initial state of the "llentry" should remain initialized
to ND6_LLINFO_NOSTATE so that the ND code will send a solicitation.
Setting this to ND6_LLINFO_STALE implies that the link-level entry
is valid and can be used (but needs to be refreshed via the Neighbor
Unreachability state machine).

https://forums.freebsd.org/threads/64287/

Submitted by: Farrell Woods <Farrell_Woods@Dell.com>
Reviewed by: mjoras, dab, ae
Sponsored by: Dell EMC
Differential Revision: https://reviews.freebsd.org/D14059

6 years agoMFC r308434, 308827
kevans [Mon, 5 Feb 2018 17:01:18 +0000 (17:01 +0000)]
MFC r308434, 308827

MFC r308434: Loader paged/pageable data is not always paged.
MFC r308827: lsdev device name section headers should be printed by dv_print
callback.

6 years agoMerge r327951
n_hibma [Mon, 5 Feb 2018 16:28:03 +0000 (16:28 +0000)]
Merge r327951

Add IDs for Quectel EC25.

Submitted by: Samuel Crookes

6 years agoMFC r328567:
pfg [Mon, 5 Feb 2018 15:02:35 +0000 (15:02 +0000)]
MFC r328567:
libedit: sort the Makefile in line with NetBSD's version.

NetBSD's libedit has been been cleaned-up considerably so the
non-widecharacter version is no longer an option. Re-sorting the
Makefile should make it easier for some brave soul trying to update it.

No functional change intended.

6 years agoMFC r328773:
kib [Mon, 5 Feb 2018 10:29:57 +0000 (10:29 +0000)]
MFC r328773:
On pageout, in vnode generic pager, for partially dirty page, only
clear dirty bits for completely invalid blocks.

PR: 225586

6 years agoMFC r328770:
ae [Mon, 5 Feb 2018 09:25:02 +0000 (09:25 +0000)]
MFC r328770:
  Merge r1.120 from NetBSD:
    Fix a pretty simple, yet pretty tragic typo: we should return IPPROTO_DONE,
    not IPPROTO_NONE. With IPPROTO_NONE we will keep parsing the header chain
    on an mbuf that was already freed.

  Reported by: Maxime Villard <max at m00nbsd dot net>

6 years agoMFC r323683:
eadler [Mon, 5 Feb 2018 08:20:11 +0000 (08:20 +0000)]
MFC r323683:

MFV r323678: file 5.32

6 years agoMFC r304321,304753,304754,306751,316077,316110:
kevans [Mon, 5 Feb 2018 04:00:59 +0000 (04:00 +0000)]
MFC r304321,304753,304754,306751,316077,316110:
SHA512, skein, large block support for loader zfs

MFC r304321: Add SHA512, skein, large blocks support for loader zfs.
MFC r304753: loader: zio_checksum_verify() must test spa for NULL pointer
MFC r304754: r304321 broken bhyve zvol VM bhyveload hang 100% WCPU
MFC r306751: Disable loop unrolling in skein for sys/boot
MFC r316077: Unbreak compilation with gcc 4.2.1
MFC r316110: Use `-Wno-missing-declarations` with CWARNFLAGS for skein.c

6 years agoMFC r328126: correct read-ahead calculations in vfs_bio_getpages
avg [Sun, 4 Feb 2018 14:00:38 +0000 (14:00 +0000)]
MFC r328126: correct read-ahead calculations in vfs_bio_getpages

6 years agoMFC r327775: amdsbwd: fix handling of timeout values beyond the supported range
avg [Sun, 4 Feb 2018 13:57:15 +0000 (13:57 +0000)]
MFC r327775: amdsbwd: fix handling of timeout values beyond the supported range

6 years agoMFC r327726: vmm/svm: contigmalloc of the whole svm_softc is excessive
avg [Sun, 4 Feb 2018 13:53:45 +0000 (13:53 +0000)]
MFC r327726: vmm/svm: contigmalloc of the whole svm_softc is excessive

6 years agoMFC r327911:
jhibbits [Sun, 4 Feb 2018 03:15:06 +0000 (03:15 +0000)]
MFC r327911:

  Replace the PMC class struct copy with an explicit memcpy()

6 years agoRemove now-unused variable after r328809
emaste [Sun, 4 Feb 2018 02:58:12 +0000 (02:58 +0000)]
Remove now-unused variable after r328809

6 years agoMFH r328332:
mm [Sat, 3 Feb 2018 02:17:04 +0000 (02:17 +0000)]
MFH r328332:
Sync libarchive with vendor.

Relevant vendor changes:
  PR #893: delete dead ppmd7 alloc callbacks
  PR #904: Fix archive freeing bug in bsdcat
  PR #961: Fix ZIP format names
  PR #962: Don't modify attributes for existing directories
           when ARCHIVE_EXTRACT_NO_OVERWRITE is set
  PR #964: Fix -Werror=implicit-fallthrough= for GCC 7
  PR #970: zip: Allow backslash as path separator

6 years agoMFC r328641: dtc(1): Revert WARNS change from r328173
kevans [Sat, 3 Feb 2018 01:20:01 +0000 (01:20 +0000)]
MFC r328641: dtc(1): Revert WARNS change from r328173

WARNS > 3 breaks xtoolchain builds to varying degrees. Revert it.

6 years agoMFC r328491: MFV r328490: Update libfdt to github:f1879e1
kevans [Sat, 3 Feb 2018 01:18:19 +0000 (01:18 +0000)]
MFC r328491: MFV r328490: Update libfdt to github:f1879e1

Pulls in a patch, now upstreamed, from nwhitehorn to add limited read-only
support for older (v2 and v3) FDT blobs.

6 years agoMFC r303468 (by imp):
mav [Fri, 2 Feb 2018 23:22:58 +0000 (23:22 +0000)]
MFC r303468 (by imp):
Move protocol specific stuff into a linker set object that's
per-protocol. This reduces the number scsi symbols references by
cam_xpt significantly, and eliminates all ata / nvme symbols. There's
still some NVME / ATA specific code for dealing with XPT_NVME_IO and
XPT_ATA_IO respectively, and a bunch of scsi-specific code, but this
is progress.

6 years agoMFC r303467 (by imp):
mav [Fri, 2 Feb 2018 23:19:20 +0000 (23:19 +0000)]
MFC r303467 (by imp):
Switch to linker sets to find the xport callback object.  This
eliminates the need to special case everything in cam_xpt for new
transports. It is now a failure to not have a transport object when
registering the bus as well. You can still, however, create a
transport that's unspecified (XPT_)

6 years agoMFC geli test suite changes
asomers [Fri, 2 Feb 2018 21:57:00 +0000 (21:57 +0000)]
MFC geli test suite changes

MFC r306188, r306395, r327346-r327347, r327352-r327353, r327662, r327666, r327682-r327683, r327685

r306188 by br:
Use bsdlabel as we don't have hardlink disklabel -> bsdlabel
on some platforms.

Reviewed by: ngie
Sponsored by: DARPA, AFRL
Sponsored by: HEIF5
Differential Revision: https://reviews.freebsd.org/D7968

r306395 by br:
Increase timeouts for geli tests. It takes 2-3x more time to proceed the
tests on MIPS64EB in QEMU.

Sponsored by: DARPA, AFRL
Sponsored by: HEIF5

r327346:
Fix potential TOCTTOU bug in the geli tests

This change mostly reverts r293436, which introduced the bug due to a belief
that geli(8) would allocate md(4) devices by itself. However, that belief is
incorrect. Instead of using linear probing to find available md(4) numbers,
it's best to use the existing attach_md function.

Reviewed by: ngie
Sponsored by: Spectra Logic Corp
Differential Revision: https://reviews.freebsd.org/D13666

r327347:
geli: factor out some common code in the geli tests

No functional change.

Sponsored by: Spectra Logic Corp

r327352:
Fix a harmless typo from r310786

I copy/pasted a reference to an undefined shell variable.

r327353:
geli: fix the resize test on arm64

The resize test used bsdlabel(8), which is not available on all
architectures.  Change it to use gpart(8) instead, which should be available
everywhere.

PR: 221763
Reported by: andrew

r327662:
geli: convert most tests from TAP to ATF

I'm leaving readonly_test and nokey_test alone for now. In a future commit
they should be broken up into several smaller test cases and distributed
between multiple files.

Reviewed by: ngie
Differential Revision: https://reviews.freebsd.org/D13717

r327666:
geli: fix parallel execution of tests

The trick is not to destroy an md(4) device during a test.  That can create
a "double-free" situation, because we also destroy md devices during test
cleanup.

r327682:
Fix typo from r327666

X-MFC-With: 327666

r327683:
geli: convert remaining TAP tests to ATF

r327685:
geli: optimize tests

Reduce the geli tests' runtime by about a third:

* In integrity_test:copy, use a file-backed md(4) device instead of a
  malloc'd one.  That way we can corrupt the underlying storage without
  needing to detach and reattach the geli device.

* In integrity_test:{copy, hmac, data} and onetime_test:{onetime,
  onetime_a}, move reads of /dev/random out of the loop.

6 years agoMFC r328504: stand/fdt: Consolidate overlay handling a little further
kevans [Fri, 2 Feb 2018 21:25:32 +0000 (21:25 +0000)]
MFC r328504: stand/fdt: Consolidate overlay handling a little further

[This is effectively a direct commit to stable/11 due to path restructuring
in HEAD. The diff against HEAD has simply been applied to the old path]

This should have been done as part of r327350, but due to lack of foresight
it came later. In the different places we apply overlays, we duplicate the
bits that check for fdt_overlays in the environment and supplement that with
any other places we need to check for overlays to load. These "other places"
will be loader specific and are not candidates for consolidation.

Provide an fdt_load_dtb_overlays to capture the common logic, allow passing
in an additional list of overlays to be loaded. This additional list of
overlays is used in practice for ubldr to pull in any fdt_overlays passed to
it from U-Boot environment, but it can be used for any other source of
overlays.

These additional overlays supplement loader.conf(5) fdt_overlays, rather
than replace, so that we're not restricted to specifying overlays in only
one place. This is a change from previous behavior where loader.conf(5)
supplied fdt_overlays would cause us to ignore U-Boot environment, and this
seems nonsensical- user should have sufficient control over both of these
aspects, or lack of control for good reasons.

A knob could be considered in the future to ignore U-Boot supplied overlays,
but the supplemental treatment seems like a good start.

6 years agoMFC r322894:
bdrewery [Fri, 2 Feb 2018 21:00:06 +0000 (21:00 +0000)]
MFC r322894:

  Replace makefs' hand-rolled unescaping with strunvis

Sponsored by: Dell EMC

6 years agoMFC r312293,312305,312434,312698,312759,312760,312814,312815,322672:
mav [Fri, 2 Feb 2018 18:38:29 +0000 (18:38 +0000)]
MFC r312293,312305,312434,312698,312759,312760,312814,312815,322672:
Synchronize gtaskqueue vs SMP initialization order with head.

This should fix panics on boot, caused by recent Linux KPI merges.

6 years agoPartial MFC of r312205 (by sbruno): Skip smp check if we're running UP
mav [Fri, 2 Feb 2018 18:12:09 +0000 (18:12 +0000)]
Partial MFC of r312205 (by sbruno): Skip smp check if we're running UP

6 years agoPartial MFC of r311039 (by sbruno):
mav [Fri, 2 Feb 2018 18:10:45 +0000 (18:10 +0000)]
Partial MFC of r311039 (by sbruno):
- add INVARIANTS debugging hooks to gtaskqueue enqueue (mmacy)

6 years agoMFC r307657 (by sbruno): Resolve whitespace diff to NextBSD.
mav [Fri, 2 Feb 2018 18:04:57 +0000 (18:04 +0000)]
MFC r307657 (by sbruno): Resolve whitespace diff to NextBSD.

Check to see that the taskqueue thread count requires us to acutally
iterate over the thread count to bind to cpus.

6 years agoMFC r307567 (by sbruno): Assert that we're assigning a non-null taskqueue.
mav [Fri, 2 Feb 2018 18:03:14 +0000 (18:03 +0000)]
MFC r307567 (by sbruno): Assert that we're assigning a non-null taskqueue.
ref: https://github.com/NextBSD/NextBSD/commit/535865d02c162e415d7436899cd6db5000a0cc7b

Fix cpu assignment by assuring stride is non-zero, assert that all tasks
have a valid taskqueue.
ref: https://github.com/NextBSD/NextBSD/commit/db398176234fe3ce9f8e8b671f56000f8276feba

Start cpu assignment from zero.
ref: https://github.com/NextBSD/NextBSD/commit/d99d39b6b6c5dfac1eb440c41e36ebf4c897198e

6 years agoMFC r307566 (by sbruno):
mav [Fri, 2 Feb 2018 18:02:06 +0000 (18:02 +0000)]
MFC r307566 (by sbruno):
Ensure that tasks with a specific cpu set prior to smp starting get
re-attached to a thread running on that cpu.

ref: https://github.com/NextBSD/NextBSD/commit/fcc20e306bc93ebbbe51f3775d1afb527970a2e9

6 years agoMFC r307561 (by sbruno): Tell gtask to what we've been bound.
mav [Fri, 2 Feb 2018 17:59:44 +0000 (17:59 +0000)]
MFC r307561 (by sbruno):  Tell gtask to what we've been bound.

ref: https://github.com/NextBSD/NextBSD/commit/54414984cfebb920bbc40aadeb601bdce448d8d7

6 years agoMFC r307041 (by sbruno):
mav [Fri, 2 Feb 2018 17:56:47 +0000 (17:56 +0000)]
MFC r307041 (by sbruno):
Fix bug where malloc(.., M_NOWAIT) return value is not checked, Change to
M_WAITOK and move outside the mutex

6 years agoMFC r328584: stand/fdt: Remove unused write-only new_fdtp, correct comment
kevans [Fri, 2 Feb 2018 14:47:25 +0000 (14:47 +0000)]
MFC r328584: stand/fdt: Remove unused write-only new_fdtp, correct comment

This is effectively a direct commit to stable/11 due to path restructuring
in HEAD. The diff against HEAD has simply been applied to the old path.

6 years agoMFC r328161:
ae [Fri, 2 Feb 2018 07:55:31 +0000 (07:55 +0000)]
MFC r328161:
  Add UDPLite support to ipfw(4).

  Now it is possible to use UDPLite's port numbers in rules,
  create dynamic states for UDPLite packets and see "UDPLite" for matched
  packets in log.

  Obtained from: Yandex LLC
  Sponsored by: Yandex LLC

6 years agoMFC r328160:
ae [Fri, 2 Feb 2018 07:48:46 +0000 (07:48 +0000)]
MFC r328160:
  Add to bsnmpd(1) ability to specify multiple community strings with
  different access rights.

  By default there are two community strings with index 1 and 2, one for
  read-only access and second for read-write access:

    begemotSnmpdCommunityString.0.1 = $(read)
    begemotSnmpdCommunityString.0.2 = $(write)

  Now it is possible to define additional community strings using different
  indexes:

    begemotSnmpdCommunityString.0.3 = "SomeString1"
    begemotSnmpdCommunityPermission.0.3 = 1
    begemotSnmpdCommunityString.0.4 = "SomeString2"
    begemotSnmpdCommunityPermission.0.4 = 2
    begemotSnmpdCommunityString.0.5 = "SomeString3"
    begemotSnmpdCommunityString.0.6 = "SomeString4"

  New attribute begemotSnmpdCommunityPermission can be used to specify access
  rights: 1 means "read-only" access, 2 means "read-write" access. If
  attribute is not specified for some index this means "read-only" rights.

  Community strings must be unique, i.e. must not be the same for different
  indexes.

  Obtained from: Yandex LLC
  Sponsored by: Yandex LLC
  Differential Revision: https://reviews.freebsd.org/D13785

MFC r328171:
  Rename "index" variable to "idx" since gcc complains that it shadows
  index(3) function declaration.

6 years agoMFC of 328444.
mckusick [Fri, 2 Feb 2018 00:52:29 +0000 (00:52 +0000)]
MFC of 328444.

Eliminate "fsync: giving up on dirty" messages.

6 years agoMFC small part of r325794 to fix the build.
mav [Thu, 1 Feb 2018 21:34:50 +0000 (21:34 +0000)]
MFC small part of r325794 to fix the build.

6 years agoMFC r327034 (by imp):
mav [Thu, 1 Feb 2018 21:25:56 +0000 (21:25 +0000)]
MFC r327034 (by imp):
Return domain, bus, slot, and function for the transport settings in
PATH_INQ requests for nvme.

6 years agoMFC r326937, r326940 (by imp):
mav [Thu, 1 Feb 2018 21:23:42 +0000 (21:23 +0000)]
MFC r326937, r326940 (by imp):
When we're disabling the nvme device, some drives have a controller
bug that requires 'hands off' for a period of time (2.3s) before we
check the RDY bit. Sicne this is a very odd quirk for a very limited
selection of drives, do this as a quirk. This prevented a successful
reset of the card when the card wedged.

Also, make sure that we comply with the advice from section 3.1.5 of
the 1.3 spec says that transitioning CC.EN from 0 to 1 when CSTS.RDY
is 1 or transitioning CC.EN from 1 to 0 when CSTS.RDY is 0 "has
undefined results". Short circuit when EN == RDY == desired state.

Finally, fail the reset if the disable fails. This will lead to a
failed device, which is what we want. (note: nda device needs
work for coping with a failed device).

6 years agoMFC r324978: Report only the valid slots in the firmware log page.
mav [Thu, 1 Feb 2018 21:14:54 +0000 (21:14 +0000)]
MFC r324978: Report only the valid slots in the firmware log page.

Printing the entire log page is causing confusion over available
slots. Report only those slots that are valid. In the case where the
firmware download isn't supported, assume that only the first slot is
valid (I have no hardware to test this assumption though)

6 years agoMFC r324977 (by imp):
mav [Thu, 1 Feb 2018 21:14:21 +0000 (21:14 +0000)]
MFC r324977 (by imp):
Add nvme_controller_data argument to all print functions.

It's desirable to access controler data to inform printing log pages
(such as limiting the printing to valid ranges).

6 years agoMFC r324630 (by imp): Update comment to reflect actual default timeout.
mav [Thu, 1 Feb 2018 21:12:59 +0000 (21:12 +0000)]
MFC r324630 (by imp):  Update comment to reflect actual default timeout.

6 years agoMFC r323625 (by imp): Allow multiple TRIMs to be done for nda
mav [Thu, 1 Feb 2018 21:12:09 +0000 (21:12 +0000)]
MFC r323625 (by imp):  Allow multiple TRIMs to be done for nda

Don't call cam_iosched_trim_done or cam_iosched_submit_trim for nda
since its hardware can handle almost an arbitrary number of TRIMs and
we don't have to be careful to only ever do one.

6 years agoMFC r322999 (by imp): Fix NVMe's use of XPT_GDEV_TYPE
mav [Thu, 1 Feb 2018 21:11:17 +0000 (21:11 +0000)]
MFC r322999 (by imp):  Fix NVMe's use of XPT_GDEV_TYPE

This patch changes the way XPT_GDEV_TYPE works for NVMe. The current
ccb_getdev structure includes pointers to the NVMe Identify Controller
and Namespace structures, but these are kernel virtual addresses which
are not accessible from user space.

As an alternative, the patch changes the pointers into padding in
ccb_getdev and adds two new types to ccb_dev_advinfo to retrieve the
Identify Controller (CDAI_TYPE_NVME_CNTRL) and Namespace
(CDAI_TYPE_NVME_NS) data structures.

6 years agoMFC r322992 (by imp): Print the controller's ID in identify.
mav [Thu, 1 Feb 2018 21:06:28 +0000 (21:06 +0000)]
MFC r322992 (by imp): Print the controller's ID in identify.

6 years agoMFC r320522 (by imp):
mav [Thu, 1 Feb 2018 21:04:10 +0000 (21:04 +0000)]
MFC r320522 (by imp):
Fix sign of resid and add a mostly useless cast to cope with signed vs
unsigned check warnings from traditional unix code construsts bogusly
flagged as potentially unsafe.

6 years agoMFC r320483 (by imp): Improve wdc error log pulling.
mav [Thu, 1 Feb 2018 19:48:05 +0000 (19:48 +0000)]
MFC r320483 (by imp): Improve wdc error log pulling.

After review by the WDC engineers, improve how we pull down the
so-called 'e6' logs. The 'c6' logs are obsolete and support for them
has been removed because FreeBSD needed to pull them in chunks, which
is incompatible with the 0xc6 opcode implementation. Rather than leave
the code in place that produces bad log pulls, remove it.

6 years agoMFC r320425 (by imp):
mav [Thu, 1 Feb 2018 19:47:16 +0000 (19:47 +0000)]
MFC r320425 (by imp):
Report some aspects of namespaces and namespace support in identify
command.

6 years agoMFC r320423 (by imp):
mav [Thu, 1 Feb 2018 19:46:41 +0000 (19:46 +0000)]
MFC r320423 (by imp):
Move 128-bit integer routines to util.c so they can be used by more
than just the log page code.

6 years agoMFC r320412 (by imp): Namespace is 32-bits, don't cast it to 16 here
mav [Thu, 1 Feb 2018 19:46:08 +0000 (19:46 +0000)]
MFC r320412 (by imp): Namespace is 32-bits, don't cast it to 16 here

6 years agoMFC r316105 (by ngie): Don't use K&R style prototypes; ANSIfy them
mav [Thu, 1 Feb 2018 19:45:28 +0000 (19:45 +0000)]
MFC r316105 (by ngie): Don't use K&R style prototypes; ANSIfy them

This fixes several -Wold-style-definition warnings.

6 years agoMFC r314230 (by imp):
mav [Thu, 1 Feb 2018 19:44:24 +0000 (19:44 +0000)]
MFC r314230 (by imp):
Make nvmecontrol logpage -p help list known pages.

Make -p help and -v help list all the pages we know about.
Add -v to usage.
Update the man page.

6 years agoMFC r314229 (by imp):
mav [Thu, 1 Feb 2018 19:43:51 +0000 (19:43 +0000)]
MFC r314229 (by imp):
Exit with usage if argv[1] is NULL in dispatch. This fixes core dumps
when a command has subcommands, but the user doesn't give the
parameters on the command line.

6 years agoMFC r314228 (by imp): Fix typos in output.
mav [Thu, 1 Feb 2018 19:43:18 +0000 (19:43 +0000)]
MFC r314228 (by imp): Fix typos in output.

6 years agoMFC r313259 (by imp):
mav [Thu, 1 Feb 2018 19:41:46 +0000 (19:41 +0000)]
MFC r313259 (by imp):
Use ssize_t instead of uint32_t to prevent warnings about a comparison
with different signs. Due to the promotion rules, this would only
happen on 32-bit platforms.

6 years agoMFC r313258 (by imp):
mav [Thu, 1 Feb 2018 19:40:51 +0000 (19:40 +0000)]
MFC r313258 (by imp):
Add the ability to dump log pages directly in binary to stdout.
Update man page to include this flag, and an example of dumping a
vendor-specific page while I'm here.

6 years agoMFC r313257 (by imp):
mav [Thu, 1 Feb 2018 19:39:29 +0000 (19:39 +0000)]
MFC r313257 (by imp):
Add some descriptions to the man page for the supported log pages as
well as the new wdc commands. Make wdc be an alias for hgst when
specifying the vendor to use to interpret the page.

6 years agoMFC r313252 (by imp):
mav [Thu, 1 Feb 2018 19:39:00 +0000 (19:39 +0000)]
MFC r313252 (by imp):
Fix off by one error that truncated the serial number for filenames.

6 years agoMFC r313251 (by imp):
mav [Thu, 1 Feb 2018 19:38:29 +0000 (19:38 +0000)]
MFC r313251 (by imp):
Fix a typo in usage string for unimplemented command.

6 years agoMFC r313191 (by imp):
mav [Thu, 1 Feb 2018 19:37:50 +0000 (19:37 +0000)]
MFC r313191 (by imp):
Implement 5 wdc-specific nvme control options for their HGST drives:
        wdc cap-diag            Capture diagnostic data from drive
        wdc drive-log           Capture drive history data from drive
        wdc get-crash-dump      Retrieve firmware crash dump from drive

6 years agoMFC r313190 (by imp):
mav [Thu, 1 Feb 2018 19:37:18 +0000 (19:37 +0000)]
MFC r313190 (by imp):
Move the usage and command name lookup into functions.

6 years agoMFC r313188 (by imp):
mav [Thu, 1 Feb 2018 19:36:42 +0000 (19:36 +0000)]
MFC r313188 (by imp):
Put the arguments to aligned_alloc in the right order.

6 years agoMFC r313111 (by imp):
mav [Thu, 1 Feb 2018 19:35:34 +0000 (19:35 +0000)]
MFC r313111 (by imp):
Use aligned buffer for the firmware data. Otherwise, when loading a
MAXPHYS bytes of data, the I/O would require MAXPHYS + PAGE_SIZE worth
of pages to do the I/O and we'd hit an assertion in
vm_fault_quick_hold_pages unless MAXPHYS was larger than 1M +
PAGE_SIZE.

6 years agoMFC r309777 (by imp):
mav [Thu, 1 Feb 2018 19:33:51 +0000 (19:33 +0000)]
MFC r309777 (by imp):
Implement Intel's log page 0xc1 (Read Command Latency Log) and page
0xc1 (Write Command Latency Log).

6 years agoMFC r309684 (by imp): Fix Typo
mav [Thu, 1 Feb 2018 19:33:17 +0000 (19:33 +0000)]
MFC r309684 (by imp): Fix Typo

6 years agoMFC r309413 (by imp):
mav [Thu, 1 Feb 2018 19:32:45 +0000 (19:32 +0000)]
MFC r309413 (by imp):
Flag the vendor specific pages as such. This allows different decoding
for the same page number as different vendors encode vendor specific
pages differently.

6 years agoMFC r308869 (by imp):
mav [Thu, 1 Feb 2018 19:31:39 +0000 (19:31 +0000)]
MFC r308869 (by imp):
i386 turns out to not have __uint128_t. So confusingly use 64-bit math
instead. Since we're little endian, we can get away with it. Also,
since the counters in quesitons would require billions of iops for
tens of billions of seconds to overflow, and since such data rates are
unlikely for people using i386 for a while, that's OK. The fastest
cards today can't do even a million IOPs.

6 years agoMFC r308856 (by imp):
mav [Thu, 1 Feb 2018 19:30:37 +0000 (19:30 +0000)]
MFC r308856 (by imp):
Decode the Intel-specific Additional SMART data page (0xca) and print
it in human readable form. Include a pointer to the public spec that
was followed to implement this in the code. Samsung also implements
page 0xca on some of their drives, but the format is slighly
different, so the code skips printing zero keys. Samsung's log page
has additional, unknown data after the end of Intel defined data which
isn't displayed.

6 years agoMFC r308848 (by imp):
mav [Thu, 1 Feb 2018 19:30:02 +0000 (19:30 +0000)]
MFC r308848 (by imp):
Remove check for valid log pages. Let the drive tell us which pages
are valid or not. While many pages are reserved in the standard, that
doesn't make them invalid and future versions of the standard may
define then.

6 years agoMFC r303315 (by imp): Remove some extraneous printfs.
mav [Thu, 1 Feb 2018 19:28:00 +0000 (19:28 +0000)]
MFC r303315 (by imp): Remove some extraneous printfs.

6 years agoMFC r303125 (by imp):
mav [Thu, 1 Feb 2018 19:27:10 +0000 (19:27 +0000)]
MFC r303125 (by imp):
Remove some bogus comments and printfs. Also, we can't
cam_periph_releaes_locked() at the end of nvme_probe_start because we
hit an assertion which may be bogus. Instead, leak a periph until we
sort it out. Since these devices don't arrive and depart often, so
this is the lessor of two evils.

6 years agoMFC r324632 (by imp):
mav [Thu, 1 Feb 2018 19:13:19 +0000 (19:13 +0000)]
MFC r324632 (by imp):
Be nicer on the dump stack by allocating only a ccb_nvmeio rather than
a full ccb. This saves a few hundre bytes, which might be important
during a crash dump...

6 years agoMFC r324644 (by imp):
mav [Thu, 1 Feb 2018 19:07:21 +0000 (19:07 +0000)]
MFC r324644 (by imp):
Closer examination shows that nvme and CAM both normally zero-fill
allocations (for req and ccb, which ultimately contain the
nvme_cmd). As such, we can micro-optimize these routines. Add a
comment to this effect, and bzero the ccb used to make the requests
for the nda dump rotuine so it more closely matches a ccb allocated
with xpt_get_ccb().

6 years agoMFC r324634 (by imp):
mav [Thu, 1 Feb 2018 19:06:42 +0000 (19:06 +0000)]
MFC r324634 (by imp):
Use nvme_ctrlr_poll instead of nvme_ctrlr_intx_handler since it is
more general and doesn't try to access registers that may be undefined
when the card is in MSIX mode.

This change, along with r324630, r324631, r324632, makes nda crash
dumps work again. Previously, they only worked on CPU 0 when the stack
garbage was just so.

6 years agoMFC r324633 (by imp):
mav [Thu, 1 Feb 2018 19:05:48 +0000 (19:05 +0000)]
MFC r324633 (by imp):
Create general polling function for the nvme controller. Use it when
we're doing the various pin-based interrupt modes. Adjust
nvme_ctrlr_intx_handler to use nvme_ctrlr_poll.

6 years agoMFC r324631 (by imp):
mav [Thu, 1 Feb 2018 19:04:50 +0000 (19:04 +0000)]
MFC r324631 (by imp):
Explicitly set reserved fields and 'fuse' to 0. This prevents us from
acidentally sending bogus values in these fields, which some drives
may reject with an error or worse (undefined behavior).

This is especially needed for the ndadump routine which allocates the
cmd from stack garbage....

6 years agoMFC r324075 (by imp): Tweak performance of nda completions
mav [Thu, 1 Feb 2018 19:01:06 +0000 (19:01 +0000)]
MFC r324075 (by imp): Tweak performance of nda completions

Use xpt_done_direct in preference to xpt_done when completing a
successful I/O. Continue to use xpt_done when there's an error, or for
completion of the submission of a CCB. This eliminates a context
switch to the cam_doneq thread.

6 years agoMFC r323834 (by imp): Fix queue depth for nda.
mav [Thu, 1 Feb 2018 19:00:05 +0000 (19:00 +0000)]
MFC r323834 (by imp):  Fix queue depth for nda.

1/4 of the number of queues times queue entries is too limiting. It
works up to about 4k IOPS / 3.0GB/s for hardware that can do
4.4k/3.2GB/s with nvd. 3/4 works better, though it highlights issues
in the fairness of nda's choice of TRIM vs READ. That will be fixed
separately.

6 years agoMFC r322998 (by imp):
mav [Thu, 1 Feb 2018 18:59:03 +0000 (18:59 +0000)]
MFC r322998 (by imp):
Fix a few overlooked spots where the coded uses 16-bit NSIDs. Chuck
Tuffli had submitted a more thorough patch that I was unaware of when
I did my work and this brings in the bits I missed from that patch.

6 years agoMFC r322997: Add CAM/NVMe support for CAM_DATA_SG
mav [Thu, 1 Feb 2018 18:57:10 +0000 (18:57 +0000)]
MFC r322997: Add CAM/NVMe support for CAM_DATA_SG

This adds support in pass(4) for data to be described with a
scatter-gather list (sglist) to augment the existing (single) virtual
address.

6 years agoMFC r322995 (by imp):
mav [Thu, 1 Feb 2018 16:53:08 +0000 (16:53 +0000)]
MFC r322995 (by imp):
Add new compile-time option NVME_USE_NVD that sets the default value
of the runtime hw.nvme.use_vnd tunable. We still default to nvd unless
otherwise requested.

6 years agoMFC r322994: Set the max transactions for NVMe drives better.
mav [Thu, 1 Feb 2018 16:52:03 +0000 (16:52 +0000)]
MFC r322994: Set the max transactions for NVMe drives better.

Provided a better estimate for the number of transactions that can be
pending at one time. This will be number of queues * number of
trackers / 4, as suggested by Jim Harris. This gives a better estimate
of the number of transactions that CAM should queue before applying
back pressure. This should be revisted when we have real multi-queue
support in CAM and the upper layers of the I/O stack.

6 years agoMFC r322903 (by imp):
mav [Thu, 1 Feb 2018 16:51:11 +0000 (16:51 +0000)]
MFC r322903 (by imp):
Fill in reserved areas from NVMe spec in the IDENTIFY structure
(struct nvme_controller_data) as defined in the NVM Express
specification, revsion 1.3.

6 years agoMFC r322902 (by imp):
mav [Thu, 1 Feb 2018 16:50:25 +0000 (16:50 +0000)]
MFC r322902 (by imp):
NVME Namespace ID is 32-bits, so widen interface to reflect that.

6 years agoMFC r322901 (by imp): Add feature codes from NVMe 1.3 specification:
mav [Thu, 1 Feb 2018 16:49:28 +0000 (16:49 +0000)]
MFC r322901 (by imp): Add feature codes from NVMe 1.3 specification:

o Automomous Power State Transition
o Host Memory Buffer
o Timestamp
o Keep Alive Timer
o Host Controlled Thermal Management
o Non-Operational Power State Config

Also note that feature codes 0x78-0x7f are reserved for the NVMe
Management Interface.

6 years agoMFC r322874, r322875 (by imp): Sanity check sizes
mav [Thu, 1 Feb 2018 16:48:40 +0000 (16:48 +0000)]
MFC r322874, r322875 (by imp): Sanity check sizes

Add compile time sanity checks to make sure that packed structures are
the proper size, typically as defined in the NVMe standard.

6 years agoMFC r322872 (by imp):
mav [Thu, 1 Feb 2018 16:45:44 +0000 (16:45 +0000)]
MFC r322872 (by imp):
Enable bus mastering on the device before resetting the device. The
card has to do PCIe transactions to complete the reset process, but
can't do them, per the PCIe spec, unless bus mastering is enabled.

6 years agoMFC r322443 (by nwhitehorn):
mav [Thu, 1 Feb 2018 16:45:08 +0000 (16:45 +0000)]
MFC r322443 (by nwhitehorn):
Move NVME controller shutdown from being called as part of module unloading
to being called through the newbus DEVICE_SHUTDOWN() path. This ensures that
the NVME controller gets shut down before the device and bus disappear
and prevents data corruption on shutdown on at least Samsung EVO 960 SSDs.

PR: kern/211852

6 years agoMFC r322257 (by imp): Use the correct queue depth for nda devices.
mav [Thu, 1 Feb 2018 16:44:19 +0000 (16:44 +0000)]
MFC r322257 (by imp): Use the correct queue depth for nda devices.