]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
2 years agosctp: improve consistency, no functional change intended
Michael Tuexen [Fri, 26 Nov 2021 11:53:12 +0000 (12:53 +0100)]
sctp: improve consistency, no functional change intended

(cherry picked from commit 3c1ba6f394d2711beabc961f0bda10e1212b7ca6)

2 years agosctp: add some asserts, no functional changes intended
Michael Tuexen [Fri, 26 Nov 2021 11:19:33 +0000 (12:19 +0100)]
sctp: add some asserts, no functional changes intended

This might help in narrowing down
https://syzkaller.appspot.com/bug?id=fbd79abaec55f5aede63937182f4247006ea883b

(cherry picked from commit 0906362646546843f371bebccb51d5578a99cc7c)

2 years agosctp: improve KASSERT messages
Michael Tuexen [Fri, 8 Oct 2021 09:32:55 +0000 (11:32 +0200)]
sctp: improve KASSERT messages

(cherry picked from commit bd19202c92e3d73e90aedd518f0963797744e50f)

2 years agosctp: don't keep being locked on a stream which is removed
Michael Tuexen [Fri, 1 Oct 2021 22:48:01 +0000 (00:48 +0200)]
sctp: don't keep being locked on a stream which is removed

Reported by: syzbot+f5f551e8a3a0302a4914@syzkaller.appspotmail.com

(cherry picked from commit 3ff3733991ba049959c4fd2e7179ea96241a396e)

2 years agosctp: provide a specific stream scheduler function for FCFS
Michael Tuexen [Wed, 29 Sep 2021 00:08:37 +0000 (02:08 +0200)]
sctp: provide a specific stream scheduler function for FCFS

A KASSERT in the genric routine does not apply and triggers
incorrectly.

Reported by: syzbot+8435af157238c6a11430@syzkaller.appspotmail.com

(cherry picked from commit 28ea9470782d4d01004b801c3ec7d74761fcf611)

2 years agosctp: cleanup and adding KASSERT()s, no functional change
Michael Tuexen [Tue, 28 Sep 2021 18:29:43 +0000 (20:29 +0200)]
sctp: cleanup and adding KASSERT()s, no functional change

(cherry picked from commit fa947a3687b98b387de55a33154fce7d6e3dffa3)

2 years agosctp: fix usage of stream scheduler functions
Michael Tuexen [Tue, 28 Sep 2021 03:25:58 +0000 (05:25 +0200)]
sctp: fix usage of stream scheduler functions

sctp_ss_scheduled() should only be called for streams that are
scheduled. So call sctp_ss_remove_from_stream() before it.
This bug was uncovered by the earlier cleanup.

Reported by: syzbot+bbf739922346659df4b2@syzkaller.appspotmail.com
Reported by: syzbot+0a0857458f4a7b0507c8@syzkaller.appspotmail.com
Reported by: syzbot+a0b62c6107b34a04e54d@syzkaller.appspotmail.com
Reported by: syzbot+0aa0d676429ebcd53299@syzkaller.appspotmail.com
Reported by: syzbot+104cc0c1d3ccf2921c1d@syzkaller.appspotmail.com

(cherry picked from commit 5b53e749a95e7f18475df9f9ce7984a31880a7ee)

2 years agosctp: avoid locking an already locked mutex
Michael Tuexen [Tue, 28 Sep 2021 03:14:56 +0000 (05:14 +0200)]
sctp: avoid locking an already locked mutex

Reported by: syzbot+f048680690f2e8d7ddad@syzkaller.appspotmail.com
Reported by: syzbot+0725c712ba89d123c2e9@syzkaller.appspotmail.com

(cherry picked from commit 171633765c4367dc233a4bf0e5926cb7c4decfc1)

2 years agosctp: Cleanup stream schedulers.
Michael Tuexen [Thu, 23 Sep 2021 12:16:56 +0000 (14:16 +0200)]
sctp: Cleanup stream schedulers.

No functional change intended.

(cherry picked from commit 414499b3f911812d49a8c9af05102c0dc37ff878)

2 years agosctp: Simplify stream scheduler usage
Michael Tuexen [Tue, 21 Sep 2021 15:13:57 +0000 (17:13 +0200)]
sctp: Simplify stream scheduler usage

Callers are getting the stcb send lock, so just KASSERT that.
No need to signal this when calling stream scheduler functions.
No functional change intended.

(cherry picked from commit 762ae0ec8d83ed0e3c084e19174b4bd809a7ef2d)

2 years agosctp: improve consistency when calling stream scheduler
Michael Tuexen [Mon, 20 Sep 2021 22:54:13 +0000 (00:54 +0200)]
sctp: improve consistency when calling stream scheduler

Hold always the stcb send lock when calling sctp_ss_init() and
sctp_ss_remove_from_stream().

(cherry picked from commit 0b79a76f848768068d409edcb36f2a58cdd17e61)

2 years agosctp: use a valid outstream when adding it to the scheduler
Michael Tuexen [Mon, 20 Sep 2021 13:52:10 +0000 (15:52 +0200)]
sctp: use a valid outstream when adding it to the scheduler

Without holding the stcb send lock, the outstreams might get
reallocated if the number of streams are increased.

Reported by: syzbot+4a5431d7caa666f2c19c@syzkaller.appspotmail.com
Reported by: syzbot+aa2e3b013a48870e193d@syzkaller.appspotmail.com
Reported by: syzbot+e4368c3bde07cd2fb29f@syzkaller.appspotmail.com
Reported by: syzbot+fe2f110e34811ea91690@syzkaller.appspotmail.com
Reported by: syzbot+ed6e8de942351d0309f4@syzkaller.appspotmail.com

(cherry picked from commit 34b1efcea19dd4324eecd19d2de313d039fd9656)

2 years agosctp: fix FCFS stream scheduler
Michael Tuexen [Sun, 19 Sep 2021 09:56:26 +0000 (11:56 +0200)]
sctp: fix FCFS stream scheduler

Reported by: syzbot+c6793f0f0ce698bce230@syzkaller.appspotmail.com

(cherry picked from commit e19d93b19dce276bdf178bb6a449728238d1c6f8)

2 years agosctp: cleanup, no functional change intended
Michael Tuexen [Wed, 15 Sep 2021 08:18:11 +0000 (10:18 +0200)]
sctp: cleanup, no functional change intended

(cherry picked from commit 454216468583481746845a1c8a45a8c18898ee72)

2 years agosctp: avoid LOR
Michael Tuexen [Sun, 12 Sep 2021 19:11:14 +0000 (21:11 +0200)]
sctp: avoid LOR

Don't lock the inp-info lock while holding an stcb lock.

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

(cherry picked from commit 29545986bdf6c949671e61fc46ee3f2440b1535b)

2 years agosctp: minor cleanup, no functional change
Michael Tuexen [Sun, 12 Sep 2021 17:21:15 +0000 (19:21 +0200)]
sctp: minor cleanup, no functional change

