From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:57908) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TSs6z-000860-C1 for qemu-devel@nongnu.org; Mon, 29 Oct 2012 12:22:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TSs6v-0006jb-1i for qemu-devel@nongnu.org; Mon, 29 Oct 2012 12:22:49 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41442) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TSs6u-0006jW-Ph for qemu-devel@nongnu.org; Mon, 29 Oct 2012 12:22:44 -0400 From: Avi Kivity Date: Mon, 29 Oct 2012 18:22:36 +0200 Message-Id: <1351527756-13782-1-git-send-email-avi@redhat.com> Subject: [Qemu-devel] [PATCH] memory: fix rendering of a region obscured by another List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Anthony Liguori Cc: qemu-devel@nongnu.org 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 --- memory.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/memory.c b/memory.c index 36bb9a5..243cb23 100644 --- a/memory.c +++ b/memory.c @@ -539,12 +539,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; -- 1.7.12