Commit graph

42120 commits

Author SHA1 Message Date
Gordon Bergling
06d3ecb09f hvsock: Fix a typo in a source code comment
- s/recieved/received/

(cherry picked from commit 6dc7bf0c5ce9ce0b77b0f7b9293467babc685abe)
2024-01-07 12:42:45 +01:00
John Baldwin
1309b3fd01 agp_amd64: Use <machine/pci_cfgreg.h> rather than bare prototypes
Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D42826

(cherry picked from commit 71ac18a84df2771fb9bd91e2349eae91602c4e46)
2024-01-04 15:13:26 -08:00
Mark Johnston
2c840bedd6 ti: Handle errors from copyin() and copyout()
This is in preparation for annotating copyin() and related functions
with __result_use_check.

MFC after:	1 week

(cherry picked from commit 916273680b6d6439a117d6cf8c2d7423234bc1c0)
2024-01-04 08:42:13 -05:00
Mark Johnston
9fcacb1e68 tdfx: Handle errors from copyin() and copyout()
This is in preparation for annotating copyin() and related functions
with __result_use_check.

MFC after:	1 week

(cherry picked from commit 2873d841f81cdc205135370875d3d71a3402e90a)
2024-01-04 08:42:13 -05:00
Mark Johnston
1e73894191 hptmv: Handle errors from copyout() in hpt_set_info()
This is in preparation for annotating copyin() and related functions
with __result_use_check.

MFC after:	1 week

(cherry picked from commit b4a9e6d81447c46c7bae56dc798097d9d3a4c495)
2024-01-04 08:42:13 -05:00
Mark Johnston
aa545f18d3 netmap: Ignore errors in CSB_WRITE()
The CSB_WRITE() and _READ() macros respectively write to and read from
userspace memory and so can in principle fault.  However, we do not
check for errors and will proceed blindly if they fail.  Add assertions
to verify that they do not.

This is in preparation for annotating copyin() and related functions
with __result_use_check.

Reviewed by:	vmaffione
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D43200

(cherry picked from commit 99efa2c88d93c6272a8f54b18d18d0fd9d60f137)
2024-01-04 08:42:13 -05:00
Mark Johnston
3e53fec002 fb: Explicitly handle errors when getting or setting a colour palette
In the VESA driver, simply ignore errors.  It is not clear to me how to
return them to userspace.

This is in preparation for annotating copyin() and related functions
with __result_use_check.

MFC after:	1 week

(cherry picked from commit ddc8576d297937a1395f47550a8f5b1fac79afc2)
2024-01-04 08:42:13 -05:00
John Baldwin
a4c3fdf96d gpiobus: Use bus_generic_rl_* methods
Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D42715

(cherry picked from commit a19ed3495d5556281ea39995d962b93a637183f0)
2024-01-03 12:33:51 -08:00
John Baldwin
bf63f0e7e3 qlnx: Fix a couple of type mismatches in function declarations
Reported by:	GCC 13 via -Wenum-int-mismatch
Reviewed by:	imp, emaste
Differential Revision:	https://reviews.freebsd.org/D42586

(cherry picked from commit be909a79a8e2506b49ed81f9bd8115512dd613a4)
2024-01-03 09:43:48 -08:00
John Baldwin
df8d325b8d ocs: Fix a couple of type mismatches in function prototypes
Reported by:	GCC 13 via -Wenum-int-mismatch
Reviewed by:	imp, emaste
Differential Revision:	https://reviews.freebsd.org/D42585

(cherry picked from commit 7aa5b2a9e7f5f3cd33e72cb1e95790fe7637f10f)
2024-01-03 09:43:48 -08:00
John Baldwin
6a1b9033d8 ath_hal: Fix a couple of type mismatches in function prototypes
Reported by:	GCC 13 via -Wenum-int-mismatch
Reviewed by:	imp, emaste
Differential Revision:	https://reviews.freebsd.org/D42584

