]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
2 years agoiwlwifi: import firmware for Intel iwlwifi/mvm supported chipsets.
Bjoern A. Zeeb [Sun, 28 Nov 2021 18:34:19 +0000 (18:34 +0000)]
iwlwifi: import firmware for Intel iwlwifi/mvm supported chipsets.

Import the most recent versions of the firmware images for iwlwifi
chipsets supported by the "mvm" sub-driver.
This is based on linux-firmware at f5d519563ac9d2d1f382a817aae5ec5473811ac8.
The license of the firmware matches the previous iwnfw(4) and
iwmfw(4) firmware files and you can find a copy in
sys/contrib/dev/iwlwififw/LICENCE.iwlwifi_firmware .

Add build infrastructure to create the .ko files but do not yet hook
it up to the build until all parts are in the tree.
There is an open issue concerning kldxref that we need to resolve
(D32383).

Sponsored by: The FreeBSD Foundation

(cherry picked from commit f4c129f5fb1669b284d76a838b1e509f97c2d299)

2 years agoLinuxKPI: USB return possible error from suspend/resume
Bjoern A. Zeeb [Wed, 24 Nov 2021 21:28:46 +0000 (21:28 +0000)]
LinuxKPI: USB return possible error from suspend/resume

USB suspend/resume cannot fail so we never returned the error which
resulted in a -Wunused-but-set-variable warning.
Initialize the return variable and return a possible error possibly
triggering a printf upstream to at least have a trace of the problem.
This also fixes the warning.

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

(cherry picked from commit 943df073a348bcb1e701c3677536f913761d4123)

2 years agoLinuxKPI: fix -Wunused-but-set-variable warnings
Bjoern A. Zeeb [Wed, 24 Nov 2021 21:20:52 +0000 (21:20 +0000)]
LinuxKPI: fix -Wunused-but-set-variable warnings

Handle write-only variables by removing the unused return value from void
functions or removing the unused variables entirely.

Sponsored by: The FreeBSD Foundation
Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D33107

(cherry picked from commit 7043359ce3c1e56ed55c8b41867a14a418511a05)

2 years agostd.nodebug: turn off net80211 debugging as well
Bjoern A. Zeeb [Wed, 24 Nov 2021 18:03:48 +0000 (18:03 +0000)]
std.nodebug: turn off net80211 debugging as well

Add IEEE80211_DEBUG to turn off some net80211 debbugging for
no-debug builds.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit 1c55b0ce1c944c0b1b7657b7efa151cd25a74f5b)

2 years agonet80211: fix -Wunused-but-set-variable warnings
Bjoern A. Zeeb [Wed, 24 Nov 2021 17:36:48 +0000 (17:36 +0000)]
net80211: fix -Wunused-but-set-variable warnings

Put the offending variables under the appropriate #ifdefs
(mostly IEEE80211_DEBUG, in one case IEEE80211_SUPPORT_SUPERG, and
in two cases under __notyet__ to revisit why these had been left
there but not used).

Sponsored by: The FreeBSD Foundation

(cherry picked from commit 05ea7a3e5e748547a0229efa80be0e71eaf84f52)

2 years agonet80211: radiotap add another define
Bjoern A. Zeeb [Thu, 18 Nov 2021 14:57:09 +0000 (14:57 +0000)]
net80211: radiotap add another define

Add a define needed by latest iwlwifi-next.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit f7c526ab3f23e5663cb8477c3dfb41a89de2d4cd)

2 years agolibthr: Use kern.stacktop for thread stack calculation.
Dawid Gorecki [Wed, 13 Oct 2021 19:06:05 +0000 (21:06 +0200)]
libthr: Use kern.stacktop for thread stack calculation.

Use the new kern.stacktop sysctl to retrieve the address of stack top
instead of kern.usrstack. kern.usrstack does not have any knowledge
of the stack gap, so this can cause problems with thread stacks.
Using kern.stacktop sysctl should fix most of those problems.
kern.usrstack is used as a fallback when kern.stacktop cannot be read.

Rename usrstack variables to stacktop to reflect this change.

Fixes problems with firefox and thunderbird not starting with
stack gap enabled.

PR: 239873
Reviewed by: kib
Obtained from: Semihalf
Sponsored by: Stormshield
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D31898

(cherry picked from commit 78df56ccfcb40013a3e6904bd6d39836220c3550)

2 years agokern_exec: Add kern.stacktop sysctl.
Dawid Gorecki [Wed, 13 Oct 2021 19:03:37 +0000 (21:03 +0200)]
kern_exec: Add kern.stacktop sysctl.

With stack gap enabled top of the stack is moved down by a random
amount of bytes. Because of that some multithreaded applications
which use kern.usrstack sysctl to calculate address of stacks for
their threads can fail. Add kern.stacktop sysctl, which can be used
to retrieve address of the stack after stack gap is applied to it.
Returns value identical to kern.usrstack for processes which have
no stack gap.

Reviewed by: kib
Obtained from: Semihalf
Sponsored by: Stormshield
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D31897

(cherry picked from commit a97d697122da2bfb0baae5f0939d118d119dae33)

2 years agosetrlimit: Take stack gap into account.
Dawid Gorecki [Wed, 13 Oct 2021 19:01:08 +0000 (21:01 +0200)]
setrlimit: Take stack gap into account.

Calling setrlimit with stack gap enabled and with low values of stack
resource limit often caused the program to abort immediately after
exiting the syscall. This happened due to the fact that the resource
limit was calculated assuming that the stack started at sv_usrstack,
while with stack gap enabled the stack is moved by a random number
of bytes.

Save information about stack size in struct vmspace and adjust the
rlim_cur value. If the rlim_cur and stack gap is bigger than rlim_max,
then the value is truncated to rlim_max.

PR: 253208
Reviewed by: kib
Obtained from: Semihalf
Sponsored by: Stormshield
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D31516

(cherry picked from commit 889b56c8cd84c9a9f2d9e3b019c154d6f14d9021)

2 years agobsdinstall: zfsboot: Prompt user for zpool name if the pool already exists
Emmanuel Vadot [Wed, 8 Dec 2021 10:37:50 +0000 (11:37 +0100)]
bsdinstall: zfsboot: Prompt user for zpool name if the pool already exists

If one install FreeBSD on multiple disks (say 13 and CURRENT) the first created
pool will always be used.
Prompt the user for a new pool name if we detect that the default or supplied one
already exists.

Reviewed by: imp
MFC after:      2 weeks
Sponsored by:   Beckhoff Automation GmbH & Co. KG
Differential Revision: https://reviews.freebsd.org/D33331

(cherry picked from commit 9935b0e8ea41804b32576987531be4d31ba705f1)

2 years agobsdinstall: bootconfig: Try to clean old efi boot entries
Emmanuel Vadot [Wed, 8 Dec 2021 09:37:54 +0000 (10:37 +0100)]
bsdinstall: bootconfig: Try to clean old efi boot entries

If one install FreeBSD on the same machine multiple times in a row or
on different harddrive they have a lot of 'FreeBSD' efi boot entries added.
With this patch we now do :
- If there is no 'FreeBSD' entry we add one like before
- If there is one or more entries we ask the user if they want to delete
  them all and add a new one
  - If they say yes we do that
  - If they say no we prompt them an inputbox so they can enter a different
    entry name if they want, it defaults to 'FreeBSD'

Reviewed by: bapt, imp
MFC after: 2 weeks
Sponsored by: Beckhoff Automation GmbH & Co. KG
Differential Revision: https://reviews.freebsd.org/D33330

(cherry picked from commit 40c928e7b80a7e2ba3652f7c3dc1d30fe92e5b48)

2 years agonfscl: Handle CB_SEQUENCE not first op correctly
Rick Macklem [Thu, 16 Dec 2021 00:36:40 +0000 (16:36 -0800)]
nfscl: Handle CB_SEQUENCE not first op correctly

The check for "not first operation" in CB_SEQUENCE
was done after the slot, etc. was updated. This patch
moves the check to the beginning of CB_SEQUENCE
processing.

While here, also fix the check for "no CB_SEQUENCE operation first"
by moving the check to the beginning of callback operation parsing,
since the check was in a couple of the other operations, but
not all of them.

PR: 260412

(cherry picked from commit e0861304a7b6b9c410db69be6148a5510c6b2d23)

2 years agorpc: Delete AUTH_NEEDS_TLS(_MUTUAL_HOST) auth_stat values
Rick Macklem [Thu, 23 Dec 2021 22:31:53 +0000 (14:31 -0800)]
rpc: Delete AUTH_NEEDS_TLS(_MUTUAL_HOST) auth_stat values

I thought that these new auth_stat values had been agreed
upon by the IETF NFSv4 working group, but that no longer
is the case.  As such, delete them and use AUTH_TOOWEAK
instead.  Leave the code that uses these new auth_stat
values in the sources #ifdef notnow, in case they are
defined in the future.

(cherry picked from commit 744c2dc7dde4ee1e1efc9630439682ea0dc338db)

2 years agogetfh: clarify that it is a privileged operation
Ed Maste [Thu, 23 Dec 2021 15:24:27 +0000 (10:24 -0500)]
getfh: clarify that it is a privileged operation

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

(cherry picked from commit 5bc2e6e22774f4663c971a4b5b7eaf4cb9a2485e)

2 years agoMFC: Improve readahead in loader
Colin Percival [Sun, 19 Sep 2021 22:24:00 +0000 (15:24 -0700)]
MFC: Improve readahead in loader

style: Fix leading whitespace in bcache.c
loader: Refactor readahead adjustment in bcache
loader bcache: Track unconsumed readahead
loader bcache: Allow readahead up to 256 kB I/Os

Sponsored by: https://www.patreon.com/cperciva

(cherry picked from commit 5a01dea7e8c9640605e5731a9fc7f600c07ace61)
(cherry picked from commit b841148bbbdc967c871e8742a6f0b7b17b2d1d91)
(cherry picked from commit 04b9b7c507c52daf7b2999329a50825db098151f)
(cherry picked from commit 248682a589159619aa5f2019e415a423e849e327)

2 years agoOnly trigger read-ahead if two adjacent blocks have been requested.
Maxim Sobolev [Fri, 20 Aug 2021 19:33:51 +0000 (12:33 -0700)]
Only trigger read-ahead if two adjacent blocks have been requested.

The change makes block caching algorithm to work better for remote
media on low-BW/high-delay links.

This cuts boot time over IP KVMs noticeably, since the initialization
stage reads bunch of small 4th (and now lua) files that are not in
the same cache stripe (usually), thus wasting lot of bandwidth and
increasing latency even further.

The original regression came in 2017 with revision 87ed2b7f5. We've
seen increase of time it takes for the loader to get to the kernel
loading from under a minute to 10-15 minutes in many cases.

Reviewed by: tsoome
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D31623

(cherry picked from commit 0d13f5343fafbf3067ffc33a507ffca0375c4417)

2 years agoEFI loader: Don't free bcache for DEVT_DISK devs
Colin Percival [Thu, 30 Sep 2021 21:48:14 +0000 (14:48 -0700)]
EFI loader: Don't free bcache for DEVT_DISK devs

Booting on an EC2 c5.xlarge instance, this reduces the number of I/Os
performed from 609 to 432, reduces the total number of blocks read
from 61963 to 60797, and reduces the time spent in the loader by 39 ms.

Note that b4cb3fe0e39a allowed the bcache to be retained for most of
the boot process, but relies on mounting filesystems; this commit
allows the bcache to be retained at the start of the boot process,
before the root filesystem has been located.

Sponsored by: https://www.patreon.com/cperciva
Differential Revision: https://reviews.freebsd.org/D32239

(cherry picked from commit ce73f768b76486b1562f207a6fc1cef87065418a)

2 years agoMFC: Add TSLOG to loader sprintf
Colin Percival [Sat, 25 Sep 2021 03:19:38 +0000 (20:19 -0700)]
MFC: Add TSLOG to loader sprintf

loader tslog: Don't use sprintf
loader printf: Profile with TSLOG

Sponsored by: https://www.patreon.com/cperciva

(cherry picked from commit 242923eb848a94d657344c2ff45c4f15433cdf3c)
(cherry picked from commit 0a35c4b3cab563e3ab1bf5b7b49bf26e0bb7cb04)

2 years agoAdd _sleep to TSLOG
Colin Percival [Sun, 5 Sep 2021 19:50:15 +0000 (12:50 -0700)]
Add _sleep to TSLOG

Most of the nvme initialization time in my tests is being spent here
(via pause_sbt).

Sponsored by: https://www.patreon.com/cperciva

(cherry picked from commit bd11e253a9a459c9a7b69ebb1c68f0162eb6119f)

2 years agoloader: Set twiddle globaldiv to 16 by default
Colin Percival [Tue, 28 Sep 2021 18:39:59 +0000 (11:39 -0700)]
loader: Set twiddle globaldiv to 16 by default

Booting FreeBSD on an EC2 c5.xlarge instance, the loader "twiddles"
810 times over the course of 510 ms, a rate of 1.59 kHz. Even accepting
that many systems are slower than this particular VM and will take
longer to boot (especially if using spinning-rust disks), this seems
like an unhelpfully large amount of twiddling when compared to the
~60 Hz frame rate of many displays; printing the twiddles also consumes
roughly 10% of the boot time on the aforementioned VM.

Setting the default globaldiv to 16 dramatically reduces the time spent
printing twiddles to the console while still twiddling at roughly 100
Hz; this should be ample even for systems which take longer to boot and
consequently twiddle slower.

Note that this can adjusted via the twiddle_divisor variable in
loader.conf, but that file is not processed until nearly halfway
through the loader's runtime.

Sponsored by: https://www.patreon.com/cperciva
Differential Revision: https://reviews.freebsd.org/D32163

(cherry picked from commit 7457840230c5a470ee5df8abed6ab59c4d008a45)

2 years agoMFC: arm64 fixes for TSLOG
Colin Percival [Thu, 24 Jun 2021 05:10:26 +0000 (22:10 -0700)]
MFC: arm64 fixes for TSLOG

arm64: Disable early printf if TSLOG
arm64: Instrument initarm with TSLOG
libsa: Add tslog support for arm64

Sponsored by: https://www.patreon.com/cperciva

(cherry picked from commit 0acc529dc35f88836dbcbe75940954c75595b058)
(cherry picked from commit ccadcb8f3343562f22a426e845dba640319d4355)
(cherry picked from commit e6caac717b4fc2b87cf93f67109884e768253e77)

2 years agoMFC loader+userland TSLOG support
Colin Percival [Sun, 30 May 2021 20:17:11 +0000 (20:17 +0000)]
MFC loader+userland TSLOG support

stand/common: Add file_addbuf()
libsa: Add support for timestamp logging (tslog)
stand/common: Add support for timestamp logging (tslog)
i386/loader: Call tslog_init
efi/loader: Call tslog_init (+ bugfix)
stand/common command_boot: Pass tslog to kernel
kern_tslog: Include tslog data from loader
loader: Use tslog to instrument some functions
Add userland boot profiling to TSLOG (+ bugfix)

Sponsored by: https://www.patreon.com/cperciva

(cherry picked from commit 60a978bec9123fcb9c74bd925e06dd3f4faddac6)
(cherry picked from commit e193d3ba337757a27148a38494d3df106b826d1c)
(cherry picked from commit c8dfc327db2373c721a35efe857cf07262fd7dd0)
(cherry picked from commit c4b65e954f0f4754941f5b37436231f611b76d67)
(cherry picked from commit f49381ccb6bc8a5733f1aa505e716eddae299986)
(cherry picked from commit 537a44bf281559d304850b5e28b6f8b8e44fd593)
(cherry picked from commit fe51b5a76de38d20cddc05a4c6cb1103d1a0547e)
(cherry picked from commit 313724bab940c1844fda3d797cf88cd46780e62a)
(cherry picked from commit 46dd801acb2318c8464b185893bb111f09b71138)
(cherry picked from commit 52e125c2bd302982c179ecc920cc9a6e166033d6)
(cherry picked from commit 19e4f2f289fb8d2b14576a65ca9e6f931dbb6a02)

