ppc/pnv: Add a "hostboot" mode
cover ppc/pnv: Add a "hostboot" mode
Hello,
The QEMU PowerNV machine was first designed to start with a skiboot firmware at 0x0, which then loads a kernel and ramfs acting as a boot loader. Support of the POWER processor improving in QEMU, it has been possible to support other firmwares.
These changes add support for firmwares mapped at a different address than 0x0. First two patches are fixes/cleanups and the last one adds a "hb-mode" option to the machine for this purpose. It needs some discussion to see how we want to activate this new mode.
Thanks,
C.
Cédric Le Goater (3):
ppc/pnv: Add support for HRMOR on Radix host ppc/pnv: remove useless "core-pir" property alias. ppc/pnv: Add support for "hostboot" mode
include/hw/ppc/pnv.h | 2 ++ include/hw/ppc/pnv_core.h | 1 + hw/ppc/pnv.c | 28 +++++++++++++++++++++++++++- hw/ppc/pnv_core.c | 31 ++++++++++++++++--------------- hw/ppc/pnv_lpc.c | 5 ++++- target/ppc/mmu-radix64.c | 6 ++++++ 6 files changed, 56 insertions(+), 17 deletions(-)
Signature · 1 line
2.21.1
PATCH 1/3 ppc/pnv: Add support for HRMOR on Radix host
When in HV mode, if EA[0] is 0, the Hypervisor Offset Real Mode Register controls the access.
--- target/ppc/mmu-radix64.c | 6 ++++++ 1 file changed, 6 insertions(+)
target/ppc/mmu-radix64.c +6 -0
@@ -235,6 +235,12 @@ int ppc_radix64_handle_mmu_fault(PowerPCCPU *cpu, vaddr eaddr, int rwx,/* In real mode top 4 effective addr bits (mostly) ignored */ raddr = eaddr &0x0FFFFFFFFFFFFFFFULL ; +/* In HV mode, add HRMOR if top EA bit is clear */ +if (msr_hv || !env->has_hv_mode) { +if (!(eaddr >>63 )) { + raddr |= env->spr[SPR_HRMOR ]; + } + }tlb_set_page (cs, eaddr &TARGET_PAGE_MASK , raddr &TARGET_PAGE_MASK ,PAGE_READ |PAGE_WRITE |PAGE_EXEC , mmu_idx,TARGET_PAGE_SIZE );
Signature · 1 line
2.21.1
PATCH 2/3 ppc/pnv: remove useless "core-pir" property alias.
In reply to Cédric Le GoaterCommit 158e17a65e1a ("ppc/pnv: Link "chip" property to PnvCore::chip pointer") introduced some cleanups of the PnvCore realize handler. Let's continue by reworking a bit the interface of the PnvCore handlers for the CPU threads. These changes make the "core-pir" property alias unused. Remove it.
--- hw/ppc/pnv_core.c | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-)
hw/ppc/pnv_core.c +13 -15
@@ -40,11 +40,11 @@ static const char *pnv_core_cpu_typename(PnvCore *pc)return cpu_type; } -static void pnv_core_cpu_reset (PowerPCCPU *cpu,PnvChip *chip) +static void pnv_core_cpu_reset (PnvCore *pc,PowerPCCPU *cpu) {CPUState *cs =CPU (cpu);CPUPPCState *env = &cpu->env; -PnvChipClass *pcc =PNV_CHIP_GET_CLASS (chip); +PnvChipClass *pcc =PNV_CHIP_GET_CLASS (pc->chip);cpu_reset (cs);
@@ -56,7 +56,7 @@ static void pnv_core_cpu_reset(PowerPCCPU *cpu, PnvChip *chip) env->nip =0x10 ; env->msr |=MSR_HVB ;/* Hypervisor mode */ - pcc->intc_reset (chip, cpu); + pcc->intc_reset (pc->chip, cpu); }/*
@@ -162,14 +162,14 @@ static const MemoryRegionOps pnv_core_power9_xscom_ops = { .endianness = DEVICE_BIG_ENDIAN, }; -static void pnv_core_cpu_realize (PowerPCCPU *cpu,PnvChip *chip,Error **errp) +static void pnv_core_cpu_realize (PnvCore *pc,PowerPCCPU *cpu,Error **errp) {CPUPPCState *env = &cpu->env;int core_pir;int thread_index =0 ;/* TODO: TCG supports only one thread */ ppc_spr_t *pir = &env->spr_cb[SPR_PIR ];Error *local_err =NULL ; -PnvChipClass *pcc =PNV_CHIP_GET_CLASS (chip); +PnvChipClass *pcc =PNV_CHIP_GET_CLASS (pc->chip);object_property_set_bool (OBJECT (cpu), true,"realized" , &local_err);if (local_err) {
@@ -177,13 +177,13 @@ static void pnv_core_cpu_realize(PowerPCCPU *cpu, PnvChip *chip, Error **errp)return ; } - pcc->intc_create (chip, cpu, &local_err); + pcc->intc_create (pc->chip, cpu, &local_err);if (local_err) {error_propagate (errp, local_err);return ; } - core_pir =object_property_get_uint (OBJECT (cpu),"core-pir" , &error_abort); + core_pir =object_property_get_uint (OBJECT (pc),"pir" , &error_abort);/* * The PIR of a thread is the core PIR + the thread index. We will
@@ -203,7 +203,7 @@ static void pnv_core_reset(void *dev)int i;for (i =0 ; i < cc->nr_threads; i++) { -pnv_core_cpu_reset (pc->threads[i], pc->chip); +pnv_core_cpu_reset (pc, pc->threads[i]); } }
@@ -231,8 +231,6 @@ static void pnv_core_realize(DeviceState *dev, Error **errp)snprintf (name,sizeof (name),"thread[%d]" , i);object_property_add_child (OBJECT (pc), name, obj, &error_abort); -object_property_add_alias (obj,"core-pir" ,OBJECT (pc), -"pir" , &error_abort); cpu->machine_data =g_new0 (PnvCPUState,1 );
@@ -240,7 +238,7 @@ static void pnv_core_realize(DeviceState *dev, Error **errp) }for (j =0 ; j < cc->nr_threads; j++) { -pnv_core_cpu_realize (pc->threads[j], pc->chip, &local_err); +pnv_core_cpu_realize (pc, pc->threads[j], &local_err);if (local_err) { goto err; }
@@ -263,12 +261,12 @@ err:error_propagate (errp, local_err); } -static void pnv_core_cpu_unrealize (PowerPCCPU *cpu,PnvChip *chip) +static void pnv_core_cpu_unrealize (PnvCore *pc,PowerPCCPU *cpu) {PnvCPUState *pnv_cpu =pnv_cpu_state (cpu); -PnvChipClass *pcc =PNV_CHIP_GET_CLASS (chip); +PnvChipClass *pcc =PNV_CHIP_GET_CLASS (pc->chip); - pcc->intc_destroy (chip, cpu); + pcc->intc_destroy (pc->chip, cpu);cpu_remove_sync (CPU (cpu)); cpu->machine_data =NULL ;g_free (pnv_cpu);
@@ -284,7 +282,7 @@ static void pnv_core_unrealize(DeviceState *dev, Error **errp)qemu_unregister_reset (pnv_core_reset, pc);for (i =0 ; i < cc->nr_threads; i++) { -pnv_core_cpu_unrealize (pc->threads[i], pc->chip); +pnv_core_cpu_unrealize (pc, pc->threads[i]); }g_free (pc->threads); }
Signature · 1 line
2.21.1
PATCH 3/3 ppc/pnv: Add support for "hostboot" mode
In reply to Cédric Le GoaterWhen 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.
--- include/hw/ppc/pnv.h | 2 ++ include/hw/ppc/pnv_core.h | 1 + hw/ppc/pnv.c | 28 +++++++++++++++++++++++++++- hw/ppc/pnv_core.c | 3 +++ hw/ppc/pnv_lpc.c | 5 ++++- 5 files changed, 37 insertions(+), 2 deletions(-)
include/hw/ppc/pnv.h +2 -0
@@ -217,6 +217,8 @@ struct PnvMachineState {Notifier powerdown_notifier;PnvPnor *pnor; + +hwaddr fw_load_addr; };#define PNV_FDT_ADDR 0x01000000
include/hw/ppc/pnv_core.h +1 -0
@@ -40,6 +40,7 @@ typedef struct PnvCore {/*< public >*/ PowerPCCPU **threads;uint32_t pir; +uint64_t hrmor;PnvChip *chip;MemoryRegion xscom_regs;
hw/ppc/pnv.c +27 -1
@@ -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) \
hw/ppc/pnv_core.c +3 -0
@@ -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 (), };
hw/ppc/pnv_lpc.c +4 -1
@@ -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; }
Signature · 1 line
2.21.1
David Gibson
AppliedQuoted 11 lines · Cédric Le Goater
Hello,
The QEMU PowerNV machine was first designed to start with a skiboot firmware at
0x0, which then loads a kernel and ramfs acting as a boot loader. Support of the POWER processor improving in QEMU, it has been possible to support other firmwares.These changes add support for firmwares mapped at a different address than
0x0. First two patches are fixes/cleanups and the last one adds a "hb-mode" option to the machine for this purpose. It needs some discussion to see how we want to activate this new mode.
Applied to ppc-for-5.0, thanks.
Quoted 18 lines
Thanks,
C.
Cédric Le Goater (3):
ppc/pnv: Add support for HRMOR on Radix host ppc/pnv: remove useless "core-pir" property alias. ppc/pnv: Add support for "hostboot" modeinclude/hw/ppc/pnv.h | 2 ++ include/hw/ppc/pnv_core.h | 1 + hw/ppc/pnv.c | 28 +++++++++++++++++++++++++++- hw/ppc/pnv_core.c | 31 ++++++++++++++++--------------- hw/ppc/pnv_lpc.c | 5 ++++- target/ppc/mmu-radix64.c | 6 ++++++ 6 files changed, 56 insertions(+), 17 deletions(-)
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson