Changeset 83703 in vbox
- Timestamp:
- Apr 15, 2020 2:58:14 PM (4 years ago)
- File:
-
- 1 edited
-
trunk/src/VBox/Devices/Bus/DevIommuAmd.cpp (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Bus/DevIommuAmd.cpp
r83684 r83703 1266 1266 } IOMMU_HW_EVT_STATUS_T; 1267 1267 AssertCompileSize(IOMMU_HW_EVT_STATUS_T, 8); 1268 #define IOMMU_HW_EVT_STATUS_VALID_MASK UINT64_C(0x0000000000000003) 1268 1269 1269 1270 /** … … 1842 1843 typedef struct IOMMU 1843 1844 { 1845 /** The event semaphore the command thread waits on. */ 1846 SUPSEMEVENT hEvtCmdThread; 1847 /** The MMIO handle. */ 1848 IOMMMIOHANDLE hMmio; 1844 1849 /** Whether this IOMMU is at the top of the PCI tree hierarchy or not. */ 1845 1850 bool fRootComplex; 1846 1851 /** Alignment padding. */ 1847 bool afPadding[3]; 1848 /** The MMIO handle. */ 1849 IOMMMIOHANDLE hMmio; 1850 /** The event semaphore the command thread waits on. */ 1851 SUPSEMEVENT hEvtCmdThread; 1852 bool afPadding[7]; 1852 1853 1853 1854 /** @name MMIO: Control and status registers. … … 1985 1986 typedef struct IOMMUR3 1986 1987 { 1988 /** Device instance. */ 1989 PPDMDEVINSR3 pDevInsR3; 1987 1990 /** The IOMMU helpers. */ 1988 1991 PCPDMIOMMUHLPR3 pIommuHlp; … … 1998 2001 typedef struct IOMMUR0 1999 2002 { 2003 /** Device instance. */ 2004 PPDMDEVINSR0 pDevInsR0; 2000 2005 /** The IOMMU helpers. */ 2001 2006 PCPDMIOMMUHLPR0 pIommuHlp; … … 2009 2014 typedef struct IOMMURC 2010 2015 { 2016 /** Device instance. */ 2017 PPDMDEVINSR0 pDevInsRC; 2011 2018 /** The IOMMU helpers. */ 2012 2019 PCPDMIOMMUHLPRC pIommuHlp; … … 2016 2023 2017 2024 /** The IOMMU device state for the current context. */ 2018 typedef CTX_SUFF(IOMMU) IOMMUCC;2025 typedef CTX_SUFF(IOMMU) IOMMUCC; 2019 2026 /** Pointer to the IOMMU device state for the current context. */ 2020 2027 typedef CTX_SUFF(PIOMMU) PIOMMUCC; … … 2117 2124 } 2118 2125 2126 2119 2127 /** 2120 2128 * Writes the Event Log Base Address Register. … … 2159 2167 pThis->PprLogBaseAddr.u64 = u64Value & IOMMU_PPR_LOG_BAR_VALID_MASK; 2160 2168 iommuAmdCheckBufferLength(pThis->PprLogBaseAddr.n.u4PprLogLen, __PRETTY_FUNCTION__); 2169 return VINF_SUCCESS; 2170 } 2171 2172 2173 /** 2174 * Writes the Hardware Event Register (Hi). 2175 */ 2176 static VBOXSTRICTRC iommuAmdHwEvtHi_w(PPDMDEVINS pDevIns, PIOMMU pThis, uint32_t iReg, uint64_t u64Value) 2177 { 2178 /** @todo IOMMU: Why the heck is this marked read/write by the AMD IOMMU spec? */ 2179 RT_NOREF(pDevIns, iReg); 2180 Log((IOMMU_LOG_PFX ": Writing %#RX64 to hardware event (Hi) register!\n", u64Value)); 2181 pThis->HwEvtHi.u64 = u64Value; 2182 return VINF_SUCCESS; 2183 } 2184 2185 2186 /** 2187 * Writes the Hardware Event Register (Lo). 2188 */ 2189 static VBOXSTRICTRC iommuAmdHwEvtLo_w(PPDMDEVINS pDevIns, PIOMMU pThis, uint32_t iReg, uint64_t u64Value) 2190 { 2191 /** @todo IOMMU: Why the heck is this marked read/write by the AMD IOMMU spec? */ 2192 RT_NOREF(pDevIns, iReg); 2193 Log((IOMMU_LOG_PFX ": Writing %#RX64 to hardware event (Lo) register!\n", u64Value)); 2194 pThis->HwEvtLo = u64Value; 2195 return VINF_SUCCESS; 2196 } 2197 2198 2199 /** 2200 * Writes the Hardware Event Status Register. 2201 */ 2202 static VBOXSTRICTRC iommuAmdHwEvtStatus_w(PPDMDEVINS pDevIns, PIOMMU pThis, uint32_t iReg, uint64_t u64Value) 2203 { 2204 RT_NOREF(pDevIns, iReg); 2205 2206 /* Ignore all unrecognized bits. */ 2207 u64Value &= IOMMU_HW_EVT_STATUS_VALID_MASK; 2208 2209 /* 2210 * The two bits (HEO and HEV) are RW1C (Read/Write 1-to-Clear; writing 0 has no effect). 2211 * If the current status bits or the bits being written are both 0, we've nothing to do. 2212 * The Overflow bit (bit 1) is only valid when the Valid bit (bit 0) is 1. 2213 */ 2214 uint64_t HwStatus = pThis->HwEvtStatus.u64; 2215 if (!(HwStatus & RT_BIT(0))) 2216 return VINF_SUCCESS; 2217 if (u64Value & HwStatus & RT_BIT(0)) 2218 HwStatus &= ~RT_BIT(0); 2219 if (u64Value & HwStatus & RT_BIT(1)) 2220 HwStatus &= ~RT_BIT(1); 2221 pThis->HwEvtStatus.u64 = HwStatus; 2161 2222 return VINF_SUCCESS; 2162 2223 } … … 2354 2415 2355 2416 case IOMMU_MMIO_OFF_PPR_LOG_BAR: return iommuAmdPprLogBar_w(pDevIns, pThis, off, uValue); 2356 case IOMMU_MMIO_OFF_HW_EVT_HI: 2357 case IOMMU_MMIO_OFF_HW_EVT_LO: return iommuAmd Ignore_w(pDevIns, pThis, off, uValue);2358 case IOMMU_MMIO_OFF_HW_EVT_STATUS: /** @todo IOMMU: HW Event Status is RW. Figure this out later. */2417 case IOMMU_MMIO_OFF_HW_EVT_HI: return iommuAmdHwEvtHi_w(pDevIns, pThis, off, uValue); 2418 case IOMMU_MMIO_OFF_HW_EVT_LO: return iommuAmdHwEvtLo_w(pDevIns, pThis, off, uValue); 2419 case IOMMU_MMIO_OFF_HW_EVT_STATUS: return iommuAmdHwEvtStatus_w(pDevIns, pThis, off, uValue); 2359 2420 2360 2421 case IOMMU_MMIO_OFF_GALOG_BAR: … … 2474 2535 * 2475 2536 * @returns Strict VBox status code. 2476 * @param p This The IOMMU device state.2537 * @param pDevIns The device instance. 2477 2538 * @param off Offset in bytes. 2478 2539 * @param puResult Where to store the value being read. 2479 2540 */ 2480 static VBOXSTRICTRC iommuAmdReadRegister(P CIOMMU pThis, uint32_t off, uint64_t *puResult)2541 static VBOXSTRICTRC iommuAmdReadRegister(PPDMDEVINS pDevIns, uint32_t off, uint64_t *puResult) 2481 2542 { 2482 2543 Assert(off < IOMMU_MMIO_REGION_SIZE); 2483 2544 Assert(!(off & 7) || !(off & 3)); 2545 2546 PIOMMU pThis = PDMDEVINS_2_DATA(pDevIns, PIOMMU); 2547 Assert(pThis); 2484 2548 2485 2549 /** @todo IOMMU: fine-grained locking? */ … … 2618 2682 2619 2683 uint64_t uResult; 2620 PIOMMU pThis = PDMDEVINS_2_DATA(pDevIns, PIOMMU); 2621 VBOXSTRICTRC rcStrict = iommuAmdReadRegister(pThis, off, &uResult); 2684 VBOXSTRICTRC rcStrict = iommuAmdReadRegister(pDevIns, off, &uResult); 2622 2685 if (cb == 8) 2623 2686 *(uint64_t *)pv = uResult; … … 3366 3429 LogFlowFunc(("\n")); 3367 3430 3368 NOREF(pThisCC); /** @todo IOMMU: populate CC data. */3431 pThisCC->pDevInsR3 = pDevIns; 3369 3432 3370 3433 /* … … 3536 3599 { 3537 3600 PDMDEV_CHECK_VERSIONS_RETURN(pDevIns); 3601 PIOMMU pThis = PDMDEVINS_2_DATA(pDevIns, PIOMMU); 3602 PIOMMUCC pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PIOMMUCC); 3603 3604 pThisCC->CTX_SUFF(pDevIns) = pDevIns; 3605 3606 int rc = PDMDevHlpMmioSetUpContext(pDevIns, pThis->hMmio, iommuAmdMmioWrite, iommuAmdMmioRead, NULL /* pvUser */); 3607 AssertRCReturn(rc, rc); 3608 3538 3609 return VINF_SUCCESS; 3539 3610 }
Note:
See TracChangeset
for help on using the changeset viewer.

