IOMMU Fixes:

* Fix and issue introduced this merge window into the AMD and
 	  Intel IOMMU drivers that causes an oops when the
 	  vendor-specific sysfs-entries are accessed.
 	  Reason for this issue is that I forgot to update the sysfs
 	  code in the drivers when moving the iommu 'struct device' to
 	  the iommu-core.
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2
 
 iQIcBAABAgAGBQJYtY44AAoJECvwRC2XARrj4YcP/j1AERrFxEPuxBIxclYWi5iH
 cgTD0xuc3VqXX3suA6HV3FDXQFkx9HVRBImEb8IT1h1/KzgCsbcgpt9EqZWY+T6W
 4zKf86sHIoC9rRZns7eoPey96356gUppnoTmgKVIRAJI7b7A6BqDDd+0Lw4vclSe
 2uzYrvLYKJj6k7ekg7jqwkU73O9IS90MGSRR99N8dNpKY04OBFgOQIuOqt80z6IN
 k37rnDH6YNBTKsb3QOWhSK0yRHNY3sSHJosUxaxD/w9/ZkxkkTUzOspmQQgYotO+
 B/Sy2NfQH06L1PMO7gdKgzZrzgDFyLYN4pakzenZ1wqmFbk4fq/Uw3KyNEQuLsrg
 iXhAy53UInb6P3HJWq9M1PtoB8WL2WquM7zWHLqDmlb38AOVn17fE/DEjM3o3J+a
 CGSly0JVQFAAMIJQ/pRGLxsAdL2qHQT2XH5jmYA+k7C3EdyrVHK1NzQcZg55Lx6J
 chyRU1nOQBfnzMUcvsS4eJXjGBXesz6JUhWus5UpbcdiI27nvg2zrUAJAuzn1+AV
 lUoHsWllLIq8cn6KENY/sQO4g52jFE2FZGNnlEt0+ZxIpM3pawSnkdSLncUo/HY4
 YippEdzSv1YrmGQDu4fyvqZj05PS+mwrh3unbFfTVdM94So9+o2vwRuwLUYC+/PQ
 1964I8+k9F0CArBNG5yI
 =NM+y
 -----END PGP SIGNATURE-----

Merge tag 'iommu-fix-v4.11-rc0-2' of git://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu

Pull IOMMU fixes from Joerg Roedel:
 "Fix an issue introduced this merge window into the AMD and Intel IOMMU
  drivers that causes an oops when the vendor-specific sysfs-entries are
  accessed.

  The reason for this issue is that I forgot to update the sysfs code in
  the drivers when moving the iommu 'struct device' to the iommu-core"

* tag 'iommu-fix-v4.11-rc0-2' of git://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu:
  iommu/amd: Fix crash when accessing AMD-Vi sysfs entries
  iommu/vt-d: Fix crash when accessing VT-d sysfs entries
This commit is contained in:
Linus Torvalds 2017-02-28 20:18:44 -08:00
commit 5ecc5ac215
3 changed files with 18 additions and 8 deletions

View File

@ -1507,7 +1507,7 @@ static ssize_t amd_iommu_show_cap(struct device *dev,
struct device_attribute *attr,
char *buf)
{
struct amd_iommu *iommu = dev_get_drvdata(dev);
struct amd_iommu *iommu = dev_to_amd_iommu(dev);
return sprintf(buf, "%x\n", iommu->cap);
}
static DEVICE_ATTR(cap, S_IRUGO, amd_iommu_show_cap, NULL);
@ -1516,7 +1516,7 @@ static ssize_t amd_iommu_show_features(struct device *dev,
struct device_attribute *attr,
char *buf)
{
struct amd_iommu *iommu = dev_get_drvdata(dev);
struct amd_iommu *iommu = dev_to_amd_iommu(dev);
return sprintf(buf, "%llx\n", iommu->features);
}
static DEVICE_ATTR(features, S_IRUGO, amd_iommu_show_features, NULL);

View File

@ -569,6 +569,11 @@ struct amd_iommu {
volatile u64 __aligned(8) cmd_sem;
};
static inline struct amd_iommu *dev_to_amd_iommu(struct device *dev)
{
return container_of(dev, struct amd_iommu, iommu.dev);
}
#define ACPIHID_UID_LEN 256
#define ACPIHID_HID_LEN 9

View File

@ -4730,11 +4730,16 @@ static int intel_iommu_cpu_dead(unsigned int cpu)
return 0;
}
static inline struct intel_iommu *dev_to_intel_iommu(struct device *dev)
{
return container_of(dev, struct intel_iommu, iommu.dev);
}
static ssize_t intel_iommu_show_version(struct device *dev,
struct device_attribute *attr,
char *buf)
{
struct intel_iommu *iommu = dev_get_drvdata(dev);
struct intel_iommu *iommu = dev_to_intel_iommu(dev);
u32 ver = readl(iommu->reg + DMAR_VER_REG);
return sprintf(buf, "%d:%d\n",
DMAR_VER_MAJOR(ver), DMAR_VER_MINOR(ver));
@ -4745,7 +4750,7 @@ static ssize_t intel_iommu_show_address(struct device *dev,
struct device_attribute *attr,
char *buf)
{
struct intel_iommu *iommu = dev_get_drvdata(dev);
struct intel_iommu *iommu = dev_to_intel_iommu(dev);
return sprintf(buf, "%llx\n", iommu->reg_phys);
}
static DEVICE_ATTR(address, S_IRUGO, intel_iommu_show_address, NULL);
@ -4754,7 +4759,7 @@ static ssize_t intel_iommu_show_cap(struct device *dev,
struct device_attribute *attr,
char *buf)
{
struct intel_iommu *iommu = dev_get_drvdata(dev);
struct intel_iommu *iommu = dev_to_intel_iommu(dev);
return sprintf(buf, "%llx\n", iommu->cap);
}
static DEVICE_ATTR(cap, S_IRUGO, intel_iommu_show_cap, NULL);
@ -4763,7 +4768,7 @@ static ssize_t intel_iommu_show_ecap(struct device *dev,
struct device_attribute *attr,
char *buf)
{
struct intel_iommu *iommu = dev_get_drvdata(dev);
struct intel_iommu *iommu = dev_to_intel_iommu(dev);
return sprintf(buf, "%llx\n", iommu->ecap);
}
static DEVICE_ATTR(ecap, S_IRUGO, intel_iommu_show_ecap, NULL);
@ -4772,7 +4777,7 @@ static ssize_t intel_iommu_show_ndoms(struct device *dev,
struct device_attribute *attr,
char *buf)
{
struct intel_iommu *iommu = dev_get_drvdata(dev);
struct intel_iommu *iommu = dev_to_intel_iommu(dev);
return sprintf(buf, "%ld\n", cap_ndoms(iommu->cap));
}
static DEVICE_ATTR(domains_supported, S_IRUGO, intel_iommu_show_ndoms, NULL);
@ -4781,7 +4786,7 @@ static ssize_t intel_iommu_show_ndoms_used(struct device *dev,
struct device_attribute *attr,
char *buf)
{
struct intel_iommu *iommu = dev_get_drvdata(dev);
struct intel_iommu *iommu = dev_to_intel_iommu(dev);
return sprintf(buf, "%d\n", bitmap_weight(iommu->domain_ids,
cap_ndoms(iommu->cap)));
}