vhost: skip ROM sections
authorMichael S. Tsirkin <mst@redhat.com>
Tue, 24 Jan 2017 17:03:40 +0000 (19:03 +0200)
committerMichael S. Tsirkin <mst@redhat.com>
Wed, 1 Feb 2017 01:37:18 +0000 (03:37 +0200)
vhost does not support RO protections on memory at the moment - adding
ROMs would mean that e.g. a buggy guest might change them in-memory - a
condition from which guest reset does not recover. Not nice.

We also definitely don't want to try logging writes into ROMs -
in particular guests set very high addresses for ROM BARs
so logging these writes would waste a lot of memory.

Maybe ROMs could be supported with the iotlb variant -
not sure, but there seems to be no good reason for virtio
to try to do DMA from ROM. So let's just skip ROM memory.

Suggested-by: Laurent Vivier <lvivier@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Laurent Vivier <lvivier@redhat.com>
Tested-by: Laurent Vivier <lvivier@redhat.com>
hw/virtio/vhost.c

index b124d97d7c013e1a2fa01d8e26b8e5f91cdce0a4..febe519bbdfc97af6ee8d1204b25d1ddee4d790d 100644 (file)
@@ -612,7 +612,8 @@ static void vhost_set_memory(MemoryListener *listener,
 
 static bool vhost_section(MemoryRegionSection *section)
 {
-    return memory_region_is_ram(section->mr);
+    return memory_region_is_ram(section->mr) &&
+        !memory_region_is_rom(section->mr);
 }
 
 static void vhost_begin(MemoryListener *listener)