VirtualBox

Changeset 88638 in vbox for trunk/src/VBox/VMM/VMMAll


Ignore:
Timestamp:
Apr 22, 2021 5:40:05 AM (4 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
143951
Message:

Intel IOMMU: bugref:9967 Refactor some PDM-IOMMU interfaces to differentiate between device present vs. device instance available in current context (ring-0/ring-3).
This should help us to support IOMMU as ring-3-only device in the future.
Still more work to do in that regard (PDM task queue), but one step at a time.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMAll/PDMAllIommu.cpp

    r88636 r88638  
    8989    PPDMIOMMU  pIommu       = PDMDEVINS_TO_IOMMU(pDevIns);
    9090    PPDMDEVINS pDevInsIommu = pIommu->CTX_SUFF(pDevIns);
    91     if (   pDevInsIommu
    92         && pDevInsIommu != pDevIns)
    93     {
    94         int rc = pIommu->pfnMsiRemap(pDevInsIommu, idDevice, pMsiIn, pMsiOut);
    95         if (RT_FAILURE(rc))
    96         {
    97             LogFunc(("MSI remap failed. idDevice=%#x pMsiIn=(%#RX64, %#RU32) rc=%Rrc\n", idDevice, pMsiIn->Addr.u64,
    98                      pMsiIn->Data.u32, rc));
    99         }
    100         return rc;
    101     }
    102     /** @todo Should we return an rc such that we can reschedule to R3 if R0 isn't
    103      *        enabled?  Is that even viable with the state the I/O APIC would be in? */
    104     return VERR_IOMMU_NOT_PRESENT;
     91    Assert(pDevInsIommu);
     92    if (pDevInsIommu != pDevIns)
     93        return pIommu->pfnMsiRemap(pDevInsIommu, idDevice, pMsiIn, pMsiOut);
     94    return VERR_IOMMU_CANNOT_CALL_SELF;
    10595}
    10696
     
    126116    PPDMIOMMU  pIommu       = PDMDEVINS_TO_IOMMU(pDevIns);
    127117    PPDMDEVINS pDevInsIommu = pIommu->CTX_SUFF(pDevIns);
    128     if (   pDevInsIommu
    129         && pDevInsIommu != pDevIns)
    130     {
     118    if (pDevInsIommu)
     119    {
     120        if (pDevInsIommu != pDevIns)
     121        { /* likely */ }
     122        else
     123            return VERR_IOMMU_CANNOT_CALL_SELF;
     124
    131125        uint16_t const idDevice = pdmIommuGetPciDeviceId(pDevIns, pPciDev);
    132126        int rc = VINF_SUCCESS;
     
    190184    PPDMIOMMU  pIommu       = PDMDEVINS_TO_IOMMU(pDevIns);
    191185    PPDMDEVINS pDevInsIommu = pIommu->CTX_SUFF(pDevIns);
    192     if (   pDevInsIommu
    193         && pDevInsIommu != pDevIns)
    194     {
     186    if (pDevInsIommu)
     187    {
     188        if (pDevInsIommu != pDevIns)
     189        { /* likely */ }
     190        else
     191            return VERR_IOMMU_CANNOT_CALL_SELF;
     192
    195193        uint16_t const idDevice = pdmIommuGetPciDeviceId(pDevIns, pPciDev);
    196194        int rc = VINF_SUCCESS;
     
    251249    PPDMIOMMU  pIommu       = PDMDEVINS_TO_IOMMU(pDevIns);
    252250    PPDMDEVINS pDevInsIommu = pIommu->CTX_SUFF(pDevIns);
    253     if (   pDevInsIommu
    254         && pDevInsIommu != pDevIns)
    255     {
     251    if (pDevInsIommu)
     252    {
     253        if (pDevInsIommu != pDevIns)
     254        { /* likely */ }
     255        else
     256            return VERR_IOMMU_CANNOT_CALL_SELF;
     257
    256258        uint16_t const idDevice = pdmIommuGetPciDeviceId(pDevIns, pPciDev);
    257259        size_t   cbContig  = 0;
     
    296298    PPDMIOMMU  pIommu       = PDMDEVINS_TO_IOMMU(pDevIns);
    297299    PPDMDEVINS pDevInsIommu = pIommu->CTX_SUFF(pDevIns);
    298     if (   pDevInsIommu
    299         && pDevInsIommu != pDevIns)
    300     {
     300    if (pDevInsIommu)
     301    {
     302        if (pDevInsIommu != pDevIns)
     303        { /* likely */ }
     304        else
     305            return VERR_IOMMU_CANNOT_CALL_SELF;
     306
    301307        uint16_t const idDevice = pdmIommuGetPciDeviceId(pDevIns, pPciDev);
    302308        size_t   cbContig  = 0;
     
    344350    PPDMIOMMU  pIommu       = PDMDEVINS_TO_IOMMU(pDevIns);
    345351    PPDMDEVINS pDevInsIommu = pIommu->CTX_SUFF(pDevIns);
    346     if (   pDevInsIommu
    347         && pDevInsIommu != pDevIns)
    348     {
     352    if (pDevInsIommu)
     353    {
     354        if (pDevInsIommu != pDevIns)
     355        { /* likely */ }
     356        else
     357            return VERR_IOMMU_CANNOT_CALL_SELF;
     358
    349359        /* Allocate space for translated addresses. */
    350360        size_t const cbIovas  = cPages * sizeof(uint64_t);
     
    407417    PPDMIOMMU  pIommu       = PDMDEVINS_TO_IOMMU(pDevIns);
    408418    PPDMDEVINS pDevInsIommu = pIommu->CTX_SUFF(pDevIns);
    409     if (   pDevInsIommu
    410         && pDevInsIommu != pDevIns)
    411     {
     419    if (pDevInsIommu)
     420    {
     421        if (pDevInsIommu != pDevIns)
     422        { /* likely */ }
     423        else
     424            return VERR_IOMMU_CANNOT_CALL_SELF;
     425
    412426        /* Allocate space for translated addresses. */
    413427        size_t const cbIovas  = cPages * sizeof(uint64_t);
Note: See TracChangeset for help on using the changeset viewer.

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