Changeset 93650 in vbox for trunk/src/VBox
- Timestamp:
- Feb 8, 2022 10:43:53 AM (3 years ago)
- Location:
- trunk/src/VBox
- Files:
-
- 1 added
- 27 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Graphics/DevVGA-SVGA.cpp
r93115 r93650 6219 6219 pSVGAState = pThisCC->svga.pSvgaR3State; 6220 6220 6221 /* Register the write-protected GBO access handler type. */ 6222 rc = PDMDevHlpPGMHandlerPhysicalTypeRegister(pDevIns, PGMPHYSHANDLERKIND_WRITE, 6223 vmsvgaR3GboAccessHandler, 6224 NULL, NULL, 6225 NULL, NULL, 6221 /* Register the write-protected GBO access handler type (no ring-0 callbacks here). */ 6222 rc = PDMDevHlpPGMHandlerPhysicalTypeRegister(pDevIns, PGMPHYSHANDLERKIND_WRITE, vmsvgaR3GboAccessHandler, 6226 6223 "VMSVGA GBO", &pSVGAState->hGboAccessHandlerType); 6227 6224 AssertRCReturn(rc, rc); … … 6273 6270 # ifdef DEBUG_GMR_ACCESS 6274 6271 /* Register the GMR access handler type. */ 6275 rc = PDMDevHlpPGMHandlerPhysicalTypeRegister(pDevIns, PGMPHYSHANDLERKIND_WRITE, 6276 vmsvgaR3GmrAccessHandler, 6277 NULL, NULL, 6278 NULL, NULL, 6272 rc = PDMDevHlpPGMHandlerPhysicalTypeRegister(pDevIns, PGMPHYSHANDLERKIND_WRITE, vmsvgaR3GmrAccessHandler, 6279 6273 "VMSVGA GMR", &pThis->svga.hGmrAccessHandlerType); 6280 6274 AssertRCReturn(rc, rc); … … 6282 6276 6283 6277 # if defined(VMSVGA_USE_FIFO_ACCESS_HANDLER) || defined(DEBUG_FIFO_ACCESS) 6284 /* Register the FIFO access handler type. In addition to 6285 debugging FIFO access, this is also used to facilitate 6286 extended fifo thread sleeps. */ 6278 /* Register the FIFO access handler type. In addition to debugging FIFO 6279 access, this is also used to facilitate extended fifo thread sleeps. */ 6287 6280 rc = PDMDevHlpPGMHandlerPhysicalTypeRegister(pDevIns, 6288 6281 # ifdef DEBUG_FIFO_ACCESS … … 6292 6285 # endif 6293 6286 vmsvgaR3FifoAccessHandler, 6294 NULL, NULL,6295 NULL, NULL,6296 6287 "VMSVGA FIFO", &pThis->svga.hFifoAccessHandlerType); 6297 6288 AssertRCReturn(rc, rc); -
trunk/src/VBox/Devices/Graphics/DevVGA-SVGA.h
r93307 r93650 370 370 /** FIFO debug access handler type handle. */ 371 371 PGMPHYSHANDLERTYPE hFifoAccessHandlerType; 372 #elif defined(DEBUG_GMR_ACCESS)373 uint32_t uPadding1;374 372 #endif 375 373 /** Number of GMRs (VMSVGA_MAX_GMR_IDS, count of elements in VMSVGAR3STATE::paGMR array). */ -
trunk/src/VBox/Runtime/Makefile.kmk
r93483 r93650 2789 2789 common/misc/term.cpp \ 2790 2790 common/path/RTPathFilename.cpp \ 2791 common/rand/rand.cpp \ 2792 common/rand/randadv.cpp \ 2793 common/rand/randparkmiller.cpp \ 2791 2794 common/string/strprintf-ellipsis.cpp \ 2792 2795 common/string/strprintf2-ellipsis.cpp \ … … 2794 2797 common/string/strncmp.cpp \ 2795 2798 common/string/strpbrk.cpp \ 2799 common/string/strtonum.cpp \ 2796 2800 common/string/RTStrCat.cpp \ 2797 2801 common/string/RTStrCatEx.cpp \ … … 2824 2828 generic/critsect-generic.cpp \ 2825 2829 generic/critsectrw-generic.cpp \ 2830 generic/RTRandAdvCreateSystemFaster-generic.cpp \ 2831 generic/RTRandAdvCreateSystemTruer-generic.cpp \ 2826 2832 \ 2827 2833 $(RuntimeNoCrt_SOURCES) -
trunk/src/VBox/VMM/Makefile.kmk
r93609 r93650 481 481 VMMR0/HMVMXR0.cpp \ 482 482 VMMR0/HMSVMR0.cpp \ 483 VMMR0/IEMR0.cpp \ 483 484 VMMR0/IOMR0.cpp \ 484 485 VMMR0/IOMR0IoPort.cpp \ -
trunk/src/VBox/VMM/VMMAll/IEMAllCImplVmxInstr.cpp.h
r93635 r93650 6851 6851 if (!PGMHandlerPhysicalIsRegistered(pVCpu->CTX_SUFF(pVM), GCPhysApicAccess)) 6852 6852 { 6853 PVMCC pVM = pVCpu->CTX_SUFF(pVM); 6854 PVMCPUCC pVCpu0 = VMCC_GET_CPU_0(pVM); 6853 PVMCC pVM = pVCpu->CTX_SUFF(pVM); 6855 6854 int rc = PGMHandlerPhysicalRegister(pVM, GCPhysApicAccess, GCPhysApicAccess + X86_PAGE_4K_SIZE - 1, 6856 pV Cpu0->iem.s.hVmxApicAccessPage, 0 /*uUser*/, NULL /*pszDesc*/);6855 pVM->iem.s.hVmxApicAccessPage, 0 /*uUser*/, NULL /*pszDesc*/); 6857 6856 if (RT_SUCCESS(rc)) 6858 6857 { /* likely */ } -
trunk/src/VBox/VMM/VMMAll/IOMAllMmioNew.cpp
r93635 r93650 728 728 * @remarks The @a uUser argument is the MMIO handle. 729 729 */ 730 DECL EXPORT(VBOXSTRICTRC) iomMmioPfHandlerNew(PVMCC pVM, PVMCPUCC pVCpu, RTGCUINT uErrorCode, PCPUMCTXCORE pCtxCore,731 RTGCPTR pvFault, RTGCPHYS GCPhysFault, uint64_t uUser)730 DECLCALLBACK(VBOXSTRICTRC) iomMmioPfHandlerNew(PVMCC pVM, PVMCPUCC pVCpu, RTGCUINT uErrorCode, PCPUMCTXCORE pCtxCore, 731 RTGCPTR pvFault, RTGCPHYS GCPhysFault, uint64_t uUser) 732 732 { 733 733 STAM_PROFILE_START(&pVM->iom.s.StatMmioPfHandler, Prf); … … 797 797 * @remarks The @a uUser argument is the MMIO handle. 798 798 */ 799 PGM_ALL_CB2_DECL(VBOXSTRICTRC) iomMmioHandlerNew(PVMCC pVM, PVMCPUCC pVCpu, RTGCPHYS GCPhysFault, void *pvPhys, void *pvBuf,800 799 DECLCALLBACK(VBOXSTRICTRC) iomMmioHandlerNew(PVMCC pVM, PVMCPUCC pVCpu, RTGCPHYS GCPhysFault, void *pvPhys, void *pvBuf, 800 size_t cbBuf, PGMACCESSTYPE enmAccessType, PGMACCESSORIGIN enmOrigin, uint64_t uUser) 801 801 { 802 802 STAM_PROFILE_START(UnusedMacroArg, Prf); -
trunk/src/VBox/VMM/VMMAll/MMAllHyper.cpp
r93592 r93650 1260 1260 1261 1261 /** 1262 * Converts a context neutral heap offset into a pointer.1263 *1264 * @returns Pointer to hyper heap data.1265 * @param pVM The cross context VM structure.1266 * @param offHeap The hyper heap offset.1267 */1268 VMMDECL(void *) MMHyperHeapOffsetToPtr(PVM pVM, uint32_t offHeap)1269 {1270 Assert(offHeap - MMYPERHEAP_HDR_SIZE <= pVM->mm.s.CTX_SUFF(pHyperHeap)->cbHeap);1271 return (uint8_t *)pVM->mm.s.CTX_SUFF(pHyperHeap) + offHeap;1272 }1273 1274 1275 /**1276 * Converts a context specific heap pointer into a neutral heap offset.1277 *1278 * @returns Heap offset.1279 * @param pVM The cross context VM structure.1280 * @param pv Pointer to the heap data.1281 */1282 VMMDECL(uint32_t) MMHyperHeapPtrToOffset(PVM pVM, void *pv)1283 {1284 size_t offHeap = (uint8_t *)pv - (uint8_t *)pVM->mm.s.CTX_SUFF(pHyperHeap);1285 Assert(offHeap - MMYPERHEAP_HDR_SIZE <= pVM->mm.s.CTX_SUFF(pHyperHeap)->cbHeap);1286 return (uint32_t)offHeap;1287 }1288 1289 1290 /**1291 1262 * Checks if an address is within the hypervisor memory area. 1292 1263 * -
trunk/src/VBox/VMM/VMMAll/PGMAllBth.h
r93635 r93650 243 243 if (pCur) 244 244 { 245 P PGMPHYSHANDLERTYPEINTpCurType = PGMPHYSHANDLER_GET_TYPE(pVM, pCur);245 PCPGMPHYSHANDLERTYPEINT const pCurType = PGMPHYSHANDLER_GET_TYPE(pVM, pCur); 246 246 247 247 # ifdef PGM_SYNC_N_PAGES … … 312 312 } 313 313 314 if (pCurType-> CTX_SUFF(pfnPfHandler))314 if (pCurType->pfnPfHandler) 315 315 { 316 316 STAM_PROFILE_START(&pCur->Stat, h); … … 318 318 if (pCurType->fKeepPgmLock) 319 319 { 320 rcStrict = pCurType-> CTX_SUFF(pfnPfHandler)(pVM, pVCpu, uErr, pRegFrame, pvFault, GCPhysFault,321 322 320 rcStrict = pCurType->pfnPfHandler(pVM, pVCpu, uErr, pRegFrame, pvFault, GCPhysFault, 321 !pCurType->fRing0DevInsIdx ? pCur->uUser 322 : (uintptr_t)PDMDeviceRing0IdxToInstance(pVM, pCur->uUser)); 323 323 324 324 # ifdef VBOX_WITH_STATISTICS … … 335 335 *pfLockTaken = false; 336 336 337 rcStrict = pCurType-> CTX_SUFF(pfnPfHandler)(pVM, pVCpu, uErr, pRegFrame, pvFault, GCPhysFault, uUser);337 rcStrict = pCurType->pfnPfHandler(pVM, pVCpu, uErr, pRegFrame, pvFault, GCPhysFault, uUser); 338 338 339 339 # ifdef VBOX_WITH_STATISTICS -
trunk/src/VBox/VMM/VMMAll/PGMAllHandler.cpp
r93635 r93650 47 47 48 48 /********************************************************************************************************************************* 49 * Global Variables * 50 *********************************************************************************************************************************/ 51 /** Dummy physical access handler type record. */ 52 CTX_SUFF(PGMPHYSHANDLERTYPEINT) const g_pgmHandlerPhysicalDummyType = 53 { 54 /* .hType = */ UINT64_C(0x93b7557e1937aaff), 55 /* .enmKind = */ PGMPHYSHANDLERKIND_INVALID, 56 /* .uState = */ PGM_PAGE_HNDL_PHYS_STATE_ALL, 57 /* .fKeepPgmLock = */ true, 58 /* .fRing0DevInsIdx = */ false, 59 #ifdef IN_RING0 60 /* .afPadding = */ {false}, 61 /* .pfnHandler = */ pgmR0HandlerPhysicalHandlerToRing3, 62 /* .pfnPfHandler = */ pgmR0HandlerPhysicalPfHandlerToRing3, 63 #elif defined(IN_RING3) 64 /* .fRing0Enabled = */ false, 65 /* .pfnHandler = */ pgmR3HandlerPhysicalHandlerInvalid, 66 #else 67 # error "unsupported context" 68 #endif 69 /* .pszDesc = */ "dummy" 70 }; 71 72 73 /********************************************************************************************************************************* 49 74 * Internal Functions * 50 75 *********************************************************************************************************************************/ … … 55 80 56 81 57 /** 58 * Internal worker for releasing a physical handler type registration reference. 59 * 60 * @returns New reference count. UINT32_MAX if invalid input (asserted). 61 * @param pVM The cross context VM structure. 62 * @param pType Pointer to the type registration. 63 */ 64 DECLINLINE(uint32_t) pgmHandlerPhysicalTypeRelease(PVMCC pVM, PPGMPHYSHANDLERTYPEINT pType) 65 { 66 AssertMsgReturn(pType->u32Magic == PGMPHYSHANDLERTYPEINT_MAGIC, ("%#x\n", pType->u32Magic), UINT32_MAX); 67 uint32_t cRefs = ASMAtomicDecU32(&pType->cRefs); 68 if (cRefs == 0) 69 { 70 PGM_LOCK_VOID(pVM); 71 pType->u32Magic = PGMPHYSHANDLERTYPEINT_MAGIC_DEAD; 72 RTListOff32NodeRemove(&pType->ListNode); 73 PGM_UNLOCK(pVM); 74 MMHyperFree(pVM, pType); 75 } 76 return cRefs; 77 } 78 79 80 /** 81 * Internal worker for retaining a physical handler type registration reference. 82 * 83 * @returns New reference count. UINT32_MAX if invalid input (asserted). 84 * @param pVM The cross context VM structure. 85 * @param pType Pointer to the type registration. 86 */ 87 DECLINLINE(uint32_t) pgmHandlerPhysicalTypeRetain(PVM pVM, PPGMPHYSHANDLERTYPEINT pType) 88 { 89 NOREF(pVM); 90 AssertMsgReturn(pType->u32Magic == PGMPHYSHANDLERTYPEINT_MAGIC, ("%#x\n", pType->u32Magic), UINT32_MAX); 91 uint32_t cRefs = ASMAtomicIncU32(&pType->cRefs); 92 Assert(cRefs < _1M && cRefs > 0); 93 return cRefs; 94 } 95 96 97 /** 98 * Releases a reference to a physical handler type registration. 99 * 100 * @returns New reference count. UINT32_MAX if invalid input (asserted). 101 * @param pVM The cross context VM structure. 102 * @param hType The type regiration handle. 103 */ 104 VMMDECL(uint32_t) PGMHandlerPhysicalTypeRelease(PVMCC pVM, PGMPHYSHANDLERTYPE hType) 105 { 106 if (hType != NIL_PGMPHYSHANDLERTYPE) 107 return pgmHandlerPhysicalTypeRelease(pVM, PGMPHYSHANDLERTYPEINT_FROM_HANDLE(pVM, hType)); 108 return 0; 109 } 110 111 112 /** 113 * Retains a reference to a physical handler type registration. 114 * 115 * @returns New reference count. UINT32_MAX if invalid input (asserted). 116 * @param pVM The cross context VM structure. 117 * @param hType The type regiration handle. 118 */ 119 VMMDECL(uint32_t) PGMHandlerPhysicalTypeRetain(PVM pVM, PGMPHYSHANDLERTYPE hType) 120 { 121 return pgmHandlerPhysicalTypeRetain(pVM, PGMPHYSHANDLERTYPEINT_FROM_HANDLE(pVM, hType)); 122 } 82 #ifndef IN_RING3 83 84 /** 85 * @callback_method_impl{FNPGMPHYSHANDLER, 86 * Dummy for forcing ring-3 handling of the access.} 87 */ 88 DECLCALLBACK(VBOXSTRICTRC) 89 pgmR0HandlerPhysicalHandlerToRing3(PVMCC pVM, PVMCPUCC pVCpu, RTGCPHYS GCPhys, void *pvPhys, void *pvBuf, size_t cbBuf, 90 PGMACCESSTYPE enmAccessType, PGMACCESSORIGIN enmOrigin, uint64_t uUser) 91 { 92 RT_NOREF(pVM, pVCpu, GCPhys, pvPhys, pvBuf, cbBuf, enmAccessType, enmOrigin, uUser); 93 return VINF_EM_RAW_EMULATE_INSTR; 94 } 95 96 97 /** 98 * @callback_method_impl{FNPGMRZPHYSPFHANDLER, 99 * Dummy for forcing ring-3 handling of the access.} 100 */ 101 DECLCALLBACK(VBOXSTRICTRC) 102 pgmR0HandlerPhysicalPfHandlerToRing3(PVMCC pVM, PVMCPUCC pVCpu, RTGCUINT uErrorCode, PCPUMCTXCORE pRegFrame, 103 RTGCPTR pvFault, RTGCPHYS GCPhysFault, uint64_t uUser) 104 { 105 RT_NOREF(pVM, pVCpu, uErrorCode, pRegFrame, pvFault, GCPhysFault, uUser); 106 return VINF_EM_RAW_EMULATE_INSTR; 107 } 108 109 #endif /* !IN_RING3 */ 123 110 124 111 … … 145 132 R3PTRTYPE(const char *) pszDesc, PPGMPHYSHANDLER *ppPhysHandler) 146 133 { 147 PPGMPHYSHANDLERTYPEINT pType = PGMPHYSHANDLERTYPEINT_FROM_HANDLE(pVM, hType); 134 /* 135 * Validate input. 136 */ 137 PCPGMPHYSHANDLERTYPEINT const pType = pgmHandlerPhysicalTypeHandleToPtr(pVM, hType); 138 AssertReturn(pType, VERR_INVALID_HANDLE); 139 AssertReturn(pType->enmKind > PGMPHYSHANDLERKIND_INVALID && pType->enmKind < PGMPHYSHANDLERKIND_END, VERR_INVALID_HANDLE); 140 AssertPtr(ppPhysHandler); 141 148 142 Log(("pgmHandlerPhysicalExCreate: uUser=%#RX64 hType=%#x (%d, %s) pszDesc=%RHv:%s\n", 149 uUser, hType, pType->enmKind, R3STRING(pType->pszDesc), pszDesc, R3STRING(pszDesc))); 150 151 /* 152 * Validate input. 153 */ 154 AssertPtr(ppPhysHandler); 155 AssertReturn(pType->u32Magic == PGMPHYSHANDLERTYPEINT_MAGIC, VERR_INVALID_HANDLE); 143 uUser, hType, pType->enmKind, pType->pszDesc, pszDesc, R3STRING(pszDesc))); 156 144 157 145 /* … … 169 157 pNew->uUser = uUser; 170 158 pNew->hType = hType; 171 pNew->pszDesc = pszDesc != NIL_RTR3PTR ? pszDesc : pType->pszDesc; 172 pgmHandlerPhysicalTypeRetain(pVM, pType); 159 pNew->pszDesc = pszDesc != NIL_RTR3PTR ? pszDesc 160 #ifdef IN_RING3 161 : pType->pszDesc; 162 #else 163 : pVM->pgm.s.aPhysHandlerTypes[hType].pszDesc; 164 #endif 173 165 *ppPhysHandler = pNew; 174 166 return VINF_SUCCESS; … … 213 205 * Validate input. 214 206 */ 207 PGMPHYSHANDLERTYPE const hType = pPhysHandler->hType; 208 PCPGMPHYSHANDLERTYPEINT const pType = pgmHandlerPhysicalTypeHandleToPtr(pVM, hType); 209 AssertReturn(pType, VERR_INVALID_HANDLE); 210 AssertReturn(pType->enmKind > PGMPHYSHANDLERKIND_INVALID && pType->enmKind < PGMPHYSHANDLERKIND_END, VERR_INVALID_HANDLE); 211 215 212 AssertPtr(pPhysHandler); 216 PPGMPHYSHANDLERTYPEINT pType = PGMPHYSHANDLERTYPEINT_FROM_HANDLE(pVM, pPhysHandler->hType); 217 Assert(pType->u32Magic == PGMPHYSHANDLERTYPEINT_MAGIC); 218 Log(("pgmHandlerPhysicalExRegister: GCPhys=%RGp GCPhysLast=%RGp hType=%#x (%d, %s) pszDesc=%RHv:%s\n", 219 GCPhys, GCPhysLast, pPhysHandler->hType, pType->enmKind, R3STRING(pType->pszDesc), pPhysHandler->pszDesc, R3STRING(pPhysHandler->pszDesc))); 213 214 Log(("pgmHandlerPhysicalExRegister: GCPhys=%RGp GCPhysLast=%RGp hType=%#x (%d, %s) pszDesc=%RHv:%s\n", GCPhys, GCPhysLast, 215 hType, pType->enmKind, pType->pszDesc, pPhysHandler->pszDesc, R3STRING(pPhysHandler->pszDesc))); 220 216 AssertReturn(pPhysHandler->Core.Key == NIL_RTGCPHYS, VERR_WRONG_ORDER); 221 217 … … 313 309 { 314 310 #ifdef LOG_ENABLED 315 P PGMPHYSHANDLERTYPEINT pType = PGMPHYSHANDLERTYPEINT_FROM_HANDLE(pVM, hType);311 PCPGMPHYSHANDLERTYPEINT pType = pgmHandlerPhysicalTypeHandleToPtr(pVM, hType); 316 312 Log(("PGMHandlerPhysicalRegister: GCPhys=%RGp GCPhysLast=%RGp uUser=%#RX64 hType=%#x (%d, %s) pszDesc=%RHv:%s\n", 317 313 GCPhys, GCPhysLast, uUser, hType, pType->enmKind, R3STRING(pType->pszDesc), pszDesc, R3STRING(pszDesc))); … … 353 349 bool fFlushTLBs = false; 354 350 int rc = VINF_SUCCESS; 355 P PGMPHYSHANDLERTYPEINT pCurType = PGMPHYSHANDLER_GET_TYPE(pVM, pCur);351 PCPGMPHYSHANDLERTYPEINT pCurType = PGMPHYSHANDLER_GET_TYPE_NO_NULL(pVM, pCur); 356 352 const unsigned uState = pCurType->uState; 357 353 uint32_t cPages = pCur->cPages; … … 483 479 AssertPtr(pHandler); 484 480 AssertReturn(pHandler->Core.Key == NIL_RTGCPHYS, VERR_WRONG_ORDER); 485 PGMHandlerPhysicalTypeRelease(pVM, pHandler->hType);486 481 MMHyperFree(pVM, pHandler); 487 482 } … … 539 534 { 540 535 #ifdef VBOX_WITH_NATIVE_NEM 541 P PGMPHYSHANDLERTYPEINT pCurType = PGMPHYSHANDLER_GET_TYPE(pVM, pCur);536 PCPGMPHYSHANDLERTYPEINT pCurType = PGMPHYSHANDLER_GET_TYPE_NO_NULL(pVM, pCur); 542 537 RTGCPHYS GCPhysStart = pCur->Core.Key; 543 538 RTGCPHYS GCPhysLast = pCur->Core.KeyLast; … … 623 618 || ((fAbove ? pCur->Core.Key : pCur->Core.KeyLast) >> GUEST_PAGE_SHIFT) != (GCPhys >> GUEST_PAGE_SHIFT)) 624 619 break; 625 P PGMPHYSHANDLERTYPEINT pCurType = PGMPHYSHANDLER_GET_TYPE(pVM, pCur);620 PCPGMPHYSHANDLERTYPEINT pCurType = PGMPHYSHANDLER_GET_TYPE_NO_NULL(pVM, pCur); 626 621 uState = RT_MAX(uState, pCurType->uState); 627 622 … … 636 631 637 632 /* 638 * Update if we found something that is a higher priority 639 * state than the current. 633 * Update if we found something that is a higher priority state than the current. 640 634 */ 641 635 if (uState != PGM_PAGE_HNDL_PHYS_STATE_NONE) … … 786 780 } 787 781 #ifdef VBOX_STRICT 788 PPGMPHYSHANDLERTYPEINT pCurType = PGMPHYSHANDLER_GET_TYPE(pVM, pCur); 789 AssertMsg(pCurType->enmKind != PGMPHYSHANDLERKIND_MMIO || PGM_PAGE_IS_MMIO(pPage), ("%RGp %R[pgmpage]\n", GCPhys, pPage)); 782 PCPGMPHYSHANDLERTYPEINT const pCurType = PGMPHYSHANDLER_GET_TYPE(pVM, pCur); 783 AssertMsg(pCurType && (pCurType->enmKind != PGMPHYSHANDLERKIND_MMIO || PGM_PAGE_IS_MMIO(pPage)), 784 ("%RGp %R[pgmpage]\n", GCPhys, pPage)); 790 785 #endif 791 786 PGM_PAGE_SET_HNDL_PHYS_STATE(pPage, PGM_PAGE_HNDL_PHYS_STATE_NONE); … … 855 850 */ 856 851 pgmHandlerPhysicalResetRamFlags(pVM, pCur); 857 PPGMPHYSHANDLERTYPEINT const pCurType = PGMPHYSHANDLER_GET_TYPE(pVM, pCur); 852 PCPGMPHYSHANDLERTYPEINT const pCurType = PGMPHYSHANDLER_GET_TYPE_NO_NULL(pVM, pCur); 853 @todo pCurType validation 858 854 bool const fRestoreAsRAM = pCurType->pfnHandlerR3 /** @todo this isn't entirely correct. */ 859 855 && pCurType->enmKind != PGMPHYSHANDLERKIND_MMIO; … … 1141 1137 * Validate kind. 1142 1138 */ 1143 P PGMPHYSHANDLERTYPEINT pCurType = PGMPHYSHANDLER_GET_TYPE(pVM, pCur);1139 PCPGMPHYSHANDLERTYPEINT pCurType = PGMPHYSHANDLER_GET_TYPE_NO_NULL(pVM, pCur); 1144 1140 switch (pCurType->enmKind) 1145 1141 { … … 1205 1201 */ 1206 1202 default: 1207 AssertMsgFailed(("Invalid type %d ! Corruption!\n", pCurType->enmKind));1203 AssertMsgFailed(("Invalid type %d/%#x! Corruption!\n", pCurType->enmKind, pCur->hType)); 1208 1204 rc = VERR_PGM_PHYS_HANDLER_IPE; 1209 1205 break; … … 1249 1245 * Validate kind. 1250 1246 */ 1251 PPGMPHYSHANDLERTYPEINT pCurType = PGMPHYSHANDLER_GET_TYPE(pVM, pCur); 1252 if (pCurType->enmKind == PGMPHYSHANDLERKIND_WRITE) 1247 PCPGMPHYSHANDLERTYPEINT pCurType = PGMPHYSHANDLER_GET_TYPE(pVM, pCur); 1248 if ( pCurType 1249 && pCurType->enmKind == PGMPHYSHANDLERKIND_WRITE) 1253 1250 { 1254 1251 STAM_COUNTER_INC(&pVM->pgm.s.Stats.CTX_MID_Z(Stat,PhysHandlerReset)); … … 1316 1313 if (RT_LIKELY(pCur)) 1317 1314 { 1318 if (RT_LIKELY( 1319 && 1315 if (RT_LIKELY( GCPhysPage >= pCur->Core.Key 1316 && GCPhysPage <= pCur->Core.KeyLast)) 1320 1317 { 1321 1318 Assert(!(pCur->Core.Key & GUEST_PAGE_OFFSET_MASK)); 1322 1319 Assert((pCur->Core.KeyLast & GUEST_PAGE_OFFSET_MASK) == GUEST_PAGE_OFFSET_MASK); 1323 1320 1324 PPGMPHYSHANDLERTYPEINT pCurType = PGMPHYSHANDLER_GET_TYPE(pVM, pCur); 1325 AssertReturnStmt( pCurType->enmKind == PGMPHYSHANDLERKIND_WRITE 1326 || pCurType->enmKind == PGMPHYSHANDLERKIND_ALL, 1321 PCPGMPHYSHANDLERTYPEINT const pCurType = PGMPHYSHANDLER_GET_TYPE(pVM, pCur); 1322 AssertReturnStmt( pCurType 1323 && ( pCurType->enmKind == PGMPHYSHANDLERKIND_WRITE 1324 || pCurType->enmKind == PGMPHYSHANDLERKIND_ALL), 1327 1325 PGM_UNLOCK(pVM), VERR_ACCESS_DENIED); 1328 1326 … … 1488 1486 && GCPhysPage <= pCur->Core.KeyLast)) 1489 1487 { 1490 P PGMPHYSHANDLERTYPEINT pCurType = PGMPHYSHANDLER_GET_TYPE(pVM, pCur);1488 PCPGMPHYSHANDLERTYPEINT const pCurType = PGMPHYSHANDLER_GET_TYPE_NO_NULL(pVM, pCur); 1491 1489 AssertReturnStmt(pCurType->enmKind == PGMPHYSHANDLERKIND_MMIO, PGM_UNLOCK(pVM), VERR_ACCESS_DENIED); 1492 1490 AssertReturnStmt(!(pCur->Core.Key & GUEST_PAGE_OFFSET_MASK), PGM_UNLOCK(pVM), VERR_INVALID_PARAMETER); … … 1617 1615 && GCPhysPage <= pCur->Core.KeyLast)) 1618 1616 { 1619 P PGMPHYSHANDLERTYPEINT pCurType = PGMPHYSHANDLER_GET_TYPE(pVM, pCur);1617 PCPGMPHYSHANDLERTYPEINT const pCurType = PGMPHYSHANDLER_GET_TYPE_NO_NULL(pVM, pCur); 1620 1618 AssertReturnStmt(pCurType->enmKind == PGMPHYSHANDLERKIND_MMIO, PGM_UNLOCK(pVM), VERR_ACCESS_DENIED); 1621 1619 AssertReturnStmt(!(pCur->Core.Key & GUEST_PAGE_OFFSET_MASK), PGM_UNLOCK(pVM), VERR_INVALID_PARAMETER); … … 1706 1704 #ifdef VBOX_STRICT 1707 1705 Assert(GCPhys >= pCur->Core.Key && GCPhys <= pCur->Core.KeyLast); 1708 P PGMPHYSHANDLERTYPEINT pCurType = PGMPHYSHANDLER_GET_TYPE(pVM, pCur);1706 PCPGMPHYSHANDLERTYPEINT const pCurType = PGMPHYSHANDLER_GET_TYPE_NO_NULL(pVM, pCur); 1709 1707 Assert( pCurType->enmKind == PGMPHYSHANDLERKIND_WRITE 1710 1708 || pCurType->enmKind == PGMPHYSHANDLERKIND_ALL … … 1740 1738 return true; 1741 1739 } 1742 PPGMPHYSHANDLERTYPEINT pCurType = PGMPHYSHANDLER_GET_TYPE(pVM, pCur); 1740 1741 /* Only whole pages can be disabled. */ 1742 Assert( pCur->Core.Key <= (GCPhys & ~(RTGCPHYS)GUEST_PAGE_OFFSET_MASK) 1743 && pCur->Core.KeyLast >= (GCPhys | GUEST_PAGE_OFFSET_MASK)); 1744 1745 PCPGMPHYSHANDLERTYPEINT const pCurType = PGMPHYSHANDLER_GET_TYPE_NO_NULL(pVM, pCur); 1743 1746 Assert( pCurType->enmKind == PGMPHYSHANDLERKIND_WRITE 1744 1747 || pCurType->enmKind == PGMPHYSHANDLERKIND_ALL 1745 1748 || pCurType->enmKind == PGMPHYSHANDLERKIND_MMIO); /* sanity */ 1746 /* Only whole pages can be disabled. */ 1747 Assert( pCur->Core.Key <= (GCPhys & ~(RTGCPHYS)GUEST_PAGE_OFFSET_MASK) 1748 && pCur->Core.KeyLast >= (GCPhys | GUEST_PAGE_OFFSET_MASK)); 1749 1750 bool bRet = pCurType->enmKind != PGMPHYSHANDLERKIND_WRITE; 1749 bool const fRet = pCurType->enmKind != PGMPHYSHANDLERKIND_WRITE; 1751 1750 PGM_UNLOCK(pVM); 1752 return bRet;1751 return fRet; 1753 1752 } 1754 1753 … … 1818 1817 if (pPhys) 1819 1818 { 1820 P PGMPHYSHANDLERTYPEINT pPhysType = (PPGMPHYSHANDLERTYPEINT)MMHyperHeapOffsetToPtr(pVM, pPhys->hType);1819 PCPGMPHYSHANDLERTYPEINT pPhysType = pgmHandlerPhysicalTypeHandleToPtr(pVM, pPhys->hType); 1821 1820 unsigned uState = pPhysType->uState; 1822 1821 … … 1829 1828 || pPhys2->Core.Key > (State.GCPhys | GUEST_PAGE_OFFSET_MASK)) 1830 1829 break; 1831 P PGMPHYSHANDLERTYPEINT pPhysType2 = (PPGMPHYSHANDLERTYPEINT)MMHyperHeapOffsetToPtr(pVM, pPhys2->hType);1830 PCPGMPHYSHANDLERTYPEINT pPhysType2 = pgmHandlerPhysicalTypeHandleToPtr(pVM, pPhys2->hType); 1832 1831 uState = RT_MAX(uState, pPhysType2->uState); 1833 1832 pPhys = pPhys2; -
trunk/src/VBox/VMM/VMMAll/PGMAllPhys.cpp
r93635 r93650 114 114 115 115 116 #ifndef IN_RING3117 118 /**119 * @callback_method_impl{FNPGMPHYSHANDLER,120 * Dummy for forcing ring-3 handling of the access.}121 */122 DECLEXPORT(VBOXSTRICTRC)123 pgmPhysHandlerRedirectToHC(PVMCC pVM, PVMCPUCC pVCpu, RTGCPHYS GCPhys, void *pvPhys, void *pvBuf, size_t cbBuf,124 PGMACCESSTYPE enmAccessType, PGMACCESSORIGIN enmOrigin, uint64_t uUser)125 {126 RT_NOREF(pVM, pVCpu, GCPhys, pvPhys, pvBuf, cbBuf, enmAccessType, enmOrigin, uUser);127 return VINF_EM_RAW_EMULATE_INSTR;128 }129 130 131 /**132 * @callback_method_impl{FNPGMRZPHYSPFHANDLER,133 * Dummy for forcing ring-3 handling of the access.}134 */135 VMMDECL(VBOXSTRICTRC) pgmPhysPfHandlerRedirectToHC(PVMCC pVM, PVMCPUCC pVCpu, RTGCUINT uErrorCode, PCPUMCTXCORE pRegFrame,136 RTGCPTR pvFault, RTGCPHYS GCPhysFault, uint64_t uUser)137 {138 RT_NOREF(pVM, pVCpu, uErrorCode, pRegFrame, pvFault, GCPhysFault, uUser);139 return VINF_EM_RAW_EMULATE_INSTR;140 }141 142 #endif /* !IN_RING3 */143 144 116 /** 145 117 * Looks up a ROM range by its PGMROMRANGE::GCPhys value. … … 161 133 * @remarks The @a uUser argument is the PGMROMRANGE::GCPhys value. 162 134 */ 163 DECL EXPORT(VBOXSTRICTRC) pgmPhysRomWritePfHandler(PVMCC pVM, PVMCPUCC pVCpu, RTGCUINT uErrorCode, PCPUMCTXCORE pRegFrame,164 RTGCPTR pvFault, RTGCPHYS GCPhysFault, uint64_t uUser)135 DECLCALLBACK(VBOXSTRICTRC) pgmPhysRomWritePfHandler(PVMCC pVM, PVMCPUCC pVCpu, RTGCUINT uErrorCode, PCPUMCTXCORE pRegFrame, 136 RTGCPTR pvFault, RTGCPHYS GCPhysFault, uint64_t uUser) 165 137 166 138 { … … 233 205 * @remarks The @a uUser argument is the PGMROMRANGE::GCPhys value. 234 206 */ 235 PGM_ALL_CB2_DECL(VBOXSTRICTRC)207 DECLCALLBACK(VBOXSTRICTRC) 236 208 pgmPhysRomWriteHandler(PVMCC pVM, PVMCPUCC pVCpu, RTGCPHYS GCPhys, void *pvPhys, void *pvBuf, size_t cbBuf, 237 209 PGMACCESSTYPE enmAccessType, PGMACCESSORIGIN enmOrigin, uint64_t uUser) … … 396 368 * @remarks The @a uUser is the MMIO2 index. 397 369 */ 398 DECL EXPORT(VBOXSTRICTRC) pgmPhysMmio2WritePfHandler(PVMCC pVM, PVMCPUCC pVCpu, RTGCUINT uErrorCode, PCPUMCTXCORE pRegFrame,399 RTGCPTR pvFault, RTGCPHYS GCPhysFault, uint64_t uUser)370 DECLCALLBACK(VBOXSTRICTRC) pgmPhysMmio2WritePfHandler(PVMCC pVM, PVMCPUCC pVCpu, RTGCUINT uErrorCode, PCPUMCTXCORE pRegFrame, 371 RTGCPTR pvFault, RTGCPHYS GCPhysFault, uint64_t uUser) 400 372 { 401 373 RT_NOREF(pVCpu, uErrorCode, pRegFrame); … … 417 389 * @remarks The @a uUser is the MMIO2 index. 418 390 */ 419 PGM_ALL_CB2_DECL(VBOXSTRICTRC)391 DECLCALLBACK(VBOXSTRICTRC) 420 392 pgmPhysMmio2WriteHandler(PVMCC pVM, PVMCPUCC pVCpu, RTGCPHYS GCPhys, void *pvPhys, void *pvBuf, size_t cbBuf, 421 393 PGMACCESSTYPE enmAccessType, PGMACCESSORIGIN enmOrigin, uint64_t uUser) … … 2436 2408 { 2437 2409 PPGMPHYSHANDLER pCur = pgmHandlerPhysicalLookup(pVM, GCPhys); 2438 AssertReleaseMsg(pCur, ("GCPhys=%RGp cb=%#x\n", GCPhys, cb)); 2439 Assert(GCPhys >= pCur->Core.Key && GCPhys <= pCur->Core.KeyLast); 2440 Assert((pCur->Core.Key & GUEST_PAGE_OFFSET_MASK) == 0); 2441 Assert((pCur->Core.KeyLast & GUEST_PAGE_OFFSET_MASK) == GUEST_PAGE_OFFSET_MASK); 2410 if (pCur) 2411 { 2412 Assert(pCur && GCPhys >= pCur->Core.Key && GCPhys <= pCur->Core.KeyLast); 2413 Assert((pCur->Core.Key & GUEST_PAGE_OFFSET_MASK) == 0); 2414 Assert((pCur->Core.KeyLast & GUEST_PAGE_OFFSET_MASK) == GUEST_PAGE_OFFSET_MASK); 2442 2415 #ifndef IN_RING3 2443 if (enmOrigin != PGMACCESSORIGIN_IEM)2444 {2445 /* Cannot reliably handle informational status codes in this context */2446 pgmPhysReleaseInternalPageMappingLock(pVM, &PgMpLck);2447 return VERR_PGM_PHYS_WR_HIT_HANDLER;2448 }2416 if (enmOrigin != PGMACCESSORIGIN_IEM) 2417 { 2418 /* Cannot reliably handle informational status codes in this context */ 2419 pgmPhysReleaseInternalPageMappingLock(pVM, &PgMpLck); 2420 return VERR_PGM_PHYS_WR_HIT_HANDLER; 2421 } 2449 2422 #endif 2450 PPGMPHYSHANDLERTYPEINT const pCurType = PGMPHYSHANDLER_GET_TYPE(pVM, pCur);2451 PFNPGMPHYSHANDLER const pfnHandler = pCurType->CTX_SUFF(pfnHandler); Assert(pfnHandler);2452 uint64_t constuUser = !pCurType->fRing0DevInsIdx ? pCur->uUser2453 : (uintptr_t)PDMDeviceRing0IdxToInstance(pVM, pCur->uUser);2454 2455 Log5(("pgmPhysReadHandler: GCPhys=%RGp cb=%#x pPage=%R[pgmpage] phys %s\n", GCPhys, cb, pPage, R3STRING(pCur->pszDesc) ));2456 STAM_PROFILE_START(&pCur->Stat, h);2457 PGM_LOCK_ASSERT_OWNER(pVM);2458 2459 /* Release the PGM lock as MMIO handlers take the IOM lock. (deadlock prevention) */2460 PGM_UNLOCK(pVM);2461 rcStrict = pfnHandler(pVM, pVCpu, GCPhys, (void *)pvSrc, pvBuf, cb, PGMACCESSTYPE_READ, enmOrigin, uUser);2462 PGM_LOCK_VOID(pVM);2423 PCPGMPHYSHANDLERTYPEINT const pCurType = PGMPHYSHANDLER_GET_TYPE_NO_NULL(pVM, pCur); 2424 PFNPGMPHYSHANDLER const pfnHandler = pCurType->pfnHandler; Assert(pfnHandler); 2425 uint64_t const uUser = !pCurType->fRing0DevInsIdx ? pCur->uUser 2426 : (uintptr_t)PDMDeviceRing0IdxToInstance(pVM, pCur->uUser); 2427 2428 Log5(("pgmPhysReadHandler: GCPhys=%RGp cb=%#x pPage=%R[pgmpage] phys %s\n", GCPhys, cb, pPage, R3STRING(pCur->pszDesc) )); 2429 STAM_PROFILE_START(&pCur->Stat, h); 2430 PGM_LOCK_ASSERT_OWNER(pVM); 2431 2432 /* Release the PGM lock as MMIO handlers take the IOM lock. (deadlock prevention) */ 2433 PGM_UNLOCK(pVM); 2434 rcStrict = pfnHandler(pVM, pVCpu, GCPhys, (void *)pvSrc, pvBuf, cb, PGMACCESSTYPE_READ, enmOrigin, uUser); 2435 PGM_LOCK_VOID(pVM); 2463 2436 2464 2437 #ifdef VBOX_WITH_STATISTICS 2465 pCur = pgmHandlerPhysicalLookup(pVM, GCPhys);2466 if (pCur)2467 STAM_PROFILE_STOP(&pCur->Stat, h);2438 pCur = pgmHandlerPhysicalLookup(pVM, GCPhys); 2439 if (pCur) 2440 STAM_PROFILE_STOP(&pCur->Stat, h); 2468 2441 #else 2469 pCur = NULL; /* might not be valid anymore. */2442 pCur = NULL; /* might not be valid anymore. */ 2470 2443 #endif 2471 AssertLogRelMsg(PGM_HANDLER_PHYS_IS_VALID_STATUS(rcStrict, false), 2472 ("rcStrict=%Rrc GCPhys=%RGp\n", VBOXSTRICTRC_VAL(rcStrict), GCPhys)); 2473 if ( rcStrict != VINF_PGM_HANDLER_DO_DEFAULT 2474 && !PGM_PHYS_RW_IS_SUCCESS(rcStrict)) 2475 { 2476 pgmPhysReleaseInternalPageMappingLock(pVM, &PgMpLck); 2477 return rcStrict; 2478 } 2444 AssertLogRelMsg(PGM_HANDLER_PHYS_IS_VALID_STATUS(rcStrict, false), 2445 ("rcStrict=%Rrc GCPhys=%RGp\n", VBOXSTRICTRC_VAL(rcStrict), GCPhys)); 2446 if ( rcStrict != VINF_PGM_HANDLER_DO_DEFAULT 2447 && !PGM_PHYS_RW_IS_SUCCESS(rcStrict)) 2448 { 2449 pgmPhysReleaseInternalPageMappingLock(pVM, &PgMpLck); 2450 return rcStrict; 2451 } 2452 } 2453 else 2454 AssertLogRelMsgFailed(("GCPhys=%RGp cb=%#x\n", GCPhys, cb)); 2479 2455 } 2480 2456 … … 2665 2641 * Give priority to physical handlers (like #PF does). 2666 2642 * 2667 * Hope for a lonely physical handler first that covers the whole 2668 * write area. This should be a pretty frequent case with MMIO and2669 * the heavyusage of full page handlers in the page pool.2643 * Hope for a lonely physical handler first that covers the whole write 2644 * area. This should be a pretty frequent case with MMIO and the heavy 2645 * usage of full page handlers in the page pool. 2670 2646 */ 2671 2647 PVMCPUCC pVCpu = VMMGetCpu(pVM); … … 2683 2659 cbRange = cbWrite; 2684 2660 2685 Assert(PGMPHYSHANDLER_GET_TYPE(pVM, pCur)-> CTX_SUFF(pfnHandler));2661 Assert(PGMPHYSHANDLER_GET_TYPE(pVM, pCur)->pfnHandler); 2686 2662 Log5(("pgmPhysWriteHandler: GCPhys=%RGp cbRange=%#x pPage=%R[pgmpage] phys %s\n", 2687 2663 GCPhys, cbRange, pPage, R3STRING(pCur->pszDesc) )); … … 2692 2668 if (RT_SUCCESS(rcStrict)) 2693 2669 { 2694 P PGMPHYSHANDLERTYPEINT const pCurType = PGMPHYSHANDLER_GET_TYPE(pVM, pCur);2695 PFNPGMPHYSHANDLER const pfnHandler = pCurType->CTX_SUFF(pfnHandler);2696 uint64_t const uUser = !pCurType->fRing0DevInsIdx ? pCur->uUser2697 : (uintptr_t)PDMDeviceRing0IdxToInstance(pVM, pCur->uUser);2670 PCPGMPHYSHANDLERTYPEINT const pCurType = PGMPHYSHANDLER_GET_TYPE_NO_NULL(pVM, pCur); 2671 PFNPGMPHYSHANDLER const pfnHandler = pCurType->pfnHandler; 2672 uint64_t const uUser = !pCurType->fRing0DevInsIdx ? pCur->uUser 2673 : (uintptr_t)PDMDeviceRing0IdxToInstance(pVM, pCur->uUser); 2698 2674 STAM_PROFILE_START(&pCur->Stat, h); 2699 2675 … … 2747 2723 else /* The handler is somewhere else in the page, deal with it below. */ 2748 2724 rcStrict = VINF_SUCCESS; 2749 Assert(!PGM_PAGE_IS_MMIO_OR_ALIAS(pPage)); /* MMIO handlers are all PAGE_SIZEed! */2725 Assert(!PGM_PAGE_IS_MMIO_OR_ALIAS(pPage)); /* MMIO handlers are all GUEST_PAGE_SIZEed! */ 2750 2726 2751 2727 /* … … 2763 2739 } 2764 2740 2741 /** @todo clean up this code some more now there are no virtual handlers any 2742 * more. */ 2765 2743 /* The loop state (big + ugly). */ 2766 2744 PPGMPHYSHANDLER pPhys = NULL; … … 2804 2782 VBOXSTRICTRC rcStrict2 = VINF_PGM_HANDLER_DO_DEFAULT; 2805 2783 uint32_t cbRange = (uint32_t)cbWrite; 2784 Assert(cbRange == cbWrite); 2806 2785 2807 2786 /* … … 2818 2797 cbRange = offPhysLast + 1; 2819 2798 2820 P PGMPHYSHANDLERTYPEINT const pCurType = PGMPHYSHANDLER_GET_TYPE(pVM, pPhys);2821 PFNPGMPHYSHANDLER const pfnHandler = pCurType->CTX_SUFF(pfnHandler);2822 uint64_t const uUser = !pCurType->fRing0DevInsIdx ? pPhys->uUser2823 : (uintptr_t)PDMDeviceRing0IdxToInstance(pVM, pPhys->uUser);2799 PCPGMPHYSHANDLERTYPEINT const pCurType = PGMPHYSHANDLER_GET_TYPE_NO_NULL(pVM, pPhys); 2800 PFNPGMPHYSHANDLER const pfnHandler = pCurType->pfnHandler; 2801 uint64_t const uUser = !pCurType->fRing0DevInsIdx ? pPhys->uUser 2802 : (uintptr_t)PDMDeviceRing0IdxToInstance(pVM, pPhys->uUser); 2824 2803 2825 2804 Log5(("pgmPhysWriteHandler: GCPhys=%RGp cbRange=%#x pPage=%R[pgmpage] phys %s\n", GCPhys, cbRange, pPage, R3STRING(pPhys->pszDesc) )); -
trunk/src/VBox/VMM/VMMR0/IOMR0.cpp
r93115 r93650 22 22 #define LOG_GROUP LOG_GROUP_IOM 23 23 #include <VBox/vmm/iom.h> 24 #include <VBox/vmm/pgm.h> 24 25 #include "IOMInternal.h" 25 26 #include <VBox/vmm/vmcc.h> 26 27 #include <VBox/log.h> 28 #include <iprt/assert.h> 27 29 #include <iprt/assertcompile.h> 30 #include <iprt/errcore.h> 28 31 29 32 … … 48 51 49 52 /** 53 * Called during ring-0 init (vmmR0InitVM). 54 * 55 * @returns VBox status code. 56 * @param pGVM Pointer to the global VM structure. 57 */ 58 VMMR0_INT_DECL(int) IOMR0InitVM(PGVM pGVM) 59 { 60 int rc = PGMR0HandlerPhysicalTypeSetUpContext(pGVM, PGMPHYSHANDLERKIND_MMIO, 0 /*fFlags*/, 61 iomMmioHandlerNew, iomMmioPfHandlerNew, 62 "MMIO", pGVM->iom.s.hNewMmioHandlerType); 63 AssertRCReturn(rc, rc); 64 return VINF_SUCCESS; 65 } 66 67 68 /** 50 69 * Cleans up any loose ends before the GVM structure is destroyed. 51 70 */ -
trunk/src/VBox/VMM/VMMR0/PDMR0DevHlp.cpp
r93609 r93650 1321 1321 LogFlow(("pdmR0DevHlp_HpetSetUpContext: caller='%s'/%d: returns %Rrc\n", pDevIns->pReg->szName, pDevIns->iInstance, VINF_SUCCESS)); 1322 1322 return VINF_SUCCESS; 1323 } 1324 1325 1326 /** @interface_method_impl{PDMDEVHLPR0,pfnPGMHandlerPhysicalTypeSetUpContext} */ 1327 static DECLCALLBACK(int) pdmR0DevHlp_PGMHandlerPhysicalTypeSetUpContext(PPDMDEVINS pDevIns, PGMPHYSHANDLERKIND enmKind, 1328 PFNPGMPHYSHANDLER pfnHandler, 1329 PFNPGMRZPHYSPFHANDLER pfnPfHandler, 1330 const char *pszDesc, PGMPHYSHANDLERTYPE hType) 1331 { 1332 PDMDEV_ASSERT_DEVINS(pDevIns); 1333 LogFlow(("pdmR0DevHlp_PGMHandlerPhysicalTypeSetUpContext: caller='%s'/%d: enmKind=%d pfnHandler=%p pfnPfHandler=%p pszDesc=%p:{%s} hType=%#x\n", 1334 pDevIns->pReg->szName, pDevIns->iInstance, enmKind, pfnHandler, pfnPfHandler, pszDesc, pszDesc, hType)); 1335 1336 int rc = PGMR0HandlerPhysicalTypeSetUpContext(pDevIns->Internal.s.pGVM, enmKind, PGMPHYSHANDLER_F_R0_DEVINS_IDX, 1337 pfnHandler, pfnPfHandler, pszDesc, hType); 1338 1339 Log(("pdmR0DevHlp_PGMHandlerPhysicalTypeSetUpContext: caller='%s'/%d: returns %Rrc\n", 1340 pDevIns->pReg->szName, pDevIns->iInstance, rc)); 1341 return rc; 1323 1342 } 1324 1343 … … 1477 1496 pdmR0DevHlp_IoApicSetUpContext, 1478 1497 pdmR0DevHlp_HpetSetUpContext, 1498 pdmR0DevHlp_PGMHandlerPhysicalTypeSetUpContext, 1479 1499 pdmR0DevHlp_PGMHandlerPhysicalPageTempOff, 1480 1500 pdmR0DevHlp_MmioMapMmio2Page, … … 1589 1609 pdmR0DevHlp_IoApicSetUpContext, 1590 1610 pdmR0DevHlp_HpetSetUpContext, 1611 pdmR0DevHlp_PGMHandlerPhysicalTypeSetUpContext, 1591 1612 pdmR0DevHlp_PGMHandlerPhysicalPageTempOff, 1592 1613 pdmR0DevHlp_MmioMapMmio2Page, -
trunk/src/VBox/VMM/VMMR0/PGMR0.cpp
r93635 r93650 35 35 #include <iprt/mem.h> 36 36 #include <iprt/memobj.h> 37 #include <iprt/rand.h> 37 38 #include <iprt/string.h> 38 39 #include <iprt/time.h> … … 83 84 84 85 /* 86 * Initialize the handler type table with return to ring-3 callbacks so we 87 * don't have to do anything special for ring-3 only registrations. 88 * 89 * Note! The random bits of the hType value is mainly for prevent trouble 90 * with zero initialized handles w/o needing to sacrifice handle zero. 91 */ 92 for (size_t i = 0; i < RT_ELEMENTS(pGVM->pgm.s.aPhysHandlerTypes); i++) 93 { 94 pGVM->pgmr0.s.aPhysHandlerTypes[i].hType = i | (RTRandU64() & ~(uint64_t)PGMPHYSHANDLERTYPE_IDX_MASK); 95 pGVM->pgmr0.s.aPhysHandlerTypes[i].enmKind = PGMPHYSHANDLERKIND_INVALID; 96 pGVM->pgmr0.s.aPhysHandlerTypes[i].pfnHandler = pgmR0HandlerPhysicalHandlerToRing3; 97 pGVM->pgmr0.s.aPhysHandlerTypes[i].pfnPfHandler = pgmR0HandlerPhysicalPfHandlerToRing3; 98 99 pGVM->pgm.s.aPhysHandlerTypes[i].hType = pGVM->pgmr0.s.aPhysHandlerTypes[i].hType; 100 pGVM->pgm.s.aPhysHandlerTypes[i].enmKind = PGMPHYSHANDLERKIND_INVALID; 101 } 102 103 /* 85 104 * Get the physical address of the ZERO and MMIO-dummy pages. 86 105 */ … … 107 126 VMMR0_INT_DECL(int) PGMR0InitVM(PGVM pGVM) 108 127 { 109 RT_NOREF(pGVM); 110 /* Was used for DynMap init */ 111 return VINF_SUCCESS; 128 /* 129 * Set up the ring-0 context for our access handlers. 130 */ 131 int rc = PGMR0HandlerPhysicalTypeSetUpContext(pGVM, PGMPHYSHANDLERKIND_WRITE, 0 /*fFlags*/, 132 pgmPhysRomWriteHandler, pgmPhysRomWritePfHandler, 133 "ROM write protection", pGVM->pgm.s.hRomPhysHandlerType); 134 AssertLogRelRCReturn(rc, rc); 135 136 /* 137 * Register the physical access handler doing dirty MMIO2 tracing. 138 */ 139 rc = PGMR0HandlerPhysicalTypeSetUpContext(pGVM, PGMPHYSHANDLERKIND_WRITE, PGMPHYSHANDLER_F_KEEP_PGM_LOCK, 140 pgmPhysMmio2WriteHandler, pgmPhysMmio2WritePfHandler, 141 "MMIO2 dirty page tracing", pGVM->pgm.s.hMmio2DirtyPhysHandlerType); 142 AssertLogRelRCReturn(rc, rc); 143 144 /* 145 * The page pool. 146 */ 147 return pgmR0PoolInitVM(pGVM); 148 } 149 150 151 /** 152 * Called at the end of the ring-0 initialization to seal access handler types. 153 * 154 * @returns VBox status code. 155 * @param pGVM Pointer to the global VM structure. 156 */ 157 VMMR0_INT_DECL(void) PGMR0DoneInitVM(PGVM pGVM) 158 { 159 /* 160 * Seal all the access handler types. Does both ring-3 and ring-0. 161 * 162 * Note! Since this is a void function and we don't have any ring-0 state 163 * machinery for marking the VM as bogus, this code will just 164 * override corrupted values as best as it can. 165 */ 166 AssertCompile(RT_ELEMENTS(pGVM->pgmr0.s.aPhysHandlerTypes) == RT_ELEMENTS(pGVM->pgm.s.aPhysHandlerTypes)); 167 for (size_t i = 0; i < RT_ELEMENTS(pGVM->pgmr0.s.aPhysHandlerTypes); i++) 168 { 169 PPGMPHYSHANDLERTYPEINTR0 const pTypeR0 = &pGVM->pgmr0.s.aPhysHandlerTypes[i]; 170 PPGMPHYSHANDLERTYPEINTR3 const pTypeR3 = &pGVM->pgm.s.aPhysHandlerTypes[i]; 171 PGMPHYSHANDLERKIND const enmKindR3 = pTypeR3->enmKind; 172 PGMPHYSHANDLERKIND const enmKindR0 = pTypeR0->enmKind; 173 AssertLogRelMsgStmt(pTypeR0->hType == pTypeR3->hType, 174 ("i=%u %#RX64 vs %#RX64 %s\n", i, pTypeR0->hType, pTypeR3->hType, pTypeR0->pszDesc), 175 pTypeR3->hType = pTypeR0->hType); 176 switch (enmKindR3) 177 { 178 case PGMPHYSHANDLERKIND_ALL: 179 case PGMPHYSHANDLERKIND_MMIO: 180 if ( enmKindR0 == enmKindR3 181 || enmKindR0 == PGMPHYSHANDLERKIND_INVALID) 182 { 183 pTypeR3->fRing0Enabled = enmKindR0 == enmKindR3; 184 pTypeR0->uState = PGM_PAGE_HNDL_PHYS_STATE_ALL; 185 pTypeR3->uState = PGM_PAGE_HNDL_PHYS_STATE_ALL; 186 continue; 187 } 188 break; 189 190 case PGMPHYSHANDLERKIND_WRITE: 191 if ( enmKindR0 == enmKindR3 192 || enmKindR0 == PGMPHYSHANDLERKIND_INVALID) 193 { 194 pTypeR3->fRing0Enabled = enmKindR0 == enmKindR3; 195 pTypeR0->uState = PGM_PAGE_HNDL_PHYS_STATE_WRITE; 196 pTypeR3->uState = PGM_PAGE_HNDL_PHYS_STATE_WRITE; 197 continue; 198 } 199 break; 200 201 default: 202 AssertLogRelMsgFailed(("i=%u enmKindR3=%d\n", i, enmKindR3)); 203 RT_FALL_THROUGH(); 204 case PGMPHYSHANDLERKIND_INVALID: 205 AssertLogRelMsg(enmKindR0 == PGMPHYSHANDLERKIND_INVALID, 206 ("i=%u enmKind=%d %s\n", i, enmKindR0, pTypeR0->pszDesc)); 207 AssertLogRelMsg(pTypeR0->pfnHandler == pgmR0HandlerPhysicalHandlerToRing3, 208 ("i=%u pfnHandler=%p %s\n", i, pTypeR0->pfnHandler, pTypeR0->pszDesc)); 209 AssertLogRelMsg(pTypeR0->pfnPfHandler == pgmR0HandlerPhysicalPfHandlerToRing3, 210 ("i=%u pfnPfHandler=%p %s\n", i, pTypeR0->pfnPfHandler, pTypeR0->pszDesc)); 211 212 /* Unused of bad ring-3 entry, make it and the ring-0 one harmless. */ 213 pTypeR3->enmKind = PGMPHYSHANDLERKIND_END; 214 pTypeR3->fRing0DevInsIdx = false; 215 pTypeR3->fKeepPgmLock = false; 216 pTypeR3->uState = 0; 217 break; 218 } 219 pTypeR3->fRing0Enabled = false; 220 221 /* Make sure the entry is harmless and goes to ring-3. */ 222 pTypeR0->enmKind = PGMPHYSHANDLERKIND_END; 223 pTypeR0->pfnHandler = pgmR0HandlerPhysicalHandlerToRing3; 224 pTypeR0->pfnPfHandler = pgmR0HandlerPhysicalPfHandlerToRing3; 225 pTypeR0->fRing0DevInsIdx = false; 226 pTypeR0->fKeepPgmLock = false; 227 pTypeR0->uState = 0; 228 pTypeR0->pszDesc = "invalid"; 229 } 112 230 } 113 231 … … 631 749 return SUPR0PageMapKernel(pGVM->pSession, pvR3, (uint32_t)offSub, (uint32_t)cbSub, 0 /*fFlags*/, ppvMapping); 632 750 #endif 751 } 752 753 754 /** 755 * Updates a physical access handler type with ring-0 callback functions. 756 * 757 * The handler type must first have been registered in ring-3. 758 * 759 * @returns VBox status code. 760 * @param pGVM The global (ring-0) VM structure. 761 * @param enmKind The kind of access handler. 762 * @param fFlags PGMPHYSHANDLER_F_XXX 763 * @param pfnHandler Pointer to the ring-0 handler callback. 764 * @param pfnPfHandler Pointer to the ring-0 \#PF handler callback. 765 * callback. 766 * @param pszDesc The type description. 767 * @param hType The handle to do ring-0 callback registrations for. 768 * @thread EMT(0) 769 */ 770 VMMR0_INT_DECL(int) PGMR0HandlerPhysicalTypeSetUpContext(PGVM pGVM, PGMPHYSHANDLERKIND enmKind, uint32_t fFlags, 771 PFNPGMPHYSHANDLER pfnHandler, PFNPGMRZPHYSPFHANDLER pfnPfHandler, 772 const char *pszDesc, PGMPHYSHANDLERTYPE hType) 773 { 774 /* 775 * Validate input. 776 */ 777 AssertPtrReturn(pfnHandler, VERR_INVALID_POINTER); 778 AssertPtrReturn(pfnPfHandler, VERR_INVALID_POINTER); 779 AssertPtrReturn(pszDesc, VERR_INVALID_POINTER); 780 AssertReturn( enmKind == PGMPHYSHANDLERKIND_WRITE 781 || enmKind == PGMPHYSHANDLERKIND_ALL 782 || enmKind == PGMPHYSHANDLERKIND_MMIO, 783 VERR_INVALID_PARAMETER); 784 AssertMsgReturn(!(fFlags & ~PGMPHYSHANDLER_F_VALID_MASK), ("%#x\n", fFlags), VERR_INVALID_FLAGS); 785 786 PPGMPHYSHANDLERTYPEINTR0 const pTypeR0 = &pGVM->pgmr0.s.aPhysHandlerTypes[hType & PGMPHYSHANDLERTYPE_IDX_MASK]; 787 AssertMsgReturn(hType == pTypeR0->hType, ("%#RX64, expected=%#RX64\n", hType, pTypeR0->hType), VERR_INVALID_HANDLE); 788 AssertCompile(RT_ELEMENTS(pGVM->pgmr0.s.aPhysHandlerTypes) == RT_ELEMENTS(pGVM->pgm.s.aPhysHandlerTypes)); 789 AssertCompile(RT_ELEMENTS(pGVM->pgmr0.s.aPhysHandlerTypes) == PGMPHYSHANDLERTYPE_IDX_MASK + 1); 790 AssertReturn(pTypeR0->enmKind == PGMPHYSHANDLERKIND_INVALID, VERR_ALREADY_INITIALIZED); 791 792 int rc = GVMMR0ValidateGVMandEMT(pGVM, 0); 793 AssertRCReturn(rc, rc); 794 VM_ASSERT_STATE_RETURN(pGVM, VMSTATE_CREATING, VERR_VM_INVALID_VM_STATE); /** @todo ring-0 safe state check. */ 795 796 PPGMPHYSHANDLERTYPEINTR3 const pTypeR3 = &pGVM->pgm.s.aPhysHandlerTypes[hType & PGMPHYSHANDLERTYPE_IDX_MASK]; 797 AssertMsgReturn(pTypeR3->enmKind == enmKind, 798 ("%#x: %d, expected %d\n", hType, pTypeR3->enmKind, enmKind), 799 VERR_INVALID_HANDLE); 800 AssertMsgReturn(pTypeR3->fKeepPgmLock == RT_BOOL(fFlags & PGMPHYSHANDLER_F_KEEP_PGM_LOCK), 801 ("%#x: %d, fFlags=%d\n", hType, pTypeR3->fKeepPgmLock, fFlags), 802 VERR_INVALID_HANDLE); 803 AssertMsgReturn(pTypeR3->fRing0DevInsIdx == RT_BOOL(fFlags & PGMPHYSHANDLER_F_R0_DEVINS_IDX), 804 ("%#x: %d, fFlags=%d\n", hType, pTypeR3->fRing0DevInsIdx, fFlags), 805 VERR_INVALID_HANDLE); 806 807 /* 808 * Update the entry. 809 */ 810 pTypeR0->enmKind = enmKind; 811 pTypeR0->uState = enmKind == PGMPHYSHANDLERKIND_WRITE 812 ? PGM_PAGE_HNDL_PHYS_STATE_WRITE : PGM_PAGE_HNDL_PHYS_STATE_ALL; 813 pTypeR0->fKeepPgmLock = RT_BOOL(fFlags & PGMPHYSHANDLER_F_KEEP_PGM_LOCK); 814 pTypeR0->fRing0DevInsIdx = RT_BOOL(fFlags & PGMPHYSHANDLER_F_R0_DEVINS_IDX); 815 pTypeR0->pfnHandler = pfnHandler; 816 pTypeR0->pfnPfHandler = pfnPfHandler; 817 pTypeR0->pszDesc = pszDesc; 818 819 pTypeR3->fRing0Enabled = true; 820 821 LogFlow(("PGMR0HandlerPhysicalTypeRegister: hType=%#x: enmKind=%d fFlags=%#x pfnHandler=%p pfnPfHandler=%p pszDesc=%s\n", 822 hType, enmKind, fFlags, pfnHandler, pfnPfHandler, pszDesc)); 823 return VINF_SUCCESS; 633 824 } 634 825 … … 965 1156 */ 966 1157 PGM_LOCK_VOID(pGVM); 967 PPGMPHYSHANDLER pHandler = pgmHandlerPhysicalLookup(pGVM, GCPhysFault);968 P PGMPHYSHANDLERTYPEINT pHandlerType = RT_LIKELY(pHandler) ? PGMPHYSHANDLER_GET_TYPE(pGVM, pHandler) : NULL;1158 PPGMPHYSHANDLER pHandler = pgmHandlerPhysicalLookup(pGVM, GCPhysFault); 1159 PCPGMPHYSHANDLERTYPEINT pHandlerType = RT_LIKELY(pHandler) ? PGMPHYSHANDLER_GET_TYPE_NO_NULL(pGVM, pHandler) : NULL; 969 1160 if (RT_LIKELY(pHandler && pHandlerType->enmKind != PGMPHYSHANDLERKIND_WRITE)) 970 1161 { … … 988 1179 else 989 1180 { 990 if (pHandlerType-> CTX_SUFF(pfnPfHandler))1181 if (pHandlerType->pfnPfHandler) 991 1182 { 992 1183 uint64_t const uUser = !pHandlerType->fRing0DevInsIdx ? pHandler->uUser … … 995 1186 PGM_UNLOCK(pGVM); 996 1187 997 Log6(("PGMR0Trap0eHandlerNPMisconfig: calling %p(,%#x,,%RGp,%p)\n", pHandlerType-> CTX_SUFF(pfnPfHandler), uErr, GCPhysFault, uUser));998 rc = pHandlerType-> CTX_SUFF(pfnPfHandler)(pGVM, pGVCpu, uErr == UINT32_MAX ? RTGCPTR_MAX : uErr, pRegFrame,999 1188 Log6(("PGMR0Trap0eHandlerNPMisconfig: calling %p(,%#x,,%RGp,%p)\n", pHandlerType->pfnPfHandler, uErr, GCPhysFault, uUser)); 1189 rc = pHandlerType->pfnPfHandler(pGVM, pGVCpu, uErr == UINT32_MAX ? RTGCPTR_MAX : uErr, pRegFrame, 1190 GCPhysFault, GCPhysFault, uUser); 1000 1191 1001 1192 #ifdef VBOX_WITH_STATISTICS -
trunk/src/VBox/VMM/VMMR0/PGMR0Pool.cpp
r93554 r93650 32 32 #include <iprt/mem.h> 33 33 #include <iprt/memobj.h> 34 35 36 /** 37 * Called by PGMR0InitVM to complete the page pool setup for ring-0. 38 * 39 * @returns VBox status code. 40 * @param pGVM Pointer to the global VM structure. 41 */ 42 int pgmR0PoolInitVM(PGVM pGVM) 43 { 44 PPGMPOOL pPool = pGVM->pgm.s.pPoolR0; 45 AssertPtrReturn(pPool, VERR_PGM_POOL_IPE); 46 47 int rc = PGMR0HandlerPhysicalTypeSetUpContext(pGVM, PGMPHYSHANDLERKIND_WRITE, PGMPHYSHANDLER_F_KEEP_PGM_LOCK, 48 pgmPoolAccessHandler, pgmRZPoolAccessPfHandler, 49 "Guest Paging Access Handler", pPool->hAccessHandlerType); 50 AssertLogRelRCReturn(rc, rc); 51 52 return VINF_SUCCESS; 53 } 34 54 35 55 -
trunk/src/VBox/VMM/VMMR0/VMMR0.cpp
r93609 r93650 23 23 #include <VBox/vmm/vmm.h> 24 24 #include <VBox/sup.h> 25 #include <VBox/vmm/iem.h> 25 26 #include <VBox/vmm/iom.h> 26 27 #include <VBox/vmm/trpm.h> … … 55 56 #include <iprt/assert.h> 56 57 #include <iprt/crc.h> 58 #include <iprt/initterm.h> 57 59 #include <iprt/mem.h> 58 60 #include <iprt/memobj.h> … … 282 284 283 285 vmmTermFormatTypes(); 286 RTTermRunCallbacks(RTTERMREASON_UNLOAD, 0); 284 287 285 288 LogFlow(("ModuleTerm: returns\n")); … … 436 439 { 437 440 /* 438 * Init HM, CPUM and PGM (Darwin only).441 * Init HM, CPUM and PGM. 439 442 */ 440 443 rc = HMR0InitVM(pGVM); … … 450 453 if (RT_SUCCESS(rc)) 451 454 { 452 #ifdef VBOX_WITH_PCI_PASSTHROUGH 453 rc = PciRawR0InitVM(pGVM); 454 #endif 455 rc = IEMR0InitVM(pGVM); 455 456 if (RT_SUCCESS(rc)) 456 457 { 457 rc = GIMR0InitVM(pGVM);458 rc = IOMR0InitVM(pGVM); 458 459 if (RT_SUCCESS(rc)) 459 460 { 460 GVMMR0DoneInitVM(pGVM); 461 462 /* 463 * Collect a bit of info for the VM release log. 464 */ 465 pGVM->vmm.s.fIsPreemptPendingApiTrusty = RTThreadPreemptIsPendingTrusty(); 466 pGVM->vmm.s.fIsPreemptPossible = RTThreadPreemptIsPossible();; 467 return rc; 468 469 /* bail out*/ 470 //GIMR0TermVM(pGVM); 461 #ifdef VBOX_WITH_PCI_PASSTHROUGH 462 rc = PciRawR0InitVM(pGVM); 463 #endif 464 if (RT_SUCCESS(rc)) 465 { 466 rc = GIMR0InitVM(pGVM); 467 if (RT_SUCCESS(rc)) 468 { 469 GVMMR0DoneInitVM(pGVM); 470 PGMR0DoneInitVM(pGVM); 471 472 /* 473 * Collect a bit of info for the VM release log. 474 */ 475 pGVM->vmm.s.fIsPreemptPendingApiTrusty = RTThreadPreemptIsPendingTrusty(); 476 pGVM->vmm.s.fIsPreemptPossible = RTThreadPreemptIsPossible();; 477 return rc; 478 479 /* bail out*/ 480 //GIMR0TermVM(pGVM); 481 } 482 #ifdef VBOX_WITH_PCI_PASSTHROUGH 483 PciRawR0TermVM(pGVM); 484 #endif 485 } 471 486 } 472 #ifdef VBOX_WITH_PCI_PASSTHROUGH473 PciRawR0TermVM(pGVM);474 #endif475 487 } 476 488 } -
trunk/src/VBox/VMM/VMMR3/IEMR3.cpp
r93635 r93650 171 171 if (pVM->cpum.ro.GuestFeatures.fVmx) 172 172 { 173 PVMCPU pVCpu0 = pVM->apCpusR3[0];174 173 int rc = PGMR3HandlerPhysicalTypeRegister(pVM, PGMPHYSHANDLERKIND_ALL, 0 /*fFlags*/, 175 174 iemVmxApicAccessPageHandler, 176 NULL /* pszModR0 */, 177 "iemVmxApicAccessPageHandler", NULL /* pszPfHandlerR0 */, 178 NULL /* pszModRC */, 179 NULL /* pszHandlerRC */, NULL /* pszPfHandlerRC */, 180 "VMX APIC-access page", &pVCpu0->iem.s.hVmxApicAccessPage); 175 "VMX APIC-access page", &pVM->iem.s.hVmxApicAccessPage); 181 176 AssertLogRelRCReturn(rc, rc); 182 177 } -
trunk/src/VBox/VMM/VMMR3/IOM.cpp
r93635 r93650 160 160 */ 161 161 rc = PGMR3HandlerPhysicalTypeRegister(pVM, PGMPHYSHANDLERKIND_MMIO, 0 /*fFlags*/, 162 iomMmioHandlerNew, 163 NULL, "iomMmioHandlerNew", "iomMmioPfHandlerNew", 164 NULL, "iomMmioHandlerNew", "iomMmioPfHandlerNew", 165 "MMIO New", &pVM->iom.s.hNewMmioHandlerType); 162 iomMmioHandlerNew, "MMIO", &pVM->iom.s.hNewMmioHandlerType); 166 163 AssertRCReturn(rc, rc); 167 164 -
trunk/src/VBox/VMM/VMMR3/PDMDevHlp.cpp
r93635 r93650 860 860 /** @interface_method_impl{PDMDEVHLPR3,pfnPGMHandlerPhysicalTypeRegister} */ 861 861 static DECLCALLBACK(int) pdmR3DevHlp_PGMHandlerPhysicalTypeRegister(PPDMDEVINS pDevIns, PGMPHYSHANDLERKIND enmKind, 862 R3PTRTYPE(PFNPGMPHYSHANDLER) pfnHandlerR3, 863 const char *pszHandlerR0, const char *pszPfHandlerR0, 864 const char *pszHandlerRC, const char *pszPfHandlerRC, 865 const char *pszDesc, PPGMPHYSHANDLERTYPE phType) 862 PFNPGMPHYSHANDLER pfnHandlerR3, const char *pszDesc, 863 PPGMPHYSHANDLERTYPE phType) 866 864 { 867 865 PDMDEV_ASSERT_DEVINS(pDevIns); 868 866 PVM pVM = pDevIns->Internal.s.pVMR3; 869 LogFlow(("pdmR3DevHlp_PGMHandlerPhysicalTypeRegister: caller='%s'/%d: enmKind=%d pfnHandlerR3=%p pszHandlerR0=%p:{%s} pszPfHandlerR0=%p:{%s} pszHandlerRC=%p:{%s} pszPfHandlerRC=%p:{%s} pszDesc=%p:{%s} phType=%p\n", 870 pDevIns->pReg->szName, pDevIns->iInstance, enmKind, pfnHandlerR3, 871 pszHandlerR0, pszHandlerR0, pszPfHandlerR0, pszPfHandlerR0, 872 pszHandlerRC, pszHandlerRC, pszPfHandlerRC, pszPfHandlerRC, 873 pszDesc, pszDesc, phType)); 867 LogFlow(("pdmR3DevHlp_PGMHandlerPhysicalTypeRegister: caller='%s'/%d: enmKind=%d pfnHandlerR3=%p pszDesc=%p:{%s} phType=%p\n", 868 pDevIns->pReg->szName, pDevIns->iInstance, enmKind, pfnHandlerR3, pszDesc, pszDesc, phType)); 874 869 875 870 int rc = PGMR3HandlerPhysicalTypeRegister(pVM, enmKind, 876 871 pDevIns->Internal.s.fIntFlags & PDMDEVINSINT_FLAGS_R0_ENABLED 877 872 ? PGMPHYSHANDLER_F_R0_DEVINS_IDX : 0, 878 pfnHandlerR3, 879 pDevIns->pReg->pszR0Mod, pszHandlerR0, pszPfHandlerR0, 880 pDevIns->pReg->pszRCMod, pszHandlerRC, pszPfHandlerRC, 881 pszDesc, phType); 873 pfnHandlerR3, pszDesc, phType); 882 874 883 875 Log(("pdmR3DevHlp_PGMHandlerPhysicalTypeRegister: caller='%s'/%d: returns %Rrc\n", … … 5764 5756 /** @interface_method_impl{PDMDEVHLPR3,pfnPGMHandlerPhysicalTypeRegister} */ 5765 5757 static DECLCALLBACK(int) pdmR3DevHlp_Untrusted_PGMHandlerPhysicalTypeRegister(PPDMDEVINS pDevIns, PGMPHYSHANDLERKIND enmKind, 5766 R3PTRTYPE(PFNPGMPHYSHANDLER) pfnHandlerR3, 5767 const char *pszHandlerR0, const char *pszPfHandlerR0, 5768 const char *pszHandlerRC, const char *pszPfHandlerRC, 5758 PFNPGMPHYSHANDLER pfnHandler, 5769 5759 const char *pszDesc, PPGMPHYSHANDLERTYPE phType) 5770 5760 { 5771 5761 PDMDEV_ASSERT_DEVINS(pDevIns); 5772 RT_NOREF( enmKind, pfnHandlerR3, pszHandlerR0, pszPfHandlerR0, pszHandlerRC, pszPfHandlerRC, pszDesc, phType);5762 RT_NOREF(pDevIns, enmKind, pfnHandler, pszDesc); 5773 5763 AssertReleaseMsgFailed(("Untrusted device called trusted helper! '%s'/%d\n", 5774 5764 pDevIns->pReg->szName, pDevIns->iInstance)); 5765 *phType = NIL_PGMPHYSHANDLERTYPE; 5775 5766 return VERR_ACCESS_DENIED; 5776 5767 } -
trunk/src/VBox/VMM/VMMR3/PGM.cpp
r93635 r93650 618 618 #include <iprt/assert.h> 619 619 #include <iprt/env.h> 620 #include <iprt/file.h> 620 621 #include <iprt/mem.h> 621 #include <iprt/ file.h>622 #include <iprt/rand.h> 622 623 #include <iprt/string.h> 623 624 #include <iprt/thread.h> … … 794 795 pVM->pgm.s.aLargeHandyPage[i].idPage = NIL_GMM_PAGEID; 795 796 pVM->pgm.s.aLargeHandyPage[i].idSharedPage = NIL_GMM_PAGEID; 797 } 798 799 AssertReleaseReturn(pVM->pgm.s.cPhysHandlerTypes == 0, VERR_WRONG_ORDER); 800 for (size_t i = 0; i < RT_ELEMENTS(pVM->pgm.s.aPhysHandlerTypes); i++) 801 { 802 if (fDriverless) 803 pVM->pgm.s.aPhysHandlerTypes[i].hType = i | (RTRandU64() & ~(uint64_t)PGMPHYSHANDLERTYPE_IDX_MASK); 804 pVM->pgm.s.aPhysHandlerTypes[i].enmKind = PGMPHYSHANDLERKIND_INVALID; 805 pVM->pgm.s.aPhysHandlerTypes[i].pfnHandler = pgmR3HandlerPhysicalHandlerInvalid; 796 806 } 797 807 … … 954 964 if (RT_SUCCESS(rc)) 955 965 /** @todo why isn't pgmPhysRomWriteHandler registered for ring-0? */ 956 rc = PGMR3HandlerPhysicalTypeRegister(pVM, PGMPHYSHANDLERKIND_WRITE, 0 /*fFlags*/, 957 pgmPhysRomWriteHandler, 958 NULL, NULL, "pgmPhysRomWritePfHandler", 959 NULL, NULL, "pgmPhysRomWritePfHandler", 960 "ROM write protection", 961 &pVM->pgm.s.hRomPhysHandlerType); 966 rc = PGMR3HandlerPhysicalTypeRegister(pVM, PGMPHYSHANDLERKIND_WRITE, 0 /*fFlags*/, pgmPhysRomWriteHandler, 967 "ROM write protection", &pVM->pgm.s.hRomPhysHandlerType); 962 968 963 969 /* … … 966 972 if (RT_SUCCESS(rc)) 967 973 rc = PGMR3HandlerPhysicalTypeRegister(pVM, PGMPHYSHANDLERKIND_WRITE, PGMPHYSHANDLER_F_KEEP_PGM_LOCK, 968 pgmPhysMmio2WriteHandler, 969 NULL, "pgmPhysMmio2WriteHandler", "pgmPhysMmio2WritePfHandler", 970 NULL, "pgmPhysMmio2WriteHandler", "pgmPhysMmio2WritePfHandler", 971 "MMIO2 dirty page tracing", 974 pgmPhysMmio2WriteHandler, "MMIO2 dirty page tracing", 972 975 &pVM->pgm.s.hMmio2DirtyPhysHandlerType); 973 976 -
trunk/src/VBox/VMM/VMMR3/PGMHandler.cpp
r93635 r93650 58 58 59 59 60 61 /** 62 * Register a physical page access handler type, extended version. 60 /** 61 * @callback_method_impl{FNPGMPHYSHANDLER, 62 * Invalid callback entry triggering guru mediation} 63 */ 64 DECLCALLBACK(VBOXSTRICTRC) pgmR3HandlerPhysicalHandlerInvalid(PVMCC pVM, PVMCPUCC pVCpu, RTGCPHYS GCPhys, void *pvPhys, 65 void *pvBuf, size_t cbBuf, PGMACCESSTYPE enmAccessType, 66 PGMACCESSORIGIN enmOrigin, uint64_t uUser) 67 { 68 RT_NOREF(pVM, pVCpu, GCPhys, pvPhys, pvBuf, cbBuf, enmAccessType, enmOrigin, uUser); 69 LogRel(("GCPhys=%RGp cbBuf=%#zx enmAccessType=%d uUser=%#RX64\n", GCPhys, cbBuf, enmAccessType, uUser)); 70 return VERR_PGM_HANDLER_IPE_1; 71 } 72 73 74 /** 75 * Register a physical page access handler type. 63 76 * 64 77 * @returns VBox status code. 65 * @param pVM The cross context VM structure. 66 * @param enmKind The kind of access handler. 67 * @param fFlags PGMPHYSHANDLER_F_XXX 68 * @param pfnHandlerR3 Pointer to the ring-3 handler callback. 69 * @param pfnHandlerR0 Pointer to the ring-0 handler callback. 70 * @param pfnPfHandlerR0 Pointer to the ring-0 \#PF handler callback. 71 * callback. 72 * @param pszDesc The type description. 73 * @param phType Where to return the type handle (cross context 74 * safe). 75 */ 76 VMMR3_INT_DECL(int) PGMR3HandlerPhysicalTypeRegisterEx(PVM pVM, PGMPHYSHANDLERKIND enmKind, uint32_t fFlags, 77 PFNPGMPHYSHANDLER pfnHandlerR3, 78 R0PTRTYPE(PFNPGMPHYSHANDLER) pfnHandlerR0, 79 R0PTRTYPE(PFNPGMRZPHYSPFHANDLER) pfnPfHandlerR0, 80 const char *pszDesc, PPGMPHYSHANDLERTYPE phType) 81 { 82 AssertPtrReturn(pfnHandlerR3, VERR_INVALID_POINTER); 83 AssertReturn(pfnHandlerR0 != NIL_RTR0PTR || SUPR3IsDriverless(), VERR_INVALID_POINTER); 84 AssertReturn(pfnPfHandlerR0 != NIL_RTR0PTR || SUPR3IsDriverless(), VERR_INVALID_POINTER); 78 * @param pVM The cross context VM structure. 79 * @param enmKind The kind of access handler. 80 * @param fFlags PGMPHYSHANDLER_F_XXX 81 * @param pfnHandler Pointer to the ring-3 handler callback. 82 * @param pszDesc The type description. 83 * @param phType Where to return the type handle (cross context safe). 84 */ 85 VMMR3_INT_DECL(int) PGMR3HandlerPhysicalTypeRegister(PVM pVM, PGMPHYSHANDLERKIND enmKind, uint32_t fFlags, 86 PFNPGMPHYSHANDLER pfnHandler, const char *pszDesc, 87 PPGMPHYSHANDLERTYPE phType) 88 { 89 /* 90 * Validate input. 91 */ 92 AssertPtrReturn(phType, VERR_INVALID_POINTER); 93 *phType = NIL_PGMPHYSHANDLERTYPE; 94 95 AssertPtrReturn(pfnHandler, VERR_INVALID_POINTER); 85 96 AssertPtrReturn(pszDesc, VERR_INVALID_POINTER); 86 97 AssertReturn( enmKind == PGMPHYSHANDLERKIND_WRITE … … 90 101 AssertMsgReturn(!(fFlags & ~PGMPHYSHANDLER_F_VALID_MASK), ("%#x\n", fFlags), VERR_INVALID_FLAGS); 91 102 92 PPGMPHYSHANDLERTYPEINT pType; 93 int rc = MMHyperAlloc(pVM, sizeof(*pType), 0, MM_TAG_PGM_HANDLER_TYPES, (void **)&pType); 94 if (RT_SUCCESS(rc)) 95 { 96 pType->u32Magic = PGMPHYSHANDLERTYPEINT_MAGIC; 97 pType->cRefs = 1; 98 pType->enmKind = enmKind; 99 pType->uState = enmKind == PGMPHYSHANDLERKIND_WRITE 100 ? PGM_PAGE_HNDL_PHYS_STATE_WRITE : PGM_PAGE_HNDL_PHYS_STATE_ALL; 101 pType->fKeepPgmLock = RT_BOOL(fFlags & PGMPHYSHANDLER_F_KEEP_PGM_LOCK); 102 pType->fRing0DevInsIdx = RT_BOOL(fFlags & PGMPHYSHANDLER_F_R0_DEVINS_IDX); 103 pType->pfnHandlerR3 = pfnHandlerR3; 104 pType->pfnHandlerR0 = pfnHandlerR0; 105 pType->pfnPfHandlerR0 = pfnPfHandlerR0; 106 pType->pszDesc = pszDesc; 107 108 PGM_LOCK_VOID(pVM); 109 RTListOff32Append(&pVM->pgm.s.CTX_SUFF(pTrees)->HeadPhysHandlerTypes, &pType->ListNode); 110 PGM_UNLOCK(pVM); 111 112 *phType = MMHyperHeapPtrToOffset(pVM, pType); 113 LogFlow(("PGMR3HandlerPhysicalTypeRegisterEx: %p/%#x: enmKind=%d pfnHandlerR3=%RHv pfnHandlerR0=%RHv pszDesc=%s\n", 114 pType, *phType, enmKind, pfnHandlerR3, pfnPfHandlerR0, pszDesc)); 115 return VINF_SUCCESS; 116 } 117 *phType = NIL_PGMPHYSHANDLERTYPE; 118 return rc; 119 } 120 121 122 /** 123 * Register a physical page access handler type. 124 * 125 * @returns VBox status code. 126 * @param pVM The cross context VM structure. 127 * @param enmKind The kind of access handler. 128 * @param fFlags PGMPHYSHANDLER_F_XXX 129 * @param pfnHandlerR3 Pointer to the ring-3 handler callback. 130 * @param pszModR0 The name of the ring-0 module, NULL is an alias for 131 * the main ring-0 module. 132 * @param pszHandlerR0 The name of the ring-0 handler, NULL if the ring-3 133 * handler should be called. 134 * @param pszPfHandlerR0 The name of the ring-0 \#PF handler, NULL if the 135 * ring-3 handler should be called. 136 * @param pszModRC The name of the raw-mode context module, NULL is an 137 * alias for the main RC module. 138 * @param pszHandlerRC The name of the raw-mode context handler, NULL if 139 * the ring-3 handler should be called. 140 * @param pszPfHandlerRC The name of the raw-mode context \#PF handler, NULL 141 * if the ring-3 handler should be called. 142 * @param pszDesc The type description. 143 * @param phType Where to return the type handle (cross context 144 * safe). 145 */ 146 VMMR3DECL(int) PGMR3HandlerPhysicalTypeRegister(PVM pVM, PGMPHYSHANDLERKIND enmKind, uint32_t fFlags, 147 R3PTRTYPE(PFNPGMPHYSHANDLER) pfnHandlerR3, 148 const char *pszModR0, const char *pszHandlerR0, const char *pszPfHandlerR0, 149 const char *pszModRC, const char *pszHandlerRC, const char *pszPfHandlerRC, 150 const char *pszDesc, PPGMPHYSHANDLERTYPE phType) 151 { 152 LogFlow(("PGMR3HandlerPhysicalTypeRegister: enmKind=%d pfnHandlerR3=%RHv pszModR0=%s pszHandlerR0=%s pszPfHandlerR0=%s pszModRC=%s pszHandlerRC=%s pszPfHandlerRC=%s pszDesc=%s\n", 153 enmKind, pfnHandlerR3, pszModR0, pszHandlerR0, pszPfHandlerR0, pszModRC, pszHandlerRC, pszPfHandlerRC, pszDesc)); 154 155 /* 156 * Validate input. 157 */ 158 AssertPtrReturn(pfnHandlerR3, VERR_INVALID_POINTER); 159 AssertPtrNullReturn(pszModR0, VERR_INVALID_POINTER); 160 AssertPtrNullReturn(pszHandlerR0, VERR_INVALID_POINTER); 161 AssertPtrNullReturn(pszPfHandlerR0, VERR_INVALID_POINTER); 162 AssertPtrNullReturn(pszModRC, VERR_INVALID_POINTER); 163 AssertPtrNullReturn(pszHandlerRC, VERR_INVALID_POINTER); 164 AssertPtrNullReturn(pszPfHandlerRC, VERR_INVALID_POINTER); 165 166 /* 167 * Resolve the R0 handlers. 168 */ 169 R0PTRTYPE(PFNPGMPHYSHANDLER) pfnHandlerR0 = NIL_RTR0PTR; 170 R0PTRTYPE(PFNPGMR0PHYSPFHANDLER) pfnPfHandlerR0 = NIL_RTR0PTR; 171 int rc = VINF_SUCCESS; 172 if (!SUPR3IsDriverless()) 173 { 174 rc = PDMR3LdrGetSymbolR0Lazy(pVM, pszHandlerR0 ? pszModR0 : NULL, NULL /*pszSearchPath*/, 175 pszHandlerR0 ? pszHandlerR0 : "pgmPhysHandlerRedirectToHC", &pfnHandlerR0); 176 if (RT_SUCCESS(rc)) 177 { 178 rc = PDMR3LdrGetSymbolR0Lazy(pVM, pszPfHandlerR0 ? pszModR0 : NULL, NULL /*pszSearchPath*/, 179 pszPfHandlerR0 ? pszPfHandlerR0 : "pgmPhysPfHandlerRedirectToHC", &pfnPfHandlerR0); 180 AssertMsgRC(rc, ("Failed to resolve %s.%s, rc=%Rrc.\n", pszPfHandlerR0 ? pszModR0 : VMMR0_MAIN_MODULE_NAME, 181 pszPfHandlerR0 ? pszPfHandlerR0 : "pgmPhysHandlerRedirectToHC", rc)); 182 } 183 else 184 AssertMsgFailed(("Failed to resolve %s.%s, rc=%Rrc.\n", pszHandlerR0 ? pszModR0 : VMMR0_MAIN_MODULE_NAME, 185 pszHandlerR0 ? pszHandlerR0 : "pgmPhysHandlerRedirectToHC", rc)); 186 } 187 if (RT_SUCCESS(rc)) 188 { 189 /* 190 * Resolve the GC handler. 191 */ 192 RTRCPTR pfnHandlerRC = NIL_RTRCPTR; 193 RTRCPTR pfnPfHandlerRC = NIL_RTRCPTR; 194 if (VM_IS_RAW_MODE_ENABLED(pVM)) 195 { 196 rc = PDMR3LdrGetSymbolRCLazy(pVM, pszHandlerRC ? pszModRC : NULL, NULL /*pszSearchPath*/, 197 pszHandlerRC ? pszHandlerRC : "pgmPhysHandlerRedirectToHC", &pfnHandlerRC); 198 if (RT_SUCCESS(rc)) 199 { 200 rc = PDMR3LdrGetSymbolRCLazy(pVM, pszPfHandlerRC ? pszModRC : NULL, NULL /*pszSearchPath*/, 201 pszPfHandlerRC ? pszPfHandlerRC : "pgmPhysPfHandlerRedirectToHC", &pfnPfHandlerRC); 202 AssertMsgRC(rc, ("Failed to resolve %s.%s, rc=%Rrc.\n", pszPfHandlerRC ? pszModRC : VMMRC_MAIN_MODULE_NAME, 203 pszPfHandlerRC ? pszPfHandlerRC : "pgmPhysPfHandlerRedirectToHC", rc)); 204 } 205 else 206 AssertMsgFailed(("Failed to resolve %s.%s, rc=%Rrc.\n", pszHandlerRC ? pszModRC : VMMRC_MAIN_MODULE_NAME, 207 pszHandlerRC ? pszHandlerRC : "pgmPhysHandlerRedirectToHC", rc)); 208 209 } 210 if (RT_SUCCESS(rc)) 211 return PGMR3HandlerPhysicalTypeRegisterEx(pVM, enmKind, fFlags, pfnHandlerR3, 212 pfnHandlerR0, pfnPfHandlerR0, pszDesc, phType); 213 } 214 215 return rc; 103 VM_ASSERT_EMT0_RETURN(pVM, VERR_VM_THREAD_NOT_EMT); 104 VM_ASSERT_STATE_RETURN(pVM, VMSTATE_CREATING, VERR_VM_INVALID_VM_STATE); 105 106 /* 107 * Do the allocating. 108 */ 109 PGMPHYSHANDLERTYPE hType = pVM->pgm.s.cPhysHandlerTypes; 110 AssertLogRelReturn(hType < RT_ELEMENTS(pVM->pgm.s.aPhysHandlerTypes), VERR_OUT_OF_RESOURCES); 111 PPGMPHYSHANDLERTYPEINTR3 const pType = &pVM->pgm.s.aPhysHandlerTypes[hType]; 112 AssertReturn(pType->enmKind == PGMPHYSHANDLERKIND_INVALID, VERR_PGM_HANDLER_IPE_1); 113 pVM->pgm.s.cPhysHandlerTypes++; 114 115 pType->enmKind = enmKind; 116 pType->uState = enmKind == PGMPHYSHANDLERKIND_WRITE 117 ? PGM_PAGE_HNDL_PHYS_STATE_WRITE : PGM_PAGE_HNDL_PHYS_STATE_ALL; 118 pType->fKeepPgmLock = RT_BOOL(fFlags & PGMPHYSHANDLER_F_KEEP_PGM_LOCK); 119 pType->fRing0DevInsIdx = RT_BOOL(fFlags & PGMPHYSHANDLER_F_R0_DEVINS_IDX); 120 pType->pfnHandler = pfnHandler; 121 pType->pszDesc = pszDesc; 122 123 *phType = pType->hType; 124 LogFlow(("PGMR3HandlerPhysicalTypeRegisterEx: hType=%#x: enmKind=%d fFlags=%#x pfnHandler=%p pszDesc=%s\n", 125 hType, enmKind, fFlags, pfnHandler, pszDesc)); 126 return VINF_SUCCESS; 216 127 } 217 128 … … 294 205 PVM pVM = (PVM)pvUser; 295 206 PPGMPHYSHANDLER pCur = (PPGMPHYSHANDLER)pNode; 296 P PGMPHYSHANDLERTYPEINT pCurType = PGMPHYSHANDLER_GET_TYPE(pVM, pCur);207 PCPGMPHYSHANDLERTYPEINT pCurType = PGMPHYSHANDLER_GET_TYPE_NO_NULL(pVM, pCur); 297 208 unsigned uState = pCurType->uState; 298 209 PPGMRAMRANGE pRamHint = NULL; … … 365 276 pHlp->pfnPrintf(pHlp, 366 277 "Physical handlers: (PhysHandlers=%d (%#x))\n" 367 "%*s %*s %*s %*s uUserType Description\n",278 "%*s %*s %*s uUser Type Description\n", 368 279 pVM->pgm.s.pTreesR3->PhysHandlers, pVM->pgm.s.pTreesR3->PhysHandlers, 369 280 - (int)sizeof(RTGCPHYS) * 2, "From", 370 281 - (int)sizeof(RTGCPHYS) * 2 - 3, "- To (incl)", 371 - (int)sizeof(RTHCPTR) * 2 - 1, "HandlerR3", 372 - (int)sizeof(RTHCPTR) * 2 - 1, "HandlerR0"); 282 - (int)sizeof(RTHCPTR) * 2 - 1, "Handler (R3)"); 373 283 RTAvlroGCPhysDoWithAll(&pVM->pgm.s.pTreesR3->PhysHandlers, true, pgmR3InfoHandlersPhysicalOne, &Args); 374 284 } … … 384 294 static DECLCALLBACK(int) pgmR3InfoHandlersPhysicalOne(PAVLROGCPHYSNODECORE pNode, void *pvUser) 385 295 { 386 PPGMPHYSHANDLER pCur = (PPGMPHYSHANDLER)pNode;387 PPGMHANDLERINFOARG pArgs = (PPGMHANDLERINFOARG)pvUser;388 PCDBGFINFOHLP pHlp = pArgs->pHlp;389 P PGMPHYSHANDLERTYPEINT pCurType = PGMPHYSHANDLER_GET_TYPE(pArgs->pVM, pCur);296 PPGMPHYSHANDLER pCur = (PPGMPHYSHANDLER)pNode; 297 PPGMHANDLERINFOARG pArgs = (PPGMHANDLERINFOARG)pvUser; 298 PCDBGFINFOHLP pHlp = pArgs->pHlp; 299 PCPGMPHYSHANDLERTYPEINT pCurType = PGMPHYSHANDLER_GET_TYPE_NO_NULL(pArgs->pVM, pCur); 390 300 const char *pszType; 391 301 switch (pCurType->enmKind) … … 394 304 case PGMPHYSHANDLERKIND_WRITE: pszType = "Write "; break; 395 305 case PGMPHYSHANDLERKIND_ALL: pszType = "All "; break; 396 default: pszType = "???? "; break;306 default: pszType = "???????"; break; 397 307 } 308 309 char szFlags[80]; 310 size_t cchFlags = 0; 311 if (pCurType->fKeepPgmLock) 312 cchFlags = RTStrPrintf(szFlags, sizeof(szFlags), "(keep-pgm-lock"); 313 if (pCurType->fRing0DevInsIdx) 314 cchFlags += RTStrPrintf(&szFlags[cchFlags], sizeof(szFlags) - cchFlags, cchFlags ? ", keep-pgm-lock" : "(keep-pgm-lock"); 315 if (pCurType->fRing0Enabled) 316 cchFlags += RTStrPrintf(&szFlags[cchFlags], sizeof(szFlags) - cchFlags, cchFlags ? ", r0-enabled)" : "(r0-enabled)"); 317 else 318 cchFlags += RTStrPrintf(&szFlags[cchFlags], sizeof(szFlags) - cchFlags, cchFlags ? ", r3-only)" : "(r3-only)"); 319 398 320 pHlp->pfnPrintf(pHlp, 399 "%RGp - %RGp %RHv %RHv %#018RX64 %s %s\n", 400 pCur->Core.Key, pCur->Core.KeyLast, pCurType->pfnHandlerR3, pCurType->pfnPfHandlerR0, pCur->uUser, 401 pszType, pCur->pszDesc); 321 "%RGp - %RGp %p %016RX64 %s %s %s\n", 322 pCur->Core.Key, pCur->Core.KeyLast, pCurType->pfnHandler, pCur->uUser, pszType, pCur->pszDesc, szFlags); 402 323 #ifdef VBOX_WITH_STATISTICS 403 324 if (pArgs->fStats) -
trunk/src/VBox/VMM/VMMR3/PGMPhys.cpp
r93635 r93650 2271 2271 AssertPtrReturn(pszDesc, VERR_INVALID_POINTER); 2272 2272 AssertReturn(*pszDesc, VERR_INVALID_PARAMETER); 2273 Assert(((PPGMPHYSHANDLERTYPEINT)MMHyperHeapOffsetToPtr(pVM, hType))->enmKind == PGMPHYSHANDLERKIND_MMIO); 2273 #ifdef VBOX_STRICT 2274 PCPGMPHYSHANDLERTYPEINT pType = pgmHandlerPhysicalTypeHandleToPtr(pVM, hType); 2275 Assert(pType); 2276 Assert(pType->enmKind == PGMPHYSHANDLERKIND_MMIO); 2277 #endif 2274 2278 2275 2279 int rc = PGM_LOCK(pVM); -
trunk/src/VBox/VMM/VMMR3/PGMPool.cpp
r93635 r93650 284 284 pPool->hAccessHandlerType = NIL_PGMPHYSHANDLERTYPE; 285 285 rc = PGMR3HandlerPhysicalTypeRegister(pVM, PGMPHYSHANDLERKIND_WRITE, PGMPHYSHANDLER_F_KEEP_PGM_LOCK, 286 pgmPoolAccessHandler, 287 NULL, "pgmPoolAccessHandler", "pgmRZPoolAccessPfHandler", 288 NULL, "pgmPoolAccessHandler", "pgmRZPoolAccessPfHandler", 289 "Guest Paging Access Handler", 290 &pPool->hAccessHandlerType); 286 pgmPoolAccessHandler, "Guest Paging Access Handler", &pPool->hAccessHandlerType); 291 287 AssertLogRelRCReturn(rc, rc); 292 288 -
trunk/src/VBox/VMM/include/GIMInternal.h
r93115 r93650 51 51 /** Physical access handler type for semi-read-only MMIO2 memory. Lazy creation. */ 52 52 PGMPHYSHANDLERTYPE hSemiReadOnlyMmio2Handler; 53 /** Alignment padding. */54 uint32_t u32Padding;55 53 56 54 /** Pointer to the GIM device - R3 ptr. */ -
trunk/src/VBox/VMM/include/IEMInternal.h
r93115 r93650 552 552 /** The error code for the current exception / interrupt. */ 553 553 uint32_t uCurXcptErr; 554 /** The VMX APIC-access page handler type. */555 PGMPHYSHANDLERTYPE hVmxApicAccessPage;556 554 557 555 /** @name Statistics … … 725 723 # define IEM_GET_INSTR_LEN(a_pVCpu) ((a_pVCpu)->iem.s.offOpcode) 726 724 #endif 725 726 727 /** 728 * Shared per-VM IEM data. 729 */ 730 typedef struct IEM 731 { 732 /** The VMX APIC-access page handler type. */ 733 PGMPHYSHANDLERTYPE hVmxApicAccessPage; 734 } IEM; 735 727 736 728 737 -
trunk/src/VBox/VMM/include/IOMInternal.h
r93115 r93650 571 571 572 572 #ifndef IN_RING3 573 DECL EXPORT(FNPGMRZPHYSPFHANDLER)iomMmioPfHandlerNew;574 #endif 575 PGM_ALL_CB2_PROTO(FNPGMPHYSHANDLER)iomMmioHandlerNew;573 DECLCALLBACK(FNPGMRZPHYSPFHANDLER) iomMmioPfHandlerNew; 574 #endif 575 DECLCALLBACK(FNPGMPHYSHANDLER) iomMmioHandlerNew; 576 576 577 577 /* IOM locking helpers. */ -
trunk/src/VBox/VMM/include/PGMInline.h
r93554 r93650 992 992 993 993 /** 994 * Converts a handle to a pointer. 995 * 996 * @returns Pointer on success, NULL on failure (asserted). 997 * @param pVM The cross context VM structure. 998 * @param hType Physical access handler type handle. 999 */ 1000 DECLINLINE(PCPGMPHYSHANDLERTYPEINT) pgmHandlerPhysicalTypeHandleToPtr(PVMCC pVM, PGMPHYSHANDLERTYPE hType) 1001 { 1002 #ifdef IN_RING0 1003 PPGMPHYSHANDLERTYPEINT pType = &pVM->pgmr0.s.aPhysHandlerTypes[hType & PGMPHYSHANDLERTYPE_IDX_MASK]; 1004 #elif defined(IN_RING3) 1005 PPGMPHYSHANDLERTYPEINT pType = &pVM->pgm.s.aPhysHandlerTypes[hType & PGMPHYSHANDLERTYPE_IDX_MASK]; 1006 #else 1007 # error "Invalid context" 1008 #endif 1009 AssertReturn(pType->hType == hType, NULL); 1010 return pType; 1011 } 1012 1013 1014 /** 1015 * Converts a handle to a pointer, never returns NULL. 1016 * 1017 * @returns Pointer on success, dummy on failure (asserted). 1018 * @param pVM The cross context VM structure. 1019 * @param hType Physical access handler type handle. 1020 */ 1021 DECLINLINE(PCPGMPHYSHANDLERTYPEINT) pgmHandlerPhysicalTypeHandleToPtr2(PVMCC pVM, PGMPHYSHANDLERTYPE hType) 1022 { 1023 #ifdef IN_RING0 1024 PPGMPHYSHANDLERTYPEINT pType = &pVM->pgmr0.s.aPhysHandlerTypes[hType & PGMPHYSHANDLERTYPE_IDX_MASK]; 1025 #elif defined(IN_RING3) 1026 PPGMPHYSHANDLERTYPEINT pType = &pVM->pgm.s.aPhysHandlerTypes[hType & PGMPHYSHANDLERTYPE_IDX_MASK]; 1027 #else 1028 # error "Invalid context" 1029 #endif 1030 AssertReturn(pType->hType == hType, &g_pgmHandlerPhysicalDummyType); 1031 return pType; 1032 } 1033 1034 1035 /** 994 1036 * Internal worker for finding a 'in-use' shadow page give by it's physical address. 995 1037 * -
trunk/src/VBox/VMM/include/PGMInternal.h
r93635 r93650 483 483 484 484 485 /** 486 * Physical page access handler type registration. 487 */ 488 typedef struct PGMPHYSHANDLERTYPEINT 489 { 490 /** Number of references. */ 491 uint32_t volatile cRefs; 492 /** Magic number (PGMPHYSHANDLERTYPEINT_MAGIC). */ 493 uint32_t u32Magic; 494 /** Link of handler types anchored in PGMTREES::HeadPhysHandlerTypes. */ 495 RTLISTOFF32NODE ListNode; 485 /** The physical access handler type handle count (power of two). */ 486 #define PGMPHYSHANDLERTYPE_COUNT 0x20 487 /** Mask for getting the array index from an access handler type handle. 488 * The other handle bits are random and non-zero to avoid mixups due to zero 489 * initialized fields. */ 490 #define PGMPHYSHANDLERTYPE_IDX_MASK 0x1f 491 492 /** 493 * Physical page access handler type registration, ring-0 part. 494 */ 495 typedef struct PGMPHYSHANDLERTYPEINTR0 496 { 497 /** The handle value for verfication. */ 498 PGMPHYSHANDLERTYPE hType; 496 499 /** The kind of accesses we're handling. */ 497 500 PGMPHYSHANDLERKIND enmKind; … … 506 509 bool fRing0DevInsIdx; 507 510 bool afPadding[1]; 508 /** Pointer to R3 callback function. */ 509 R3PTRTYPE(PFNPGMPHYSHANDLER) pfnHandlerR3; 510 /** Pointer to R0 callback function. */ 511 R0PTRTYPE(PFNPGMPHYSHANDLER) pfnHandlerR0; 512 /** Pointer to R0 callback function for \#PFs. */ 513 R0PTRTYPE(PFNPGMRZPHYSPFHANDLER) pfnPfHandlerR0; 511 /** Pointer to the ring-0 callback function. */ 512 R0PTRTYPE(PFNPGMPHYSHANDLER) pfnHandler; 513 /** Pointer to the ring-9 callback function for \#PFs. */ 514 R0PTRTYPE(PFNPGMRZPHYSPFHANDLER) pfnPfHandler; 515 /** Description / Name. For easing debugging. */ 516 R0PTRTYPE(const char *) pszDesc; 517 } PGMPHYSHANDLERTYPEINTR0; 518 /** Pointer to a physical access handler type registration. */ 519 typedef PGMPHYSHANDLERTYPEINTR0 *PPGMPHYSHANDLERTYPEINTR0; 520 521 /** 522 * Physical page access handler type registration, shared/ring-3 part. 523 */ 524 typedef struct PGMPHYSHANDLERTYPEINTR3 525 { 526 /** The handle value for verfication. */ 527 PGMPHYSHANDLERTYPE hType; 528 /** The kind of accesses we're handling. */ 529 PGMPHYSHANDLERKIND enmKind; 530 /** The PGM_PAGE_HNDL_PHYS_STATE_XXX value corresponding to enmKind. */ 531 uint8_t uState; 532 /** Whether to keep the PGM lock when calling the handler. 533 * @sa PGMPHYSHANDLER_F_KEEP_PGM_LOCK */ 534 bool fKeepPgmLock; 535 /** Set if this is registered by a device instance and uUser should be 536 * translated from a device instance ID to a pointer. 537 * @sa PGMPHYSHANDLER_F_R0_DEVINS_IDX */ 538 bool fRing0DevInsIdx; 539 /** Set by ring-0 if the handler is ring-0 enabled (for debug). */ 540 bool fRing0Enabled : 1; 541 /** Pointer to the ring-3 callback function. */ 542 R3PTRTYPE(PFNPGMPHYSHANDLER) pfnHandler; 514 543 /** Description / Name. For easing debugging. */ 515 544 R3PTRTYPE(const char *) pszDesc; 516 } PGMPHYSHANDLERTYPEINT ;545 } PGMPHYSHANDLERTYPEINTR3; 517 546 /** Pointer to a physical access handler type registration. */ 518 typedef PGMPHYSHANDLERTYPEINT *PPGMPHYSHANDLERTYPEINT; 519 /** Magic value for the physical handler callbacks (Robert A. Heinlein). */ 520 #define PGMPHYSHANDLERTYPEINT_MAGIC UINT32_C(0x19070707) 521 /** Magic value for the physical handler callbacks. */ 522 #define PGMPHYSHANDLERTYPEINT_MAGIC_DEAD UINT32_C(0x19880508) 523 524 /** 525 * Converts a handle to a pointer. 526 * @returns PPGMPHYSHANDLERTYPEINT 527 * @param a_pVM The cross context VM structure. 528 * @param a_hType Physical access handler type handle. 529 */ 530 #define PGMPHYSHANDLERTYPEINT_FROM_HANDLE(a_pVM, a_hType) ((PPGMPHYSHANDLERTYPEINT)MMHyperHeapOffsetToPtr(a_pVM, a_hType)) 547 typedef PGMPHYSHANDLERTYPEINTR3 *PPGMPHYSHANDLERTYPEINTR3; 548 549 /** Pointer to a physical access handler type record for the current context. */ 550 typedef CTX_SUFF(PPGMPHYSHANDLERTYPEINT) PPGMPHYSHANDLERTYPEINT; 551 /** Pointer to a const physical access handler type record for the current context. */ 552 typedef CTX_SUFF(PGMPHYSHANDLERTYPEINT) const *PCPGMPHYSHANDLERTYPEINT; 553 /** Dummy physical access handler type record. */ 554 extern CTX_SUFF(PGMPHYSHANDLERTYPEINT) const g_pgmHandlerPhysicalDummyType; 531 555 532 556 … … 546 570 /** Set if we have pages that have temporarily been disabled. */ 547 571 uint32_t cTmpOffPages; 548 /** Registered handler type handle (heap offset). */ 549 PGMPHYSHANDLERTYPE hType; 572 uint32_t u32Padding; 573 /** Registered handler type handle. 574 * @note Marked volatile to prevent re-reading after validation. */ 575 PGMPHYSHANDLERTYPE volatile hType; 550 576 /** User argument for the handlers. */ 551 577 uint64_t uUser; … … 562 588 /** 563 589 * Gets the type record for a physical handler (no reference added). 564 * @returns P PGMPHYSHANDLERTYPEINT590 * @returns PCPGMPHYSHANDLERTYPEINT, can be NULL 565 591 * @param a_pVM The cross context VM structure. 566 592 * @param a_pPhysHandler Pointer to the physical handler structure 567 593 * (PGMPHYSHANDLER). 568 594 */ 569 #define PGMPHYSHANDLER_GET_TYPE(a_pVM, a_pPhysHandler) PGMPHYSHANDLERTYPEINT_FROM_HANDLE(a_pVM, (a_pPhysHandler)->hType) 595 #define PGMPHYSHANDLER_GET_TYPE(a_pVM, a_pPhysHandler) \ 596 pgmHandlerPhysicalTypeHandleToPtr(a_pVM, (a_pPhysHandler) ? (a_pPhysHandler)->hType : NIL_PGMPHYSHANDLERTYPE) 597 598 /** 599 * Gets the type record for a physical handler, never returns NULL. 600 * 601 * @returns PCPGMPHYSHANDLERTYPEINT, never NULL. 602 * @param a_pVM The cross context VM structure. 603 * @param a_pPhysHandler Pointer to the physical handler structure 604 * (PGMPHYSHANDLER). 605 */ 606 #define PGMPHYSHANDLER_GET_TYPE_NO_NULL(a_pVM, a_pPhysHandler) \ 607 pgmHandlerPhysicalTypeHandleToPtr2(a_pVM, (a_pPhysHandler) ? (a_pPhysHandler)->hType : NIL_PGMPHYSHANDLERTYPE) 570 608 571 609 … … 2034 2072 /** The current number of modified pages. */ 2035 2073 uint16_t cModifiedPages; 2074 /** Alignment padding. */ 2075 uint32_t u32Padding2; 2036 2076 /** Physical access handler type registration handle. */ 2037 2077 PGMPHYSHANDLERTYPE hAccessHandlerType; … … 2330 2370 typedef struct PGMTREES 2331 2371 { 2332 /** List of physical access handler types (offset pointers) of type2333 * PGMPHYSHANDLERTYPEINT. This is needed for relocations. */2334 RTLISTOFF32ANCHOR HeadPhysHandlerTypes;2335 2372 /** Physical access handlers (AVL range+offsetptr tree). */ 2336 2373 AVLROGCPHYSTREE PhysHandlers; 2374 uint32_t u32PaddingTo8Bytes; 2337 2375 } PGMTREES; 2338 2376 /** Pointer to PGM trees. */ … … 2954 2992 * owner via pgmPhysGCPhys2CCPtrInternalDepr. */ 2955 2993 uint32_t cDeprecatedPageLocks; 2956 /** Alignment padding. */ 2957 uint32_t au32Alignment2[1+2]; 2994 2995 /** Registered physical access handler types. */ 2996 uint32_t cPhysHandlerTypes; 2997 /** Physical access handler types. 2998 * Initialized to callback causing guru meditations and invalid enmKind. */ 2999 PGMPHYSHANDLERTYPEINTR3 aPhysHandlerTypes[PGMPHYSHANDLERTYPE_COUNT]; 2958 3000 2959 3001 /** PGM critical section. … … 3537 3579 * @{ */ 3538 3580 /** Critical section for serializing pool growth. */ 3539 RTCRITSECT PoolGrowCritSect;3581 RTCRITSECT PoolGrowCritSect; 3540 3582 /** The memory objects for the pool pages. */ 3541 RTR0MEMOBJ ahPoolMemObjs[(PGMPOOL_IDX_LAST + PGMPOOL_CFG_MAX_GROW - 1) / PGMPOOL_CFG_MAX_GROW];3583 RTR0MEMOBJ ahPoolMemObjs[(PGMPOOL_IDX_LAST + PGMPOOL_CFG_MAX_GROW - 1) / PGMPOOL_CFG_MAX_GROW]; 3542 3584 /** The ring-3 mapping objects for the pool pages. */ 3543 RTR0MEMOBJ ahPoolMapObjs[(PGMPOOL_IDX_LAST + PGMPOOL_CFG_MAX_GROW - 1) / PGMPOOL_CFG_MAX_GROW];3585 RTR0MEMOBJ ahPoolMapObjs[(PGMPOOL_IDX_LAST + PGMPOOL_CFG_MAX_GROW - 1) / PGMPOOL_CFG_MAX_GROW]; 3544 3586 /** @} */ 3587 3588 /** Physical access handler types for ring-0. 3589 * Initialized to callback causing return to ring-3 and invalid enmKind. */ 3590 PGMPHYSHANDLERTYPEINTR0 aPhysHandlerTypes[PGMPHYSHANDLERTYPE_COUNT]; 3545 3591 } PGMR0PERVM; 3546 3592 … … 3583 3629 DECLHIDDEN(int) pgmHandlerPhysicalResetMmio2WithBitmap(PVMCC pVM, RTGCPHYS GCPhys, void *pvBitmap, uint32_t offBitmap); 3584 3630 DECLCALLBACK(void) pgmR3InfoHandlers(PVM pVM, PCDBGFINFOHLP pHlp, const char *pszArgs); 3631 DECLCALLBACK(FNPGMPHYSHANDLER) pgmR3HandlerPhysicalHandlerInvalid; 3632 #ifndef IN_RING3 3633 DECLCALLBACK(FNPGMPHYSHANDLER) pgmR0HandlerPhysicalHandlerToRing3; 3634 DECLCALLBACK(FNPGMRZPHYSPFHANDLER) pgmR0HandlerPhysicalPfHandlerToRing3; 3635 #endif 3636 3585 3637 int pgmR3InitSavedState(PVM pVM, uint64_t cbRam); 3586 3638 … … 3606 3658 int pgmPhysGCPhys2CCPtrInternalReadOnly(PVMCC pVM, PPGMPAGE pPage, RTGCPHYS GCPhys, const void **ppv, PPGMPAGEMAPLOCK pLock); 3607 3659 void pgmPhysReleaseInternalPageMappingLock(PVMCC pVM, PPGMPAGEMAPLOCK pLock); 3608 PGM_ALL_CB2_PROTO(FNPGMPHYSHANDLER)pgmPhysRomWriteHandler;3609 PGM_ALL_CB2_PROTO(FNPGMPHYSHANDLER)pgmPhysMmio2WriteHandler;3660 DECLCALLBACK(FNPGMPHYSHANDLER) pgmPhysRomWriteHandler; 3661 DECLCALLBACK(FNPGMPHYSHANDLER) pgmPhysMmio2WriteHandler; 3610 3662 #ifndef IN_RING3 3611 DECLEXPORT(FNPGMPHYSHANDLER) pgmPhysHandlerRedirectToHC; 3612 DECLEXPORT(FNPGMRZPHYSPFHANDLER) pgmPhysPfHandlerRedirectToHC; 3613 DECLEXPORT(FNPGMRZPHYSPFHANDLER) pgmPhysRomWritePfHandler; 3614 DECLEXPORT(FNPGMRZPHYSPFHANDLER) pgmPhysMmio2WritePfHandler; 3663 DECLCALLBACK(FNPGMRZPHYSPFHANDLER) pgmPhysRomWritePfHandler; 3664 DECLCALLBACK(FNPGMRZPHYSPFHANDLER) pgmPhysMmio2WritePfHandler; 3615 3665 #endif 3616 3666 int pgmPhysFreePage(PVM pVM, PGMMFREEPAGESREQ pReq, uint32_t *pcPendingPages, PPGMPAGE pPage, RTGCPHYS GCPhys, … … 3648 3698 3649 3699 #endif /* IN_RING3 */ 3700 #ifdef IN_RING0 3701 int pgmR0PoolInitVM(PGVM pGVM); 3702 #endif 3650 3703 int pgmPoolAlloc(PVMCC pVM, RTGCPHYS GCPhys, PGMPOOLKIND enmKind, PGMPOOLACCESS enmAccess, bool fA20Enabled, 3651 3704 uint16_t iUser, uint32_t iUserTable, bool fLockPage, PPPGMPOOLPAGE ppPage);
Note:
See TracChangeset
for help on using the changeset viewer.