]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
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)

2 years agoLinuxKPI: 802.11 scan update
Bjoern A. Zeeb [Wed, 16 Feb 2022 03:00:34 +0000 (03:00 +0000)]
LinuxKPI: 802.11 scan update

Realtek's rtw88 is returning a hard-coded 1 in case they cannot
hw_scan (fw not advertising it).  In that case if we want any scan
to run we need to fall-back to sw scan.  Start dealing with this.
Long-term we probably need to keep internal state.

(cherry picked from commit d3ef7fb459ff924911e5276db0c04b13cd8074d9)

2 years agoLinuxKPI: pci.h add more defines
Bjoern A. Zeeb [Tue, 15 Feb 2022 23:51:40 +0000 (23:51 +0000)]
LinuxKPI: pci.h add more defines

Add and sort in more defines needed by newer drivers.

Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D34293

(cherry picked from commit c4f52f71de98a575dab84f5654f73d7022d40795)

2 years agoLinuxKPI: 802.11 enahnce linuxkpi_ieee80211_iterate_interfaces()
Bjoern A. Zeeb [Wed, 16 Feb 2022 03:56:54 +0000 (03:56 +0000)]
LinuxKPI: 802.11 enahnce linuxkpi_ieee80211_iterate_interfaces()

Add support for IEEE80211_IFACE_SKIP_SDATA_NOT_IN_DRIVER in
linuxkpi_ieee80211_iterate_interfaces() needed by a driver.

(cherry picked from commit 61a68e50d436333396ffd2e1d6a4b5d2875f8118)

2 years agoLinuxKPI: lockdep add lockdep_assert_not_held()
Bjoern A. Zeeb [Wed, 9 Feb 2022 12:01:32 +0000 (12:01 +0000)]
LinuxKPI: lockdep add lockdep_assert_not_held()

Add lockdep_assert_not_held() asserting LA_UNLOCKED as needed by a
driver.

Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D34232

(cherry picked from commit 064c110f4b551cbf3f2ef6f567736005c2d7007a)

2 years agonet80211: enhance (disabled) debugging
Bjoern A. Zeeb [Mon, 14 Feb 2022 22:16:59 +0000 (22:16 +0000)]
net80211: enhance (disabled) debugging

Add maxchans to the disabled debugging in addchan() and copychan_prev()
to aid debugging possible errors rreturned due to reaching maxchans
limits.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit 32cf376a01d42710ccbb1d6664ebd0a85c9e0064)

2 years agoLinuxKPI: add kstrtoint_from_user() and DECLARE_FLEX_ARRAY()
Bjoern A. Zeeb [Wed, 9 Feb 2022 11:58:40 +0000 (11:58 +0000)]
LinuxKPI: add kstrtoint_from_user() and DECLARE_FLEX_ARRAY()

Add an implementation of kstrtoint_from_user() based on the other
implementations and an attempt at DECLARE_FLEX_ARRAY() which works
for the driver needing it.

Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D34231

(cherry picked from commit c840d5cec2607932d077ffcfee7ccf0a6b50cdf3)

2 years agoLinuxKPI: add UUID_STRING_LEN and GUID_INIT to uuid.h
Bjoern A. Zeeb [Wed, 9 Feb 2022 12:10:59 +0000 (12:10 +0000)]
LinuxKPI: add UUID_STRING_LEN and GUID_INIT to uuid.h

Add a definition for UUID_STRING_LEN to uuid.h as needed by a driver.
Also add GUID_INIT for drm-kmod [1].

Submitted by: wulf [1]
Reviewed by: hselasky (earlier), wulf
Differential Revision: https://reviews.freebsd.org/D34235

(cherry picked from commit 97009980c492f5bc44a942cee09ac1ccfe4ae00a)

2 years agoLinuxKPI: 802.11: get rid of lkpi_ic_getradiocaps warnings
Bjoern A. Zeeb [Mon, 14 Feb 2022 22:29:38 +0000 (22:29 +0000)]
LinuxKPI: 802.11: get rid of lkpi_ic_getradiocaps warnings

Users are seeing warnings about 2 channels (1 per band)
triggered by an ioctl from wpa_supplicant usually:
lkpi_ic_getradiocaps: Adding chan ... returned error 55
This was an early FAQ.

