Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1676121 > unrolled thread
| Started by | Jacob Pan <jacob.jun.pan@linux.intel.com> |
|---|---|
| First post | 2017-06-27 21:50 +0200 |
| Last post | 2017-06-28 20:00 +0200 |
| Articles | 7 — 2 participants |
Back to article view | Back to linux.kernel
[RFC 0/9] IOMMU driver support for shared virtual memory virtualization Jacob Pan <jacob.jun.pan@linux.intel.com> - 2017-06-27 21:50 +0200
[PATCH 6/9] iommu/vt-d: track device with pasid table bond to a guest Jacob Pan <jacob.jun.pan@linux.intel.com> - 2017-06-27 21:50 +0200
[PATCH 7/9] iommu/dmar: notify unrecoverable faults Jacob Pan <jacob.jun.pan@linux.intel.com> - 2017-06-27 21:50 +0200
[PATCH 8/9] iommu/intel-svm: notify page request to guest Jacob Pan <jacob.jun.pan@linux.intel.com> - 2017-06-27 21:50 +0200
[PATCH 5/9] iommu: Introduce fault notifier API Jacob Pan <jacob.jun.pan@linux.intel.com> - 2017-06-27 21:50 +0200
Re: [PATCH 5/9] iommu: Introduce fault notifier API Joerg Roedel <joro@8bytes.org> - 2017-06-28 12:20 +0200
Re: [PATCH 5/9] iommu: Introduce fault notifier API Jacob Pan <jacob.jun.pan@linux.intel.com> - 2017-06-28 20:00 +0200
| From | Jacob Pan <jacob.jun.pan@linux.intel.com> |
|---|---|
| Date | 2017-06-27 21:50 +0200 |
| Subject | [RFC 0/9] IOMMU driver support for shared virtual memory virtualization |
| Message-ID | <tX4EN-57v-3@gated-at.bofh.it> |
Shared virtual memory (SVM) space between devices and applications can reduce programming complexity and enhance security. To enable SVM in the guest, i.e. share guest application address space with physical device DMA address, IOMMU driver must provide some new functionalities. The complete guest SVM support also involves changes in QEMU and VFIO, which has been posted earlier. https://www.spinics.net/lists/kvm/msg148798.html This is the IOMMU portion follow up of the more complete series of the kernel changes to support SVM. Please refer to the link below for more details. https://www.spinics.net/lists/kvm/msg148819.html Generic APIs are introduced in addition to Intel VT-d specific changes, the goal is to have common interfaces across IOMMU and device types for both VFIO and other in-kernel users. At the top level, three new IOMMU interfaces are introduced: - bind PASID table - passdown invalidation - per device IOMMU fault notification The additional patches are Intel VT-d specific, which either implements or replaces existing private interfaces with the generic ones. Thanks, Jacob Jacob Pan (8): iommu: Introduce bind_pasid_table API function iommu/vt-d: add bind_pasid_table function iommu/vt-d: Add iommu do invalidate function iommu: Introduce fault notifier API iommu/vt-d: track device with pasid table bond to a guest iommu/dmar: notify unrecoverable faults iommu/intel-svm: notify page request to guest iommu/intel-svm: replace dev ops with generic fault notifier Liu, Yi L (1): iommu: Introduce iommu do invalidate API function drivers/iommu/dmar.c | 38 ++++++++- drivers/iommu/intel-iommu.c | 177 +++++++++++++++++++++++++++++++++++++----- drivers/iommu/intel-svm.c | 102 +++++++++++++++++++++--- drivers/iommu/iommu.c | 77 ++++++++++++++++++ include/linux/dma_remapping.h | 1 + include/linux/intel-iommu.h | 30 ++++++- include/linux/intel-svm.h | 20 +---- include/linux/iommu.h | 59 ++++++++++++++ include/uapi/linux/iommu.h | 85 ++++++++++++++++++++ 9 files changed, 540 insertions(+), 49 deletions(-) create mode 100644 include/uapi/linux/iommu.h -- 2.7.4
[toc] | [next] | [standalone]
| From | Jacob Pan <jacob.jun.pan@linux.intel.com> |
|---|---|
| Date | 2017-06-27 21:50 +0200 |
| Subject | [PATCH 6/9] iommu/vt-d: track device with pasid table bond to a guest |
| Message-ID | <tX4EP-57v-47@gated-at.bofh.it> |
| In reply to | #1676121 |
When PASID table pointer of an assigned device is bond to a guest,
the first level page tables are managed by the guest. However, only
host/physical IOMMU can detect fault events, e.g. page requests.
Therefore, we need to keep track of which device has its PASID table
pointer bond to a guest such that page request and other events can
be propagated to the guest as needed.
Signed-off-by: Jacob Pan <jacob.jun.pan@linux.intel.com>
Signed-off-by: Ashok Raj <ashok.raj@intel.com>
---
drivers/iommu/intel-iommu.c | 19 +------------------
include/linux/intel-iommu.h | 19 +++++++++++++++++++
2 files changed, 20 insertions(+), 18 deletions(-)
diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
index 242bb8c..d911d47 100644
--- a/drivers/iommu/intel-iommu.c
+++ b/drivers/iommu/intel-iommu.c
@@ -416,24 +416,6 @@ struct dmar_domain {
iommu core */
};
-/* PCI domain-device relationship */
-struct device_domain_info {
- struct list_head link; /* link to domain siblings */
- struct list_head global; /* link to global list */
- u8 bus; /* PCI bus number */
- u8 devfn; /* PCI devfn number */
- u8 pasid_supported:3;
- u8 pasid_enabled:1;
- u8 pri_supported:1;
- u8 pri_enabled:1;
- u8 ats_supported:1;
- u8 ats_enabled:1;
- u8 ats_qdep;
- struct device *dev; /* it's NULL for PCIe-to-PCI bridge */
- struct intel_iommu *iommu; /* IOMMU used by this device */
- struct dmar_domain *domain; /* pointer to domain */
-};
-
struct dmar_rmrr_unit {
struct list_head list; /* list of rmrr units */
struct acpi_dmar_header *hdr; /* ACPI header */
@@ -5555,6 +5537,7 @@ static int intel_iommu_bind_pasid_table(struct iommu_domain *domain,
DMA_CCMD_MASK_NOBIT,
DMA_CCMD_DEVICE_INVL);
iommu->flush.flush_iotlb(iommu, did, 0, 0, DMA_TLB_DSI_FLUSH);
+ info->pasid_tbl_bound = 1;
spin_unlock_irqrestore(&iommu->lock, flags);
diff --git a/include/linux/intel-iommu.h b/include/linux/intel-iommu.h
index 8df6c91..61f81ab 100644
--- a/include/linux/intel-iommu.h
+++ b/include/linux/intel-iommu.h
@@ -434,6 +434,25 @@ struct intel_iommu {
u32 flags; /* Software defined flags */
};
+/* PCI domain-device relationship */
+struct device_domain_info {
+ struct list_head link; /* link to domain siblings */
+ struct list_head global; /* link to global list */
+ u8 bus; /* PCI bus number */
+ u8 devfn; /* PCI devfn number */
+ u8 pasid_supported:3;
+ u8 pasid_enabled:1;
+ u8 pasid_tbl_bound:1; /* bound to guest PASID table */
+ u8 pri_supported:1;
+ u8 pri_enabled:1;
+ u8 ats_supported:1;
+ u8 ats_enabled:1;
+ u8 ats_qdep;
+ struct device *dev; /* it's NULL for PCIe-to-PCI bridge */
+ struct intel_iommu *iommu; /* IOMMU used by this device */
+ struct dmar_domain *domain; /* pointer to domain */
+};
+
static inline void __iommu_flush_cache(
struct intel_iommu *iommu, void *addr, int size)
{
--
2.7.4
[toc] | [prev] | [next] | [standalone]
| From | Jacob Pan <jacob.jun.pan@linux.intel.com> |
|---|---|
| Date | 2017-06-27 21:50 +0200 |
| Subject | [PATCH 7/9] iommu/dmar: notify unrecoverable faults |
| Message-ID | <tX4EP-57v-45@gated-at.bofh.it> |
| In reply to | #1676121 |
Currently, when device DMA faults are detected by IOMMU the fault
reasons are printed but the offending device is not notified.
This patch allows device drivers to be optionally notified for fault
conditions when device specific handling is needed for more subtle
processing, e.g. request with PASID transactions.
Signed-off-by: Jacob Pan <jacob.jun.pan@linux.intel.com>
Signed-off-by: Ashok Raj <ashok.raj@intel.com>
---
drivers/iommu/dmar.c | 38 +++++++++++++++++++++++++++++++++++++-
1 file changed, 37 insertions(+), 1 deletion(-)
diff --git a/drivers/iommu/dmar.c b/drivers/iommu/dmar.c
index cbf7763..459a472 100644
--- a/drivers/iommu/dmar.c
+++ b/drivers/iommu/dmar.c
@@ -1587,6 +1587,39 @@ void dmar_msi_read(int irq, struct msi_msg *msg)
raw_spin_unlock_irqrestore(&iommu->register_lock, flag);
}
+static int dmar_unrecov_fault_notify(u8 fault_reason, u16 source_id,
+ unsigned long long addr)
+{
+ int ret;
+ struct pci_dev *pdev;
+ struct iommu_fault_event *event;
+
+ pdev = pci_get_bus_and_slot(source_id >> 8, source_id & 0xFF);
+ if (!pdev)
+ return -ENODEV;
+ pr_debug("Notify PCI device fault [%02x:%02x.%d]\n",
+ source_id >> 8, PCI_SLOT(source_id & 0xff),
+ PCI_FUNC(source_id & 0xff));
+ event = kzalloc(sizeof(*event) + sizeof(fault_reason), GFP_KERNEL);
+ if (!event) {
+ ret = -ENOMEM;
+ goto exit_dev_put;
+ }
+
+ event->dev = &pdev->dev;
+ event->buf[0] = fault_reason;
+ event->addr = addr;
+ event->length = sizeof(fault_reason);
+ event->flags = IOMMU_FAULT_UNRECOV;
+ ret = iommu_fault_notifier_call_chain(event);
+
+ kfree(event);
+exit_dev_put:
+ pci_dev_put(pdev);
+
+ return ret;
+}
+
static int dmar_fault_do_one(struct intel_iommu *iommu, int type,
u8 fault_reason, u16 source_id, unsigned long long addr)
{
@@ -1600,11 +1633,14 @@ static int dmar_fault_do_one(struct intel_iommu *iommu, int type,
source_id >> 8, PCI_SLOT(source_id & 0xFF),
PCI_FUNC(source_id & 0xFF), addr >> 48,
fault_reason, reason);
- else
+ else {
pr_err("[%s] Request device [%02x:%02x.%d] fault addr %llx [fault reason %02d] %s\n",
type ? "DMA Read" : "DMA Write",
source_id >> 8, PCI_SLOT(source_id & 0xFF),
PCI_FUNC(source_id & 0xFF), addr, fault_reason, reason);
+ dmar_unrecov_fault_notify(fault_reason, source_id, addr);
+ }
+
return 0;
}
--
2.7.4
[toc] | [prev] | [next] | [standalone]
| From | Jacob Pan <jacob.jun.pan@linux.intel.com> |
|---|---|
| Date | 2017-06-27 21:50 +0200 |
| Subject | [PATCH 8/9] iommu/intel-svm: notify page request to guest |
| Message-ID | <tX4EP-57v-51@gated-at.bofh.it> |
| In reply to | #1676121 |
If the source device of a page request has its PASID table pointer
bond to a guest, the first level page tables are owned by the guest.
In this case, we shall let guest OS to manage page fault.
This patch uses the IOMMU fault notification API to send notifications,
possibly via VFIO, to the guest OS. Once guest pages are fault in, guest
will issue page response which will be passed down via the invalidation
passdown APIs.
Signed-off-by: Jacob Pan <jacob.jun.pan@linux.intel.com>
Signed-off-by: Ashok Raj <ashok.raj@intel.com>
---
drivers/iommu/intel-svm.c | 89 ++++++++++++++++++++++++++++++++++++++++++++++-
include/linux/iommu.h | 1 +
2 files changed, 89 insertions(+), 1 deletion(-)
diff --git a/drivers/iommu/intel-svm.c b/drivers/iommu/intel-svm.c
index 23c4276..98fca35 100644
--- a/drivers/iommu/intel-svm.c
+++ b/drivers/iommu/intel-svm.c
@@ -525,6 +525,88 @@ static bool access_error(struct vm_area_struct *vma, struct page_req_dsc *req)
return (requested & ~vma->vm_flags) != 0;
}
+static int prq_to_iommu_prot(struct page_req_dsc *req)
+{
+ int prot = 0;
+
+ if (req->rd_req)
+ prot |= IOMMU_READ;
+ if (req->wr_req)
+ prot |= IOMMU_WRITE;
+ if (req->exe_req)
+ prot |= IOMMU_EXEC;
+ if (req->priv_req)
+ prot |= IOMMU_PRIV;
+
+ return prot;
+}
+
+static int intel_svm_prq_notify(struct device *dev, struct page_req_dsc *desc)
+{
+ int ret = 0;
+ struct iommu_fault_event *event;
+ struct pci_dev *pdev;
+ struct device_domain_info *info;
+ unsigned long buf_offset;
+
+ /**
+ * If caller does not provide struct device, this is the case where
+ * guest PASID table is bound to the device. So we need to retrieve
+ * struct device from the page request descriptor then proceed.
+ */
+ if (!dev) {
+ pdev = pci_get_bus_and_slot(desc->bus, desc->devfn);
+ if (!pdev) {
+ pr_err("No PCI device found for PRQ [%02x:%02x.%d]\n",
+ desc->bus, PCI_SLOT(desc->devfn),
+ PCI_FUNC(desc->devfn));
+ return -ENODEV;
+ }
+ /**
+ * Make sure PASID table pointer is bound to guest, if yes notify
+ * handler in the guest, e.g. via VFIO.
+ */
+ info = pdev->dev.archdata.iommu;
+ if (!info || !info->pasid_tbl_bound) {
+ pr_debug("PRQ device pasid table not bound.\n");
+ ret = -EINVAL;
+ goto exit_put_dev;
+ }
+ dev = &pdev->dev;
+ } else if (dev_is_pci(dev)) {
+ pdev = to_pci_dev(dev);
+ pci_dev_get(pdev);
+ } else
+ return -ENODEV;
+
+ pr_debug("Notify PRQ device [%02x:%02x.%d]\n",
+ desc->bus, PCI_SLOT(desc->devfn),
+ PCI_FUNC(desc->devfn));
+ event = kzalloc(sizeof(*event) + sizeof(*desc), GFP_KERNEL);
+ if (!event) {
+ ret = -ENOMEM;
+ goto exit_put_dev;
+ }
+
+ /* Fill in event data for device specific processing */
+ event->dev = dev;
+ buf_offset = offsetofend(struct iommu_fault_event, length);
+ memcpy(buf_offset + event, desc, sizeof(*desc));
+ event->addr = desc->addr;
+ event->pasid = desc->pasid;
+ event->prot = prq_to_iommu_prot(desc);
+ event->length = sizeof(*desc);
+ event->flags = IOMMU_FAULT_PAGE_REQ;
+
+ ret = iommu_fault_notifier_call_chain(event);
+ kfree(event);
+
+exit_put_dev:
+ pci_dev_put(pdev);
+
+ return ret;
+}
+
static irqreturn_t prq_event_thread(int irq, void *d)
{
struct intel_iommu *iommu = d;
@@ -548,7 +630,12 @@ static irqreturn_t prq_event_thread(int irq, void *d)
handled = 1;
req = &iommu->prq[head / sizeof(*req)];
-
+ /**
+ * If prq is to be handled outside iommu driver via receiver of
+ * the fault notifiers, we skip the page response here.
+ */
+ if (!intel_svm_prq_notify(NULL, req))
+ continue;
result = QI_RESP_FAILURE;
address = (u64)req->addr << VTD_PAGE_SHIFT;
if (!req->pasid_present) {
diff --git a/include/linux/iommu.h b/include/linux/iommu.h
index ed2f804..d0f28cd 100644
--- a/include/linux/iommu.h
+++ b/include/linux/iommu.h
@@ -42,6 +42,7 @@
* if the IOMMU page table format is equivalent.
*/
#define IOMMU_PRIV (1 << 5)
+#define IOMMU_EXEC (1 << 6)
struct iommu_ops;
struct iommu_group;
--
2.7.4
[toc] | [prev] | [next] | [standalone]
| From | Jacob Pan <jacob.jun.pan@linux.intel.com> |
|---|---|
| Date | 2017-06-27 21:50 +0200 |
| Subject | [PATCH 5/9] iommu: Introduce fault notifier API |
| Message-ID | <tX4EP-57v-49@gated-at.bofh.it> |
| In reply to | #1676121 |
Traditionally, device specific faults are detected and handled within
their own device drivers. When IOMMU is enabled, faults such as DMA
related transactions are detected by IOMMU. There is no generic
reporting mechanism to report faults back to the in-kernel device
driver or the guest OS in case of assigned devices.
Faults detected by IOMMU is based on the transaction's source ID which
can be reported at per device basis, regardless of the device type is a
PCI device or not.
The fault types includes recoverable (e.g. page request) and
unrecoverable faults(e.g. invalid context). In most cases, faults can be
handled by IOMMU drivers. However, there are use cases that require
fault processing outside IOMMU driver, e.g.
1. page request fault originated from an SVM capable device that is
assigned to guest via vIOMMU. In this case, the first level page tables
are owned by the guest. Page request must be propagated to the guest to
let guest OS fault in the pages then send page response. In this
mechanism, the direct receiver of IOMMU fault notification is VFIO,
which can relay notification events to QEMU or other user space
software.
2. faults need more subtle handling by device drivers. Other than
simply invoke reset function, there are needs to let device driver
handle the fault with a smaller impact.
This patchset is intended to create a generic fault notification API such
that it can scale as follows:
- all IOMMU types
- PCI and non-PCI devices
- recoverable and unrecoverable faults
- VFIO and other other in kernel users
- DMA & IRQ remapping (TBD)
The event data contains both generic and raw architectural data
such that performance is not compromised as the data propagation may
involve many layers.
Signed-off-by: Jacob Pan <jacob.jun.pan@linux.intel.com>
Signed-off-by: Ashok Raj <ashok.raj@intel.com>
---
drivers/iommu/iommu.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
include/linux/iommu.h | 23 +++++++++++++++++++++++
include/uapi/linux/iommu.h | 34 ++++++++++++++++++++++++++++++++++
3 files changed, 101 insertions(+)
diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
index d973555..07cfd92 100644
--- a/drivers/iommu/iommu.c
+++ b/drivers/iommu/iommu.c
@@ -48,6 +48,7 @@ struct iommu_group {
struct list_head devices;
struct mutex mutex;
struct blocking_notifier_head notifier;
+ struct blocking_notifier_head fault_notifier;
void *iommu_data;
void (*iommu_data_release)(void *iommu_data);
char *name;
@@ -345,6 +346,7 @@ struct iommu_group *iommu_group_alloc(void)
mutex_init(&group->mutex);
INIT_LIST_HEAD(&group->devices);
BLOCKING_INIT_NOTIFIER_HEAD(&group->notifier);
+ BLOCKING_INIT_NOTIFIER_HEAD(&group->fault_notifier);
ret = ida_simple_get(&iommu_group_ida, 0, 0, GFP_KERNEL);
if (ret < 0) {
@@ -790,6 +792,48 @@ int iommu_group_unregister_notifier(struct iommu_group *group,
EXPORT_SYMBOL_GPL(iommu_group_unregister_notifier);
/**
+ * iommu_register_fault_notifier - Register a notifier for fault reporting
+ * @group: device's iommu group to notify fault events
+ * @nb: notifier block to signal
+ *
+ */
+int iommu_register_fault_notifier(struct iommu_group *group,
+ struct notifier_block *nb)
+{
+ return blocking_notifier_chain_register(&group->fault_notifier, nb);
+}
+EXPORT_SYMBOL_GPL(iommu_register_fault_notifier);
+
+/**
+ * iommu_unregister_fault_notifier - Unregister a notifier for fault reporting
+ * @domain: the domain to watch
+ * @nb: notifier block to signal
+ *
+ */
+int iommu_unregister_fault_notifier(struct iommu_group *group,
+ struct notifier_block *nb)
+{
+ return blocking_notifier_chain_unregister(&group->fault_notifier, nb);
+}
+EXPORT_SYMBOL_GPL(iommu_unregister_fault_notifier);
+
+int iommu_fault_notifier_call_chain(struct iommu_fault_event *event)
+{
+ int ret;
+ struct iommu_group *group = iommu_group_get(event->dev);
+
+ if (!group)
+ return -EINVAL;
+ /* caller provide generic data related to the event, TBD */
+ ret = (blocking_notifier_call_chain(&group->fault_notifier, 0, (void *)event)
+ == NOTIFY_BAD) ? -EINVAL : 0;
+ iommu_group_put(group);
+
+ return ret;
+}
+EXPORT_SYMBOL(iommu_fault_notifier_call_chain);
+
+/**
* iommu_group_id - Return ID for a group
* @group: the group to ID
*
diff --git a/include/linux/iommu.h b/include/linux/iommu.h
index fbc08ae..ed2f804 100644
--- a/include/linux/iommu.h
+++ b/include/linux/iommu.h
@@ -342,6 +342,12 @@ extern int iommu_group_register_notifier(struct iommu_group *group,
struct notifier_block *nb);
extern int iommu_group_unregister_notifier(struct iommu_group *group,
struct notifier_block *nb);
+extern int iommu_register_fault_notifier(struct iommu_group *group,
+ struct notifier_block *nb);
+extern int iommu_unregister_fault_notifier(struct iommu_group *group,
+ struct notifier_block *nb);
+extern int iommu_fault_notifier_call_chain(struct iommu_fault_event *event);
+
extern int iommu_group_id(struct iommu_group *group);
extern struct iommu_group *iommu_group_get_for_dev(struct device *dev);
extern struct iommu_domain *iommu_group_default_domain(struct iommu_group *);
@@ -574,6 +580,23 @@ static inline int iommu_group_unregister_notifier(struct iommu_group *group,
return 0;
}
+static inline int iommu_register_fault_notifier(struct device *dev,
+ struct notifier_block *nb)
+{
+ return 0;
+}
+
+static inline int iommu_unregister_fault_notifier(struct device *dev,
+ struct notifier_block *nb)
+{
+ return 0;
+}
+
+static inline int iommu_fault_notifier_call_chain(struct iommu_fault_event *event)
+{
+ return 0;
+}
+
static inline int iommu_group_id(struct iommu_group *group)
{
return -ENODEV;
diff --git a/include/uapi/linux/iommu.h b/include/uapi/linux/iommu.h
index f077353..a8e3d7f 100644
--- a/include/uapi/linux/iommu.h
+++ b/include/uapi/linux/iommu.h
@@ -48,4 +48,38 @@ struct tlb_invalidate_info {
__u8 opaque[];
};
+/*
+ * Generic fault event notification data, used by all IOMMU models
+ *
+ * - PCI and non-PCI devices
+ * - Recoverable faults (e.g. page request) & un-recoverable faults
+ * - DMA remapping and IRQ remapping faults
+ *
+ * @dev The device which faults are reported by IOMMU
+ * @addr tells the offending address
+ * @pasid contains process address space ID, used in shared virtual memory (SVM)
+ * @prot page access protection flag, e.g. IOMMU_READ, IOMMU_WRITE
+ * @flags contains fault type, etc.
+ * @length tells the size of the buf in bytes
+ * @buf contains any raw or arch specific data
+ *
+ */
+struct iommu_fault_event {
+ struct device *dev;
+ __u64 addr;
+ __u32 pasid;
+ __u32 prot;
+ __u32 flags;
+/* page request as result of recoverable translation fault */
+#define IOMMU_FAULT_PAGE_REQ BIT(0)
+/* unrecoverable fault, e.g. invalid device context */
+#define IOMMU_FAULT_UNRECOV BIT(1)
+/* unrecoverable fault related to interrupt remapping */
+#define IOMMU_FAULT_IRQ_REMAP BIT(2)
+/* unrecoverable fault on invalidation of translation caches */
+#define IOMMU_FAULT_INVAL BIT(3)
+ __u32 length;
+ __u8 buf[];
+};
+
#endif /* _UAPI_IOMMU_H */
--
2.7.4
[toc] | [prev] | [next] | [standalone]
| From | Joerg Roedel <joro@8bytes.org> |
|---|---|
| Date | 2017-06-28 12:20 +0200 |
| Subject | Re: [PATCH 5/9] iommu: Introduce fault notifier API |
| Message-ID | <tXieK-5vN-25@gated-at.bofh.it> |
| In reply to | #1676125 |
On Tue, Jun 27, 2017 at 12:47:59PM -0700, Jacob Pan wrote:
> diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
> index d973555..07cfd92 100644
> --- a/drivers/iommu/iommu.c
> +++ b/drivers/iommu/iommu.c
> @@ -48,6 +48,7 @@ struct iommu_group {
> struct list_head devices;
> struct mutex mutex;
> struct blocking_notifier_head notifier;
> + struct blocking_notifier_head fault_notifier;
Do you really need a notifier chain here? Will there ever be more than
one callback registered to it?
> +struct iommu_fault_event {
> + struct device *dev;
Putting a 'struct device *' member in a uapi struct looks fundamentally
wrong.
Joerg
[toc] | [prev] | [next] | [standalone]
| From | Jacob Pan <jacob.jun.pan@linux.intel.com> |
|---|---|
| Date | 2017-06-28 20:00 +0200 |
| Subject | Re: [PATCH 5/9] iommu: Introduce fault notifier API |
| Message-ID | <tXpq4-t5-203@gated-at.bofh.it> |
| In reply to | #1676515 |
On Wed, 28 Jun 2017 12:16:03 +0200
Joerg Roedel <joro@8bytes.org> wrote:
> On Tue, Jun 27, 2017 at 12:47:59PM -0700, Jacob Pan wrote:
> > diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
> > index d973555..07cfd92 100644
> > --- a/drivers/iommu/iommu.c
> > +++ b/drivers/iommu/iommu.c
> > @@ -48,6 +48,7 @@ struct iommu_group {
> > struct list_head devices;
> > struct mutex mutex;
> > struct blocking_notifier_head notifier;
> > + struct blocking_notifier_head fault_notifier;
>
> Do you really need a notifier chain here? Will there ever be more than
> one callback registered to it?
>
yes, this notifier chain is shared by all devices under a group. the
event contains device info which notifier callbacks can filter.
> > +struct iommu_fault_event {
> > + struct device *dev;
>
> Putting a 'struct device *' member in a uapi struct looks
> fundamentally wrong.
>
>
my mistake, it was originally (RFC) not in uapi but with the
consideration of using vfio to expose it to user space I have moved it
to uapi. But you are right, it should be some other forms of device
representation used by vfio. VFIO layer has to do the translation and
inject that into the guest. In kernel driver users can use struct
device to identify the faulting device.
>
> Joerg
>
[Jacob Pan]
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web