Commit graph

292225 commits

Author SHA1 Message Date
Souradeep Chakrabarti 2b887687ed Hyper-V: TLB flush enlightment using hypercall
Currently FreeBSD uses IPI based TLB flushing for remote
TLB flushing. Hyper-V allows hypercalls to flush local and
remote TLB. The use of Hyper-V hypercalls gives significant
performance improvement in TLB operations.

This patch set during test has shown near to 40 percent
TLB performance improvement.

Also this patch adds rep hypercall implementation as well.

Reviewed by:	whu, kib
Tested by:	whu
Authored-by:	Souradeep Chakrabarti <schakrabarti@microsoft.com>
Co-Authored-by:	Erni Sri Satya Vennela <ernis@microsoft.com>
MFC after:	1 week
Sponsored by:	Microsoft
Differential Revision:	https://reviews.freebsd.org/D45521
2024-06-07 07:56:07 +00:00
Pau Amma 21faf821a3 ifconfig(8): wordsmith -G and -g descriptions
Remove spurious ".Ar groupname".
Add missing full stops.
While there, tweak word order for better grammar.

MFC after: 3 days

Reviewed by:	Alexander Ziaee, Mina Galić, allanjude, imp
Differential Revision:	https://reviews.freebsd.org/D45092
2024-06-06 15:48:39 -06:00
Dapeng Gao 7cae020b9c Simplify signal handling code in libthr by removing use of SYS_sigreturn
The use of SYS_sigreturn is unnecessary here.

If handle_signal is called when a signal is delivered, it can just
return normally back to sigcode which will call sigreturn anyway.

In case handle_signal is called by check_deferred_signal, using
setcontext is better than SYS_sigreturn because that is the correct
system call to pair with the earlier getcontext.

Reviewed by:	imp, kib
Differential Revision:	https://reviews.freebsd.org/D44893
2024-06-06 15:48:39 -06:00
Warner Losh c0c066f86d config: Remove redundant code
since errx is marked dead2, we don't need this.

Noticed by:		jrtc27
Sponsored by:		Netflix
2024-06-06 15:48:38 -06:00
John Baldwin b0e7358bf8 cryptocheck: Don't treat OpenSSL errors as fatal
Abort the current test but keep running additional tests if OpenSSL
reports an error during a test.  This matches the behavior for other
tests such as an error from OCF.

Reviewed by:	markj
Sponsored by:	AFRL, DARPA
Differential Revision:	https://reviews.freebsd.org/D45279
2024-06-06 14:48:38 -07:00
John Baldwin a2c88e0d47 git-arc: Use a helper function to fetch boolean config variables
Requested by:	markj
Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D45104
2024-06-06 14:45:30 -07:00
Vladimir Kondratyev db42bd1f71 LinuxKPI: Convert Linux integer types to ISO C99 in linux/kstrtox.h
Sponsored by:	Serenity Cyber Security, LLC
MFC after:	1 week
Reviewed by:	bz, emaste
Differential Revision:	https://reviews.freebsd.org/D45465
2024-06-06 23:42:07 +03:00
Vladimir Kondratyev d207a2dee3 LinuxKPI: Add kstrtoll to linux/kstrtox.h
kstrtoll converts a string to a long long.

Sponsored by:	Serenity Cyber Security, LLC
MFC after:	1 week
Reviewed by:	bz, emaste
Differential Revision:	https://reviews.freebsd.org/D45455
2024-06-06 23:42:07 +03:00
Vladimir Kondratyev a97f3a9ec9 LinuxKPI: Move kstrto* functions to linux/kstrtox.h
from linux/kernel.h to match Linux and
allow direct linux/kstrtox.h inclusion.

Sponsored by:	Serenity Cyber Security, LLC
MFC after:	1 week
Reviewed by:	bz
Differential Revision:	https://reviews.freebsd.org/D45454
2024-06-06 23:42:07 +03:00
Vladimir Kondratyev afc450fac9 LinuxKPI: Add abs_diff to linux/math.h
It returns absolute value of the difference between the arguments.

Add LinuxKPI version check as the macro was moved from drm-kmod to
linux/math.h in Linux kernel commit 46f12960aad (6.6 timeframe).

Sponsored by:	Serenity Cyber Security, LLC
MFC after:	1 week
Reviewed by:	bz, emaste
Differential Revision:	https://reviews.freebsd.org/D45453
2024-06-06 23:42:07 +03:00
Vladimir Kondratyev 588064e658 LinuxKPI: Move linux/math.h content out of linux/kernel.h
To match Linux and allow direct linux/math.h inclusion.

Sponsored by:	Serenity Cyber Security, LLC
MFC after:	1 week
Reviewed by:	bz
Differential Revision:	https://reviews.freebsd.org/D45452
2024-06-06 23:42:07 +03:00
Vladimir Kondratyev 07c7c41ca1 LinuxKPI: Add min_not_zero() to linux/minmax.h
It returns the minimum that is not zero, except both equals to zero.

Sponsored by:	Serenity Cyber Security, LLC
MFC after:	1 week
Reviewed by:	bz, emaste, ssaxena
Differential Revision:	https://reviews.freebsd.org/D45450
Differential Revision:	https://reviews.freebsd.org/D45451
2024-06-06 23:42:06 +03:00
Vladimir Kondratyev f79474c4e3 LinuxKPI: Move linux/minmax.h content out of linux/kernel.h
To match Linux and allow direct linux/minmax.h inclusion.

Sponsored by:	Serenity Cyber Security, LLC
MFC after:	1 week
Reviewed by:	bz
Differential Revision:	https://reviews.freebsd.org/D45449
2024-06-06 23:42:06 +03:00
Vladimir Kondratyev cb8bfc4db8 LinuxKPI: Move page_address definition from linux/gfp.h to linux/mm.h
To match Linux. Some future changes may depend on proper location.

Sponsored by:	Serenity Cyber Security, LLC
MFC after:	1 week
Reviewed by:	bz, emaste
Differential Revision:	https://reviews.freebsd.org/D45448
2024-06-06 23:42:06 +03:00
Austin Shafer 613723bac2 linuxkpi: Allow ida_destroy and idr_destroy to be called multiple times
This fixes some weird behavior triggered by nvidia-drm.ko: some DRM
cleanup functions will be called multiple times, leading to a double
free. drm_mode_config_cleanup will be called twice, causing ida_destroy
to be called twice. Although calling the cleanup twice doesn't seem
very clean, on Linux this seems to be permissable as it handles it
just fine. Not doing these checks causes mutex panics and double frees.

In order to preserve this behavior this change checks if the objects
have already been destroyed and bails if so. This fixes the panic seen
when unloading the nvidia-drm driver.

MFC after:	1 week
Reviewed by:	bz, manu
Differential revision:	https://reviews.freebsd.org/D44865
2024-06-06 23:42:06 +03:00
Alvin Chen 21f4cf5ccf LinuxKPI: lockdep_assert: wrong 'cond' used in WARN_ON MACRO
'cond' in WARN_ON need be bracketed,
otherwise it is wrong for multiple conditions.

Reviewed by:	wulf
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D44604
2024-06-06 23:42:06 +03:00
Kristof Provost f042e15154 pf: add sctp multihome probe points
Add probe points to allow us to probe when we add or remove multihome addresses.

Example use:
	pf:sctp:multihome:add
	{
		printf("Add tag %x address %x", arg0,
		    ((struct pf_sctp_source *)arg1)->addr.v4.s_addr);
	}

	pf:sctp:multihome:remove
	{
		printf("Remove tag %x address %x", arg0,
		    ((struct pf_sctp_source *)arg2)->addr.v4.s_addr);
	}

MFC after:	1 week
Sponsored by:	Orange Business Services
2024-06-06 20:46:19 +02:00
Kristof Provost 8ed5170c66 pf tests: test setting and retrieving timeout values 2024-06-06 20:46:19 +02:00
Kristof Provost 30bad751e8 pf: convert DIOCGETTIMEOUT/DIOCSETTIMEOUT to netlink 2024-06-06 20:46:18 +02:00
Doug Moore 2c10bacdf4 rangeset: add next() iteration
Add a method rangeset_next to find the first range that starts at or
after a given value. Use it to rewrite pmap_pkru_same and
pmap_bti_same to avoid walking a page at a time over pages in no
range.

Reviewed by:	andrew, kib
Differential Revision:	https://reviews.freebsd.org/D45511
2024-06-06 13:42:31 -05:00
Ryan Libby 1b13e36fcc vm_page_insert: use pctrie combined insert/lookup
This reduces work done under vm_page_insert for large objects.

Reviewed by:	alc, dougm, markj
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D45486
2024-06-06 10:26:50 -07:00
Ryan Libby 7658d1532c vm_radix: define vm_radix_insert_lookup_lt and use in vm_page_rename
Use the new pctrie combined lookup/insert.  This is an easy application
of the new facility.  There are other places where we do this for pages
that may need more plumbing to use combined lookup/insert.

Reviewed by:	kib (previous version), dougm, markj
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D45396
2024-06-06 10:26:50 -07:00
Cosimo Cecchi 4472fd66d0 lam: fail on I/O errors
I/O errors should be reported; however lam currently does not
disambiguate between EOF because end-of-file was reached and EOF because
an I/O error occurred.
This commit changes lam to exit with EX_IOERR when an I/O error occurs.

Reviewed by:	imp, allanjude
Sponsored by:	Apple Inc.
Differential Revision:	https://reviews.freebsd.org/D45437
2024-06-06 17:24:15 +00:00
Alan Somers 60107d23d8 ctladm.8: fix several errors in the "port" section
* Document the "-d" option.
* Add the "-c" and "-r" options to the summary.
* Correct the list of required options.
* Clarify that the "-t" option is only for use with "-o", "-w", and "-W"
* Replace references to the nonexistent "-n" with "-p".

Also, fix a few related error strings in the ctladm command.

MFC after:	2 weeks
Sponsored by:	Axcient
Reviewed by:	jhb
Differential Revision: https://reviews.freebsd.org/D45503
2024-06-06 11:22:06 -06:00
Cosimo Cecchi 7dd39ef4e0 comm: close a race condition when comm is fed from stdin
If one of the files has ended, we won't show the column, but we still
need to drain the file pointer to avoid potentially hitting a pipe
failure.

This commit moves the NULL offset checks inside show() so that getline()
and ferror() are still called on fp.

Reviewed by:	allanjude
Sponsored by:	Apple Inc.
Differential Revision:	https://reviews.freebsd.org/D45440
2024-06-06 17:04:38 +00:00
Cosimo Cecchi 63f5c101a1 comm: flush stdout for error checking prior to exiting
UNIX conformance wants utilities to catch any errors when doing I/O, as
opposed to relying on the implicit flush upon exit.
comm currently does not do that.
This commit adds handling of I/O errors on stdout prior to exit.

Reviewed by:	imp, allanjude
Sponsored by:	Apple Inc.
Differential Revision:	https://reviews.freebsd.org/D45439
2024-06-06 17:04:37 +00:00
Maxime Thiebaut b5b90ff984 u3g: Add support for SIM7600G
Signed-off-by:	Maxime Thiebaut <maxime+freebsd@thiebaut.dev>
Reviewed by:	kp
2024-06-06 17:02:15 +02:00
Andreas Kempe 230efeda08 libusbhid: add missing include guards
PR:		265136
2024-06-06 10:09:05 -04:00
Kristof Provost dc3ee89c86 pfctl: fix possible out-of-bounds read
Tags in $10 (filter_opts) are not guaranteed to be the maximum possible
tag length, so memcpy() can end up reading outside of the allocated
buffer.

Use strlcpy() instead.

Reported by:	CheriBSD
Event:		Kitchener-Waterloo Hackathon 202406
2024-06-06 15:45:31 +02:00
Kristof Provost 8f04209d37 pf: simplify pf_addrcpy() and pf_match_addr()
Use the v4/v6 union members rather than the uint32_t ones.
Export IN_ARE_MASKED_ADDR_EQUAL() in in_var.h and use it (and its IPv6
equivalent) for masked comparisons rather than hand-rolled code.

Event:		Kitchener-Waterloo Hackathon 202406
2024-06-06 15:45:31 +02:00
Kristof Provost f0829825fb netlink: pass the correct arguments for SIOCDIFADDR and SIOCDIFADDR_IN6
These take struct ifreq and struct in6_ifreq respectively. Passing struct
in_aliasreq or struct in6_aliasreq means we're supplying a shorter object than
expected. While this doesn't actively break things on most architectures other
than CHERI it is still wrong.