Check the current number of channels against maxchans and the return
code from net80211. In case net80211 reports that we reached the limit
do not print the warning and do not try to add further channels.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit cee56e77d77909df69624cc707a571647651c853)

2 years agoLinuxKPI: add get_unaligned_le16()
Bjoern A. Zeeb [Wed, 9 Feb 2022 11:37:37 +0000 (11:37 +0000)]
LinuxKPI: add get_unaligned_le16()

Add get_unaligned_le16() to asm/unaligned.h needed by a driver.

Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D34224

(cherry picked from commit 2e818fbcfc03f9416593d5fe5bc860c1829f5366)

2 years agoLinuxKPI: add sizeof_field()
Bjoern A. Zeeb [Wed, 9 Feb 2022 11:46:15 +0000 (11:46 +0000)]
LinuxKPI: add sizeof_field()

Add sizeof_field() to linux/compiler.h needed by a driver.

Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D34226

(cherry picked from commit e5b95b220135bba90154c9c27803f54bf1a75548)

2 years agoLinuxKPI: add __ffs64()
Bjoern A. Zeeb [Wed, 9 Feb 2022 11:43:33 +0000 (11:43 +0000)]
LinuxKPI: add __ffs64()

Add __ffs64() to linux/bitops.h needed by a driver.

Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D34225

(cherry picked from commit d17b78aa142d7c63490c7a2c3f202ef99fffad70)

2 years agoLinuxKPI: add linux/pm_qos.h
Bjoern A. Zeeb [Wed, 9 Feb 2022 12:07:44 +0000 (12:07 +0000)]
LinuxKPI: add linux/pm_qos.h

Add a linux/pm_qos.h with three dummy functions and a struct as needed
by a driver and drm-kmod [1] in main with no intend to support this for
the moment.

Submitted by: wulf (drm-kmod bits) [1]
Sponsored by: The FreeBSD Foundation (drm-kmod requested updates)
Reviewed by: hselasky (earlier version), wulf
Differential Revision: https://reviews.freebsd.org/D34234

(cherry picked from commit fa6d3522b56d482e77740e325b59019e2ffc347e)

2 years agoLinuxKPI: add NETIF_F_HW_CSUM to netdev_features.h
Bjoern A. Zeeb [Wed, 9 Feb 2022 12:05:13 +0000 (12:05 +0000)]
LinuxKPI: add NETIF_F_HW_CSUM to netdev_features.h

Add NETIF_F_HW_CSUM to netdev_features.h as needed by a driver.

Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D34233

(cherry picked from commit 85d61bd872a0d91173d6cc8dc5bb2c927a5a4302)

2 years agoTCP syncache: enhance KASSERT output
Bjoern A. Zeeb [Tue, 8 Feb 2022 23:47:15 +0000 (23:47 +0000)]
TCP syncache: enhance KASSERT output

Improve the "syncache: mbuf too small" assertion message with various
variables (some not actually needed) but enough that it will be obvious
if (a) we use IPv4 or IPv6, (b) if UDP tunneling is on, (c) what
max_linkhdr is, and (d) what MHLEN is.

This should help diagnostics in the future.
The case was hit with wireless drivers setting a large ic_headroom
and using IPv6.

Reviewed by: gallatin, tuexen, rscheff
Differential Revision: https://reviews.freebsd.org/D34217

(cherry picked from commit 232d323ef227109acce37f5a0d62492673666ee2)

2 years agoLinuxKPI: add more errno
Bjoern A. Zeeb [Wed, 9 Feb 2022 11:48:37 +0000 (11:48 +0000)]
LinuxKPI: add more errno

Add ENOMEDIUM, ENOSR, and ELNRNG to linux/errno.h needed by drivers.

Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D34227

(cherry picked from commit 8f33ad3cf5361c700e2b133915685983003de67c)

2 years agoLinuxKPI: add eth_random_addr() and device_get_mac_address()
Bjoern A. Zeeb [Wed, 9 Feb 2022 11:50:27 +0000 (11:50 +0000)]
LinuxKPI: add eth_random_addr() and device_get_mac_address()

Add eth_random_addr() and a dummy of device_get_mac_address()
pending OF (FDT) support needed by drivers.

While here remove a white space in random_ether_addr().

Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D34228

