Commit Graph

141188 Commits

Author SHA1 Message Date
Wei Hu
aa108bc7c5 mana: Add RX fencing
RX fencing allows the driver to know that any prior change to the RQs has
finished, e.g. when the RQs are disabled/enabled or the hashkey/indirection
table are changed, RX fencing is required.

Remove the previous 'sleep' workaround and add the real support for
RX fencing as the PF driver supports the MANA_FENCE_RQ request now (any
old PF driver not supporting the request won't be used in production).

MFC after:	2 weeks
Sponsored by:	Microsoft
2022-01-14 07:34:39 +00:00
Justin Hibbits
4873653519 powerpc64le: enable ISA_206_ATOMICS option
powerpc64le requires at minimum POWER8 hardware, so ISA 2.06 atomic
instructions are always available.

This isn't so for powerpc64 (BE), so isn't enabled by default there.
2022-01-13 21:47:05 -06:00
Justin Hibbits
b5d227b0b2 powerpc: Add atomic_testand_{set,clear}_{int,long}
Add machine-optimized implementations for the following:
* atomic_testandset_int
* atomic_testandclear_int
* atomic_testandset_long
* atomic_testandclear_long

This fixes the build with ISA_206_ATOMICS enabled.
Add the associated atomic_testandset_32, atomic_testandclear_32, so
that ice(4) can potentially build.
2022-01-13 21:46:52 -06:00
Alexander Motin
dd694648ff cam: Fix type of elm_idx in struct enc_element.
It is a global element index, so it may need more than one byte.
For now it is only a cosmetics, since the field is never read.

MFC after:	2 weeks
2022-01-13 21:43:34 -05:00
John Baldwin
8c22fe46a5 ia32_signal.h: Drop #ifdef's for old compat structures.
Requested by:	kib
2022-01-13 17:44:15 -08:00
John Baldwin
9142bb0791 ia32: Rename a struct ia32_sigcontext3 -> struct ia32_osigcontext.
Fixes:		bd7630ef61 ia32: Sync signal context type names with i386.
2022-01-13 17:41:28 -08:00
John Baldwin
d61effd38b Use G_ELI_IVKEYLEN as the size of IV in the user test code.
IVs are not the size of keys as a general case.  Most often they are
the size of a single block.

Reviewed by:	imp
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D33885
2022-01-13 17:22:06 -08:00
John Baldwin
be887b3e6c Move struct freebsd4_ucontext to sys/i386/include/ucontext.h.
Requested by:	kib
Reviewed by:	brooks, imp, kib
Sponsored by:	The University of Cambridge, Google Inc.
Differential Revision:	https://reviews.freebsd.org/D33886
2022-01-13 17:17:43 -08:00
John Baldwin
bd7630ef61 ia32: Sync signal context type names with i386.
- Use ia32_freebsd4_* instead of ia32_*4.
- Use ia32_o* instead of ia32_*3.

Reviewed by:	brooks, imp, kib
Sponsored by:	The University of Cambridge, Google Inc.
Differential Revision:	https://reviews.freebsd.org/D33882
2022-01-13 17:17:21 -08:00
John Baldwin
efdb03e9a9 Rename struct sigframe4 to struct freebsd4_sigframe.
Reviewed by:	brooks, imp, kib
Sponsored by:	The University of Cambridge, Google Inc.
Differential Revision:	https://reviews.freebsd.org/D33881
2022-01-13 17:16:50 -08:00
John Baldwin
71ec998a1c Rename struct mcontext4 to struct freebsd4_mcontext.
This matches the recent renaming of struct freebsd4_ucontext.

Reviewed by:	brooks, imp, kib
Sponsored by:	The University of Cambridge, Google Inc.
Differential Revision:	https://reviews.freebsd.org/D33880
2022-01-13 17:11:03 -08:00
Austin Zhang
e1ef6c0ef2 atrtc: reads Century field from FADT table
The ACPI spec describes the FADT->Century field as:

    The RTC CMOS RAM index to the century of data value (hundred and
    thousand year decimals).  If this field contains a zero, then the
    RTC centenary feature is not supported.  If this field has a non-zero
    value, then this field contains an index into RTC RAM space that
    OSPM can use to program the centenary field.

Use this field to decide whether to program the CENTURY register
of the CMOS RTC device.

Reviewed by:	akumar3@isilon.com, dab, vangyzen
MFC after:	1 week
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D33667

MFC after:	1 week
Sponsored by:	Dell EMC Isilon
2022-01-13 11:24:00 -06:00
Warner Losh
272e4f5384 cam: Fix wiring fence post error
If the last matching device entry partially matched in camperiphunit,
but then hit a continue case, we'd mistakenly think we had a match on
that entry. This lead to a number of problems downstream (usually a
belief that we had a duplicate wiring hint because unit = 0 is the
default). Fix this by using a for loop that does the assignment before
the loop termination test.

Sponsored by:		Netflix
Reviewed by:		jhb
Differential Revision:	https://reviews.freebsd.org/D33873
2022-01-13 15:22:56 -07:00
Alexander Motin
2e19fae49f sesutil: Avoid setting reserved bits.
Weird side of SES specification is that some bits have different
meaning or semantics in status and control pages.  This patch fixes
non-zero writes into reserved fields, that caused errors on some
enclosures when trying to control locate/fault LEDs, keeping other
bits unchanged.

MFC after:	2 weeks
Sposonred by:	iXsystems, Inc.
2022-01-13 13:57:35 -05:00
Gleb Smirnoff
1d41a49404 tcp_usr_connect: report actual error code when stack requests drop 2022-01-13 10:32:41 -08:00
Ryan Stone
3284f4925f LRO: Don't merge ACK and non-ACK packets together
LRO was willing to merge ACK and non-ACK packets together.  This
can cause incorrect th_ack values to be reported up the stack.
While non-ACKs are quite unlikely to appear in practice, LRO's
behaviour is against the spec.  Make LRO unwilling to merge
packets with different TH_ACK flag values in order to fix the
issue.

Found by: Sysunit test
Differential Revision:	https://reviews.freebsd.org/D33775
Reviewed by: rrs
2022-01-13 11:17:58 -05:00
Ryan Stone
24fe6643da LRO: Fix lost packets when merging 1 payload with an ACK
To check if it needed to regenerate a packet's header before
sending it up the stack, LRO was checking if more than one payload
had been merged into the packet.  This failed in the case where
a single payload was merged with one or more pure ACKs.  This
results in lost ACKs.

Fix this by precisely tracking whether header regeneration is
required instead of using an incorrect heuristic.

Found with: Sysunit test
Differential Revision:	https://reviews.freebsd.org/D33774
Reviewed by: rrs
2022-01-13 11:17:48 -05:00
Roger Pau Monné
7d06c761c8 x86/madt: allow Xen guest to use x2APIC mode
The old bogus Xen versions that would deliver a GPF when writing to
the LAPIC MSR are likely retired, so it's safe to enable x2APIC
unconditionally now if available.

Tested by: avg
Reviewed by: kib
Sponsored by: Citrix Systems R&D
Differential revision: https://reviews.freebsd.org/D33877
2022-01-13 17:15:24 +01:00
Kenneth D. Merry
ca2a7262df Free UMA zones when a pass(4) instance goes away.
If the UMA zones are not freed, we get warnings about re-using the
sysctl variables associated with the UMA zones, and we're leaking
the other memory associated with the zone structures.  e.g.:

sysctl_warn_reuse: can't re-use a leaf (vm.uma.pass44.size)!
sysctl_warn_reuse: can't re-use a leaf (vm.uma.pass44.flags)!
sysctl_warn_reuse: can't re-use a leaf (vm.uma.pass44.bucket_size)!
sysctl_warn_reuse: can't re-use a leaf (vm.uma.pass44.bucket_size_max)!
sysctl_warn_reuse: can't re-use a leaf (vm.uma.pass44.keg.name)!
sysctl_warn_reuse: can't re-use a leaf (vm.uma.pass44.keg.rsize)!
sysctl_warn_reuse: can't re-use a leaf (vm.uma.pass44.keg.ppera)!
sysctl_warn_reuse: can't re-use a leaf (vm.uma.pass44.keg.ipers)!

Also, correctly clear the PASS_FLAG_ZONE_INPROG flag in
passcreatezone().  The way it was previously done, it would have
had set the flag and cleared all other flags that were set at
that point.

MFC after:	1 week
Sponsored by:	Spectra Logic
2022-01-13 10:54:56 -05:00
Roger Pau Monné
ca46f3289d xen: use an hypercall for shutdown and reboot
When running as a Xen guest it's easier to use an hypercall in order
to do power management operations (power off, power cycle). Do this
for all supported guest types (HVM and PVH). Note that for HVM the
power operation could also be done using ACPI, but there's no reason
to differentiate between PVH and HVM.

While there fix the shutdown handler to properly differentiate between
power cycle and power off requests.

Reported by: Freddy DISSAUX
MFC: 1 week
Sponsored by: Citrix Systems R&D
2022-01-13 16:54:30 +01:00
Wei Hu
027d0c1c04 mana: fix misc minor handlding issues when error happens.
- In mana_create_txq(), if test fails we must free some resources
  as in all the other handling paths of this function.
- In mana_gd_read_cqe(), add warning log in case of CQE read
  overflow, instead of failing silently.
- Fix error handling in mana_create_rxq() when
  cq->gdma_id >= gc->max_num_cqs.
- In mana_init_port(), use the correct port index rather than 0.
- In mana_hwc_create_wq(), If allocating the DMA buffer fails,
  mana_hwc_destroy_wq was called without previously storing the
  pointer to the queue. In order to avoid leaking the pointer to
  the queue, store it as soon as it is allocated.

MFC after:	2 weeks
Sponsored by:	Microsoft
2022-01-13 07:22:21 +00:00
Wei Hu
623918a198 mana: Improve the HWC error handling
Currently when the HWC creation fails, the error handling is flawed,
e.g. if mana_hwc_create_channel() -> mana_hwc_establish_channel() fails,
the resources acquired in mana_hwc_init_queues() is not released.

Enhance mana_hwc_destroy_channel() to do the proper cleanup work and
call it accordingly.

MFC after:	2 weeks
Sponsored by:	Microsoft
2022-01-13 06:08:43 +00:00
Eric Joyner
0e8181c012
ixl(4): Remove unused function declaration
Signed-off-by: Eric Joyner <erj@FreeBSD.org>

Sponsored by:	Intel Corporation
2022-01-12 15:37:42 -08:00
Brooks Davis
0910a41ef3 Revert "syscallarg_t: Add a type for system call arguments"
Missed issues in truss on at least armv7 and powerpcspe need to be
resolved before recommit.

This reverts commit 3889fb8af0.
This reverts commit 1544e0f5d1.
2022-01-12 23:29:20 +00:00
Brooks Davis
3889fb8af0 sysent: regen for syscallarg_t 2022-01-12 22:51:25 +00:00
Brooks Davis
1544e0f5d1 syscallarg_t: Add a type for system call arguments
This more clearly differentiates system call arguments from integer
registers and return values. On current architectures it has no effect,
but on architectures where pointers are not integers (CHERI) and may
not even share registers (CHERI-MIPS) it is necessiary to differentiate
between system call arguments (syscallarg_t) and integer register values
(register_t).

Obtained from:	CheriBSD

Reviewed by:	imp, kib
Differential Revision:	https://reviews.freebsd.org/D33780
2022-01-12 22:51:25 +00:00
Cy Schubert
896a015319 ipfilter: Fixup comment
Fix comment documenting checksum block in ip_nat.c. Fastforward doesn't
perform checksum.

MFC after:	1 week
2022-01-12 13:03:46 -08:00
Cy Schubert
2a6465245f ipfilter: Fix IP header checksums post ftp proxy
Don't assume checksums will be calculated later in fastforward.

MFC after:	1 week
2022-01-12 12:58:05 -08:00
Cy Schubert
6af38b34e4 ipfilter: Fix whitespace errors
MFC after:	3 days
2022-01-12 12:58:05 -08:00
Cy Schubert
4b5c0c9b81 ipfilter: Correct function description
Correct the parameters descriptions for ipf_fix_outcksum and
ipf_fix_incksum.

MFC after:	3 days
2022-01-12 12:58:05 -08:00
Cy Schubert
835a0e2f0d ipfilter: inline is superfluous for an extrn function
Remove superfluous inline for function defined as extrn.

MFC after:	3 days
2022-01-12 12:58:05 -08:00
Cy Schubert
f98cc177f7 ipfilter: Remove redundant else if
Combine two else ifs using an or.

MFC after:	3 days
2022-01-12 12:58:05 -08:00
Colin Percival
c2705ceaeb x86: Speed up clock calibration
Prior to this commit, the TSC and local APIC frequencies were calibrated
at boot time by measuring the clocks before and after a one-second sleep.
This was simple and effective, but had the disadvantage of *requiring a
one-second sleep*.

Rather than making two clock measurements (before and after sleeping) we
now perform many measurements; and rather than simply subtracting the
starting count from the ending count, we calculate a best-fit regression
between the target clock and the reference clock (for which the current
best available timecounter is used). While we do this, we keep track
of an estimate of the uncertainty in the regression slope (aka. the ratio
of clock speeds), and stop measuring when we believe the uncertainty is
less than 1 PPM.

In order to avoid the risk of aliasing resulting from the data-gathering
loop synchronizing with (a multiple of) the frequency of the reference
clock, we add some additional spinning depending upon the iteration number.

For numerical stability and simplicity of implementation, we make use of
floating-point arithmetic for the statistical calculations.

On the author's Dell laptop, this reduces the time spent in calibration
from 2000 ms to 29 ms; on an EC2 c5.xlarge instance, it is reduced from
2000 ms to 2.5 ms.

Reviewed by:	bde (previous version), kib
MFC after:	1 month
Sponsored by:	https://www.patreon.com/cperciva
Differential Revision:	https://reviews.freebsd.org/D33802
2022-01-12 12:34:07 -08:00
Doug Moore
84e2ae64c5 vm_reserv: use enhanced bitstring for popmaps
vm_reserv.c uses its own bitstring implemenation for popmaps. Using
the bitstring_t type from a standard header eliminates the code
duplication, allows some bit-at-a-time operations to be replaced with
more efficient bitstring range operations, and, in
vm_reserv_test_contig, allows bit_ffc_area_at to more efficiently
search for a big-enough set of consecutive zero-bits.

Make bitstring changes improve the vm_reserv code.  Define a bit_ntest
method to test whether a range of bits is all set, or all clear.
Define bit_ff_at and bit_ff_area_at to implement the ffs and ffc
versions with a parameter to choose between set- and clear- bits.
Improve the area_at implementation.  Modify the bit_nset and
bit_nclear implementations to allow code optimization in the cases
when start or end are multiples of _BITSTR_BITS.

Add a few new cases to bitstring_test.

Discussed with:	alc
Reviewed by:	markj
Tested by:	pho (earlier version)
Differential Revision:	https://reviews.freebsd.org/D33312
2022-01-12 11:03:53 -06:00
Andrew Turner
85b7c566f1 Add arm64 pointer authentication support
Pointer authentication allows userspace to add instructions to insert
a Pointer Authentication Code (PAC) into a register based on an address
and modifier and check if the PAC is correct. If the check fails it will
either return an invalid address or fault to the kernel.

As many of these instructions are a NOP when disabled and in earlier
revisions of the architecture this can be used, for example, to sign
the return address before pushing it to the stack making Return-oriented
programming (ROP) attack more difficult on hardware that supports them.

The kernel manages five 128 bit signing keys: 2 instruction keys, 2 data
keys, and a generic key. The instructions then use one of these when
signing the registers. Instructions that use the first four store the
PAC in the register being signed, however the instructions that use the
generic key store the PAC in a separate register.

Currently all userspace threads share all the keys within a process
with a new set of userspace keys being generated when executing a new
process. This means a forked child will share its keys with its parent
until it calls an appropriate exec system call.

In the kernel we allow the use of one of the instruction keys, the ia
key. This will be used to sign return addresses in function calls.
Unlike userspace each kernel thread has its own randomly generated.

Thread0 has a static key as does the early code on secondary CPUs.
This should be safe as there is minimal user interaction with these
threads, however we could generate random keys when the Armv8.5
Random number generation instructions are present.

Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D31261
2022-01-12 15:27:17 +00:00
Andrew Turner
a3cea15680 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
2022-01-12 13:53:19 +00:00
Andriy Gapon
dfb1c97ab9 mmc_da: remove write-only local variables
MFC after:	1 week
2022-01-12 09:17:35 +02:00
Andriy Gapon
60b7d5a24a mmc_da: use MMC_SECTOR_SIZE constant in place of literals
Suggested by:	manu
MFC after:	2 weeks
2022-01-12 09:14:36 +02:00
Andriy Gapon
44682688f0 mmc_da: implement d_dump method, sddadump
sddadump has been derived from sddastart.

mmc_sim interface has grown a new method, cam_poll, to support polled
operation.

mmc_sim code has been changed to provide a sim_poll hook only if the
controller implements the new method.  The hooks is implemented in terms
of the new mmc_sim_cam_poll method.
Additionally, in-progress CCB-s now have CAM_REQ_INPROG status to
satisfy xpt_pollwait().

mmc_sim_cam_poll method has been implemented in dwmmc host controller.

Reviewed by:	manu, mav, imp
MFC after:	2 weeks
Relnotes:	perhaps
Differential Revision:	https://reviews.freebsd.org/D33843
2022-01-12 09:02:47 +02:00
Konstantin Belousov
a24afbb4e6 Ignore debugger-injected signals left after detaching
PR:	261010
Reported by:	Martin Simmons <martin@lispworks.com>
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D33787
2022-01-12 07:33:30 +02:00
Jason A. Harmening
39a2dc44f8 unionfs: allow vnode lock to be held shared during VOP_OPEN
do_execve() will hold the vnode lock shared when it calls VOP_OPEN(),
but unionfs_open() requires the lock to be held exclusive to
correctly synchronize node status updates.  This requirement is
asserted in unionfs_get_node_status().

Change unionfs_open() to temporarily upgrade the lock as is already
done in unionfs_close().  Related to this, fix various cases throughout
unionfs in which vnodes are not checked for reclamation following lock
upgrades that may have temporarily dropped the lock.  Also fix another
related issue in which unionfs_lock() can incorrectly add LK_NOWAIT
during a downgrade operation, which trips a lockmgr assertion.

Reviewed by:	kib (prior version), markj, pho
Reported by:	pho
Differential Revision: https://reviews.freebsd.org/D33729
2022-01-11 18:44:03 -08:00
Warner Losh
8bb9cd271e stand: Fix KASSERT use
Explicitly include sys/systm.h to pull in KASSERT.

Sponsored by:		Netflix
Reviewed by:		jhb
Differential Revision:	https://reviews.freebsd.org/D33855
2022-01-11 16:43:18 -07:00
John Baldwin
5022c68732 cryptosoft: Use multi-block encrypt/decrypt for ChaCha20-Poly1305.
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D33758
2022-01-11 14:21:31 -08:00
John Baldwin
f8580fcaa1 cryptosoft: Use multi-block encrypt/decrypt for AES-CCM.
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D33757
2022-01-11 14:21:00 -08:00
John Baldwin
a221a8f4a0 cryptosoft: Use multi-block encrypt/decrypt for AES-GCM.
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D33756
2022-01-11 14:20:32 -08:00
John Baldwin
69e533c3ff swcr_encdec: Rename blks to blksz.
This better reflects the variables purpose and matches other functions
in this file.

Requested by:	markj
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D33755
2022-01-11 14:20:10 -08:00
John Baldwin
cfb7b942be cryptosoft: Use multi-block encrypt/decrypt for non-AEAD ciphers.
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D33531
2022-01-11 14:18:57 -08:00
John Baldwin
d7f0b3ce6d crypto: Re-add encrypt/decrypt_multi hooks to enc_xform.
These callbacks allow multiple contiguous blocks to be manipulated in
a single call.  Note that any trailing partial block for a stream
cipher must still be passed to encrypt/decrypt_last.

While here, document the setkey and reinit hooks and reorder the hooks
in 'struct enc_xform' to better reflect the life cycle.

Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D33529
2022-01-11 14:17:41 -08:00
John Baldwin
8f35841f1f crypto: Add support for the XChaCha20-Poly1305 AEAD cipher.
This cipher is a wrapper around the ChaCha20-Poly1305 AEAD cipher
which accepts a larger nonce.  Part of the nonce is used along with
the key as an input to HChaCha20 to generate a derived key used for
ChaCha20-Poly1305.

This cipher is used by WireGuard.

Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D33523
2022-01-11 14:16:41 -08:00
John Baldwin
7df4c50643 crypto.ko: Add hchacha20 from libsodium.
This was added to 'device crypto' in the kernel in
bbb7a2c7c3 but was missing from the
module.

Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D33522
2022-01-11 14:15:51 -08:00
Hans Petter Selasky
75d20a5e38 rtwn(4): Add new USB ID.
Submitted by:	Wensi <supdrewin@outlook.com>
PR:		261098
MFC after:	1 week
Sponsored by:	NVIDIA Networking
2022-01-11 21:19:53 +01:00
Rick Macklem
a91a57846b nfsd: Do not accept audit/alarm ACEs for the NFSv4 server
The UFS and ZFS file systems only support Allow/Deny ACEs
in the NFSv4 ACLs.  This patch does not allow the server
to parse Audit/Alarm ACEs.  The NFSv4 client is still
allowed to pase Audit/Alarm ACEs, since non-FreeBSD NFSv4
servers may use them.

This patch should not have a significant effect, since the
UFS and ZFS file systems will not handle these ACEs anyhow.
It simply serves as an additional "safety belt" for the
NFSv4 server.

MFC after:	2 weeks
2022-01-11 09:40:07 -08:00
Andrew Turner
2754373f9a Use ${MACHINE} for the kernel modeule ldscript
For consistancy with the kernel linker script also use ${MACHINE} for
finding the kernel module linker script. As we currently only use this
for amd64 and i386 this is a no-op, but I'm planning on using this with
arm64 where ${MACHINE} != ${MACHINE_ARCH}.

Reviewed by:	markj, kib, imp
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D33841
2022-01-11 16:58:31 +00:00
Rick Macklem
5da9b3b011 Revert "nfscommon: Add arguments for support of the dacl attribute"
This reverts commit 0fa074b53e.

I now see that the implementation of the "dacl" operation
requires that the NFSv4 server to "automatic inheritance"
and I do not plan on doing this.  As such, this patch is
harmless, but unneeded.
2022-01-11 08:30:50 -08:00
Rick Macklem
b1f80dfac9 Revert "nfscommon: Return NFSERR_ATTRNOTSUPP for AUDIT/ALARM ACEs"
This reverts commit f10dc28ec2.

The client should still be able to getfacl
audit and alarm ACEs, for non-FreeBSD NFSv4 servers.

A patch that only disables audit/alarm for the server
side will be committed to replace this patch.
2022-01-11 08:26:42 -08:00
Vitaliy Gusev
c72e914cf1 vmm: vlapic resume can eat 100% CPU by vlapic_callout_handler
Suspend/Resume of Win10 leads that CPU0 is busy on handling interrupts.

Win10 does not use LAPIC timer to often and in most cases, and I see it
is disabled by writing 0 to Initial Count Register (for Timer).

During resume, restart timer only for enabled LAPIC and enabled timer
for that LAPIC.

Reviewed by:	markj
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D33448
2022-01-11 09:27:45 -05:00
Mark Johnston
c4a25e0713 vm_pageout: Group sysctl variables together with sysctl definitions
Fix some style bugs while here.  No functional change intended.

Reviewed by:	alc, kib
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D33811
2022-01-11 09:27:45 -05:00
Mark Johnston
43b3b8e52d swap_pager: uma_zcreate() doesn't fail
Remove always-false checks for UMA zone creation failure.  No functional
change intended.

Reviewed by:	alc, kib
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D33809
2022-01-11 09:27:45 -05:00
Andriy Gapon
94f4afd772 rk805 / rk808: re-add system poweroff support
This was lost by accident in 98c60dc31f.

Reviewed by:	manu
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D33844
2022-01-11 16:22:36 +02:00
Andriy Gapon
ee900888c4 dwwdt: make it actually useful
Flip dwwdt_prevent_restart to false.  What's the use of a watchdog if it
does not restart a hung system?

Add a knob for panic-ing on the first timeout, resetting on the second
one.  This can be useful if interrupts can still work, otherwise a reset
recovers a system without any aid for debugging the hang.

The change also doubles the timeout that's programmed into the hardware.
The previous version of the code always had the interrupt on the first
timeout enabled, but it took no action on it.  Only the second timeout
could be configured to reset the system.  So, the hardware timeout was
set to a half of the user requested timeout.  But now,we can take a
corrective action on the first timeout, so we use the user requested
timeout.

While here, define boolean sysctl-s as such.

Reviewed by:	manu
MFC after:	3 weeks
Differential Revision:	https://reviews.freebsd.org/D33534
2022-01-11 15:56:07 +02:00
Andriy Gapon
7fdf0e8835 dtrace: add a knob to control maximum size of principal buffers
We had a hardcoded limit of 1/128-th of physical memory that was further
subdivided between all CPUs as principal buffers are allocated on the
per-CPU basis.  Actually, the buffers could use up 1/64-th of the
memmory because with the default switch policy there are two buffers per
CPU.

This commit allows to change that limit.

Note that the discussed limit is per dtrace command invocation.
The idea is to limit the size of a single malloc(9) call, not the total
memory size used by DTrace buffers.

Reviewed by:	markj
MFC after:	3 weeks
Differential Revision:	https://reviews.freebsd.org/D33648
2022-01-11 15:47:50 +02:00
Andriy Gapon
75bc7150f4 add and use defintions for ATA power modes
Those can be returned by CHECK POWER MODE command (0xe5).
Note that some of the definitions duplicate definitions for Extended
Power Conditions.

MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D33646
2022-01-11 15:41:38 +02:00
Wojciech Macek
776c34f646 ip_mroute: remove unused variables
Sponsored by:	Stormshield
Obtained from:	Semihalf
2022-01-11 13:06:22 +01:00
Andrew Turner
e7961ccd9f Remove Arm barriers for pre-armv6 CPUs
Remove the macros that define the Arm barriers on Armv5 and earlier. We
don't support these CPUs.

Reviewed by:	imp
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D33807
2022-01-11 11:22:29 +00:00
Andrew Turner
ac795a774c Remove old arm CPU macros
The _ARM_ARCH_* and _HAVE_ARMv*_INSTRUCTIONS macros are FreeBSD
specific. Remove them as they are unused in the base system.

Reviewed by:	imp
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D33806
2022-01-11 11:22:29 +00:00
Wojciech Macek
2e72208b6c ip_mroute: do not call epoch_waitwhen lock is taken
mrouter_done is called with RAW IP lock taken. Some annoying
printfs are visible on the console if INVARIANTS option is enabled.

Provide atomic-based mechanism which counts enters and exits from/to
critical section in ip_input and ip_output.
Before de-initialization of function pointers ensure (with busy-wait)
that mrouter de-initialization is visible to all readers and that we don't
remove pointers (like ip_mforward etc.) in the middle of packet processing.
2022-01-11 11:19:32 +01:00
Wojciech Macek
68f28dd1cc ip_mroute: do not sleep when lock is taken
Kthread initialization calls uma_alloc which can sleep.
Modify the code to use deferred work instead.
2022-01-11 11:19:32 +01:00
Kristof Provost
751d4c7b87 pf: postpone clearing of struct pf_pdesc
Postpone zeroing out pd until after the PFI_IFLAG_SKIP/M_SKIP_FIREWALL
checks. We don't need it until then, and it saves us a few CPU cycles in
some cases.
This isn't expected to make a measurable performance change though.

Reviewed by:	mjg, glebius
Pointed out by:	markj
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D33815
2022-01-11 10:10:23 +01:00
Kristof Provost
ecc393594d pf: remove PF_TAG_GENERATED
It's never set, so we can remove both the check for it and the
definition.

Reviewed by:	mjg, glebius
Pointed out by:	markj
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D33814
2022-01-11 10:09:22 +01:00
Vladimir Kondratyev
ed6417cd8d Bump __FreeBSD_version for LinuxKPI changes 2022-01-11 10:36:14 +03:00
Bjoern A. Zeeb
bec766282f LinuxKPI: 802.11 fix locking in lkpi_stop_hw_scan()
In lkpi_stop_hw_scan() we have to unlock around cancelling the
hardware scan and an msleep to wait for the confirmation that the
scan ended.  Otherwise we are sleeping with the non-sleepable
net80211 com lock held.  At the same time we need to hold the lhw
lock for the msleep().
This lock change got lost in the refactoring of lkpi_iv_newstate().

Reported by:	ambrisko, delphij
PR:		261075
MFC after:	3 days
Sponsored by:	The FreeBSD Foundation
2022-01-10 22:29:23 +00:00
Navdeep Parhar
d0ff9b029c cxgbe(4): Fix regression in previous attempt to fix FEC selection.
Fixes:	f3c2987f2f
MFC after:	3 days
Sponsored by:	Chelsio Communications
2022-01-10 14:04:56 -08:00
Navdeep Parhar
cdd7fe04cb cxgbe(4): Do not ignore the return value of ifmedia_ioctl.
This ensures that the driver reports an error instead of failing
silently when an invalid media is requested.

Reported by:	Suhas Lokesha @ Chelsio
MFC after:	1 week
Sponsored by:	Chelsio Communications
2022-01-10 13:05:01 -08:00
Navdeep Parhar
94e6b3fee1 cxgbe(4): Fix build warning for LINT-NOIP.
MFC after:	1 week
Sponsored by:	Chelsio Communications
2022-01-10 12:35:43 -08:00
Navdeep Parhar
39d5cbdc1b cxgbe(4): Fix "set but not used [-Wunused-but-set-variable]" warnings.
MFC after:	1 week
Sponsored by:	Chelsio Communications
2022-01-10 12:15:12 -08:00
Navdeep Parhar
6792568fe2 cxgb(4): Fix "set but not used [-Wunused-but-set-variable]" warnings.
MFC after:	1 week
Sponsored by:	Chelsio Communications
2022-01-10 12:15:12 -08:00
Vladimir Kondratyev
7356f661e8 LinuxKPI: Add sort() wrapper.
swap parameter is not supported as it is rarely used in Linux kernel
and its implementation will add some preprocessor spaghetti to qsort.

Required by drm-kmod.

MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D33675
2022-01-10 22:49:38 +03:00
Vladimir Kondratyev
64dab63f3b LinuxKPI: Use negative bit field size to trigger BUILD_BUG_ON_ZERO
compile time assertion on non-NULL pointers. Tests conducted show that
_Static_assert, negative array size method and current code does not
handle pointers well enough. Bit field method solves this problem.

This change is derrived from Linux implementation of BUILD_BUG_ON_ZERO.

MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D33674
2022-01-10 22:49:38 +03:00
Vladimir Kondratyev
307f78f3ed LinuxKPI: Constantly use _LINUXKPI_ prefix in include guards
MFC after:	1 week
Reviewed by:	bz, emaste, hselasky, manu
Differential Revision:	https://reviews.freebsd.org/D33562
2022-01-10 22:49:38 +03:00
Vladimir Kondratyev
98b129783c LinuxKPI: Import MTRR support functions from drm-kmod
They are superseded by PAT and mostly useless nowadays but still can be
used on Pentium III/IV era processors. Unlike drm-kmod version, this one
ignores MTRR if PAT is available that fixes confusing "Failed to add WC
MTRR for [0xXXXX-0xYYYY]: 22; performance may suffer" message often
appearing during drm-kmod initialization process.

MFC after:	1 week
Reviewed by:	hselasky, manu
Differential Revision:	https://reviews.freebsd.org/D33561
2022-01-10 22:49:38 +03:00
Vladimir Kondratyev
1456816425 LinuxKPI: Import linux/ratelimit.h
Required by drm-kmod.

Obtained from:	OpenBSD
MFC after:	1 week
Reviewed by:	manu
Differential Revision:	https://reviews.freebsd.org/D33560
2022-01-10 22:49:38 +03:00
Vladimir Kondratyev
f9c8b5880d LinuxKPI: Add linux/capability.h header
Required by drm-kmod.

Obtained from:	DragonflyBSD
MFC after:	1 week
Reviewed by:	hselasky, manu

Differential Revision:	https://reviews.freebsd.org/D33559
2022-01-10 22:49:38 +03:00
Vladimir Kondratyev
2e194c20c1 LinuxKPI: Add readx_poll_timeout wrapper
Required by drm-kmod 5.7

MFC after:	1 week
Reviewed by:	hselasky
Differential Revision:	https://reviews.freebsd.org/D33307
2022-01-10 22:49:38 +03:00
Vladimir Kondratyev
f3ddb82d9a LinuxKPI: Add static_cpu_has() implementation
static_cpu_has returns true if CPU supports requested feature.

Obtained from:	OpenBSD
MFC after:	1 week
Reviewed by:	hselasky, manu
Differential Revision:	https://reviews.freebsd.org/D33301
2022-01-10 22:49:38 +03:00
Vladimir Kondratyev
89bb7f9bda LinuxKPI: Implement efi_enabled(EFI_BOOT)
efi_enabled(EFI_BOOT) returns true if machine was booted from EFI
Used by drm-kmod and some unported drm drivers like hyperv

MFC after:	1 week
Reviewed by:	hselasky, manu
Differential Revision:	https://reviews.freebsd.org/D33300
2022-01-10 22:49:38 +03:00
Vladimir Kondratyev
882f8d059c LinuxKPI: Import linux/jump_label.h
Required by drm-kmod

Obtained from:	DragonflyBSD
Differential Revision:	https://reviews.freebsd.org/D33299
2022-01-10 22:49:38 +03:00
Vladimir Kondratyev
0b1244bd79 LinuxKPI: Move kfree_async() functionality in to kfree()
Obsolete it usage but keep for a while for drm-kmod 5.4 compatibility

MFC after:	1 week
Reviewed by:	hselasky, manu
Differential Revision:	https://reviews.freebsd.org/D33298
2022-01-10 22:49:37 +03:00
Vladimir Kondratyev
35235d5ff6 LinuxKPI: Add stdarg.h proxy header
To reduce amount of drm-kmod patching

MFC after:	1 week
Reviewed by:	hselasky, manu
Differential Revision:	https://reviews.freebsd.org/D33297
2022-01-10 22:49:37 +03:00
Vladimir Kondratyev
f1a7639a16 LinuxKPI: Add some typical header pollution
To reduce amount of drm-kmod patching

MFC after:	1 week
Reviewed by:	hselasky, manu
Differential Revision:	https://reviews.freebsd.org/D33297
2022-01-10 22:49:37 +03:00
Vladimir Kondratyev
2fb5be7978 LinuxKPI: Implement smp_*mb barriers with atomic_thread_fence_*
for x86 and move them to asm/barrier.h

MFC after:	1 week
Reviewed by:	bz, hselasky, manu
Differential Revision:	https://reviews.freebsd.org/D33296
2022-01-10 22:49:37 +03:00
Vladimir Kondratyev
68fcdba38b LinuxKPI: Make lockdep*_pin_lock macros useable for drm-kmod
Summary:
- Add dummy struct pin_cookie definition;
- Convert lockdep_pin_lock macro to function;
- Fix 'unused variable' compile-time errors;

MFC after:	1 week
Reviewers:	hselasky, manu
Differential Revision:	https://reviews.freebsd.org/D33295
2022-01-10 22:49:37 +03:00
Vladimir Kondratyev
7ec6cbf1d2 LinuxKPI: Convert schedule() to inlined function
to prevent name clashing with drm-kmod

MFC after:	1 week
Reviewed by:	hselasky, manu
Differential Revision:	https://reviews.freebsd.org/D33294
2022-01-10 22:49:37 +03:00
Vladimir Kondratyev
e705066cd8 LinuxKPI: Add support for XA_FLAGS_ALLOC1 xarray flag
XA_FLAGS_ALLOC1 causes allocation of xarray entries starting at 1

Required by drm-kmod 5.7

MFC after:	1 week
Reviewed by:	hselasky, manu
Differential Revision:	https://reviews.freebsd.org/D33293
2022-01-10 22:49:37 +03:00
Vladimir Kondratyev
04d42cb453 LinuxKPI: Implement default sysfs kobject attribute operations
Required by drm-kmod 5.7

MFC after:	1 week
Reviewed by:	hselasky
Differential Revision:	https://reviews.freebsd.org/D33292
2022-01-10 22:49:37 +03:00
Vladimir Kondratyev
c427456fd5 LinuxKPI: Implement kstrtoull
Required by drm-kmod 5.7

MFC after:	1 week
Reviewed by:	hselasky, manu
Differential Revision:	https://reviews.freebsd.org/D33291
2022-01-10 22:49:37 +03:00
Vladimir Kondratyev
bc923d93df LinuxKPI: Implement dev_driver_string()
Required by drm-kmod 5.7

MFC after:	1 week
Reviewed by:	bz, hselasky, manu
Differential Revision:	https://reviews.freebsd.org/D33290
2022-01-10 22:49:37 +03:00
Vladimir Kondratyev
db562aeff7 LinuxKPI: Implement clflush_cache_range()
Required by drm-kmod 5.7

MFC after:	1 week
Reviewed by:	hselasky, manu
Differential Revision:	https://reviews.freebsd.org/D33289
2022-01-10 22:49:36 +03:00
Vladimir Kondratyev
9a79e08ae7 LinuxKPI: Add clflush argument type conversion wrapper
to reduce amount of source patching in drm-kmod.

MFC after:	1 week
Reviewed by:	manu
Differential Revision:	https://reviews.freebsd.org/D33288
2022-01-10 22:49:36 +03:00
Vladimir Kondratyev
dbc920bd9a LinuxKPI: Implement interval_tree
Required by drm-kmod

MFC after:	1 week
Reviewed by:	hselasky, manu
Differential Revision: https://reviews.freebsd.org/D32869
2022-01-10 22:49:36 +03:00
Vladimir Kondratyev
dd52763387 LinuxKPI: Import some linux/rbtree.h functions from OpenBSD
Required by drm-kmod

Obtained from:	OpenBSD
MFC after:	1 week
2022-01-10 22:49:36 +03:00
Ruslan Makhmatkhanov
312ba38a9b LinuxKPI: 802.11 correctly spell queues
PR:		261078
MFC after:	3 days
Sponsored by:	The FreeBSD Foundation
2022-01-10 18:08:17 +00:00
Mitchell Horne
d72e944812 riscv: gdb(4) support
Add the MD portion required for the gdb stub.

Reviewed by:	jhb (earlier version)
Discussed with:	jrtc27
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D33734
2022-01-10 13:40:12 -04:00
Edward Tomasz Napierala
1866c766d2 linux: Improve debugging by recognizing TIOCGPTPEER
Sponsored By:	EPSRC
2022-01-10 15:36:11 +00:00
Alexander Motin
618d49f5ca Revert "iflib: Relax timer period from 0.5 to 0.5-0.75s."
I've noticed relations between iflib_timer() vs ixl_admin_timer().
Both scheduled at the same 2Hz rate, but the second is rescheduling
the first each time, so if the first get any slower, it won't be
executed at all.  Revert this until deeper investigation.

This reverts commit 90bc1cf657.
2022-01-10 09:40:38 -05:00
Jessica Clarke
e74c7ffcb1 hwpmc: Fix amd/arm64/armv7/uncore sampling overflow race
If a counter more than overflows just as we read it on switch out then,
if using sampling mode, we will negate this small value to give a huge
reload count, and if we later switch back in that context we will
validate that value against pm_reloadcount and panic an INVARIANTS
kernel with:

  panic: [pmc,1470] pmcval outside of expected range cpu=2 ri=16 pmcval=fffff292 pm_reloadcount=10000

or similar. Presumably in a non-INVARIANTS kernel we will instead just
use the provided value as the reload count, which would lead to the
overflow not happing for a very long time (e.g. 78 minutes for a 48-bit
counter incrementing at an averate rate of 1GHz).

Instead, clamp the reload count to 0 (which corresponds precisely to the
value we would compute if it had just overflowed and no more), which
will result in hwpmc using the full original reload count again. This is
the approach used by core for Intel (for both fixed and programmable
counters).

As part of this, armv7 and arm64 are made conceptually simpler; rather
than skipping modifying the overflow count for sampling mode counters so
it's always kept as ~0, those special cases are removed so it's always
applicable and the concatentation of it and the hardware counter can
always be viewed as a 64-bit counter, which also makes them look more
like other architectures.

Whilst here, fix an instance of UB (shifting a 1 into the sign bit) for
amd in its sign-extension code.

Reviewed by:	andrew, mhorne, kib
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D33654
2022-01-10 14:30:05 +00:00
Andrew Turner
78c347d9f3 Fix a typo in an arm64 comment
This was pointed out by markj in the review, but I missed it and forgot
to fix before pushing.

Reported by:	markj
Sponsored by:	The FreeBSD Foundation
2022-01-10 14:08:15 +00:00
Wei Hu
ed65c80a34 Mana: report OS info to PF driver
The PF driver might use the OS info for statistical purposes.

MFC after:	2 weeks
Sponsored by:	Microsoft
2022-01-10 13:32:30 +00:00
Andrew Turner
77402d2834 Move instructions into the arm64 exception vectors
We have 32 instructions in each exception vector on arm64. Previously
only one was used to branch to the handler function. We can split the
start of these functions and move some of the instructions into the
vectors.

Reviewed by:	kib, markj
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D33751
2022-01-10 10:51:16 +00:00
Doug Moore
ae13829ddc vm_addr_ok: add power2 invariant check
With INVARIANTS defined, have vm_addr_align_ok and vm_addr_bound_ok
panic when passed an alignment/boundary parameter that is not a power
of two.

Reviewed by:	alc
Suggested by:	kib, se
Differential Revision:	https://reviews.freebsd.org/D33725
2022-01-10 01:17:25 -06:00
Alexander Motin
90bc1cf657 iflib: Relax timer period from 0.5 to 0.5-0.75s.
While there switch it from hardclock ticks to milliseconds.

MFC after:	2 weeks
2022-01-09 20:32:50 -05:00
Alexander Motin
cb1f5d1136 Reduce minimum idle hardclock rate from 2Hz to 1Hz.
On idle 80-thread system it allows to improve package-level idle state
residency and so power consumption by several percent.

MFC after:	2 weeks
2022-01-09 19:25:56 -05:00
Kirk McKusick
7ef56fb049 Avoid unnecessary setting of UFS flag requesting fsck(8) be run.
When the kernel is requested to mount a filesystem with a bad superblock
check hash, it would set the flag in the superblock requesting that the
fsck(8) program be run. The flag is only written to disk as part of a
superblock update. Since the superblock always has its check hash updated
when it is written to disk, the problem for which the flag has been set
will no longer exist. Hence, it is counter-productive to set the flag
as it will just cause an unnecessary run of fsck if it ever gets written.

Sponsored by: Netflix
2022-01-09 16:18:28 -08:00
Robert Wing
174d86a01b tws: fix "set but not used" in the tws driver
With __diagused, these warnings were still emitted since INVARIANTS was
defined but TWS_DEBUG was not.

Fixes:  a21f086a33 ("Fix "set but not used" in the tws driver")
Differential Revision:	https://reviews.freebsd.org/D33784
2022-01-09 14:28:08 -09:00
Alexander Motin
3455c738ac nfsd: Reduce callouts rate.
Before this callouts were scheduled twice a seconds even if nfsd was
never used.  This reduces the rate to ~1Hz and only after nfsd first
started.

MFC after:	2 weeks
2022-01-09 13:14:23 -05:00
Bjoern A. Zeeb
51b461b3db LinuxKPI: 802.11 update compat code for driver updates
Add more (dummy in case of HE) defines, structs, functions and another
mac80211 function pointer needed to update and support recent drivers.

MFC after:	3 days
2022-01-09 18:08:47 +00:00
Warner Losh
85056a56f3 cam: Include more statuses as errors for CAM_IO_STATS
Tag more status return values as an error for the
I/O. CAM_SCSI_STATUS_ERROR is returned for medium errors, for example,
but the counts weren't increased. The added errors all indicate a
problem with the device request.

Sponsored by:		Netflix
PR:			260257
Feedback from:		ken
Reviewed by:		asomers
Differential Revision:	https://reviews.freebsd.org/D33783
2022-01-09 10:13:05 -07:00
Bjoern A. Zeeb
2fb0569f1f LinuxKPI: bitfields add more *replace_bits()
Add or extend the already existing *_replace_bits() implementations
using macros as we do for the other parts in the file for
le<n>p_replace_bits(), u<n>p_replace_bits(), and _u<n>_replace_bits().

MFC after:	3 days
Reviewed by:	hselasky
Differential Revision: https://reviews.freebsd.org/D33799
2022-01-09 14:39:19 +00:00
Bjoern A. Zeeb
deb9bfbd5b LinuxKPI: add hex2bin()
Add a hex2bin() implementation needed by a driver's debugfs code.

MFC after:	3 days
Reviewed by:	hselasky
Differential Revision: https://reviews.freebsd.org/D33798
2022-01-09 14:36:28 +00:00
Bjoern A. Zeeb
e200809190 LinuxKPI / iwlwifi: fix spelling of constants
Fix the spelling of IEEE80211_HE_PHY_CAP9_NOMINAL_PKT_PADDING_*
(was "NOMIMAL").  The original version came from iwlwifi
in iwlwifi-next.  Other drivers (from wireless-testing) already
use the correct spelling and need this change in LinuxKPI.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
2022-01-09 02:21:05 +00:00
Robert Wing
eb18708ec8 syncache: accept packet with no SA when TCP_MD5SIG is set
When TCP_MD5SIG is set on a socket, all packets are dropped that don't
contain an MD5 signature. Relax this behavior to accept a non-signed
packet when a security association doesn't exist with the peer.

This is useful when a listen socket set with TCP_MD5SIG wants to handle
connections protected with and without MD5 signatures.

Reviewed by:	bz (previous version)
Sponsored by:   nepustil.net
Sponsored by:   Klara Inc.
Differential Revision:	https://reviews.freebsd.org/D33227
2022-01-08 16:32:14 -09:00
Robert Wing
91d388119a tcpmd5: return ENOENT when security association not found
Return ENOENT from tcp_ipsec_input() when a security association is not
found. This allows callers of TCP_MD5_INPUT() to differentiate between a
security association not found and receiving a bad signature.

Also return ENOENT from tcp_ipsec_output() for consistency.

Reviewed by:	ae
Sponsored by:   nepustil.net
Sponsored by:   Klara Inc.
Differential Revision:	https://reviews.freebsd.org/D33226
2022-01-08 16:31:17 -09:00
Bjoern A. Zeeb
086be6a809 LinuxKPI: 802.11 handle IEEE80211_CONF_IDLE better
We never initialized hw->conf.flags for IEEE80211_CONF_IDLE but
on set_channel we would clear it and announce a change.
This lead to a problem that drivers may do some work every time
which was not needed and may lead to unexpected behaviour (for no
better driver code).

Properly initialize conf.flags with IEEE80211_CONF_IDLE.
Factor out the toggling into a function and clear IDLE while
sw scanning and when associated and set again when scan ends
or we are bouncing out of assoc.

MFC after:	3 days
2022-01-09 00:59:50 +00:00
Bjoern A. Zeeb
4ddc0079ea LinuxKPI: ip.h add #include
Also include netinet/in.h so that in_addr in known for ip.h.
Found by compiling a new piece of code which complained.

MFC after:	3 days
2022-01-09 00:57:13 +00:00
Konstantin Belousov
15964f1cb3 amd64 pmap: preset A and M bits for pmap_qenter() and pmap_kenter() mappings
This removes one or two atomic update of the pte on access. Also it
makes the pte constant during its lifecycle.

Reviewed by:	alc, markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D33778
2022-01-08 06:34:18 +02:00
Konstantin Belousov
720a892ac6 amd64 pmap: simplify vtopte() and vtopde()
Pre-calculate masks and page table/page directory bases, for LA48 and
LA57 cases, trading a conditional for the memory accesses.

This shaves 672 bytes of .text, by the cost of 32 .data bytes.  Note
that eliminated code contained one conditional, and several costly
movabs instructions, which are traded by two memory fetches per
vtop{t,d}e() inlines.

Reviewed by:	markj
Discussed with:	alc
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D33776
2022-01-08 06:34:18 +02:00
Konstantin Belousov
aaaa4fb54e msdosfs: use mntfs vnode for pm_devvp
to prevent races with devfs VCHR vnode reclamation, same as it was
done for UFS.

Reported by:	pho
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D33721
2022-01-08 06:21:58 +02:00
Konstantin Belousov
41e85eeab9 msdosfs: on integrity error, fire a task to remount filesystem to ro
In collaboration with:	pho
Reviewed by:	markj, mckusick
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D33721
2022-01-08 06:20:48 +02:00
Konstantin Belousov
b2e4b63584 msdosfs: add msdosfs_integrity_error()
A function to remount the filesystem from rw to ro on integrity error.
The work is performed in taskqueue to allow the call to be done from
almost arbitrary context where erronous state was detected.

Tested by:	pho
Reviewed by:	markj, mckusick
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D33721
2022-01-08 06:20:48 +02:00
Konstantin Belousov
4a4b059a97 Add vfs_remount_ro()
a helper to remount filesystem from rw to ro.

Tested by:	pho
Reviewed by:	markj, mckusick
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D33721
2022-01-08 05:41:44 +02:00
Konstantin Belousov
ba2c98389b msdosfs: sanity check sector count from BPB
We use sector count to size the FAT inuse bitset.  If sector count is
corrupted, kernel might be tricked into doing unbound allocation.
Ensure that the sector count does not exceed the actual volume size.

In collaboration with:	pho
Reviewed by:	markj, mckusick
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D33721
2022-01-08 05:41:44 +02:00
Konstantin Belousov
65990b68a2 msdosfs: clusterfree() is used only in error handling cases
Change its return type to void, because its result is ignored in both
call sites.  Remove oldcnp argument as well, it is NULL always.

Suggested and reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D33721
2022-01-08 05:41:44 +02:00
Konstantin Belousov
aec97963cd msdosfs: do no allow lookup to return vdp except for dot lookups
In collaboaration with:	pho
Reviewed by:	markj, mckusick
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D33721
2022-01-08 05:41:44 +02:00
Konstantin Belousov
1319c433f4 msdosfs: handle a case when non-dot lookup returned dvp
This means that filesystem is corrupted, there is a loop.

In collaboration with:	pho
Reviewed by:	markj, mckusick
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D33721
2022-01-08 05:41:44 +02:00
Konstantin Belousov
2c9a1c22c3 msdosfs: take inusemap inconsistency as an error, not invariants violation
In other words, stop silently accepting freeing free cluster in
non-debug kernels, but return the error to the caller.  Modify callers
to handle errors from usemap_free().

In collaboration with:	pho
Reviewed by:	markj, mckusick
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D33721
2022-01-08 05:41:44 +02:00
Konstantin Belousov
595ed4d767 msdosfs: handle inconsistently hashed denodes
It is possible, on the corrupted msdosfs volume, to have file which
denode inode number does not match the one calculated using directory
cluster.  Instead of asserting the condition as impossible, handle it
and return error, after reclaiming the aliased vnode.

In collaboration with:	pho
Reviewed by:	markj, mckusick
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D33721
2022-01-08 05:41:44 +02:00
Konstantin Belousov
9f4073d446 geom label msdosfs: sanity check BPB before using it for io request
It must be greater than zero, and be multiple of the device block size.

In collaboration with:	pho
Reviewed by:	markj, mckusick
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D33721
2022-01-08 05:41:44 +02:00
Alexander Motin
1849bc5f3f mps/mpr: Relax doorbell polling precision.
It does not matter how often do we check firmware for crashes.

MFC after:	2 weeks
2022-01-07 21:34:49 -05:00
Alexander Motin
135c269d87 Fix build. Sorry.
MFC after:	2 weeks
2022-01-07 14:33:51 -05:00
Alexander Motin
f4d499fd67 CTL: Relax callouts precisions.
MFC after:	2 weeks
2022-01-07 14:30:44 -05:00
Alexander Motin
b3c9b6060f nvme: Do not rearm timeout for commands without one.
Admin queues almost always have several ASYNC_EVENT_REQUEST outstanding.
They have no timeouts, but their presence in qpair->outstanding_tr caused
useless timeout callout rearming twice a second.

While there, relax timeout callout period from 0.5s to 0.5-1s to improve
aggregation.  Command timeouts are measured in seconds, so we don't need
to be precise here.

Reviewed by:	imp
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D33781
2022-01-07 12:59:16 -05:00
Alexander Motin
0e5c50bf60 cam: Relax callouts precisions.
On large systems even relatively rare callouts may fire many times
per second.  This should allow them to aggregate better, since we do
not require any precision when polling for media change, etc.

MFC after:	2 weeks
2022-01-07 12:59:16 -05:00
Warner Losh
d6c0538dae ddb: Remove SOFTWARE_SSTEP support
It was needed for mips only, and only kinda sorta worked for mips. It
can be brought back if we grow another architecture that need it.

Sponsored by:		Netflix
2022-01-07 09:25:33 -07:00
Warner Losh
1d85ab6b86 wbwd: Move set but not used variable test under notyet
Sponsored by:		Netflix
2022-01-07 09:23:00 -07:00
Warner Losh
746e31e418 Remove mips dtrace.
Remove mips dtrace code. It's no longer needed.

Sponsored by:		Netflix
2022-01-07 09:00:56 -07:00
Warner Losh
47796d47ec powerpc/aim: ifdef DDB pmap debugging functions
INVARIANTS and DDB can be enabled independently.

Submitted by: Sterling Jensen
Pull Request: https://github.com/freebsd/freebsd-src/pull/566
2022-01-07 08:56:57 -07:00
Mitchell Horne
153b6271a7 Fix 'make cscope' with ALL_ARCH defined
The sys/mips directory has been removed.
2022-01-07 11:53:52 -04:00
Hans Petter Selasky
2891a28052 rtwn(4): Add new USB ID.
Submitted by:	arved@
PR:		260952
MFC after:	1 week
Sponsored by:	NVIDIA Networking
2022-01-07 14:02:30 +01:00
Hans Petter Selasky
34bedcee3c uchcom(4): Add new USB ID.
Submitted by:	darius@dons.net.au
PR:		260783
MFC after:	1 week
Sponsored by:	NVIDIA Networking
2022-01-07 14:02:30 +01:00
Rick Macklem
e4df1036f6 nfscl: Always invalidate buffers for append writes
kib@ reported a problem which was resolved by
reverting commit 867c27c23a, which changed the NFS
client to use direct RPCs to the server for
IO_APPEND writes.  He also spotted that the
code only invalidated buffer cache buffers
when they were marked NMODIFIED (had been
written into).

This patch modifies the NFS VOP_WRITE() to
always invalidate the buffer cache buffers
and pages for the file when IO_APPEND is
specified.  It also includes some cleanup
suggested by kib@.

Reported by:	kib
Tested by:	kib
Reviewed by:	kib
MFC after:	10 weeks
2022-01-06 14:18:36 -08:00
Ryan Stone
5adea417d4 Fix ifa refcount leak in ifa_ifwithnet()
In 4f6c66cc9c, ifa_ifwithnet() was changed to no longer
ifa_ref() the returned ifaddr, and instead the caller was required
to stay in the net_epoch for as long as they wanted the ifaddr
to remain valid.  However, this missed the case where an AF_LINK
lookup would call ifaddr_byindex(), which still does ifa_ref()
the ifaddr.  This would cause a refcount leak.

Fix this by inlining the relevant parts of ifaddr_byindex() here,
with the ifa_ref() call removed.  This also avoids an unnecessary
entry and exit from the net_epoch for this case.

I've audited all in-tree consumers of ifa_ifwithnet() that could
possibly perform an AF_LINK lookup and confirmed that none of them
will expect the ifaddr to have a reference that they need to
release.

MFC after: 2 months
Sponsored by: Dell Inc
Differential Revision:	https://reviews.freebsd.org/D28705
Reviewed by: melifaro
2022-01-06 15:04:24 -05:00