(cherry picked from commit 1e65df68403acac2231dda161fd12e62f888a031)
2024-01-03 09:43:48 -08:00
Alexander Motin
78c98588c9 nvme: Add some bits from NVMe 2.0c spec.
MFC after:	1 week

(cherry picked from commit b46c7b1ed4e5307c689df72ea8a0b69e02456905)
2024-01-02 20:40:31 -05:00
Konstantin Belousov
aaa4654adc iommu_gas_remove(): consolidate places where decision is made to keep the entry
(cherry picked from commit c0047e7c356953d138194ff71cc510ffe85425f0)
2024-01-02 02:41:39 +02:00
Konstantin Belousov
8019d103e0 iommu_gas: make placeholder entry at the start of the GAS zero size
(cherry picked from commit f59128775636846574e092c68e849a56f74577e6)
2024-01-02 02:41:39 +02:00
Konstantin Belousov
264e49515f iommu: add iommu_gas_remove_locked()
(cherry picked from commit 273b4de3462d7825ebe4ace7a1930f098311287f)
2024-01-02 02:41:39 +02:00
Konstantin Belousov
5dcf0d72f6 IOMMU: add GAS map entry flag IOMMU_MAP_ENTRY_FAKE
(cherry picked from commit a59c252903e81f46c74903ce5b1cf0960927dbcc)
2024-01-02 02:41:39 +02:00
Konstantin Belousov
edaece2f7e iommu_gas: zero fake on-stack map entry used in iommu_gas_remove_clip_left()
(cherry picked from commit cb1d664b0073232173072231cb386f0216ee596b)
2024-01-02 02:41:38 +02:00
Konstantin Belousov
b86d839af9 iommu_gas: print entries flags and domains if an overlap detected
(cherry picked from commit 733da1eb947688210bc152656357ecafbd172bb7)
2024-01-02 02:41:38 +02:00
Konstantin Belousov
1bb758df1a iommu_gas: add ddb 'show iommu_domain' command
(cherry picked from commit 30ce85ca11433ba05cdbab8aedceaa15a93bd97a)
2024-01-02 02:41:38 +02:00
Konstantin Belousov
eb0d8cb121 iommu_gas_match_one(): check for underflow
(cherry picked from commit a869643e184a73382ef7939b465fd42785e096d1)
2024-01-02 02:41:38 +02:00
Konstantin Belousov
d60d1d5840 iommu: remove leftover sys/cdefs.h includes
(cherry picked from commit 6afa2333d2e42e1df67a0fab20f0ede76dff516d)
2024-01-02 02:41:38 +02:00
Mark Johnston
9b28f3f032 iscsi: Check for copyout errors in iscsi_ioctl_daemon_receive()
Reviewed by:	jhb
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D43148

(cherry picked from commit 74e713804fa4767991c5f20e6b85da4235107122)
2024-01-01 19:29:59 -05:00
Mark Johnston
494fe2e050 gntdev: Handle errors from suword32() in gntdev_alloc_gref()
Try to copy out output values before handling errors, and check that we
did so successfully.  In particular, it doesn't seem sensible to ignore
errors here, otherwise userspace won't have any way to refer to the
allocations.

This is in preparation for annotating copyin() and related functions
with __result_use_check.

Reviewed by:	royger
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D43145

(cherry picked from commit 6cdff09c0d70f780a738dbd3d87deb3b13ec8446)
2024-01-01 19:29:56 -05:00
Mark Johnston
d60d9b713a mpr: Handle errors from copyout() in ioctl handlers
In preparation for adding a __result_use_check annotation to copyin()
and related functions, start checking for errors from copyout() in
the mpr(4) user command handler.  This should make it easier to catch
bugs.

Reviewed by:	imp, asomers
MFC after:	1 month
Differential Revision:	https://reviews.freebsd.org/D43177