2 years agoEliminate key press requirement "show vmopag" command output.
Stephen J. Kiernan [Fri, 17 Dec 2021 21:39:51 +0000 (16:39 -0500)]
Eliminate key press requirement "show vmopag" command output.

Summary:
One was required to press a key to continue after every 18 lines of
output. This requirement had been in the "show vmopag" command since it
was introduced, which was many years before paging was added to DDB.
With paging, this explict key check is no longer necessary.

Obtained from: Juniper Networks, Inc.
MFC after: 1 week

Test Plan:
Run "show vmopag" from db> prompt and see that it does not need additional
keypresses other than the ones needed for the pager.

Subscribers: imp, #contributor_reviews_base

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

(cherry picked from commit 18048b6e3cb647f2a18e1e51df1cf86a90fc6802)

2 years agovm_reserv: fix zero-boundary error
Doug Moore [Sun, 26 Dec 2021 17:40:27 +0000 (11:40 -0600)]
vm_reserv: fix zero-boundary error

Handle specially the boundary==0 case of vm_reserv_reclaim_config,
by turning off boundary adjustment in that case.

Reviewed by: alc
Tested by: pho, madpilot

(cherry picked from commit 49fd2d51f07fb29af3fd239f83f249c00cd84123)

2 years agoUSB dwc3 controller: add quirk snps,dis_rxdet_inp3_quirk
Bjoern A. Zeeb [Wed, 10 Nov 2021 00:22:20 +0000 (00:22 +0000)]
USB dwc3 controller: add quirk snps,dis_rxdet_inp3_quirk

Add support for the "snps,dis_rxdet_inp3_quirk" quirk needed
at least on SolidRun's HoneyComb.

Reviewed by: manu, mw
Differential Revision: https://reviews.freebsd.org/D32921

(cherry picked from commit 3987e506112a7e8af6f09966792fb8656d630496)

2 years agoUSB: add CYUSB330x to usbdevs
Bjoern A. Zeeb [Fri, 15 Oct 2021 10:46:58 +0000 (10:46 +0000)]
USB: add CYUSB330x to usbdevs

Add the Cypress dual USB3/2 HUB CYUSB330x as found in SolidRun's
HoneyComb to usbdevs.

(cherry picked from commit 1910048eb931bb749c42534a8f252d772c0719de)

2 years agofw_stub: fix -Wunused-but-set-variable for firmware files
Bjoern A. Zeeb [Tue, 30 Nov 2021 14:23:18 +0000 (14:23 +0000)]
fw_stub: fix -Wunused-but-set-variable for firmware files

In case we are only embedding a single firmware image the variable
"parent" gets set but never used.  Add checks for the number of files
for it and only print it out if we are exceeding the single file count.
This fixes -Wunused-but-set-variable warnings for the majority of
firmware files in the tree.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit b394e16ef0b5ad0da5e029bcdd3a01e361724d8d)

2 years agorc: network.subr improve network6_getladdr()
Bjoern A. Zeeb [Mon, 13 Dec 2021 22:10:25 +0000 (22:10 +0000)]
rc: network.subr improve network6_getladdr()

In network6_getladdr() we are iterating over inet6 lines and are not
interested in any others.  So tell ifconfig to limit output to "inet6"
as much as possible.
This is probably a micro-optimisation but was noticed while looking
at other IPv6-related boot-time improvements.

(cherry picked from commit e448ff6f0e8035c3dd5b7bd0872f3f0d91c4e0d0)

2 years agox86: Do not attempt to calibrate the LAPIC timer if no APIC is present
Mark Johnston [Tue, 28 Dec 2021 22:44:57 +0000 (17:44 -0500)]
x86: Do not attempt to calibrate the LAPIC timer if no APIC is present

Reported and tested by: Michael Butler <imb@protected-networks.net>
Reviewed by: jhb, kib
Fixes: 62d09b46ad75 ("x86: Defer LAPIC calibration until after timecounters are available")
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 0ecda8d5ae896b229f13bfe73ffa3a7fc81cc550)

2 years agox86: Perform late TSC calibration before LAPIC timer calibration
Mark Johnston [Mon, 6 Dec 2021 15:42:19 +0000 (10:42 -0500)]
x86: Perform late TSC calibration before LAPIC timer calibration

This ensures that LAPIC calibration is done using the correct tsc_freq
value, i.e., the one associated with the TSC timecounter.  It does mean
though that TSC calibration cannot use sbinuptime() to read the
reference timecounter, as timehands are not yet set up.

Reviewed by: kib, jhb
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 553af8f1ec71d397b5b4fd5876622b9269936e63)

2 years agox86: Defer LAPIC calibration until after timecounters are available
Mark Johnston [Mon, 6 Dec 2021 15:42:10 +0000 (10:42 -0500)]
x86: Defer LAPIC calibration until after timecounters are available

This ensures that we have a good reference timecounter for performing
calibration.

Change lapic_setup to avoid configuring the timer when booting, and move
calibration and initial configuration to a new lapic routine,
lapic_calibrate_timer.  This calibration will be initiated from
cpu_initclocks(), before an eventtimer is selected.

Reviewed by: kib, jhb
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 62d09b46ad7508ae74d462e49234f0a80f91ff69)

2 years agox86: Implement deferred TSC calibration
Mark Johnston [Mon, 15 Nov 2021 20:31:21 +0000 (15:31 -0500)]
x86: Implement deferred TSC calibration

There is no universal way to find the TSC frequency.  Newer Intel CPUs
may report it via CPUID leaves 0x15 and 0x16.  Sometimes it can be
obtained from the PLATFORM_INFO MSR as well, though we never use that.
On older platforms we derive the frequency using a DELAY(1000000) call,
which uses the 8254 PIT.  On some newer platforms the 8254 is apparently
non-functional, leading to bogus calibration results.  On such platforms
the TSC frequency must be available from CPUID.  It is also possible to
disable calibration with a tunable, in which case we try to parse the
brand string if the TSC freq is not available from CPUID.

CPUID 0x15 provides an authoritative TSC frequency value, but even that
is not always available on new Intel platforms.  CPUID 0x16 provides the
specified processor base frequency, which is not the same as the TSC
frequency.  Empirically, it is close enough for early boot, but too far
off for timekeeping: on a Comet Lake NUC, CPUID 0x16 yields 1600MHz but
the TSC frequency is rougly 1608MHz, leading to frequent clock stepping
when NTP is in use.

Thus we have a situation where we cannot calibrate using the PIT and
cannot obtain a precise frequency from CPUID (or MSRs).  This change
seeks to address that by using the CPUID 0x16 value during early boot
and refining the calibration later once ACPI-based timecounters are
available.  TSC frequency detection is thus split into two phases:

Early phase:
- On Intel platforms, query CPUID 0x15 and 0x16 and use that value
  initially if available.
- Otherwise, get an estimate using the PIT, reducing the delay loop to
  100ms from 1s.
- Continue to register the TSC as the CPU ticks provider early, even
  though the frequency may be off.  Otherwise any code executed during
  boot that uses cpu_ticks() (e.g., context switching) gets tripped up
  when the ticks provider changes.

Later phase:
- In SI_SUB_CLOCKS, once the timehands are initialized, load the current
  TSC and timecounter (sbinuptime()) values at the beginning and end of
  a 1s interval and use the timecounter frequency (typically from
  kvmclock, HPET or the ACPI PM timer) to estimate the TSC frequency.
- Update the TSC timecounter, global tsc_freq and CPU ticker with the
  new frequency and finally register the TSC as a timecounter.

Reviewed by: kib, jhb (previous version)
Discussed with: imp, cperciva
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 22875f88799e1684febf79b5049541e0f825aaa1)

2 years agoAdd assembly optimized code for OpenSSL on powerpc, powerpc64 and powerpc64le
Piotr Kubaj [Mon, 22 Nov 2021 02:28:46 +0000 (03:28 +0100)]
Add assembly optimized code for OpenSSL on powerpc, powerpc64 and powerpc64le