(cherry picked from commit 4181fa2a209e0709939ac2f9fb86884522855600)

2 years agosctp: Tighten up locking around sctp_aloc_assoc()
Mark Johnston [Sat, 11 Sep 2021 14:15:21 +0000 (10:15 -0400)]
sctp: Tighten up locking around sctp_aloc_assoc()

All callers of sctp_aloc_assoc() mark the PCB as connected after a
successful call (for one-to-one-style sockets).  In all cases this is
done without the PCB lock, so the PCB's flags can be corrupted.  We also
do not atomically check whether a one-to-one-style socket is a listening
socket, which violates various assumptions in solisten_proto().

We need to hold the PCB lock across all of sctp_aloc_assoc() to fix
this.  In order to do that without introducing lock order reversals, we
have to hold the global info lock as well.

So:
- Convert sctp_aloc_assoc() so that the inp and info locks are
  consistently held.  It returns with the association lock held, as
  before.
- Fix an apparent bug where we failed to remove an association from a
  global hash if sctp_add_remote_addr() fails.
- sctp_select_a_tag() is called when initializing an association, and it
  acquires the global info lock.  To avoid lock recursion, push locking
  into its callers.
- Introduce sctp_aloc_assoc_connected(), which atomically checks for a
  listening socket and sets SCTP_PCB_FLAGS_CONNECTED.

There is still one edge case in sctp_process_cookie_new() where we do
not update PCB/socket state correctly.

Reviewed by: tuexen
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D31908

(cherry picked from commit 2d5c48eccd9f29b9df8020bb1c3a8ffda38df37b)

2 years agosctp: add explicit cast, no functional change intended
Michael Tuexen [Thu, 9 Sep 2021 17:13:47 +0000 (19:13 +0200)]
sctp: add explicit cast, no functional change intended

(cherry picked from commit 3ea2cdd45ec1e057315ccc3aea16a65d62aad337)

2 years agosctp: use appropriate argument when freeing association
Michael Tuexen [Thu, 9 Sep 2021 16:01:35 +0000 (18:01 +0200)]
sctp: use appropriate argument when freeing association

Reported by: syzbot+7fe26e26911344e7211d@syzkaller.appspotmail.com

(cherry picked from commit 0c1a20beb4560eaae69202bc49026ab9e2a677a4)

2 years agosctp: cleanup timewait handling for vtags
Michael Tuexen [Wed, 8 Sep 2021 23:18:58 +0000 (01:18 +0200)]
sctp: cleanup timewait handling for vtags

(cherry picked from commit 58a7bf124cc2b20e069bb89f2fd9ea5c1b7049c2)

2 years agosctp: minor cleanups, no functional change intended
Michael Tuexen [Wed, 8 Sep 2021 13:13:05 +0000 (15:13 +0200)]
sctp: minor cleanups, no functional change intended

(cherry picked from commit aab1d593b2ec2c24a808eed39c39890b066d5fba)

2 years agotcp: make network epoch expectations of LRO explicit
Michael Tuexen [Wed, 25 Aug 2021 15:09:25 +0000 (17:09 +0200)]
tcp: make network epoch expectations of LRO explicit

Reviewed by: gallatin, hselasky
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D31648

(cherry picked from commit dc6ab77d66f892566de926274e6a58a637975510)

2 years agosctp: improve handling of illegal parameters of INIT-ACK chunks
Michael Tuexen [Fri, 20 Aug 2021 12:03:49 +0000 (14:03 +0200)]
sctp: improve handling of illegal parameters of INIT-ACK chunks

(cherry picked from commit a3665770d7d85e990f7703170a27f8e2d3e455b5)

2 years agosctp: improve handling of INIT chunks with invalid parameters
Michael Tuexen [Wed, 18 Aug 2021 22:31:35 +0000 (00:31 +0200)]
sctp: improve handling of INIT chunks with invalid parameters

(cherry picked from commit eba8e643b19cb7acd7c9a79acfab376b3967f20d)

2 years agosctp: remove some set, but unused variables
Michael Tuexen [Mon, 9 Aug 2021 13:58:46 +0000 (15:58 +0200)]
sctp: remove some set, but unused variables

Thanks to pkasting for submitting the patch for the userland stack.

(cherry picked from commit 3808ab732e6a044cc101cf22027a0db2ac4ad58d)

2 years agoipv6: Fix getsockopt() for some IPPROTO_IPV6 level socket options
Michael Tuexen [Mon, 9 Aug 2021 07:23:42 +0000 (09:23 +0200)]
ipv6: Fix getsockopt() for some IPPROTO_IPV6 level socket options

Fix getsockopt() for the IPPROTO_IPV6 level socket options with the
following names: IPV6_HOPOPTS, IPV6_RTHDR, IPV6_RTHDRDSTOPTS,
IPV6_DSTOPTS, and IPV6_NEXTHOP.

Reviewed by: markj
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D31458

(cherry picked from commit a8d54fc903cca354572ddd7a890baefd81baa7e8)

2 years agosctp: improve handling of IPv4 addresses on IPV6 sockets
Michael Tuexen [Sat, 7 Aug 2021 15:27:56 +0000 (17:27 +0200)]
sctp: improve handling of IPv4 addresses on IPV6 sockets

Reported by: syzbot+08fe66e4bfc2777cba95@syzkaller.appspotmail.com

(cherry picked from commit 784692c74019fa69b5298fb1693a97f107c56b4b)

2 years agosctp: improve input validation of mapped addresses in sctp_connectx()
Michael Tuexen [Sat, 7 Aug 2021 13:12:09 +0000 (15:12 +0200)]
sctp: improve input validation of mapped addresses in sctp_connectx()

(cherry picked from commit 112899c6afc5d174445b6ab4738b8eb4de19d835)

2 years agosctp: improve input validation of mapped addresses in send()
Michael Tuexen [Sat, 7 Aug 2021 12:50:40 +0000 (14:50 +0200)]
sctp: improve input validation of mapped addresses in send()
Reported by: syzbot+35528f275f2eea6317cc@syzkaller.appspotmail.com
Reported by: syzbot+ac29916d5f16d241553d@syzkaller.appspotmail.com

(cherry picked from commit b732091a761a04c7a04229f28642d27dc48485d8)

2 years agotcp, udp: improve input validation in handling bind()
Michael Tuexen [Thu, 5 Aug 2021 11:42:30 +0000 (13:42 +0200)]
tcp, udp: improve input validation in handling bind()

Reported by: syzbot+24fcfd8057e9bc339295@syzkaller.appspotmail.com
Reported by: syzbot+6e90ceb5c89285b2655b@syzkaller.appspotmail.com
Reviewed by: markj, rscheff
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D31422

(cherry picked from commit 3f1f6b6ef7f6fea63583a4b6e917b3cc0f0d525e)

2 years agoelfctl: whitespace cleanup
Ed Maste [Tue, 15 Feb 2022 13:45:05 +0000 (08:45 -0500)]
elfctl: whitespace cleanup

Reported by: jrm (in review D34283)

(cherry picked from commit 828e50092ac84f50247fb3f400027fc7510d8141)

2 years agoreadelf: add newer Linux core arm note types
Ed Maste [Wed, 16 Feb 2022 16:00:57 +0000 (11:00 -0500)]
readelf: add newer Linux core arm note types

Sponsored by: The FreeBSD Foundation

(cherry picked from commit 089eb4ead8d22d90100a2ad0923794daee31777d)

2 years agovtfontcvt: update FreeBSD Foundation copyrights
Ed Maste [Fri, 18 Feb 2022 01:04:29 +0000 (20:04 -0500)]
vtfontcvt: update FreeBSD Foundation copyrights

Remove "All Rights Reserved"

(cherry picked from commit 4e1e3ff5718acc110f3cd4e7a6855248f8ced652)

2 years agoCirrus-CI: add a manual amd64-gcc9 build and smoketest job
Ed Maste [Mon, 14 Feb 2022 20:02:08 +0000 (15:02 -0500)]
Cirrus-CI: add a manual amd64-gcc9 build and smoketest job

Allow users to test changes and find GCC-specific issues using Cirrus-CI
against their own GitHub forks.

Reviewed by: lwhsu, jhb
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D34289

(cherry picked from commit 75e44873df2c86b9e15544b496af7040f9f6e0d2)

2 years agoCirrus-CI: use qemu-nox11
Ed Maste [Mon, 14 Feb 2022 20:14:02 +0000 (15:14 -0500)]
Cirrus-CI: use qemu-nox11

We use -nographic for the smoke test and there is no need to pull in all
of the x11 deps.  This saves some time and bandwidth during package
installation.

When I originally added Cirrus-CI support the -nox11 package was not
available.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit e510f97b4814f5ddb8169bf378030a31a99545d9)

2 years agonewvers.sh: allow multiple -V args in one invocation
Ed Maste [Fri, 11 Feb 2022 17:55:46 +0000 (12:55 -0500)]
newvers.sh: allow multiple -V args in one invocation

Reviewed by: imp
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D34253

(cherry picked from commit acfb506b3d008cab2e5e73fe52ec718766a53560)

2 years agoed: Remove options
Warner Losh [Fri, 10 Dec 2021 00:41:39 +0000 (17:41 -0700)]
ed: Remove options

ed(4) was removed some time ago, but these options relevant to only it
weren't GC'd at the time. Remove them.

Sponsored by: Netflix

(cherry picked from commit 21e22be91aa0d77723f761b014a06f80e25e6291)

2 years agoStop single stepping in signal handers on arm64
Andrew Turner [Wed, 26 Jan 2022 14:25:48 +0000 (14:25 +0000)]
Stop single stepping in signal handers on arm64

We should clear the single step flag when entering a signal hander and
set it when returning. This fixes the ptrace__PT_STEP_with_signal test.

While here add support for userspace to set the single step bit as on
x86. This can be used by userspace for self tracing.

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

(cherry picked from commit 31cf95cec738bdb51a652689e2f829addc3b984b)

2 years agoFix the signal code on 32-bit breakpoints on arm64
Andrew Turner [Mon, 7 Feb 2022 11:47:04 +0000 (11:47 +0000)]
Fix the signal code on 32-bit breakpoints on arm64

When debugging 32-bit programs a debugger may insert a instruction that
will raise the undefined instruction trap. The kernel handles these
by raising a SIGTRAP, however the code was incorrect.

Fix this by using the expected TRAP_BRKPT signal code.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit 67dc576bae6e624ae46962ad187e0e31fece6688)

2 years agoSort the names of the arm64 debug registers
Andrew Turner [Wed, 26 Jan 2022 15:43:14 +0000 (15:43 +0000)]
Sort the names of the arm64 debug registers

While here clean up the names for the naming convention of the other
registers in this file.

Reviewed by: kib, mhorne (earlier version)
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D34060

(cherry picked from commit 664640ba6ccd0c14b607e9babd101dc85ac9c28a)

2 years agoAdd the Arm SPE interrupt to acpidump
Andrew Turner [Tue, 1 Feb 2022 11:43:13 +0000 (11:43 +0000)]
Add the Arm SPE interrupt to acpidump

To support the Arm Statistical Profiling Extension (SPE) ACPI 6.3 added
a place to hold the SPE interrupt. Add to acpidump to show when printing
the Arm Generic Interrupt data.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit c363da4ae81b319223ae06adb96c5ecd9260b45e)

2 years agoAdd the Armv8.3-SPE registers
Andrew Turner [Tue, 17 Aug 2021 08:32:39 +0000 (10:32 +0200)]
Add the Armv8.3-SPE registers

(cherry picked from commit 2ad1999722ecf3c1be5c2013af56fa5cb509e073)

2 years agoTeach DTrace about BTI on arm64
Andrew Turner [Wed, 22 Dec 2021 17:26:33 +0000 (17:26 +0000)]
Teach DTrace about BTI on arm64

The Branch Target Identification (BTI) Armv8-A extension adds new
instructions that can be placed where we may indirrectly branch to,
e.g. at the start of a function called via a function pointer. We can't
emulate these in DTrace as the kernel will have raised a different
exception before the DTrace handler has run.

Skip over the BTI instruction if it's used as the first instruction in
a function.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit b5876847acfeae2dd3a655cde8cdf6145aed16d8)

2 years agoHandle functions that use a nop in the arm64 fbt
Andrew Turner [Wed, 13 Jan 2021 11:08:19 +0000 (11:08 +0000)]
Handle functions that use a nop in the arm64 fbt

To trace leaf asm functions we can insert a single nop instruction as
the first instruction in a function and trigger off this.

Reviewed by: gnn
Sponsored by: Innovate UK
Differential Revision: https://reviews.freebsd.org/D28132

(cherry picked from commit 28d945204ea1014d7de6906af8470ed8b3311335)

2 years agoFix undefined behaviour in the USB controllers
Andrew Turner [Wed, 29 Dec 2021 12:10:49 +0000 (12:10 +0000)]
Fix undefined behaviour in the USB controllers

The USB controller drivers assume they can cast a NULL pointer to a
struct and find the address of a member. KUBSan complains about this so
replace with the __offsetof and __containerof macros that use either a
builtin function where available, or the same NULL pointer on older
compilers without the builtin.

Reviewers: hselasky

Subscribers: imp

Reviewed by: hselasky
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D33865

(cherry picked from commit a3cea156801790d0bbbb4cd9bede0ece8742af82)

2 years agorc: improve dependencies for growfs
Edward Tomasz Napierala [Sun, 25 Apr 2021 12:41:36 +0000 (13:41 +0100)]
rc: improve dependencies for growfs

