VirtualBox

Changeset 43047 in vbox for trunk/src/VBox/VMM/VMMR0


Ignore:
Timestamp:
Aug 28, 2012 2:47:29 PM (12 years ago)
Author:
vboxsync
Message:

VMM: Must flush changes pending in the handy page array before freeing memory. There may be requests to free shared pages in there, esp. in a guest shutdown scenario.

Location:
trunk/src/VBox/VMM/VMMR0
Files:
3 edited

Legend:

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

    r43045 r43047  
    27812781            } /* for each page to update */
    27822782
    2783             if (RT_SUCCESS(rc))
     2783            if (RT_SUCCESS(rc) && cPagesToAlloc > 0)
    27842784            {
    27852785#if defined(VBOX_STRICT) && 0 /** @todo re-test this later. Appeared to be a PGM init bug. */
  • trunk/src/VBox/VMM/VMMR0/PGMR0.cpp

    r42404 r43047  
    6666 *          must clear the new pages.
    6767 */
    68 VMMR0DECL(int) PGMR0PhysAllocateHandyPages(PVM pVM, PVMCPU pVCpu)
     68VMMR0_INT_DECL(int) PGMR0PhysAllocateHandyPages(PVM pVM, PVMCPU pVCpu)
    6969{
    7070    PGM_LOCK_ASSERT_OWNER_EX(pVM, pVCpu);
     
    169169
    170170/**
     171 * Flushes any changes pending in the handy page array.
     172 *
     173 * It is very important that this gets done when page sharing is enabled.
     174 *
     175 * @returns The following VBox status codes.
     176 * @retval  VINF_SUCCESS on success. FF cleared.
     177 *
     178 * @param   pVM         Pointer to the VM.
     179 * @param   pVCpu       Pointer to the VMCPU.
     180 *
     181 * @remarks Must be called from within the PGM critical section.
     182 */
     183VMMR0_INT_DECL(int) PGMR0PhysFlushHandyPages(PVM pVM, PVMCPU pVCpu)
     184{
     185    PGM_LOCK_ASSERT_OWNER_EX(pVM, pVCpu);
     186
     187    /*
     188     * Try allocate a full set of handy pages.
     189     */
     190    uint32_t iFirst = pVM->pgm.s.cHandyPages;
     191    AssertReturn(iFirst <= RT_ELEMENTS(pVM->pgm.s.aHandyPages), VERR_PGM_HANDY_PAGE_IPE);
     192    uint32_t cPages = RT_ELEMENTS(pVM->pgm.s.aHandyPages) - iFirst;
     193    if (!cPages)
     194        return VINF_SUCCESS;
     195    int rc = GMMR0AllocateHandyPages(pVM, pVCpu->idCpu, cPages, 0, &pVM->pgm.s.aHandyPages[iFirst]);
     196
     197    LogFlow(("PGMR0PhysFlushHandyPages: cPages=%d rc=%Rrc\n", cPages, rc));
     198    return rc;
     199}
     200
     201
     202/**
    171203 * Worker function for PGMR3PhysAllocateLargeHandyPage
    172204 *
     
    181213 *          must clear the new pages.
    182214 */
    183 VMMR0DECL(int) PGMR0PhysAllocateLargeHandyPage(PVM pVM, PVMCPU pVCpu)
     215VMMR0_INT_DECL(int) PGMR0PhysAllocateLargeHandyPage(PVM pVM, PVMCPU pVCpu)
    184216{
    185217    PGM_LOCK_ASSERT_OWNER_EX(pVM, pVCpu);
  • trunk/src/VBox/VMM/VMMR0/VMMR0.cpp

    r41976 r43047  
    363363
    364364/**
    365  * Terminates the R0 driver for a particular VM instance.
     365 * Terminates the R0 bits for a particular VM instance.
    366366 *
    367367 * This is normally called by ring-3 as part of the VM termination process, but
     
    381381#endif
    382382
     383
    383384    /*
    384385     * Tell GVMM what we're up to and check that we only do this once.
     
    386387    if (GVMMR0DoingTermVM(pVM, pGVM))
    387388    {
     389        /** @todo I wish to call PGMR0PhysFlushHandyPages(pVM, &pVM->aCpus[idCpu])
     390         *        here to make sure we don't leak any shared pages if we crash... */
    388391#ifdef VBOX_WITH_2X_4GB_ADDR_SPACE
    389392        PGMR0DynMapTermVM(pVM);
     
    10001003            return PGMR0PhysAllocateHandyPages(pVM, &pVM->aCpus[idCpu]);
    10011004
     1005        case VMMR0_DO_PGM_FLUSH_HANDY_PAGES:
     1006            if (idCpu == NIL_VMCPUID)
     1007                return VERR_INVALID_CPU_ID;
     1008            return PGMR0PhysFlushHandyPages(pVM, &pVM->aCpus[idCpu]);
     1009
    10021010        case VMMR0_DO_PGM_ALLOCATE_LARGE_HANDY_PAGE:
    10031011            if (idCpu == NIL_VMCPUID)
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