Summary:
1. https://github.com/openssl/openssl/commit/34ab13b7d8e3e723adb60be8142e38b7c9cd382a
needs to be merged for ELFv2 support on big-endian.
2. crypto/openssl/crypto/ppccap.c needs to be patched.
Same reason as in https://github.com/openssl/openssl/pull/17082.

Approved by: jkim, jhibbits, alfredo (MFC to stable/13)
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D33076

(cherry picked from commit 3a60869237b8b315fe66497cf5299ec08b688533)

2 years agoIPv4: fix redirect sending conditions
Bjoern A. Zeeb [Sun, 26 Dec 2021 15:33:48 +0000 (15:33 +0000)]
IPv4: fix redirect sending conditions

RFC792,1009,1122 state the original conditions for sending a redirect.
RFC1812 further refine these.
ip_forward() still sepcifies the checks originally implemented for these
(we do slightly more/different than suggested as makes sense).
The implementation added in 8ad114c082a159c0dde95aa35d2e3e108aa30a75
to ip_tryforward() however is flawed and may send a "multi-hop"
redirects (to a host not on the directly connected network).

Do proper checks in ip_tryforward() to stop us from sending redirects
in situations we may not.  Keep as much logic out of ip_tryforward()
and in ip_redir_alloc() and only do the mbuf copy once we are sure we
will send a redirect.

While here enhance and fix comments as to which conditions are handled
for sending redirects in various places.

Reported by: pi (on net@ 2021-12-04)
Sponsored by: Dr.-Ing. Nepustil & Co. GmbH
Reviewed by: cy, others (earlier versions)
Differential Revision: https://reviews.freebsd.org/D33274

(cherry picked from commit f389439f50fc4c27d15d3017b622270e25ba71c7)

2 years agoFix dtrace fbt return probes on arm64
Andrew Turner [Tue, 14 Dec 2021 15:49:07 +0000 (15:49 +0000)]
Fix dtrace fbt return probes on arm64

As with arm and riscv fix return fbt probes on arm64. arg0 should be
the offset within the function of the return instruction and arg1
should be the return value.

Reviewed by: kp, markj
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D33440

(cherry picked from commit e3ccf4f9dee9ae39774639407264199a07fa41ff)

2 years agoAdd accelerated arm64 sha512 to libmd
Andrew Turner [Fri, 19 Nov 2021 11:32:58 +0000 (11:32 +0000)]
Add accelerated arm64 sha512 to libmd

As with sha256 add support for accelerated sha512 support to libmd on
arm64. This depends on clang 13+ to build as this is the first release
with the needed intrinsics. Gcc should also support them, however from
a currently unknown release.

Reviewed by: cem
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D33373

(cherry picked from commit 71bf1c4cc5b21e7e5740514c1bc6ad751f312eea)

2 years agoFix a set but not used warning in the arm64 pmap
Andrew Turner [Tue, 7 Dec 2021 14:32:11 +0000 (14:32 +0000)]
Fix a set but not used warning in the arm64 pmap

In pmap_ts_referenced we read the virtual address from pv->pv_va,
but then continue to use the pv struct to get the same value later
in the function.

Use the virtual address value we initially read rather than loading
from the pv struct each time.

(cherry picked from commit 1c643b721bed48ba795b42cdc5e8b5818f30ed14)

2 years agoHandle table attributes in the arm64 kernel map
Andrew Turner [Tue, 7 Dec 2021 14:23:13 +0000 (14:23 +0000)]
Handle table attributes in the arm64 kernel map

When getting the arm64 kernel maps sysctl we should look at the table
attributes as well as the block/page attributes. These attributes are
different to the last level attributes so need to be translated.

The previous code assumed the table and block/page attributes are
identical, however this is not the case. Handle the difference by
extracting the code into new helper functions & calling them as needed
based on the entry type being checked.

Reviewed by: markj
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D33321

(cherry picked from commit 8d0b41b058795dcb0270ca0abcbf92289563c3ed)

2 years agoTeach vm.pmap.kernel_maps about both XN bits
Andrew Turner [Mon, 6 Dec 2021 13:08:39 +0000 (13:08 +0000)]
Teach vm.pmap.kernel_maps about both XN bits

The arm64 vm.pmap.kernel_maps sysctl would only check the kernel XN bit
when printing the kernel mapping. It can also be useful to check none
of the mappings allow userspace to execute from a given virtual address.
To check for this add the user XN bit when getting the kernel maps.

While here fix the ATTR_S1_AP_USER check to use ATTR_S1_AP to shift the
value to the correct offset.

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

(cherry picked from commit 38dbca724335fec679e79b72d91a8e36b2624fe1)

2 years agoDon't fail changing props for unmapped DMAP memory
Andrew Turner [Tue, 14 Dec 2021 18:09:47 +0000 (18:09 +0000)]
Don't fail changing props for unmapped DMAP memory

When recursing in pmap_change_props_locked we may fail because there is
no pte. This shouldn't be considered a fail as it may happen in a few
cases, e.g. there are multiple normal memory ranges with device memory
between them.

Reported by: cperciva
Tested by: cperciva
Reviewed by: alc, kib
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D33459

(cherry picked from commit 69cfbd669e34aaaa49f4caed49bd7df93d4115b2)

2 years agoOnly change DMAP props on DMAP covered memory
Andrew Turner [Tue, 14 Dec 2021 10:05:15 +0000 (10:05 +0000)]
Only change DMAP props on DMAP covered memory

When changing memory properties in the arm64 pmap we need to keep both
the kernel address and DMAP mappings in sync.

To keep the kernel and DMAP memory in sync we recurse when updating the
former to also update the latter. There was insuffucuent checking around
this recursion. It would check if the virtual address is not within the
DMAP region, but not if the physical address is covered.

Add the missing check as without it the recursion may return an error.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit 6238905c5b253c5b8c6a4b66796819c3a0bed637)

2 years agosys/queue.h: move trashing from SLIST_REMOVE to REMOVE_AFTER, REMOVE_HEAD
Andriy Gapon [Wed, 15 Dec 2021 11:27:49 +0000 (13:27 +0200)]
sys/queue.h: move trashing from SLIST_REMOVE to REMOVE_AFTER, REMOVE_HEAD

SLIST_REMOVE calls either REMOVE_AFTER or REMOVE_HEAD to do the job.
But those two macros can be used independently as well.

(cherry picked from commit 5dab06a003189ebb017810bdbf3b3c2f074afd3e)

2 years agovm_fault: Fix vm_fault_populate()'s handling of VM_FAULT_WIRE
Mark Johnston [Tue, 14 Dec 2021 20:10:46 +0000 (15:10 -0500)]
vm_fault: Fix vm_fault_populate()'s handling of VM_FAULT_WIRE

vm_map_wire() works by calling vm_fault(VM_FAULT_WIRE) on each page in
the rage.  (For largepage mappings, it calls vm_fault() once per large
page.)

A pager's populate method may return more than one page to be mapped.
If VM_FAULT_WIRE is also specified, we'd wire each page in the run, not
just the fault page.  Consider an object with two pages mapped in a
vm_map_entry, and suppose vm_map_wire() is called on the entry.  Then,
the first vm_fault() would allocate and wire both pages, and the second
would encounter a valid page upon lookup and wire it again in the
regular fault handler.  So the second page is wired twice and will be
leaked when the object is destroyed.

Fix the problem by modify vm_fault_populate() to wire only the fault
page.  Also modify the error handler for pmap_enter(psind=1) to not test
fs->wired, since it must be false.

PR: 260347
Reviewed by: alc, kib
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 88642d978a999aaa3752e86d2f54b1a6aba7fc85)

2 years agoClean up a couple of MD warts in vm_fault_populate():
Jason A. Harmening [Sat, 27 Mar 2021 03:10:46 +0000 (20:10 -0700)]
Clean up a couple of MD warts in vm_fault_populate():

