xref: /openbmc/qemu/hw/s390x/s390-virtio-ccw.c (revision 7f709ce7)
1 /*
2  * virtio ccw machine
3  *
4  * Copyright 2012 IBM Corp.
5  * Copyright (c) 2009 Alexander Graf <agraf@suse.de>
6  * Author(s): Cornelia Huck <cornelia.huck@de.ibm.com>
7  *
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.
11  */
12 
13 #include "qemu/osdep.h"
14 #include "qapi/error.h"
15 #include "qemu-common.h"
16 #include "cpu.h"
17 #include "hw/boards.h"
18 #include "exec/address-spaces.h"
19 #include "hw/s390x/s390-virtio-hcall.h"
20 #include "hw/s390x/sclp.h"
21 #include "hw/s390x/s390_flic.h"
22 #include "hw/s390x/ioinst.h"
23 #include "hw/s390x/css.h"
24 #include "virtio-ccw.h"
25 #include "qemu/config-file.h"
26 #include "qemu/error-report.h"
27 #include "s390-pci-bus.h"
28 #include "hw/s390x/storage-keys.h"
29 #include "hw/s390x/storage-attributes.h"
30 #include "hw/compat.h"
31 #include "ipl.h"
32 #include "hw/s390x/s390-virtio-ccw.h"
33 #include "hw/s390x/css-bridge.h"
34 #include "migration/register.h"
35 #include "cpu_models.h"
36 #include "qapi/qmp/qerror.h"
37 #include "hw/nmi.h"
38 
39 S390CPU *s390_cpu_addr2state(uint16_t cpu_addr)
40 {
41     static MachineState *ms;
42 
43     if (!ms) {
44         ms = MACHINE(qdev_get_machine());
45         g_assert(ms->possible_cpus);
46     }
47 
48     /* CPU address corresponds to the core_id and the index */
49     if (cpu_addr >= ms->possible_cpus->len) {
50         return NULL;
51     }
52     return S390_CPU(ms->possible_cpus->cpus[cpu_addr].cpu);
53 }
54 
55 static S390CPU *s390x_new_cpu(const char *typename, uint32_t core_id,
56                               Error **errp)
57 {
58     S390CPU *cpu = S390_CPU(object_new(typename));
59     Error *err = NULL;
60 
61     object_property_set_int(OBJECT(cpu), core_id, "core-id", &err);
62     if (err != NULL) {
63         goto out;
64     }
65     object_property_set_bool(OBJECT(cpu), true, "realized", &err);
66 
67 out:
68     object_unref(OBJECT(cpu));
69     if (err) {
70         error_propagate(errp, err);
71         cpu = NULL;
72     }
73     return cpu;
74 }
75 
76 static void s390_init_cpus(MachineState *machine)
77 {
78     MachineClass *mc = MACHINE_GET_CLASS(machine);
79     int i;
80 
81     if (tcg_enabled() && max_cpus > 1) {
82         error_report("WARNING: SMP support on s390x is experimental!");
83     }
84 
85     /* initialize possible_cpus */
86     mc->possible_cpu_arch_ids(machine);
87 
88     for (i = 0; i < smp_cpus; i++) {
89         s390x_new_cpu(machine->cpu_type, i, &error_fatal);
90     }
91 }
92 
93 static const char *const reset_dev_types[] = {
94     TYPE_VIRTUAL_CSS_BRIDGE,
95     "s390-sclp-event-facility",
96     "s390-flic",
97     "diag288",
98 };
99 
100 void subsystem_reset(void)
101 {
102     DeviceState *dev;
103     int i;
104 
105     for (i = 0; i < ARRAY_SIZE(reset_dev_types); i++) {
106         dev = DEVICE(object_resolve_path_type("", reset_dev_types[i], NULL));
107         if (dev) {
108             qdev_reset_all(dev);
109         }
110     }
111 }
112 
113 static int virtio_ccw_hcall_notify(const uint64_t *args)
114 {
115     uint64_t subch_id = args[0];
116     uint64_t queue = args[1];
117     SubchDev *sch;
118     int cssid, ssid, schid, m;
119 
120     if (ioinst_disassemble_sch_ident(subch_id, &m, &cssid, &ssid, &schid)) {
121         return -EINVAL;
122     }
123     sch = css_find_subch(m, cssid, ssid, schid);
124     if (!sch || !css_subch_visible(sch)) {
125         return -EINVAL;
126     }
127     if (queue >= VIRTIO_QUEUE_MAX) {
128         return -EINVAL;
129     }
130     virtio_queue_notify(virtio_ccw_get_vdev(sch), queue);
131     return 0;
132 
133 }
134 
135 static int virtio_ccw_hcall_early_printk(const uint64_t *args)
136 {
137     uint64_t mem = args[0];
138 
139     if (mem < ram_size) {
140         /* Early printk */
141         return 0;
142     }
143     return -EINVAL;
144 }
145 
146 static void virtio_ccw_register_hcalls(void)
147 {
148     s390_register_virtio_hypercall(KVM_S390_VIRTIO_CCW_NOTIFY,
149                                    virtio_ccw_hcall_notify);
150     /* Tolerate early printk. */
151     s390_register_virtio_hypercall(KVM_S390_VIRTIO_NOTIFY,
152                                    virtio_ccw_hcall_early_printk);
153 }
154 
155 static void s390_memory_init(ram_addr_t mem_size)
156 {
157     MemoryRegion *sysmem = get_system_memory();
158     MemoryRegion *ram = g_new(MemoryRegion, 1);
159 
160     /* allocate RAM for core */
161     memory_region_allocate_system_memory(ram, NULL, "s390.ram", mem_size);
162     memory_region_add_subregion(sysmem, 0, ram);
163 
164     /* Initialize storage key device */
165     s390_skeys_init();
166     /* Initialize storage attributes device */
167     s390_stattrib_init();
168 }
169 
170 #define S390_TOD_CLOCK_VALUE_MISSING    0x00
171 #define S390_TOD_CLOCK_VALUE_PRESENT    0x01
172 
173 static void gtod_save(QEMUFile *f, void *opaque)
174 {
175     uint64_t tod_low;
176     uint8_t tod_high;
177     int r;
178 
179     r = s390_get_clock(&tod_high, &tod_low);
180     if (r) {
181         warn_report("Unable to get guest clock for migration: %s",
182                     strerror(-r));
183         error_printf("Guest clock will not be migrated "
184                      "which could cause the guest to hang.");
185         qemu_put_byte(f, S390_TOD_CLOCK_VALUE_MISSING);
186         return;
187     }
188 
189     qemu_put_byte(f, S390_TOD_CLOCK_VALUE_PRESENT);
190     qemu_put_byte(f, tod_high);
191     qemu_put_be64(f, tod_low);
192 }
193 
194 static int gtod_load(QEMUFile *f, void *opaque, int version_id)
195 {
196     uint64_t tod_low;
197     uint8_t tod_high;
198     int r;
199 
200     if (qemu_get_byte(f) == S390_TOD_CLOCK_VALUE_MISSING) {
201         warn_report("Guest clock was not migrated. This could "
202                     "cause the guest to hang.");
203         return 0;
204     }
205 
206     tod_high = qemu_get_byte(f);
207     tod_low = qemu_get_be64(f);
208 
209     r = s390_set_clock(&tod_high, &tod_low);
210     if (r) {
211         error_report("Unable to set KVM guest TOD clock: %s", strerror(-r));
212     }
213 
214     return r;
215 }
216 
217 static SaveVMHandlers savevm_gtod = {
218     .save_state = gtod_save,
219     .load_state = gtod_load,
220 };
221 
222 static void s390_init_ipl_dev(const char *kernel_filename,
223                               const char *kernel_cmdline,
224                               const char *initrd_filename, const char *firmware,
225                               const char *netboot_fw, bool enforce_bios)
226 {
227     Object *new = object_new(TYPE_S390_IPL);
228     DeviceState *dev = DEVICE(new);
229 
230     if (kernel_filename) {
231         qdev_prop_set_string(dev, "kernel", kernel_filename);
232     }
233     if (initrd_filename) {
234         qdev_prop_set_string(dev, "initrd", initrd_filename);
235     }
236     qdev_prop_set_string(dev, "cmdline", kernel_cmdline);
237     qdev_prop_set_string(dev, "firmware", firmware);
238     qdev_prop_set_string(dev, "netboot_fw", netboot_fw);
239     qdev_prop_set_bit(dev, "enforce_bios", enforce_bios);
240     object_property_add_child(qdev_get_machine(), TYPE_S390_IPL,
241                               new, NULL);
242     object_unref(new);
243     qdev_init_nofail(dev);
244 }
245 
246 static void s390_create_virtio_net(BusState *bus, const char *name)
247 {
248     int i;
249 
250     for (i = 0; i < nb_nics; i++) {
251         NICInfo *nd = &nd_table[i];
252         DeviceState *dev;
253 
254         if (!nd->model) {
255             nd->model = g_strdup("virtio");
256         }
257 
258         qemu_check_nic_model(nd, "virtio");
259 
260         dev = qdev_create(bus, name);
261         qdev_set_nic_properties(dev, nd);
262         qdev_init_nofail(dev);
263     }
264 }
265 
266 static void ccw_init(MachineState *machine)
267 {
268     int ret;
269     VirtualCssBus *css_bus;
270     DeviceState *dev;
271 
272     s390_sclp_init();
273     s390_memory_init(machine->ram_size);
274 
275     /* init CPUs (incl. CPU model) early so s390_has_feature() works */
276     s390_init_cpus(machine);
277 
278     s390_flic_init();
279 
280     /* init the SIGP facility */
281     s390_init_sigp();
282 
283     /* get a BUS */
284     css_bus = virtual_css_bus_init();
285     s390_init_ipl_dev(machine->kernel_filename, machine->kernel_cmdline,
286                       machine->initrd_filename, "s390-ccw.img",
287                       "s390-netboot.img", true);
288 
289     /*
290      * We cannot easily make the pci host bridge conditional as older QEMUs
291      * always created it. Doing so would break migration across QEMU versions.
292      */
293     dev = qdev_create(NULL, TYPE_S390_PCI_HOST_BRIDGE);
294     object_property_add_child(qdev_get_machine(), TYPE_S390_PCI_HOST_BRIDGE,
295                               OBJECT(dev), NULL);
296     qdev_init_nofail(dev);
297 
298     /* register hypercalls */
299     virtio_ccw_register_hcalls();
300 
301     s390_enable_css_support(s390_cpu_addr2state(0));
302     /*
303      * Non mcss-e enabled guests only see the devices from the default
304      * css, which is determined by the value of the squash_mcss property.
305      * Note: we must not squash non virtual devices to css 0xFE.
306      */
307     if (css_bus->squash_mcss) {
308         ret = css_create_css_image(0, true);
309     } else {
310         ret = css_create_css_image(VIRTUAL_CSSID, true);
311     }
312     assert(ret == 0);
313     if (css_migration_enabled()) {
314         css_register_vmstate();
315     }
316 
317     /* Create VirtIO network adapters */
318     s390_create_virtio_net(BUS(css_bus), "virtio-net-ccw");
319 
320     /* Register savevm handler for guest TOD clock */
321     register_savevm_live(NULL, "todclock", 0, 1, &savevm_gtod, NULL);
322 }
323 
324 static void s390_cpu_plug(HotplugHandler *hotplug_dev,
325                         DeviceState *dev, Error **errp)
326 {
327     MachineState *ms = MACHINE(hotplug_dev);
328     S390CPU *cpu = S390_CPU(dev);
329 
330     g_assert(!ms->possible_cpus->cpus[cpu->env.core_id].cpu);
331     ms->possible_cpus->cpus[cpu->env.core_id].cpu = OBJECT(dev);
332 
333     if (dev->hotplugged) {
334         raise_irq_cpu_hotplug();
335     }
336 }
337 
338 static void s390_machine_reset(void)
339 {
340     S390CPU *ipl_cpu = S390_CPU(qemu_get_cpu(0));
341 
342     s390_cmma_reset();
343     qemu_devices_reset();
344     s390_crypto_reset();
345 
346     /* all cpus are stopped - configure and start the ipl cpu only */
347     s390_ipl_prepare_cpu(ipl_cpu);
348     s390_cpu_set_state(CPU_STATE_OPERATING, ipl_cpu);
349 }
350 
351 static void s390_machine_device_plug(HotplugHandler *hotplug_dev,
352                                      DeviceState *dev, Error **errp)
353 {
354     if (object_dynamic_cast(OBJECT(dev), TYPE_CPU)) {
355         s390_cpu_plug(hotplug_dev, dev, errp);
356     }
357 }
358 
359 static void s390_machine_device_unplug_request(HotplugHandler *hotplug_dev,
360                                                DeviceState *dev, Error **errp)
361 {
362     if (object_dynamic_cast(OBJECT(dev), TYPE_CPU)) {
363         error_setg(errp, "CPU hot unplug not supported on this machine");
364         return;
365     }
366 }
367 
368 static CpuInstanceProperties s390_cpu_index_to_props(MachineState *machine,
369                                                      unsigned cpu_index)
370 {
371     g_assert(machine->possible_cpus && cpu_index < machine->possible_cpus->len);
372 
373     return machine->possible_cpus->cpus[cpu_index].props;
374 }
375 
376 static const CPUArchIdList *s390_possible_cpu_arch_ids(MachineState *ms)
377 {
378     int i;
379 
380     if (ms->possible_cpus) {
381         g_assert(ms->possible_cpus && ms->possible_cpus->len == max_cpus);
382         return ms->possible_cpus;
383     }
384 
385     ms->possible_cpus = g_malloc0(sizeof(CPUArchIdList) +
386                                   sizeof(CPUArchId) * max_cpus);
387     ms->possible_cpus->len = max_cpus;
388     for (i = 0; i < ms->possible_cpus->len; i++) {
389         ms->possible_cpus->cpus[i].vcpus_count = 1;
390         ms->possible_cpus->cpus[i].arch_id = i;
391         ms->possible_cpus->cpus[i].props.has_core_id = true;
392         ms->possible_cpus->cpus[i].props.core_id = i;
393     }
394 
395     return ms->possible_cpus;
396 }
397 
398 static HotplugHandler *s390_get_hotplug_handler(MachineState *machine,
399                                                 DeviceState *dev)
400 {
401     if (object_dynamic_cast(OBJECT(dev), TYPE_CPU)) {
402         return HOTPLUG_HANDLER(machine);
403     }
404     return NULL;
405 }
406 
407 static void s390_hot_add_cpu(const int64_t id, Error **errp)
408 {
409     MachineState *machine = MACHINE(qdev_get_machine());
410     ObjectClass *oc;
411 
412     g_assert(machine->possible_cpus->cpus[0].cpu);
413     oc = OBJECT_CLASS(CPU_GET_CLASS(machine->possible_cpus->cpus[0].cpu));
414 
415     s390x_new_cpu(object_class_get_name(oc), id, errp);
416 }
417 
418 static void s390_nmi(NMIState *n, int cpu_index, Error **errp)
419 {
420     CPUState *cs = qemu_get_cpu(cpu_index);
421 
422     s390_cpu_restart(S390_CPU(cs));
423 }
424 
425 static void ccw_machine_class_init(ObjectClass *oc, void *data)
426 {
427     MachineClass *mc = MACHINE_CLASS(oc);
428     NMIClass *nc = NMI_CLASS(oc);
429     HotplugHandlerClass *hc = HOTPLUG_HANDLER_CLASS(oc);
430     S390CcwMachineClass *s390mc = S390_MACHINE_CLASS(mc);
431 
432     s390mc->ri_allowed = true;
433     s390mc->cpu_model_allowed = true;
434     s390mc->css_migration_enabled = true;
435     mc->init = ccw_init;
436     mc->reset = s390_machine_reset;
437     mc->hot_add_cpu = s390_hot_add_cpu;
438     mc->block_default_type = IF_VIRTIO;
439     mc->no_cdrom = 1;
440     mc->no_floppy = 1;
441     mc->no_serial = 1;
442     mc->no_parallel = 1;
443     mc->no_sdcard = 1;
444     mc->use_sclp = 1;
445     mc->max_cpus = S390_MAX_CPUS;
446     mc->has_hotpluggable_cpus = true;
447     mc->get_hotplug_handler = s390_get_hotplug_handler;
448     mc->cpu_index_to_instance_props = s390_cpu_index_to_props;
449     mc->possible_cpu_arch_ids = s390_possible_cpu_arch_ids;
450     /* it is overridden with 'host' cpu *in kvm_arch_init* */
451     mc->default_cpu_type = S390_CPU_TYPE_NAME("qemu");
452     hc->plug = s390_machine_device_plug;
453     hc->unplug_request = s390_machine_device_unplug_request;
454     nc->nmi_monitor_handler = s390_nmi;
455 }
456 
457 static inline bool machine_get_aes_key_wrap(Object *obj, Error **errp)
458 {
459     S390CcwMachineState *ms = S390_CCW_MACHINE(obj);
460 
461     return ms->aes_key_wrap;
462 }
463 
464 static inline void machine_set_aes_key_wrap(Object *obj, bool value,
465                                             Error **errp)
466 {
467     S390CcwMachineState *ms = S390_CCW_MACHINE(obj);
468 
469     ms->aes_key_wrap = value;
470 }
471 
472 static inline bool machine_get_dea_key_wrap(Object *obj, Error **errp)
473 {
474     S390CcwMachineState *ms = S390_CCW_MACHINE(obj);
475 
476     return ms->dea_key_wrap;
477 }
478 
479 static inline void machine_set_dea_key_wrap(Object *obj, bool value,
480                                             Error **errp)
481 {
482     S390CcwMachineState *ms = S390_CCW_MACHINE(obj);
483 
484     ms->dea_key_wrap = value;
485 }
486 
487 static S390CcwMachineClass *current_mc;
488 
489 static S390CcwMachineClass *get_machine_class(void)
490 {
491     if (unlikely(!current_mc)) {
492         /*
493         * No s390 ccw machine was instantiated, we are likely to
494         * be called for the 'none' machine. The properties will
495         * have their after-initialization values.
496         */
497         current_mc = S390_MACHINE_CLASS(
498                      object_class_by_name(TYPE_S390_CCW_MACHINE));
499     }
500     return current_mc;
501 }
502 
503 bool ri_allowed(void)
504 {
505     /* for "none" machine this results in true */
506     return get_machine_class()->ri_allowed;
507 }
508 
509 bool cpu_model_allowed(void)
510 {
511     /* for "none" machine this results in true */
512     return get_machine_class()->cpu_model_allowed;
513 }
514 
515 static char *machine_get_loadparm(Object *obj, Error **errp)
516 {
517     S390CcwMachineState *ms = S390_CCW_MACHINE(obj);
518 
519     return g_memdup(ms->loadparm, sizeof(ms->loadparm));
520 }
521 
522 static void machine_set_loadparm(Object *obj, const char *val, Error **errp)
523 {
524     S390CcwMachineState *ms = S390_CCW_MACHINE(obj);
525     int i;
526 
527     for (i = 0; i < sizeof(ms->loadparm) && val[i]; i++) {
528         uint8_t c = qemu_toupper(val[i]); /* mimic HMC */
529 
530         if (('A' <= c && c <= 'Z') || ('0' <= c && c <= '9') || (c == '.') ||
531             (c == ' ')) {
532             ms->loadparm[i] = c;
533         } else {
534             error_setg(errp, "LOADPARM: invalid character '%c' (ASCII 0x%02x)",
535                        c, c);
536             return;
537         }
538     }
539 
540     for (; i < sizeof(ms->loadparm); i++) {
541         ms->loadparm[i] = ' '; /* pad right with spaces */
542     }
543 }
544 static inline bool machine_get_squash_mcss(Object *obj, Error **errp)
545 {
546     S390CcwMachineState *ms = S390_CCW_MACHINE(obj);
547 
548     return ms->s390_squash_mcss;
549 }
550 
551 static inline void machine_set_squash_mcss(Object *obj, bool value,
552                                            Error **errp)
553 {
554     S390CcwMachineState *ms = S390_CCW_MACHINE(obj);
555 
556     ms->s390_squash_mcss = value;
557 }
558 
559 static inline void s390_machine_initfn(Object *obj)
560 {
561     object_property_add_bool(obj, "aes-key-wrap",
562                              machine_get_aes_key_wrap,
563                              machine_set_aes_key_wrap, NULL);
564     object_property_set_description(obj, "aes-key-wrap",
565             "enable/disable AES key wrapping using the CPACF wrapping key",
566             NULL);
567     object_property_set_bool(obj, true, "aes-key-wrap", NULL);
568 
569     object_property_add_bool(obj, "dea-key-wrap",
570                              machine_get_dea_key_wrap,
571                              machine_set_dea_key_wrap, NULL);
572     object_property_set_description(obj, "dea-key-wrap",
573             "enable/disable DEA key wrapping using the CPACF wrapping key",
574             NULL);
575     object_property_set_bool(obj, true, "dea-key-wrap", NULL);
576     object_property_add_str(obj, "loadparm",
577             machine_get_loadparm, machine_set_loadparm, NULL);
578     object_property_set_description(obj, "loadparm",
579             "Up to 8 chars in set of [A-Za-z0-9. ] (lower case chars converted"
580             " to upper case) to pass to machine loader, boot manager,"
581             " and guest kernel",
582             NULL);
583     object_property_add_bool(obj, "s390-squash-mcss",
584                              machine_get_squash_mcss,
585                              machine_set_squash_mcss, NULL);
586     object_property_set_description(obj, "s390-squash-mcss",
587             "enable/disable squashing subchannels into the default css",
588             NULL);
589     object_property_set_bool(obj, false, "s390-squash-mcss", NULL);
590 }
591 
592 static const TypeInfo ccw_machine_info = {
593     .name          = TYPE_S390_CCW_MACHINE,
594     .parent        = TYPE_MACHINE,
595     .abstract      = true,
596     .instance_size = sizeof(S390CcwMachineState),
597     .instance_init = s390_machine_initfn,
598     .class_size = sizeof(S390CcwMachineClass),
599     .class_init    = ccw_machine_class_init,
600     .interfaces = (InterfaceInfo[]) {
601         { TYPE_NMI },
602         { TYPE_HOTPLUG_HANDLER},
603         { }
604     },
605 };
606 
607 bool css_migration_enabled(void)
608 {
609     return get_machine_class()->css_migration_enabled;
610 }
611 
612 #define DEFINE_CCW_MACHINE(suffix, verstr, latest)                            \
613     static void ccw_machine_##suffix##_class_init(ObjectClass *oc,            \
614                                                   void *data)                 \
615     {                                                                         \
616         MachineClass *mc = MACHINE_CLASS(oc);                                 \
617         ccw_machine_##suffix##_class_options(mc);                             \
618         mc->desc = "VirtIO-ccw based S390 machine v" verstr;                  \
619         if (latest) {                                                         \
620             mc->alias = "s390-ccw-virtio";                                    \
621             mc->is_default = 1;                                               \
622         }                                                                     \
623     }                                                                         \
624     static void ccw_machine_##suffix##_instance_init(Object *obj)             \
625     {                                                                         \
626         MachineState *machine = MACHINE(obj);                                 \
627         current_mc = S390_MACHINE_CLASS(MACHINE_GET_CLASS(machine));          \
628         ccw_machine_##suffix##_instance_options(machine);                     \
629     }                                                                         \
630     static const TypeInfo ccw_machine_##suffix##_info = {                     \
631         .name = MACHINE_TYPE_NAME("s390-ccw-virtio-" verstr),                 \
632         .parent = TYPE_S390_CCW_MACHINE,                                      \
633         .class_init = ccw_machine_##suffix##_class_init,                      \
634         .instance_init = ccw_machine_##suffix##_instance_init,                \
635     };                                                                        \
636     static void ccw_machine_register_##suffix(void)                           \
637     {                                                                         \
638         type_register_static(&ccw_machine_##suffix##_info);                   \
639     }                                                                         \
640     type_init(ccw_machine_register_##suffix)
641 
642 #define CCW_COMPAT_2_10 \
643         HW_COMPAT_2_10
644 
645 #define CCW_COMPAT_2_9 \
646         HW_COMPAT_2_9 \
647         {\
648             .driver   = TYPE_S390_STATTRIB,\
649             .property = "migration-enabled",\
650             .value    = "off",\
651         },
652 
653 #define CCW_COMPAT_2_8 \
654         HW_COMPAT_2_8 \
655         {\
656             .driver   = TYPE_S390_FLIC_COMMON,\
657             .property = "adapter_routes_max_batch",\
658             .value    = "64",\
659         },
660 
661 #define CCW_COMPAT_2_7 \
662         HW_COMPAT_2_7
663 
664 #define CCW_COMPAT_2_6 \
665         HW_COMPAT_2_6 \
666         {\
667             .driver   = TYPE_S390_IPL,\
668             .property = "iplbext_migration",\
669             .value    = "off",\
670         }, {\
671             .driver   = TYPE_VIRTUAL_CSS_BRIDGE,\
672             .property = "css_dev_path",\
673             .value    = "off",\
674         },
675 
676 #define CCW_COMPAT_2_5 \
677         HW_COMPAT_2_5
678 
679 #define CCW_COMPAT_2_4 \
680         HW_COMPAT_2_4 \
681         {\
682             .driver   = TYPE_S390_SKEYS,\
683             .property = "migration-enabled",\
684             .value    = "off",\
685         },{\
686             .driver   = "virtio-blk-ccw",\
687             .property = "max_revision",\
688             .value    = "0",\
689         },{\
690             .driver   = "virtio-balloon-ccw",\
691             .property = "max_revision",\
692             .value    = "0",\
693         },{\
694             .driver   = "virtio-serial-ccw",\
695             .property = "max_revision",\
696             .value    = "0",\
697         },{\
698             .driver   = "virtio-9p-ccw",\
699             .property = "max_revision",\
700             .value    = "0",\
701         },{\
702             .driver   = "virtio-rng-ccw",\
703             .property = "max_revision",\
704             .value    = "0",\
705         },{\
706             .driver   = "virtio-net-ccw",\
707             .property = "max_revision",\
708             .value    = "0",\
709         },{\
710             .driver   = "virtio-scsi-ccw",\
711             .property = "max_revision",\
712             .value    = "0",\
713         },{\
714             .driver   = "vhost-scsi-ccw",\
715             .property = "max_revision",\
716             .value    = "0",\
717         },
718 
719 static void ccw_machine_2_11_instance_options(MachineState *machine)
720 {
721 }
722 
723 static void ccw_machine_2_11_class_options(MachineClass *mc)
724 {
725 }
726 DEFINE_CCW_MACHINE(2_11, "2.11", true);
727 
728 static void ccw_machine_2_10_instance_options(MachineState *machine)
729 {
730     ccw_machine_2_11_instance_options(machine);
731 }
732 
733 static void ccw_machine_2_10_class_options(MachineClass *mc)
734 {
735     ccw_machine_2_11_class_options(mc);
736     SET_MACHINE_COMPAT(mc, CCW_COMPAT_2_10);
737 }
738 DEFINE_CCW_MACHINE(2_10, "2.10", false);
739 
740 static void ccw_machine_2_9_instance_options(MachineState *machine)
741 {
742     ccw_machine_2_10_instance_options(machine);
743     s390_cpudef_featoff_greater(12, 1, S390_FEAT_ESOP);
744     s390_cpudef_featoff_greater(12, 1, S390_FEAT_SIDE_EFFECT_ACCESS_ESOP2);
745     s390_cpudef_featoff_greater(12, 1, S390_FEAT_ZPCI);
746     s390_cpudef_featoff_greater(12, 1, S390_FEAT_ADAPTER_INT_SUPPRESSION);
747     s390_cpudef_featoff_greater(12, 1, S390_FEAT_ADAPTER_EVENT_NOTIFICATION);
748 }
749 
750 static void ccw_machine_2_9_class_options(MachineClass *mc)
751 {
752     S390CcwMachineClass *s390mc = S390_MACHINE_CLASS(mc);
753 
754     ccw_machine_2_10_class_options(mc);
755     SET_MACHINE_COMPAT(mc, CCW_COMPAT_2_9);
756     s390mc->css_migration_enabled = false;
757 }
758 DEFINE_CCW_MACHINE(2_9, "2.9", false);
759 
760 static void ccw_machine_2_8_instance_options(MachineState *machine)
761 {
762     ccw_machine_2_9_instance_options(machine);
763 }
764 
765 static void ccw_machine_2_8_class_options(MachineClass *mc)
766 {
767     ccw_machine_2_9_class_options(mc);
768     SET_MACHINE_COMPAT(mc, CCW_COMPAT_2_8);
769 }
770 DEFINE_CCW_MACHINE(2_8, "2.8", false);
771 
772 static void ccw_machine_2_7_instance_options(MachineState *machine)
773 {
774     ccw_machine_2_8_instance_options(machine);
775 }
776 
777 static void ccw_machine_2_7_class_options(MachineClass *mc)
778 {
779     S390CcwMachineClass *s390mc = S390_MACHINE_CLASS(mc);
780 
781     s390mc->cpu_model_allowed = false;
782     ccw_machine_2_8_class_options(mc);
783     SET_MACHINE_COMPAT(mc, CCW_COMPAT_2_7);
784 }
785 DEFINE_CCW_MACHINE(2_7, "2.7", false);
786 
787 static void ccw_machine_2_6_instance_options(MachineState *machine)
788 {
789     ccw_machine_2_7_instance_options(machine);
790 }
791 
792 static void ccw_machine_2_6_class_options(MachineClass *mc)
793 {
794     S390CcwMachineClass *s390mc = S390_MACHINE_CLASS(mc);
795 
796     s390mc->ri_allowed = false;
797     ccw_machine_2_7_class_options(mc);
798     SET_MACHINE_COMPAT(mc, CCW_COMPAT_2_6);
799 }
800 DEFINE_CCW_MACHINE(2_6, "2.6", false);
801 
802 static void ccw_machine_2_5_instance_options(MachineState *machine)
803 {
804     ccw_machine_2_6_instance_options(machine);
805 }
806 
807 static void ccw_machine_2_5_class_options(MachineClass *mc)
808 {
809     ccw_machine_2_6_class_options(mc);
810     SET_MACHINE_COMPAT(mc, CCW_COMPAT_2_5);
811 }
812 DEFINE_CCW_MACHINE(2_5, "2.5", false);
813 
814 static void ccw_machine_2_4_instance_options(MachineState *machine)
815 {
816     ccw_machine_2_5_instance_options(machine);
817 }
818 
819 static void ccw_machine_2_4_class_options(MachineClass *mc)
820 {
821     ccw_machine_2_5_class_options(mc);
822     SET_MACHINE_COMPAT(mc, CCW_COMPAT_2_4);
823 }
824 DEFINE_CCW_MACHINE(2_4, "2.4", false);
825 
826 static void ccw_machine_register_types(void)
827 {
828     type_register_static(&ccw_machine_info);
829 }
830 
831 type_init(ccw_machine_register_types)
832