VirtualBox

儲存庫 vbox 的更動 88333


忽略:
時間撮記:
2021-3-31 下午04:29:39 (4 年 以前)
作者:
vboxsync
svn:sync-xref-src-repo-rev:
143559
訊息:

Intel IOMMU: bugref:9967 ACPI, BusAssignmentManager and ConsoleImpl2 changes for VT-d PCI device.

位置:
trunk/src/VBox
檔案:
修改 3 筆資料

圖例:

未更動
新增
刪除
  • trunk/src/VBox/Devices/PC/DevACPI.cpp

    r88310 r88333  
    209209    SYSTEM_INFO_INDEX_PREF64_MEMORY_MAX = 30,
    210210    SYSTEM_INFO_INDEX_NVME_ADDRESS      = 31, /**< First NVMe controller PCI address, or 0 */
    211     SYSTEM_INFO_INDEX_IOMMU_AMD_ADDRESS = 32, /**< AMD IOMMU PCI address, or 0 */
     211    SYSTEM_INFO_INDEX_IOMMU_ADDRESS     = 32, /**< IOMMU PCI address, or 0 */
    212212    SYSTEM_INFO_INDEX_SB_IOAPIC_ADDRESS = 33, /**< Southbridge I/O APIC (needed by AMD IOMMU) PCI address, or 0 */
    213213    SYSTEM_INFO_INDEX_END               = 34,
     
    402402    /** PCI address of the host bus controller device. */
    403403    uint32_t            u32HbcPciAddress;
    404     /** PCI address of the AMD IOMMU device. */
    405     uint32_t            u32IommuAmdPciAddress;
     404    /** PCI address of the IOMMU device. */
     405    uint32_t            u32IommuPciAddress;
    406406    /** PCI address of the southbridge I/O APIC device. */
    407407    uint32_t            u32SbIoApicPciAddress;
     
    16551655            break;
    16561656
    1657         case SYSTEM_INFO_INDEX_IOMMU_AMD_ADDRESS:
    1658             *pu32 = pThis->u32IommuAmdPciAddress;
     1657        case SYSTEM_INFO_INDEX_IOMMU_ADDRESS:
     1658            *pu32 = pThis->u32IommuPciAddress;
    16591659            break;
    16601660
     
    32203220
    32213221    uint16_t const uIommuBus = 0;
    3222     uint16_t const uIommuDev = RT_HI_U16(pThis->u32IommuAmdPciAddress);
    3223     uint16_t const uIommuFn  = RT_LO_U16(pThis->u32IommuAmdPciAddress);
     3222    uint16_t const uIommuDev = RT_HI_U16(pThis->u32IommuPciAddress);
     3223    uint16_t const uIommuFn  = RT_LO_U16(pThis->u32IommuPciAddress);
    32243224
    32253225    /* IVRS header. */
     
    33873387    VtdTable.Drhd.cbLength     = sizeof(ACPIDRHD) /* + sizeof(VtdTable.DevScope) */;
    33883388    VtdTable.Drhd.fFlags       = ACPI_DRHD_F_INCLUDE_PCI_ALL;
    3389     VtdTable.Drhd.uRegBaseAddr = VTD_MMIO_BASE_ADDR;
     3389    VtdTable.Drhd.uRegBaseAddr = VTD_MMIO_BASE_PHYSADDR;
    33903390
    33913391    /* Finally, compute checksum. */
     
    40744074                                  "|Parallel0Irq"
    40754075                                  "|Parallel1Irq"
     4076                                  "|IommuIntelEnabled"
    40764077                                  "|IommuAmdEnabled"
    4077                                   "|IommuAmdPciAddress"
     4078                                  "|IommuPciAddress"
    40784079                                  "|SbIoApicPciAddress"
    40794080                                  , "");
     
    42424243    {
    42434244        /* Query IOMMU AMD address (IOMA). */
    4244         rc = pHlp->pfnCFGMQueryU32Def(pCfg, "IommuAmdPciAddress", &pThis->u32IommuAmdPciAddress, 0);
     4245        rc = pHlp->pfnCFGMQueryU32Def(pCfg, "IommuPciAddress", &pThis->u32IommuPciAddress, 0);
    42454246        if (RT_FAILURE(rc))
    4246             return PDMDEV_SET_ERROR(pDevIns, rc, N_("Configuration error: Failed to read \"IommuAmdAddress\""));
     4247            return PDMDEV_SET_ERROR(pDevIns, rc, N_("Configuration error: Failed to read \"IommuPciAddress\""));
    42474248
    42484249        /* Query southbridge I/O APIC address (required when an AMD IOMMU is configured). */
     
    42544255        /** @todo We should eventually not assign the IOMMU at this address, see
    42554256         *        @bugref{9654#c53}. */
    4256         if (!pThis->u32IommuAmdPciAddress)
     4257        if (!pThis->u32IommuPciAddress)
    42574258            LogRel(("ACPI: Warning! AMD IOMMU assigned the PCI host bridge address.\n"));
    42584259
     
    42724273    if (RT_FAILURE(rc))
    42734274        return PDMDEV_SET_ERROR(pDevIns, rc, N_("Configuration error: Failed to read \"IommuIntelEnabled\""));
     4275
     4276    if (pThis->fUseIommuIntel)
     4277    {
     4278        /* Query IOMMU Intel address. */
     4279        rc = pHlp->pfnCFGMQueryU32Def(pCfg, "IommuPciAddress", &pThis->u32IommuPciAddress, 0);
     4280        if (RT_FAILURE(rc))
     4281            return PDMDEV_SET_ERROR(pDevIns, rc, N_("Configuration error: Failed to read \"IommuPciAddress\""));
     4282    }
    42744283#endif
    42754284
  • trunk/src/VBox/Main/src-client/BusAssignmentManager.cpp

    r87242 r88333  
    238238 * to device number 23 when the VM is configured for an AMD IOMMU.
    239239 */
    240 static const DeviceAssignmentRule g_aIch9IommuLsiRules[] =
     240static const DeviceAssignmentRule g_aIch9IommuAmdRules[] =
    241241{
    242242    /* AMD IOMMU. */
     
    247247    /* Storage controller */
    248248    {"lsilogic",      0, 23,  0, 1},
     249    { NULL,          -1, -1, -1, 0}
     250};
     251#endif
     252
     253#ifdef VBOX_WITH_IOMMU_INTEL
     254/*
     255 * Intel IOMMU.
     256 * The VT-d misc, address remapping, system management device is
     257 * located at BDF 00:5:0 on real hardware so we mimick the same.
     258 * LSI logic remains at 0:20:0.
     259 */
     260static const DeviceAssignmentRule g_aIch9IommuIntelRules[] =
     261{
     262    /* Intel IOMMU. */
     263    {"iommu-intel",   0,  5,  0, 0},
     264
     265    /* Storage controller */
     266    {"lsilogic",      0, 20,  0, 1},
    249267    { NULL,          -1, -1, -1, 0}
    250268};
     
    334352HRESULT BusAssignmentManager::State::init(ChipsetType_T chipsetType, IommuType_T iommuType)
    335353{
    336     /* Currently we only support AMD IOMMU. */
    337     Assert(iommuType == IommuType_None || iommuType == IommuType_AMD);
     354    if (iommuType != IommuType_None)
     355    {
     356#if defined(VBOX_WITH_IOMMU_AMD) && defined(VBOX_WITH_IOMMU_INTEL)
     357        Assert(iommuType == IommuType_AMD || iommuType == IommuType_Intel);
     358#elif defined(VBOX_WITH_IOMMU_AMD)
     359        Assert(iommuType == IommuType_AMD);
     360#elif defined(VBOX_WITH_IOMMU_INTEL)
     361        Assert(iommuType == IommuType_Intel);
     362#endif
     363    }
    338364
    339365    mChipsetType = chipsetType;
     
    405431#ifdef VBOX_WITH_IOMMU_AMD
    406432            if (mIommuType == IommuType_AMD)
    407                 aArrays[2] = g_aIch9IommuLsiRules;
     433                aArrays[2] = g_aIch9IommuAmdRules;
     434            else
     435#endif
     436#ifdef VBOX_WITH_IOMMU_INTEL
     437            if (mIommuType == IommuType_Intel)
     438                aArrays[2] = g_aIch9IommuIntelRules;
    408439            else
    409440#endif
  • trunk/src/VBox/Main/src-client/ConsoleImpl2.cpp

    r88217 r88333  
    844844    }
    845845
    846 #ifdef VBOX_WITH_IOMMU_AMD
     846#if defined(VBOX_WITH_IOMMU_AMD) || defined(VBOX_WITH_IOMMU_INTEL)
    847847    IommuType_T iommuType;
    848848    hrc = pMachine->COMGETTER(IommuType)(&iommuType);                                       H();
     
    854854            iommuType = IommuType_AMD;
    855855        else if (ASMIsIntelCpu())
    856         {
     856            iommuType = IommuType_Intel;
     857        else
     858        {
     859            /** @todo Should we handle other CPUs like Shanghai, VIA etc. here? */
     860            LogRel(("WARNING! Unrecognized CPU type, IOMMU disabled.\n"));
    857861            iommuType = IommuType_None;
    858             LogRel(("WARNING! Intel IOMMU implemention is not yet supported. Disabled IOMMU.\n"));
    859         }
    860         else
    861         {
    862             /** @todo Should we handle other CPUs like Shanghai, VIA etc. here? */
    863             LogRel(("WARNING! Unrecognized CPU type. Disabled IOMMU.\n"));
    864             iommuType = IommuType_None;
    865862        }
    866863    }
    867864
    868     /* Handle AMD IOMMU specifics. */
    869     if (   iommuType == IommuType_AMD
     865    if (iommuType == IommuType_AMD)
     866    {
     867#ifndef VBOX_WITH_IOMMU_AMD
     868        LogRel(("WARNING! AMD IOMMU not supported, IOMMU disabled.\n"));
     869        iommuType = IommuType_None;
     870#endif
     871    }
     872    if (iommuType != IommuType_Intel)
     873    {
     874#ifndef VBOX_WITH_IOMMU_INTEL
     875        LogRel(("WARNING! Intel IOMMU not supported, IOMMU disabled.\n"));
     876        iommuType = IommuType_None;
     877#endif
     878    }
     879    if (   (iommuType == IommuType_AMD || iommuType == IommuType_Intel)
    870880        && chipsetType != ChipsetType_ICH9)
    871         return VMR3SetError(pUVM, VERR_INVALID_PARAMETER, RT_SRC_POS,
    872                             N_("AMD IOMMU uses MSIs which requires the ICH9 chipset implementation."));
    873 
    874     /** @todo Handle Intel IOMMU specifics. */
     881            return VMR3SetError(pUVM, VERR_INVALID_PARAMETER, RT_SRC_POS,
     882                                N_("IOMMU uses MSIs which requires the ICH9 chipset implementation."));
    875883#else
    876884    IommuType_T const iommuType = IommuType_None;
     
    15751583#endif
    15761584
    1577 #ifdef VBOX_WITH_IOMMU_AMD
    15781585            if (iommuType == IommuType_AMD)
    15791586            {
     
    15831590                InsertConfigInteger(pInst, "Trusted",   1); /* boolean */
    15841591                InsertConfigNode(pInst,    "Config", &pCfg);
    1585                 hrc = pBusMgr->assignPCIDevice("iommu-amd", pInst);                             H();
     1592                hrc = pBusMgr->assignPCIDevice("iommu-amd", pInst);                         H();
    15861593
    15871594                /*
     
    15921599                hrc = pBusMgr->assignPCIDevice("sb-ioapic", NULL /* pCfg */, PCIAddr, true /*fGuestAddressRequired*/);  H();
    15931600            }
    1594 #endif
    1595         }
    1596         /** @todo IOMMU: Disallow creating a VM without ICH9 chipset if an IOMMU is
    1597          *        configured. */
     1601            else if (iommuType == IommuType_Intel)
     1602            {
     1603                /* Intel IOMMU. */
     1604                InsertConfigNode(pDevices, "iommu-intel", &pDev);
     1605                InsertConfigNode(pDev,     "0", &pInst);
     1606                InsertConfigInteger(pInst, "Trusted",   1); /* boolean */
     1607                InsertConfigNode(pInst,    "Config", &pCfg);
     1608                hrc = pBusMgr->assignPCIDevice("iommu-intel", pInst);                       H();
     1609            }
     1610        }
    15981611
    15991612        /*
     
    33613374                }
    33623375            }
    3363 #ifdef VBOX_WITH_IOMMU_AMD
    33643376            if (iommuType == IommuType_AMD)
    33653377            {
     
    33693381                    uint32_t u32IommuAddress = (Address.miDevice << 16) | Address.miFn;
    33703382                    InsertConfigInteger(pCfg, "IommuAmdEnabled", true);
    3371                     InsertConfigInteger(pCfg, "IommuAmdPciAddress", u32IommuAddress);
     3383                    InsertConfigInteger(pCfg, "IommuPciAddress", u32IommuAddress);
    33723384                    if (pBusMgr->findPCIAddress("sb-ioapic", 0, Address))
    33733385                    {
     
    33793391                }
    33803392            }
    3381 #endif
     3393            else if (iommuType == IommuType_Intel)
     3394            {
     3395                PCIBusAddress Address;
     3396                if (pBusMgr->findPCIAddress("iommu-intel", 0, Address))
     3397                {
     3398                    uint32_t u32IommuAddress = (Address.miDevice << 16) | Address.miFn;
     3399                    InsertConfigInteger(pCfg, "IommuIntelEnabled", true);
     3400                    InsertConfigInteger(pCfg, "IommuPciAddress", u32IommuAddress);
     3401                }
     3402            }
     3403
    33823404            InsertConfigInteger(pCfg,  "IocPciAddress", uIocPCIAddress);
    33833405            if (chipsetType == ChipsetType_ICH9)
注意: 瀏覽 TracChangeset 來幫助您使用更動檢視器

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