--Eliminate a big ifdef that encompassed all currently-supported
architectures except mips and powerpc32.  This applied to the case
in which we've allocated a superpage but the pager-populated range
is insufficient for a superpage mapping.  For platforms that don't
support superpages the check should be inexpensive as we shouldn't
get a superpage in the first place.  Make the normal-page fallback
logic identical for all platforms and provide a simple implementation
of pmap_ps_enabled() for MIPS and Book-E/AIM32 powerpc.

--Apply the logic for handling pmap_enter() failure if a superpage
mapping can't be supported due to additional protection policy.
Use KERN_PROTECTION_FAILURE instead of KERN_FAILURE for this case,
and note Intel PKU on amd64 as the first example of such protection
policy.

Reviewed by: kib, markj, bdragon

(cherry picked from commit 8dc8feb53da0c1a2301cb21c87b17a09d12e8fa7)

2 years agox86: Deduplicate clock.h
Mark Johnston [Mon, 6 Dec 2021 15:39:08 +0000 (10:39 -0500)]
x86: Deduplicate clock.h

The headers were mostly identical on amd64 and i386.

No functional change intended.

Reviewed by: cperciva, mav, imp, kib, jhb
Sponsored by: The FreeBSD Foundation

(cherry picked from commit f06f1d1fdb969fa7a0a6eefa030d8536f365eb6e)

2 years agoaesni: Fix an out-of-bounds read in AES_GCM_decrypt()
Mark Johnston [Thu, 16 Dec 2021 14:08:16 +0000 (09:08 -0500)]
aesni: Fix an out-of-bounds read in AES_GCM_decrypt()

This is the same as 4285655adb74 ("aesni: Avoid a potential
out-of-bounds load in AES_GCM_encrypt()") except for the decryption
path.

Reported by: Jenkins (KASAN job)
Reviewed by: cem
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 4a61d8ef42cb44c337dfdc17424cc2e2f1d67fd5)

2 years agoamdsbwd: always enable watchdog register decoding
Andriy Gapon [Wed, 27 May 2020 10:15:54 +0000 (13:15 +0300)]
amdsbwd: always enable watchdog register decoding

This seems to be required even if the watchdog is accessed via the common
MMIO space.

Tested on:
- Ryzen 3 3200U APU;
- Ryzen 7 5800X CPU with X570 chipset.

(cherry picked from commit cca0d3bbd8c9f8b50c6940c33704a6c8c464b68f)

2 years agovmxnet3: skip zero-length descriptor in the middle of a packet
Andriy Gapon [Mon, 6 Dec 2021 07:59:28 +0000 (09:59 +0200)]
vmxnet3: skip zero-length descriptor in the middle of a packet

Passing up such descriptors to iflib is obviously wasteful.
But the main conern is that we may overrun iri_frags array because of
them.  That's been observed in practice.

Also, assert that the number of fragments / descriptors / segments is
less than IFLIB_MAX_RX_SEGS.

Sponsored by: Panzura LLC

(cherry picked from commit 9c612a5d0af17021abc6e1bb2a8baa5a4c97d05f)

2 years agoApply clang fix for crash or assertion failure compiling part of llvm
Dimitry Andric [Fri, 24 Dec 2021 11:46:00 +0000 (12:46 +0100)]
Apply clang fix for crash or assertion failure compiling part of llvm

Merge commit 77e8f4eeeeed from llvm git (by David Green):

  [ARM] Define ComplexPatternFuncMutatesDAG

  Some of the Arm complex pattern functions call canExtractShiftFromMul,
  which can modify the DAG in-place. For this to be valid and handled
  successfully we need to define ComplexPatternFuncMutatesDAG.

  Differential Revision: https://reviews.llvm.org/D107476

When building parts of llvm targeting armv6 on stable/12, the following
assertion can appear (or if assertions are disabled, clang is likely to
crash):

Assertion failed: (NodeToMatch->getOpcode() != ISD::DELETED_NODE && "NodeToMatch was removed partway through selection"), function SelectCodeCommon, file /usr/src/contrib/llvm-project/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp, line 3573.
PLEASE submit a bug report to https://bugs.freebsd.org/submit/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0. Program arguments: /usr/obj/usr/src/freebsd12-amd64/tmp/usr/bin/c++ -cc1 -triple armv6kz-unknown-freebsd12.3-gnueabihf -S --mrelax-relocations -disable-free -disable-llvm-verifier -discard-value-names -mrelocation-model static -mconstructor-aliases -target-cpu arm1176jzf-s -target-feature +vfp2 -target-feature +vfp2sp -target-feature -vfp3 -target-feature -vfp3d16 -target-feature -vfp3d16sp -target-feature -vfp3sp -target-feature -fp16 -target-feature -vfp4 -target-feature -vfp4d16 -target-feature -vfp4d16sp -target-feature -vfp4sp -target-feature -fp-armv8 -target-feature -fp-armv8d16 -target-feature -fp-armv8d16sp -target-feature -fp-armv8sp -target-feature -fullfp16 -target-feature +fp64 -target-feature -d32 -target-feature -neon -target-feature -sha2 -target-feature -aes -target-feature -fp16fml -target-feature +strict-align -target-abi aapcs-linux -mfloat-abi hard -fallow-half-arguments-and-returns -ffunction-sections -fdata-sections -O1 -std=c++14 -fdeprecated-macro -fno-rtti -fno-signed-char -faddrsig -fexperimental-new-pass-manager PPCISelLowering-009095.ii
1. <eof> parser at end of file
2. Code generation
3. Running pass 'Function Pass Manager' on module 'PPCISelLowering-009095.cpp'.
4. Running pass 'ARM Instruction Selection' on function '@_ZN4llvm17PPCTargetLoweringC2ERKNS_16PPCTargetMachineERKNS_12PPCSubtargetE'

This crash or assertion is fixed by the upstream commit.

MFC after: 3 days

(cherry picked from commit ada8b24d48d93f0b13209b555b64f3d355ef61d9)

2 years agotests/libalias: Make inline functions static inline
Dimitry Andric [Mon, 20 Dec 2021 09:52:02 +0000 (10:52 +0100)]
tests/libalias: Make inline functions static inline

In C, plain inline functions should never be used: they should be
declared either static inline or extern inline. In this case, they are
clearly meant to be static inline.

MFC after: 3 days

(cherry picked from commit 46aec7fae47ed46368f95338741b4daffa5cbc94)

2 years agoipfilter userland: Revert the ipmon part of a6fb9bbea731
Cy Schubert [Mon, 27 Dec 2021 09:10:52 +0000 (01:10 -0800)]
ipfilter userland: Revert the ipmon part of a6fb9bbea731

a6fb9bbea731 caused incorrect formatting of ipmon log output.

Fixes: a6fb9bbea7318e993dfe0f8a7f00821f79850b26

(cherry picked from commit d740faa30a4a2b300da0b2f2af4680a2cb260828)

2 years agosys/dev/arcmsr: Update Areca RAID driver to fix some issues on ARC-1886.
黃清隆 [Mon, 13 Dec 2021 16:09:15 +0000 (08:09 -0800)]
sys/dev/arcmsr: Update Areca RAID driver to fix some issues on ARC-1886.

1. Doorbell interrupt status may arrive lately when doorbell interrupt on
   ARC-1886.
2. System boot up hung when ARC-1886 with no volume created or no device
   attached.

Many thanks to Areca for continuing to support FreeBSD.

(cherry picked from commit 6964b77e598597789764ab6949a8031c14075a25)

2 years agonfscl: add a filesize limit check to nfs_allocate()
Rick Macklem [Mon, 13 Dec 2021 23:32:19 +0000 (15:32 -0800)]
nfscl: add a filesize limit check to nfs_allocate()

As reported in PR#260343, nfs_allocate() did not check
the filesize rlimit. This patch adds that check.

PR: 260343

(cherry picked from commit fe04c91184e9e82609a657c4e6e70e213ed3a859)

2 years agonfsd: Limit parsing of layout errors to maxcnt bytes
Rick Macklem [Mon, 13 Dec 2021 23:21:31 +0000 (15:21 -0800)]
nfsd: Limit parsing of layout errors to maxcnt bytes

This patch decrements maxcnt by the appropriate
number of bytes during parsing and checks to see
if there is data remaining.  If not, it just returns
from nfsrv_flexlayouterr() without further processing.
This prevents the tl pointer from running off the end
of the error data pointed at by layp, if there are
flaws in the data.

