]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
6 years agoMFC Loader Fixes 2017q2: r316437,r316577,r316578,r316585,r316590,r316612,
kevans [Sat, 10 Feb 2018 04:56:07 +0000 (04:56 +0000)]
MFC Loader Fixes 2017q2: r316437,r316577,r316578,r316585,r316590,r316612,
r316625,r316628,r316654,r316682,r316704,r316771,r317092,r317097,r317099,
r317652,r317785,r317886,r317887,r318142,r318320,r318356,r318678,r318754,
r318982,r318986,r318987,r318988,r318989,r318990,r318991,r318992,r318993,
r318994,r318999,r319083,r319084,r319085,r320011,r320234,r320288,r320304,
r320467,r320482

r316437: Small cleanup to make i386/loader match efi/loader boot environment
code

r316577: loader: part.c cstyle cleanup

r316578: loader: want mechanism to avoid RA with bcache

r316585: loader: zfs reader should check all labels

r316590: libstand/dosfs: cache FAT32 in 128 Kb blocks to save loader memory

r316612: In r298230 the value of HEAP_MIN was changed from 3MB to 64MB.
Correct a comment.

r316625: Do not use -msoft-float with intention of disabling FP on aarch64

r316628: Silence GCC warning by initializing the local variable.

r316654: loader: r316585 did miss userboot update

r316682: loader: r316585 did miss sparc/ofw

r316704: loader.efi: only fetch zfs pool guid for the actual boot device

r316771: loader: Avoid possible overflow via environment variable

r317092: loader: zfs reader vdev_probe should check for minimum device size

r317097: loader: F_READ/F_WRITE should be checked against masked flag

r317099: loader: uboot disk ioctl should call disk_ioctl

r317652: loader.efi: ResetSystem does not use data with EFI_SUCCESS

r317785: zfsboot: drvsize() may be unusable on some systems

r317886: distinguish NFS versus TFTP boot by rootpath

r317887: loader: network read rework

r318142: libstand: NULL pointer dereference in rarp

r318320: loader: add ip layer code into libstand

r318356: libstand: increase nfs max read size to 16k

r318678: Replacing iterating over rootpath by strsep(3).

r318754: Pass -N directly to ld via -Wl rather than passing it to the
compiler driver.

r318982: Pass a "FREEBSD" user-class in PXE dhcp request

r318986: add a comment on vendor index 19 and 20 to avoid confusion

r318987: Support URI scheme for root-path in netbooting

r318988: Always build tftpfs support along with nfs for pxeboot

r318989: Always issue the pxe request

r318990: Partially revert r314948

r318991: Document recent changes on pxeboot

r318992: Capitalize DHCP

r318993: Use the usual FreeBSD spelling for the DHCP user class

r318994: Catch with the change in the user class

r318999: Update the comments concerning net_parse_rootpath to reflect what
it is now

r319083: Followup on the user-class changes

r319084: Small cleanup in dev_net.c

r319085: use the same option list for dhcp discovery and request

r320011: Add chain loader support for loader

r320234: Make structure padding explicit in EFI_MEMORY_DESCRIPTOR

r320288: Allow Clang's integrated assembler to assemble boot0

r320304: loader.efi: Disable smbios for arm

r320467: loader: chain load relocate data declaration is bad

r320482: As with arm64 mark the EFI PE header as allocated on arm.

PR: 218473

6 years agoMFC Loader Fixes 2017q1: r311458,r312237,r312314,r312374,r312947,r313042,
kevans [Sat, 10 Feb 2018 04:37:44 +0000 (04:37 +0000)]
MFC Loader Fixes 2017q1: r311458,r312237,r312314,r312374,r312947,r313042,
r313047,r313166,r313328,r313332,r313333,r313337,r313348,r313349,r313389,
r313442,r313451,r313575,r313645,r313710,r314114,r314213,r314275,r314945,
r314948,r315008,r315408,r315427,r315645,r315646,r315648,r315653,r315850,
r316064,r316078,r316079,r316100,r316104,r316111,r316112,r316171,r316279,
r316280,r316287,r316311,r316343,r316424,r316436

r311458: Use compiler driver to link BERI boot loaders

r312237: loader.efi: find_currdev() can leak memory

r312314: loader: move device path definitions to include/efidevp.h

r312374: loader: efi devpath api usage should be more aware of NULL pointers

r312947: Remove "-Xassembler -G0" from CFLAGS.

r313042: loader.efi environment related cleanups

r313047: loader: disk/part api needs to use uint64_t offsets

