Changeset 88668 in vbox
- Timestamp:
- Apr 23, 2021 4:17:04 AM (4 years ago)
- svn:sync-xref-src-repo-rev:
- 143982
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Bus/DevIommuAmd.cpp
r88642 r88668 173 173 174 174 /** Acquires the cache lock. */ 175 # 175 #define IOMMU_LOCK_CACHE(a_pDevIns, a_pThis) \ 176 176 do { \ 177 177 int const rcLock = PDMDevHlpCritSectEnter((a_pDevIns), &(a_pThis)->CritSectCache, VERR_SEM_BUSY); \ … … 200 200 201 201 /** Acquires the PDM lock. */ 202 #define IOMMU_LOCK(a_pDevIns, a_pThisCC ) \202 #define IOMMU_LOCK(a_pDevIns, a_pThisCC, a_rcBusy) \ 203 203 do { \ 204 int const rcLock = (a_pThisCC)->CTX_SUFF(pIommuHlp)->pfnLock((a_pDevIns), VERR_SEM_BUSY); \204 int const rcLock = (a_pThisCC)->CTX_SUFF(pIommuHlp)->pfnLock((a_pDevIns), (a_rcBusy)); \ 205 205 if (RT_LIKELY(rcLock == VINF_SUCCESS)) \ 206 206 { /* likely */ } \ … … 2716 2716 Log4Func(("off=%#x cb=%u uValue=%#RX64\n", off, cb, uValue)); 2717 2717 2718 PIOMMU pThis = PDMDEVINS_2_DATA(pDevIns, PIOMMU); 2719 PCIOMMUREGACC pReg = iommuAmdGetRegAccess(off); 2718 PIOMMU pThis = PDMDEVINS_2_DATA(pDevIns, PIOMMU); 2719 PIOMMUCC pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PIOMMUCC); 2720 PCIOMMUREGACC pReg = iommuAmdGetRegAccess(off); 2720 2721 if (pReg) 2721 2722 { /* likely */ } … … 2743 2744 { 2744 2745 if (!(off & 7)) 2745 return pReg->pfnWrite(pDevIns, pThis, off, uValue); 2746 { 2747 IOMMU_LOCK(pDevIns, pThisCC, VINF_IOM_R3_MMIO_WRITE); 2748 VBOXSTRICTRC rcStrict = pReg->pfnWrite(pDevIns, pThis, off, uValue); 2749 IOMMU_UNLOCK(pDevIns, pThisCC); 2750 return rcStrict; 2751 } 2746 2752 2747 2753 LogFunc(("Misaligned access while writing register at off=%#x (cb=%u) with %#RX64 -> Ignored\n", off, cb, uValue)); … … 2753 2759 if (!(off & 7)) 2754 2760 { 2761 VBOXSTRICTRC rcStrict; 2762 IOMMU_LOCK(pDevIns, pThisCC, VINF_IOM_R3_MMIO_WRITE); 2763 2755 2764 /* 2756 2765 * Lower 32 bits of a 64-bit register or a 32-bit register is being written. … … 2759 2768 uint64_t u64Read; 2760 2769 if (pReg->pfnRead) 2761 { 2762 VBOXSTRICTRC rcStrict = pReg->pfnRead(pDevIns, pThis, off, &u64Read); 2763 if (RT_FAILURE(rcStrict)) 2764 { 2765 LogFunc(("Reading off %#x during split write failed! rc=%Rrc\n -> Ignored", off, VBOXSTRICTRC_VAL(rcStrict))); 2766 return rcStrict; 2767 } 2768 } 2770 rcStrict = pReg->pfnRead(pDevIns, pThis, off, &u64Read); 2769 2771 else 2772 { 2773 rcStrict = VINF_SUCCESS; 2770 2774 u64Read = 0; 2771 2772 uValue = (u64Read & UINT64_C(0xffffffff00000000)) | uValue; 2773 return pReg->pfnWrite(pDevIns, pThis, off, uValue); 2775 } 2776 2777 if (RT_SUCCESS(rcStrict)) 2778 { 2779 uValue = (u64Read & UINT64_C(0xffffffff00000000)) | uValue; 2780 rcStrict = pReg->pfnWrite(pDevIns, pThis, off, uValue); 2781 } 2782 else 2783 LogFunc(("Reading off %#x during split write failed! rc=%Rrc\n -> Ignored", off, VBOXSTRICTRC_VAL(rcStrict))); 2784 2785 IOMMU_UNLOCK(pDevIns, pThisCC); 2786 return rcStrict; 2774 2787 } 2775 2788 … … 2778 2791 * Merge with lower 32 bits (after reading the full 64-bits) and perform a 64-bit write. 2779 2792 */ 2793 VBOXSTRICTRC rcStrict; 2780 2794 Assert(!(off & 3)); 2781 2795 Assert(off & 7); … … 2783 2797 uint64_t u64Read; 2784 2798 if (pReg->pfnRead) 2785 { 2786 VBOXSTRICTRC rcStrict = pReg->pfnRead(pDevIns, pThis, off - 4, &u64Read); 2787 if (RT_FAILURE(rcStrict)) 2788 { 2789 LogFunc(("Reading off %#x during split write failed! rc=%Rrc\n -> Ignored", off, VBOXSTRICTRC_VAL(rcStrict))); 2790 return rcStrict; 2791 } 2792 } 2799 rcStrict = pReg->pfnRead(pDevIns, pThis, off - 4, &u64Read); 2793 2800 else 2801 { 2802 rcStrict = VINF_SUCCESS; 2794 2803 u64Read = 0; 2795 2796 uValue = (uValue << 32) | (u64Read & UINT64_C(0xffffffff)); 2797 return pReg->pfnWrite(pDevIns, pThis, off - 4, uValue); 2804 } 2805 2806 if (RT_SUCCESS(rcStrict)) 2807 { 2808 uValue = (uValue << 32) | (u64Read & UINT64_C(0xffffffff)); 2809 rcStrict = pReg->pfnWrite(pDevIns, pThis, off - 4, uValue); 2810 } 2811 else 2812 LogFunc(("Reading off %#x during split write failed! rc=%Rrc\n -> Ignored", off, VBOXSTRICTRC_VAL(rcStrict))); 2813 2814 IOMMU_UNLOCK(pDevIns, pThisCC); 2815 return rcStrict; 2798 2816 } 2799 2817 … … 2824 2842 Log4Func(("off=%#x\n", off)); 2825 2843 2826 PIOMMU pThis = PDMDEVINS_2_DATA(pDevIns, PIOMMU); 2844 PIOMMU pThis = PDMDEVINS_2_DATA(pDevIns, PIOMMU); 2845 PIOMMUCC pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PIOMMUCC); 2827 2846 PCPDMPCIDEV pPciDev = pDevIns->apPciDevs[0]; 2828 2847 PDMPCIDEV_ASSERT_VALID(pDevIns, pPciDev); NOREF(pPciDev); … … 2851 2870 */ 2852 2871 if (!(off & 7)) 2853 return pReg->pfnRead(pDevIns, pThis, off, puResult); 2872 { 2873 IOMMU_LOCK(pDevIns, pThisCC, VINF_IOM_R3_MMIO_READ); 2874 VBOXSTRICTRC rcStrict = pReg->pfnRead(pDevIns, pThis, off, puResult); 2875 IOMMU_UNLOCK(pDevIns, pThisCC); 2876 return rcStrict; 2877 } 2854 2878 2855 2879 /* … … 2860 2884 Assert(off & 7); 2861 2885 Assert(off >= 4); 2886 IOMMU_LOCK(pDevIns, pThisCC, VINF_IOM_R3_MMIO_READ); 2862 2887 VBOXSTRICTRC rcStrict = pReg->pfnRead(pDevIns, pThis, off - 4, puResult); 2888 IOMMU_UNLOCK(pDevIns, pThisCC); 2863 2889 if (RT_SUCCESS(rcStrict)) 2864 2890 *puResult >>= 32; … … 3458 3484 PIOMMUCC pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PIOMMUCC); 3459 3485 3460 IOMMU_LOCK(pDevIns, pThisCC );3486 IOMMU_LOCK(pDevIns, pThisCC, VERR_SEM_BUSY); 3461 3487 3462 3488 /* Figure out which device table segment is being accessed. */ … … 4852 4878 if (pCmdComWait->n.u1Interrupt) 4853 4879 { 4854 IOMMU_LOCK(pDevIns, pThisR3 );4880 IOMMU_LOCK(pDevIns, pThisR3, VERR_IGNORED); 4855 4881 ASMAtomicOrU64(&pThis->Status.u64, IOMMU_STATUS_COMPLETION_WAIT_INTR); 4856 4882 bool const fRaiseInt = pThis->Ctrl.n.u1CompWaitIntrEn; 4857 4883 IOMMU_UNLOCK(pDevIns, pThisR3); 4858 4859 4884 if (fRaiseInt) 4860 4885 iommuAmdMsiInterruptRaise(pDevIns); … … 5083 5108 * save on host memory a bit, we could (once PGM has the necessary APIs) 5084 5109 * lock the page mappings page mappings and access them directly. */ 5085 IOMMU_LOCK(pDevIns, pThisR3 );5110 IOMMU_LOCK(pDevIns, pThisR3, VERR_IGNORED); 5086 5111 5087 5112 if (pThis->Status.n.u1CmdBufRunning) … … 5104 5129 IOMMU_UNLOCK(pDevIns, pThisR3); 5105 5130 int rc = PDMDevHlpPCIPhysRead(pDevIns, GCPhysCmdBufBase, pvCmds, cbCmdBuf); 5106 IOMMU_LOCK(pDevIns, pThisR3 );5131 IOMMU_LOCK(pDevIns, pThisR3, VERR_IGNORED); 5107 5132 5108 5133 if (RT_SUCCESS(rc)) … … 5267 5292 5268 5293 PIOMMUR3 pThisR3 = PDMDEVINS_2_DATA_CC(pDevIns, PIOMMUR3); 5269 IOMMU_LOCK(pDevIns, pThisR3 );5294 IOMMU_LOCK(pDevIns, pThisR3, VERR_IGNORED); 5270 5295 5271 5296 VBOXSTRICTRC rcStrict; … … 6611 6636 6612 6637 int rc; 6613 IOMMU_LOCK(pDevIns, pThisR3 );6638 IOMMU_LOCK(pDevIns, pThisR3, VERR_IGNORED); 6614 6639 6615 6640 /* Map MMIO regions if the IOMMU BAR is enabled. */
Note:
See TracChangeset
for help on using the changeset viewer.