(cherry picked from commit 68cc77a3b73ffda1e8ac891b9852faca833e11b7)
2024-01-01 19:29:55 -05:00
Mark Johnston
0e83222347 mps: Handle errors from copyout() in ioctl handlers
In preparation for adding a __result_use_check annotation to copyin()
and related functions, start checking for errors from copyout() in
the mps(4) user command handler.  This should make it easier to catch
bugs.

Reviewed by:	imp, asomers
MFC after:	1 month
Differential Revision:	https://reviews.freebsd.org/D43176

(cherry picked from commit bcf4a7c7ace21a01d10003de9c7692f0887526c1)
2024-01-01 19:29:55 -05:00
Mark Johnston
d8fe1e4c5a ocs: Check for copyin errors in the ioctl handler
If copyin() fails, the driver will blindly proceed with whatever had
been in the uninitialized DMA buffer.  This is not what we want.  Check
for copyin failures.

This is in preparation for annotating copyin() and related functions
with __result_use_check.

Reviewed by:	ram
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D43097

(cherry picked from commit a01ff11cb73d7a1988f6241f63d141371ff23717)
2024-01-01 19:29:46 -05:00
Mark Johnston
8adca661c2 mpi3mr: Check for copyin errors in mpi3mr_map_data_buffer_dma()
A failed copyin will cause the driver to use the contents of
uninitialized buffers instead, which is unlikely to be the behaviour
that we want.  Check for errors.

This is in preparation for annotating copyin() and related functions
with __result_use_check.

Reviewed by:	imp
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D43098

(cherry picked from commit 6bfb7306ef92aaccffae42ed00ce6d7201b76966)
2024-01-01 19:29:45 -05:00
Mark Johnston
f9946e9ae7 uhid: Check for errors from copyin() in ioctl handlers
This is in preparation for annotating copyin() and related functions
with __result_use_check.

Reviewed by:	wulf
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D43103

(cherry picked from commit b2caed2f8d699d6dc59ecf8810d945cdea148c44)
2024-01-01 19:29:44 -05:00
Mark Johnston
4f1e5e94d4 hid: Handle errors from copyin() in ioctl handlers
If copyin() fails, the driver will proceed blindly with a zeroed buffer,
which is not what we want.  In preparation for annotating copyin() with
__result_use_check, start checking for errors.

Reviewed by:	wulf
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D43102

(cherry picked from commit e452fa70d50761b5fe5f19c3c93c107be116728c)
2024-01-01 19:29:43 -05:00
Mark Johnston
9483388587 ath: Handle errors from copyout() in ath_rate_fetch_node_stats()
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D43096

(cherry picked from commit 711880597c6c4ac971eb2aba6a2dadb5933d38dd)
2024-01-01 19:29:39 -05:00
Yuji Hagiwara
1e9df419f1 mlx4(5): fix driver initialization
PR:	275897
MFC after:	1 week

(cherry picked from commit 553ed8e38bfdd4832deecdec1c0b023824dcff94)
2023-12-30 02:24:07 +02:00
John Baldwin
90ac116d5e nehemiah RNG: Switch to using FPU_KERN_NOCTX
Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D41583

(cherry picked from commit 7aec088cbce8381bd5bf730419b8fdcddf43b08d)
2023-12-29 13:49:41 -08:00
Ronald Klop
028e4c6548 Teach if_smsc to get MAC from bootargs.
Some Raspberry Pi pass smsc95xx.macaddr=XX:XX:XX:XX:XX:XX as bootargs.
Use this if no ethernet address is found in an EEPROM.
As last resort fall back to ether_gen_addr() instead of random MAC.

(cherry picked from commit 3878bbf1bb9e68f8579b57cde7d4e5c77de93320)

if_smsc: fix build on armv6 & armv7

