大网数据广告活动
启动与系统组件

Data corruption without special transfer handling

· 52CE 我爱测

This article provides resolutions for the problem where data corruption may occur without special handling of the transfer.

This article helps you resolve the problem where data corruption may occur without special handling of the transfer.

Original product version:   Direct Memory Access
Original KB number:   2714876

Symptoms

On PAE enabled x86 Windows versions that support access to memory above 4 GB, device drivers which intermix 32-bit Direct Memory Access (DMA) device reads with writes to the virtual address of the same transfer buffer may lead to data corruption without special handling of the transfer.

Cause

PAE enabled x86 Windows versions that support access to memory above 4 GB implement special handling for devices that report being incapable of using more than 32-bit DMA addresses. This special handling is implemented in the Hardware Abstraction Layer (HAL) of the operating system using Map Registers that are sometimes referred to as bounce buffers.

When a device driver begins a DMA operation to a 32-bit only capable device, DmaOperations function HalGetScatterGatherList must determine whether any of the physical addresses describing the transfer reside above 4 GB. The HAL will then substitute the transfer buffer physical addresses residing above 4 GB with Map Register residing below 4 GB, which the device is capable of addressing.

If substitutions were performed, the Scatter Gather List (SGL) generated will be composed of physical addresses, some of which differ from the original Memory Descriptor List (MDL) describing the transfer. When the driver indicates that the DMA transfer is complete, the HAL determines whether it used map registers to support the transfer. If it did, and if the operation was a read from the device to system memory, the HAL will copy the contents of any Map Register used to the original data buffer. Data written directly to the transfer buffer virtual addresses by the driver prior to the requests completion will thus be overwritten by the contents of the HAL substituted Map Registers upon completion of the request.

If the data contained in the Map Registers does not match what the driver has written directly to the transfer buffer, then the data in the transfer buffer may be inconsistent.

Resolution

Device drivers that require intermixing 32-bit DMA read operations with writes to the virtual addresses of a transfer buffer must use DmaOperations function HalBuildMdlFromScatterGatherList.

If Map Register substitutions were done by the HAL, HalBuildMdlFromScatterGatherList will create a new MDL that is composed of the non-substituted transfer buffer physical address and the physical addresses of the substituted HAL Map Registers. The virtual address mapping of the new MDL may be obtained by calling MmGetSystemAddressForMdlSafe. If HalBuildMdlFromScatterGatherList returns the original MDL, then no Map Register substitutions were performed.

New MDLs created by HalBuildMdlFromScatterGatherList must be unmapped and freed by calls to MmUnmapLockedPages and IoFreeMdl function.

More information

Source: Microsoft Learn / IT Pro troubleshooting by Microsoft and contributors. Documentation licensed CC BY 4.0. Code samples are covered by the MIT License. Converted from Markdown, with links normalized and embedded media omitted.

资料来源与适用范围

资料来源
Microsoft Learn / IT Pro troubleshooting
适用范围
See source applicability · Source date 09/02/2020
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY 4.0 (documentation), MIT (code samples)

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。