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=1796467288; b=I2x58n4PswDsebwCWFjMkOd7uWcIHoMUWaii1T+9rn8+q3C4P14MRm8Y1aSTlcANQ21a 9svxJaK3eRLQBMxlB1J1HcI2O5+utFF0icRJUUJoAX4mCLrp3lOXqxMMNRQ3k8isOL8Lw 5GBh/tzPBJLbvzfZ+QsT+FVsIMeOvLuMD9Lke86dBV6gWgTB2Hx7yaC5+JepvmfWKDdpu cnDSFXFkreYlEHriEcRo9VHKzuJ8fh1057jcGrRy6NP+/qpRqAT7TjPvSzh10TgG3T/J3 Nx51l6rUznQrjv8orvFE6SnVQ0tmpnTmhJ37dc3JEENPzDBmVCVoRTmcZdO+a1oo+ww== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796467288; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=/JLRBHlsYRM7545/HxJX+AS1M8VjF1Djbn3fiJFP2zc=; b=asFs2khISRVCz9KGZ8c0/PpgywUvADwh71l5kClf0wfqtrhaPOwfbbKAU1hwOOsnXvSq VldKv46sVrU9fPKIdYf1O1R4IyLEcuC9Wyz/rJq+Q/ZzvtmctNlY1ZFDRBufOk5/HvrNm jz+LofLzd8BZ2V1ola+lEg1Exm+W3SYQRr7/YL7Pelm3uBRlTmJoa9q7mUACcdTccpE09 IuE9y5veb3IEWm/h/vNqsCRyt4fwx51oDIEIGl4Wo9SvD5BJQ2MQ/9srEsuHQVEySjaeh hDOTLlHkTGXHnC5cIX2Pf7qstgiHQ4juAhRu56vuGmxk36MByoc7tbwE8GGGPyB9L5w== 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=CXqL4C0m; 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 F2891606A322 for ; Sat, 5 Dec 2026 10:41:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=CXqL4C0m Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5F90D1F00936; Sat, 5 Dec 2026 10:41:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796467287; bh=/JLRBHlsYRM7545/HxJX+AS1M8VjF1Djbn3fiJFP2zc=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=CXqL4C0mEbPrLY43CjogESYgQ1/D2w4yiAg37I46Cf7gJ13Har/HdFto2RmtqlGBF FYQUwBnUjtdpiO/INb7vp6VWJ0ZrxWqJ5T92NYTPZZ5fUExx2zYQf5biZOn7dieeZf 0gjAvXFlfZYj7rf/MD8Z4/E3I2a2UY2eyi4nd46b3tAJlAC/3ETDSLUlz8S2n19XyE T/LUpNnkzrQ/RFeol/JA3TxGLV5zvcFVm/oAkiQLM1A7QRVLVTWOnM4ZiLOFxmphRw 1jxWr+NE6lFzQS/r85Yo76aVbjE9yU5DLVFoh+Hm/XJQGPrdZ8vJScqdzgpbQfjVib yZvkStfB2W+rA== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH] virtio: reset the device when probe fails Reply-To: sashiko-reviews@lists.linux.dev To: "Peng Fan" Cc: virtualization@lists.linux.dev, "Michael S. Tsirkin" , "Eugenio Perez" In-Reply-To: <20261205-virtio-reset-v1-1-c2203390b005@nxp.com> References: <20261205-virtio-reset-v1-1-c2203390b005@nxp.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Sat, 05 Dec 2026 10:41:27 +0000 X-Mailing-List: virtualization@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Medium] virtio: probe error reset clears ACKNOWLEDGE and leaves FAILED set on rebind -- commit d8797162668785b8b6784f10a498e39eb14b7ecf Author: Peng Fan virtio: reset the device when probe fails This commit calls virtio_reset_device() in the error path of virtio_dev_probe() before setting VIRTIO_CONFIG_S_FAILED so that virtqueues enabled before a probe failure are cleared for a later rebind. > diff --git a/drivers/virtio/virtio.c b/drivers/virtio/virtio.c > index c8be1a3f479d6..bf3ae72104567 100644 > --- a/drivers/virtio/virtio.c > +++ b/drivers/virtio/virtio.c > @@ -362,6 +362,12 @@ static int virtio_dev_probe(struct device *_d) > return 0; > =20 > err: > + /* > + * Reset the device so a failed probe does not leave enabled queues > + * behind (virtio-pci queue_enable can only be cleared by reset), which > + * would otherwise make a later rebind fail in setup_vq(). > + */ > + virtio_reset_device(dev); > virtio_add_status(dev, VIRTIO_CONFIG_S_FAILED); [Severity: Medium] Does resetting the device here clear VIRTIO_CONFIG_S_ACKNOWLEDGE and leave VIRTIO_CONFIG_S_FAILED set across a subsequent rebind? virtio_reset_device() zeroes device status, so virtio_add_status() leaves only VIRTIO_CONFIG_S_FAILED set. On rebind, virtio_dev_probe() relies on the register_virtio_device() / virtio_dev_remove() invariant and ORs VIRTIO_CONFIG_S_DRIVER directly onto the existing status. That drives status from VIRTIO_CONFIG_S_FAILED | VIRTIO_CONFIG_S_DRIVER through VIRTIO_CONFIG_S_DRIVER_OK without resetting out of the failed state or setting VIRTIO_CONFIG_S_ACKNOWLEDGE, violating the Virtio specification (sections 2.1.1/2.1.2 and 3.1.1). Strict devices or vDPA backends can reject VIRTIO_CONFIG_S_FEATURES_OK on rebind, defeating the fix. Even on lenient backends, the rebound device keeps VIRTIO_CONFIG_S_FAILED set, which virtio_device_freeze() latches into dev->failed and re-applies on future restores. Setting VIRTIO_CONFIG_S_ACKNOWLEDGE before VIRTIO_CONFIG_S_FAILED in the error path (as virtio_device_restore_priv() does), and resetting and re-acknowledging on entry to virtio_dev_probe() when status is not cleanly VIRTIO_CONFIG_S_ACKNOWLEDGE, would keep rebind spec-compliant. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261205-virtio-res= et-v1-1-c2203390b005@nxp.com?part=3D1