Reported by:	CheriBSD
Event:		Kitchener-Waterloo Hackathon 202406
2024-06-06 15:45:30 +02:00
Kristof Provost 8ca12190bf pf: remove incorrect SUNION2PF() macro
It casts in_addr to pf_addr, which is smaller, so this isn't quite right.
Replace it with a function that will only read the actual address.

Reported by:	CheriBSD
Event:		Kitchener-Waterloo Hackathon 202406
2024-06-06 15:45:30 +02:00
Chandrakanth patil 8d3c3b5242 mpi3mr: Track IO per target counter during queue poll with local variable
Reviewed by:            imp
Approved by:            imp
Differential revision:  https://reviews.freebsd.org/D44494
2024-06-06 10:39:16 +00:00
Chandrakanth patil 3f3a15543a mpi3mr: Divert large WriteSame IOs to firmware if unmap and ndob bits are set
Firmware advertises the transfer lenght for writesame commands to driver during init.
So for any writesame IOs with ndob and unmap bit set and transfer lengh is greater
than the max write same length specified by the firmware, then direct those commands
to firmware instead of hardware otherwise hardware will break.

Reviewed by:            imp
Approved by:            imp
Differential revision:  https://reviews.freebsd.org/D44452
2024-06-06 10:39:15 +00:00
Chandrakanth patil df595fc43e mpi3mr: driver version update to 8.10.0.1.0
Reviewed by:            imp
Approved by:            imp
Differential revision:  https://reviews.freebsd.org/D44430
2024-06-06 10:39:15 +00:00
Chandrakanth patil 945c3ce49e mpi3mr: copyright year update to 2024
Reviewed by:            imp
Approved by:            imp
Differential revision:  https://reviews.freebsd.org/D44429
2024-06-06 10:39:15 +00:00
Chandrakanth patil baabb91934 mpi3mr: mpi headers update to latest
Reviewed by:            imp
Approved by:            imp
Differential revision:  https://reviews.freebsd.org/D44428
2024-06-06 10:39:15 +00:00
Chandrakanth patil 3012fa8fae mpi3mr: Adding FreeBSD OS Type to Fault/Reset Reason Code
The driver is modified to add FreeBSD OS type in the upper nibble of the
fault/reset reason code for appropriate qualification of the reason code.

Reviewed by:            imp
Approved by:            imp
Differential revision:  https://reviews.freebsd.org/D44427
2024-06-06 10:39:15 +00:00
Chandrakanth patil 4034d7061a mpi3mr: diag fault success beyond F000 fault code
Accept any fault as successful for diagnostic fault reset, not just the 0xF000
code. print fault information and return.

Reviewed by:            imp
Approved by:            imp
Differential revision:  https://reviews.freebsd.org/D44426
2024-06-06 10:39:15 +00:00
Chandrakanth patil eb7a4b35de mpi3mr: Update consumer index of admin and operational reply queues after every 100 replies
Instead of updating the ConsumerIndex of the Admin and Operational ReplyQueues
after processing all replies in the queue, it will now be periodically updated
after processing every 100 replies.

Reviewed by:            imp
Approved by:            imp
Differential revision:  https://reviews.freebsd.org/D44425
2024-06-06 10:39:15 +00:00
Chandrakanth patil 571f1d0638 mpi3mr: Decrement per controller and per target counter post reset
Post controller reset, If any device removal events arrive, and if
there are any outstanding IOs then the driver will unnecessarily wait
in the loop for 30 seconds before removing the device from the OS.

reset target outstanding IO counter and controller outstanding IO counter
and remove the redundant wait loop.

Reviewed by:            imp
Approved by:            imp
Differential revision:  https://reviews.freebsd.org/D44424
2024-06-06 10:39:15 +00:00
Chandrakanth patil 701d776c98 mpi3mr: poll reply queue and add MPI3MR_DEV_REMOVE_HS_COMPLETED flag
An outstanding IO counter per target check has been added before deleting
the target from the OS which will poll the reply queue if there are any
outstanding IOs are found.

