History

iommu/vt-d: Implement hw_info for iommu capability query

Add intel_iommu_hw_info() to report cap_reg and ecap_reg information.

Yi Liu committed 3 years ago

Commit 55243391 parent af4fde92 files · +42 −0Browse files

Unified · Split

2 files
  1. drivers/iommu/intel/iommu.c +19 −0
  2. include/uapi/linux/iommufd.h +23 −0
drivers/iommu/intel/iommu.c+19−0
@@ -22,6 +22,7 @@ · 21 unmodified lines
2222 #include <linux/spinlock.h>
2323 #include <linux/syscore_ops.h>
2424 #include <linux/tboot.h>
25+#include <uapi/linux/iommufd.h>
2526
2627 #include "iommu.h"
2728 #include "../dma-iommu.h"
@@ -4732,8 +4733,26 @@ static void intel_iommu_remove_dev_pasid(struct device *dev, ioasid_t pasid) · 4704 unmodified lines
47324733 intel_pasid_tear_down_entry(iommu, dev, pasid, false);
47334734 }
47344735
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+
47354753 const struct iommu_ops intel_iommu_ops = {
47364754 .capable = intel_iommu_capable,
4755+ .hw_info = intel_iommu_hw_info,
47374756 .domain_alloc = intel_iommu_domain_alloc,
47384757 .probe_device = intel_iommu_probe_device,
47394758 .probe_finalize = intel_iommu_probe_finalize,
include/uapi/linux/iommufd.h+23−0
@@ -372,13 +372,36 @@ struct iommu_hwpt_alloc { · 371 unmodified lines
372372 };
373373 #define IOMMU_HWPT_ALLOC _IO(IOMMUFD_TYPE, IOMMUFD_CMD_HWPT_ALLOC)
374374
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+
375396 /**
376397 * enum iommu_hw_info_type - IOMMU Hardware Info Types
377398 * @IOMMU_HW_INFO_TYPE_NONE: Used by the drivers that do not report hardware
378399 * info
400+ * @IOMMU_HW_INFO_TYPE_INTEL_VTD: Intel VT-d iommu info type
379401 */
380402 enum iommu_hw_info_type {
381403 IOMMU_HW_INFO_TYPE_NONE,
404+ IOMMU_HW_INFO_TYPE_INTEL_VTD,
382405 };
383406
384407 /**

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t