VirtualBox

Changeset 83666 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Apr 10, 2020 12:53:12 PM (5 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
137139
Message:

AMD IOMMU: bugref:9654 Bits.

File:
1 edited

Legend:

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

    r83665 r83666  
    11311131} IOMMU_EXCL_RANGE_BAR_T;
    11321132AssertCompileSize(IOMMU_EXCL_RANGE_BAR_T, 8);
     1133#define IOMMU_EXCL_RANGE_BAR_VALID_MASK     UINT64_C(0x000ffffffffff003)
    11331134
    11341135/**
     
    11481149} IOMMU_EXCL_RANGE_LIMIT_T;
    11491150AssertCompileSize(IOMMU_EXCL_RANGE_LIMIT_T, 8);
     1151#define IOMMU_EXCL_RANGE_LIMIT_VALID_MASK   UINT64_C(0x000ffffffffff000)
     1152
    11501153
    11511154/**
     
    12221225} PPR_LOG_BAR_T;
    12231226AssertCompileSize(PPR_LOG_BAR_T, 8);
     1227#define IOMMU_PPR_LOG_BAR_VALID_MASK    UINT64_C(0x0f0ffffffffff000)
    12241228
    12251229/**
     
    20532057
    20542058/**
     2059 * Logs if the buffer length is invalid.
     2060 *
     2061 * @param   uEncodedLen     The length to decode.
     2062 * @param   pszFunc         Name of the calling function for logging purposes.
     2063 */
     2064DECLINLINE(void) iommuAmdCheckBufferLength(uint8_t uEncodedLen, const char *pszFunc)
     2065{
     2066#ifdef VBOX_STRICT
     2067    uint32_t cEntries;
     2068    iommuAmdDecodeBufferLength(uEncodedLen, &cEntries, NULL /* pcbBuffer */);
     2069    if (!cEntries)
     2070        Log((IOMMU_LOG_PFX ": %s: Invalid length %#x\n", pszFunc, uEncodedLen));
     2071#else
     2072    RT_NOREF(uEncodedLen, pszFunc);
     2073#endif
     2074}
     2075
     2076
     2077/**
     2078 * Writes to a read-only register.
     2079 */
     2080static VBOXSTRICTRC iommuAmdIgnore_w(PPDMDEVINS pDevIns, PIOMMU pThis, uint32_t iReg, uint64_t  u64Value)
     2081{
     2082    RT_NOREF(pDevIns, pThis, iReg);
     2083    Log((IOMMU_LOG_PFX ": iommuAmdIgnore_w: Write to read-only register (%#x) with value %#RX64 ignored\n", iReg, u64Value));
     2084    return VINF_SUCCESS;
     2085}
     2086
     2087
     2088/**
    20552089 * Writes the Device Table Base Address Register.
    20562090 */
     
    20702104    RT_NOREF(pDevIns, pThis, iReg);
    20712105    pThis->CmdBufBaseAddr.u64 = u64Value & IOMMU_CMD_BUF_BAR_VALID_MASK;
    2072 
    2073 #ifdef VBOX_STRICT
    2074     uint32_t cEntries;
    2075     uint8_t const uLen = pThis->CmdBufBaseAddr.n.u4CmdLen;
    2076     iommuAmdDecodeBufferLength(uLen, &cEntries, NULL /* pcbBuffer */);
    2077     if (!cEntries)
    2078         Log((IOMMU_LOG_PFX ": iommuAmdCmdBufBar_w: Invalid length %#x\n", uLen));
    2079 #endif
     2106    iommuAmdCheckBufferLength(pThis->CmdBufBaseAddr.n.u4CmdLen, __PRETTY_FUNCTION__);
    20802107    return VINF_SUCCESS;
    20812108}
     
    20882115    RT_NOREF(pDevIns, pThis, iReg);
    20892116    pThis->EvtLogBaseAddr.u64 = u64Value & IOMMU_EVT_LOG_BAR_VALID_MASK;
    2090 
    2091 #ifdef VBOX_STRICT
    2092     uint32_t cEntries;
    2093     uint8_t const uLen = pThis->EvtLogBaseAddr.n.u4EvtLen;
    2094     iommuAmdDecodeBufferLength(uLen, &cEntries, NULL /* pcbBuffer */);
    2095     if (!cEntries)
    2096         Log((IOMMU_LOG_PFX ": iommuAmdEvtLogBar_w: Invalid length %#x\n", uLen));
    2097 #endif
     2117    iommuAmdCheckBufferLength(pThis->EvtLogBaseAddr.n.u4EvtLen, __PRETTY_FUNCTION__);
     2118    return VINF_SUCCESS;
     2119}
     2120
     2121
     2122/**
     2123 * Writes to the Excluse Range Base Address Register.
     2124 */
     2125static VBOXSTRICTRC iommuAmdExclRangeBar_w(PPDMDEVINS pDevIns, PIOMMU pThis, uint32_t iReg, uint64_t  u64Value)
     2126{
     2127    RT_NOREF(pDevIns, pThis, iReg);
     2128    pThis->ExclRangeBaseAddr.u64 = u64Value & IOMMU_EXCL_RANGE_BAR_VALID_MASK;
     2129    return VINF_SUCCESS;
     2130}
     2131
     2132
     2133/**
     2134 * Writes to the Excluse Range Limit Register.
     2135 */
     2136static VBOXSTRICTRC iommuAmdExclRangeLimit_w(PPDMDEVINS pDevIns, PIOMMU pThis, uint32_t iReg, uint64_t  u64Value)
     2137{
     2138    RT_NOREF(pDevIns, pThis, iReg);
     2139    pThis->ExclRangeLimit.u64 = u64Value & IOMMU_EXCL_RANGE_LIMIT_VALID_MASK;
     2140    return VINF_SUCCESS;
     2141}
     2142
     2143
     2144/**
     2145 * Writes the PPR Log Base Address Register.
     2146 */
     2147static VBOXSTRICTRC iommuAmdPprLogBar_w(PPDMDEVINS pDevIns, PIOMMU pThis, uint32_t iReg, uint64_t  u64Value)
     2148{
     2149    RT_NOREF(pDevIns, pThis, iReg);
     2150    pThis->PprLogBaseAddr.u64 = u64Value & IOMMU_PPR_LOG_BAR_VALID_MASK;
     2151    iommuAmdCheckBufferLength(pThis->PprLogBaseAddr.n.u4PprLogLen, __PRETTY_FUNCTION__);
    20982152    return VINF_SUCCESS;
    20992153}
     
    21222176 * @returns Strict VBox status code.
    21232177 * @param   pDevIns     The device instance.
    2124  * @param   off         Offset in bytes.
     2178 * @param   off         MMIO byte offset to the register.
    21252179 * @param   cb          The size of the write access.
    21262180 * @param   uValue      The value being written.
     
    21352189    Assert(pThis);
    21362190
    2137     VBOXSTRICTRC rcStrict;
    21382191    switch (off)
    21392192    {
    21402193        case IOMMU_MMIO_OFF_DEV_TAB_BAR:        return iommuAmdDevTabBar_w(pDevIns, pThis, off, uValue);
    21412194        case IOMMU_MMIO_OFF_CMD_BUF_BAR:        return iommuAmdCmdBufBar_w(pDevIns, pThis, off, uValue);
    2142         case IOMMU_MMIO_OFF_EVT_LOG_BAR:        return iommuAmdEvtLogBar_w(pDevIns, pThis, off,  uValue);
     2195        case IOMMU_MMIO_OFF_EVT_LOG_BAR:        return iommuAmdEvtLogBar_w(pDevIns, pThis, off, uValue);
    21432196        case IOMMU_MMIO_OFF_CTRL:
    2144         case IOMMU_MMIO_OFF_EXCL_BAR:
    2145         case IOMMU_MMIO_OFF_EXCL_RANGE_LIMIT:
    2146         case IOMMU_MMIO_OFF_EXT_FEAT:
    2147 
    2148         case IOMMU_MMIO_OFF_PPR_LOG_BAR:
    2149         case IOMMU_MMIO_OFF_HW_EVT_HI:
    2150         case IOMMU_MMIO_OFF_HW_EVT_LO:
     2197        case IOMMU_MMIO_OFF_EXCL_BAR:           return iommuAmdExclRangeBar_w(pDevIns, pThis, off, uValue);
     2198        case IOMMU_MMIO_OFF_EXCL_RANGE_LIMIT:   return iommuAmdExclRangeLimit_w(pDevIns, pThis, off, uValue);
     2199        case IOMMU_MMIO_OFF_EXT_FEAT:           return iommuAmdIgnore_w(pDevIns, pThis, off, uValue);
     2200
     2201        case IOMMU_MMIO_OFF_PPR_LOG_BAR:        return iommuAmdPprLogBar_w(pDevIns, pThis, off, uValue);
     2202        case IOMMU_MMIO_OFF_HW_EVT_HI:          return iommuAmdIgnore_w(pDevIns, pThis, off, uValue);
     2203        case IOMMU_MMIO_OFF_HW_EVT_LO:          return iommuAmdIgnore_w(pDevIns, pThis, off, uValue);
    21512204        case IOMMU_MMIO_OFF_HW_EVT_STATUS:
    21522205
    2153         case IOMMU_MMIO_OFF_GALOG_BAR:
    2154         case IOMMU_MMIO_OFF_GALOG_TAIL_ADDR:
    2155 
    2156         case IOMMU_MMIO_OFF_PPR_LOG_B_BAR:
    2157         case IOMMU_MMIO_OFF_PPR_EVT_B_BAR:
     2206        case IOMMU_MMIO_OFF_GALOG_BAR:          return iommuAmdIgnore_w(pDevIns, pThis, off, uValue);
     2207        case IOMMU_MMIO_OFF_GALOG_TAIL_ADDR:    return iommuAmdIgnore_w(pDevIns, pThis, off, uValue);
     2208
     2209        case IOMMU_MMIO_OFF_PPR_LOG_B_BAR:      return iommuAmdIgnore_w(pDevIns, pThis, off, uValue);
     2210        case IOMMU_MMIO_OFF_PPR_EVT_B_BAR:      return iommuAmdIgnore_w(pDevIns, pThis, off, uValue);
    21582211
    21592212        case IOMMU_MMIO_OFF_DEV_TAB_SEG_FIRST:
     
    21622215            uint8_t const idxDevTabSeg = (off - IOMMU_MMIO_OFF_DEV_TAB_SEG_FIRST) >> 3;
    21632216            Assert(idxDevTabSeg < RT_ELEMENTS(pThis->DevTabSeg));
    2164             break;
     2217            return iommuAmdIgnore_w(pDevIns, pThis, off, uValue);
    21652218        }
    21662219
     
    22272280            Log((IOMMU_LOG_PFX ": iommuAmdWriteRegister: Writing unsupported register: SMI filter %u -> Ignored\n",
    22282281                 (off - IOMMU_MMIO_OFF_SMI_FLT_FIRST) >> 3));
    2229             rcStrict = VINF_SUCCESS;
    2230             break;
     2282            return VINF_SUCCESS;
    22312283        }
    22322284
     
    22362288            Log((IOMMU_LOG_PFX ": iommuAmdWriteRegister: Trying to write unknown register at %u (%#x) with %#RX64\n", off, off,
    22372289                 uValue));
    2238             rcStrict = VINF_SUCCESS;
    2239             break;
     2290            return VINF_SUCCESS;
    22402291        }
    22412292    }
    2242 
    2243     return rcStrict;
    22442293}
    22452294
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