Patchwork [1/3] vhost: fix incorrect userspace address

login
register
mail settings
Submitter Avi Kivity
Date Jan. 9, 2012, 12:04 p.m.
Message ID <1326110694-5196-2-git-send-email-avi@redhat.com>
Download mbox | patch
Permalink /patch/135008/
State New
Headers show

Comments

Avi Kivity - Jan. 9, 2012, 12:04 p.m.
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>
---
 hw/vhost.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
Michael S. Tsirkin - Jan. 9, 2012, 1:28 p.m.
On Mon, Jan 09, 2012 at 02:04:52PM +0200, Avi Kivity wrote:
> 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 |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/hw/vhost.c b/hw/vhost.c
> index cd56e75..541c716 100644
> --- a/hw/vhost.c
> +++ b/hw/vhost.c
> @@ -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. */
> -- 
> 1.7.7.1
>

Patch

diff --git a/hw/vhost.c b/hw/vhost.c
index cd56e75..541c716 100644
--- a/hw/vhost.c
+++ b/hw/vhost.c
@@ -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. */