PR: 260293

(cherry picked from commit c302f889e21f73746a3b0917df5246e639df1481)

2 years agoqat: Address -Wunused-but-set-variable warnings
Mark Johnston [Fri, 10 Dec 2021 15:52:30 +0000 (10:52 -0500)]
qat: Address -Wunused-but-set-variable warnings

(cherry picked from commit 8fcf230c1377c4598a7aa6560ec43ff46662fbaa)

2 years agodtrace: Disable getf() as it is broken on FreeBSD
Domagoj Stolfa [Fri, 17 Dec 2021 16:01:54 +0000 (11:01 -0500)]
dtrace: Disable getf() as it is broken on FreeBSD

getf() on FreeBSD calls _sx_slock(), _sx_sunlock() and fget_locked().
Furthermore, it does not set the per-core fault flag, meaning it
usually ends up in a double fault panic once getf() does get called,
especially from fbt.

Reviewing the DTrace Toolkit + a number of other scripts scattered
around FreeBSD, I have not been able to find one use of getf(). Given
how broken the implementation currently is, we disable it until it
can be implemented properly.

Also comment out a test in aggs/tst.subr.d for getf().

Reviewed by: markj

(cherry picked from commit 30ec3138edc9d491446409910f52ccb1b158253e)

2 years agobhyve: Only snapshot initialized VirtIO queues
Vitaliy Gusev [Thu, 16 Dec 2021 16:06:08 +0000 (11:06 -0500)]
bhyve: Only snapshot initialized VirtIO queues

If the virtio device is not fully initialized, then suspend fails with:

  vi_pci_snapshot_queues: invalid address: vq->vq_desc
  Failed to snapshot virtio-rnd; ret=14

Reviewed by: jhb

(cherry picked from commit d079fc197aca951c7918276922038852167dd39f)

2 years agotwsi: use twsi_error() to handle wrong bus status when starting
Andriy Gapon [Sun, 19 Dec 2021 09:28:02 +0000 (11:28 +0200)]
twsi: use twsi_error() to handle wrong bus status when starting

(cherry picked from commit 46e0c03795443675f95db6da2195825d24a9fb7c)

2 years agonfscl: Fix must_commit handling for mirrored pNFS mounts
Rick Macklem [Sun, 12 Dec 2021 23:40:30 +0000 (15:40 -0800)]
nfscl: Fix must_commit handling for mirrored pNFS mounts

For pNFS mounts to mirrored Flexible File layout pNFS servers,
the "must_commit" component in the nfsclwritedsdorpc
structure must be checked and the "must_commit" argument passed
into nfscl_doiods() must be updated.  Technically, only writes to
the DS with a writeverf change must be redone, but since this
occurrence will be rare, the must_commit argument to nfscl_doiosd()
is set to 1, so all writes to all DSs will be redone.

This bug would affect few, since use of mirrored pNFS servers
is rare and "writeverf" rarely changes. Normally "writeverf"
only changes when a NFS server reboots.

(cherry picked from commit 24947b701d07634434b3208b0a0c970235f9d16e)

2 years agohwpmc: Add IDs for Intel Comet/Ice/Tiger/Rocketlake CPUs.
Alexander Motin [Fri, 26 Nov 2021 00:17:58 +0000 (19:17 -0500)]
hwpmc: Add IDs for Intel Comet/Ice/Tiger/Rocketlake CPUs.

MFC after: 1 month

(cherry picked from commit 913c07a04998b8cd11dc428f5d00fae7dd392244)

2 years agolibpmc: Update some x86 event definitions.
Alexander Motin [Thu, 25 Nov 2021 16:19:26 +0000 (11:19 -0500)]
libpmc: Update some x86 event definitions.

MFC after: 1 month

(cherry picked from commit 52d973f52c07b94909a6487be373c269988dc151)

2 years agogfx_fb: Fix a typo in a source code comment
Gordon Bergling [Wed, 22 Dec 2021 09:00:42 +0000 (10:00 +0100)]
gfx_fb: Fix a typo in a source code comment

- s/decriptor/descriptor/

(cherry picked from commit b5e0a70193a7a02ba611317cd1688e29002685a4)

2 years agosound(4): Fix a typo in a source code comment
Gordon Bergling [Wed, 22 Dec 2021 09:18:35 +0000 (10:18 +0100)]
sound(4): Fix a typo in a source code comment

- s/aggresively/aggressively/

(cherry picked from commit d34632a235dc4cb1b4f89e5dd570a6a53f0117ce)

2 years agommc_sim: fix setting of the mutex name
Andriy Gapon [Wed, 15 Dec 2021 11:37:59 +0000 (13:37 +0200)]
mmc_sim: fix setting of the mutex name

To quote the manual:
 The pointer passed in as name and type is saved rather than the data
 it points to.  The data pointed to must remain stable until the mutex
 is destroyed.

It seems that the type is actually copied, but the name is stored as
a pointer indeed.
mmc_cam_sim_alloc used a name stored on stack.
So, a corrupt mutex name would be reported.
For example:
  lock order reversal: (sleepable after non-sleepable)
  1st 0xd7285b20 <8A><C0><C0>P@<C1><D0>P@<C1>^D^A (aw_mmc_sim, sleep mutex) @ sys/cam/cam_xpt.c:2804

This change moves the name to struct mmc_sim.
Also, that name is used as the sim name as well.
Unused mtx_name variable is removed too.
The name buffer is reduced to 16 characters.

(cherry picked from commit 18679ab1c06575517df9df2509564dbf038d4720)
(cherry picked from commit 8eca341d9bb678f08065edd8f24c2ab32dcf8e56)

2 years agonfscl: Fix must_commit/writeverf handling for Direct I/O
Rick Macklem [Sat, 11 Dec 2021 23:00:30 +0000 (15:00 -0800)]
nfscl: Fix must_commit/writeverf handling for Direct I/O

Without this patch, the KASSERT(must_commit == 0,..) can be
triggered by the writeverf in the Direct I/O write reply changing.
This is not a situation that should cause a panic(). Correct
handling is to ignore the change in "writeverf" for Direct
I/O, since it is done with NFSWRITE_FILESYNC.

This patch modifies the semantics of the "must_commit"
argument slightly, allowing an initial value of 2 to indicate
that a change in "writeverf" should be ignored.
It also fixes the KASSERT()s.

This bug would affect few, since Direct I/O is not enabled
by default and "writeverf" rarely changes. Normally "writeverf"
only changes when a NFS server reboots, however I found the
bug when testing against a Linux 5.15.1 kernel nfsd, which
replied to a NFSWRITE_FILESYNC write with a "writeverf" of all
0x0 bytes.

(cherry picked from commit ead50c94cb604594987e6512289268891a427725)

2 years agoocs_fc: Populate subvendor and subdevice ids.
Ram Kishore Vegesna [Mon, 20 Dec 2021 12:25:13 +0000 (17:55 +0530)]
ocs_fc: Populate subvendor and subdevice ids.
Enable serialnumber reporting.

Reviewed by: mav
MFC after: 3 days

(cherry picked from commit cba757ef2a7ec2bb985fbcd67e8d616328b7209a)

ocs_fs(4): Fix some common typos in source code comments

- s/transfered/transferred/
- s/associted/associated/

MFC after: 3 days

(cherry picked from commit 16b71d98d96a3a9a2ac666440aa80f12d478959d)

2 years agolibefivar(3): efi_set_variables_supported.3 should be efi_variables_supported.3
Li-Wen Hsu [Tue, 21 Dec 2021 12:42:39 +0000 (20:42 +0800)]
libefivar(3): efi_set_variables_supported.3 should be efi_variables_supported.3

MFC after: 3 days

(cherry picked from commit 71779dddffe5e860118f42739ff8d51d181272ce)

2 years agosmist: Remove unneeded Giant from bus_dma_tag_create().
Alexander Motin [Fri, 10 Dec 2021 01:54:22 +0000 (20:54 -0500)]
smist: Remove unneeded Giant from bus_dma_tag_create().

