From: Chao Gao <chao.gao@intel.com>
To: xen-devel@lists.xenproject.org
Cc: "Wei Liu" <wei.liu2@citrix.com>,
"Andrew Cooper" <andrew.cooper3@citrix.com>,
"Ian Jackson" <ian.jackson@eu.citrix.com>,
"Jan Beulich" <jbeulich@suse.com>,
"Chao Gao" <chao.gao@intel.com>,
"Roger Pau Monné" <roger.pau@citrix.com>
Subject: [PATCH v3 2/2] libxl: don't reset device when it is accessible by the guest
Date: Tue, 18 Dec 2018 22:43:38 +0800 [thread overview]
Message-ID: <1545144218-6463-2-git-send-email-chao.gao@intel.com> (raw)
In-Reply-To: <1545144218-6463-1-git-send-email-chao.gao@intel.com>
When I destroyed a guest with 'xl destroy', I found the warning
in msi_set_mask_bit() in Xen was triggered. After adding "WARN_ON(1)"
to that place, I got the call trace below:
(XEN) Xen call trace:
(XEN) [<ffff82d080281a6a>] msi.c#msi_set_mask_bit+0x1da/0x29b
(XEN) [<ffff82d080282e78>] guest_mask_msi_irq+0x1c/0x1e
(XEN) [<ffff82d08030ceb9>] vmsi.c#msixtbl_write+0x173/0x1d4
(XEN) [<ffff82d08030cf30>] vmsi.c#_msixtbl_write+0x16/0x18
(XEN) [<ffff82d0802ffac4>] hvm_process_io_intercept+0x216/0x270
(XEN) [<ffff82d0802ffb45>] hvm_io_intercept+0x27/0x4c
(XEN) [<ffff82d0802f0e86>] emulate.c#hvmemul_do_io+0x273/0x454
(XEN) [<ffff82d0802f10a4>] emulate.c#hvmemul_do_io_buffer+0x3d/0x70
(XEN) [<ffff82d0802f2343>] emulate.c#hvmemul_linear_mmio_access+0x35e/0x436
(XEN) [<ffff82d0802f2640>] emulate.c#linear_write+0xdd/0x13b
(XEN) [<ffff82d0802f3f25>] emulate.c#hvmemul_write+0xbd/0xf1
(XEN) [<ffff82d0802d51df>] x86_emulate+0x2249d/0x23c5c
(XEN) [<ffff82d0802d861f>] x86_emulate_wrapper+0x2b/0x5f
(XEN) [<ffff82d0802f28aa>] emulate.c#_hvm_emulate_one+0x54/0x1b2
(XEN) [<ffff82d0802f2a18>] hvm_emulate_one+0x10/0x12
(XEN) [<ffff82d080300227>] hvm_emulate_one_insn+0x42/0x14a
(XEN) [<ffff82d08030037e>] handle_mmio_with_translation+0x4f/0x51
(XEN) [<ffff82d0802f803b>] hvm_hap_nested_page_fault+0x16c/0x6d8
(XEN) [<ffff82d08032446a>] vmx_vmexit_handler+0x19b0/0x1f2e
(XEN) [<ffff82d08032995a>] vmx_asm_vmexit_handler+0xfa/0x270
It seems to me that guest is trying to mask a msi while the memory decoding
of the device is disabled. Performing a device reset without proper method
to avoid guest's MSI-X operation would lead to this issue.
The fix is basic - detach pci device before resetting the device.
Signed-off-by: Chao Gao <chao.gao@intel.com>
---
tools/libxl/libxl_pci.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/tools/libxl/libxl_pci.c b/tools/libxl/libxl_pci.c
index 87afa03..855fb71 100644
--- a/tools/libxl/libxl_pci.c
+++ b/tools/libxl/libxl_pci.c
@@ -1459,17 +1459,17 @@ skip1:
fclose(f);
}
out:
- /* don't do multiple resets while some functions are still passed through */
- if ( (pcidev->vdevfn & 0x7) == 0 ) {
- libxl__device_pci_reset(gc, pcidev->domain, pcidev->bus, pcidev->dev, pcidev->func);
- }
-
if (!isstubdom) {
rc = xc_deassign_device(ctx->xch, domid, pcidev_encode_bdf(pcidev));
if (rc < 0 && (hvm || errno != ENOSYS))
LOGED(ERROR, domainid, "xc_deassign_device failed");
}
+ /* don't do multiple resets while some functions are still passed through */
+ if ( (pcidev->vdevfn & 0x7) == 0 ) {
+ libxl__device_pci_reset(gc, pcidev->domain, pcidev->bus, pcidev->dev, pcidev->func);
+ }
+
stubdomid = libxl_get_stubdom_id(ctx, domid);
if (stubdomid != 0) {
libxl_device_pci pcidev_s = *pcidev;
--
1.8.3.1
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
next prev parent reply other threads:[~2018-12-18 14:40 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-18 14:43 [PATCH v3 1/2] xen/pt: fix some pass-thru devices don't work across reboot Chao Gao
2018-12-18 14:43 ` Chao Gao [this message]
2018-12-19 9:00 ` [PATCH v3 2/2] libxl: don't reset device when it is accessible by the guest Roger Pau Monné
2018-12-20 2:47 ` Chao Gao
2019-01-02 11:49 ` Wei Liu
2018-12-18 15:53 ` [PATCH v3 1/2] xen/pt: fix some pass-thru devices don't work across reboot Jan Beulich
2018-12-19 4:56 ` Chao Gao
2018-12-19 8:57 ` Roger Pau Monné
2018-12-20 2:46 ` Chao Gao
2018-12-20 9:29 ` Roger Pau Monné
2018-12-20 14:20 ` Chao Gao
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=1545144218-6463-2-git-send-email-chao.gao@intel.com \
--to=chao.gao@intel.com \
--cc=andrew.cooper3@citrix.com \
--cc=ian.jackson@eu.citrix.com \
--cc=jbeulich@suse.com \
--cc=roger.pau@citrix.com \
--cc=wei.liu2@citrix.com \
--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 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.