git: 78cb8841f085 - main - mrsas: Use mrsas_sge64 instead of iovec for the S/G list for passthru.

From: John Baldwin <jhb_at_FreeBSD.org>
Date: Wed, 28 Jun 2023 18:10:30 UTC
The branch main has been updated by jhb:

URL: https://cgit.FreeBSD.org/src/commit/?id=78cb8841f0853e8059537c32ec4bd31d1fec7134

commit 78cb8841f0853e8059537c32ec4bd31d1fec7134
Author:     John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2023-06-28 18:10:05 +0000
Commit:     John Baldwin <jhb@FreeBSD.org>
CommitDate: 2023-06-28 18:10:05 +0000

    mrsas: Use mrsas_sge64 instead of iovec for the S/G list for passthru.
    
    The DMA scatter/gather list for mrsas passthrough ioctl commands is
    stored in a SGL at the end of the DCMD frame.  Given the SGL member at
    the end of the DCMD frame it seems likely this S/G list is formatted
    as a fixed-width structure such as the type mrsas_sge64 and not as a
    iovec which contains a kernel pointer and length that vary with the
    native architecture size.
    
    Reviewed by:    imp
    Obtained from:  CheriBSD
    Sponsored by:   DARPA
    Differential Revision:  https://reviews.freebsd.org/D40727
---
 sys/dev/mrsas/mrsas_ioctl.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/sys/dev/mrsas/mrsas_ioctl.c b/sys/dev/mrsas/mrsas_ioctl.c
index 9d3699df5b7b..6f27d18ccab9 100644
--- a/sys/dev/mrsas/mrsas_ioctl.c
+++ b/sys/dev/mrsas/mrsas_ioctl.c
@@ -45,7 +45,7 @@ __FBSDID("$FreeBSD$");
 #include <dev/mrsas/mrsas_ioctl.h>
 
 struct mrsas_passthru_cmd {
-	struct iovec *kern_sge;
+	struct mrsas_sge64 *kern_sge;
 	struct mrsas_softc *sc;
 	struct mrsas_mfi_cmd *cmd;
 	bus_dma_tag_t ioctl_data_tag;
@@ -112,8 +112,8 @@ mrsas_passthru_load_cb(void *arg, bus_dma_segment_t *segs, int nseg, int error)
 	}
 
 	for (i = 0; i < nseg; i++) {
-		cb->kern_sge[i].iov_base = PTRIN(segs[i].ds_addr);
-		cb->kern_sge[i].iov_len = segs[i].ds_len;
+		cb->kern_sge[i].phys_addr = htole64(segs[i].ds_addr);
+		cb->kern_sge[i].length = htole32(segs[i].ds_len);
 	}
 	cb->sge_count = nseg;
 
@@ -421,7 +421,7 @@ mrsas_user_command(struct mrsas_softc *sc, struct mfi_ioc_passthru *ioc)
 	bus_dma_tag_t ioctl_data_tag;
 	bus_dmamap_t ioctl_data_dmamap;
 	bus_addr_t ioctl_data_phys_addr;
-	struct iovec *kern_sge;
+	struct mrsas_sge64 *kern_sge;
 	int ret, ioctl_data_size;
 	char *ioctl_temp_data_mem;
 
@@ -457,11 +457,11 @@ mrsas_user_command(struct mrsas_softc *sc, struct mfi_ioc_passthru *ioc)
 	if (sizeof(bus_addr_t) == 8)
 		cmd->frame->hdr.flags |= MFI_FRAME_SGL64 | MFI_FRAME_SENSE64;
 
-	kern_sge = (struct iovec *)(&dcmd->sgl);
+	kern_sge = (struct mrsas_sge64 *)(&dcmd->sgl);
 
 	if (ioctl_data_size == 0) {
-		kern_sge[0].iov_base = 0;
-		kern_sge[0].iov_len = 0;
+		kern_sge[0].phys_addr = 0;
+		kern_sge[0].length = 0;
 	} else {
 		ioctl_temp_data_mem = malloc(ioc->buf_size, M_MRSAS, M_WAITOK);
 		if (ioctl_temp_data_mem == NULL) {