(cherry picked from commit 3cd6d6ff527ad0a57d278e2911f59b22dbd402cf)

2 years agoLinuxKPI: add an initial ethtool.h
Bjoern A. Zeeb [Wed, 9 Feb 2022 11:53:27 +0000 (11:53 +0000)]
LinuxKPI: add an initial ethtool.h

Add an initial ethtool.h for a define and a dummy struct for now
needed by drivers.

Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D34229

(cherry picked from commit 0c37ffda799a9d44370bfe9898f220c193306842)

2 years agoLinuxKPI; add the beginning of a tracepoint.h implementation
Bjoern A. Zeeb [Wed, 9 Feb 2022 12:13:19 +0000 (12:13 +0000)]
LinuxKPI; add the beginning of a tracepoint.h implementation

Add a beginning of a tracepoint.h implementation to ease porting drivers
making use of this Linux facility.

Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D34236

(cherry picked from commit a4529c46d4ee330ff6d347a611d62f4792e94392)

2 years agoetc/defaults/rc.conf: set default of zfskeys_enable to NO
Robert Wing [Tue, 18 Jan 2022 23:26:30 +0000 (14:26 -0900)]
etc/defaults/rc.conf: set default of zfskeys_enable to NO

This addresses the following boot message:
    /etc/rc: WARNING: $zfskeys_enable is not set properly - see rc.conf(5).

Reported by:    Mark Millard
Sponsored by:   Modirum MDPay
Sponsored by:   Klara Inc.
Fixes: bfb7a31b6a22 ("rc: Hook zfskeys to the build")
Fixes: 33ff39796ffe ("Add zfskeys rc.d script for auto-loading encryption keys")
(cherry picked from commit 6596f19daa42d5b968030e08826542c704533b73)

2 years agolibthr: Disable stack unwinding on ARM.
John Baldwin [Thu, 10 Feb 2022 20:47:08 +0000 (12:47 -0800)]
libthr: Disable stack unwinding on ARM.

When a thread exits, _Unwind_ForcedUnwind() is used to walk up stack
frames executing pending cleanups pushed by pthread_cleanup_push().
The cleanups are popped by thread_unwind_stop() which is passed as a
callback function to _Unwind_ForcedUnwind().

LLVM's libunwind uses a different function type for the callback on
32-bit ARM relative to all other platforms.  The previous unwind.h
header (as well as the unwind.h from libcxxrt) use the non-ARM type on
all platforms, so this has likely been broken on 32-bit arm since it
switched to using LLVM's libunwind.

For now, just disable stack unwinding on 32-bit arm to unbreak the
build until a proper fix is tested.

(cherry picked from commit bbf4df1722060fb78939419476fb624114fb303d)

2 years agoInstall unwind.h into /usr/include
John Baldwin [Thu, 10 Feb 2022 17:57:49 +0000 (18:57 +0100)]
Install unwind.h into /usr/include

Install headers from LLVM's libunwind in place of the headers from
libcxxrt and allow C applications to use the library.

As part of this, remove include/unwind.h and switch libthr over to
using the installed unwind.h.

Reviewed by: dim, emaste
MFC after: 10 days
Differential Revision: https://reviews.freebsd.org/D34065

(cherry picked from commit c00d345665366a89aaba7244d6f078dc756f4c53)

2 years agoChange the return value of _Unwind_GetCFA in include/unwind.h.
John Baldwin [Thu, 27 Jan 2022 22:42:40 +0000 (14:42 -0800)]
Change the return value of _Unwind_GetCFA in include/unwind.h.

I tested the original commit as part of a series that culminates in
removing this header and installing LLVM libunwind's unwind.h in its
place so missed updating this header as was done in b84693501af6.

Pointy hat to: jhb
Reported by: kevans
Fixes: 3a502289d316 Use uintptr_t for return type of _Unwind_GetCFA.

(cherry picked from commit 522f5383547a2b3980f097a647b25f12c15411af)

2 years agoUse uintptr_t for return type of _Unwind_GetCFA.
John Baldwin [Thu, 27 Jan 2022 18:53:21 +0000 (10:53 -0800)]
Use uintptr_t for return type of _Unwind_GetCFA.

This matches the type in other unwind headers.

Reviewed by: dim, emaste
Differential Revision: https://reviews.freebsd.org/D34050

