Changeset 87477 in vbox
- Timestamp:
- Jan 29, 2021 11:43:09 AM (4 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/err.h
r87439 r87477 3053 3053 /** Command hardware failure. */ 3054 3054 #define VERR_IOMMU_CMD_HW_ERROR (-7213) 3055 /** IOMMU device is not present. */ 3056 #define VERR_IOMMU_NOT_PRESENT (-7214) 3055 3057 /** @} */ 3056 3058 -
trunk/include/VBox/vmm/pdmdev.h
r87371 r87477 1320 1320 * @returns VBox status code. 1321 1321 * @param pDevIns The IOMMU device instance. 1322 * @param uDev IdThe device identifier (bus, device, function).1322 * @param uDeviceId The device identifier (bus, device, function). 1323 1323 * @param pMsiIn The source MSI. 1324 1324 * @param pMsiOut Where to store the remapped MSI. … … 1326 1326 * @thread Any. 1327 1327 */ 1328 DECLR0CALLBACKMEMBER(int, pfnMsiRemap,(PPDMDEVINS pDevIns, uint16_t uDev Id, PCMSIMSG pMsiIn, PMSIMSG pMsiOut));1328 DECLR0CALLBACKMEMBER(int, pfnMsiRemap,(PPDMDEVINS pDevIns, uint16_t uDeviceId, PCMSIMSG pMsiIn, PMSIMSG pMsiOut)); 1329 1329 1330 1330 /** Just a safety precaution. */ … … 1390 1390 * @returns VBox status code. 1391 1391 * @param pDevIns The IOMMU device instance. 1392 * @param uDev IdThe device identifier (bus, device, function).1392 * @param uDeviceId The device identifier (bus, device, function). 1393 1393 * @param pMsiIn The source MSI. 1394 1394 * @param pMsiOut Where to store the remapped MSI. … … 1396 1396 * @thread Any. 1397 1397 */ 1398 DECLRCCALLBACKMEMBER(int, pfnMsiRemap,(PPDMDEVINS pDevIns, uint16_t uDev Id, PCMSIMSG pMsiIn, PMSIMSG pMsiOut));1398 DECLRCCALLBACKMEMBER(int, pfnMsiRemap,(PPDMDEVINS pDevIns, uint16_t uDeviceId, PCMSIMSG pMsiIn, PMSIMSG pMsiOut)); 1399 1399 1400 1400 /** Just a safety precaution. */ … … 1460 1460 * @returns VBox status code. 1461 1461 * @param pDevIns The IOMMU device instance. 1462 * @param uDev IdThe device identifier (bus, device, function).1462 * @param uDeviceId The device identifier (bus, device, function). 1463 1463 * @param pMsiIn The source MSI. 1464 1464 * @param pMsiOut Where to store the remapped MSI. … … 1466 1466 * @thread Any. 1467 1467 */ 1468 DECLR3CALLBACKMEMBER(int, pfnMsiRemap,(PPDMDEVINS pDevIns, uint16_t uDev Id, PCMSIMSG pMsiIn, PMSIMSG pMsiOut));1468 DECLR3CALLBACKMEMBER(int, pfnMsiRemap,(PPDMDEVINS pDevIns, uint16_t uDeviceId, PCMSIMSG pMsiIn, PMSIMSG pMsiOut)); 1469 1469 1470 1470 /** Just a safety precaution. */ … … 1834 1834 * @returns status code. 1835 1835 * @param pDevIns Device instance of the IOAPIC. 1836 * @param uDev Id The device ID (bus, device, function) for the source MSI.1836 * @param uDeviceId The device identifier (bus, device, function). 1837 1837 * @param pMsiIn The source MSI. 1838 1838 * @param pMsiOut Where to store the remapped MSI. … … 1840 1840 * @sa iommuAmdDeviceMsiRemap(). 1841 1841 */ 1842 DECLCALLBACKMEMBER(int, pfnIommuMsiRemap,(PPDMDEVINS pDevIns, uint16_t uDev It, PCMSIMSG pMsiIn, PMSIMSG pMsiOut));1842 DECLCALLBACKMEMBER(int, pfnIommuMsiRemap,(PPDMDEVINS pDevIns, uint16_t uDeviceId, PCMSIMSG pMsiIn, PMSIMSG pMsiOut)); 1843 1843 1844 1844 /** Just a safety precaution. */ -
trunk/src/VBox/VMM/Makefile.kmk
r87310 r87477 193 193 VMMAll/PDMAllCritSectRw.cpp \ 194 194 VMMAll/PDMAllCritSectBoth.cpp \ 195 $(if-expr defined(VBOX_WITH_IOMMU_AMD), VMMAll/PDMAllIommu.cpp,) \ 195 196 VMMAll/PDMAllQueue.cpp \ 196 197 VMMAll/PDMAllTask.cpp \ … … 538 539 VMMAll/PDMAllCritSectRw.cpp \ 539 540 VMMAll/PDMAllCritSectBoth.cpp \ 541 $(if-expr defined(VBOX_WITH_IOMMU_AMD), VMMAll/PDMAllIommu.cpp,) \ 540 542 VMMAll/PDMAllQueue.cpp \ 541 543 VMMAll/PDMAllTask.cpp \ -
trunk/src/VBox/VMM/VMMR0/PDMR0DevHlp.cpp
r87371 r87477 144 144 else 145 145 { 146 Log (("pdmRCDevHlp_PCIPhysRead: caller=%p/%d: returns %Rrc - Not bus master! GCPhys=%RGp cbRead=%#zx\n",147 pDevIns, pDevIns->iInstance,VERR_PDM_NOT_PCI_BUS_MASTER, GCPhys, cbRead));146 LogFunc(("caller=%p/%d: returns %Rrc - Not bus master! GCPhys=%RGp cbRead=%#zx\n", pDevIns, pDevIns->iInstance, 147 VERR_PDM_NOT_PCI_BUS_MASTER, GCPhys, cbRead)); 148 148 memset(pvBuf, 0xff, cbRead); 149 149 return VERR_PDM_NOT_PCI_BUS_MASTER; … … 152 152 153 153 #ifdef VBOX_WITH_IOMMU_AMD 154 /** @todo IOMMU: Optimize/re-organize things here later. */ 155 PGVM pGVM = pDevIns->Internal.s.pGVM; 156 PPDMIOMMUR0 pIommu = &pGVM->pdmr0.s.aIommus[0]; 157 PPDMDEVINS pDevInsIommu = pIommu->CTX_SUFF(pDevIns); 158 if ( pDevInsIommu 159 && pDevInsIommu != pDevIns) 160 { 161 size_t const idxBus = pPciDev->Int.s.idxPdmBus; 162 Assert(idxBus < RT_ELEMENTS(pGVM->pdmr0.s.aPciBuses)); 163 PPDMPCIBUSR0 pBus = &pGVM->pdmr0.s.aPciBuses[idxBus]; 164 uint16_t const uDeviceId = PCIBDF_MAKE(pBus->iBus, pPciDev->uDevFn); 165 int rc = VINF_SUCCESS; 166 while (cbRead > 0) 167 { 168 RTGCPHYS GCPhysOut; 169 size_t cbContig; 170 rc = pIommu->pfnMemAccess(pDevInsIommu, uDeviceId, GCPhys, cbRead, PDMIOMMU_MEM_F_READ, &GCPhysOut, &cbContig); 171 if (RT_SUCCESS(rc)) 172 { 173 /** @todo Handle strict return codes from PGMPhysRead. */ 174 rc = pDevIns->pHlpR0->pfnPhysRead(pDevIns, GCPhysOut, pvBuf, cbRead, fFlags); 175 if (RT_SUCCESS(rc)) 176 { 177 cbRead -= cbContig; 178 pvBuf = (void *)((uintptr_t)pvBuf + cbContig); 179 GCPhys += cbContig; 180 } 181 else 182 break; 183 } 184 else 185 { 186 Log(("pdmR0DevHlp_PCIPhysRead: IOMMU translation failed. uDeviceId=%#x GCPhys=%#RGp cb=%u rc=%Rrc\n", uDeviceId, 187 GCPhys, cbRead, rc)); 188 break; 189 } 190 } 154 int rc = pdmIommuMemAccessRead(pDevIns, pPciDev, GCPhys, pvBuf, cbRead, fFlags); 155 if (RT_SUCCESS(rc) || rc != VERR_IOMMU_NOT_PRESENT) 191 156 return rc; 192 }193 157 #endif 194 158 … … 215 179 else 216 180 { 217 Log (("pdmRCDevHlp_PCIPhysWrite: caller=%p/%d: returns %Rrc - Not bus master! GCPhys=%RGp cbWrite=%#zx\n",218 pDevIns, pDevIns->iInstance,VERR_PDM_NOT_PCI_BUS_MASTER, GCPhys, cbWrite));181 LogFunc(("caller=%p/%d: returns %Rrc - Not bus master! GCPhys=%RGp cbWrite=%#zx\n", pDevIns, pDevIns->iInstance, 182 VERR_PDM_NOT_PCI_BUS_MASTER, GCPhys, cbWrite)); 219 183 return VERR_PDM_NOT_PCI_BUS_MASTER; 220 184 } … … 222 186 223 187 #ifdef VBOX_WITH_IOMMU_AMD 224 /** @todo IOMMU: Optimize/re-organize things here later. */ 225 PGVM pGVM = pDevIns->Internal.s.pGVM; 226 PPDMIOMMUR0 pIommu = &pGVM->pdmr0.s.aIommus[0]; 227 PPDMDEVINS pDevInsIommu = pIommu->CTX_SUFF(pDevIns); 228 if ( pDevInsIommu 229 && pDevInsIommu != pDevIns) 230 { 231 size_t const idxBus = pPciDev->Int.s.idxPdmBus; 232 Assert(idxBus < RT_ELEMENTS(pGVM->pdmr0.s.aPciBuses)); 233 PPDMPCIBUSR0 pBus = &pGVM->pdmr0.s.aPciBuses[idxBus]; 234 uint16_t const uDeviceId = PCIBDF_MAKE(pBus->iBus, pPciDev->uDevFn); 235 int rc = VINF_SUCCESS; 236 while (cbWrite > 0) 237 { 238 RTGCPHYS GCPhysOut; 239 size_t cbContig; 240 rc = pIommu->pfnMemAccess(pDevInsIommu, uDeviceId, GCPhys, cbWrite, PDMIOMMU_MEM_F_WRITE, &GCPhysOut, &cbContig); 241 if (RT_SUCCESS(rc)) 242 { 243 /** @todo Handle strict return codes from PGMPhysWrite. */ 244 rc = pDevIns->pHlpR0->pfnPhysWrite(pDevIns, GCPhysOut, pvBuf, cbWrite, fFlags); 245 if (RT_SUCCESS(rc)) 246 { 247 cbWrite -= cbContig; 248 pvBuf = (const void *)((uintptr_t)pvBuf + cbContig); 249 GCPhys += cbContig; 250 } 251 else 252 break; 253 } 254 else 255 { 256 Log(("pdmR0DevHlp_PCIPhysWrite: IOMMU translation failed. uDeviceId=%#x GCPhys=%#RGp cb=%u rc=%Rrc\n", uDeviceId, 257 GCPhys, cbWrite, rc)); 258 break; 259 } 260 } 188 int rc = pdmIommuMemAccessWrite(pDevIns, pPciDev, GCPhys, pvBuf, cbWrite, fFlags); 189 if (RT_SUCCESS(rc) || rc != VERR_IOMMU_NOT_PRESENT) 261 190 return rc; 262 }263 191 #endif 264 192 … … 1588 1516 1589 1517 /** @interface_method_impl{PDMIOAPICHLP,pfnIommuMsiRemap} */ 1590 static DECLCALLBACK(int) pdmR0IoApicHlp_IommuMsiRemap(PPDMDEVINS pDevIns, uint16_t uDev Id, PCMSIMSG pMsiIn, PMSIMSG pMsiOut)1518 static DECLCALLBACK(int) pdmR0IoApicHlp_IommuMsiRemap(PPDMDEVINS pDevIns, uint16_t uDeviceId, PCMSIMSG pMsiIn, PMSIMSG pMsiOut) 1591 1519 { 1592 1520 PDMDEV_ASSERT_DEVINS(pDevIns); … … 1595 1523 1596 1524 #ifdef VBOX_WITH_IOMMU_AMD 1597 /** @todo IOMMU: Optimize/re-organize things here later. */ 1598 PGVM pGVM = pDevIns->Internal.s.pGVM; 1599 PPDMIOMMUR0 pIommu = &pGVM->pdmr0.s.aIommus[0]; 1600 PPDMDEVINS pDevInsIommu = pIommu->CTX_SUFF(pDevIns); 1601 if ( pDevInsIommu 1602 && pDevInsIommu != pDevIns) 1603 { 1604 AssertMsgReturn(VALID_PTR(pIommu->pfnMsiRemap), 1605 ("pdmR0IoApicHlp_IommuMsiRemap: pfnMsiRemap invalid!\n"), VERR_INVALID_POINTER); 1606 int rc = pIommu->pfnMsiRemap(pDevInsIommu, uDevId, pMsiIn, pMsiOut); 1607 if (RT_SUCCESS(rc)) 1608 return rc; 1609 1610 Log(("pdmR0IoApicHlp_IommuMsiRemap: IOMMU MSI remap failed. uDevId=%#x pMsiIn=(%#RX64, %#RU32) rc=%Rrc\n", 1611 uDevId, pMsiIn->Addr.u64, pMsiIn->Data.u32, rc)); 1612 } 1525 int rc = pdmIommuMsiRemap(pDevIns, uDeviceId, pMsiIn, pMsiOut); 1526 if (RT_SUCCESS(rc) || rc != VERR_IOMMU_NOT_PRESENT) 1527 return rc; 1613 1528 #else 1614 RT_NOREF(pDevIns, uDev Id);1529 RT_NOREF(pDevIns, uDeviceId); 1615 1530 #endif 1616 1531 -
trunk/src/VBox/VMM/VMMR0/PDMR0DevHlpTracing.cpp
r87474 r87477 313 313 314 314 #ifdef VBOX_WITH_IOMMU_AMD 315 /** @todo IOMMU: Optimize/re-organize things here later. */ 316 PGVM pGVM = pDevIns->Internal.s.pGVM; 317 PPDMIOMMUR0 pIommu = &pGVM->pdmr0.s.aIommus[0]; 318 PPDMDEVINS pDevInsIommu = pIommu->CTX_SUFF(pDevIns); 319 if ( pDevInsIommu 320 && pDevInsIommu != pDevIns) 321 { 322 size_t const idxBus = pPciDev->Int.s.idxPdmBus; 323 Assert(idxBus < RT_ELEMENTS(pGVM->pdmr0.s.aPciBuses)); 324 PPDMPCIBUSR0 pBus = &pGVM->pdmr0.s.aPciBuses[idxBus]; 325 uint16_t const uDeviceId = PCIBDF_MAKE(pBus->iBus, pPciDev->uDevFn); 326 int rc = VINF_SUCCESS; 327 while (cbRead > 0) 328 { 329 RTGCPHYS GCPhysOut; 330 size_t cbContig; 331 rc = pIommu->pfnMemAccess(pDevInsIommu, uDeviceId, GCPhys, cbRead, PDMIOMMU_MEM_F_READ, &GCPhysOut, &cbContig); 332 if (RT_SUCCESS(rc)) 333 { 334 /** @todo Handle strict return codes from PGMPhysRead. */ 335 rc = pDevIns->pHlpR0->pfnPhysRead(pDevIns, GCPhysOut, pvBuf, cbRead, fFlags); 336 if (RT_SUCCESS(rc)) 337 { 338 cbRead -= cbContig; 339 pvBuf = (void *)((uintptr_t)pvBuf + cbContig); 340 GCPhys += cbContig; 341 } 342 else 343 break; 344 } 345 else 346 { 347 Log(("pdmR0DevHlp_PCIPhysRead: IOMMU translation failed. uDeviceId=%#x GCPhys=%#RGp cb=%u rc=%Rrc\n", uDeviceId, 348 GCPhys, cbRead, rc)); 349 break; 350 } 351 } 315 int rc = pdmIommuMemAccessRead(pDevIns, pPciDev, GCPhys, pvBuf, cbRead, fFlags); 316 if (RT_SUCCESS(rc) || rc != VERR_IOMMU_NOT_PRESENT) 352 317 return rc; 353 }354 318 #endif 355 319 … … 383 347 384 348 #ifdef VBOX_WITH_IOMMU_AMD 385 /** @todo IOMMU: Optimize/re-organize things here later. */ 386 PGVM pGVM = pDevIns->Internal.s.pGVM; 387 PPDMIOMMUR0 pIommu = &pGVM->pdmr0.s.aIommus[0]; 388 PPDMDEVINS pDevInsIommu = pIommu->CTX_SUFF(pDevIns); 389 if ( pDevInsIommu 390 && pDevInsIommu != pDevIns) 391 { 392 size_t const idxBus = pPciDev->Int.s.idxPdmBus; 393 Assert(idxBus < RT_ELEMENTS(pGVM->pdmr0.s.aPciBuses)); 394 PPDMPCIBUSR0 pBus = &pGVM->pdmr0.s.aPciBuses[idxBus]; 395 uint16_t const uDeviceId = PCIBDF_MAKE(pBus->iBus, pPciDev->uDevFn); 396 int rc = VINF_SUCCESS; 397 while (cbWrite > 0) 398 { 399 RTGCPHYS GCPhysOut; 400 size_t cbContig; 401 rc = pIommu->pfnMemAccess(pDevInsIommu, uDeviceId, GCPhys, cbWrite, PDMIOMMU_MEM_F_WRITE, &GCPhysOut, &cbContig); 402 if (RT_SUCCESS(rc)) 403 { 404 /** @todo Handle strict return codes from PGMPhysWrite. */ 405 rc = pDevIns->pHlpR0->pfnPhysWrite(pDevIns, GCPhysOut, pvBuf, cbWrite, fFlags); 406 if (RT_SUCCESS(rc)) 407 { 408 cbWrite -= cbContig; 409 pvBuf = (const void *)((uintptr_t)pvBuf + cbContig); 410 GCPhys += cbContig; 411 } 412 else 413 break; 414 } 415 else 416 { 417 LogFunc(("IOMMU translation failed. uDeviceId=%#x GCPhys=%#RGp cb=%u rc=%Rrc\n", uDeviceId, GCPhys, cbWrite, rc)); 418 break; 419 } 420 } 349 int rc = pdmIommuMemAccessWrite(pDevIns, pPciDev, GCPhys, pvBuf, cbWrite, fFlags); 350 if (RT_SUCCESS(rc) || rc != VERR_IOMMU_NOT_PRESENT) 421 351 return rc; 422 }423 352 #endif 424 353 -
trunk/src/VBox/VMM/VMMR3/PDMDevHlp.cpp
r87371 r87477 1821 1821 1822 1822 #ifdef VBOX_WITH_IOMMU_AMD 1823 /** @todo IOMMU: Optimize/re-organize things here later. */ 1824 PVM pVM = pDevIns->Internal.s.pVMR3; 1825 PPDMIOMMU pIommu = &pVM->pdm.s.aIommus[0]; 1826 PPDMDEVINS pDevInsIommu = pIommu->CTX_SUFF(pDevIns); 1827 if ( pDevInsIommu 1828 && pDevInsIommu != pDevIns) 1829 { 1830 size_t const idxBus = pPciDev->Int.s.idxPdmBus; 1831 Assert(idxBus < RT_ELEMENTS(pVM->pdm.s.aPciBuses)); 1832 PPDMPCIBUS pBus = &pVM->pdm.s.aPciBuses[idxBus]; 1833 uint16_t const uDevId = PCIBDF_MAKE(pBus->iBus, pPciDev->uDevFn); 1834 int rc = VINF_SUCCESS; 1835 while (cbRead > 0) 1836 { 1837 RTGCPHYS GCPhysOut; 1838 size_t cbContig; 1839 rc = pIommu->pfnMemAccess(pDevInsIommu, uDevId, GCPhys, cbRead, PDMIOMMU_MEM_F_READ, &GCPhysOut, &cbContig); 1840 if (RT_SUCCESS(rc)) 1841 { 1842 /** @todo Handle strict return codes from PGMPhysRead. */ 1843 rc = pDevIns->pHlpR3->pfnPhysRead(pDevIns, GCPhysOut, pvBuf, cbContig, fFlags); 1844 if (RT_SUCCESS(rc)) 1845 { 1846 cbRead -= cbContig; 1847 pvBuf = (void *)((uintptr_t)pvBuf + cbContig); 1848 GCPhys += cbContig; 1849 } 1850 else 1851 break; 1852 } 1853 else 1854 { 1855 AssertMsgFailed(("Here\n")); 1856 Log(("pdmR3DevHlp_PCIPhysRead: IOMMU translation failed. uDevId=%#x GCPhys=%#RGp cb=%u rc=%Rrc\n", uDevId, GCPhys, 1857 cbRead, rc)); 1858 break; 1859 } 1860 } 1823 int rc = pdmIommuMemAccessRead(pDevIns, pPciDev, GCPhys, pvBuf, cbRead, fFlags); 1824 if (RT_SUCCESS(rc) || rc != VERR_IOMMU_NOT_PRESENT) 1861 1825 return rc; 1862 }1863 1826 #endif 1864 1827 … … 1892 1855 1893 1856 #ifdef VBOX_WITH_IOMMU_AMD 1894 /** @todo IOMMU: Optimize/re-organize things here later. */ 1895 PVM pVM = pDevIns->Internal.s.pVMR3; 1896 PPDMIOMMU pIommu = &pVM->pdm.s.aIommus[0]; 1897 PPDMDEVINS pDevInsIommu = pIommu->CTX_SUFF(pDevIns); 1898 if ( pDevInsIommu 1899 && pDevInsIommu != pDevIns) 1900 { 1901 size_t const idxBus = pPciDev->Int.s.idxPdmBus; 1902 Assert(idxBus < RT_ELEMENTS(pVM->pdm.s.aPciBuses)); 1903 PPDMPCIBUS pBus = &pVM->pdm.s.aPciBuses[idxBus]; 1904 uint16_t const uDevId = PCIBDF_MAKE(pBus->iBus, pPciDev->uDevFn); 1905 int rc = VINF_SUCCESS; 1906 while (cbWrite > 0) 1907 { 1908 RTGCPHYS GCPhysOut; 1909 size_t cbContig; 1910 rc = pIommu->pfnMemAccess(pDevInsIommu, uDevId, GCPhys, cbWrite, PDMIOMMU_MEM_F_WRITE, &GCPhysOut, &cbContig); 1911 if (RT_SUCCESS(rc)) 1912 { 1913 /** @todo Handle strict return codes from PGMPhysWrite. */ 1914 rc = pDevIns->pHlpR3->pfnPhysWrite(pDevIns, GCPhysOut, pvBuf, cbContig, fFlags); 1915 if (RT_SUCCESS(rc)) 1916 { 1917 cbWrite -= cbContig; 1918 pvBuf = (const void *)((uintptr_t)pvBuf + cbContig); 1919 GCPhys += cbContig; 1920 } 1921 else 1922 break; 1923 } 1924 else 1925 { 1926 Log(("pdmR3DevHlp_PCIPhysWrite: IOMMU translation failed. uDevId=%#x GCPhys=%#RGp cb=%u rc=%Rrc\n", uDevId, GCPhys, 1927 cbWrite, rc)); 1928 break; 1929 } 1930 } 1857 int rc = pdmIommuMemAccessWrite(pDevIns, pPciDev, GCPhys, pvBuf, cbWrite, fFlags); 1858 if (RT_SUCCESS(rc) || rc != VERR_IOMMU_NOT_PRESENT) 1931 1859 return rc; 1932 }1933 1860 #endif 1934 1861 … … 1959 1886 1960 1887 #ifdef VBOX_WITH_IOMMU_AMD 1961 /** @todo IOMMU: Optimize/re-organize things here later. */ 1962 PVM pVM = pDevIns->Internal.s.pVMR3; 1963 PPDMIOMMU pIommu = &pVM->pdm.s.aIommus[0]; 1964 PPDMDEVINS pDevInsIommu = pIommu->CTX_SUFF(pDevIns); 1965 if ( pDevInsIommu 1966 && pDevInsIommu != pDevIns) 1967 { 1968 size_t const idxBus = pPciDev->Int.s.idxPdmBus; 1969 Assert(idxBus < RT_ELEMENTS(pVM->pdm.s.aPciBuses)); 1970 PPDMPCIBUS pBus = &pVM->pdm.s.aPciBuses[idxBus]; 1971 uint16_t const uDevId = PCIBDF_MAKE(pBus->iBus, pPciDev->uDevFn); 1972 RTGCPHYS GCPhysOut; 1973 size_t cbContig; 1974 int rc = pIommu->pfnMemAccess(pDevInsIommu, uDevId, GCPhys & X86_PAGE_BASE_MASK, X86_PAGE_SIZE, PDMIOMMU_MEM_F_WRITE, 1975 &GCPhysOut, &cbContig); 1976 if (RT_SUCCESS(rc)) 1977 { 1978 GCPhys = GCPhysOut; 1979 Assert(cbContig == X86_PAGE_SIZE); 1980 } 1981 else 1982 { 1983 LogFunc(("IOMMU translation failed. uDevId=%#x GCPhys=%#RGp rc=%Rrc\n", uDevId, GCPhys, rc)); 1984 return rc; 1985 } 1986 } 1888 int rc = pdmIommuMemAccessWriteCCPtr(pDevIns, pPciDev, GCPhys, fFlags, ppv, pLock); 1889 if (RT_SUCCESS(rc) || rc != VERR_IOMMU_NOT_PRESENT) 1890 return rc; 1987 1891 #endif 1988 1892 … … 2013 1917 2014 1918 #ifdef VBOX_WITH_IOMMU_AMD 2015 /** @todo IOMMU: Optimize/re-organize things here later. */ 2016 PVM pVM = pDevIns->Internal.s.pVMR3; 2017 PPDMIOMMU pIommu = &pVM->pdm.s.aIommus[0]; 2018 PPDMDEVINS pDevInsIommu = pIommu->CTX_SUFF(pDevIns); 2019 if ( pDevInsIommu 2020 && pDevInsIommu != pDevIns) 2021 { 2022 size_t const idxBus = pPciDev->Int.s.idxPdmBus; 2023 Assert(idxBus < RT_ELEMENTS(pVM->pdm.s.aPciBuses)); 2024 PPDMPCIBUS pBus = &pVM->pdm.s.aPciBuses[idxBus]; 2025 uint16_t const uDevId = PCIBDF_MAKE(pBus->iBus, pPciDev->uDevFn); 2026 RTGCPHYS GCPhysOut; 2027 size_t cbContig; 2028 int rc = pIommu->pfnMemAccess(pDevInsIommu, uDevId, GCPhys & X86_PAGE_BASE_MASK, X86_PAGE_SIZE, PDMIOMMU_MEM_F_READ, 2029 &GCPhysOut, &cbContig); 2030 if (RT_SUCCESS(rc)) 2031 { 2032 GCPhys = GCPhysOut; 2033 Assert(cbContig == X86_PAGE_SIZE); 2034 } 2035 else 2036 { 2037 LogFunc(("IOMMU translation failed. uDevId=%#x GCPhys=%#RGp rc=%Rrc\n", uDevId, GCPhys, rc)); 2038 return rc; 2039 } 2040 } 1919 int rc = pdmIommuMemAccessReadCCPtr(pDevIns, pPciDev, GCPhys, fFlags, ppv, pLock); 1920 if (RT_SUCCESS(rc) || rc != VERR_IOMMU_NOT_PRESENT) 1921 return rc; 2041 1922 #endif 2042 1923 … … 2068 1949 2069 1950 #ifdef VBOX_WITH_IOMMU_AMD 2070 /** @todo IOMMU: Optimize/re-organize things here later. */ 2071 PVM pVM = pDevIns->Internal.s.pVMR3; 2072 PPDMIOMMU pIommu = &pVM->pdm.s.aIommus[0]; 2073 PPDMDEVINS pDevInsIommu = pIommu->CTX_SUFF(pDevIns); 2074 if ( pDevInsIommu 2075 && pDevInsIommu != pDevIns) 2076 { 2077 size_t const idxBus = pPciDev->Int.s.idxPdmBus; 2078 Assert(idxBus < RT_ELEMENTS(pVM->pdm.s.aPciBuses)); 2079 PPDMPCIBUS pBus = &pVM->pdm.s.aPciBuses[idxBus]; 2080 2081 /* Allocate space of translated addresses. */ 2082 size_t const cbIovas = cPages * sizeof(uint64_t); 2083 PRTGCPHYS paGCPhysSpa = (PRTGCPHYS)RTMemAllocZ(cbIovas); 2084 if (paGCPhysSpa) 2085 { /* likely */ } 2086 else 2087 { 2088 LogFunc(("caller='%s'/%d: returns %Rrc - Failed to alloc %zu bytes for IOVA addresses\n", 2089 pDevIns->pReg->szName, pDevIns->iInstance, VERR_NO_MEMORY, cbIovas)); 2090 return VERR_NO_MEMORY; 2091 } 2092 2093 /* Ask the IOMMU for corresponding translated physical addresses. */ 2094 uint16_t const uDevId = PCIBDF_MAKE(pBus->iBus, pPciDev->uDevFn); 2095 AssertCompile(sizeof(RTGCPHYS) == sizeof(uint64_t)); 2096 int rc = pIommu->pfnMemBulkAccess(pDevInsIommu, uDevId, cPages, (uint64_t const *)paGCPhysPages, PDMIOMMU_MEM_F_WRITE, 2097 paGCPhysSpa); 2098 if (RT_SUCCESS(rc)) 2099 { 2100 /* Perform the bulk mapping but with the translated addresses. */ 2101 rc = pDevIns->pHlpR3->pfnPhysBulkGCPhys2CCPtr(pDevIns, cPages, paGCPhysSpa, fFlags, papvPages, paLocks); 2102 if (RT_FAILURE(rc)) 2103 LogFunc(("Bulk mapping of addresses failed. cPages=%zu fFlags=%#x rc=%Rrc\n", rc, cPages, fFlags)); 2104 } 2105 else 2106 LogFunc(("IOMMU bulk translation failed. uDevId=%#x cPages=%zu rc=%Rrc\n", uDevId, cPages, rc)); 2107 2108 /* Free the translated addresses and return result of the address translation or mapping operation. */ 2109 RTMemFree(paGCPhysSpa); 1951 int rc = pdmIommuMemAccessBulkWriteCCPtr(pDevIns, pPciDev, cPages, paGCPhysPages, fFlags, papvPages, paLocks); 1952 if (RT_SUCCESS(rc) || rc != VERR_IOMMU_NOT_PRESENT) 2110 1953 return rc; 2111 }2112 1954 #endif 2113 1955 … … 2139 1981 2140 1982 #ifdef VBOX_WITH_IOMMU_AMD 2141 /** @todo IOMMU: Optimize/re-organize things here later. */ 2142 PVM pVM = pDevIns->Internal.s.pVMR3; 2143 PPDMIOMMU pIommu = &pVM->pdm.s.aIommus[0]; 2144 PPDMDEVINS pDevInsIommu = pIommu->CTX_SUFF(pDevIns); 2145 if ( pDevInsIommu 2146 && pDevInsIommu != pDevIns) 2147 { 2148 size_t const idxBus = pPciDev->Int.s.idxPdmBus; 2149 Assert(idxBus < RT_ELEMENTS(pVM->pdm.s.aPciBuses)); 2150 PPDMPCIBUS pBus = &pVM->pdm.s.aPciBuses[idxBus]; 2151 2152 /* Allocate space of translated addresses. */ 2153 size_t const cbIovas = cPages * sizeof(uint64_t); 2154 PRTGCPHYS paGCPhysSpa = (PRTGCPHYS)RTMemAllocZ(cbIovas); 2155 if (paGCPhysSpa) 2156 { /* likely */ } 2157 else 2158 { 2159 LogFunc(("caller='%s'/%d: returns %Rrc - Failed to alloc %zu bytes for IOVA addresses\n", 2160 pDevIns->pReg->szName, pDevIns->iInstance, VERR_NO_MEMORY, cbIovas)); 2161 return VERR_NO_MEMORY; 2162 } 2163 2164 /* Ask the IOMMU for corresponding translated physical addresses. */ 2165 uint16_t const uDevId = PCIBDF_MAKE(pBus->iBus, pPciDev->uDevFn); 2166 AssertCompile(sizeof(RTGCPHYS) == sizeof(uint64_t)); 2167 int rc = pIommu->pfnMemBulkAccess(pDevInsIommu, uDevId, cPages, (uint64_t const *)paGCPhysPages, PDMIOMMU_MEM_F_READ, 2168 paGCPhysSpa); 2169 if (RT_SUCCESS(rc)) 2170 { 2171 /* Perform the bulk mapping but with the translated addresses. */ 2172 rc = pDevIns->pHlpR3->pfnPhysBulkGCPhys2CCPtrReadOnly(pDevIns, cPages, paGCPhysSpa, fFlags, papvPages, paLocks); 2173 if (RT_FAILURE(rc)) 2174 LogFunc(("Bulk mapping of addresses failed. cPages=%zu fFlags=%#x rc=%Rrc\n", rc, cPages, fFlags)); 2175 } 2176 else 2177 LogFunc(("IOMMU bulk translation failed. uDevId=%#x cPages=%zu rc=%Rrc\n", uDevId, cPages, rc)); 2178 2179 /* Free the translated addresses and return result of the address translation or mapping operation. */ 2180 RTMemFree(paGCPhysSpa); 1983 int rc = pdmIommuMemAccessBulkReadCCPtr(pDevIns, pPciDev, cPages, paGCPhysPages, fFlags, papvPages, paLocks); 1984 if (RT_SUCCESS(rc) || rc != VERR_IOMMU_NOT_PRESENT) 2181 1985 return rc; 2182 }2183 1986 #endif 2184 1987 -
trunk/src/VBox/VMM/VMMR3/PDMDevHlpTracing.cpp
r87474 r87477 419 419 420 420 #ifdef VBOX_WITH_IOMMU_AMD 421 /** @todo IOMMU: Optimize/re-organize things here later. */ 422 PVM pVM = pDevIns->Internal.s.pVMR3; 423 PPDMIOMMU pIommu = &pVM->pdm.s.aIommus[0]; 424 PPDMDEVINS pDevInsIommu = pIommu->CTX_SUFF(pDevIns); 425 if ( pDevInsIommu 426 && pDevInsIommu != pDevIns) 427 { 428 size_t const idxBus = pPciDev->Int.s.idxPdmBus; 429 Assert(idxBus < RT_ELEMENTS(pVM->pdm.s.aPciBuses)); 430 PPDMPCIBUS pBus = &pVM->pdm.s.aPciBuses[idxBus]; 431 uint16_t const uDevId = PCIBDF_MAKE(pBus->iBus, pPciDev->uDevFn); 432 int rc = VINF_SUCCESS; 433 while (cbRead > 0) 434 { 435 RTGCPHYS GCPhysOut; 436 size_t cbContig; 437 rc = pIommu->pfnMemAccess(pDevInsIommu, uDevId, GCPhys, cbRead, PDMIOMMU_MEM_F_READ, &GCPhysOut, &cbContig); 438 if (RT_SUCCESS(rc)) 439 { 440 /** @todo Handle strict return codes from PGMPhysRead. */ 441 rc = pDevIns->pHlpR3->pfnPhysRead(pDevIns, GCPhysOut, pvBuf, cbRead, fFlags); 442 if (RT_SUCCESS(rc)) 443 { 444 cbRead -= cbContig; 445 pvBuf = (void *)((uintptr_t)pvBuf + cbContig); 446 GCPhys += cbContig; 447 } 448 else 449 break; 450 } 451 else 452 { 453 LogFunc(("IOMMU translation failed. uDevId=%#x GCPhys=%#RGp cb=%u rc=%Rrc\n", uDevId, GCPhys, cbRead, rc)); 454 break; 455 } 456 } 421 int rc = pdmIommuMemAccessRead(pDevIns, pPciDev, GCPhys, pvBuf, cbRead, fFlags); 422 if (RT_SUCCESS(rc) || rc != VERR_IOMMU_NOT_PRESENT) 457 423 return rc; 458 }459 424 #endif 460 425 … … 488 453 489 454 #ifdef VBOX_WITH_IOMMU_AMD 490 /** @todo IOMMU: Optimize/re-organize things here later. */ 491 PVM pVM = pDevIns->Internal.s.pVMR3; 492 PPDMIOMMU pIommu = &pVM->pdm.s.aIommus[0]; 493 PPDMDEVINS pDevInsIommu = pIommu->CTX_SUFF(pDevIns); 494 if ( pDevInsIommu 495 && pDevInsIommu != pDevIns) 496 { 497 size_t const idxBus = pPciDev->Int.s.idxPdmBus; 498 Assert(idxBus < RT_ELEMENTS(pVM->pdm.s.aPciBuses)); 499 PPDMPCIBUS pBus = &pVM->pdm.s.aPciBuses[idxBus]; 500 uint16_t const uDevId = PCIBDF_MAKE(pBus->iBus, pPciDev->uDevFn); 501 int rc = VINF_SUCCESS; 502 while (cbWrite > 0) 503 { 504 RTGCPHYS GCPhysOut; 505 size_t cbContig; 506 rc = pIommu->pfnMemAccess(pDevInsIommu, uDevId, GCPhys, cbWrite, PDMIOMMU_MEM_F_WRITE, &GCPhysOut, &cbContig); 507 if (RT_SUCCESS(rc)) 508 { 509 /** @todo Handle strict return codes from PGMPhysWrite. */ 510 rc = pDevIns->pHlpR3->pfnPhysWrite(pDevIns, GCPhysOut, pvBuf, cbContig, fFlags); 511 if (RT_SUCCESS(rc)) 512 { 513 cbWrite -= cbContig; 514 pvBuf = (const void *)((uintptr_t)pvBuf + cbContig); 515 GCPhys += cbContig; 516 } 517 else 518 break; 519 } 520 else 521 { 522 Log(("pdmR3DevHlp_PCIPhysWrite: IOMMU translation failed. uDevId=%#x GCPhys=%#RGp cb=%u rc=%Rrc\n", uDevId, GCPhys, 523 cbWrite, rc)); 524 break; 525 } 526 } 455 int rc = pdmIommuMemAccessWrite(pDevIns, pPciDev, GCPhys, pvBuf, cbWrite, fFlags); 456 if (RT_SUCCESS(rc) || rc != VERR_IOMMU_NOT_PRESENT) 527 457 return rc; 528 }529 458 #endif 530 459 -
trunk/src/VBox/VMM/VMMR3/PDMDevMiscHlp.cpp
r86070 r87477 142 142 143 143 /** @interface_method_impl{PDMIOAPICHLP,pfnIommuMsiRemap} */ 144 static DECLCALLBACK(int) pdmR3IoApicHlp_IommuMsiRemap(PPDMDEVINS pDevIns, uint16_t uDev Id, PCMSIMSG pMsiIn, PMSIMSG pMsiOut)144 static DECLCALLBACK(int) pdmR3IoApicHlp_IommuMsiRemap(PPDMDEVINS pDevIns, uint16_t uDeviceId, PCMSIMSG pMsiIn, PMSIMSG pMsiOut) 145 145 { 146 146 PDMDEV_ASSERT_DEVINS(pDevIns); … … 149 149 150 150 #ifdef VBOX_WITH_IOMMU_AMD 151 /** @todo IOMMU: Optimize/re-organize things here later. */ 152 PVM pVM = pDevIns->Internal.s.pVMR3; 153 PPDMIOMMU pIommu = &pVM->pdm.s.aIommus[0]; 154 PPDMDEVINS pDevInsIommu = pIommu->CTX_SUFF(pDevIns); 155 if ( pDevInsIommu 156 && pDevInsIommu != pDevIns) 157 { 158 int rc = pIommu->pfnMsiRemap(pDevInsIommu, uDevId, pMsiIn, pMsiOut); 159 if (RT_SUCCESS(rc)) 160 return rc; 161 162 Log(("pdmR3IoApicHlp_IommuRemapMsi: IOMMU MSI remap failed. uDevId=%#x pMsiIn=(%#RX64, %#RU32) rc=%Rrc\n", 163 uDevId, pMsiIn->Addr.u64, pMsiIn->Data.u32, rc)); 151 int rc = pdmIommuMsiRemap(pDevIns, uDeviceId, pMsiIn, pMsiOut); 152 if (RT_SUCCESS(rc) || rc != VERR_IOMMU_NOT_PRESENT) 164 153 return rc; 165 }166 154 #else 167 RT_NOREF(pDevIns, uDev Id);155 RT_NOREF(pDevIns, uDeviceId); 168 156 #endif 157 169 158 *pMsiOut = *pMsiIn; 170 159 return VINF_SUCCESS; -
trunk/src/VBox/VMM/include/PDMInternal.h
r87371 r87477 109 109 typedef PPDMLUN *PPPDMLUN; 110 110 111 /** Pointer to a PDM PCI Bus instance. */112 typedef struct PDMPCIBUS *PPDMPCIBUS;113 /** Pointer to a PDM IOMMU instance. */114 typedef struct PDMIOMMU *PPDMIOMMU;115 111 /** Pointer to a DMAC instance. */ 116 112 typedef struct PDMDMAC *PPDMDMAC; … … 707 703 DECLR3CALLBACKMEMBER(int, pfnMsiRemap,(PPDMDEVINS pDevIns, uint16_t uDevId, PCMSIMSG pMsiIn, PMSIMSG pMsiOut)); 708 704 } PDMIOMMU; 705 /** Pointer to a PDM IOMMU instance. */ 706 typedef PDMIOMMU *PPDMIOMMU; 707 /** Pointer to a const PDM IOMMU instance. */ 708 typedef const PDMIOMMU *PCPDMIOMMU; 709 709 710 710 … … 868 868 uint32_t uAddress, unsigned cb, uint32_t *pu32Value)); 869 869 } PDMPCIBUS; 870 /** Pointer to a PDM PCI Bus instance. */ 871 typedef PDMPCIBUS *PPDMPCIBUS; 872 /** Pointer to a const PDM PCI Bus instance. */ 873 typedef const PDMPCIBUS *PCPDMPCIBUS; 870 874 871 875 … … 885 889 /** Pointer to the ring-0 PCI bus data. */ 886 890 typedef PDMPCIBUSR0 *PPDMPCIBUSR0; 891 /** Pointer to the const ring-0 PCI bus data. */ 892 typedef const PDMPCIBUSR0 *PCPDMPCIBUSR0; 887 893 888 894 … … 1658 1664 void pdmUnlock(PVMCC pVM); 1659 1665 1666 #ifdef VBOX_WITH_IOMMU_AMD 1667 int pdmIommuMemAccessRead(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead, uint32_t fFlags); 1668 int pdmIommuMemAccessWrite(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite, uint32_t fFlags); 1669 int pdmIommuMemAccessReadCCPtr(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, RTGCPHYS GCPhys, uint32_t fFlags, void const **ppv, PPGMPAGEMAPLOCK pLock); 1670 int pdmIommuMemAccessWriteCCPtr(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, RTGCPHYS GCPhys, uint32_t fFlags, void **ppv, PPGMPAGEMAPLOCK pLock); 1671 int pdmIommuMemAccessBulkReadCCPtr(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, uint32_t cPages, PCRTGCPHYS paGCPhysPages, uint32_t fFlags, const void **papvPages, PPGMPAGEMAPLOCK paLocks); 1672 int pdmIommuMemAccessBulkWriteCCPtr(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, uint32_t cPages, PCRTGCPHYS paGCPhysPages, uint32_t fFlags, void **papvPages, PPGMPAGEMAPLOCK paLocks); 1673 int pdmIommuMsiRemap(PPDMDEVINS pDevIns, uint16_t uDeviceId, PCMSIMSG pMsiIn, PMSIMSG pMsiOut); 1674 #endif 1675 1660 1676 #if defined(IN_RING3) || defined(IN_RING0) 1661 1677 void pdmCritSectRwLeaveSharedQueued(PPDMCRITSECTRW pThis);
Note:
See TracChangeset
for help on using the changeset viewer.