VirtualBox

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


Ignore:
Timestamp:
Apr 16, 2009 11:41:38 AM (16 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
46003
Message:

Big step to separate VMM data structures for guest SMP. (pgm, em)

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/PATM/CSAM.cpp

    r16552 r18927  
    562562    int rc;
    563563    R3PTRTYPE(void *) pHCPtr;
     564    Assert(pVM->cCPUs == 1);
     565    PVMCPU pVCpu = VMMGetCpu0(pVM);
    564566
    565567    STAM_PROFILE_START(&pVM->csam.s.StatTimeAddrConv, a);
     
    578580    }
    579581
    580     rc = PGMPhysGCPtr2R3Ptr(pVM, pGCPtr, &pHCPtr);
     582    rc = PGMPhysGCPtr2R3Ptr(pVCpu, pGCPtr, &pHCPtr);
    581583    if (rc != VINF_SUCCESS)
    582584    {
     
    585587        return NULL;
    586588    }
    587 ////invalid?    Assert(sizeof(R3PTRTYPE(uint8_t*)) == sizeof(uint32_t));
    588589
    589590    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;
    591592    STAM_PROFILE_STOP(&pVM->csam.s.StatTimeAddrConv, a);
    592593    return pHCPtr;
     
    608609    PVM           pVM      = (PVM)pCpu->apvUserData[0];
    609610    RTHCUINTPTR   pInstrHC = (RTHCUINTPTR)pCpu->apvUserData[1];
    610     RTGCUINTPTR32   pInstrGC = (uintptr_t)pCpu->apvUserData[2];
     611    RTGCUINTPTR32 pInstrGC = (uintptr_t)pCpu->apvUserData[2];
    611612    int           orgsize  = size;
     613    Assert(pVM->cCPUs == 1);
     614    PVMCPU        pVCpu = VMMGetCpu0(pVM);
    612615
    613616    /* We are not interested in patched instructions, so read the original opcode bytes. */
     
    630633    if (PAGE_ADDRESS(pInstrGC) != PAGE_ADDRESS(pSrc + size - 1) && !PATMIsPatchGCAddr(pVM, pSrc))
    631634    {
    632         return PGMPhysSimpleReadGCPtr(pVM, pDest, pSrc, size);
     635        return PGMPhysSimpleReadGCPtr(pVCpu, pDest, pSrc, size);
    633636    }
    634637    else
     
    10801083    R3PTRTYPE(uint8_t *) pCurInstrHC = 0;
    10811084    int rc2;
     1085    Assert(pVM->cCPUs == 1);
     1086    PVMCPU pVCpu = VMMGetCpu0(pVM);
    10821087
    10831088#ifdef DEBUG
     
    11621167        if (PAGE_ADDRESS(pCurInstrGC) != PAGE_ADDRESS(pCurInstrGC + opsize - 1))
    11631168        {
    1164             if (!PGMGstIsPagePresent(pVM, pCurInstrGC + opsize - 1))
     1169            if (!PGMGstIsPagePresent(pVM, pVCpu, pCurInstrGC + opsize - 1))
    11651170            {
    11661171                /// @todo fault in the page
     
    12061211            {
    12071212                addr = 0;
    1208                 PGMPhysSimpleReadGCPtr(pVM, &addr, (RTRCUINTPTR)cpu.param1.disp32, sizeof(addr));
     1213                PGMPhysSimpleReadGCPtr(pVCpu, &addr, (RTRCUINTPTR)cpu.param1.disp32, sizeof(addr));
    12091214            }
    12101215            else
     
    12251230            if (PAGE_ADDRESS(addr) != PAGE_ADDRESS(pCurInstrGC ))
    12261231            {
    1227                 if (!PGMGstIsPagePresent(pVM, addr))
     1232                if (!PGMGstIsPagePresent(pVM, pVCpu, addr))
    12281233                {
    12291234                    Log(("Page for current instruction %RRv is not present!!\n", addr));
     
    12791284            Log(("Jump through jump table\n"));
    12801285
    1281             rc2 = PGMPhysGCPtr2R3Ptr(pVM, pJumpTableGC, (PRTHCPTR)&pJumpTableHC);
     1286            rc2 = PGMPhysGCPtr2R3Ptr(pVCpu, pJumpTableGC, (PRTHCPTR)&pJumpTableHC);
    12821287            if (rc2 == VINF_SUCCESS)
    12831288            {
     
    12931298                    addr = *(RTRCPTR *)(pJumpTableHC + cpu.param1.scale * i);
    12941299
    1295                     rc2 = PGMGstGetPage(pVM, addr, &fFlags, NULL);
     1300                    rc2 = PGMGstGetPage(pVM, pVCpu, addr, &fFlags, NULL);
    12961301                    if (    rc2 != VINF_SUCCESS
    12971302                        ||  (fFlags & X86_PTE_US)
     
    13541359    uint32_t val[5];
    13551360    int      rc;
     1361    Assert(pVM->cCPUs == 1);
     1362    PVMCPU pVCpu = VMMGetCpu0(pVM);
    13561363
    13571364    Assert((pInstr & PAGE_OFFSET_MASK) == 0);
    13581365
    1359     rc = PGMPhysSimpleReadGCPtr(pVM, &val[0], pInstr, sizeof(val[0]));
     1366    rc = PGMPhysSimpleReadGCPtr(pVCpu, &val[0], pInstr, sizeof(val[0]));
    13601367    AssertMsg(RT_SUCCESS(rc) || rc == VERR_PAGE_NOT_PRESENT || rc == VERR_PAGE_TABLE_NOT_PRESENT, ("rc = %Rrc\n", rc));
    13611368    if (rc == VERR_PAGE_NOT_PRESENT || rc == VERR_PAGE_TABLE_NOT_PRESENT)
     
    13651372    }
    13661373
    1367     rc = PGMPhysSimpleReadGCPtr(pVM, &val[1], pInstr+1024, sizeof(val[0]));
     1374    rc = PGMPhysSimpleReadGCPtr(pVCpu, &val[1], pInstr+1024, sizeof(val[0]));
    13681375    AssertMsg(RT_SUCCESS(rc) || rc == VERR_PAGE_NOT_PRESENT || rc == VERR_PAGE_TABLE_NOT_PRESENT, ("rc = %Rrc\n", rc));
    13691376    if (rc == VERR_PAGE_NOT_PRESENT || rc == VERR_PAGE_TABLE_NOT_PRESENT)
     
    13731380    }
    13741381
    1375     rc = PGMPhysSimpleReadGCPtr(pVM, &val[2], pInstr+2048, sizeof(val[0]));
     1382    rc = PGMPhysSimpleReadGCPtr(pVCpu, &val[2], pInstr+2048, sizeof(val[0]));
    13761383    AssertMsg(RT_SUCCESS(rc) || rc == VERR_PAGE_NOT_PRESENT || rc == VERR_PAGE_TABLE_NOT_PRESENT, ("rc = %Rrc\n", rc));
    13771384    if (rc == VERR_PAGE_NOT_PRESENT || rc == VERR_PAGE_TABLE_NOT_PRESENT)
     
    13811388    }
    13821389
    1383     rc = PGMPhysSimpleReadGCPtr(pVM, &val[3], pInstr+3072, sizeof(val[0]));
     1390    rc = PGMPhysSimpleReadGCPtr(pVCpu, &val[3], pInstr+3072, sizeof(val[0]));
    13841391    AssertMsg(RT_SUCCESS(rc) || rc == VERR_PAGE_NOT_PRESENT || rc == VERR_PAGE_TABLE_NOT_PRESENT, ("rc = %Rrc\n", rc));
    13851392    if (rc == VERR_PAGE_NOT_PRESENT || rc == VERR_PAGE_TABLE_NOT_PRESENT)
     
    13891396    }
    13901397
    1391     rc = PGMPhysSimpleReadGCPtr(pVM, &val[4], pInstr+4092, sizeof(val[0]));
     1398    rc = PGMPhysSimpleReadGCPtr(pVCpu, &val[4], pInstr+4092, sizeof(val[0]));
    13921399    AssertMsg(RT_SUCCESS(rc) || rc == VERR_PAGE_NOT_PRESENT || rc == VERR_PAGE_TABLE_NOT_PRESENT, ("rc = %Rrc\n", rc));
    13931400    if (rc == VERR_PAGE_NOT_PRESENT || rc == VERR_PAGE_TABLE_NOT_PRESENT)
     
    14201427    RTGCPHYS GCPhys = 0;
    14211428    uint64_t fFlags = 0;
     1429    Assert(pVM->cCPUs == 1);
     1430    PVMCPU pVCpu = VMMGetCpu0(pVM);
    14221431
    14231432    if (!CSAMIsEnabled(pVM))
     
    14371446    }
    14381447
    1439     rc = PGMGstGetPage(pVM, addr, &fFlags, &GCPhys);
     1448    rc = PGMGstGetPage(pVM, pVCpu, addr, &fFlags, &GCPhys);
    14401449    /* Returned at a very early stage (no paging yet presumably). */
    14411450    if (rc == VERR_NOT_SUPPORTED)
     
    14831492            pPageRec->page.GCPhys = 0;
    14841493            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);
    14861495            if (rc == VINF_SUCCESS)
    14871496                pPageRec->page.u64Hash = csamR3CalcPageHash(pVM, addr);
     
    16101619    int          rc;
    16111620    bool         ret;
     1621    Assert(pVM->cCPUs == 1);
     1622    PVMCPU pVCpu = VMMGetCpu0(pVM);
    16121623
    16131624    Log(("New page record for %RRv\n", GCPtr & PAGE_BASE_GC_MASK));
     
    16281639    pPage->page.fMonitorActive       = false;
    16291640    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);
    16311642    AssertMsg(RT_SUCCESS(rc) || rc == VERR_PAGE_NOT_PRESENT || rc == VERR_PAGE_TABLE_NOT_PRESENT, ("rc = %Rrc\n", rc));
    16321643
     
    16561667
    16571668        /* Prefetch it in case it's not there yet. */
    1658         rc = PGMPrefetchPage(pVM, GCPtr);
     1669        rc = PGMPrefetchPage(pVM, pVCpu, GCPtr);
    16591670        AssertRC(rc);
    16601671
    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);
    16621673        Assert(rc == VINF_SUCCESS || rc == VERR_PAGE_NOT_PRESENT || rc == VERR_PAGE_TABLE_NOT_PRESENT);
    16631674
     
    17111722    int          rc;
    17121723    bool         fMonitorInvalidation;
     1724    Assert(pVM->cCPUs == 1);
     1725    PVMCPU pVCpu = VMMGetCpu0(pVM);
    17131726
    17141727    /* Dirty pages must be handled before calling this function!. */
     
    17301743        uint64_t fFlags;
    17311744
    1732         rc = PGMGstGetPage(pVM, pPageAddrGC, &fFlags, NULL);
     1745        rc = PGMGstGetPage(pVM, pVCpu, pPageAddrGC, &fFlags, NULL);
    17331746        AssertMsg(RT_SUCCESS(rc) || rc == VERR_PAGE_NOT_PRESENT || rc == VERR_PAGE_TABLE_NOT_PRESENT, ("rc = %Rrc\n", rc));
    17341747        if (    rc == VINF_SUCCESS
     
    17661779
    17671780        /* Prefetch it in case it's not there yet. */
    1768         rc = PGMPrefetchPage(pVM, pPageAddrGC);
     1781        rc = PGMPrefetchPage(pVM, pVCpu, pPageAddrGC);
    17691782        AssertRC(rc);
    17701783
    1771         rc = PGMShwModifyPage(pVM, pPageAddrGC, 1, 0, ~(uint64_t)X86_PTE_RW);
     1784        rc = PGMShwModifyPage(pVM, pVCpu, pPageAddrGC, 1, 0, ~(uint64_t)X86_PTE_RW);
    17721785        Assert(rc == VINF_SUCCESS || rc == VERR_PAGE_NOT_PRESENT || rc == VERR_PAGE_TABLE_NOT_PRESENT);
    17731786
     
    17871800
    17881801        /* Prefetch it in case it's not there yet. */
    1789         rc = PGMPrefetchPage(pVM, pPageAddrGC);
     1802        rc = PGMPrefetchPage(pVM, pVCpu, pPageAddrGC);
    17901803        AssertRC(rc);
    17911804
    17921805        /* Make sure it's readonly. Page invalidation may have modified the attributes. */
    1793         rc = PGMShwModifyPage(pVM, pPageAddrGC, 1, 0, ~(uint64_t)X86_PTE_RW);
     1806        rc = PGMShwModifyPage(pVM, pVCpu, pPageAddrGC, 1, 0, ~(uint64_t)X86_PTE_RW);
    17941807        Assert(rc == VINF_SUCCESS || rc == VERR_PAGE_NOT_PRESENT || rc == VERR_PAGE_TABLE_NOT_PRESENT);
    17951808    }
     
    18001813        uint64_t fPageShw;
    18011814        RTHCPHYS GCPhys;
    1802         rc = PGMShwGetPage(pVM, pPageAddrGC, &fPageShw, &GCPhys);
     1815        rc = PGMShwGetPage(pVM, pVCpu, pPageAddrGC, &fPageShw, &GCPhys);
    18031816//        AssertMsg(     (rc == VERR_PAGE_NOT_PRESENT || rc == VERR_PAGE_TABLE_NOT_PRESENT)
    18041817//                ||  !(fPageShw & X86_PTE_RW)
     
    18101823    {
    18111824        /* Prefetch it in case it's not there yet. */
    1812         rc = PGMPrefetchPage(pVM, pPageAddrGC);
     1825        rc = PGMPrefetchPage(pVM, pVCpu, pPageAddrGC);
    18131826        AssertRC(rc);
    18141827        /* 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, pPageAddrGC, 1, 0, ~(uint64_t)X86_PTE_RW);
     1828        rc = PGMShwModifyPage(pVM, pVCpu, pPageAddrGC, 1, 0, ~(uint64_t)X86_PTE_RW);
    18161829        Assert(rc == VINF_SUCCESS || rc == VERR_PAGE_NOT_PRESENT || rc == VERR_PAGE_TABLE_NOT_PRESENT);
    18171830    }
     
    18551868{
    18561869    PCSAMPAGEREC pPageRec;
     1870    Assert(pVM->cCPUs == 1);
     1871    PVMCPU pVCpu = VMMGetCpu0(pVM);
    18571872
    18581873    Log(("csamRemovePageRecord %RRv\n", GCPtr));
     
    18771892            /* Make sure the recompiler flushes its cache as this page is no longer monitored. */
    18781893            STAM_COUNTER_INC(&pVM->csam.s.StatPageRemoveREMFlush);
    1879             CPUMSetChangedFlags(pVM, CPUM_CHANGED_GLOBAL_TLB_FLUSH);
     1894            CPUMSetChangedFlags(pVCpu, CPUM_CHANGED_GLOBAL_TLB_FLUSH);
    18801895        }
    18811896#endif
     
    21742189static int csamR3FlushDirtyPages(PVM pVM)
    21752190{
     2191    Assert(pVM->cCPUs == 1);
     2192    PVMCPU pVCpu = VMMGetCpu0(pVM);
     2193
    21762194    STAM_PROFILE_START(&pVM->csam.s.StatFlushDirtyPages, a);
    21772195
     
    21852203
    21862204        /* Notify the recompiler that this page has been changed. */
    2187         REMR3NotifyCodePageChanged(pVM, GCPtr);
     2205        REMR3NotifyCodePageChanged(pVM, pVCpu, GCPtr);
    21882206
    21892207        /* Enable write protection again. (use the fault address as it might be an alias) */
    2190         rc = PGMShwModifyPage(pVM, pVM->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);
    21912209        Assert(rc == VINF_SUCCESS || rc == VERR_PAGE_NOT_PRESENT || rc == VERR_PAGE_TABLE_NOT_PRESENT);
    21922210
     
    21982216            uint64_t fFlags;
    21992217
    2200             rc = PGMGstGetPage(pVM, GCPtr, &fFlags, NULL);
     2218            rc = PGMGstGetPage(pVM, pVCpu, GCPtr, &fFlags, NULL);
    22012219            AssertMsg(RT_SUCCESS(rc) || rc == VERR_PAGE_NOT_PRESENT || rc == VERR_PAGE_TABLE_NOT_PRESENT, ("rc = %Rrc\n", rc));
    22022220            if (    rc == VINF_SUCCESS
     
    22222240static int csamR3FlushCodePages(PVM pVM)
    22232241{
     2242    Assert(pVM->cCPUs == 1);
     2243    PVMCPU pVCpu = VMMGetCpu0(pVM);
     2244
    22242245    for (uint32_t i=0;i<pVM->csam.s.cPossibleCodePages;i++)
    22252246    {
    2226         RTRCPTR      GCPtr = pVM->csam.s.pvPossibleCodePage[i];
     2247        RTRCPTR GCPtr = pVM->csam.s.pvPossibleCodePage[i];
    22272248
    22282249        GCPtr = GCPtr & PAGE_BASE_GC_MASK;
    22292250
    22302251        Log(("csamR3FlushCodePages: %RRv\n", GCPtr));
    2231         PGMShwSetPage(pVM, GCPtr, 1, 0);
     2252        PGMShwSetPage(pVM, pVCpu, GCPtr, 1, 0);
    22322253        /* Resync the page to make sure instruction fetch will fault */
    22332254        CSAMMarkPage(pVM, GCPtr, false);
     
    22622283VMMR3DECL(int) CSAMR3CheckGates(PVM pVM, uint32_t iGate, uint32_t cGates)
    22632284{
     2285    Assert(pVM->cCPUs == 1);
     2286    PVMCPU      pVCpu = VMMGetCpu0(pVM);
    22642287    uint16_t    cbIDT;
    2265     RTRCPTR     GCPtrIDT = CPUMGetGuestIDTR(pVM, &cbIDT);
     2288    RTRCPTR     GCPtrIDT = CPUMGetGuestIDTR(pVCpu, &cbIDT);
    22662289    uint32_t    iGateEnd;
    22672290    uint32_t    maxGates;
     
    23362359    {
    23372360        /* Just convert the IDT address to a R3 pointer. The whole IDT fits in one page. */
    2338         rc = PGMPhysGCPtr2R3Ptr(pVM, GCPtrIDT, (PRTR3PTR)&pGuestIdte);
     2361        rc = PGMPhysGCPtr2R3Ptr(pVCpu, GCPtrIDT, (PRTR3PTR)&pGuestIdte);
    23392362        if (RT_FAILURE(rc))
    23402363        {
     
    23472370    {
    23482371        /* Slow method when it crosses a page boundary. */
    2349         rc = PGMPhysSimpleReadGCPtr(pVM, aIDT, GCPtrIDT,  cGates*sizeof(VBOXIDTE));
     2372        rc = PGMPhysSimpleReadGCPtr(pVCpu, aIDT, GCPtrIDT,  cGates*sizeof(VBOXIDTE));
    23502373        if (RT_FAILURE(rc))
    23512374        {
     
    23742397            pHandler = SELMToFlatBySel(pVM, pGuestIdte->Gen.u16SegSel, pHandler);
    23752398
    2376             rc = SELMR3GetSelectorInfo(pVM, pGuestIdte->Gen.u16SegSel, &selInfo);
     2399            rc = SELMR3GetSelectorInfo(pVM, pVCpu, pGuestIdte->Gen.u16SegSel, &selInfo);
    23772400            if (    RT_FAILURE(rc)
    23782401                ||  selInfo.GCPtrBase != 0
     
    24122435                                                       0x2F};      /* OpenBSD 4.0 after install */
    24132436
    2414                 pCtx = CPUMQueryGuestCtxPtr(pVM);
     2437                pCtx = CPUMQueryGuestCtxPtr(pVCpu);
    24152438
    24162439                for (unsigned i=0;i<RT_ELEMENTS(aOpenBsdPushCSOffset);i++)
    24172440                {
    2418                     rc = CPUMR3DisasmInstrCPU(pVM, pCtx, pHandler - aOpenBsdPushCSOffset[i], &cpu, NULL);
     2441                    rc = CPUMR3DisasmInstrCPU(pVM, pVCpu, pCtx, pHandler - aOpenBsdPushCSOffset[i], &cpu, NULL);
    24192442                    if (    rc == VINF_SUCCESS
    24202443                        &&  cpu.pCurInstr->opcode == OP_PUSH
  • trunk/src/VBox/VMM/PATM/PATM.cpp

    r15677 r18927  
    346346
    347347    /* 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)));
    349349
    350350    Assert(pVM->patm.s.PatchLookupTreeHC);
     
    426426        RTAvloU32DoWithAll(&pVM->patm.s.PatchLookupTreeHC->PatchTree, true, RelocatePatches, (void *)pVM);
    427427
    428         pCtx = CPUMQueryGuestCtxPtr(pVM);
     428        pCtx = CPUMQueryGuestCtxPtr(VMMGetCpu0(pVM));
    429429
    430430        /* If we are running patch code right now, then also adjust EIP. */
     
    557557    if (PAGE_ADDRESS(pDisInfo->pInstrGC) != PAGE_ADDRESS(pSrc + size - 1) && !PATMIsPatchGCAddr(pDisInfo->pVM, pSrc))
    558558    {
    559         return PGMPhysSimpleReadGCPtr(pDisInfo->pVM, pDest, pSrc, size);
     559        return PGMPhysSimpleReadGCPtr(&pDisInfo->pVM->aCpus[0], pDest, pSrc, size);
    560560    }
    561561    else
     
    604604    {
    605605        /** @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);
    607607        if (rc == VINF_SUCCESS)
    608608        {
     
    651651                *(RTRCPTR *)&oldInstr[pPatch->patch.cbPrivInstr - sizeof(RTRCPTR)] = pRec->pDest;
    652652
    653                 rc = PGMPhysSimpleReadGCPtr(pVM, curInstr, pPatch->patch.pPrivInstrGC, pPatch->patch.cbPrivInstr);
     653                rc = PGMPhysSimpleReadGCPtr(VMMGetCpu0(pVM), curInstr, pPatch->patch.pPrivInstrGC, pPatch->patch.cbPrivInstr);
    654654                Assert(RT_SUCCESS(rc) || rc == VERR_PAGE_NOT_PRESENT || rc == VERR_PAGE_TABLE_NOT_PRESENT);
    655655
     
    678678                {
    679679                    *(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);
    681681                    AssertRC(rc);
    682682                }
     
    728728                 * Read old patch jump and compare it to the one we previously installed
    729729                 */
    730                 rc = PGMPhysSimpleReadGCPtr(pVM, temp, pPatch->patch.pPrivInstrGC, pPatch->patch.cbPatchJump);
     730                rc = PGMPhysSimpleReadGCPtr(VMMGetCpu0(pVM), temp, pPatch->patch.pPrivInstrGC, pPatch->patch.cbPatchJump);
    731731                Assert(RT_SUCCESS(rc) || rc == VERR_PAGE_NOT_PRESENT || rc == VERR_PAGE_TABLE_NOT_PRESENT);
    732732
     
    751751                if (RT_SUCCESS(rc))
    752752                {
    753                     rc = PGMPhysSimpleDirtyWriteGCPtr(pVM, pJumpOffGC, &displ, sizeof(displ));
     753                    rc = PGMPhysSimpleDirtyWriteGCPtr(VMMGetCpu0(pVM), pJumpOffGC, &displ, sizeof(displ));
    754754                    AssertRC(rc);
    755755                }
     
    790790    {
    791791        /** @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);
    793793        if (rc == VINF_SUCCESS)
    794794        {
     
    995995    }
    996996
    997     rc = PGMPhysGCPtr2R3Ptr(pVM, pGCPtr, (void **)&pHCPtr);
     997    rc = PGMPhysGCPtr2R3Ptr(VMMGetCpu0(pVM), pGCPtr, (void **)&pHCPtr);
    998998    if (rc != VINF_SUCCESS)
    999999    {
     
    25292529        *(uint32_t *)&temp[1] = (RTRCUINTPTR)PATCHCODE_PTR_GC(pPatch) - ((RTRCUINTPTR)pPatch->pPrivInstrGC + SIZEOF_NEARJUMP32);    //return address
    25302530    }
    2531     rc = PGMPhysSimpleDirtyWriteGCPtr(pVM, pPatch->pPrivInstrGC, temp, pPatch->cbPatchJump);
     2531    rc = PGMPhysSimpleDirtyWriteGCPtr(VMMGetCpu0(pVM), pPatch->pPrivInstrGC, temp, pPatch->cbPatchJump);
    25322532    AssertRC(rc);
    25332533
     
    25672567
    25682568    /* 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);
    25702570#ifdef DEBUG
    25712571    if (rc == VINF_SUCCESS)
     
    26262626    *(uint32_t *)&temp[1] = (uint32_t)pTargetGC - ((uint32_t)pPatch->pPrivInstrGC + SIZEOF_NEARJUMP32);    //return address
    26272627
    2628     rc = PGMPhysSimpleDirtyWriteGCPtr(pVM, pPatch->pPrivInstrGC, temp, pPatch->cbPatchJump);
     2628    rc = PGMPhysSimpleDirtyWriteGCPtr(VMMGetCpu0(pVM), pPatch->pPrivInstrGC, temp, pPatch->cbPatchJump);
    26292629    AssertRC(rc);
    26302630
     
    27922792    pPatch->cbPatchJump = SIZEOF_NEARJUMP32;
    27932793
    2794     rc = PGMPhysSimpleReadGCPtr(pVM, pPatch->aPrivInstr, pPatch->pPrivInstrGC, pPatch->cbPatchJump);
     2794    rc = PGMPhysSimpleReadGCPtr(VMMGetCpu0(pVM), pPatch->aPrivInstr, pPatch->pPrivInstrGC, pPatch->cbPatchJump);
    27952795    AssertRC(rc);
    27962796
     
    35243524    pPatch->cbPatchJump = SIZEOF_NEARJUMP32;
    35253525
    3526     rc = PGMPhysSimpleReadGCPtr(pVM, pPatch->aPrivInstr, pPatch->pPrivInstrGC, pPatch->cbPatchJump);
     3526    rc = PGMPhysSimpleReadGCPtr(VMMGetCpu0(pVM), pPatch->aPrivInstr, pPatch->pPrivInstrGC, pPatch->cbPatchJump);
    35273527    AssertRC(rc);
    35283528
     
    36003600
    36013601    /* Save original instruction. */
    3602     rc = PGMPhysSimpleReadGCPtr(pVM, pPatch->aPrivInstr, pPatch->pPrivInstrGC, pPatch->cbPrivInstr);
     3602    rc = PGMPhysSimpleReadGCPtr(VMMGetCpu0(pVM), pPatch->aPrivInstr, pPatch->pPrivInstrGC, pPatch->cbPrivInstr);
    36033603    AssertRC(rc);
    36043604
     
    36063606
    36073607    /* 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));
    36093609    AssertRC(rc);
    36103610    if (RT_FAILURE(rc))
     
    37133713
    37143714    /* 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));
    37163716    AssertRC(rc);
    37173717
     
    37373737
    37383738    /* 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));
    37403740    AssertRC(rc);
    37413741    return rc;
     
    37733773
    37743774    /* 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);
    37763776    AssertRC(rc);
    37773777    pPatch->cbPatchJump = sizeof(ASMInt3);  /* bit of a misnomer in this case; size of replacement instruction. */
     
    38773877    pPatch->cbPatchJump = pCpu->opsize;
    38783878
    3879     rc = PGMPhysSimpleReadGCPtr(pVM, pPatch->aPrivInstr, pPatch->pPrivInstrGC, pPatch->cbPatchJump);
     3879    rc = PGMPhysSimpleReadGCPtr(VMMGetCpu0(pVM), pPatch->aPrivInstr, pPatch->pPrivInstrGC, pPatch->cbPatchJump);
    38803880    AssertRC(rc);
    38813881
     
    39593959    bool disret;
    39603960    int rc;
     3961    PVMCPU pVCpu = VMMGetCpu0(pVM);
    39613962
    39623963    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)))
     
    39903991
    39913992    /* Make sure the code selector is wide open; otherwise refuse. */
    3992     pCtx = CPUMQueryGuestCtxPtr(pVM);
    3993     if (CPUMGetGuestCPL(pVM, CPUMCTX2CORE(pCtx)) == 0)
     3993    pCtx = CPUMQueryGuestCtxPtr(pVCpu);
     3994    if (CPUMGetGuestCPL(pVCpu, CPUMCTX2CORE(pCtx)) == 0)
    39943995    {
    39953996        RTRCPTR pInstrGCFlat = SELMToFlat(pVM, DIS_SELREG_CS, CPUMCTX2CORE(pCtx), pInstrGC);
     
    41074108
    41084109    RTGCPHYS GCPhys;
    4109     rc = PGMGstGetPage(pVM, pInstrGC, NULL, &GCPhys);
     4110    rc = PGMGstGetPage(pVM, pVCpu, pInstrGC, NULL, &GCPhys);
    41104111    if (rc != VINF_SUCCESS)
    41114112    {
     
    44024403    uint8_t *pInstrHC;
    44034404
    4404     int rc = PGMPhysGCPtr2R3Ptr(pVM, pInstrGC, (PRTR3PTR)&pInstrHC);
     4405    int rc = PGMPhysGCPtr2R3Ptr(VMMGetCpu0(pVM), pInstrGC, (PRTR3PTR)&pInstrHC);
    44054406    if (rc == VINF_SUCCESS)
    44064407    {
     
    49995000
    50005001                /** 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);
    50025003                if (rc == VINF_SUCCESS)
    50035004                {
     
    50075008
    50085009                    /* 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);
    50105011                    Assert(rc == VINF_SUCCESS || rc == VERR_PAGE_TABLE_NOT_PRESENT || rc == VERR_PAGE_NOT_PRESENT);
    50115012                    if (rc == VINF_SUCCESS)
     
    50495050
    50505051            /* 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);
    50525053            Assert(rc == VINF_SUCCESS || rc == VERR_PAGE_TABLE_NOT_PRESENT || rc == VERR_PAGE_NOT_PRESENT);
    50535054            if (rc == VINF_SUCCESS)
     
    52185219                Assert(!(pPatch->flags & PATMFL_PATCHED_GUEST_CODE));
    52195220                /** @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);
    52215222                if (rc == VINF_SUCCESS)
    52225223                {
     
    52315232
    52325233                    // 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);
    52345235                    AssertRC(rc);
    52355236
     
    52705271
    52715272                /* 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);
    52735274                AssertRC(rc);
    52745275
     
    58175818    uint32_t     cbDirty;
    58185819    PRECPATCHTOGUEST pRec;
     5820    PVMCPU       pVCpu = VMMGetCpu0(pVM);
    58195821
    58205822    Log(("patmR3HandleDirtyInstr: dirty instruction at %RRv (%RRv)\n", pEip, pPatchToGuestRec->pOrgInstrGC));
     
    58415843
    58425844        /* Only harmless instructions are acceptable. */
    5843         rc = CPUMR3DisasmInstrCPU(pVM, pCtx, pCurPatchInstrGC, &CpuOld, 0);
     5845        rc = CPUMR3DisasmInstrCPU(pVM, pVCpu, pCtx, pCurPatchInstrGC, &CpuOld, 0);
    58445846        if (    RT_FAILURE(rc)
    58455847            ||  !(CpuOld.pCurInstr->optype & OPTYPE_HARMLESS))
     
    58565858        char szBuf[256];
    58575859        szBuf[0] = '\0';
    5858         DBGFR3DisasInstr(pVM, pCtx->cs, pCurPatchInstrGC, szBuf, sizeof(szBuf));
     5860        DBGFR3DisasInstr(pVM, pVCpu, pCtx->cs, pCurPatchInstrGC, szBuf, sizeof(szBuf));
    58595861        Log(("DIRTY: %s\n", szBuf));
    58605862#endif
     
    58915893            bool fValidInstr;
    58925894
    5893             rc = CPUMR3DisasmInstrCPU(pVM, pCtx, pCurInstrGC, &CpuNew, 0);
     5895            rc = CPUMR3DisasmInstrCPU(pVM, pVCpu, pCtx, pCurInstrGC, &CpuNew, 0);
    58945896
    58955897            fValidInstr = !!(CpuNew.pCurInstr->optype & OPTYPE_HARMLESS);
     
    59185920                char szBuf[256];
    59195921                szBuf[0] = '\0';
    5920                 DBGFR3DisasInstr(pVM, pCtx->cs, pCurInstrGC, szBuf, sizeof(szBuf));
     5922                DBGFR3DisasInstr(pVM, pVCpu, pCtx->cs, pCurInstrGC, szBuf, sizeof(szBuf));
    59215923                Log(("NEW:   %s\n", szBuf));
    59225924#endif
    59235925
    59245926                /* Copy the new instruction. */
    5925                 rc = PGMPhysSimpleReadGCPtr(pVM, pCurPatchInstrHC, pCurInstrGC, CpuNew.opsize);
     5927                rc = PGMPhysSimpleReadGCPtr(VMMGetCpu0(pVM), pCurPatchInstrHC, pCurInstrGC, CpuNew.opsize);
    59265928                AssertRC(rc);
    59275929
     
    59345936                char szBuf[256];
    59355937                szBuf[0] = '\0';
    5936                 DBGFR3DisasInstr(pVM, pCtx->cs, pCurInstrGC, szBuf, sizeof(szBuf));
     5938                DBGFR3DisasInstr(pVM, pVCpu, pCtx->cs, pCurInstrGC, szBuf, sizeof(szBuf));
    59375939                Log(("NEW:   %s (FAILED)\n", szBuf));
    59385940#endif
     
    59986000    int              rc ;
    59996001    PRECPATCHTOGUEST pPatchToGuestRec = 0;
     6002    PVMCPU           pVCpu = VMMGetCpu0(pVM);
     6003
     6004    Assert(pVM->cCPUs == 1);
    60006005
    60016006    pNewEip   = 0;
     
    60586063    {
    60596064        DISCPUSTATE Cpu;
    6060         rc = CPUMR3DisasmInstrCPU(pVM, pCtx, pEip, &Cpu, "PIF Trap: ");
     6065        rc = CPUMR3DisasmInstrCPU(pVM, pVCpu, pCtx, pEip, &Cpu, "PIF Trap: ");
    60616066        AssertRC(rc);
    60626067
     
    60736078            if (Cpu.pCurInstr->opcode == OP_PUSH)
    60746079            {
    6075                 rc = PGMShwGetPage(pVM, pCtx->esp, &fFlags, NULL);
     6080                rc = PGMShwGetPage(pVM, pVCpu, pCtx->esp, &fFlags, NULL);
    60766081                if (    rc == VINF_SUCCESS
    60776082                    &&  ((fFlags & (X86_PTE_P|X86_PTE_RW)) == (X86_PTE_P|X86_PTE_RW)) )
     
    60946099
    60956100            /* Typical pushf (most patches)/push (call patch) trap because of a monitored page. */
    6096             rc = PGMShwModifyPage(pVM, pCtx->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);
    60976102            AssertMsgRC(rc, ("PGMShwModifyPage -> rc=%Rrc\n", rc));
    60986103            if (rc == VINF_SUCCESS)
     
    61006105
    61016106                /* The guest page *must* be present. */
    6102                 rc = PGMGstGetPage(pVM, pCtx->esp, &fFlags, NULL);
     6107                rc = PGMGstGetPage(pVM, pVCpu, pCtx->esp, &fFlags, NULL);
    61036108                if (rc == VINF_SUCCESS && (fFlags & X86_PTE_P))
    61046109                {
     
    61296134        char szBuf[256];
    61306135        szBuf[0] = '\0';
    6131         DBGFR3DisasInstr(pVM, pCtx->cs, pEip, szBuf, sizeof(szBuf));
     6136        DBGFR3DisasInstr(pVM, pVCpu, pCtx->cs, pEip, szBuf, sizeof(szBuf));
    61326137
    61336138        /* Very bad. We crashed in emitted code. Probably stack? */
     
    61356140        {
    61366141            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(pVM), 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));
    61386143        }
    61396144        else
    61406145            AssertReleaseMsg(pVM->patm.s.pGCStateHC->fPIF == 1,
    6141                             ("Crash in patch code %RRv (%RRv) esp=%RX32\n%s\n", pEip, pNewEip, CPUMGetGuestESP(pVM), szBuf));
    6142         EMR3FatalError(pVM, 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);
    61436148    }
    61446149
     
    61916196            PCPUMCTX pCtx;
    61926197
    6193             pCtx = CPUMQueryGuestCtxPtr(pVM);
    6194 
    6195             rc = PGMPhysSimpleReadGCPtr(pVM, &retaddr, pCtx->esp, sizeof(retaddr));
     6198            pCtx = CPUMQueryGuestCtxPtr(pVCpu);
     6199
     6200            rc = PGMPhysSimpleReadGCPtr(pVCpu, &retaddr, pCtx->esp, sizeof(retaddr));
    61966201            AssertRC(rc);
    61976202
     
    62286233        }
    62296234#endif
    6230         EMSetInhibitInterruptsPC(pVM, pNewEip);
     6235        EMSetInhibitInterruptsPC(pVM, pVCpu, pNewEip);
    62316236        pVM->patm.s.pGCStateHC->GCPtrInhibitInterrupts = 0;
    62326237    }
     
    62346239    Log2(("pPatchBlockGC %RRv - pEip %RRv corresponding GC address %RRv\n", PATCHCODE_PTR_GC(&pPatch->patch), pEip, pNewEip));
    62356240#ifdef LOG_ENABLED
    6236     CPUMR3DisasmInstr(pVM, pCtx, pNewEip, "PATCHRET: ");
     6241    CPUMR3DisasmInstr(pVM, pVCpu, pCtx, pNewEip, "PATCHRET: ");
    62376242#endif
    62386243    if (pNewEip >= pPatch->patch.pPrivInstrGC && pNewEip < pPatch->patch.pPrivInstrGC + pPatch->patch.cbPatchJump)
  • trunk/src/VBox/VMM/PATM/PATMGuest.cpp

    r13835 r18927  
    9999int PATMPatchSysenterXP(PVM pVM, RTGCPTR32 pInstrGC, PPATMPATCHREC pPatchRec)
    100100{
    101     PPATCHINFO pPatch = &pPatchRec->patch;
    102     uint8_t   uTemp[16];
     101    PPATCHINFO  pPatch = &pPatchRec->patch;
     102    uint8_t     uTemp[16];
    103103    RTGCPTR32   lpfnKiFastSystemCall, lpfnKiIntSystemCall = 0; /* (initializing it to shut up warning.) */
    104     int       rc, i;
     104    int         rc, i;
     105    PVMCPU      pVCpu = VMMGetCpu0(pVM);
    105106
    106107    Assert(sizeof(uTemp) > sizeof(uFnKiIntSystemCall));
     
    111112    /* check the epilog of KiFastSystemCall */
    112113    lpfnKiFastSystemCall = pInstrGC - 2;
    113     rc = PGMPhysSimpleReadGCPtr(pVM, uTemp, lpfnKiFastSystemCall, sizeof(uFnKiFastSystemCall));
     114    rc = PGMPhysSimpleReadGCPtr(pVCpu, uTemp, lpfnKiFastSystemCall, sizeof(uFnKiFastSystemCall));
    114115    if (    RT_FAILURE(rc)
    115116        ||  memcmp(uFnKiFastSystemCall, uTemp, sizeof(uFnKiFastSystemCall)))
     
    121122    for (i=0;i<64;i++)
    122123    {
    123         rc = PGMPhysSimpleReadGCPtr(pVM, uTemp, pInstrGC + i, sizeof(uFnKiIntSystemCall));
     124        rc = PGMPhysSimpleReadGCPtr(pVCpu, uTemp, pInstrGC + i, sizeof(uFnKiIntSystemCall));
    124125        if(RT_FAILURE(rc))
    125126        {
     
    146147
    147148    // make a copy of the guest code bytes that will be overwritten
    148     rc = PGMPhysSimpleReadGCPtr(pVM, pPatch->aPrivInstr, pPatch->pPrivInstrGC, SIZEOF_NEARJUMP32);
     149    rc = PGMPhysSimpleReadGCPtr(pVCpu, pPatch->aPrivInstr, pPatch->pPrivInstrGC, SIZEOF_NEARJUMP32);
    149150    AssertRC(rc);
    150151
     
    152153    uTemp[0] = 0xE9;
    153154    *(RTGCPTR32 *)&uTemp[1] = lpfnKiIntSystemCall - (pInstrGC + SIZEOF_NEARJUMP32);
    154     rc = PGMPhysSimpleDirtyWriteGCPtr(pVM, pInstrGC, uTemp, SIZEOF_NEARJUMP32);
     155    rc = PGMPhysSimpleDirtyWriteGCPtr(pVCpu, pInstrGC, uTemp, SIZEOF_NEARJUMP32);
    155156    if (RT_FAILURE(rc))
    156157    {
     
    189190    /* Guest OS specific patch; check heuristics first */
    190191
    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)));
    192193    if (    RT_FAILURE(rc)
    193194        || (    memcmp(uFnOpenBSDHandlerPrefix1, uTemp, sizeof(uFnOpenBSDHandlerPrefix1))
  • trunk/src/VBox/VMM/PATM/PATMInternal.h

    r13832 r18927  
    704704{
    705705    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  = patmReadBytes;
     706    disinfo.pVM         = pVM;
     707    disinfo.pPatchInfo  = pPatch;
     708    disinfo.pInstrHC    = InstrHC;
     709    disinfo.pInstrGC    = InstrGC;
     710    disinfo.fReadFlags  = fReadFlags;
     711    (pCpu)->pfnReadBytes = patmReadBytes;
    712712    (pCpu)->apvUserData[0] = &disinfo;
    713713    return RT_SUCCESS(DISInstr(pCpu, InstrGC, 0, pOpsize, pszOutput));
  • trunk/src/VBox/VMM/PATM/PATMPatch.cpp

    r13830 r18927  
    404404static int patmPatchReadBytes(PVM pVM, uint8_t *pDest, RTRCPTR pSrc, uint32_t cb)
    405405{
    406     int rc = PGMPhysSimpleReadGCPtr(pVM, pDest, pSrc, cb);
     406    int rc = PGMPhysSimpleReadGCPtr(&pVM->aCpus[0], pDest, pSrc, cb);
    407407    AssertRCReturn(rc, rc);
    408408    /*
  • trunk/src/VBox/VMM/PATM/PATMSSM.cpp

    r18272 r18927  
    583583        pPatchRec->patch.pPrivInstrHC   = 0;
    584584        /* 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);
    586586        /* Can fail due to page or page table not present. */
    587587
     
    961961             * Read old patch jump and compare it to the one we previously installed
    962962             */
    963             int rc = PGMPhysSimpleReadGCPtr(pVM, temp, pPatch->pPrivInstrGC, pPatch->cbPatchJump);
     963            int rc = PGMPhysSimpleReadGCPtr(VMMGetCpu0(pVM), temp, pPatch->pPrivInstrGC, pPatch->cbPatchJump);
    964964            Assert(RT_SUCCESS(rc) || rc == VERR_PAGE_NOT_PRESENT || rc == VERR_PAGE_TABLE_NOT_PRESENT);
    965965
     
    984984            if (RT_SUCCESS(rc))
    985985            {
    986                 rc = PGMPhysSimpleDirtyWriteGCPtr(pVM, pJumpOffGC, &displ, sizeof(displ));
     986                rc = PGMPhysSimpleDirtyWriteGCPtr(VMMGetCpu0(pVM), pJumpOffGC, &displ, sizeof(displ));
    987987                AssertRC(rc);
    988988            }
  • trunk/src/VBox/VMM/PATM/VMMAll/PATMAll.cpp

    r13832 r18927  
    3434#include "PATMInternal.h"
    3535#include <VBox/vm.h>
     36#include <VBox/vmm.h>
    3637#include "PATMA.h"
    3738
     
    190191        if (CTXSUFF(pVM->patm.s.pGCState)->GCPtrInhibitInterrupts == (RTRCPTR)pCtxCore->eip)
    191192        {
    192             EMSetInhibitInterruptsPC(pVM, pCtxCore->eip);
     193            EMSetInhibitInterruptsPC(pVM, VMMGetCpu0(pVM), pCtxCore->eip);
    193194        }
    194195        CTXSUFF(pVM->patm.s.pGCState)->GCPtrInhibitInterrupts = 0;
     
    298299VMMDECL(bool) PATMAreInterruptsEnabled(PVM pVM)
    299300{
    300     PCPUMCTX pCtx = CPUMQueryGuestCtxPtr(pVM);
     301    PCPUMCTX pCtx = CPUMQueryGuestCtxPtr(VMMGetCpu0(pVM));
    301302
    302303    return PATMAreInterruptsEnabledByCtxCore(pVM, CPUMCTX2CORE(pCtx));
     
    382383VMMDECL(int) PATMSysCall(PVM pVM, PCPUMCTXCORE pRegFrame, PDISCPUSTATE pCpu)
    383384{
    384     PCPUMCTX pCtx = CPUMQueryGuestCtxPtr(pVM);
     385    PCPUMCTX pCtx = CPUMQueryGuestCtxPtr(VMMGetCpu0(pVM));
    385386
    386387    if (pCpu->pCurInstr->opcode == OP_SYSENTER)
  • trunk/src/VBox/VMM/PATM/VMMGC/CSAMGC.cpp

    r14029 r18927  
    6767    bool         fPatchCode = PATMIsPatchGCAddr(pVM, (RTRCPTR)pRegFrame->eip);
    6868    int          rc;
     69    PVMCPU       pVCpu = VMMGetCpu0(pVM);
    6970
    7071    Assert(pVM->csam.s.cDirtyPages < CSAM_MAX_DIRTY_PAGES);
     
    8788         * Make this particular page R/W.
    8889         */
    89         int rc = PGMShwModifyPage(pVM, pvFault, 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);
    9091        AssertMsgRC(rc, ("PGMShwModifyPage -> rc=%Rrc\n", rc));
    9192        ASMInvalidatePage((void *)pvFault);
     
    128129     */
    129130    Log(("CSAMGCCodePageWriteHandler: enabled r/w for page %RGv\n", pvFault));
    130     rc = PGMShwModifyPage(pVM, pvFault, 1, X86_PTE_RW, ~(uint64_t)X86_PTE_RW);
     131    rc = PGMShwModifyPage(pVM, pVCpu, pvFault, 1, X86_PTE_RW, ~(uint64_t)X86_PTE_RW);
    131132    AssertMsgRC(rc, ("PGMShwModifyPage -> rc=%Rrc\n", rc));
    132133    ASMInvalidatePage((void *)pvFault);
  • trunk/src/VBox/VMM/PATM/VMMGC/PATMGC.cpp

    r14029 r18927  
    117117
    118118            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);
    120120            if (rc == VINF_SUCCESS)
    121121            {
     
    281281                pVM->patm.s.CTXSUFF(pGCState)->Restore.uFlags = 0;
    282282
    283                 rc = EMInterpretIret(pVM, pRegFrame);
     283                rc = EMInterpretIret(pVM, VMMGetCpu0(pVM), pRegFrame);
    284284                if (RT_SUCCESS(rc))
    285285                {
     
    517517            }
    518518
    519             rc = EMInterpretInstructionCPU(pVM, &cpu, pRegFrame, 0 /* not relevant here */, &size);
     519            rc = EMInterpretInstructionCPU(pVM, VMMGetCpu0(pVM), &cpu, pRegFrame, 0 /* not relevant here */, &size);
    520520            if (rc != VINF_SUCCESS)
    521521            {
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