From patchwork Mon Dec 14 04:14:48 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 41062 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 20323B6F08 for ; Mon, 14 Dec 2009 15:15:26 +1100 (EST) Received: from localhost ([127.0.0.1]:52402 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NK2LC-0003pt-4l for incoming@patchwork.ozlabs.org; Sun, 13 Dec 2009 23:15:22 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NK2Ki-0003pg-Ez for qemu-devel@nongnu.org; Sun, 13 Dec 2009 23:14:52 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NK2Kh-0003pU-Dj for qemu-devel@nongnu.org; Sun, 13 Dec 2009 23:14:51 -0500 Received: from [199.232.76.173] (port=41398 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NK2Kh-0003pR-8F for qemu-devel@nongnu.org; Sun, 13 Dec 2009 23:14:51 -0500 Received: from are.twiddle.net ([75.149.56.221]:42780) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NK2Kg-00017L-PM for qemu-devel@nongnu.org; Sun, 13 Dec 2009 23:14:51 -0500 Received: from stone.twiddle.home (stone.twiddle.home [172.31.0.16]) by are.twiddle.net (Postfix) with ESMTPSA id DC3AC304 for ; Sun, 13 Dec 2009 20:14:48 -0800 (PST) Message-ID: <4B25BBB8.5070807@twiddle.net> Date: Sun, 13 Dec 2009 20:14:48 -0800 From: Richard Henderson User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.4pre) Gecko/20090922 Fedora/3.0-3.9.b4.fc12 Thunderbird/3.0b4 MIME-Version: 1.0 To: qemu-devel@nongnu.org X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) Subject: [Qemu-devel] [patch] linux-user: problem with mmap_find_vma X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org With host x86_64 target alpha, a trivial recompile started producing "MMU faults". Eventually, I determined that adding "-B 0x100000000" was enough to produce the fault with the original working executable. I expect, but have not verified, that a similar failure can be elicited with any 64-bit host and any target using such a large explicit base. The cause is that the default address used by mmap_find_vma may not be inside the area defined for use by the guest by GUEST_BASE. Certainly this patch fixes the failure I was seeing. I cannot see though all the macro ugliness to understand what happens when GUEST_BASE is not in use to know what needs happening there. Please feel free to edit the ??? comment to match reality. r~ commit a85b499eabe5a71bb02305c2856c136590276edf Author: Richard Henderson Date: Sun Dec 13 20:00:39 2009 -0800 linux-user: Adjust mmap_find_vma for guest_base. The definition of mmap_find_vma requires guest addresses as input to the START parameter. However, when START==0 i.e. no preferred address, we use a value pre-defined value which may not be within the area defined by GUEST_BASE. Make sure and adjust that value via g2h before using it. diff --git a/linux-user/mmap.c b/linux-user/mmap.c index 144fb7c..7e04c23 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -266,11 +266,13 @@ static int mmap_frag(abi_ulong real_start, #if defined(__CYGWIN__) /* Cygwin doesn't have a whole lot of address space. */ -static abi_ulong mmap_next_start = 0x18000000; +#define MMAP_FIRST_START 0x18000000 #else -static abi_ulong mmap_next_start = 0x40000000; +#define MMAP_FIRST_START 0x40000000 #endif +static abi_ulong mmap_next_start; + unsigned long last_brk; /* @@ -288,8 +290,19 @@ abi_ulong mmap_find_vma(abi_ulong start, abi_ulong size) start &= qemu_host_page_mask; /* If 'start' == 0, then a default start address is used. */ - if (start == 0) + if (start == 0) { start = mmap_next_start; + if (start == 0) { +#ifdef CONFIG_USE_GUEST_BASE + mmap_next_start = start = (abi_ulong) g2h(MMAP_FIRST_START); +#else + /* ??? What sort of host-guest remapping do we use for + when GUEST_BASE is not in use? Presumably we can + simply map at any address we choose. */ + mmap_next_start = start = MMAP_FIRST_START; +#endif + } + } addr = start;