Changeset 18927 in vbox for trunk/src/VBox/VMM/PATM
- Timestamp:
- Apr 16, 2009 11:41:38 AM (16 years ago)
- svn:sync-xref-src-repo-rev:
- 46003
- Location:
- trunk/src/VBox/VMM/PATM
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/PATM/CSAM.cpp
r16552 r18927 562 562 int rc; 563 563 R3PTRTYPE(void *) pHCPtr; 564 Assert(pVM->cCPUs == 1); 565 PVMCPU pVCpu = VMMGetCpu0(pVM); 564 566 565 567 STAM_PROFILE_START(&pVM->csam.s.StatTimeAddrConv, a); … … 578 580 } 579 581 580 rc = PGMPhysGCPtr2R3Ptr(pV M, pGCPtr, &pHCPtr);582 rc = PGMPhysGCPtr2R3Ptr(pVCpu, pGCPtr, &pHCPtr); 581 583 if (rc != VINF_SUCCESS) 582 584 { … … 585 587 return NULL; 586 588 } 587 ////invalid? Assert(sizeof(R3PTRTYPE(uint8_t*)) == sizeof(uint32_t));588 589 589 590 pCacheRec->pPageLocStartHC = (R3PTRTYPE(uint8_t*))((RTHCUINTPTR)pHCPtr & PAGE_BASE_HC_MASK); 590 pCacheRec->pGuestLoc = pGCPtr & PAGE_BASE_GC_MASK;591 pCacheRec->pGuestLoc = pGCPtr & PAGE_BASE_GC_MASK; 591 592 STAM_PROFILE_STOP(&pVM->csam.s.StatTimeAddrConv, a); 592 593 return pHCPtr; … … 608 609 PVM pVM = (PVM)pCpu->apvUserData[0]; 609 610 RTHCUINTPTR pInstrHC = (RTHCUINTPTR)pCpu->apvUserData[1]; 610 RTGCUINTPTR32 611 RTGCUINTPTR32 pInstrGC = (uintptr_t)pCpu->apvUserData[2]; 611 612 int orgsize = size; 613 Assert(pVM->cCPUs == 1); 614 PVMCPU pVCpu = VMMGetCpu0(pVM); 612 615 613 616 /* We are not interested in patched instructions, so read the original opcode bytes. */ … … 630 633 if (PAGE_ADDRESS(pInstrGC) != PAGE_ADDRESS(pSrc + size - 1) && !PATMIsPatchGCAddr(pVM, pSrc)) 631 634 { 632 return PGMPhysSimpleReadGCPtr(pV M, pDest, pSrc, size);635 return PGMPhysSimpleReadGCPtr(pVCpu, pDest, pSrc, size); 633 636 } 634 637 else … … 1080 1083 R3PTRTYPE(uint8_t *) pCurInstrHC = 0; 1081 1084 int rc2; 1085 Assert(pVM->cCPUs == 1); 1086 PVMCPU pVCpu = VMMGetCpu0(pVM); 1082 1087 1083 1088 #ifdef DEBUG … … 1162 1167 if (PAGE_ADDRESS(pCurInstrGC) != PAGE_ADDRESS(pCurInstrGC + opsize - 1)) 1163 1168 { 1164 if (!PGMGstIsPagePresent(pVM, p CurInstrGC + opsize - 1))1169 if (!PGMGstIsPagePresent(pVM, pVCpu, pCurInstrGC + opsize - 1)) 1165 1170 { 1166 1171 /// @todo fault in the page … … 1206 1211 { 1207 1212 addr = 0; 1208 PGMPhysSimpleReadGCPtr(pV M, &addr, (RTRCUINTPTR)cpu.param1.disp32, sizeof(addr));1213 PGMPhysSimpleReadGCPtr(pVCpu, &addr, (RTRCUINTPTR)cpu.param1.disp32, sizeof(addr)); 1209 1214 } 1210 1215 else … … 1225 1230 if (PAGE_ADDRESS(addr) != PAGE_ADDRESS(pCurInstrGC )) 1226 1231 { 1227 if (!PGMGstIsPagePresent(pVM, addr))1232 if (!PGMGstIsPagePresent(pVM, pVCpu, addr)) 1228 1233 { 1229 1234 Log(("Page for current instruction %RRv is not present!!\n", addr)); … … 1279 1284 Log(("Jump through jump table\n")); 1280 1285 1281 rc2 = PGMPhysGCPtr2R3Ptr(pV M, pJumpTableGC, (PRTHCPTR)&pJumpTableHC);1286 rc2 = PGMPhysGCPtr2R3Ptr(pVCpu, pJumpTableGC, (PRTHCPTR)&pJumpTableHC); 1282 1287 if (rc2 == VINF_SUCCESS) 1283 1288 { … … 1293 1298 addr = *(RTRCPTR *)(pJumpTableHC + cpu.param1.scale * i); 1294 1299 1295 rc2 = PGMGstGetPage(pVM, addr, &fFlags, NULL);1300 rc2 = PGMGstGetPage(pVM, pVCpu, addr, &fFlags, NULL); 1296 1301 if ( rc2 != VINF_SUCCESS 1297 1302 || (fFlags & X86_PTE_US) … … 1354 1359 uint32_t val[5]; 1355 1360 int rc; 1361 Assert(pVM->cCPUs == 1); 1362 PVMCPU pVCpu = VMMGetCpu0(pVM); 1356 1363 1357 1364 Assert((pInstr & PAGE_OFFSET_MASK) == 0); 1358 1365 1359 rc = PGMPhysSimpleReadGCPtr(pV M, &val[0], pInstr, sizeof(val[0]));1366 rc = PGMPhysSimpleReadGCPtr(pVCpu, &val[0], pInstr, sizeof(val[0])); 1360 1367 AssertMsg(RT_SUCCESS(rc) || rc == VERR_PAGE_NOT_PRESENT || rc == VERR_PAGE_TABLE_NOT_PRESENT, ("rc = %Rrc\n", rc)); 1361 1368 if (rc == VERR_PAGE_NOT_PRESENT || rc == VERR_PAGE_TABLE_NOT_PRESENT) … … 1365 1372 } 1366 1373 1367 rc = PGMPhysSimpleReadGCPtr(pV M, &val[1], pInstr+1024, sizeof(val[0]));1374 rc = PGMPhysSimpleReadGCPtr(pVCpu, &val[1], pInstr+1024, sizeof(val[0])); 1368 1375 AssertMsg(RT_SUCCESS(rc) || rc == VERR_PAGE_NOT_PRESENT || rc == VERR_PAGE_TABLE_NOT_PRESENT, ("rc = %Rrc\n", rc)); 1369 1376 if (rc == VERR_PAGE_NOT_PRESENT || rc == VERR_PAGE_TABLE_NOT_PRESENT) … … 1373 1380 } 1374 1381 1375 rc = PGMPhysSimpleReadGCPtr(pV M, &val[2], pInstr+2048, sizeof(val[0]));1382 rc = PGMPhysSimpleReadGCPtr(pVCpu, &val[2], pInstr+2048, sizeof(val[0])); 1376 1383 AssertMsg(RT_SUCCESS(rc) || rc == VERR_PAGE_NOT_PRESENT || rc == VERR_PAGE_TABLE_NOT_PRESENT, ("rc = %Rrc\n", rc)); 1377 1384 if (rc == VERR_PAGE_NOT_PRESENT || rc == VERR_PAGE_TABLE_NOT_PRESENT) … … 1381 1388 } 1382 1389 1383 rc = PGMPhysSimpleReadGCPtr(pV M, &val[3], pInstr+3072, sizeof(val[0]));1390 rc = PGMPhysSimpleReadGCPtr(pVCpu, &val[3], pInstr+3072, sizeof(val[0])); 1384 1391 AssertMsg(RT_SUCCESS(rc) || rc == VERR_PAGE_NOT_PRESENT || rc == VERR_PAGE_TABLE_NOT_PRESENT, ("rc = %Rrc\n", rc)); 1385 1392 if (rc == VERR_PAGE_NOT_PRESENT || rc == VERR_PAGE_TABLE_NOT_PRESENT) … … 1389 1396 } 1390 1397 1391 rc = PGMPhysSimpleReadGCPtr(pV M, &val[4], pInstr+4092, sizeof(val[0]));1398 rc = PGMPhysSimpleReadGCPtr(pVCpu, &val[4], pInstr+4092, sizeof(val[0])); 1392 1399 AssertMsg(RT_SUCCESS(rc) || rc == VERR_PAGE_NOT_PRESENT || rc == VERR_PAGE_TABLE_NOT_PRESENT, ("rc = %Rrc\n", rc)); 1393 1400 if (rc == VERR_PAGE_NOT_PRESENT || rc == VERR_PAGE_TABLE_NOT_PRESENT) … … 1420 1427 RTGCPHYS GCPhys = 0; 1421 1428 uint64_t fFlags = 0; 1429 Assert(pVM->cCPUs == 1); 1430 PVMCPU pVCpu = VMMGetCpu0(pVM); 1422 1431 1423 1432 if (!CSAMIsEnabled(pVM)) … … 1437 1446 } 1438 1447 1439 rc = PGMGstGetPage(pVM, addr, &fFlags, &GCPhys);1448 rc = PGMGstGetPage(pVM, pVCpu, addr, &fFlags, &GCPhys); 1440 1449 /* Returned at a very early stage (no paging yet presumably). */ 1441 1450 if (rc == VERR_NOT_SUPPORTED) … … 1483 1492 pPageRec->page.GCPhys = 0; 1484 1493 pPageRec->page.fFlags = 0; 1485 rc = PGMGstGetPage(pVM, addr, &pPageRec->page.fFlags, &pPageRec->page.GCPhys);1494 rc = PGMGstGetPage(pVM, pVCpu, addr, &pPageRec->page.fFlags, &pPageRec->page.GCPhys); 1486 1495 if (rc == VINF_SUCCESS) 1487 1496 pPageRec->page.u64Hash = csamR3CalcPageHash(pVM, addr); … … 1610 1619 int rc; 1611 1620 bool ret; 1621 Assert(pVM->cCPUs == 1); 1622 PVMCPU pVCpu = VMMGetCpu0(pVM); 1612 1623 1613 1624 Log(("New page record for %RRv\n", GCPtr & PAGE_BASE_GC_MASK)); … … 1628 1639 pPage->page.fMonitorActive = false; 1629 1640 pPage->page.pBitmap = (uint8_t *)MMR3HeapAllocZ(pVM, MM_TAG_CSAM_PATCH, PAGE_SIZE/sizeof(uint8_t)); 1630 rc = PGMGstGetPage(pVM, GCPtr, &pPage->page.fFlags, &pPage->page.GCPhys);1641 rc = PGMGstGetPage(pVM, pVCpu, GCPtr, &pPage->page.fFlags, &pPage->page.GCPhys); 1631 1642 AssertMsg(RT_SUCCESS(rc) || rc == VERR_PAGE_NOT_PRESENT || rc == VERR_PAGE_TABLE_NOT_PRESENT, ("rc = %Rrc\n", rc)); 1632 1643 … … 1656 1667 1657 1668 /* Prefetch it in case it's not there yet. */ 1658 rc = PGMPrefetchPage(pVM, GCPtr);1669 rc = PGMPrefetchPage(pVM, pVCpu, GCPtr); 1659 1670 AssertRC(rc); 1660 1671 1661 rc = PGMShwModifyPage(pVM, GCPtr, 1, 0, ~(uint64_t)X86_PTE_RW);1672 rc = PGMShwModifyPage(pVM, pVCpu, GCPtr, 1, 0, ~(uint64_t)X86_PTE_RW); 1662 1673 Assert(rc == VINF_SUCCESS || rc == VERR_PAGE_NOT_PRESENT || rc == VERR_PAGE_TABLE_NOT_PRESENT); 1663 1674 … … 1711 1722 int rc; 1712 1723 bool fMonitorInvalidation; 1724 Assert(pVM->cCPUs == 1); 1725 PVMCPU pVCpu = VMMGetCpu0(pVM); 1713 1726 1714 1727 /* Dirty pages must be handled before calling this function!. */ … … 1730 1743 uint64_t fFlags; 1731 1744 1732 rc = PGMGstGetPage(pVM, p PageAddrGC, &fFlags, NULL);1745 rc = PGMGstGetPage(pVM, pVCpu, pPageAddrGC, &fFlags, NULL); 1733 1746 AssertMsg(RT_SUCCESS(rc) || rc == VERR_PAGE_NOT_PRESENT || rc == VERR_PAGE_TABLE_NOT_PRESENT, ("rc = %Rrc\n", rc)); 1734 1747 if ( rc == VINF_SUCCESS … … 1766 1779 1767 1780 /* Prefetch it in case it's not there yet. */ 1768 rc = PGMPrefetchPage(pVM, p PageAddrGC);1781 rc = PGMPrefetchPage(pVM, pVCpu, pPageAddrGC); 1769 1782 AssertRC(rc); 1770 1783 1771 rc = PGMShwModifyPage(pVM, p PageAddrGC, 1, 0, ~(uint64_t)X86_PTE_RW);1784 rc = PGMShwModifyPage(pVM, pVCpu, pPageAddrGC, 1, 0, ~(uint64_t)X86_PTE_RW); 1772 1785 Assert(rc == VINF_SUCCESS || rc == VERR_PAGE_NOT_PRESENT || rc == VERR_PAGE_TABLE_NOT_PRESENT); 1773 1786 … … 1787 1800 1788 1801 /* Prefetch it in case it's not there yet. */ 1789 rc = PGMPrefetchPage(pVM, p PageAddrGC);1802 rc = PGMPrefetchPage(pVM, pVCpu, pPageAddrGC); 1790 1803 AssertRC(rc); 1791 1804 1792 1805 /* Make sure it's readonly. Page invalidation may have modified the attributes. */ 1793 rc = PGMShwModifyPage(pVM, p PageAddrGC, 1, 0, ~(uint64_t)X86_PTE_RW);1806 rc = PGMShwModifyPage(pVM, pVCpu, pPageAddrGC, 1, 0, ~(uint64_t)X86_PTE_RW); 1794 1807 Assert(rc == VINF_SUCCESS || rc == VERR_PAGE_NOT_PRESENT || rc == VERR_PAGE_TABLE_NOT_PRESENT); 1795 1808 } … … 1800 1813 uint64_t fPageShw; 1801 1814 RTHCPHYS GCPhys; 1802 rc = PGMShwGetPage(pVM, p PageAddrGC, &fPageShw, &GCPhys);1815 rc = PGMShwGetPage(pVM, pVCpu, pPageAddrGC, &fPageShw, &GCPhys); 1803 1816 // AssertMsg( (rc == VERR_PAGE_NOT_PRESENT || rc == VERR_PAGE_TABLE_NOT_PRESENT) 1804 1817 // || !(fPageShw & X86_PTE_RW) … … 1810 1823 { 1811 1824 /* Prefetch it in case it's not there yet. */ 1812 rc = PGMPrefetchPage(pVM, p PageAddrGC);1825 rc = PGMPrefetchPage(pVM, pVCpu, pPageAddrGC); 1813 1826 AssertRC(rc); 1814 1827 /* The page was changed behind our back. It won't be made read-only until the next SyncCR3, so force it here. */ 1815 rc = PGMShwModifyPage(pVM, p PageAddrGC, 1, 0, ~(uint64_t)X86_PTE_RW);1828 rc = PGMShwModifyPage(pVM, pVCpu, pPageAddrGC, 1, 0, ~(uint64_t)X86_PTE_RW); 1816 1829 Assert(rc == VINF_SUCCESS || rc == VERR_PAGE_NOT_PRESENT || rc == VERR_PAGE_TABLE_NOT_PRESENT); 1817 1830 } … … 1855 1868 { 1856 1869 PCSAMPAGEREC pPageRec; 1870 Assert(pVM->cCPUs == 1); 1871 PVMCPU pVCpu = VMMGetCpu0(pVM); 1857 1872 1858 1873 Log(("csamRemovePageRecord %RRv\n", GCPtr)); … … 1877 1892 /* Make sure the recompiler flushes its cache as this page is no longer monitored. */ 1878 1893 STAM_COUNTER_INC(&pVM->csam.s.StatPageRemoveREMFlush); 1879 CPUMSetChangedFlags(pV M, CPUM_CHANGED_GLOBAL_TLB_FLUSH);1894 CPUMSetChangedFlags(pVCpu, CPUM_CHANGED_GLOBAL_TLB_FLUSH); 1880 1895 } 1881 1896 #endif … … 2174 2189 static int csamR3FlushDirtyPages(PVM pVM) 2175 2190 { 2191 Assert(pVM->cCPUs == 1); 2192 PVMCPU pVCpu = VMMGetCpu0(pVM); 2193 2176 2194 STAM_PROFILE_START(&pVM->csam.s.StatFlushDirtyPages, a); 2177 2195 … … 2185 2203 2186 2204 /* Notify the recompiler that this page has been changed. */ 2187 REMR3NotifyCodePageChanged(pVM, GCPtr);2205 REMR3NotifyCodePageChanged(pVM, pVCpu, GCPtr); 2188 2206 2189 2207 /* Enable write protection again. (use the fault address as it might be an alias) */ 2190 rc = PGMShwModifyPage(pVM, pV M->csam.s.pvDirtyFaultPage[i], 1, 0, ~(uint64_t)X86_PTE_RW);2208 rc = PGMShwModifyPage(pVM, pVCpu, pVM->csam.s.pvDirtyFaultPage[i], 1, 0, ~(uint64_t)X86_PTE_RW); 2191 2209 Assert(rc == VINF_SUCCESS || rc == VERR_PAGE_NOT_PRESENT || rc == VERR_PAGE_TABLE_NOT_PRESENT); 2192 2210 … … 2198 2216 uint64_t fFlags; 2199 2217 2200 rc = PGMGstGetPage(pVM, GCPtr, &fFlags, NULL);2218 rc = PGMGstGetPage(pVM, pVCpu, GCPtr, &fFlags, NULL); 2201 2219 AssertMsg(RT_SUCCESS(rc) || rc == VERR_PAGE_NOT_PRESENT || rc == VERR_PAGE_TABLE_NOT_PRESENT, ("rc = %Rrc\n", rc)); 2202 2220 if ( rc == VINF_SUCCESS … … 2222 2240 static int csamR3FlushCodePages(PVM pVM) 2223 2241 { 2242 Assert(pVM->cCPUs == 1); 2243 PVMCPU pVCpu = VMMGetCpu0(pVM); 2244 2224 2245 for (uint32_t i=0;i<pVM->csam.s.cPossibleCodePages;i++) 2225 2246 { 2226 RTRCPTR 2247 RTRCPTR GCPtr = pVM->csam.s.pvPossibleCodePage[i]; 2227 2248 2228 2249 GCPtr = GCPtr & PAGE_BASE_GC_MASK; 2229 2250 2230 2251 Log(("csamR3FlushCodePages: %RRv\n", GCPtr)); 2231 PGMShwSetPage(pVM, GCPtr, 1, 0);2252 PGMShwSetPage(pVM, pVCpu, GCPtr, 1, 0); 2232 2253 /* Resync the page to make sure instruction fetch will fault */ 2233 2254 CSAMMarkPage(pVM, GCPtr, false); … … 2262 2283 VMMR3DECL(int) CSAMR3CheckGates(PVM pVM, uint32_t iGate, uint32_t cGates) 2263 2284 { 2285 Assert(pVM->cCPUs == 1); 2286 PVMCPU pVCpu = VMMGetCpu0(pVM); 2264 2287 uint16_t cbIDT; 2265 RTRCPTR GCPtrIDT = CPUMGetGuestIDTR(pV M, &cbIDT);2288 RTRCPTR GCPtrIDT = CPUMGetGuestIDTR(pVCpu, &cbIDT); 2266 2289 uint32_t iGateEnd; 2267 2290 uint32_t maxGates; … … 2336 2359 { 2337 2360 /* Just convert the IDT address to a R3 pointer. The whole IDT fits in one page. */ 2338 rc = PGMPhysGCPtr2R3Ptr(pV M, GCPtrIDT, (PRTR3PTR)&pGuestIdte);2361 rc = PGMPhysGCPtr2R3Ptr(pVCpu, GCPtrIDT, (PRTR3PTR)&pGuestIdte); 2339 2362 if (RT_FAILURE(rc)) 2340 2363 { … … 2347 2370 { 2348 2371 /* Slow method when it crosses a page boundary. */ 2349 rc = PGMPhysSimpleReadGCPtr(pV M, aIDT, GCPtrIDT, cGates*sizeof(VBOXIDTE));2372 rc = PGMPhysSimpleReadGCPtr(pVCpu, aIDT, GCPtrIDT, cGates*sizeof(VBOXIDTE)); 2350 2373 if (RT_FAILURE(rc)) 2351 2374 { … … 2374 2397 pHandler = SELMToFlatBySel(pVM, pGuestIdte->Gen.u16SegSel, pHandler); 2375 2398 2376 rc = SELMR3GetSelectorInfo(pVM, p GuestIdte->Gen.u16SegSel, &selInfo);2399 rc = SELMR3GetSelectorInfo(pVM, pVCpu, pGuestIdte->Gen.u16SegSel, &selInfo); 2377 2400 if ( RT_FAILURE(rc) 2378 2401 || selInfo.GCPtrBase != 0 … … 2412 2435 0x2F}; /* OpenBSD 4.0 after install */ 2413 2436 2414 pCtx = CPUMQueryGuestCtxPtr(pV M);2437 pCtx = CPUMQueryGuestCtxPtr(pVCpu); 2415 2438 2416 2439 for (unsigned i=0;i<RT_ELEMENTS(aOpenBsdPushCSOffset);i++) 2417 2440 { 2418 rc = CPUMR3DisasmInstrCPU(pVM, p Ctx, pHandler - aOpenBsdPushCSOffset[i], &cpu, NULL);2441 rc = CPUMR3DisasmInstrCPU(pVM, pVCpu, pCtx, pHandler - aOpenBsdPushCSOffset[i], &cpu, NULL); 2419 2442 if ( rc == VINF_SUCCESS 2420 2443 && cpu.pCurInstr->opcode == OP_PUSH -
trunk/src/VBox/VMM/PATM/PATM.cpp
r15677 r18927 346 346 347 347 /* Needed for future patching of sldt/sgdt/sidt/str etc. */ 348 pVM->patm.s.pCPUMCtxGC = VM_RC_ADDR(pVM, CPUMQueryGuestCtxPtr( pVM));348 pVM->patm.s.pCPUMCtxGC = VM_RC_ADDR(pVM, CPUMQueryGuestCtxPtr(VMMGetCpu0(pVM))); 349 349 350 350 Assert(pVM->patm.s.PatchLookupTreeHC); … … 426 426 RTAvloU32DoWithAll(&pVM->patm.s.PatchLookupTreeHC->PatchTree, true, RelocatePatches, (void *)pVM); 427 427 428 pCtx = CPUMQueryGuestCtxPtr( pVM);428 pCtx = CPUMQueryGuestCtxPtr(VMMGetCpu0(pVM)); 429 429 430 430 /* If we are running patch code right now, then also adjust EIP. */ … … 557 557 if (PAGE_ADDRESS(pDisInfo->pInstrGC) != PAGE_ADDRESS(pSrc + size - 1) && !PATMIsPatchGCAddr(pDisInfo->pVM, pSrc)) 558 558 { 559 return PGMPhysSimpleReadGCPtr( pDisInfo->pVM, pDest, pSrc, size);559 return PGMPhysSimpleReadGCPtr(&pDisInfo->pVM->aCpus[0], pDest, pSrc, size); 560 560 } 561 561 else … … 604 604 { 605 605 /** @note pPrivInstrHC is probably not valid anymore */ 606 rc = PGMPhysGCPtr2R3Ptr( pVM, pPatch->patch.pPrivInstrGC, (PRTR3PTR)&pPatch->patch.pPrivInstrHC);606 rc = PGMPhysGCPtr2R3Ptr(VMMGetCpu0(pVM), pPatch->patch.pPrivInstrGC, (PRTR3PTR)&pPatch->patch.pPrivInstrHC); 607 607 if (rc == VINF_SUCCESS) 608 608 { … … 651 651 *(RTRCPTR *)&oldInstr[pPatch->patch.cbPrivInstr - sizeof(RTRCPTR)] = pRec->pDest; 652 652 653 rc = PGMPhysSimpleReadGCPtr( pVM, curInstr, pPatch->patch.pPrivInstrGC, pPatch->patch.cbPrivInstr);653 rc = PGMPhysSimpleReadGCPtr(VMMGetCpu0(pVM), curInstr, pPatch->patch.pPrivInstrGC, pPatch->patch.cbPrivInstr); 654 654 Assert(RT_SUCCESS(rc) || rc == VERR_PAGE_NOT_PRESENT || rc == VERR_PAGE_TABLE_NOT_PRESENT); 655 655 … … 678 678 { 679 679 *(RTRCPTR *)&curInstr[pPatch->patch.cbPrivInstr - sizeof(RTRCPTR)] = pRec->pDest; 680 rc = PGMPhysSimpleDirtyWriteGCPtr( pVM, pRec->pSource, curInstr, pPatch->patch.cbPrivInstr);680 rc = PGMPhysSimpleDirtyWriteGCPtr(VMMGetCpu0(pVM), pRec->pSource, curInstr, pPatch->patch.cbPrivInstr); 681 681 AssertRC(rc); 682 682 } … … 728 728 * Read old patch jump and compare it to the one we previously installed 729 729 */ 730 rc = PGMPhysSimpleReadGCPtr( pVM, temp, pPatch->patch.pPrivInstrGC, pPatch->patch.cbPatchJump);730 rc = PGMPhysSimpleReadGCPtr(VMMGetCpu0(pVM), temp, pPatch->patch.pPrivInstrGC, pPatch->patch.cbPatchJump); 731 731 Assert(RT_SUCCESS(rc) || rc == VERR_PAGE_NOT_PRESENT || rc == VERR_PAGE_TABLE_NOT_PRESENT); 732 732 … … 751 751 if (RT_SUCCESS(rc)) 752 752 { 753 rc = PGMPhysSimpleDirtyWriteGCPtr( pVM, pJumpOffGC, &displ, sizeof(displ));753 rc = PGMPhysSimpleDirtyWriteGCPtr(VMMGetCpu0(pVM), pJumpOffGC, &displ, sizeof(displ)); 754 754 AssertRC(rc); 755 755 } … … 790 790 { 791 791 /** @note pPrivInstrHC is probably not valid anymore */ 792 rc = PGMPhysGCPtr2R3Ptr( pVM, pPatch->patch.pPrivInstrGC, (PRTR3PTR)&pPatch->patch.pPrivInstrHC);792 rc = PGMPhysGCPtr2R3Ptr(VMMGetCpu0(pVM), pPatch->patch.pPrivInstrGC, (PRTR3PTR)&pPatch->patch.pPrivInstrHC); 793 793 if (rc == VINF_SUCCESS) 794 794 { … … 995 995 } 996 996 997 rc = PGMPhysGCPtr2R3Ptr( pVM, pGCPtr, (void **)&pHCPtr);997 rc = PGMPhysGCPtr2R3Ptr(VMMGetCpu0(pVM), pGCPtr, (void **)&pHCPtr); 998 998 if (rc != VINF_SUCCESS) 999 999 { … … 2529 2529 *(uint32_t *)&temp[1] = (RTRCUINTPTR)PATCHCODE_PTR_GC(pPatch) - ((RTRCUINTPTR)pPatch->pPrivInstrGC + SIZEOF_NEARJUMP32); //return address 2530 2530 } 2531 rc = PGMPhysSimpleDirtyWriteGCPtr( pVM, pPatch->pPrivInstrGC, temp, pPatch->cbPatchJump);2531 rc = PGMPhysSimpleDirtyWriteGCPtr(VMMGetCpu0(pVM), pPatch->pPrivInstrGC, temp, pPatch->cbPatchJump); 2532 2532 AssertRC(rc); 2533 2533 … … 2567 2567 2568 2568 /* Restore original code (privileged instruction + following instructions that were overwritten because of the 5/6 byte jmp). */ 2569 int rc = PGMPhysSimpleDirtyWriteGCPtr( pVM, pPatch->pPrivInstrGC, pPatch->aPrivInstr, pPatch->cbPatchJump);2569 int rc = PGMPhysSimpleDirtyWriteGCPtr(VMMGetCpu0(pVM), pPatch->pPrivInstrGC, pPatch->aPrivInstr, pPatch->cbPatchJump); 2570 2570 #ifdef DEBUG 2571 2571 if (rc == VINF_SUCCESS) … … 2626 2626 *(uint32_t *)&temp[1] = (uint32_t)pTargetGC - ((uint32_t)pPatch->pPrivInstrGC + SIZEOF_NEARJUMP32); //return address 2627 2627 2628 rc = PGMPhysSimpleDirtyWriteGCPtr( pVM, pPatch->pPrivInstrGC, temp, pPatch->cbPatchJump);2628 rc = PGMPhysSimpleDirtyWriteGCPtr(VMMGetCpu0(pVM), pPatch->pPrivInstrGC, temp, pPatch->cbPatchJump); 2629 2629 AssertRC(rc); 2630 2630 … … 2792 2792 pPatch->cbPatchJump = SIZEOF_NEARJUMP32; 2793 2793 2794 rc = PGMPhysSimpleReadGCPtr( pVM, pPatch->aPrivInstr, pPatch->pPrivInstrGC, pPatch->cbPatchJump);2794 rc = PGMPhysSimpleReadGCPtr(VMMGetCpu0(pVM), pPatch->aPrivInstr, pPatch->pPrivInstrGC, pPatch->cbPatchJump); 2795 2795 AssertRC(rc); 2796 2796 … … 3524 3524 pPatch->cbPatchJump = SIZEOF_NEARJUMP32; 3525 3525 3526 rc = PGMPhysSimpleReadGCPtr( pVM, pPatch->aPrivInstr, pPatch->pPrivInstrGC, pPatch->cbPatchJump);3526 rc = PGMPhysSimpleReadGCPtr(VMMGetCpu0(pVM), pPatch->aPrivInstr, pPatch->pPrivInstrGC, pPatch->cbPatchJump); 3527 3527 AssertRC(rc); 3528 3528 … … 3600 3600 3601 3601 /* Save original instruction. */ 3602 rc = PGMPhysSimpleReadGCPtr( pVM, pPatch->aPrivInstr, pPatch->pPrivInstrGC, pPatch->cbPrivInstr);3602 rc = PGMPhysSimpleReadGCPtr(VMMGetCpu0(pVM), pPatch->aPrivInstr, pPatch->pPrivInstrGC, pPatch->cbPrivInstr); 3603 3603 AssertRC(rc); 3604 3604 … … 3606 3606 3607 3607 /* Replace address with that of the cached item. */ 3608 rc = PGMPhysSimpleDirtyWriteGCPtr( pVM, pInstrGC + pCpu->opsize - sizeof(RTRCPTR), &pVM->patm.s.mmio.pCachedData, sizeof(RTRCPTR));3608 rc = PGMPhysSimpleDirtyWriteGCPtr(VMMGetCpu0(pVM), pInstrGC + pCpu->opsize - sizeof(RTRCPTR), &pVM->patm.s.mmio.pCachedData, sizeof(RTRCPTR)); 3609 3609 AssertRC(rc); 3610 3610 if (RT_FAILURE(rc)) … … 3713 3713 3714 3714 /* Replace first opcode byte with 'int 3'. */ 3715 rc = PGMPhysSimpleDirtyWriteGCPtr( pVM, pPatch->pPrivInstrGC, &ASMInt3, sizeof(ASMInt3));3715 rc = PGMPhysSimpleDirtyWriteGCPtr(VMMGetCpu0(pVM), pPatch->pPrivInstrGC, &ASMInt3, sizeof(ASMInt3)); 3716 3716 AssertRC(rc); 3717 3717 … … 3737 3737 3738 3738 /* Restore first opcode byte. */ 3739 rc = PGMPhysSimpleDirtyWriteGCPtr( pVM, pPatch->pPrivInstrGC, pPatch->aPrivInstr, sizeof(ASMInt3));3739 rc = PGMPhysSimpleDirtyWriteGCPtr(VMMGetCpu0(pVM), pPatch->pPrivInstrGC, pPatch->aPrivInstr, sizeof(ASMInt3)); 3740 3740 AssertRC(rc); 3741 3741 return rc; … … 3773 3773 3774 3774 /* Save the original instruction. */ 3775 rc = PGMPhysSimpleReadGCPtr( pVM, pPatch->aPrivInstr, pPatch->pPrivInstrGC, pPatch->cbPrivInstr);3775 rc = PGMPhysSimpleReadGCPtr(VMMGetCpu0(pVM), pPatch->aPrivInstr, pPatch->pPrivInstrGC, pPatch->cbPrivInstr); 3776 3776 AssertRC(rc); 3777 3777 pPatch->cbPatchJump = sizeof(ASMInt3); /* bit of a misnomer in this case; size of replacement instruction. */ … … 3877 3877 pPatch->cbPatchJump = pCpu->opsize; 3878 3878 3879 rc = PGMPhysSimpleReadGCPtr( pVM, pPatch->aPrivInstr, pPatch->pPrivInstrGC, pPatch->cbPatchJump);3879 rc = PGMPhysSimpleReadGCPtr(VMMGetCpu0(pVM), pPatch->aPrivInstr, pPatch->pPrivInstrGC, pPatch->cbPatchJump); 3880 3880 AssertRC(rc); 3881 3881 … … 3959 3959 bool disret; 3960 3960 int rc; 3961 PVMCPU pVCpu = VMMGetCpu0(pVM); 3961 3962 3962 3963 if (!pVM || pInstrGC == 0 || (flags & ~(PATMFL_CODE32|PATMFL_IDTHANDLER|PATMFL_INTHANDLER|PATMFL_SYSENTER|PATMFL_TRAPHANDLER|PATMFL_DUPLICATE_FUNCTION|PATMFL_REPLACE_FUNCTION_CALL|PATMFL_GUEST_SPECIFIC|PATMFL_INT3_REPLACEMENT|PATMFL_TRAPHANDLER_WITH_ERRORCODE|PATMFL_IDTHANDLER_WITHOUT_ENTRYPOINT|PATMFL_MMIO_ACCESS|PATMFL_TRAMPOLINE|PATMFL_INSTR_HINT|PATMFL_JUMP_CONFLICT))) … … 3990 3991 3991 3992 /* Make sure the code selector is wide open; otherwise refuse. */ 3992 pCtx = CPUMQueryGuestCtxPtr(pV M);3993 if (CPUMGetGuestCPL(pV M, CPUMCTX2CORE(pCtx)) == 0)3993 pCtx = CPUMQueryGuestCtxPtr(pVCpu); 3994 if (CPUMGetGuestCPL(pVCpu, CPUMCTX2CORE(pCtx)) == 0) 3994 3995 { 3995 3996 RTRCPTR pInstrGCFlat = SELMToFlat(pVM, DIS_SELREG_CS, CPUMCTX2CORE(pCtx), pInstrGC); … … 4107 4108 4108 4109 RTGCPHYS GCPhys; 4109 rc = PGMGstGetPage(pVM, p InstrGC, NULL, &GCPhys);4110 rc = PGMGstGetPage(pVM, pVCpu, pInstrGC, NULL, &GCPhys); 4110 4111 if (rc != VINF_SUCCESS) 4111 4112 { … … 4402 4403 uint8_t *pInstrHC; 4403 4404 4404 int rc = PGMPhysGCPtr2R3Ptr( pVM, pInstrGC, (PRTR3PTR)&pInstrHC);4405 int rc = PGMPhysGCPtr2R3Ptr(VMMGetCpu0(pVM), pInstrGC, (PRTR3PTR)&pInstrHC); 4405 4406 if (rc == VINF_SUCCESS) 4406 4407 { … … 4999 5000 5000 5001 /** pPrivInstrHC is probably not valid anymore */ 5001 rc = PGMPhysGCPtr2R3Ptr( pVM, pPatchRec->patch.pPrivInstrGC, (PRTR3PTR)&pPatchRec->patch.pPrivInstrHC);5002 rc = PGMPhysGCPtr2R3Ptr(VMMGetCpu0(pVM), pPatchRec->patch.pPrivInstrGC, (PRTR3PTR)&pPatchRec->patch.pPrivInstrHC); 5002 5003 if (rc == VINF_SUCCESS) 5003 5004 { … … 5007 5008 5008 5009 /* Let's first check if the guest code is still the same. */ 5009 rc = PGMPhysSimpleReadGCPtr( pVM, temp, pPatch->pPrivInstrGC, pPatch->cbPatchJump);5010 rc = PGMPhysSimpleReadGCPtr(VMMGetCpu0(pVM), temp, pPatch->pPrivInstrGC, pPatch->cbPatchJump); 5010 5011 Assert(rc == VINF_SUCCESS || rc == VERR_PAGE_TABLE_NOT_PRESENT || rc == VERR_PAGE_NOT_PRESENT); 5011 5012 if (rc == VINF_SUCCESS) … … 5049 5050 5050 5051 /* Let's first check if the guest code is still the same. */ 5051 rc = PGMPhysSimpleReadGCPtr( pVM, temp, pPatch->pPrivInstrGC, pPatch->cbPatchJump);5052 rc = PGMPhysSimpleReadGCPtr(VMMGetCpu0(pVM), temp, pPatch->pPrivInstrGC, pPatch->cbPatchJump); 5052 5053 Assert(rc == VINF_SUCCESS || rc == VERR_PAGE_TABLE_NOT_PRESENT || rc == VERR_PAGE_NOT_PRESENT); 5053 5054 if (rc == VINF_SUCCESS) … … 5218 5219 Assert(!(pPatch->flags & PATMFL_PATCHED_GUEST_CODE)); 5219 5220 /** @todo -> pPrivInstrHC is probably not valid anymore */ 5220 rc = PGMPhysGCPtr2R3Ptr( pVM, pPatchRec->patch.pPrivInstrGC, (PRTR3PTR)&pPatchRec->patch.pPrivInstrHC);5221 rc = PGMPhysGCPtr2R3Ptr(VMMGetCpu0(pVM), pPatchRec->patch.pPrivInstrGC, (PRTR3PTR)&pPatchRec->patch.pPrivInstrHC); 5221 5222 if (rc == VINF_SUCCESS) 5222 5223 { … … 5231 5232 5232 5233 // let's first check if the guest code is still the same 5233 int rc = PGMPhysSimpleReadGCPtr( pVM, temp, pPatch->pPrivInstrGC, pPatch->cbPatchJump);5234 int rc = PGMPhysSimpleReadGCPtr(VMMGetCpu0(pVM), temp, pPatch->pPrivInstrGC, pPatch->cbPatchJump); 5234 5235 AssertRC(rc); 5235 5236 … … 5270 5271 5271 5272 /* Let's first check if the guest code is still the same. */ 5272 int rc = PGMPhysSimpleReadGCPtr( pVM, temp, pPatch->pPrivInstrGC, pPatch->cbPatchJump);5273 int rc = PGMPhysSimpleReadGCPtr(VMMGetCpu0(pVM), temp, pPatch->pPrivInstrGC, pPatch->cbPatchJump); 5273 5274 AssertRC(rc); 5274 5275 … … 5817 5818 uint32_t cbDirty; 5818 5819 PRECPATCHTOGUEST pRec; 5820 PVMCPU pVCpu = VMMGetCpu0(pVM); 5819 5821 5820 5822 Log(("patmR3HandleDirtyInstr: dirty instruction at %RRv (%RRv)\n", pEip, pPatchToGuestRec->pOrgInstrGC)); … … 5841 5843 5842 5844 /* Only harmless instructions are acceptable. */ 5843 rc = CPUMR3DisasmInstrCPU(pVM, p Ctx, pCurPatchInstrGC, &CpuOld, 0);5845 rc = CPUMR3DisasmInstrCPU(pVM, pVCpu, pCtx, pCurPatchInstrGC, &CpuOld, 0); 5844 5846 if ( RT_FAILURE(rc) 5845 5847 || !(CpuOld.pCurInstr->optype & OPTYPE_HARMLESS)) … … 5856 5858 char szBuf[256]; 5857 5859 szBuf[0] = '\0'; 5858 DBGFR3DisasInstr(pVM, p Ctx->cs, pCurPatchInstrGC, szBuf, sizeof(szBuf));5860 DBGFR3DisasInstr(pVM, pVCpu, pCtx->cs, pCurPatchInstrGC, szBuf, sizeof(szBuf)); 5859 5861 Log(("DIRTY: %s\n", szBuf)); 5860 5862 #endif … … 5891 5893 bool fValidInstr; 5892 5894 5893 rc = CPUMR3DisasmInstrCPU(pVM, p Ctx, pCurInstrGC, &CpuNew, 0);5895 rc = CPUMR3DisasmInstrCPU(pVM, pVCpu, pCtx, pCurInstrGC, &CpuNew, 0); 5894 5896 5895 5897 fValidInstr = !!(CpuNew.pCurInstr->optype & OPTYPE_HARMLESS); … … 5918 5920 char szBuf[256]; 5919 5921 szBuf[0] = '\0'; 5920 DBGFR3DisasInstr(pVM, p Ctx->cs, pCurInstrGC, szBuf, sizeof(szBuf));5922 DBGFR3DisasInstr(pVM, pVCpu, pCtx->cs, pCurInstrGC, szBuf, sizeof(szBuf)); 5921 5923 Log(("NEW: %s\n", szBuf)); 5922 5924 #endif 5923 5925 5924 5926 /* Copy the new instruction. */ 5925 rc = PGMPhysSimpleReadGCPtr( pVM, pCurPatchInstrHC, pCurInstrGC, CpuNew.opsize);5927 rc = PGMPhysSimpleReadGCPtr(VMMGetCpu0(pVM), pCurPatchInstrHC, pCurInstrGC, CpuNew.opsize); 5926 5928 AssertRC(rc); 5927 5929 … … 5934 5936 char szBuf[256]; 5935 5937 szBuf[0] = '\0'; 5936 DBGFR3DisasInstr(pVM, p Ctx->cs, pCurInstrGC, szBuf, sizeof(szBuf));5938 DBGFR3DisasInstr(pVM, pVCpu, pCtx->cs, pCurInstrGC, szBuf, sizeof(szBuf)); 5937 5939 Log(("NEW: %s (FAILED)\n", szBuf)); 5938 5940 #endif … … 5998 6000 int rc ; 5999 6001 PRECPATCHTOGUEST pPatchToGuestRec = 0; 6002 PVMCPU pVCpu = VMMGetCpu0(pVM); 6003 6004 Assert(pVM->cCPUs == 1); 6000 6005 6001 6006 pNewEip = 0; … … 6058 6063 { 6059 6064 DISCPUSTATE Cpu; 6060 rc = CPUMR3DisasmInstrCPU(pVM, p Ctx, pEip, &Cpu, "PIF Trap: ");6065 rc = CPUMR3DisasmInstrCPU(pVM, pVCpu, pCtx, pEip, &Cpu, "PIF Trap: "); 6061 6066 AssertRC(rc); 6062 6067 … … 6073 6078 if (Cpu.pCurInstr->opcode == OP_PUSH) 6074 6079 { 6075 rc = PGMShwGetPage(pVM, p Ctx->esp, &fFlags, NULL);6080 rc = PGMShwGetPage(pVM, pVCpu, pCtx->esp, &fFlags, NULL); 6076 6081 if ( rc == VINF_SUCCESS 6077 6082 && ((fFlags & (X86_PTE_P|X86_PTE_RW)) == (X86_PTE_P|X86_PTE_RW)) ) … … 6094 6099 6095 6100 /* Typical pushf (most patches)/push (call patch) trap because of a monitored page. */ 6096 rc = PGMShwModifyPage(pVM, p Ctx->esp, 1, X86_PTE_RW, ~(uint64_t)X86_PTE_RW);6101 rc = PGMShwModifyPage(pVM, pVCpu, pCtx->esp, 1, X86_PTE_RW, ~(uint64_t)X86_PTE_RW); 6097 6102 AssertMsgRC(rc, ("PGMShwModifyPage -> rc=%Rrc\n", rc)); 6098 6103 if (rc == VINF_SUCCESS) … … 6100 6105 6101 6106 /* The guest page *must* be present. */ 6102 rc = PGMGstGetPage(pVM, p Ctx->esp, &fFlags, NULL);6107 rc = PGMGstGetPage(pVM, pVCpu, pCtx->esp, &fFlags, NULL); 6103 6108 if (rc == VINF_SUCCESS && (fFlags & X86_PTE_P)) 6104 6109 { … … 6129 6134 char szBuf[256]; 6130 6135 szBuf[0] = '\0'; 6131 DBGFR3DisasInstr(pVM, p Ctx->cs, pEip, szBuf, sizeof(szBuf));6136 DBGFR3DisasInstr(pVM, pVCpu, pCtx->cs, pEip, szBuf, sizeof(szBuf)); 6132 6137 6133 6138 /* Very bad. We crashed in emitted code. Probably stack? */ … … 6135 6140 { 6136 6141 AssertReleaseMsg(pVM->patm.s.pGCStateHC->fPIF == 1, 6137 ("Crash in patch code %RRv (%RRv) esp=%RX32\nPatch state=%x flags=%x fDirty=%d\n%s\n", pEip, pNewEip, CPUMGetGuestESP(pV M), pPatch->patch.uState, pPatch->patch.flags, pPatchToGuestRec->fDirty, szBuf));6142 ("Crash in patch code %RRv (%RRv) esp=%RX32\nPatch state=%x flags=%x fDirty=%d\n%s\n", pEip, pNewEip, CPUMGetGuestESP(pVCpu), pPatch->patch.uState, pPatch->patch.flags, pPatchToGuestRec->fDirty, szBuf)); 6138 6143 } 6139 6144 else 6140 6145 AssertReleaseMsg(pVM->patm.s.pGCStateHC->fPIF == 1, 6141 ("Crash in patch code %RRv (%RRv) esp=%RX32\n%s\n", pEip, pNewEip, CPUMGetGuestESP(pV M), szBuf));6142 EMR3FatalError(pV M, VERR_INTERNAL_ERROR);6146 ("Crash in patch code %RRv (%RRv) esp=%RX32\n%s\n", pEip, pNewEip, CPUMGetGuestESP(pVCpu), szBuf)); 6147 EMR3FatalError(pVCpu, VERR_INTERNAL_ERROR); 6143 6148 } 6144 6149 … … 6191 6196 PCPUMCTX pCtx; 6192 6197 6193 pCtx = CPUMQueryGuestCtxPtr(pV M);6194 6195 rc = PGMPhysSimpleReadGCPtr(pV M,&retaddr, pCtx->esp, sizeof(retaddr));6198 pCtx = CPUMQueryGuestCtxPtr(pVCpu); 6199 6200 rc = PGMPhysSimpleReadGCPtr(pVCpu, &retaddr, pCtx->esp, sizeof(retaddr)); 6196 6201 AssertRC(rc); 6197 6202 … … 6228 6233 } 6229 6234 #endif 6230 EMSetInhibitInterruptsPC(pVM, p NewEip);6235 EMSetInhibitInterruptsPC(pVM, pVCpu, pNewEip); 6231 6236 pVM->patm.s.pGCStateHC->GCPtrInhibitInterrupts = 0; 6232 6237 } … … 6234 6239 Log2(("pPatchBlockGC %RRv - pEip %RRv corresponding GC address %RRv\n", PATCHCODE_PTR_GC(&pPatch->patch), pEip, pNewEip)); 6235 6240 #ifdef LOG_ENABLED 6236 CPUMR3DisasmInstr(pVM, p Ctx, pNewEip, "PATCHRET: ");6241 CPUMR3DisasmInstr(pVM, pVCpu, pCtx, pNewEip, "PATCHRET: "); 6237 6242 #endif 6238 6243 if (pNewEip >= pPatch->patch.pPrivInstrGC && pNewEip < pPatch->patch.pPrivInstrGC + pPatch->patch.cbPatchJump) -
trunk/src/VBox/VMM/PATM/PATMGuest.cpp
r13835 r18927 99 99 int PATMPatchSysenterXP(PVM pVM, RTGCPTR32 pInstrGC, PPATMPATCHREC pPatchRec) 100 100 { 101 PPATCHINFO pPatch = &pPatchRec->patch;102 uint8_t uTemp[16];101 PPATCHINFO pPatch = &pPatchRec->patch; 102 uint8_t uTemp[16]; 103 103 RTGCPTR32 lpfnKiFastSystemCall, lpfnKiIntSystemCall = 0; /* (initializing it to shut up warning.) */ 104 int rc, i; 104 int rc, i; 105 PVMCPU pVCpu = VMMGetCpu0(pVM); 105 106 106 107 Assert(sizeof(uTemp) > sizeof(uFnKiIntSystemCall)); … … 111 112 /* check the epilog of KiFastSystemCall */ 112 113 lpfnKiFastSystemCall = pInstrGC - 2; 113 rc = PGMPhysSimpleReadGCPtr(pV M, uTemp, lpfnKiFastSystemCall, sizeof(uFnKiFastSystemCall));114 rc = PGMPhysSimpleReadGCPtr(pVCpu, uTemp, lpfnKiFastSystemCall, sizeof(uFnKiFastSystemCall)); 114 115 if ( RT_FAILURE(rc) 115 116 || memcmp(uFnKiFastSystemCall, uTemp, sizeof(uFnKiFastSystemCall))) … … 121 122 for (i=0;i<64;i++) 122 123 { 123 rc = PGMPhysSimpleReadGCPtr(pV M, uTemp, pInstrGC + i, sizeof(uFnKiIntSystemCall));124 rc = PGMPhysSimpleReadGCPtr(pVCpu, uTemp, pInstrGC + i, sizeof(uFnKiIntSystemCall)); 124 125 if(RT_FAILURE(rc)) 125 126 { … … 146 147 147 148 // make a copy of the guest code bytes that will be overwritten 148 rc = PGMPhysSimpleReadGCPtr(pV M, pPatch->aPrivInstr, pPatch->pPrivInstrGC, SIZEOF_NEARJUMP32);149 rc = PGMPhysSimpleReadGCPtr(pVCpu, pPatch->aPrivInstr, pPatch->pPrivInstrGC, SIZEOF_NEARJUMP32); 149 150 AssertRC(rc); 150 151 … … 152 153 uTemp[0] = 0xE9; 153 154 *(RTGCPTR32 *)&uTemp[1] = lpfnKiIntSystemCall - (pInstrGC + SIZEOF_NEARJUMP32); 154 rc = PGMPhysSimpleDirtyWriteGCPtr(pV M, pInstrGC, uTemp, SIZEOF_NEARJUMP32);155 rc = PGMPhysSimpleDirtyWriteGCPtr(pVCpu, pInstrGC, uTemp, SIZEOF_NEARJUMP32); 155 156 if (RT_FAILURE(rc)) 156 157 { … … 189 190 /* Guest OS specific patch; check heuristics first */ 190 191 191 rc = PGMPhysSimpleReadGCPtr( pVM, uTemp, pInstrGC, RT_MAX(sizeof(uFnOpenBSDHandlerPrefix1), sizeof(uFnOpenBSDHandlerPrefix2)));192 rc = PGMPhysSimpleReadGCPtr(VMMGetCpu0(pVM), uTemp, pInstrGC, RT_MAX(sizeof(uFnOpenBSDHandlerPrefix1), sizeof(uFnOpenBSDHandlerPrefix2))); 192 193 if ( RT_FAILURE(rc) 193 194 || ( memcmp(uFnOpenBSDHandlerPrefix1, uTemp, sizeof(uFnOpenBSDHandlerPrefix1)) -
trunk/src/VBox/VMM/PATM/PATMInternal.h
r13832 r18927 704 704 { 705 705 PATMDISASM disinfo; 706 disinfo.pVM = pVM;707 disinfo.pPatchInfo = pPatch;708 disinfo.pInstrHC = InstrHC;709 disinfo.pInstrGC = InstrGC;710 disinfo.fReadFlags = fReadFlags;711 (pCpu)->pfnReadBytes 706 disinfo.pVM = pVM; 707 disinfo.pPatchInfo = pPatch; 708 disinfo.pInstrHC = InstrHC; 709 disinfo.pInstrGC = InstrGC; 710 disinfo.fReadFlags = fReadFlags; 711 (pCpu)->pfnReadBytes = patmReadBytes; 712 712 (pCpu)->apvUserData[0] = &disinfo; 713 713 return RT_SUCCESS(DISInstr(pCpu, InstrGC, 0, pOpsize, pszOutput)); -
trunk/src/VBox/VMM/PATM/PATMPatch.cpp
r13830 r18927 404 404 static int patmPatchReadBytes(PVM pVM, uint8_t *pDest, RTRCPTR pSrc, uint32_t cb) 405 405 { 406 int rc = PGMPhysSimpleReadGCPtr( pVM, pDest, pSrc, cb);406 int rc = PGMPhysSimpleReadGCPtr(&pVM->aCpus[0], pDest, pSrc, cb); 407 407 AssertRCReturn(rc, rc); 408 408 /* -
trunk/src/VBox/VMM/PATM/PATMSSM.cpp
r18272 r18927 583 583 pPatchRec->patch.pPrivInstrHC = 0; 584 584 /* The GC virtual ptr is fixed, but we must convert it manually again to HC. */ 585 int rc2 = rc = PGMPhysGCPtr2R3Ptr( pVM, pPatchRec->patch.pPrivInstrGC, (PRTR3PTR)&pPatchRec->patch.pPrivInstrHC);585 int rc2 = rc = PGMPhysGCPtr2R3Ptr(VMMGetCpu0(pVM), pPatchRec->patch.pPrivInstrGC, (PRTR3PTR)&pPatchRec->patch.pPrivInstrHC); 586 586 /* Can fail due to page or page table not present. */ 587 587 … … 961 961 * Read old patch jump and compare it to the one we previously installed 962 962 */ 963 int rc = PGMPhysSimpleReadGCPtr( pVM, temp, pPatch->pPrivInstrGC, pPatch->cbPatchJump);963 int rc = PGMPhysSimpleReadGCPtr(VMMGetCpu0(pVM), temp, pPatch->pPrivInstrGC, pPatch->cbPatchJump); 964 964 Assert(RT_SUCCESS(rc) || rc == VERR_PAGE_NOT_PRESENT || rc == VERR_PAGE_TABLE_NOT_PRESENT); 965 965 … … 984 984 if (RT_SUCCESS(rc)) 985 985 { 986 rc = PGMPhysSimpleDirtyWriteGCPtr( pVM, pJumpOffGC, &displ, sizeof(displ));986 rc = PGMPhysSimpleDirtyWriteGCPtr(VMMGetCpu0(pVM), pJumpOffGC, &displ, sizeof(displ)); 987 987 AssertRC(rc); 988 988 } -
trunk/src/VBox/VMM/PATM/VMMAll/PATMAll.cpp
r13832 r18927 34 34 #include "PATMInternal.h" 35 35 #include <VBox/vm.h> 36 #include <VBox/vmm.h> 36 37 #include "PATMA.h" 37 38 … … 190 191 if (CTXSUFF(pVM->patm.s.pGCState)->GCPtrInhibitInterrupts == (RTRCPTR)pCtxCore->eip) 191 192 { 192 EMSetInhibitInterruptsPC(pVM, pCtxCore->eip);193 EMSetInhibitInterruptsPC(pVM, VMMGetCpu0(pVM), pCtxCore->eip); 193 194 } 194 195 CTXSUFF(pVM->patm.s.pGCState)->GCPtrInhibitInterrupts = 0; … … 298 299 VMMDECL(bool) PATMAreInterruptsEnabled(PVM pVM) 299 300 { 300 PCPUMCTX pCtx = CPUMQueryGuestCtxPtr( pVM);301 PCPUMCTX pCtx = CPUMQueryGuestCtxPtr(VMMGetCpu0(pVM)); 301 302 302 303 return PATMAreInterruptsEnabledByCtxCore(pVM, CPUMCTX2CORE(pCtx)); … … 382 383 VMMDECL(int) PATMSysCall(PVM pVM, PCPUMCTXCORE pRegFrame, PDISCPUSTATE pCpu) 383 384 { 384 PCPUMCTX pCtx = CPUMQueryGuestCtxPtr( pVM);385 PCPUMCTX pCtx = CPUMQueryGuestCtxPtr(VMMGetCpu0(pVM)); 385 386 386 387 if (pCpu->pCurInstr->opcode == OP_SYSENTER) -
trunk/src/VBox/VMM/PATM/VMMGC/CSAMGC.cpp
r14029 r18927 67 67 bool fPatchCode = PATMIsPatchGCAddr(pVM, (RTRCPTR)pRegFrame->eip); 68 68 int rc; 69 PVMCPU pVCpu = VMMGetCpu0(pVM); 69 70 70 71 Assert(pVM->csam.s.cDirtyPages < CSAM_MAX_DIRTY_PAGES); … … 87 88 * Make this particular page R/W. 88 89 */ 89 int rc = PGMShwModifyPage(pVM, p vFault, 1, X86_PTE_RW, ~(uint64_t)X86_PTE_RW);90 int rc = PGMShwModifyPage(pVM, pVCpu, pvFault, 1, X86_PTE_RW, ~(uint64_t)X86_PTE_RW); 90 91 AssertMsgRC(rc, ("PGMShwModifyPage -> rc=%Rrc\n", rc)); 91 92 ASMInvalidatePage((void *)pvFault); … … 128 129 */ 129 130 Log(("CSAMGCCodePageWriteHandler: enabled r/w for page %RGv\n", pvFault)); 130 rc = PGMShwModifyPage(pVM, p vFault, 1, X86_PTE_RW, ~(uint64_t)X86_PTE_RW);131 rc = PGMShwModifyPage(pVM, pVCpu, pvFault, 1, X86_PTE_RW, ~(uint64_t)X86_PTE_RW); 131 132 AssertMsgRC(rc, ("PGMShwModifyPage -> rc=%Rrc\n", rc)); 132 133 ASMInvalidatePage((void *)pvFault); -
trunk/src/VBox/VMM/PATM/VMMGC/PATMGC.cpp
r14029 r18927 117 117 118 118 LogFlow(("PATMHandleWriteToPatchPage: Interpret %x accessing %RRv\n", pRegFrame->eip, GCPtr)); 119 int rc = EMInterpretInstruction(pVM, pRegFrame, (RTGCPTR)(RTRCUINTPTR)GCPtr, &cb);119 int rc = EMInterpretInstruction(pVM, VMMGetCpu0(pVM), pRegFrame, (RTGCPTR)(RTRCUINTPTR)GCPtr, &cb); 120 120 if (rc == VINF_SUCCESS) 121 121 { … … 281 281 pVM->patm.s.CTXSUFF(pGCState)->Restore.uFlags = 0; 282 282 283 rc = EMInterpretIret(pVM, pRegFrame);283 rc = EMInterpretIret(pVM, VMMGetCpu0(pVM), pRegFrame); 284 284 if (RT_SUCCESS(rc)) 285 285 { … … 517 517 } 518 518 519 rc = EMInterpretInstructionCPU(pVM, &cpu, pRegFrame, 0 /* not relevant here */, &size);519 rc = EMInterpretInstructionCPU(pVM, VMMGetCpu0(pVM), &cpu, pRegFrame, 0 /* not relevant here */, &size); 520 520 if (rc != VINF_SUCCESS) 521 521 {
Note:
See TracChangeset
for help on using the changeset viewer.