VirtualBox

Changeset 392 in vbox for trunk


Ignore:
Timestamp:
Jan 27, 2007 10:28:29 PM (18 years ago)
Author:
vboxsync
Message:

Added a process specifier to the APIs dealing with user addresses.

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/iprt/memobj.h

    r1 r392  
    126126 * @param   pv              User virtual address. This is rounded down to a page boundrary.
    127127 * @param   cb              Number of bytes to lock. This is rounded up to nearest page boundrary.
     128 * @param   R0Process       The process to lock pages in. NIL_R0PROCESS is an alias for the current one.
    128129 *
    129130 * @remark  RTR0MemObjGetAddress() will return the rounded down address.
    130131 */
    131 RTR0DECL(int) RTR0MemObjLockUser(PRTR0MEMOBJ pMemObj, void *pv, size_t cb);
     132RTR0DECL(int) RTR0MemObjLockUser(PRTR0MEMOBJ pMemObj, void *pv, size_t cb, RTR0PROCESS R0Process);
    132133
    133134/**
     
    188189 * @param   uAlignment      The alignment of the reserved memory.
    189190 *                          Supported values are 0 (alias for PAGE_SIZE), PAGE_SIZE, _2M and _4M.
    190  */
    191 RTR0DECL(int) RTR0MemObjReserveUser(PRTR0MEMOBJ pMemObj, void *pvFixed, size_t cb, size_t uAlignment);
     191 * @param   R0Process       The process to reserve the memory in. NIL_R0PROCESS is an alias for the current one.
     192 */
     193RTR0DECL(int) RTR0MemObjReserveUser(PRTR0MEMOBJ pMemObj, void *pvFixed, size_t cb, size_t uAlignment, RTR0PROCESS R0Process);
    192194
    193195/**
     
    214216 *                          Supported values are 0 (alias for PAGE_SIZE), PAGE_SIZE, _2M and _4M.
    215217 * @param   fProt           Combination of RTMEM_PROT_* flags (except RTMEM_PROT_NONE).
    216  */
    217 RTR0DECL(int) RTR0MemObjMapUser(PRTR0MEMOBJ pMemObj, RTR0MEMOBJ MemObjToMap, void *pvFixed, size_t uAlignment, unsigned fProt);
     218 * @param   R0Process       The process to map the memory into. NIL_R0PROCESS is an alias for the current one.
     219 */
     220RTR0DECL(int) RTR0MemObjMapUser(PRTR0MEMOBJ pMemObj, RTR0MEMOBJ MemObjToMap, void *pvFixed, size_t uAlignment, unsigned fProt, RTR0PROCESS R0Process);
    218221
    219222#endif /* IN_RING0 */
  • trunk/src/VBox/HostDrivers/Support/SUPDRVShared.c

    r387 r392  
    3333#include <iprt/spinlock.h>
    3434#include <iprt/thread.h>
     35#include <iprt/process.h>
    3536#include <iprt/log.h>
    3637#ifdef VBOX_WITHOUT_IDT_PATCHING
     
    17271728     */
    17281729    Mem.eType = MEMREF_TYPE_LOCKED;
    1729     rc = RTR0MemObjLockUser(&Mem.MemObj, pvR3, cb);
     1730    rc = RTR0MemObjLockUser(&Mem.MemObj, pvR3, cb, RTR0ProcHandleSelf());
    17301731    if (RT_SUCCESS(rc))
    17311732    {
     
    18321833    {
    18331834        int rc2;
    1834         rc = RTR0MemObjMapUser(&Mem.MapObjR3, Mem.MemObj, (void *)-1, 0, RTMEM_PROT_EXEC | RTMEM_PROT_WRITE | RTMEM_PROT_READ);
     1835        rc = RTR0MemObjMapUser(&Mem.MapObjR3, Mem.MemObj, (void *)-1, 0,
     1836                               RTMEM_PROT_EXEC | RTMEM_PROT_WRITE | RTMEM_PROT_READ, RTR0ProcHandleSelf());
    18351837        if (RT_SUCCESS(rc))
    18361838        {
     
    19361938    {
    19371939        int rc2;
    1938         rc = RTR0MemObjMapUser(&Mem.MapObjR3, Mem.MemObj, (void *)-1, 0, RTMEM_PROT_EXEC | RTMEM_PROT_WRITE | RTMEM_PROT_READ);
     1940        rc = RTR0MemObjMapUser(&Mem.MapObjR3, Mem.MemObj, (void *)-1, 0,
     1941                               RTMEM_PROT_EXEC | RTMEM_PROT_WRITE | RTMEM_PROT_READ, RTR0ProcHandleSelf());
    19391942        if (RT_SUCCESS(rc))
    19401943        {
     
    20462049    {
    20472050        int rc2;
    2048         rc = RTR0MemObjMapUser(&Mem.MapObjR3, Mem.MemObj, (void*)-1, 0, RTMEM_PROT_EXEC | RTMEM_PROT_WRITE | RTMEM_PROT_READ);
     2051        rc = RTR0MemObjMapUser(&Mem.MapObjR3, Mem.MemObj, (void*)-1, 0,
     2052                               RTMEM_PROT_EXEC | RTMEM_PROT_WRITE | RTMEM_PROT_READ, RTR0ProcHandleSelf());
    20492053        if (RT_SUCCESS(rc))
    20502054        {
     
    22202224#ifdef USE_NEW_OS_INTERFACE
    22212225            if (pSession->GipMapObjR3 == NIL_RTR0MEMOBJ)
    2222                 rc = RTR0MemObjMapUser(&pSession->GipMapObjR3, pDevExt->GipMemObj, (void*)-1, 0, RTMEM_PROT_READ);
     2226                rc = RTR0MemObjMapUser(&pSession->GipMapObjR3, pDevExt->GipMemObj, (void*)-1, 0,
     2227                                       RTMEM_PROT_READ, RTR0ProcHandleSelf());
    22232228            if (RT_SUCCESS(rc))
    22242229            {
  • trunk/src/VBox/Runtime/include/internal/memobj.h

    r385 r392  
    264264 * @param   pv              User virtual address, page aligned.
    265265 * @param   cb              Number of bytes to lock, page aligned.
    266  */
    267 int rtR0MemObjNativeLockUser(PPRTR0MEMOBJINTERNAL ppMem, void *pv, size_t cb);
     266 * @param   R0Process       The process to lock pages in.
     267 */
     268int rtR0MemObjNativeLockUser(PPRTR0MEMOBJINTERNAL ppMem, void *pv, size_t cb, RTR0PROCESS R0Process);
    268269
    269270/**
     
    317318 * @param   cb              The number of bytes to reserve, page aligned.
    318319 * @param   uAlignment      The alignment of the reserved memory; PAGE_SIZE, _2M or _4M.
    319  */
    320 int rtR0MemObjNativeReserveUser(PPRTR0MEMOBJINTERNAL ppMem, void *pvFixed, size_t cb, size_t uAlignment);
     320 * @param   R0Process       The process to reserve the memory in.
     321 */
     322int rtR0MemObjNativeReserveUser(PPRTR0MEMOBJINTERNAL ppMem, void *pvFixed, size_t cb, size_t uAlignment, RTR0PROCESS R0Process);
    321323
    322324/**
     
    341343 * @param   uAlignment      The alignment of the reserved memory; PAGE_SIZE, _2M or _4M.
    342344 * @param   fProt           Combination of RTMEM_PROT_* flags (except RTMEM_PROT_NONE).
    343  */
    344 int rtR0MemObjNativeMapUser(PPRTR0MEMOBJINTERNAL ppMem, PRTR0MEMOBJINTERNAL pMemToMap, void *pvFixed, size_t uAlignment, unsigned fProt);
     345 * @param   R0Process       The process to map the memory into.
     346 */
     347int rtR0MemObjNativeMapUser(PPRTR0MEMOBJINTERNAL ppMem, PRTR0MEMOBJINTERNAL pMemToMap, void *pvFixed, size_t uAlignment, unsigned fProt, RTR0PROCESS R0Process);
    345348
    346349/**
  • trunk/src/VBox/Runtime/r0drv/darwin/memobj-r0drv-darwin.cpp

    r385 r392  
    423423
    424424
    425 int rtR0MemObjNativeLockUser(PPRTR0MEMOBJINTERNAL ppMem, void *pv, size_t cb)
    426 {
    427     return rtR0MemObjNativeLock(ppMem, pv, cb, current_task());
     425int rtR0MemObjNativeLockUser(PPRTR0MEMOBJINTERNAL ppMem, void *pv, size_t cb, RTR0PROCESS R0Process)
     426{
     427    return rtR0MemObjNativeLock(ppMem, pv, cb, (task_t)R0Process);
    428428}
    429429
     
    441441
    442442
    443 int rtR0MemObjNativeReserveUser(PPRTR0MEMOBJINTERNAL ppMem, void *pvFixed, size_t cb, size_t uAlignment)
     443int rtR0MemObjNativeReserveUser(PPRTR0MEMOBJINTERNAL ppMem, void *pvFixed, size_t cb, size_t uAlignment, RTR0PROCESS R0Process)
    444444{
    445445    return VERR_NOT_IMPLEMENTED;
     
    490490
    491491
    492 int rtR0MemObjNativeMapUser(PPRTR0MEMOBJINTERNAL ppMem, RTR0MEMOBJ pMemToMap, void *pvFixed, size_t uAlignment, unsigned fProt)
     492int rtR0MemObjNativeMapUser(PPRTR0MEMOBJINTERNAL ppMem, RTR0MEMOBJ pMemToMap, void *pvFixed, size_t uAlignment, unsigned fProt, RTR0PROCESS R0Process)
    493493{
    494494    /*
     
    499499    if (pMemToMapDarwin->pMemDesc)
    500500    {
    501         Assert(current_task() != kernel_task);
    502         IOMemoryMap *pMemMap = pMemToMapDarwin->pMemDesc->map(current_task(), kIOMapAnywhere,
     501        IOMemoryMap *pMemMap = pMemToMapDarwin->pMemDesc->map((task_t)R0Process, kIOMapAnywhere,
    503502                                                              kIOMapAnywhere | kIOMapDefaultCache);
    504503        if (pMemMap)
     
    515514                if (pMemDarwin)
    516515                {
    517                     pMemDarwin->Core.u.Mapping.R0Process = RTR0ProcHandleSelf();
     516                    pMemDarwin->Core.u.Mapping.R0Process = R0Process;
    518517                    pMemDarwin->pMemMap = pMemMap;
    519518                    *ppMem = &pMemDarwin->Core;
  • trunk/src/VBox/Runtime/r0drv/memobj-r0drv.cpp

    r217 r392  
    2727#include <iprt/memobj.h>
    2828#include <iprt/alloc.h>
     29#include <iprt/process.h>
    2930#include <iprt/assert.h>
    3031#include <iprt/err.h>
     
    389390 * @param   pv              User virtual address. This is rounded down to a page boundrary.
    390391 * @param   cb              Number of bytes to lock. This is rounded up to nearest page boundrary.
     392 * @param   R0Process       The process to lock pages in. NIL_R0PROCESS is an alias for the current one.
    391393 *
    392394 * @remark  RTR0MemObjGetAddress() will return the rounded down address.
    393395 */
    394 RTR0DECL(int) RTR0MemObjLockUser(PRTR0MEMOBJ pMemObj, void *pv, size_t cb)
     396RTR0DECL(int) RTR0MemObjLockUser(PRTR0MEMOBJ pMemObj, void *pv, size_t cb, RTR0PROCESS R0Process)
    395397{
    396398    /* sanity checks. */
     
    401403    AssertReturn(cb <= cbAligned, VERR_INVALID_PARAMETER);
    402404    void * const pvAligned = (void *)((uintptr_t)pv & ~(uintptr_t)PAGE_OFFSET_MASK);
     405    if (R0Process == NIL_RTR0PROCESS)
     406        R0Process = RTR0ProcHandleSelf();
    403407
    404408    /* do the allocation. */
    405     return rtR0MemObjNativeLockUser(pMemObj, pvAligned, cbAligned);
     409    return rtR0MemObjNativeLockUser(pMemObj, pvAligned, cbAligned, R0Process);
    406410}
    407411
     
    522526 * @param   uAlignment      The alignment of the reserved memory.
    523527 *                          Supported values are 0 (alias for PAGE_SIZE), PAGE_SIZE, _2M and _4M.
    524  */
    525 RTR0DECL(int) RTR0MemObjReserveUser(PRTR0MEMOBJ pMemObj, void *pvFixed, size_t cb, size_t uAlignment)
     528 * @param   R0Process       The process to reserve the memory in. NIL_R0PROCESS is an alias for the current one.
     529 */
     530RTR0DECL(int) RTR0MemObjReserveUser(PRTR0MEMOBJ pMemObj, void *pvFixed, size_t cb, size_t uAlignment, RTR0PROCESS R0Process)
    526531{
    527532    /* sanity checks. */
     
    536541    if (pvFixed != (void *)-1)
    537542        AssertReturn(!((uintptr_t)pvFixed & (uAlignment - 1)), VERR_INVALID_PARAMETER);
     543    if (R0Process == NIL_RTR0PROCESS)
     544        R0Process = RTR0ProcHandleSelf();
    538545
    539546    /* do the reservation. */
    540     return rtR0MemObjNativeReserveUser(pMemObj, pvFixed, cbAligned, uAlignment);
     547    return rtR0MemObjNativeReserveUser(pMemObj, pvFixed, cbAligned, uAlignment, R0Process);
    541548}
    542549
     
    607614 *                          Supported values are 0 (alias for PAGE_SIZE), PAGE_SIZE, _2M and _4M.
    608615 * @param   fProt           Combination of RTMEM_PROT_* flags (except RTMEM_PROT_NONE).
    609  */
    610 RTR0DECL(int) RTR0MemObjMapUser(PRTR0MEMOBJ pMemObj, RTR0MEMOBJ MemObjToMap, void *pvFixed, size_t uAlignment, unsigned fProt)
     616 * @param   R0Process       The process to map the memory into. NIL_R0PROCESS is an alias for the current one.
     617 */
     618RTR0DECL(int) RTR0MemObjMapUser(PRTR0MEMOBJ pMemObj, RTR0MEMOBJ MemObjToMap, void *pvFixed, size_t uAlignment, unsigned fProt, RTR0PROCESS R0Process)
    611619{
    612620    /* sanity checks. */
     
    626634    AssertReturn(fProt != RTMEM_PROT_NONE, VERR_INVALID_PARAMETER);
    627635    AssertReturn(!(fProt & ~(RTMEM_PROT_READ | RTMEM_PROT_WRITE | RTMEM_PROT_EXEC)), VERR_INVALID_PARAMETER);
    628 
     636    if (R0Process == NIL_RTR0PROCESS)
     637        R0Process = RTR0ProcHandleSelf();
    629638
    630639    /* do the mapping. */
    631640    PRTR0MEMOBJINTERNAL pNew;
    632     int rc = rtR0MemObjNativeMapUser(&pNew, pMemToMap, pvFixed, uAlignment, fProt);
     641    int rc = rtR0MemObjNativeMapUser(&pNew, pMemToMap, pvFixed, uAlignment, fProt, R0Process);
    633642    if (RT_SUCCESS(rc))
    634643    {
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