]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
2 years agobhyve.8: Fix mandoc -Tlint issues
Mateusz Piotrowski [Sun, 18 Apr 2021 23:53:06 +0000 (01:53 +0200)]
bhyve.8: Fix mandoc -Tlint issues

While here, keep network backends section consistent with other
sections.

MFC after: 2 weeks

(cherry picked from commit 8d9fefe64334818a27812658bf9efd0371fbc77c)

2 years agobhyve: Document the format for HD audio backends
Mateusz Piotrowski [Sun, 18 Apr 2021 23:50:29 +0000 (01:50 +0200)]
bhyve: Document the format for HD audio backends

- This change is done for consistency with other backend definitions.

MFC after: 2 weeks

(cherry picked from commit 061f37d280976e0f79f823c732fa80825ce48ded)

2 years agobhyve.8: Improve AHCI backends documentation
Mateusz Piotrowski [Sun, 18 Apr 2021 23:44:23 +0000 (01:44 +0200)]
bhyve.8: Improve AHCI backends documentation

- Document the backend format.

MFC after: 2 weeks

(cherry picked from commit d5fcc4b6066e878ed70bce7a52d6aca605befde5)

2 years agobhyve.8: Improve documentation of NVME backend
Mateusz Piotrowski [Sun, 18 Apr 2021 23:16:51 +0000 (01:16 +0200)]
bhyve.8: Improve documentation of NVME backend

- Document the configuration format.
- Document two additional configuration options: eui64 and dsm.

MFC after: 2 weeks

(cherry picked from commit 6eff58acc776d8308863f49b89664997d4642a4e)

2 years agobhyve.8: Improve framebuffer backends description
Mateusz Piotrowski [Sun, 18 Apr 2021 22:59:44 +0000 (00:59 +0200)]
bhyve.8: Improve framebuffer backends description

- Use appropriate mdoc macros
- Document that tcp= is a synonym to rfb= (tcp is used in the examples,
  but never mentioned)
- Clarify the IP address specification

MFC after: 2 weeks

(cherry picked from commit 8b97e97548bdc74cf3b4939a0b21cfdd27d8c11c)

2 years agobhyve.8: Clean up virtio console device backends description
Mateusz Piotrowski [Sun, 18 Apr 2021 22:23:26 +0000 (00:23 +0200)]
bhyve.8: Clean up virtio console device backends description

MFC after: 2 weeks

(cherry picked from commit 3f4c771f64e816750de08ab6fd7e7bf29398f5fb)

2 years agobhyve.8: Clean up TTY, boot ROM, and pass-through descriptions
Mateusz Piotrowski [Sun, 18 Apr 2021 22:09:22 +0000 (00:09 +0200)]
bhyve.8: Clean up TTY, boot ROM, and pass-through descriptions

MFC after: 2 weeks

(cherry picked from commit 2fda01a1b7e958e6cfffda512954b8d6c40a064e)

2 years agobhyve.8: Clean up SCSI device backends section
Mateusz Piotrowski [Sun, 18 Apr 2021 21:49:18 +0000 (23:49 +0200)]
bhyve.8: Clean up SCSI device backends section

MFC after: 2 weeks

(cherry picked from commit 7c5829c942822561688c9b8239900773c6d82db4)

2 years agobhyve.8: Clean up block storage device backends description
Mateusz Piotrowski [Sun, 18 Apr 2021 21:39:53 +0000 (23:39 +0200)]
bhyve.8: Clean up block storage device backends description

MFC after: 2 weeks

(cherry picked from commit 5232a35f1ed7b8fa4f378897598438c2056ef60e)

2 years agobhyve.8: Clean up network backends section
Mateusz Piotrowski [Sun, 18 Apr 2021 21:29:30 +0000 (23:29 +0200)]
bhyve.8: Clean up network backends section

- Reformat the format lists, use appropriate mdoc macros for
  readability.
- Add a missing Oxford comma.

MFC after: 2 weeks

(cherry picked from commit 7fb22729816ef6c9e65e5c544047e669edd2f06d)

2 years agobhyve.8: Improve emulation description of the -s flag
Mateusz Piotrowski [Sun, 18 Apr 2021 21:08:39 +0000 (23:08 +0200)]
bhyve.8: Improve emulation description of the -s flag

- Set width of the list to the longest key word for readability.
- Separate descriptions of amd_hostbridge and hostbridge emulations.
  Also, wordsmith their descriptions for consistency with other entries.
- Use Cm instead of Li for command modifiers.
- Do not stylize AMD with Li, there's no need to do it.
- Fix a typo in the definition of ahci-hd ("hard drive" instead of
  "hard-drive").

MFC after: 2 weeks

(cherry picked from commit 7014cb2393594ee4a8389c65d507afacf729c041)

2 years agobhyve.8: Clean up the slot description of -s
Mateusz Piotrowski [Sun, 18 Apr 2021 20:56:19 +0000 (22:56 +0200)]
bhyve.8: Clean up the slot description of -s

Also, remove the macros of the nested list which contained slot,
emulation and conf. This decreases the indention of the -s description.
It was necessary to clean up the slot description.

MFC after: 2 weeks

(cherry picked from commit 234d8c470b44160fe0cbce49b972b3b19f246a89)

2 years agobhyve.8: Clean-up synopsis of -s
Mateusz Piotrowski [Sun, 18 Apr 2021 20:28:47 +0000 (22:28 +0200)]
bhyve.8: Clean-up synopsis of -s

- Document "-s help" separately for readability.
- Use appropriate mdoc macros.

MFC after: 2 weeks

(cherry picked from commit 449f0e48e902ed36ec0de31279eefad9e6200cdc)

2 years agobhyve.8: Fix indention in the signals table
Mateusz Piotrowski [Sun, 18 Apr 2021 20:06:12 +0000 (22:06 +0200)]
bhyve.8: Fix indention in the signals table

MFC after: 2 weeks

(cherry picked from commit 3357e9482fe8a0ee153ec62d4bd8cb96966bbf26)

2 years agobhyve.8: Fix the synopsis of -p
Mateusz Piotrowski [Sun, 18 Apr 2021 20:01:30 +0000 (22:01 +0200)]
bhyve.8: Fix the synopsis of -p

Use appropriate mdoc macros.

MFC after: 2 weeks

(cherry picked from commit 90df54374f1ce1b94c10c34c2a5b06be0353ebae)

2 years agobhyve.8: Improve the description of the -m flag
Mateusz Piotrowski [Sun, 18 Apr 2021 19:56:13 +0000 (21:56 +0200)]
bhyve.8: Improve the description of the -m flag

- Stylize the synopsis with proper mdoc macros
- Do some wordsmithing on the description for consistency.

