VirtualBox

Changeset 26606 in vbox for trunk/src/VBox/VMM


Ignore:
Timestamp:
Feb 17, 2010 12:40:42 PM (15 years ago)
Author:
vboxsync
Message:

Large page work

Location:
trunk/src/VBox/VMM
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/GMM.cpp

    r26577 r26606  
    315315
    316316/**
    317  * @see GMMR0AllocateLargePage
    318  */
    319 GMMR3DECL(int)  GMMR3AllocateLargePage(PVM pVM,  uint32_t cbPage, uint32_t *pidPage, RTHCPHYS *pHCPhys)
    320 {
    321     GMMALLOCLARGEPAGEREQ Req;
    322     Req.Hdr.u32Magic = SUPVMMR0REQHDR_MAGIC;
    323     Req.Hdr.cbReq = sizeof(Req);
    324     Req.cbPage = cbPage;
    325     Req.idPage = NIL_GMM_PAGEID;
    326     int rc = VMMR3CallR0(pVM, VMMR0_DO_GMM_ALLOC_LARGE_PAGE, 0, &Req.Hdr);
    327     if (RT_SUCCESS(rc) && pidPage)
    328         *pidPage = Req.idPage;
    329    
    330     if (RT_SUCCESS(rc) && pHCPhys)
    331         *pHCPhys = Req.HCPhys;
    332     return rc;
    333 }
    334 
    335 /**
    336317 * @see GMMR0FreeLargePage
    337318 */
  • trunk/src/VBox/VMM/PGMInternal.h

    r26577 r26606  
    612612     *  - [8-9]: u2HandlerVirtStateY - the virtual handler state
    613613     *    (PGM_PAGE_HNDL_VIRT_STATE_*).
     614     *  - [14]:  u1LargePage - flag indicating that it's part of a large (2 MB) page
    614615     *  - [15]:  fWrittenToY - flag indicating that a write monitored page was
    615616     *    written to when set.
    616      *  - [10-14]: 5 unused bits.
     617     *  - [10-13]: 4 unused bits.
    617618     * @remarks Warning! All accesses to the bits are hardcoded.
    618619     *
     
    813814
    814815/**
    815  * Marks the paget as written to (for GMM change monitoring).
     816 * Marks the page as written to (for GMM change monitoring).
    816817 * @param   pPage       Pointer to the physical guest page tracking structure.
    817818 */
     
    831832#define PGM_PAGE_IS_WRITTEN_TO(pPage)       ( !!((pPage)->u16MiscY.au8[1] & UINT8_C(0x80)) )
    832833
     834/**
     835 * Marks the page as part of a large continuous page
     836 * @param   pPage       Pointer to the physical guest page tracking structure.
     837 */
     838#define PGM_PAGE_SET_LARGE_PAGE(pPage)      do { (pPage)->u16MiscY.au8[1] |= UINT8_C(0x40); } while (0)
     839
     840/**
     841 * Clears the page as part of a large continuous page indicator.
     842 * @param   pPage       Pointer to the physical guest page tracking structure.
     843 */
     844#define PGM_PAGE_CLEAR_LARGE_PAGE(pPage)    do { (pPage)->u16MiscY.au8[1] &= UINT8_C(0xbf); } while (0)
     845
     846/**
     847 * Checks if the page was marked being part of a large page
     848 * @returns true/false.
     849 * @param   pPage       Pointer to the physical guest page tracking structure.
     850 */
     851#define PGM_PAGE_IS_LARGE_PAGE(pPage)       ( !!((pPage)->u16MiscY.au8[1] & UINT8_C(0x40)) )
    833852
    834853/** Enabled optimized access handler tests.
  • trunk/src/VBox/VMM/PGMPhys.cpp

    r26577 r26606  
    31743174 * @param   pVM         The VM handle.
    31753175 */
    3176 VMMR3DECL(int) PGMR3PhysAllocateLargePage(PVM pVM)
    3177 {
    3178     int      rc = VINF_SUCCESS;
    3179     uint32_t idPage;
    3180     RTHCPHYS HCPhys;
    3181     void    *pvDummy;
    3182 
     3176VMMR3DECL(int) PGMR3PhysAllocateLargeHandyPage(PVM pVM)
     3177{
    31833178    pgmLock(pVM);
    31843179
    3185     rc = GMMR3AllocateLargePage(pVM, _2M, &idPage, &HCPhys);
     3180    int rc = VMMR3CallR0(pVM, VMMR0_DO_PGM_ALLOCATE_LARGE_HANDY_PAGE, 0, NULL);
    31863181    if (RT_SUCCESS(rc))
    31873182    {
    3188         /* Map the large page into our address space. */
    3189         rc = pgmPhysPageMapByPageID(pVM, idPage, HCPhys, &pvDummy);
     3183        Assert(pVM->pgm.s.cLargeHandyPages == 1);
     3184
     3185        uint32_t idPage = pVM->pgm.s.aLargeHandyPage[0].idPage;
     3186        RTHCPHYS HCPhys = pVM->pgm.s.aLargeHandyPage[0].HCPhysGCPhys;
     3187
     3188        /*
     3189         * Clear the pages.
     3190         */
     3191        for (unsigned i = 0; i < _2M/PAGE_SIZE; i++)
     3192        {
     3193            void *pv;
     3194
     3195            /* Map the large page into our address space. Could only fail the first time */
     3196            rc = pgmPhysPageMapByPageID(pVM, idPage, HCPhys, &pv);
     3197            AssertLogRelMsgBreak(RT_SUCCESS(rc), ("idPage=%#x HCPhysGCPhys=%RHp rc=%Rrc", idPage, HCPhys, rc));
     3198            ASMMemZeroPage(pv);
     3199            idPage++;
     3200            HCPhys += PAGE_SIZE;
     3201            Log3(("PGMR3PhysAllocateLargePage: idPage=%#x HCPhys=%RGp\n", idPage, HCPhys));
     3202        }
     3203        pVM->pgm.s.cLargeHandyPages = 0;
    31903204    }
    31913205
  • trunk/src/VBox/VMM/VMM.cpp

    r26577 r26606  
    20732073         * Allocates a large page.
    20742074         */
    2075         case VMMCALLRING3_PGM_ALLOCATE_LARGE_PAGE:
    2076         {
    2077             pVCpu->vmm.s.rcCallRing3 = PGMR3PhysAllocateLargePage(pVM);
     2075        case VMMCALLRING3_PGM_ALLOCATE_LARGE_HANDY_PAGE:
     2076        {
     2077            pVCpu->vmm.s.rcCallRing3 = PGMR3PhysAllocateLargeHandyPage(pVM);
    20782078            break;
    20792079        }
  • trunk/src/VBox/VMM/VMMR0/GMMR0.cpp

    r26577 r26606  
    22902290 * @param   idCpu           VCPU id
    22912291 * @param   cbPage          Large page size
    2292  * @param   pidPage         Id of the page (out)
    2293  * @param   HCPhys          Host physical address of the page (out)
    2294  */
    2295 GMMR0DECL(int)  GMMR0AllocateLargePage(PVM pVM, VMCPUID idCpu, uint32_t cbPage, uint32_t *pidPage, RTHCPHYS *pHCPhys)
     2292 */
     2293GMMR0DECL(int)  GMMR0AllocateLargePage(PVM pVM, VMCPUID idCpu, uint32_t cbPage, uint32_t *pIdPage, RTHCPHYS *pHCPhys)
    22962294{
    22972295    LogFlow(("GMMR0AllocateLargePage: pVM=%p cbPage=%x\n", pVM, cbPage));
    22982296
    22992297    AssertReturn(cbPage == GMM_CHUNK_SIZE, VERR_INVALID_PARAMETER);
    2300     AssertPtrReturn(pidPage, VERR_INVALID_PARAMETER);
     2298    AssertPtrReturn(pIdPage, VERR_INVALID_PARAMETER);
    23012299    AssertPtrReturn(pHCPhys, VERR_INVALID_PARAMETER);
    23022300
     
    23152313        return VERR_NOT_SUPPORTED;
    23162314
    2317     *pidPage = NIL_GMM_PAGEID;
    23182315    *pHCPhys = NIL_RTHCPHYS;
     2316    *pIdPage = NIL_GMM_PAGEID;
    23192317
    23202318    rc = RTSemFastMutexRequest(pGMM->Mtx);
     
    23482346        gmmR0AllocatePage(pGMM, pGVM->hSelf, pChunk, &PageDesc);
    23492347        /* Return the first page as we'll use the whole chunk as one big page. */
    2350         *pidPage = PageDesc.idPage;
     2348        *pIdPage = PageDesc.idPage;
    23512349        *pHCPhys = PageDesc.HCPhysGCPhys;
    23522350
     
    23672365    LogFlow(("GMMR0AllocatePages: returns %Rrc\n", rc));
    23682366    return rc;
    2369 }
    2370 
    2371 
    2372 /**
    2373  * VMMR0 request wrapper for GMMR0AllocateLargePage.
    2374  *
    2375  * @returns see GMMR0AllocateLargePage.
    2376  * @param   pVM             Pointer to the shared VM structure.
    2377  * @param   idCpu           VCPU id
    2378  * @param   pReq            The request packet.
    2379  */
    2380 GMMR0DECL(int) GMMR0AllocateLargePageReq(PVM pVM, VMCPUID idCpu, PGMMALLOCLARGEPAGEREQ pReq)
    2381 {
    2382     /*
    2383      * Validate input and pass it on.
    2384      */
    2385     AssertPtrReturn(pVM, VERR_INVALID_POINTER);
    2386     AssertPtrReturn(pReq, VERR_INVALID_POINTER);
    2387     AssertMsgReturn(pReq->Hdr.cbReq == sizeof(GMMALLOCATEPAGESREQ),
    2388                     ("%#x != %#x\n", pReq->Hdr.cbReq, sizeof(GMMALLOCATEPAGESREQ)),
    2389                     VERR_INVALID_PARAMETER);
    2390 
    2391     return GMMR0AllocateLargePage(pVM, idCpu, pReq->cbPage, &pReq->idPage, &pReq->HCPhys);
    23922367}
    23932368
  • trunk/src/VBox/VMM/VMMR0/PGMR0.cpp

    r26233 r26606  
    164164}
    165165
     166/**
     167 * Worker function for PGMR3PhysAllocateLargeHandyPage
     168 *
     169 * @returns The following VBox status codes.
     170 * @retval  VINF_SUCCESS on success.
     171 * @retval  VINF_EM_NO_MEMORY if we're out of memory.
     172 *
     173 * @param   pVM         The VM handle.
     174 * @param   pVCpu       The VMCPU handle.
     175 *
     176 * @remarks Must be called from within the PGM critical section. The caller
     177 *          must clear the new pages.
     178 */
     179VMMR0DECL(int) PGMR0PhysAllocateLargeHandyPage(PVM pVM, PVMCPU pVCpu)
     180{
     181    Assert(PDMCritSectIsOwnerEx(&pVM->pgm.s.CritSect, pVCpu->idCpu));
     182
     183    Assert(!pVM->pgm.s.cLargeHandyPages);
     184    int rc = GMMR0AllocateLargePage(pVM, pVCpu->idCpu, _2M, &pVM->pgm.s.aLargeHandyPage[0].idPage, &pVM->pgm.s.aLargeHandyPage[0].HCPhysGCPhys);
     185    if (RT_SUCCESS(rc))
     186        pVM->pgm.s.cLargeHandyPages = 1;
     187
     188    return rc;
     189}
    166190
    167191/**
  • trunk/src/VBox/VMM/VMMR0/VMMR0.cpp

    r26563 r26606  
    877877            return PGMR0PhysAllocateHandyPages(pVM, &pVM->aCpus[idCpu]);
    878878
     879        case VMMR0_DO_PGM_ALLOCATE_LARGE_HANDY_PAGE:
     880            if (idCpu == NIL_VMCPUID)
     881                return VERR_INVALID_CPU_ID;
     882            return PGMR0PhysAllocateLargeHandyPage(pVM, &pVM->aCpus[idCpu]);
     883
    879884        /*
    880885         * GMM wrappers.
     
    894899                return VERR_INVALID_PARAMETER;
    895900            return GMMR0AllocatePagesReq(pVM, idCpu, (PGMMALLOCATEPAGESREQ)pReqHdr);
    896 
    897         case VMMR0_DO_GMM_ALLOC_LARGE_PAGE:
    898             if (u64Arg)
    899                 return VERR_INVALID_PARAMETER;
    900             return GMMR0AllocateLargePageReq(pVM, idCpu, (PGMMALLOCLARGEPAGEREQ)pReqHdr);
    901901
    902902        case VMMR0_DO_GMM_FREE_PAGES:
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