compile error was:
/usr/src/sys/dev/usb/net/if_smsc.c:1597:40: error: format specifies type 'unsigned long' but the argument has type 'ssize_t' (aka 'int') [-Werror,-Wformat]
                                "failed alloc for bootargs (%lu)", len);
                                                            ~~~    ^~~
                                                            %zd

(cherry picked from commit 8a0ee306227a17a998bdc7af2275fd94b9164342)

PR:	274092
Reported by:	Patrick M. Hausen (via ML)
Reviewed by:	imp, karels, zlei
Tested by:	Patrick M. Hausen
Approved by:	karels
Relnotes:	yes
Differential Revision: https://reviews.freebsd.org/D42463
2023-12-28 15:40:31 +01:00
Ram Kishore Vegesna
0a6b61a89a ocs_fc: Use xpt_path_sbuf() to copy the path to sbuf.
Reported by:	imp
 MFC after:	1 week

(cherry picked from commit a9504d76ccdad240b7d5761f4208e252f57042dd)
2023-12-27 17:49:51 +05:30
Ram Kishore Vegesna
b70cf00842 ocs_fc: IO timeout handling and error reporting fix.
Hardware timeout uses a 8-bit timeout value and expects the timeout to
be less than 255 seconds. Added software timer implemetation to timeout
and abort the IOs with timeout more than 255 seconds.

Fix the timeout problem by dividing CAM timeouts by 1000 as hardware
expects timeout value in seconds.  Before this change, CAM timeouts in
milliseconds were getting truncated to 8 bits and converted to seconds.
So the actual timeout used when going down to the card would depend on
the bottom 8 bits of the timeout used.

Add the mapping of ocs_fc error status to CAM status.

Reported by:	ken
Reviewed by:	ken
Tested by:	ken, ram
Approved by:	ken
MFC after:	1 week

(cherry picked from commit 70547544ce931357c980be47d937e5b57a2d7f49)
2023-12-27 17:46:08 +05:30
Mark Johnston
dcd747fda5 nvme: Initialize HMB entries before loading them into the controller
struct nvme_hmb_desc contains a pad field which was not getting
initialized before being synced.  This doesn't have much consequence but
triggers a report from KMSAN, which verifies that host-filled DMA memory
is initialized before it is made visible to the device.  So, let's just
initialize it properly.

Reported by:	KMSAN
Reviewed by:	mav, imp
MFC after:	1 week
Sponsored by:	Klara, Inc.
Sponsored by:	Juniper Networks, Inc.
Differential Revision:	https://reviews.freebsd.org/D43090

(cherry picked from commit d9b7301bb791faab48b6c7733c34078427b9a374)
2023-12-25 11:58:19 -05:00
Alexander Motin
129c3aa4b2 Use xpt_path_sbuf() in few drivers
xpt_path_string() is now a wrapper around xpt_path_sbuf().  Using it
to than concatenate result to another sbuf makes no sense.  Just call
xpt_path_sbuf() directly.

MFC after:	1 month

(cherry picked from commit 8c4ee0b22c98fc1e208dd133f617bd329cd10728)
2023-12-22 23:36:56 -05:00
Kenneth D. Merry
504e85ade1 mpr, mps: Establish busdma boundaries for memory pools
Most all of the memory used by the cards in the mpr(4) and mps(4)
drivers is required, according to the specs and Broadcom developers,
to be within a 4GB segment of memory.

This includes:

System Request Message Frames pool
Reply Free Queues pool
ReplyDescriptorPost Queues pool
Chain Segments pool
Sense Buffers pool
SystemReply message pool

We got a bug report from Dwight Engen, who ran into data corruption
in the BAE port of FreeBSD:

> We have a port of the FreeBSD mpr driver to our kernel and recently
> I found an issue under heavy load where a DMA may go to the wrong
> address. The test system is a Supermicro X10SRH-CLN4F with the
> onboard SAS3008 controller setup with 2 enterprise Micron SSDs in
> RAID 0 (striped). I have debugged the issue and narrowed down that
> the errant DMA is one that has a segment that crosses a 4GB
> physical boundary.  There are more details I can provide if you'd
> like, but with the attached patch in place I can no longer
> re-create the issue.

