Skip to contentSkip to conversation

vhost: skip RAM device memory sections

PATCH In review ZhiPeng Lu 2 participants 2 messages Apr 7, 2017

lore
Share & tools
lore

ZhiPeng Lu

author
#0 lore raw

PATCH 1/1 vhost: skip RAM device memory sections

A RAM device represents a mapping to a physical device, such as to a PCI
* MMIO BAR of an vfio-pci assigned device.
Vhost listens to this region,and increases the region's reference count while passthrough?for?network adapters (Physical Function, PF or Virtual Function, VF).
After detaching network adapters with vhost backend dirver or vhost user dirver,
it unregister vhost listen function by memory_listener_unregister.
After detaching the passthrough pf or vf,
the RAM device region's reference by vhost listener increated can not be released, due to vhost listen function does not exist.So let's just skip RAM device memory.

---
 hw/virtio/vhost.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
hw/virtio/vhost.c +2 -1
index 613494d..c1ff98f 100644
@@ -611,7 +611,8 @@ static void vhost_set_memory(MemoryListener *listener,
 static bool vhost_section(MemoryRegionSection *section)
 {
     return memory_region_is_ram(section->mr) &&
-        !memory_region_is_rom(section->mr);
+        !memory_region_is_rom(section->mr) &&
+        !memory_region_is_skip_dump(section->mr);
 }
 
 static void vhost_begin(MemoryListener *listener)
Signature · 1 line
1.8.3.1
#1 lore raw
Quoted 6 lines · ZhiPeng Lu

A RAM device represents a mapping to a physical device, such as to a PCI
* MMIO BAR of an vfio-pci assigned device.
Vhost listens to this region,and increases the region's reference count while passthrough?for?network adapters (Physical Function, PF or Virtual Function, VF).
After detaching network adapters with vhost backend dirver or vhost user dirver,
it unregister vhost listen function by memory_listener_unregister.

Shouldn't that drop all references? That might be a cleaner fix.

Quoted 26 lines

After detaching the passthrough pf or vf,
the RAM device region's reference by vhost listener increated can not be released, due to vhost listen function does not exist.So let's just skip RAM device memory.

---
 hw/virtio/vhost.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
hw/virtio/vhost.c +2 -1
index 613494d..c1ff98f 100644
@@ -611,7 +611,8 @@ static void vhost_set_memory(MemoryListener *listener,
 static bool vhost_section(MemoryRegionSection *section)
 {
     return memory_region_is_ram(section->mr) &&
-        !memory_region_is_rom(section->mr);
+        !memory_region_is_rom(section->mr) &&
+        !memory_region_is_skip_dump(section->mr);
 }
 
 static void vhost_begin(MemoryListener *listener)
Signature · 1 line
1.8.3.1