diff mbox series

[8/8] spapr/xive: Introduce a XIVE StoreEOI IRQ backend

Message ID 20200819130843.2230799-9-clg@kaod.org
State New
Headers show
Series [1/8] spapr/xive: Add a 'hv-prio' property to represent the KVM escalation priority | expand

Commit Message

Cédric Le Goater Aug. 19, 2020, 1:08 p.m. UTC
As it is still useful to run a P9 compat guest with StoreEOI enabled,
introduce a new IRQ backend to allow that. May be we should add a
migration blocker.

Signed-off-by: Cédric Le Goater <clg@kaod.org>
---
 include/hw/ppc/spapr_irq.h |  1 +
 hw/ppc/spapr.c             |  6 +++++-
 hw/ppc/spapr_irq.c         | 14 ++++++++++++++
 3 files changed, 20 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/include/hw/ppc/spapr_irq.h b/include/hw/ppc/spapr_irq.h
index ca8cb4421374..548895a89cca 100644
--- a/include/hw/ppc/spapr_irq.h
+++ b/include/hw/ppc/spapr_irq.h
@@ -90,6 +90,7 @@  typedef struct SpaprIrq {
 extern SpaprIrq spapr_irq_xics;
 extern SpaprIrq spapr_irq_xics_legacy;
 extern SpaprIrq spapr_irq_xive;
+extern SpaprIrq spapr_irq_xive_storeeoi;
 extern SpaprIrq spapr_irq_dual;
 
 void spapr_irq_init(SpaprMachineState *spapr, Error **errp);
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index a5bb0736e237..23f26d50f598 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -3248,6 +3248,8 @@  static char *spapr_get_ic_mode(Object *obj, Error **errp)
         return g_strdup("xics");
     } else if (spapr->irq == &spapr_irq_xive) {
         return g_strdup("xive");
+    } else if (spapr->irq == &spapr_irq_xive_storeeoi) {
+        return g_strdup("xive-storeeoi");
     } else if (spapr->irq == &spapr_irq_dual) {
         return g_strdup("dual");
     }
@@ -3268,6 +3270,8 @@  static void spapr_set_ic_mode(Object *obj, const char *value, Error **errp)
         spapr->irq = &spapr_irq_xics;
     } else if (strcmp(value, "xive") == 0) {
         spapr->irq = &spapr_irq_xive;
+    } else if (strcmp(value, "xive-storeeoi") == 0) {
+        spapr->irq = &spapr_irq_xive_storeeoi;
     } else if (strcmp(value, "dual") == 0) {
         spapr->irq = &spapr_irq_dual;
     } else {
@@ -3350,7 +3354,7 @@  static void spapr_instance_init(Object *obj)
     object_property_add_str(obj, "ic-mode", spapr_get_ic_mode,
                             spapr_set_ic_mode);
     object_property_set_description(obj, "ic-mode",
-                 "Specifies the interrupt controller mode (xics, xive, dual)");
+                 "Specifies the interrupt controller mode (xics, xive, xive-storeeoi, dual)");
 
     object_property_add_str(obj, "host-model",
         spapr_get_host_model, spapr_set_host_model);
diff --git a/hw/ppc/spapr_irq.c b/hw/ppc/spapr_irq.c
index d036c8fef519..c2e83fd0b34d 100644
--- a/hw/ppc/spapr_irq.c
+++ b/hw/ppc/spapr_irq.c
@@ -119,6 +119,15 @@  SpaprIrq spapr_irq_xive = {
     .xive        = true,
 };
 
+/*
+ * XIVE IRQ backend + StoreEOI activated
+ */
+
+SpaprIrq spapr_irq_xive_storeeoi = {
+    .xics        = false,
+    .xive        = true,
+};
+
 /*
  * Dual XIVE and XICS IRQ backend.
  *
@@ -213,6 +222,11 @@  static bool spapr_irq_xive_hw_storeeoi(SpaprMachineState *spapr)
     }
 
     /* StoreEOI on P9 compat is unsafe */
+    if (spapr->irq == &spapr_irq_xive_storeeoi) {
+        warn_report("HW Store EOI on a POWER9 CPU is unsafe.");
+        return true;
+    }
+
     return false;
 }