VirtualBox

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


Ignore:
Timestamp:
Feb 10, 2021 4:50:02 PM (4 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
142735
Message:

AMD IOMMU: bugref:9654 Drop the atomic reads when holding the lock.

File:
1 edited

Legend:

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

    r87691 r87692  
    12211221
    12221222
    1223 DECLINLINE(IOMMU_STATUS_T) iommuAmdGetStatus(PCIOMMU pThis)
    1224 {
    1225     IOMMU_STATUS_T Status;
    1226     Status.u64 = ASMAtomicReadU64((volatile uint64_t *)&pThis->Status.u64);
    1227     return Status;
    1228 }
    1229 
    1230 
    1231 DECLINLINE(IOMMU_CTRL_T) iommuAmdGetCtrl(PCIOMMU pThis)
     1223DECL_FORCE_INLINE(IOMMU_CTRL_T) iommuAmdGetCtrlUnlocked(PCIOMMU pThis)
    12321224{
    12331225    IOMMU_CTRL_T Ctrl;
     
    12721264 * @param   pDevIns     The IOMMU device instance.
    12731265 *
    1274  * @remarks The IOMMU lock must be held.
     1266 * @remarks The IOMMU lock must be held while calling this!
    12751267 */
    12761268static void iommuAmdCmdThreadWakeUpIfNeeded(PPDMDEVINS pDevIns)
    12771269{
    1278     IOMMU_ASSERT_LOCKED(pDevIns);
    12791270    Log4Func(("\n"));
    12801271
    12811272    PIOMMU pThis = PDMDEVINS_2_DATA(pDevIns, PIOMMU);
    1282     IOMMU_STATUS_T const Status = iommuAmdGetStatus(pThis);
    1283     if (Status.n.u1CmdBufRunning)
     1273    if (pThis->Status.n.u1CmdBufRunning)
    12841274    {
    12851275        Log4Func(("Signaling command thread\n"));
     
    16221612     * Inconsistent specs :/
    16231613     */
    1624     IOMMU_STATUS_T const Status = iommuAmdGetStatus(pThis);
    1625     if (Status.n.u1CmdBufRunning)
     1614    if (pThis->Status.n.u1CmdBufRunning)
    16261615    {
    16271616        LogFunc(("Setting CmdBufBar (%#RX64) when command buffer is running -> Ignored\n", u64Value));
     
    16651654     * See AMD IOMMU spec. "Event Log Base Address Register".
    16661655     */
    1667     IOMMU_STATUS_T const Status = iommuAmdGetStatus(pThis);
    1668     if (Status.n.u1EvtLogRunning)
     1656    if (pThis->Status.n.u1EvtLogRunning)
    16691657    {
    16701658        LogFunc(("Setting EvtLogBar (%#RX64) when event logging is running -> Ignored\n", u64Value));
     
    17121700    if (NewCtrl.n.u3DevTabSegEn <= pThis->ExtFeat.n.u2DevTabSegSup)
    17131701    {
    1714         IOMMU_CTRL_T const OldCtrl = iommuAmdGetCtrl(pThis);
     1702        IOMMU_CTRL_T const OldCtrl = pThis->Ctrl;
    17151703
    17161704        /* Update the register. */
     
    19621950     * See AMD IOMMU spec. 3.3.13 "Command and Event Log Pointer Registers".
    19631951     */
    1964     IOMMU_STATUS_T const Status = iommuAmdGetStatus(pThis);
    1965     if (Status.n.u1CmdBufRunning)
     1952    if (pThis->Status.n.u1CmdBufRunning)
    19661953    {
    19671954        LogFunc(("Setting CmdBufHeadPtr (%#RX64) when command buffer is running -> Ignored\n", u64Value));
     
    20752062     * See AMD IOMMU spec. 3.3.13 "Command and Event Log Pointer Registers".
    20762063     */
    2077     IOMMU_STATUS_T const Status = iommuAmdGetStatus(pThis);
    2078     if (Status.n.u1EvtLogRunning)
     2064    if (pThis->Status.n.u1EvtLogRunning)
    20792065    {
    20802066        LogFunc(("Setting EvtLogTailPtr (%#RX64) when event log is running -> Ignored\n", u64Value));
     
    21172103     * Writing 0 to an RW1C bit has no effect. Writing 1 to an RW1C bit, clears the bit if it's already 1.
    21182104     */
    2119     IOMMU_STATUS_T const OldStatus = iommuAmdGetStatus(pThis);
     2105    IOMMU_STATUS_T const OldStatus = pThis->Status;
    21202106    uint64_t const fOldRw1cBits = (OldStatus.u64 &  IOMMU_STATUS_RW1C_MASK);
    21212107    uint64_t const fOldRoBits   = (OldStatus.u64 & ~IOMMU_STATUS_RW1C_MASK);
     
    25232509
    25242510    /* Check if event logging is active and the log has not overflowed. */
    2525     IOMMU_STATUS_T const Status = iommuAmdGetStatus(pThis);
     2511    IOMMU_STATUS_T const Status = pThis->Status;
    25262512    if (   Status.n.u1EvtLogRunning
    25272513        && !Status.n.u1EvtOverflow)
     
    25532539
    25542540            /* Check and signal an interrupt if software wants to receive one when an event log entry is written. */
    2555             IOMMU_CTRL_T const Ctrl = iommuAmdGetCtrl(pThis);
    2556             if (Ctrl.n.u1EvtIntrEn)
     2541            if (pThis->Ctrl.n.u1EvtIntrEn)
    25572542                iommuAmdMsiInterruptRaise(pDevIns);
    25582543        }
     
    25632548
    25642549            /* Check and signal an interrupt if software wants to receive one when the event log has overflowed. */
    2565             IOMMU_CTRL_T const Ctrl = iommuAmdGetCtrl(pThis);
    2566             if (Ctrl.n.u1EvtIntrEn)
     2550            if (pThis->Ctrl.n.u1EvtIntrEn)
    25672551                iommuAmdMsiInterruptRaise(pDevIns);
    25682552        }
     
    30623046
    30633047    /* Figure out which device table segment is being accessed. */
    3064     IOMMU_CTRL_T const Ctrl = iommuAmdGetCtrl(pThis);
    3065     uint8_t const idxSegsEn = Ctrl.n.u3DevTabSegEn;
     3048    uint8_t const idxSegsEn = pThis->Ctrl.n.u3DevTabSegEn;
    30663049    Assert(idxSegsEn < RT_ELEMENTS(g_auDevTabSegShifts));
    30673050
     
    37763759
    37773760    PIOMMU pThis = PDMDEVINS_2_DATA(pDevIns, PIOMMU);
    3778     IOMMU_CTRL_T const Ctrl = iommuAmdGetCtrl(pThis);
     3761    IOMMU_CTRL_T const Ctrl = iommuAmdGetCtrlUnlocked(pThis);
    37793762    if (Ctrl.n.u1IommuEn)
    37803763    {
     
    38523835
    38533836    PIOMMU pThis = PDMDEVINS_2_DATA(pDevIns, PIOMMU);
    3854     IOMMU_CTRL_T const Ctrl = iommuAmdGetCtrl(pThis);
     3837    IOMMU_CTRL_T const Ctrl = iommuAmdGetCtrlUnlocked(pThis);
    38553838    if (Ctrl.n.u1IommuEn)
    38563839    {
     
    42074190
    42084191    /* Interrupts are forwarded with remapping when the IOMMU is disabled. */
    4209     IOMMU_CTRL_T const Ctrl = iommuAmdGetCtrl(pThis);
     4192    IOMMU_CTRL_T const Ctrl = iommuAmdGetCtrlUnlocked(pThis);
    42104193    if (Ctrl.n.u1IommuEn)
    42114194    {
     
    43134296                    IOMMU_LOCK(pDevIns, pThisCC);
    43144297                    ASMAtomicOrU64(&pThis->Status.u64, IOMMU_STATUS_COMPLETION_WAIT_INTR);
    4315                     IOMMU_CTRL_T const Ctrl = iommuAmdGetCtrl(pThis);
    4316                     bool const fRaiseInt = Ctrl.n.u1CompWaitIntrEn;
     4298                    bool const fRaiseInt = pThis->Ctrl.n.u1CompWaitIntrEn;
    43174299                    IOMMU_UNLOCK(pDevIns, pThisCC);
    43184300
     
    45474529        IOMMU_LOCK(pDevIns, pThisCC);
    45484530
    4549         IOMMU_STATUS_T const Status = iommuAmdGetStatus(pThis);
    4550         if (Status.n.u1CmdBufRunning)
     4531        if (pThis->Status.n.u1CmdBufRunning)
    45514532        {
    45524533            /* Get the offsets we need to read commands from memory (circular buffer offset). */
     
    59165897    PDMDevHlpSTAMRegister(pDevIns, &pThis->StatIotlbeCacheMiss, STAMTYPE_COUNTER, "IOTLB/CacheMiss", STAMUNIT_OCCURENCES, "Number of IOTLB cache misses.");
    59175898    PDMDevHlpSTAMRegister(pDevIns, &pThis->StatIotlbeLazyEvictReuse, STAMTYPE_COUNTER, "IOTLB/LazyEvictReuse", STAMUNIT_OCCURENCES, "Number of IOTLB entries reused after lazy eviction.");
    5918     PDMDevHlpSTAMRegister(pDevIns, &pThis->StatIotlbeLookup, STAMTYPE_PROFILE, "IOTLB/Lookup", STAMUNIT_TICKS_PER_CALL, "Profiling IOTLB entry lookup.");
     5899    PDMDevHlpSTAMRegister(pDevIns, &pThis->StatIotlbeLookup, STAMTYPE_PROFILE, "Profile/IotlbeLookup", STAMUNIT_TICKS_PER_CALL, "Profiling IOTLB entry lookup.");
    59195900
    59205901    PDMDevHlpSTAMRegister(pDevIns, &pThis->StatDteLookupNonContig, STAMTYPE_COUNTER, "DTE/LookupNonContig", STAMUNIT_OCCURENCES, "DTE lookups that resulted in non-contiguous translated regions.");
    5921     PDMDevHlpSTAMRegister(pDevIns, &pThis->StatIoPageWalkLookup, STAMTYPE_PROFILE, "DTE/Lookup", STAMUNIT_TICKS_PER_CALL, "Profiling I/O page walk lookup.");
     5902    PDMDevHlpSTAMRegister(pDevIns, &pThis->StatIoPageWalkLookup, STAMTYPE_PROFILE, "Profile/IoPageWalk", STAMUNIT_TICKS_PER_CALL, "Profiling I/O page walk lookup.");
    59225903# endif
    59235904
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