From nobody Thu Nov 03 07:52:47 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4N2wwH3Z1Mz4hHCd; Thu, 3 Nov 2022 07:52:47 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4N2wwH2xqJz42Mb; Thu, 3 Nov 2022 07:52:47 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1667461967; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=yGBhmwKlOYx4R9C0+aXM7Mbg3MrqQPcy3VSAf/2/+CU=; b=sHTL7XRVhMXRbbc6yE09axnDiWT7lvPljwZ2lZ0zkQVEc1+PuZU9qF122CN20jqCUx4afC DDGCPCmheG5ev24VnyXidzOZhMWTaUquzJVIqAPNAGWBhl59lCZ9nuD1WWRcp1S33ggI2X BY8K0ssiDp3G1xvkTv6enJsp81HfkpAgtwUwXq4Nj9OnF/1v1IgniMSgTL/iAwNAS2zcQr 92RSfYO6r1LgExyRYxA/TdW6K9lh29fMlPqmPxJ/O5HrEaax4sCHDFoS69NosFpvH4RBTA rV+937MfPHgJX9KPJpq41nta3j3/19dxWKZqTqDdTeEPLMlwelmlQk/BM2OlUQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4N2wwH2249zT5J; Thu, 3 Nov 2022 07:52:47 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 2A37qlBS022966; Thu, 3 Nov 2022 07:52:47 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 2A37qlc8022965; Thu, 3 Nov 2022 07:52:47 GMT (envelope-from git) Date: Thu, 3 Nov 2022 07:52:47 GMT Message-Id: <202211030752.2A37qlc8022965@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Colin Percival Subject: git: 75549de770df - main - vtblk: Fix dumping List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: cperciva X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 75549de770df470b024c92ff093009c6987b40fd Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1667461967; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=yGBhmwKlOYx4R9C0+aXM7Mbg3MrqQPcy3VSAf/2/+CU=; b=anKk6Pj0A7U+q46NmVHYP248bGJCyIgZTFdbXgtlMDMbbg5zklu6JZcpbs1cRykuc2p0h8 dJZVlMw1rBytYKwbCxaK5ksAtwJvOlTeTyphejl2uFBCJBSdfwFuUxI1aJ3pOgrrWuH4Sh 7c2TfbyC+Hy0A7D5VCcUjxPTu110WtrCTjyqnzi15hSo904tHoQPAPIKBWoO2uuFssO6zd gE310uinbyQQPTWMmWiwL4OU12dGRC09/BH8PhVb070Te+a6uBWGRZwSIBg/fggnaKs576 ScCyLxLdh7lu+z0/EozlMZZXJw3md6jRWaT46pEvD260VnOdQcEnEq1AlaeIAw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1667461967; a=rsa-sha256; cv=none; b=PSHSL8TvDnKn50FCyh/EW1XvOLK1kpAd3eTr999UNKFsJi8KCznawKAO3IKPfTp/DW1GEG VqQXV8sJeFbxpdMu9wY2+goUmTg0yUAq1ufsXrAFc/dgU5DmJdSLUeXvEpk7FSUddKTmBy u/agP1NWD0IsAYTPtjXS4+nxYE/DQ+rJDgjNp8BDDydhJL+4MunCzJ7Y5s7QKDDiNkXxs7 BMt9IJYZuZ3N9H84+FLtJxmcmXQhu9Xs/xYjRqqInFMeNGAy2XG9ya2RIgTxPq9qM3Vy5r d2cpw2K1F+Adt6n0Yt61eggIpdxe9H4tstgfgBwl9yK+X0LuD5l8R4KHW5CdMQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by cperciva: URL: https://cgit.FreeBSD.org/src/commit/?id=75549de770df470b024c92ff093009c6987b40fd commit 75549de770df470b024c92ff093009c6987b40fd Author: Colin Percival AuthorDate: 2022-11-03 01:55:12 +0000 Commit: Colin Percival CommitDate: 2022-11-03 07:52:43 +0000 vtblk: Fix dumping Now that vtblk uses busdma, it keeps important information inside its request structures. The functions used for kernel dumps synthesize their own request structures rather than using structures initialized with the necessary bits for busdma. Add busdma-bypass paths. Since dumping writes contiguous blocks of physical memory, vtblk doesn't need busdma in that case. Reported by: glebius Tested by: glebius Differential Revision: https://reviews.freebsd.org/D37243 --- sys/dev/virtio/block/virtio_blk.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/sys/dev/virtio/block/virtio_blk.c b/sys/dev/virtio/block/virtio_blk.c index b3b3a6dd1aed..41229bb6da2c 100644 --- a/sys/dev/virtio/block/virtio_blk.c +++ b/sys/dev/virtio/block/virtio_blk.c @@ -992,9 +992,12 @@ vtblk_request_execute(struct vtblk_request *req, int flags) /* * Call via bus_dmamap_load_bio or directly depending on whether we - * have a buffer we need to map. + * have a buffer we need to map. If we don't have a busdma map, + * try to perform the I/O directly and hope that it works (this will + * happen when dumping). */ - if (bp->bio_cmd == BIO_READ || bp->bio_cmd == BIO_WRITE) { + if ((req->vbr_mapp != NULL) && + (bp->bio_cmd == BIO_READ || bp->bio_cmd == BIO_WRITE)) { error = bus_dmamap_load_bio(sc->vtblk_dmat, req->vbr_mapp, req->vbr_bp, vtblk_request_execute_cb, req, flags); if (error == EINPROGRESS) { @@ -1080,6 +1083,15 @@ vtblk_request_execute_cb(void * callback_arg, bus_dma_segment_t * segs, } } + /* Special handling for dump, which bypasses busdma. */ + if (req->vbr_mapp == NULL) { + error = sglist_append_bio(sg, bp); + if (error || sg->sg_nseg == sg->sg_maxseg) { + panic("%s: bio %p data buffer too big %d", + __func__, bp, error); + } + } + /* BIO_READ means the host writes into our buffer. */ if (bp->bio_cmd == BIO_READ) writable = sg->sg_nseg - 1; @@ -1130,7 +1142,7 @@ vtblk_request_execute_cb(void * callback_arg, bus_dma_segment_t * segs, virtqueue_notify(vq); out: - if (error) + if (error && (req->vbr_mapp != NULL)) bus_dmamap_unload(sc->vtblk_dmat, req->vbr_mapp); out1: if (error && req->vbr_requeue_on_error) @@ -1505,6 +1517,7 @@ vtblk_dump_write(struct vtblk_softc *sc, void *virtual, off_t offset, struct vtblk_request *req; req = &sc->vtblk_dump_request; + req->vbr_sc = sc; req->vbr_ack = -1; req->vbr_hdr.type = vtblk_gtoh32(sc, VIRTIO_BLK_T_OUT); req->vbr_hdr.ioprio = vtblk_gtoh32(sc, 1); @@ -1527,6 +1540,7 @@ vtblk_dump_flush(struct vtblk_softc *sc) struct vtblk_request *req; req = &sc->vtblk_dump_request; + req->vbr_sc = sc; req->vbr_ack = -1; req->vbr_hdr.type = vtblk_gtoh32(sc, VIRTIO_BLK_T_FLUSH); req->vbr_hdr.ioprio = vtblk_gtoh32(sc, 1);