- Timestamp:
- Sep 3, 2020 7:31:53 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Bus/DevIommuAmd.cpp
r85996 r86014 180 180 /** @name PCI: Base capability block registers. 181 181 * @{ */ 182 IOMMU_BAR_T IommuBar; /**< IOMMU base address register. */182 IOMMU_BAR_T IommuBar; /**< IOMMU base address register. */ 183 183 /** @} */ 184 184 185 185 /** @name MMIO: Control and status registers. 186 186 * @{ */ 187 DEV_TAB_BAR_T aDevTabBaseAddrs[8]; /**< Device table base address registers. */188 CMD_BUF_BAR_T CmdBufBaseAddr; /**< Command buffer base address register. */189 EVT_LOG_BAR_T EvtLogBaseAddr; /**< Event log base address register. */190 IOMMU_CTRL_T Ctrl; /**< IOMMU control register. */191 IOMMU_EXCL_RANGE_BAR_T ExclRangeBaseAddr; /**< IOMMU exclusion range base register. */192 IOMMU_EXCL_RANGE_LIMIT_T ExclRangeLimit; /**< IOMMU exclusion range limit. */193 IOMMU_EXT_FEAT_T ExtFeat; /**< IOMMU extended feature register. */187 DEV_TAB_BAR_T aDevTabBaseAddrs[8]; /**< Device table base address registers. */ 188 CMD_BUF_BAR_T CmdBufBaseAddr; /**< Command buffer base address register. */ 189 EVT_LOG_BAR_T EvtLogBaseAddr; /**< Event log base address register. */ 190 IOMMU_CTRL_T Ctrl; /**< IOMMU control register. */ 191 IOMMU_EXCL_RANGE_BAR_T ExclRangeBaseAddr; /**< IOMMU exclusion range base register. */ 192 IOMMU_EXCL_RANGE_LIMIT_T ExclRangeLimit; /**< IOMMU exclusion range limit. */ 193 IOMMU_EXT_FEAT_T ExtFeat; /**< IOMMU extended feature register. */ 194 194 /** @} */ 195 195 196 196 /** @name MMIO: PPR Log registers. 197 197 * @{ */ 198 PPR_LOG_BAR_T PprLogBaseAddr; /**< PPR Log base address register. */199 IOMMU_HW_EVT_HI_T HwEvtHi; /**< IOMMU hardware event register (Hi). */200 IOMMU_HW_EVT_LO_T HwEvtLo; /**< IOMMU hardware event register (Lo). */201 IOMMU_HW_EVT_STATUS_T HwEvtStatus; /**< IOMMU hardware event status. */198 PPR_LOG_BAR_T PprLogBaseAddr; /**< PPR Log base address register. */ 199 IOMMU_HW_EVT_HI_T HwEvtHi; /**< IOMMU hardware event register (Hi). */ 200 IOMMU_HW_EVT_LO_T HwEvtLo; /**< IOMMU hardware event register (Lo). */ 201 IOMMU_HW_EVT_STATUS_T HwEvtStatus; /**< IOMMU hardware event status. */ 202 202 /** @} */ 203 203 … … 206 206 /** @name MMIO: Guest Virtual-APIC Log registers. 207 207 * @{ */ 208 GALOG_BAR_T GALogBaseAddr; /**< Guest Virtual-APIC Log base address register. */209 GALOG_TAIL_ADDR_T GALogTailAddr; /**< Guest Virtual-APIC Log Tail address register. */208 GALOG_BAR_T GALogBaseAddr; /**< Guest Virtual-APIC Log base address register. */ 209 GALOG_TAIL_ADDR_T GALogTailAddr; /**< Guest Virtual-APIC Log Tail address register. */ 210 210 /** @} */ 211 211 212 212 /** @name MMIO: Alternate PPR and Event Log registers. 213 213 * @{ */ 214 PPR_LOG_B_BAR_T PprLogBBaseAddr; /**< PPR Log B base address register. */215 EVT_LOG_B_BAR_T EvtLogBBaseAddr; /**< Event Log B base address register. */214 PPR_LOG_B_BAR_T PprLogBBaseAddr; /**< PPR Log B base address register. */ 215 EVT_LOG_B_BAR_T EvtLogBBaseAddr; /**< Event Log B base address register. */ 216 216 /** @} */ 217 217 218 218 /** @name MMIO: Device-specific feature registers. 219 219 * @{ */ 220 DEV_SPECIFIC_FEAT_T DevSpecificFeat; /**< Device-specific feature extension register (DSFX). */221 DEV_SPECIFIC_CTRL_T DevSpecificCtrl; /**< Device-specific control extension register (DSCX). */222 DEV_SPECIFIC_STATUS_T DevSpecificStatus; /**< Device-specific status extension register (DSSX). */220 DEV_SPECIFIC_FEAT_T DevSpecificFeat; /**< Device-specific feature extension register (DSFX). */ 221 DEV_SPECIFIC_CTRL_T DevSpecificCtrl; /**< Device-specific control extension register (DSCX). */ 222 DEV_SPECIFIC_STATUS_T DevSpecificStatus; /**< Device-specific status extension register (DSSX). */ 223 223 /** @} */ 224 224 225 225 /** @name MMIO: MSI Capability Block registers. 226 226 * @{ */ 227 MSI_MISC_INFO_T MiscInfo; /**< MSI Misc. info registers / MSI Vector registers. */227 MSI_MISC_INFO_T MiscInfo; /**< MSI Misc. info registers / MSI Vector registers. */ 228 228 /** @} */ 229 229 230 230 /** @name MMIO: Performance Optimization Control registers. 231 231 * @{ */ 232 IOMMU_PERF_OPT_CTRL_T PerfOptCtrl; /**< IOMMU Performance optimization control register. */232 IOMMU_PERF_OPT_CTRL_T PerfOptCtrl; /**< IOMMU Performance optimization control register. */ 233 233 /** @} */ 234 234 235 235 /** @name MMIO: x2APIC Control registers. 236 236 * @{ */ 237 IOMMU_XT_GEN_INTR_CTRL_T XtGenIntrCtrl; /**< IOMMU X2APIC General interrupt control register. */238 IOMMU_XT_PPR_INTR_CTRL_T XtPprIntrCtrl; /**< IOMMU X2APIC PPR interrupt control register. */239 IOMMU_XT_GALOG_INTR_CTRL_T XtGALogIntrCtrl; /**< IOMMU X2APIC Guest Log interrupt control register. */237 IOMMU_XT_GEN_INTR_CTRL_T XtGenIntrCtrl; /**< IOMMU X2APIC General interrupt control register. */ 238 IOMMU_XT_PPR_INTR_CTRL_T XtPprIntrCtrl; /**< IOMMU X2APIC PPR interrupt control register. */ 239 IOMMU_XT_GALOG_INTR_CTRL_T XtGALogIntrCtrl; /**< IOMMU X2APIC Guest Log interrupt control register. */ 240 240 /** @} */ 241 241 242 242 /** @name MMIO: MARC registers. 243 243 * @{ */ 244 MARC_APER_T aMarcApers[4]; /**< MARC Aperture Registers. */244 MARC_APER_T aMarcApers[4]; /**< MARC Aperture Registers. */ 245 245 /** @} */ 246 246 247 247 /** @name MMIO: Reserved register. 248 248 * @{ */ 249 IOMMU_RSVD_REG_T RsvdReg; /**< IOMMU Reserved Register. */249 IOMMU_RSVD_REG_T RsvdReg; /**< IOMMU Reserved Register. */ 250 250 /** @} */ 251 251 252 252 /** @name MMIO: Command and Event Log pointer registers. 253 253 * @{ */ 254 CMD_BUF_HEAD_PTR_T CmdBufHeadPtr; /**< Command buffer head pointer register. */255 CMD_BUF_TAIL_PTR_T CmdBufTailPtr; /**< Command buffer tail pointer register. */256 EVT_LOG_HEAD_PTR_T EvtLogHeadPtr; /**< Event log head pointer register. */257 EVT_LOG_TAIL_PTR_T EvtLogTailPtr; /**< Event log tail pointer register. */254 CMD_BUF_HEAD_PTR_T CmdBufHeadPtr; /**< Command buffer head pointer register. */ 255 CMD_BUF_TAIL_PTR_T CmdBufTailPtr; /**< Command buffer tail pointer register. */ 256 EVT_LOG_HEAD_PTR_T EvtLogHeadPtr; /**< Event log head pointer register. */ 257 EVT_LOG_TAIL_PTR_T EvtLogTailPtr; /**< Event log tail pointer register. */ 258 258 /** @} */ 259 259 260 260 /** @name MMIO: Command and Event Status register. 261 261 * @{ */ 262 IOMMU_STATUS_T Status; /**< IOMMU status register. */262 IOMMU_STATUS_T Status; /**< IOMMU status register. */ 263 263 /** @} */ 264 264 265 265 /** @name MMIO: PPR Log Head and Tail pointer registers. 266 266 * @{ */ 267 PPR_LOG_HEAD_PTR_T PprLogHeadPtr; /**< IOMMU PPR log head pointer register. */268 PPR_LOG_TAIL_PTR_T PprLogTailPtr; /**< IOMMU PPR log tail pointer register. */267 PPR_LOG_HEAD_PTR_T PprLogHeadPtr; /**< IOMMU PPR log head pointer register. */ 268 PPR_LOG_TAIL_PTR_T PprLogTailPtr; /**< IOMMU PPR log tail pointer register. */ 269 269 /** @} */ 270 270 271 271 /** @name MMIO: Guest Virtual-APIC Log Head and Tail pointer registers. 272 272 * @{ */ 273 GALOG_HEAD_PTR_T GALogHeadPtr; /**< Guest Virtual-APIC log head pointer register. */274 GALOG_TAIL_PTR_T GALogTailPtr; /**< Guest Virtual-APIC log tail pointer register. */273 GALOG_HEAD_PTR_T GALogHeadPtr; /**< Guest Virtual-APIC log head pointer register. */ 274 GALOG_TAIL_PTR_T GALogTailPtr; /**< Guest Virtual-APIC log tail pointer register. */ 275 275 /** @} */ 276 276 277 277 /** @name MMIO: PPR Log B Head and Tail pointer registers. 278 278 * @{ */ 279 PPR_LOG_B_HEAD_PTR_T PprLogBHeadPtr; /**< PPR log B head pointer register. */280 PPR_LOG_B_TAIL_PTR_T PprLogBTailPtr; /**< PPR log B tail pointer register. */279 PPR_LOG_B_HEAD_PTR_T PprLogBHeadPtr; /**< PPR log B head pointer register. */ 280 PPR_LOG_B_TAIL_PTR_T PprLogBTailPtr; /**< PPR log B tail pointer register. */ 281 281 /** @} */ 282 282 283 283 /** @name MMIO: Event Log B Head and Tail pointer registers. 284 284 * @{ */ 285 EVT_LOG_B_HEAD_PTR_T EvtLogBHeadPtr; /**< Event log B head pointer register. */286 EVT_LOG_B_TAIL_PTR_T EvtLogBTailPtr; /**< Event log B tail pointer register. */285 EVT_LOG_B_HEAD_PTR_T EvtLogBHeadPtr; /**< Event log B head pointer register. */ 286 EVT_LOG_B_TAIL_PTR_T EvtLogBTailPtr; /**< Event log B tail pointer register. */ 287 287 /** @} */ 288 288 … … 296 296 /** @todo IOMMU: IOMMU Event counter registers. */ 297 297 298 /** @todo IOMMU: Stat counters. */ 298 #ifdef VBOX_WITH_STATISTICS 299 /** @name IOMMU: Stat counters. 300 * @{ */ 301 STAMCOUNTER StatMmioReadR3; /**< Number of MMIO reads in R3. */ 302 STAMCOUNTER StatMmioReadRZ; /**< Number of MMIO reads in RZ. */ 303 304 STAMCOUNTER StatMmioWriteR3; /**< Number of MMIO writes in R3. */ 305 STAMCOUNTER StatMmioWriteRZ; /**< Number of MMIO writes in RZ. */ 306 307 STAMCOUNTER StatMsiRemapR3; /**< Number of MSI remap requests in R3. */ 308 STAMCOUNTER StatMsiRemapRZ; /**< Number of MSI remap requests in RZ. */ 309 310 STAMCOUNTER StatCmd; /**< Number of commands processed. */ 311 STAMCOUNTER StatCmdCompWait; /**< Number of Completion Wait commands processed. */ 312 STAMCOUNTER StatCmdInvDte; /**< Number of Invalidate DTE commands processed. */ 313 STAMCOUNTER StatCmdInvIommuPages; /**< Number of Invalidate IOMMU pages commands processed. */ 314 STAMCOUNTER StatCmdInvIotlbPages; /**< Number of Invalidate IOTLB pages commands processed. */ 315 STAMCOUNTER StatCmdInvIntrTable; /**< Number of Invalidate Interrupt Table commands processed. */ 316 STAMCOUNTER StatCmdPrefIommuPages; /**< Number of Prefetch IOMMU Pages commands processed. */ 317 STAMCOUNTER StatCmdCompletePprReq; /**< Number of Complete PPR Requests commands processed. */ 318 STAMCOUNTER StatCmdInvIommuAll; /**< Number of Invalidate IOMMU All commands processed. */ 319 /** @} */ 320 #endif 299 321 } IOMMU; 300 322 /** Pointer to the IOMMU device state. */ … … 504 526 { 505 527 IOMMU_ASSERT_LOCKED(pDevIns); 506 Log FlowFunc(("\n"));528 Log5Func(("\n")); 507 529 508 530 PIOMMU pThis = PDMDEVINS_2_DATA(pDevIns, PIOMMU); … … 510 532 if (Status.n.u1CmdBufRunning) 511 533 { 512 Log FlowFunc(("Signaling command thread\n"));534 Log5Func(("Signaling command thread\n")); 513 535 PDMDevHlpSUPSemEventSignal(pDevIns, pThis->hEvtCmdThread); 514 536 } … … 2717 2739 2718 2740 PIOMMU pThis = PDMDEVINS_2_DATA(pDevIns, PIOMMU); 2741 STAM_COUNTER_INC(&pThis->CTX_SUFF_Z(StatMsiRemap)); 2742 2719 2743 LogFlowFunc(("uDevId=%#x\n", uDevId)); 2720 2744 … … 2742 2766 Assert(!(off & (cb - 1))); 2743 2767 2768 PIOMMU pThis = PDMDEVINS_2_DATA(pDevIns, PIOMMU); 2769 STAM_COUNTER_INC(&pThis->CTX_SUFF_Z(StatMmioWrite)); NOREF(pThis); 2770 2744 2771 uint64_t const uValue = cb == 8 ? *(uint64_t const *)pv : *(uint32_t const *)pv; 2745 2772 return iommuAmdWriteRegister(pDevIns, off, cb, uValue); … … 2755 2782 Assert(cb == 4 || cb == 8); 2756 2783 Assert(!(off & (cb - 1))); 2784 2785 PIOMMU pThis = PDMDEVINS_2_DATA(pDevIns, PIOMMU); 2786 STAM_COUNTER_INC(&pThis->CTX_SUFF_Z(StatMmioRead)); NOREF(pThis); 2757 2787 2758 2788 uint64_t uResult; … … 2786 2816 2787 2817 PIOMMU pThis = PDMDEVINS_2_DATA(pDevIns, PIOMMU); 2818 STAM_COUNTER_INC(&pThis->StatCmd); 2819 2788 2820 uint8_t const bCmd = pCmd->n.u4Opcode; 2789 2821 switch (bCmd) … … 2791 2823 case IOMMU_CMD_COMPLETION_WAIT: 2792 2824 { 2825 STAM_COUNTER_INC(&pThis->StatCmdCompWait); 2826 2793 2827 PCCMD_COMWAIT_T pCmdComWait = (PCCMD_COMWAIT_T)pCmd; 2794 2828 AssertCompile(sizeof(*pCmdComWait) == sizeof(*pCmd)); … … 2836 2870 /** @todo IOMMU: Implement this once we implement IOTLB. Pretend success until 2837 2871 * then. */ 2872 STAM_COUNTER_INC(&pThis->StatCmdInvDte); 2838 2873 return VINF_SUCCESS; 2839 2874 } … … 2843 2878 /** @todo IOMMU: Implement this once we implement IOTLB. Pretend success until 2844 2879 * then. */ 2880 STAM_COUNTER_INC(&pThis->StatCmdInvIommuPages); 2845 2881 return VINF_SUCCESS; 2846 2882 } … … 2848 2884 case IOMMU_CMD_INV_IOTLB_PAGES: 2849 2885 { 2886 STAM_COUNTER_INC(&pThis->StatCmdInvIotlbPages); 2887 2850 2888 uint32_t const uCapHdr = PDMPciDevGetDWord(pDevIns->apPciDevs[0], IOMMU_PCI_OFF_CAP_HDR); 2851 2889 if (RT_BF_GET(uCapHdr, IOMMU_BF_CAPHDR_IOTLB_SUP)) … … 2862 2900 /** @todo IOMMU: Implement this once we implement IOTLB. Pretend success until 2863 2901 * then. */ 2902 STAM_COUNTER_INC(&pThis->StatCmdInvIntrTable); 2864 2903 return VINF_SUCCESS; 2865 2904 } … … 2867 2906 case IOMMU_CMD_PREFETCH_IOMMU_PAGES: 2868 2907 { 2908 STAM_COUNTER_INC(&pThis->StatCmdPrefIommuPages); 2869 2909 if (pThis->ExtFeat.n.u1PrefetchSup) 2870 2910 { … … 2878 2918 case IOMMU_CMD_COMPLETE_PPR_REQ: 2879 2919 { 2920 STAM_COUNTER_INC(&pThis->StatCmdCompletePprReq); 2921 2880 2922 /* We don't support PPR requests yet. */ 2881 2923 Assert(!pThis->ExtFeat.n.u1PprSup); … … 2886 2928 case IOMMU_CMD_INV_IOMMU_ALL: 2887 2929 { 2930 STAM_COUNTER_INC(&pThis->StatCmdInvIommuAll); 2931 2888 2932 if (pThis->ExtFeat.n.u1InvAllSup) 2889 2933 { … … 2896 2940 } 2897 2941 2942 STAM_COUNTER_DEC(&pThis->StatCmd); 2898 2943 LogFunc(("Cmd(%#x): Unrecognized\n", bCmd)); 2899 2944 iommuAmdInitIllegalCmdEvent(GCPhysCmd, (PEVT_ILLEGAL_CMD_ERR_T)pEvtError); … … 2931 2976 if (RT_UNLIKELY(pThread->enmState != PDMTHREADSTATE_RUNNING)) 2932 2977 break; 2933 Log FlowFunc(("Woken up with rc=%Rrc\n", rc));2978 Log5Func(("Woken up with rc=%Rrc\n", rc)); 2934 2979 ASMAtomicWriteBool(&pThis->fCmdThreadSignaled, false); 2935 2980 } … … 2950 2995 if (Status.n.u1CmdBufRunning) 2951 2996 { 2952 LogFlowFunc(("Command buffer running\n"));2953 2954 2997 /* Get the offset we need to read the command from memory (circular buffer offset). */ 2955 2998 uint32_t const cbCmdBuf = iommuAmdGetTotalBufLength(pThis->CmdBufBaseAddr.n.u4Len); … … 3983 4026 rc = PDMDevHlpDBGFInfoRegister(pDevIns, "iommu", "Display IOMMU state.", iommuAmdR3DbgInfo); 3984 4027 AssertLogRelRCReturn(rc, rc); 4028 4029 # ifdef VBOX_WITH_STATISTICS 4030 /* 4031 * Statistics. 4032 */ 4033 PDMDevHlpSTAMRegister(pDevIns, &pThis->StatMmioReadR3, STAMTYPE_COUNTER, "R3/MmioReadR3", STAMUNIT_OCCURENCES, "Number of MMIO reads in R3"); 4034 PDMDevHlpSTAMRegister(pDevIns, &pThis->StatMmioReadRZ, STAMTYPE_COUNTER, "RZ/MmioReadRZ", STAMUNIT_OCCURENCES, "Number of MMIO reads in RZ."); 4035 4036 PDMDevHlpSTAMRegister(pDevIns, &pThis->StatMmioWriteR3, STAMTYPE_COUNTER, "R3/MmioWriteR3", STAMUNIT_OCCURENCES, "Number of MMIO writes in R3."); 4037 PDMDevHlpSTAMRegister(pDevIns, &pThis->StatMmioWriteRZ, STAMTYPE_COUNTER, "RZ/MmioWriteRZ", STAMUNIT_OCCURENCES, "Number of MMIO writes in RZ."); 4038 4039 PDMDevHlpSTAMRegister(pDevIns, &pThis->StatMsiRemapR3, STAMTYPE_COUNTER, "R3/MsiRemapR3", STAMUNIT_OCCURENCES, "Number of interrupt remap requests in R3."); 4040 PDMDevHlpSTAMRegister(pDevIns, &pThis->StatMsiRemapRZ, STAMTYPE_COUNTER, "RZ/MsiRemapRZ", STAMUNIT_OCCURENCES, "Number of interrupt remap requests in RZ."); 4041 4042 PDMDevHlpSTAMRegister(pDevIns, &pThis->StatCmd, STAMTYPE_COUNTER, "R3/Commands", STAMUNIT_OCCURENCES, "Number of commands processed (total)."); 4043 PDMDevHlpSTAMRegister(pDevIns, &pThis->StatCmdCompWait, STAMTYPE_COUNTER, "R3/Commands/CompWait", STAMUNIT_OCCURENCES, "Number of Completion Wait commands processed."); 4044 PDMDevHlpSTAMRegister(pDevIns, &pThis->StatCmdInvDte, STAMTYPE_COUNTER, "R3/Commands/InvDte", STAMUNIT_OCCURENCES, "Number of Invalidate DTE commands processed."); 4045 PDMDevHlpSTAMRegister(pDevIns, &pThis->StatCmdInvIommuPages, STAMTYPE_COUNTER, "R3/Commands/InvIommuPages", STAMUNIT_OCCURENCES, "Number of Invalidate IOMMU Pages commands processed."); 4046 PDMDevHlpSTAMRegister(pDevIns, &pThis->StatCmdInvIotlbPages, STAMTYPE_COUNTER, "R3/Commands/InvIotlbPages", STAMUNIT_OCCURENCES, "Number of Invalidate IOTLB Pages commands processed."); 4047 PDMDevHlpSTAMRegister(pDevIns, &pThis->StatCmdInvIntrTable, STAMTYPE_COUNTER, "R3/Commands/InvIntrTable", STAMUNIT_OCCURENCES, "Number of Invalidate Interrupt Table commands processed."); 4048 PDMDevHlpSTAMRegister(pDevIns, &pThis->StatCmdPrefIommuPages, STAMTYPE_COUNTER, "R3/Commands/PrefIommuPages", STAMUNIT_OCCURENCES, "Number of Prefetch IOMMU Pages commands processed."); 4049 PDMDevHlpSTAMRegister(pDevIns, &pThis->StatCmdCompletePprReq, STAMTYPE_COUNTER, "R3/Commands/CompletePprReq", STAMUNIT_OCCURENCES, "Number of Complete PPR Requests commands processed."); 4050 PDMDevHlpSTAMRegister(pDevIns, &pThis->StatCmdInvIommuAll, STAMTYPE_COUNTER, "R3/Commands/InvIommuAll", STAMUNIT_OCCURENCES, "Number of Invalidate IOMMU All commands processed."); 4051 # endif 3985 4052 3986 4053 /*
Note:
See TracChangeset
for help on using the changeset viewer.