Changeset 81333 in vbox for trunk/src/VBox/VMM/include
- Timestamp:
- Oct 17, 2019 11:49:39 PM (5 years ago)
- Location:
- trunk/src/VBox/VMM/include
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/include/IOMInline.h
r80679 r81333 37 37 * 38 38 * @param pVM The cross context VM structure. 39 * @param uPort The I/O port lookup.40 * @param poffPort Where to the port offset relative to the start of41 * the I/O port range.39 * @param uPort The I/O port to lookup. 40 * @param poffPort Where to return the port offset relative to the 41 * start of the I/O port range. 42 42 * @param pidxLastHint Pointer to IOMCPU::idxIoPortLastRead or 43 43 * IOMCPU::idxIoPortLastWrite. … … 47 47 * for the entry. Use IOMIOPORTENTRYR0::idxSelf to get the ring-3 48 48 * entry. 49 * 50 * @note This code is almost identical to iomMmioGetEntry, so keep in sync. 49 51 */ 50 52 DECLINLINE(CTX_SUFF(PIOMIOPORTENTRY)) iomIoPortGetEntry(PVMCC pVM, RTIOPORT uPort, PRTIOPORT poffPort, uint16_t *pidxLastHint) … … 117 119 #ifdef VBOX_WITH_STATISTICS 118 120 /** 119 * Gets the I/O port statistics entry.121 * Gets the statistics entry for an I/O port. 120 122 * 121 123 * @returns Pointer to stats. Instead of NULL, a pointer to IoPortDummyStats is … … 139 141 # endif 140 142 return &pVM->iom.s.IoPortDummyStats; 143 } 144 #endif 145 146 147 /** 148 * Gets the MMIO region entry for the specified address in the current context. 149 * 150 * @returns Pointer to MMIO region entry. 151 * @returns NULL if no MMIO region registered for the given address. 152 * 153 * @param pVM The cross context VM structure. 154 * @param GCPhys The address to lookup. 155 * @param poffRegion Where to return the byte offset into the MMIO 156 * region that corresponds to @a GCPhys. 157 * @param pidxLastHint Pointer to IOMCPU::idxMmioLastRead, 158 * IOMCPU::idxMmioLastWrite, or similar. 159 * 160 * @note In ring-0 it is possible to get an uninitialized entry (pDevIns is 161 * NULL, cbRegion is 0), in which case there should be ring-3 handlers 162 * for the entry. Use IOMMMIOENTRYR0::idxSelf to get the ring-3 entry. 163 * 164 * @note This code is almost identical to iomIoPortGetEntry, so keep in sync. 165 */ 166 DECLINLINE(CTX_SUFF(PIOMMMIOENTRY)) iomMmioGetEntry(PVMCC pVM, RTGCPHYS GCPhys, PRTGCPHYS poffRegion, uint16_t *pidxLastHint) 167 { 168 Assert(IOM_IS_SHARED_LOCK_OWNER(pVM)); 169 170 #ifdef IN_RING0 171 uint32_t iEnd = RT_MIN(pVM->iom.s.cMmioLookupEntries, pVM->iomr0.s.cMmioAlloc); 172 PCIOMMMIOLOOKUPENTRY paLookup = pVM->iomr0.s.paMmioLookup; 173 #else 174 uint32_t iEnd = pVM->iom.s.cMmioLookupEntries; 175 PCIOMMMIOLOOKUPENTRY paLookup = pVM->iom.s.paMmioLookup; 176 #endif 177 if (iEnd > 0) 178 { 179 uint32_t iFirst = 0; 180 uint32_t i = *pidxLastHint; 181 if (i < iEnd) 182 { /* likely */ } 183 else 184 i = iEnd / 2; 185 for (;;) 186 { 187 PCIOMMMIOLOOKUPENTRY pCur = &paLookup[i]; 188 if (pCur->GCPhysFirst > GCPhys) 189 { 190 if (i > iFirst) 191 iEnd = i; 192 else 193 break; 194 } 195 else if (pCur->GCPhysLast < GCPhys) 196 { 197 i += 1; 198 if (i < iEnd) 199 iFirst = i; 200 else 201 break; 202 } 203 else 204 { 205 *pidxLastHint = (uint16_t)i; 206 *poffRegion = GCPhys - pCur->GCPhysFirst; 207 208 /* 209 * Translate the 'idx' member into a pointer. 210 */ 211 size_t const idx = pCur->idx; 212 #ifdef IN_RING0 213 AssertMsg(idx < pVM->iom.s.cMmioRegs && idx < pVM->iomr0.s.cMmioAlloc, 214 ("%#zx vs %#x/%x (GCPhys=%RGp)\n", idx, pVM->iom.s.cMmioRegs, pVM->iomr0.s.cMmioMax, GCPhys)); 215 if (idx < pVM->iomr0.s.cMmioAlloc) 216 return &pVM->iomr0.s.paMmioRegs[idx]; 217 #else 218 if (idx < pVM->iom.s.cMmioRegs) 219 return &pVM->iom.s.paMmioRegs[idx]; 220 AssertMsgFailed(("%#zx vs %#x (GCPhys=%RGp)\n", idx, pVM->iom.s.cMmioRegs, GCPhys)); 221 #endif 222 break; 223 } 224 225 i = iFirst + (iEnd - iFirst) / 2; 226 } 227 } 228 *poffRegion = 0; 229 return NULL; 230 } 231 232 233 #ifdef VBOX_WITH_STATISTICS 234 /** 235 * Gets the statistics entry for an MMIO region. 236 * 237 * @returns Pointer to stats. Instead of NULL, a pointer to MmioDummyStats is 238 * returned, so the caller does not need to check for NULL. 239 * 240 * @param pVM The cross context VM structure. 241 * @param pRegEntry The I/O port entry to get stats for. 242 */ 243 DECLINLINE(PIOMMMIOSTATSENTRY) iomMmioGetStats(PVMCC pVM, CTX_SUFF(PIOMMMIOENTRY) pRegEntry) 244 { 245 size_t idxStats = pRegEntry->idxStats; 246 # ifdef IN_RING0 247 if (idxStats < pVM->iomr0.s.cMmioStatsAllocation) 248 return &pVM->iomr0.s.paMmioStats[idxStats]; 249 # else 250 if (idxStats < pVM->iom.s.cMmioStats) 251 return &pVM->iom.s.paMmioStats[idxStats]; 252 # endif 253 return &pVM->iom.s.MmioDummyStats; 141 254 } 142 255 #endif -
trunk/src/VBox/VMM/include/IOMInternal.h
r81197 r81333 307 307 /** Pointer to the fill callback function. */ 308 308 R0PTRTYPE(PFNIOMMMIONEWFILL) pfnFillCallback; 309 /** The entry of the first statistics entry, UINT16_MAX if no stats. */ 309 /** The entry of the first statistics entry, UINT16_MAX if no stats. 310 * @note For simplicity, this is always copied from ring-3 for all entries at 311 * the end of VM creation. */ 310 312 uint16_t idxStats; 311 313 /** Same as the handle index. */ … … 371 373 typedef struct IOMMMIOSTATSENTRY 372 374 { 373 /** Number of accesses (subtract ReadRZToR3 and WriteRZToR3 to get the right 374 * number). */ 375 STAMCOUNTER Accesses; 376 375 /** Counting and profiling reads in R0/RC. */ 376 STAMPROFILE ProfReadRZ; 377 /** Number of successful read accesses. */ 378 STAMCOUNTER Reads; 379 /** Number of reads to this address from R0/RC which was serviced in R3. */ 380 STAMCOUNTER ReadRZToR3; 381 /** Number of complicated reads. */ 382 STAMCOUNTER ComplicatedReads; 383 /** Number of reads of 0xff or 0x00. */ 384 STAMCOUNTER FFor00Reads; 377 385 /** Profiling read handler overhead in R3. */ 378 386 STAMPROFILE ProfReadR3; 387 388 /** Counting and profiling writes in R0/RC. */ 389 STAMPROFILE ProfWriteRZ; 390 /** Number of successful read accesses. */ 391 STAMCOUNTER Writes; 392 /** Number of writes to this address from R0/RC which was serviced in R3. */ 393 STAMCOUNTER WriteRZToR3; 394 /** Number of writes to this address from R0/RC which was committed in R3. */ 395 STAMCOUNTER CommitRZToR3; 396 /** Number of complicated writes. */ 397 STAMCOUNTER ComplicatedWrites; 379 398 /** Profiling write handler overhead in R3. */ 380 399 STAMPROFILE ProfWriteR3; 381 /** Counting and profiling reads in R0/RC. */382 STAMPROFILE ProfReadRZ;383 /** Counting and profiling writes in R0/RC. */384 STAMPROFILE ProfWriteRZ;385 386 /** Number of reads to this address from R0/RC which was serviced in R3. */387 STAMCOUNTER ReadRZToR3;388 /** Number of writes to this address from R0/RC which was serviced in R3. */389 STAMCOUNTER WriteRZToR3;390 400 } IOMMMIOSTATSENTRY; 391 401 /** Pointer to MMIO statistics entry. */ … … 602 612 /** Guest physical MMIO address. */ 603 613 RTGCPHYS GCPhys; 614 /** The number of bytes to write (0 if nothing pending). */ 615 uint32_t cbValue; 616 /** Hint. */ 617 uint32_t idxMmioRegionHint; 604 618 /** The value to write. */ 605 619 uint8_t abValue[128]; 606 /** The number of bytes to write (0 if nothing pending). */607 uint32_t cbValue;608 /** Alignment padding. */609 uint32_t uAlignmentPadding;610 620 } PendingMmioWrite; 611 621 … … 654 664 /** MMIO physical access handler type. */ 655 665 PGMPHYSHANDLERTYPE hMmioHandlerType; 656 uint32_t u32Padding; 666 /** MMIO physical access handler type, new style. */ 667 PGMPHYSHANDLERTYPE hNewMmioHandlerType; 657 668 658 669 /** @name I/O ports … … 729 740 * @{ */ 730 741 STAMPROFILE StatRZMMIOHandler; 731 STAMCOUNTER StatRZMMIOFailures; 732 733 STAMPROFILE StatRZInstMov; 734 STAMPROFILE StatRZInstCmp; 735 STAMPROFILE StatRZInstAnd; 736 STAMPROFILE StatRZInstOr; 737 STAMPROFILE StatRZInstXor; 738 STAMPROFILE StatRZInstBt; 739 STAMPROFILE StatRZInstTest; 740 STAMPROFILE StatRZInstXchg; 741 STAMPROFILE StatRZInstStos; 742 STAMPROFILE StatRZInstLods; 743 #ifdef IOM_WITH_MOVS_SUPPORT 744 STAMPROFILEADV StatRZInstMovs; 745 STAMPROFILE StatRZInstMovsToMMIO; 746 STAMPROFILE StatRZInstMovsFromMMIO; 747 STAMPROFILE StatRZInstMovsMMIO; 748 #endif 749 STAMCOUNTER StatRZInstOther; 750 742 STAMCOUNTER StatRZMMIOReadsToR3; 743 STAMCOUNTER StatRZMMIOWritesToR3; 744 STAMCOUNTER StatRZMMIOCommitsToR3; 745 STAMCOUNTER StatRZMMIODevLockContention; 746 #if 0 751 747 STAMCOUNTER StatRZMMIO1Byte; 752 748 STAMCOUNTER StatRZMMIO2Bytes; 753 749 STAMCOUNTER StatRZMMIO4Bytes; 754 750 STAMCOUNTER StatRZMMIO8Bytes; 755 751 #endif 756 752 STAMCOUNTER StatR3MMIOHandler; 753 754 STAMCOUNTER StatMmioHandlerR3; 755 STAMCOUNTER StatMmioHandlerR0; 757 756 758 757 RTUINT cMovsMaxBytes; … … 791 790 /** The size of the paIoPortStats allocation (in entries). */ 792 791 uint32_t cIoPortStatsAllocation; 792 /** Prevents paIoPortStats from growing, set by IOMR0IoPortSyncStatisticsIndices(). */ 793 bool fIoPortStatsFrozen; 793 794 /** I/O port lookup table. */ 794 795 R0PTRTYPE(PIOMIOPORTSTATSENTRY) paIoPortStats; … … 822 823 /** The size of the paMmioStats allocation (in entries). */ 823 824 uint32_t cMmioStatsAllocation; 825 /* Prevents paMmioStats from growing, set by IOMR0MmioSyncStatisticsIndices(). */ 826 bool fMmioStatsFrozen; 824 827 /** MMIO lookup table. */ 825 828 R0PTRTYPE(PIOMMMIOSTATSENTRY) paMmioStats; … … 841 844 DECLCALLBACK(void) iomR3IoPortInfo(PVM pVM, PCDBGFINFOHLP pHlp, const char *pszArgs); 842 845 void iomR3IoPortRegStats(PVM pVM, PIOMIOPORTENTRYR3 pRegEntry); 846 DECLCALLBACK(void) iomR3MmioInfo(PVM pVM, PCDBGFINFOHLP pHlp, const char *pszArgs); 847 void iomR3MmioRegStats(PVM pVM, PIOMMMIOENTRYR3 pRegEntry); 843 848 #endif /* IN_RING3 */ 844 849 #ifdef IN_RING0 … … 848 853 void iomR0MmioInitPerVMData(PGVM pGVM); 849 854 #endif 855 VBOXSTRICTRC iomMmioCommonPfHandlerOld(PVMCC pVM, PVMCPUCC pVCpu, uint32_t uErrorCode, PCPUMCTXCORE pCtxCore, 856 RTGCPHYS GCPhysFault, void *pvUser); 850 857 851 858 #ifndef IN_RING3 852 859 DECLEXPORT(FNPGMRZPHYSPFHANDLER) iomMmioPfHandler; 860 DECLEXPORT(FNPGMRZPHYSPFHANDLER) iomMmioPfHandlerNew; 853 861 #endif 854 862 PGM_ALL_CB2_PROTO(FNPGMPHYSHANDLER) iomMmioHandler; 863 PGM_ALL_CB2_PROTO(FNPGMPHYSHANDLER) iomMmioHandlerNew; 855 864 856 865 /* IOM locking helpers. */
Note:
See TracChangeset
for help on using the changeset viewer.