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: 45431 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 59158B7C09 for ; Tue, 16 Feb 2010 08:09:40 +1100 (EST) Received: from localhost ([127.0.0.1]:53362 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Nh8CH-0004xR-Iy for incoming@patchwork.ozlabs.org; Mon, 15 Feb 2010 16:09:37 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Nh87M-0003lr-6A for qemu-devel@nongnu.org; Mon, 15 Feb 2010 16:04:32 -0500 Received: from [199.232.76.173] (port=59656 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Nh87L-0003lP-CH for qemu-devel@nongnu.org; Mon, 15 Feb 2010 16:04:31 -0500 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1Nh87K-0000rd-En for qemu-devel@nongnu.org; Mon, 15 Feb 2010 16:04:30 -0500 Received: from are.twiddle.net ([75.149.56.221]:51083) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Nh87I-0000rB-3C for qemu-devel@nongnu.org; Mon, 15 Feb 2010 16:04:28 -0500 Received: by are.twiddle.net (Postfix, from userid 5000) id 3BBAFEF6; Mon, 15 Feb 2010 13:04:24 -0800 (PST) Message-Id: <0904b2af2ae800f8dd4d39f3219feead40c93cb7.1266267595.git.rth@twiddle.net> 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 monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) Cc: blauwirbel@gmail.com Subject: [Qemu-devel] [PATCH 5/7] 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); }