> I'm not sure if this is a known limit of the card (have not found a
> datasheet/programming docs for the chip) or our system is just
> doing something a bit different. Any helpful info or insight would
> be welcome.

> Anyway, just thought this might be helpful info if you want to
> apply a similar fix to FreeBSD. You can ignore/discard the commit
> message as it is my internal commit (blkio is our own tool we use
> to write/read every block of a device with CRC verification which
> is how I found the problem).

The commit message was:

> [PATCH 8/9] mpr: fix memory corrupting DMA when sg segment crosses
> 4GB boundary

> Test case was two SSD's in RAID 0 (stripe). The logical disk was
> then partitioned into two partitions. One partition had lots of
> filesystem I/O and the other was initially filled using blkio with
> CRCable data and then read back with blkio CRC verify in a loop.
> Eventually blkio would report a bad CRC block because the physical
> page being read-ahead into didn't contain the right data. If the
> physical address in the arq/segs was for example 0x500003000 the
> data would actually be DMAed to 0x400003000.

The original patch was against mpr(4) before busdma templates were
introduced, and only affected the buffer pool (sc->buffer_dmat) in
the mpr(4) driver. After some discussion with Dwight and the
LSI/Broadcom developers and looking through the driver, it looks
like most of the queues in the driver are ok, because they limit
the memory used to memory below 4GB. The buffer queue and the chain
frames seem to be the exceptions.

This is pretty much the same between the mpr(4) and mps(4) drivers.

So, apply a 4GB boundary limitation for the buffer and chain frame pools
in the mpr(4) and mps(4) drivers.

Reported by:	Dwight Engen <dwight.engen@gmail.com>
Reviewed by:	imp
Obtained from:	Dwight Engen <dwight.engen@gmail.com>
Differential Revision:	<https://reviews.freebsd.org/D43008>

(cherry picked from commit 264610a86e14f8e123d94c3c3bd9632d75c078a3)
2023-12-20 10:40:42 -05:00
Gordon Bergling
2ad07dc6ce qat: Fix two typos in source code comments
- s/parmeters/parameters/

(cherry picked from commit ada4cd3f7710d9759e391e84ad21b7763062bdbc)
2023-12-20 08:35:25 +01:00
Vladimir Kondratyev
36d6a45654 ig4: Add PCI IDs for Intel Ice Lake I2C controller.
PR:		275115
Tested by:	Sam <sam3423.yntmr_AT_slmail_DOT_me>
2023-12-19 23:34:56 +03:00
Mark Johnston
d264ddb9c7 bhnd: Correct the softc size in the siba_bhndb_driver definition
struct siba_bhndb_softc embeds struct siba_softc and adds an extra
field, "quirks".  In practice, this bug was harmless since "quirks" is
unconditionally initialized during driver attach and would have lived in
the redzone of the softc allocation, but KASAN catches the out-of-bounds
access.

PR:		275515
Reported by:	Frank Hilgendorf <frank.hilgendorf@posteo.de>
MFC after:	1 week

(cherry picked from commit 4c3aa00c0a0093c78f42d138bb9eef9b1a7cbb39)
2023-12-11 19:30:05 -05:00
Mitchell Horne
121656c2b1 pst: improve shutdown_post_sync handler
It is desirable to shut down the raid controller even in the face of a
panic. In the SCHEDULER_STOPPED() case, set the interrupt mask bits so
that we request a polled wait, rather than sleep(), from
iop_queue_wait_msg().

Tweak the function name and signature.

Reviewed by:	markj
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D42337

