VirtualBox

Changeset 29217 in vbox


Ignore:
Timestamp:
May 7, 2010 2:38:51 PM (15 years ago)
Author:
vboxsync
Message:

Shared paging updates

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMAll/PGMAllBth.h

    r28800 r29217  
    14381438# ifdef VBOX_WITH_REAL_WRITE_MONITORED_PAGES
    14391439                         && PGM_PAGE_GET_STATE(pPage) != PGM_PAGE_STATE_WRITE_MONITORED
     1440# endif
     1441# ifdef VBOX_WITH_PAGE_SHARING
     1442                         && PGM_PAGE_GET_STATE(pPage) != PGM_PAGE_STATE_SHARED
    14401443# endif
    14411444                        )
     
    18341837                                 && PGM_PAGE_GET_STATE(pPage) != PGM_PAGE_STATE_WRITE_MONITORED
    18351838#  endif
     1839#  ifdef VBOX_WITH_PAGE_SHARING
     1840                                 && PGM_PAGE_GET_STATE(pPage) != PGM_PAGE_STATE_SHARED
     1841#  endif
    18361842                                 )
    18371843                             )
     
    28672873#  ifdef VBOX_WITH_REAL_WRITE_MONITORED_PAGES
    28682874                                     && PGM_PAGE_GET_STATE(pPage) != PGM_PAGE_STATE_WRITE_MONITORED
     2875#  endif
     2876#  ifdef VBOX_WITH_PAGE_SHARING
     2877                                     && PGM_PAGE_GET_STATE(pPage) != PGM_PAGE_STATE_SHARED
    28692878#  endif
    28702879                                     && !PGM_PAGE_IS_BALLOONED(pPage))
  • trunk/src/VBox/VMM/VMMAll/PGMAllPhys.cpp

    r28800 r29217  
    434434    pVM->pgm.s.aHandyPages[iHandyPage].HCPhysGCPhys = GCPhys & ~(RTGCPHYS)PAGE_OFFSET_MASK;
    435435
     436    const void *pvSharedPage = NULL;
     437   
    436438    if (PGM_PAGE_IS_SHARED(pPage))
    437439    {
     
    440442        VM_FF_SET(pVM, VM_FF_PGM_NEED_HANDY_PAGES);
    441443
    442         Log2(("PGM: Replaced shared page %#x at %RGp with %#x / %RHp\n", PGM_PAGE_GET_PAGEID(pPage),
    443               GCPhys, pVM->pgm.s.aHandyPages[iHandyPage].idPage, HCPhys));
     444        Log(("PGM: Replaced shared page %#x at %RGp with %#x / %RHp\n", PGM_PAGE_GET_PAGEID(pPage),
     445             GCPhys, pVM->pgm.s.aHandyPages[iHandyPage].idPage, HCPhys));
    444446        STAM_COUNTER_INC(&pVM->pgm.s.CTX_MID_Z(Stat,PageReplaceShared));
    445447        pVM->pgm.s.cSharedPages--;
    446         AssertMsgFailed(("TODO: copy shared page content")); /** @todo err.. what about copying the page content? */
     448   
     449        /* Grab the address of the page so we can make a copy later on. */
     450        rc = pgmPhysGCPhys2CCPtrInternalReadOnly(pVM, pPage, GCPhys, &pvSharedPage);
     451        AssertRC(rc);
    447452    }
    448453    else
     
    463468    PGM_PAGE_SET_PDE_TYPE(pPage, PGM_PAGE_PDE_TYPE_PT);
    464469    PGMPhysInvalidatePageMapTLBEntry(pVM, GCPhys);
     470
     471    /* Copy the shared page contents to the replacement page. */
     472    if (pvSharedPage)
     473    {
     474        void *pvNewPage;
     475
     476        /* Get the virtual address of the new page. */
     477        rc = pgmPhysGCPhys2CCPtrInternal(pVM, pPage, GCPhys, &pvNewPage);
     478        AssertRC(rc);
     479        if (rc == VINF_SUCCESS)
     480        {
     481            /** todo write ASMMemCopy */
     482            memcpy(pvNewPage, pvSharedPage, PAGE_SIZE);
     483        }
     484    }
    465485
    466486    if (    fFlushTLBs
  • trunk/src/VBox/VMM/VMMR0/GMMR0.cpp

    r29209 r29217  
    26202620}
    26212621
     2622/**
     2623 * Converts a private page to a shared page, the page is known to exist and be valid and such.
     2624 *
     2625 * @param   pGMM        Pointer to the GMM instance.
     2626 * @param   pGVM        Pointer to the GVM instance.
     2627 * @param   idPage      The Page ID
     2628 * @param   pPage       The page structure.
     2629 */
     2630DECLINLINE(void) gmmR0ConvertToSharedPage(PGMM pGMM, PGVM pGVM, uint32_t idPage, PGMMPAGE pPage)
     2631{
     2632    PGMMCHUNK pChunk = gmmR0GetChunk(pGMM, idPage >> GMM_CHUNKID_SHIFT);
     2633    Assert(pChunk);
     2634    Assert(pChunk->cFree < GMM_CHUNK_NUM_PAGES);
     2635    Assert(GMM_PAGE_IS_PRIVATE(pPage));
     2636
     2637    pChunk->cPrivate--;
     2638    pChunk->cShared++;
     2639
     2640    pGMM->cSharedPages++;
     2641
     2642    pGVM->gmm.s.cSharedPages++;
     2643    pGVM->gmm.s.cPrivatePages--;
     2644
     2645    /* Modify the page structure. */
     2646    pPage->Shared.pfn     = pPage->Private.pfn;     /* same location */
     2647    pPage->Shared.cRefs   = 1;
     2648    pPage->Common.u2State = GMM_PAGE_STATE_SHARED;
     2649}
     2650
     2651/**
     2652 * Increase the use count of a shared page, the page is known to exist and be valid and such.
     2653 *
     2654 * @param   pGMM        Pointer to the GMM instance.
     2655 * @param   pGVM        Pointer to the GVM instance.
     2656 * @param   pPage       The page structure.
     2657 */
     2658DECLINLINE(void) gmmR0UseSharedPage(PGMM pGMM, PGVM pGVM, PGMMPAGE pPage)
     2659{
     2660    Assert(pGMM->cSharedPages > 0);
     2661    Assert(pGMM->cAllocatedPages > 0);
     2662
     2663    pPage->Shared.cRefs++;
     2664    pGVM->gmm.s.cSharedPages++;
     2665}
    26222666
    26232667/**
     
    26402684    gmmR0FreePageWorker(pGMM, pChunk, idPage, pPage);
    26412685}
    2642 
    26432686
    26442687/**
     
    37393782
    37403783                    Assert(paPageDesc[i].HCPhys == (pPage->Private.pfn << 12));
    3741                     pPage->Shared.pfn     = pPage->Private.pfn;     /* same location */
    3742                     pPage->Shared.cRefs   = 1;
    3743                     pPage->Common.u2State = GMM_PAGE_STATE_SHARED;
     3784
     3785                    gmmR0ConvertToSharedPage(pGMM, pGVM, paPageDesc[i].uHCPhysPageId, pPage);
    37443786
    37453787                    /* Keep track of these references. */
     
    38153857                    AssertRC(rc);
    38163858
    3817                     /* Increase reference count. */
    3818                     pPage->Shared.cRefs++;
     3859                    gmmR0UseSharedPage(pGMM, pGVM, pPage);
    38193860
    38203861                    /* Pass along the new physical address & page id. */
  • trunk/src/VBox/VMM/VMMR0/PGMR0.cpp

    r29209 r29217  
    422422                        PGM_PAGE_SET_HCPHYS(pPage, paPageDesc[i].HCPhys);
    423423                        PGM_PAGE_SET_PAGEID(pPage, paPageDesc[i].uHCPhysPageId);
     424
     425                        /* Invalidate page map TLB entry for this page too. */
     426                        PGMPhysInvalidatePageMapTLBEntry(pVM, paPageDesc[i].GCPhys);
    424427                    }
    425428                    /* else nothing changed (== this page is now a shared page), so no need to flush anything. */
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