VirtualBox

Changeset 83545 in vbox for trunk/src/VBox/Devices/Bus


Ignore:
Timestamp:
Apr 4, 2020 6:34:01 AM (5 years ago)
Author:
vboxsync
Message:

AMD IOMMU: bugref:9654 Bits.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Bus/DevIommuAmd.cpp

    r83542 r83545  
    353353#define IOMMU_MMIO_REGION_SIZE                      _16K            /**< Size of the MMIO region in bytes. */
    354354/** @} */
     355
     356/**
     357 * Acquires the IOMMU lock or returns.
     358 */
     359#define IOMMU_LOCK_RET(a_pDevIns, a_pThis, a_rcBusy)  \
     360    do { \
     361        int rcLock = PDMDevHlpCritSectEnter((a_pDevIns), &(a_pThis)->CritSect, (a_rcBusy)); \
     362        if (RT_LIKELY(rcLock == VINF_SUCCESS)) \
     363        { /* likely */ } \
     364        else \
     365            return rcLock; \
     366    } while (0)
     367
     368/**
     369 * Releases the IOMMU lock.
     370 */
     371#define IOMMU_UNLOCK(a_pDevIns, a_pThis) \
     372    do { PDMDevHlpCritSectLeave((a_pDevIns), &(a_pThis)->CritSect); } while (0)
    355373
    356374
     
    19641982#ifndef VBOX_DEVICE_STRUCT_TESTCASE
    19651983
    1966 static VBOXSTRICTRC iommuAmdReadRegister(PCIOMMU pThis, uint32_t off, uint8_t cb, uint64_t *puResult)
     1984static VBOXSTRICTRC iommuAmdReadRegister(PCIOMMU pThis, uint32_t off, uint64_t *puResult)
    19671985{
    19681986    Assert(off < _16K);
    1969     Assert(cb == 4 || cb == 8);
    1970     Assert(cb == 4 || !(off & 7));
    1971     Assert(cb == 8 || !(off & 3));
    1972 
     1987    Assert(!(off & 7) || !(off & 3));
     1988
     1989    /** @todo locking? */
    19731990    switch (off)
    19741991    {
     
    20612078        case IOMMU_MMIO_OFF_SMI_FLT_LAST:
    20622079        {
     2080            Log((IOMMU_LOG_PFX ": iommuAmdReadRegister: Reading unsupported register: SMI filter %u\n",
     2081                 (off - IOMMU_MMIO_OFF_SMI_FLT_FIRST) >> 3));
    20632082            *puResult = 0;
    20642083            break;
     
    20682087        default:
    20692088        {
     2089            Log((IOMMU_LOG_PFX ": iommuAmdReadRegister: Trying to read unknown register at %u (%#x)\n", off, off));
    20702090            *puResult = 0;
    2071             ASSERT_GUEST_MSG_FAILED((IOMMU_LOG_PFX ": iommuAmdReadRegister: Unknown offset %u (cb=%u)\n", off, cb));
    2072             break;
     2091            return VINF_IOM_MMIO_UNUSED_00;
    20732092        }
    20742093    }
     2094    return VINF_SUCCESS;
    20752095}
    20762096
     
    20942114    NOREF(pvUser);
    20952115    Assert(cb == 4 || cb == 8);
    2096 
    2097     uint64_t uResult = 0;
    2098     PIOMMU   pThis   = PDMDEVINS_2_DATA(pDevIns, PIOMMU);
    2099     VBOXSTRICTRC rcStrict = iommuAmdReadRegister(pThis, off, cb, &uResult);
     2116    Assert(cb == 4 || !(off & 7));
     2117    Assert(cb == 8 || !(off & 3));
     2118
     2119    uint64_t uResult  = 0;
     2120    PIOMMU pThis = PDMDEVINS_2_DATA(pDevIns, PIOMMU);
     2121    VBOXSTRICTRC rcStrict = iommuAmdReadRegister(pThis, off, &uResult);
    21002122    if (cb == 8)
    21012123        *(uint64_t *)pv = uResult;
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