From patchwork Wed Mar 10 22:38: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: 47291 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 133AFB7D0A for ; Thu, 11 Mar 2010 11:15:01 +1100 (EST) Received: from localhost ([127.0.0.1]:55038 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NpW3G-0003yk-6Z for incoming@patchwork.ozlabs.org; Wed, 10 Mar 2010 19:14:58 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NpVzF-0001RS-VD for qemu-devel@nongnu.org; Wed, 10 Mar 2010 19:10:50 -0500 Received: from [199.232.76.173] (port=48165 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NpVzE-0001R7-PB for qemu-devel@nongnu.org; Wed, 10 Mar 2010 19:10:48 -0500 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1NpVzB-0001sB-9c for qemu-devel@nongnu.org; Wed, 10 Mar 2010 19:10:48 -0500 Received: from are.twiddle.net ([75.149.56.221]:58408) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NpVzA-0001rQ-K4 for qemu-devel@nongnu.org; Wed, 10 Mar 2010 19:10:44 -0500 Received: by are.twiddle.net (Postfix, from userid 5000) id F23BF101D; Wed, 10 Mar 2010 16:10:39 -0800 (PST) Message-Id: <12e14bc5d38dbfd2d07b95afca507fcea236a795.1268265556.git.rth@twiddle.net> In-Reply-To: References: From: Richard Henderson Date: Wed, 10 Mar 2010 14:38:59 -0800 To: qemu-devel@nongnu.org X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) Cc: paul@codesourcery.com Subject: [Qemu-devel] [PATCH 3/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 Signed-off-by: Richard Henderson --- 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); }