From: Lan Tianyu <tianyu.lan@intel.com>
To: qemu-devel@nongnu.org, xen-devel@lists.xenproject.org
Cc: Chao Gao <chao.gao@intel.com>,
mst@redhat.com, marcel@redhat.com, sstabellini@kernel.org,
anthony.perard@citrix.com, kevin.tian@intel.com,
Lan Tianyu <tianyu.lan@intel.com>
Subject: [Qemu-devel] [RFC PATCH V2 1/2] xen-pt: bind/unbind interrupt remapping format MSI
Date: Thu, 18 May 2017 01:32:59 -0400 [thread overview]
Message-ID: <1495085580-10631-2-git-send-email-tianyu.lan@intel.com> (raw)
In-Reply-To: <1495085580-10631-1-git-send-email-tianyu.lan@intel.com>
From: Chao Gao <chao.gao@intel.com>
If a vIOMMU is exposed to guest, guest will configure the msi to remapping
format. The original code isn't suitable to the new format. A new pair
bind/unbind interfaces are added for this usage. This patch recognizes
this case and use new interfaces to bind/unbind msi.
Signed-off-by: Chao Gao <chao.gao@intel.com>
Signed-off-by: Lan Tianyu <tianyu.lan@intel.com>
---
hw/xen/xen_pt_msi.c | 50 ++++++++++++++++++++++++++++++++-----------
include/hw/i386/apic-msidef.h | 3 ++-
2 files changed, 39 insertions(+), 14 deletions(-)
diff --git a/hw/xen/xen_pt_msi.c b/hw/xen/xen_pt_msi.c
index 62add06..5fab95e 100644
--- a/hw/xen/xen_pt_msi.c
+++ b/hw/xen/xen_pt_msi.c
@@ -163,16 +163,24 @@ static int msi_msix_update(XenPCIPassthroughState *s,
int rc = 0;
uint64_t table_addr = 0;
- XEN_PT_LOG(d, "Updating MSI%s with pirq %d gvec %#x gflags %#x"
- " (entry: %#x)\n",
- is_msix ? "-X" : "", pirq, gvec, gflags, msix_entry);
-
if (is_msix) {
table_addr = s->msix->mmio_base_addr;
}
- rc = xc_domain_update_msi_irq(xen_xc, xen_domid, gvec,
- pirq, gflags, table_addr);
+ if (addr & MSI_ADDR_IF_MASK) {
+ XEN_PT_LOG(d, "Updating MSI%s with addr %#" PRIx64 "data %#x\n",
+ is_msix ? "-X": "", addr, data);
+ rc = xc_domain_update_msi_irq_remapping(xen_xc, xen_domid, pirq,
+ d->devfn, data, addr, table_addr);
+ }
+ else {
+ XEN_PT_LOG(d, "Updating MSI%s with pirq %d gvec %#x gflags %#x"
+ " (entry: %#x)\n",
+ is_msix ? "-X" : "", pirq, gvec, gflags, msix_entry);
+
+ rc = xc_domain_update_msi_irq(xen_xc, xen_domid, gvec,
+ pirq, gflags, table_addr);
+ }
if (rc) {
XEN_PT_ERR(d, "Updating of MSI%s failed. (err: %d)\n",
@@ -204,13 +212,29 @@ static int msi_msix_disable(XenPCIPassthroughState *s,
}
if (is_binded) {
- XEN_PT_LOG(d, "Unbind MSI%s with pirq %d, gvec %#x\n",
- is_msix ? "-X" : "", pirq, gvec);
- rc = xc_domain_unbind_msi_irq(xen_xc, xen_domid, gvec, pirq, gflags);
- if (rc) {
- XEN_PT_ERR(d, "Unbinding of MSI%s failed. (err: %d, pirq: %d, gvec: %#x)\n",
- is_msix ? "-X" : "", errno, pirq, gvec);
- return rc;
+ if ( addr & MSI_ADDR_IF_MASK ) {
+ XEN_PT_LOG(d, "Unbinding of MSI%s . ( pirq: %d, data: %x, "
+ "addr: %#" PRIx64 ")\n",
+ is_msix ? "-X" : "", pirq, data, addr);
+ rc = xc_domain_unbind_msi_irq_remapping(xen_xc, xen_domid, pirq,
+ d->devfn, data, addr);
+ if (rc) {
+ XEN_PT_ERR(d, "Unbinding of MSI%s . (error: %d, pirq: %d, "
+ "data: %x, addr: %#" PRIx64 ")\n",
+ is_msix ? "-X" : "", rc, pirq, data, addr);
+ return rc;
+ }
+
+ } else {
+ XEN_PT_LOG(d, "Unbind MSI%s with pirq %d, gvec %#x\n",
+ is_msix ? "-X" : "", pirq, gvec);
+ rc = xc_domain_unbind_msi_irq(xen_xc, xen_domid, gvec, pirq, gflags);
+ if (rc) {
+ XEN_PT_ERR(d, "Unbinding of MSI%s failed. (err: %d, pirq: %d, "
+ "gvec: %#x)\n",
+ is_msix ? "-X" : "", errno, pirq, gvec);
+ return rc;
+ }
}
}
diff --git a/include/hw/i386/apic-msidef.h b/include/hw/i386/apic-msidef.h
index 8b4d4cc..2c450f9 100644
--- a/include/hw/i386/apic-msidef.h
+++ b/include/hw/i386/apic-msidef.h
@@ -26,6 +26,7 @@
#define MSI_ADDR_DEST_ID_SHIFT 12
#define MSI_ADDR_DEST_IDX_SHIFT 4
-#define MSI_ADDR_DEST_ID_MASK 0x00ffff0
+#define MSI_ADDR_DEST_ID_MASK 0x000fff00
+#define MSI_ADDR_IF_MASK 0x00000010
#endif /* HW_APIC_MSIDEF_H */
--
1.8.3.1
next prev parent reply other threads:[~2017-05-18 11:38 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-18 5:32 [Qemu-devel] [RFC PATCH V2 0/2] Qemu: Add Xen vIOMMU interrupt remapping function Lan Tianyu
2017-05-18 5:32 ` Lan Tianyu [this message]
2017-05-19 11:16 ` [Qemu-devel] [RFC PATCH V2 1/2] xen-pt: bind/unbind interrupt remapping format MSI Anthony PERARD
2017-05-19 12:04 ` [Qemu-devel] [Xen-devel] " Jan Beulich
2017-05-23 12:16 ` Lan Tianyu
2017-05-23 17:06 ` Anthony PERARD
2017-05-24 1:40 ` Lan Tianyu
2017-05-18 5:33 ` [Qemu-devel] [RFC PATCH V2 2/2] msi: Handle remappable format interrupt request Lan Tianyu
2017-05-19 11:57 ` Anthony PERARD
2017-05-22 2:41 ` Lan Tianyu
2017-05-18 13:56 ` [Qemu-devel] [RFC PATCH V2 0/2] Qemu: Add Xen vIOMMU interrupt remapping function no-reply
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=1495085580-10631-2-git-send-email-tianyu.lan@intel.com \
--to=tianyu.lan@intel.com \
--cc=anthony.perard@citrix.com \
--cc=chao.gao@intel.com \
--cc=kevin.tian@intel.com \
--cc=marcel@redhat.com \
--cc=mst@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=sstabellini@kernel.org \
--cc=xen-devel@lists.xenproject.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).