VirtualBox

Changeset 18101 in vbox for trunk/src


Ignore:
Timestamp:
Mar 19, 2009 10:39:06 PM (16 years ago)
Author:
vboxsync
Message:

PDM,PGM,DevPcArch,types.h: Added GCPhys2CCPtr conversion methods to PDMDEVHLP and removed some obsolete (or soon to be obsolete) methods.

Location:
trunk/src/VBox
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/PC/DevPcArch.c

    r17251 r18101  
    259259     * Note: This will be removed before long.
    260260     */
    261     rc = PDMDevHlpPhysReserve(pDevIns, 0x000a0000, 0x50000, "Low ROM Region");
     261    rc = MMR3PhysReserve(PDMDevHlpGetVM(pDevIns), 0x000a0000, 0x50000, "Low ROM Region");
    262262    if (RT_FAILURE(rc))
    263263        return rc;
    264     rc = PDMDevHlpPhysReserve(pDevIns, 0xfff80000, 0x80000, "High ROM Region");
     264    rc = MMR3PhysReserve(PDMDevHlpGetVM(pDevIns), 0xfff80000, 0x80000, "High ROM Region");
    265265    if (RT_FAILURE(rc))
    266266        return rc;
  • trunk/src/VBox/VMM/PDMDevHlp.cpp

    r17534 r18101  
    20242024
    20252025/** @copydoc PDMDEVHLPR3::pfnPhysRead */
    2026 static DECLCALLBACK(void) pdmR3DevHlp_PhysRead(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead)
     2026static DECLCALLBACK(int) pdmR3DevHlp_PhysRead(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead)
    20272027{
    20282028    PDMDEV_ASSERT_DEVINS(pDevIns);
     
    20332033    int rc;
    20342034#ifdef VBOX_WITH_NEW_PHYS_CODE
    2035     if (!VM_IS_EMT(pVM))
     2035    if (VM_IS_EMT(pVM))
     2036        rc = PGMPhysRead(pVM, GCPhys, pvBuf, cbRead);
     2037    else
    20362038        rc = PGMR3PhysReadExternal(pVM, GCPhys, pvBuf, cbRead);
    2037     else
    2038         rc = PGMPhysRead(pVM, GCPhys, pvBuf, cbRead);
    20392039#else
    20402040    PGMPhysRead(pVM, GCPhys, pvBuf, cbRead);
     
    20422042#endif
    20432043    Log(("pdmR3DevHlp_PhysRead: caller='%s'/%d: returns %Rrc\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, rc));
    2044     /** @todo return rc; */ NOREF(rc);
     2044    return rc;
    20452045}
    20462046
    20472047
    20482048/** @copydoc PDMDEVHLPR3::pfnPhysWrite */
    2049 static DECLCALLBACK(void) pdmR3DevHlp_PhysWrite(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite)
     2049static DECLCALLBACK(int) pdmR3DevHlp_PhysWrite(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite)
    20502050{
    20512051    PDMDEV_ASSERT_DEVINS(pDevIns);
     
    20562056    int rc;
    20572057#ifdef VBOX_WITH_NEW_PHYS_CODE
    2058     if (!VM_IS_EMT(pVM))
     2058    if (VM_IS_EMT(pVM))
     2059        rc = PGMPhysWrite(pVM, GCPhys, pvBuf, cbWrite);
     2060    else
    20592061        rc = PGMR3PhysWriteExternal(pVM, GCPhys, pvBuf, cbWrite);
    2060     else
    2061         rc = PGMPhysWrite(pVM, GCPhys, pvBuf, cbWrite);
    20622062#else
    20632063    PGMPhysWrite(pVM, GCPhys, pvBuf, cbWrite);
     
    20652065#endif
    20662066    Log(("pdmR3DevHlp_PhysWrite: caller='%s'/%d: returns %Rrc\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, rc));
    2067     /** @todo return rc; */ NOREF(rc);
     2067    return rc;
     2068}
     2069
     2070
     2071/** @copydoc PDMDEVHLPR3::pfnPhysGCPhys2CCPtr */
     2072static DECLCALLBACK(int) pdmR3DevHlp_PhysGCPhys2CCPtr(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, uint32_t fFlags, void **ppv, PPGMPAGEMAPLOCK pLock)
     2073{
     2074    PDMDEV_ASSERT_DEVINS(pDevIns);
     2075    PVM pVM = pDevIns->Internal.s.pVMR3;
     2076    LogFlow(("pdmR3DevHlp_PhysGCPhys2CCPtr: caller='%s'/%d: GCPhys=%RGp fFlags=%#x ppv=%p pLock=%p\n",
     2077             pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, GCPhys, fFlags, ppv, pLock));
     2078    AssertReturn(!fFlags, VERR_INVALID_PARAMETER);
     2079
     2080    int rc = PGMR3PhysGCPhys2CCPtrExternal(pVM, GCPhys, ppv, pLock);
     2081
     2082    Log(("pdmR3DevHlp_PhysGCPhys2CCPtr: caller='%s'/%d: returns %Rrc\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, rc));
     2083    return rc;
     2084}
     2085
     2086
     2087/** @copydoc PDMDEVHLPR3::pfnPhysGCPhys2CCPtrReadOnly */
     2088static DECLCALLBACK(int) pdmR3DevHlp_PhysGCPhys2CCPtrReadOnly(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, uint32_t fFlags, const void **ppv, PPGMPAGEMAPLOCK pLock)
     2089{
     2090    PDMDEV_ASSERT_DEVINS(pDevIns);
     2091    PVM pVM = pDevIns->Internal.s.pVMR3;
     2092    LogFlow(("pdmR3DevHlp_PhysGCPhys2CCPtrReadOnly: caller='%s'/%d: GCPhys=%RGp fFlags=%#x ppv=%p pLock=%p\n",
     2093             pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, GCPhys, fFlags, ppv, pLock));
     2094    AssertReturn(!fFlags, VERR_INVALID_PARAMETER);
     2095
     2096    int rc = PGMR3PhysGCPhys2CCPtrReadOnlyExternal(pVM, GCPhys, ppv, pLock);
     2097
     2098    Log(("pdmR3DevHlp_PhysGCPhys2CCPtrReadOnly: caller='%s'/%d: returns %Rrc\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, rc));
     2099    return rc;
     2100}
     2101
     2102
     2103/** @copydoc PDMDEVHLPR3::pfnPhysReleasePageMappingLock */
     2104static DECLCALLBACK(void) pdmR3DevHlp_PhysReleasePageMappingLock(PPDMDEVINS pDevIns, PPGMPAGEMAPLOCK pLock)
     2105{
     2106    PDMDEV_ASSERT_DEVINS(pDevIns);
     2107    PVM pVM = pDevIns->Internal.s.pVMR3;
     2108    LogFlow(("pdmR3DevHlp_PhysReleasePageMappingLock: caller='%s'/%d: pLock=%p\n",
     2109             pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, pLock));
     2110
     2111    PGMPhysReleasePageMappingLock(pVM, pLock);
     2112
     2113    Log(("pdmR3DevHlp_PhysReleasePageMappingLock: caller='%s'/%d: returns void\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance));
    20682114}
    20692115
     
    21062152
    21072153    return rc;
    2108 }
    2109 
    2110 
    2111 /** @copydoc PDMDEVHLPR3::pfnPhysReserve */
    2112 static DECLCALLBACK(int) pdmR3DevHlp_PhysReserve(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, RTUINT cbRange, const char *pszDesc)
    2113 {
    2114 #ifdef VBOX_WITH_NEW_PHYS_CODE
    2115     AssertFailed();
    2116     return VERR_ACCESS_DENIED;
    2117 #else
    2118     PDMDEV_ASSERT_DEVINS(pDevIns);
    2119     VM_ASSERT_EMT(pDevIns->Internal.s.pVMR3);
    2120     LogFlow(("pdmR3DevHlp_PhysReserve: caller='%s'/%d: GCPhys=%RGp cbRange=%#x pszDesc=%p:{%s}\n",
    2121              pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, GCPhys, cbRange, pszDesc, pszDesc));
    2122 
    2123     int rc = MMR3PhysReserve(pDevIns->Internal.s.pVMR3, GCPhys, cbRange, pszDesc);
    2124 
    2125     LogFlow(("pdmR3DevHlp_PhysReserve: caller='%s'/%d: returns %Rrc\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, rc));
    2126 
    2127     return rc;
    2128 #endif
    2129 }
    2130 
    2131 
    2132 /** @copydoc PDMDEVHLPR3::pfnObsoletePhys2HCVirt */
    2133 static DECLCALLBACK(int) pdmR3DevHlp_Obsolete_Phys2HCVirt(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, RTUINT cbRange, PRTHCPTR ppvHC)
    2134 {
    2135     PDMDEV_ASSERT_DEVINS(pDevIns);
    2136     AssertReleaseMsgFailed(("Untrusted device called trusted helper! '%s'/%d\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance));
    2137     NOREF(GCPhys);
    2138     NOREF(cbRange);
    2139     NOREF(ppvHC);
    2140     return VERR_ACCESS_DENIED;
    2141 }
    2142 
    2143 
    2144 /** @copydoc PDMDEVHLPR3::pfnObsoletePhysGCPtr2HCPtr */
    2145 static DECLCALLBACK(int) pdmR3DevHlp_Obsolete_PhysGCPtr2HCPtr(PPDMDEVINS pDevIns, RTGCPTR GCPtr, PRTHCPTR pHCPtr)
    2146 {
    2147     PDMDEV_ASSERT_DEVINS(pDevIns);
    2148     AssertReleaseMsgFailed(("Untrusted device called trusted helper! '%s'/%d\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance));
    2149     NOREF(GCPtr);
    2150     NOREF(pHCPtr);
    2151     return VERR_ACCESS_DENIED;
    21522154}
    21532155
     
    27032705    pdmR3DevHlp_PhysRead,
    27042706    pdmR3DevHlp_PhysWrite,
     2707    pdmR3DevHlp_PhysGCPhys2CCPtr,
     2708    pdmR3DevHlp_PhysGCPhys2CCPtrReadOnly,
     2709    pdmR3DevHlp_PhysReleasePageMappingLock,
    27052710    pdmR3DevHlp_PhysReadGCVirt,
    27062711    pdmR3DevHlp_PhysWriteGCVirt,
    2707     pdmR3DevHlp_PhysReserve,
    2708     pdmR3DevHlp_Obsolete_Phys2HCVirt,
    2709     pdmR3DevHlp_Obsolete_PhysGCPtr2HCPtr,
    27102712    pdmR3DevHlp_A20IsEnabled,
    27112713    pdmR3DevHlp_A20Set,
     
    28052807
    28062808/** @copydoc PDMDEVHLPR3::pfnPhysRead */
    2807 static DECLCALLBACK(void) pdmR3DevHlp_Untrusted_PhysRead(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead)
     2809static DECLCALLBACK(int) pdmR3DevHlp_Untrusted_PhysRead(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead)
    28082810{
    28092811    PDMDEV_ASSERT_DEVINS(pDevIns);
     
    28122814    NOREF(pvBuf);
    28132815    NOREF(cbRead);
     2816    return VERR_ACCESS_DENIED;
    28142817}
    28152818
    28162819
    28172820/** @copydoc PDMDEVHLPR3::pfnPhysWrite */
    2818 static DECLCALLBACK(void) pdmR3DevHlp_Untrusted_PhysWrite(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite)
     2821static DECLCALLBACK(int) pdmR3DevHlp_Untrusted_PhysWrite(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite)
    28192822{
    28202823    PDMDEV_ASSERT_DEVINS(pDevIns);
     
    28232826    NOREF(pvBuf);
    28242827    NOREF(cbWrite);
     2828    return VERR_ACCESS_DENIED;
     2829}
     2830
     2831
     2832/** @copydoc PDMDEVHLPR3::pfnPhysGCPhys2CCPtr */
     2833static DECLCALLBACK(int) pdmR3DevHlp_Untrusted_PhysGCPhys2CCPtr(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, uint32_t fFlags, void **ppv, PPGMPAGEMAPLOCK pLock)
     2834{
     2835    PDMDEV_ASSERT_DEVINS(pDevIns);
     2836    AssertReleaseMsgFailed(("Untrusted device called trusted helper! '%s'/%d\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance));
     2837    NOREF(GCPhys);
     2838    NOREF(fFlags);
     2839    NOREF(ppv);
     2840    NOREF(pLock);
     2841    return VERR_ACCESS_DENIED;
     2842}
     2843
     2844
     2845/** @copydoc PDMDEVHLPR3::pfnPhysGCPhys2CCPtrReadOnly */
     2846static DECLCALLBACK(int) pdmR3DevHlp_Untrusted_PhysGCPhys2CCPtrReadOnly(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, uint32_t fFlags, const void **ppv, PPGMPAGEMAPLOCK pLock)
     2847{
     2848    PDMDEV_ASSERT_DEVINS(pDevIns);
     2849    AssertReleaseMsgFailed(("Untrusted device called trusted helper! '%s'/%d\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance));
     2850    NOREF(GCPhys);
     2851    NOREF(fFlags);
     2852    NOREF(ppv);
     2853    NOREF(pLock);
     2854    return VERR_ACCESS_DENIED;
     2855}
     2856
     2857
     2858/** @copydoc PDMDEVHLPR3::pfnPhysReleasePageMappingLock */
     2859static DECLCALLBACK(void) pdmR3DevHlp_Untrusted_PhysReleasePageMappingLock(PPDMDEVINS pDevIns, PPGMPAGEMAPLOCK pLock)
     2860{
     2861    PDMDEV_ASSERT_DEVINS(pDevIns);
     2862    AssertReleaseMsgFailed(("Untrusted device called trusted helper! '%s'/%d\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance));
     2863    NOREF(pLock);
    28252864}
    28262865
     
    28462885    NOREF(pvSrc);
    28472886    NOREF(cb);
    2848     return VERR_ACCESS_DENIED;
    2849 }
    2850 
    2851 
    2852 /** @copydoc PDMDEVHLPR3::pfnPhysReserve */
    2853 static DECLCALLBACK(int) pdmR3DevHlp_Untrusted_PhysReserve(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, RTUINT cbRange, const char *pszDesc)
    2854 {
    2855     PDMDEV_ASSERT_DEVINS(pDevIns);
    2856     AssertReleaseMsgFailed(("Untrusted device called trusted helper! '%s'/%d\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance));
    2857     NOREF(GCPhys);
    2858     NOREF(cbRange);
    2859     return VERR_ACCESS_DENIED;
    2860 }
    2861 
    2862 
    2863 /** @copydoc PDMDEVHLPR3::pfnObsoletePhys2HCVirt */
    2864 static DECLCALLBACK(int) pdmR3DevHlp_Untrusted_Obsolete_Phys2HCVirt(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, RTUINT cbRange, PRTHCPTR ppvHC)
    2865 {
    2866     PDMDEV_ASSERT_DEVINS(pDevIns);
    2867     AssertReleaseMsgFailed(("Untrusted device called trusted helper! '%s'/%d\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance));
    2868     NOREF(GCPhys);
    2869     NOREF(cbRange);
    2870     NOREF(ppvHC);
    2871     return VERR_ACCESS_DENIED;
    2872 }
    2873 
    2874 
    2875 /** @copydoc PDMDEVHLPR3::pfnObsoletePhysGCPtr2HCPtr */
    2876 static DECLCALLBACK(int) pdmR3DevHlp_Untrusted_Obsolete_PhysGCPtr2HCPtr(PPDMDEVINS pDevIns, RTGCPTR GCPtr, PRTHCPTR pHCPtr)
    2877 {
    2878     PDMDEV_ASSERT_DEVINS(pDevIns);
    2879     AssertReleaseMsgFailed(("Untrusted device called trusted helper! '%s'/%d\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance));
    2880     NOREF(GCPtr);
    2881     NOREF(pHCPtr);
    28822887    return VERR_ACCESS_DENIED;
    28832888}
     
    31833188    pdmR3DevHlp_Untrusted_PhysRead,
    31843189    pdmR3DevHlp_Untrusted_PhysWrite,
     3190    pdmR3DevHlp_Untrusted_PhysGCPhys2CCPtr,
     3191    pdmR3DevHlp_Untrusted_PhysGCPhys2CCPtrReadOnly,
     3192    pdmR3DevHlp_Untrusted_PhysReleasePageMappingLock,
    31853193    pdmR3DevHlp_Untrusted_PhysReadGCVirt,
    31863194    pdmR3DevHlp_Untrusted_PhysWriteGCVirt,
    3187     pdmR3DevHlp_Untrusted_PhysReserve,
    3188     pdmR3DevHlp_Untrusted_Obsolete_Phys2HCVirt,
    3189     pdmR3DevHlp_Untrusted_Obsolete_PhysGCPtr2HCPtr,
    31903195    pdmR3DevHlp_Untrusted_A20IsEnabled,
    31913196    pdmR3DevHlp_Untrusted_A20Set,
  • trunk/src/VBox/VMM/PGMPhys.cpp

    r18046 r18101  
    345345}
    346346
     347
     348#ifdef VBOX_WITH_NEW_PHYS_CODE
     349/**
     350 * VMR3ReqCall worker for PGMR3PhysGCPhys2CCPtrExternal to make pages writable.
     351 * 
     352 * @returns see PGMR3PhysGCPhys2CCPtrExternal
     353 * @param   pVM         The VM handle.
     354 * @param   pGCPhys     Pointer to the guest physical address.
     355 * @param   ppv         Where to store the mapping address.
     356 * @param   pLock       Where to store the lock.
     357 */
     358static DECLCALLBACK(int) pgmR3PhysGCPhys2CCPtrDelegated(PVM pVM, PRTGCPHYS pGCPhys, void **ppv, PPGMPAGEMAPLOCK pLock)
     359{
     360    /*
     361     * Just hand it to PGMPhysGCPhys2CCPtr and check that it's not a page with
     362     * an access handler after it succeeds.
     363     */
     364    int rc = pgmLock(pVM);
     365    AssertRCReturn(rc, rc);
     366
     367    rc = PGMPhysGCPhys2CCPtr(pVM, *pGCPhys, ppv, pLock);
     368    if (RT_SUCCESS(rc))
     369    {
     370        PPGMPAGEMAPTLBE pTlbe;
     371        int rc2 = pgmPhysPageQueryTlbe(&pVM->pgm.s, *pGCPhys, &pTlbe);
     372        AssertFatalRC(rc2);
     373        PPGMPAGE pPage = pTlbe->pPage;
     374#if 1
     375        if (PGM_PAGE_IS_MMIO(pPage))
     376#else
     377        if (PGM_PAGE_HAS_ACTIVE_HANDLERS(pPage))
     378#endif
     379        {
     380            PGMPhysReleasePageMappingLock(pVM, pLock);
     381            rc = VERR_PGM_PHYS_PAGE_RESERVED;
     382        }
     383    }
     384
     385    pgmUnlock(pVM);
     386    return rc;
     387}
     388#endif /* VBOX_WITH_NEW_PHYS_CODE */
     389
     390
     391/**
     392 * Requests the mapping of a guest page into ring-3, external threads.
     393 *
     394 * When you're done with the page, call PGMPhysReleasePageMappingLock() ASAP to
     395 * release it.
     396 *
     397 * This API will assume your intention is to write to the page, and will
     398 * therefore replace shared and zero pages. If you do not intend to modify the
     399 * page, use the PGMR3PhysGCPhys2CCPtrReadOnlyExternal() API.
     400 *
     401 * @returns VBox status code.
     402 * @retval  VINF_SUCCESS on success.
     403 * @retval  VERR_PGM_PHYS_PAGE_RESERVED it it's a valid page but has no physical
     404 *          backing or if the page has any active access handlers. The caller
     405 *          must fall back on using PGMR3PhysWriteExternal.
     406 * @retval  VERR_PGM_INVALID_GC_PHYSICAL_ADDRESS if it's not a valid physical address.
     407 *
     408 * @param   pVM         The VM handle.
     409 * @param   GCPhys      The guest physical address of the page that should be mapped.
     410 * @param   ppv         Where to store the address corresponding to GCPhys.
     411 * @param   pLock       Where to store the lock information that PGMPhysReleasePageMappingLock needs.
     412 *
     413 * @remark  Avoid calling this API from within critical sections (other than the
     414 *          PGM one) because of the deadlock risk when we have to delegating the
     415 *          task to an EMT.
     416 * @thread  Any.
     417 */
     418VMMR3DECL(int) PGMR3PhysGCPhys2CCPtrExternal(PVM pVM, RTGCPHYS GCPhys, void **ppv, PPGMPAGEMAPLOCK pLock)
     419{
     420    VM_ASSERT_OTHER_THREAD(pVM);
     421    AssertPtr(ppv);
     422    AssertPtr(pLock);
     423
     424#ifdef VBOX_WITH_NEW_PHYS_CODE
     425    int rc = pgmLock(pVM);
     426    AssertRCReturn(rc, rc);
     427
     428    /*
     429     * Query the Physical TLB entry for the page (may fail).
     430     */
     431    PPGMPAGEMAPTLBE pTlbe;
     432    rc = pgmPhysPageQueryTlbe(&pVM->pgm.s, GCPhys, &pTlbe);
     433    if (RT_SUCCESS(rc))
     434    {
     435        PPGMPAGE pPage = pTlbe->pPage;
     436#if 1
     437        if (PGM_PAGE_IS_MMIO(pPage))
     438            rc = VERR_PGM_PHYS_PAGE_RESERVED;
     439#else
     440        if (PGM_PAGE_HAS_ACTIVE_HANDLERS(pPage))
     441            rc = VERR_PGM_PHYS_PAGE_RESERVED;
     442#endif
     443        else
     444        {
     445            /*
     446             * If the page is shared, the zero page, or being write monitored
     447             * it must be converted to an page that's writable if possible.
     448             * This has to be done on an EMT.
     449             */
     450            if (RT_UNLIKELY(PGM_PAGE_GET_STATE(pPage) != PGM_PAGE_STATE_ALLOCATED))
     451            {
     452                pgmUnlock(pVM);
     453   
     454                PVMREQ pReq = NULL;
     455                rc = VMR3ReqCall(pVM, VMREQDEST_ANY, &pReq, RT_INDEFINITE_WAIT,
     456                                 (PFNRT)pgmR3PhysGCPhys2CCPtrDelegated, 4, pVM, &GCPhys, ppv, pLock);
     457                if (RT_SUCCESS(rc))
     458                {
     459                    rc = pReq->iStatus;
     460                    VMR3ReqFree(pReq);
     461                }
     462                return rc;
     463            }
     464
     465            /*
     466             * Now, just perform the locking and calculate the return address.
     467             */
     468            PPGMPAGEMAP pMap = pTlbe->pMap;
     469            pMap->cRefs++;
     470#if 0 /** @todo implement locking properly */
     471            if (RT_LIKELY(pPage->cLocks != PGM_PAGE_MAX_LOCKS))
     472                if (RT_UNLIKELY(++pPage->cLocks == PGM_PAGE_MAX_LOCKS))
     473                {
     474                    AssertMsgFailed(("%RGp is entering permanent locked state!\n", GCPhys));
     475                    pMap->cRefs++; /* Extra ref to prevent it from going away. */
     476                }
     477#endif
     478            *ppv = (void *)((uintptr_t)pTlbe->pv | (GCPhys & PAGE_OFFSET_MASK));
     479            pLock->pvPage = pPage;
     480            pLock->pvMap = pMap;
     481        }
     482    }
     483
     484    pgmUnlock(pVM);
     485    return rc;
     486
     487#else  /* !VBOX_WITH_NEW_PHYS_CODE */
     488    /*
     489     * Fallback code.
     490     */
     491    return PGMPhysGCPhys2R3Ptr(pVM, GCPhys, 1, (PRTR3PTR)ppv);
     492#endif /* !VBOX_WITH_NEW_PHYS_CODE */
     493}
     494
     495
     496/**
     497 * Requests the mapping of a guest page into ring-3, external threads.
     498 *
     499 * When you're done with the page, call PGMPhysReleasePageMappingLock() ASAP to
     500 * release it.
     501 *
     502 * @returns VBox status code.
     503 * @retval  VINF_SUCCESS on success.
     504 * @retval  VERR_PGM_PHYS_PAGE_RESERVED it it's a valid page but has no physical
     505 *          backing or if the page as an active ALL access handler. The caller
     506 *          must fall back on using PGMPhysRead.
     507 * @retval  VERR_PGM_INVALID_GC_PHYSICAL_ADDRESS if it's not a valid physical address.
     508 *
     509 * @param   pVM         The VM handle.
     510 * @param   GCPhys      The guest physical address of the page that should be mapped.
     511 * @param   ppv         Where to store the address corresponding to GCPhys.
     512 * @param   pLock       Where to store the lock information that PGMPhysReleasePageMappingLock needs.
     513 *
     514 * @remark  Avoid calling this API from within critical sections (other than
     515 *          the PGM one) because of the deadlock risk.
     516 * @thread  Any.
     517 */
     518VMMR3DECL(int) PGMR3PhysGCPhys2CCPtrReadOnlyExternal(PVM pVM, RTGCPHYS GCPhys, void const **ppv, PPGMPAGEMAPLOCK pLock)
     519{
     520#ifdef VBOX_WITH_NEW_PHYS_CODE
     521    int rc = pgmLock(pVM);
     522    AssertRCReturn(rc, rc);
     523
     524    /*
     525     * Query the Physical TLB entry for the page (may fail).
     526     */
     527    PPGMPAGEMAPTLBE pTlbe;
     528    rc = pgmPhysPageQueryTlbe(&pVM->pgm.s, GCPhys, &pTlbe);
     529    if (RT_SUCCESS(rc))
     530    {
     531        PPGMPAGE pPage = pTlbe->pPage;
     532#if 1
     533        /* MMIO pages doesn't have any readable backing. */
     534        if (PGM_PAGE_IS_MMIO(pPage))
     535            rc = VERR_PGM_PHYS_PAGE_RESERVED;
     536#else
     537        if (PGM_PAGE_HAS_ACTIVE_ALL_HANDLERS(pPage))
     538            rc = VERR_PGM_PHYS_PAGE_RESERVED;
     539#endif
     540        else
     541        {
     542            /*
     543             * Now, just perform the locking and calculate the return address.
     544             */
     545            PPGMPAGEMAP pMap = pTlbe->pMap;
     546            pMap->cRefs++;
     547#if 0 /** @todo implement locking properly */
     548            if (RT_LIKELY(pPage->cLocks != PGM_PAGE_MAX_LOCKS))
     549                if (RT_UNLIKELY(++pPage->cLocks == PGM_PAGE_MAX_LOCKS))
     550                {
     551                    AssertMsgFailed(("%RGp is entering permanent locked state!\n", GCPhys));
     552                    pMap->cRefs++; /* Extra ref to prevent it from going away. */
     553                }
     554#endif
     555            *ppv = (void *)((uintptr_t)pTlbe->pv | (GCPhys & PAGE_OFFSET_MASK));
     556            pLock->pvPage = pPage;
     557            pLock->pvMap = pMap;
     558        }
     559    }
     560
     561    pgmUnlock(pVM);
     562    return rc;
     563
     564#else  /* !VBOX_WITH_NEW_PHYS_CODE */
     565    /*
     566     * Fallback code.
     567     */
     568    return PGMPhysGCPhys2CCPtr(pVM, GCPhys, (void **)ppv, pLock);
     569#endif /* !VBOX_WITH_NEW_PHYS_CODE */
     570}
    347571
    348572
  • trunk/src/VBox/VMM/VMMAll/PGMAllPhys.cpp

    r18073 r18101  
    939939 * @param   ppv         Where to store the address corresponding to GCPhys.
    940940 * @param   pLock       Where to store the lock information that PGMPhysReleasePageMappingLock needs.
    941  *
    942  * @remark  Avoid calling this API from within critical sections (other than
    943  *          the PGM one) because of the deadlock risk.
     941 * 
     942 * @remarks The caller is responsible for dealing with access handlers.
     943 * @todo    Add an informational return code for pages with access handlers?
     944 * 
     945 * @remark  Avoid calling this API from within critical sections (other than the
     946 *          PGM one) because of the deadlock risk. External threads may need to
     947 *          delegate jobs to the EMTs.
    944948 * @thread  Any thread.
    945949 */
     
    972976    }
    973977
    974 # else
     978# else  /* IN_RING3 || IN_RING0 */
    975979    int rc = pgmLock(pVM);
    976980    AssertRCReturn(rc, rc);
     
    10411045 * This API should only be used for very short term, as it will consume
    10421046 * scarse resources (R0 and GC) in the mapping cache. When you're done
    1043  * with the page, call PGMPhysReleasePageMappingLock() ASAP to release it.
    1044  *
     1047 * with the page, call PGMPhysReleasePageMappingLock() ASAP to release it. 
     1048 * 
    10451049 * @returns VBox status code.
    10461050 * @retval  VINF_SUCCESS on success.
     
    10531057 * @param   pLock       Where to store the lock information that PGMPhysReleasePageMappingLock needs.
    10541058 *
     1059 * @remarks The caller is responsible for dealing with access handlers.
     1060 * @todo    Add an informational return code for pages with access handlers?
     1061 * 
    10551062 * @remark  Avoid calling this API from within critical sections (other than
    10561063 *          the PGM one) because of the deadlock risk.
     
    10591066VMMDECL(int) PGMPhysGCPhys2CCPtrReadOnly(PVM pVM, RTGCPHYS GCPhys, void const **ppv, PPGMPAGEMAPLOCK pLock)
    10601067{
    1061     /** @todo implement this */
     1068#ifdef VBOX_WITH_NEW_PHYS_CODE
     1069# if defined(IN_RC) || defined(VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0)
     1070
     1071    /*
     1072     * Find the page and make sure it's readable.
     1073     */
     1074    PPGMPAGE pPage;
     1075    int rc = pgmPhysGetPageEx(&pVM->pgm.s, GCPhys, &pPage);
     1076    if (RT_SUCCESS(rc))
     1077    {
     1078        if (RT_UNLIKELY(PGM_PAGE_IS_MMIO(pPage)))
     1079            rc = VERR_PGM_PHYS_PAGE_RESERVED;
     1080        else
     1081        {
     1082            *ppv = pgmDynMapHCPageOff(&pVM->pgm.s, PGM_PAGE_GET_HCPHYS(pPage) | (GCPhys & PAGE_OFFSET_MASK)); /** @todo add a read only flag? */
     1083#if 0
     1084            pLock->pvMap = 0;
     1085            pLock->pvPage = pPage;
     1086#else
     1087            pLock->u32Dummy = UINT32_MAX;
     1088#endif
     1089            AssertMsg(rc == VINF_SUCCESS || rc == VINF_PGM_SYNC_CR3 /* not returned */, ("%Rrc\n", rc));
     1090            rc = VINF_SUCCESS;
     1091        }
     1092    }
     1093
     1094# else  /* IN_RING3 || IN_RING0 */
     1095    int rc = pgmLock(pVM);
     1096    AssertRCReturn(rc, rc);
     1097
     1098    /*
     1099     * Query the Physical TLB entry for the page (may fail).
     1100     */
     1101    PPGMPAGEMAPTLBE pTlbe;
     1102    rc = pgmPhysPageQueryTlbe(&pVM->pgm.s, GCPhys, &pTlbe);
     1103    if (RT_SUCCESS(rc))
     1104    {
     1105        /* MMIO pages doesn't have any readable backing. */
     1106        PPGMPAGE pPage = pTlbe->pPage;
     1107        if (RT_UNLIKELY(PGM_PAGE_IS_MMIO(pPage)))
     1108            rc = VERR_PGM_PHYS_PAGE_RESERVED;
     1109        else
     1110        {
     1111            /*
     1112             * Now, just perform the locking and calculate the return address.
     1113             */
     1114            PPGMPAGEMAP pMap = pTlbe->pMap;
     1115            pMap->cRefs++;
     1116#if 0 /** @todo implement locking properly */
     1117            if (RT_LIKELY(pPage->cLocks != PGM_PAGE_MAX_LOCKS))
     1118                if (RT_UNLIKELY(++pPage->cLocks == PGM_PAGE_MAX_LOCKS))
     1119                {
     1120                    AssertMsgFailed(("%RGp is entering permanent locked state!\n", GCPhys));
     1121                    pMap->cRefs++; /* Extra ref to prevent it from going away. */
     1122                }
     1123#endif
     1124            *ppv = (void *)((uintptr_t)pTlbe->pv | (GCPhys & PAGE_OFFSET_MASK));
     1125            pLock->pvPage = pPage;
     1126            pLock->pvMap = pMap;
     1127        }
     1128    }
     1129
     1130    pgmUnlock(pVM);
     1131#endif /* IN_RING3 || IN_RING0 */
     1132    return rc;
     1133
     1134#else  /* !VBOX_WITH_NEW_PHYS_CODE */
     1135    /*
     1136     * Fallback code.
     1137     */
    10621138    return PGMPhysGCPhys2CCPtr(pVM, GCPhys, (void **)ppv, pLock);
     1139#endif /* !VBOX_WITH_NEW_PHYS_CODE */
    10631140}
    10641141
  • trunk/src/VBox/VMM/VMMGC/PDMGCDevice.cpp

    r17534 r18101  
    5959static DECLCALLBACK(void) pdmGCDevHlp_PCISetIrq(PPDMDEVINS pDevIns, int iIrq, int iLevel);
    6060static DECLCALLBACK(void) pdmGCDevHlp_ISASetIrq(PPDMDEVINS pDevIns, int iIrq, int iLevel);
    61 static DECLCALLBACK(void) pdmGCDevHlp_PhysRead(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead);
    62 static DECLCALLBACK(void) pdmGCDevHlp_PhysWrite(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite);
     61static DECLCALLBACK(int) pdmGCDevHlp_PhysRead(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead);
     62static DECLCALLBACK(int) pdmGCDevHlp_PhysWrite(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite);
    6363static DECLCALLBACK(bool) pdmGCDevHlp_A20IsEnabled(PPDMDEVINS pDevIns);
    6464static DECLCALLBACK(int)  pdmGCDevHlp_VMSetError(PPDMDEVINS pDevIns, int rc, RT_SRC_POS_DECL, const char *pszFormat, ...);
     
    248248
    249249/** @copydoc PDMDEVHLPRC::pfnPhysRead */
    250 static DECLCALLBACK(void) pdmGCDevHlp_PhysRead(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead)
     250static DECLCALLBACK(int) pdmGCDevHlp_PhysRead(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead)
    251251{
    252252    PDMDEV_ASSERT_DEVINS(pDevIns);
     
    259259#else
    260260    PGMPhysRead(pDevIns->Internal.s.pVMRC, GCPhys, pvBuf, cbRead);
     261    int rc = VINF_SUCCESS;
    261262#endif
    262263
    263     Log(("pdmGCDevHlp_PhysRead: caller=%p/%d: returns void\n", pDevIns, pDevIns->iInstance));
     264    Log(("pdmGCDevHlp_PhysRead: caller=%p/%d: returns %Rrc\n", pDevIns, pDevIns->iInstance, rc));
     265    return rc;
    264266}
    265267
    266268
    267269/** @copydoc PDMDEVHLPRC::pfnPhysWrite */
    268 static DECLCALLBACK(void) pdmGCDevHlp_PhysWrite(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite)
     270static DECLCALLBACK(int) pdmGCDevHlp_PhysWrite(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite)
    269271{
    270272    PDMDEV_ASSERT_DEVINS(pDevIns);
     
    277279#else
    278280    PGMPhysWrite(pDevIns->Internal.s.pVMRC, GCPhys, pvBuf, cbWrite);
     281    int rc = VINF_SUCCESS;
    279282#endif
    280283
    281     Log(("pdmGCDevHlp_PhysWrite: caller=%p/%d: returns void\n", pDevIns, pDevIns->iInstance));
     284    Log(("pdmGCDevHlp_PhysWrite: caller=%p/%d: returns %Rrc\n", pDevIns, pDevIns->iInstance, rc));
     285    return rc;
    282286}
    283287
  • trunk/src/VBox/VMM/VMMR0/PDMR0Device.cpp

    r17534 r18101  
    6060static DECLCALLBACK(void) pdmR0DevHlp_PCISetIrq(PPDMDEVINS pDevIns, int iIrq, int iLevel);
    6161static DECLCALLBACK(void) pdmR0DevHlp_ISASetIrq(PPDMDEVINS pDevIns, int iIrq, int iLevel);
    62 static DECLCALLBACK(void) pdmR0DevHlp_PhysRead(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead);
    63 static DECLCALLBACK(void) pdmR0DevHlp_PhysWrite(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite);
     62static DECLCALLBACK(int) pdmR0DevHlp_PhysRead(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead);
     63static DECLCALLBACK(int) pdmR0DevHlp_PhysWrite(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite);
    6464static DECLCALLBACK(bool) pdmR0DevHlp_A20IsEnabled(PPDMDEVINS pDevIns);
    6565static DECLCALLBACK(int)  pdmR0DevHlp_VMSetError(PPDMDEVINS pDevIns, int rc, RT_SRC_POS_DECL, const char *pszFormat, ...);
     
    251251
    252252/** @copydoc PDMDEVHLPR0::pfnPhysRead */
    253 static DECLCALLBACK(void) pdmR0DevHlp_PhysRead(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead)
     253static DECLCALLBACK(int) pdmR0DevHlp_PhysRead(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead)
    254254{
    255255    PDMDEV_ASSERT_DEVINS(pDevIns);
     
    262262#else
    263263    PGMPhysRead(pDevIns->Internal.s.pVMR0, GCPhys, pvBuf, cbRead);
     264    int rc = VINF_SUCCESS;
    264265#endif
    265266
    266     Log(("pdmR0DevHlp_PhysRead: caller=%p/%d: returns void\n", pDevIns, pDevIns->iInstance));
     267    Log(("pdmR0DevHlp_PhysRead: caller=%p/%d: returns %Rrc\n", pDevIns, pDevIns->iInstance, rc));
     268    return rc;
    267269}
    268270
    269271
    270272/** @copydoc PDMDEVHLPR0::pfnPhysWrite */
    271 static DECLCALLBACK(void) pdmR0DevHlp_PhysWrite(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite)
     273static DECLCALLBACK(int) pdmR0DevHlp_PhysWrite(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite)
    272274{
    273275    PDMDEV_ASSERT_DEVINS(pDevIns);
     
    280282#else
    281283    PGMPhysWrite(pDevIns->Internal.s.pVMR0, GCPhys, pvBuf, cbWrite);
     284    int rc = VINF_SUCCESS;
    282285#endif
    283286
    284     Log(("pdmR0DevHlp_PhysWrite: caller=%p/%d: returns void\n", pDevIns, pDevIns->iInstance));
     287    Log(("pdmR0DevHlp_PhysWrite: caller=%p/%d: returns %Rrc\n", pDevIns, pDevIns->iInstance, rc));
     288    return rc;
    285289}
    286290
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