summaryrefslogtreecommitdiff
path: root/target-s390x
diff options
context:
space:
mode:
authorDavid Hildenbrand <dahi@linux.vnet.ibm.com>2016-09-05 10:52:22 +0200
committerCornelia Huck <cornelia.huck@de.ibm.com>2016-09-06 17:06:49 +0200
commit6c064de1e08f425e2852ea9b38ea0723994aa4fd (patch)
tree9a4c3edb47dc105fea65b26275cfc4efbe7b1ca1 /target-s390x
parent8b3d6cb1fa6ae12e80ed8c266a637468b52835c7 (diff)
downloadqemu-6c064de1e08f425e2852ea9b38ea0723994aa4fd.tar.gz
s390x/cpumodel: register defined CPU models as subclasses
This patch adds the CPU model definitions that are known on s390x - like z900, zBC12 or z13. For each definition, introduce two CPU models: 1. Base model (e.g. z13-base): Minimum feature set we expect to be around on all z13 systems. These models are migration-safe and will never change. 2. Flexible models (e.g. z13): Models that can change between QEMU versions and will be extended over time as we implement further features that are already part of such a model in real hardware of certain configurations. We want to work on features using ordinary bitmap operations, however we can't initialize a bitmap statically (unsigned long[] ...). Therefore we store the generated feature lists in separate arrays and convert them to proper bitmaps before registering all our CPU model classes. Acked-by: Cornelia Huck <cornelia.huck@de.ibm.com> Signed-off-by: David Hildenbrand <dahi@linux.vnet.ibm.com> Message-Id: <20160905085244.99980-9-dahi@linux.vnet.ibm.com> Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Diffstat (limited to 'target-s390x')
-rw-r--r--target-s390x/cpu-qom.h2
-rw-r--r--target-s390x/cpu_models.c124
-rw-r--r--target-s390x/cpu_models.h42
3 files changed, 168 insertions, 0 deletions
diff --git a/target-s390x/cpu-qom.h b/target-s390x/cpu-qom.h
index bb993d47f2..4e936e7788 100644
--- a/target-s390x/cpu-qom.h
+++ b/target-s390x/cpu-qom.h
@@ -21,6 +21,7 @@
#define QEMU_S390_CPU_QOM_H
#include "qom/cpu.h"
+#include "cpu_models.h"
#define TYPE_S390_CPU "s390-cpu"
@@ -45,6 +46,7 @@ typedef struct S390CPUClass {
/*< private >*/
CPUClass parent_class;
/*< public >*/
+ const S390CPUDef *cpu_def;
bool kvm_required;
bool is_static;
bool is_migration_safe;
diff --git a/target-s390x/cpu_models.c b/target-s390x/cpu_models.c
index b043c63cf1..491d0dbb5b 100644
--- a/target-s390x/cpu_models.c
+++ b/target-s390x/cpu_models.c
@@ -12,11 +12,66 @@
#include "qemu/osdep.h"
#include "cpu.h"
+#include "gen-features.h"
#include "qapi/error.h"
#ifndef CONFIG_USER_ONLY
#include "sysemu/arch_init.h"
#endif
+#define CPUDEF_INIT(_type, _gen, _ec_ga, _mha_pow, _hmfai, _name, _desc) \
+ { \
+ .name = _name, \
+ .type = _type, \
+ .gen = _gen, \
+ .ec_ga = _ec_ga, \
+ .mha_pow = _mha_pow, \
+ .hmfai = _hmfai, \
+ .desc = _desc, \
+ .base_init = { S390_FEAT_LIST_GEN ## _gen ## _GA ## _ec_ga ## _BASE }, \
+ .default_init = { S390_FEAT_LIST_GEN ## _gen ## _GA ## _ec_ga ## _DEFAULT }, \
+ .full_init = { S390_FEAT_LIST_GEN ## _gen ## _GA ## _ec_ga ## _FULL }, \
+ }
+
+/*
+ * CPU definiton list in order of release. For now, base features of a
+ * following release are always a subset of base features of the previous
+ * release. Same is correct for the other feature sets.
+ * A BC release always follows the corresponding EC release.
+ */
+static S390CPUDef s390_cpu_defs[] = {
+ CPUDEF_INIT(0x2064, 7, 1, 38, 0x00000000U, "z900", "IBM zSeries 900 GA1"),
+ CPUDEF_INIT(0x2064, 7, 2, 38, 0x00000000U, "z900.2", "IBM zSeries 900 GA2"),
+ CPUDEF_INIT(0x2064, 7, 3, 38, 0x00000000U, "z900.3", "IBM zSeries 900 GA3"),
+ CPUDEF_INIT(0x2066, 7, 3, 38, 0x00000000U, "z800", "IBM zSeries 800 GA1"),
+ CPUDEF_INIT(0x2084, 8, 1, 38, 0x00000000U, "z990", "IBM zSeries 990 GA1"),
+ CPUDEF_INIT(0x2084, 8, 2, 38, 0x00000000U, "z990.2", "IBM zSeries 990 GA2"),
+ CPUDEF_INIT(0x2084, 8, 3, 38, 0x00000000U, "z990.3", "IBM zSeries 990 GA3"),
+ CPUDEF_INIT(0x2086, 8, 3, 38, 0x00000000U, "z890", "IBM zSeries 880 GA1"),
+ CPUDEF_INIT(0x2084, 8, 4, 38, 0x00000000U, "z990.4", "IBM zSeries 990 GA4"),
+ CPUDEF_INIT(0x2086, 8, 4, 38, 0x00000000U, "z890.2", "IBM zSeries 880 GA2"),
+ CPUDEF_INIT(0x2084, 8, 5, 38, 0x00000000U, "z990.5", "IBM zSeries 990 GA5"),
+ CPUDEF_INIT(0x2086, 8, 5, 38, 0x00000000U, "z890.3", "IBM zSeries 880 GA3"),
+ CPUDEF_INIT(0x2094, 9, 1, 40, 0x00000000U, "z9EC", "IBM System z9 EC GA1"),
+ CPUDEF_INIT(0x2094, 9, 2, 40, 0x00000000U, "z9EC.2", "IBM System z9 EC GA2"),
+ CPUDEF_INIT(0x2096, 9, 2, 40, 0x00000000U, "z9BC", "IBM System z9 BC GA1"),
+ CPUDEF_INIT(0x2094, 9, 3, 40, 0x00000000U, "z9EC.3", "IBM System z9 EC GA3"),
+ CPUDEF_INIT(0x2096, 9, 3, 40, 0x00000000U, "z9BC.2", "IBM System z9 BC GA2"),
+ CPUDEF_INIT(0x2097, 10, 1, 43, 0x00000000U, "z10EC", "IBM System z10 EC GA1"),
+ CPUDEF_INIT(0x2097, 10, 2, 43, 0x00000000U, "z10EC.2", "IBM System z10 EC GA2"),
+ CPUDEF_INIT(0x2098, 10, 2, 43, 0x00000000U, "z10BC", "IBM System z10 BC GA1"),
+ CPUDEF_INIT(0x2097, 10, 3, 43, 0x00000000U, "z10EC.3", "IBM System z10 EC GA3"),
+ CPUDEF_INIT(0x2098, 10, 3, 43, 0x00000000U, "z10BC.2", "IBM System z10 BC GA2"),
+ CPUDEF_INIT(0x2817, 11, 1, 44, 0x08000000U, "z196", "IBM zEnterprise 196 GA1"),
+ CPUDEF_INIT(0x2817, 11, 2, 44, 0x08000000U, "z196.2", "IBM zEnterprise 196 GA2"),
+ CPUDEF_INIT(0x2818, 11, 2, 44, 0x08000000U, "z114", "IBM zEnterprise 114 GA1"),
+ CPUDEF_INIT(0x2827, 12, 1, 44, 0x08000000U, "zEC12", "IBM zEnterprise EC12 GA1"),
+ CPUDEF_INIT(0x2827, 12, 2, 44, 0x08000000U, "zEC12.2", "IBM zEnterprise EC12 GA2"),
+ CPUDEF_INIT(0x2828, 12, 2, 44, 0x08000000U, "zBC12", "IBM zEnterprise BC12 GA1"),
+ CPUDEF_INIT(0x2964, 13, 1, 47, 0x08000000U, "z13", "IBM z13 GA1"),
+ CPUDEF_INIT(0x2964, 13, 2, 47, 0x08000000U, "z13.2", "IBM z13 GA2"),
+ CPUDEF_INIT(0x2965, 13, 2, 47, 0x08000000U, "z13s", "IBM z13s GA1"),
+};
+
struct S390PrintCpuListInfo {
FILE *f;
fprintf_function print;
@@ -96,6 +151,10 @@ void s390_realize_cpu_model(CPUState *cs, Error **errp)
}
}
+static void s390_cpu_model_initfn(Object *obj)
+{
+}
+
#ifdef CONFIG_KVM
static void s390_host_cpu_model_initfn(Object *obj)
{
@@ -145,6 +204,27 @@ static void s390_host_cpu_model_class_init(ObjectClass *oc, void *data)
}
#endif
+static void s390_base_cpu_model_class_init(ObjectClass *oc, void *data)
+{
+ S390CPUClass *xcc = S390_CPU_CLASS(oc);
+
+ /* all base models are migration safe */
+ xcc->cpu_def = (const S390CPUDef *) data;
+ xcc->is_migration_safe = true;
+ xcc->is_static = true;
+ xcc->desc = xcc->cpu_def->desc;
+}
+
+static void s390_cpu_model_class_init(ObjectClass *oc, void *data)
+{
+ S390CPUClass *xcc = S390_CPU_CLASS(oc);
+
+ /* model that can change between QEMU versions */
+ xcc->cpu_def = (const S390CPUDef *) data;
+ xcc->is_migration_safe = true;
+ xcc->desc = xcc->cpu_def->desc;
+}
+
static void s390_qemu_cpu_model_class_init(ObjectClass *oc, void *data)
{
S390CPUClass *xcc = S390_CPU_CLASS(oc);
@@ -163,6 +243,12 @@ static char *s390_cpu_type_name(const char *model_name)
return g_strdup_printf(S390_CPU_TYPE_NAME("%s"), model_name);
}
+/* Generate type name for a base cpu model. Caller has to free the string. */
+static char *s390_base_cpu_type_name(const char *model_name)
+{
+ return g_strdup_printf(S390_CPU_TYPE_NAME("%s-base"), model_name);
+}
+
ObjectClass *s390_cpu_class_by_name(const char *name)
{
char *typename = s390_cpu_type_name(name);
@@ -193,6 +279,44 @@ static const TypeInfo host_s390_cpu_type_info = {
static void register_types(void)
{
+ int i;
+
+ /* init all bitmaps from gnerated data initially */
+ for (i = 0; i < ARRAY_SIZE(s390_cpu_defs); i++) {
+ s390_init_feat_bitmap(s390_cpu_defs[i].base_init,
+ s390_cpu_defs[i].base_feat);
+ s390_init_feat_bitmap(s390_cpu_defs[i].default_init,
+ s390_cpu_defs[i].default_feat);
+ s390_init_feat_bitmap(s390_cpu_defs[i].full_init,
+ s390_cpu_defs[i].full_feat);
+ }
+
+ for (i = 0; i < ARRAY_SIZE(s390_cpu_defs); i++) {
+ char *base_name = s390_base_cpu_type_name(s390_cpu_defs[i].name);
+ TypeInfo ti_base = {
+ .name = base_name,
+ .parent = TYPE_S390_CPU,
+ .instance_init = s390_cpu_model_initfn,
+ .instance_finalize = s390_cpu_model_finalize,
+ .class_init = s390_base_cpu_model_class_init,
+ .class_data = (void *) &s390_cpu_defs[i],
+ };
+ char *name = s390_cpu_type_name(s390_cpu_defs[i].name);
+ TypeInfo ti = {
+ .name = name,
+ .parent = TYPE_S390_CPU,
+ .instance_init = s390_cpu_model_initfn,
+ .instance_finalize = s390_cpu_model_finalize,
+ .class_init = s390_cpu_model_class_init,
+ .class_data = (void *) &s390_cpu_defs[i],
+ };
+
+ type_register_static(&ti_base);
+ type_register_static(&ti);
+ g_free(base_name);
+ g_free(name);
+ }
+
type_register_static(&qemu_s390_cpu_type_info);
#ifdef CONFIG_KVM
type_register_static(&host_s390_cpu_type_info);
diff --git a/target-s390x/cpu_models.h b/target-s390x/cpu_models.h
new file mode 100644
index 0000000000..0b87134daa
--- /dev/null
+++ b/target-s390x/cpu_models.h
@@ -0,0 +1,42 @@
+/*
+ * CPU models for s390x
+ *
+ * Copyright 2016 IBM Corp.
+ *
+ * Author(s): David Hildenbrand <dahi@linux.vnet.ibm.com>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or (at
+ * your option) any later version. See the COPYING file in the top-level
+ * directory.
+ */
+
+#ifndef TARGET_S390X_CPU_MODELS_H
+#define TARGET_S390X_CPU_MODELS_H
+
+#include "cpu_features.h"
+#include "qom/cpu.h"
+
+/* static CPU definition */
+typedef struct S390CPUDef {
+ const char *name; /* name exposed to the user */
+ const char *desc; /* description exposed to the user */
+ uint8_t gen; /* hw generation identification */
+ uint16_t type; /* cpu type identification */
+ uint8_t ec_ga; /* EC GA version (on which also the BC is based) */
+ uint8_t mha_pow; /* Maximum Host Adress Power, mha = 2^pow-1 */
+ uint32_t hmfai; /* hypervisor-managed facilities */
+ /* base/min features, must never be changed between QEMU versions */
+ S390FeatBitmap base_feat;
+ /* used to init base_feat from generated data */
+ S390FeatInit base_init;
+ /* deafault features, QEMU version specific */
+ S390FeatBitmap default_feat;
+ /* used to init default_feat from generated data */
+ S390FeatInit default_init;
+ /* max allowed features, QEMU version specific */
+ S390FeatBitmap full_feat;
+ /* used to init full_feat from generated data */
+ S390FeatInit full_init;
+} S390CPUDef;
+
+#endif /* TARGET_S390X_CPU_MODELS_H */