VirtualBox

Changeset 10141 in vbox for trunk/src/VBox/VMM/PATM


Ignore:
Timestamp:
Jul 3, 2008 8:58:33 AM (17 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
32666
Message:

PATM: some preparations for new SSM handling.

Location:
trunk/src/VBox/VMM/PATM
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/PATM/PATMInternal.h

    r9387 r10141  
    3737
    3838
    39 #define PATM_SSM_VERSION                    53
     39#ifdef PATM_WITH_NEW_SSM
     40# define PATM_SSM_VERSION                    54
     41/* Last version to use SSMR3Put/GetMem */
     42# define PATM_SSM_VERSION_GETPUTMEM          53
     43#else
     44# define PATM_SSM_VERSION                    53
     45#endif
    4046
    4147/* Enable for call patching. */
     
    406412
    407413    /** Global PATM lookup and call function (used by call patches). */
    408     RTRCPTR               pfnHelperCallGC;
     414    RTRCPTR                 pfnHelperCallGC;
    409415    /** Global PATM return function (used by ret patches). */
    410     RTRCPTR               pfnHelperRetGC;
     416    RTRCPTR                 pfnHelperRetGC;
    411417    /** Global PATM jump function (used by indirect jmp patches). */
    412     RTRCPTR               pfnHelperJumpGC;
     418    RTRCPTR                 pfnHelperJumpGC;
    413419    /** Global PATM return function (used by iret patches). */
    414     RTRCPTR               pfnHelperIretGC;
     420    RTRCPTR                 pfnHelperIretGC;
    415421
    416422    /** Fake patch record for global functions. */
     
    418424
    419425    /** Pointer to original sysenter handler */
    420     RTRCPTR               pfnSysEnterGC;
     426    RTRCPTR                 pfnSysEnterGC;
    421427    /** Pointer to sysenter handler trampoline */
    422     RTRCPTR               pfnSysEnterPatchGC;
     428    RTRCPTR                 pfnSysEnterPatchGC;
    423429    /** Sysenter patch index (for stats only) */
    424430    uint32_t                uSysEnterPatchIdx;
    425431
    426432    // GC address of fault in monitored page (set by PATMGCMonitorPage, used by PATMR3HandleMonitoredPage)
    427     RTRCPTR               pvFaultMonitor;
     433    RTRCPTR                 pvFaultMonitor;
    428434
    429435    /* Temporary information for pending MMIO patch. Set in GC or R0 context. */
     
    431437    {
    432438        RTGCPHYS            GCPhys;
    433         RTRCPTR           pCachedData;
    434         RTRCPTR           Alignment0; /**< Align the structure size on a 8-byte boundrary. */
     439        RTRCPTR             pCachedData;
     440        RTRCPTR             Alignment0; /**< Align the structure size on a 8-byte boundrary. */
    435441    } mmio;
    436442
  • trunk/src/VBox/VMM/PATM/PATMSSM.cpp

    r9228 r10141  
    282282    int  rc;
    283283
    284     if (u32Version != PATM_SSM_VERSION)
     284    if (    u32Version != PATM_SSM_VERSION
     285#ifdef PATM_WITH_NEW_SSM
     286        &&  u32Version != PATM_SSM_VERSION_GETPUTMEM)
     287#else
     288       )
     289#endif
    285290        return VERR_SSM_UNSUPPORTED_DATA_UNIT_VERSION;
    286291
     
    290295     * Restore PATM structure
    291296     */
    292     rc = SSMR3GetMem(pSSM, &patmInfo, sizeof(patmInfo));
    293     AssertRCReturn(rc, rc);
     297#ifdef PATM_WITH_NEW_SSM
     298    if (u32Version == PATM_SSM_VERSION_GETPUTMEM)
     299    {
     300#endif
     301        rc = SSMR3GetMem(pSSM, &patmInfo, sizeof(patmInfo));
     302        AssertRCReturn(rc, rc);
     303#ifdef PATM_WITH_NEW_SSM
     304    }
     305    else
     306    {
     307        memset(&patmInfo, 0, sizeof(patmInfo));
     308
     309        AssertCompile(sizeof(patmInfo.pGCStateGC) == sizeof(RTRCPTR));
     310        rc = SSMR3GetRCPtr(pSSM, &patmInfo.pGCStateGC);
     311        AssertRCReturn(rc, rc);
     312
     313        AssertCompile(sizeof(patmInfo.pCPUMCtxGC) == sizeof(RTRCPTR));
     314        rc = SSMR3GetRCPtr(pSSM, &patmInfo.pCPUMCtxGC);
     315        AssertRCReturn(rc, rc);
     316
     317        AssertCompile(sizeof(patmInfo.pStatsGC) == sizeof(RTRCPTR));
     318        rc = SSMR3GetRCPtr(pSSM, &patmInfo.pStatsGC);
     319        AssertRCReturn(rc, rc);
     320
     321        AssertCompile(sizeof(patmInfo.pfnHelperCallGC) == sizeof(RTRCPTR));
     322        rc = SSMR3GetRCPtr(pSSM, &patmInfo.pfnHelperCallGC);
     323        AssertRCReturn(rc, rc);
     324
     325        AssertCompile(sizeof(patmInfo.pfnHelperRetGC) == sizeof(RTRCPTR));
     326        rc = SSMR3GetRCPtr(pSSM, &patmInfo.pfnHelperRetGC);
     327        AssertRCReturn(rc, rc);
     328
     329        AssertCompile(sizeof(patmInfo.pfnHelperJumpGC) == sizeof(RTRCPTR));
     330        rc = SSMR3GetRCPtr(pSSM, &patmInfo.pfnHelperJumpGC);
     331        AssertRCReturn(rc, rc);
     332
     333        AssertCompile(sizeof(patmInfo.pfnHelperIretGC) == sizeof(RTRCPTR));
     334        rc = SSMR3GetRCPtr(pSSM, &patmInfo.pfnHelperIretGC);
     335        AssertRCReturn(rc, rc);
     336
     337        AssertCompile(sizeof(patmInfo.pPatchMemGC) == sizeof(RTRCPTR));
     338        rc = SSMR3GetRCPtr(pSSM, &patmInfo.pPatchMemGC);
     339        AssertRCReturn(rc, rc);
     340
     341        AssertCompile(sizeof(patmInfo.cbPatchMem) == sizeof(uint32_t));
     342        rc = SSMR3GetU32(pSSM, &patmInfo.cbPatchMem);
     343        AssertRCReturn(rc, rc);
     344
     345        AssertCompile(sizeof(patmInfo.offPatchMem) == sizeof(uint32_t));
     346        rc = SSMR3GetU32(pSSM, &patmInfo.offPatchMem);
     347        AssertRCReturn(rc, rc);
     348
     349        AssertCompile(sizeof(patmInfo.deltaReloc) == sizeof(int32_t));
     350        rc = SSMR3GetS32(pSSM, &patmInfo.deltaReloc);
     351        AssertRCReturn(rc, rc);
     352
     353        AssertCompile(sizeof(patmInfo.uCurrentPatchIdx) == sizeof(uint32_t));
     354        rc = SSMR3GetS32(pSSM, &patmInfo.uCurrentPatchIdx);
     355        AssertRCReturn(rc, rc);
     356               
     357        AssertCompile(sizeof(patmInfo.pPatchedInstrGCLowest) == sizeof(RTRCPTR));
     358        rc = SSMR3GetRCPtr(pSSM, &patmInfo.pPatchedInstrGCLowest);
     359        AssertRCReturn(rc, rc);
     360
     361        AssertCompile(sizeof(patmInfo.pPatchedInstrGCHighest) == sizeof(RTRCPTR));
     362        rc = SSMR3GetRCPtr(pSSM, &patmInfo.pPatchedInstrGCHighest);
     363        AssertRCReturn(rc, rc);
     364
     365        AssertCompile(sizeof(patmInfo.pfnSysEnterGC) == sizeof(RTRCPTR));
     366        rc = SSMR3GetRCPtr(pSSM, &patmInfo.pfnSysEnterGC);
     367        AssertRCReturn(rc, rc);
     368
     369        AssertCompile(sizeof(patmInfo.pfnSysEnterPatchGC) == sizeof(RTRCPTR));
     370        rc = SSMR3GetRCPtr(pSSM, &patmInfo.pfnSysEnterPatchGC);
     371        AssertRCReturn(rc, rc);
     372
     373        AssertCompile(sizeof(patmInfo.uSysEnterPatchIdx) == sizeof(uint32_t));
     374        rc = SSMR3GetU32(pSSM, &patmInfo.uSysEnterPatchIdx);
     375        AssertRCReturn(rc, rc);
     376
     377        AssertCompile(sizeof(patmInfo.ulCallDepth) == sizeof(uint32_t));
     378        rc = SSMR3GetU32(pSSM, &patmInfo.ulCallDepth);
     379        AssertRCReturn(rc, rc);
     380
     381        AssertCompile(sizeof(patmInfo.pGCStackGC) == sizeof(RTRCPTR));
     382        rc = SSMR3GetRCPtr(pSSM, &patmInfo.pGCStackGC);
     383        AssertRCReturn(rc, rc);
     384
     385        AssertCompile(sizeof(patmInfo.cPageRecords) == sizeof(uint32_t));
     386        rc = SSMR3GetU32(pSSM, &patmInfo.cPageRecords);
     387        AssertRCReturn(rc, rc);
     388
     389        AssertCompile(sizeof(patmInfo.fOutOfMemory) == sizeof(bool));
     390        rc = SSMR3GetBool(pSSM, &patmInfo.fOutOfMemory);
     391        AssertRCReturn(rc, rc);
     392
     393        AssertCompile(sizeof(patmInfo.savedstate.cPatches) == sizeof(uint32_t));
     394        rc = SSMR3GetU32(pSSM, &patmInfo.savedstate.cPatches);
     395        AssertRCReturn(rc, rc);
     396       
     397    }
     398#endif
    294399
    295400    /** @todo this restriction could be removed as we relocate when loading the saved state,.. */
     
    323428    pVM->patm.s.deltaReloc          = patmInfo.deltaReloc;
    324429    pVM->patm.s.uCurrentPatchIdx    = patmInfo.uCurrentPatchIdx;
     430    pVM->patm.s.fOutOfMemory        = patmInfo.fOutOfMemory;
    325431
    326432    /* Lowest and highest patched instruction */
     
    346452     * Restore GC state memory
    347453     */
    348     if (pVM->patm.s.pGCStateGC != patmInfo.pGCStateGC)
    349     {
    350         AssertMsgFailed(("GC patch state ptrs don't match!!!\n"));
    351         return VERR_SSM_INVALID_STATE;
    352     }
    353     rc = SSMR3GetMem(pSSM, pVM->patm.s.pGCStateHC, sizeof(PATMGCSTATE));
    354     AssertRCReturn(rc, rc);
     454#ifdef PATM_WITH_NEW_SSM
     455    if (u32Version == PATM_SSM_VERSION_GETPUTMEM)
     456    {
     457#endif
     458        rc = SSMR3GetMem(pSSM, pVM->patm.s.pGCStateHC, sizeof(PATMGCSTATE));
     459        AssertRCReturn(rc, rc);
     460#ifdef PATM_WITH_NEW_SSM
     461    }
     462    else
     463    {
     464        AssertCompile(sizeof(pVM->patm.s.pGCStateHC->uVMFlags) == sizeof(uint32_t));
     465        rc = SSMR3GetU32(pSSM, &pVM->patm.s.pGCStateHC->uVMFlags);
     466        AssertRCReturn(rc, rc);
     467
     468        AssertCompile(sizeof(pVM->patm.s.pGCStateHC->uPendingAction) == sizeof(uint32_t));
     469        rc = SSMR3GetU32(pSSM, &pVM->patm.s.pGCStateHC->uPendingAction);
     470        AssertRCReturn(rc, rc);
     471
     472        AssertCompile(sizeof(pVM->patm.s.pGCStateHC->uPatchCalls) == sizeof(uint32_t));
     473        rc = SSMR3GetU32(pSSM, &pVM->patm.s.pGCStateHC->uPatchCalls);
     474        AssertRCReturn(rc, rc);
     475
     476        AssertCompile(sizeof(pVM->patm.s.pGCStateHC->uScratch) == sizeof(uint32_t));
     477        rc = SSMR3GetU32(pSSM, &pVM->patm.s.pGCStateHC->uScratch);
     478        AssertRCReturn(rc, rc);
     479
     480        AssertCompile(sizeof(pVM->patm.s.pGCStateHC->uIretEFlags) == sizeof(uint32_t));
     481        rc = SSMR3GetU32(pSSM, &pVM->patm.s.pGCStateHC->uIretEFlags);
     482        AssertRCReturn(rc, rc);
     483
     484        AssertCompile(sizeof(pVM->patm.s.pGCStateHC->uIretCS) == sizeof(uint32_t));
     485        rc = SSMR3GetU32(pSSM, &pVM->patm.s.pGCStateHC->uIretCS);
     486        AssertRCReturn(rc, rc);
     487
     488        AssertCompile(sizeof(pVM->patm.s.pGCStateHC->uIretEIP) == sizeof(uint32_t));
     489        rc = SSMR3GetU32(pSSM, &pVM->patm.s.pGCStateHC->uIretEIP);
     490        AssertRCReturn(rc, rc);
     491
     492        AssertCompile(sizeof(pVM->patm.s.pGCStateHC->Psp) == sizeof(uint32_t));
     493        rc = SSMR3GetU32(pSSM, &pVM->patm.s.pGCStateHC->Psp);
     494        AssertRCReturn(rc, rc);
     495
     496        AssertCompile(sizeof(pVM->patm.s.pGCStateHC->fPIF) == sizeof(uint32_t));
     497        rc = SSMR3GetU32(pSSM, &pVM->patm.s.pGCStateHC->fPIF);
     498        AssertRCReturn(rc, rc);
     499
     500        AssertCompile(sizeof(pVM->patm.s.pGCStateHC->GCPtrInhibitInterrupts) == sizeof(RTRCPTR));
     501        rc = SSMR3GetRCPtr(pSSM, &pVM->patm.s.pGCStateHC->GCPtrInhibitInterrupts);
     502        AssertRCReturn(rc, rc);
     503
     504        AssertCompile(sizeof(pVM->patm.s.pGCStateHC->GCCallPatchTargetAddr) == sizeof(RTRCPTR));
     505        rc = SSMR3GetRCPtr(pSSM, &pVM->patm.s.pGCStateHC->GCCallPatchTargetAddr);
     506        AssertRCReturn(rc, rc);
     507
     508        AssertCompile(sizeof(pVM->patm.s.pGCStateHC->GCCallReturnAddr) == sizeof(RTRCPTR));
     509        rc = SSMR3GetRCPtr(pSSM, &pVM->patm.s.pGCStateHC->GCCallReturnAddr);
     510        AssertRCReturn(rc, rc);
     511
     512        AssertCompile(sizeof(pVM->patm.s.pGCStateHC->Restore.uEAX) == sizeof(uint32_t));
     513        rc = SSMR3GetU32(pSSM, &pVM->patm.s.pGCStateHC->Restore.uEAX);
     514        AssertRCReturn(rc, rc);
     515
     516        AssertCompile(sizeof(pVM->patm.s.pGCStateHC->Restore.uECX) == sizeof(uint32_t));
     517        rc = SSMR3GetU32(pSSM, &pVM->patm.s.pGCStateHC->Restore.uECX);
     518        AssertRCReturn(rc, rc);
     519
     520        AssertCompile(sizeof(pVM->patm.s.pGCStateHC->Restore.uEDI) == sizeof(uint32_t));
     521        rc = SSMR3GetU32(pSSM, &pVM->patm.s.pGCStateHC->Restore.uEDI);
     522        AssertRCReturn(rc, rc);
     523
     524        AssertCompile(sizeof(pVM->patm.s.pGCStateHC->Restore.eFlags) == sizeof(uint32_t));
     525        rc = SSMR3GetU32(pSSM, &pVM->patm.s.pGCStateHC->Restore.eFlags);
     526        AssertRCReturn(rc, rc);
     527
     528        AssertCompile(sizeof(pVM->patm.s.pGCStateHC->Restore.uFlags) == sizeof(uint32_t));
     529        rc = SSMR3GetU32(pSSM, &pVM->patm.s.pGCStateHC->Restore.uFlags);
     530        AssertRCReturn(rc, rc);
     531    }
     532#endif
    355533
    356534    /*
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette