- Timestamp:
- Mar 19, 2009 10:39:06 PM (16 years ago)
- Location:
- trunk/src/VBox
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/PC/DevPcArch.c
r17251 r18101 259 259 * Note: This will be removed before long. 260 260 */ 261 rc = PDMDevHlpPhysReserve(pDevIns, 0x000a0000, 0x50000, "Low ROM Region");261 rc = MMR3PhysReserve(PDMDevHlpGetVM(pDevIns), 0x000a0000, 0x50000, "Low ROM Region"); 262 262 if (RT_FAILURE(rc)) 263 263 return rc; 264 rc = PDMDevHlpPhysReserve(pDevIns, 0xfff80000, 0x80000, "High ROM Region");264 rc = MMR3PhysReserve(PDMDevHlpGetVM(pDevIns), 0xfff80000, 0x80000, "High ROM Region"); 265 265 if (RT_FAILURE(rc)) 266 266 return rc; -
trunk/src/VBox/VMM/PDMDevHlp.cpp
r17534 r18101 2024 2024 2025 2025 /** @copydoc PDMDEVHLPR3::pfnPhysRead */ 2026 static DECLCALLBACK( void) pdmR3DevHlp_PhysRead(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead)2026 static DECLCALLBACK(int) pdmR3DevHlp_PhysRead(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead) 2027 2027 { 2028 2028 PDMDEV_ASSERT_DEVINS(pDevIns); … … 2033 2033 int rc; 2034 2034 #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 2036 2038 rc = PGMR3PhysReadExternal(pVM, GCPhys, pvBuf, cbRead); 2037 else2038 rc = PGMPhysRead(pVM, GCPhys, pvBuf, cbRead);2039 2039 #else 2040 2040 PGMPhysRead(pVM, GCPhys, pvBuf, cbRead); … … 2042 2042 #endif 2043 2043 Log(("pdmR3DevHlp_PhysRead: caller='%s'/%d: returns %Rrc\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, rc)); 2044 /** @todo return rc; */ NOREF(rc);2044 return rc; 2045 2045 } 2046 2046 2047 2047 2048 2048 /** @copydoc PDMDEVHLPR3::pfnPhysWrite */ 2049 static DECLCALLBACK( void) pdmR3DevHlp_PhysWrite(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite)2049 static DECLCALLBACK(int) pdmR3DevHlp_PhysWrite(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite) 2050 2050 { 2051 2051 PDMDEV_ASSERT_DEVINS(pDevIns); … … 2056 2056 int rc; 2057 2057 #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 2059 2061 rc = PGMR3PhysWriteExternal(pVM, GCPhys, pvBuf, cbWrite); 2060 else2061 rc = PGMPhysWrite(pVM, GCPhys, pvBuf, cbWrite);2062 2062 #else 2063 2063 PGMPhysWrite(pVM, GCPhys, pvBuf, cbWrite); … … 2065 2065 #endif 2066 2066 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 */ 2072 static 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 */ 2088 static 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 */ 2104 static 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)); 2068 2114 } 2069 2115 … … 2106 2152 2107 2153 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_CODE2115 AssertFailed();2116 return VERR_ACCESS_DENIED;2117 #else2118 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 #endif2129 }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;2152 2154 } 2153 2155 … … 2703 2705 pdmR3DevHlp_PhysRead, 2704 2706 pdmR3DevHlp_PhysWrite, 2707 pdmR3DevHlp_PhysGCPhys2CCPtr, 2708 pdmR3DevHlp_PhysGCPhys2CCPtrReadOnly, 2709 pdmR3DevHlp_PhysReleasePageMappingLock, 2705 2710 pdmR3DevHlp_PhysReadGCVirt, 2706 2711 pdmR3DevHlp_PhysWriteGCVirt, 2707 pdmR3DevHlp_PhysReserve,2708 pdmR3DevHlp_Obsolete_Phys2HCVirt,2709 pdmR3DevHlp_Obsolete_PhysGCPtr2HCPtr,2710 2712 pdmR3DevHlp_A20IsEnabled, 2711 2713 pdmR3DevHlp_A20Set, … … 2805 2807 2806 2808 /** @copydoc PDMDEVHLPR3::pfnPhysRead */ 2807 static DECLCALLBACK( void) pdmR3DevHlp_Untrusted_PhysRead(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead)2809 static DECLCALLBACK(int) pdmR3DevHlp_Untrusted_PhysRead(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead) 2808 2810 { 2809 2811 PDMDEV_ASSERT_DEVINS(pDevIns); … … 2812 2814 NOREF(pvBuf); 2813 2815 NOREF(cbRead); 2816 return VERR_ACCESS_DENIED; 2814 2817 } 2815 2818 2816 2819 2817 2820 /** @copydoc PDMDEVHLPR3::pfnPhysWrite */ 2818 static DECLCALLBACK( void) pdmR3DevHlp_Untrusted_PhysWrite(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite)2821 static DECLCALLBACK(int) pdmR3DevHlp_Untrusted_PhysWrite(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite) 2819 2822 { 2820 2823 PDMDEV_ASSERT_DEVINS(pDevIns); … … 2823 2826 NOREF(pvBuf); 2824 2827 NOREF(cbWrite); 2828 return VERR_ACCESS_DENIED; 2829 } 2830 2831 2832 /** @copydoc PDMDEVHLPR3::pfnPhysGCPhys2CCPtr */ 2833 static 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 */ 2846 static 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 */ 2859 static 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); 2825 2864 } 2826 2865 … … 2846 2885 NOREF(pvSrc); 2847 2886 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);2882 2887 return VERR_ACCESS_DENIED; 2883 2888 } … … 3183 3188 pdmR3DevHlp_Untrusted_PhysRead, 3184 3189 pdmR3DevHlp_Untrusted_PhysWrite, 3190 pdmR3DevHlp_Untrusted_PhysGCPhys2CCPtr, 3191 pdmR3DevHlp_Untrusted_PhysGCPhys2CCPtrReadOnly, 3192 pdmR3DevHlp_Untrusted_PhysReleasePageMappingLock, 3185 3193 pdmR3DevHlp_Untrusted_PhysReadGCVirt, 3186 3194 pdmR3DevHlp_Untrusted_PhysWriteGCVirt, 3187 pdmR3DevHlp_Untrusted_PhysReserve,3188 pdmR3DevHlp_Untrusted_Obsolete_Phys2HCVirt,3189 pdmR3DevHlp_Untrusted_Obsolete_PhysGCPtr2HCPtr,3190 3195 pdmR3DevHlp_Untrusted_A20IsEnabled, 3191 3196 pdmR3DevHlp_Untrusted_A20Set, -
trunk/src/VBox/VMM/PGMPhys.cpp
r18046 r18101 345 345 } 346 346 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 */ 358 static 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 */ 418 VMMR3DECL(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 */ 518 VMMR3DECL(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 } 347 571 348 572 -
trunk/src/VBox/VMM/VMMAll/PGMAllPhys.cpp
r18073 r18101 939 939 * @param ppv Where to store the address corresponding to GCPhys. 940 940 * @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. 944 948 * @thread Any thread. 945 949 */ … … 972 976 } 973 977 974 # else 978 # else /* IN_RING3 || IN_RING0 */ 975 979 int rc = pgmLock(pVM); 976 980 AssertRCReturn(rc, rc); … … 1041 1045 * This API should only be used for very short term, as it will consume 1042 1046 * 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 * 1045 1049 * @returns VBox status code. 1046 1050 * @retval VINF_SUCCESS on success. … … 1053 1057 * @param pLock Where to store the lock information that PGMPhysReleasePageMappingLock needs. 1054 1058 * 1059 * @remarks The caller is responsible for dealing with access handlers. 1060 * @todo Add an informational return code for pages with access handlers? 1061 * 1055 1062 * @remark Avoid calling this API from within critical sections (other than 1056 1063 * the PGM one) because of the deadlock risk. … … 1059 1066 VMMDECL(int) PGMPhysGCPhys2CCPtrReadOnly(PVM pVM, RTGCPHYS GCPhys, void const **ppv, PPGMPAGEMAPLOCK pLock) 1060 1067 { 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 */ 1062 1138 return PGMPhysGCPhys2CCPtr(pVM, GCPhys, (void **)ppv, pLock); 1139 #endif /* !VBOX_WITH_NEW_PHYS_CODE */ 1063 1140 } 1064 1141 -
trunk/src/VBox/VMM/VMMGC/PDMGCDevice.cpp
r17534 r18101 59 59 static DECLCALLBACK(void) pdmGCDevHlp_PCISetIrq(PPDMDEVINS pDevIns, int iIrq, int iLevel); 60 60 static 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);61 static DECLCALLBACK(int) pdmGCDevHlp_PhysRead(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead); 62 static DECLCALLBACK(int) pdmGCDevHlp_PhysWrite(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite); 63 63 static DECLCALLBACK(bool) pdmGCDevHlp_A20IsEnabled(PPDMDEVINS pDevIns); 64 64 static DECLCALLBACK(int) pdmGCDevHlp_VMSetError(PPDMDEVINS pDevIns, int rc, RT_SRC_POS_DECL, const char *pszFormat, ...); … … 248 248 249 249 /** @copydoc PDMDEVHLPRC::pfnPhysRead */ 250 static DECLCALLBACK( void) pdmGCDevHlp_PhysRead(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead)250 static DECLCALLBACK(int) pdmGCDevHlp_PhysRead(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead) 251 251 { 252 252 PDMDEV_ASSERT_DEVINS(pDevIns); … … 259 259 #else 260 260 PGMPhysRead(pDevIns->Internal.s.pVMRC, GCPhys, pvBuf, cbRead); 261 int rc = VINF_SUCCESS; 261 262 #endif 262 263 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; 264 266 } 265 267 266 268 267 269 /** @copydoc PDMDEVHLPRC::pfnPhysWrite */ 268 static DECLCALLBACK( void) pdmGCDevHlp_PhysWrite(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite)270 static DECLCALLBACK(int) pdmGCDevHlp_PhysWrite(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite) 269 271 { 270 272 PDMDEV_ASSERT_DEVINS(pDevIns); … … 277 279 #else 278 280 PGMPhysWrite(pDevIns->Internal.s.pVMRC, GCPhys, pvBuf, cbWrite); 281 int rc = VINF_SUCCESS; 279 282 #endif 280 283 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; 282 286 } 283 287 -
trunk/src/VBox/VMM/VMMR0/PDMR0Device.cpp
r17534 r18101 60 60 static DECLCALLBACK(void) pdmR0DevHlp_PCISetIrq(PPDMDEVINS pDevIns, int iIrq, int iLevel); 61 61 static 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);62 static DECLCALLBACK(int) pdmR0DevHlp_PhysRead(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead); 63 static DECLCALLBACK(int) pdmR0DevHlp_PhysWrite(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite); 64 64 static DECLCALLBACK(bool) pdmR0DevHlp_A20IsEnabled(PPDMDEVINS pDevIns); 65 65 static DECLCALLBACK(int) pdmR0DevHlp_VMSetError(PPDMDEVINS pDevIns, int rc, RT_SRC_POS_DECL, const char *pszFormat, ...); … … 251 251 252 252 /** @copydoc PDMDEVHLPR0::pfnPhysRead */ 253 static DECLCALLBACK( void) pdmR0DevHlp_PhysRead(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead)253 static DECLCALLBACK(int) pdmR0DevHlp_PhysRead(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead) 254 254 { 255 255 PDMDEV_ASSERT_DEVINS(pDevIns); … … 262 262 #else 263 263 PGMPhysRead(pDevIns->Internal.s.pVMR0, GCPhys, pvBuf, cbRead); 264 int rc = VINF_SUCCESS; 264 265 #endif 265 266 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; 267 269 } 268 270 269 271 270 272 /** @copydoc PDMDEVHLPR0::pfnPhysWrite */ 271 static DECLCALLBACK( void) pdmR0DevHlp_PhysWrite(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite)273 static DECLCALLBACK(int) pdmR0DevHlp_PhysWrite(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite) 272 274 { 273 275 PDMDEV_ASSERT_DEVINS(pDevIns); … … 280 282 #else 281 283 PGMPhysWrite(pDevIns->Internal.s.pVMR0, GCPhys, pvBuf, cbWrite); 284 int rc = VINF_SUCCESS; 282 285 #endif 283 286 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; 285 289 } 286 290
Note:
See TracChangeset
for help on using the changeset viewer.