MFC after: 2 weeks

(cherry picked from commit 7e0cb3df687695212ae20cc90d5f2f48bd42eba7)

2 years agobhyve.8: Improve the description and synopsis of -l
Mateusz Piotrowski [Sun, 18 Apr 2021 19:41:15 +0000 (21:41 +0200)]
bhyve.8: Improve the description and synopsis of -l

- Describe "-l help" separately for readability.
- List all the supported comX devices explicitly
- Use Cm instead of Ar for command modifiers (i.e., literal values a
  user can specify as an argument to the command).
- Explain where to get more information about the possible values of the
  conf argument.

MFC after: 2 weeks

(cherry picked from commit 4c08b978b276f8cfc25f72715e97898f629f7f89)

2 years agobhyve.8: Sort the options in the OPTIONS section
Mateusz Piotrowski [Sun, 18 Apr 2021 18:26:04 +0000 (20:26 +0200)]
bhyve.8: Sort the options in the OPTIONS section

No content change intended. Just moving the option descriptions around
to follow the order suggested by style(9).

MFC after: 2 weeks

(cherry picked from commit ccb1c87a6aa563a927a98a6f9175d95929535b21)

2 years agobhyve: Improve the option description in the usage message
Mateusz Piotrowski [Sun, 18 Apr 2021 18:13:54 +0000 (20:13 +0200)]
bhyve: Improve the option description in the usage message

- Sort options as suggested by style(9)
- Capitalize some words like CPU and HLT
- Add a missing description for the -G flag

MFC after: 2 weeks

(cherry picked from commit b6a572d03f654236b929b91d376ad1a6dfaa2e9a)

2 years agobhyve: Fix synopsis in the usage message
Mateusz Piotrowski [Sun, 18 Apr 2021 18:04:12 +0000 (20:04 +0200)]
bhyve: Fix synopsis in the usage message

In particular:
- Sort short options to align with style(9)
- Add two missing flags: -G and -r
- Drop unnecessary angle brackets for consistency
- Rename the "vm" argument to vmname for consistency with the manual
  page

MFC after: 2 weeks

(cherry picked from commit 03c3e5e40d6497afa33df1d0b43857157c086729)

Note: the -r flag is not present on branch stable/12.

2 years agobhyve.8: Make synopsis more readable
Mateusz Piotrowski [Sun, 18 Apr 2021 17:54:45 +0000 (19:54 +0200)]
bhyve.8: Make synopsis more readable

There is no need to squeeze all the possible options into one synopsis
entry. Let "-l help" and "-s help" be listed separately.

While here, keep -s and its arguments on the same line.

MFC after: 2 weeks

(cherry picked from commit bfe40b692d087cdd5fdeea69e18496ab2a7f67ac)

2 years agoipfw(8): Fix a typo in an error message
Gordon Bergling [Wed, 11 Aug 2021 07:53:01 +0000 (09:53 +0200)]
ipfw(8): Fix a typo in an error message

- s/suport/support/

(cherry picked from commit 809ad8170aa97e570ef5e1e414b4c25e4b58044c)

2 years agoiscontrol(8): Fix a typo in a struct
Gordon Bergling [Wed, 11 Aug 2021 07:55:08 +0000 (09:55 +0200)]
iscontrol(8): Fix a typo in a struct

- s/suport/support/

(cherry picked from commit 1e1fbf3b47d7296896593b1e477141263b0c555f)

2 years agopsm(4): Probe Synaptics touchpad with active multiplexing mode enabled
Vladimir Kondratyev [Wed, 14 Jul 2021 10:30:26 +0000 (13:30 +0300)]
psm(4): Probe Synaptics touchpad with active multiplexing mode enabled

if it is only multiplexed device. Also enable syncbit checks for them.
This fixes touchpad recognition on Panasonic Toughbook CF-MX4 laptop.

Reported by: Tomasz "CeDeROM" CEDRO <tomek_AT_cedro_DOT_info>
PR: 253279
Differential revision: https://reviews.freebsd.org/D28502

(cherry picked from commit f5998d20ed80fdc1cb3ba0c245cae5f179e22fe2)

2 years agoe1000: Fix lem/em UDP rx csum offload
Kevin Bowling [Mon, 9 Aug 2021 21:29:31 +0000 (14:29 -0700)]
e1000: Fix lem/em UDP rx csum offload

Rebase on igb code and unify lem/em implementations.

PR: 257642
Reported by: Nick Reilly <nreilly@blackberry.com>
Reviewed by: karels, emaste
Tested by: Nick Reilly <nreilly@blackberry.com>
Approved by: grehan
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D31449

(cherry picked from commit 015075f383489fcbedbe8aae7c1c64a3d55ca75e)

2 years agogetprogname.3: Add an example
Mateusz Piotrowski [Sat, 17 Apr 2021 21:26:54 +0000 (23:26 +0200)]
getprogname.3: Add an example

It shows the difference between getprogname() and argv[0].

Reviewed by: yuripv
Approved by: yuripv (src)
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D27204

(cherry picked from commit 1ffdcdadf61423dd02ddad82fc4f3f6c39090c8c)

2 years agogrep: Fix an incorrect description of the -C flag
Mateusz Piotrowski [Fri, 5 Feb 2021 18:38:09 +0000 (19:38 +0100)]
grep: Fix an incorrect description of the -C flag

It seems that the number of lines is no longer an optional parameter to
the -C flag. Document it accordingly both in the manual page and the
usage message.

Reviewed by: yuripv
Approved by: yuripv
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D28509

(cherry picked from commit be6b8b7a3a18acb3b044e144d946392fca05e5d0)

2 years agoAdd ElfW() macro for compatibility with Linux
Dimitry Andric [Thu, 5 Aug 2021 18:57:22 +0000 (20:57 +0200)]
Add ElfW() macro for compatibility with Linux

Some Linux software using ELF headers assumes the existence of an
ElfW(type) macro, which concatenates 'Elf', the default ELF word size,
and the given type. This is identical to our __ElfN(x) macro in
<sys/elf_generic.h>. Add the macro for compatibility, with a comment
that we prefer the __ElfN() macro for FreeBSD.

Reviewed by: emaste, kib
Differential Revision: https://reviews.freebsd.org/D31427
MFC after: 1 week

(cherry picked from commit 34e7e4b6a059eee5e4e3e34de5b9d5f0d6e589f9)

2 years agomkimg(1): Correct a typo in the usage output
Gordon Bergling [Mon, 9 Aug 2021 11:53:30 +0000 (13:53 +0200)]
mkimg(1): Correct a typo in the usage output

- s/partion/partition/

(cherry picked from commit 6bddade6114abacacb30ef2c28781f1af331c106)

2 years agoFix panic in IPv6 multicast code.
Andrey V. Elsukov [Thu, 5 Aug 2021 08:51:46 +0000 (11:51 +0300)]
Fix panic in IPv6 multicast code.

Add check that ifp supports IPv6 multicasts in in6_getmulti.
This fixes panic when user application tries to join into multicast
group on an interface that doesn't support IPv6 multicasts, like
IFT_PFLOG interfaces.

PR:             257302
Reviewed by: melifaro
Differential Revision: https://reviews.freebsd.org/D31420

(cherry picked from commit d477a7feed177d0ad5c12bc6e2cce804d427ed38)

2 years agocoretemp(4): Switch to smp_rendezvous_cpus().
Alexander Motin [Fri, 30 Jul 2021 03:16:22 +0000 (23:16 -0400)]
coretemp(4): Switch to smp_rendezvous_cpus().

Use of smp_rendezvous_cpus() instead of sched_bind() allows to not
block indefinitely if target CPU is running some thread with higher
priority, while all we need is single rdmsr/wrmsr instruction call.
I guess it should also be much cheaper than full thread migration.

MFC after: 2 weeks
Sponsored by: iXsystems, Inc.

(cherry picked from commit 74f80bc1af2ffd56ec290f610c80e46f768731a0)

2 years agoipmi(4): Add more watchdog error checks.
Alexander Motin [Fri, 30 Jul 2021 03:39:04 +0000 (23:39 -0400)]
ipmi(4): Add more watchdog error checks.

Add request submission status checks before checking req->ir_compcode,
otherwise it may be zero just because of initialization.

Add checks for req->ir_compcode errors in ipmi_reset_watchdog() and
ipmi_set_watchdog().  In first case explicitly check for 0x80, which
means timer was not previously set, that I found happening after BMC
cold reset.  This change makes watchdog timer to recover instead of
permanently ignoring reset errors after BMC reset or upgraded.

MFC after: 2 weeks
Sponsored by:   iXsystems, Inc.

(cherry picked from commit 9d3b47abbba74830661e90206cc0f692b159c432)

2 years agonanobsd: Correct a typo in a comment
Gordon Bergling [Mon, 9 Aug 2021 11:45:10 +0000 (13:45 +0200)]
nanobsd: Correct a typo in a comment

- s/partion/partition/

(cherry picked from commit 8b9f6d62f75a367459997e5bb27d86d0302aedd2)

2 years agoPrefer MK_SSP=no to SSP_CFLAGS=
Mitchell Horne [Wed, 4 Aug 2021 18:20:50 +0000 (15:20 -0300)]
Prefer MK_SSP=no to SSP_CFLAGS=

It is more idiomatic. CFLAGS is only augmented with $SSP_CFLAGS when
$MK_SSP != "no".

Reviewed by: imp
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D31401

(cherry picked from commit 61ed578ee66648eff206ee5622b66727bfb52e78)

2 years agomk: format some option lists
Mitchell Horne [Wed, 4 Aug 2021 18:17:34 +0000 (15:17 -0300)]
mk: format some option lists

Alphabetize and give each option its own line, ahead of making another
change to these lists. This makes future diffs easier to read.

Reviewed by: imp, emaste
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D31399

(cherry picked from commit bcd2f41f7d222a942fe0a268614b46d3ec3af4c0)

2 years agohwpmc: disable uncore class on Sandy Bridge and newer
Mitchell Horne [Wed, 4 Aug 2021 17:31:36 +0000 (14:31 -0300)]
hwpmc: disable uncore class on Sandy Bridge and newer

It was written for Nehalem and Westmere, with minor but incomplete
updates for Sandy Bridge in 78d763a29b15. The uncore architecture
changed significantly with this generation, bringing new layouts and
locations for some MSRs.

Misprogramming these MSRs in ucp_start_pmc() may panic the system, and
this is trivially reproducible via pmcstat(8) on at least Broadwell and
Haswell. Disable the class on these CPUs until it can be updated more
completely and leave a TODO comment detailing some of the work required.
Note that the nclasses value for Broadwell was already incorrect and
doesn't need changing.

The result is that any uncore events listed by pmcstat -L will no longer
be allocatable, but this is already the case for newer generations of
Intel CPUs.

PR: 253687
Reported by: Zhenlei Huang <zlei.huang@gmail.com>
Reviewed by: kib
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D31389

(cherry picked from commit 4f35e8cba232d9256ab1399b8adfb761988e5eff)

2 years agopf: batch critical section for several counters
Mateusz Guzik [Sat, 24 Jul 2021 07:47:40 +0000 (09:47 +0200)]
pf: batch critical section for several counters

Reviewed by: kp
Sponsored by: Rubicon Communications, LLC ("Netgate")

(cherry picked from commit 87c010e6e364e96e2c1546b3c2bbcbef1dcd422f)

2 years agopf: switch rule counters to pf_counter_u64
Mateusz Guzik [Thu, 22 Jul 2021 14:45:14 +0000 (16:45 +0200)]
pf: switch rule counters to pf_counter_u64

Reviewed by: kp
Sponsored by: Rubicon Communications, LLC ("Netgate")

(cherry picked from commit 02cf67ccf6538b14677672640e405f7f94044dc3)

2 years agopf: switch kif counters to pf_counter_u64
Mateusz Guzik [Fri, 23 Jul 2021 10:29:46 +0000 (12:29 +0200)]
pf: switch kif counters to pf_counter_u64

Reviewed by: kp
Sponsored by: Rubicon Communications, LLC ("Netgate")

(cherry picked from commit d40d4b3ed788b05697541b9ae94b1960ff2cf6f6)

2 years agopf: switch pf_status.fcounters to pf_counter_u64
Mateusz Guzik [Sat, 24 Jul 2021 05:33:52 +0000 (07:33 +0200)]
pf: switch pf_status.fcounters to pf_counter_u64

Reviewed by: kp
Sponsored by: Rubicon Communications, LLC ("Netgate")

(cherry picked from commit fc4c42ce0b5ce87901b327e25f55b4e3ab4c6cf5)

2 years agopf: add hybrid 32- an 64- bit counters
Mateusz Guzik [Thu, 22 Jul 2021 20:47:24 +0000 (22:47 +0200)]
pf: add hybrid 32- an 64- bit counters

Numerous counters got migrated from straight uint64_t to the counter(9)
API. Unfortunately the implementation comes with a significiant
performance hit on some platforms and cannot be easily fixed.

Work around the problem by implementing a pf-specific variant.

Reviewed by: kp
Sponsored by: Rubicon Communications, LLC ("Netgate")

(cherry picked from commit defdcdd5648dc1ea789bc54bb45108fcab546a6b)

2 years agopf: drop redundant 'else' in pf_normalize_*
Mateusz Guzik [Sat, 24 Jul 2021 05:17:27 +0000 (07:17 +0200)]
pf: drop redundant 'else' in pf_normalize_*

Reviewed by: kp
Sponsored by: Rubicon Communications, LLC ("Netgate")

(cherry picked from commit 6f1fb6561236fa933835a9a67bd442053fb509e9)

2 years agopf: consistently malloc rules with M_ZERO
Mateusz Guzik [Fri, 23 Jul 2021 15:01:29 +0000 (17:01 +0200)]
pf: consistently malloc rules with M_ZERO

Reviewed by: kp
Sponsored by: Rubicon Communications, LLC ("Netgate")

(cherry picked from commit 49a7d47235434a300cc57b205e493988fdebf79c)

2 years agopf: hide struct pf_kstatus behind ifdef _KERNEL
Mateusz Guzik [Fri, 23 Jul 2021 17:34:43 +0000 (17:34 +0000)]
pf: hide struct pf_kstatus behind ifdef _KERNEL

Reviewed by:    kp
Sponsored by:   Rubicon Communications, LLC ("Netgate")

(cherry picked from commit d9cc6ea270ea52e860e3cc730876ee4324081586)

2 years agoudp: Fix soroverflow SOCKBUF unlocking
Konstantin Kukushkin [Sun, 1 Aug 2021 14:41:38 +0000 (07:41 -0700)]
udp: Fix soroverflow SOCKBUF unlocking

We hold the SOCKBUF_LOCK so use soroverflow_locked here.
This bug may manifest as a non-killable process stuck in [*so_rcv].

Approved by: scottl
Reviewed by: Roy Marples <roy@marples.name>
Fixes: 7045b1603bdf
MFC after:  10 days
Differential Revision: https://reviews.freebsd.org/D31374

(cherry picked from commit a61c24ddb7d677337d6184ffcee34a6e902d72d7)

2 years agosocket: Implement SO_RERROR
Roy Marples [Wed, 28 Jul 2021 15:46:59 +0000 (08:46 -0700)]
socket: Implement SO_RERROR

SO_RERROR indicates that receive buffer overflows should be handled as
errors. Historically receive buffer overflows have been ignored and
programs could not tell if they missed messages or messages had been
truncated because of overflows. Since programs historically do not
expect to get receive overflow errors, this behavior is not the
default.

This is really really important for programs that use route(4) to keep
in sync with the system. If we loose a message then we need to reload
the full system state, otherwise the behaviour from that point is
undefined and can lead to chasing bogus bug reports.

Reviewed by: philip (network), kbowling (transport), gbe (manpages)
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D26652

(cherry picked from commit 7045b1603bdf054145dd958a4acc17b410fb62a0)

2 years agoDo not expose to scheduler caches of single CPU.
Alexander Motin [Wed, 28 Jul 2021 20:15:43 +0000 (16:15 -0400)]
Do not expose to scheduler caches of single CPU.

Before this change my dual-Xeon(R) Gold 6242R always reported 3 levels
or topology (root, package/L3 and core/L2).  But with SMT disabled
core/L2 matches thread, so additional topology level only causes more
traversal work.  With this change SMT case is reported same as before,
while non-SMT is reported with only 2 much more simple levels.

MFC after: 2 weeks

(cherry picked from commit 5a49f1914178c5275105f2ab0d23a98118cd585f)

2 years agopf: bound DIOCGETSTATES memory use
Kristof Provost [Mon, 2 Aug 2021 07:46:33 +0000 (09:46 +0200)]
pf: bound DIOCGETSTATES memory use

Similar to what we did earlier for DIOCGETSTATESV2 we only allocate
enough memory for a handful of states and copy those out, bit by bit,
rather than allocating memory for all states in one go.

MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")

(cherry picked from commit 600745f1e2260e7ed3c2e6183b24388ff38c916c)

2 years agopf tests: test locally originated connections with route-to
Kristof Provost [Wed, 14 Jul 2021 10:33:37 +0000 (12:33 +0200)]
pf tests: test locally originated connections with route-to

PR: 257106
Submitted by: Mark Cammidge <mark@peralex.com>
MFC after: 3 weeks
Differential Revision: https://reviews.freebsd.org/D31178

(cherry picked from commit f808bb9b7e5ee2243e5a2aaad2275a78cdbe981b)

2 years agopf: locally originating connections with 'route-to' fail
Kristof Provost [Wed, 14 Jul 2021 10:17:03 +0000 (12:17 +0200)]
pf: locally originating connections with 'route-to' fail

Similar to the REPLY_TO shortcut (6d786845cf) we also can't shortcut
ROUTE_TO. If we do we will fail to apply transformations or update the
state, which can lead to premature termination of the connections.

PR: 257106
MFC after: 3 weeks
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D31177

(cherry picked from commit 2c0d115bbc8f8ee3f011a5c4a69bcbf58c4b721f)

2 years agoUPDATING: Document the removal of DIOCGETSTATESNV
Kristof Provost [Wed, 14 Jul 2021 13:51:36 +0000 (15:51 +0200)]
UPDATING: Document the removal of DIOCGETSTATESNV

MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")

(cherry picked from commit 3412900333e659124f61ada6389ef40dd0f3ddd4)

2 years agopf: remove DIOCGETSTATESNV
Kristof Provost [Tue, 6 Jul 2021 11:13:24 +0000 (13:13 +0200)]
pf: remove DIOCGETSTATESNV

While nvlists are very useful in maximising flexibility for future
extensions their performance is simply unacceptably bad for the
getstates feature, where we can easily want to export a million states
or more.

The DIOCGETSTATESNV call has been MFCd, but has not hit a release on any
branch, so we can still remove it everywhere.

Reviewed by: mjg
MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D31099

(cherry picked from commit b69019c14cd89a5e699bc6e69941aec5b1041b1e)

2 years agofortuna: Deduplicate kernel vs user includes
Conrad Meyer [Fri, 1 Mar 2019 22:51:45 +0000 (22:51 +0000)]
fortuna: Deduplicate kernel vs user includes

No functional change.

Reviewed by: markj, markm
Approved by: secteam (delphij), core (brooks)
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D19409
(cherry picked from commit e66ccbeaa3613d022dbc07b9f7403c6bfbe40be6)

2 years agoFortuna: Add failpoints to simulate initial seeding conditions
Conrad Meyer [Fri, 26 Oct 2018 21:03:57 +0000 (21:03 +0000)]
Fortuna: Add failpoints to simulate initial seeding conditions