bus_dmamap_load() call uses BUS_DMA_NOWAIT.

MFC after: 2 weeks

(cherry picked from commit a69f8104665c7356b08d81728d406c595973672c)

2 years agohpt27xx: Remove FreeBSD 9.x support including Giant.
Alexander Motin [Fri, 10 Dec 2021 01:24:29 +0000 (20:24 -0500)]
hpt27xx: Remove FreeBSD 9.x support including Giant.

MFC after: 2 weeks

(cherry picked from commit 63e0f96acecb4ca3aba778858361278177333dc1)

2 years agobusdma: Remove outdated comments about Giant.
Alexander Motin [Fri, 10 Dec 2021 03:17:54 +0000 (22:17 -0500)]
busdma: Remove outdated comments about Giant.

MFC after: 2 weeks

(cherry picked from commit 8493918868151d3d000fa11c0feb635c51702c95)

2 years agoahc: Mark sysctls with CTLFLAG_MPSAFE.
Alexander Motin [Fri, 10 Dec 2021 02:36:21 +0000 (21:36 -0500)]
ahc: Mark sysctls with CTLFLAG_MPSAFE.

MFC after: 2 weeks

(cherry picked from commit 35b2021a0adf6bd1a41930014bafbc5ee8b6369a)

2 years agoahci(4): Allow enclosure emulation without hardware.
Alexander Motin [Fri, 17 Dec 2021 20:24:56 +0000 (15:24 -0500)]
ahci(4): Allow enclosure emulation without hardware.

After 53f5ac1310e allowed SATA device mapping to enclosure slots,
it may have sense to provide enclosure device emulation even without
real hardware interface like SGPIO just for purposes of physical
device location tracking (still assuming straight cabling).

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

(cherry picked from commit 9aba757e92aaf0751c83c0ce3f18f65f864f1811)

2 years agowbwd: Mark sysctls with CTLFLAG_MPSAFE.
Alexander Motin [Fri, 10 Dec 2021 02:13:10 +0000 (21:13 -0500)]
wbwd: Mark sysctls with CTLFLAG_MPSAFE.

MFC after: 2 weeks

(cherry picked from commit fdec27ed82ea3f6406a7089e5e1ffd99bb4929e0)

2 years agohptiop: Remove Giant locking around ioctls.
Alexander Motin [Fri, 10 Dec 2021 01:35:21 +0000 (20:35 -0500)]
hptiop: Remove Giant locking around ioctls.

The methods have their own locking and don't require Giant.

MFC after: 2 weeks

(cherry picked from commit e06c67eef8faae3322c06056960562fde88fd7aa)

2 years agofxp: Mark sysctls with CTLFLAG_MPSAFE.
Alexander Motin [Fri, 10 Dec 2021 02:16:16 +0000 (21:16 -0500)]
fxp: Mark sysctls with CTLFLAG_MPSAFE.

MFC after: 2 weeks

(cherry picked from commit 35efbedc98539fa655c3fb8df146fb6f7784df57)

2 years agofxp: Remove unneeded Giant from bus_dma_tag_create().
Alexander Motin [Fri, 10 Dec 2021 01:09:48 +0000 (20:09 -0500)]
fxp: Remove unneeded Giant from bus_dma_tag_create().

All bus_dmamap_load() calls here use BUS_DMA_NOWAIT.

MFC after: 2 weeks

(cherry picked from commit 5ae7518b7b9711d54fdf3627dd052501bfab5407)

2 years agotwsi: fix handling of consecuitve write messages in transaction
Andriy Gapon [Sun, 19 Dec 2021 09:26:40 +0000 (11:26 +0200)]
twsi: fix handling of consecuitve write messages in transaction

Make sure to reset 'message_done' flag when jumping from a message to the
next one within the same interrupt handler call.  This happens only when
a write with no-stop flag message is followed by a write with no-start
flag message.
Without this fix the second message would be prematurely "completed"
without waiting for an ACK (or NACK) for its first byte and without
sending subsequent bytes (if any).

Fixes: ff1e8581 twsi: support more message combinations in transfers

(cherry picked from commit e5268c3d435e0a0f0fef64e6213504dd189272f6)

2 years agods3231: allow configuration via hints on FDT systems
Andriy Gapon [Mon, 13 Dec 2021 07:21:08 +0000 (09:21 +0200)]
ds3231: allow configuration via hints on FDT systems

(cherry picked from commit 1256067c5c575474e626e5f119f50275ea2d975e)
(cherry picked from commit b277ef3304fa97da041c191b02b2fcfb74378c75)

2 years agoCorrect type size format error in KASSERT.
Doug Moore [Thu, 16 Dec 2021 19:48:58 +0000 (13:48 -0600)]
Correct type size format error in KASSERT.
Reported by: jenkins
Fixes: 6f1c8908272f vm: Don't break vm reserv that can't meet align reqs

(cherry picked from commit f7aa44763d20d06c9ea5caf330aca02a8b107a70)

2 years agovm: Don't break vm reserv that can't meet align reqs
Doug Moore [Thu, 16 Dec 2021 18:20:56 +0000 (12:20 -0600)]
vm: Don't break vm reserv that can't meet align reqs

Function vm_reserv_test_contig has incorrectly used its alignment
and boundary parameters to find a well-positioned range of empty pages
in a reservation.  Consequently, a reservation could be broken
mistakenly when it was unable to provide a satisfactory set of pages.

Rename the function, correct the errors, and add assertions to detect
the error in case it appears again.

Reviewed by: alc, markj
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D33344

(cherry picked from commit 6f1c8908272f3c0a6631e001bd2eb50a5b69261d)

2 years agomca: Some error handling logic improvements.
Alexander Motin [Thu, 9 Dec 2021 02:06:11 +0000 (21:06 -0500)]
mca: Some error handling logic improvements.

 - Enable local MCEs on capable Intel CPUs.  It delivers exceptions
only to the affected CPU instead of global broadcast, requiring a lot
of synchronization between CPUs.  AMD always deliver MCEs locally.
 - Make MCE handler process only uncorrected errors, while CMCI and
polling only corrected.  It reduces synchronization problems between
them and is explicitly recommended by the documentation.
 - Add minimal support for uncorrected software recoverable errors
on Intel CPUs.  It allows to avoid kernel panics in case uncorrected
errors do not affect current operation, like ones found during scrub
or write.  Such errors are only logged, postponing the panic until
the corrupted data will actually be needed (that may never happen).
 - Reduce polling period from 1 hour to 5 minutes.

MFC after: 2 weeks

(cherry picked from commit 63346fef3382b0ee02366cd9799930f8dbc15a52)

2 years agoloader.efi: Do not use as frame buffer BLT-only GOPs.
Alexander Motin [Thu, 16 Dec 2021 16:44:34 +0000 (11:44 -0500)]
loader.efi: Do not use as frame buffer BLT-only GOPs.

Kernel needs physical frame buffer address and size, which Block
Transfer-only Graphics Output Protocol instances do not have.

Some recent ASUS boards like PRIME Z690M-PLUS D4 and PRIME H570-Plus
report two GOPs, out of which the second one support ConOut protocol,
that made it preferable, but is BLT-only, that made console unusable.

Discussed with: tsoome (previous version)
MFC after: 1 week

(cherry picked from commit 02732f945ed2ec2b4fd03421923720608b28a615)

2 years agonfscl: Sanity check the callback tag length
Rick Macklem [Thu, 9 Dec 2021 22:15:48 +0000 (14:15 -0800)]
nfscl: Sanity check the callback tag length

The sanity check for tag length in a callback request
was broken in two ways:

It checked for a negative value, but not a large positive
value.

It did not set taglen to -1, to indicate to the code that
it should not be used.

This patch fixes both of these issues.

PR: 260266

(cherry picked from commit d9931c25617d6625e280fda19bd9c2878e49c091)

2 years agonfscl: Check for an error return from nfsrv_getattrbits()
Rick Macklem [Thu, 9 Dec 2021 22:32:22 +0000 (14:32 -0800)]
nfscl: Check for an error return from nfsrv_getattrbits()