r313166: loader: libefi/env.c warnings in arm build

r313328: loader: Implement disk_ioctl() to support DIOCGSECTORSIZE and
DIOCGMEDIASIZE.

r313332: loader: bcache read ahead block count should take account the large
sectors

r313333: loader: Replace EFI part devices.

r313337: loader: 313329 missed ZFS guard in loader/main.c

r313348: loader: biosdisk fix for 2+TB disks

r313349: loader: disk io should not use alloca()

r313389: efipart is also using the '%S' printf format, add -Wno-format for
it.

r313442: loader: possible NULL pointer dereference in efipart.c

r313451: loader: possible NULL pointer dereference in bcache.c

r313575: makefs: make the buffer functions look exactly like the kernel ones

r313645: loader: implement MEDIA_FILEPATH_DP support in efipart

r313710: loader: cstyle fixes and DIOCGMEDIASIZE should use uint64_t

r314114: Use LDFLAGS with CC instead of _LDFLAGS.

r314213: Remove control+r handling from geliboot's pwgets()

r314275: Remove unused macro from common/drv.c.

r314945: Some style(9) fixes. No functional changes.

r314948: Try to extract the RFC1048 data from PXE.

r315008: r314948 seems to be missing a variable or two that will break

r315408: loader: remove open_disk cache

r315427: loader: biosdisk should report IO error from INT13

r315645: loader: disk_cleanup was left in userboot_disk.c

r315646: loader: pxe.h constants have wrong values

r315648: libstand: verify value provided by nfs.read_size

r315653: loader: verify the value from dhcp.interface-mtu and use snprintf
o set mtu

r315850: The original author abused Nd (one-line description, used by
makewhatis)

r316064: Fix build with path names with 'align' or 'nop' in them.

r316078: gpt*boot: Save a bit more memory when LOADER_NO_GELI_SUPPORT is
specified

r316079: Simply retire the sedification of the boot2.s file.

r316100: Remove -fno-guess-branch-probability and -fno-unit-at-a-time.

r316104: Use `NO_WCAST_ALIGN` instead of spelling it out as -Wno-cast-align
in CFLAGS

r316111: loader: move bios getsecs into time.c

r316112: loader: ls command should display file types properly

r316171: xfsread inlined uses more space, so remove the inline tag.

r316279: loader: efipart should check disk size from partition table

r316280: loader: simplify efi_zfs_probe and avoid double probing for zfs.

r316287: Remove OLD_NFSV2 from loader and libstand

r316311: Add explicit_bzero() to libstand, and switch GELIBoot to using it

r316343: Implement boot-time encryption key passing (keybuf)

r316424: Fix sparc64 build broken by r316343 and r316076

r316436: Restore EFI boot environment functionality broken in r313333

PR: 216940 217298 217935

6 years agoMFC libstand catch-up: r305116,306534,306538,306552,306638
kevans [Sat, 10 Feb 2018 01:52:58 +0000 (01:52 +0000)]
MFC libstand catch-up: r305116,306534,306538,306552,306638

r305116: recvtftp() is broken for large files, report file size
r306534: cd9660_open should check for padding
r306538: cstyle fix of cd9660_open in libstand
r306552: Fix remaining cstyle issues in libstand/cd9660.c
r306638: Fix remaining bugs in libstand/cd9660.c reported by Bruce Evans.

PR: 200500

6 years agoMFC r325795 (by imp):
mav [Sat, 10 Feb 2018 00:39:34 +0000 (00:39 +0000)]
MFC r325795 (by imp):
Belatedly add opt_nvme.h to fix building nvme.ko outside of a kernel
build.

6 years agoMFC r327606: Handle misconfigured/nonexistent pcidev for comconsole instead
kevans [Fri, 9 Feb 2018 17:25:34 +0000 (17:25 +0000)]
MFC r327606: Handle misconfigured/nonexistent pcidev for comconsole instead
of BTX panic.

[This is effectively a direct commit to stable/11 due to path restructuring
in head. Diffs have simply been applied to previous location]

PR: 203319

6 years agoMFC r306325, r306329-r306330, r306333, r306620-r306622, r307544, r307550, r318137...
manu [Fri, 9 Feb 2018 09:15:43 +0000 (09:15 +0000)]
MFC r306325, r306329-r306330, r306333, r306620-r306622, 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.

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 r328611: Try to preallocate receive memory early.
mav [Fri, 9 Feb 2018 03:07:12 +0000 (03:07 +0000)]
MFC r328611: Try to preallocate receive memory early.

We may not have enough contiguous memory later, when NTB connection get
established.  It is quite likely that NTB windows are symmetric and this
allocation remain, but even if not, we will just reallocate it later.

6 years agoMFC r328450: Use bus_dmamem_alloc(9) KPI instead of contigmalloc(9).
mav [Fri, 9 Feb 2018 03:06:45 +0000 (03:06 +0000)]
MFC r328450: Use bus_dmamem_alloc(9) KPI instead of contigmalloc(9).

I suppose it should make this code NUMA-aware with recent NUMA drop-in,
trying to allocate shared memory buffers from domain closer to NT-bridge.

6 years agoMFC r309062: Release laundered vnode pages to the head of the inactive
kevans [Thu, 8 Feb 2018 17:14:56 +0000 (17:14 +0000)]
MFC r309062: Release laundered vnode pages to the head of the inactive
queue.

The swap pager enqueues laundered pages near the head of the inactive queue
to avoid another trip through LRU before reclamation. This change adds
support for this behaviour to the vnode pager and makes use of it in UFS and
ext2fs. Some ioflag handling is consolidated into a common subroutine so
that this support can be easily extended to other filesystems which make use
of the buffer cache. No changes are needed for ZFS since its putpages
routine always undirties the pages before returning, and the laundry
thread requeues the pages appropriately in this case.

6 years agoiw_cxgbe: Manually backport changes related to QP flush. This fixes a
np [Thu, 8 Feb 2018 14:39:07 +0000 (14:39 +0000)]
iw_cxgbe: Manually backport changes related to QP flush.  This fixes a
panic where poll_cq sees an empty RQ while processing an incoming SEND
for a QP that is being taken down.

This is a direct commit to stable/11.

Sponsored by: Chelsio Communications

6 years agoMFC r307322,r307323,r307324,r307326,r307327,r307338,r307879,r307908,r307911,
kevans [Thu, 8 Feb 2018 02:50:47 +0000 (02:50 +0000)]
MFC r307322,r307323,r307324,r307326,r307327,r307338,r307879,r307908,r307911,
r307942,r307950,r307951,r307954,r307955,r308125,r308195,r308476,r308534,
r308535,r308776,r308843,r310236,r310726: Loader fixes, 2016q4

r307322: Remove /boot/boot.conf, deprecated for 16 years

r307323: Remove fetching of pInterp.

r307324: Create a new linker set, Xficl_compile_set which contains a list of
functions to call to register new forth words.

r307326: In UEFI mode expose the SMBIOS anchor base address via kenv

r307327: Update i386 build of loader.efi (but leave it disabled) so that we
at least build it now.

r307338: Create a pcibios-version environment FORTH word.

r307879: Preliminary support for EFI in boot loader.

r307908: Fix the build on both arm64 and when WITHOUT_FORTH is defined.

r307911: Add better comment...

r307942: Really make WITHOUT_FORTH (MK_FORTH==no) work.

r307950: Add it (Makefile.ficl) to the right place

r307951: Fix two backwards tests.

r307954: Back out the move to the loader script from -N.

r307955: LIBSTAND goes last, so put it last here too.

r308125: In loader.efi, instead of exiting directly, try to fallback.

r308195: efinet_dev_print should honor verbose option.

r308476: boot/forth spelling issue in forth word

r308534: The file_loadraw function grew an argument, update install function

r308535: Add support for LOADER_RC setting in the pkgfs manifes

r308776: loader: zfs toplevel vdev must have spa set.

r308843: loader: smbios version check is not correct

r310236: Renumber license clauses to avoid skipping #3

r310726: cdboot: add explict suffix to ambiguous or instruction

PR: 214375

6 years agoMFC r303555,r303556,r303936,r303962,r304317,r304532,r305026,r305107,r305132,
kevans [Thu, 8 Feb 2018 02:44:21 +0000 (02:44 +0000)]
MFC r303555,r303556,r303936,r303962,r304317,r304532,r305026,r305107,r305132,
r305178,r305353,r305814,r306159,r306380,r306504: Loader fixes, 2016q3

r303555: bcache should support reads shorter than sector size

r303556: Improve boot loader quote parsing

r303936: Add kernel environment variables under smbios.system

r303962: Add the missing space between .asciz directive and opening quote
for some lines with #ifdef BTXLDR_VERBOSE/#endif

r304317: boot1.efi Free() should check for NULL to provide consistent
behavior

r304532: Replace sprintf -> snprintf for command_errbuf provisioned from
dynamic content.