A new flag, named "MPI3MR_DEV_REMOVE_HS_COMPLETED," is added. If a remove event
for a target occurs and before the deletion of the target resource if the add event
for another target arrives reusing the same target ID then this flag will prevent
the removal of the target reference. This flag ensures synchronization between the interrupt
top and bottom half during target removal and addition events.

Reviewed by:            imp
Approved by:            imp
Differential revision:  https://reviews.freebsd.org/D44423
2024-06-06 10:39:14 +00:00
Chandrakanth patil 042808f747 mpi3mr: Controller state check before enabling PEL
Reviewed by:            imp
Approved by:            imp
Differential revision:  https://reviews.freebsd.org/D44422
2024-06-06 10:39:14 +00:00
Chandrakanth patil 0d7056458d mpi3mr: Block devices persist despite being offlined during reset
The driver removes the drive from the OS if firmware sends 'device added'
event with hidden bit or inaccessible status.

Reviewed by:            imp
Approved by:            imp
Differential revision:  https://reviews.freebsd.org/D44421
2024-06-06 10:39:14 +00:00
Stefan Eßer 17e85f5990 newfs_msdos: align to multiple of cluster size by default
A previous commit aligned the start of the data area to a multiple of
the VM page size, in order to prevent extra buffers to be allocated
(which failed for 64 KB cluster size without this alignment).

Since a dependency on PAGE_SIZE caused compatibility issues, the
alignment was made conditional on this macro being defined, in the
previous commit. This lead to different behavior of this program
when built on FreeBSD vs. Linux (which does not define PAGE_SIZE).

This commit removes any use of PAGE_SIZE and instead always aligns
the start of the data area to a multiple of the cluster size.

The -A option is now implied, unless overridden by a specific number
of reserved sectors with the -r option.

Approved by:	kib
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D45436
2024-06-06 12:28:02 +02:00
Andrew Turner ec69d23093 linux: Allows writing to the vdso from the kernel
We need to write to the vdso in the kernel to perform fixups. Move it
from .rodata to .data so these can be run.

Reported by:	cy
Sponsored by:	Arm Ltd
2024-06-06 09:07:49 +00:00
Michael Tuexen 86c9325d34 tcp: simplify stack switching protocol
Before this patch, a stack (tfb) accepts a tcpcb (tp), if the
tp->t_state is TCPS_CLOSED or tfb->tfb_tcp_handoff_ok is not NULL
and tfb->tfb_tcp_handoff_ok(tp) returns 0.
After this patch, the only check is tfb->tfb_tcp_handoff_ok(tp)
returns 0. tfb->tfb_tcp_handoff_ok must always be provided.
For existing TCP stacks (FreeBSD, RACK and BBR) there is no
functional change. However, the logic is simpler.

Reviewed by:		lstewart, peter_lei_ieee_.org, rrs
MFC after:		1 week
Sponsored by:		Netflix, Inc.
Differential Revision:	https://reviews.freebsd.org/D45253
2024-06-06 08:29:05 +02:00
Konstantin Belousov 9c5d7e4a0c pmap: move the smp_targeted_tlb_shutdown pointer stuff to amd64 pmap.h
Fixes:	bec000c9c1ef409989685bb03ff0532907befb4aESC
Sponsored by:	The FreeBSD Foundation
2024-06-06 08:15:08 +03:00
Zhenlei Huang 215a18d502 if_enc(4): Prefer the boolean form when calling bpf_peers_present()
No functional change intended.

MFC after:	1 week
2024-06-06 12:20:26 +08:00
Ryan Libby 780666c09b getblk: reduce time under bufobj lock
Use the new pctrie combined insert/lookup facility to reduce work and
time under the bufobj interlock when associating a buf with a vnode.

We now do one lookup in the dirty tree and one combined lookup/insert in
the clean tree instead of one lookup in dirty, two in clean, and then an
insert in clean.  We also avoid touching the possibly unrelated buf at
the tail of the queue.

Also correct an issue where the actual order of the tail queue depended
on the insertion order due to sign issues.

Reviewed by:	kib (previous version), dougm, markj
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D45395
2024-06-05 20:21:22 -07:00