qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: qemu-devel@nongnu.org
Cc: Peter Maydell <peter.maydell@linaro.org>,
	Gao Shiyuan <gaoshiyuan@baidu.com>,
	Zuo Boqun <zuoboqun@baidu.com>
Subject: [PULL 14/18] virtio-pci: Add lookup subregion of VirtIOPCIRegion MR
Date: Wed, 11 Sep 2024 09:52:08 -0400	[thread overview]
Message-ID: <ffa8a3e3b2e6ff017113b98d500d6a9e05b1560a.1726062663.git.mst@redhat.com> (raw)
In-Reply-To: <cover.1726062663.git.mst@redhat.com>

From: Gao Shiyuan <gaoshiyuan@baidu.com>

Now virtio_address_space_lookup only lookup common/isr/device/notify
MR and exclude their subregions.

When VHOST_USER_PROTOCOL_F_HOST_NOTIFIER enable, the notify MR has
host-notifier subregions and we need use host-notifier MR to
notify the hardware accelerator directly instead of eventfd notify.

Further more, maybe common/isr/device MR also has subregions in
the future, so need memory_region_find for each MR incluing
their subregions.

Add lookup subregion of VirtIOPCIRegion MR instead of only lookup container MR.

Fixes: a93c8d8 ("virtio-pci: Replace modern_as with direct access to modern_bar")
Co-developed-by: Zuo Boqun <zuoboqun@baidu.com>
Signed-off-by: Gao Shiyuan <gaoshiyuan@baidu.com>
Signed-off-by: Zuo Boqun <zuoboqun@baidu.com>
Message-Id: <20240903120304.97833-1-gaoshiyuan@baidu.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 hw/virtio/virtio-pci.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c
index 524b63e5c7..4d832fe845 100644
--- a/hw/virtio/virtio-pci.c
+++ b/hw/virtio/virtio-pci.c
@@ -615,8 +615,12 @@ static MemoryRegion *virtio_address_space_lookup(VirtIOPCIProxy *proxy,
         reg = &proxy->regs[i];
         if (*off >= reg->offset &&
             *off + len <= reg->offset + reg->size) {
-            *off -= reg->offset;
-            return &reg->mr;
+            MemoryRegionSection mrs = memory_region_find(&reg->mr,
+                                        *off - reg->offset, len);
+            assert(mrs.mr);
+            *off = mrs.offset_within_region;
+            memory_region_unref(mrs.mr);
+            return mrs.mr;
         }
     }
 
-- 
MST



  parent reply	other threads:[~2024-09-11 14:30 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-11 13:51 [PULL 00/18] virtio,pc,pci: features, fixes, cleanups Michael S. Tsirkin
2024-09-11 13:51 ` [PULL 01/18] virtio: Allow .get_vhost() without vhost_started Michael S. Tsirkin
2024-09-11 13:51 ` [PULL 02/18] virtio: Always reset vhost devices Michael S. Tsirkin
2024-09-11 13:51 ` [PULL 03/18] hw: Move declaration of IRQState to header and add init function Michael S. Tsirkin
2024-09-11 13:51 ` [PULL 04/18] hw/isa/vt82c686.c: Embed i8259 irq in device state instead of allocating Michael S. Tsirkin
2024-09-11 13:51 ` [PULL 05/18] pci: don't skip function 0 occupancy verification for devfn auto assign Michael S. Tsirkin
2024-09-11 13:51 ` [PULL 06/18] hw/pci/pci-hmp-cmds: Avoid displaying bogus size in 'info pci' Michael S. Tsirkin
2024-09-11 13:51 ` [PULL 07/18] virtio: rename virtio_split_packed_update_used_idx Michael S. Tsirkin
2024-09-11 13:51 ` [PULL 08/18] intel_iommu: Fix invalidation descriptor type field Michael S. Tsirkin
2024-09-11 13:51 ` [PULL 09/18] intel_iommu: Make PASID-cache and PIOTLB type invalid in legacy mode Michael S. Tsirkin
2024-09-11 13:51 ` [PULL 10/18] tests/acpi: pc: allow DSDT acpi table changes Michael S. Tsirkin
2024-09-11 13:51 ` [PULL 11/18] hw/i386/acpi-build: Return a pre-computed _PRT table Michael S. Tsirkin
2024-09-11 13:52 ` [PULL 12/18] tests/acpi: pc: update golden masters for DSDT Michael S. Tsirkin
2024-09-11 13:52 ` [PULL 13/18] vhost_net: configure all host notifiers in a single MR transaction Michael S. Tsirkin
2024-09-11 13:52 ` Michael S. Tsirkin [this message]
2024-09-17 20:19   ` [PULL 14/18] virtio-pci: Add lookup subregion of VirtIOPCIRegion MR Peter Xu
2024-09-11 13:52 ` [PULL 15/18] hw/cxl: fix physical address field in get scan media results output Michael S. Tsirkin
2024-09-11 13:52 ` [PULL 16/18] hw/audio/virtio-sound: fix heap buffer overflow Michael S. Tsirkin
2024-09-13 18:47   ` Volker Rümelin
2024-09-11 13:52 ` [PULL 17/18] virtio-mem: don't warn about THP sizes on a kernel without THP support Michael S. Tsirkin
2024-09-11 13:52 ` [PULL 18/18] hw/acpi/ich9: Add periodic and swsmi timer Michael S. Tsirkin
2024-09-13  9:24 ` [PULL 00/18] virtio,pc,pci: features, fixes, cleanups Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ffa8a3e3b2e6ff017113b98d500d6a9e05b1560a.1726062663.git.mst@redhat.com \
    --to=mst@redhat.com \
    --cc=gaoshiyuan@baidu.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=zuoboqun@baidu.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).