vhost: fix incorrect userspace address
authorAvi Kivity <avi@redhat.com>
Mon, 9 Jan 2012 11:09:40 +0000 (13:09 +0200)
committerAvi Kivity <avi@redhat.com>
Mon, 9 Jan 2012 11:09:40 +0000 (13:09 +0200)
MemoryListener::region_add() gives us a slice of a MemoryRegion, not a
region.  Adjust the userspace address to reflect that.

Signed-off-by: Avi Kivity <avi@redhat.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
hw/vhost.c

index cd56e75d0a6be62b0553b5013265eb26927bc1b0..541c7163b26cfec7e0da0676e45578eca70ea92a 100644 (file)
@@ -378,7 +378,7 @@ static void vhost_set_memory(MemoryListener *listener,
     assert(size);
 
     /* Optimize no-change case. At least cirrus_vga does this a lot at this time. */
-    ram = memory_region_get_ram_ptr(section->mr);
+    ram = memory_region_get_ram_ptr(section->mr) + section->offset_within_region;
     if (add) {
         if (!vhost_dev_cmp_memory(dev, start_addr, size, (uintptr_t)ram)) {
             /* Region exists with same address. Nothing to do. */