There were two places where the client code did not check
for a parse error return from nfsrv_getattrbits().

This patch fixes both of these cases.

PR: 260272

(cherry picked from commit ab639f2398bf7efd4dfd38cd6527e22f6e781ae9)

2 years agoOpenSSL: Do not remove symbolic links readded in 1.1.1m
Jung-uk Kim [Thu, 16 Dec 2021 14:31:46 +0000 (09:31 -0500)]
OpenSSL: Do not remove symbolic links readded in 1.1.1m

(cherry picked from commit 5c154c6b6bf7fef71b3ee457ec2e53a88b9abe24)

2 years agoe1000: fix interface capabilities management
Vincenzo Maffione [Wed, 8 Dec 2021 08:55:04 +0000 (08:55 +0000)]
e1000: fix interface capabilities management

The e1000 drivers (em, lem, igb) are currently looking at the
iflib copies of the capabilities bitvectors (scctx->isc_capabilities
and scctx->isc_capenable) rather than the ifnet ones
(ifp->if_capabilities and ifp->if_capenable). However, the latter
are the ones that are actually updated by ifconfig and that should
be used by the drivers during interface operation. The former are
set by the driver on interface attach (for iflib internal use)
and should not be used anymore by the driver.
This patch fixes the e1000 driver to use the correct bitvectors.

PR: 260068
Reviewed by: markj
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D33154

(cherry picked from commit e0f4cdba533693bb6ef9d90243acdad89605b150)

2 years agoo Fix i2c read operation for large transfers (more than 32 bytes).
Ruslan Bukin [Wed, 26 May 2021 09:55:23 +0000 (10:55 +0100)]
o Fix i2c read operation for large transfers (more than 32 bytes).

o Fix slave address setting.

This allows to read the EDID from an HDMI monitor.

(cherry picked from commit 38e7025a60b28623b5991622a6efd1b8a329ccb2)

2 years agork_i2c_fill_tx: fix a number of issues
Andriy Gapon [Wed, 15 Dec 2021 11:00:45 +0000 (13:00 +0200)]
rk_i2c_fill_tx: fix a number of issues

- maximum number of bytes that can be sent is 32, not 8;
- previous interface required callers to bump sc->msg->len in addition
  to setting sc->tx_slave_addr;
- because of the above there was an issue with writing one too many bytes
  because sc->cnt is not advanced when the slave address is written;
- the inetraction between outer and inner loops was confusing as the former
  was bounded on the number of bytes to write and the counter was
  incremented by one, but the inner loop advanced four bytes at a time;
- the return value was incorrect in the tx_slave_addr case; one call place
  had to use its own (and incorrect in some cases) notion of the write
  lenth.

All of the above issues should be fixed.
Some sanity asserts are added.
All callers use the return value to program RK_I2C_MTXCNT.
iic_msg::len no longer needs to be hacked.
A constant is added to reflect the maximum number of octets that can be
sent or received in one go (they are the same).

(cherry picked from commit c6635459510c9c03a439bc5b59fef37259d21967)
(cherry picked from commit b7bcd21d2da50364a512092cb4e75f2d53070ba6)

2 years agork_i2c_transfer: minor improvement to bit twiddling
Andriy Gapon [Wed, 15 Dec 2021 09:11:15 +0000 (11:11 +0200)]
rk_i2c_transfer: minor improvement to bit twiddling

No need to mask a uint8_t with 0xff, the mask covers the whole type.
Explcitly cast to uint32_t before bit shifting instead of relying on
the implicit promotion to signed int.

(cherry picked from commit 25e92673b54ea3b66cbaf53826cfd01df3441ea3)

2 years agork_i2c: do not hide NACK condition from consumers
Andriy Gapon [Wed, 15 Dec 2021 08:59:22 +0000 (10:59 +0200)]
rk_i2c: do not hide NACK condition from consumers

Previously the driver would happily talk to addresses with no device
returning some garbage for reads and sending bits into the void for writes.

(cherry picked from commit 4501b0707198e7ad1da792639a8b164f9380b95d)

2 years agork_i2c: keep sending bytes until all bytes are sent
Andriy Gapon [Wed, 15 Dec 2021 08:51:24 +0000 (10:51 +0200)]
rk_i2c: keep sending bytes until all bytes are sent

Previously the code would decalre the transfer complete after sending
first 31 bytes (plus the slave address) of a larger I2C write transfer.

That was tested using a large write to an EEPROM with 32-byte write page
size and a 2-byte address type.  Such a transaction needed to send 34
bytes, 2 bytes for an offset and 32 bytes of actual data.

(cherry picked from commit 7dc8a0e5dff4ad4c9c10442bef5228a91a98d5d6)

2 years agork_i2c_transfer: fix off-by-one in check for last message
Andriy Gapon [Wed, 15 Dec 2021 08:44:43 +0000 (10:44 +0200)]
rk_i2c_transfer: fix off-by-one in check for last message

This also fixes an access beyond msgs array.

(cherry picked from commit b6a2aba959c8b30d740c653c96c01fb90a3073f7)

2 years agork_i2c_drain_rx: remove useless arithmetic manipulations
Andriy Gapon [Wed, 15 Dec 2021 08:42:23 +0000 (10:42 +0200)]
rk_i2c_drain_rx: remove useless arithmetic manipulations

When i % 4 == 0 the result of (i / 4) * 4 is always i.

(cherry picked from commit ede576831b818c78d23a9600932e13e47b8fd745)

2 years agork_i2c: consistently treat booleans as such
Andriy Gapon [Wed, 15 Dec 2021 08:40:22 +0000 (10:40 +0200)]
rk_i2c: consistently treat booleans as such

(cherry picked from commit 1da04ae8fb5b7a1f1d9e52b87af1aaf756d28d4b)

2 years agork_i2c_transfer: use iicbus error codes instead of generic ones
Andriy Gapon [Wed, 15 Dec 2021 08:38:24 +0000 (10:38 +0200)]
rk_i2c_transfer: use iicbus error codes instead of generic ones

(cherry picked from commit 552503aca975ccab1b1f67f95f627e279db5826f)

2 years agork_i2c: remove write-only softc field
Andriy Gapon [Wed, 15 Dec 2021 08:37:04 +0000 (10:37 +0200)]
rk_i2c: remove write-only softc field

(cherry picked from commit 5f863d7e1319afe32d18e505c26acaacfcae0db7)

2 years agoipfilter: MSN RPC proxy is not complete
Cy Schubert [Thu, 16 Dec 2021 00:08:11 +0000 (16:08 -0800)]
ipfilter: MSN RPC proxy is not complete

The MSN RPC proxy is incomplete and does not do any address
translation. Remove it.

(cherry picked from commit c610426c4deeaa80ad86d8177e7c0b7680104dc7)

2 years agoipfilter: ipf_dstlist is a kernel source file
Cy Schubert [Wed, 15 Dec 2021 21:50:38 +0000 (13:50 -0800)]
ipfilter: ipf_dstlist is a kernel source file

Remove duplicate ipf_dstlist.* files. They live in sys/.

(cherry picked from commit 7aec934fffde73f7d22450b18e04436aa77b1148)

2 years agoipfilter: Fix struct ifnet pointer type
Cy Schubert [Sun, 12 Dec 2021 23:57:36 +0000 (15:57 -0800)]
ipfilter: Fix struct ifnet pointer type

The fr_info struct contains a summary of a packet. One of its fields
is a pointer to the ifnet struct the packet arrived on. It is pointed
to by a void* because ipfilter supports multiple O/Ses. Unfortunately
this makes it difficult it examine with DTrace. Defining fin_ifp as a
pointer to an ifnet struct makes the struct it points to using a DTrace
script possible.

(cherry picked from commit 8f19f3d31a7224c502c36dd16f1321b802e4da60)

2 years agoipfilter fil.c: Fix two typos in comments
Cy Schubert [Wed, 15 Dec 2021 03:44:58 +0000 (19:44 -0800)]
ipfilter fil.c: Fix two typos in comments

(cherry picked from commit 7835925aa420ae3046b5f13899a0c208741d0ad4)