s390x/sclp: indicate sclp features
[qemu.git] / target-s390x / cpu_models.c
blobd59e5ef4ee669850a7f46707af72dee1dc85491a
1 /*
2 * CPU models for s390x
4 * Copyright 2016 IBM Corp.
6 * Author(s): David Hildenbrand <dahi@linux.vnet.ibm.com>
8 * This work is licensed under the terms of the GNU GPL, version 2 or (at
9 * your option) any later version. See the COPYING file in the top-level
10 * directory.
13 #include "qemu/osdep.h"
14 #include "cpu.h"
15 #include "gen-features.h"
16 #include "qapi/error.h"
17 #include "qapi/visitor.h"
18 #include "qemu/error-report.h"
19 #ifndef CONFIG_USER_ONLY
20 #include "sysemu/arch_init.h"
21 #endif
23 #define CPUDEF_INIT(_type, _gen, _ec_ga, _mha_pow, _hmfai, _name, _desc) \
24 { \
25 .name = _name, \
26 .type = _type, \
27 .gen = _gen, \
28 .ec_ga = _ec_ga, \
29 .mha_pow = _mha_pow, \
30 .hmfai = _hmfai, \
31 .desc = _desc, \
32 .base_init = { S390_FEAT_LIST_GEN ## _gen ## _GA ## _ec_ga ## _BASE }, \
33 .default_init = { S390_FEAT_LIST_GEN ## _gen ## _GA ## _ec_ga ## _DEFAULT }, \
34 .full_init = { S390_FEAT_LIST_GEN ## _gen ## _GA ## _ec_ga ## _FULL }, \
38 * CPU definiton list in order of release. For now, base features of a
39 * following release are always a subset of base features of the previous
40 * release. Same is correct for the other feature sets.
41 * A BC release always follows the corresponding EC release.
43 static S390CPUDef s390_cpu_defs[] = {
44 CPUDEF_INIT(0x2064, 7, 1, 38, 0x00000000U, "z900", "IBM zSeries 900 GA1"),
45 CPUDEF_INIT(0x2064, 7, 2, 38, 0x00000000U, "z900.2", "IBM zSeries 900 GA2"),
46 CPUDEF_INIT(0x2064, 7, 3, 38, 0x00000000U, "z900.3", "IBM zSeries 900 GA3"),
47 CPUDEF_INIT(0x2066, 7, 3, 38, 0x00000000U, "z800", "IBM zSeries 800 GA1"),
48 CPUDEF_INIT(0x2084, 8, 1, 38, 0x00000000U, "z990", "IBM zSeries 990 GA1"),
49 CPUDEF_INIT(0x2084, 8, 2, 38, 0x00000000U, "z990.2", "IBM zSeries 990 GA2"),
50 CPUDEF_INIT(0x2084, 8, 3, 38, 0x00000000U, "z990.3", "IBM zSeries 990 GA3"),
51 CPUDEF_INIT(0x2086, 8, 3, 38, 0x00000000U, "z890", "IBM zSeries 880 GA1"),
52 CPUDEF_INIT(0x2084, 8, 4, 38, 0x00000000U, "z990.4", "IBM zSeries 990 GA4"),
53 CPUDEF_INIT(0x2086, 8, 4, 38, 0x00000000U, "z890.2", "IBM zSeries 880 GA2"),
54 CPUDEF_INIT(0x2084, 8, 5, 38, 0x00000000U, "z990.5", "IBM zSeries 990 GA5"),
55 CPUDEF_INIT(0x2086, 8, 5, 38, 0x00000000U, "z890.3", "IBM zSeries 880 GA3"),
56 CPUDEF_INIT(0x2094, 9, 1, 40, 0x00000000U, "z9EC", "IBM System z9 EC GA1"),
57 CPUDEF_INIT(0x2094, 9, 2, 40, 0x00000000U, "z9EC.2", "IBM System z9 EC GA2"),
58 CPUDEF_INIT(0x2096, 9, 2, 40, 0x00000000U, "z9BC", "IBM System z9 BC GA1"),
59 CPUDEF_INIT(0x2094, 9, 3, 40, 0x00000000U, "z9EC.3", "IBM System z9 EC GA3"),
60 CPUDEF_INIT(0x2096, 9, 3, 40, 0x00000000U, "z9BC.2", "IBM System z9 BC GA2"),
61 CPUDEF_INIT(0x2097, 10, 1, 43, 0x00000000U, "z10EC", "IBM System z10 EC GA1"),
62 CPUDEF_INIT(0x2097, 10, 2, 43, 0x00000000U, "z10EC.2", "IBM System z10 EC GA2"),
63 CPUDEF_INIT(0x2098, 10, 2, 43, 0x00000000U, "z10BC", "IBM System z10 BC GA1"),
64 CPUDEF_INIT(0x2097, 10, 3, 43, 0x00000000U, "z10EC.3", "IBM System z10 EC GA3"),
65 CPUDEF_INIT(0x2098, 10, 3, 43, 0x00000000U, "z10BC.2", "IBM System z10 BC GA2"),
66 CPUDEF_INIT(0x2817, 11, 1, 44, 0x08000000U, "z196", "IBM zEnterprise 196 GA1"),
67 CPUDEF_INIT(0x2817, 11, 2, 44, 0x08000000U, "z196.2", "IBM zEnterprise 196 GA2"),
68 CPUDEF_INIT(0x2818, 11, 2, 44, 0x08000000U, "z114", "IBM zEnterprise 114 GA1"),
69 CPUDEF_INIT(0x2827, 12, 1, 44, 0x08000000U, "zEC12", "IBM zEnterprise EC12 GA1"),
70 CPUDEF_INIT(0x2827, 12, 2, 44, 0x08000000U, "zEC12.2", "IBM zEnterprise EC12 GA2"),
71 CPUDEF_INIT(0x2828, 12, 2, 44, 0x08000000U, "zBC12", "IBM zEnterprise BC12 GA1"),
72 CPUDEF_INIT(0x2964, 13, 1, 47, 0x08000000U, "z13", "IBM z13 GA1"),
73 CPUDEF_INIT(0x2964, 13, 2, 47, 0x08000000U, "z13.2", "IBM z13 GA2"),
74 CPUDEF_INIT(0x2965, 13, 2, 47, 0x08000000U, "z13s", "IBM z13s GA1"),
77 void s390_get_feat_block(S390FeatType type, uint8_t *data)
79 static S390CPU *cpu;
81 if (!cpu) {
82 cpu = S390_CPU(qemu_get_cpu(0));
85 if (!cpu || !cpu->model) {
86 return;
88 s390_fill_feat_block(cpu->model->features, type, data);
91 bool s390_has_feat(S390Feat feat)
93 static S390CPU *cpu;
95 if (!cpu) {
96 cpu = S390_CPU(qemu_get_cpu(0));
99 if (!cpu || !cpu->model) {
100 #ifdef CONFIG_KVM
101 if (kvm_enabled()) {
102 if (feat == S390_FEAT_VECTOR) {
103 return kvm_check_extension(kvm_state,
104 KVM_CAP_S390_VECTOR_REGISTERS);
106 if (feat == S390_FEAT_RUNTIME_INSTRUMENTATION) {
107 return kvm_s390_get_ri();
110 #endif
111 return 0;
113 return test_bit(feat, cpu->model->features);
116 struct S390PrintCpuListInfo {
117 FILE *f;
118 fprintf_function print;
121 static void print_cpu_model_list(ObjectClass *klass, void *opaque)
123 struct S390PrintCpuListInfo *info = opaque;
124 S390CPUClass *scc = S390_CPU_CLASS(klass);
125 char *name = g_strdup(object_class_get_name(klass));
126 const char *details = "";
128 if (scc->is_static) {
129 details = "(static, migration-safe)";
130 } else if (scc->is_migration_safe) {
131 details = "(migration-safe)";
134 /* strip off the -s390-cpu */
135 g_strrstr(name, "-" TYPE_S390_CPU)[0] = 0;
136 (*info->print)(info->f, "s390 %-15s %-35s %s\n", name, scc->desc,
137 details);
138 g_free(name);
141 void s390_cpu_list(FILE *f, fprintf_function print)
143 struct S390PrintCpuListInfo info = {
144 .f = f,
145 .print = print,
147 S390FeatGroup group;
148 S390Feat feat;
150 object_class_foreach(print_cpu_model_list, TYPE_S390_CPU, false, &info);
152 (*print)(f, "\nRecognized feature flags:\n");
153 for (feat = 0; feat < S390_FEAT_MAX; feat++) {
154 const S390FeatDef *def = s390_feat_def(feat);
156 (*print)(f, "%-20s %-50s\n", def->name, def->desc);
159 (*print)(f, "\nRecognized feature groups:\n");
160 for (group = 0; group < S390_FEAT_GROUP_MAX; group++) {
161 const S390FeatGroupDef *def = s390_feat_group_def(group);
163 (*print)(f, "%-20s %-50s\n", def->name, def->desc);
167 #ifndef CONFIG_USER_ONLY
168 static void create_cpu_model_list(ObjectClass *klass, void *opaque)
170 CpuDefinitionInfoList **cpu_list = opaque;
171 CpuDefinitionInfoList *entry;
172 CpuDefinitionInfo *info;
173 char *name = g_strdup(object_class_get_name(klass));
174 S390CPUClass *scc = S390_CPU_CLASS(klass);
176 /* strip off the -s390-cpu */
177 g_strrstr(name, "-" TYPE_S390_CPU)[0] = 0;
178 info = g_malloc0(sizeof(*info));
179 info->name = name;
180 info->has_migration_safe = true;
181 info->migration_safe = scc->is_migration_safe;
182 info->q_static = scc->is_static;
185 entry = g_malloc0(sizeof(*entry));
186 entry->value = info;
187 entry->next = *cpu_list;
188 *cpu_list = entry;
191 CpuDefinitionInfoList *arch_query_cpu_definitions(Error **errp)
193 CpuDefinitionInfoList *list = NULL;
195 object_class_foreach(create_cpu_model_list, TYPE_S390_CPU, false, &list);
197 return list;
199 #endif
201 static void check_consistency(const S390CPUModel *model)
203 static int dep[][2] = {
204 { S390_FEAT_IPTE_RANGE, S390_FEAT_DAT_ENH },
205 { S390_FEAT_IDTE_SEGMENT, S390_FEAT_DAT_ENH },
206 { S390_FEAT_IDTE_REGION, S390_FEAT_DAT_ENH },
207 { S390_FEAT_IDTE_REGION, S390_FEAT_IDTE_SEGMENT },
208 { S390_FEAT_LOCAL_TLB_CLEARING, S390_FEAT_DAT_ENH},
209 { S390_FEAT_LONG_DISPLACEMENT_FAST, S390_FEAT_LONG_DISPLACEMENT },
210 { S390_FEAT_DFP_FAST, S390_FEAT_DFP },
211 { S390_FEAT_TRANSACTIONAL_EXE, S390_FEAT_STFLE_49 },
212 { S390_FEAT_EDAT_2, S390_FEAT_EDAT},
213 { S390_FEAT_MSA_EXT_5, S390_FEAT_KIMD_SHA_512 },
214 { S390_FEAT_MSA_EXT_5, S390_FEAT_KLMD_SHA_512 },
215 { S390_FEAT_MSA_EXT_4, S390_FEAT_MSA_EXT_3 },
216 { S390_FEAT_SIE_CMMA, S390_FEAT_CMM },
217 { S390_FEAT_SIE_CMMA, S390_FEAT_SIE_GSLS },
218 { S390_FEAT_SIE_PFMFI, S390_FEAT_EDAT },
220 int i;
222 for (i = 0; i < ARRAY_SIZE(dep); i++) {
223 if (test_bit(dep[i][0], model->features) &&
224 !test_bit(dep[i][1], model->features)) {
225 error_report("Warning: \'%s\' requires \'%s\'.",
226 s390_feat_def(dep[i][0])->name,
227 s390_feat_def(dep[i][1])->name);
232 static void error_prepend_missing_feat(const char *name, void *opaque)
234 error_prepend((Error **) opaque, "%s ", name);
237 static void check_compatibility(const S390CPUModel *max_model,
238 const S390CPUModel *model, Error **errp)
240 S390FeatBitmap missing;
242 if (model->def->gen > max_model->def->gen) {
243 error_setg(errp, "Selected CPU generation is too new. Maximum "
244 "supported model in the configuration: \'%s\'",
245 max_model->def->name);
246 return;
247 } else if (model->def->gen == max_model->def->gen &&
248 model->def->ec_ga > max_model->def->ec_ga) {
249 error_setg(errp, "Selected CPU GA level is too new. Maximum "
250 "supported model in the configuration: \'%s\'",
251 max_model->def->name);
252 return;
255 /* detect the missing features to properly report them */
256 bitmap_andnot(missing, model->features, max_model->features, S390_FEAT_MAX);
257 if (bitmap_empty(missing, S390_FEAT_MAX)) {
258 return;
261 error_setg(errp, " ");
262 s390_feat_bitmap_to_ascii(missing, errp, error_prepend_missing_feat);
263 error_prepend(errp, "Some features requested in the CPU model are not "
264 "available in the configuration: ");
267 static S390CPUModel *get_max_cpu_model(Error **errp)
269 #ifndef CONFIG_USER_ONLY
270 static S390CPUModel max_model;
271 static bool cached;
273 if (cached) {
274 return &max_model;
277 if (kvm_enabled()) {
278 error_setg(errp, "KVM does not support CPU models.");
279 } else {
280 /* TCG enulates a z900 */
281 max_model.def = &s390_cpu_defs[0];
282 bitmap_copy(max_model.features, max_model.def->default_feat,
283 S390_FEAT_MAX);
285 if (!*errp) {
286 cached = true;
287 return &max_model;
289 #endif
290 return NULL;
293 static inline void apply_cpu_model(const S390CPUModel *model, Error **errp)
295 #ifndef CONFIG_USER_ONLY
296 static S390CPUModel applied_model;
297 static bool applied;
300 * We have the same model for all VCPUs. KVM can only be configured before
301 * any VCPUs are defined in KVM.
303 if (applied) {
304 if (model && memcmp(&applied_model, model, sizeof(S390CPUModel))) {
305 error_setg(errp, "Mixed CPU models are not supported on s390x.");
307 return;
310 if (kvm_enabled()) {
311 /* FIXME KVM */
312 error_setg(errp, "KVM doesn't support CPU models.");
313 } else if (model) {
314 /* FIXME TCG - use data for stdip/stfl */
317 if (!*errp) {
318 applied = true;
319 if (model) {
320 applied_model = *model;
323 #endif
326 void s390_realize_cpu_model(CPUState *cs, Error **errp)
328 S390CPUClass *xcc = S390_CPU_GET_CLASS(cs);
329 S390CPU *cpu = S390_CPU(cs);
330 const S390CPUModel *max_model;
332 if (xcc->kvm_required && !kvm_enabled()) {
333 error_setg(errp, "CPU definition requires KVM");
334 return;
337 if (!cpu->model) {
338 /* no host model support -> perform compatibility stuff */
339 apply_cpu_model(NULL, errp);
340 return;
343 max_model = get_max_cpu_model(errp);
344 if (*errp) {
345 error_prepend(errp, "CPU models are not available: ");
346 return;
349 /* copy over properties that can vary */
350 cpu->model->lowest_ibc = max_model->lowest_ibc;
351 cpu->model->cpu_id = max_model->cpu_id;
352 cpu->model->cpu_ver = max_model->cpu_ver;
354 check_consistency(cpu->model);
355 check_compatibility(max_model, cpu->model, errp);
356 if (*errp) {
357 return;
360 apply_cpu_model(cpu->model, errp);
363 static void get_feature(Object *obj, Visitor *v, const char *name,
364 void *opaque, Error **errp)
366 S390Feat feat = (S390Feat) opaque;
367 S390CPU *cpu = S390_CPU(obj);
368 bool value;
370 if (!cpu->model) {
371 error_setg(errp, "Details about the host CPU model are not available, "
372 "features cannot be queried.");
373 return;
376 value = test_bit(feat, cpu->model->features);
377 visit_type_bool(v, name, &value, errp);
380 static void set_feature(Object *obj, Visitor *v, const char *name,
381 void *opaque, Error **errp)
383 S390Feat feat = (S390Feat) opaque;
384 DeviceState *dev = DEVICE(obj);
385 S390CPU *cpu = S390_CPU(obj);
386 bool value;
388 if (dev->realized) {
389 error_setg(errp, "Attempt to set property '%s' on '%s' after "
390 "it was realized", name, object_get_typename(obj));
391 return;
392 } else if (!cpu->model) {
393 error_setg(errp, "Details about the host CPU model are not available, "
394 "features cannot be changed.");
395 return;
398 visit_type_bool(v, name, &value, errp);
399 if (*errp) {
400 return;
402 if (value) {
403 if (!test_bit(feat, cpu->model->def->full_feat)) {
404 error_setg(errp, "Feature '%s' is not available for CPU model '%s',"
405 " it was introduced with later models.",
406 name, cpu->model->def->name);
407 return;
409 set_bit(feat, cpu->model->features);
410 } else {
411 clear_bit(feat, cpu->model->features);
415 static void get_feature_group(Object *obj, Visitor *v, const char *name,
416 void *opaque, Error **errp)
418 S390FeatGroup group = (S390FeatGroup) opaque;
419 const S390FeatGroupDef *def = s390_feat_group_def(group);
420 S390CPU *cpu = S390_CPU(obj);
421 S390FeatBitmap tmp;
422 bool value;
424 if (!cpu->model) {
425 error_setg(errp, "Details about the host CPU model are not available, "
426 "features cannot be queried.");
427 return;
430 /* a group is enabled if all features are enabled */
431 bitmap_and(tmp, cpu->model->features, def->feat, S390_FEAT_MAX);
432 value = bitmap_equal(tmp, def->feat, S390_FEAT_MAX);
433 visit_type_bool(v, name, &value, errp);
436 static void set_feature_group(Object *obj, Visitor *v, const char *name,
437 void *opaque, Error **errp)
439 S390FeatGroup group = (S390FeatGroup) opaque;
440 const S390FeatGroupDef *def = s390_feat_group_def(group);
441 DeviceState *dev = DEVICE(obj);
442 S390CPU *cpu = S390_CPU(obj);
443 bool value;
445 if (dev->realized) {
446 error_setg(errp, "Attempt to set property '%s' on '%s' after "
447 "it was realized", name, object_get_typename(obj));
448 return;
449 } else if (!cpu->model) {
450 error_setg(errp, "Details about the host CPU model are not available, "
451 "features cannot be changed.");
452 return;
455 visit_type_bool(v, name, &value, errp);
456 if (*errp) {
457 return;
459 if (value) {
460 /* groups are added in one shot, so an intersect is sufficient */
461 if (!bitmap_intersects(def->feat, cpu->model->def->full_feat,
462 S390_FEAT_MAX)) {
463 error_setg(errp, "Group '%s' is not available for CPU model '%s',"
464 " it was introduced with later models.",
465 name, cpu->model->def->name);
466 return;
468 bitmap_or(cpu->model->features, cpu->model->features, def->feat,
469 S390_FEAT_MAX);
470 } else {
471 bitmap_andnot(cpu->model->features, cpu->model->features, def->feat,
472 S390_FEAT_MAX);
476 void s390_cpu_model_register_props(Object *obj)
478 S390FeatGroup group;
479 S390Feat feat;
481 for (feat = 0; feat < S390_FEAT_MAX; feat++) {
482 const S390FeatDef *def = s390_feat_def(feat);
483 object_property_add(obj, def->name, "bool", get_feature,
484 set_feature, NULL, (void *) feat, NULL);
485 object_property_set_description(obj, def->name, def->desc , NULL);
487 for (group = 0; group < S390_FEAT_GROUP_MAX; group++) {
488 const S390FeatGroupDef *def = s390_feat_group_def(group);
489 object_property_add(obj, def->name, "bool", get_feature_group,
490 set_feature_group, NULL, (void *) group, NULL);
491 object_property_set_description(obj, def->name, def->desc , NULL);
495 static void s390_cpu_model_initfn(Object *obj)
497 S390CPU *cpu = S390_CPU(obj);
498 S390CPUClass *xcc = S390_CPU_GET_CLASS(cpu);
500 cpu->model = g_malloc0(sizeof(*cpu->model));
501 /* copy the model, so we can modify it */
502 cpu->model->def = xcc->cpu_def;
503 if (xcc->is_static) {
504 /* base model - features will never change */
505 bitmap_copy(cpu->model->features, cpu->model->def->base_feat,
506 S390_FEAT_MAX);
507 } else {
508 /* latest model - features can change */
509 bitmap_copy(cpu->model->features,
510 cpu->model->def->default_feat, S390_FEAT_MAX);
514 #ifdef CONFIG_KVM
515 static void s390_host_cpu_model_initfn(Object *obj)
518 #endif
520 static void s390_qemu_cpu_model_initfn(Object *obj)
522 S390CPU *cpu = S390_CPU(obj);
524 cpu->model = g_malloc0(sizeof(*cpu->model));
525 /* TCG emulates a z900 */
526 cpu->model->def = &s390_cpu_defs[0];
527 bitmap_copy(cpu->model->features, cpu->model->def->default_feat,
528 S390_FEAT_MAX);
531 static void s390_cpu_model_finalize(Object *obj)
533 S390CPU *cpu = S390_CPU(obj);
535 g_free(cpu->model);
536 cpu->model = NULL;
539 static bool get_is_migration_safe(Object *obj, Error **errp)
541 return S390_CPU_GET_CLASS(obj)->is_migration_safe;
544 static bool get_is_static(Object *obj, Error **errp)
546 return S390_CPU_GET_CLASS(obj)->is_static;
549 static char *get_description(Object *obj, Error **errp)
551 return g_strdup(S390_CPU_GET_CLASS(obj)->desc);
554 void s390_cpu_model_class_register_props(ObjectClass *oc)
556 object_class_property_add_bool(oc, "migration-safe", get_is_migration_safe,
557 NULL, NULL);
558 object_class_property_add_bool(oc, "static", get_is_static,
559 NULL, NULL);
560 object_class_property_add_str(oc, "description", get_description, NULL,
561 NULL);
564 #ifdef CONFIG_KVM
565 static void s390_host_cpu_model_class_init(ObjectClass *oc, void *data)
567 S390CPUClass *xcc = S390_CPU_CLASS(oc);
569 xcc->kvm_required = true;
570 xcc->desc = "KVM only: All recognized features";
572 #endif
574 static void s390_base_cpu_model_class_init(ObjectClass *oc, void *data)
576 S390CPUClass *xcc = S390_CPU_CLASS(oc);
578 /* all base models are migration safe */
579 xcc->cpu_def = (const S390CPUDef *) data;
580 xcc->is_migration_safe = true;
581 xcc->is_static = true;
582 xcc->desc = xcc->cpu_def->desc;
585 static void s390_cpu_model_class_init(ObjectClass *oc, void *data)
587 S390CPUClass *xcc = S390_CPU_CLASS(oc);
589 /* model that can change between QEMU versions */
590 xcc->cpu_def = (const S390CPUDef *) data;
591 xcc->is_migration_safe = true;
592 xcc->desc = xcc->cpu_def->desc;
595 static void s390_qemu_cpu_model_class_init(ObjectClass *oc, void *data)
597 S390CPUClass *xcc = S390_CPU_CLASS(oc);
599 xcc->is_migration_safe = true;
600 xcc->desc = g_strdup_printf("QEMU Virtual CPU version %s",
601 qemu_hw_version());
604 #define S390_CPU_TYPE_SUFFIX "-" TYPE_S390_CPU
605 #define S390_CPU_TYPE_NAME(name) (name S390_CPU_TYPE_SUFFIX)
607 /* Generate type name for a cpu model. Caller has to free the string. */
608 static char *s390_cpu_type_name(const char *model_name)
610 return g_strdup_printf(S390_CPU_TYPE_NAME("%s"), model_name);
613 /* Generate type name for a base cpu model. Caller has to free the string. */
614 static char *s390_base_cpu_type_name(const char *model_name)
616 return g_strdup_printf(S390_CPU_TYPE_NAME("%s-base"), model_name);
619 ObjectClass *s390_cpu_class_by_name(const char *name)
621 char *typename = s390_cpu_type_name(name);
622 ObjectClass *oc;
624 oc = object_class_by_name(typename);
625 g_free(typename);
626 return oc;
629 static const TypeInfo qemu_s390_cpu_type_info = {
630 .name = S390_CPU_TYPE_NAME("qemu"),
631 .parent = TYPE_S390_CPU,
632 .instance_init = s390_qemu_cpu_model_initfn,
633 .instance_finalize = s390_cpu_model_finalize,
634 .class_init = s390_qemu_cpu_model_class_init,
637 #ifdef CONFIG_KVM
638 static const TypeInfo host_s390_cpu_type_info = {
639 .name = S390_CPU_TYPE_NAME("host"),
640 .parent = TYPE_S390_CPU,
641 .instance_init = s390_host_cpu_model_initfn,
642 .instance_finalize = s390_cpu_model_finalize,
643 .class_init = s390_host_cpu_model_class_init,
645 #endif
647 static void register_types(void)
649 int i;
651 /* init all bitmaps from gnerated data initially */
652 for (i = 0; i < ARRAY_SIZE(s390_cpu_defs); i++) {
653 s390_init_feat_bitmap(s390_cpu_defs[i].base_init,
654 s390_cpu_defs[i].base_feat);
655 s390_init_feat_bitmap(s390_cpu_defs[i].default_init,
656 s390_cpu_defs[i].default_feat);
657 s390_init_feat_bitmap(s390_cpu_defs[i].full_init,
658 s390_cpu_defs[i].full_feat);
661 for (i = 0; i < ARRAY_SIZE(s390_cpu_defs); i++) {
662 char *base_name = s390_base_cpu_type_name(s390_cpu_defs[i].name);
663 TypeInfo ti_base = {
664 .name = base_name,
665 .parent = TYPE_S390_CPU,
666 .instance_init = s390_cpu_model_initfn,
667 .instance_finalize = s390_cpu_model_finalize,
668 .class_init = s390_base_cpu_model_class_init,
669 .class_data = (void *) &s390_cpu_defs[i],
671 char *name = s390_cpu_type_name(s390_cpu_defs[i].name);
672 TypeInfo ti = {
673 .name = name,
674 .parent = TYPE_S390_CPU,
675 .instance_init = s390_cpu_model_initfn,
676 .instance_finalize = s390_cpu_model_finalize,
677 .class_init = s390_cpu_model_class_init,
678 .class_data = (void *) &s390_cpu_defs[i],
681 type_register_static(&ti_base);
682 type_register_static(&ti);
683 g_free(base_name);
684 g_free(name);
687 type_register_static(&qemu_s390_cpu_type_info);
688 #ifdef CONFIG_KVM
689 type_register_static(&host_s390_cpu_type_info);
690 #endif
693 type_init(register_types)