Patchwork memory: fix subregion collision warning

login
register
mail settings
Submitter Michael Walle
Date Sept. 15, 2011, 9:16 p.m.
Message ID <1316121409-9086-1-git-send-email-michael@walle.cc>
Download mbox | patch
Permalink /patch/114837/
State New
Headers show

Comments

Michael Walle - Sept. 15, 2011, 9:16 p.m.
Instead of the offset property use the proper addr property to calculate
the offsets.

Additionally, be a little more verbose on the warning and print the
subregion name.

Signed-off-by: Michael Walle <michael@walle.cc>
---
 memory.c |   13 ++++++++-----
 1 files changed, 8 insertions(+), 5 deletions(-)
Avi Kivity - Sept. 18, 2011, 11:55 a.m.
On 09/16/2011 12:16 AM, Michael Walle wrote:
> Instead of the offset property use the proper addr property to calculate
> the offsets.
>
> Additionally, be a little more verbose on the warning and print the
> subregion name.
>
>

Thanks, applied to memory/core.

Patch

diff --git a/memory.c b/memory.c
index 101b67c..ba74435 100644
--- a/memory.c
+++ b/memory.c
@@ -1190,16 +1190,19 @@  static void memory_region_add_subregion_common(MemoryRegion *mr,
         if (subregion->may_overlap || other->may_overlap) {
             continue;
         }
-        if (offset >= other->offset + other->size
-            || offset + subregion->size <= other->offset) {
+        if (offset >= other->addr + other->size
+            || offset + subregion->size <= other->addr) {
             continue;
         }
 #if 0
-        printf("warning: subregion collision %llx/%llx vs %llx/%llx\n",
+        printf("warning: subregion collision %llx/%llx (%s) "
+               "vs %llx/%llx (%s)\n",
                (unsigned long long)offset,
                (unsigned long long)subregion->size,
-               (unsigned long long)other->offset,
-               (unsigned long long)other->size);
+               subregion->name,
+               (unsigned long long)other->addr,
+               (unsigned long long)other->size,
+               other->name);
 #endif
     }
     QTAILQ_FOREACH(other, &mr->subregions, subregions_link) {