Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 27 Feb 2010 21:28:39 +0000 (GMT)
From:      Alexander Eichner <alexeichi@yahoo.de>
To:        freebsd-emulation@freebsd.org
Subject:   Re: Patch to fix VirtualBox with recent kernel versions
Message-ID:  <215745.35399.qm@web27602.mail.ukl.yahoo.com>

next in thread | raw e-mail | index | archive | help

[-- Attachment #1 --]
> Von: Adam K Kirchhoff <adamk@voicenet.com>
> Betreff: Re: Patch to fix VirtualBox with recent kernel versions
> An: freebsd-emulation@freebsd.org
> Datum: Donnerstag, 25. Februar, 2010 01:10 Uhr
> On 02/24/2010 04:50 PM, Alexander
> Eichner wrote:
> > Hi,
> > 
> > as promised to decke here is the final patch to fix
> VirtualBox with recent FreeBSD kernel versions. As it is
> quite different to the one posted to freebsd-current please
> test it first before including it in the port. The problem
> seems to be 32bit specific and I don't have a 32bit FreeBSD
> system here to test unfortunately.
> > 
> > Regards,
> > Alexander Eichner
> > 
> > PS: the OSE repository is working again. :)
> >    
> 
> I tried the patch on one of my machines here and it's still
> aborting:
> 
> 
> !!Assertion Failed!!
> Expression: paPages[i].Phys != 0 && paPages[i].Phys
> != NIL_RTHCPHYS && !(paPages[i].Phys &
> PAGE_OFFSET_MASK)
> Location  :
> /usr/ports/emulators/virtualbox-ose/work/VirtualBox-3.1.2_OSE/src/VBox/VMM/MMHyper.cpp(610)
> int MMR3HyperMapPages(VM*, void*, RTR0PTR, size_t, const
> SUPPAGE*, const char*, RTGCPTR64*)
> i=0x4 Phys=0000000000000000 Heap
> 
> 
> Adam

Hi,

attached is a new version of the patch. I tested it on 32bit FreeBSD 8

Regards,
Alexander Eichner


__________________________________________________
Do You Yahoo!?
Sie sind Spam leid? Yahoo! Mail verfügt über einen herausragenden Schutz gegen Massenmails. 
http://mail.yahoo.com 
[-- Attachment #2 --]
Index: src/VBox/Runtime/r0drv/freebsd/memobj-r0drv-freebsd.c
===================================================================
--- src/VBox/Runtime/r0drv/freebsd/memobj-r0drv-freebsd.c	(revision 58167)
+++ src/VBox/Runtime/r0drv/freebsd/memobj-r0drv-freebsd.c	(working copy)
@@ -726,20 +726,45 @@
     switch (pMemFreeBSD->Core.enmType)
     {
         case RTR0MEMOBJTYPE_LOCK:
+        {
             if (    pMemFreeBSD->Core.u.Lock.R0Process != NIL_RTR0PROCESS
                 &&  pMemFreeBSD->Core.u.Lock.R0Process != (RTR0PROCESS)curproc)
             {
                 /* later */
                 return NIL_RTHCPHYS;
             }
-            /* fall thru*/
+
+            vm_offset_t pb = (vm_offset_t)pMemFreeBSD->Core.pv + (iPage << PAGE_SHIFT);
+
+            struct proc    *pProc     = (struct proc *)pMemFreeBSD->Core.u.Lock.R0Process;
+            struct vm_map  *pProcMap  = &pProc->p_vmspace->vm_map;
+            pmap_t pPhysicalMap       = pProcMap->pmap;
+
+            return pmap_extract(pPhysicalMap, pb);
+        }
+
         case RTR0MEMOBJTYPE_PAGE:
-        case RTR0MEMOBJTYPE_MAPPING:
         {
-            uint8_t *pb = (uint8_t *)pMemFreeBSD->Core.pv + (iPage << PAGE_SHIFT);
+            vm_offset_t pb = (vm_offset_t)pMemFreeBSD->Core.pv + (iPage << PAGE_SHIFT);
             return vtophys(pb);
         }
 
+        case RTR0MEMOBJTYPE_MAPPING:
+        {
+            vm_offset_t pb = (vm_offset_t)pMemFreeBSD->Core.pv + (iPage << PAGE_SHIFT);
+
+            if (pMemFreeBSD->Core.u.Mapping.R0Process != NIL_RTR0PROCESS)
+            {
+                struct proc    *pProc     = (struct proc *)pMemFreeBSD->Core.u.Mapping.R0Process;
+                struct vm_map  *pProcMap  = &pProc->p_vmspace->vm_map;
+                pmap_t pPhysicalMap       = pProcMap->pmap;
+
+                return pmap_extract(pPhysicalMap, pb);
+            }
+            else
+                return vtophys(pb);
+        }
+
         case RTR0MEMOBJTYPE_CONT:
             return pMemFreeBSD->Core.u.Cont.Phys + (iPage << PAGE_SHIFT);
 

Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?215745.35399.qm>