From patchwork Mon Dec 3 22:08:36 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 203493 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 39D8D2C0095 for ; Tue, 4 Dec 2012 10:45:59 +1100 (EST) Received: from localhost ([::1]:48218 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TfeJC-0008Pf-No for incoming@patchwork.ozlabs.org; Mon, 03 Dec 2012 17:16:14 -0500 Received: from eggs.gnu.org ([208.118.235.92]:49855) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TfeIR-0006kd-Ma for qemu-devel@nongnu.org; Mon, 03 Dec 2012 17:15:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TfeIQ-00030f-Mr for qemu-devel@nongnu.org; Mon, 03 Dec 2012 17:15:27 -0500 Received: from mail-ia0-f178.google.com ([209.85.210.178]:34192) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TfeIN-0002zs-R5; Mon, 03 Dec 2012 17:15:23 -0500 Received: by mail-ia0-f178.google.com with SMTP id k25so2937405iah.37 for ; Mon, 03 Dec 2012 14:15:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=DL2aHlsFOc3fOJoWWNt+UGy3+dOeOGMGLgmEmzcUgCc=; b=FKGpUxx4IiMgtYeUrTKetcamV4LmouTnQwJzKHp80rzZIqWTh8uMny4gjm4MfImx0R eSHFAOeloxE+m9Ix9e23DW1t3HD0ZPrKT/Q2vFikN8BO/mbfkwP74wCF2ECMdVPxAPjF IhY9hTTrmLJbhZLWB201MUX4W4U6LlesY5avsPTKvB88U0+AObN7grKBsw3x2fQ3fOuf G3k8rK7/7eMYTcB76tPXFQgm4FqK1vd25+AdLRMFwc3mzHYzstbsk8xgsRDnerTPG7xO DRIK71X5f5cOTZNOqFXRUVOaI+ZfmQz9FUx2yGtq7Y/TefXnAFxPsu9Ht1qsPyYU7Fk/ V1Ow== Received: by 10.50.6.136 with SMTP id b8mr560008iga.54.1354572922796; Mon, 03 Dec 2012 14:15:22 -0800 (PST) Received: from localhost ([32.97.110.59]) by mx.google.com with ESMTPS id em3sm8166434igc.7.2012.12.03.14.15.21 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 03 Dec 2012 14:15:22 -0800 (PST) From: Michael Roth To: qemu-stable@nongnu.org Date: Mon, 3 Dec 2012 16:08:36 -0600 Message-Id: <1354572547-21271-13-git-send-email-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1354572547-21271-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1354572547-21271-1-git-send-email-mdroth@linux.vnet.ibm.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 209.85.210.178 Cc: aliguori@us.ibm.com, qemu-devel@nongnu.org Subject: [Qemu-devel] [PATCH 12/43] memory: fix rendering of a region obscured by another X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Avi Kivity 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 --- memory.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/memory.c b/memory.c index d528d1f..7144020 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;