Set debug.fail_point.random_fortuna_pre_read=return(1) and
debug.fail_point.random_fortuna_seeded=return(1) to return to unseeded
status (sort of).  See the Differential URL for more detail.

The goal is to reproduce e.g. Lev's recent CURRENT report[1] about failing
newfs arc4random(3) usage (fixed in r338542).

No functional change when failpoints are not set.

[1]: https://lists.freebsd.org/pipermail/freebsd-current/2018-September/071067.html

Reported by: lev
Reviewed by: delphij, markm
Approved by: secteam (delphij)
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D17047
(cherry picked from commit 9b8d0fe462b2f3f689cb87fe34bd42c388e23d49)

2 years agofortuna: Drop global lock to zero stack variables
Conrad Meyer [Fri, 26 Oct 2018 21:00:26 +0000 (21:00 +0000)]
fortuna: Drop global lock to zero stack variables

Also drop explicit zeroing of hash context -- hash finish() operation is
expected to do this.

PR: 230877
Suggested by: delphij@
Reviewed by: delphij, markm
Approved by: secteam (delphij)
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D16986
(cherry picked from commit 7be4093a844e80a591221e93d03f3daf6a972be3)

2 years agoFortuna: fix a correctness issue in reseed (fortuna_pre_read)
Conrad Meyer [Fri, 26 Oct 2018 20:55:01 +0000 (20:55 +0000)]
Fortuna: fix a correctness issue in reseed (fortuna_pre_read)

'i' counts the number of pools included in the array 's'.  Passing 'i+1' to
reseed_internal() as the number of blocks in 's' is a bogus overrun of the
initialized portion of 's' -- technically UB.

I found this via code inspection, referencing Â§9.5.2 "Pools" of the Fortuna
chapter, but I would expect Coverity to notice the same issue.
Unfortunately, it doesn't appear to.

Reviewed by: markm
Approved by: secteam (gordon)
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D16985
(cherry picked from commit 9a88479843e2314018f66fd2cdad5ae0200393d0)

2 years agoFortuna: Fix a race to prevent reseed spamming
Conrad Meyer [Sat, 20 Oct 2018 21:09:12 +0000 (21:09 +0000)]
Fortuna: Fix a race to prevent reseed spamming

If multiple threads enter fortuna_pre_read contemporaneously, such as via
read(2) or getrandom(2), they could race to check how long it has been since
the last update due to a TOCTOU problem with 'now'.

Here is an example problematic execution:

Thread A:                       Thread B:
now_A = getsbinuptime();
                                now_B = getsbinuptime();  // now_B > now_A
                                RANDOM_RESEED_LOCK();
                                if (now - fs_lasttime > SBT_1S/10) {
                                        fs_lasttime = now;
                                        ... // reseed
                                }
                                RANDOM_RESEED_UNLOCK();
RANDOM_RESEED_LOCK();
if (now_A - fs_lasttime > SBT_1S/10)  // now_A - fs_lasttime underflows
        fs_lasttime = now_A;
        ... // reseed again, despite less than 100ms elapsing
}
RANDOM_RESEED_UNLOCK();

To resolve the race, simply check the current time after we win the lock
race.

If getsbinuptime is perceived to be expensive, another option might be to
just accept the race and validate that fs_lasttime isn't "in the future."
(It should be within the last ~2^31 seconds out of ~2^32 seconds
representable duration.)

Reviewed by: delphij, markm
Approved by: secteam (delphij)
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D16984
(cherry picked from commit 5528565a76f5caae336d4f13213108dc1fad4ae0)

2 years agoFortuna: trivial static variable cleanup
Conrad Meyer [Sat, 20 Oct 2018 20:15:06 +0000 (20:15 +0000)]
Fortuna: trivial static variable cleanup

Remove unnecessary use of function-local static variable.  32 bytes is
small enough to live on the stack.

Reviewed by: delphij, markm
Approved by: secteam (delphij)
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D16937
(cherry picked from commit 494dda455cd1dad0277a35e292735243f92ec10a)

2 years agoFortuna: Add trivial assert to match FS&K definition
Conrad Meyer [Sat, 20 Oct 2018 20:12:57 +0000 (20:12 +0000)]
Fortuna: Add trivial assert to match FS&K definition

FS&K GenerateBlocks function asserts C (counter) != 0.  This should also
be true in our implementation.

Reviewed by: delphij, markm
Approved by: secteam (delphij)
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D16936
(cherry picked from commit 84880efae7040bb55e6f63166f53158135574e3a)

2 years agoFortuna: Clean up reseeding key material to closer match FS&K
Conrad Meyer [Sat, 20 Oct 2018 19:44:59 +0000 (19:44 +0000)]
Fortuna: Clean up reseeding key material to closer match FS&K

When reseeding, only incorporate actual key material.  Do not include e.g.
the derived key schedules or other AES context.

I don't think the extra material was harmful here, just not beneficial.

Reviewed by: delphij, markm
Approved by: secteam (delphij)
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D16934
(cherry picked from commit 90545403e9d293efb0b843a75ad02361eadaae6d)

2 years agovirtio: enable VTNET_LEGACY_TX when ALTQ is enabled.
Luiz Otavio O Souza [Thu, 26 Oct 2017 02:30:54 +0000 (21:30 -0500)]
virtio: enable VTNET_LEGACY_TX when ALTQ is enabled.

ALTQ only works on network drivers which use if_start (rather than
if_transmit). vtnet uses if_start if built with VTNET_LEGACY_TX. Default
to that the kernel is built with ALTQ enabled, to reduce user surprise.

MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")

(cherry picked from commit 5afe81a7b23afd27289ca40e04a6a764134d6273)

2 years agovmci(4): Shorten interrupt descriptions.
Alexander Motin [Thu, 22 Jul 2021 16:58:10 +0000 (12:58 -0400)]
vmci(4): Shorten interrupt descriptions.

We have no space there for such a long strings.  Also it makes no
sense to set description if there is only one interrupt.

MFC after: 2 weeks

(cherry picked from commit ab38c12b4a488c011ea85252621430ded6e87139)

2 years agoCorrect section reference for examples in RFC3542
Tom Jones [Sun, 1 Aug 2021 12:52:07 +0000 (13:52 +0100)]
Correct section reference for examples in RFC3542

Reviewed by: bz, network
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D26272

(cherry picked from commit 44752e92e134167e9a0ecd277e32608a5595e6d1)

2 years agoloader.conf(5): mention "efi" option for "console" parameter
Li-Wen Hsu [Sat, 31 Jul 2021 22:41:49 +0000 (06:41 +0800)]
loader.conf(5): mention "efi" option for "console" parameter

PR: 213467
Reviewed by: imp
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D31368

