From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DDA96CCA485 for ; Wed, 6 Jul 2022 15:31:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233814AbiGFPbQ (ORCPT ); Wed, 6 Jul 2022 11:31:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44164 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233781AbiGFPbJ (ORCPT ); Wed, 6 Jul 2022 11:31:09 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5325B26127; Wed, 6 Jul 2022 08:31:06 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id E493B61FE8; Wed, 6 Jul 2022 15:31:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A0815C3411C; Wed, 6 Jul 2022 15:31:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1657121465; bh=aArpVS4VNheVFDiOhTep3qwKK7+LFJJviBSs/dkrB5s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RbE7mkkg9UfI21kF5HqUIL21ItaEPBVtRGn/kbuW1SSIM5Dz5UU0g48rIeUTObzAR aA8HUj+QEyb3bI91bVV1Q2Q4s/Klbomnuf7eY8HJNehSIe7Cwt6iSetzCT+YYR5nZG kIfbEF3eEHmw40PoliJvqHp6a8OAUnL8qIeVqRvPM5pGAYuTE/lX9rXkiCjkTi4YvY Fy7MJlVqxyzNNYx5kLBO4eut9BMjVNk4JVtZhg/KiqXiplW/mAEGvUZRlM+Bkm/5Mx 3xEUN/ZjPfkzONSReNMvQuF0KxxHjRv7Vl/FYHUBSSQawbcSfF03BSWij7k8g4okg/ ZFwQADyvI0dJw== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Stephan Gerhold , "Michael S . Tsirkin" , Sasha Levin , jasowang@redhat.com, virtualization@lists.linux-foundation.org Subject: [PATCH AUTOSEL 5.18 07/22] virtio_mmio: Restore guest page size on resume Date: Wed, 6 Jul 2022 11:30:25 -0400 Message-Id: <20220706153041.1597639-7-sashal@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220706153041.1597639-1-sashal@kernel.org> References: <20220706153041.1597639-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Stephan Gerhold [ Upstream commit e0c2ce8217955537dd5434baeba061f209797119 ] Virtio devices might lose their state when the VMM is restarted after a suspend to disk (hibernation) cycle. This means that the guest page size register must be restored for the virtio_mmio legacy interface, since otherwise the virtio queues are not functional. This is particularly problematic for QEMU that currently still defaults to using the legacy interface for virtio_mmio. Write the guest page size register again in virtio_mmio_restore() to make legacy virtio_mmio devices work correctly after hibernation. Signed-off-by: Stephan Gerhold Message-Id: <20220621110621.3638025-3-stephan.gerhold@kernkonzept.com> Signed-off-by: Michael S. Tsirkin Signed-off-by: Sasha Levin --- drivers/virtio/virtio_mmio.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/virtio/virtio_mmio.c b/drivers/virtio/virtio_mmio.c index 7522832529dd..fe696aafaed8 100644 --- a/drivers/virtio/virtio_mmio.c +++ b/drivers/virtio/virtio_mmio.c @@ -556,6 +556,9 @@ static int virtio_mmio_restore(struct device *dev) { struct virtio_mmio_device *vm_dev = dev_get_drvdata(dev); + if (vm_dev->version == 1) + writel(PAGE_SIZE, vm_dev->base + VIRTIO_MMIO_GUEST_PAGE_SIZE); + return virtio_device_restore(&vm_dev->vdev); } -- 2.35.1