All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/1] virtio-pci: return RAM device MR when set host notifier success
@ 2024-08-12 12:20 Gao Shiyuan via
  2024-08-16 10:12 ` Gao,Shiyuan via
  2024-08-16 10:29 ` Michael S. Tsirkin
  0 siblings, 2 replies; 5+ messages in thread
From: Gao Shiyuan via @ 2024-08-12 12:20 UTC (permalink / raw)
  To: Michael S. Tsirkin, Tiwei Bie, zuoboqun; +Cc: qemu-devel, Gao Shiyuan

When vhost-user backend register memory region based host notifiers,
we should return RAM device MR of notify region MR's subregion in
virtio_address_space_lookup.

In seabios, it will use virtio PCI Configration Access Capability
access notify region when assign notify region above 4GB. This will
exit to QEMU and invoke virtio_address_space_write. When vhost-user
backend register memory region based host notifiers, return RAM device
MR instead of notify region MR is suitable.

Co-developed-by: Zuo Boqun <zuoboqun@baidu.com>
Signed-off-by: Gao Shiyuan <gaoshiyuan@baidu.com>
Signed-off-by: Zuo Boqun <zuoboqun@baidu.com>
---
 hw/virtio/virtio-pci.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c
index 9534730bba..167ac9718a 100644
--- a/hw/virtio/virtio-pci.c
+++ b/hw/virtio/virtio-pci.c
@@ -610,13 +610,22 @@ static MemoryRegion *virtio_address_space_lookup(VirtIOPCIProxy *proxy,
 {
     int i;
     VirtIOPCIRegion *reg;
+    MemoryRegion *mr, *submr;
 
     for (i = 0; i < ARRAY_SIZE(proxy->regs); ++i) {
         reg = &proxy->regs[i];
         if (*off >= reg->offset &&
             *off + len <= reg->offset + reg->size) {
             *off -= reg->offset;
-            return &reg->mr;
+            mr = &reg->mr;
+            QTAILQ_FOREACH(submr, &mr->subregions, subregions_link) {
+                if (*off >= submr->addr &&
+                    *off + len < submr->addr + submr->size) {
+                    *off -= submr->addr;
+                    return submr;
+                }
+            }
+            return mr;
         }
     }
 
-- 
2.39.3 (Apple Git-146)



^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-08-16 12:35 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-12 12:20 [PATCH 1/1] virtio-pci: return RAM device MR when set host notifier success Gao Shiyuan via
2024-08-16 10:12 ` Gao,Shiyuan via
2024-08-16 10:29 ` Michael S. Tsirkin
2024-08-16 12:12   ` Jason Wang
2024-08-16 12:33   ` Gao,Shiyuan via

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.