(cherry picked from commit 3a502289d316f726fec24087012fabb06313a2bf)

2 years agoUse an unsigned 64-bit integer for exception class.
John Baldwin [Thu, 27 Jan 2022 18:34:35 +0000 (10:34 -0800)]
Use an unsigned 64-bit integer for exception class.

This matches the type in other unwind headers (LLVM libunwind,
libcxxrt, glibc).

NB: include/unwind.h is not installed but is only used by libthr

Reviewed by: imp, dim, emaste
Differential Revision: https://reviews.freebsd.org/D34049

(cherry picked from commit b84693501af6521487327ec4eb7c6ae0097ac5d7)

2 years agounbound: Refresh manpages to latest version
Cy Schubert [Thu, 17 Feb 2022 16:11:33 +0000 (08:11 -0800)]
unbound: Refresh manpages to latest version

Update unbound manpages by copying the current unbound manpages in
contrib/doc/*.in to their respective manpages,

PR: 262013
Reported by: Michael Osipov <michael.osipov@siemens.com>
Fixes: numerous previous updates

(cherry picked from commit 0640e0c1965948da53e0baae9eece957919c0b43)

2 years agopf tests: Test adding counters to an existing table
Kristof Provost [Tue, 1 Feb 2022 17:27:40 +0000 (18:27 +0100)]
pf tests: Test adding counters to an existing table

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

(cherry picked from commit 109418996514111d887b6790c617cbc7cc3f41a5)

2 years agopf: deal with tables gaining or losing counters
Kristof Provost [Tue, 1 Feb 2022 17:25:57 +0000 (18:25 +0100)]
pf: deal with tables gaining or losing counters

When we create a table without counters, add an entry  and later
re-define the table to have counters we wound up trying to read
non-existent counters.

We now cope with this by attempting to add them if needed, removing them
when they're no longer needed and not trying to read from counters that
are not present.

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

(cherry picked from commit b21826bf15f7ec1e206fa3cfdf40691f84fb1d8e)

2 years agoFix non-printable characters in NVMe model and serial numbers.
Kenneth D. Merry [Mon, 24 Jan 2022 21:19:25 +0000 (16:19 -0500)]
Fix non-printable characters in NVMe model and serial numbers.

The NVMe 1.4 spec simply says that Model and Serial numbers are
ASCII strings.  Unlike SCSI, it doesn't prohibit non-printable
characters or say that the strings should be padded with spaces.

Since 2014, we have had cam_strvis_sbuf(), which gives additional
options for handling non-ASCII characters.  That behavior hasn't
been available for non-sbuf consumers, so users of cam_strvis()
were left with having octal ASCII codes inserted.

So, to avoid having garbage or octal chracters in the strings, use
cam_strvis_sbuf() to create a new function, cam_strvis_flag(), and
re-implement cam_strvis() using cam_strvis_flag().

Now, for the NVMe drives, we can use cam_strvis_flag with the
CAM_STRVIS_FLAG_NONASCII_SPC flag.  This transforms non-printable
characters into spaces.

sys/cam/cam.c:
Add a new function, cam_strvis_flag(), that creates an sbuf
on the stack with the user's destination buffer, and calls
cam_strvis_sbuf() with the given flag argument.

Re-implement cam_strvis() to call cam_strvis_flag with the
CAM_STRVIS_FLAG_NONASCII_ESC argument.  This should be the
equivalent of the old cam_strvis() function, except for the
overhead of creating the sbuf and calling sbuf_putc/printf.

sys/cam/cam.h:
Declaration for cam_strvis_flag.

sys/cam/nvme/nvme_all.c:
In nvme_print_ident, use the NONASCII_SPC flag with
cam_strvis_flag().

sys/cam/nvme/nvme_da.c:
In ndaregister(), use cam_strvis_flag() with the
NONASCII_SPC flag for the disk description and serial
number we report to GEOM.

sys/cam/nvme/nvme_xpt.c:
In nvme_probe_done(), use cam_strvis_flag with the
NONASCII_SPC flag when storing the drive serial number
in the CAM EDT.

Sponsored by: Spectra Logic
Differential Revision: https://reviews.freebsd.org/D33973

(cherry picked from commit 3090d5045a1e5663f151ef3f50f3c7db8f9a9e3c)