aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGavin Shan <gwshan@linux.vnet.ibm.com>2014-09-29 12:16:24 -0400
committerAlex Williamson <alex.williamson@redhat.com>2014-09-29 12:16:24 -0400
commitb8f02af096b1fc9fd46680cbe55214e477eb76d3 (patch)
tree4f579b40a558d0ad1ad38b032bfb1f72a0d5cf21
parent3b307ffe3faad60aeda0e9a4f661d5c1edbd761e (diff)
vfio/pci: Restore MSIx message prior to enabling
The MSIx vector table lives in device memory, which may be cleared as part of a backdoor device reset. This is the case on the IBM IPR HBA when the BIST is run on the device. When assigned to a QEMU guest, the guest driver does a pci_save_state(), issues a BIST, then does a pci_restore_state(). The BIST clears the MSIx vector table, but due to the way interrupts are configured the pci_restore_state() does not restore the vector table as expected. Eventually this results in an EEH error on Power platforms when the device attempts to signal an interrupt with the zero'd table entry. Fix the problem by restoring the host cached MSI message prior to enabling each vector. Reported-by: Wen Xiong <wenxiong@linux.vnet.ibm.com> Signed-off-by: Gavin Shan <gwshan@linux.vnet.ibm.com> Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
-rw-r--r--drivers/vfio/pci/vfio_pci_intrs.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/drivers/vfio/pci/vfio_pci_intrs.c b/drivers/vfio/pci/vfio_pci_intrs.c
index 9dd49c9839ac..553212f037c3 100644
--- a/drivers/vfio/pci/vfio_pci_intrs.c
+++ b/drivers/vfio/pci/vfio_pci_intrs.c
@@ -16,6 +16,7 @@
16#include <linux/device.h> 16#include <linux/device.h>
17#include <linux/interrupt.h> 17#include <linux/interrupt.h>
18#include <linux/eventfd.h> 18#include <linux/eventfd.h>
19#include <linux/msi.h>
19#include <linux/pci.h> 20#include <linux/pci.h>
20#include <linux/file.h> 21#include <linux/file.h>
21#include <linux/poll.h> 22#include <linux/poll.h>
@@ -548,6 +549,20 @@ static int vfio_msi_set_vector_signal(struct vfio_pci_device *vdev,
548 return PTR_ERR(trigger); 549 return PTR_ERR(trigger);
549 } 550 }
550 551
552 /*
553 * The MSIx vector table resides in device memory which may be cleared
554 * via backdoor resets. We don't allow direct access to the vector
555 * table so even if a userspace driver attempts to save/restore around
556 * such a reset it would be unsuccessful. To avoid this, restore the
557 * cached value of the message prior to enabling.
558 */
559 if (msix) {
560 struct msi_msg msg;
561
562 get_cached_msi_msg(irq, &msg);
563 write_msi_msg(irq, &msg);
564 }
565
551 ret = request_irq(irq, vfio_msihandler, 0, 566 ret = request_irq(irq, vfio_msihandler, 0,
552 vdev->ctx[vector].name, trigger); 567 vdev->ctx[vector].name, trigger);
553 if (ret) { 568 if (ret) {