From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NZRxp-00063R-2r for qemu-devel@nongnu.org; Mon, 25 Jan 2010 11:38:57 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NZRxo-00063F-55 for qemu-devel@nongnu.org; Mon, 25 Jan 2010 11:38:56 -0500 Received: from [199.232.76.173] (port=40327 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NZRxo-00063C-0C for qemu-devel@nongnu.org; Mon, 25 Jan 2010 11:38:56 -0500 Received: from are.twiddle.net ([75.149.56.221]:55612) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NZRxn-0004ew-Cv for qemu-devel@nongnu.org; Mon, 25 Jan 2010 11:38:55 -0500 Message-ID: <4B5DC91C.1050308@twiddle.net> Date: Mon, 25 Jan 2010 08:38:52 -0800 From: Richard Henderson MIME-Version: 1.0 Subject: Re: [Qemu-devel] [PATCH] linux-user: Align mmap memory to the target page size. References: <20100115011604.DCB1CB93@are.twiddle.net> <4B508D34.70304@twiddle.net> <20100125133502.GA28489@afflict.kos.to> In-Reply-To: <20100125133502.GA28489@afflict.kos.to> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Riku Voipio Cc: qemu-devel@nongnu.org On 01/25/2010 05:35 AM, Riku Voipio wrote: > On Fri, Jan 15, 2010 at 07:43:48AM -0800, Richard Henderson wrote: >>> This patch uses a more complex search algorithm that takes the result >>> of the previous allocation into account. We normally search upward, >>> but notice 2 consecutive results and start searching downward instead. > >> I've failed to take guest_base into account properly; my testing >> happened to have guest_base = 0. New patch to follow. > > Did you have time to look at this again? Some. There is an additional problem. The target's pages are recorded in the physical page mapping via page_set_flags, whose input address is bounded by TARGET_PHYS_ADDR_SPACE_BITS, which is local to exec.c. Doubly unfortunately, page_set_flags silently discards pages that it considers must be outside the target's address space. It's fairly easy to get the x86-64 kernel to return a vma outside the range of any of the existing TARGET_PHYS_ADDR_SPACE_BITS. Which works fine inside the TB's, but causes any other syscall to return -EFAULT. We have a check /* If address fits target address space we've found what we need */ if ((unsigned long)ptr + size - 1 <= (abi_ulong)-1) break; which kind-of works for 32-bit targets. (You'll note, of course, that the comparison is against PTR, which is a host address; the correct test would have been h2g_valid, as seen with -B 0x100000000.) However, it does nothing for 64-bit targets and the artificial 2**42 virtual address space limit we impose on most of them. I talked with pbrook a bit about this on irc, and there seems to be no simple solution (like exporting TARGET_PHYS_ADDR_SPACE_BITS, possibly renamed as TARGET_ADDR_SPACE_BITS, in cpu.h) that would be acceptable to him. Given the number of patches I've already submitted that aren't being reviewed, I'm unlikely to develop the momentum to totally rewrite qemu's page table support. Particularly without a clue as to what sort of solution might be acceptable. (Something like Sparc64's hashed page tables perhaps, which support a full 64-bit virtual address space?) r~