All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Gibson <david@gibson.dropbear.id.au>
To: peter.maydell@linaro.org
Cc: lvivier@redhat.com, qemu-devel@nongnu.org, groug@kaod.org,
	qemu-ppc@nongnu.org, "Cédric Le Goater" <clg@kaod.org>,
	"David Gibson" <david@gibson.dropbear.id.au>
Subject: [PULL 12/34] ppc/pnv: Add support for "hostboot" mode
Date: Fri, 31 Jan 2020 17:09:02 +1100	[thread overview]
Message-ID: <20200131060924.147449-13-david@gibson.dropbear.id.au> (raw)
In-Reply-To: <20200131060924.147449-1-david@gibson.dropbear.id.au>

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

When the "hb-mode" option is activated on the powernv machine, the
firmware is mapped at 0x8000000 and the HRMOR of the HW threads are
set to the same address.

The PNOR mapping on the FW address space of the LPC bus is left enabled
to let the firmware load any other images required to boot the host.

Signed-off-by: Cédric Le Goater <clg@kaod.org>
Message-Id: <20200127144154.10170-4-clg@kaod.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
 hw/ppc/pnv.c              | 28 +++++++++++++++++++++++++++-
 hw/ppc/pnv_core.c         |  3 +++
 hw/ppc/pnv_lpc.c          |  5 ++++-
 include/hw/ppc/pnv.h      |  2 ++
 include/hw/ppc/pnv_core.h |  1 +
 5 files changed, 37 insertions(+), 2 deletions(-)

diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c
index e61994cf5a..9442e5eb63 100644
--- a/hw/ppc/pnv.c
+++ b/hw/ppc/pnv.c
@@ -716,7 +716,7 @@ static void pnv_init(MachineState *machine)
         exit(1);
     }
 
