Add intel_iommu_hw_info() to report cap_reg and ecap_reg information.
Unified · Split
| @@ -22,6 +22,7 @@ · 21 unmodified lines | |||
| 22 | #include <linux/spinlock.h> | 22 | #include <linux/spinlock.h> |
| 23 | #include <linux/syscore_ops.h> | 23 | #include <linux/syscore_ops.h> |
| 24 | #include <linux/tboot.h> | 24 | #include <linux/tboot.h> |
| 25 | #include <uapi/linux/iommufd.h> | ||
| 25 | 26 | ||
| 26 | #include "iommu.h" | 27 | #include "iommu.h" |
| 27 | #include "../dma-iommu.h" | 28 | #include "../dma-iommu.h" |
| @@ -4732,8 +4733,26 @@ static void intel_iommu_remove_dev_pasid(struct device *dev, ioasid_t pasid) · 4704 unmodified lines | |||
| 4732 | intel_pasid_tear_down_entry(iommu, dev, pasid, false); | 4733 | intel_pasid_tear_down_entry(iommu, dev, pasid, false); |
| 4733 | } | 4734 | } |
| 4734 | 4735 | ||
| 4736 | static void *intel_iommu_hw_info(struct device *dev, u32 *length, u32 *type) | ||
| 4737 | { | ||
| 4738 | struct device_domain_info *info = dev_iommu_priv_get(dev); | ||
| 4739 | struct intel_iommu *iommu = info->iommu; | ||
| 4740 | struct iommu_hw_info_vtd *vtd; | ||
| 4741 | |||
| 4742 | vtd = kzalloc(sizeof(*vtd), GFP_KERNEL); | ||
| 4743 | if (!vtd) | ||
| 4744 | return ERR_PTR(-ENOMEM); | ||
| 4745 | |||
| 4746 | vtd->cap_reg = iommu->cap; | ||
| 4747 | vtd->ecap_reg = iommu->ecap; | ||
| 4748 | *length = sizeof(*vtd); | ||
| 4749 | *type = IOMMU_HW_INFO_TYPE_INTEL_VTD; | ||
| 4750 | return vtd; | ||
| 4751 | } | ||
| 4752 | |||
| 4735 | const struct iommu_ops intel_iommu_ops = { | 4753 | const struct iommu_ops intel_iommu_ops = { |
| 4736 | .capable = intel_iommu_capable, | 4754 | .capable = intel_iommu_capable, |
| 4755 | .hw_info = intel_iommu_hw_info, | ||
| 4737 | .domain_alloc = intel_iommu_domain_alloc, | 4756 | .domain_alloc = intel_iommu_domain_alloc, |
| 4738 | .probe_device = intel_iommu_probe_device, | 4757 | .probe_device = intel_iommu_probe_device, |
| 4739 | .probe_finalize = intel_iommu_probe_finalize, | 4758 | .probe_finalize = intel_iommu_probe_finalize, |
| @@ -372,13 +372,36 @@ struct iommu_hwpt_alloc { · 371 unmodified lines | |||
| 372 | }; | 372 | }; |
| 373 | #define IOMMU_HWPT_ALLOC _IO(IOMMUFD_TYPE, IOMMUFD_CMD_HWPT_ALLOC) | 373 | #define IOMMU_HWPT_ALLOC _IO(IOMMUFD_TYPE, IOMMUFD_CMD_HWPT_ALLOC) |
| 374 | 374 | ||
| 375 | /** | ||
| 376 | * struct iommu_hw_info_vtd - Intel VT-d hardware information | ||
| 377 | * | ||
| 378 | * @flags: Must be 0 | ||
| 379 | * @__reserved: Must be 0 | ||
| 380 | * | ||
| 381 | * @cap_reg: Value of Intel VT-d capability register defined in VT-d spec | ||
| 382 | * section 11.4.2 Capability Register. | ||
| 383 | * @ecap_reg: Value of Intel VT-d capability register defined in VT-d spec | ||
| 384 | * section 11.4.3 Extended Capability Register. | ||
| 385 | * | ||
| 386 | * User needs to understand the Intel VT-d specification to decode the | ||
| 387 | * register value. | ||
| 388 | */ | ||
| 389 | struct iommu_hw_info_vtd { | ||
| 390 | __u32 flags; | ||
| 391 | __u32 __reserved; | ||
| 392 | __aligned_u64 cap_reg; | ||
| 393 | __aligned_u64 ecap_reg; | ||
| 394 | }; | ||
| 395 | |||
| 375 | /** | 396 | /** |
| 376 | * enum iommu_hw_info_type - IOMMU Hardware Info Types | 397 | * enum iommu_hw_info_type - IOMMU Hardware Info Types |
| 377 | * @IOMMU_HW_INFO_TYPE_NONE: Used by the drivers that do not report hardware | 398 | * @IOMMU_HW_INFO_TYPE_NONE: Used by the drivers that do not report hardware |
| 378 | * info | 399 | * info |
| 400 | * @IOMMU_HW_INFO_TYPE_INTEL_VTD: Intel VT-d iommu info type | ||
| 379 | */ | 401 | */ |
| 380 | enum iommu_hw_info_type { | 402 | enum iommu_hw_info_type { |
| 381 | IOMMU_HW_INFO_TYPE_NONE, | 403 | IOMMU_HW_INFO_TYPE_NONE, |
| 404 | IOMMU_HW_INFO_TYPE_INTEL_VTD, | ||
| 382 | }; | 405 | }; |
| 383 | 406 | ||
| 384 | /** | 407 | /** |