VirtualBox

Changeset 40916 in vbox for trunk


Ignore:
Timestamp:
Apr 14, 2012 7:53:26 AM (13 years ago)
Author:
vboxsync
Message:

FreeBSD/MemObjR0: Bug fixes (Thanks to Andriy Gapon and Bernhard Froehlich)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/r0drv/freebsd/memobj-r0drv-freebsd.c

    r39744 r40916  
    192192{
    193193    vm_page_t pPages;
     194    int cTries = 0;
     195
    194196#if __FreeBSD_version > 1000000
    195197    int fFlags = VM_ALLOC_INTERRUPT | VM_ALLOC_NOBUSY;
    196198    if (fWire)
    197199        fFlags |= VM_ALLOC_WIRED;
    198     VM_OBJECT_LOCK(pObject);
    199     pPages = vm_page_alloc_contig(pObject, iPIndex, fFlags, cPages, 0, VmPhysAddrHigh, uAlignment, 0, VM_MEMATTR_DEFAULT);
    200     VM_OBJECT_UNLOCK(pObject);
     200
     201    while (cTries <= 1)
     202    {
     203        VM_OBJECT_LOCK(pObject);
     204        pPages = vm_page_alloc_contig(pObject, iPIndex, fFlags, cPages, 0,
     205                                      VmPhysAddrHigh, uAlignment, 0, VM_MEMATTR_DEFAULT);
     206        VM_OBJECT_UNLOCK(pObject);
     207        if (pPages)
     208            break;
     209        vm_contig_grow_cache(cTries, 0, VmPhysAddrHigh);
     210        cTries++;
     211    }
     212
    201213    return pPages;
    202214#else
    203     pPages = vm_phys_alloc_contig(cPages, 0, VmPhysAddrHigh, uAlignment, 0);
     215    while (cTries <= 1)
     216    {
     217        pPages = vm_phys_alloc_contig(cPages, 0, VmPhysAddrHigh, uAlignment, 0);
     218        if (pPages)
     219            break;
     220        vm_contig_grow_cache(cTries, 0, VmPhysAddrHigh);
     221        cTries++;
     222    }
     223
    204224    if (!pPages)
    205225        return pPages;
     
    260280                                        vm_paddr_t VmPhysAddrHigh, bool fContiguous, int rcNoMem)
    261281{
    262     int rc;
    263     size_t cPages = atop(pMemFreeBSD->Core.cb);
     282    vm_offset_t MapAddress = vm_map_min(kernel_map);
     283    size_t      cPages = atop(pMemFreeBSD->Core.cb);
     284    int         rc;
    264285
    265286    pMemFreeBSD->pObject = vm_object_allocate(OBJT_PHYS, cPages);
    266     vm_offset_t MapAddress;
    267287
    268288    /* No additional object reference for auto-deallocation upon unmapping. */
     
    288308        vm_map_remove(kernel_map, MapAddress, MapAddress + pMemFreeBSD->Core.cb);
    289309    }
    290     rc = rcNoMem; /** @todo fix translation (borrow from darwin) */
    291 
    292     vm_object_deallocate(pMemFreeBSD->pObject);
     310    else
     311    {
     312        rc = rcNoMem; /** @todo fix translation (borrow from darwin) */
     313        vm_object_deallocate(pMemFreeBSD->pObject);
     314    }
     315
    293316    rtR0MemObjDelete(&pMemFreeBSD->Core);
    294317    return rc;
     
    320343        return VERR_NO_MEMORY;
    321344
    322     int rc = rtR0MemObjFreeBSDAllocHelper(pMemFreeBSD, fExecutable, _4G, false, VERR_NO_LOW_MEMORY);
     345    int rc = rtR0MemObjFreeBSDAllocHelper(pMemFreeBSD, fExecutable, _4G - 1, false, VERR_NO_LOW_MEMORY);
    323346    if (RT_FAILURE(rc))
    324347    {
     
    339362        return VERR_NO_MEMORY;
    340363
    341     int rc = rtR0MemObjFreeBSDAllocHelper(pMemFreeBSD, fExecutable, _4G, true, VERR_NO_CONT_MEMORY);
     364    int rc = rtR0MemObjFreeBSDAllocHelper(pMemFreeBSD, fExecutable, _4G - 1, true, VERR_NO_CONT_MEMORY);
    342365    if (RT_FAILURE(rc))
    343366    {
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette