* [PATCH 0/2][RFC] exclude ivshmem mr from vhost sections
@ 2020-08-28 9:59 Wang Xin
2020-08-28 9:59 ` [PATCH 1/2] memory: Allow a MemoryRegion to be marked no_vhost Wang Xin
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Wang Xin @ 2020-08-28 9:59 UTC (permalink / raw)
To: qemu-devel; +Cc: Wang Xin, jianjay.zhou, weidong.huang, dgilbert, mst
The ivshmem me now mapped to vhost memory regions, and it reduces
the number of available memslots of vhost backend, which may
causes vhost backend memory slots limit check failure in
vhost dev init.
Since ivshmem_bar2 not normal RAM in Guest, and it shouldn't
have vhost DMAing into them, exclude it from the vhost sections.
The 1st patch re-spin Dave's patch, see link
https://lists.nongnu.org/archive/html/qemu-devel/2020-01/msg02370.html
However, I'm not sure is there any side effects, or maybe it's
better to add a new device property like 'novhost/nodma'?
Thanks,
Xin
Wang Xin (2):
memory: Allow a MemoryRegion to be marked no_vhost
misc/ivshmem: Mark shared memory regions as no vhost
hw/misc/ivshmem.c | 2 ++
hw/virtio/vhost.c | 5 ++++-
include/exec/memory.h | 21 +++++++++++++++++++++
softmmu/memory.c | 15 +++++++++++++++
4 files changed, 42 insertions(+), 1 deletion(-)
--
2.26.0.windows.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/2] memory: Allow a MemoryRegion to be marked no_vhost
2020-08-28 9:59 [PATCH 0/2][RFC] exclude ivshmem mr from vhost sections Wang Xin
@ 2020-08-28 9:59 ` Wang Xin
2020-08-28 9:59 ` [PATCH 2/2] misc/ivshmem: Mark shared memory regions as no vhost Wang Xin
2020-09-04 4:36 ` [PATCH 0/2][RFC] exclude ivshmem mr from vhost sections Wangxin (Alexander)
2 siblings, 0 replies; 4+ messages in thread
From: Wang Xin @ 2020-08-28 9:59 UTC (permalink / raw)
To: qemu-devel; +Cc: Wang Xin, jianjay.zhou, weidong.huang, dgilbert, mst
Allow a memory region to be marked as 'no_vhost' and
exclude that region from vhost's list build.
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Signed-off-by: Wang Xin <wangxinxin.wang@huawei.com>
---
hw/virtio/vhost.c | 5 ++++-
include/exec/memory.h | 21 +++++++++++++++++++++
softmmu/memory.c | 15 +++++++++++++++
3 files changed, 40 insertions(+), 1 deletion(-)
diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
index 1a1384e7a6..bd50532a30 100644
--- a/hw/virtio/vhost.c
+++ b/hw/virtio/vhost.c
@@ -415,7 +415,10 @@ static bool vhost_section(struct vhost_dev *dev, MemoryRegionSection *section)
{
MemoryRegion *mr = section->mr;
- if (memory_region_is_ram(mr) && !memory_region_is_rom(mr)) {
+ if (memory_region_is_ram(mr) &&
+ !memory_region_is_rom(mr) &&
+ !memory_region_is_no_vhost(mr)) {
+
uint8_t dirty_mask = memory_region_get_dirty_log_mask(mr);
uint8_t handled_dirty;
diff --git a/include/exec/memory.h b/include/exec/memory.h
index 0cfe987ab4..7258fd6996 100644
--- a/include/exec/memory.h
+++ b/include/exec/memory.h
@@ -380,6 +380,7 @@ struct MemoryRegion {
bool global_locking;
uint8_t dirty_log_mask;
bool is_iommu;
+ bool no_vhost;
RAMBlock *ram_block;
Object *owner;
@@ -1205,6 +1206,26 @@ static inline bool memory_region_is_romd(MemoryRegion *mr)
return mr->rom_device && mr->romd_mode;
}
+/**
+ * memory_region_set_no_vhost: Make vhost ignore a memory region
+ *
+ * Makes vhost ignore a memory region, useful if it isn't real
+ * DMAble memory and is at inconvenient addresses
+ *
+ * @mr: the region being updated.
+ * @no_vhost: true to ignore
+ */
+void memory_region_set_no_vhost(MemoryRegion *mr, bool no_vhost);
+
+/**
+ * memory_region_is_no_vhost: Test if memory region is marked no vhost
+ *
+ * Test if the no_vhost flag is set on the memory region
+ *
+ * @mr: the region being tested.
+ */
+bool memory_region_is_no_vhost(const MemoryRegion *mr);
+
/**
* memory_region_get_iommu: check whether a memory region is an iommu
*
diff --git a/softmmu/memory.c b/softmmu/memory.c
index 70b93104e8..5debe22978 100644
--- a/softmmu/memory.c
+++ b/softmmu/memory.c
@@ -2125,6 +2125,21 @@ void memory_region_rom_device_set_romd(MemoryRegion *mr, bool romd_mode)
}
}
+void memory_region_set_no_vhost(MemoryRegion *mr, bool no_vhost)
+{
+ if (mr->no_vhost != no_vhost) {
+ memory_region_transaction_begin();
+ mr->no_vhost = no_vhost;
+ memory_region_update_pending |= mr->enabled;
+ memory_region_transaction_commit();
+ }
+}
+
+bool memory_region_is_no_vhost(const MemoryRegion *mr)
+{
+ return mr->no_vhost;
+}
+
void memory_region_reset_dirty(MemoryRegion *mr, hwaddr addr,
hwaddr size, unsigned client)
{
--
2.26.0.windows.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] misc/ivshmem: Mark shared memory regions as no vhost
2020-08-28 9:59 [PATCH 0/2][RFC] exclude ivshmem mr from vhost sections Wang Xin
2020-08-28 9:59 ` [PATCH 1/2] memory: Allow a MemoryRegion to be marked no_vhost Wang Xin
@ 2020-08-28 9:59 ` Wang Xin
2020-09-04 4:36 ` [PATCH 0/2][RFC] exclude ivshmem mr from vhost sections Wangxin (Alexander)
2 siblings, 0 replies; 4+ messages in thread
From: Wang Xin @ 2020-08-28 9:59 UTC (permalink / raw)
To: qemu-devel; +Cc: Wang Xin, jianjay.zhou, weidong.huang, dgilbert, mst
Since ivshmem_bar2 not normal RAM in Guest, and it shouldn't have
vhost DMAing into them, exclude it from the vhost sections, mark the
shared memory regions as novhost.
Signed-off-by: Wang Xin <wangxinxin.wang@huawei.com>
---
hw/misc/ivshmem.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/hw/misc/ivshmem.c b/hw/misc/ivshmem.c
index 2b6882face..1f3a7a1dfc 100644
--- a/hw/misc/ivshmem.c
+++ b/hw/misc/ivshmem.c
@@ -499,6 +499,7 @@ static void process_msg_shmem(IVShmemState *s, int fd, Error **errp)
}
s->ivshmem_bar2 = &s->server_bar2;
+ memory_region_set_no_vhost(s->ivshmem_bar2, true);
}
static void process_msg_disconnect(IVShmemState *s, uint16_t posn,
@@ -855,6 +856,7 @@ static void ivshmem_common_realize(PCIDevice *dev, Error **errp)
s->ivshmem_bar2 = host_memory_backend_get_memory(s->hostmem);
host_memory_backend_set_mapped(s->hostmem, true);
+ memory_region_set_no_vhost(s->ivshmem_bar2, true);
} else {
Chardev *chr = qemu_chr_fe_get_driver(&s->server_chr);
assert(chr);
--
2.26.0.windows.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* RE: [PATCH 0/2][RFC] exclude ivshmem mr from vhost sections
2020-08-28 9:59 [PATCH 0/2][RFC] exclude ivshmem mr from vhost sections Wang Xin
2020-08-28 9:59 ` [PATCH 1/2] memory: Allow a MemoryRegion to be marked no_vhost Wang Xin
2020-08-28 9:59 ` [PATCH 2/2] misc/ivshmem: Mark shared memory regions as no vhost Wang Xin
@ 2020-09-04 4:36 ` Wangxin (Alexander)
2 siblings, 0 replies; 4+ messages in thread
From: Wangxin (Alexander) @ 2020-09-04 4:36 UTC (permalink / raw)
To: qemu-devel@nongnu.org
Cc: Zhoujian (jay), Huangweidong (C), dgilbert@redhat.com,
mst@redhat.com
Ping.
>
> The ivshmem me now mapped to vhost memory regions, and it reduces
> the number of available memslots of vhost backend, which may
> causes vhost backend memory slots limit check failure in
> vhost dev init.
>
> Since ivshmem_bar2 not normal RAM in Guest, and it shouldn't
> have vhost DMAing into them, exclude it from the vhost sections.
>
> The 1st patch re-spin Dave's patch, see link
> https://lists.nongnu.org/archive/html/qemu-devel/2020-01/msg02370.html
>
> However, I'm not sure is there any side effects, or maybe it's
> better to add a new device property like 'novhost/nodma'?
>
> Thanks,
> Xin
>
> Wang Xin (2):
> memory: Allow a MemoryRegion to be marked no_vhost
> misc/ivshmem: Mark shared memory regions as no vhost
>
> hw/misc/ivshmem.c | 2 ++
> hw/virtio/vhost.c | 5 ++++-
> include/exec/memory.h | 21 +++++++++++++++++++++
> softmmu/memory.c | 15 +++++++++++++++
> 4 files changed, 42 insertions(+), 1 deletion(-)
>
> --
> 2.26.0.windows.1
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-09-04 4:37 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-08-28 9:59 [PATCH 0/2][RFC] exclude ivshmem mr from vhost sections Wang Xin
2020-08-28 9:59 ` [PATCH 1/2] memory: Allow a MemoryRegion to be marked no_vhost Wang Xin
2020-08-28 9:59 ` [PATCH 2/2] misc/ivshmem: Mark shared memory regions as no vhost Wang Xin
2020-09-04 4:36 ` [PATCH 0/2][RFC] exclude ivshmem mr from vhost sections Wangxin (Alexander)
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).