From patchwork Thu Feb 11 23:11:59 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 45172 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 8D20BB7CB9 for ; Fri, 12 Feb 2010 12:50:17 +1100 (EST) Received: from localhost ([127.0.0.1]:53655 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Nfkfe-00034x-Q3 for incoming@patchwork.ozlabs.org; Thu, 11 Feb 2010 20:50:14 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Nfkc9-0001td-6p for qemu-devel@nongnu.org; Thu, 11 Feb 2010 20:46:37 -0500 Received: from [199.232.76.173] (port=58968 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Nfkc7-0001tL-S5 for qemu-devel@nongnu.org; Thu, 11 Feb 2010 20:46:36 -0500 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1Nfkc6-0002kk-Sc for qemu-devel@nongnu.org; Thu, 11 Feb 2010 20:46:35 -0500 Received: from mx20.gnu.org ([199.232.41.8]:52911) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1NfkbX-0002jA-3t for qemu-devel@nongnu.org; Thu, 11 Feb 2010 20:46:34 -0500 Received: from are.twiddle.net ([75.149.56.221]) by mx20.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Nfjuh-0001eN-Ni for qemu-devel@nongnu.org; Thu, 11 Feb 2010 20:01:44 -0500 Received: by are.twiddle.net (Postfix, from userid 5000) id 3FD56C2D; Thu, 11 Feb 2010 16:54:14 -0800 (PST) Message-Id: In-Reply-To: References: From: Richard Henderson Date: Thu, 11 Feb 2010 15:11:59 -0800 To: qemu-devel@nongnu.org X-detected-operating-system: by mx20.gnu.org: GNU/Linux 2.6 (newer, 2) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) Subject: [Qemu-devel] [PATCH 5/6] linux-user: Use h2g_valid in qemu_vmalloc. 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 --- linux-user/mmap.c | 9 ++++----- 1 files changed, 4 insertions(+), 5 deletions(-) diff --git a/linux-user/mmap.c b/linux-user/mmap.c index 25fc0b2..65fdc33 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -80,16 +80,15 @@ void mmap_unlock(void) void *qemu_vmalloc(size_t size) { void *p; - unsigned long addr; + mmap_lock(); /* Use map and mark the pages as used. */ p = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); - addr = (unsigned long)p; - if (addr == (target_ulong) addr) { - /* Allocated region overlaps guest address space. - This may recurse. */ + if (h2g_valid(p)) { + /* Allocated region overlaps guest address space. This may recurse. */ + unsigned long addr = h2g(p); page_set_flags(addr & TARGET_PAGE_MASK, TARGET_PAGE_ALIGN(addr + size), PAGE_RESERVED); }