qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: David Gibson <david@gibson.dropbear.id.au>
To: peter.maydell@linaro.org
Cc: qemu-ppc@nongnu.org, qemu-devel@nongnu.org, gkurz@redhat.com,
	lvivier@redhat.com, clg@kaod.org,
	David Gibson <david@gibson.dropbear.id.au>
Subject: [Qemu-devel] [PULL 38/40] spapr: introduce an 'ic-mode' machine option
Date: Fri, 21 Dec 2018 16:46:04 +1100	[thread overview]
Message-ID: <20181221054606.22007-39-david@gibson.dropbear.id.au> (raw)
In-Reply-To: <20181221054606.22007-1-david@gibson.dropbear.id.au>

From: Cédric Le Goater <clg@kaod.org>

This option is used to select the interrupt controller mode (XICS or
XIVE) with which the machine will operate. XICS being the default
mode for now.

When running a machine with the XIVE interrupt mode backend, the guest
OS is required to have support for the XIVE exploitation mode. In the
case of legacy OS, the mode selected by CAS should be XICS and the OS
should fail to boot. However, QEMU could possibly detect it, terminate
the boot process and reset to stop in the SLOF firmware. This is not
yet handled.

Signed-off-by: Cédric Le Goater <clg@kaod.org>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
 hw/ppc/spapr.c          | 50 +++++++++++++++++++++++++++++++++++------
 hw/ppc/spapr_cpu_core.c |  3 +--
 hw/ppc/spapr_irq.c      | 34 +++++++++-------------------
 include/hw/ppc/spapr.h  |  1 +
 4 files changed, 55 insertions(+), 33 deletions(-)

diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index 2f87c8ba19..65c6065602 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -1104,10 +1104,9 @@ static void spapr_dt_ov5_platform_support(sPAPRMachineState *spapr, void *fdt,
                                           int chosen)
 {
     PowerPCCPU *first_ppc_cpu = POWERPC_CPU(first_cpu);
-    sPAPRMachineClass *smc = SPAPR_MACHINE_GET_CLASS(spapr);
 
     char val[2 * 4] = {
-        23, smc->irq->ov5, /* Xive mode. */
+        23, spapr->irq->ov5, /* Xive mode. */
         24, 0x00, /* Hash/Radix, filled in below. */
         25, 0x00, /* Hash options: Segment Tables == no, GTSE == no. */
         26, 0x40, /* Radix options: GTSE == yes. */
@@ -1276,7 +1275,7 @@ static void *spapr_build_fdt(sPAPRMachineState *spapr,
     _FDT(fdt_setprop_cell(fdt, 0, "#size-cells", 2));
 
     /* /interrupt controller */
-    smc->irq->dt_populate(spapr, spapr_max_server_number(spapr), fdt,
+    spapr->irq->dt_populate(spapr, spapr_max_server_number(spapr), fdt,
                           PHANDLE_XICP);
 
     ret = spapr_populate_memory(spapr, fdt);
@@ -1297,7 +1296,8 @@ static void *spapr_build_fdt(sPAPRMachineState *spapr,
     }
 
     QLIST_FOREACH(phb, &spapr->phbs, list) {
-        ret = spapr_populate_pci_dt(phb, PHANDLE_XICP, fdt, smc->irq->nr_msis);
+        ret = spapr_populate_pci_dt(phb, PHANDLE_XICP, fdt,
+                                    spapr->irq->nr_msis);
         if (ret < 0) {
             error_report("couldn't setup PCI devices in fdt");
             exit(1);
@@ -2633,7 +2633,7 @@ static void spapr_machine_init(MachineState *machine)
     spapr_ovec_set(spapr->ov5, OV5_DRMEM_V2);
 
     /* advertise XIVE on POWER9 machines */
-    if (smc->irq->ov5 & SPAPR_OV5_XIVE_EXPLOIT) {
+    if (spapr->irq->ov5 & SPAPR_OV5_XIVE_EXPLOIT) {
         if (ppc_type_check_compat(machine->cpu_type, CPU_POWERPC_LOGICAL_3_00,
                                   0, spapr->max_compat_pvr)) {
             spapr_ovec_set(spapr->ov5, OV5_XIVE_EXPLOIT);
@@ -3053,9 +3053,38 @@ static void spapr_set_vsmt(Object *obj, Visitor *v, const char *name,
     visit_type_uint32(v, name, (uint32_t *)opaque, errp);
 }
 
+static char *spapr_get_ic_mode(Object *obj, Error **errp)
+{
+    sPAPRMachineState *spapr = SPAPR_MACHINE(obj);
+
+    if (spapr->irq == &spapr_irq_xics_legacy) {
+        return g_strdup("legacy");
+    } else if (spapr->irq == &spapr_irq_xics) {
+        return g_strdup("xics");
+    } else if (spapr->irq == &spapr_irq_xive) {
+        return g_strdup("xive");
+    }
+    g_assert_not_reached();
+}
+
+static void spapr_set_ic_mode(Object *obj, const char *value, Error **errp)
+{
+    sPAPRMachineState *spapr = SPAPR_MACHINE(obj);
+
+    /* The legacy IRQ backend can not be set */
+    if (strcmp(value, "xics") == 0) {
+        spapr->irq = &spapr_irq_xics;
+    } else if (strcmp(value, "xive") == 0) {
+        spapr->irq = &spapr_irq_xive;
+    } else {
+        error_setg(errp, "Bad value for \"ic-mode\" property");
+    }
+}
+
 static void spapr_instance_init(Object *obj)
 {
     sPAPRMachineState *spapr = SPAPR_MACHINE(obj);
+    sPAPRMachineClass *smc = SPAPR_MACHINE_GET_CLASS(spapr);
 
     spapr->htab_fd = -1;
     spapr->use_hotplug_event_source = true;
@@ -3089,6 +3118,14 @@ static void spapr_instance_init(Object *obj)
                                     " the host's SMT mode", &error_abort);
     object_property_add_bool(obj, "vfio-no-msix-emulation",
                              spapr_get_msix_emulation, NULL, NULL);
+
+    /* The machine class defines the default interrupt controller mode */
+    spapr->irq = smc->irq;
+    object_property_add_str(obj, "ic-mode", spapr_get_ic_mode,
+                            spapr_set_ic_mode, NULL);
+    object_property_set_description(obj, "ic-mode",
+                 "Specifies the interrupt controller mode (xics, xive)",
+                 NULL);
 }
 
 static void spapr_machine_finalizefn(Object *obj)
@@ -3811,9 +3848,8 @@ static void spapr_pic_print_info(InterruptStatsProvider *obj,
                                  Monitor *mon)
 {
     sPAPRMachineState *spapr = SPAPR_MACHINE(obj);
-    sPAPRMachineClass *smc = SPAPR_MACHINE_GET_CLASS(spapr);
 
-    smc->irq->print_info(spapr, mon);
+    spapr->irq->print_info(spapr, mon);
 }
 
 int spapr_get_vcpu_id(PowerPCCPU *cpu)
diff --git a/hw/ppc/spapr_cpu_core.c b/hw/ppc/spapr_cpu_core.c
index 1811cd48db..82666436e9 100644
--- a/hw/ppc/spapr_cpu_core.c
+++ b/hw/ppc/spapr_cpu_core.c
@@ -214,7 +214,6 @@ static void spapr_cpu_core_unrealize(DeviceState *dev, Error **errp)
 static void spapr_realize_vcpu(PowerPCCPU *cpu, sPAPRMachineState *spapr,
                                sPAPRCPUCore *sc, Error **errp)
 {
-    sPAPRMachineClass *smc = SPAPR_MACHINE_GET_CLASS(spapr);
     CPUPPCState *env = &cpu->env;
     CPUState *cs = CPU(cpu);
     Error *local_err = NULL;
@@ -233,7 +232,7 @@ static void spapr_realize_vcpu(PowerPCCPU *cpu, sPAPRMachineState *spapr,
     qemu_register_reset(spapr_cpu_reset, cpu);
     spapr_cpu_reset(cpu);
 
-    cpu->intc = smc->irq->cpu_intc_create(spapr, OBJECT(cpu), &local_err);
+    cpu->intc = spapr->irq->cpu_intc_create(spapr, OBJECT(cpu), &local_err);
     if (local_err) {
         goto error_unregister;
     }
diff --git a/hw/ppc/spapr_irq.c b/hw/ppc/spapr_irq.c
index 9e3aa85b6d..7b3b5afec2 100644
--- a/hw/ppc/spapr_irq.c
+++ b/hw/ppc/spapr_irq.c
@@ -94,8 +94,7 @@ error:
 static void spapr_irq_init_xics(sPAPRMachineState *spapr, Error **errp)
 {
     MachineState *machine = MACHINE(spapr);
-    sPAPRMachineClass *smc = SPAPR_MACHINE_GET_CLASS(spapr);
-    int nr_irqs = smc->irq->nr_irqs;
+    int nr_irqs = spapr->irq->nr_irqs;
     Error *local_err = NULL;
 
     if (kvm_enabled()) {
@@ -234,7 +233,6 @@ sPAPRIrq spapr_irq_xics = {
 static void spapr_irq_init_xive(sPAPRMachineState *spapr, Error **errp)
 {
     MachineState *machine = MACHINE(spapr);
-    sPAPRMachineClass *smc = SPAPR_MACHINE_GET_CLASS(spapr);
     uint32_t nr_servers = spapr_max_server_number(spapr);
     DeviceState *dev;
     int i;
@@ -248,7 +246,7 @@ static void spapr_irq_init_xive(sPAPRMachineState *spapr, Error **errp)
     }
 
     dev = qdev_create(NULL, TYPE_SPAPR_XIVE);
-    qdev_prop_set_uint32(dev, "nr-irqs", smc->irq->nr_irqs);
+    qdev_prop_set_uint32(dev, "nr-irqs", spapr->irq->nr_irqs);
     /*
      * 8 XIVE END structures per CPU. One for each available priority
      */
@@ -362,50 +360,38 @@ sPAPRIrq spapr_irq_xive = {
  */
 void spapr_irq_init(sPAPRMachineState *spapr, Error **errp)
 {
-    sPAPRMachineClass *smc = SPAPR_MACHINE_GET_CLASS(spapr);
-
     /* Initialize the MSI IRQ allocator. */
     if (!SPAPR_MACHINE_GET_CLASS(spapr)->legacy_irq_allocation) {
-        spapr_irq_msi_init(spapr, smc->irq->nr_msis);
+        spapr_irq_msi_init(spapr, spapr->irq->nr_msis);
     }
 
-    smc->irq->init(spapr, errp);
+    spapr->irq->init(spapr, errp);
 }
 
 int spapr_irq_claim(sPAPRMachineState *spapr, int irq, bool lsi, Error **errp)
 {
-    sPAPRMachineClass *smc = SPAPR_MACHINE_GET_CLASS(spapr);
-
-    return smc->irq->claim(spapr, irq, lsi, errp);
+    return spapr->irq->claim(spapr, irq, lsi, errp);
 }
 
 void spapr_irq_free(sPAPRMachineState *spapr, int irq, int num)
 {
-    sPAPRMachineClass *smc = SPAPR_MACHINE_GET_CLASS(spapr);
-
-    smc->irq->free(spapr, irq, num);
+    spapr->irq->free(spapr, irq, num);
 }
 
 qemu_irq spapr_qirq(sPAPRMachineState *spapr, int irq)
 {
-    sPAPRMachineClass *smc = SPAPR_MACHINE_GET_CLASS(spapr);
-
-    return smc->irq->qirq(spapr, irq);
+    return spapr->irq->qirq(spapr, irq);
 }
 
 int spapr_irq_post_load(sPAPRMachineState *spapr, int version_id)
 {
-    sPAPRMachineClass *smc = SPAPR_MACHINE_GET_CLASS(spapr);
-
-    return smc->irq->post_load(spapr, version_id);
+    return spapr->irq->post_load(spapr, version_id);
 }
 
 void spapr_irq_reset(sPAPRMachineState *spapr, Error **errp)
 {
-    sPAPRMachineClass *smc = SPAPR_MACHINE_GET_CLASS(spapr);
-
-    if (smc->irq->reset) {
-        smc->irq->reset(spapr, errp);
+    if (spapr->irq->reset) {
+        spapr->irq->reset(spapr, errp);
     }
 }
 
diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h
index 06765b4e9d..2c77a8ba88 100644
--- a/include/hw/ppc/spapr.h
+++ b/include/hw/ppc/spapr.h
@@ -177,6 +177,7 @@ struct sPAPRMachineState {
     int32_t irq_map_nr;
     unsigned long *irq_map;
     sPAPRXive  *xive;
+    sPAPRIrq *irq;
 
     bool cmd_line_caps[SPAPR_CAP_NUM];
     sPAPRCapabilities def, eff, mig;
-- 
2.19.2

  parent reply	other threads:[~2018-12-21  5:47 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-21  5:45 [Qemu-devel] [PULL 00/40] ppc-for-4.0 queue 20181221 David Gibson
2018-12-21  5:45 ` [Qemu-devel] [PULL 01/40] target/ppc: fix the PPC_BIT definitions David Gibson
2018-12-21  5:45 ` [Qemu-devel] [PULL 02/40] target/ppc: Remove silly GETFIELD/SETFIELD/MASK_TO_LSH macros David Gibson
2018-12-21  5:45 ` [Qemu-devel] [PULL 03/40] spapr: Fix ibm, max-associativity-domains property number of nodes David Gibson
2018-12-21  5:45 ` [Qemu-devel] [PULL 04/40] target/ppc: tcg: Implement addex instruction David Gibson
2018-12-21  5:45 ` [Qemu-devel] [PULL 05/40] spapr: drop redundant statement in spapr_populate_drconf_memory() David Gibson
2018-12-21  5:45 ` [Qemu-devel] [PULL 06/40] target/ppc: use g_new(T, n) instead of g_malloc(sizeof(T) * n) David Gibson
2018-12-21  5:45 ` [Qemu-devel] [PULL 07/40] spapr: " David Gibson
2018-12-21  5:45 ` [Qemu-devel] [PULL 08/40] ppc405_boards: " David Gibson
2018-12-21  5:45 ` [Qemu-devel] [PULL 09/40] ppc405_uc: " David Gibson
2018-12-21  5:45 ` [Qemu-devel] [PULL 10/40] ppc440_bamboo: " David Gibson
2018-12-21  5:45 ` [Qemu-devel] [PULL 11/40] sam460ex: " David Gibson
2018-12-21  5:45 ` [Qemu-devel] [PULL 12/40] virtex_ml507: " David Gibson
2018-12-21  5:45 ` [Qemu-devel] [PULL 13/40] mac_newworld: simplify IRQ wiring David Gibson
2018-12-21  5:45 ` [Qemu-devel] [PULL 14/40] e500: " David Gibson
2018-12-21  5:45 ` [Qemu-devel] [PULL 15/40] ppc/xive: introduce a XIVE interrupt source model David Gibson
2018-12-21  5:45 ` [Qemu-devel] [PULL 16/40] ppc/xive: add support for the LSI interrupt sources David Gibson
2018-12-21  5:45 ` [Qemu-devel] [PULL 17/40] ppc/xive: introduce the XiveNotifier interface David Gibson
2018-12-21  5:45 ` [Qemu-devel] [PULL 18/40] ppc/xive: introduce the XiveRouter model David Gibson
2018-12-21  5:45 ` [Qemu-devel] [PULL 19/40] ppc/xive: introduce the XIVE Event Notification Descriptors David Gibson
2018-12-21  5:45 ` [Qemu-devel] [PULL 20/40] spapr: initialize VSMT before initializing the IRQ backend David Gibson
2018-12-21  5:45 ` [Qemu-devel] [PULL 21/40] spapr: introduce a spapr_irq_init() routine David Gibson
2018-12-21  5:45 ` [Qemu-devel] [PULL 22/40] spapr: export and rename the xics_max_server_number() routine David Gibson
2018-12-21  5:45 ` [Qemu-devel] [PULL 23/40] Changes requirement for "vsubsbs" instruction David Gibson
2018-12-21  5:45 ` [Qemu-devel] [PULL 24/40] ppc/xive: add support for the END Event State Buffers David Gibson
2018-12-21  5:45 ` [Qemu-devel] [PULL 25/40] ppc/xive: introduce the XIVE interrupt thread context David Gibson
2018-12-21  5:45 ` [Qemu-devel] [PULL 26/40] ppc/xive: introduce a simplified XIVE presenter David Gibson
2018-12-21  5:45 ` [Qemu-devel] [PULL 27/40] ppc/xive: notify the CPU when the interrupt priority is more privileged David Gibson
2018-12-21  5:45 ` [Qemu-devel] [PULL 28/40] spapr/xive: introduce a XIVE interrupt controller David Gibson
2018-12-21  5:45 ` [Qemu-devel] [PULL 29/40] spapr/xive: use the VCPU id as a NVT identifier David Gibson
2018-12-21  5:45 ` [Qemu-devel] [PULL 30/40] spapr-iommu: Always advertise the maximum possible DMA window size David Gibson
2018-12-21  5:45 ` [Qemu-devel] [PULL 31/40] spapr: introduce a new machine IRQ backend for XIVE David Gibson
2018-12-21  5:45 ` [Qemu-devel] [PULL 32/40] spapr: add hcalls support for the XIVE exploitation interrupt mode David Gibson
2018-12-21  5:45 ` [Qemu-devel] [PULL 33/40] spapr: add device tree support for the XIVE exploitation mode David Gibson
2018-12-21  5:46 ` [Qemu-devel] [PULL 34/40] spapr: allocate the interrupt thread context under the CPU core David Gibson
2018-12-21  5:46 ` [Qemu-devel] [PULL 35/40] spapr: extend the sPAPR IRQ backend for XICS migration David Gibson
2019-01-03 19:07   ` Peter Maydell
2019-01-03 21:57     ` Cédric Le Goater
2019-01-04  5:16       ` David Gibson
2018-12-21  5:46 ` [Qemu-devel] [PULL 36/40] spapr: add a 'reset' method to the sPAPR IRQ backend David Gibson
2018-12-21  5:46 ` [Qemu-devel] [PULL 37/40] spapr: add an extra OV5 field " David Gibson
2018-12-21  5:46 ` David Gibson [this message]
2018-12-21  5:46 ` [Qemu-devel] [PULL 39/40] spapr: change default CPU type to POWER9 David Gibson
2018-12-21  5:46 ` [Qemu-devel] [PULL 40/40] MAINTAINERS: PPC: add a XIVE section David Gibson
2018-12-21 19:30 ` [Qemu-devel] [PULL 00/40] ppc-for-4.0 queue 20181221 Peter Maydell
2019-01-03 16:39   ` Cédric Le Goater
2018-12-26  5:27 ` no-reply

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=20181221054606.22007-39-david@gibson.dropbear.id.au \
    --to=david@gibson.dropbear.id.au \
    --cc=clg@kaod.org \
    --cc=gkurz@redhat.com \
    --cc=lvivier@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).