Linux IOMMU页表 [英] Linux IOMMU page tables

查看:388
本文介绍了Linux IOMMU页表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在阅读有关 IOMMU 在Linux和Linux中的支持.对IOMMU中的页表有一些疑问:

I've been reading about IOMMU support in Linux and have some questions regarding page tables in IOMMU:

  1. IOMMU是否使用CPU MMU页表存储VA映射?
  2. 如果没有,即虚拟地址不同,那么是按设备还是按IOMMU单元创建映射?

我还没有看过任何驱动程序代码,所以如果有人可以指出一些示例驱动程序代码,那就太好了.

I haven't looked at any driver code yet, so it would be great if anyone can point me to some sample driver code.

推荐答案

IOMMU是否使用CPU MMU页表存储VA-> PA映射?

Does the IOMMU uses the CPU MMU page tables for storing VA->PA mapping?

不. OS中有许多进程,每个进程都有自己的VA-> PA映射(它们都运行在单独的虚拟地址空间中).

No. There are many processes in OS, and every process has its own VA->PA mapping (they all running in separate virtual address spaces).

有物理内存,由内存控制器控制.还有一些想要访问物理内存的设备:CPU和外部总线控制器. CPU具有自己的转换,总线控制器具有自己的转换.

There is physical memory, controlled by memory controller. And there are devices which want to access physical memory: CPU and external bus controller. CPU has own translation and bus controller has own.

如果不是,即虚拟地址不同,那么是按设备还是按IOMMU单元创建映射?

If not i.e. the virtual addresses are different then are the mappings created per device or per IOMMU unit?

根据IOMMU的功能创建映射.一些简单的IOMMU可能具有一个针对设备总线根控制器的全局映射(PCI Express根编译器).像英特尔的VT-d这样的复杂IOMMU可能具有多个映射或嵌套转换,这些映射或嵌套转换是基于某些每个端口规则选择的. (但是网桥后面的两个设备通常会有相同的翻译.)

Mappings are created according to capabilities of IOMMU. Some simple IOMMU may have one global mapping for the device bus root controller (PCI-express root comples). Complex IOMMU like Intel's VT-d may have several mappings or nested translations, selected based on some per-port rules. (But two devices behind bridge typically will have same translation.)

https://www.kernel.org/doc/Documentation/Intel- IOMMU.txt

Intel IOMMU驱动程序为每个域分配一个虚拟地址.每个PCIE 设备具有其自己的域(因此受到保护). p2p网桥下的设备 由于以下原因,与p2p网桥下的所有设备共享虚拟地址: p2p网桥的事务ID别名.

The Intel IOMMU driver allocates a virtual address per domain. Each PCIE device has its own domain (hence protection). Devices under p2p bridges share the virtual address with all devices under the p2p bridge due to transaction id aliasing for p2p bridges.

https://www.kernel.org/doc/Documentation/DMA-API-HOWTO.txt

在某些系统中,总线地址与CPU物理地址相同,但在 一般他们不是. IOMMU和主机桥可以产生任意 物理地址和总线地址之间的映射.

In some systems, bus addresses are identical to CPU physical addresses, but in general they are not. IOMMUs and host bridges can produce arbitrary mappings between physical and bus addresses.

(还请在

虚拟地址(X)...虚拟内存系统将X映射到系统RAM中的物理地址(Y).驱动程序可以使用虚拟地址X来访问缓冲区,但设备本身无法使用,因为DMA不会通过CPU虚拟内存系统.

virtual address (X)... The virtual memory system maps X to a physical address (Y) in system RAM. The driver can use virtual address X to access the buffer, but the device itself cannot because DMA doesn't go through the CPU virtual memory system.

在某些简单的系统中,设备可以直接对物理地址进行DMA 是的,但是在许多其他情况下,有IOMMU硬件可以转换DMA 地址转换为物理地址,例如,它将Z转换为Y.

In some simple systems, the device can do DMA directly to physical address Y. But in many others, there is IOMMU hardware that translates DMA addresses to physical addresses, e.g., it translates Z to Y.

还要检查 https://events.linuxfoundation.org/sites/events/files/slides/20140429-dma.pdf (2014)和

Check also https://events.linuxfoundation.org/sites/events/files/slides/20140429-dma.pdf (2014) and http://www.linuxplumbersconf.org/2014/wp-content/uploads/2014/10/LPC2014_IOMMU.txt

http://developer.amd.com /wordpress/media/2012/10/IOMMU-ben-yehuda.pdf 论文(2012),了解设备内存重新映射的历史以及IOMMU用于虚拟化的情况.

And http://developer.amd.com/wordpress/media/2012/10/IOMMU-ben-yehuda.pdf paper (2012) for history of device memory remapping and IOMMU usage for virtualization.

这篇关于Linux IOMMU页表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