From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Xen-devel <xen-devel@lists.xen.org>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>,
Jan Beulich <JBeulich@suse.com>,
Sander Eikelenboom <linux@eikelenboom.it>
Subject: [PATCH] x86/vMSI-X: Fix host crash when shutting down guests with MSI capable devices
Date: Thu, 21 Jul 2016 11:18:37 +0100 [thread overview]
Message-ID: <1469096317-6643-1-git-send-email-andrew.cooper3@citrix.com> (raw)
In-Reply-To: <cda5c5669c9977feade120397ff428ec@eikelenboom.it>
c/s 74c6dc2d "x86/vMSI-X: defer intercept handler registration" caused MSI-X
table infrastructure not to always be initialised, but it missed one path
which needed an is-initialised check.
If a devices is passed through to a domain which is MSI capable but not MSI-X
capable, the call to msixtbl_init() is omitted, but a XEN_DOMCTL_unbind_pt_irq
hypercall still calls into msixtbl_pt_unregister(). This follows the linked
list pointer which is still NULL.
Introduce an is-initalised check to msixtbl_pt_unregister().
Furthermore, the purpose of the open-coded msixtbl_list.next check is rather
subtle. Introduce an msixtbl_initialised() predicate instead, which makes its
purpose far more obvious.
Reported-by: Sander Eikelenboom <linux@eikelenboom.it>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Jan Beulich <JBeulich@suse.com>
CC: Sander Eikelenboom <linux@eikelenboom.it>
Sander - would you mind double checking this patch?
---
xen/arch/x86/hvm/vmsi.c | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
diff --git a/xen/arch/x86/hvm/vmsi.c b/xen/arch/x86/hvm/vmsi.c
index e418b98..ef1dfff 100644
--- a/xen/arch/x86/hvm/vmsi.c
+++ b/xen/arch/x86/hvm/vmsi.c
@@ -166,6 +166,16 @@ struct msixtbl_entry
static DEFINE_RCU_READ_LOCK(msixtbl_rcu_lock);
+/*
+ * MSI-X table infrastructure is dynamically initialised when an MSI-X capable
+ * device is passed through to a domain, rather than unconditionally for all
+ * domains.
+ */
+static bool msixtbl_initialised(const struct domain *d)
+{
+ return !!d->arch.hvm_domain.msixtbl_list.next;
+}
+
static struct msixtbl_entry *msixtbl_find_entry(
struct vcpu *v, unsigned long addr)
{
@@ -519,7 +529,7 @@ void msixtbl_pt_unregister(struct domain *d, struct pirq *pirq)
ASSERT(pcidevs_locked());
ASSERT(spin_is_locked(&d->event_lock));
- if ( !has_vlapic(d) )
+ if ( !msixtbl_initialised(d) )
return;
irq_desc = pirq_spin_lock_irq_desc(pirq, NULL);
@@ -552,7 +562,7 @@ void msixtbl_init(struct domain *d)
struct hvm_io_handler *handler;
if ( !has_hvm_container_domain(d) || !has_vlapic(d) ||
- d->arch.hvm_domain.msixtbl_list.next )
+ msixtbl_initialised(d) )
return;
INIT_LIST_HEAD(&d->arch.hvm_domain.msixtbl_list);
@@ -569,7 +579,7 @@ void msixtbl_pt_cleanup(struct domain *d)
{
struct msixtbl_entry *entry, *temp;
- if ( !d->arch.hvm_domain.msixtbl_list.next )
+ if ( !msixtbl_initialised(d) )
return;
spin_lock(&d->event_lock);
--
2.1.4
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
next prev parent reply other threads:[~2016-07-21 10:18 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-18 10:21 Xen-unstable 4.8: Host crash when shutting down guest with pci device passed through using MSI-X interrupts linux
2016-07-18 17:48 ` Andrew Cooper
2016-07-18 19:26 ` Sander Eikelenboom
2016-07-18 20:57 ` Andrew Cooper
2016-07-18 22:03 ` linux
2016-07-18 22:07 ` Andrew Cooper
2016-07-21 10:18 ` Andrew Cooper [this message]
2016-07-21 10:37 ` [PATCH] x86/vMSI-X: Fix host crash when shutting down guests with MSI capable devices Sander Eikelenboom
2016-07-22 8:50 ` Sander Eikelenboom
2016-07-25 10:16 ` Andrew Cooper
2016-07-25 10:19 ` Andrew Cooper
2016-07-25 10:23 ` Sander Eikelenboom
2016-07-25 10:26 ` George Dunlap
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=1469096317-6643-1-git-send-email-andrew.cooper3@citrix.com \
--to=andrew.cooper3@citrix.com \
--cc=JBeulich@suse.com \
--cc=linux@eikelenboom.it \
--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).