zoukankan      html  css  js  c++  java
  • 如何判断iommu/smmu 是否能用

    /sys/class/iommu   ??

    /sys/kernel/iommu_groups  ??   

    vfio API ??

    转自  https://blog.csdn.net/tiantao2012/article/details/60756851        ?????

    https://stackoverflow.com/questions/44286683/check-for-iommu-support-on-linux

    我认为不能单单从 /sys/kernel/iommu_groups 下面是否为空来判断,因为在没有iommu的时候,若使用vfio+noiommu模式(echo 1 > /sys/module/vfio/parameters/enable_unsafe_noiommu_mode),  vfio 也会在 iommu_groups下面添加设备,此时该目录下非空,但其实iommu不能用。

    struct iommu_group *vfio_iommu_group_get(struct device *dev)
    {
     struct iommu_group *group;
     int __maybe_unused ret;
     group = iommu_group_get(dev);
    #ifdef CONFIG_VFIO_NOIOMMU
     /*
      * With noiommu enabled, an IOMMU group will be created for a device
      * that doesn't already have one and doesn't have an iommu_ops on their
      * bus.  We set iommudata simply to be able to identify these groups
      * as special use and for reclamation later.
      */
     if (group || !noiommu || iommu_present(dev->bus))
      return group;
     group = iommu_group_alloc();
     if (IS_ERR(group))
      return NULL;
     iommu_group_set_name(group, "vfio-noiommu");
     iommu_group_set_iommudata(group, &noiommu, NULL);
     ret = iommu_group_add_device(group, dev);
     if (ret) {
      iommu_group_put(group);
      return NULL;
     }
     /*
      * Where to taint?  At this point we've added an IOMMU group for a
      * device that is not backed by iommu_ops, therefore any iommu_
      * callback using iommu_ops can legitimately Oops.  So, while we may
      * be about to give a DMA capable device to a user without IOMMU
      * protection, which is clearly taint-worthy, let's go ahead and do
      * it here.
      */
     add_taint(TAINT_USER, LOCKDEP_STILL_OK);
     dev_warn(dev, "Adding kernel taint for vfio-noiommu group on device ");
    #endif
     return group;
    }
  • 相关阅读:
    理解和学习qml
    (离线)英语词典软件推荐
    Ubuntu:安装deb文件包以及deb卸载
    mac man汉化方法
    Linux中文件和目录的权限(r, w, x)
    解决mac休眠掉电的解决方法
    线程池之ThreadPool与ForkJoinPool
    程序员的知识焦虑
    回顾2018,展望2019
    NIO基础学习——缓冲区
  • 原文地址:https://www.cnblogs.com/yi-mu-xi/p/12355584.html
Copyright © 2011-2022 走看看