VirtualBox

Changeset 83669 in vbox


Ignore:
Timestamp:
Apr 10, 2020 1:42:32 PM (5 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
137150
Message:

AMD IOMMU: bugref:9654 Bits.

File:
1 edited

Legend:

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

    r83666 r83669  
    14541454} MSI_ADDR_T;
    14551455AssertCompileSize(MSI_ADDR_T, 8);
     1456#define IOMMU_MSI_ADDR_VALID_MASK           UINT64_C(0xfffffffffffffffc)
    14561457
    14571458/**
     
    14701471} MSI_DATA_T;
    14711472AssertCompileSize(MSI_DATA_T, 4);
     1473#define IOMMU_MSI_DATA_VALID_MASK       UINT64_C(0x000000000000ffff)
    14721474
    14731475/**
     
    20782080 * Writes to a read-only register.
    20792081 */
    2080 static VBOXSTRICTRC iommuAmdIgnore_w(PPDMDEVINS pDevIns, PIOMMU pThis, uint32_t iReg, uint64_t  u64Value)
    2081 {
    2082     RT_NOREF(pDevIns, pThis, iReg);
     2082static VBOXSTRICTRC iommuAmdIgnore_w(PPDMDEVINS pDevIns, PIOMMU pThis, uint32_t iReg, uint64_t u64Value)
     2083{
     2084    RT_NOREF(pDevIns, pThis, iReg, u64Value);
    20832085    Log((IOMMU_LOG_PFX ": iommuAmdIgnore_w: Write to read-only register (%#x) with value %#RX64 ignored\n", iReg, u64Value));
    20842086    return VINF_SUCCESS;
     
    20892091 * Writes the Device Table Base Address Register.
    20902092 */
    2091 static VBOXSTRICTRC iommuAmdDevTabBar_w(PPDMDEVINS pDevIns, PIOMMU pThis, uint32_t iReg, uint64_t  u64Value)
    2092 {
    2093     RT_NOREF(pDevIns, pThis, iReg);
     2093static VBOXSTRICTRC iommuAmdDevTabBar_w(PPDMDEVINS pDevIns, PIOMMU pThis, uint32_t iReg, uint64_t u64Value)
     2094{
     2095    RT_NOREF(pDevIns, iReg);
    20942096    pThis->DevTabBaseAddr.u64 = u64Value & IOMMU_DEV_TAB_BAR_VALID_MASK;
    20952097    return VINF_SUCCESS;
     
    21002102 * Writes the Command Buffer Base Address Register.
    21012103 */
    2102 static VBOXSTRICTRC iommuAmdCmdBufBar_w(PPDMDEVINS pDevIns, PIOMMU pThis, uint32_t iReg, uint64_t  u64Value)
    2103 {
    2104     RT_NOREF(pDevIns, pThis, iReg);
     2104static VBOXSTRICTRC iommuAmdCmdBufBar_w(PPDMDEVINS pDevIns, PIOMMU pThis, uint32_t iReg, uint64_t u64Value)
     2105{
     2106    RT_NOREF(pDevIns, iReg);
    21052107    pThis->CmdBufBaseAddr.u64 = u64Value & IOMMU_CMD_BUF_BAR_VALID_MASK;
    21062108    iommuAmdCheckBufferLength(pThis->CmdBufBaseAddr.n.u4CmdLen, __PRETTY_FUNCTION__);
     
    21112113 * Writes the Event Log Base Address Register.
    21122114 */
    2113 static VBOXSTRICTRC iommuAmdEvtLogBar_w(PPDMDEVINS pDevIns, PIOMMU pThis, uint32_t iReg, uint64_t  u64Value)
    2114 {
    2115     RT_NOREF(pDevIns, pThis, iReg);
     2115static VBOXSTRICTRC iommuAmdEvtLogBar_w(PPDMDEVINS pDevIns, PIOMMU pThis, uint32_t iReg, uint64_t u64Value)
     2116{
     2117    RT_NOREF(pDevIns, iReg);
    21162118    pThis->EvtLogBaseAddr.u64 = u64Value & IOMMU_EVT_LOG_BAR_VALID_MASK;
    21172119    iommuAmdCheckBufferLength(pThis->EvtLogBaseAddr.n.u4EvtLen, __PRETTY_FUNCTION__);
     
    21232125 * Writes to the Excluse Range Base Address Register.
    21242126 */
    2125 static VBOXSTRICTRC iommuAmdExclRangeBar_w(PPDMDEVINS pDevIns, PIOMMU pThis, uint32_t iReg, uint64_t  u64Value)
    2126 {
    2127     RT_NOREF(pDevIns, pThis, iReg);
     2127static VBOXSTRICTRC iommuAmdExclRangeBar_w(PPDMDEVINS pDevIns, PIOMMU pThis, uint32_t iReg, uint64_t u64Value)
     2128{
     2129    RT_NOREF(pDevIns, iReg);
    21282130    pThis->ExclRangeBaseAddr.u64 = u64Value & IOMMU_EXCL_RANGE_BAR_VALID_MASK;
    21292131    return VINF_SUCCESS;
     
    21342136 * Writes to the Excluse Range Limit Register.
    21352137 */
    2136 static VBOXSTRICTRC iommuAmdExclRangeLimit_w(PPDMDEVINS pDevIns, PIOMMU pThis, uint32_t iReg, uint64_t  u64Value)
    2137 {
    2138     RT_NOREF(pDevIns, pThis, iReg);
     2138static VBOXSTRICTRC iommuAmdExclRangeLimit_w(PPDMDEVINS pDevIns, PIOMMU pThis, uint32_t iReg, uint64_t u64Value)
     2139{
     2140    RT_NOREF(pDevIns, iReg);
    21392141    pThis->ExclRangeLimit.u64 = u64Value & IOMMU_EXCL_RANGE_LIMIT_VALID_MASK;
    21402142    return VINF_SUCCESS;
     
    21452147 * Writes the PPR Log Base Address Register.
    21462148 */
    2147 static VBOXSTRICTRC iommuAmdPprLogBar_w(PPDMDEVINS pDevIns, PIOMMU pThis, uint32_t iReg, uint64_t  u64Value)
    2148 {
    2149     RT_NOREF(pDevIns, pThis, iReg);
     2149static VBOXSTRICTRC iommuAmdPprLogBar_w(PPDMDEVINS pDevIns, PIOMMU pThis, uint32_t iReg, uint64_t u64Value)
     2150{
     2151    RT_NOREF(pDevIns, iReg);
    21502152    pThis->PprLogBaseAddr.u64 = u64Value & IOMMU_PPR_LOG_BAR_VALID_MASK;
    21512153    iommuAmdCheckBufferLength(pThis->PprLogBaseAddr.n.u4PprLogLen, __PRETTY_FUNCTION__);
     2154    return VINF_SUCCESS;
     2155}
     2156
     2157
     2158/**
     2159 * Writes the MSI Address (Lo) Register (32-bit).
     2160 */
     2161static VBOXSTRICTRC iommuAmdMsiAddrLo_w(PPDMDEVINS pDevIns, PIOMMU pThis, uint32_t iReg, uint64_t u64Value)
     2162{
     2163    RT_NOREF(pDevIns, iReg);
     2164    Assert(!RT_HI_U32(u64Value));
     2165    pThis->MsiAddr.au32[0] = u64Value & IOMMU_MSI_ADDR_VALID_MASK;
     2166    return VINF_SUCCESS;
     2167}
     2168
     2169
     2170/**
     2171 * Writes the MSI Address (Hi) Register (32-bit).
     2172 */
     2173static VBOXSTRICTRC iommuAmdMsiAddrHi_w(PPDMDEVINS pDevIns, PIOMMU pThis, uint32_t iReg, uint64_t u64Value)
     2174{
     2175    RT_NOREF(pDevIns, iReg);
     2176    Assert(!RT_HI_U32(u64Value));
     2177    pThis->MsiAddr.au32[1] = u64Value;
     2178    return VINF_SUCCESS;
     2179}
     2180
     2181
     2182/**
     2183 * Writes the MSI Data Register (32-bit).
     2184 */
     2185static VBOXSTRICTRC iommuAmdMsiData_w(PPDMDEVINS pDevIns, PIOMMU pThis, uint32_t iReg, uint64_t u64Value)
     2186{
     2187    RT_NOREF(pDevIns, iReg);
     2188    pThis->MsiData.u32 = u64Value & IOMMU_MSI_DATA_VALID_MASK;
    21522189    return VINF_SUCCESS;
    21532190}
     
    21912228    switch (off)
    21922229    {
    2193         case IOMMU_MMIO_OFF_DEV_TAB_BAR:        return iommuAmdDevTabBar_w(pDevIns, pThis, off, uValue);
    2194         case IOMMU_MMIO_OFF_CMD_BUF_BAR:        return iommuAmdCmdBufBar_w(pDevIns, pThis, off, uValue);
    2195         case IOMMU_MMIO_OFF_EVT_LOG_BAR:        return iommuAmdEvtLogBar_w(pDevIns, pThis, off, uValue);
    2196         case IOMMU_MMIO_OFF_CTRL:
    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);
    2204         case IOMMU_MMIO_OFF_HW_EVT_STATUS:
    2205 
    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);
     2230        case IOMMU_MMIO_OFF_DEV_TAB_BAR:         return iommuAmdDevTabBar_w(pDevIns, pThis, off, uValue);
     2231        case IOMMU_MMIO_OFF_CMD_BUF_BAR:         return iommuAmdCmdBufBar_w(pDevIns, pThis, off, uValue);
     2232        case IOMMU_MMIO_OFF_EVT_LOG_BAR:         return iommuAmdEvtLogBar_w(pDevIns, pThis, off, uValue);
     2233        case IOMMU_MMIO_OFF_CTRL:                /** @todo IOMMU: Control register. */
     2234        case IOMMU_MMIO_OFF_EXCL_BAR:            return iommuAmdExclRangeBar_w(pDevIns, pThis, off, uValue);
     2235        case IOMMU_MMIO_OFF_EXCL_RANGE_LIMIT:    return iommuAmdExclRangeLimit_w(pDevIns, pThis, off, uValue);
     2236        case IOMMU_MMIO_OFF_EXT_FEAT:            return iommuAmdIgnore_w(pDevIns, pThis, off, uValue);
     2237
     2238        case IOMMU_MMIO_OFF_PPR_LOG_BAR:         return iommuAmdPprLogBar_w(pDevIns, pThis, off, uValue);
     2239        case IOMMU_MMIO_OFF_HW_EVT_HI:
     2240        case IOMMU_MMIO_OFF_HW_EVT_LO:           return iommuAmdIgnore_w(pDevIns, pThis, off, uValue);
     2241        case IOMMU_MMIO_OFF_HW_EVT_STATUS:       /** @todo IOMMU: HW Event Status is RW. Figure this out later. */
     2242
     2243        case IOMMU_MMIO_OFF_GALOG_BAR:
     2244        case IOMMU_MMIO_OFF_GALOG_TAIL_ADDR:     return iommuAmdIgnore_w(pDevIns, pThis, off, uValue);
     2245
     2246        case IOMMU_MMIO_OFF_PPR_LOG_B_BAR:
     2247        case IOMMU_MMIO_OFF_PPR_EVT_B_BAR:       return iommuAmdIgnore_w(pDevIns, pThis, off, uValue);
    22112248
    22122249        case IOMMU_MMIO_OFF_DEV_TAB_SEG_FIRST:
     
    22202257        case IOMMU_MMIO_OFF_DEV_SPECIFIC_FEAT:
    22212258        case IOMMU_MMIO_OFF_DEV_SPECIFIC_CTRL:
    2222         case IOMMU_MMIO_OFF_DEV_SPECIFIC_STATUS:
     2259        case IOMMU_MMIO_OFF_DEV_SPECIFIC_STATUS: return iommuAmdIgnore_w(pDevIns, pThis, off, uValue);
    22232260
    22242261        case IOMMU_MMIO_OFF_MSI_VECTOR_0:
    2225         case IOMMU_MMIO_OFF_MSI_VECTOR_1:
     2262        case IOMMU_MMIO_OFF_MSI_VECTOR_1:        return iommuAmdIgnore_w(pDevIns, pThis, off, uValue);
    22262263        case IOMMU_MMIO_OFF_MSI_CAP_HDR:
    2227         case IOMMU_MMIO_OFF_MSI_ADDR_LO:
     2264        {
     2265            VBOXSTRICTRC rcStrict = iommuAmdIgnore_w(pDevIns, pThis, off, (uint32_t)uValue);
     2266            if (cb == 4 || RT_FAILURE(rcStrict))
     2267                return rcStrict;
     2268            uValue >>= 32;
     2269            RT_FALL_THRU();
     2270        }
     2271        case IOMMU_MMIO_OFF_MSI_ADDR_LO:         return iommuAmdMsiAddrLo_w(pDevIns, pThis, off, uValue);
    22282272        case IOMMU_MMIO_OFF_MSI_ADDR_HI:
    2229         case IOMMU_MMIO_OFF_MSI_DATA:
    2230         case IOMMU_MMIO_OFF_MSI_MAPPING_CAP_HDR:
    2231 
    2232         case IOMMU_MMIO_OFF_PERF_OPT_CTRL:
     2273        {
     2274            VBOXSTRICTRC rcStrict = iommuAmdMsiAddrHi_w(pDevIns, pThis, off, (uint32_t)uValue);
     2275            if (cb == 4 || RT_FAILURE(rcStrict))
     2276                return rcStrict;
     2277            uValue >>= 32;
     2278            RT_FALL_THRU();
     2279        }
     2280        case IOMMU_MMIO_OFF_MSI_DATA:            return iommuAmdMsiData_w(pDevIns, pThis, off, uValue);
     2281        case IOMMU_MMIO_OFF_MSI_MAPPING_CAP_HDR: return iommuAmdIgnore_w(pDevIns, pThis, off, uValue);
     2282
     2283        case IOMMU_MMIO_OFF_PERF_OPT_CTRL:       return iommuAmdIgnore_w(pDevIns, pThis, off, uValue);
    22332284
    22342285        case IOMMU_MMIO_OFF_XT_GEN_INTR_CTRL:
    22352286        case IOMMU_MMIO_OFF_XT_PPR_INTR_CTRL:
    2236         case IOMMU_MMIO_OFF_XT_GALOG_INT_CTRL:
     2287        case IOMMU_MMIO_OFF_XT_GALOG_INT_CTRL:   return iommuAmdIgnore_w(pDevIns, pThis, off, uValue);
    22372288
    22382289        case IOMMU_MMIO_OFF_MARC_APER_BAR_0:
     
    22472298        case IOMMU_MMIO_OFF_MARC_APER_BAR_3:
    22482299        case IOMMU_MMIO_OFF_MARC_APER_RELOC_3:
    2249         case IOMMU_MMIO_OFF_MARC_APER_LEN_3:
    2250 
    2251         case IOMMU_MMIO_OFF_RSVD_REG:
     2300        case IOMMU_MMIO_OFF_MARC_APER_LEN_3:     return iommuAmdIgnore_w(pDevIns, pThis, off, uValue);
     2301
     2302        case IOMMU_MMIO_OFF_RSVD_REG:            return iommuAmdIgnore_w(pDevIns, pThis, off, uValue);
    22522303
    22532304        case IOMMU_MMIO_CMD_BUF_HEAD_PTR:
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