Previously it depended on sysctl, which itself has no dependencies,
so rcorder(8) had a bit too much flexibility when choosing when to run
it.  Make sure it runs just between 'fsck' and 'root'.

Reviewed By: jmg, imp
Sponsored By: EPSRC
Differential Revision: https://reviews.freebsd.org/D29748

(cherry picked from commit b68e6569221ecade8899eaab8e1b088947ef2f8a)

2 years agorc.d/linux: Attempt to mount only if necessary
Mateusz Piotrowski [Tue, 12 Oct 2021 08:40:36 +0000 (10:40 +0200)]
rc.d/linux: Attempt to mount only if necessary

Currently, if the linux service is run twice, mount(8) fails with:

    mount: linprocfs: Device busy
    mount: linsysfs: Device busy
    mount: devfs: Device busy
    mount: fdescfs: Device busy
    mount: tmpfs: Device busy

It is a bit more user-friendly if before running mount(8) the service
checks if there are any file systems left to be mounted. This patch
implements this behavior.

Also, while here, create mount points directories (as suggested by
otis).

Reviewed by: trasz
Approved by: trasz (src)
Differential Revision: https://reviews.freebsd.org/D32463

(cherry picked from commit 5690261858b6bd8f7d09eda2ae74f3def2d69a01)

2 years agogssd: Modify /etc/rc.d/gssd so that it starts after NETWORKING
Rick Macklem [Tue, 15 Feb 2022 22:18:23 +0000 (14:18 -0800)]
gssd: Modify /etc/rc.d/gssd so that it starts after NETWORKING

Arno Tuber reported via email that he needed to restart the gssd daemon
after booting, to get his Kerberized NFS mount to work.

Without this patch, rcorder shows that the gssd starts before NETWORKING
and kdc. The gssd will need NETWORKING to connect to the KDC and, if
the kdc is running on the same system, it does not make sense to start it
before the kdc.  This fixed the problem for Arno.

While here, I also added a "# BEFORE: mountcritremote".
It does not affect ordering at this time, but I felt
it should be added, since the gssd needs to be running
when remote NFS mounts are done.

PR: 261939

(cherry picked from commit 0f5e9425e74b0e0ecf60c293525a307a6e709967)

2 years agobhyve nvme: Fix Identify Namespace, NSID=ffffffff
Chuck Tuffli [Sun, 30 Jan 2022 07:11:14 +0000 (23:11 -0800)]
bhyve nvme: Fix Identify Namespace, NSID=ffffffff

If the NVMe Controller doesn't support Namespace Management, it should
return "Invalid Namespace or Format" when the Host request Identify
Namespace with the global NSID value.

Fixes UNH IOL 16.0 Test 9.1, Case 6

(cherry picked from commit ac678b4aaf1e852aa033906eabee7322d985c810)

2 years agobhyve nvme: Fix Set Features, AEN
Chuck Tuffli [Sun, 30 Jan 2022 07:10:59 +0000 (23:10 -0800)]
bhyve nvme: Fix Set Features, AEN

NVMe Controllers which do not support Endurance Groups must return an
error when the Endurance Group Event Aggregate Log Change Notices bit is
set in Set Features, Asynchronous Event Configuration.

Fixes UNH IOL Test 3.12, Case 8

(cherry picked from commit fa263c532beec68eb3b36f676aa0a072ffbe593f)

2 years agobhyve nvme: Fix reported VWC value
Chuck Tuffli [Sun, 30 Jan 2022 07:10:42 +0000 (23:10 -0800)]
bhyve nvme: Fix reported VWC value

v1.4 and later NVMe Controllers report "Flush all Namespaces" support
differently.

Fixes UNH IOL 16.0 Test 2.6, Case 3

(cherry picked from commit ff5ed0fac420d3441aac436d884d926d91c79b3c)

2 years agobhyve nvme: Fix LBA out-of-range calculation
Chuck Tuffli [Sun, 30 Jan 2022 07:09:57 +0000 (23:09 -0800)]
bhyve nvme: Fix LBA out-of-range calculation

The function which checks for a valid LBA range mistakenly named an
input value as NLB ("Number of Logical Blocks") instead of "number of
blocks". The NVMe specification defines NLB as a zero-based value (i.e.
NLB=0x0 represents 1 block, 0x1 is 2 blocks, etc.), but the passed
parameter is a 1's-based value.

Fix is to rename the variable to avoid future confusion.

While in the neighborhood, also check that the starting LBA is less than
the size of the backing storage to avoid an integer overflow.

(cherry picked from commit 9d8cd04694d47d48cc4003f8322739ba10fa8108)

2 years agobhyve nvme: Add Select support to Get Features
Chuck Tuffli [Sun, 30 Jan 2022 07:09:35 +0000 (23:09 -0800)]
bhyve nvme: Add Select support to Get Features

Implement basic support for the SEL field of Get Features. This returns
information about Namespace Specific features.

Fixes UNH IOL 16.0 Test 1.2, Case 13

(cherry picked from commit 073f2076fea4748b457b15dbd1d6e11b802b76f3)

2 years agobhyve nvme: Update v1.4 Identify Controller data
Chuck Tuffli [Sun, 30 Jan 2022 07:09:10 +0000 (23:09 -0800)]
bhyve nvme: Update v1.4 Identify Controller data

Compliant v1.4 Controllers must report a Controller Type (CNTRLTYPE).
Also, do not advertise secure erase functionality in the Format NVM
Attributes field of the Identify Controller data structure as the
Controller does not implement secure erase.

Fixes UNH ILO Test 1.1, Case 2

(cherry picked from commit 29241c96f75b38f09fb8752a18ac1ae1b864325e)

2 years agobhyve nvme: Add Temperature Threshold support
Chuck Tuffli [Sun, 30 Jan 2022 07:08:47 +0000 (23:08 -0800)]
bhyve nvme: Add Temperature Threshold support

This adds the ability for a guest OS to send Set / Get Feature,
Temperature Threshold commands. The implementation assumes a constant
temperature and will generate an Asynchronous Event Notification if the
specified threshold is above/below this value. Although the
specification allows 9 temperature values, this implementation only
implements the Composite Temperature.

While in the neighborhood, move the clear of the CSTS register in the
reset function after all other cleanup. This avoids a race with the
guest thinking the reset is complete (i.e. CSTS.RDY = 0) before the NVMe
emulation is actually complete with the reset.

Fixes UNH IOL 16.0 Test 1.7, cases 1, 2, and 4.

(cherry picked from commit ea9ee35583a8faec1ec3d2f8df550baefc2b86b5)

2 years agobhyve nvme: Fix Set Features
Chuck Tuffli [Sun, 30 Jan 2022 07:07:44 +0000 (23:07 -0800)]
bhyve nvme: Fix Set Features

Be more conservative and only support the Features mandatory for an I/O
Controller.

Avoids a "hang" in UNH test 1.2.10 associated with Predictable Latency
Mode Configuration and Host Behavior Support features.

(cherry picked from commit 1381a118297c5f304178707219983c4f70cfd2c5)

2 years agobhyve nvme: Remove redundant AER Limit checks
Chuck Tuffli [Sun, 30 Jan 2022 07:07:29 +0000 (23:07 -0800)]
bhyve nvme: Remove redundant AER Limit checks

The NVMe emulation checked if the Asynchronous Event Request Limit
(a.k.a AERL) would be exceeded in pci_nvme_aer_add(), but this function
is only called from nvme_opc_async_event_req() which also checks for
exceeding the AERL.

(cherry picked from commit 45ab4076f36b428595ba1ce200515fda6af58a76)

2 years agobhyve nvme: Add missing Admin opcodes
Chuck Tuffli [Sun, 30 Jan 2022 07:07:04 +0000 (23:07 -0800)]
bhyve nvme: Add missing Admin opcodes

Don't treat unsupported Admin commands as Invalid Opcode. Instead return
the proper Invalid Field in Command.

Fixes UNH IOL test 1.17.2

(cherry picked from commit 785b5da318bf0e523fa00b3c9c6fde94b1156542)

2 years agobhyve nvme: Implement Log Page Offset
Chuck Tuffli [Sun, 30 Jan 2022 07:06:46 +0000 (23:06 -0800)]
bhyve nvme: Implement Log Page Offset

Modify the Get Log Page command to parse the Log Page Offset fields to
support more recent versions of the NVMe specification.

Fixes various tests for UNH Test 1.3.*

(cherry picked from commit b1b2a4d9e87e0eec413781e4580cd14edf74af7f)

2 years agobhyve nvme: Fix Namespace Specific Set Features
Chuck Tuffli [Sun, 30 Jan 2022 07:06:23 +0000 (23:06 -0800)]
bhyve nvme: Fix Namespace Specific Set Features

Return an error if the feature specified in Set Features is Namespace
specific but the Namespace ID uses the Global Namespace tag.

Fixes UNH Test 1.2.7

(cherry picked from commit 62d47feceba8d457f5a28691cfbed5b90ede30b6)

2 years agobhyve nvme: Fix NVM Format completion status
Chuck Tuffli [Sun, 30 Jan 2022 07:05:58 +0000 (23:05 -0800)]
bhyve nvme: Fix NVM Format completion status

The NVM Format command is unique among the Admin commands in that it
needs to finish asynchronously. For this reason, the emulation code
invented a synthetic completion status (NVME_NO_STATUS) to indicate that
the command was still in progress and the command processing loop should
not generate a completion message. The implementation used the value
0xffff for the synthetic value as this set both the Status Code and
Status Code Type fields to reserved values.

Format initialized the completion status to this value and expected
error cases to override it with a status code/type appropriate to the
situation. The macros used to set the NVMe status are careful not to
modify bit 0 (i.e. the phase bit), which with the synthetic completion
status, causes the phase bit to get out of sync. When running tests in a
guest with illegal NVM Format commands, Admin commands would eventually
hang because it appeared there were no completions due to the incorrect
phase bit value.

Fix is to only set NVME_NO_STATUS if the blockif delete command
succeeds. While in the neighborhood, add a missing break statement when
NVM Format is not supported.

(cherry picked from commit cf76cdd4bf05908eb278b825fc6d33bb6557e0c8)

2 years agobhyve nvme: Advertise v1.4 support
Chuck Tuffli [Sun, 30 Jan 2022 07:04:25 +0000 (23:04 -0800)]
bhyve nvme: Advertise v1.4 support

Bump advertised NVMe support from v1.3 to v1.4

(cherry picked from commit 595a12f18bc4cf9b707a4cfc18e9c923ef6036ff)

2 years agobhyve nvme: Inform guests of namespace resize
Chuck Tuffli [Wed, 15 Dec 2021 07:17:55 +0000 (23:17 -0800)]
bhyve nvme: Inform guests of namespace resize

Register a "block resize" callback to be notified of changes to the
backing storage for the Namespace. Use this to generate an Asynchronous
Event Notification, Namespace Attributes Changed when the guest OS
provides an Asynchronous Event Request.

(cherry picked from commit cf3ed8e0cd9505f21f614e8208f7afd9cfa4d621)

2 years agobhyve nvme: Add AEN support to NVMe emulation
Chuck Tuffli [Wed, 15 Dec 2021 07:16:49 +0000 (23:16 -0800)]
bhyve nvme: Add AEN support to NVMe emulation

Add Asynchronous Event Notification infrastructure to the NVMe
emulation.

(cherry picked from commit 9f1fa1a46117a418e7f7fbfb1be437100fad531f)

2 years agobhyve blockif: fix blockif_candelete with Capsicum
Chuck Tuffli [Wed, 1 Dec 2021 05:07:32 +0000 (21:07 -0800)]
bhyve blockif: fix blockif_candelete with Capsicum

NVMe conformance tests for the Format command failed if the
backing-storage for the bhyve device was a file instead of a Zvol. The
tests (and the specification) expect a Format to destroy all previously
written data. The bhyve NVMe emulation implements this by trimming /
deallocating all data from the backing-storage.

The blockif_candelete() function indicated the file did not support
deallocation (i.e. fpathconf(..., _PC_DEALLOC_PRESENT) returned FALSE)
even though the kernel supported file hole punching. This occurs on
builds with Capsicum enabled because blockif did not allow the
fpathconf(2) right.

Fix is to add CAP_FPATHCONF to the cap_rights_init(3) call.

PR: 260081

(cherry picked from commit d8c1d7b6526c7063304cd1e938d12dec137454e2)

2 years agobhyve: fix NVMe MDTS comment
Chuck Tuffli [Thu, 24 Jun 2021 16:54:05 +0000 (09:54 -0700)]
bhyve: fix NVMe MDTS comment

Removes an obsolete comment and adds parenthesis around the macro while
in the area. No functional change.

(cherry picked from commit a11ca79cd9d00b102c7bf8a0b683fd85079a6346)

2 years agoFix handling of errors from dmu_write_uio_dbuf() on FreeBSD
Mark Johnston [Fri, 21 Jan 2022 19:54:05 +0000 (14:54 -0500)]
Fix handling of errors from dmu_write_uio_dbuf() on FreeBSD

FreeBSD's implementation of zfs_uio_fault_move() returns EFAULT when a
page fault occurs while copying data in or out of user buffers.  The VFS
treats such errors specially and will retry the I/O operation (which may
have made some partial progress).

When the FreeBSD and Linux implementations of zfs_write() were merged,
the handling of errors from dmu_write_uio_dbuf() changed such that
EFAULT is not handled as a partial write.  For example, when appending
to a file, the z_size field of the znode is not updated after a partial
write resulting in EFAULT.

Restore the old handling of errors from dmu_write_uio_dbuf() to fix
this.  This should have no impact on Linux, which has special handling
for EFAULT already.

Reviewed-by: Andriy Gapon <avg@FreeBSD.org>
Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Signed-off-by: Mark Johnston <markj@FreeBSD.org>
Closes #12964
(cherry picked from commit 063daa8350d4a78f96d1ee6550910363fd3756fb)

2 years agoAvoid memory allocations in the ARC eviction thread
Mark Johnston [Fri, 21 Jan 2022 18:28:13 +0000 (13:28 -0500)]
Avoid memory allocations in the ARC eviction thread

When the eviction thread goes to shrink an ARC state, it allocates a set
of marker buffers used to hold its place in the state's sublists.

This can be problematic in low memory conditions, since
1) the allocation can be substantial, as we allocate NCPU markers;
2) on at least FreeBSD, page reclamation can block in
   arc_wait_for_eviction()

In particular, in stress tests it's possible to hit a deadlock on
FreeBSD when the number of free pages is very low, wherein the system is
waiting for the page daemon to reclaim memory, the page daemon is
waiting for the ARC eviction thread to finish, and the ARC eviction
thread is blocked waiting for more memory.

Try to reduce the likelihood of such deadlocks by pre-allocating markers
for the eviction thread at ARC initialization time.  When evicting
buffers from an ARC state, check to see if the current thread is the ARC
eviction thread, and use the pre-allocated markers for that purpose
rather than dynamically allocating them.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Reviewed-by: George Amanakis <gamanakis@gmail.com>
Signed-off-by: Mark Johnston <markj@FreeBSD.org>
Closes #12985
(cherry picked from commit 6e2a59181e286a397d260fa9f140b58688d60c58)

2 years agomsdosfs: Fix mounting when the device sector size is >512B
Mark Johnston [Mon, 14 Feb 2022 14:41:32 +0000 (09:41 -0500)]
msdosfs: Fix mounting when the device sector size is >512B

HugeSectors * BytesPerSec should be computed before converting
HugeSectors to a DEV_BSIZE-based count.

Fixes: ba2c98389b78 ("msdosfs: sanity check sector count from BPB")
Reviewed by: kib
Sponsored by: The FreeBSD Foundation

(cherry picked from commit c7cd607a4e28233ab6679ee330c0a4836414bb0a)

2 years agosleepqueue: Annotate sleepq_max_depth as static
Mark Johnston [Mon, 14 Feb 2022 14:41:07 +0000 (09:41 -0500)]
sleepqueue: Annotate sleepq_max_depth as static

Sponsored by: The FreeBSD Foundation

(cherry picked from commit 852ff943b9c23d40e36ebe5f82112f7bce4537c9)

2 years agolibctf: Rip out CTFv1 support
Mark Johnston [Thu, 10 Feb 2022 20:32:23 +0000 (15:32 -0500)]
libctf: Rip out CTFv1 support

CTFv1 was obsolete before libctf was imported into FreeBSD, and
ctfconvert/ctfmerge can emit only CTFv2.  Make ctf.h a bit easier to
maintain by ripping v1 support out.  No functional change intended.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit 7db423d69273644d3be2a65a48a67b9e0cfb0147)

2 years agolibctf: Use ctf_type_t instead of struct ctf_type
Mark Johnston [Wed, 9 Feb 2022 14:38:03 +0000 (09:38 -0500)]
libctf: Use ctf_type_t instead of struct ctf_type

For consistency with other CTF toolchain code.  No functional change
intended.

Fixes: 105fd928b0b5 ("libctf: Improve check for duplicate SOU definitions in ctf_add_type()")

(cherry picked from commit 2e4311906d8c8dc7a7c726345268253bca6d4acc)

2 years agoctfconvert: Rip out STABS support
Mark Johnston [Thu, 10 Feb 2022 20:36:19 +0000 (15:36 -0500)]
ctfconvert: Rip out STABS support

It is unused on FreeBSD and complicates some efforts to modify the CTF
format to permit wider type IDs, so remove it.  No functional change
intended.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit 7be9a3b45356747f9fcb6d69a722c1c95f8060bf)

2 years agotcp: Avoid conditionally defined fields in union lro_address
Mark Johnston [Thu, 10 Feb 2022 20:31:26 +0000 (15:31 -0500)]
tcp: Avoid conditionally defined fields in union lro_address

The layout of the structure ends up depending on whether the including
file includes opt_inet.h and opt_inet6.h, so different compilation units
can end up seeing different versions of the structure.  Fix this by
unconditionally defining the address fields.

As a side effect, this eliminates some duplication in the kernel's CTF
type graph.

Reviewed by: rscheff, tuexen
Sponsored by: The FreeBSD Foundation

(cherry picked from commit b4f60fab5d3fdd2ea51c1151fa79b2c541c6b81a)

2 years agolinux: Add additional ptracestop only if the debugger is Linux
Edward Tomasz Napierala [Sat, 30 Oct 2021 08:53:55 +0000 (09:53 +0100)]
linux: Add additional ptracestop only if the debugger is Linux

In 6e66030c4c0, additional ptracestop was added in order
to implement PTRACE_EVENT_EXEC.  Make it only apply to cases
where the debugger is a Linux processes; native FreeBSD
debuggers can trace Linux processes too, but they don't
expect that additonal ptracestop.

Fixes: 6e66030c4c0
Reported By: kib
Reviewed By: kib
Sponsored By: EPSRC
Differential Revision: https://reviews.freebsd.org/D32726

(cherry picked from commit 8bbc0600cc21bbfdc3b8e67199eec4220952b7e3)

2 years agolinux: Make PTRACE_GETREGSET return proper buffer size
Edward Tomasz Napierala [Fri, 29 Oct 2021 14:28:56 +0000 (15:28 +0100)]
linux: Make PTRACE_GETREGSET return proper buffer size

This fixes Chrome warning:

[1022/152319.328632:ERROR:ptracer.cc(476)] Unexpected registers size 0 != 216, 68

Reviewed By: emaste
Sponsored By: EPSRC
Differential Revision: https://reviews.freebsd.org/D32616

(cherry picked from commit f939dccfd770df2f9070cd30aa52105b7afe1bde)

2 years agolinux: Fix ptrace panic with ERESTART
Edward Tomasz Napierala [Fri, 29 Oct 2021 13:21:21 +0000 (14:21 +0100)]
linux: Fix ptrace panic with ERESTART

Translate ERESTART into Linux "internal" errno ERESTARTSYS.
This fixes the erestartsys.gen.test from strace(1).

Reviewed By: kib
Sponsored By: EPSRC
Differential Revision: https://reviews.freebsd.org/D32623

(cherry picked from commit 6547153e4618c3b57e5f76062de006a04ecbd64b)

