From owner-freebsd-hackers@FreeBSD.ORG Tue Mar 2 08:44:32 2010 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8B0F510656C2 for ; Tue, 2 Mar 2010 08:44:32 +0000 (UTC) (envelope-from alexeichi@yahoo.de) Received: from smtp125.mail.ukl.yahoo.com (smtp125.mail.ukl.yahoo.com [77.238.184.56]) by mx1.freebsd.org (Postfix) with SMTP id 013868FC20 for ; Tue, 2 Mar 2010 08:44:31 +0000 (UTC) Received: (qmail 40345 invoked from network); 2 Mar 2010 08:44:29 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.de; h=Received:X-Yahoo-SMTP:X-YMail-OSG:X-Yahoo-Newman-Property:Subject:From:To:Cc:In-Reply-To:References:Content-Type:Date:Message-ID:Mime-Version:X-Mailer:Content-Transfer-Encoding; b=aYsZrKrwWygE/BCVkpOM/j2GfMe2z9H2uYQmvHJdgc1T+o4qlO8UG+F3EzGZCtU2M9f+AltivRL+ns+/uiproGSTE2ptzv69Ml7h1bamTv0u+v1bPs/CSvZpPQ5ut0n3CWRFL2VlqojzXI6qXYpPIKiv6MJ8HgciGJ4LGGOi1ws= ; Received: from p57BBC91B.dip.t-dialin.net (alexeichi@87.187.201.27 with login) by smtp125.mail.ukl.yahoo.com with SMTP; 02 Mar 2010 08:44:29 +0000 GMT X-Yahoo-SMTP: yMol3buswBBNNUOSiWLj.UV.YXoMOg-- X-YMail-OSG: ERSmh_oVM1lLvEMKcJYvxAQwmV4_LWYSLgj5yvJMJbZi8cgI7SvfM0.GgF2zM8bNFbVLShwsX40A6O6wW5rsDUVwu82Hrk9Rfz1YbKtL.OTLIJL1_MEGGvehvTmym9jmTTDHKKD93zgqmHpcZldk4gh9JCdve3zRZT1XdHGp1gIcKKQKPu5lwqD_kBrEJngEke4zovsJbOlRoEE4_rqX0PPz42QxT.ZEUhZjHY5v9SKosnvKCxcfGQh.jyCSYt9Y5JBLb3XEVowJI8LT3YeHyQ8EX8l13jWffnLbUw-- X-Yahoo-Newman-Property: ymail-3 From: Alexander Eichner To: Giovanni Trematerra In-Reply-To: <4e6cba831003010619j560f5b92n4c63ab2520cff7db@mail.gmail.com> References: <317657.30145.qm@web27603.mail.ukl.yahoo.com> <4e6cba831003010619j560f5b92n4c63ab2520cff7db@mail.gmail.com> Content-Type: text/plain; charset="UTF-8" Date: Tue, 02 Mar 2010 09:34:39 +0100 Message-ID: <1267518879.2794.14.camel@Prometheus> Mime-Version: 1.0 X-Mailer: Evolution 2.28.1 Content-Transfer-Encoding: 8bit Cc: alc@freebsd.org, freebsd-hackers@freebsd.org Subject: Re: Allocating physical memory without a kernel mapping X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Mar 2010 08:44:32 -0000 Giovanni Trematerra wrote: > On Mon, Mar 1, 2010 at 10:59 AM, Alexander Eichner wrote: > > Hi, > > > > I'm currently trying to finish the R0 memory implementation[1] of FreeBSD for VirtualBox. One of the missing methods allocates physical non contiguous pages which don't need to have a kernel mapping (rtR0MemObjNativeAllocPhysNC). I'm using vm_phys_alloc_contig to achieve this. The pages are than mapped into the user space VM process using pmap_enter (rtR0MemObjNativeMapUser) and if they are not needed anymore vm_page_free_toq is used to free the pages (rtR0MemObjNativeFree). > > Everything works as long as the VM runs but if the VM process terminates and I do something else the host will panic at some point (usually when I try to start a gnome session) with "pmap_enter: missing reference to page table page "[2]. > > There seems to some problem with the wire count of that page but I can't see what I'm doing wrong at the moment. > > Thanks in advance for any help. > > Please, try this patch against revision 26898. > > --- memobj-r0drv-freebsd.c.orig 2010-02-26 10:28:44.000000000 +0100 > +++ memobj-r0drv-freebsd.c 2010-02-26 13:55:35.000000000 +0100 > @@ -209,8 +209,7 @@ int rtR0MemObjNativeAllocPage(PPRTR0MEMO > vm_page_t pPage; > > pPage = vm_page_alloc(pMemFreeBSD->pObject, PageIndex, > - VM_ALLOC_NOBUSY | VM_ALLOC_SYSTEM | > - VM_ALLOC_WIRED); > + VM_ALLOC_NOBUSY | VM_ALLOC_SYSTEM); > > #if __FreeBSD_version >= 800000 /** @todo Find exact version number */ > /* Fixes crashes during VM termination on > FreeBSD8-CURRENT amd64 > @@ -220,9 +219,6 @@ int rtR0MemObjNativeAllocPage(PPRTR0MEMO > > if (pPage) > { > - vm_page_lock_queues(); > - vm_page_wire(pPage); > - vm_page_unlock_queues(); > /* Put the page into the page table now. */ > #if __FreeBSD_version >= 701105 > pmap_enter(kernel_map->pmap, AddressDst, > VM_PROT_NONE, pPage, > @@ -253,6 +249,8 @@ int rtR0MemObjNativeAllocPage(PPRTR0MEMO > > if (rc == VINF_SUCCESS) > { > + vm_map_wire(kernel_map, MapAddress, > MapAddress + cb, > + VM_MAP_WIRE_SYSTEM | > VM_MAP_WIRE_NOHOLES); > pMemFreeBSD->Core.pv = (void *)MapAddress; > *ppMem = &pMemFreeBSD->Core; > return VINF_SUCCESS; > > > > > Regards, > > Alexander Eichner > > > > [1] http://www.virtualbox.org/browser/trunk/src/VBox/Runtime/r0drv/freebsd/memobj-r0drv-freebsd.c?rev=26899 > > [2]http://fxr.watson.org/fxr/source/amd64/amd64/pmap.c?im=bigexcerpts#L3076 > > > > __________________________________________________ > > Do You Yahoo!? > > Sie sind Spam leid? Yahoo! Mail verfügt über einen herausragenden Schutz gegen Massenmails. > > http://mail.yahoo.com > > _______________________________________________ > > freebsd-hackers@freebsd.org mailing list > > http://lists.freebsd.org/mailman/listinfo/freebsd-hackers > > To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org" > > > _______________________________________________ > freebsd-hackers@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-hackers > To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org" Thanks for your help but I don't see how that patch could help with my problem. rtR0MemObjNativeAllocPage allocates pages with a kernel mapping but the problem appears when using rtR0MemObjNativeAllocPhysNC + rtR0MemObjNativeMapUser and freeing the pages later. rtR0MemObjNativeAllocPage is used if I use the old allocation mode which does not use rtR0MemObjNativeAllocPhysNC and this works fine here. The double wiring problem should also be solved with the latest source. Regards, Alexander