Skip to content

Commit 2238c08

Browse files
awilliamjoergroedel
authored andcommitted
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>
1 parent 5069076 commit 2238c08

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

drivers/iommu/intel-iommu.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4449,11 +4449,32 @@ static ssize_t intel_iommu_show_ecap(struct device *dev,
44494449
}
44504450
static DEVICE_ATTR(ecap, S_IRUGO, intel_iommu_show_ecap, NULL);
44514451

4452+
static 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+
}
4459+
static DEVICE_ATTR(domains_supported, S_IRUGO, intel_iommu_show_ndoms, NULL);
4460+
4461+
static 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+
}
4469+
static DEVICE_ATTR(domains_used, S_IRUGO, intel_iommu_show_ndoms_used, NULL);
4470+
44524471
static struct attribute *intel_iommu_attrs[] = {
44534472
&dev_attr_version.attr,
44544473
&dev_attr_address.attr,
44554474
&dev_attr_cap.attr,
44564475
&dev_attr_ecap.attr,
4476+
&dev_attr_domains_supported.attr,
4477+
&dev_attr_domains_used.attr,
44574478
NULL,
44584479
};
44594480

0 commit comments

Comments
 (0)