qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Wang Xin <wangxinxin.wang@huawei.com>
To: <qemu-devel@nongnu.org>
Cc: Wang Xin <wangxinxin.wang@huawei.com>,
	jianjay.zhou@huawei.com, weidong.huang@huawei.com,
	dgilbert@redhat.com, mst@redhat.com
Subject: [PATCH 1/2] memory: Allow a MemoryRegion to be marked no_vhost
Date: Fri, 28 Aug 2020 17:59:52 +0800	[thread overview]
Message-ID: <20200828095953.2276-2-wangxinxin.wang@huawei.com> (raw)
In-Reply-To: <20200828095953.2276-1-wangxinxin.wang@huawei.com>

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




  reply	other threads:[~2020-08-28 10:01 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-28  9:59 [PATCH 0/2][RFC] exclude ivshmem mr from vhost sections Wang Xin
2020-08-28  9:59 ` Wang Xin [this message]
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)

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=20200828095953.2276-2-wangxinxin.wang@huawei.com \
    --to=wangxinxin.wang@huawei.com \
    --cc=dgilbert@redhat.com \
    --cc=jianjay.zhou@huawei.com \
    --cc=mst@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=weidong.huang@huawei.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).