(cherry picked from commit de0c7fbe280a1e0946afb111cf7a9811364c4bd6)

2 years agoarm: Bump KSTACK_PAGES default to match i386/amd64
Kevin Bowling [Wed, 21 Jul 2021 01:35:54 +0000 (18:35 -0700)]
arm: Bump KSTACK_PAGES default to match i386/amd64

See 3f6867ef6386 for additional context.

It is also needed for OpenZFS performance and stability.

Reviewed by: ian (arm), imp
Differential Revision: https://reviews.freebsd.org/D31244

(cherry picked from commit b684d812fcb04b2997fd755405a92c36b9f6e30e)

2 years agoigb: clean up igb_txrx comments
Kevin Bowling [Sat, 31 Jul 2021 15:04:25 +0000 (08:04 -0700)]
igb: clean up igb_txrx comments

Reviewed by: grehan
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D31227

(cherry picked from commit ff01d6343f1f0c6550e4072eddda91dabd366d09)

2 years agoe1000: Add missing branch prediction
Kevin Bowling [Tue, 20 Jul 2021 07:21:21 +0000 (00:21 -0700)]
e1000: Add missing branch prediction

I missed this edit from the ixgbe review (D30074)

Reviewed by: gallatin
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D30073

(cherry picked from commit 9fd0cda92d3346e1daa30eb48e185e2077ac0566)

2 years agoe1000: Clean up igb_txrx
Kevin Bowling [Tue, 20 Jul 2021 07:06:31 +0000 (00:06 -0700)]
e1000: Clean up igb_txrx

The intention here is to reduce differences between em, igb, igc, ixgbe.

The main functional change is logical simplification in igb_rx_checksum
and getting interface caps from scctx instead of the ifp.

Reviewed by: gallatin, markj
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D30073

(cherry picked from commit 41f02257146d128cdd4aa2bdcfdab7f9e08a4314)

2 years agorip: Add missing minimum length validation in rip_output()
Mark Johnston [Mon, 26 Jul 2021 20:39:18 +0000 (16:39 -0400)]
rip: Add missing minimum length validation in rip_output()

If the socket is configured such that the sender is expected to supply
the IP header, then we need to verify that it actually did so.

Reported by: syzkaller+KMSAN
Reviewed by: donner
Sponsored by: The FreeBSD Foundation

(cherry picked from commit ba21825202737a8b7e90e1ef669c7fe7e7d50325)

2 years agomrsas(4): Report more correct maximum I/O size.
Alexander Motin [Thu, 1 Jul 2021 19:28:55 +0000 (15:28 -0400)]
mrsas(4): Report more correct maximum I/O size.

Subtract one SGE for the case of misaligned address.  Also take into
account maximum number of sectors reported by firmware, that gives
nicer 256KB limit instead of 276KB calculated from the SGE limit.

While there, remove number of I/O size checks, duplicating what is
already checked by CAM and busdma(9).

MFC after: 1 month
Sponsored by: iXsystems, Inc.

(cherry picked from commit fa3d57c256104649217b5022947de9c1c59a326e)

2 years agovlan: deduplicate bpf_setpcp() and pf_ieee8021q_setpcp()
Kristof Provost [Thu, 22 Jul 2021 08:35:08 +0000 (10:35 +0200)]
vlan: deduplicate bpf_setpcp() and pf_ieee8021q_setpcp()

These two fuctions were identical, so move them into the common
vlan_set_pcp() function, exposed in the if_vlan_var.h header.

Reviewed by: donner
MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D31275

(cherry picked from commit 9ef8cd0b7906371803421aa897056b6fc0710fcb)

2 years agonet tests: basic test case for bpf(4)'s ability to set vlan pcp
Kristof Provost [Thu, 22 Jul 2021 12:50:27 +0000 (14:50 +0200)]
net tests: basic test case for bpf(4)'s ability to set vlan pcp

Use dhclient with its 'vlan-pcp' option to set a VLAN PCP value and
verify that it actually gets set.

MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D31276

(cherry picked from commit 3e87f800f01b6d2cbe49924a01038379889d8b3b)

2 years agotests: basic VLAN test
Kristof Provost [Tue, 15 Oct 2019 04:50:08 +0000 (04:50 +0000)]
tests: basic VLAN test

Set up two jails connected by an epair. Create VLAN interfaces in both
jails and check connectivity.

This is a very basic test, but exposed panics during the network stack
epoch work, so this is worth testing.

(cherry picked from commit fcd69db27dc93796374600938e4fcf5544aa2a06)

2 years agobpf: Add an ioctl to set the VLAN Priority on packets sent by bpf
Luiz Otavio O Souza [Wed, 21 Jul 2021 15:41:22 +0000 (17:41 +0200)]
bpf: Add an ioctl to set the VLAN Priority on packets sent by bpf

This allows the use of VLAN PCP in dhclient, which is required for
certain ISPs (such as Orange.fr).

Reviewed by: bcr (man page)
MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D31263

(cherry picked from commit 1e7fe2fbb9c0bed230d8db94d7444a90ca5ce199)

2 years agobridge tests: test linking bridges with a gif tunnel
Kristof Provost [Wed, 21 Jul 2021 15:32:24 +0000 (17:32 +0200)]
bridge tests: test linking bridges with a gif tunnel

Fairly basic test case for using gif(4)'s ability to tunnel Ethernet
traffic between bridges.

MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")

(cherry picked from commit 4b765ab4cda051a6d9ceb5fb9cac80c7f3b910bf)

2 years agotests: Enable net tests
Kristof Provost [Thu, 13 Feb 2020 14:09:09 +0000 (14:09 +0000)]
tests: Enable net tests

We have a number of tests in the net subdirectory that were not executed. List
the net directory so we run those tests.

(cherry picked from commit 475b483aeef96d8bf47159f06761104d92c58c8c)

2 years agoawk: merge fixes to metamode
Warner Losh [Sat, 31 Jul 2021 17:57:21 +0000 (11:57 -0600)]
awk: merge fixes to metamode

This is a partial MFC of c63c5ab001106/r349062. The whole thing doesn't
apply cleanly, but this bit, at least, is needed to fix metamode on
stable/12 after the changes to awk were merged from head. Rather than
risk breaking other things, I'm just merging the bit I know that's
needed. All build tools need to be in DEPENDOBJ so the dependency order
is correct and they get built with host tools.

Reported by: kp
Sponsored by: Netflix

2 years agosmartpqi: Maintenance commit of Microchip smartpqi
Papani Srikanth [Fri, 30 Jul 2021 23:49:53 +0000 (17:49 -0600)]
smartpqi: Maintenance commit of Microchip smartpqi

