Changeset 90111 in vbox
- Timestamp:
- Jul 9, 2021 10:34:28 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Bus/DevIommuIntel.cpp
r89732 r90111 2297 2297 2298 2298 /** 2299 * Checks whether two consecutive I/O page results of a DMA memory request2300 * 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_STRICT2315 /* 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 #endif2323 return GCPhysPrev + cbPrev == GCPhys;2324 }2325 2326 2327 /**2328 2299 * Looks up the range of addresses for a DMA memory request remapping. 2329 2300 * … … 2344 2315 uint64_t offAddrIn = MemReqIn.AddrRange.uAddr & X86_PAGE_4K_OFFSET_MASK; 2345 2316 size_t cbRemaining = cbAddrIn; 2317 size_t const cbPage = X86_PAGE_4K_SIZE; 2346 2318 2347 2319 int rc; … … 2354 2326 MemReqIn.AddrRange.cb = cbRemaining; /* Not currently accessed by pfnLookup, but keep things consistent. */ 2355 2327 2328 /* Lookup the physical page corresponding to the I/O virtual address. */ 2356 2329 DMARIOPAGE IoPage; 2357 2330 rc = pfnLookup(pDevIns, &MemReqIn, &pMemReqRemap->Aux, &IoPage); 2358 2331 if (RT_SUCCESS(rc)) 2359 2332 { 2333 /* Validate results of the translation. */ 2360 2334 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); 2361 2337 2362 2338 /* Store the translated address before continuing to access more pages. */ … … 2369 2345 } 2370 2346 /* 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 2372 2352 { 2373 2353 rc = VERR_OUT_OF_RANGE; … … 2379 2359 2380 2360 /* Check if we need to access more pages. */ 2381 size_t const cbPage = RT_BIT_64(IoPage.cShift);2382 2361 if (cbRemaining > cbPage - offAddrIn) 2383 2362 {
Note:
See TracChangeset
for help on using the changeset viewer.