From owner-freebsd-hackers@FreeBSD.ORG Mon Mar 1 14:19:43 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 8D9731065677; Mon, 1 Mar 2010 14:19:43 +0000 (UTC) (envelope-from giovanni.trematerra@gmail.com) Received: from mail-fx0-f223.google.com (mail-fx0-f223.google.com [209.85.220.223]) by mx1.freebsd.org (Postfix) with ESMTP id F08A98FC1C; Mon, 1 Mar 2010 14:19:42 +0000 (UTC) Received: by fxm23 with SMTP id 23so144214fxm.3 for ; Mon, 01 Mar 2010 06:19:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=g3BKpuj9X4yKlfjQ02U1nuT9HUEimnB2xSjf69vkiIE=; b=pa3klplkBoWZYZyztXwEnXDIOBJJfovM8XvFbq60o3z+6EPnZ4vaaGWdH0KpH5rLHi fRDiIdUHP7v+PKnqgp18JL7LjaaCY2GFHU9gi1HldNDzk/efIYzYB5cgovEa7AO7U076 bl4EGSBHGpzrmkOQQ01IXh6v0OtocfAdgxiIc= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=aWEifrNdkqH8THvGnwklxwQpe4Co76Awzp8zWelNIZiaBr1ciK5SasAtJuPXNFhM8o 8R4vG6eMkeJVKZoFfF8fm0ROc6Aog6AX4ra6B3iZIdmHVIneSr1QIEZ6bC+U9/D/aTBL +rCaI48YBkNkNteG7MTr7mQ8roShP9yCAq/54= MIME-Version: 1.0 Received: by 10.223.100.216 with SMTP id z24mr5138597fan.5.1267453176050; Mon, 01 Mar 2010 06:19:36 -0800 (PST) In-Reply-To: <317657.30145.qm@web27603.mail.ukl.yahoo.com> References: <317657.30145.qm@web27603.mail.ukl.yahoo.com> Date: Mon, 1 Mar 2010 15:19:35 +0100 Message-ID: <4e6cba831003010619j560f5b92n4c63ab2520cff7db@mail.gmail.com> From: Giovanni Trematerra To: Alexander Eichner , alc@freebsd.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: 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: Mon, 01 Mar 2010 14:19:43 -0000 On Mon, Mar 1, 2010 at 10:59 AM, Alexander Eichner wro= te: > Hi, > > I'm currently trying to finish the R0 memory implementation[1] of FreeBSD= for VirtualBox. One of the missing methods allocates physical non contiguo= us pages which don't need to have a kernel mapping (rtR0MemObjNativeAllocPh= ysNC). I'm using vm_phys_alloc_contig to achieve this. The pages are than m= apped into the user space VM process using pmap_enter (rtR0MemObjNativeMapU= ser) and if they are not needed anymore vm_page_free_toq is used to free th= e 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 t= ry to start a gnome session) with "pmap_enter: missing reference to page ta= ble 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 =3D vm_page_alloc(pMemFreeBSD->pObject, PageIndex, - VM_ALLOC_NOBUSY | VM_ALLOC_SYSTEM | - VM_ALLOC_WIRED); + VM_ALLOC_NOBUSY | VM_ALLOC_SYSTEM); #if __FreeBSD_version >=3D 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 >=3D 701105 pmap_enter(kernel_map->pmap, AddressDst, VM_PROT_NONE, pPage, @@ -253,6 +249,8 @@ int rtR0MemObjNativeAllocPage(PPRTR0MEMO if (rc =3D=3D VINF_SUCCESS) { + vm_map_wire(kernel_map, MapAddress, MapAddress + cb, + VM_MAP_WIRE_SYSTEM | VM_MAP_WIRE_NOHOLES); pMemFreeBSD->Core.pv =3D (void *)MapAddress; *ppMem =3D &pMemFreeBSD->Core; return VINF_SUCCESS; > > Regards, > Alexander Eichner > > [1] http://www.virtualbox.org/browser/trunk/src/VBox/Runtime/r0drv/freebs= d/memobj-r0drv-freebsd.c?rev=3D26899 > [2]http://fxr.watson.org/fxr/source/amd64/amd64/pmap.c?im=3Dbigexcerpts#L= 3076 > > __________________________________________________ > Do You Yahoo!? > Sie sind Spam leid? Yahoo! Mail verf=FCgt =FCber einen herausragenden Sch= utz 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= " >