VirtualBox

Ignore:
Timestamp:
Apr 24, 2020 2:55:49 PM (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

    r83959 r83968  
    416416    } while (0)
    417417
     418/**
     419 * Gets the device table size given the size field.
     420 */
     421#define IOMMU_GET_DEV_TAB_SIZE(a_uSize)     (((a_uSize) + 1) << X86_PAGE_4K_SHIFT)
    418422
    419423/*********************************************************************************************************************************
     
    10631067    struct
    10641068    {
    1065         RT_GCC_EXTENSION uint64_t   u9Size : 9;             /**< Bits 8:0   - Size: Size of the device table. */
    1066         RT_GCC_EXTENSION uint64_t   u3Rsvd0 : 3;            /**< Bits 11:9  - Reserved. */
    1067         RT_GCC_EXTENSION uint64_t   u40DevTabBase : 40;     /**< Bits 51:12 - DevTabBase: Device table base address. */
    1068         RT_GCC_EXTENSION uint64_t   u12Rsvd0 : 12;          /**< Bits 63:52 - Reserved. */
     1069        RT_GCC_EXTENSION uint64_t   u9Size : 9;     /**< Bits 8:0   - Size: Size of the device table. */
     1070        RT_GCC_EXTENSION uint64_t   u3Rsvd0 : 3;    /**< Bits 11:9  - Reserved. */
     1071        RT_GCC_EXTENSION uint64_t   u40Base : 40;   /**< Bits 51:12 - DevTabBase: Device table base address. */
     1072        RT_GCC_EXTENSION uint64_t   u12Rsvd0 : 12;  /**< Bits 63:52 - Reserved. */
    10691073    } n;
    10701074    /** The 64-bit unsigned integer view. */
     
    10831087    {
    10841088        RT_GCC_EXTENSION uint64_t   u12Rsvd0 : 12;      /**< Bits 11:0  - Reserved. */
    1085         RT_GCC_EXTENSION uint64_t   u40CmdBase : 40;    /**< Bits 51:12 - ComBase: Command buffer base address. */
     1089        RT_GCC_EXTENSION uint64_t   u40Base : 40;       /**< Bits 51:12 - ComBase: Command buffer base address. */
    10861090        RT_GCC_EXTENSION uint64_t   u4Rsvd0 : 4;        /**< Bits 55:52 - Reserved. */
    1087         RT_GCC_EXTENSION uint64_t   u4CmdLen : 4;       /**< Bits 59:56 - ComLen: Command buffer length. */
     1091        RT_GCC_EXTENSION uint64_t   u4Len : 4;          /**< Bits 59:56 - ComLen: Command buffer length. */
    10881092        RT_GCC_EXTENSION uint64_t   u4Rsvd1 : 4;        /**< Bits 63:60 - Reserved. */
    10891093    } n;
     
    11031107    {
    11041108        RT_GCC_EXTENSION uint64_t   u12Rsvd0 : 12;      /**< Bits 11:0  - Reserved. */
    1105         RT_GCC_EXTENSION uint64_t   u40EvtBase : 40;    /**< Bits 51:12 - EventBase: Event log base address. */
     1109        RT_GCC_EXTENSION uint64_t   u40Base : 40;       /**< Bits 51:12 - EventBase: Event log base address. */
    11061110        RT_GCC_EXTENSION uint64_t   u4Rsvd0 : 4;        /**< Bits 55:52 - Reserved. */
    1107         RT_GCC_EXTENSION uint64_t   u4EvtLen : 4;       /**< Bits 59:56 - EventLen: Event log length. */
     1111        RT_GCC_EXTENSION uint64_t   u4Len : 4;          /**< Bits 59:56 - EventLen: Event log length. */
    11081112        RT_GCC_EXTENSION uint64_t   u4Rsvd1 : 4;        /**< Bits 63:60 - Reserved. */
    11091113    } n;
     
    12721276    {
    12731277        RT_GCC_EXTENSION uint64_t   u12Rsvd0 : 12;      /**< Bit 11:0   - Reserved. */
    1274         RT_GCC_EXTENSION uint64_t   u40PprLogBase : 40; /**< Bits 51:12 - PPRLogBase: Peripheral Page Request Log Base Address. */
     1278        RT_GCC_EXTENSION uint64_t   u40Base : 40;      /**< Bits 51:12 - PPRLogBase: Peripheral Page Request Log Base Address. */
    12751279        RT_GCC_EXTENSION uint64_t   u4Rsvd0 : 4;        /**< Bits 55:52 - Reserved. */
    1276         RT_GCC_EXTENSION uint64_t   u4PprLogLen : 4;    /**< Bits 59:56 - PPRLogLen: Peripheral Page Request Log Length. */
     1280        RT_GCC_EXTENSION uint64_t   u4Len : 4;          /**< Bits 59:56 - PPRLogLen: Peripheral Page Request Log Length. */
    12771281        RT_GCC_EXTENSION uint64_t   u4Rsvd1 : 4;        /**< Bits 63:60 - Reserved. */
    12781282    } n;
     
    13321336    struct
    13331337    {
    1334         RT_GCC_EXTENSION uint64_t   u12Rsvd0 : 12;      /**< Bit 11:0   - Reserved. */
    1335         RT_GCC_EXTENSION uint64_t   u40GALogBase : 40;  /**< Bits 51:12 - GALogBase: Guest Virtual-APIC Log Base Address. */
    1336         RT_GCC_EXTENSION uint64_t   u4Rsvd0 : 4;        /**< Bits 55:52 - Reserved. */
    1337         RT_GCC_EXTENSION uint64_t   u4GALogLen : 4;     /**< Bits 59:56 - GALogLen: Guest Virtual-APIC Log Length. */
    1338         RT_GCC_EXTENSION uint64_t   u4Rsvd1 : 4;        /**< Bits 63:60 - Reserved. */
     1338        RT_GCC_EXTENSION uint64_t   u12Rsvd0 : 12;  /**< Bit 11:0   - Reserved. */
     1339        RT_GCC_EXTENSION uint64_t   u40Base : 40;   /**< Bits 51:12 - GALogBase: Guest Virtual-APIC Log Base Address. */
     1340        RT_GCC_EXTENSION uint64_t   u4Rsvd0 : 4;    /**< Bits 55:52 - Reserved. */
     1341        RT_GCC_EXTENSION uint64_t   u4Len : 4;      /**< Bits 59:56 - GALogLen: Guest Virtual-APIC Log Length. */
     1342        RT_GCC_EXTENSION uint64_t   u4Rsvd1 : 4;    /**< Bits 63:60 - Reserved. */
    13391343    } n;
    13401344    /** The 64-bit unsigned integer view. */
     
    13821386    struct
    13831387    {
    1384         RT_GCC_EXTENSION uint64_t   u8Size : 8;             /**< Bits 7:0   - Size: Size of the Device Table segment. */
    1385         RT_GCC_EXTENSION uint64_t   u4Rsvd0 : 4;            /**< Bits 11:8  - Reserved. */
    1386         RT_GCC_EXTENSION uint64_t   u40DevTabBase : 40;     /**< Bits 51:12 - DevTabBase: Device Table Segment Base Address. */
    1387         RT_GCC_EXTENSION uint64_t   u12Rsvd0 : 12;          /**< Bits 63:52 - Reserved. */
     1388        RT_GCC_EXTENSION uint64_t   u8Size : 8;     /**< Bits 7:0   - Size: Size of the Device Table segment. */
     1389        RT_GCC_EXTENSION uint64_t   u4Rsvd0 : 4;    /**< Bits 11:8  - Reserved. */
     1390        RT_GCC_EXTENSION uint64_t   u40Base : 40;   /**< Bits 51:12 - DevTabBase: Device Table Segment Base Address. */
     1391        RT_GCC_EXTENSION uint64_t   u12Rsvd0 : 12;  /**< Bits 63:52 - Reserved. */
    13881392    } n;
    13891393    /** The 64-bit unsigned integer view. */
     
    21082112 * Indexed by u2DevTabSegSup.
    21092113 */
    2110 static uint8_t const g_aDevTabSegments[] = { 0, 2, 4, 8 };
     2114static uint8_t const g_acDevTabSegs[] = { 0, 2, 4, 8 };
    21112115
    21122116/**
     
    21142118 * Indexed by the device table segment index.
    21152119 */
    2116 static uint16_t const g_aDevTabSegmentSizes[] = { 0x1ff, 0xff, 0x7f, 0x7f, 0x3f, 0x3f, 0x3f, 0x3f };
     2120static uint16_t const g_auDevTabSegSizes[] = { 0x1ff, 0xff, 0x7f, 0x7f, 0x3f, 0x3f, 0x3f, 0x3f };
    21172121
    21182122
     
    21582162
    21592163
    2160 /**
    2161  * Logs if the buffer length is invalid.
    2162  *
    2163  * @param   uEncodedLen     The length to decode.
    2164  * @param   pszFunc         Name of the calling function for logging purposes.
    2165  */
    2166 DECLINLINE(void) iommuAmdCheckBufferLength(uint8_t uEncodedLen, const char *pszFunc)
    2167 {
    2168 #ifdef VBOX_STRICT
    2169     uint32_t cEntries;
    2170     iommuAmdGetBaseBufferLength(uEncodedLen, &cEntries, NULL /* pcbBuffer */);
    2171     if (!cEntries)
    2172         Log((IOMMU_LOG_PFX ": %s: Invalid length %#x\n", pszFunc, uEncodedLen));
    2173 #else
    2174     RT_NOREF(uEncodedLen, pszFunc);
    2175 #endif
     2164DECL_FORCE_INLINE(IOMMU_CTRL_T) iommuAmdGetCtrl(PCIOMMU pThis)
     2165{
     2166    IOMMU_CTRL_T Ctrl;
     2167    Ctrl.u64 = ASMAtomicReadU64((volatile uint64_t *)&pThis->Ctrl.u64);
     2168    return Ctrl;
    21762169}
    21772170
     
    21942187{
    21952188    RT_NOREF(pDevIns, iReg);
    2196     pThis->DevTabBaseAddr.u64 = u64Value & IOMMU_DEV_TAB_BAR_VALID_MASK;
     2189
     2190    /* Mask out all unrecognized bits. */
     2191    u64Value &= IOMMU_DEV_TAB_BAR_VALID_MASK;
     2192    DEV_TAB_BAR_T DevTabBaseAddr;
     2193    DevTabBaseAddr.u64 = u64Value;
     2194
     2195    /* Validate the base address. */
     2196    RTGCPHYS const GCPhysDevTab = DevTabBaseAddr.n.u40Base;
     2197    if (!(GCPhysDevTab & X86_PAGE_4K_OFFSET_MASK))
     2198        pThis->DevTabBaseAddr.u64 = DevTabBaseAddr.u64;
     2199    else
     2200        Log((IOMMU_LOG_PFX ": Device table base address (%#RX64) misaligned -> Ignored\n", GCPhysDevTab));
    21972201    return VINF_SUCCESS;
    21982202}
     
    22052209{
    22062210    RT_NOREF(pDevIns, iReg);
    2207     pThis->CmdBufBaseAddr.u64 = u64Value & IOMMU_CMD_BUF_BAR_VALID_MASK;
    2208     iommuAmdCheckBufferLength(pThis->CmdBufBaseAddr.n.u4CmdLen, __PRETTY_FUNCTION__);
    22092211
    22102212    /*
     
    22202222    }
    22212223
     2224    /* Mask out all unrecognized bits. */
     2225    CMD_BUF_BAR_T CmdBufBaseAddr;
     2226    CmdBufBaseAddr.u64 = u64Value & IOMMU_CMD_BUF_BAR_VALID_MASK;
     2227
     2228    /* Validate the base address. */
     2229    RTGCPHYS const GCPhysCmdBuf = CmdBufBaseAddr.n.u40Base;
     2230    if (!(GCPhysCmdBuf & X86_PAGE_4K_OFFSET_MASK))
     2231    {
     2232        /* Validate the length. */
     2233        if (CmdBufBaseAddr.n.u4Len >= 8)
     2234            pThis->CmdBufBaseAddr.u64 = CmdBufBaseAddr.u64;
     2235        else
     2236            Log((IOMMU_LOG_PFX ": Command buffer length (%#x) invalid -> Ignored\n", CmdBufBaseAddr.n.u4Len));
     2237    }
     2238    else
     2239        Log((IOMMU_LOG_PFX ": Command buffer base address (%#RX64) misaligned -> Ignored\n", CmdBufBaseAddr.n.u40Base));
     2240
    22222241    /*
    22232242     * Writing the command log base address, clears the command buffer head and tail pointers.
     
    22502269    }
    22512270
    2252     pThis->EvtLogBaseAddr.u64 = u64Value & IOMMU_EVT_LOG_BAR_VALID_MASK;
    2253     iommuAmdCheckBufferLength(pThis->EvtLogBaseAddr.n.u4EvtLen, __PRETTY_FUNCTION__);
     2271    /* Mask out all unrecognized bits. */
     2272    u64Value &= IOMMU_EVT_LOG_BAR_VALID_MASK;
     2273    EVT_LOG_BAR_T EvtLogBaseAddr;
     2274    EvtLogBaseAddr.u64 = u64Value;
     2275
     2276    /* Validate the base address. */
     2277    RTGCPHYS const GCPhysEvtLog = EvtLogBaseAddr.n.u40Base;
     2278    if (!(GCPhysEvtLog & X86_PAGE_4K_OFFSET_MASK))
     2279    {
     2280        /* Validate the length. */
     2281        if (EvtLogBaseAddr.n.u4Len >= 8)
     2282            pThis->EvtLogBaseAddr.u64 = EvtLogBaseAddr.u64;
     2283        else
     2284            Log((IOMMU_LOG_PFX ": Event log length (%#x) invalid -> Ignored\n", EvtLogBaseAddr.n.u4Len));
     2285    }
     2286    else
     2287        Log((IOMMU_LOG_PFX ": Event log base address (%#RX64) misaligned -> Ignored\n", EvtLogBaseAddr.n.u40Base));
    22542288
    22552289    /*
     
    22922326{
    22932327    RT_NOREF(pDevIns, iReg);
    2294     pThis->PprLogBaseAddr.u64 = u64Value & IOMMU_PPR_LOG_BAR_VALID_MASK;
    2295     iommuAmdCheckBufferLength(pThis->PprLogBaseAddr.n.u4PprLogLen, __PRETTY_FUNCTION__);
     2328
     2329    /*
     2330     * IOMMU behavior is undefined when software writes this register when PPR logging is running.
     2331     * In our emulation, we ignore the write entirely.
     2332     * See AMD IOMMU spec. 3.3.2 "PPR Log Registers".
     2333     */
     2334    IOMMU_STATUS_T const Status = iommuAmdGetStatus(pThis);
     2335    if (Status.n.u1PprLogRunning)
     2336    {
     2337        Log((IOMMU_LOG_PFX ": Setting PprLogBar (%#RX64) when PPR logging is running -> Ignored\n", u64Value));
     2338        return VINF_SUCCESS;
     2339    }
     2340
     2341    /* Mask out all unrecognized bits. */
     2342    u64Value &= IOMMU_PPR_LOG_BAR_VALID_MASK;
     2343    PPR_LOG_BAR_T PprLogBaseAddr;
     2344    PprLogBaseAddr.u64 = u64Value;
     2345
     2346    /* Validate the base address. */
     2347    RTGCPHYS const GCPhysPprLog = PprLogBaseAddr.n.u40Base;
     2348    if (!(GCPhysPprLog & X86_PAGE_4K_OFFSET_MASK))
     2349    {
     2350        /* Validate the length. */
     2351        if (PprLogBaseAddr.n.u4Len >= 8)
     2352            pThis->PprLogBaseAddr.u64 = PprLogBaseAddr.u64;
     2353        else
     2354            Log((IOMMU_LOG_PFX ": PPR log length (%#x) invalid -> Ignored\n", PprLogBaseAddr.n.u4Len));
     2355    }
     2356    else
     2357        Log((IOMMU_LOG_PFX ": PPR log base address (%#RX64) misaligned -> Ignored\n", PprLogBaseAddr.n.u40Base));
     2358
     2359    /*
     2360     * Writing the event log base address, clears the PPR log head and tail pointers.
     2361     * See AMD spec. 2.6 "Peripheral Page Request (PPR) Logging"
     2362     */
     2363    pThis->PprLogHeadPtr.u64 = 0;
     2364    pThis->PprLogTailPtr.u64 = 0;
     2365
    22962366    return VINF_SUCCESS;
    22972367}
     
    23602430    /* Figure out which segment is being written. */
    23612431    uint8_t const idxDevTabSeg = (iReg - IOMMU_MMIO_OFF_DEV_TAB_SEG_FIRST) >> 3;
     2432    uint8_t const idxSegment   = idxDevTabSeg + 1;
    23622433    Assert(idxDevTabSeg < RT_ELEMENTS(pThis->DevTabSeg));
    23632434
    23642435    /* Mask out all unrecognized bits. */
    23652436    u64Value &= IOMMU_DEV_TAB_SEG_BAR_VALID_MASK;
    2366     uint8_t const cbSegSize = u64Value & UINT64_C(0xff);
    2367 
    2368     /* Validate the size and write the register. */
    2369     uint8_t const  idxSegment   = idxDevTabSeg + 1;
    2370     uint16_t const cbMaxSegSize = g_aDevTabSegmentSizes[idxSegment];
    2371     if (cbSegSize <= cbMaxSegSize)
    2372         pThis->DevTabSeg[idxDevTabSeg].u64 = u64Value;
     2437    DEV_TAB_SEG_BAR_T DevTabSegBar;
     2438    DevTabSegBar.u64 = u64Value;
     2439
     2440    /* Validate the base address. */
     2441    RTGCPHYS const GCPhysDevTab = DevTabSegBar.n.u40Base;
     2442    if (!(GCPhysDevTab & X86_PAGE_4K_OFFSET_MASK))
     2443    {
     2444        /* Validate the size. */
     2445        uint16_t const uSegSize    = DevTabSegBar.n.u8Size;
     2446        uint16_t const uMaxSegSize = g_auDevTabSegSizes[idxSegment];
     2447        if (uSegSize <= uMaxSegSize)
     2448        {
     2449            /* Finally, update the segment register. */
     2450            pThis->DevTabSeg[idxDevTabSeg].u64 = u64Value;
     2451        }
     2452        else
     2453            Log((IOMMU_LOG_PFX ": Device table segment (%u) size invalid (%#RX32) -> Ignored\n", idxSegment, uSegSize));
     2454    }
    23732455    else
    2374         Log((IOMMU_LOG_PFX ": Setting device table segment %u with invalid size (%#RX32) -> Ignored\n", idxSegment, cbSegSize));
     2456        Log((IOMMU_LOG_PFX ": Device table segment (%u) address misaligned (%#RX64) -> Ignored\n", idxSegment, GCPhysDevTab));
    23752457
    23762458    return VINF_SUCCESS;
     
    24452527    CMD_BUF_BAR_T const CmdBufBar  = pThis->CmdBufBaseAddr;
    24462528    uint32_t            cbBuf;
    2447     iommuAmdGetBaseBufferLength(CmdBufBar.n.u4CmdLen, NULL, &cbBuf);
     2529    iommuAmdGetBaseBufferLength(CmdBufBar.n.u4Len, NULL, &cbBuf);
    24482530    if (offBuf >= cbBuf)
    24492531    {
     
    25242606static DECLCALLBACK(int) iommuAmdR3CmdThreadWakeUp(PPDMDEVINS pDevIns, PPDMTHREAD pThread)
    25252607{
    2526     NOREF(pThread);
     2608    RT_NOREF(pThread);
    25272609    PIOMMU pThis = PDMDEVINS_2_DATA(pDevIns, PIOMMU);
    25282610    return PDMDevHlpSUPSemEventSignal(pDevIns, pThis->hEvtCmdThread);
     
    25632645
    25642646    PIOMMU pThis = PDMDEVINS_2_DATA(pDevIns, PIOMMU);
    2565     Assert(pThis);
    2566 
    25672647    switch (off)
    25682648    {
     
    27042784    Assert(!(off & 7) || !(off & 3));
    27052785
     2786    PIOMMU     pThis = PDMDEVINS_2_DATA(pDevIns, PIOMMU);
    27062787    PPDMPCIDEV pPciDev = pDevIns->apPciDevs[0];
    27072788    PDMPCIDEV_ASSERT_VALID(pDevIns, pPciDev);
    2708 
    2709     PIOMMU pThis = PDMDEVINS_2_DATA(pDevIns, PIOMMU);
    2710     Assert(pThis);
    27112789
    27122790    /** @todo IOMMU: fine-grained locking? */
     
    28592937 * @param   pvBuf       Where to store the device table segment.
    28602938 * @param   cbBuf       The size of the buffer in bytes.
     2939 *
     2940 * @thread  Any.
    28612941 */
    28622942static int iommuAmdReadDeviceTableSegment(PPDMDEVINS pDevIns, uint8_t idxSeg, void *pvBuf, uint32_t cbBuf)
    28632943{
    28642944    PIOMMU pThis = PDMDEVINS_2_DATA(pDevIns, PIOMMU);
    2865     Assert(pThis);
    28662945
    28672946    /* Validate. */
     
    28692948    Assert(cbBuf <= _2M);
    28702949    Assert(!idxSeg || pThis->ExtFeat.n.u2DevTabSegSup);
    2871     Assert(!idxSeg || idxSeg < g_aDevTabSegments[pThis->ExtFeat.n.u2DevTabSegSup]);
     2950    Assert(!idxSeg || idxSeg < g_acDevTabSegs[pThis->ExtFeat.n.u2DevTabSegSup]);
    28722951
    28732952    /* Get the base address and size of the segment. */
     
    28762955    if (!idxSeg)
    28772956    {
    2878         GCPhysDevTab = pThis->DevTabBaseAddr.n.u40DevTabBase;
    2879         cbDevTab     = pThis->DevTabBaseAddr.n.u9Size;
     2957        GCPhysDevTab = pThis->DevTabBaseAddr.n.u40Base;
     2958        cbDevTab     = IOMMU_GET_DEV_TAB_SIZE(pThis->DevTabBaseAddr.n.u9Size);
    28802959    }
    28812960    else
    28822961    {
    2883         GCPhysDevTab = pThis->DevTabSeg[idxSeg].n.u40DevTabBase;
    2884         cbDevTab     = pThis->DevTabSeg[idxSeg].n.u8Size;
     2962        GCPhysDevTab = pThis->DevTabSeg[idxSeg].n.u40Base;
     2963        cbDevTab     = IOMMU_GET_DEV_TAB_SIZE(pThis->DevTabSeg[idxSeg].n.u8Size);
    28852964    }
    28862965
     
    29012980
    29022981/**
    2903  * Memory read transaction from a downstream device.
     2982 * Calculates and returns the total size of the device table.
     2983 * This includes device table segments if they are used.
     2984 *
     2985 * @returns The size of the device table in bytes.
     2986 * @param   pDevIns     The IOMMU device instance.
     2987 *
     2988 * @thread  Any.
     2989 */
     2990static uint32_t iommuAmdCalcTotalDevTabSize(PPDMDEVINS pDevIns)
     2991{
     2992    PCIOMMU pThis = PDMDEVINS_2_DATA(pDevIns, PIOMMU);
     2993    IOMMU_CTRL_T const Ctrl = iommuAmdGetCtrl(pThis);
     2994
     2995    /* The base address register always exists. */
     2996    uint32_t cbDevTabSize = IOMMU_GET_DEV_TAB_SIZE(pThis->DevTabBaseAddr.n.u9Size);
     2997
     2998    /* If segmentation is enabled, add the size of each segments. */
     2999    uint8_t const uSegmentsEnabled = Ctrl.n.u3DevTabSegEn;
     3000    if (uSegmentsEnabled)
     3001    {
     3002        Assert(uSegmentsEnabled < RT_ELEMENTS(g_acDevTabSegs));
     3003        uint8_t const cSegments = g_acDevTabSegs[uSegmentsEnabled] - 1;
     3004        for (uint8_t idxSegment = 0; idxSegment < cSegments - 1; idxSegment++)
     3005            cbDevTabSize += IOMMU_GET_DEV_TAB_SIZE(pThis->DevTabSeg[idxSegment].n.u8Size);
     3006    }
     3007
     3008    return cbDevTabSize;
     3009}
     3010
     3011
     3012/**
     3013 * Memory read transaction from a device.
    29043014 *
    29053015 * @returns VBox status code.
     
    29203030
    29213031/**
    2922  * Memory write transaction from a downstream device.
     3032 * Memory write transaction from a device.
    29233033 *
    29243034 * @returns VBox status code.
     
    29943104{
    29953105    PIOMMU pThis = PDMDEVINS_2_DATA(pDevIns, PIOMMU);
    2996     Assert(pThis);
    29973106
    29983107    /*
     
    30763185static DECLCALLBACK(void) iommuAmdR3DbgInfo(PPDMDEVINS pDevIns, PCDBGFINFOHLP pHlp, const char *pszArgs)
    30773186{
     3187    PCIOMMU    pThis   = PDMDEVINS_2_DATA(pDevIns, PIOMMU);
    30783188    PPDMPCIDEV pPciDev = pDevIns->apPciDevs[0];
    30793189    PDMPCIDEV_ASSERT_VALID(pDevIns, pPciDev);
    3080 
    3081     PCIOMMU pThis = PDMDEVINS_2_DATA(pDevIns, PIOMMU);
    3082     Assert(pThis);
    30833190
    30843191    LogFlow((IOMMU_LOG_PFX ": %s: pThis=%p pszArgs=%s\n", __PRETTY_FUNCTION__, pThis, pszArgs));
     
    30923199        if (fVerbose)
    30933200        {
    3094             pHlp->pfnPrintf(pHlp, "    Size                                    = %u (%u bytes)\n", DevTabBar.n.u9Size,
    3095                         (DevTabBar.n.u9Size + 1) * _4K);
    3096             pHlp->pfnPrintf(pHlp, "    Base address                            = %#RX64\n", DevTabBar.n.u40DevTabBase);
     3201            pHlp->pfnPrintf(pHlp, "    Size                                    = %#x (%u bytes)\n", DevTabBar.n.u9Size,
     3202                            IOMMU_GET_DEV_TAB_SIZE(DevTabBar.n.u9Size));
     3203            pHlp->pfnPrintf(pHlp, "    Base address                            = %#RX64\n", DevTabBar.n.u40Base);
    30973204        }
    30983205    }
     
    31023209        uint32_t      cEntries;
    31033210        uint32_t      cbBuffer;
    3104         uint8_t const uEncodedLen = CmdBufBar.n.u4CmdLen;
     3211        uint8_t const uEncodedLen = CmdBufBar.n.u4Len;
    31053212        iommuAmdGetBaseBufferLength(uEncodedLen, &cEntries, &cbBuffer);
    31063213        pHlp->pfnPrintf(pHlp, "  Command buffer BAR                      = %#RX64\n", CmdBufBar.u64);
    31073214        if (fVerbose)
    31083215        {
    3109             pHlp->pfnPrintf(pHlp, "    Base address                            = %#RX64\n", CmdBufBar.n.u40CmdBase);
     3216            pHlp->pfnPrintf(pHlp, "    Base address                            = %#RX64\n", CmdBufBar.n.u40Base);
    31103217            pHlp->pfnPrintf(pHlp, "    Length                                  = %u (%u entries, %u bytes)\n", uEncodedLen,
    31113218                            cEntries, cbBuffer);
     
    31173224        uint32_t      cEntries;
    31183225        uint32_t      cbBuffer;
    3119         uint8_t const uEncodedLen = EvtLogBar.n.u4EvtLen;
     3226        uint8_t const uEncodedLen = EvtLogBar.n.u4Len;
    31203227        iommuAmdGetBaseBufferLength(uEncodedLen, &cEntries, &cbBuffer);
    31213228        pHlp->pfnPrintf(pHlp, "  Event log BAR                           = %#RX64\n", EvtLogBar.u64);
    31223229        if (fVerbose)
    31233230        {
    3124             pHlp->pfnPrintf(pHlp, "    Base address                            = %#RX64\n", EvtLogBar.n.u40EvtBase);
     3231            pHlp->pfnPrintf(pHlp, "    Base address                            = %#RX64\n", EvtLogBar.n.u40Base);
    31253232            pHlp->pfnPrintf(pHlp, "    Length                                  = %u (%u entries, %u bytes)\n", uEncodedLen,
    31263233                            cEntries, cbBuffer);
     
    32173324            pHlp->pfnPrintf(pHlp, "    User/supervisor page protection support = %RTbool\n",  ExtFeat.n.u1UserSupervisorSup);
    32183325            pHlp->pfnPrintf(pHlp, "    Device table segments supported         = %#x (%u)\n", ExtFeat.n.u2DevTabSegSup,
    3219                             g_aDevTabSegments[ExtFeat.n.u2DevTabSegSup]);
     3326                            g_acDevTabSegs[ExtFeat.n.u2DevTabSegSup]);
    32203327            pHlp->pfnPrintf(pHlp, "    PPR log overflow early warning support  = %RTbool\n",  ExtFeat.n.u1PprLogOverflowWarn);
    32213328            pHlp->pfnPrintf(pHlp, "    PPR auto response support               = %RTbool\n",  ExtFeat.n.u1PprAutoRespSup);
     
    32393346        uint32_t      cEntries;
    32403347        uint32_t      cbBuffer;
    3241         uint8_t const uEncodedLen = PprLogBar.n.u4PprLogLen;
     3348        uint8_t const uEncodedLen = PprLogBar.n.u4Len;
    32423349        iommuAmdGetBaseBufferLength(uEncodedLen, &cEntries, &cbBuffer);
    32433350        pHlp->pfnPrintf(pHlp, "  PPR Log BAR                             = %#RX64\n",   PprLogBar.u64);
    32443351        if (fVerbose)
    32453352        {
    3246             pHlp->pfnPrintf(pHlp, "    Base address                            = %#RX64\n", PprLogBar.n.u40PprLogBase);
     3353            pHlp->pfnPrintf(pHlp, "    Base address                            = %#RX64\n", PprLogBar.n.u40Base);
    32473354            pHlp->pfnPrintf(pHlp, "    Length                                  = %u (%u entries, %u bytes)\n", uEncodedLen,
    32483355                            cEntries, cbBuffer);
     
    32763383        uint32_t      cEntries;
    32773384        uint32_t      cbBuffer;
    3278         uint8_t const uEncodedLen = GALogBar.n.u4GALogLen;
     3385        uint8_t const uEncodedLen = GALogBar.n.u4Len;
    32793386        iommuAmdGetBaseBufferLength(uEncodedLen, &cEntries, &cbBuffer);
    32803387        pHlp->pfnPrintf(pHlp, "  Guest Log BAR                           = %#RX64\n",    GALogBar.u64);
    32813388        if (fVerbose)
    32823389        {
    3283             pHlp->pfnPrintf(pHlp, "    Base address                            = %RTbool\n", GALogBar.n.u40GALogBase);
     3390            pHlp->pfnPrintf(pHlp, "    Base address                            = %RTbool\n", GALogBar.n.u40Base);
    32843391            pHlp->pfnPrintf(pHlp, "    Length                                  = %u (%u entries, %u bytes)\n", uEncodedLen,
    32853392                            cEntries, cbBuffer);
     
    32983405        uint32_t      cEntries;
    32993406        uint32_t      cbBuffer;
    3300         uint8_t const uEncodedLen = PprLogBBar.n.u4PprLogLen;
     3407        uint8_t const uEncodedLen = PprLogBBar.n.u4Len;
    33013408        iommuAmdGetBaseBufferLength(uEncodedLen, &cEntries, &cbBuffer);
    33023409        pHlp->pfnPrintf(pHlp, "  PPR Log B BAR                           = %#RX64\n",   PprLogBBar.u64);
    33033410        if (fVerbose)
    33043411        {
    3305             pHlp->pfnPrintf(pHlp, "    Base address                            = %#RX64\n", PprLogBBar.n.u40PprLogBase);
     3412            pHlp->pfnPrintf(pHlp, "    Base address                            = %#RX64\n", PprLogBBar.n.u40Base);
    33063413            pHlp->pfnPrintf(pHlp, "    Length                                  = %u (%u entries, %u bytes)\n", uEncodedLen,
    33073414                            cEntries, cbBuffer);
     
    33133420        uint32_t      cEntries;
    33143421        uint32_t      cbBuffer;
    3315         uint8_t const uEncodedLen = EvtLogBBar.n.u4EvtLen;
     3422        uint8_t const uEncodedLen = EvtLogBBar.n.u4Len;
    33163423        iommuAmdGetBaseBufferLength(uEncodedLen, &cEntries, &cbBuffer);
    33173424        pHlp->pfnPrintf(pHlp, "  Event Log B BAR                         = %#RX64\n",   EvtLogBBar.u64);
    33183425        if (fVerbose)
    33193426        {
    3320             pHlp->pfnPrintf(pHlp, "    Base address                            = %#RX64\n", EvtLogBBar.n.u40EvtBase);
     3427            pHlp->pfnPrintf(pHlp, "    Base address                            = %#RX64\n", EvtLogBBar.n.u40Base);
    33213428            pHlp->pfnPrintf(pHlp, "    Length                                  = %u (%u entries, %u bytes)\n", uEncodedLen,
    33223429                            cEntries, cbBuffer);
     
    33303437        if (fVerbose)
    33313438        {
    3332             pHlp->pfnPrintf(pHlp, "    Base address                            = %#RX64\n", DevTabSeg.n.u40DevTabBase);
     3439            pHlp->pfnPrintf(pHlp, "    Base address                            = %#RX64\n", DevTabSeg.n.u40Base);
    33333440            pHlp->pfnPrintf(pHlp, "    Size                                    = %#x (%u bytes)\n", DevTabSeg.n.u8Size,
    3334                             (DevTabSeg.n.u8Size + 1) << X86_PAGE_4K_SHIFT);
     3441                            IOMMU_GET_DEV_TAB_SIZE(DevTabSeg.n.u8Size));
    33353442        }
    33363443    }
     
    36633770     * device construction and remain read-only through the lifetime of the VM.
    36643771     */
    3665     PIOMMU pThis = PDMDEVINS_2_DATA(pDevIns, PIOMMU);
    3666     Assert(pThis);
    3667 
     3772    PIOMMU     pThis   = PDMDEVINS_2_DATA(pDevIns, PIOMMU);
    36683773    PPDMPCIDEV pPciDev = pDevIns->apPciDevs[0];
    36693774    PDMPCIDEV_ASSERT_VALID(pDevIns, pPciDev);
    36703775
    3671     pThis->DevTabBaseAddr.u64    = 0;
    3672     pThis->CmdBufBaseAddr.u64    = 0;
    3673     pThis->EvtLogBaseAddr.u64    = 0;
    3674     pThis->Ctrl.u64              = 0;
    3675     pThis->ExclRangeBaseAddr.u64 = 0;
    3676     pThis->ExclRangeLimit.u64    = 0;
     3776    pThis->DevTabBaseAddr.u64     = 0;
     3777
     3778    pThis->CmdBufBaseAddr.u64     = 0;
     3779    pThis->CmdBufBaseAddr.n.u4Len = 8;
     3780
     3781    pThis->EvtLogBaseAddr.u64     = 0;
     3782    pThis->EvtLogBaseAddr.n.u4Len = 8;
     3783
     3784    pThis->Ctrl.u64               = 0;
     3785
     3786    pThis->ExclRangeBaseAddr.u64  = 0;
     3787    pThis->ExclRangeLimit.u64     = 0;
     3788
    36773789    pThis->ExtFeat.n.u1PrefetchSup           = 0;
    36783790    pThis->ExtFeat.n.u1PprSup                = 0;
     
    36943806    pThis->ExtFeat.n.u5MaxPasidSup           = 0;   /* Requires GstTranslateSup. */
    36953807    pThis->ExtFeat.n.u1UserSupervisorSup     = 0;
    3696     AssertCompile(IOMMU_MAX_DEV_TAB_SEGMENTS < RT_ELEMENTS(g_aDevTabSegments));
     3808    AssertCompile(IOMMU_MAX_DEV_TAB_SEGMENTS < RT_ELEMENTS(g_acDevTabSegs));
    36973809    pThis->ExtFeat.n.u2DevTabSegSup          = IOMMU_MAX_DEV_TAB_SEGMENTS;
    36983810    pThis->ExtFeat.n.u1PprLogOverflowWarn    = 0;
     
    37103822    pThis->ExtFeat.n.u1GstUpdateDisSup       = 0;
    37113823    pThis->ExtFeat.n.u1ForcePhysDstSup       = 0;
    3712     pThis->PprLogBaseAddr.u64                = 0;
    3713     pThis->HwEvtHi.u64                       = 0;
    3714     pThis->HwEvtLo                           = 0;
    3715     pThis->HwEvtStatus.u64                   = 0;
    3716     pThis->GALogBaseAddr.n.u40GALogBase      = 0;
    3717     pThis->GALogBaseAddr.n.u4GALogLen        = 8;
    3718     pThis->GALogTailAddr.u64                 = 0;
    3719     pThis->PprLogBBaseAddr.n.u40PprLogBase   = 0;
    3720     pThis->PprLogBBaseAddr.n.u4PprLogLen     = 8;
    3721     pThis->EvtLogBBaseAddr.n.u40EvtBase      = 0;
    3722     pThis->EvtLogBBaseAddr.n.u4EvtLen        = 8;
     3824
     3825    pThis->PprLogBaseAddr.u64        = 0;
     3826    pThis->PprLogBaseAddr.n.u4Len    = 8;
     3827
     3828    pThis->HwEvtHi.u64               = 0;
     3829    pThis->HwEvtLo                   = 0;
     3830    pThis->HwEvtStatus.u64           = 0;
     3831
     3832    pThis->GALogBaseAddr.n.u40Base   = 0;
     3833    pThis->GALogBaseAddr.n.u4Len     = 8;
     3834    pThis->GALogTailAddr.u64         = 0;
     3835
     3836    pThis->PprLogBBaseAddr.n.u40Base = 0;
     3837    pThis->PprLogBBaseAddr.n.u4Len   = 8;
     3838    pThis->EvtLogBBaseAddr.n.u40Base = 0;
     3839    pThis->EvtLogBBaseAddr.n.u4Len   = 8;
     3840
    37233841    memset(&pThis->DevTabSeg[0], 0, sizeof(pThis->DevTabSeg));
    3724     pThis->DevSpecificFeat.u64               = 0;
    3725     pThis->DevSpecificCtrl.u64               = 0;
    3726     pThis->DevSpecificStatus.u64             = 0;
    3727     pThis->MsiMiscInfo.u64                   = 0;
    3728     pThis->PerfOptCtrl.u32                   = 0;
    3729     pThis->XtGenIntrCtrl.u64                 = 0;
    3730     pThis->XtPprIntrCtrl.u64                 = 0;
    3731     pThis->XtGALogIntrCtrl.u64               = 0;
     3842
     3843    pThis->DevSpecificFeat.u64       = 0;
     3844    pThis->DevSpecificCtrl.u64       = 0;
     3845    pThis->DevSpecificStatus.u64     = 0;
     3846
     3847    pThis->MsiMiscInfo.u64           = 0;
     3848    pThis->PerfOptCtrl.u32           = 0;
     3849
     3850    pThis->XtGenIntrCtrl.u64         = 0;
     3851    pThis->XtPprIntrCtrl.u64         = 0;
     3852    pThis->XtGALogIntrCtrl.u64       = 0;
     3853
    37323854    memset(&pThis->aMarcApers[0], 0, sizeof(pThis->aMarcApers));
    3733     pThis->RsvdReg                           = 0;
    3734     pThis->CmdBufHeadPtr.u64                 = 0;
    3735     pThis->CmdBufTailPtr.u64                 = 0;
    3736     pThis->EvtLogHeadPtr.u64                 = 0;
    3737     pThis->EvtLogTailPtr.u64                 = 0;
    3738     pThis->Status.u64                        = 0;
    3739     pThis->PprLogHeadPtr.u64                 = 0;
    3740     pThis->PprLogTailPtr.u64                 = 0;
    3741     pThis->GALogHeadPtr.u64                  = 0;
    3742     pThis->GALogTailPtr.u64                  = 0;
    3743     pThis->PprLogBHeadPtr.u64                = 0;
    3744     pThis->PprLogBTailPtr.u64                = 0;
    3745     pThis->EvtLogBHeadPtr.u64                = 0;
    3746     pThis->EvtLogBTailPtr.u64                = 0;
    3747     pThis->PprLogAutoResp.u64                = 0;
    3748     pThis->PprLogOverflowEarly.u64           = 0;
    3749     pThis->PprLogBOverflowEarly.u64          = 0;
     3855
     3856    pThis->RsvdReg                   = 0;
     3857
     3858    pThis->CmdBufHeadPtr.u64         = 0;
     3859    pThis->CmdBufTailPtr.u64         = 0;
     3860    pThis->EvtLogHeadPtr.u64         = 0;
     3861    pThis->EvtLogTailPtr.u64         = 0;
     3862
     3863    pThis->Status.u64                = 0;
     3864
     3865    pThis->PprLogHeadPtr.u64         = 0;
     3866    pThis->PprLogTailPtr.u64         = 0;
     3867
     3868    pThis->GALogHeadPtr.u64          = 0;
     3869    pThis->GALogTailPtr.u64          = 0;
     3870
     3871    pThis->PprLogBHeadPtr.u64        = 0;
     3872    pThis->PprLogBTailPtr.u64        = 0;
     3873
     3874    pThis->EvtLogBHeadPtr.u64        = 0;
     3875    pThis->EvtLogBTailPtr.u64        = 0;
     3876
     3877    pThis->PprLogAutoResp.u64        = 0;
     3878    pThis->PprLogOverflowEarly.u64   = 0;
     3879    pThis->PprLogBOverflowEarly.u64  = 0;
    37503880
    37513881    PDMPciDevSetDWord(pPciDev, IOMMU_PCI_OFF_BASE_ADDR_REG_LO, 0);
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