From: Avi Kivity Date: Mon, 29 Oct 2012 16:22:36 +0000 (+0200) Subject: memory: fix rendering of a region obscured by another X-Git-Tag: v1.2.2~32 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0dfd8215c2d7023436e4bd25b68d6f00d83702e6;p=thirdparty%2Fqemu.git memory: fix rendering of a region obscured by another The memory core drops regions that are hidden by another region (for example, during BAR sizing), but it doesn't do so correctly if the lower address of the existing range is below the lower address of the new range. Example (qemu-system-mips -M malta -kernel vmlinux-2.6.32-5-4kc-malta -append "console=ttyS0" -nographic -vga cirrus): Existing range: 10000000-107fffff New range: 100a0000-100bffff Correct behaviour: drop new range Incorrect behaviour: add new range Fix by taking this case into account (previously we only considered equal lower boundaries). Tested-by: Aurelien Jarno Signed-off-by: Avi Kivity Signed-off-by: Anthony Liguori (cherry picked from commit d26a8caea3f160782841efb87b5e8bea606b512b) Signed-off-by: Michael Roth --- diff --git a/memory.c b/memory.c index d528d1f7f3b..714402096a3 100644 --- a/memory.c +++ b/memory.c @@ -538,12 +538,12 @@ static void render_memory_region(FlatView *view, offset_in_region += int128_get64(now); int128_subfrom(&remain, now); } - if (int128_eq(base, view->ranges[i].addr.start)) { - now = int128_min(remain, view->ranges[i].addr.size); - int128_addto(&base, now); - offset_in_region += int128_get64(now); - int128_subfrom(&remain, now); - } + now = int128_sub(int128_min(int128_add(base, remain), + addrrange_end(view->ranges[i].addr)), + base); + int128_addto(&base, now); + offset_in_region += int128_get64(now); + int128_subfrom(&remain, now); } if (int128_nz(remain)) { fr.mr = mr;