1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-11-24 07:40:52 +00:00
Commit Graph

151533 Commits

Author SHA1 Message Date
Alexander Ziaee
088cc7d221 man filesystems: fix more xrefs after move to s4
Fixes: 1a720cbec5
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1282
2024-06-27 18:32:05 -06:00
Mitchell Horne
32d2a1de3d arm64: correct physmap bounds in pmap_bootstrap()
physmap_idx now contains the raw value; we should not multiply it.

Reviewed by:	markj
Fixes:	d03e1ffbea ("arm64: Remove some redundant calculations...")
2024-06-27 16:32:44 -03:00
Doug Moore
995730a635 swap_pager: cleanup swapoff_object
Function swap_pager_swapoff_object calls vm_pager_unswapped (via
swp_pager_force_dirty) for every page that must be unswapped. That
means that there's an unneeded check for lock ownership (the caller
always owns it), a needless PCTRIE_LOOKUP (the caller has already
found it), a call to free one page of swap space only, and a check to
see if all blocks are empty, when the caller usually knows that the
check is useless.

Isolate the essential part, needed however swap_pager_unswapped is
invoked, into a smaller function swap_pager_unswapped_acct.  From
swapoff_object, invoke swp_pager_update_freerange for each appropriate
page, so that there are potentially fewer calls to
swp_pager_freeswapspace.  Consider freeing a set of blocks (a struct
swblk) only after having invalidated all those blocks.

Replace the doubly-nested loops with a single loop, and refetch and
rescan a swblk only when the object write lock has been released and
reacquired.

After getting a page from swap, dirty it immediately to address a race
condition observed by @kib.

Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D45668
2024-06-27 14:06:09 -05:00
Michael Tuexen
14fee5324a tcp: improve failure handling in tcp_newtcpcb()
In case of a failure of tcp_newtcpcb, where NULL is returned,
* call CC_ALGO(tp)->cb_destroy, after CC_ALGO(tp)->cb_init was called.
* call khelp_destroy_osd(), after khelp_init_osd() was called.

Reviewed by:		glebius, rscheff
MFC after:		1 week
Sponsored by:		Netflix, Inc.
Differential Revision:	https://reviews.freebsd.org/D45753
2024-06-27 08:26:34 +02:00
Mitchell Horne
a35f665109 if_genet: don't load DMA mapping when tx_queue is full
gen_encap() always calls bus_dmamap_load_mbuf_sg() into 'map' (which is
the current tx_queue). If the tx_queue is full, it will load with a
'map' that already has a currently active mapping. This violates the
busdma(9) KPI.

Checking for a full queue and returning ENOBUFS will allow
gen_start_locked() to set the IFF_DRV_OACTIVE faster without having to
needlessly check if the mbuf will fit (it won't).

PR:		256482
Reviewed by:	mhorne
MFC after:	1 week
Submitted by:	ghuckriede@blackberry.com
2024-06-27 14:44:36 -03:00
Michael Tuexen
3703e1a73e tcp: improve error handling in syncache_socket()
If syncache_socket() fails after calling tcp_newtcpcb(), the resources
allocated in tcp_newtcpcb() needs to be freed. Just call
tcp_discardcb() to do this.
Thanks to jtl for making me aware of the issue and proposing a fix.
Reviewed by:		glebius, jtl, rscheff
MFC after:		1 week
Sponsored by:		Netflix, Inc.
Differential Revision:	https://reviews.freebsd.org/D45749
2024-06-27 07:25:15 +02:00
Alexander Motin
87085c12ba Fix SATA NCQ error recovery after 25375b1415
Since that commit ahci(4), siis(4) and mvs(4) drivers ended up
using wrong command to fetch error information for NCQ commands.
Since ATA errors are not very informative to begin with, the only
noticeable effect is a lack of retries on those errors by CAM.

MFC after:	1 week
PR:		279978
2024-06-27 09:29:23 -04:00
Andriy Gapon
a743e280ea rk_i2c: use the register read mode even if the read ends with IIC_M_NOSTOP
Tested with max44009(4).

MFC after:	2 weeks
2024-06-27 13:32:47 +03:00
Andriy Gapon
0deaf4be34 rk_i2c: emulate repeated start
rk_i2c_send_stop is modified so that it sends a stop condition, like it
always did, if there is no IIC_M_NOSTOP flag.
But if the flag is set then the function completely resets the control
register and sets the driver state to transfer completed.
Something like this was previously done for a write with IIC_M_NOSTOP.
Now it is done for a read with IIC_M_NOSTOP as well.

Linux code says that the hardware does not support the repeated start
condition and the documentation, indeed, does not mention it.
But according to the Linux driver clearing the control register and then
sending a start condition acts as if it were a repeated start.

While here, add braces around a single-line 'if' branch to balance it
with a multi-line 'else' branch.

Tested with max44009(4).

MFC after:	2 weeks
2024-06-27 13:32:15 +03:00
Zhenlei Huang
ef4f4a44d9 ifnet: Restore curvnet earlier
This improves readability a little. As a side effect, a redundant
CURVNET_RESTORE is removed.

No functional change intended.

Reviewed by:	glebius
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D45595
2024-06-27 12:38:04 +08:00
Ryan Libby
b195d7498b nvme: avoid gcc -Werror=int-to-pointer-cast on 32-bit arch
Reviewed by:	chuck (previous version), imp
Differential Revision:	https://reviews.freebsd.org/D45750
2024-06-26 20:50:04 -07:00
Vladimir Kondratyev
8c5c572125 LinuxKPI: Add DEFINE_DEBUGFS_ATTRIBUTE_SIGNED to linux/debugfs.h
Sponsored by:	Serenity CyberSecurity, LLC
MFC after:	1 week
Reviewed by:	manu
Differential Revision:	https://reviews.freebsd.org/D45615
2024-06-26 23:51:34 +03:00
Vladimir Kondratyev
e1b0f431a1 LinuxKPI: Remove vmas argument from get_user_pages on KPI layer
To chase Linux kernel 6.5

Sponsored by:	Serenity CyberSecurity, LLC
MFC after:	1 week
Reviewed by:	manu, emaste
Differential Revision:	https://reviews.freebsd.org/D45614
2024-06-26 23:51:04 +03:00
Vladimir Kondratyev
889f74af66 LinuxKPI: Add linux/nodemask.h
and dummy num_possible_nodes() implementation.
We do not fully support NUMA in LinuxKPI yet.

Sponsored by:	Serenity CyberSecurity, LLC
MFC after:	1 week
Reviewed by:	manu, bz
Differential Revision:	https://reviews.freebsd.org/D45613
2024-06-26 23:49:52 +03:00
Vladimir Kondratyev
256eb8d536 LinuxKPI: Remove linux/sched.h include from linux/kernel.h header
This include prevents usage of any kernel.h helpers in sched.h and
all of dependencies. Linux does not have it too.
Fix building of kernel and drm-kmod after than.

Sponsored by:	Serenity CyberSecurity, LLC
MFC after:	1 week
Reviewed by:	manu, bz
Differential Revision:	https://reviews.freebsd.org/D45692
2024-06-26 23:47:12 +03:00
Vladimir Kondratyev
d21316ff22 LinuxKPI: Add header polution to compile linux/numa.h
Sponsored by:	Serenity CyberSecurity, LLC
MFC after:	1 week
Reviewed by:	manu, bz, emaste
Differential Revision:	https://reviews.freebsd.org/D45612
2024-06-26 23:44:56 +03:00
Vladimir Kondratyev
597ffdc1d3 LinuxKPI: Add smp_store_release and smp_load_acquire functions
Sponsored by:	Serenity Cyber Security, LLC
MFC after:	1 week
Reviewed by:	manu
Differential Revision:	https://reviews.freebsd.org/D45611
2024-06-26 23:44:37 +03:00
Vladimir Kondratyev
460908ea55 LinuxKPI: Remove owner argument from class_create function on KPI layer
to chase Linux 6.4

Sponsored by:	Serenity Cyber Security, LLC
MFC after:	1 week
Reviewed by:	manu, emaste
Differential Revision:	https://reviews.freebsd.org/D45610
2024-06-26 23:44:12 +03:00
Vladimir Kondratyev
73f3589120 LinuxKPI: Add kmap_local_page function
kmap_local_page maps a page for temporary usage

Sponsored by:	Serenity CyberSecurity, LLC
MFC after:	1 week
Reviewed by:	manu
Differential Revision:	https://reviews.freebsd.org/D45609
2024-06-26 23:43:43 +03:00
Vladimir Kondratyev
a5cac2e672 LinuxKPI: Add rb_add_cached function
rb_add_cached inserts node into the leftmost cached tree

Sponsored by:	Serenity CyberSecurity, LLC
MFC after:	1 week
Reviewed by:	manu
Differential Revision:	https://reviews.freebsd.org/D45608
2024-06-26 23:43:16 +03:00
Vladimir Kondratyev
249e24d76a x86/pci_early_quirks: Sync Intel 11th+ gen PCI IDs with Linux
Sponsored by:	Serenity Cyber Security, LLC
MFC after:	1 week
Reviewed by:	manu, imp
Differential Revision:	https://reviews.freebsd.org/D45617
2024-06-26 23:42:25 +03:00
Mitchell Horne
609cdb12b9 ofw: convert boolean_t to bool
Most of these already treat it as a proper bool, i.e. using true/false.
Also fix-up callers of OF_install().

No functional change intended.

Reviewed by:	andrew, emaste
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D45733
2024-06-26 11:14:36 -03:00
Zhenlei Huang
2cb7605a24 lo: Use new KPI to create the first loop interface
While here remove a pointless static local variable lo_cloner.

No functional change intended.

Reviewed by:	kp
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D45728
2024-06-26 18:00:37 +08:00
Doug Moore
8502c68d29 x86_iommu: use roundup_pow_of_two
Drop a private implementation of roundup_pow_of_two and use the global
one instead.

Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D45739
2024-06-26 04:23:54 -05:00
Andrew Turner
5afc347944 arm: Start to remove the now unneeded acle-compat.h
All supported compilers provide the acle macros so we don't need the
backup versions.

Keep the file around for anything that included it directly, but make
it an error to not support the acle macros.

Reviewed by:	imp
Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D45726
2024-06-26 08:52:08 +00:00
Doug Moore
7d37fcbf52 cxgbe: replace a loop with rounddown_pow_of_two
Replace a loop with a function call.

Reviewed by:	np, alc
Differential Revision:	https://reviews.freebsd.org/D45716
2024-06-26 03:19:16 -05:00
Konstantin Belousov
7e5574f9e5 sched_unpin(): assert that curthread was pinned
Reviewed by:	emaste, imp, markj, olce
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D45736
2024-06-26 10:04:10 +03:00
Ryan Libby
f29bdea047 ext4_ext_tree_init: correct memset initialization
gcc -Wmemset-elt-size diagnosed this.  The code was only initializing
1/4 of the array.  However, it was actually harmless, as the only caller
had done an M_ZERO allocation anyway.

Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D45701
2024-06-25 10:41:11 -07:00
Ryan Libby
d25f0bdceb cdefs.h: add __inline to __always_inline
Add __inline to the __always_inline macro to quiet dozens of gcc
warnings of the form:
warning: 'always_inline' function might not be inlinable [-Wattributes]

It's clearly the intention of the __always_inline macro applied to a
function to inline the function.  However, gcc seems to be picky with
the -Wattributes.  It appears that __attribute__((__always_inline__))
was intended to apply to inline functions, as in, function declarations
with the attribute should also be declared as inline.  Both clang and
gcc sources themselves use the two in combination:
inline __attribute__((__always_inline__))

FreeBSD sources mostly only use __always_inline, without the inline
keyword.  Only a few files in libmsun used both.

Reviewed by:	imp, kib, olce
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D45711
2024-06-25 10:39:13 -07:00
Mariusz Zaborski
8aa9192ce9 isp: fix ISPCTL_ABORT_CMD switch case
Prevent kernel panic by not running ISPCTL_FCLINK_TEST after a
failed ISPCTL_ABORT_CMD.

Reviewed by:	mav
Tested by:	Arne Steinkamm <arne@steinkamm.com>
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D45718
2024-06-25 16:56:12 +02:00
Ruslan Bukin
44d4ee7f3d riscv: add FPE code.
Add floating point extension (FPE) code needed for bhyve and world switch.

Reviewed by:	mhorne
Sponsored by:	UKRI
Differential Revision:	https://reviews.freebsd.org/D45697
2024-06-25 12:35:35 +01:00
Ruslan Bukin
d5963606f0 riscv: add SBI implementation IDs.
Add new SBI implementation IDs including recently allocated one for bhyve.

Reviewed by:	mhorne
Sponsored by:	UKRI
Differential Revision:	https://reviews.freebsd.org/D45696
2024-06-25 12:25:26 +01:00
Andrew Turner
36e0db4916 Revert "arm: Start to remove the now unneeded acle-compat.h"
This reverts commit 3d02fe6c59.

This wasn't ready to be committed
2024-06-25 09:37:14 +00:00
Andrew Turner
3d02fe6c59 arm: Start to remove the now unneeded acle-compat.h
All supported compilers provide the acle macros so we don't need the
backup versions.

Sponsored by:	Arm Ltd
2024-06-25 09:07:19 +00:00
Andrew Turner
0cdd0032a7 arm64/vmm: Fix the SPAN check
When raising an exception we may need to set the SPSR_EL1.PAN field.
The check for this was incorrect meaning it would be set when it
shouldn't be.

Reviewed by:	markj
Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D45717
2024-06-25 09:07:19 +00:00
Andrew Turner
c36fa8d502 hwpmc/arm64: Support the kernel booting to VHE
When booting to VHE we need to handle using the PMU at either EL1 or
EL2. WE already support EL1 so add support for EL2.

Reviewed by:	mhorne
Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D45527
2024-06-25 09:07:19 +00:00
Andrew Turner
915161b3d3 hwpmc/arm64: fix the type for pm_arm64_evsel
It holds a 64-bit register, use a uint64_t.

Reviewed by:	mhorne
Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D45526
2024-06-25 09:07:19 +00:00
Warner Losh
bbecd3148a tpm: Fix acpi attachment
The third arg of the DRIVER_MODULE arg is the driver to use. We want to
use the acpi bus version rather than the generic one. Otherwise, the
ACPI specific probe and attach functions aren't used and we don't see
the device.

Sponsored by:		Netflix
2024-06-24 23:35:30 -06:00
Warner Losh
6a467c783d tpm: Fix standalone build
We're building ACPI, so	we need	-DDEV_ACPI on CFLAGS. Nomally, the
kernel config brings this in, but there's no kernel directory for the
standalone build.

Sponsored by:		Netflix
2024-06-24 23:34:59 -06:00
Ed Maste
e6b88237c6 p9fs: use M_WAITOK where appropriate
device_attach routines are allowed to sleep, and this routine already
has other M_WAITOK allocations.

Reported by:	markj
Reviewed by:	markj
Fixes: 1efd69f933 ("p9fs: move NULL check immediately after alloc...")
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D45721
2024-06-24 22:02:13 -04:00
Warner Losh
677b28750a sys/cdefs.h: Note gcc supports many __has_* macros
The __has_* macros are no longer clang-speicifc. gcc 5 introduced
__has_include, gcc 9 introduce __has_attribute, gcc 10 introduced
__has_builtin. So all of these are supported by all the versrions of gcc
we support as a project (we have gcc 10 and newer ports, but no older
ones), so just refer to them as supported by gcc. The exact version
doesn't matter so much these days (we provide a fallback for older
compilers still, should anybody still be using them), so don't mention
them in the comments (but here in the commit message they are
discoverable).