2 years agolinux: Improve debug for PTRACE_GETEVENTMSG
Edward Tomasz Napierala [Sat, 23 Oct 2021 18:53:12 +0000 (19:53 +0100)]
linux: Improve debug for PTRACE_GETEVENTMSG

No functional changes.

Sponsored By: EPSRC

(cherry picked from commit 2ec26ae402fc2589cb97bb5aa713b6d0ba080c17)

2 years agolinux: implement PTRACE_EVENT_EXEC
Edward Tomasz Napierala [Sat, 23 Oct 2021 18:13:14 +0000 (19:13 +0100)]
linux: implement PTRACE_EVENT_EXEC

This fixes strace(1) from Ubuntu Focal.

Reviewed By: jhb
Sponsored By: EPSRC
Differential Revision: https://reviews.freebsd.org/D32367

(cherry picked from commit 6e66030c4c05331f9b0adf87c31f2f233dd3ae1f)

2 years agolinux: Make PTRACE_GET_SYSCALL_INFO handle EJUSTRETURN
Edward Tomasz Napierala [Sat, 23 Oct 2021 17:56:29 +0000 (18:56 +0100)]
linux: Make PTRACE_GET_SYSCALL_INFO handle EJUSTRETURN

This fixes panic when trying to run strace(8) from Focal.

Reviewed By: kib
Sponsored By: EPSRC
Differential Revision: https://reviews.freebsd.org/D32355

(cherry picked from commit 2558bb8e9166395dce26afcfac91fc692621de7b)

2 years agolinux: Improve debug for PTRACE_GETREGSET
Edward Tomasz Napierala [Fri, 22 Oct 2021 18:58:52 +0000 (19:58 +0100)]
linux: Improve debug for PTRACE_GETREGSET

No functional changes.

Sponsored By: EPSRC

(cherry picked from commit e3a83df1195cc4f48f2908b423b5c80dd9c49a21)

2 years agolinux: Improve debugging for PTRACE_GETREGSET
Edward Tomasz Napierala [Sun, 17 Oct 2021 11:52:39 +0000 (12:52 +0100)]
linux: Improve debugging for PTRACE_GETREGSET

It's triggered by gdb(1).

Sponsored By: EPSRC
Differential Revision: https://reviews.freebsd.org/D32456

(cherry picked from commit a03d4d73e4c7c73447263294df6ebd1791ab01f2)

2 years agolinux: Implement some bits of PTRACE_PEEKUSER
Edward Tomasz Napierala [Sun, 17 Oct 2021 11:20:16 +0000 (12:20 +0100)]
linux: Implement some bits of PTRACE_PEEKUSER

This makes Linux gdb from Bionic a little less broken.

Sponsored By: EPSRC
Differential Revision: https://reviews.freebsd.org/D32455

(cherry picked from commit f9246e14848820664539763b72b6fdef408d20e4)

2 years agolinux: Adjust PTRACE_GET_SYSCALL_INFO buffer size semantics
Edward Tomasz Napierala [Sun, 17 Oct 2021 10:49:42 +0000 (11:49 +0100)]
linux: Adjust PTRACE_GET_SYSCALL_INFO buffer size semantics

The tests/ptrace_syscall_info test from strace(1) complained
about this.

Sponsored By: EPSRC
Differential Revision: https://reviews.freebsd.org/D32368

(cherry picked from commit 75a9d95b4d0a043ac0f3f8d1efc0982156337eac)

2 years agoRemove PT_GET_SC_ARGS_ALL
Konstantin Belousov [Wed, 15 Sep 2021 13:24:09 +0000 (16:24 +0300)]
Remove PT_GET_SC_ARGS_ALL

Reimplement bdf0f24bb16d556a5b by checking for the caller' ABI in
the implementation of PT_GET_SC_ARGS, and copying out everything if
it is Linuxolator.

Also fix a minor information leak: if PT_GET_SC_ARGS_ALL is done on the
thread reused after other process, it allows to read some number of that
thread last syscall arguments. Clear td_sa.args in thread_alloc().

Reviewed by: jhb
Sponsored by: The FreeBSD Foundation
Differential revision: https://reviews.freebsd.org/D31968

(cherry picked from commit f575573ca57716395ad88b962388a55d755cf6a7)

2 years agolinux: implement PTRACE_GET_SYSCALL_INFO
Edward Tomasz Napierala [Sun, 12 Sep 2021 11:31:10 +0000 (11:31 +0000)]
linux: implement PTRACE_GET_SYSCALL_INFO

This is one of the pieces required to make modern (ie Focal)
strace(1) work.

Reviewed By: jhb (earlier version)
Sponsored by: EPSRC
Differential Revision: https://reviews.freebsd.org/D28212

(cherry picked from commit bdf0f24bb16d556a5b1e01cdfc087d08e91ac572)

2 years agolinux: make ptrace(2) return EIO when trying to peek invalid address
Edward Tomasz Napierala [Sat, 24 Apr 2021 10:37:06 +0000 (11:37 +0100)]
linux: make ptrace(2) return EIO when trying to peek invalid address

Previously we've returned the error from native ptrace(2), ENOMEM.
This confused Linux strace(2).

Reviewed By: emaste
Sponsored By: EPSRC
Differential Revision: https://reviews.freebsd.org/D29925

(cherry picked from commit 77651151f3caec7d2440404f8c0f1819757d1d5d)

2 years agolinux: refactor bsd_to_linux_regset() out of linux_ptrace.c
Edward Tomasz Napierala [Fri, 21 May 2021 06:22:25 +0000 (07:22 +0100)]
linux: refactor bsd_to_linux_regset() out of linux_ptrace.c

This will be used for Linux coredump support.

Sponsored By: EPSRC
Differential Revision: https://reviews.freebsd.org/D30365

(cherry picked from commit 95c19e1d65619624db4a7a21afc1685f122a05c1)

2 years agolinux(4): make arch_prctl(2) support GET_CET_STATUS, report unknown codes
Edward Tomasz Napierala [Thu, 6 May 2021 08:33:35 +0000 (09:33 +0100)]
linux(4): make arch_prctl(2) support GET_CET_STATUS, report unknown codes

This is largely a no-op, to make future debugging slightly easier.

Sponsored By: EPSRC
Differential Revision: https://reviews.freebsd.org/D30035

(cherry picked from commit 916f3dba4523d1b2d478538875d45df56b20bcdb)

2 years agolinux(4): fix ptrace(2) to properly handle orig_rax
Edward Tomasz Napierala [Tue, 4 May 2021 13:11:01 +0000 (14:11 +0100)]
linux(4): fix ptrace(2) to properly handle orig_rax

This fixes strace(1) erroneously reporting return values
as "Function not implemented", combined with reporting the binary
ABI as X32.

Very similar code in linux_ptrace_getregs() is left as it is - it's
probably wrong too, but I don't have a way to test it.