-    fw_size = load_image_targphys(fw_filename, FW_LOAD_ADDR, FW_MAX_SIZE);
+    fw_size = load_image_targphys(fw_filename, pnv->fw_load_addr, FW_MAX_SIZE);
     if (fw_size < 0) {
         error_report("Could not load OPAL firmware '%s'", fw_filename);
         exit(1);
@@ -1533,6 +1533,7 @@ static void pnv_chip_core_realize(PnvChip *chip, Error **errp)
     PnvChipClass *pcc = PNV_CHIP_GET_CLASS(chip);
     const char *typename = pnv_chip_core_typename(chip);
     int i, core_hwid;
+    PnvMachineState *pnv = PNV_MACHINE(qdev_get_machine());
 
     if (!object_class_by_name(typename)) {
         error_setg(errp, "Unable to find PowerNV CPU Core '%s'", typename);
@@ -1571,6 +1572,8 @@ static void pnv_chip_core_realize(PnvChip *chip, Error **errp)
         object_property_set_int(OBJECT(pnv_core),
                                 pcc->core_pir(chip, core_hwid),
                                 "pir", &error_fatal);
+        object_property_set_int(OBJECT(pnv_core), pnv->fw_load_addr,
+                                "hrmor", &error_fatal);
         object_property_set_link(OBJECT(pnv_core), OBJECT(chip), "chip",
                                  &error_abort);
         object_property_set_bool(OBJECT(pnv_core), true, "realized",
@@ -1767,6 +1770,22 @@ static void pnv_machine_power10_class_init(ObjectClass *oc, void *data)
     pmc->dt_power_mgt = pnv_dt_power_mgt;
 }
 
+static bool pnv_machine_get_hb(Object *obj, Error **errp)
+{
+    PnvMachineState *pnv = PNV_MACHINE(obj);
+
+    return !!pnv->fw_load_addr;
+}
+
+static void pnv_machine_set_hb(Object *obj, bool value, Error **errp)
+{
+    PnvMachineState *pnv = PNV_MACHINE(obj);
+
+    if (value) {
+        pnv->fw_load_addr = 0x8000000;
+    }
+}
+
 static void pnv_machine_class_init(ObjectClass *oc, void *data)
 {
     MachineClass *mc = MACHINE_CLASS(oc);
@@ -1786,6 +1805,13 @@ static void pnv_machine_class_init(ObjectClass *oc, void *data)
      */
     mc->default_ram_size = INITRD_LOAD_ADDR + INITRD_MAX_SIZE;
     ispc->print_info = pnv_pic_print_info;
+
+    object_class_property_add_bool(oc, "hb-mode",
+                                   pnv_machine_get_hb, pnv_machine_set_hb,
+                                   &error_abort);
+    object_class_property_set_description(oc, "hb-mode",
+                              "Use a hostboot like boot loader",
+                              NULL);
 }
 
 #define DEFINE_PNV8_CHIP_TYPE(type, class_initfn) \
diff --git a/hw/ppc/pnv_core.c b/hw/ppc/pnv_core.c
index 5fe3f21e12..f7247222bc 100644
--- a/hw/ppc/pnv_core.c
+++ b/hw/ppc/pnv_core.c
@@ -56,6 +56,8 @@ static void pnv_core_cpu_reset(PnvCore *pc, PowerPCCPU *cpu)
     env->nip = 0x10;
     env->msr |= MSR_HVB; /* Hypervisor mode */
 
+    env->spr[SPR_HRMOR] = pc->hrmor;
+
     pcc->intc_reset(pc->chip, cpu);
 }
 
@@ -289,6 +291,7 @@ static void pnv_core_unrealize(DeviceState *dev, Error **errp)
 
 static Property pnv_core_properties[] = {
     DEFINE_PROP_UINT32("pir", PnvCore, pir, 0),
+    DEFINE_PROP_UINT64("hrmor", PnvCore, hrmor, 0),
     DEFINE_PROP_LINK("chip", PnvCore, chip, TYPE_PNV_CHIP, PnvChip *),
     DEFINE_PROP_END_OF_LIST(),
 };
diff --git a/hw/ppc/pnv_lpc.c b/hw/ppc/pnv_lpc.c
index 22b205532b..d1de98f04c 100644
--- a/hw/ppc/pnv_lpc.c
+++ b/hw/ppc/pnv_lpc.c
@@ -825,6 +825,7 @@ ISABus *pnv_lpc_isa_create(PnvLpcController *lpc, bool use_cpld, Error **errp)
     qemu_irq *irqs;
     qemu_irq_handler handler;
     PnvMachineState *pnv = PNV_MACHINE(qdev_get_machine());
+    bool hostboot_mode = !!pnv->fw_load_addr;
 
     /* let isa_bus_new() create its own bridge on SysBus otherwise
      * devices speficied on the command line won't find the bus and
@@ -859,7 +860,9 @@ ISABus *pnv_lpc_isa_create(PnvLpcController *lpc, bool use_cpld, Error **errp)
      * Start disabled. The HIOMAP protocol will activate the mapping
      * with HIOMAP_C_CREATE_WRITE_WINDOW
      */
-    memory_region_set_enabled(&pnv->pnor->mmio, false);
+    if (!hostboot_mode) {
+        memory_region_set_enabled(&pnv->pnor->mmio, false);
+    }
 
     return isa_bus;
 }
diff --git a/include/hw/ppc/pnv.h b/include/hw/ppc/pnv.h
index d65dd32036..f225f2f6bf 100644
--- a/include/hw/ppc/pnv.h
+++ b/include/hw/ppc/pnv.h
@@ -217,6 +217,8 @@ struct PnvMachineState {
     Notifier     powerdown_notifier;
 
     PnvPnor      *pnor;
+
+    hwaddr       fw_load_addr;
 };
 
 #define PNV_FDT_ADDR          0x01000000
