VirtualBox

Changeset 14755 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Nov 28, 2008 2:58:01 AM (16 years ago)
Author:
vboxsync
Message:

#1865: Converted 4 PGM*2HC* conversion functions to RTR3PTR.

Location:
trunk/src/VBox/VMM
Files:
10 edited

Legend:

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

    r14075 r14755  
    578578    }
    579579
    580     rc = PGMPhysGCPtr2HCPtr(pVM, pGCPtr, &pHCPtr);
     580    rc = PGMPhysGCPtr2R3Ptr(pVM, pGCPtr, &pHCPtr);
    581581    if (rc != VINF_SUCCESS)
    582582    {
     
    12791279            Log(("Jump through jump table\n"));
    12801280
    1281             rc2 = PGMPhysGCPtr2HCPtr(pVM, pJumpTableGC, (PRTHCPTR)&pJumpTableHC);
     1281            rc2 = PGMPhysGCPtr2R3Ptr(pVM, pJumpTableGC, (PRTHCPTR)&pJumpTableHC);
    12821282            if (rc2 == VINF_SUCCESS)
    12831283            {
     
    23282328    if (PAGE_ADDRESS(GCPtrIDT) == PAGE_ADDRESS(GCPtrIDT+cGates*sizeof(VBOXIDTE)))
    23292329    {
    2330         /* Just convert the IDT address to a HC pointer. The whole IDT fits in one page. */
    2331         rc = PGMPhysGCPtr2HCPtr(pVM, GCPtrIDT, (PRTHCPTR)&pGuestIdte);
     2330        /* Just convert the IDT address to a R3 pointer. The whole IDT fits in one page. */
     2331        rc = PGMPhysGCPtr2R3Ptr(pVM, GCPtrIDT, (PRTR3PTR)&pGuestIdte);
    23322332        if (RT_FAILURE(rc))
    23332333        {
  • trunk/src/VBox/VMM/PATM/PATM.cpp

    r13960 r14755  
    604604    {
    605605        /** @note pPrivInstrHC is probably not valid anymore */
    606         rc = PGMPhysGCPtr2HCPtr(pVM, pPatch->patch.pPrivInstrGC, (PRTHCPTR)&pPatch->patch.pPrivInstrHC);
     606        rc = PGMPhysGCPtr2R3Ptr(pVM, pPatch->patch.pPrivInstrGC, (PRTR3PTR)&pPatch->patch.pPrivInstrHC);
    607607        if (rc == VINF_SUCCESS)
    608608        {
     
    790790    {
    791791        /** @note pPrivInstrHC is probably not valid anymore */
    792         rc = PGMPhysGCPtr2HCPtr(pVM, pPatch->patch.pPrivInstrGC, (PRTHCPTR)&pPatch->patch.pPrivInstrHC);
     792        rc = PGMPhysGCPtr2R3Ptr(pVM, pPatch->patch.pPrivInstrGC, (PRTR3PTR)&pPatch->patch.pPrivInstrHC);
    793793        if (rc == VINF_SUCCESS)
    794794        {
     
    995995    }
    996996
    997     rc = PGMPhysGCPtr2HCPtr(pVM, pGCPtr, (void **)&pHCPtr);
     997    rc = PGMPhysGCPtr2R3Ptr(pVM, pGCPtr, (void **)&pHCPtr);
    998998    if (rc != VINF_SUCCESS)
    999999    {
     
    41214121    }
    41224122    GCPhys = GCPhys + (pInstrGC & PAGE_OFFSET_MASK);
    4123     rc = PGMPhysGCPhys2HCPtr(pVM, GCPhys, MAX_INSTR_SIZE, (void **)&pInstrHC);
     4123    rc = PGMPhysGCPhys2R3Ptr(pVM, GCPhys, MAX_INSTR_SIZE, (void **)&pInstrHC);
    41244124    AssertRCReturn(rc, rc);
    41254125
     
    44024402    uint8_t *pInstrHC;
    44034403
    4404     int rc = PGMPhysGCPtr2HCPtr(pVM, pInstrGC, (RTHCPTR *)&pInstrHC);
     4404    int rc = PGMPhysGCPtr2R3Ptr(pVM, pInstrGC, (PRTR3PTR)&pInstrHC);
    44054405    if (rc == VINF_SUCCESS)
    44064406    {
     
    49994999
    50005000                /** pPrivInstrHC is probably not valid anymore */
    5001                 rc = PGMPhysGCPtr2HCPtr(pVM, pPatchRec->patch.pPrivInstrGC, (PRTHCPTR)&pPatchRec->patch.pPrivInstrHC);
     5001                rc = PGMPhysGCPtr2R3Ptr(pVM, pPatchRec->patch.pPrivInstrGC, (PRTR3PTR)&pPatchRec->patch.pPrivInstrHC);
    50025002                if (rc == VINF_SUCCESS)
    50035003                {
     
    52185218                Assert(!(pPatch->flags & PATMFL_PATCHED_GUEST_CODE));
    52195219                /** @todo -> pPrivInstrHC is probably not valid anymore */
    5220                 rc = PGMPhysGCPtr2HCPtr(pVM, pPatchRec->patch.pPrivInstrGC, (PRTHCPTR)&pPatchRec->patch.pPrivInstrHC);
     5220                rc = PGMPhysGCPtr2R3Ptr(pVM, pPatchRec->patch.pPrivInstrGC, (PRTR3PTR)&pPatchRec->patch.pPrivInstrHC);
    52215221                if (rc == VINF_SUCCESS)
    52225222                {
  • trunk/src/VBox/VMM/PATM/PATMSSM.cpp

    r13830 r14755  
    582582        pPatchRec->patch.pPrivInstrHC   = 0;
    583583        /* The GC virtual ptr is fixed, but we must convert it manually again to HC. */
    584         rc = PGMPhysGCPtr2HCPtr(pVM, pPatchRec->patch.pPrivInstrGC, (PRTHCPTR)&pPatchRec->patch.pPrivInstrHC);
     584        rc = PGMPhysGCPtr2R3Ptr(pVM, pPatchRec->patch.pPrivInstrGC, (PRTR3PTR)&pPatchRec->patch.pPrivInstrHC);
    585585        /* Can fail due to page or page table not present. */
    586586
  • trunk/src/VBox/VMM/PGM.cpp

    r14301 r14755  
    15331533                pVM->pgm.s.HCPhysShwPaePdpt,
    15341534                pVM->pgm.s.HCPhysShwPaePml4));
    1535 # endif 
     1535# endif
    15361536        LogRel(("Debug: HCPhysInterPD=%RHp HCPhysInterPaePDPT=%RHp HCPhysInterPaePML4=%RHp\n",
    15371537                pVM->pgm.s.HCPhysInterPD, pVM->pgm.s.HCPhysInterPaePDPT, pVM->pgm.s.HCPhysInterPaePML4));
     
    26432643    PX86PD     pPDSrc = pVM->pgm.s.pGst32BitPdR3;
    26442644    Assert(pPDSrc);
    2645     Assert(PGMPhysGCPhys2HCPtrAssert(pVM, (RTGCPHYS)(CPUMGetGuestCR3(pVM) & X86_CR3_PAGE_MASK), sizeof(*pPDSrc)) == pPDSrc);
     2645    Assert(PGMPhysGCPhys2R3PtrAssert(pVM, (RTGCPHYS)(CPUMGetGuestCR3(pVM) & X86_CR3_PAGE_MASK), sizeof(*pPDSrc)) == pPDSrc);
    26462646
    26472647    /*
  • trunk/src/VBox/VMM/PGMInternal.h

    r14750 r14755  
    251251#else
    252252# define PGM_GCPHYS_2_PTR(pVM, GCPhys, ppv) \
    253      PGMPhysGCPhys2HCPtr(pVM, GCPhys, 1 /* one page only */, (void **)(ppv)) /** @todo this isn't asserting, use PGMRamGCPhys2HCPtr! */
     253     PGMPhysGCPhys2R3Ptr(pVM, GCPhys, 1 /* one page only */, (PRTR3PTR)(ppv)) /** @todo this isn't asserting, use PGMRamGCPhys2HCPtr! */
    254254#endif
    255255
     
    271271#else
    272272# define PGM_GCPHYS_2_PTR_EX(pVM, GCPhys, ppv) \
    273      PGMPhysGCPhys2HCPtr(pVM, GCPhys, 1 /* one page only */, (void **)(ppv)) /** @todo this isn't asserting, use PGMRamGCPhys2HCPtr! */
     273     PGMPhysGCPhys2R3Ptr(pVM, GCPhys, 1 /* one page only */, (PRTR3PTR)(ppv)) /** @todo this isn't asserting, use PGMRamGCPhys2HCPtr! */
    274274#endif
    275275
     
    31823182 * @param   pHCPtr      Where to store the corresponding HC virtual address.
    31833183 *
    3184  * @deprecated  This will be eliminated by PGMPhysGCPhys2CCPtr.
     3184 * @deprecated  This will be eliminated by PGMPhysGCPhys2CCPtr. Only user is
     3185 *              pgmPoolMonitorGCPtr2CCPtr.
    31853186 */
    31863187DECLINLINE(int) pgmRamGCPhys2HCPtr(PPGM pPGM, RTGCPHYS GCPhys, PRTHCPTR pHCPtr)
     
    32043205    if (pRam->pvR3)
    32053206    {
    3206         *pHCPtr = (RTHCPTR)((RTHCUINTPTR)pRam->pvR3 + off); /** @todo @bugref{1865,3202}: Code is converting R3 pointer and maybe using it in R0! */
     3207        *pHCPtr = (RTHCPTR)((RTHCUINTPTR)pRam->pvR3 + off);
    32073208        return VINF_SUCCESS;
    32083209    }
     
    32113212}
    32123213# endif /* !VBOX_WITH_NEW_PHYS_CODE */
    3213 
    3214 
    3215 /**
    3216  * Convert GC Phys to HC Virt.
    3217  *
    3218  * @returns VBox status.
    3219  * @param   PVM         VM handle.
    3220  * @param   pRam        Ram range
    3221  * @param   GCPhys      The GC physical address.
    3222  * @param   pHCPtr      Where to store the corresponding HC virtual address.
    3223  *
    3224  * @deprecated  This will be eliminated. Don't use it.
    3225  */
    3226 DECLINLINE(int) pgmRamGCPhys2HCPtrWithRange(PVM pVM, PPGMRAMRANGE pRam, RTGCPHYS GCPhys, PRTHCPTR pHCPtr)
    3227 {
    3228     RTGCPHYS off = GCPhys - pRam->GCPhys;
    3229     Assert(off < pRam->cb);
    3230 
    3231     if (pRam->fFlags & MM_RAM_FLAGS_DYNAMIC_ALLOC)
    3232     {
    3233         unsigned idx = (off >> PGM_DYNAMIC_CHUNK_SHIFT);
    3234         /* Physical chunk in dynamically allocated range not present? */
    3235         if (RT_UNLIKELY(!pRam->paChunkR3Ptrs[idx]))
    3236         {
    3237 #ifdef IN_RING3
    3238             int rc = pgmr3PhysGrowRange(pVM, GCPhys);
    3239 #else
    3240             int rc = CTXALLMID(VMM, CallHost)(pVM, VMMCALLHOST_PGM_RAM_GROW_RANGE, GCPhys);
    3241 #endif
    3242             if (rc != VINF_SUCCESS)
    3243             {
    3244                 *pHCPtr = 0; /* GCC crap */
    3245                 return rc;
    3246             }
    3247         }
    3248         *pHCPtr = (RTHCPTR)(pRam->paChunkR3Ptrs[idx] + (off & PGM_DYNAMIC_CHUNK_OFFSET_MASK));
    3249         return VINF_SUCCESS;
    3250     }
    3251     if (pRam->pvR3)
    3252     {
    3253         *pHCPtr = (RTHCPTR)((RTHCUINTPTR)pRam->pvR3 + off); /** @todo @bugref{1865,3202}: Code is converting R3 pointer and maybe using it in R0! */
    3254         return VINF_SUCCESS;
    3255     }
    3256     *pHCPtr = 0; /* GCC crap */
    3257     return VERR_PGM_INVALID_GC_PHYSICAL_ADDRESS;
    3258 }
    3259 
    32603214#endif /* !IN_RC && !defined(VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0) */
    32613215
     
    32993253    if (pRam->pvR3)
    33003254    {
    3301         *pHCPtr = (RTHCPTR)((RTHCUINTPTR)pRam->pvR3 + off); /** @todo @bugref{1865,3202}: Code is converting R3 pointer and maybe using it in R0! */
     3255        *pHCPtr = (RTHCPTR)((RTHCUINTPTR)pRam->pvR3 + off);
    33023256        return VINF_SUCCESS;
    33033257    }
  • trunk/src/VBox/VMM/PGMMap.cpp

    r14716 r14755  
    10971097        PX86PD pPD = pVM->pgm.s.pGst32BitPdR3;
    10981098        Assert(pPD);
    1099         Assert(pPD == (PX86PD)PGMPhysGCPhys2HCPtrAssert(pVM, cr3 & X86_CR3_PAGE_MASK, sizeof(*pPD)));
     1099        Assert(pPD == (PX86PD)PGMPhysGCPhys2R3PtrAssert(pVM, cr3 & X86_CR3_PAGE_MASK, sizeof(*pPD)));
    11001100
    11011101        for (PPGMMAPPING pCur = pVM->pgm.s.pMappingsR3; pCur; pCur = pCur->pNextR3)
  • trunk/src/VBox/VMM/TRPM.cpp

    r14351 r14755  
    13191319         */
    13201320        PVBOXIDTE   pIDTE;
    1321         int rc = PGMPhysGCPtr2HCPtr(pVM, GCPtrIDTE, (void **)&pIDTE);
     1321        int rc = PGMPhysGCPtr2R3Ptr(pVM, GCPtrIDTE, (void **)&pIDTE);
    13221322        if (RT_SUCCESS(rc))
    13231323        {
  • trunk/src/VBox/VMM/VMMAll/EMAll.cpp

    r14562 r14755  
    352352
    353353
    354 /* Convert sel:addr to a flat GC address */
    355 static RTGCPTR emConvertToFlatAddr(PVM pVM, PCPUMCTXCORE pRegFrame, PDISCPUSTATE pCpu, POP_PARAMETER pParam, RTGCPTR pvAddr)
     354/** Convert sel:addr to a flat GC address. */
     355DECLINLINE(RTGCPTR) emConvertToFlatAddr(PVM pVM, PCPUMCTXCORE pRegFrame, PDISCPUSTATE pCpu, POP_PARAMETER pParam, RTGCPTR pvAddr)
    356356{
    357357    DIS_SELREG enmPrefixSeg = DISDetectSegReg(pCpu, pParam);
     
    822822    }
    823823
    824     /* The destination is always a virtual address */
    825     AssertReturn(param1.type == PARMTYPE_ADDRESS, VERR_EM_INTERPRETER);
    826 
    827     RTGCPTR GCPtrPar1 = param1.val.val64;
    828     GCPtrPar1 = emConvertToFlatAddr(pVM, pRegFrame, pCpu, &pCpu->param1, GCPtrPar1);
    829 #ifdef IN_RC
    830     pvParam1  = (void *)GCPtrPar1;
    831 #else
    832     rc = PGMPhysGCPtr2HCPtr(pVM, GCPtrPar1, &pvParam1);
    833     if (RT_FAILURE(rc))
    834     {
    835         AssertRC(rc);
    836         return VERR_EM_INTERPRETER;
    837     }
    838 #endif
    839 
    840824#ifdef IN_RC
    841825    /* Safety check (in theory it could cross a page boundary and fault there though) */
     
    849833    RTGCUINTREG ValPar2 = param2.val.val64;
    850834
    851     /* Try emulate it with a one-shot #PF handler in place. */
     835    /* The destination is always a virtual address */
     836    AssertReturn(param1.type == PARMTYPE_ADDRESS, VERR_EM_INTERPRETER);
     837
     838    RTGCPTR GCPtrPar1 = param1.val.val64;
     839    GCPtrPar1 = emConvertToFlatAddr(pVM, pRegFrame, pCpu, &pCpu->param1, GCPtrPar1);
     840#ifdef IN_RC
     841    pvParam1  = (void *)GCPtrPar1;
     842#else
     843    PGMPAGEMAPLOCK Lock;
     844    rc = PGMPhysGCPtr2CCPtr(pVM, GCPtrPar1, &pvParam1, &Lock);
     845    AssertRCReturn(rc, VERR_EM_INTERPRETER);
     846#endif
     847
     848    /* Try emulate it with a one-shot #PF handler in place. (RC) */
    852849    Log2(("%s %RGv imm%d=%RX64\n", emGetMnemonic(pCpu), GCPtrPar1, pCpu->param2.size*8, ValPar2));
    853850
     
    859856#ifdef IN_RC
    860857    MMGCRamDeregisterTrapHandler(pVM);
     858#else
     859    PGMPhysReleasePageMappingLock(pVM, &Lock);
    861860#endif
    862861    if (RT_FAILURE(rc))
     
    10891088    ValPar2 &= 7;
    10901089
    1091 #ifdef IN_RC
    10921090    GCPtrPar1 = emConvertToFlatAddr(pVM, pRegFrame, pCpu, &pCpu->param1, GCPtrPar1);
     1091#ifdef IN_RC
     1092    Assert(TRPMHasTrap(pVM));
     1093    EM_ASSERT_FAULT_RETURN((RTGCPTR)((RTGCUINTPTR)GCPtrPar1 & ~(RTGCUINTPTR)3) == pvFault, VERR_EM_INTERPRETER);
     1094#endif
     1095
     1096#ifdef IN_RC
    10931097    pvParam1  = (void *)GCPtrPar1;
    10941098#else
    1095     GCPtrPar1 = emConvertToFlatAddr(pVM, pRegFrame, pCpu, &pCpu->param1, GCPtrPar1);
    1096     rc = PGMPhysGCPtr2HCPtr(pVM, GCPtrPar1, &pvParam1);
    1097     if (RT_FAILURE(rc))
    1098     {
    1099         AssertRC(rc);
    1100         return VERR_EM_INTERPRETER;
    1101     }
     1099    PGMPAGEMAPLOCK Lock;
     1100    rc = PGMPhysGCPtr2CCPtr(pVM, GCPtrPar1, &pvParam1, &Lock);
     1101    AssertRCReturn(rc, VERR_EM_INTERPRETER);
    11021102#endif
    11031103
    11041104    Log2(("emInterpretLockBitTest %s: pvFault=%RGv GCPtrPar1=%RGv imm=%RX64\n", emGetMnemonic(pCpu), pvFault, GCPtrPar1, ValPar2));
    11051105
    1106 #ifdef IN_RC
    1107     Assert(TRPMHasTrap(pVM));
    1108     EM_ASSERT_FAULT_RETURN((RTGCPTR)((RTGCUINTPTR)GCPtrPar1 & ~(RTGCUINTPTR)3) == pvFault, VERR_EM_INTERPRETER);
    1109 #endif
    1110 
    1111     /* Try emulate it with a one-shot #PF handler in place. */
     1106    /* Try emulate it with a one-shot #PF handler in place. (RC) */
    11121107    RTGCUINTREG32 eflags = 0;
    11131108#ifdef IN_RC
     
    11171112#ifdef IN_RC
    11181113    MMGCRamDeregisterTrapHandler(pVM);
     1114#else
     1115    PGMPhysReleasePageMappingLock(pVM, &Lock);
    11191116#endif
    11201117    if (RT_FAILURE(rc))
     
    14231420        return VERR_EM_INTERPRETER;
    14241421
     1422    uint64_t valpar;
     1423    switch(param2.type)
     1424    {
     1425    case PARMTYPE_IMMEDIATE: /* register actually */
     1426        valpar = param2.val.val64;
     1427        break;
     1428
     1429    default:
     1430        return VERR_EM_INTERPRETER;
     1431    }
     1432
     1433    PGMPAGEMAPLOCK Lock;
    14251434    RTGCPTR  GCPtrPar1;
    14261435    void    *pvParam1;
    1427     uint64_t valpar, eflags;
     1436    uint64_t eflags;
    14281437
    14291438    AssertReturn(pCpu->param1.size == pCpu->param2.size, VERR_EM_INTERPRETER);
     
    14341443        GCPtrPar1 = emConvertToFlatAddr(pVM, pRegFrame, pCpu, &pCpu->param1, GCPtrPar1);
    14351444
    1436         rc = PGMPhysGCPtr2HCPtr(pVM, GCPtrPar1, &pvParam1);
    1437         if (RT_FAILURE(rc))
    1438         {
    1439             AssertRC(rc);
    1440             return VERR_EM_INTERPRETER;
    1441         }
    1442         break;
    1443 
    1444     default:
    1445         return VERR_EM_INTERPRETER;
    1446     }
    1447 
    1448     switch(param2.type)
    1449     {
    1450     case PARMTYPE_IMMEDIATE: /* register actually */
    1451         valpar = param2.val.val64;
     1445        rc = PGMPhysGCPtr2CCPtr(pVM, GCPtrPar1, &pvParam1, &Lock);
     1446        AssertRCReturn(rc, VERR_EM_INTERPRETER);
    14521447        break;
    14531448
     
    14701465
    14711466    *pcbSize = param2.size;
     1467    PGMPhysReleasePageMappingLock(pVM, &Lock);
    14721468    return VINF_SUCCESS;
    14731469}
     
    14901486    void    *pvParam1;
    14911487    uint64_t eflags;
     1488    PGMPAGEMAPLOCK Lock;
    14921489
    14931490    AssertReturn(pCpu->param1.size == 8, VERR_EM_INTERPRETER);
     
    14981495        GCPtrPar1 = emConvertToFlatAddr(pVM, pRegFrame, pCpu, &pCpu->param1, GCPtrPar1);
    14991496
    1500         rc = PGMPhysGCPtr2HCPtr(pVM, GCPtrPar1, &pvParam1);
    1501         if (RT_FAILURE(rc))
    1502         {
    1503             AssertRC(rc);
    1504             return VERR_EM_INTERPRETER;
    1505         }
     1497        rc = PGMPhysGCPtr2CCPtr(pVM, GCPtrPar1, &pvParam1, &Lock);
     1498        AssertRCReturn(rc, VERR_EM_INTERPRETER);
    15061499        break;
    15071500
     
    15241517
    15251518    *pcbSize = 8;
     1519    PGMPhysReleasePageMappingLock(pVM, &Lock);
    15261520    return VINF_SUCCESS;
    15271521}
  • trunk/src/VBox/VMM/VMMAll/PGMAllBth.h

    r14681 r14755  
    31673167    Assert(pPDSrc);
    31683168#   if !defined(IN_RC) && !defined(VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0)
    3169     Assert(PGMPhysGCPhys2HCPtrAssert(pVM, (RTGCPHYS)(cr3 & GST_CR3_PAGE_MASK), sizeof(*pPDSrc)) == pPDSrc);
     3169    Assert(PGMPhysGCPhys2R3PtrAssert(pVM, (RTGCPHYS)(cr3 & GST_CR3_PAGE_MASK), sizeof(*pPDSrc)) == (RTR3PTR)pPDSrc);
    31703170#   endif
    31713171#  endif /* PGM_GST_TYPE == PGM_TYPE_32BIT */
  • trunk/src/VBox/VMM/VMMAll/PGMAllPhys.cpp

    r14560 r14755  
    705705    return PGMDynMapGCPageOff(pVM, GCPhys, ppv);
    706706# else
    707     return PGMPhysGCPhys2HCPtr(pVM, GCPhys, 1, ppv);
     707    return PGMPhysGCPhys2R3Ptr(pVM, GCPhys, 1, (PRTR3PTR)ppv);
    708708# endif
    709709#endif
     
    850850
    851851/**
    852  * Converts a GC physical address to a HC pointer.
     852 * Converts a GC physical address to a HC ring-3 pointer.
    853853 *
    854854 * @returns VINF_SUCCESS on success.
     
    859859 * @returns VERR_PGM_GCPHYS_RANGE_CROSSES_BOUNDARY if the range crosses
    860860 *          a dynamic ram chunk boundary
    861  * @param   pVM     The VM handle.
    862  * @param   GCPhys  The GC physical address to convert.
    863  * @param   cbRange Physical range
    864  * @param   pHCPtr  Where to store the HC pointer on success.
    865  */
    866 VMMDECL(int) PGMPhysGCPhys2HCPtr(PVM pVM, RTGCPHYS GCPhys, RTUINT cbRange, PRTHCPTR pHCPtr) /** @todo @bugref{1865}: HCPtr -> R3Ptr */
     861 *
     862 * @param   pVM         The VM handle.
     863 * @param   GCPhys      The GC physical address to convert.
     864 * @param   cbRange     Physical range
     865 * @param   pR3Ptr      Where to store the R3 pointer on success.
     866 */
     867VMMDECL(int) PGMPhysGCPhys2R3Ptr(PVM pVM, RTGCPHYS GCPhys, RTUINT cbRange, PRTR3PTR pR3Ptr)
    867868{
    868869#ifdef VBOX_WITH_NEW_PHYS_CODE
     
    900901#if defined(IN_RC) || defined(VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0) /* ASSUMES this is a rare occurence */
    901902        PRTR3UINTPTR paChunkR3Ptrs = (PRTR3UINTPTR)MMHyperR3ToCC(pVM, pRam->paChunkR3Ptrs);
    902         *pHCPtr = (RTHCPTR)(paChunkR3Ptrs[iChunk] + (off & PGM_DYNAMIC_CHUNK_OFFSET_MASK));
     903        *pR3Ptr = (RTR3PTR)(paChunkR3Ptrs[iChunk] + (off & PGM_DYNAMIC_CHUNK_OFFSET_MASK));
    903904#else
    904         *pHCPtr = (RTHCPTR)(pRam->paChunkR3Ptrs[iChunk] + (off & PGM_DYNAMIC_CHUNK_OFFSET_MASK));
     905        *pR3Ptr = (RTR3PTR)(pRam->paChunkR3Ptrs[iChunk] + (off & PGM_DYNAMIC_CHUNK_OFFSET_MASK));
    905906#endif
    906907    }
    907908    else if (RT_LIKELY(pRam->pvR3))
    908         *pHCPtr = (RTHCPTR)((RTR3UINTPTR)pRam->pvR3 + off);
     909        *pR3Ptr = (RTR3PTR)((RTR3UINTPTR)pRam->pvR3 + off);
    909910    else
    910911        return VERR_PGM_PHYS_PAGE_RESERVED;
     
    914915
    915916/**
    916  * PGMPhysGCPhys2HCPtr convenience for use with assertions.
    917  *
    918  * @returns The HCPtr, NIL_RTHCPTR on failure.
     917 * PGMPhysGCPhys2R3Ptr convenience for use with assertions.
     918 *
     919 * @returns The R3Ptr, NIL_RTR3PTR on failure.
    919920 * @param   pVM         The VM handle.
    920921 * @param   GCPhys      The GC Physical addresss.
    921922 * @param   cbRange     Physical range.
    922923 */
    923 VMMDECL(RTHCPTR) PGMPhysGCPhys2HCPtrAssert(PVM pVM, RTGCPHYS GCPhys, RTUINT cbRange) /** @todo @bugref{1865}: HCPtr -> R3Ptr */
    924 {
    925     RTHCPTR HCPtr;
    926     int rc = PGMPhysGCPhys2HCPtr(pVM, GCPhys, cbRange, &HCPtr);
     924VMMDECL(RTR3PTR) PGMPhysGCPhys2R3PtrAssert(PVM pVM, RTGCPHYS GCPhys, RTUINT cbRange)
     925{
     926    RTR3PTR R3Ptr;
     927    int rc = PGMPhysGCPhys2R3Ptr(pVM, GCPhys, cbRange, &R3Ptr);
    927928    if (RT_SUCCESS(rc))
    928         return HCPtr;
    929     return NIL_RTHCPTR;
     929        return R3Ptr;
     930    return NIL_RTR3PTR;
    930931}
    931932
     
    971972
    972973/**
    973  * Converts a guest pointer to a HC pointer.
     974 * Converts a guest pointer to a R3 pointer.
    974975 *
    975976 * This uses the current CR3/CR0/CR4 of the guest.
     
    978979 * @param   pVM         The VM Handle
    979980 * @param   GCPtr       The guest pointer to convert.
    980  * @param   pHCPtr      Where to store the HC virtual address.
    981  */
    982 VMMDECL(int) PGMPhysGCPtr2HCPtr(PVM pVM, RTGCPTR GCPtr, PRTHCPTR pHCPtr) /** @todo @bugref{1865}: HCPtr -> R3Ptr */
     981 * @param   pR3Ptr      Where to store the R3 virtual address.
     982 */
     983VMMDECL(int) PGMPhysGCPtr2R3Ptr(PVM pVM, RTGCPTR GCPtr, PRTR3PTR pR3Ptr)
    983984{
    984985#ifdef VBOX_WITH_NEW_PHYS_CODE
     
    989990    int rc = PGM_GST_PFN(GetPage,pVM)(pVM, (RTGCUINTPTR)GCPtr, NULL, &GCPhys);
    990991    if (RT_SUCCESS(rc))
    991         rc = PGMPhysGCPhys2HCPtr(pVM, GCPhys | ((RTGCUINTPTR)GCPtr & PAGE_OFFSET_MASK), 1 /* we always stay within one page */, pHCPtr);
     992        rc = PGMPhysGCPhys2R3Ptr(pVM, GCPhys | ((RTGCUINTPTR)GCPtr & PAGE_OFFSET_MASK), 1 /* we always stay within one page */, pR3Ptr);
    992993    return rc;
    993994}
     
    995996
    996997/**
    997  * Converts a guest virtual address to a HC pointer by specfied CR3 and flags.
     998 * Converts a guest virtual address to a HC ring-3 pointer by specfied CR3 and
     999 * flags.
    9981000 *
    9991001 * @returns VBox status code.
     
    10021004 * @param   cr3         The guest CR3.
    10031005 * @param   fFlags      Flags used for interpreting the PD correctly: X86_CR4_PSE and X86_CR4_PAE
    1004  * @param   pHCPtr      Where to store the HC pointer.
     1006 * @param   pR3Ptr      Where to store the R3 pointer.
    10051007 *
    10061008 * @remark  This function is used by the REM at a time where PGM could
     
    10081010 *          future DBGF API to cpu state independent conversions.
    10091011 */
    1010 VMMDECL(int) PGMPhysGCPtr2HCPtrByGstCR3(PVM pVM, RTGCPTR GCPtr, uint64_t cr3, unsigned fFlags, PRTHCPTR pHCPtr) /** @todo @bugref{1865}: HCPtr -> R3Ptr */
     1012VMMDECL(int) PGMPhysGCPtr2R3PtrByGstCR3(PVM pVM, RTGCPTR GCPtr, uint64_t cr3, unsigned fFlags, PRTR3PTR pR3Ptr)
    10111013{
    10121014#ifdef VBOX_WITH_NEW_PHYS_CODE
     
    10301032                if ((fFlags & X86_CR4_PSE) && Pde.b.u1Size)
    10311033                {   /* (big page) */
    1032                     rc = PGMPhysGCPhys2HCPtr(pVM, pgmGstGet4MBPhysPage(&pVM->pgm.s, Pde) | ((RTGCUINTPTR)GCPtr & X86_PAGE_4M_OFFSET_MASK), 1 /* we always stay within one page */, pHCPtr);
     1034                    rc = PGMPhysGCPhys2R3Ptr(pVM, pgmGstGet4MBPhysPage(&pVM->pgm.s, Pde) | ((RTGCUINTPTR)GCPtr & X86_PAGE_4M_OFFSET_MASK),
     1035                                             1 /* we always stay within one page */, pR3Ptr);
    10331036                }
    10341037                else
     
    10401043                        X86PTE Pte = pPT->a[((RTGCUINTPTR)GCPtr >> X86_PT_SHIFT) & X86_PT_MASK];
    10411044                        if (Pte.n.u1Present)
    1042                             return PGMPhysGCPhys2HCPtr(pVM, (Pte.u & X86_PTE_PG_MASK) | ((RTGCUINTPTR)GCPtr & PAGE_OFFSET_MASK), 1 /* we always stay within one page */, pHCPtr);
     1045                            return PGMPhysGCPhys2R3Ptr(pVM, (Pte.u & X86_PTE_PG_MASK) | ((RTGCUINTPTR)GCPtr & PAGE_OFFSET_MASK),
     1046                                                       1 /* we always stay within one page */, pR3Ptr);
    10431047                        rc = VERR_PAGE_NOT_PRESENT;
    10441048                    }
     
    10701074                        if ((fFlags & X86_CR4_PSE) && Pde.b.u1Size)
    10711075                        {   /* (big page) */
    1072                             rc = PGMPhysGCPhys2HCPtr(pVM, (Pde.u & X86_PDE2M_PAE_PG_MASK) | ((RTGCUINTPTR)GCPtr & X86_PAGE_2M_OFFSET_MASK), 1 /* we always stay within one page */, pHCPtr);
     1076                            rc = PGMPhysGCPhys2R3Ptr(pVM, (Pde.u & X86_PDE2M_PAE_PG_MASK) | ((RTGCUINTPTR)GCPtr & X86_PAGE_2M_OFFSET_MASK),
     1077                                                     1 /* we always stay within one page */, pR3Ptr);
    10731078                        }
    10741079                        else
     
    10801085                                X86PTEPAE Pte = pPT->a[((RTGCUINTPTR)GCPtr >> X86_PT_PAE_SHIFT) & X86_PT_PAE_MASK];
    10811086                                if (Pte.n.u1Present)
    1082                                     return PGMPhysGCPhys2HCPtr(pVM, (Pte.u & X86_PTE_PAE_PG_MASK) | ((RTGCUINTPTR)GCPtr & PAGE_OFFSET_MASK), 1 /* we always stay within one page */, pHCPtr);
     1087                                    return PGMPhysGCPhys2R3Ptr(pVM, (Pte.u & X86_PTE_PAE_PG_MASK) | ((RTGCUINTPTR)GCPtr & PAGE_OFFSET_MASK),
     1088                                                               1 /* we always stay within one page */, pR3Ptr);
    10831089                                rc = VERR_PAGE_NOT_PRESENT;
    10841090                            }
Note: See TracChangeset for help on using the changeset viewer.

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