Changeset 57009 in vbox for trunk/src/VBox
- Timestamp:
- Jul 19, 2015 5:57:02 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMR3/PATMSSM.cpp
r55889 r57009 138 138 PATCHINFOSSM patch; 139 139 } PATMPATCHRECSSM, *PPATMPATCHRECSSM; 140 141 142 /** 143 * Callback arguments. 144 */ 145 typedef struct PATMCALLBACKARGS 146 { 147 PVM pVM; 148 PSSMHANDLE pSSM; 149 PPATMPATCHREC pPatchRec; 150 } PATMCALLBACKARGS; 151 typedef PATMCALLBACKARGS *PPATMCALLBACKARGS; 140 152 141 153 … … 522 534 * @returns VBox status code. 523 535 * @param pNode Current node 524 * @param pVM1 Pointer to the VM 525 */ 526 static DECLCALLBACK(int) patmSaveP2GLookupRecords(PAVLU32NODECORE pNode, void *pVM1) 527 { 528 PVM pVM = (PVM)pVM1; 529 PSSMHANDLE pSSM = pVM->patm.s.savedstate.pSSM; 536 * @param pvUser Pointer to PATMCALLBACKARGS. 537 */ 538 static DECLCALLBACK(int) patmSaveP2GLookupRecords(PAVLU32NODECORE pNode, void *pvUser) 539 { 540 PPATMCALLBACKARGS pArgs = (PPATMCALLBACKARGS)pvUser; 530 541 PRECPATCHTOGUEST pPatchToGuestRec = (PRECPATCHTOGUEST)pNode; 531 542 532 543 /* Save the lookup record. */ 533 int rc = SSMR3PutStructEx(pSSM, pPatchToGuestRec, sizeof(RECPATCHTOGUEST), 0 /*fFlags*/, &g_aPatmRecPatchToGuest[0], NULL); 544 int rc = SSMR3PutStructEx(pArgs->pSSM, pPatchToGuestRec, sizeof(RECPATCHTOGUEST), 0 /*fFlags*/, 545 &g_aPatmRecPatchToGuest[0], NULL); 534 546 AssertRCReturn(rc, rc); 535 547 … … 544 556 * @returns VBox status code. 545 557 * @param pNode Current node 546 * @param pVM1 Pointer to the VM 547 */ 548 static DECLCALLBACK(int) patmSaveFixupRecords(PAVLPVNODECORE pNode, void *pVM1) 549 { 550 PVM pVM = (PVM)pVM1; 551 PSSMHANDLE pSSM = pVM->patm.s.savedstate.pSSM; 558 * @param pvUser Pointer to PATMCALLBACKARGS. 559 */ 560 static DECLCALLBACK(int) patmSaveFixupRecords(PAVLPVNODECORE pNode, void *pvUser) 561 { 562 PPATMCALLBACKARGS pArgs = (PPATMCALLBACKARGS)pvUser; 552 563 RELOCREC rec = *(PRELOCREC)pNode; 553 RTRCPTR *pFixup = (RTRCPTR *)rec.pRelocPos;554 564 555 565 /* Convert pointer to an offset into patch memory. May not be applicable 556 566 to all fixup types, thus the UINT32_MAX. */ 557 Assert(rec.pRelocPos); 558 uintptr_t offRelocPos = (uintptr_t)rec.pRelocPos - (uintptr_t)pVM->patm.s.pPatchMemHC; 559 if (offRelocPos > pVM->patm.s.cbPatchMem) 567 AssertMsg( rec.pRelocPos 568 || ( rec.uType == FIXUP_REL_JMPTOPATCH 569 && !(pArgs->pPatchRec->patch.flags & PATMFL_PATCHED_GUEST_CODE)), 570 ("uState=%#x uType=%#x flags=%#RX64\n", pArgs->pPatchRec->patch.uState, rec.uType, pArgs->pPatchRec->patch.flags)); 571 uintptr_t offRelocPos = (uintptr_t)rec.pRelocPos - (uintptr_t)pArgs->pVM->patm.s.pPatchMemHC; 572 if (offRelocPos > pArgs->pVM->patm.s.cbPatchMem) 560 573 offRelocPos = UINT32_MAX; 561 574 rec.pRelocPos = (uint8_t *)offRelocPos; … … 564 577 rec.Core.Key = 0; 565 578 566 567 579 /* Save the lookup record. */ 568 int rc = SSMR3PutStructEx(p SSM, &rec, sizeof(rec), 0 /*fFlags*/, &g_aPatmRelocRec[0], NULL);580 int rc = SSMR3PutStructEx(pArgs->pSSM, &rec, sizeof(rec), 0 /*fFlags*/, &g_aPatmRelocRec[0], NULL); 569 581 AssertRCReturn(rc, rc); 570 582 … … 669 681 * @returns VBox status code. 670 682 * @param pNode Current node 671 * @param p VM1 Pointer to the VM672 */ 673 static DECLCALLBACK(int) patmSavePatchState(PAVLOU32NODECORE pNode, void *p VM1)674 { 675 P VM pVM = (PVM)pVM1;676 PPATMPATCHREC pPatch = (PPATMPATCHREC)pNode;677 PATMPATCHRECSSM patch;678 PSSMHANDLE pSSM = pVM->patm.s.savedstate.pSSM;679 int rc; 680 683 * @param pvUser Pointer to PATMCALLBACKARGS. 684 */ 685 static DECLCALLBACK(int) patmSavePatchState(PAVLOU32NODECORE pNode, void *pvUser) 686 { 687 PPATMCALLBACKARGS pArgs = (PPATMCALLBACKARGS)pvUser; 688 PPATMPATCHREC pPatch = (PPATMPATCHREC)pNode; 689 PATMPATCHRECSSM patch; 690 int rc; 691 692 pArgs->pPatchRec = pPatch; 681 693 Assert(!(pPatch->patch.flags & PATMFL_GLOBAL_FUNCTIONS)); 682 694 … … 689 701 * Reset HC pointers that need to be recalculated when loading the state 690 702 */ 703 #ifdef VBOX_STRICT 704 PVM pVM = pArgs->pVM; /* For PATCHCODE_PTR_HC. */ 691 705 AssertMsg(patch.patch.uState == PATCH_REFUSED || (patch.patch.pPatchBlockOffset || (patch.patch.flags & (PATMFL_SYSENTER_XP|PATMFL_INT3_REPLACEMENT))), 692 706 ("State = %x pPatchBlockHC=%08x flags=%x\n", patch.patch.uState, PATCHCODE_PTR_HC(&patch.patch), patch.patch.flags)); 707 #endif 693 708 Assert(pPatch->patch.JumpTree == 0); 694 709 Assert(!pPatch->patch.pTempInfo || pPatch->patch.pTempInfo->DisasmJumpTree == 0); … … 696 711 697 712 /* Save the patch record itself */ 698 rc = SSMR3PutStructEx(p SSM, &patch, sizeof(patch), 0 /*fFlags*/, &g_aPatmPatchRecFields[0], NULL);713 rc = SSMR3PutStructEx(pArgs->pSSM, &patch, sizeof(patch), 0 /*fFlags*/, &g_aPatmPatchRecFields[0], NULL); 699 714 AssertRCReturn(rc, rc); 700 715 … … 707 722 AssertMsg(nrFixupRecs == pPatch->patch.nrFixups, ("Fixup inconsistency! counted %d vs %d\n", nrFixupRecs, pPatch->patch.nrFixups)); 708 723 #endif 709 rc = RTAvlPVDoWithAll(&pPatch->patch.FixupTree, true, patmSaveFixupRecords, p VM);724 rc = RTAvlPVDoWithAll(&pPatch->patch.FixupTree, true, patmSaveFixupRecords, pArgs); 710 725 AssertRCReturn(rc, rc); 711 726 … … 716 731 #endif 717 732 718 rc = RTAvlU32DoWithAll(&pPatch->patch.Patch2GuestAddrTree, true, patmSaveP2GLookupRecords, p VM);733 rc = RTAvlU32DoWithAll(&pPatch->patch.Patch2GuestAddrTree, true, patmSaveP2GLookupRecords, pArgs); 719 734 AssertRCReturn(rc, rc); 720 735 736 pArgs->pPatchRec = NULL; 721 737 return VINF_SUCCESS; 722 738 } … … 779 795 * Save all patches 780 796 */ 781 rc = RTAvloU32DoWithAll(&pVM->patm.s.PatchLookupTreeHC->PatchTree, true, patmSavePatchState, pVM); 797 PATMCALLBACKARGS Args; 798 Args.pVM = pVM; 799 Args.pSSM = pSSM; 800 rc = RTAvloU32DoWithAll(&pVM->patm.s.PatchLookupTreeHC->PatchTree, true, patmSavePatchState, &Args); 782 801 AssertRCReturn(rc, rc); 783 802 784 /* * @note patch statistics are not saved. */803 /* Note! Patch statistics are not saved. */ 785 804 786 805 return VINF_SUCCESS;
Note:
See TracChangeset
for help on using the changeset viewer.