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=1796379402; b=c8RbygzEyN4NjkEtG/GDeLVOrb14u1tCz52giHgMNpcY1o2HTEN6V+1zHwz2qo+rkwbm DU3GgA7igkuM2qZwd9BVqpBXX3k4Vj00r5A7J2wE3veRXlZYASkNEO88N+vzRjNVmQSqc TqpwVOjizwW29KGgdlFg5GTnnAVXm9uaGRuR5ovYvrRDhCzlXw2qDMAv+O7Rjf+WR2Jmr pZkhQ72MRboJSb9lTVPqLbMKZPa7xUiHvfX6lHwGPP/fAJf5e4f/gU6dvts6a1HZUu2Wc grYH00b3bJEi3L0vOcp1OS7cQzH0FC1aB3nuBWekBElI+/wxnkOPSc1QNy/0Vlx4UJQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796379402; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=lndyAdfiFcizdg7Sn11qaojZVvFsI368p0WLeHKG+ZY=; b=SYqw4pW/boA6XLrPZca2ncgLSisa2eOyzalZvdt6MCg8qPrXyYuGXMCz2A/RLO5OZSpR AxX0cyUVtokgxPgOdguQo5ojq29fqEQJ3K5/AKNMCvR5LwD8UcM1luOC/6xVvtEvhKZan wqrNdHBrHa3mwzP8cP89BXGXMd2IONnZsfoaFkWomska6KCPBL+QtrrSVM4/ccJYBvkbk B4wrujObioXDvgzMSaXYx2bQWl9MiW0ORKLcmiA8yeSf+1Q7X5/VFpn0+Ih6E5gD5Ba08 Qd0UZzDHu9ns0bxmPuJkVkRtH9akwURVgKws+lpoWcJApM2nXuHGlfDTbFA811Y7aFg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=FaXGuMHP; 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 D69E1606A322; Fri, 4 Dec 2026 10:16:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=FaXGuMHP Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0230E1F000C2; Fri, 4 Dec 2026 10:16:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796379402; bh=lndyAdfiFcizdg7Sn11qaojZVvFsI368p0WLeHKG+ZY=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=FaXGuMHPmNveY5uX/uxL3y1oKx1nqhJi/g350vgsoYptkexLHDvvvMfTCj6IUSXA4 6hwOvdMG3nlhx8QEsPDnMYCKzETkmWDmFXzxVWLhq5NtYa3Cw1XUU6y97U1VLAPdoB XZkUPw5Rkx+WhNG/HwTVm19F3vgDSt57vSAt+y/E= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, "Denis V. Lunev" , "David Hildenbrand (Arm)" , "Michael S. Tsirkin" , Dickson Wu , Sasha Levin Subject: [PATCH 6.12 005/555] virtio_balloon: quiesce balloon work before device shutdown Date: Fri, 4 Dec 2026 19:00:48 +0900 Message-ID: <20261204100604.159655575@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100603.988357525@linuxfoundation.org> References: <20261204100603.988357525@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Denis V. Lunev commit 7e17eef04600c399c7e0f5ce765da5cf9d40d8e1 upstream. Commit 8bd2fa086a04 ("virtio: break and reset virtio devices on device_shutdown()") added a generic virtio bus .shutdown handler that breaks and resets every virtio device during device_shutdown(), i.e. on reboot and kexec. virtio_balloon provides no .shutdown of its own, so that generic path runs while the balloon's asynchronous work is still armed. Once the device has been broken, virtqueue_add_inbuf() in virtballoon_free_page_report() returns -EIO and trips its WARN_ON_ONCE(). On a kernel booted with panic_on_warn that turns an ordinary reboot, for example a kexec based upgrade, into a fatal panic in the middle of device_shutdown(), so the machine never reaches the new kernel. Relaxing that single WARN_ON_ONCE() would only hide the symptom: the inflate/deflate and OOM paths do not warn, they call wait_event(vb->acked, ...) and would instead block forever on a broken queue that can no longer complete. The device has to be quiesced, not just kept quiet. Add a .shutdown handler that quiesces the balloon via the shared virtballoon_quiesce() helper while the device is still alive, and only then breaks and resets it via virtio_device_shutdown(). Unlike virtballoon_remove() the balloon workqueue is not destroyed, as shutdown does not free the device and cancel_work_sync() together with stop_update already prevent any further work from being queued. Fixes: 8bd2fa086a04 ("virtio: break and reset virtio devices on device_shutdown()") Signed-off-by: Denis V. Lunev Reviewed-by: David Hildenbrand (Arm) Signed-off-by: Michael S. Tsirkin Message-ID: <20260624140846.2616797-4-den@openvz.org> Signed-off-by: Dickson Wu Signed-off-by: Sasha Levin --- drivers/virtio/virtio_balloon.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloon.c index a3b6e38752ab9..14443e66d118a 100644 --- a/drivers/virtio/virtio_balloon.c +++ b/drivers/virtio/virtio_balloon.c @@ -1158,6 +1158,12 @@ static void virtballoon_remove(struct virtio_device *vdev) kfree(vb); } +static void virtballoon_shutdown(struct virtio_device *vdev) +{ + virtballoon_quiesce(vdev->priv); + virtio_device_shutdown(vdev); +} + #ifdef CONFIG_PM_SLEEP static int virtballoon_freeze(struct virtio_device *vdev) { @@ -1228,6 +1234,7 @@ static struct virtio_driver virtio_balloon_driver = { .validate = virtballoon_validate, .probe = virtballoon_probe, .remove = virtballoon_remove, + .shutdown = virtballoon_shutdown, .config_changed = virtballoon_changed, #ifdef CONFIG_PM_SLEEP .freeze = virtballoon_freeze, -- 2.53.0