VirtualBox

Changeset 90111 in vbox


Ignore:
Timestamp:
Jul 9, 2021 10:34:28 AM (4 years ago)
Author:
vboxsync
Message:

Intel IOMMU: bugref:9967 Similar fix as r145610 but for Intel.
I haven't observed this yet as guests I tested so far don't use non-standard page sizes with Intel IOMMUs but if it did, it would cause similar problems.

File:
1 edited

Legend:

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

    r89732 r90111  
    22972297
    22982298/**
    2299  * Checks whether two consecutive I/O page results of a DMA memory request
    2300  * translates to a physically contiguous region.
    2301  *
    2302  * @returns @c true if the I/O pages are contiguous, @c false otherwise.
    2303  * @param   pIoPagePrev     The previous I/O page.
    2304  * @param   pIoPage         The current I/O page.
    2305  */
    2306 static bool dmarIsIoPageAccessContig(PCDMARIOPAGE pIoPagePrev, PCDMARIOPAGE pIoPage)
    2307 {
    2308     /* Paranoia: Permissions for pages of a DMA memory request must be identical. */
    2309     Assert(pIoPagePrev->fPerm  == pIoPage->fPerm);
    2310 
    2311     size_t const   cbPrev     = RT_BIT_64(pIoPagePrev->cShift);
    2312     RTGCPHYS const GCPhysPrev = pIoPagePrev->GCPhysBase;
    2313     RTGCPHYS const GCPhys     = pIoPage->GCPhysBase;
    2314 #ifdef RT_STRICT
    2315     /* Paranoia: Ensure offset bits are 0. */
    2316     {
    2317         uint64_t const fOffMaskPrev = X86_GET_PAGE_OFFSET_MASK(pIoPagePrev->cShift);
    2318         uint64_t const fOffMask     = X86_GET_PAGE_OFFSET_MASK(pIoPage->cShift);
    2319         Assert(!(GCPhysPrev & fOffMaskPrev));
    2320         Assert(!(GCPhys     & fOffMask));
    2321     }
    2322 #endif
    2323     return GCPhysPrev + cbPrev == GCPhys;
    2324 }
    2325 
    2326 
    2327 /**
    23282299 * Looks up the range of addresses for a DMA memory request remapping.
    23292300 *
     
    23442315    uint64_t       offAddrIn   = MemReqIn.AddrRange.uAddr & X86_PAGE_4K_OFFSET_MASK;
    23452316    size_t         cbRemaining = cbAddrIn;
     2317    size_t const   cbPage      = X86_PAGE_4K_SIZE;
    23462318
    23472319    int rc;
     
    23542326        MemReqIn.AddrRange.cb    = cbRemaining;  /* Not currently accessed by pfnLookup, but keep things consistent. */
    23552327
     2328        /* Lookup the physical page corresponding to the I/O virtual address. */
    23562329        DMARIOPAGE IoPage;
    23572330        rc = pfnLookup(pDevIns, &MemReqIn, &pMemReqRemap->Aux, &IoPage);
    23582331        if (RT_SUCCESS(rc))
    23592332        {
     2333            /* Validate results of the translation. */
    23602334            Assert(IoPage.cShift >= X86_PAGE_4K_SHIFT && IoPage.cShift <= X86_PAGE_1G_SHIFT);
     2335            Assert(!(IoPage.GCPhysBase & X86_GET_PAGE_OFFSET_MASK(IoPage.cShift)));
     2336            Assert((IoPage.fPerm & MemReqIn.AddrRange.fPerm) == MemReqIn.AddrRange.fPerm);
    23612337
    23622338            /* Store the translated address before continuing to access more pages. */
     
    23692345            }
    23702346            /* Check if addresses translated so far result in a physically contiguous region. */
    2371             else if (!dmarIsIoPageAccessContig(&IoPagePrev, &IoPage))
     2347            /** @todo Ensure permissions are identical as well if we implementing IOTLB caching
     2348             *        that relies on it being so. */
     2349            else if (IoPagePrev.GCPhysBase + cbPage == IoPage.GCPhysBase)
     2350            { /* likely */ }
     2351            else
    23722352            {
    23732353                rc = VERR_OUT_OF_RANGE;
     
    23792359
    23802360            /* Check if we need to access more pages. */
    2381             size_t const cbPage = RT_BIT_64(IoPage.cShift);
    23822361            if (cbRemaining > cbPage - offAddrIn)
    23832362            {
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