gcc 14 adds __has_feature and __has_extension, so note that since it
will be relevant for many years.

Sponsored by:		Netflix
2024-06-24 15:11:05 -06:00
Warner Losh
65522b64ad sys/cdefs.h: Remove old arm acle-compat.h workaround
The ACLE defines the modern ARM compiler symbols. ARM published
acle-compat.h to ease the transition to the new standard. This standard
is in all modern versions of gcc and clang, only gcc prior to 4.4 lacked
them (though our 4.2.1 back-ported them, IIRC). Since this is no longer
needed, remove the global inclusion in sys/ctypes.h. We should likely
remove arm/include/acle-compat.h as well (it's unused now in the tree),
but I'll make sure this change is the NOP I think it is before moving
ahead there. I also recall at one time some out of tree code needing
this file, though the need for it to make things right has long since
past.

Sponsored by:		Netflix
2024-06-24 15:11:05 -06:00
Kenneth D. Merry
31354813f3 Add an isp(4) tunable to default to ispfw(4) firmware.
ispfw(4) recently gained firmware for Qlogic 27XX and 28XX
FC controllers, and isp(4) now selects the newer of firmware in
flash or in ispfw(4) to load for those controllers.

This differs from the previous behavior (which remains for older
controllers), which was to always load the ispfw(4) firmware if it
is available.

This adds a loader tunable, hint.isp.N.fwload_force to default to
loading the ispfw(4) firmware, whether or not it is newer than the
firmware in flash.  This allows the user to always use the known
firmware version included with the kernel.

Note that there is an existing fwload_disable tunable that tells
the driver to always load the firmware from flash and ignore
ispfw(4).  If fwload_disable is set, fwload_force will be ignored.
So users with existing fwload_disable tunables will have the same
behavior.

If a user specifies both fwload_force and fwload_disable for the
same controller, the isp(4) driver prints a warning message,
and fwload_disable will be honored.

The user can see which firmware is active through the
dev.isp.N.fw_version* sysctl variables.

share/man/man4/isp.4:
	Document the new loader tunable.

sys/dev/isp/isp.c:
	In isp_load_risc_flash(), changet the decision logic to
	also consider ISP_CFG_FWLOAD_ONLY.  Load the flash firmware
	and get the version, so the user knows what it is, but if
	the user set fwload_force, honor that.  If the user didn't
	set fwload_force, the behavior remains to select the newer
	firmware version.

sys/dev/isp/isp_pci.c:
	Add a new fwload_force tunable.  Print out a warning if the
	user sets both fwload_disable and fwload_force.

sys/dev/isp/ispvar.h:
	Add a new ISP_CFG_FWLOAD_FORCE configuration bit.

Reviewed by:	mav
MFC after:	1 week
Sponsored by:	Spectra Logic
Differential Revision:	<https://reviews.freebsd.org/D45688>
2024-06-24 16:47:55 -04:00
Kenneth D. Merry
137b004e2b Fix the isp(4) driver with 9.x firmware.
The isp(4) driver (and ispfw(4) firmware) previously only included
firmware for Qlogic controllers up to 8Gb.  It recently gained
firmware for the 27XX and 28XX series controllers along with
improved firmware loading capabilities.

The 9.x firmware available for the 27XX and 28XX controllers in
ispfw(4) adds login state for NVMe devices in the top nibble of
the login state in the port database (isp_pdb_24xx_t in ispmbox.h).

This breaks the check at the end of isp_getpdb() to make sure the
device is in the right login state.  As a result, it breaks device
discovery for many (perhaps all?) FC devices.  In my testing with
IBM LTO-6 drives attached to a quad port 16Gb Qlogic 2714, they
don't show up when they are directly connected (and in loop mode)
or connected via a switch (and in fabric mode).

So, mask off the top bits of of the login state before checking it.
This shouldn't break anything, because all of the existing login
states defined in ispmbox.h are in the low nibble.

sys/dev/isp/ispmbox.h:
	Add a FCP login state mask define, and a NVMe login state
	shift.

sys/dev/isp/isp.c:
	In isp_getpdb(), make sure we're only looking at the FCP
	login state bits when we try to determine whether a device
	is in the right login state.

MFC after:	1 week
Sponsored by:	Spectra Logic
Reviewed by:	mav
Differential Revision:	<https://reviews.freebsd.org/D45660>
2024-06-24 16:47:55 -04:00
Jamie Gritton
9cbf1de7e3 Mark the zfs.mount_snapshot jail parameter as boolean.
PR:		274263
Differential Revision:	https://reviews.freebsd.org/D45647
2024-06-24 13:00:49 -07:00
Ed Maste
1efd69f933 p9fs: move NULL check immediately after allocation
Reported by:	Shawn Webb (HardenedBSD)
Reviewed by:	dfr
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D45719
2024-06-24 15:36:11 -04:00
Ryan Libby
eae1767d8f vfs: move __always_inline to canonical position
Ahead of including inline in __always_inline, move __always_inline to
where inline goes.

Reviewed by:	kib, olce
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D45709
2024-06-24 10:05:58 -07:00
Ryan Libby
3c84b4b35f kern: move __always_inline to canonical position
Ahead of including inline in __always_inline, move __always_inline to
where inline goes.

Reviewed by:	kib, olce
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D45708
2024-06-24 10:05:58 -07:00
Val Packett
daa2c99c89 p9fs: implement working putpages (fix mmap write)
Mostly copied from smbfs. This driver in its current state has the exact
same issue that prevents the generic putpages implementation from
working.

Sponsored by:		https://www.patreon.com/valpackett
Reviewed by:		dfr
Differential Revision:	https://reviews.freebsd.org/D45639
MFC after:		3 months
2024-06-24 17:11:47 +01:00
Alan Somers
6efba04df3 fusefs: fix two bugs regarding _PC_MIN_HOLE_SIZE
Background:

If a user does pathconf(_, _PC_MIN_HOLE_SIZE) on a fusefs file system,
the kernel must actually issue a FUSE_LSEEK operation in order to
determine whether the server supports it.  We cache that result, so we
only have to send FUSE_LSEEK the first time that _PC_MIN_HOLE_SIZE is
requested on any given mountpoint.

Problem 1:

Unlike fpathconf, pathconf operates on files that may not be open.  But
FUSE_LSEEK requires the file to be open.  As described in PR 278135,
FUSE_LSEEK cannot be sent for unopened files, causing _PC_MIN_HOLE_size
to wrongly report EINVAL.  We never noticed that before because the
fusefs test suite only uses fpathconf, not pathconf.  Fix this bug by
opening the file if necessary.

Problem 2:

On a completely sparse file, with no data blocks at all, FUSE_LSEEK with
SEEK_DATA would fail to ENXIO.  That's correct behavior, but
fuse_vnop_pathconf wrongly interpreted that as "FUSE_LSEEK not
supported".  Fix the interpretation.

PR:		278135
MFC after:	1 week
Sponsored by:	Axcient
Differential Revision: https://reviews.freebsd.org/D44618
2024-06-24 10:02:02 -06:00