r305026: Emulate efi_cons_poll when WaitForKey is not available

r305107: Create a hook 'post-initialize' for people that want to define
something to read in .conf files after all other .conf files for the purpose
of overriding.

r305132: Remove accidentally committed stray comment.

r305178: bd_int13probe() should check extended info if sector info is bad

r305353: Don't use -N to set the OMAGIC with data and text writeable and
data not page aligned.

r305814: ufsread: Do not cast struct direct from void *

r306159: Consistently declare getsecs(void) with proper return type and void
when no arguments are present.

r306380: loader command interpreter should reset command_errmsg

r306504: Fix a cluster of bugs in list EFI environment variables

PR:             204602, 211958, 211958
Relnotes:       yes ("Improve boot loader quote parsing")

6 years agoMFC 319454: Honor the requested crid when running a test.
jhb [Thu, 8 Feb 2018 00:59:56 +0000 (00:59 +0000)]
MFC 319454: Honor the requested crid when running a test.

Otherwise, the kernel is free to choose an aribtrary crypto device
rather than the requested device subverting tests that force the use
of a specific device.

6 years agoMFC r328412: vt: add Ctrl+/ key mapping
emaste [Thu, 8 Feb 2018 00:40:56 +0000 (00:40 +0000)]
MFC r328412: vt: add Ctrl+/ key mapping

This matches Xorg's handling of Ctrl+/ and may be useful as a tmux
escape.

PR: 212197
Submitted by: martin at sugioarto.com
Relnotes: Yes

6 years agoFix rootgen.sh to reflect proper bootloader paths
kevans [Wed, 7 Feb 2018 19:49:07 +0000 (19:49 +0000)]
Fix rootgen.sh to reflect proper bootloader paths

This is a direct commit to stable/11 to use sys/boot instead of stand/. It
will be reverted once the move from sys/boot to stand/ gets an MFC.

6 years agoMFC r326873,r326874,r326875,r326883,r326884,r326885,r326954,r328865
kevans [Wed, 7 Feb 2018 19:45:23 +0000 (19:45 +0000)]
MFC r326873,r326874,r326875,r326883,r326884,r326885,r326954,r328865

r326873: Script that knows how to put boot blocks onto a device.

r326874: Script to generate minimal boot images for each of the 24 supported

r326875: Add missing of=/dev/${dev}s${s} when installing zfsboot.

r326883: For now, make the gpart commands verbose

r326884: Be a little verbose and list the loader files we're putting on

r326885: Use -h -D in preference to -D so that the serial port gets the
interactive console.

r326954: Support more images (but still no geli)

r328865: Flesh out the creation of sparc64 UFS images.

6 years agoMFC r328694:
hselasky [Wed, 7 Feb 2018 18:18:33 +0000 (18:18 +0000)]
MFC r328694:
Make sure the LinuxKPI's internal ERESTARTSYS error code gets translated
into ERESTART for mmap and page fault calls aswell.

Sponsored by: Mellanox Technologies

6 years agoMFC r328436 and r328731:
hselasky [Wed, 7 Feb 2018 18:17:10 +0000 (18:17 +0000)]
MFC r328436 and r328731:
Decouple Linux files from the belonging character device right after open
in the LinuxKPI. This is done by calling finit() just before returning a magic
value of ENXIO in the "linux_dev_fdopen" function.

The Linux file structure should mimic the BSD file structure as much as
possible. This patch decouples the Linux file structure from the belonging
character device right after the "linux_dev_fdopen" function has returned.
This fixes an issue which allows a Linux file handle to exist after a
character device has been destroyed and removed from the directory index
of /dev. Only when the reference count of the BSD file handle reaches zero,
the Linux file handle is destroyed. This fixes use-after-free issues related
to accessing the Linux file structure after the character device has been
destroyed.

While at it add a missing NULL check for non-present file operation.
Calling a NULL pointer will result in a segmentation fault.

Fix some recent regressions after r328436 in the LinuxKPI:

1) The OPW() function macro should have the same return type like the
function it executes.
2) The DEVFS I/O-limit should be enforced for all character device reads
and writes.
3) The character device file handle should be passable, same as for
DEVFS based file handles.

Reviewed by: kib @
Reported by: jbeich @
Sponsored by: Mellanox Technologies

6 years agoRevert r328974, r307387 was not supposed to be part of it.
manu [Wed, 7 Feb 2018 16:45:38 +0000 (16:45 +0000)]
Revert r328974, r307387 was not supposed to be part of it.

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.