Changeset 18101 in vbox
- Timestamp:
- Mar 19, 2009 10:39:06 PM (16 years ago)
- svn:sync-xref-src-repo-rev:
- 44762
- Location:
- trunk
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/pdmdev.h
r17334 r18101 2402 2402 /** 2403 2403 * Read physical memory. 2404 * 2404 * 2405 * @returns VINF_SUCCESS (for now). 2405 2406 * @param pDevIns Device instance. 2406 2407 * @param GCPhys Physical address start reading from. … … 2409 2410 * @thread Any thread, but the call may involve the emulation thread. 2410 2411 */ 2411 DECLR3CALLBACKMEMBER( void, pfnPhysRead,(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead));2412 DECLR3CALLBACKMEMBER(int, pfnPhysRead,(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead)); 2412 2413 2413 2414 /** 2414 2415 * Write to physical memory. 2415 2416 * 2417 * @returns VINF_SUCCESS for now, and later maybe VERR_EM_MEMORY. 2416 2418 * @param pDevIns Device instance. 2417 2419 * @param GCPhys Physical address to write to. … … 2420 2422 * @thread Any thread, but the call may involve the emulation thread. 2421 2423 */ 2422 DECLR3CALLBACKMEMBER(void, pfnPhysWrite,(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite)); 2424 DECLR3CALLBACKMEMBER(int, pfnPhysWrite,(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite)); 2425 2426 /** 2427 * Requests the mapping of a guest page into ring-3. 2428 * 2429 * When you're done with the page, call pfnPhysReleasePageMappingLock() ASAP to 2430 * release it. 2431 * 2432 * This API will assume your intention is to write to the page, and will 2433 * therefore replace shared and zero pages. If you do not intend to modify the 2434 * page, use the pfnPhysGCPhys2CCPtrReadOnly() API. 2435 * 2436 * @returns VBox status code. 2437 * @retval VINF_SUCCESS on success. 2438 * @retval VERR_PGM_PHYS_PAGE_RESERVED it it's a valid page but has no physical 2439 * backing or if the page has any active access handlers. The caller 2440 * must fall back on using PGMR3PhysWriteExternal. 2441 * @retval VERR_PGM_INVALID_GC_PHYSICAL_ADDRESS if it's not a valid physical address. 2442 * 2443 * @param pVM The VM handle. 2444 * @param GCPhys The guest physical address of the page that should be mapped. 2445 * @param fFlags Flags reserved for future use, MBZ. 2446 * @param ppv Where to store the address corresponding to GCPhys. 2447 * @param pLock Where to store the lock information that 2448 * pfnPhysReleasePageMappingLock needs. 2449 * 2450 * @remark Avoid calling this API from within critical sections (other than the 2451 * PGM one) because of the deadlock risk when we have to delegating the 2452 * task to an EMT. 2453 * @thread Any. 2454 */ 2455 DECLR3CALLBACKMEMBER(int, pfnPhysGCPhys2CCPtr,(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, uint32_t fFlags, void **ppv, PPGMPAGEMAPLOCK pLock)); 2456 2457 /** 2458 * Requests the mapping of a guest page into ring-3, external threads. 2459 * 2460 * When you're done with the page, call pfnPhysReleasePageMappingLock() ASAP to 2461 * release it. 2462 * 2463 * @returns VBox status code. 2464 * @retval VINF_SUCCESS on success. 2465 * @retval VERR_PGM_PHYS_PAGE_RESERVED it it's a valid page but has no physical 2466 * backing or if the page as an active ALL access handler. The caller 2467 * must fall back on using PGMPhysRead. 2468 * @retval VERR_PGM_INVALID_GC_PHYSICAL_ADDRESS if it's not a valid physical address. 2469 * 2470 * @param pDevIns Device instance. 2471 * @param GCPhys The guest physical address of the page that should be mapped. 2472 * @param fFlags Flags reserved for future use, MBZ. 2473 * @param ppv Where to store the address corresponding to GCPhys. 2474 * @param pLock Where to store the lock information that 2475 * pfnPhysReleasePageMappingLock needs. 2476 * 2477 * @remark Avoid calling this API from within critical sections. 2478 * @thread Any. 2479 */ 2480 DECLR3CALLBACKMEMBER(int, pfnPhysGCPhys2CCPtrReadOnly,(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, uint32_t fFlags, void const **ppv, PPGMPAGEMAPLOCK pLock)); 2481 2482 /** 2483 * Release the mapping of a guest page. 2484 * 2485 * This is the counter part of pfnPhysGCPhys2CCPtr and 2486 * pfnPhysGCPhys2CCPtrReadOnly. 2487 * 2488 * @param pDevIns Device instance. 2489 * @param pLock The lock structure initialized by the mapping function. 2490 */ 2491 DECLR3CALLBACKMEMBER(void, pfnPhysReleasePageMappingLock,(PPDMDEVINS pDevIns, PPGMPAGEMAPLOCK pLock)); 2423 2492 2424 2493 /** … … 2443 2512 */ 2444 2513 DECLR3CALLBACKMEMBER(int, pfnPhysWriteGCVirt,(PPDMDEVINS pDevIns, RTGCPTR GCVirtDst, const void *pvSrc, size_t cb)); 2445 2446 /**2447 * Reserve physical address space for ROM and MMIO ranges.2448 *2449 * @returns VBox status code.2450 * @param pDevIns Device instance.2451 * @param GCPhys Start physical address.2452 * @param cbRange The size of the range.2453 * @param pszDesc Description string.2454 * @thread The emulation thread.2455 */2456 DECLR3CALLBACKMEMBER(int, pfnPhysReserve,(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, RTUINT cbRange, const char *pszDesc));2457 2458 /**2459 * Convert a guest physical address to a host virtual address. (OBSOLETE)2460 *2461 * @returns VBox status code.2462 * @param pDevIns Device instance.2463 * @param GCPhys Start physical address.2464 * @param cbRange The size of the range. Use 0 if you don't care about the range.2465 * @param ppvHC Where to store the HC pointer corresponding to GCPhys.2466 * @thread The emulation thread.2467 *2468 * @remark Careful with page boundraries.2469 * @remark Do not use the mapping after you return to the caller! (it could get invalidated/changed)2470 */2471 DECLR3CALLBACKMEMBER(int, pfnObsoletePhys2HCVirt,(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, RTUINT cbRange, PRTHCPTR ppvHC));2472 2473 /**2474 * Convert a guest virtual address to a host virtual address. (OBSOLETE)2475 *2476 * @returns VBox status code.2477 * @param pDevIns Device instance.2478 * @param GCPtr Guest virtual address.2479 * @param pHCPtr Where to store the HC pointer corresponding to GCPtr.2480 * @thread The emulation thread.2481 *2482 * @remark Careful with page boundraries.2483 * @remark Do not use the mapping after you return to the caller! (it could get invalidated/changed)2484 */2485 DECLR3CALLBACKMEMBER(int, pfnObsoletePhysGCPtr2HCPtr,(PPDMDEVINS pDevIns, RTGCPTR GCPtr, PRTHCPTR pHCPtr));2486 2514 2487 2515 /** … … 2743 2771 * 2744 2772 * @return VBox status code. 2745 * @param pDevIns The device owning the MMIO2 memory.2746 * @param iRegion The region.2747 * @param off The offset into the region. Will be rounded down to closest page boundrary.2748 * @param cb The number of bytes to map. Will be rounded up to the closest page boundrary.2749 * @param pszDesc Mapping description.2750 * @param pRCPtr Where to store the RC address.2773 * @param pDevIns The device owning the MMIO2 memory. 2774 * @param iRegion The region. 2775 * @param off The offset into the region. Will be rounded down to closest page boundrary. 2776 * @param cb The number of bytes to map. Will be rounded up to the closest page boundrary. 2777 * @param pszDesc Mapping description. 2778 * @param pRCPtr Where to store the RC address. 2751 2779 */ 2752 2780 DECLR3CALLBACKMEMBER(int, pfnMMHyperMapMMIO2,(PPDMDEVINS pDevIns, uint32_t iRegion, RTGCPHYS off, RTGCPHYS cb, … … 2760 2788 * 2761 2789 * @return VBox status code. 2762 * @param pDevIns The device owning the MMIO2 memory.2763 * @param iRegion The region.2764 * @param off The offset into the region. Must be page aligned.2765 * @param cb The number of bytes to map. Must be page aligned.2766 * @param pszDesc Mapping description.2767 * @param pR0Ptr Where to store the R0 address.2790 * @param pDevIns The device owning the MMIO2 memory. 2791 * @param iRegion The region. 2792 * @param off The offset into the region. Must be page aligned. 2793 * @param cb The number of bytes to map. Must be page aligned. 2794 * @param pszDesc Mapping description. 2795 * @param pR0Ptr Where to store the R0 address. 2768 2796 */ 2769 2797 DECLR3CALLBACKMEMBER(int, pfnMMIO2MapKernel,(PPDMDEVINS pDevIns, uint32_t iRegion, RTGCPHYS off, RTGCPHYS cb, … … 2804 2832 2805 2833 /** Current PDMDEVHLP version number. */ 2806 #define PDM_DEVHLP_VERSION 0xf20 700002834 #define PDM_DEVHLP_VERSION 0xf2080000 2807 2835 2808 2836 … … 2838 2866 * Read physical memory. 2839 2867 * 2868 * @returns VINF_SUCCESS (for now). 2840 2869 * @param pDevIns Device instance. 2841 2870 * @param GCPhys Physical address start reading from. … … 2843 2872 * @param cbRead How many bytes to read. 2844 2873 */ 2845 DECLRCCALLBACKMEMBER( void, pfnPhysRead,(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead));2874 DECLRCCALLBACKMEMBER(int, pfnPhysRead,(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead)); 2846 2875 2847 2876 /** 2848 2877 * Write to physical memory. 2849 2878 * 2879 * @returns VINF_SUCCESS for now, and later maybe VERR_EM_MEMORY. 2850 2880 * @param pDevIns Device instance. 2851 2881 * @param GCPhys Physical address to write to. … … 2853 2883 * @param cbWrite How many bytes to write. 2854 2884 */ 2855 DECLRCCALLBACKMEMBER( void, pfnPhysWrite,(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite));2885 DECLRCCALLBACKMEMBER(int, pfnPhysWrite,(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite)); 2856 2886 2857 2887 /** … … 2940 2970 2941 2971 /** Current PDMDEVHLP version number. */ 2942 #define PDM_DEVHLPRC_VERSION 0xfb01000 02972 #define PDM_DEVHLPRC_VERSION 0xfb010001 2943 2973 2944 2974 … … 2974 3004 * Read physical memory. 2975 3005 * 3006 * @returns VINF_SUCCESS (for now). 2976 3007 * @param pDevIns Device instance. 2977 3008 * @param GCPhys Physical address start reading from. … … 2979 3010 * @param cbRead How many bytes to read. 2980 3011 */ 2981 DECLR0CALLBACKMEMBER( void, pfnPhysRead,(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead));3012 DECLR0CALLBACKMEMBER(int, pfnPhysRead,(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead)); 2982 3013 2983 3014 /** 2984 3015 * Write to physical memory. 2985 3016 * 3017 * @returns VINF_SUCCESS for now, and later maybe VERR_EM_MEMORY. 2986 3018 * @param pDevIns Device instance. 2987 3019 * @param GCPhys Physical address to write to. … … 2989 3021 * @param cbWrite How many bytes to write. 2990 3022 */ 2991 DECLR0CALLBACKMEMBER( void, pfnPhysWrite,(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite));3023 DECLR0CALLBACKMEMBER(int, pfnPhysWrite,(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite)); 2992 3024 2993 3025 /** … … 3084 3116 3085 3117 /** Current PDMDEVHLP version number. */ 3086 #define PDM_DEVHLPR0_VERSION 0xfb02000 03118 #define PDM_DEVHLPR0_VERSION 0xfb020001 3087 3119 3088 3120 … … 3521 3553 } 3522 3554 3523 #ifndef VBOX_WITH_NEW_PHYS_CODE3524 /**3525 * @copydoc PDMDEVHLPR3::pfnPhysReserve3526 */3527 DECLINLINE(int) PDMDevHlpPhysReserve(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, RTUINT cbRange, const char *pszDesc)3528 {3529 return pDevIns->pDevHlpR3->pfnPhysReserve(pDevIns, GCPhys, cbRange, pszDesc);3530 }3531 #endif3532 3533 3555 /** 3534 3556 * @copydoc PDMDEVHLPR3::pfnPhysGCPtr2GCPhys … … 3715 3737 * @copydoc PDMDEVHLPR3::pfnPhysRead 3716 3738 */ 3717 DECLINLINE( void) PDMDevHlpPhysRead(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead)3718 { 3719 pDevIns->CTX_SUFF(pDevHlp)->pfnPhysRead(pDevIns, GCPhys, pvBuf, cbRead);3739 DECLINLINE(int) PDMDevHlpPhysRead(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead) 3740 { 3741 return pDevIns->CTX_SUFF(pDevHlp)->pfnPhysRead(pDevIns, GCPhys, pvBuf, cbRead); 3720 3742 } 3721 3743 … … 3723 3745 * @copydoc PDMDEVHLPR3::pfnPhysWrite 3724 3746 */ 3725 DECLINLINE(void) PDMDevHlpPhysWrite(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite) 3726 { 3727 pDevIns->CTX_SUFF(pDevHlp)->pfnPhysWrite(pDevIns, GCPhys, pvBuf, cbWrite); 3728 } 3747 DECLINLINE(int) PDMDevHlpPhysWrite(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite) 3748 { 3749 return pDevIns->CTX_SUFF(pDevHlp)->pfnPhysWrite(pDevIns, GCPhys, pvBuf, cbWrite); 3750 } 3751 3752 #ifdef IN_RING3 3753 3754 /** 3755 * @copydoc PDMDEVHLPR3::pfnPhysGCPhys2CCPtr 3756 */ 3757 DECLINLINE(int) PDMDevHlpPhysGCPhys2CCPtr(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, uint32_t fFlags, void **ppv, PPGMPAGEMAPLOCK pLock) 3758 { 3759 return pDevIns->CTX_SUFF(pDevHlp)->pfnPhysGCPhys2CCPtr(pDevIns, GCPhys, fFlags, ppv, pLock); 3760 } 3761 3762 /** 3763 * @copydoc PDMDEVHLPR3::pfnPhysGCPhys2CCPtrReadOnly 3764 */ 3765 DECLINLINE(int) PDMDevHlpPhysGCPhys2CCPtrReadOnly(PPDMDEVINS pDevIns, RTGCPHYS GCPhys, uint32_t fFlags, void const **ppv, PPGMPAGEMAPLOCK pLock) 3766 { 3767 return pDevIns->CTX_SUFF(pDevHlp)->pfnPhysGCPhys2CCPtrReadOnly(pDevIns, GCPhys, fFlags, ppv, pLock); 3768 } 3769 3770 /** 3771 * @copydoc PDMDEVHLPR3::pfnPhysReleasePageMappingLock 3772 */ 3773 DECLINLINE(void) PDMDevHlpPhysReleasePageMappingLock(PPDMDEVINS pDevIns, PPGMPAGEMAPLOCK pLock) 3774 { 3775 pDevIns->CTX_SUFF(pDevHlp)->pfnPhysReleasePageMappingLock(pDevIns, pLock); 3776 } 3777 3778 #endif /* IN_RING3 */ 3729 3779 3730 3780 /** -
trunk/include/VBox/pgm.h
r17534 r18101 359 359 VMMDECL(void) PGMPhysInvalidatePageR3MapTLB(PVM pVM); 360 360 361 /**362 * Page mapping lock.363 *364 * @remarks This doesn't work in structures shared between365 * ring-3, ring-0 and/or GC.366 */367 typedef struct PGMPAGEMAPLOCK368 {369 /** @todo see PGMPhysIsPageMappingLockValid for possibly incorrect assumptions */370 #if defined(IN_RC) || defined(VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0)371 /** Just a dummy for the time being. */372 uint32_t u32Dummy;373 #else374 /** Pointer to the PGMPAGE. */375 void *pvPage;376 /** Pointer to the PGMCHUNKR3MAP. */377 void *pvMap;378 #endif379 } PGMPAGEMAPLOCK;380 /** Pointer to a page mapping lock. */381 typedef PGMPAGEMAPLOCK *PPGMPAGEMAPLOCK;382 383 361 VMMDECL(int) PGMPhysGCPhys2CCPtr(PVM pVM, RTGCPHYS GCPhys, void **ppv, PPGMPAGEMAPLOCK pLock); 384 362 VMMDECL(int) PGMPhysGCPhys2CCPtrReadOnly(PVM pVM, RTGCPHYS GCPhys, void const **ppv, PPGMPAGEMAPLOCK pLock); … … 575 553 VMMR3DECL(int) PGMR3PhysReadExternal(PVM pVM, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead); 576 554 VMMR3DECL(int) PGMR3PhysWriteExternal(PVM pVM, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite); 555 VMMR3DECL(int) PGMR3PhysGCPhys2CCPtrExternal(PVM pVM, RTGCPHYS GCPhys, void **ppv, PPGMPAGEMAPLOCK pLock); 556 VMMR3DECL(int) PGMR3PhysGCPhys2CCPtrReadOnlyExternal(PVM pVM, RTGCPHYS GCPhys, void const **ppv, PPGMPAGEMAPLOCK pLock); 577 557 VMMR3DECL(int) PGMR3PhysChunkMap(PVM pVM, uint32_t idChunk); 578 558 VMMR3DECL(void) PGMR3PhysChunkInvalidateTLB(PVM pVM); -
trunk/include/VBox/types.h
r17661 r18101 574 574 575 575 576 /** 577 * Page mapping lock. 578 * 579 * @remarks This doesn't work in structures shared between 580 * ring-3, ring-0 and/or GC. 581 */ 582 typedef struct PGMPAGEMAPLOCK 583 { 584 /** @todo see PGMPhysIsPageMappingLockValid for possibly incorrect assumptions */ 585 #if defined(IN_RC) || defined(VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0) 586 /** Just a dummy for the time being. */ 587 uint32_t u32Dummy; 588 #else 589 /** Pointer to the PGMPAGE. */ 590 void *pvPage; 591 /** Pointer to the PGMCHUNKR3MAP. */ 592 void *pvMap; 593 #endif 594 } PGMPAGEMAPLOCK; 595 /** Pointer to a page mapping lock. */ 596 typedef PGMPAGEMAPLOCK *PPGMPAGEMAPLOCK; 597 598 576 599 /** @} */ 577 600 -
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.