Showing posts with label DMA. Show all posts
Showing posts with label DMA. Show all posts

Tuesday, March 26, 2013

Why do we need IOMMU for virtualization

Short answer: 
translate guest physical address to host physical address for DMA access of guest OS

Long answer from wiki:

When an operating system is running inside a virtual machine, including systems that use paravirtualization, such as Xen, it does not usually know the host-physical addresses of memory that it accesses. This makes providing direct access to the computer hardware difficult, because if the guest OS tried to instruct the hardware to perform a direct memory access (DMA) using guest-physical addresses, it would likely corrupt the memory, as the hardware does not know about the mapping between the guest-physical and host-physical addresses for the given virtual machine. The corruption is avoided because the hypervisor or host OS intervenes in the I/O operation to apply the translations; unfortunately, this delays the I/O operation.
An IOMMU can solve this problem by re-mapping the addresses accessed by the hardware according to the same (or a compatible) translation table that is used to map guest-physical address to host-physical addresses.[9]

[edit]

Friday, April 1, 2011

DMA

Here is the definition from wiki:
Direct memory access (DMA) is a feature of modern computers and microprocessors that allows certain hardware subsystems within the computer to access system memory for reading and/or writing independently of the central processing unit

The basic idea is that: DMA could move data from one device to another device without CPU.
For example, it would move data from memory to harddisk. If you use Peripheral Input/Output PIO to move data, it would access CPU for each single byte. (copy 0x80 to register, and copy register to hard disk.)
Another example, video capture card send data to network card(Video Chat), DMA helps a lot. DMA is a feature of Bus, not necessary to be a device.

Today, I just had a experience about DMA. The coreboot doesn't support the DMA enable for SATA on Windows XP, so the XP is very slow. Every single byte of data reading/writing to disk need to be done by CPU.
If we go to device manage and click Primary IDE Channel Properties, we would see Current Transfer Mode as PIO.
We could fix this problem by install the south-bridge SATA driver(VIA SATA on ASUS M2V-MX_SE ). After we installed the SATA driver, the Current Transfer Mode changed to Ultra DMA Mode 6