VirtualBox

Ignore:
Timestamp:
May 5, 2009 2:44:43 PM (16 years ago)
Author:
vboxsync
Message:

Further breakup of GVM. Deal with VCPU thread handles.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMR0/GMMR0.cpp

    r19360 r19381  
    10371037 *
    10381038 * @param   pVM             Pointer to the shared VM structure.
     1039 * @param   idCpu           VCPU id
    10391040 * @param   cBasePages      The number of pages that may be allocated for the base RAM and ROMs.
    10401041 *                          This does not include MMIO2 and similar.
     
    10471048 * @thread  The creator thread / EMT.
    10481049 */
    1049 GMMR0DECL(int) GMMR0InitialReservation(PVM pVM, uint64_t cBasePages, uint32_t cShadowPages, uint32_t cFixedPages,
     1050GMMR0DECL(int) GMMR0InitialReservation(PVM pVM, unsigned idCpu, uint64_t cBasePages, uint32_t cShadowPages, uint32_t cFixedPages,
    10501051                                       GMMOCPOLICY enmPolicy, GMMPRIORITY enmPriority)
    10511052{
     
    10591060    GMM_GET_VALID_INSTANCE(pGMM, VERR_INTERNAL_ERROR);
    10601061    PGVM pGVM = GVMMR0ByVM(pVM);
    1061     if (!pGVM)
     1062    if (RT_UNLIKELY(!pGVM))
    10621063        return VERR_INVALID_PARAMETER;
    1063     if (pGVM->hEMT != RTThreadNativeSelf())
     1064    if (RT_UNLIKELY(pGVM->aCpus[idCpu].hEMT != RTThreadNativeSelf()))
    10641065        return VERR_NOT_OWNER;
    10651066
     
    11111112 * @returns see GMMR0InitialReservation.
    11121113 * @param   pVM             Pointer to the shared VM structure.
     1114 * @param   idCpu           VCPU id
    11131115 * @param   pReq            The request packet.
    11141116 */
    1115 GMMR0DECL(int) GMMR0InitialReservationReq(PVM pVM, PGMMINITIALRESERVATIONREQ pReq)
     1117GMMR0DECL(int) GMMR0InitialReservationReq(PVM pVM, unsigned idCpu, PGMMINITIALRESERVATIONREQ pReq)
    11161118{
    11171119    /*
     
    11221124    AssertMsgReturn(pReq->Hdr.cbReq == sizeof(*pReq), ("%#x != %#x\n", pReq->Hdr.cbReq, sizeof(*pReq)), VERR_INVALID_PARAMETER);
    11231125
    1124     return GMMR0InitialReservation(pVM, pReq->cBasePages, pReq->cShadowPages, pReq->cFixedPages, pReq->enmPolicy, pReq->enmPriority);
     1126    return GMMR0InitialReservation(pVM, idCpu, pReq->cBasePages, pReq->cShadowPages, pReq->cFixedPages, pReq->enmPolicy, pReq->enmPriority);
    11251127}
    11261128
     
    11331135 *
    11341136 * @param   pVM             Pointer to the shared VM structure.
     1137 * @param   idCpu           VCPU id
    11351138 * @param   cBasePages      The number of pages that may be allocated for the base RAM and ROMs.
    11361139 *                          This does not include MMIO2 and similar.
     
    11411144 * @thread  EMT.
    11421145 */
    1143 GMMR0DECL(int) GMMR0UpdateReservation(PVM pVM, uint64_t cBasePages, uint32_t cShadowPages, uint32_t cFixedPages)
     1146GMMR0DECL(int) GMMR0UpdateReservation(PVM pVM, unsigned idCpu, uint64_t cBasePages, uint32_t cShadowPages, uint32_t cFixedPages)
    11441147{
    11451148    LogFlow(("GMMR0UpdateReservation: pVM=%p cBasePages=%#llx cShadowPages=%#x cFixedPages=%#x\n",
     
    11521155    GMM_GET_VALID_INSTANCE(pGMM, VERR_INTERNAL_ERROR);
    11531156    PGVM pGVM = GVMMR0ByVM(pVM);
    1154     if (!pGVM)
     1157    if (RT_UNLIKELY(!pGVM))
    11551158        return VERR_INVALID_PARAMETER;
    1156     if (pGVM->hEMT != RTThreadNativeSelf())
     1159    if (RT_UNLIKELY(pGVM->aCpus[idCpu].hEMT != RTThreadNativeSelf()))
    11571160        return VERR_NOT_OWNER;
    11581161
     
    12011204 * @returns see GMMR0UpdateReservation.
    12021205 * @param   pVM             Pointer to the shared VM structure.
     1206 * @param   idCpu           VCPU id
    12031207 * @param   pReq            The request packet.
    12041208 */
    1205 GMMR0DECL(int) GMMR0UpdateReservationReq(PVM pVM, PGMMUPDATERESERVATIONREQ pReq)
     1209GMMR0DECL(int) GMMR0UpdateReservationReq(PVM pVM, unsigned idCpu, PGMMUPDATERESERVATIONREQ pReq)
    12061210{
    12071211    /*
     
    12121216    AssertMsgReturn(pReq->Hdr.cbReq == sizeof(*pReq), ("%#x != %#x\n", pReq->Hdr.cbReq, sizeof(*pReq)), VERR_INVALID_PARAMETER);
    12131217
    1214     return GMMR0UpdateReservation(pVM, pReq->cBasePages, pReq->cShadowPages, pReq->cFixedPages);
     1218    return GMMR0UpdateReservation(pVM, idCpu, pReq->cBasePages, pReq->cShadowPages, pReq->cFixedPages);
    12151219}
    12161220
     
    18401844 *
    18411845 * @param   pVM                 Pointer to the shared VM structure.
     1846 * @param   idCpu               VCPU id
    18421847 * @param   cPagesToUpdate      The number of pages to update (starting from the head).
    18431848 * @param   cPagesToAlloc       The number of pages to allocate (starting from the head).
     
    18461851 * @thread  EMT.
    18471852 */
    1848 GMMR0DECL(int) GMMR0AllocateHandyPages(PVM pVM, uint32_t cPagesToUpdate, uint32_t cPagesToAlloc, PGMMPAGEDESC paPages)
     1853GMMR0DECL(int) GMMR0AllocateHandyPages(PVM pVM, unsigned idCpu, uint32_t cPagesToUpdate, uint32_t cPagesToAlloc, PGMMPAGEDESC paPages)
    18491854{
    18501855    LogFlow(("GMMR0AllocateHandyPages: pVM=%p cPagesToUpdate=%#x cPagesToAlloc=%#x paPages=%p\n",
     
    18601865    if (RT_UNLIKELY(!pGVM))
    18611866        return VERR_INVALID_PARAMETER;
    1862     if (RT_UNLIKELY(pGVM->hEMT != RTThreadNativeSelf()))
     1867    if (RT_UNLIKELY(pGVM->aCpus[idCpu].hEMT != RTThreadNativeSelf()))
    18631868        return VERR_NOT_OWNER;
    18641869
     
    20212026 *
    20222027 * @param   pVM                 Pointer to the shared VM structure.
     2028 * @param   idCpu               VCPU id
    20232029 * @param   cPages              The number of pages to allocate.
    20242030 * @param   paPages             Pointer to the page descriptors.
     
    20282034 * @thread  EMT.
    20292035 */
    2030 GMMR0DECL(int) GMMR0AllocatePages(PVM pVM, uint32_t cPages, PGMMPAGEDESC paPages, GMMACCOUNT enmAccount)
     2036GMMR0DECL(int) GMMR0AllocatePages(PVM pVM, unsigned idCpu, uint32_t cPages, PGMMPAGEDESC paPages, GMMACCOUNT enmAccount)
    20312037{
    20322038    LogFlow(("GMMR0AllocatePages: pVM=%p cPages=%#x paPages=%p enmAccount=%d\n", pVM, cPages, paPages, enmAccount));
     
    20382044    GMM_GET_VALID_INSTANCE(pGMM, VERR_INTERNAL_ERROR);
    20392045    PGVM pGVM = GVMMR0ByVM(pVM);
    2040     if (!pGVM)
     2046    if (RT_UNLIKELY(!pGVM))
    20412047        return VERR_INVALID_PARAMETER;
    2042     if (pGVM->hEMT != RTThreadNativeSelf())
     2048    if (RT_UNLIKELY(pGVM->aCpus[idCpu].hEMT != RTThreadNativeSelf()))
    20432049        return VERR_NOT_OWNER;
    20442050
     
    20952101 * @returns see GMMR0AllocatePages.
    20962102 * @param   pVM             Pointer to the shared VM structure.
     2103 * @param   idCpu           VCPU id
    20972104 * @param   pReq            The request packet.
    20982105 */
    2099 GMMR0DECL(int) GMMR0AllocatePagesReq(PVM pVM, PGMMALLOCATEPAGESREQ pReq)
     2106GMMR0DECL(int) GMMR0AllocatePagesReq(PVM pVM, unsigned idCpu, PGMMALLOCATEPAGESREQ pReq)
    21002107{
    21012108    /*
     
    21112118                    VERR_INVALID_PARAMETER);
    21122119
    2113     return GMMR0AllocatePages(pVM, pReq->cPages, &pReq->aPages[0], pReq->enmAccount);
     2120    return GMMR0AllocatePages(pVM, idCpu, pReq->cPages, &pReq->aPages[0], pReq->enmAccount);
    21142121}
    21152122
     
    23592366                {
    23602367                    Log(("gmmR0AllocatePages: #%#x/%#x: not owner! hGVM=%#x hSelf=%#x\n", iPage, idPage,
    2361                          pPage->Private.hGVM, pGVM->hEMT));
     2368                         pPage->Private.hGVM, pGVM->hSelf));
    23622369                    rc = VERR_GMM_NOT_PAGE_OWNER;
    23632370                    break;
     
    24172424 *
    24182425 * @param   pVM                 Pointer to the shared VM structure.
     2426 * @param   idCpu               VCPU id
    24192427 * @param   cPages              The number of pages to allocate.
    24202428 * @param   paPages             Pointer to the page descriptors containing the Page IDs for each page.
     
    24222430 * @thread  EMT.
    24232431 */
    2424 GMMR0DECL(int) GMMR0FreePages(PVM pVM, uint32_t cPages, PGMMFREEPAGEDESC paPages, GMMACCOUNT enmAccount)
     2432GMMR0DECL(int) GMMR0FreePages(PVM pVM, unsigned idCpu, uint32_t cPages, PGMMFREEPAGEDESC paPages, GMMACCOUNT enmAccount)
    24252433{
    24262434    LogFlow(("GMMR0FreePages: pVM=%p cPages=%#x paPages=%p enmAccount=%d\n", pVM, cPages, paPages, enmAccount));
     
    24322440    GMM_GET_VALID_INSTANCE(pGMM, VERR_INTERNAL_ERROR);
    24332441    PGVM pGVM = GVMMR0ByVM(pVM);
    2434     if (!pGVM)
     2442    if (RT_UNLIKELY(!pGVM))
    24352443        return VERR_INVALID_PARAMETER;
    2436     if (pGVM->hEMT != RTThreadNativeSelf())
     2444    if (RT_UNLIKELY(pGVM->aCpus[idCpu].hEMT != RTThreadNativeSelf()))
    24372445        return VERR_NOT_OWNER;
    24382446
     
    24652473 * @returns see GMMR0FreePages.
    24662474 * @param   pVM             Pointer to the shared VM structure.
     2475 * @param   idCpu           VCPU id
    24672476 * @param   pReq            The request packet.
    24682477 */
    2469 GMMR0DECL(int) GMMR0FreePagesReq(PVM pVM, PGMMFREEPAGESREQ pReq)
     2478GMMR0DECL(int) GMMR0FreePagesReq(PVM pVM, unsigned idCpu, PGMMFREEPAGESREQ pReq)
    24702479{
    24712480    /*
     
    24812490                    VERR_INVALID_PARAMETER);
    24822491
    2483     return GMMR0FreePages(pVM, pReq->cPages, &pReq->aPages[0], pReq->enmAccount);
     2492    return GMMR0FreePages(pVM, idCpu, pReq->cPages, &pReq->aPages[0], pReq->enmAccount);
    24842493}
    24852494
     
    25002509 *
    25012510 * @param   pVM                 Pointer to the shared VM structure.
     2511 * @param   idCpu               VCPU id
    25022512 * @param   cBalloonedPages     The number of pages that was ballooned.
    25032513 * @param   cPagesToFree        The number of pages to be freed.
     
    25082518 * @thread  EMT.
    25092519 */
    2510 GMMR0DECL(int) GMMR0BalloonedPages(PVM pVM, uint32_t cBalloonedPages, uint32_t cPagesToFree, PGMMFREEPAGEDESC paPages, bool fCompleted)
     2520GMMR0DECL(int) GMMR0BalloonedPages(PVM pVM, unsigned idCpu, uint32_t cBalloonedPages, uint32_t cPagesToFree, PGMMFREEPAGEDESC paPages, bool fCompleted)
    25112521{
    25122522    LogFlow(("GMMR0BalloonedPages: pVM=%p cBalloonedPages=%#x cPagestoFree=%#x paPages=%p enmAccount=%d fCompleted=%RTbool\n",
     
    25192529    GMM_GET_VALID_INSTANCE(pGMM, VERR_INTERNAL_ERROR);
    25202530    PGVM pGVM = GVMMR0ByVM(pVM);
    2521     if (!pGVM)
     2531    if (RT_UNLIKELY(!pGVM))
    25222532        return VERR_INVALID_PARAMETER;
    2523     if (pGVM->hEMT != RTThreadNativeSelf())
     2533    if (RT_UNLIKELY(pGVM->aCpus[idCpu].hEMT != RTThreadNativeSelf()))
    25242534        return VERR_NOT_OWNER;
    25252535
     
    25912601 * @returns see GMMR0BalloonedPages.
    25922602 * @param   pVM             Pointer to the shared VM structure.
     2603 * @param   idCpu           VCPU id
    25932604 * @param   pReq            The request packet.
    25942605 */
    2595 GMMR0DECL(int) GMMR0BalloonedPagesReq(PVM pVM, PGMMBALLOONEDPAGESREQ pReq)
     2606GMMR0DECL(int) GMMR0BalloonedPagesReq(PVM pVM, unsigned idCpu, PGMMBALLOONEDPAGESREQ pReq)
    25962607{
    25972608    /*
     
    26072618                    VERR_INVALID_PARAMETER);
    26082619
    2609     return GMMR0BalloonedPages(pVM, pReq->cBalloonedPages, pReq->cPagesToFree, &pReq->aPages[0], pReq->fCompleted);
     2620    return GMMR0BalloonedPages(pVM, idCpu, pReq->cBalloonedPages, pReq->cPagesToFree, &pReq->aPages[0], pReq->fCompleted);
    26102621}
    26112622
     
    26182629 *
    26192630 * @param   pVM                 Pointer to the shared VM structure.
     2631 * @param   idCpu               VCPU id
    26202632 * @param   cPages              The number of pages that was let out of the balloon.
    26212633 * @thread  EMT.
    26222634 */
    2623 GMMR0DECL(int) GMMR0DeflatedBalloon(PVM pVM, uint32_t cPages)
     2635GMMR0DECL(int) GMMR0DeflatedBalloon(PVM pVM, unsigned idCpu, uint32_t cPages)
    26242636{
    26252637    LogFlow(("GMMR0DeflatedBalloon: pVM=%p cPages=%#x\n", pVM, cPages));
     
    26312643    GMM_GET_VALID_INSTANCE(pGMM, VERR_INTERNAL_ERROR);
    26322644    PGVM pGVM = GVMMR0ByVM(pVM);
    2633     if (!pGVM)
     2645    if (RT_UNLIKELY(!pGVM))
    26342646        return VERR_INVALID_PARAMETER;
    2635     if (pGVM->hEMT != RTThreadNativeSelf())
     2647    if (RT_UNLIKELY(pGVM->aCpus[idCpu].hEMT != RTThreadNativeSelf()))
    26362648        return VERR_NOT_OWNER;
    26372649
     
    28062818 * @returns VBox status code.
    28072819 * @param   pVM             The VM.
     2820 * @param   idCpu           VCPU id
    28082821 * @param   idChunkMap      The chunk to map. NIL_GMM_CHUNKID if nothing to map.
    28092822 * @param   idChunkUnmap    The chunk to unmap. NIL_GMM_CHUNKID if nothing to unmap.
     
    28112824 * @thread  EMT
    28122825 */
    2813 GMMR0DECL(int) GMMR0MapUnmapChunk(PVM pVM, uint32_t idChunkMap, uint32_t idChunkUnmap, PRTR3PTR ppvR3)
     2826GMMR0DECL(int) GMMR0MapUnmapChunk(PVM pVM, unsigned idCpu, uint32_t idChunkMap, uint32_t idChunkUnmap, PRTR3PTR ppvR3)
    28142827{
    28152828    LogFlow(("GMMR0MapUnmapChunk: pVM=%p idChunkMap=%#x idChunkUnmap=%#x ppvR3=%p\n",
     
    28222835    GMM_GET_VALID_INSTANCE(pGMM, VERR_INTERNAL_ERROR);
    28232836    PGVM pGVM = GVMMR0ByVM(pVM);
    2824     if (!pGVM)
     2837    if (RT_UNLIKELY(!pGVM))
    28252838        return VERR_INVALID_PARAMETER;
    2826     if (pGVM->hEMT != RTThreadNativeSelf())
     2839    if (RT_UNLIKELY(pGVM->aCpus[idCpu].hEMT != RTThreadNativeSelf()))
    28272840        return VERR_NOT_OWNER;
    28282841
     
    28932906 * @returns see GMMR0MapUnmapChunk.
    28942907 * @param   pVM             Pointer to the shared VM structure.
     2908 * @param   idCpu           VCPU id
    28952909 * @param   pReq            The request packet.
    28962910 */
    2897 GMMR0DECL(int)  GMMR0MapUnmapChunkReq(PVM pVM, PGMMMAPUNMAPCHUNKREQ pReq)
     2911GMMR0DECL(int)  GMMR0MapUnmapChunkReq(PVM pVM, unsigned idCpu, PGMMMAPUNMAPCHUNKREQ pReq)
    28982912{
    28992913    /*
     
    29042918    AssertMsgReturn(pReq->Hdr.cbReq == sizeof(*pReq), ("%#x != %#x\n", pReq->Hdr.cbReq, sizeof(*pReq)), VERR_INVALID_PARAMETER);
    29052919
    2906     return GMMR0MapUnmapChunk(pVM, pReq->idChunkMap, pReq->idChunkUnmap, &pReq->pvR3);
     2920    return GMMR0MapUnmapChunk(pVM, idCpu, pReq->idChunkMap, pReq->idChunkUnmap, &pReq->pvR3);
    29072921}
    29082922
     
    29162930 * @returns VBox status code.
    29172931 * @param   pVM             The VM.
     2932 * @param   idCpu           VCPU id
    29182933 * @param   pvR3            Pointer to the chunk size memory block to lock down.
    29192934 */
    2920 GMMR0DECL(int) GMMR0SeedChunk(PVM pVM, RTR3PTR pvR3)
     2935GMMR0DECL(int) GMMR0SeedChunk(PVM pVM, unsigned idCpu, RTR3PTR pvR3)
    29212936{
    29222937    /*
     
    29262941    GMM_GET_VALID_INSTANCE(pGMM, VERR_INTERNAL_ERROR);
    29272942    PGVM pGVM = GVMMR0ByVM(pVM);
    2928     if (!pGVM)
     2943    if (RT_UNLIKELY(!pGVM))
    29292944        return VERR_INVALID_PARAMETER;
    2930     if (pGVM->hEMT != RTThreadNativeSelf())
     2945    if (RT_UNLIKELY(pGVM->aCpus[idCpu].hEMT != RTThreadNativeSelf()))
    29312946        return VERR_NOT_OWNER;
    29322947
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