vhost memory management doesn't care about non-memory (e.g. PIO) or non-RAM
regions. Adjust the filtering to reflect that, and move it earlier so it
applies to mem_sections too.
Signed-off-by: Avi Kivity <avi@redhat.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
#include "hw/hw.h"
#include "range.h"
#include <linux/vhost.h>
#include "hw/hw.h"
#include "range.h"
#include <linux/vhost.h>
+#include "exec-memory.h"
static void vhost_dev_sync_region(struct vhost_dev *dev,
MemoryRegionSection *section,
static void vhost_dev_sync_region(struct vhost_dev *dev,
MemoryRegionSection *section,
- if (!memory_region_is_ram(section->mr)) {
- return;
- }
-
dev->mem = g_realloc(dev->mem, s);
if (log_dirty) {
dev->mem = g_realloc(dev->mem, s);
if (log_dirty) {
+static bool vhost_section(MemoryRegionSection *section)
+{
+ return section->address_space == get_system_memory()
+ && memory_region_is_ram(section->mr);
+}
+
static void vhost_region_add(MemoryListener *listener,
MemoryRegionSection *section)
{
struct vhost_dev *dev = container_of(listener, struct vhost_dev,
memory_listener);
static void vhost_region_add(MemoryListener *listener,
MemoryRegionSection *section)
{
struct vhost_dev *dev = container_of(listener, struct vhost_dev,
memory_listener);
+ if (!vhost_section(section)) {
+ return;
+ }
+
++dev->n_mem_sections;
dev->mem_sections = g_renew(MemoryRegionSection, dev->mem_sections,
dev->n_mem_sections);
++dev->n_mem_sections;
dev->mem_sections = g_renew(MemoryRegionSection, dev->mem_sections,
dev->n_mem_sections);
+ if (!vhost_section(section)) {
+ return;
+ }
+
vhost_set_memory(listener, section, false);
for (i = 0; i < dev->n_mem_sections; ++i) {
if (dev->mem_sections[i].offset_within_address_space
vhost_set_memory(listener, section, false);
for (i = 0; i < dev->n_mem_sections; ++i) {
if (dev->mem_sections[i].offset_within_address_space