Newly added features and bug fixes in latest Microchip SmartPQI driver.

 1) Newly added TMF feature.
 2) Added newly Huawei & Inspur PCI ID's
 3) Fixed smartpqi driver hangs in Z-Pool while running on FreeBSD12.1
 4) Fixed flooding dmesg in kernel while the controller is offline during
    in ioctls.
 5) Avoided unnecessary host memory allocation for rcb sg buffers.
 6) Fixed race conditions while accessing internal rcb structure.
 7) Fixed where Logical volumes exposing two different names to the OS
    it's due to the system memory is overwritten with DMA stale data.
 8) Fixed dynamically unloading a smartpqi driver.
 9) Added device_shutdown callback instead of deprecated shutdown_final
    kernel event in smartpqi driver.
10) Fixed where Os is crashed during physical drive hot removal during
    heavy IO.
11) Fixed OS crash during controller lockup/offline during heavy IO.
12) Fixed coverity issues in smartpqi driver
13) Fixed system crash while creating and deleting logical volume in a
    continuous loop.
14) Fixed where the volume size is not exposing to OS when it expands.
15) Added HC3 pci id's.
16) Fixed compiler issues in 12.2 kernel.

Note: this is a direct commit, submitted by the vendor to support
stable/12

Reviewed by: imp, Murthy Bhat, Scott Benesh
Differential Revision: https://reviews.freebsd.org/D24428

2 years agoawk: remove proctab.c
Warner Losh [Mon, 12 Jul 2021 03:26:08 +0000 (21:26 -0600)]
awk: remove proctab.c

proctab.c is a generated file and never should have been committed to
the tree. This file has been added and removed a couple of times, most
recently added by me in my 2019 updates.

Sponsored by: Netflix

(cherry picked from commit 0c92d88c9180bf25187f01f1d7e419edea9a0fef)

2 years agopf: fix ABI breakage
Kristof Provost [Wed, 28 Jul 2021 09:24:44 +0000 (11:24 +0200)]
pf: fix ABI breakage

The introduction of synproxy support changed the size of struct
pf_status, which in turn broke the userspace ABI.

Revert the relevant change. More work is needed on the synproxy code to
keep and expose the counters, but in the mean time this restores the
ABI.

PR:             257469
MFC after:      3 days
Sponsored by:   Modirum MDPay

(cherry picked from commit da8d8b22e69c72f1d001d55b5eff5acbb0265cfc)

2 years agopf.conf.5: Document new 'match' keyword
Kristof Provost [Tue, 2 Mar 2021 19:34:41 +0000 (20:34 +0100)]
pf.conf.5: Document new 'match' keyword

Reviewed by: bcr
Obtained from: pfSense
MFC after: 2 weeks
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D31117

(cherry picked from commit 0351b9875a3eb5eb4b502a4106b1917ce954e959)

2 years agopf tests: Test the match keyword
Kristof Provost [Tue, 2 Mar 2021 15:57:27 +0000 (16:57 +0100)]
pf tests: Test the match keyword

The new match keyword can currently only assign queues, so we can only
test it with ALTQ.
Set up a basic scenario where we use 'match' to assign ICMP traffic to a
slow queue, and confirm that it's really getting slowed down.

MFC after: 2 weeks
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D31116

(cherry picked from commit d363ebc78cbb50bc334d74fb5bb755af53c69ff0)

2 years agopf: match keyword support
Kristof Provost [Tue, 2 Mar 2021 15:01:04 +0000 (16:01 +0100)]
pf: match keyword support

Support the 'match' keyword.
Note that support is limited to adding queuing information, so without
ALTQ support in the kernel setting match rules is pointless.

For the avoidance of doubt: this is NOT full support for the match
keyword as found in OpenBSD's pf. That could potentially be built on top
of this, but this commit is NOT that.

MFC after: 2 weeks
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D31115

(cherry picked from commit ef950daa35d43dd396958ca28ce9de0514daf873)

2 years agoaltq tests: Basic ALTQ test
Kristof Provost [Sat, 23 Jan 2021 09:37:03 +0000 (10:37 +0100)]
altq tests: Basic ALTQ test

Activate ALTQ_HFSC, crudely check if it really limits bandwidth as we'd expect.

Reviewed by: donner@
Differential Revision: https://reviews.freebsd.org/D28303

(cherry picked from commit 16b3833344ad04194f10b567bc6fae829a52a850)

2 years agoaltq: Fix typo in features sysctl description
Kristof Provost [Tue, 26 Jan 2021 15:02:45 +0000 (16:02 +0100)]
altq: Fix typo in features sysctl description

Reported by: Jose Luis Duran

(cherry picked from commit 35dabb7b9cff601045b623aeca59ccc68930d520)

2 years agoAdd FEATURE sysctls for ALTQ disciplines
Kristof Provost [Sat, 23 Jan 2021 09:36:33 +0000 (10:36 +0100)]
Add FEATURE sysctls for ALTQ disciplines

This will allow userspace to more easily figure out if ALTQ is built
into the kernel and what disciplines are supported.

Reviewed by: donner@
Differential Revision: https://reviews.freebsd.org/D28302

(cherry picked from commit e111d79806fe3652bc85593ca77ee1b4ff85498d)

2 years agonvmecontrol: update copyright on passthru command
Warner Losh [Thu, 6 May 2021 22:05:42 +0000 (16:05 -0600)]
nvmecontrol: update copyright on passthru command

I wrote this code, not Intel, so put my copyright on this. I mistakenly
copied it for the initial commit.

Sponsored by: Netflix

(cherry picked from commit 6d6cca363392943689204f920fa2da9226e42056)

2 years agonvmecontrol: Report status from passthru commands
Warner Losh [Thu, 25 Mar 2021 07:41:53 +0000 (01:41 -0600)]
nvmecontrol: Report status from passthru commands

Report status from dword0 for passthru commands. Many commands report
some status or information here, so reporting it can help know what's
going on.

Sponsored by: Netflix

(cherry picked from commit 510a3da1477a917aa2aaf6b9e3cd6fd50dd13206)

2 years agoAdd SPDX tag.
Warner Losh [Thu, 28 Feb 2019 02:29:48 +0000 (02:29 +0000)]
Add SPDX tag.

(cherry picked from commit e96f6eda1b292c9d91051be0fbe7070a5f83a464)

2 years agonvmecontrol: document power command
Warner Losh [Sat, 10 Jul 2021 16:51:15 +0000 (10:51 -0600)]
nvmecontrol: document power command

The description of the power command is missing. While the synopsis is
present, there's no explanation. Add one.

Reviewed by: mav, chuck
PR: 237866
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D31122

(cherry picked from commit 445b5554bf97254a0ead3d70f801871d62dcfb62)

