From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KUIIN-0007yu-I1 for qemu-devel@nongnu.org; Sat, 16 Aug 2008 05:42:03 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KUIIM-0007y2-8p for qemu-devel@nongnu.org; Sat, 16 Aug 2008 05:42:02 -0400 Received: from [199.232.76.173] (port=39194 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KUIIL-0007xb-L0 for qemu-devel@nongnu.org; Sat, 16 Aug 2008 05:42:01 -0400 Received: from fmmailgate02.web.de ([217.72.192.227]:49635) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KUIIK-0001hl-UC for qemu-devel@nongnu.org; Sat, 16 Aug 2008 05:42:01 -0400 Received: from smtp05.web.de (fmsmtp05.dlan.cinetic.de [172.20.4.166]) by fmmailgate02.web.de (Postfix) with ESMTP id 636F0E8ED435 for ; Sat, 16 Aug 2008 11:42:00 +0200 (CEST) Received: from [88.64.23.108] (helo=[192.168.1.198]) by smtp05.web.de with asmtp (TLSv1:AES256-SHA:256) (WEB.DE 4.109 #226) id 1KUIIK-0007Lu-00 for qemu-devel@nongnu.org; Sat, 16 Aug 2008 11:42:00 +0200 Resent-To: qemu-devel@nongnu.org Resent-Message-Id: <48A6A0E7.3050909@web.de> Message-ID: <48A6A020.2070204@web.de> Date: Sat, 16 Aug 2008 11:38:40 +0200 From: Jan Kiszka MIME-Version: 1.0 References: <48A69B64.7050001@web.de> In-Reply-To: <48A69B64.7050001@web.de> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit Sender: jan.kiszka@web.de Subject: [Qemu-devel] [PATCH 5/5] linux-user: Fix h2g usage in page_find_alloc Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Paul's comment on my first approach to fix the h2g usage in page_find_alloc finally open my eyes about what the code is actually supposed to do: With the help of h2g_valid we can no cleanly check if a freshly allocate page (for host usage) is guest-reachable and, in case it is, mark it reserved in the guest's address range. Signed-off-by: Jan Kiszka --- exec.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) Index: b/exec.c =================================================================== --- a/exec.c +++ b/exec.c @@ -294,14 +294,13 @@ static inline PageDesc *page_find_alloc( if (!p) { /* allocate if not found */ #if defined(CONFIG_USER_ONLY) - unsigned long addr; size_t len = sizeof(PageDesc) * L2_SIZE; /* Don't use qemu_malloc because it may recurse. */ p = mmap(0, len, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); *lp = p; - addr = h2g(p); - if (addr == (target_ulong)addr) { + if (h2g_valid(p)) { + unsigned long addr = h2g(p); page_set_flags(addr & TARGET_PAGE_MASK, TARGET_PAGE_ALIGN(addr + len), PAGE_RESERVED);