(cherry picked from commit c4dacfa7f4b82f23ec0924d9db772860b2066f9b)
(cherry picked from commit f97aab79868cd7d891c52b14bd964523fa56f015)
2023-12-08 18:02:45 -04:00
Mitchell Horne
a8ba64ca91 iscsi: adjust shutdown_pre_sync handler
Don't attempt to service reconnections if RB_NOSYNC is set. More
crucially, don't do it if the scheduler is stopped, as the maintenance
thread will never run again.

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

(cherry picked from commit 2ce1c45b3411410a5d0a4d08198a3b0010d493b7)
2023-12-08 18:02:44 -04:00
Mitchell Horne
c13f564f91 xen: improve shutdown hook
Make better use of the shutdown flags. In particular this now handles
standard reboot where RB_POWERCYCLE is not set, and indicates a crash
when the system has panicked.

While here, give the function a prefix.

Reviewed by:	royger, markj
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D42343

(cherry picked from commit 9e0b0f5de67fd46bddf0e12ef7b71d76a7ec1667)
2023-12-08 18:02:44 -04:00
Mitchell Horne
951d60ee3a shutdown: audit shutdown_post_sync event callbacks
Ensure they are all panic/debugger safe.

Most handlers for this event are for disk drivers/geom modules. There
are a mix of checks being used here (or not), so let's standardize on
checking the presence of the RB_NOSYNC flag.

This flag is set whenever:
 1. The kernel has panicked and kern.sync_on_panic=0*
 2. We reboot from within the kernel debugger (the "reset" command)
 3. Userspace requested it, e.g. by 'reboot -n'

Name the functions consistently.

*This sysctl is tuned to zero by default, but its existence means that
these handlers can be executed after a panic, at the user's discretion.
IMO this use-case is implicitly understood to be risky, and we'd be
better off eliminating it altogether.

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

(cherry picked from commit 4eb861d362d6a9493df7f77eab8e28f9c826702a)
2023-12-08 18:02:44 -04:00
Mitchell Horne
9af585120d pst-raid.c: sort #includes
Reviewed by:	imp, jhb
MFC after:	3 days
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D42336

(cherry picked from commit 66d9c2f38d2db9e50c0dbf56dca4a2f3e6c3107c)
2023-12-08 18:02:44 -04:00
Mitchell Horne
c154cad532 hptmv: remove vestigial EVENTHANDLER_DEREGISTER()
The registration was removed in favor of DEVICE_SHUTDOWN(). Drop the
unused eventhandler tag from the IAL_ADAPTER_T structure.

Reviewed by:	jhb
Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Fixes:	cd3ef66680 ("Use DEVICE_SHUTDOWN(9) mechanism...")
Differential Revision:	https://reviews.freebsd.org/D42334

(cherry picked from commit a4b19cf5c76ac66d02a3ef8a549115ba865d630c)
2023-12-08 18:02:44 -04:00
Eugene Grosbein
8c165cbaf0 usbdevs: add quirk for WD MyPassport Ultra External HDD
WD MyPassport Ultra External HDD needs quirk
UQ_MSC_NO_TEST_UNIT_READY to attach.

(cherry picked from commit 970d73856b626a68597de19d37b68c376e2c0491)
2023-12-06 11:21:42 +07:00
Patrisious Haddad
0312449c67 mlx5: Fix HCA cap 2 query
(cherry picked from commit 0cd90ee598cef68cef72db8b912241868d1067d0)
2023-12-06 02:27:14 +02:00
Bjoern A. Zeeb
45000447c1 mii: add Vitesse/Microsemi VSC8514
The VSC8514 Quad-Port 10/100/1000BASE-T PHY seems to match the handling
for the VSC8504 (for the little we support of what we could) and while
it works with our generic ukphy add it as vscphy for porper display of
names in the system message buffer and the like (or in case we decide
to implement some extra features).

Tested on:	Ten64

(cherry picked from commit 1965dd85c3b33ed99cb8ef164dd7c5b20425a85e)
2023-11-30 00:36:56 +00:00