From: Chao Gao <chao.gao@intel.com>
To: xen-devel@lists.xen.org
Cc: Andrew Cooper <andrew.cooper3@citrix.com>,
Jan Beulich <jbeulich@suse.com>, Chao Gao <chao.gao@intel.com>
Subject: [PATCH v10 5/6] passthrough/io: don't migrate pirq when it is delivered through VT-d PI
Date: Wed, 15 Mar 2017 13:11:21 +0800 [thread overview]
Message-ID: <1489554682-6126-6-git-send-email-chao.gao@intel.com> (raw)
In-Reply-To: <1489554682-6126-1-git-send-email-chao.gao@intel.com>
When a vCPU migrated to another pCPU, pt irqs binded to this vCPU also needed
migration. When VT-d PI is enabled, interrupt vector will be recorded to
a main memory resident data-structure and a notification whose destination
is decided by NDST is generated. NDST is properly adjusted during vCPU
migration so pirq directly injected to guest needn't be migrated.
This patch adds a indicator, @via_pi, to show whether the pt irq is delivered
through VT-d PI.
Signed-off-by: Chao Gao <chao.gao@intel.com>
---
v10:
- Newly added.
xen/arch/x86/hvm/hvm.c | 3 +++
xen/drivers/passthrough/io.c | 15 +++++++++++----
xen/include/xen/hvm/irq.h | 1 +
3 files changed, 15 insertions(+), 4 deletions(-)
diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c
index ccfae4f..abbdab9 100644
--- a/xen/arch/x86/hvm/hvm.c
+++ b/xen/arch/x86/hvm/hvm.c
@@ -445,6 +445,9 @@ static int hvm_migrate_pirq(struct domain *d, struct hvm_pirq_dpci *pirq_dpci,
struct vcpu *v = arg;
if ( (pirq_dpci->flags & HVM_IRQ_DPCI_MACH_MSI) &&
+ (pirq_dpci->flags & HVM_IRQ_DPCI_GUEST_MSI) &&
+ /* Needn't migrate pirq if this pirq is delivered to guest directly.*/
+ (pirq_dpci->gmsi.via_pi != 1) &&
(pirq_dpci->gmsi.dest_vcpu_id == v->vcpu_id) )
{
struct irq_desc *desc =
diff --git a/xen/drivers/passthrough/io.c b/xen/drivers/passthrough/io.c
index 080183e..37d9af6 100644
--- a/xen/drivers/passthrough/io.c
+++ b/xen/drivers/passthrough/io.c
@@ -365,6 +365,7 @@ int pt_irq_create_bind(
{
uint8_t dest, dest_mode, delivery_mode;
int dest_vcpu_id;
+ const struct vcpu *vcpu = NULL;
if ( !(pirq_dpci->flags & HVM_IRQ_DPCI_MAPPED) )
{
@@ -441,6 +442,15 @@ int pt_irq_create_bind(
dest_vcpu_id = hvm_girq_dest_2_vcpu_id(d, dest, dest_mode);
pirq_dpci->gmsi.dest_vcpu_id = dest_vcpu_id;
+
+ pirq_dpci->gmsi.via_pi = 0;
+ if ( iommu_intpost )
+ {
+ vcpu = pi_find_dest_vcpu(d, dest, dest_mode, delivery_mode,
+ pirq_dpci->gmsi.gvec);
+ if ( vcpu )
+ pirq_dpci->gmsi.via_pi = 1;
+ }
spin_unlock(&d->event_lock);
if ( dest_vcpu_id >= 0 )
hvm_migrate_pirqs(d->vcpu[dest_vcpu_id]);
@@ -448,11 +458,8 @@ int pt_irq_create_bind(
/* Use interrupt posting if it is supported. */
if ( iommu_intpost )
{
- const struct vcpu *vcpu = pi_find_dest_vcpu(d, dest, dest_mode,
- delivery_mode, pirq_dpci->gmsi.gvec);
-
if ( vcpu )
- pi_update_irte( vcpu, info, pirq_dpci->gmsi.gvec );
+ pi_update_irte(vcpu, info, pirq_dpci->gmsi.gvec);
else
dprintk(XENLOG_G_INFO,
"%pv: deliver interrupt in remapping mode,gvec:%02x\n",
diff --git a/xen/include/xen/hvm/irq.h b/xen/include/xen/hvm/irq.h
index d3f8623..ba74a31 100644
--- a/xen/include/xen/hvm/irq.h
+++ b/xen/include/xen/hvm/irq.h
@@ -63,6 +63,7 @@ struct hvm_gmsi_info {
uint32_t gvec;
uint32_t gflags;
int dest_vcpu_id; /* -1 :multi-dest, non-negative: dest_vcpu_id */
+ bool via_pi; /* directly deliver to guest via VT-d PI? */
};
struct hvm_girq_dpci_mapping {
--
1.8.3.1
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
next prev parent reply other threads:[~2017-03-15 5:11 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-15 5:11 [PATCH v10 0/6] VMX: Properly handle pi descriptor and per-cpu blocking list Chao Gao
2017-03-15 5:11 ` [PATCH v10 1/6] VT-d: Introduce new fields in msi_desc to track binding with guest interrupt Chao Gao
2017-03-15 16:41 ` Jan Beulich
2017-03-15 21:21 ` Chao Gao
2017-03-16 10:24 ` Jan Beulich
2017-03-22 5:59 ` Tian, Kevin
2017-03-22 0:18 ` Chao Gao
2017-03-22 8:32 ` Tian, Kevin
2017-03-15 5:11 ` [PATCH v10 2/6] VT-d: Some cleanups Chao Gao
2017-03-15 5:11 ` [PATCH v10 3/6] VMX: Fixup PI descriptor when cpu is offline Chao Gao
2017-03-15 5:11 ` [PATCH v10 4/6] VT-d: introduce update_irte to update irte safely Chao Gao
2017-03-15 16:48 ` Jan Beulich
2017-03-15 22:39 ` Chao Gao
2017-03-16 10:29 ` Jan Beulich
2017-03-17 1:52 ` Chao Gao
2017-03-17 9:08 ` Jan Beulich
2017-03-22 6:26 ` Tian, Kevin
2017-03-24 8:44 ` Tian, Kevin
2017-03-15 5:11 ` Chao Gao [this message]
2017-03-17 10:43 ` [PATCH v10 5/6] passthrough/io: don't migrate pirq when it is delivered through VT-d PI Jan Beulich
2017-03-20 1:59 ` Chao Gao
2017-03-20 9:18 ` Jan Beulich
2017-03-20 2:38 ` Chao Gao
2017-03-20 10:26 ` Jan Beulich
2017-03-20 5:22 ` Chao Gao
2017-03-20 12:50 ` Jan Beulich
2017-03-20 6:11 ` Chao Gao
2017-03-15 5:11 ` [PATCH v10 6/6] passthrough/io: Fall back to remapping interrupt when we can't use " Chao Gao
2017-03-17 10:48 ` Jan Beulich
2017-03-22 6:34 ` Tian, Kevin
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=1489554682-6126-6-git-send-email-chao.gao@intel.com \
--to=chao.gao@intel.com \
--cc=andrew.cooper3@citrix.com \
--cc=jbeulich@suse.com \
--cc=xen-devel@lists.xen.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).