From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1L93SA-0005jt-Ho for qemu-devel@nongnu.org; Sat, 06 Dec 2008 15:08:38 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1L93S6-0005hX-PT for qemu-devel@nongnu.org; Sat, 06 Dec 2008 15:08:37 -0500 Received: from [199.232.76.173] (port=46340 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1L93S6-0005hL-D1 for qemu-devel@nongnu.org; Sat, 06 Dec 2008 15:08:34 -0500 Received: from bart.se.axis.com ([195.60.68.10]:34447) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1L93S5-0006lJ-UP for qemu-devel@nongnu.org; Sat, 06 Dec 2008 15:08:34 -0500 Received: from bart.se.axis.com (bart.se.axis.com [127.0.0.1]) by bart.se.axis.com (Postfix) with ESMTP id 6FEB96425E for ; Sat, 6 Dec 2008 21:08:33 +0100 (CET) Received: from axis.com (edgar.se.axis.com [10.93.151.1]) by bart.se.axis.com (Postfix) with ESMTP id 616806425B for ; Sat, 6 Dec 2008 21:08:33 +0100 (CET) Date: Sat, 6 Dec 2008 21:08:33 +0100 From: "Edgar E. Iglesias" Subject: Re: [Qemu-devel] [PATCH] linux-user: Fix h2g usage in page_find_alloc Message-ID: <20081206200833.GD1167@edgar.se.axis.com> 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> <1228303789-25653-6-git-send-email-kirill@shutemov.name> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1228303789-25653-6-git-send-email-kirill@shutemov.name> Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Kirill A. Shutemov" Cc: Jan Kiszka , qemu-devel@nongnu.org On Wed, Dec 03, 2008 at 01:29:41PM +0200, Kirill A. Shutemov wrote: > 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 Acked-by: Edgar E. Iglesias > --- > 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 > >