VirtualBox

Changeset 39744 in vbox for trunk/src/VBox/Runtime


Ignore:
Timestamp:
Jan 10, 2012 6:15:04 PM (13 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
75626
Message:

rtr0memobj: Status code adjustments.

Location:
trunk/src/VBox/Runtime/r0drv
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/r0drv/darwin/memobj-r0drv-darwin.cpp

    r36555 r39744  
    508508                }
    509509
    510                 rc = VERR_NO_MEMORY;
     510                if (enmType == RTR0MEMOBJTYPE_PHYS_NC)
     511                    rc = VERR_NO_PHYS_MEMORY;
     512                else if (enmType == RTR0MEMOBJTYPE_LOW)
     513                    rc = VERR_NO_LOW_MEMORY;
     514                else if (enmType == RTR0MEMOBJTYPE_CONT)
     515                    rc = VERR_NO_CONT_MEMORY;
     516                else
     517                    rc = VERR_NO_MEMORY;
    511518            }
    512519            else
  • trunk/src/VBox/Runtime/r0drv/freebsd/memobj-r0drv-freebsd.c

    r39657 r39744  
    4545#include "internal/memobj.h"
    4646
     47
    4748/*******************************************************************************
    4849*   Structures and Typedefs                                                    *
     
    6263MALLOC_DEFINE(M_IPRTMOBJ, "iprtmobj", "IPRT - R0MemObj");
    6364
     65
    6466/**
    6567 * Gets the virtual memory map the specified object is mapped into.
     
    112114        case RTR0MEMOBJTYPE_LOW:
    113115        case RTR0MEMOBJTYPE_CONT:
    114         {
    115116            rc = vm_map_remove(kernel_map,
    116117                                (vm_offset_t)pMemFreeBSD->Core.pv,
     
    118119            AssertMsg(rc == KERN_SUCCESS, ("%#x", rc));
    119120            break;
    120         }
    121121
    122122        case RTR0MEMOBJTYPE_LOCK:
     
    223223static int rtR0MemObjFreeBSDPhysAllocHelper(vm_object_t pObject, u_long cPages,
    224224                                            vm_paddr_t VmPhysAddrHigh, u_long uAlignment,
    225                                             bool fContiguous, bool fWire)
     225                                            bool fContiguous, bool fWire, int rcNoMem)
    226226{
    227227    if (fContiguous)
     
    230230                                                   uAlignment, fWire) != NULL)
    231231            return VINF_SUCCESS;
    232         else
    233             return VERR_NO_MEMORY;
     232        return rcNoMem;
    234233    }
    235234
     
    252251            }
    253252            VM_OBJECT_UNLOCK(pObject);
    254             return VERR_NO_MEMORY;
     253            return rcNoMem;
    255254        }
    256255    }
     
    259258
    260259static int rtR0MemObjFreeBSDAllocHelper(PRTR0MEMOBJFREEBSD pMemFreeBSD, bool fExecutable,
    261                                         vm_paddr_t VmPhysAddrHigh, bool fContiguous)
     260                                        vm_paddr_t VmPhysAddrHigh, bool fContiguous, int rcNoMem)
    262261{
    263262    int rc;
     
    275274    {
    276275        rc = rtR0MemObjFreeBSDPhysAllocHelper(pMemFreeBSD->pObject, cPages,
    277                                               VmPhysAddrHigh, PAGE_SIZE, fContiguous, false);
    278         if (RT_SUCCESS(rc)) {
     276                                              VmPhysAddrHigh, PAGE_SIZE, fContiguous,
     277                                              false, rcNoMem);
     278        if (RT_SUCCESS(rc))
     279        {
    279280            vm_map_wire(kernel_map, MapAddress, MapAddress + pMemFreeBSD->Core.cb,
    280281                        VM_MAP_WIRE_SYSTEM | VM_MAP_WIRE_NOHOLES);
     
    287288        vm_map_remove(kernel_map, MapAddress, MapAddress + pMemFreeBSD->Core.cb);
    288289    }
    289     rc = VERR_NO_MEMORY; /** @todo fix translation (borrow from darwin) */
     290    rc = rcNoMem; /** @todo fix translation (borrow from darwin) */
    290291
    291292    vm_object_deallocate(pMemFreeBSD->pObject);
     
    300301        return VERR_NO_MEMORY;
    301302
    302     int rc = rtR0MemObjFreeBSDAllocHelper(pMemFreeBSD, fExecutable, ~(vm_paddr_t)0, false);
     303    int rc = rtR0MemObjFreeBSDAllocHelper(pMemFreeBSD, fExecutable, ~(vm_paddr_t)0, false, VERR_NO_MEMORY);
    303304    if (RT_FAILURE(rc))
    304305    {
     
    319320        return VERR_NO_MEMORY;
    320321
    321     int rc = rtR0MemObjFreeBSDAllocHelper(pMemFreeBSD, fExecutable, _4G, false);
     322    int rc = rtR0MemObjFreeBSDAllocHelper(pMemFreeBSD, fExecutable, _4G, false, VERR_NO_LOW_MEMORY);
    322323    if (RT_FAILURE(rc))
    323324    {
     
    338339        return VERR_NO_MEMORY;
    339340
    340     int rc = rtR0MemObjFreeBSDAllocHelper(pMemFreeBSD, fExecutable, _4G, true);
     341    int rc = rtR0MemObjFreeBSDAllocHelper(pMemFreeBSD, fExecutable, _4G, true, VERR_NO_CONT_MEMORY);
    341342    if (RT_FAILURE(rc))
    342343    {
     
    354355                                           size_t cb,
    355356                                           RTHCPHYS PhysHighest, size_t uAlignment,
    356                                            bool fContiguous)
     357                                           bool fContiguous, int rcNoMem)
    357358{
    358359    uint32_t   cPages = atop(cb);
     
    373374
    374375    int rc = rtR0MemObjFreeBSDPhysAllocHelper(pMemFreeBSD->pObject, cPages, VmPhysAddrHigh,
    375                                               uAlignment, fContiguous, true);
    376 
    377     if (RT_FAILURE(rc)) {
    378         vm_object_deallocate(pMemFreeBSD->pObject);
    379         rtR0MemObjDelete(&pMemFreeBSD->Core);
    380     }
    381     else
     376                                              uAlignment, fContiguous, true, rcNoMem);
     377    if (RT_SUCCESS(rc))
    382378    {
    383379        if (fContiguous)
     
    392388        *ppMem = &pMemFreeBSD->Core;
    393389    }
     390    else
     391    {
     392        vm_object_deallocate(pMemFreeBSD->pObject);
     393        rtR0MemObjDelete(&pMemFreeBSD->Core);
     394    }
    394395
    395396    return rc;
     
    399400DECLHIDDEN(int) rtR0MemObjNativeAllocPhys(PPRTR0MEMOBJINTERNAL ppMem, size_t cb, RTHCPHYS PhysHighest, size_t uAlignment)
    400401{
    401     return rtR0MemObjFreeBSDAllocPhysPages(ppMem, RTR0MEMOBJTYPE_PHYS, cb, PhysHighest, uAlignment, true);
     402    return rtR0MemObjFreeBSDAllocPhysPages(ppMem, RTR0MEMOBJTYPE_PHYS, cb, PhysHighest, uAlignment, true, VERR_NO_MEMORY);
    402403}
    403404
     
    405406DECLHIDDEN(int) rtR0MemObjNativeAllocPhysNC(PPRTR0MEMOBJINTERNAL ppMem, size_t cb, RTHCPHYS PhysHighest)
    406407{
    407     return rtR0MemObjFreeBSDAllocPhysPages(ppMem, RTR0MEMOBJTYPE_PHYS_NC, cb, PhysHighest, PAGE_SIZE, false);
     408    return rtR0MemObjFreeBSDAllocPhysPages(ppMem, RTR0MEMOBJTYPE_PHYS_NC, cb, PhysHighest, PAGE_SIZE, false, VERR_NO_PHYS_MEMORY);
    408409}
    409410
     
    497498     * The pvFixed address range must be within the VM space when specified.
    498499     */
    499     if (pvFixed != (void *)-1
     500    if (   pvFixed != (void *)-1
    500501        && (    (vm_offset_t)pvFixed      < vm_map_min(pMap)
    501502            ||  (vm_offset_t)pvFixed + cb > vm_map_max(pMap)))
  • trunk/src/VBox/Runtime/r0drv/linux/memobj-r0drv-linux.c

    r39705 r39744  
    180180 * @param   fFlagsLnx   The page allocation flags (GPFs).
    181181 * @param   fContiguous Whether the allocation must be contiguous.
     182 * @param   rcNoMem     What to return when we're out of pages.
    182183 */
    183184static int rtR0MemObjLinuxAllocPages(PRTR0MEMOBJLNX *ppMemLnx, RTR0MEMOBJTYPE enmType, size_t cb,
    184                                      size_t uAlignment, unsigned fFlagsLnx, bool fContiguous)
     185                                     size_t uAlignment, unsigned fFlagsLnx, bool fContiguous, int rcNoMem)
    185186{
    186187    size_t          iPage;
     
    231232        {
    232233            rtR0MemObjDelete(&pMemLnx->Core);
    233             return VERR_NO_MEMORY;
     234            return rcNoMem;
    234235        }
    235236    }
     
    245246                    __free_page(pMemLnx->apPages[iPage]);
    246247                rtR0MemObjDelete(&pMemLnx->Core);
    247                 return VERR_NO_MEMORY;
     248                return rcNoMem;
    248249            }
    249250        }
     
    256257    {
    257258        rtR0MemObjDelete(&pMemLnx->Core);
    258         return VERR_NO_MEMORY;
     259        return rcNoMem;
    259260    }
    260261    for (iPage = 0; iPage < cPages; iPage++)
     
    295296                    (unsigned long)cb, (unsigned long)uAlignment, rtR0MemObjLinuxOrder(cPages), (unsigned long)page_to_phys(pMemLnx->apPages[0]));
    296297            rtR0MemObjLinuxFreePages(pMemLnx);
    297             return VERR_NO_MEMORY;
     298            return rcNoMem;
    298299        }
    299300    }
     
    541542
    542543#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 4, 22)
    543     rc = rtR0MemObjLinuxAllocPages(&pMemLnx, RTR0MEMOBJTYPE_PAGE, cb, PAGE_SIZE, GFP_HIGHUSER, false /* non-contiguous */);
     544    rc = rtR0MemObjLinuxAllocPages(&pMemLnx, RTR0MEMOBJTYPE_PAGE, cb, PAGE_SIZE, GFP_HIGHUSER,
     545                                   false /* non-contiguous */, VERR_NO_MEMORY);
    544546#else
    545     rc = rtR0MemObjLinuxAllocPages(&pMemLnx, RTR0MEMOBJTYPE_PAGE, cb, PAGE_SIZE, GFP_USER, false /* non-contiguous */);
     547    rc = rtR0MemObjLinuxAllocPages(&pMemLnx, RTR0MEMOBJTYPE_PAGE, cb, PAGE_SIZE, GFP_USER,
     548                                   false /* non-contiguous */, VERR_NO_MEMORY);
    546549#endif
    547550    if (RT_SUCCESS(rc))
     
    570573#if (defined(RT_ARCH_AMD64) || defined(CONFIG_X86_PAE)) && defined(GFP_DMA32)
    571574    /* ZONE_DMA32: 0-4GB */
    572     rc = rtR0MemObjLinuxAllocPages(&pMemLnx, RTR0MEMOBJTYPE_LOW, cb, PAGE_SIZE, GFP_DMA32, false /* non-contiguous */);
     575    rc = rtR0MemObjLinuxAllocPages(&pMemLnx, RTR0MEMOBJTYPE_LOW, cb, PAGE_SIZE, GFP_DMA32,
     576                                   false /* non-contiguous */, VERR_NO_LOW_MEMORY);
    573577    if (RT_FAILURE(rc))
    574578#endif
    575579#ifdef RT_ARCH_AMD64
    576580        /* ZONE_DMA: 0-16MB */
    577         rc = rtR0MemObjLinuxAllocPages(&pMemLnx, RTR0MEMOBJTYPE_LOW, cb, PAGE_SIZE, GFP_DMA, false /* non-contiguous */);
     581        rc = rtR0MemObjLinuxAllocPages(&pMemLnx, RTR0MEMOBJTYPE_LOW, cb, PAGE_SIZE, GFP_DMA,
     582                                       false /* non-contiguous */, VERR_NO_LOW_MEMORY);
    578583#else
    579584# ifdef CONFIG_X86_PAE
    580585# endif
    581586        /* ZONE_NORMAL: 0-896MB */
    582         rc = rtR0MemObjLinuxAllocPages(&pMemLnx, RTR0MEMOBJTYPE_LOW, cb, PAGE_SIZE, GFP_USER, false /* non-contiguous */);
     587        rc = rtR0MemObjLinuxAllocPages(&pMemLnx, RTR0MEMOBJTYPE_LOW, cb, PAGE_SIZE, GFP_USER,
     588                                       false /* non-contiguous */, VERR_NO_LOW_MEMORY);
    583589#endif
    584590    if (RT_SUCCESS(rc))
     
    606612#if (defined(RT_ARCH_AMD64) || defined(CONFIG_X86_PAE)) && defined(GFP_DMA32)
    607613    /* ZONE_DMA32: 0-4GB */
    608     rc = rtR0MemObjLinuxAllocPages(&pMemLnx, RTR0MEMOBJTYPE_CONT, cb, PAGE_SIZE, GFP_DMA32, true /* contiguous */);
     614    rc = rtR0MemObjLinuxAllocPages(&pMemLnx, RTR0MEMOBJTYPE_CONT, cb, PAGE_SIZE, GFP_DMA32,
     615                                   true /* contiguous */, VERR_NO_CONT_MEMORY);
    609616    if (RT_FAILURE(rc))
    610617#endif
    611618#ifdef RT_ARCH_AMD64
    612619        /* ZONE_DMA: 0-16MB */
    613         rc = rtR0MemObjLinuxAllocPages(&pMemLnx, RTR0MEMOBJTYPE_CONT, cb, PAGE_SIZE, GFP_DMA, true /* contiguous */);
     620        rc = rtR0MemObjLinuxAllocPages(&pMemLnx, RTR0MEMOBJTYPE_CONT, cb, PAGE_SIZE, GFP_DMA,
     621                                       true /* contiguous */, VERR_NO_CONT_MEMORY);
    614622#else
    615623        /* ZONE_NORMAL (32-bit hosts): 0-896MB */
    616         rc = rtR0MemObjLinuxAllocPages(&pMemLnx, RTR0MEMOBJTYPE_CONT, cb, PAGE_SIZE, GFP_USER, true /* contiguous */);
     624        rc = rtR0MemObjLinuxAllocPages(&pMemLnx, RTR0MEMOBJTYPE_CONT, cb, PAGE_SIZE, GFP_USER,
     625                                       true /* contiguous */, VERR_NO_CONT_MEMORY);
    617626#endif
    618627    if (RT_SUCCESS(rc))
     
    658667
    659668    rc = rtR0MemObjLinuxAllocPages(&pMemLnx, enmType, cb, uAlignment, fGfp,
    660                                    enmType == RTR0MEMOBJTYPE_PHYS /* contiguous / non-contiguous */);
     669                                   enmType == RTR0MEMOBJTYPE_PHYS /* contiguous / non-contiguous */,
     670                                   VERR_NO_PHYS_MEMORY);
    661671    if (RT_FAILURE(rc))
    662672        return rc;
  • trunk/src/VBox/Runtime/r0drv/nt/memobj-r0drv-nt.cpp

    r38958 r39744  
    273273            if (rtR0MemObjNativeGetPagePhysAddr(*ppMem, iPage) >= _4G)
    274274            {
    275                 rc = VERR_NO_MEMORY;
     275                rc = VERR_NO_LOW_MEMORY;
    276276                break;
    277277            }
  • trunk/src/VBox/Runtime/r0drv/os2/memobj-r0drv-os2.cpp

    r36555 r39744  
    167167    }
    168168    rtR0MemObjDelete(&pMemOs2->Core);
    169     return RTErrConvertFromOS2(rc);
     169    rc = RTErrConvertFromOS2(rc);
     170    return rc == VERR_NO_MEMORY ? VERR_NO_LOW_MEMORY : rc;
    170171}
    171172
Note: See TracChangeset for help on using the changeset viewer.

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