From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796350536; b=mtqKFaoqVwDx8U1BujHxVtIJpMkgjLadN7ArZqSlXpY9Ubn2POkmLNEVQz+l6grlaYio V9FCL/QqOLgb4REaALwY4LEooMLD0FnRUlaiVbMiNuwb5hICSQwbdfE0BEsbyFItKo+pE POIfgtmcCJaRJ1llrDOrv6T9alXWu3x5BUCCqFcUC8Y1TMty88386rI/G/b3enRfl6KKS DD1GgWPJdOvvZYYFSaCzAnqIGzUPzgIstqfk4RJ1Adb4WoeA1OBdOuz9qG8T+HA6w+qBv DhVaV4lnFjIMHYvalg6/mn2tGuQJ0a1IKhscrQcxyTW/MT8Lywr0OXupLhSqSqrL1BA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796350536; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=8/ssy5T0xm8aBYhNArQGPiwzhZnUbUKkSyKA+7dFMB4=; b=HzXdo4WVPYrWgK0/TrogLlwhsc0xAbuAU0R1JS8YsX2sjr9fWp6FOE2+7fqRneCmY9M1 24losbFwjcALiQlom/sVRLMLTzJZdiU6g+j2aUriytTbTNhQqEy5vwV1FLlgZdhl7j3xg VrromQrS42D49r3i/GaraTiMkj+BMnT+3TBnWrdbbNN6dpVByTa6lf1CAYLOE3G/RDgCx 5JzmuJiYnYGlBj0JiKee8LMFQ+RuoBs3iQe/430A2a6vK28tkF9dr/8QzuFez3bWy3SfQ i0PKknFQOWdR/2W4f0A3Gj/2hCOYwKxhZHivkUBnQY+90ooG3eL/Lggji8CxxxTZk5Q== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=F3d2Nw6y; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8547B606A681 for ; Fri, 4 Dec 2026 02:15:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=F3d2Nw6y Received: by smtp.kernel.org (Postfix) with ESMTPSA id 014AC1F000C2; Fri, 4 Dec 2026 02:15:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796350536; bh=8/ssy5T0xm8aBYhNArQGPiwzhZnUbUKkSyKA+7dFMB4=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=F3d2Nw6yUXXp8a1ib6oNsi5vsX3zMZcgmcSSM9H2/Eag7HH/YefLm3jnslwtp3YWF XMGFVTO7aZtP8i2B387QbUkfE1uahkMBj7Pyt+9km7KbWdI4dUG9JFffnbu3eAfjAl rF/vJLHx4Mixr0LUlg6WHY4bxyyZVKPNwnMWETRghkegQhzGr2h7G6H3LXhkVO+RWw wDdrHVaOsgSEo1v2H33fojVMwU8fhr6QTeug441cBS8nYsOxCRDHL2epI3m6bLf2zy J/S5ByWkVItFc5G3srW1iAAyqxeN6HdTTxNk52tSE8LweF1L6ImAW0QzMjwSRiywlz LspRh7qKyplkg== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v2] vfio: selftests: Add NVMe driver Reply-To: sashiko-reviews@lists.linux.dev To: "Josh Hilke" Cc: linux-nvme@lists.infradead.org, kvm@vger.kernel.org In-Reply-To: <20261204015203.318020-1-jrhilke@google.com> References: <20261204015203.318020-1-jrhilke@google.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Fri, 04 Dec 2026 02:15:35 +0000 X-Mailing-List: kvm@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 3 potential issues to consider: - [Low] vfio: selftests: unconditional VFIO_DEVICE_RESET in nvme_recover() - [Low] vfio: selftests: unaligned on-disk hdr->size aborts nvme_claim_scratch() - [Low] vfio: selftests: nvme_wait_rdy() ignores NVME_REG_CRTO ready timeout -- commit 005bfc827495371f40d3d04303df45747c89d721 Author: Josh Hilke vfio: selftests: Add NVMe driver This commit adds an NVMe driver to the VFIO selftests library, implementing memcpy through logical blocks of the first active namespace (with a 4 KiB scratch header to avoid overwriting existing data) and MSI-X signaling via flush commands. > diff --git a/tools/testing/selftests/vfio/lib/drivers/nvme/nvme.c b/tools= /testing/selftests/vfio/lib/drivers/nvme/nvme.c > new file mode 100644 > index 0000000000000..4ae07c2c9a301 > --- /dev/null > +++ b/tools/testing/selftests/vfio/lib/drivers/nvme/nvme.c [ ... ] > +static int nvme_wait_rdy(struct vfio_pci_device *device, bool rdy) > +{ > + void *bar0 =3D device->bars[0].vaddr; > + int timeout_ms; > + u32 csts; > + u64 cap; > + > + cap =3D readq(bar0 + NVME_REG_CAP); > + timeout_ms =3D max(NVME_TIMEOUT_MS, > + NVME_CAP_TIMEOUT(cap) * NVME_CAP_TIMEOUT_UNIT_MS); [Severity: Low] Should nvme_wait_rdy() also check NVME_REG_CRTO when rdy is true and the controller advertises NVME_CAP_CRMS_CRWMS? nvme_enable_ctrl() enables the controller with CC.CRIME clear, while CAP.TO saturates at 127.5 seconds. On an NVMe 2.0+ controller taking longer to assert CSTS.RDY (e.g. via kvm/irq_test.c with no outer timeout), nvme_wait_rdy() times out early and fails the assertion. Using max(CAP.TO, NVME_CRTO_CRWMT(crto)) when NVME_CAP_CRMS_CRWMS is set matches drivers/nvme/host/core.c. [ ... ] > +static void nvme_recover(struct vfio_pci_device *device) > +{ > + nvme_disable_ctrl(device); > + vfio_pci_device_reset(device); > + vfio_pci_msix_reenable(device, 0, device->driver.msi + 1); > + nvme_enable_ctrl(device); > + nvme_create_io_queues(device); > +} [Severity: Low] Can vfio_pci_device_reset() abort the test here if the NVMe function does not advertise VFIO_DEVICE_FLAGS_RESET? nvme_probe() binds without checking VFIO_DEVICE_FLAGS_RESET. When vdev->reset_works is false, VFIO_DEVICE_RESET returns -EINVAL and vfio_pci_device_reset() aborts on any failed memcpy, including the unmapped-IOVA tests. Checking VFIO_DEVICE_FLAGS_RESET in nvme_probe(), or gating vfio_pci_device_reset() and vfio_pci_msix_reenable() on it in nvme_recover(), would avoid this abort. [ ... ] > + if (!memcmp(hdr->magic, NVME_SCRATCH_MAGIC, sizeof(NVME_SCRATCH_MAGIC))= ) { > + if (le64_to_cpu(hdr->size) >=3D max_size) > + return; > + > + start =3D NVME_SCRATCH_HDR_SIZE + le64_to_cpu(hdr->size); > + } > + > + chunk =3D min_t(u64, NVME_SCRATCH_CHUNK, max_size); > + end =3D NVME_SCRATCH_HDR_SIZE + max_size; > + for (offset =3D start; offset < end; offset +=3D size) { > + size =3D min_t(u64, end - offset, chunk); > + > + ret =3D nvme_scratch_rw(device, nvme_cmd_read, offset, size); [Severity: Low] Can an unaligned on-disk hdr->size cause nvme_claim_scratch() to abort in nvme_prep_rw_cmd()? If a small backing image was claimed with 512-byte logical blocks at a non-4-KiB-aligned size and is later grown and attached with 4 KiB blocks, start is not aligned to 1ULL << state->lba_shift, tripping the IS_ALIGNED() assertion in nvme_prep_rw_cmd(). Checking IS_ALIGNED(le64_to_cpu(hdr->size), 1ULL << state->lba_shift) or rounding start down to an LBA boundary would handle this cleanly. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261204015203.3180= 20-1-jrhilke@google.com?part=3D1