我想在任何给定的Linux机器上验证是否支持PCI passthrough。在谷歌了一下之后,我发现我应该检查IOMMU是否支持,我通过运行以下命令来实现:
dmesg | grep IOMMU 如果它支持IOMMU (而不是IOMMUv2),我会得到:
IOMMU
[ 0.000000] DMAR: IOMMU enabled
[ 0.049734] DMAR-IR: IOAPIC id 8 under DRHD base 0xfbffc000 IOMMU 0
[ 0.049735] DMAR-IR: IOAPIC id 9 under DRHD base 0xfbffc000 IOMMU 0
[ 1.286567] AMD IOMMUv2 driver by Joerg Roedel <jroedel@suse.de>
[ 1.286568] AMD IOMMUv2 functionality not available on this system...where DMAR: IOMMU enabled就是我要找的。
现在,如果机器已经运行了几天而没有重新启动,那么使用前面的命令,第一条消息[ 0.000000] DMAR: IOMMU enabled可能不会再出现在日志中。
当该消息从日志中消失时,有没有办法检查IOMMU支持?
发布于 2017-05-31 21:58:55
自2014年起,启用的iommu在/sys ( sysfs )特殊文件系统中注册为iommu类(在ABI/testing/sysfs-class-iommu中记录):https://patchwork.kernel.org/patch/4345491/ "2/3 IOMMU /英特尔:利用IOMMU sysfs支持“- 2014年6月12日
注册我们的DRHD IOMMU,交叉链接设备,并为IOMMU提供一组基本属性。..。在典型的桌面系统上,这提供了以下(修剪后的)功能:
$ find /sys | grep dmar /sys/devices/virtual/iommu/dmar0... /sys/class/iommu/dmar0 /sys/class/iommu/dmar1.
在更新的内核中,代码是iommu_device_create (http://elixir.free-electrons.com/linux/v4.5/ident/iommu_device_create,大约4.5)或iommu_device_sysfs_add (http://elixir.free-electrons.com/linux/v4.11/ident/iommu_device_sysfs_add)。
/*
* Create an IOMMU device and return a pointer to it. IOMMU specific
* attributes can be provided as an attribute group, allowing a unique
* namespace per IOMMU type.
*/
struct device *iommu_device_create(struct device *parent, void *drvdata,
const struct attribute_group **groups,
const char *fmt, ...)仅对启用的IOMMU进行注册。DMAR:
if (intel_iommu_enabled) {
iommu->iommu_dev = iommu_device_create(NULL, iommu,
intel_iommu_groups,
"%s", iommu->name);AMD IOMMU:
static int iommu_init_pci(struct amd_iommu *iommu)
{ ...
if (!iommu->dev)
return -ENODEV;
...
iommu->iommu_dev = iommu_device_create(&iommu->dev->dev, iommu,
amd_iommu_groups, "ivhd%d",
iommu->index);英特尔:
int __init intel_iommu_init(void)
{ ...
pr_info("Intel(R) Virtualization Technology for Directed I/O\n");
...
for_each_active_iommu(iommu, drhd)
iommu->iommu_dev = iommu_device_create(NULL, iommu,
intel_iommu_groups,
"%s", iommu->name);在4.11Linux内核版本中,类是referenced in many IOMMU drivers,所以检查/sys/ iommu_device_sysfs_add / IOMMU比解析dmesg输出或在/var/log/kern.log或/var/log/messages中搜索驱动程序特定的启用消息更好(更通用)地通过编程检测已启用的IOMMU:
10个文件中引用的
:
https://stackoverflow.com/questions/44286683
复制相似问题