VirtualBox

Ignore:
Timestamp:
Oct 7, 2009 9:22:10 PM (16 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
53284
Message:

IPRT,VMM,SUPDrv,VBGLR0: Added a parameter to RTR0MemObjLockUser/Kernel that indicates read/write intent so we can correctly lock readonly memory on Windows and OS/2. (Guest property strings, see #4238.)

Location:
trunk/src/VBox/Additions/common/VBoxGuestLib
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/common/VBoxGuestLib/HGCMInternal.cpp

    r21778 r23610  
    4747/** Linux needs to use bounce buffers since RTR0MemObjLockUser has unwanted
    4848 *  side effects. */
    49 # define USE_BOUNCH_BUFFERS
     49# define USE_BOUNCE_BUFFERS
    5050#endif
    5151
     
    6464        uint32_t    iParm;
    6565        RTR0MEMOBJ  hObj;
    66 #ifdef USE_BOUNCH_BUFFERS
     66#ifdef USE_BOUNCE_BUFFERS
    6767        void       *pvSmallBuf;
    6868#endif
     
    274274                if (cb != 0)
    275275                {
    276 #ifdef USE_BOUNCH_BUFFERS
     276#ifdef USE_BOUNCE_BUFFERS
    277277                    void       *pvSmallBuf = NULL;
    278278#endif
     
    280280                    RTR0MEMOBJ  hObj;
    281281                    int         rc;
     282                    uint32_t    fAccess =    pSrcParm->type == VMMDevHGCMParmType_LinAddr_In
     283                                          || pSrcParm->type == VMMDevHGCMParmType_LinAddr_Locked_In
     284                                        ? RTMEM_PROT_READ
     285                                        : RTMEM_PROT_READ | RTMEM_PROT_WRITE;
    282286
    283287                    AssertReturn(iLockBuf < RT_ELEMENTS(pParmInfo->aLockBufs), VERR_INVALID_PARAMETER);
     
    286290                        AssertMsgReturn(cb <= VBGLR0_MAX_HGCM_KERNEL_PARM, ("%#x > %#x\n", cb, VBGLR0_MAX_HGCM_KERNEL_PARM),
    287291                                        VERR_OUT_OF_RANGE);
    288                         rc = RTR0MemObjLockKernel(&hObj, (void *)pSrcParm->u.Pointer.u.linearAddr, cb);
     292                        rc = RTR0MemObjLockKernel(&hObj, (void *)pSrcParm->u.Pointer.u.linearAddr, cb, fAccess);
    289293                        if (RT_FAILURE(rc))
    290294                        {
     
    306310                        }
    307311
    308 #ifndef USE_BOUNCH_BUFFERS
    309                         rc = RTR0MemObjLockUser(&hObj, (RTR3PTR)pSrcParm->u.Pointer.u.linearAddr, cb, NIL_RTR0PROCESS);
     312#ifndef USE_BOUNCE_BUFFERS
     313                        rc = RTR0MemObjLockUser(&hObj, (RTR3PTR)pSrcParm->u.Pointer.u.linearAddr, cb, fAccess, NIL_RTR0PROCESS);
    310314                        if (RT_FAILURE(rc))
    311315                        {
     
    317321                              iParm, pSrcParm->type, cb, pSrcParm->u.Pointer.u.linearAddr, hObj));
    318322
    319 #else  /* USE_BOUNCH_BUFFERS */
     323#else  /* USE_BOUNCE_BUFFERS */
    320324                        /*
    321325                         * This is a bit massive, but we don't want to waste a
     
    347351                                }
    348352                            }
    349                             rc = RTR0MemObjLockKernel(&hObj, pvSmallBuf, cb);
     353                            rc = RTR0MemObjLockKernel(&hObj, pvSmallBuf, cb, fAccess);
    350354                            if (RT_FAILURE(rc))
    351355                            {
     
    380384                                  iParm, pSrcParm->type, cb, pSrcParm->u.Pointer.u.linearAddr, hObj));
    381385                        }
    382 #endif /* USE_BOUNCH_BUFFERS */
     386#endif /* USE_BOUNCE_BUFFERS */
    383387                    }
    384388
    385389                    pParmInfo->aLockBufs[iLockBuf].iParm      = iParm;
    386390                    pParmInfo->aLockBufs[iLockBuf].hObj       = hObj;
    387 #ifdef USE_BOUNCH_BUFFERS
     391#ifdef USE_BOUNCE_BUFFERS
    388392                    pParmInfo->aLockBufs[iLockBuf].pvSmallBuf = pvSmallBuf;
    389393#endif
     
    541545                if (pSrcParm->u.Pointer.size != 0)
    542546                {
    543 #ifdef USE_BOUNCH_BUFFERS
     547#ifdef USE_BOUNCE_BUFFERS
    544548                    void      *pvSmallBuf = pParmInfo->aLockBufs[iLockBuf].pvSmallBuf;
    545549#endif
     
    557561                        pDstParm->u.PageList.offset = offExtra;
    558562                        pDstPgLst->flags            = vbglR0HGCMInternalLinAddrTypeToPageListFlags(pSrcParm->type);
    559 #ifdef USE_BOUNCH_BUFFERS
     563#ifdef USE_BOUNCE_BUFFERS
    560564                        if (fIsUser)
    561565                            pDstPgLst->offFirstPage = (uintptr_t)pvSmallBuf & PAGE_OFFSET_MASK;
     
    576580                        pDstParm->type = vbglR0HGCMInternalConvertLinAddrType(pSrcParm->type);
    577581                        pDstParm->u.Pointer.size = pSrcParm->u.Pointer.size;
    578 #ifdef USE_BOUNCH_BUFFERS
     582#ifdef USE_BOUNCE_BUFFERS
    579583                        if (fIsUser)
    580584                            pDstParm->u.Pointer.u.linearAddr = pvSmallBuf
     
    749753    HGCMFunctionParameter       *pDstParm = VBOXGUEST_HGCM_CALL_PARMS(pCallInfo);
    750754    uint32_t    cParms   = pCallInfo->cParms;
    751 #ifdef USE_BOUNCH_BUFFERS
     755#ifdef USE_BOUNCE_BUFFERS
    752756    uint32_t    iLockBuf = 0;
    753757#endif
     
    777781            case VMMDevHGCMParmType_LinAddr_Locked_In:
    778782            case VMMDevHGCMParmType_LinAddr_In:
    779 #ifdef USE_BOUNCH_BUFFERS
     783#ifdef USE_BOUNCE_BUFFERS
    780784                if (    fIsUser
    781785                    &&  iLockBuf < pParmInfo->cLockBufs
     
    798802            case VMMDevHGCMParmType_LinAddr:
    799803            {
    800 #ifdef USE_BOUNCH_BUFFERS
     804#ifdef USE_BOUNCE_BUFFERS
    801805                if (fIsUser)
    802806                {
     
    830834    }
    831835
    832 #ifdef USE_BOUNCH_BUFFERS
     836#ifdef USE_BOUNCE_BUFFERS
    833837    Assert(!fIsUser || pParmInfo->cLockBufs == iLockBuf);
    834838#endif
     
    904908        {
    905909            RTR0MemObjFree(ParmInfo.aLockBufs[ParmInfo.cLockBufs].hObj, false /*fFreeMappings*/);
    906 #ifdef USE_BOUNCH_BUFFERS
     910#ifdef USE_BOUNCE_BUFFERS
    907911            RTMemTmpFree(ParmInfo.aLockBufs[ParmInfo.cLockBufs].pvSmallBuf);
    908912#endif
  • trunk/src/VBox/Additions/common/VBoxGuestLib/SysHlp.cpp

    r21412 r23610  
    100100     *       know they aren't pagable.
    101101     */
    102     RTR0MEMOBJ MemObj = NIL_RTR0MEMOBJ;
     102    RTR0MEMOBJ  MemObj = NIL_RTR0MEMOBJ;
     103    uint32_t    fAccess = RTMEM_PROT_READ | (fWriteAccess ? RTMEM_PROT_WRITE : 0);
    103104    if ((fFlags & VBGLR0_HGCMCALL_F_MODE_MASK) == VBGLR0_HGCMCALL_F_USER)
    104         rc = RTR0MemObjLockUser(&MemObj, (RTR3PTR)pv, u32Size, NIL_RTR0PROCESS);
     105        rc = RTR0MemObjLockUser(&MemObj, (RTR3PTR)pv, u32Size, fAccess, NIL_RTR0PROCESS);
    105106    else
    106         rc = RTR0MemObjLockKernel(&MemObj, pv, u32Size);
     107        rc = RTR0MemObjLockKernel(&MemObj, pv, u32Size, fAccess);
    107108    if (RT_SUCCESS(rc))
    108109        *ppvCtx = MemObj;
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