aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGavin Shan <gwshan@linux.vnet.ibm.com>2015-03-26 01:42:09 -0400
committerMichael Ellerman <mpe@ellerman.id.au>2015-05-12 06:33:35 -0400
commit68cbbc3a9d1fc231810b2490bca73b3b444ef542 (patch)
treeaa46575bc541b0680021a47e80df098bcc16789b
parentec33d36e5ab5d52d59a8f696f7efb682bfc58494 (diff)
drivers/vfio: Support EEH error injection
The patch adds one more EEH sub-command (VFIO_EEH_PE_INJECT_ERR) to inject the specified EEH error, which is represented by (struct vfio_eeh_pe_err), to the indicated PE for testing purpose. Signed-off-by: Gavin Shan <gwshan@linux.vnet.ibm.com> Reviewed-by: David Gibson <david@gibson.dropbear.id.au> Acked-by: Alex Williamson <alex.williamson@redhat.com> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
-rw-r--r--Documentation/vfio.txt12
-rw-r--r--drivers/vfio/vfio_spapr_eeh.c10
-rw-r--r--include/uapi/linux/vfio.h14
3 files changed, 35 insertions, 1 deletions
diff --git a/Documentation/vfio.txt b/Documentation/vfio.txt
index 96978eced341..4c746a7e717a 100644
--- a/Documentation/vfio.txt
+++ b/Documentation/vfio.txt
@@ -385,6 +385,18 @@ The code flow from the example above should be slightly changed:
385 385
386 .... 386 ....
387 387
388 /* Inject EEH error, which is expected to be caused by 32-bits
389 * config load.
390 */
391 pe_op.op = VFIO_EEH_PE_INJECT_ERR;
392 pe_op.err.type = EEH_ERR_TYPE_32;
393 pe_op.err.func = EEH_ERR_FUNC_LD_CFG_ADDR;
394 pe_op.err.addr = 0ul;
395 pe_op.err.mask = 0ul;
396 ioctl(container, VFIO_EEH_PE_OP, &pe_op);
397
398 ....
399
388 /* When 0xFF's returned from reading PCI config space or IO BARs 400 /* When 0xFF's returned from reading PCI config space or IO BARs
389 * of the PCI device. Check the PE's state to see if that has been 401 * of the PCI device. Check the PE's state to see if that has been
390 * frozen. 402 * frozen.
diff --git a/drivers/vfio/vfio_spapr_eeh.c b/drivers/vfio/vfio_spapr_eeh.c
index 5fa42db769ee..38edeb4729a9 100644
--- a/drivers/vfio/vfio_spapr_eeh.c
+++ b/drivers/vfio/vfio_spapr_eeh.c
@@ -85,6 +85,16 @@ long vfio_spapr_iommu_eeh_ioctl(struct iommu_group *group,
85 case VFIO_EEH_PE_CONFIGURE: 85 case VFIO_EEH_PE_CONFIGURE:
86 ret = eeh_pe_configure(pe); 86 ret = eeh_pe_configure(pe);
87 break; 87 break;
88 case VFIO_EEH_PE_INJECT_ERR:
89 minsz = offsetofend(struct vfio_eeh_pe_op, err.mask);
90 if (op.argsz < minsz)
91 return -EINVAL;
92 if (copy_from_user(&op, (void __user *)arg, minsz))
93 return -EFAULT;
94
95 ret = eeh_pe_inject_err(pe, op.err.type, op.err.func,
96 op.err.addr, op.err.mask);
97 break;
88 default: 98 default:
89 ret = -EINVAL; 99 ret = -EINVAL;
90 } 100 }
diff --git a/include/uapi/linux/vfio.h b/include/uapi/linux/vfio.h
index b57b750c222f..e4fa1995f613 100644
--- a/include/uapi/linux/vfio.h
+++ b/include/uapi/linux/vfio.h
@@ -470,12 +470,23 @@ struct vfio_iommu_spapr_tce_info {
470 * - unfreeze IO/DMA for frozen PE; 470 * - unfreeze IO/DMA for frozen PE;
471 * - read PE state; 471 * - read PE state;
472 * - reset PE; 472 * - reset PE;
473 * - configure PE. 473 * - configure PE;
474 * - inject EEH error.
474 */ 475 */
476struct vfio_eeh_pe_err {
477 __u32 type;
478 __u32 func;
479 __u64 addr;
480 __u64 mask;
481};
482
475struct vfio_eeh_pe_op { 483struct vfio_eeh_pe_op {
476 __u32 argsz; 484 __u32 argsz;
477 __u32 flags; 485 __u32 flags;
478 __u32 op; 486 __u32 op;
487 union {
488 struct vfio_eeh_pe_err err;
489 };
479}; 490};
480 491
481#define VFIO_EEH_PE_DISABLE 0 /* Disable EEH functionality */ 492#define VFIO_EEH_PE_DISABLE 0 /* Disable EEH functionality */
@@ -492,6 +503,7 @@ struct vfio_eeh_pe_op {
492#define VFIO_EEH_PE_RESET_HOT 6 /* Assert hot reset */ 503#define VFIO_EEH_PE_RESET_HOT 6 /* Assert hot reset */
493#define VFIO_EEH_PE_RESET_FUNDAMENTAL 7 /* Assert fundamental reset */ 504#define VFIO_EEH_PE_RESET_FUNDAMENTAL 7 /* Assert fundamental reset */
494#define VFIO_EEH_PE_CONFIGURE 8 /* PE configuration */ 505#define VFIO_EEH_PE_CONFIGURE 8 /* PE configuration */
506#define VFIO_EEH_PE_INJECT_ERR 9 /* Inject EEH error */
495 507
496#define VFIO_EEH_PE_OP _IO(VFIO_TYPE, VFIO_BASE + 21) 508#define VFIO_EEH_PE_OP _IO(VFIO_TYPE, VFIO_BASE + 21)
497 509