Skip to contentSkip to conversation

vhost: skip ROM sections

PATCH In review Michael S. Tsirkin 2 participants 2 messages Jan 24, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 vhost: skip ROM sections

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. With phys address in the 32T range we would need 1Gbyte sized log - scanning it would take ages, and allocating such huge amount of log memory was also reported to fail on powerpc.

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.

---
 hw/virtio/vhost.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
hw/virtio/vhost.c +2 -1
index 9cacf55..94b8c4a 100644
@@ -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)
Signature · 1 line
MST
Reviewed-by Tested-by on v1 1/1
#1 lore raw
Quoted 11 lines · Michael S. Tsirkin

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. With phys address in the 32T range we would need 1Gbyte sized log - scanning it would take ages, and allocating such huge amount of log memory was also reported to fail on powerpc.

Quoted 6 lines

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.

Quoted 19 lines
---
 hw/virtio/vhost.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
hw/virtio/vhost.c +2 -1
index 9cacf55..94b8c4a 100644
@@ -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)