diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 57564e5b8e504c84973900e3838c16913c392c45..0787c664865a5ff608f3e4ef2388dad0a7dc9afc 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -1815,6 +1815,11 @@ static void ppc_spapr_init(MachineState *machine) if (mc->query_hotpluggable_cpus) { char *type = spapr_get_cpu_core_type(machine->cpu_model); + if (type == NULL) { + error_report("Unable to find sPAPR CPU Core definition"); + exit(1); + } + spapr->cores = g_new0(Object *, spapr_max_cores); for (i = 0; i < spapr_max_cores; i++) { int core_id = i * smp_threads; @@ -1826,15 +1831,7 @@ static void ppc_spapr_init(MachineState *machine) qemu_register_reset(spapr_drc_reset, drc); if (i < spapr_cores) { - char *type = spapr_get_cpu_core_type(machine->cpu_model); - Object *core; - - if (!object_class_by_name(type)) { - error_report("Unable to find sPAPR CPU Core definition"); - exit(1); - } - - core = object_new(type); + Object *core = object_new(type); object_property_set_int(core, smp_threads, "nr-threads", &error_fatal); object_property_set_int(core, core_id, CPU_CORE_PROP_CORE_ID, diff --git a/hw/ppc/spapr_cpu_core.c b/hw/ppc/spapr_cpu_core.c index 716f7c44cdbb39ee43c05d1ca08da86e560073a3..bcb483dbe69af4ece1a659780494b5073543d2ae 100644 --- a/hw/ppc/spapr_cpu_core.c +++ b/hw/ppc/spapr_cpu_core.c @@ -93,6 +93,19 @@ char *spapr_get_cpu_core_type(const char *model) core_type = g_strdup_printf("%s-%s", model_pieces[0], TYPE_SPAPR_CPU_CORE); g_strfreev(model_pieces); + + /* Check whether it exists or whether we have to look up an alias name */ + if (!object_class_by_name(core_type)) { + const char *realmodel; + + g_free(core_type); + realmodel = ppc_cpu_lookup_alias(model); + if (realmodel) { + return spapr_get_cpu_core_type(realmodel); + } + return NULL; + } + return core_type; } @@ -354,41 +367,32 @@ typedef struct SPAPRCoreInfo { } SPAPRCoreInfo; static const SPAPRCoreInfo spapr_cores[] = { - /* 970 and aliaes */ + /* 970 */ { .name = "970_v2.2", .initfn = spapr_cpu_core_970_initfn }, - { .name = "970", .initfn = spapr_cpu_core_970_initfn }, - /* 970MP variants and aliases */ + /* 970MP variants */ { .name = "970MP_v1.0", .initfn = spapr_cpu_core_970MP_v10_initfn }, { .name = "970mp_v1.0", .initfn = spapr_cpu_core_970MP_v10_initfn }, { .name = "970MP_v1.1", .initfn = spapr_cpu_core_970MP_v11_initfn }, { .name = "970mp_v1.1", .initfn = spapr_cpu_core_970MP_v11_initfn }, - { .name = "970mp", .initfn = spapr_cpu_core_970MP_v11_initfn }, - /* POWER5 and aliases */ + /* POWER5+ */ { .name = "POWER5+_v2.1", .initfn = spapr_cpu_core_POWER5plus_initfn }, - { .name = "POWER5+", .initfn = spapr_cpu_core_POWER5plus_initfn }, - /* POWER7 and aliases */ + /* POWER7 */ { .name = "POWER7_v2.3", .initfn = spapr_cpu_core_POWER7_initfn }, - { .name = "POWER7", .initfn = spapr_cpu_core_POWER7_initfn }, - /* POWER7+ and aliases */ + /* POWER7+ */ { .name = "POWER7+_v2.1", .initfn = spapr_cpu_core_POWER7plus_initfn }, - { .name = "POWER7+", .initfn = spapr_cpu_core_POWER7plus_initfn }, - /* POWER8 and aliases */ + /* POWER8 */ { .name = "POWER8_v2.0", .initfn = spapr_cpu_core_POWER8_initfn }, - { .name = "POWER8", .initfn = spapr_cpu_core_POWER8_initfn }, - { .name = "power8", .initfn = spapr_cpu_core_POWER8_initfn }, - /* POWER8E and aliases */ + /* POWER8E */ { .name = "POWER8E_v2.1", .initfn = spapr_cpu_core_POWER8E_initfn }, - { .name = "POWER8E", .initfn = spapr_cpu_core_POWER8E_initfn }, - /* POWER8NVL and aliases */ + /* POWER8NVL */ { .name = "POWER8NVL_v1.0", .initfn = spapr_cpu_core_POWER8NVL_initfn }, - { .name = "POWER8NVL", .initfn = spapr_cpu_core_POWER8NVL_initfn }, { .name = NULL } }; diff --git a/target-ppc/arch_dump.c b/target-ppc/arch_dump.c index df1fd8c336827a51b8b108256df8c468b25c2e74..40282a1f50fa853958019e9bbbd58800ef8e0f20 100644 --- a/target-ppc/arch_dump.c +++ b/target-ppc/arch_dump.c @@ -220,6 +220,11 @@ int cpu_get_dump_info(ArchDumpInfo *info, } else { info->d_endian = ELFDATA2LSB; } + /* 64KB is the max page size for pseries kernel */ + if (strncmp(object_get_typename(qdev_get_machine()), + "pseries-", 8) == 0) { + info->page_size = (1U << 16); + } return 0; } diff --git a/target-ppc/cpu.h b/target-ppc/cpu.h index 5fce1ffa251ad85f8d60a9803478b6148f05bca9..786ab5cdfa24cc226a7122b8417e453d5046ce5a 100644 --- a/target-ppc/cpu.h +++ b/target-ppc/cpu.h @@ -1201,6 +1201,7 @@ extern const struct VMStateDescription vmstate_ppc_cpu; /*****************************************************************************/ PowerPCCPU *cpu_ppc_init(const char *cpu_model); void ppc_translate_init(void); +const char *ppc_cpu_lookup_alias(const char *alias); void gen_update_current_nip(void *opaque); /* you can call this signal handler from your SIGBUS and SIGSEGV signal handlers to inform the virtual CPU of exceptions. non zero diff --git a/target-ppc/kvm.c b/target-ppc/kvm.c index 84764edeae714fd2b384e2d3cab7b216c6efc9d8..dcb68b9081266b85e2485fdd74a3d7500af4aacc 100644 --- a/target-ppc/kvm.c +++ b/target-ppc/kvm.c @@ -2394,6 +2394,13 @@ static int kvm_ppc_register_host_cpu_type(void) type_info.parent = object_class_get_name(OBJECT_CLASS(pvr_pcc)); type_register(&type_info); + /* Register generic family CPU class for a family */ + pvr_pcc = ppc_cpu_get_family_class(pvr_pcc); + dc = DEVICE_CLASS(pvr_pcc); + type_info.parent = object_class_get_name(OBJECT_CLASS(pvr_pcc)); + type_info.name = g_strdup_printf("%s-"TYPE_POWERPC_CPU, dc->desc); + type_register(&type_info); + #if defined(TARGET_PPC64) type_info.name = g_strdup_printf("%s-"TYPE_SPAPR_CPU_CORE, "host"); type_info.parent = TYPE_SPAPR_CPU_CORE, @@ -2402,16 +2409,12 @@ static int kvm_ppc_register_host_cpu_type(void) type_info.class_init = NULL; type_register(&type_info); g_free((void *)type_info.name); - type_info.instance_size = 0; - type_info.instance_init = NULL; -#endif - /* Register generic family CPU class for a family */ - pvr_pcc = ppc_cpu_get_family_class(pvr_pcc); - dc = DEVICE_CLASS(pvr_pcc); - type_info.parent = object_class_get_name(OBJECT_CLASS(pvr_pcc)); - type_info.name = g_strdup_printf("%s-"TYPE_POWERPC_CPU, dc->desc); + /* Register generic spapr CPU family class for current host CPU type */ + type_info.name = g_strdup_printf("%s-"TYPE_SPAPR_CPU_CORE, dc->desc); type_register(&type_info); + g_free((void *)type_info.name); +#endif return 0; } diff --git a/target-ppc/translate_init.c b/target-ppc/translate_init.c index 5f28a36998827cbafe51e41680eb84a859bb90b9..7a9b15e7e1f2af93b588fcf0b185c2653eaeba8d 100644 --- a/target-ppc/translate_init.c +++ b/target-ppc/translate_init.c @@ -10012,6 +10012,19 @@ static ObjectClass *ppc_cpu_class_by_name(const char *name) return NULL; } +const char *ppc_cpu_lookup_alias(const char *alias) +{ + int ai; + + for (ai = 0; ppc_cpu_aliases[ai].alias != NULL; ai++) { + if (strcmp(ppc_cpu_aliases[ai].alias, alias) == 0) { + return ppc_cpu_aliases[ai].model; + } + } + + return NULL; +} + PowerPCCPU *cpu_ppc_init(const char *cpu_model) { return POWERPC_CPU(cpu_generic_init(TYPE_POWERPC_CPU, cpu_model));