From patchwork Mon Feb 15 19:58:08 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 45430 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 DB9DBB6EEB for ; Tue, 16 Feb 2010 08:08:02 +1100 (EST) Received: from localhost ([127.0.0.1]:52635 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Nh8Ai-0004WN-7h for incoming@patchwork.ozlabs.org; Mon, 15 Feb 2010 16:08:00 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Nh87M-0003lp-OT for qemu-devel@nongnu.org; Mon, 15 Feb 2010 16:04:32 -0500 Received: from [199.232.76.173] (port=59654 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Nh87L-0003lN-Bs 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-0000ri-9f for qemu-devel@nongnu.org; Mon, 15 Feb 2010 16:04:30 -0500 Received: from are.twiddle.net ([75.149.56.221]:51085) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Nh87H-0000rN-Vf for qemu-devel@nongnu.org; Mon, 15 Feb 2010 16:04:28 -0500 Received: by are.twiddle.net (Postfix, from userid 5000) id 4568FEF8; Mon, 15 Feb 2010 13:04:24 -0800 (PST) Message-Id: <34db9eeee1243a0a73f3e3bf15d179bee3299b3b.1266267595.git.rth@twiddle.net> In-Reply-To: References: From: Richard Henderson Date: Mon, 15 Feb 2010 11:58:08 -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 7/7] Assert arguments in range for guest address space. 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 We don't expect host addresses within page_set_flags or page_check_range. --- exec.c | 15 +++++++++++++++ 1 files changed, 15 insertions(+), 0 deletions(-) diff --git a/exec.c b/exec.c index bb712ec..10673fc 100644 --- a/exec.c +++ b/exec.c @@ -2327,6 +2327,14 @@ void page_set_flags(target_ulong start, target_ulong end, int flags) { target_ulong addr, len; + /* This function should never be called with addresses outside the + guest address space. If this assert fires, it probably indicates + a missing call to h2g_valid. */ +#if HOST_LONG_BITS > TARGET_VIRT_ADDR_SPACE_BITS + assert(end < (1ul << TARGET_VIRT_ADDR_SPACE_BITS)); +#endif + assert(start < end); + start = start & TARGET_PAGE_MASK; end = TARGET_PAGE_ALIGN(end); @@ -2356,6 +2364,13 @@ int page_check_range(target_ulong start, target_ulong len, int flags) target_ulong end; target_ulong addr; + /* This function should never be called with addresses outside the + guest address space. If this assert fires, it probably indicates + a missing call to h2g_valid. */ +#if HOST_LONG_BITS > TARGET_VIRT_ADDR_SPACE_BITS + assert(start < (1ul << TARGET_VIRT_ADDR_SPACE_BITS)); +#endif + if (start + len - 1 < start) { /* We've wrapped around. */ return -1;