Sponsored By: EPSRC
Differential Revision: https://reviews.freebsd.org/D29927

(cherry picked from commit 023bff799098cac28732f2800c967f0248d2eb47)

2 years agopf: fix set_prio after nv conversion
Franco Fichtner [Mon, 14 Feb 2022 19:26:39 +0000 (20:26 +0100)]
pf: fix set_prio after nv conversion

Reviewed by: kp
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D34266

(cherry picked from commit 0143a6bb7f634c5984b34db1834313bdb47e6ccd)

2 years agoBump __FreeBSD_version to 1300526 for LinuxKPI changes.
Bjoern A. Zeeb [Sun, 20 Feb 2022 18:10:45 +0000 (18:10 +0000)]
Bump __FreeBSD_version to 1300526 for LinuxKPI changes.

This successfully builds against drm-fbsd13-kmod-5.4.144.g20220128
so no conflicting changes on the MFC.  Given there are overlaps, bump
__FreeBSD_version so they can be detected and removed as pleases.

2 years agoLinuxKPI: 802.11 simplify beacon checks in rx path
Bjoern A. Zeeb [Thu, 17 Feb 2022 00:58:12 +0000 (00:58 +0000)]
LinuxKPI: 802.11 simplify beacon checks in rx path

In linuxkpi_ieee80211_rx() check if the frame is a beacon once upfront
and use the result for enhanced debugging and further checks.
This was done intially for rx_status->device_timestamp debugging.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit c0cadd99d1e36ffe0994f8b30df2939f1d3d0fee)

2 years agoLinuxKPI: implement dma_sync_single_for_*, apply to (un)map single/sg
Bjoern A. Zeeb [Fri, 1 Oct 2021 10:51:50 +0000 (10:51 +0000)]
LinuxKPI: implement dma_sync_single_for_*, apply to (un)map single/sg

Implement dma_sync_single_for_{cpu,device} translating the Linux
DMA_ flags to BUS_DMASYNC_ combinations.  Make map_single/unmap_single*
functions call the respective sync function.   Apply the same logic to
the scatter-gather list map/unmap functions.

Sponsored by: The FreeBSD Foundation
Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D32255

(cherry picked from commit 95edb10b47fc1a919cd1687aaf16be9e14456c89)

2 years agoLinuxKPI: 802.11: disable ic_headroom for the moment
Bjoern A. Zeeb [Wed, 16 Feb 2022 23:57:27 +0000 (23:57 +0000)]
LinuxKPI: 802.11: disable ic_headroom for the moment

There is a problem with some drivers, such as rtw88, asking for more
headroom than we currently can handle throughout the stack (we have
other legacy wireless driver in the tree with similar problems).
This may trigger an assertion in the TCP syncache where we are checking
for a reply to fit in MHLEN.
While for the moment we still copy data from mbufs to skbs,
we can simply disable the extra headroom request in ic_headroom and
deal with it ourselves (which we already did anyway).
Leave a link to the thread on freebsd-transport detailing more of the
problem so we can find it again and solve it here or there.

(cherry picked from commit 3d09d310d9981dde1d6e51fed6ecf9576480b9f7)

2 years agoLinuxKPI: 802.11 advertise full offload scanning based on hw_scan only
Bjoern A. Zeeb [Thu, 17 Feb 2022 00:15:56 +0000 (00:15 +0000)]
LinuxKPI: 802.11 advertise full offload scanning based on hw_scan only

We disabled hw_scan for drivers not advertising SINGLE_SCAN_ON_ALL_BANDS.
Do not depend on this hw flag to set IEEE80211_FEXT_SCAN_OFFLOAD for
net80211 as otherwise scanning will never work.
Long-term we probably want to re-think how we do/integrate hw_scan
better in net80211.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit cc4e78d51351d6362b0536e326280c1e230648d5)

2 years agoLinuxKPI: 802.11 header updates and add/adjust source dependencies.
Bjoern A. Zeeb [Tue, 15 Feb 2022 23:45:15 +0000 (23:45 +0000)]
LinuxKPI: 802.11 header updates and add/adjust source dependencies.

This update is for more/newer versions of drivers:
- add and properly place more structs, enums, defines needed by drivers.
- correct types of struct fields.
- make various function arguments const.
- move REG_RULE() macro to its own file regulatory.h and
  use macros for calculations.
- add linuxkpi_ieee80211_get_channel() implementation.
- change linuxkpi_ieee80211_ifattach() to return int for error checking.

No intended functional changes for iwlwifi.

Sponsored by: The FreeBSD Foundation (partially)

(cherry picked from commit 2e183d999c6033e876602ddbbc5cb538bb41e4b3)

2 years agoLinuxKPI: skbuff updates
Bjoern A. Zeeb [Wed, 16 Feb 2022 02:10:10 +0000 (02:10 +0000)]
LinuxKPI: skbuff updates

Various updates to skbuff for new/updated drivers and some housekeeping:
- update types and struct members, add new (stub) functions
- improve freeing of frags.
- fix an issue with sleeping during alloc for dev_alloc_skb().
- Adjust a KASSERT for skb_reserve() which apparently can be called
  multiple times if no data was put into the skb yet.
- move the sysctl from linux_8022.c (which may be in a different module)
  to linux_skbuff.c so in case we turn debugging on we do not run into
  unresolved symbols.  Rename the sysctl variable to be less conflicting
  and update debugging macros along with that; also add IMPROVE().
- add DDB support to show an skbuff.
- adjust comments/whitespace.

No functional changes intended for iwlwifi.

Sponsored by: The FreeBSD Foundation (partially)

(cherry picked from commit 6baea3312d92cd7eb25f5b9e0e474132636f62d9)

2 years agoLinuxKPI: 802.11: defer workq allocation until we have a name
Bjoern A. Zeeb [Wed, 16 Feb 2022 03:20:29 +0000 (03:20 +0000)]
LinuxKPI: 802.11: defer workq allocation until we have a name

Turned out all the workq's taskqueues were named "wlanNA" if you had
more then one card in a machine as by the time we called wiphy_name()
the device name was not set yet and we returned the fallback.

Move the alloc_ordered_workqueue() from linuxkpi_ieee80211_alloc_hw()
to linuxkpi_ieee80211_ifattach() at which time the device name has
to be set to give us a unique name.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit 652e22d39562ec396d12860313677599becbc749)

2 years agoLinuxKPI: 802.11 assign an(y) early chandef
Bjoern A. Zeeb [Wed, 16 Feb 2022 03:48:54 +0000 (03:48 +0000)]
LinuxKPI: 802.11 assign an(y) early chandef

The Realtek driver assumes an early chandef to be set.  At the time
of linuxkpi_ieee80211_ifattach() we do not really know one yet so
try to find the first one which is available and set that.
This prevents a NULL-deref panic.

(cherry picked from commit c5b96b3eaede01a5117975af6de3483dc43673a4)