2 years agonvmecontrol: fix typo (s/Managment/Management/)
Edward Tomasz Napierala [Fri, 7 May 2021 12:12:30 +0000 (13:12 +0100)]
nvmecontrol: fix typo (s/Managment/Management/)

Reported By: pstef

(cherry picked from commit 95a74ab4fb0879da270342bc98719b0e735694f3)

2 years agoFix 32-bit build post 6733401935f83754b4b2744bc3d33ef84b1271e0
Dimitry Andric [Fri, 8 Jan 2021 22:38:21 +0000 (23:38 +0100)]
Fix 32-bit build post 6733401935f83754b4b2744bc3d33ef84b1271e0

The general style in sbin/nvmecontrol apppears to print uint64_t types
using %j, so I'm using that instead of the more general (but admittedly
ugly) PRIu64.

(cherry picked from commit a82f07fc2e2456b0ddc847d611f56a3152a6f940)

2 years agonvme: coherently read status of completion records
Warner Losh [Fri, 2 Jul 2021 22:00:42 +0000 (16:00 -0600)]
nvme: coherently read status of completion records

Coherently read the phase bit of the status completion record. We loop
over the completion record array, looking for all the transactions in
the same phase that have been completed. In doing that, we have to be
careful to read the status field first, and if it indicates a complete
record, we need to read and process that record. Otherwise, the host
might be overtaken by device when reading this completion record,
leading to a mistaken belief that the record is in phase. This leads to
the code using old values and looking at an already completed entry, which
has no current tracker.

To work around this problem, we read the status and make sure it is in
phase, we then re-read the entire completion record guaranteeing it's
complete, valid, and consistent . In addition we resync the dmatag to
reflect changes since the prior loop for the bouncing dma case.

Reviewed by: jrtc27@, chuck@
Found by: jrtc27 (this fix is based in part on her D30995 fix)
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D31002

(cherry picked from commit aa0ab681ae755e01cd69435fab50f6852f248c42)

2 years agonvme: Fix alignment on nvme structures
Warner Losh [Fri, 2 Jul 2021 21:58:19 +0000 (15:58 -0600)]
nvme: Fix alignment on nvme structures

Remove __packed from nvme_command, nvme_completion and
nvme_dsm_trim. Add super-alignment to nvme_completion since it's always
at least that aligned in hardware (and in our existing uses of it
embedded in structures). It generates better code in
nvme_qpair_process_completions on riscv64 because otherwise the ABI
assumes a 4-byte alignment, and the same on all other platforms.

Reviewed by: jrtc27@, mav@, chuck@
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D31001

(cherry picked from commit fea3cf1d6da0acf40bc1d3dadeeea7eeccbc10dd)

2 years agonvme: style nit
Warner Losh [Fri, 2 Jul 2021 21:58:14 +0000 (15:58 -0600)]
nvme: style nit

Put the { on the same line as the struct nvme_foo when we define these
structures. It's FreeBSD standard and these were inconsistent.

Sponsored by: Netflix

(cherry picked from commit 80a75155e1601bddc2c595c06ab6ea916c603071)

2 years agonvme: fix a race between failing the controller and failing requests
Warner Losh [Sat, 29 May 2021 05:01:52 +0000 (23:01 -0600)]
nvme: fix a race between failing the controller and failing requests

Part of the nvme recovery process for errors is to reset the
card. Sometimes, this results in failing the entire controller. When nda
is in use, we free the sim, which will sleep until all the I/O has
completed. However, with only one thread, the request fail task never
runs once the reset thread sleeps here. Create two threads to allow I/O
to fail until it's all processed and the reset task can proceed.

This is a temporary kludge until I can work out questions that arose
during the review, not least is what was the race that queueing to a
failure task solved. The original commit is vague and other error paths
in the same context do a direct failure. I'll investigate that more
completely before committing changing that to a direct failure. mav@
raised this issue during the review, but didn't otherwise object.

Multiple threads, though, solve the problem in the mean time until other
such means can be perfected.

Reviewed by: jhb@
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D30366

(cherry picked from commit f0f47121653e88197d8537572294b90f5aef7f17)

2 years agonvme: use config_intrhook_drain to avoid removable card races
Warner Losh [Thu, 11 Mar 2021 15:42:44 +0000 (08:42 -0700)]
nvme: use config_intrhook_drain to avoid removable card races

nvme drives are configured early in boot. However, a number of the configuration
steps takes which take a while, so we defer those to a config intrhook that runs
before the root filesystem is mounted. At the same time, the PCI hot plug wakes
up and tests the status of the card. It may decide that the card has gone away
and deletes the child. As part of that process nvme_detach is called. If this
call happens after the config_intrhook starts to run, but before it is finished,
there's a race where we can tear down the device's soft state while the
config_intrhook is still using it. Use the new config_intrhook_drain to
disestablish the hook. Either it will be removed w/o running, or the routine
will wait for it to finish. This closes the race and allows safe hotplug at any
time, even very early in boot.

Sponsored by: Netflix, Inc
Reviewed by: jhb, mav
Differential Revision: https://reviews.freebsd.org/D29006

(cherry picked from commit 8423f5d4c127f18e7500bc455bc7b6b1691385ef)

2 years agonvme: Make nvme_ctrlr_hw_reset static
Warner Losh [Mon, 8 Feb 2021 20:28:18 +0000 (13:28 -0700)]
nvme: Make nvme_ctrlr_hw_reset static

nvme_ctrlr_hw_reset is no longer used outside of nvme_ctrlr.c, so
make it static. If we need to change this in the future we can.

(cherry picked from commit dd2516fc078f15633ad5aedaad6de140cb491f80)

2 years agonvme: use NVME_GONE rather than hard-coded 0xffffffff
Warner Losh [Mon, 8 Feb 2021 20:08:48 +0000 (13:08 -0700)]
nvme: use NVME_GONE rather than hard-coded 0xffffffff

Make it clearer that the value 0xfffffff is being used to detect the device is
gone. We use it other places in the driver for other meanings.

(cherry picked from commit 9600aa31aa633bbb9e8a56d91a781d5a7ce2bff6)

2 years agofix big-endian platforms after 6733401935f8
Chuck Tuffli [Fri, 8 Jan 2021 22:36:37 +0000 (14:36 -0800)]
fix big-endian platforms after 6733401935f8

The NVMe byte-swap routines for big-endian platforms used memcpy() to
move the unaligned 64-bit value into a temp register to byte swap it.
Instead of introducing a dependency, manually byte-swap the values in
place.

Point hat: me

(cherry picked from commit e83fdf8bb391579fa422d34663cd8c1f82a00dc0)