VirtualBox

Changeset 85988 in vbox for trunk/src


Ignore:
Timestamp:
Sep 2, 2020 7:12:44 AM (4 years ago)
Author:
vboxsync
Message:

AMD IOMMU: bugref:9654 Fix bit transitions to enable command-buffer and event logging in the control register. Fixed assertion.
Enable bus master bit as the virtual IOMMU writes to guest memory.

File:
1 edited

Legend:

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

    r85971 r85988  
    507507
    508508    PIOMMU pThis = PDMDEVINS_2_DATA(pDevIns, PIOMMU);
    509     if (   !ASMAtomicXchgBool(&pThis->fCmdThreadSignaled, true)
    510         &&  ASMAtomicReadBool(&pThis->fCmdThreadSleeping))
     509    IOMMU_STATUS_T const Status = iommuAmdGetStatus(pThis);
     510    if (Status.n.u1CmdBufRunning)
    511511    {
    512512        LogFlowFunc(("Signaling command thread\n"));
     
    647647    ASMAtomicWriteU64(&pThis->Ctrl.u64, NewCtrl.u64);
    648648
     649    bool const fNewIommuEn = NewCtrl.n.u1IommuEn;
     650    bool const fOldIommuEn = OldCtrl.n.u1IommuEn;
     651
    649652    /* Enable or disable event logging when the bit transitions. */
    650     bool const fNewIommuEn  = NewCtrl.n.u1IommuEn;
    651653    bool const fOldEvtLogEn = OldCtrl.n.u1EvtLogEn;
    652654    bool const fNewEvtLogEn = NewCtrl.n.u1EvtLogEn;
    653     if (fOldEvtLogEn != fNewEvtLogEn)
     655    if (   fOldEvtLogEn != fNewEvtLogEn
     656        || fOldIommuEn != fNewIommuEn)
    654657    {
    655658        if (   fNewIommuEn
     
    666669    bool const fOldCmdBufEn = OldCtrl.n.u1CmdBufEn;
    667670    bool const fNewCmdBufEn = NewCtrl.n.u1CmdBufEn;
    668     if (fOldCmdBufEn != fNewCmdBufEn)
    669     {
    670         if (   fNewIommuEn
    671             && fNewCmdBufEn)
     671    if (   fOldCmdBufEn != fNewCmdBufEn
     672        || fOldIommuEn != fNewIommuEn)
     673    {
     674        if (   fNewCmdBufEn
     675            && fNewIommuEn)
     676        {
    672677            ASMAtomicOrU64(&pThis->Status.u64, IOMMU_STATUS_CMD_BUF_RUNNING);
     678            LogFunc(("Command buffer enabled\n"));
     679
     680            /* Wake up the command thread to start processing commands. */
     681            iommuAmdCmdThreadWakeUpIfNeeded(pDevIns);
     682        }
    673683        else
     684        {
    674685            ASMAtomicAndU64(&pThis->Status.u64, ~IOMMU_STATUS_CMD_BUF_RUNNING);
    675 
    676         /* Wake up the command thread to start or stop processing commands. */
    677         iommuAmdCmdThreadWakeUpIfNeeded(pDevIns);
     686            LogFunc(("Command buffer disabled\n"));
     687        }
    678688    }
    679689
     
    14751485        pThis->HwEvtHi.u64 = RT_MAKE_U64(pEvent->au32[0], pEvent->au32[1]);
    14761486        pThis->HwEvtLo     = RT_MAKE_U64(pEvent->au32[2], pEvent->au32[3]);
    1477         Assert(pThis->HwEvtHi.n.u4EvtCode == IOMMU_EVT_DEV_TAB_HW_ERROR);
     1487        Assert(   pThis->HwEvtHi.n.u4EvtCode == IOMMU_EVT_DEV_TAB_HW_ERROR
     1488               || pThis->HwEvtHi.n.u4EvtCode == IOMMU_EVT_PAGE_TAB_HW_ERROR
     1489               || pThis->HwEvtHi.n.u4EvtCode == IOMMU_EVT_COMMAND_HW_ERROR);
    14781490    }
    14791491}
     
    27712783    IOMMU_ASSERT_NOT_LOCKED(pDevIns);
    27722784
     2785    LogFlowFunc(("\n"));
     2786
    27732787    PIOMMU pThis = PDMDEVINS_2_DATA(pDevIns, PIOMMU);
    27742788    uint8_t const bCmd = pCmd->n.u4Opcode;
     
    29362950        if (Status.n.u1CmdBufRunning)
    29372951        {
     2952            LogFlowFunc(("Command buffer running\n"));
     2953
    29382954            /* Get the offset we need to read the command from memory (circular buffer offset). */
    29392955            uint32_t const cbCmdBuf = iommuAmdGetTotalBufLength(pThis->CmdBufBaseAddr.n.u4Len);
     
    38443860    PDMPciDevSetVendorId(pPciDev,          IOMMU_PCI_VENDOR_ID);       /* AMD */
    38453861    PDMPciDevSetDeviceId(pPciDev,          IOMMU_PCI_DEVICE_ID);       /* VirtualBox IOMMU device */
    3846     PDMPciDevSetCommand(pPciDev,           0);                         /* Command */
     3862    PDMPciDevSetCommand(pPciDev,           VBOX_PCI_COMMAND_MASTER);   /* Enable bus master (as we write to main memory). */
    38473863    PDMPciDevSetStatus(pPciDev,            VBOX_PCI_STATUS_CAP_LIST);  /* Status - CapList supported */
    38483864    PDMPciDevSetRevisionId(pPciDev,        IOMMU_PCI_REVISION_ID);     /* VirtualBox specific device implementation revision */
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