From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9439D606A33A for ; Fri, 4 Dec 2026 02:15:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=G2K1V8jR; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=F3d2Nw6y DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Reply-To:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Date: Content-Transfer-Encoding:Content-Type:References:In-Reply-To:Cc:To:Subject: From:Message-ID:MIME-Version:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Unsubscribe-Post:List-Owner; bh=8/ssy5T0xm8aBYhNArQGPiwzhZnUbUKkSyKA+7dFMB4=; b=G2K1V8jRuHEQNAOcy4UApnSKnP NTJ9NxWJS12KOxfvoOLOwGWkKB5Idt3dYyUEFKtrL51ZRfjTUlFwoHlQCahGoft1UM3t/ekyYbxsY XPZaowz1o9Fi/yigvYBHByUCf0DGA7sDGmOs2btOTprKyqFF+zqMBfivxxz2W+rJbF4F6SVCI8FB8 WrzdOT1v8F0QKb+eP57WDs5X6RRovHdZhOK3+9gnVmDE/cVrFqQYc7c5Ku/FWOUkROpWIHYVnirZJ TulOI7cg3DJ9YZjO3PPtiUTJ6DzYU//Hfs8KOGj0Zrg57V4HfNonTZgMh/0qoJUReJ+gETGPSQHmH 2W0Tm+Eg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xZIpm-0000000GOyK-19yR; Fri, 04 Dec 2026 02:15:38 +0000 Received: from sea.source.kernel.org ([2600:3c0a:e001:78e:0:1991:8:25]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xZIpk-0000000GOyB-3omK for linux-nvme@lists.infradead.org; Fri, 04 Dec 2026 02:15:36 +0000 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id 371EC441EE; Fri, 4 Dec 2026 02:15:36 +0000 (UTC) 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 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-BeenThere: linux-nvme@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: sashiko-reviews@lists.linux.dev Sender: "Linux-nvme" X-Spam-Status: No, score=-11.3 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 X-Archived-By: 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