aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/iommu
diff options
context:
space:
mode:
authorAlex Williamson <alex.williamson@redhat.com>2015-07-14 17:24:53 -0400
committerJoerg Roedel <jroedel@suse.de>2015-08-03 10:30:57 -0400
commit2238c0827a9bfa8d517e3175110ed603fb7b9537 (patch)
tree3733039e973926a54eaf770c6e72f88345e51b33 /drivers/iommu
parent50690762cfe32abadbaa5b22bebe3855e5b8ede8 (diff)
iommu/vt-d: Report domain usage in sysfs
Debugging domain ID leakage typically requires long running tests in order to exhaust the domain ID space or kernel instrumentation to track the setting and clearing of bits. A couple trivial intel-iommu specific sysfs extensions make it much easier to expose the IOMMU capabilities and current usage. Signed-off-by: Alex Williamson <alex.williamson@redhat.com> Signed-off-by: Joerg Roedel <jroedel@suse.de>
Diffstat (limited to 'drivers/iommu')
-rw-r--r--drivers/iommu/intel-iommu.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
index 0be23c589d3b..013cbc200579 100644
--- a/drivers/iommu/intel-iommu.c
+++ b/drivers/iommu/intel-iommu.c
@@ -4449,11 +4449,32 @@ static ssize_t intel_iommu_show_ecap(struct device *dev,
4449} 4449}
4450static DEVICE_ATTR(ecap, S_IRUGO, intel_iommu_show_ecap, NULL); 4450static DEVICE_ATTR(ecap, S_IRUGO, intel_iommu_show_ecap, NULL);
4451 4451
4452static ssize_t intel_iommu_show_ndoms(struct device *dev,
4453 struct device_attribute *attr,
4454 char *buf)
4455{
4456 struct intel_iommu *iommu = dev_get_drvdata(dev);
4457 return sprintf(buf, "%ld\n", cap_ndoms(iommu->cap));
4458}
4459static DEVICE_ATTR(domains_supported, S_IRUGO, intel_iommu_show_ndoms, NULL);
4460
4461static ssize_t intel_iommu_show_ndoms_used(struct device *dev,
4462 struct device_attribute *attr,
4463 char *buf)
4464{
4465 struct intel_iommu *iommu = dev_get_drvdata(dev);
4466 return sprintf(buf, "%d\n", bitmap_weight(iommu->domain_ids,
4467 cap_ndoms(iommu->cap)));
4468}
4469static DEVICE_ATTR(domains_used, S_IRUGO, intel_iommu_show_ndoms_used, NULL);
4470
4452static struct attribute *intel_iommu_attrs[] = { 4471static struct attribute *intel_iommu_attrs[] = {
4453 &dev_attr_version.attr, 4472 &dev_attr_version.attr,
4454 &dev_attr_address.attr, 4473 &dev_attr_address.attr,
4455 &dev_attr_cap.attr, 4474 &dev_attr_cap.attr,
4456 &dev_attr_ecap.attr, 4475 &dev_attr_ecap.attr,
4476 &dev_attr_domains_supported.attr,
4477 &dev_attr_domains_used.attr,
4457 NULL, 4478 NULL,
4458}; 4479};
4459 4480