[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 1/1] virtio-pci: return RAM device MR when set host notifier
|
From: |
Michael S. Tsirkin |
|
Subject: |
Re: [PATCH 1/1] virtio-pci: return RAM device MR when set host notifier success |
|
Date: |
Fri, 16 Aug 2024 06:29:33 -0400 |
On Mon, Aug 12, 2024 at 08:20:27PM +0800, Gao Shiyuan wrote:
> 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.
I can't really parse this.
> Co-developed-by: Zuo Boqun <zuoboqun@baidu.com>
> Signed-off-by: Gao Shiyuan <gaoshiyuan@baidu.com>
> Signed-off-by: Zuo Boqun <zuoboqun@baidu.com>
CC Jason
> ---
> 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 ®->mr;
> + mr = ®->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;
> }
> }
Poking at internals of MR like this is not nice.
Doesn't memory_region_find work for this?
>
> --
> 2.39.3 (Apple Git-146)