Changeset 49464 in vbox for trunk/src/VBox/VMM/VMMR3
- Timestamp:
- Nov 13, 2013 1:02:43 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMR3/PATMSSM.cpp
r49247 r49464 249 249 250 250 /** 251 * SSM descriptor table for the PATM structure starting with r86139. 252 */ 253 static SSMFIELD const g_aPatmFields86139[] = 254 { 255 /** @todo there are a bunch more fields here which can be marked as ignored. */ 256 SSMFIELD_ENTRY_IGNORE( PATM, offVM), 257 SSMFIELD_ENTRY_RCPTR( PATM, pPatchMemGC), 258 SSMFIELD_ENTRY_IGN_HCPTR( PATM, pPatchMemHC), 259 SSMFIELD_ENTRY( PATM, cbPatchMem), 260 SSMFIELD_ENTRY( PATM, offPatchMem), 261 SSMFIELD_ENTRY( PATM, fOutOfMemory), 262 SSMFIELD_ENTRY_PAD_HC_AUTO( 3, 3), 263 SSMFIELD_ENTRY( PATM, deltaReloc), 264 SSMFIELD_ENTRY_IGN_HCPTR( PATM, pGCStateHC), 265 SSMFIELD_ENTRY_RCPTR( PATM, pGCStateGC), 266 SSMFIELD_ENTRY_RCPTR( PATM, pGCStackGC), 267 SSMFIELD_ENTRY_IGN_HCPTR( PATM, pGCStackHC), 268 SSMFIELD_ENTRY_RCPTR( PATM, pCPUMCtxGC), 269 SSMFIELD_ENTRY_RCPTR( PATM, pStatsGC), 270 SSMFIELD_ENTRY_IGN_HCPTR( PATM, pStatsHC), 271 SSMFIELD_ENTRY( PATM, uCurrentPatchIdx), 272 SSMFIELD_ENTRY( PATM, ulCallDepth), 273 SSMFIELD_ENTRY( PATM, cPageRecords), 274 SSMFIELD_ENTRY_RCPTR( PATM, pPatchedInstrGCLowest), 275 SSMFIELD_ENTRY_RCPTR( PATM, pPatchedInstrGCHighest), 276 SSMFIELD_ENTRY_RCPTR( PATM, PatchLookupTreeGC), 277 SSMFIELD_ENTRY_IGN_HCPTR( PATM, PatchLookupTreeHC), 278 SSMFIELD_ENTRY_RCPTR( PATM, pfnHelperCallGC), 279 SSMFIELD_ENTRY_RCPTR( PATM, pfnHelperRetGC), 280 SSMFIELD_ENTRY_RCPTR( PATM, pfnHelperJumpGC), 281 SSMFIELD_ENTRY_RCPTR( PATM, pfnHelperIretGC), 282 SSMFIELD_ENTRY_IGN_HCPTR( PATM, pGlobalPatchRec), 283 SSMFIELD_ENTRY_RCPTR( PATM, pfnSysEnterGC), 284 SSMFIELD_ENTRY_RCPTR( PATM, pfnSysEnterPatchGC), 285 SSMFIELD_ENTRY( PATM, uSysEnterPatchIdx), 286 SSMFIELD_ENTRY_RCPTR( PATM, pvFaultMonitor), 287 SSMFIELD_ENTRY_GCPHYS( PATM, mmio.GCPhys), 288 SSMFIELD_ENTRY_RCPTR( PATM, mmio.pCachedData), 289 SSMFIELD_ENTRY_IGN_RCPTR( PATM, mmio.Alignment0), 290 SSMFIELD_ENTRY_IGN_HCPTR( PATM, savedstate.pSSM), 291 SSMFIELD_ENTRY( PATM, savedstate.cPatches), 292 SSMFIELD_ENTRY_PAD_HC64( PATM, savedstate.Alignment0, sizeof(uint32_t)), 293 SSMFIELD_ENTRY_IGN_HCPTR( PATM, hDbgModPatchMem), 294 SSMFIELD_ENTRY_PAD_HC32( PATM, Alignment0, sizeof(uint32_t)), 295 SSMFIELD_ENTRY_IGNORE( PATM, StatNrOpcodeRead), 296 SSMFIELD_ENTRY_IGNORE( PATM, StatDisabled), 297 SSMFIELD_ENTRY_IGNORE( PATM, StatUnusable), 298 SSMFIELD_ENTRY_IGNORE( PATM, StatEnabled), 299 SSMFIELD_ENTRY_IGNORE( PATM, StatInstalled), 300 SSMFIELD_ENTRY_IGNORE( PATM, StatInstalledFunctionPatches), 301 SSMFIELD_ENTRY_IGNORE( PATM, StatInstalledTrampoline), 302 SSMFIELD_ENTRY_IGNORE( PATM, StatInstalledJump), 303 SSMFIELD_ENTRY_IGNORE( PATM, StatInt3Callable), 304 SSMFIELD_ENTRY_IGNORE( PATM, StatInt3BlockRun), 305 SSMFIELD_ENTRY_IGNORE( PATM, StatOverwritten), 306 SSMFIELD_ENTRY_IGNORE( PATM, StatFixedConflicts), 307 SSMFIELD_ENTRY_IGNORE( PATM, StatFlushed), 308 SSMFIELD_ENTRY_IGNORE( PATM, StatPageBoundaryCrossed), 309 SSMFIELD_ENTRY_IGNORE( PATM, StatMonitored), 310 SSMFIELD_ENTRY_IGNORE( PATM, StatHandleTrap), 311 SSMFIELD_ENTRY_IGNORE( PATM, StatSwitchBack), 312 SSMFIELD_ENTRY_IGNORE( PATM, StatSwitchBackFail), 313 SSMFIELD_ENTRY_IGNORE( PATM, StatPATMMemoryUsed), 314 SSMFIELD_ENTRY_IGNORE( PATM, StatDuplicateREQSuccess), 315 SSMFIELD_ENTRY_IGNORE( PATM, StatDuplicateREQFailed), 316 SSMFIELD_ENTRY_IGNORE( PATM, StatDuplicateUseExisting), 317 SSMFIELD_ENTRY_IGNORE( PATM, StatFunctionFound), 318 SSMFIELD_ENTRY_IGNORE( PATM, StatFunctionNotFound), 319 SSMFIELD_ENTRY_IGNORE( PATM, StatPatchWrite), 320 SSMFIELD_ENTRY_IGNORE( PATM, StatPatchWriteDetect), 321 SSMFIELD_ENTRY_IGNORE( PATM, StatDirty), 322 SSMFIELD_ENTRY_IGNORE( PATM, StatPushTrap), 323 SSMFIELD_ENTRY_IGNORE( PATM, StatPatchWriteInterpreted), 324 SSMFIELD_ENTRY_IGNORE( PATM, StatPatchWriteInterpretedFailed), 325 SSMFIELD_ENTRY_IGNORE( PATM, StatSysEnter), 326 SSMFIELD_ENTRY_IGNORE( PATM, StatSysExit), 327 SSMFIELD_ENTRY_IGNORE( PATM, StatEmulIret), 328 SSMFIELD_ENTRY_IGNORE( PATM, StatEmulIretFailed), 329 SSMFIELD_ENTRY_IGNORE( PATM, StatInstrDirty), 330 SSMFIELD_ENTRY_IGNORE( PATM, StatInstrDirtyGood), 331 SSMFIELD_ENTRY_IGNORE( PATM, StatInstrDirtyBad), 332 SSMFIELD_ENTRY_IGNORE( PATM, StatPatchPageInserted), 333 SSMFIELD_ENTRY_IGNORE( PATM, StatPatchPageRemoved), 334 SSMFIELD_ENTRY_IGNORE( PATM, StatPatchRefreshSuccess), 335 SSMFIELD_ENTRY_IGNORE( PATM, StatPatchRefreshFailed), 336 SSMFIELD_ENTRY_IGNORE( PATM, StatGenRet), 337 SSMFIELD_ENTRY_IGNORE( PATM, StatGenRetReused), 338 SSMFIELD_ENTRY_IGNORE( PATM, StatGenJump), 339 SSMFIELD_ENTRY_IGNORE( PATM, StatGenCall), 340 SSMFIELD_ENTRY_IGNORE( PATM, StatGenPopf), 341 SSMFIELD_ENTRY_IGNORE( PATM, StatCheckPendingIRQ), 342 SSMFIELD_ENTRY_IGNORE( PATM, StatFunctionLookupReplace), 343 SSMFIELD_ENTRY_IGNORE( PATM, StatFunctionLookupInsert), 344 SSMFIELD_ENTRY_IGNORE( PATM, StatU32FunctionMaxSlotsUsed), 345 SSMFIELD_ENTRY_IGNORE( PATM, Alignment0), 346 SSMFIELD_ENTRY_TERM() 347 }; 348 349 /** 251 350 * SSM descriptor table for the PATMGCSTATE structure. 252 351 */ … … 433 532 434 533 /* Save the lookup record. */ 435 int rc = SSMR3Put Mem(pSSM, pPatchToGuestRec, sizeof(RECPATCHTOGUEST));534 int rc = SSMR3PutStructEx(pSSM, pPatchToGuestRec, sizeof(RECPATCHTOGUEST), 0 /*fFlags*/, &g_aPatmRecPatchToGuest[0], NULL); 436 535 AssertRCReturn(rc, rc); 437 536 … … 479 578 480 579 /* Save the lookup record. */ 481 int rc = SSMR3Put Mem(pSSM, &rec, sizeof(rec));580 int rc = SSMR3PutStructEx(pSSM, &rec, sizeof(rec), 0 /*fFlags*/, &g_aPatmRelocRec[0], NULL); 482 581 AssertRCReturn(rc, rc); 483 582 … … 595 694 596 695 patmR3PatchConvertMem2SSM(&patch, pPatch); 696 Log4(("patmSavePatchState: cbPatchJump=%u uCurPathOffset=%#x pInstrGCLowest/Higest=%#x/%#x nrFixups=%#x nrJumpRecs=%#x\n", 697 patch.patch.cbPatchJump, patch.patch.uCurPatchOffset, patch.patch.pInstrGCLowest, patch.patch.pInstrGCHighest, 698 patch.patch.nrFixups, patch.patch.nrJumpRecs)); 597 699 598 700 /* … … 606 708 607 709 /* Save the patch record itself */ 608 rc = SSMR3Put Mem(pSSM, &patch, sizeof(patch));710 rc = SSMR3PutStructEx(pSSM, &patch, sizeof(patch), 0 /*fFlags*/, &g_aPatmPatchRecFields[0], NULL); 609 711 AssertRCReturn(rc, rc); 610 712 … … 661 763 * Save PATM structure 662 764 */ 663 rc = SSMR3Put Mem(pSSM, &patmInfo, sizeof(patmInfo));765 rc = SSMR3PutStructEx(pSSM, &patmInfo, sizeof(patmInfo), 0 /*fFlags*/, &g_aPatmFields[0], NULL); 664 766 AssertRCReturn(rc, rc); 665 767 … … 673 775 * Save GC state memory 674 776 */ 675 rc = SSMR3Put Mem(pSSM, pVM->patm.s.pGCStateHC, sizeof(PATMGCSTATE));777 rc = SSMR3PutStructEx(pSSM, pVM->patm.s.pGCStateHC, sizeof(PATMGCSTATE), 0 /*fFlags*/, &g_aPatmGCStateFields[0], NULL); 676 778 AssertRCReturn(rc, rc); 677 779 … … 679 781 * Save PATM stack page 680 782 */ 783 SSMR3PutU32(pSSM, PATM_STACK_TOTAL_SIZE); 681 784 rc = SSMR3PutMem(pSSM, pVM->patm.s.pGCStackHC, PATM_STACK_TOTAL_SIZE); 682 785 AssertRCReturn(rc, rc); … … 718 821 719 822 if ( uVersion != PATM_SSM_VERSION 823 && uVersion != PATM_SSM_VERSION_MEM 720 824 && uVersion != PATM_SSM_VERSION_FIXUP_HACK 721 825 && uVersion != PATM_SSM_VERSION_VER16 … … 725 829 return VERR_SSM_UNSUPPORTED_DATA_UNIT_VERSION; 726 830 } 831 uint32_t const fStructRestoreFlags = uVersion <= PATM_SSM_VERSION_MEM ? SSMSTRUCT_FLAGS_MEM_BAND_AID_RELAXED : 0; 727 832 Assert(uPass == SSM_PASS_FINAL); NOREF(uPass); 728 833 … … 733 838 */ 734 839 RT_ZERO(patmInfo); 735 rc = SSMR3GetStructEx(pSSM, &patmInfo, sizeof(patmInfo), SSMSTRUCT_FLAGS_MEM_BAND_AID_RELAXED, &g_aPatmFields[0], NULL); 840 if ( uVersion == PATM_SSM_VERSION_MEM 841 && SSMR3HandleRevision(pSSM) >= 86139) 842 rc = SSMR3GetStructEx(pSSM, &patmInfo, sizeof(patmInfo), SSMSTRUCT_FLAGS_MEM_BAND_AID_RELAXED, 843 &g_aPatmFields86139[0], NULL); 844 else 845 rc = SSMR3GetStructEx(pSSM, &patmInfo, sizeof(patmInfo), fStructRestoreFlags, &g_aPatmFields[0], NULL); 736 846 AssertRCReturn(rc, rc); 737 847 738 848 /* Relative calls are made to the helper functions. Therefor their relative location must not change! */ 739 849 /* Note: we reuse the saved global helpers and assume they are identical, which is kind of dangerous. */ 740 if ( (pVM->patm.s.pfnHelperCallGC - pVM->patm.s.pPatchMemGC) != (patmInfo.pfnHelperCallGC - patmInfo.pPatchMemGC) 741 || (pVM->patm.s.pfnHelperRetGC - pVM->patm.s.pPatchMemGC) != (patmInfo.pfnHelperRetGC - patmInfo.pPatchMemGC) 742 || (pVM->patm.s.pfnHelperJumpGC - pVM->patm.s.pPatchMemGC) != (patmInfo.pfnHelperJumpGC - patmInfo.pPatchMemGC) 743 || (pVM->patm.s.pfnHelperIretGC - pVM->patm.s.pPatchMemGC) != (patmInfo.pfnHelperIretGC - patmInfo.pPatchMemGC)) 744 { 745 AssertMsgFailed(("Helper function ptrs don't match!!!\n")); 746 return VERR_SSM_INVALID_STATE; 747 } 748 749 if (pVM->patm.s.cbPatchMem != patmInfo.cbPatchMem) 750 { 751 AssertMsgFailed(("Patch memory ptrs and/or sizes don't match!!!\n")); 752 return VERR_SSM_INVALID_STATE; 753 } 850 AssertLogRelReturn((pVM->patm.s.pfnHelperCallGC - pVM->patm.s.pPatchMemGC) == (patmInfo.pfnHelperCallGC - patmInfo.pPatchMemGC), 851 VERR_SSM_DATA_UNIT_FORMAT_CHANGED); 852 AssertLogRelReturn((pVM->patm.s.pfnHelperRetGC - pVM->patm.s.pPatchMemGC) == (patmInfo.pfnHelperRetGC - patmInfo.pPatchMemGC), 853 VERR_SSM_DATA_UNIT_FORMAT_CHANGED); 854 AssertLogRelReturn((pVM->patm.s.pfnHelperJumpGC - pVM->patm.s.pPatchMemGC) == (patmInfo.pfnHelperJumpGC - patmInfo.pPatchMemGC), 855 VERR_SSM_DATA_UNIT_FORMAT_CHANGED); 856 AssertLogRelReturn((pVM->patm.s.pfnHelperIretGC - pVM->patm.s.pPatchMemGC) == (patmInfo.pfnHelperIretGC - patmInfo.pPatchMemGC), 857 VERR_SSM_DATA_UNIT_FORMAT_CHANGED); 858 AssertLogRelReturn(pVM->patm.s.cbPatchMem == patmInfo.cbPatchMem, VERR_SSM_DATA_UNIT_FORMAT_CHANGED); 859 754 860 pVM->patm.s.offPatchMem = patmInfo.offPatchMem; 755 861 pVM->patm.s.deltaReloc = patmInfo.deltaReloc; … … 787 893 */ 788 894 RT_BZERO(pVM->patm.s.pGCStateHC, sizeof(PATMGCSTATE)); 789 rc = SSMR3GetStructEx(pSSM, pVM->patm.s.pGCStateHC, sizeof(PATMGCSTATE), SSMSTRUCT_FLAGS_MEM_BAND_AID_RELAXED, &g_aPatmGCStateFields[0], NULL);895 rc = SSMR3GetStructEx(pSSM, pVM->patm.s.pGCStateHC, sizeof(PATMGCSTATE), fStructRestoreFlags, &g_aPatmGCStateFields[0], NULL); 790 896 AssertRCReturn(rc, rc); 791 897 … … 793 899 * Restore PATM stack page 794 900 */ 795 rc = SSMR3GetMem(pSSM, pVM->patm.s.pGCStackHC, PATM_STACK_TOTAL_SIZE); 901 uint32_t cbStack = PATM_STACK_TOTAL_SIZE; 902 if (uVersion > PATM_SSM_VERSION_MEM) 903 { 904 rc = SSMR3GetU32(pSSM, &cbStack); 905 AssertRCReturn(rc, rc); 906 } 907 AssertCompile(!(PATM_STACK_TOTAL_SIZE & 31)); 908 AssertLogRelMsgReturn(cbStack > 0 && cbStack <= PATM_STACK_TOTAL_SIZE && !(cbStack & 31), 909 ("cbStack=%#x vs %#x", cbStack, PATM_STACK_TOTAL_SIZE), 910 VERR_SSM_DATA_UNIT_FORMAT_CHANGED); 911 rc = SSMR3GetMem(pSSM, pVM->patm.s.pGCStackHC, cbStack); 796 912 AssertRCReturn(rc, rc); 913 if (cbStack < PATM_STACK_TOTAL_SIZE) 914 memset((uint8_t *)pVM->patm.s.pGCStackHC + cbStack, 0, PATM_STACK_TOTAL_SIZE - cbStack); 797 915 798 916 /* … … 805 923 806 924 RT_ZERO(patch); 807 rc = SSMR3GetStructEx(pSSM, &patch, sizeof(patch), SSMSTRUCT_FLAGS_MEM_BAND_AID_RELAXED, &g_aPatmPatchRecFields[0], NULL);925 rc = SSMR3GetStructEx(pSSM, &patch, sizeof(patch), fStructRestoreFlags, &g_aPatmPatchRecFields[0], NULL); 808 926 AssertRCReturn(rc, rc); 927 Log4(("patmR3Load: cbPatchJump=%u uCurPathOffset=%#x pInstrGCLowest/Higest=%#x/%#x nrFixups=%#x nrJumpRecs=%#x\n", 928 patch.patch.cbPatchJump, patch.patch.uCurPatchOffset, patch.patch.pInstrGCLowest, patch.patch.pInstrGCHighest, 929 patch.patch.nrFixups, patch.patch.nrJumpRecs)); 809 930 810 931 Assert(!(patch.patch.flags & PATMFL_GLOBAL_FUNCTIONS)); … … 854 975 855 976 RT_ZERO(rec); 856 rc = SSMR3GetStructEx(pSSM, &rec, sizeof(rec), SSMSTRUCT_FLAGS_MEM_BAND_AID_RELAXED, &g_aPatmRelocRec[0], NULL);977 rc = SSMR3GetStructEx(pSSM, &rec, sizeof(rec), fStructRestoreFlags, &g_aPatmRelocRec[0], NULL); 857 978 AssertRCReturn(rc, rc); 858 979 … … 902 1023 { 903 1024 RT_ZERO(rec); 904 rc = SSMR3GetStructEx(pSSM, &rec, sizeof(rec), SSMSTRUCT_FLAGS_MEM_BAND_AID_RELAXED, &g_aPatmRecPatchToGuest[0], NULL);1025 rc = SSMR3GetStructEx(pSSM, &rec, sizeof(rec), fStructRestoreFlags, &g_aPatmRecPatchToGuest[0], NULL); 905 1026 AssertRCReturn(rc, rc); 906 1027 … … 1180 1301 } 1181 1302 else 1182 if (ulSSMVersion >= PATM_SSM_VERSION )1303 if (ulSSMVersion >= PATM_SSM_VERSION_MEM) 1183 1304 { 1184 1305 #ifdef LOG_ENABLED
Note:
See TracChangeset
for help on using the changeset viewer.