All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lan Tianyu <tianyu.lan@intel.com>
To: qemu-devel@nongnu.org
Cc: Lan Tianyu <tianyu.lan@intel.com>,
	kevin.tian@intel.com, mst@redhat.com, jan.kiszka@siemens.com,
	jasowang@redhat.com, peterx@redhat.com,
	david@gibson.dropbear.id.au, alex.williamson@redhat.com,
	yi.l.liu@intel.com
Subject: [Qemu-devel] [Resend RFC PATCH 3/4] Intel iommu: Add Intel IOMMU fault event callback
Date: Mon, 20 Feb 2017 09:28:06 +0800	[thread overview]
Message-ID: <1487554087-15347-4-git-send-email-tianyu.lan@intel.com> (raw)
In-Reply-To: <1487554087-15347-1-git-send-email-tianyu.lan@intel.com>

This patch is to deal with fault event reported from IOMMU driver.

Signed-off-by: Lan Tianyu <tianyu.lan@intel.com>
---
 hw/i386/intel_iommu.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c
index 9b1ba1b..79507d2 100644
--- a/hw/i386/intel_iommu.c
+++ b/hw/i386/intel_iommu.c
@@ -2286,6 +2286,30 @@ static void vtd_iommu_notify_flag_changed(MemoryRegion *iommu,
     }
 }
 
+static void vtd_iommu_notify_fault_event(MemoryRegion *iommu,
+                                         IOMMUFaultInfo *info)
+{
+    VTDAddressSpace *vtd_as = container_of(iommu, VTDAddressSpace, iommu);
+    IntelIOMMUState *s = vtd_as->iommu_state;
+    bool is_fpd_set = false;
+    uint8_t bus_num = pci_bus_num(vtd_as->bus);
+    uint8_t devfn = vtd_as->devfn;
+    VTDContextEntry ce;
+
+    /* Replace source id with device's vbdf */
+    info->sid = vtd_make_source_id(bus_num, devfn);
+
+    if (!vtd_dev_to_context_entry(s, bus_num, devfn, &ce)) {
+        is_fpd_set = ce.lo & VTD_CONTEXT_ENTRY_FPD;
+        if (is_fpd_set) {
+            trace_vtd_fault_disabled();
+        } else {
+            vtd_report_dmar_fault(s, info->sid, info->addr,
+                                  info->fault_reason, info->is_write);
+        }
+    }
+}
+
 static const VMStateDescription vtd_vmstate = {
     .name = "iommu-intel",
     .version_id = 1,
@@ -2816,6 +2840,7 @@ static void vtd_init(IntelIOMMUState *s)
 
     s->iommu_ops.translate = vtd_iommu_translate;
     s->iommu_ops.notify_flag_changed = vtd_iommu_notify_flag_changed;
+    s->iommu_ops.notify_fault_event = vtd_iommu_notify_fault_event;
     s->iommu_ops.replay = vtd_iommu_replay;
     s->root = 0;
     s->root_extended = false;
-- 
1.8.3.1

  parent reply	other threads:[~2017-02-20  1:35 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-20  1:28 [Qemu-devel] [Resend RFC PATCH 0/4] VT-d: Inject fault event from IOMMU hardware Lan Tianyu
2017-02-20  1:28 ` [Qemu-devel] [Resend RFC PATCH 1/4] VFIO: Set eventfd for IOMMU fault event via new vfio cmd Lan Tianyu
2017-02-20 21:08   ` Alex Williamson
2017-02-20  1:28 ` Lan Tianyu [this message]
2017-02-20 21:08   ` [Qemu-devel] [Resend RFC PATCH 3/4] Intel iommu: Add Intel IOMMU fault event callback Alex Williamson
2017-02-20  1:28 ` [Qemu-devel] [Resend RFC PATCH 4/4] VFIO: Read IOMMU fault info from kernel space when get fault event Lan Tianyu
2017-02-20 21:09   ` Alex Williamson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1487554087-15347-4-git-send-email-tianyu.lan@intel.com \
    --to=tianyu.lan@intel.com \
    --cc=alex.williamson@redhat.com \
    --cc=david@gibson.dropbear.id.au \
    --cc=jan.kiszka@siemens.com \
    --cc=jasowang@redhat.com \
    --cc=kevin.tian@intel.com \
    --cc=mst@redhat.com \
    --cc=peterx@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=yi.l.liu@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.