From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1L7pu9-0007zk-CJ for qemu-devel@nongnu.org; Wed, 03 Dec 2008 06:28:29 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1L7ptz-0007s1-TO for qemu-devel@nongnu.org; Wed, 03 Dec 2008 06:28:21 -0500 Received: from [199.232.76.173] (port=33380 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1L7pty-0007rJ-8t for qemu-devel@nongnu.org; Wed, 03 Dec 2008 06:28:18 -0500 Received: from ug-out-1314.google.com ([66.249.92.173]:3613) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1L7ptu-0004DO-1G for qemu-devel@nongnu.org; Wed, 03 Dec 2008 06:28:15 -0500 Received: by ug-out-1314.google.com with SMTP id 29so3354890ugc.36 for ; Wed, 03 Dec 2008 03:27:42 -0800 (PST) From: "Kirill A. Shutemov" Date: Wed, 3 Dec 2008 13:29:41 +0200 Message-Id: <1228303789-25653-6-git-send-email-kirill@shutemov.name> In-Reply-To: <1228303789-25653-5-git-send-email-kirill@shutemov.name> References: <1228303789-25653-1-git-send-email-kirill@shutemov.name> <1228303789-25653-2-git-send-email-kirill@shutemov.name> <1228303789-25653-3-git-send-email-kirill@shutemov.name> <1228303789-25653-4-git-send-email-kirill@shutemov.name> <1228303789-25653-5-git-send-email-kirill@shutemov.name> Subject: [Qemu-devel] [PATCH] 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 Cc: "Kirill A. Shutemov" , Jan Kiszka From: Jan Kiszka 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 Signed-off-by: Kirill A. Shutemov --- exec.c | 5 ++--- 1 files changed, 2 insertions(+), 3 deletions(-) diff --git a/exec.c b/exec.c index 58a0cff..105812f 100644 --- a/exec.c +++ b/exec.c @@ -305,14 +305,13 @@ static inline PageDesc *page_find_alloc(target_ulong index) 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); -- 1.6.0.2.GIT