VirtualBox

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


Ignore:
Timestamp:
Apr 23, 2008 2:21:31 PM (17 years ago)
Author:
vboxsync
Message:

Solaris vboxdrv: some memobj error handling fixes and cleanups.

File:
1 edited

Legend:

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

    r8327 r8330  
    312312    /* Lock down kernel pages */
    313313    int rc = as_pagelock(&kas, &ppl, virtAddr, cb, S_WRITE);
    314     if (rc != 0)
    315     {
    316         cmn_err(CE_NOTE,"rtR0MemObjNativeLockKernel: as_pagelock failed rc=%d\n", rc);
    317         return VERR_LOCK_FAILED;
    318     }
    319 
    320     if (!ppl)
    321     {
     314    if (!rc)
     315    {
     316        if (ppl)
     317        {
     318            pMemSolaris->Core.u.Lock.R0Process = NIL_RTR0PROCESS;   /* means kernel, see rtR0MemObjNativeFree() */
     319            pMemSolaris->ppShadowPages = ppl;
     320            *ppMem = &pMemSolaris->Core;
     321            return VINF_SUCCESS;           
     322        }
     323
    322324        as_pageunlock(&kas, ppl, virtAddr, cb, S_WRITE);
    323325        cmn_err(CE_NOTE, "rtR0MemObjNativeLockKernel: failed to get shadow pages\n");
    324         return VERR_LOCK_FAILED;
    325     }
    326 
    327     pMemSolaris->Core.u.Lock.R0Process = NIL_RTR0PROCESS;   /* means kernel, see rtR0MemObjNativeFree() */
    328     pMemSolaris->ppShadowPages = ppl;
    329     *ppMem = &pMemSolaris->Core;
    330     return VINF_SUCCESS;
     326    }
     327    else
     328        cmn_err(CE_NOTE,"rtR0MemObjNativeLockKernel: as_pagelock failed rc=%d\n", rc);
     329    rtR0MemObjDelete(pMemSolaris);
     330    return VERR_LOCK_FAILED;
    331331}
    332332
     
    431431    int rc;
    432432
    433     /* Create the mapping object */
    434     PRTR0MEMOBJSOLARIS pMemSolaris = (PRTR0MEMOBJSOLARIS)rtR0MemObjNew(sizeof(*pMemSolaris), RTR0MEMOBJTYPE_MAPPING, pv, size);
    435     if (!pMemSolaris)
    436         return VERR_NO_MEMORY;
    437 
    438433    as_rangelock(useras);
    439434    if (R3PtrFixed != (RTR3PTR)-1)
     
    486481    }
    487482
    488 #if 0
    489     /* Lock down the pages and get the shadow page list
    490      * In this case we must as_pageunlock if(ppShadowPages) exists while freeing CONT, PAGE
    491      */
    492     rc = as_pagelock(&kas, &pMemToMapSolaris->ppShadowPages, pv, size, S_WRITE);
    493     if (rc != 0 || pMemToMapSolaris->ppShadowPages == NULL)
    494     {
    495         cmn_err(CE_NOTE, "rtR0MemObjNativeMapUser: as_pagelock failed\n");
     483    /* Create the mapping object */
     484    PRTR0MEMOBJSOLARIS pMemSolaris = (PRTR0MEMOBJSOLARIS)rtR0MemObjNew(sizeof(*pMemSolaris), RTR0MEMOBJTYPE_MAPPING, pv, size);
     485    if (!pMemSolaris)
     486    {
     487        /* Undo mapping on failure. */
    496488        as_unmap(useras, addr, size);
    497489        return VERR_NO_MEMORY;
    498490    }
    499491
    500     /* Map each page into user space */
    501     rw_enter(&useras->a_lock, RW_READER);
    502     caddr_t pageAddr = addr;
    503     for (iPage = 0; iPage < cPages; iPage++)
    504     {
    505         hat_memload(useras->a_hat, pageAddr, pMemToMapSolaris->ppShadowPages[iPage], fProt | PROT_USER,
    506                 HAT_LOAD_NOCONSIST | HAT_STRICTORDER | HAT_LOAD_LOCK);
    507         pageAddr += ptob(1);
    508     }
    509     rw_exit(&useras->a_lock, RW_READER);
    510 #else
    511492    /* Map each page into user space */
    512493    rw_enter(&useras->a_lock, RW_READER);
     
    521502    }
    522503    rw_exit(&useras->a_lock);
    523 #endif
    524504
    525505    pMemSolaris->Core.u.Mapping.R0Process = (RTR0PROCESS)userproc;
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