lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230919110225.2282914-2-Jiqian.Chen@amd.com>
Date:   Tue, 19 Sep 2023 19:02:24 +0800
From:   Jiqian Chen <Jiqian.Chen@....com>
To:     Gerd Hoffmann <kraxel@...hat.com>,
        Jason Wang <jasowang@...hat.com>,
        "Michael S . Tsirkin" <mst@...hat.com>,
        Xuan Zhuo <xuanzhuo@...ux.alibaba.com>,
        David Airlie <airlied@...hat.com>,
        "Gurchetan Singh" <gurchetansingh@...omium.org>,
        Chia-I Wu <olvaffe@...il.com>,
        Marc-André Lureau <marcandre.lureau@...il.com>,
        "Robert Beckett" <bob.beckett@...labora.com>,
        <qemu-devel@...gnu.org>
CC:     <linux-kernel@...r.kernel.org>,
        Stefano Stabellini <sstabellini@...nel.org>,
        Anthony PERARD <anthony.perard@...rix.com>,
        Roger Pau Monné <roger.pau@...rix.com>,
        "Dr . David Alan Gilbert" <dgilbert@...hat.com>,
        Alex Deucher <Alexander.Deucher@....com>,
        Christian Koenig <Christian.Koenig@....com>,
        Stewart Hildebrand <Stewart.Hildebrand@....com>,
        Xenia Ragiadakou <burzalodowa@...il.com>,
        Honglei Huang <Honglei1.Huang@....com>,
        Julia Zhang <Julia.Zhang@....com>,
        Huang Rui <Ray.Huang@....com>,
        Jiqian Chen <Jiqian.Chen@....com>
Subject: [QEMU PATCH v5 1/2] virtio-pci: Add freeze_mode case for virtio pci

When guest vm do S3, Qemu will reset and clear some things of virtio
devices, but guest can't aware that, so that may cause some problems.
For excample, Qemu calls virtio_reset->virtio_gpu_gl_reset, that will
destroy render resources of virtio-gpu. As a result, after guest resume,
the display can't come back and we only saw a black screen. Due to guest
can't re-create all the resources, so we need to let Qemu not to destroy
them when S3.

For above purpose, this patch add a new parameter named freeze_mode to
struct VirtIODevice, and when guest suspends, guest can write freeze_mode
to be FREEZE_S3, so that virtio devices can change their reset behavior
on Qemu side according to that mode.

Signed-off-by: Jiqian Chen <Jiqian.Chen@....com>
---
 hw/virtio/virtio-pci.c     | 5 +++++
 hw/virtio/virtio.c         | 1 +
 include/hw/virtio/virtio.h | 2 ++
 3 files changed, 8 insertions(+)

diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c
index edbc0daa18..7a3cca79b4 100644
--- a/hw/virtio/virtio-pci.c
+++ b/hw/virtio/virtio-pci.c
@@ -1651,6 +1651,11 @@ static void virtio_pci_common_write(void *opaque, hwaddr addr,
             proxy->vqs[vdev->queue_sel].enabled = 0;
         }
         break;
+    case VIRTIO_PCI_COMMON_F_MODE:
+        virtio_pci_freeze_mode_t freeze_mode = (virtio_pci_freeze_mode_t)val;
+        if ((1 << freeze_mode) & VIRTIO_PCI_FREEZE_MODE_MASK)
+            vdev->freeze_mode = freeze_mode;
+        break;
     default:
         break;
     }
diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
index 969c25f4cf..4278cedef4 100644
--- a/hw/virtio/virtio.c
+++ b/hw/virtio/virtio.c
@@ -3201,6 +3201,7 @@ void virtio_init(VirtIODevice *vdev, uint16_t device_id, size_t config_size)
     vdev->vhost_started = false;
     vdev->device_id = device_id;
     vdev->status = 0;
+    vdev->freeze_mode = VIRTIO_PCI_FREEZE_MODE_UNFREEZE;
     qatomic_set(&vdev->isr, 0);
     vdev->queue_sel = 0;
     vdev->config_vector = VIRTIO_NO_VECTOR;
diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h
index c8f72850bc..f8bfd9da28 100644
--- a/include/hw/virtio/virtio.h
+++ b/include/hw/virtio/virtio.h
@@ -21,6 +21,7 @@
 #include "qemu/event_notifier.h"
 #include "standard-headers/linux/virtio_config.h"
 #include "standard-headers/linux/virtio_ring.h"
+#include "standard-headers/linux/virtio_pci.h"
 #include "qom/object.h"
 
 /*
@@ -106,6 +107,7 @@ struct VirtIODevice
     DeviceState parent_obj;
     const char *name;
     uint8_t status;
+    virtio_pci_freeze_mode_t freeze_mode;
     uint8_t isr;
     uint16_t queue_sel;
     /**
-- 
2.34.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