diff --git a/include/hw/ppc/pnv_core.h b/include/hw/ppc/pnv_core.h
index 55eee95104..113550eb7f 100644
--- a/include/hw/ppc/pnv_core.h
+++ b/include/hw/ppc/pnv_core.h
@@ -40,6 +40,7 @@ typedef struct PnvCore {
     /*< public >*/
     PowerPCCPU **threads;
     uint32_t pir;
+    uint64_t hrmor;
     PnvChip *chip;
 
     MemoryRegion xscom_regs;
-- 
2.24.1



  parent reply	other threads:[~2020-01-31  6:19 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-31  6:08 [PULL 00/34] ppc-for-5.0 queue 20200131 David Gibson
2020-01-31  6:08 ` [PULL 01/34] ppc/pnv: use QEMU unit definition MiB David Gibson
2020-01-31  6:08 ` [PULL 02/34] ppc/pnv: improve error logging when a PNOR update fails David Gibson
2020-01-31  6:08 ` [PULL 03/34] ppc:virtex_ml507: remove unused arguments David Gibson
2020-01-31  6:08 ` [PULL 04/34] hw/ppc/prep: Remove the deprecated "prep" machine and the OpenHackware BIOS David Gibson
2020-01-31  6:08 ` [PULL 05/34] target/ppc: Clarify the meaning of return values in kvm_handle_debug David Gibson
2020-01-31  6:08 ` [PULL 06/34] spapr: Fail CAS if option vector table cannot be parsed David Gibson
2020-01-31  6:08 ` [PULL 07/34] target/ppc: Add privileged message send facilities David Gibson
2020-01-31  6:08 ` [PULL 08/34] target/ppc: add support for Hypervisor Facility Unavailable Exception David Gibson
2020-01-31  6:08 ` [PULL 09/34] spapr: Don't allow multiple active vCPUs at CAS David Gibson
2020-01-31  6:09 ` [PULL 10/34] ppc/pnv: Add support for HRMOR on Radix host David Gibson
2020-01-31  6:09 ` [PULL 11/34] ppc/pnv: remove useless "core-pir" property alias David Gibson
2020-01-31  6:09 ` David Gibson [this message]
2020-01-31  6:09 ` [PULL 13/34] tpm: Move tpm_tis_show_buffer to tpm_util.c David Gibson
2020-01-31  6:09 ` [PULL 14/34] spapr: Implement get_dt_compatible() callback David Gibson
2020-01-31  6:09 ` [PULL 15/34] tpm_spapr: Support TPM for ppc64 using CRQ based interface David Gibson
2020-01-31  6:09 ` [PULL 16/34] tpm_spapr: Support suspend and resume David Gibson
2020-01-31  6:09 ` [PULL 17/34] hw/ppc/Kconfig: Enable TPM_SPAPR as part of PSERIES config David Gibson
2020-01-31  6:09 ` [PULL 18/34] docs/specs/tpm: reST-ify TPM documentation David Gibson
2020-01-31  6:09 ` [PULL 19/34] ppc/pnv: Add models for POWER9 PHB4 PCIe Host bridge David Gibson
2020-01-31  6:09 ` [PULL 20/34] ppc/pnv: Add models for POWER8 PHB3 " David Gibson
2020-01-31  6:09 ` [PULL 21/34] ppc/pnv: change the PowerNV machine devices to be non user creatable David Gibson
2020-01-31  6:09 ` [PULL 22/34] spapr: Enable DD2.3 accelerated count cache flush in pseries-5.0 machine David Gibson
2020-01-31  6:09 ` [PULL 23/34] target/ppc/cpu.h: Put macro parameter in parentheses David Gibson
2020-01-31  6:09 ` [PULL 24/34] Wrapper function to wait on condition for the main loop mutex David Gibson
2020-01-31  6:09 ` [PULL 25/34] ppc: spapr: Introduce FWNMI capability David Gibson
2020-01-31  6:09 ` [PULL 26/34] target/ppc: Handle NMI guest exit David Gibson
2020-01-31  6:09 ` [PULL 27/34] target/ppc: Build rtas error log upon an MCE David Gibson
2020-01-31  6:09 ` [PULL 28/34] ppc: spapr: Handle "ibm, nmi-register" and "ibm, nmi-interlock" RTAS calls David Gibson
2020-01-31  6:09 ` [PULL 29/34] migration: Include migration support for machine check handling David Gibson
2020-01-31  6:09 ` [PULL 30/34] ppc: spapr: Activate the FWNMI functionality David Gibson
2020-01-31  6:09 ` [PULL 31/34] target/ppc: Use probe_access for LSW, STSW David Gibson
2020-01-31  6:09 ` [PULL 32/34] target/ppc: Use probe_access for LMW, STMW David Gibson
2020-01-31  6:09 ` [PULL 33/34] target/ppc: Remove redundant mask in DCBZ David Gibson
2020-01-31  6:09 ` [PULL 34/34] target/ppc: Use probe_write for DCBZ David Gibson
2020-01-31 16:42 ` [PULL 00/34] ppc-for-5.0 queue 20200131 Peter Maydell
2020-02-02  8:43   ` David Gibson
2020-02-02 10:33     ` Greg Kurz

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=20200131060924.147449-13-david@gibson.dropbear.id.au \
    --to=david@gibson.dropbear.id.au \
    --cc=clg@kaod.org \
    --cc=groug@kaod.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.