VirtualBox

Changeset 85830 in vbox


Ignore:
Timestamp:
Aug 19, 2020 10:14:57 AM (4 years ago)
Author:
vboxsync
Message:

AMD IOMMU: bugref:9654 Main/API: Enable and configure an IOMMU device when compilng with VBOX_WITH_IOMMU_AMD and ICH9 is the chipset of the VM.
Stopgap solution for until Main/API support is added for IOMMU.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/src-client/ConsoleImpl2.cpp

    r85803 r85830  
    801801    }
    802802
     803#ifdef VBOX_WITH_IOMMU_AMD
    803804    /** @todo Get IOMMU from pMachine and pass info to createInstance() below. */
    804     BusAssignmentManager *pBusMgr = mBusMgr = BusAssignmentManager::createInstance(chipsetType, false /* fIommu */);
     805    bool const fIommu = RT_BOOL(chipsetType == ChipsetType_ICH9);
     806#else
     807    bool const fIommu = false;
     808#endif
     809    BusAssignmentManager *pBusMgr = mBusMgr = BusAssignmentManager::createInstance(chipsetType, fIommu);
    805810
    806811    ULONG cCpus = 1;
     
    15011506
    15021507#ifdef VBOX_WITH_IOMMU_AMD
    1503             /* AMD IOMMU. */
    1504             /** @todo Get IOMMU from pMachine. */
    1505             InsertConfigNode(pDevices, "iommu-amd", &pDev);
    1506             InsertConfigNode(pDev,     "0", &pInst);
    1507             InsertConfigInteger(pInst, "Trusted",   1); /* boolean */
    1508             InsertConfigNode(pInst,    "Config", &pCfg);
    1509             hrc = pBusMgr->assignPCIDevice("iommu-amd", pInst);                             H();
    1510 
    1511             /*
    1512              * Reserve the specific PCI address of the "SB I/O APIC" when using
    1513              * an AMD IOMMU. Required by Linux guests, see @bugref{9654#c23}.
    1514              */
    1515             PCIBusAddress PCIAddr = PCIBusAddress(VBOX_PCI_BUS_SB_IOAPIC, VBOX_PCI_DEV_SB_IOAPIC, VBOX_PCI_FN_SB_IOAPIC);
    1516             hrc = pBusMgr->assignPCIDevice("sb-ioapic", NULL /* pCfg */, PCIAddr, true /*fGuestAddressRequired*/);  H();
     1508            if (fIommu)
     1509            {
     1510                /* AMD IOMMU. */
     1511                InsertConfigNode(pDevices, "iommu-amd", &pDev);
     1512                InsertConfigNode(pDev,     "0", &pInst);
     1513                InsertConfigInteger(pInst, "Trusted",   1); /* boolean */
     1514                InsertConfigNode(pInst,    "Config", &pCfg);
     1515                hrc = pBusMgr->assignPCIDevice("iommu-amd", pInst);                             H();
     1516
     1517                /*
     1518                 * Reserve the specific PCI address of the "SB I/O APIC" when using
     1519                 * an AMD IOMMU. Required by Linux guests, see @bugref{9654#c23}.
     1520                 */
     1521                PCIBusAddress PCIAddr = PCIBusAddress(VBOX_PCI_BUS_SB_IOAPIC, VBOX_PCI_DEV_SB_IOAPIC, VBOX_PCI_FN_SB_IOAPIC);
     1522                hrc = pBusMgr->assignPCIDevice("sb-ioapic", NULL /* pCfg */, PCIAddr, true /*fGuestAddressRequired*/);  H();
     1523            }
    15171524#endif
    15181525        }
     
    32583265                }
    32593266            }
     3267#ifdef VBOX_WITH_IOMMU_AMD
     3268            if (fIommu)
     3269            {
     3270                PCIBusAddress Address;
     3271                if (pBusMgr->findPCIAddress("iommu-amd", 0, Address))
     3272                {
     3273                    uint32_t u32IommuAddress = (Address.miDevice << 16) | Address.miFn;
     3274                    InsertConfigInteger(pCfg, "IommuAmdPciAddress", u32IommuAddress);
     3275                    if (pBusMgr->findPCIAddress("sb-ioapic", 0, Address))
     3276                    {
     3277                        uint32_t u32SbIoapicAddress = (Address.miDevice << 16) | Address.miFn;
     3278                        InsertConfigInteger(pCfg, "SbIoApicPciAddress", u32SbIoapicAddress);
     3279                    }
     3280                    else
     3281                        LogRel(("IOMMU: AMD IOMMU is enabled, but southbridge I/O APIC is not assigned a PCI address!\n"));
     3282                }
     3283            }
     3284#endif
    32603285            InsertConfigInteger(pCfg,  "IocPciAddress", uIocPCIAddress);
    32613286            if (chipsetType == ChipsetType_ICH9)
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette