Changeset 93650 in vbox for trunk/src/VBox/VMM/VMMAll
- Timestamp:
- Feb 8, 2022 10:43:53 AM (3 years ago)
- Location:
- trunk/src/VBox/VMM/VMMAll
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
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) ));
Note:
See TracChangeset
for help on using the changeset viewer.