diff mbox

[RFC,v2,8/8] vfio-pci: add VFIO_FEATURE_ENABLE_AER_CAP feature

Message ID 8c9d087c2a0bbcddfcb938a87ca35f461dd2613a.1422433767.git.chen.fan.fnst@cn.fujitsu.com
State New
Headers show

Commit Message

chenfan Jan. 28, 2015, 8:37 a.m. UTC
for old machine types, we should disable aercap feature.

Signed-off-by: Chen Fan <chen.fan.fnst@cn.fujitsu.com>
---
 hw/vfio/pci.c       | 13 ++++++++++---
 include/hw/compat.h |  4 ++++
 2 files changed, 14 insertions(+), 3 deletions(-)

Comments

Alex Williamson Feb. 2, 2015, 8:16 p.m. UTC | #1
On Wed, 2015-01-28 at 16:37 +0800, Chen Fan wrote:
> for old machine types, we should disable aercap feature.
> 
> Signed-off-by: Chen Fan <chen.fan.fnst@cn.fujitsu.com>
> ---
>  hw/vfio/pci.c       | 13 ++++++++++---
>  include/hw/compat.h |  4 ++++
>  2 files changed, 14 insertions(+), 3 deletions(-)
> 
> diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
> index 65247ee..0d830e6 100644
> --- a/hw/vfio/pci.c
> +++ b/hw/vfio/pci.c
> @@ -138,6 +138,8 @@ typedef struct VFIOMSIXInfo {
>  enum {
>  #define VFIO_FEATURE_ENABLE_VGA_BIT 0
>      VFIO_FEATURE_ENABLE_VGA = (1 << VFIO_FEATURE_ENABLE_VGA_BIT),
> +#define VFIO_FEATURE_ENABLE_AER_CAP_BIT 1
> +    VFIO_FEATURE_ENABLE_AER_CAP = (1 << VFIO_FEATURE_ENABLE_AER_CAP_BIT),
>  };
>  
>  typedef struct VFIOPCIDevice {
> @@ -2724,10 +2726,12 @@ static int vfio_add_ext_capabilities(VFIOPCIDevice *vdev)
>      while (header) {
>          switch (PCI_EXT_CAP_ID(header)) {
>          case PCI_EXT_CAP_ID_ERR:
> -             exp = &pdev->exp;
> -             exp->aer_cap = next;
> +             if (vdev->features & VFIO_FEATURE_ENABLE_AER_CAP) {
> +                 exp = &pdev->exp;
> +                 exp->aer_cap = next;
>  
> -             vfio_pci_aer_init(vdev);
> +                 vfio_pci_aer_init(vdev);
> +	     }
>               break;
>          };
>  
> @@ -3498,6 +3502,9 @@ static Property vfio_pci_dev_properties[] = {
>      DEFINE_PROP_BIT("x-vga", VFIOPCIDevice, features,
>                      VFIO_FEATURE_ENABLE_VGA_BIT, false),
>      DEFINE_PROP_INT32("bootindex", VFIOPCIDevice, bootindex, -1),
> +    DEFINE_PROP_BIT("aercap", VFIOPCIDevice, features,
> +                    VFIO_FEATURE_ENABLE_AER_CAP_BIT, true),
> +
>      /*
>       * TODO - support passed fds... is this necessary?
>       * DEFINE_PROP_STRING("vfiofd", VFIOPCIDevice, vfiofd_name),
> diff --git a/include/hw/compat.h b/include/hw/compat.h
> index 313682a..72a2cdb 100644
> --- a/include/hw/compat.h
> +++ b/include/hw/compat.h
> @@ -30,6 +30,10 @@
>              .driver   = "virtio-pci",\
>              .property = "virtio-pci-bus-master-bug-migration",\
>              .value    = "on",\
> +        },{\
> +            .driver   = "vfio-pci",\
> +            .property = "aercap",\
> +            .value    = "off",\

This will leave it enabled on both Q35 and 440FX afaict, so I'm not sure
what this fixes.  We don't care about migration compatibility with
vfio-pci.

>          }
>  
>  #endif /* HW_COMPAT_H */
diff mbox

Patch

diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
index 65247ee..0d830e6 100644
--- a/hw/vfio/pci.c
+++ b/hw/vfio/pci.c
@@ -138,6 +138,8 @@  typedef struct VFIOMSIXInfo {
 enum {
 #define VFIO_FEATURE_ENABLE_VGA_BIT 0
     VFIO_FEATURE_ENABLE_VGA = (1 << VFIO_FEATURE_ENABLE_VGA_BIT),
+#define VFIO_FEATURE_ENABLE_AER_CAP_BIT 1
+    VFIO_FEATURE_ENABLE_AER_CAP = (1 << VFIO_FEATURE_ENABLE_AER_CAP_BIT),
 };
 
 typedef struct VFIOPCIDevice {
@@ -2724,10 +2726,12 @@  static int vfio_add_ext_capabilities(VFIOPCIDevice *vdev)
     while (header) {
         switch (PCI_EXT_CAP_ID(header)) {
         case PCI_EXT_CAP_ID_ERR:
-             exp = &pdev->exp;
-             exp->aer_cap = next;
+             if (vdev->features & VFIO_FEATURE_ENABLE_AER_CAP) {
+                 exp = &pdev->exp;
+                 exp->aer_cap = next;
 
-             vfio_pci_aer_init(vdev);
+                 vfio_pci_aer_init(vdev);
+	     }
              break;
         };
 
@@ -3498,6 +3502,9 @@  static Property vfio_pci_dev_properties[] = {
     DEFINE_PROP_BIT("x-vga", VFIOPCIDevice, features,
                     VFIO_FEATURE_ENABLE_VGA_BIT, false),
     DEFINE_PROP_INT32("bootindex", VFIOPCIDevice, bootindex, -1),
+    DEFINE_PROP_BIT("aercap", VFIOPCIDevice, features,
+                    VFIO_FEATURE_ENABLE_AER_CAP_BIT, true),
+
     /*
      * TODO - support passed fds... is this necessary?
      * DEFINE_PROP_STRING("vfiofd", VFIOPCIDevice, vfiofd_name),
diff --git a/include/hw/compat.h b/include/hw/compat.h
index 313682a..72a2cdb 100644
--- a/include/hw/compat.h
+++ b/include/hw/compat.h
@@ -30,6 +30,10 @@ 
             .driver   = "virtio-pci",\
             .property = "virtio-pci-bus-master-bug-migration",\
             .value    = "on",\
+        },{\
+            .driver   = "vfio-pci",\
+            .property = "aercap",\
+            .value    = "off",\
         }
 
 #endif /* HW_COMPAT_H */