xref: /openbmc/qemu/hw/s390x/s390-virtio-ccw.c (revision e9206163)
1 /*
2  * virtio ccw machine
3  *
4  * Copyright 2012, 2020 IBM Corp.
5  * Copyright (c) 2009 Alexander Graf <agraf@suse.de>
6  * Author(s): Cornelia Huck <cornelia.huck@de.ibm.com>
7  *            Janosch Frank <frankja@linux.ibm.com>
8  *
9  * This work is licensed under the terms of the GNU GPL, version 2 or (at
10  * your option) any later version. See the COPYING file in the top-level
11  * directory.
12  */
13 
14 #include "qemu/osdep.h"
15 #include "qapi/error.h"
16 #include "exec/ram_addr.h"
17 #include "hw/s390x/s390-virtio-hcall.h"
18 #include "hw/s390x/sclp.h"
19 #include "hw/s390x/s390_flic.h"
20 #include "hw/s390x/ioinst.h"
21 #include "hw/s390x/css.h"
22 #include "virtio-ccw.h"
23 #include "qemu/config-file.h"
24 #include "qemu/ctype.h"
25 #include "qemu/error-report.h"
26 #include "qemu/option.h"
27 #include "qemu/qemu-print.h"
28 #include "qemu/units.h"
29 #include "hw/s390x/s390-pci-bus.h"
30 #include "sysemu/reset.h"
31 #include "hw/s390x/storage-keys.h"
32 #include "hw/s390x/storage-attributes.h"
33 #include "hw/s390x/event-facility.h"
34 #include "ipl.h"
35 #include "hw/s390x/s390-virtio-ccw.h"
36 #include "hw/s390x/css-bridge.h"
37 #include "hw/s390x/ap-bridge.h"
38 #include "migration/register.h"
39 #include "cpu_models.h"
40 #include "hw/nmi.h"
41 #include "hw/qdev-properties.h"
42 #include "hw/s390x/tod.h"
43 #include "sysemu/sysemu.h"
44 #include "sysemu/cpus.h"
45 #include "target/s390x/kvm/pv.h"
46 #include "migration/blocker.h"
47 #include "qapi/visitor.h"
48 #include "hw/s390x/cpu-topology.h"
49 
50 static Error *pv_mig_blocker;
51 
52 S390CPU *s390_cpu_addr2state(uint16_t cpu_addr)
53 {
54     static MachineState *ms;
55 
56     if (!ms) {
57         ms = MACHINE(qdev_get_machine());
58         g_assert(ms->possible_cpus);
59     }
60 
61     /* CPU address corresponds to the core_id and the index */
62     if (cpu_addr >= ms->possible_cpus->len) {
63         return NULL;
64     }
65     return S390_CPU(ms->possible_cpus->cpus[cpu_addr].cpu);
66 }
67 
68 static S390CPU *s390x_new_cpu(const char *typename, uint32_t core_id,
69                               Error **errp)
70 {
71     S390CPU *cpu = S390_CPU(object_new(typename));
72     S390CPU *ret = NULL;
73 
74     if (!object_property_set_int(OBJECT(cpu), "core-id", core_id, errp)) {
75         goto out;
76     }
77     if (!qdev_realize(DEVICE(cpu), NULL, errp)) {
78         goto out;
79     }
80     ret = cpu;
81 
82 out:
83     object_unref(OBJECT(cpu));
84     return ret;
85 }
86 
87 static void s390_init_cpus(MachineState *machine)
88 {
89     MachineClass *mc = MACHINE_GET_CLASS(machine);
90     S390CcwMachineClass *s390mc = S390_CCW_MACHINE_CLASS(mc);
91     int i;
92 
93     if (machine->smp.threads > s390mc->max_threads) {
94         error_report("S390 does not support more than %d threads.",
95                      s390mc->max_threads);
96         exit(1);
97     }
98 
99     /* initialize possible_cpus */
100     mc->possible_cpu_arch_ids(machine);
101 
102     for (i = 0; i < machine->smp.cpus; i++) {
103         s390x_new_cpu(machine->cpu_type, i, &error_fatal);
104     }
105 }
106 
107 static const char *const reset_dev_types[] = {
108     TYPE_VIRTUAL_CSS_BRIDGE,
109     "s390-sclp-event-facility",
110     "s390-flic",
111     "diag288",
112     TYPE_S390_PCI_HOST_BRIDGE,
113     TYPE_AP_BRIDGE,
114 };
115 
116 static void subsystem_reset(void)
117 {
118     DeviceState *dev;
119     int i;
120 
121     /*
122      * ISM firmware is sensitive to unexpected changes to the IOMMU, which can
123      * occur during reset of the vfio-pci device (unmap of entire aperture).
124      * Ensure any passthrough ISM devices are reset now, while CPUs are paused
125      * but before vfio-pci cleanup occurs.
126      */
127     s390_pci_ism_reset();
128 
129     for (i = 0; i < ARRAY_SIZE(reset_dev_types); i++) {
130         dev = DEVICE(object_resolve_path_type("", reset_dev_types[i], NULL));
131         if (dev) {
132             device_cold_reset(dev);
133         }
134     }
135     if (s390_has_topology()) {
136         s390_topology_reset();
137     }
138 }
139 
140 static int virtio_ccw_hcall_notify(const uint64_t *args)
141 {
142     uint64_t subch_id = args[0];
143     uint64_t queue = args[1];
144     SubchDev *sch;
145     int cssid, ssid, schid, m;
146 
147     if (ioinst_disassemble_sch_ident(subch_id, &m, &cssid, &ssid, &schid)) {
148         return -EINVAL;
149     }
150     sch = css_find_subch(m, cssid, ssid, schid);
151     if (!sch || !css_subch_visible(sch)) {
152         return -EINVAL;
153     }
154     if (queue >= VIRTIO_QUEUE_MAX) {
155         return -EINVAL;
156     }
157     virtio_queue_notify(virtio_ccw_get_vdev(sch), queue);
158     return 0;
159 
160 }
161 
162 static int virtio_ccw_hcall_early_printk(const uint64_t *args)
163 {
164     uint64_t mem = args[0];
165     MachineState *ms = MACHINE(qdev_get_machine());
166 
167     if (mem < ms->ram_size) {
168         /* Early printk */
169         return 0;
170     }
171     return -EINVAL;
172 }
173 
174 static void virtio_ccw_register_hcalls(void)
175 {
176     s390_register_virtio_hypercall(KVM_S390_VIRTIO_CCW_NOTIFY,
177                                    virtio_ccw_hcall_notify);
178     /* Tolerate early printk. */
179     s390_register_virtio_hypercall(KVM_S390_VIRTIO_NOTIFY,
180                                    virtio_ccw_hcall_early_printk);
181 }
182 
183 static void s390_memory_init(MemoryRegion *ram)
184 {
185     MemoryRegion *sysmem = get_system_memory();
186 
187     /* allocate RAM for core */
188     memory_region_add_subregion(sysmem, 0, ram);
189 
190     /*
191      * Configure the maximum page size. As no memory devices were created
192      * yet, this is the page size of initial memory only.
193      */
194     s390_set_max_pagesize(qemu_maxrampagesize(), &error_fatal);
195     /* Initialize storage key device */
196     s390_skeys_init();
197     /* Initialize storage attributes device */
198     s390_stattrib_init();
199 }
200 
201 static void s390_init_ipl_dev(const char *kernel_filename,
202                               const char *kernel_cmdline,
203                               const char *initrd_filename, const char *firmware,
204                               const char *netboot_fw, bool enforce_bios)
205 {
206     Object *new = object_new(TYPE_S390_IPL);
207     DeviceState *dev = DEVICE(new);
208     char *netboot_fw_prop;
209 
210     if (kernel_filename) {
211         qdev_prop_set_string(dev, "kernel", kernel_filename);
212     }
213     if (initrd_filename) {
214         qdev_prop_set_string(dev, "initrd", initrd_filename);
215     }
216     qdev_prop_set_string(dev, "cmdline", kernel_cmdline);
217     qdev_prop_set_string(dev, "firmware", firmware);
218     qdev_prop_set_bit(dev, "enforce_bios", enforce_bios);
219     netboot_fw_prop = object_property_get_str(new, "netboot_fw", &error_abort);
220     if (!strlen(netboot_fw_prop)) {
221         qdev_prop_set_string(dev, "netboot_fw", netboot_fw);
222     }
223     g_free(netboot_fw_prop);
224     object_property_add_child(qdev_get_machine(), TYPE_S390_IPL,
225                               new);
226     object_unref(new);
227     qdev_realize(dev, NULL, &error_fatal);
228 }
229 
230 static void s390_create_virtio_net(BusState *bus, const char *name)
231 {
232     DeviceState *dev;
233 
234     while ((dev = qemu_create_nic_device(name, true, "virtio"))) {
235         qdev_realize_and_unref(dev, bus, &error_fatal);
236     }
237 }
238 
239 static void s390_create_sclpconsole(const char *type, Chardev *chardev)
240 {
241     DeviceState *dev;
242 
243     dev = qdev_new(type);
244     qdev_prop_set_chr(dev, "chardev", chardev);
245     qdev_realize_and_unref(dev, sclp_get_event_facility_bus(), &error_fatal);
246 }
247 
248 static void ccw_init(MachineState *machine)
249 {
250     MachineClass *mc = MACHINE_GET_CLASS(machine);
251     int ret;
252     VirtualCssBus *css_bus;
253     DeviceState *dev;
254 
255     s390_sclp_init();
256     /* init memory + setup max page size. Required for the CPU model */
257     s390_memory_init(machine->ram);
258 
259     /* init CPUs (incl. CPU model) early so s390_has_feature() works */
260     s390_init_cpus(machine);
261 
262     /* Need CPU model to be determined before we can set up PV */
263     s390_pv_init(machine->cgs, &error_fatal);
264 
265     s390_flic_init();
266 
267     /* init the SIGP facility */
268     s390_init_sigp();
269 
270     /* create AP bridge and bus(es) */
271     s390_init_ap();
272 
273     /* get a BUS */
274     css_bus = virtual_css_bus_init();
275     s390_init_ipl_dev(machine->kernel_filename, machine->kernel_cmdline,
276                       machine->initrd_filename,
277                       machine->firmware ?: "s390-ccw.img",
278                       "s390-netboot.img", true);
279 
280     dev = qdev_new(TYPE_S390_PCI_HOST_BRIDGE);
281     object_property_add_child(qdev_get_machine(), TYPE_S390_PCI_HOST_BRIDGE,
282                               OBJECT(dev));
283     sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
284 
285     /* register hypercalls */
286     virtio_ccw_register_hcalls();
287 
288     s390_enable_css_support(s390_cpu_addr2state(0));
289 
290     ret = css_create_css_image(VIRTUAL_CSSID, true);
291 
292     assert(ret == 0);
293     if (css_migration_enabled()) {
294         css_register_vmstate();
295     }
296 
297     /* Create VirtIO network adapters */
298     s390_create_virtio_net(BUS(css_bus), mc->default_nic);
299 
300     /* init consoles */
301     if (serial_hd(0)) {
302         s390_create_sclpconsole("sclpconsole", serial_hd(0));
303     }
304     if (serial_hd(1)) {
305         s390_create_sclpconsole("sclplmconsole", serial_hd(1));
306     }
307 
308     /* init the TOD clock */
309     s390_init_tod();
310 }
311 
312 static void s390_cpu_plug(HotplugHandler *hotplug_dev,
313                         DeviceState *dev, Error **errp)
314 {
315     MachineState *ms = MACHINE(hotplug_dev);
316     S390CPU *cpu = S390_CPU(dev);
317     ERRP_GUARD();
318 
319     g_assert(!ms->possible_cpus->cpus[cpu->env.core_id].cpu);
320     ms->possible_cpus->cpus[cpu->env.core_id].cpu = OBJECT(dev);
321 
322     if (s390_has_topology()) {
323         s390_topology_setup_cpu(ms, cpu, errp);
324         if (*errp) {
325             return;
326         }
327     }
328 
329     if (dev->hotplugged) {
330         raise_irq_cpu_hotplug();
331     }
332 }
333 
334 static inline void s390_do_cpu_ipl(CPUState *cs, run_on_cpu_data arg)
335 {
336     S390CPU *cpu = S390_CPU(cs);
337 
338     s390_ipl_prepare_cpu(cpu);
339     s390_cpu_set_state(S390_CPU_STATE_OPERATING, cpu);
340 }
341 
342 static void s390_machine_unprotect(S390CcwMachineState *ms)
343 {
344     if (!s390_pv_vm_try_disable_async(ms)) {
345         s390_pv_vm_disable();
346     }
347     ms->pv = false;
348     migrate_del_blocker(&pv_mig_blocker);
349     ram_block_discard_disable(false);
350 }
351 
352 static int s390_machine_protect(S390CcwMachineState *ms)
353 {
354     Error *local_err = NULL;
355     int rc;
356 
357    /*
358     * Discarding of memory in RAM blocks does not work as expected with
359     * protected VMs. Sharing and unsharing pages would be required. Disable
360     * it for now, until until we have a solution to make at least Linux
361     * guests either support it (e.g., virtio-balloon) or fail gracefully.
362     */
363     rc = ram_block_discard_disable(true);
364     if (rc) {
365         error_report("protected VMs: cannot disable RAM discard");
366         return rc;
367     }
368 
369     error_setg(&pv_mig_blocker,
370                "protected VMs are currently not migratable.");
371     rc = migrate_add_blocker(&pv_mig_blocker, &local_err);
372     if (rc) {
373         ram_block_discard_disable(false);
374         error_report_err(local_err);
375         return rc;
376     }
377 
378     /* Create SE VM */
379     rc = s390_pv_vm_enable();
380     if (rc) {
381         ram_block_discard_disable(false);
382         migrate_del_blocker(&pv_mig_blocker);
383         return rc;
384     }
385 
386     ms->pv = true;
387 
388     /* Will return 0 if API is not available since it's not vital */
389     rc = s390_pv_query_info();
390     if (rc) {
391         goto out_err;
392     }
393 
394     /* Set SE header and unpack */
395     rc = s390_ipl_prepare_pv_header(&local_err);
396     if (rc) {
397         goto out_err;
398     }
399 
400     /* Decrypt image */
401     rc = s390_ipl_pv_unpack();
402     if (rc) {
403         goto out_err;
404     }
405 
406     /* Verify integrity */
407     rc = s390_pv_verify();
408     if (rc) {
409         goto out_err;
410     }
411     return rc;
412 
413 out_err:
414     if (local_err) {
415         error_report_err(local_err);
416     }
417     s390_machine_unprotect(ms);
418     return rc;
419 }
420 
421 static void s390_pv_prepare_reset(S390CcwMachineState *ms)
422 {
423     CPUState *cs;
424 
425     if (!s390_is_pv()) {
426         return;
427     }
428     /* Unsharing requires all cpus to be stopped */
429     CPU_FOREACH(cs) {
430         s390_cpu_set_state(S390_CPU_STATE_STOPPED, S390_CPU(cs));
431     }
432     s390_pv_unshare();
433     s390_pv_prep_reset();
434 }
435 
436 static void s390_machine_reset(MachineState *machine, ShutdownCause reason)
437 {
438     S390CcwMachineState *ms = S390_CCW_MACHINE(machine);
439     enum s390_reset reset_type;
440     CPUState *cs, *t;
441     S390CPU *cpu;
442 
443     /* get the reset parameters, reset them once done */
444     s390_ipl_get_reset_request(&cs, &reset_type);
445 
446     /* all CPUs are paused and synchronized at this point */
447     s390_cmma_reset();
448 
449     cpu = S390_CPU(cs);
450 
451     switch (reset_type) {
452     case S390_RESET_EXTERNAL:
453     case S390_RESET_REIPL:
454         /*
455          * Reset the subsystem which includes a AP reset. If a PV
456          * guest had APQNs attached the AP reset is a prerequisite to
457          * unprotecting since the UV checks if all APQNs are reset.
458          */
459         subsystem_reset();
460         if (s390_is_pv()) {
461             s390_machine_unprotect(ms);
462         }
463 
464         /*
465          * Device reset includes CPU clear resets so this has to be
466          * done AFTER the unprotect call above.
467          */
468         qemu_devices_reset(reason);
469         s390_crypto_reset();
470 
471         /* configure and start the ipl CPU only */
472         run_on_cpu(cs, s390_do_cpu_ipl, RUN_ON_CPU_NULL);
473         break;
474     case S390_RESET_MODIFIED_CLEAR:
475         /*
476          * Subsystem reset needs to be done before we unshare memory
477          * and lose access to VIRTIO structures in guest memory.
478          */
479         subsystem_reset();
480         s390_crypto_reset();
481         s390_pv_prepare_reset(ms);
482         CPU_FOREACH(t) {
483             run_on_cpu(t, s390_do_cpu_full_reset, RUN_ON_CPU_NULL);
484         }
485         run_on_cpu(cs, s390_do_cpu_load_normal, RUN_ON_CPU_NULL);
486         break;
487     case S390_RESET_LOAD_NORMAL:
488         /*
489          * Subsystem reset needs to be done before we unshare memory
490          * and lose access to VIRTIO structures in guest memory.
491          */
492         subsystem_reset();
493         s390_pv_prepare_reset(ms);
494         CPU_FOREACH(t) {
495             if (t == cs) {
496                 continue;
497             }
498             run_on_cpu(t, s390_do_cpu_reset, RUN_ON_CPU_NULL);
499         }
500         run_on_cpu(cs, s390_do_cpu_initial_reset, RUN_ON_CPU_NULL);
501         run_on_cpu(cs, s390_do_cpu_load_normal, RUN_ON_CPU_NULL);
502         break;
503     case S390_RESET_PV: /* Subcode 10 */
504         subsystem_reset();
505         s390_crypto_reset();
506 
507         CPU_FOREACH(t) {
508             if (t == cs) {
509                 continue;
510             }
511             run_on_cpu(t, s390_do_cpu_full_reset, RUN_ON_CPU_NULL);
512         }
513         run_on_cpu(cs, s390_do_cpu_reset, RUN_ON_CPU_NULL);
514 
515         if (s390_machine_protect(ms)) {
516             s390_pv_inject_reset_error(cs);
517             /*
518              * Continue after the diag308 so the guest knows something
519              * went wrong.
520              */
521             s390_cpu_set_state(S390_CPU_STATE_OPERATING, cpu);
522             return;
523         }
524 
525         run_on_cpu(cs, s390_do_cpu_load_normal, RUN_ON_CPU_NULL);
526         break;
527     default:
528         g_assert_not_reached();
529     }
530 
531     CPU_FOREACH(t) {
532         run_on_cpu(t, s390_do_cpu_set_diag318, RUN_ON_CPU_HOST_ULONG(0));
533     }
534     s390_ipl_clear_reset_request();
535 }
536 
537 static void s390_machine_device_plug(HotplugHandler *hotplug_dev,
538                                      DeviceState *dev, Error **errp)
539 {
540     if (object_dynamic_cast(OBJECT(dev), TYPE_CPU)) {
541         s390_cpu_plug(hotplug_dev, dev, errp);
542     }
543 }
544 
545 static void s390_machine_device_unplug_request(HotplugHandler *hotplug_dev,
546                                                DeviceState *dev, Error **errp)
547 {
548     if (object_dynamic_cast(OBJECT(dev), TYPE_CPU)) {
549         error_setg(errp, "CPU hot unplug not supported on this machine");
550         return;
551     }
552 }
553 
554 static CpuInstanceProperties s390_cpu_index_to_props(MachineState *ms,
555                                                      unsigned cpu_index)
556 {
557     MachineClass *mc = MACHINE_GET_CLASS(ms);
558     const CPUArchIdList *possible_cpus = mc->possible_cpu_arch_ids(ms);
559 
560     assert(cpu_index < possible_cpus->len);
561     return possible_cpus->cpus[cpu_index].props;
562 }
563 
564 static const CPUArchIdList *s390_possible_cpu_arch_ids(MachineState *ms)
565 {
566     int i;
567     unsigned int max_cpus = ms->smp.max_cpus;
568 
569     if (ms->possible_cpus) {
570         g_assert(ms->possible_cpus && ms->possible_cpus->len == max_cpus);
571         return ms->possible_cpus;
572     }
573 
574     ms->possible_cpus = g_malloc0(sizeof(CPUArchIdList) +
575                                   sizeof(CPUArchId) * max_cpus);
576     ms->possible_cpus->len = max_cpus;
577     for (i = 0; i < ms->possible_cpus->len; i++) {
578         CpuInstanceProperties *props = &ms->possible_cpus->cpus[i].props;
579 
580         ms->possible_cpus->cpus[i].type = ms->cpu_type;
581         ms->possible_cpus->cpus[i].vcpus_count = 1;
582         ms->possible_cpus->cpus[i].arch_id = i;
583 
584         props->has_core_id = true;
585         props->core_id = i;
586         props->has_socket_id = true;
587         props->socket_id = s390_std_socket(i, &ms->smp);
588         props->has_book_id = true;
589         props->book_id = s390_std_book(i, &ms->smp);
590         props->has_drawer_id = true;
591         props->drawer_id = s390_std_drawer(i, &ms->smp);
592     }
593 
594     return ms->possible_cpus;
595 }
596 
597 static HotplugHandler *s390_get_hotplug_handler(MachineState *machine,
598                                                 DeviceState *dev)
599 {
600     if (object_dynamic_cast(OBJECT(dev), TYPE_CPU)) {
601         return HOTPLUG_HANDLER(machine);
602     }
603     return NULL;
604 }
605 
606 static void s390_nmi(NMIState *n, int cpu_index, Error **errp)
607 {
608     CPUState *cs = qemu_get_cpu(cpu_index);
609 
610     s390_cpu_restart(S390_CPU(cs));
611 }
612 
613 static ram_addr_t s390_fixup_ram_size(ram_addr_t sz)
614 {
615     /* same logic as in sclp.c */
616     int increment_size = 20;
617     ram_addr_t newsz;
618 
619     while ((sz >> increment_size) > MAX_STORAGE_INCREMENTS) {
620         increment_size++;
621     }
622     newsz = sz >> increment_size << increment_size;
623 
624     if (sz != newsz) {
625         qemu_printf("Ram size %" PRIu64 "MB was fixed up to %" PRIu64
626                     "MB to match machine restrictions. Consider updating "
627                     "the guest definition.\n", (uint64_t) (sz / MiB),
628                     (uint64_t) (newsz / MiB));
629     }
630     return newsz;
631 }
632 
633 static inline bool machine_get_aes_key_wrap(Object *obj, Error **errp)
634 {
635     S390CcwMachineState *ms = S390_CCW_MACHINE(obj);
636 
637     return ms->aes_key_wrap;
638 }
639 
640 static inline void machine_set_aes_key_wrap(Object *obj, bool value,
641                                             Error **errp)
642 {
643     S390CcwMachineState *ms = S390_CCW_MACHINE(obj);
644 
645     ms->aes_key_wrap = value;
646 }
647 
648 static inline bool machine_get_dea_key_wrap(Object *obj, Error **errp)
649 {
650     S390CcwMachineState *ms = S390_CCW_MACHINE(obj);
651 
652     return ms->dea_key_wrap;
653 }
654 
655 static inline void machine_set_dea_key_wrap(Object *obj, bool value,
656                                             Error **errp)
657 {
658     S390CcwMachineState *ms = S390_CCW_MACHINE(obj);
659 
660     ms->dea_key_wrap = value;
661 }
662 
663 static S390CcwMachineClass *current_mc;
664 
665 /*
666  * Get the class of the s390-ccw-virtio machine that is currently in use.
667  * Note: libvirt is using the "none" machine to probe for the features of the
668  * host CPU, so in case this is called with the "none" machine, the function
669  * returns the TYPE_S390_CCW_MACHINE base class. In this base class, all the
670  * various "*_allowed" variables are enabled, so that the *_allowed() wrappers
671  * below return the correct default value for the "none" machine.
672  *
673  * Attention! Do *not* add additional new wrappers for CPU features (e.g. like
674  * the ri_allowed() wrapper) via this mechanism anymore. CPU features should
675  * be handled via the CPU models, i.e. checking with cpu_model_allowed() during
676  * CPU initialization and s390_has_feat() later should be sufficient.
677  */
678 static S390CcwMachineClass *get_machine_class(void)
679 {
680     if (unlikely(!current_mc)) {
681         /*
682         * No s390 ccw machine was instantiated, we are likely to
683         * be called for the 'none' machine. The properties will
684         * have their after-initialization values.
685         */
686         current_mc = S390_CCW_MACHINE_CLASS(
687                      object_class_by_name(TYPE_S390_CCW_MACHINE));
688     }
689     return current_mc;
690 }
691 
692 bool ri_allowed(void)
693 {
694     return get_machine_class()->ri_allowed;
695 }
696 
697 bool cpu_model_allowed(void)
698 {
699     return get_machine_class()->cpu_model_allowed;
700 }
701 
702 bool hpage_1m_allowed(void)
703 {
704     return get_machine_class()->hpage_1m_allowed;
705 }
706 
707 static void machine_get_loadparm(Object *obj, Visitor *v,
708                                  const char *name, void *opaque,
709                                  Error **errp)
710 {
711     S390CcwMachineState *ms = S390_CCW_MACHINE(obj);
712     char *str = g_strndup((char *) ms->loadparm, sizeof(ms->loadparm));
713 
714     visit_type_str(v, name, &str, errp);
715     g_free(str);
716 }
717 
718 static void machine_set_loadparm(Object *obj, Visitor *v,
719                                  const char *name, void *opaque,
720                                  Error **errp)
721 {
722     S390CcwMachineState *ms = S390_CCW_MACHINE(obj);
723     char *val;
724     int i;
725 
726     if (!visit_type_str(v, name, &val, errp)) {
727         return;
728     }
729 
730     for (i = 0; i < sizeof(ms->loadparm) && val[i]; i++) {
731         uint8_t c = qemu_toupper(val[i]); /* mimic HMC */
732 
733         if (('A' <= c && c <= 'Z') || ('0' <= c && c <= '9') || (c == '.') ||
734             (c == ' ')) {
735             ms->loadparm[i] = c;
736         } else {
737             error_setg(errp, "LOADPARM: invalid character '%c' (ASCII 0x%02x)",
738                        c, c);
739             return;
740         }
741     }
742 
743     for (; i < sizeof(ms->loadparm); i++) {
744         ms->loadparm[i] = ' '; /* pad right with spaces */
745     }
746 }
747 
748 static void ccw_machine_class_init(ObjectClass *oc, void *data)
749 {
750     MachineClass *mc = MACHINE_CLASS(oc);
751     NMIClass *nc = NMI_CLASS(oc);
752     HotplugHandlerClass *hc = HOTPLUG_HANDLER_CLASS(oc);
753     S390CcwMachineClass *s390mc = S390_CCW_MACHINE_CLASS(mc);
754 
755     s390mc->ri_allowed = true;
756     s390mc->cpu_model_allowed = true;
757     s390mc->css_migration_enabled = true;
758     s390mc->hpage_1m_allowed = true;
759     s390mc->max_threads = 1;
760     mc->init = ccw_init;
761     mc->reset = s390_machine_reset;
762     mc->block_default_type = IF_VIRTIO;
763     mc->no_cdrom = 1;
764     mc->no_floppy = 1;
765     mc->no_parallel = 1;
766     mc->no_sdcard = 1;
767     mc->max_cpus = S390_MAX_CPUS;
768     mc->has_hotpluggable_cpus = true;
769     mc->smp_props.books_supported = true;
770     mc->smp_props.drawers_supported = true;
771     assert(!mc->get_hotplug_handler);
772     mc->get_hotplug_handler = s390_get_hotplug_handler;
773     mc->cpu_index_to_instance_props = s390_cpu_index_to_props;
774     mc->possible_cpu_arch_ids = s390_possible_cpu_arch_ids;
775     /* it is overridden with 'host' cpu *in kvm_arch_init* */
776     mc->default_cpu_type = S390_CPU_TYPE_NAME("qemu");
777     hc->plug = s390_machine_device_plug;
778     hc->unplug_request = s390_machine_device_unplug_request;
779     nc->nmi_monitor_handler = s390_nmi;
780     mc->default_ram_id = "s390.ram";
781     mc->default_nic = "virtio-net-ccw";
782 
783     object_class_property_add_bool(oc, "aes-key-wrap",
784                                    machine_get_aes_key_wrap,
785                                    machine_set_aes_key_wrap);
786     object_class_property_set_description(oc, "aes-key-wrap",
787             "enable/disable AES key wrapping using the CPACF wrapping key");
788 
789     object_class_property_add_bool(oc, "dea-key-wrap",
790                                    machine_get_dea_key_wrap,
791                                    machine_set_dea_key_wrap);
792     object_class_property_set_description(oc, "dea-key-wrap",
793             "enable/disable DEA key wrapping using the CPACF wrapping key");
794 
795     object_class_property_add(oc, "loadparm", "loadparm",
796                               machine_get_loadparm, machine_set_loadparm,
797                               NULL, NULL);
798     object_class_property_set_description(oc, "loadparm",
799             "Up to 8 chars in set of [A-Za-z0-9. ] (lower case chars converted"
800             " to upper case) to pass to machine loader, boot manager,"
801             " and guest kernel");
802 }
803 
804 static inline void s390_machine_initfn(Object *obj)
805 {
806     S390CcwMachineState *ms = S390_CCW_MACHINE(obj);
807 
808     ms->aes_key_wrap = true;
809     ms->dea_key_wrap = true;
810 }
811 
812 static const TypeInfo ccw_machine_info = {
813     .name          = TYPE_S390_CCW_MACHINE,
814     .parent        = TYPE_MACHINE,
815     .abstract      = true,
816     .instance_size = sizeof(S390CcwMachineState),
817     .instance_init = s390_machine_initfn,
818     .class_size = sizeof(S390CcwMachineClass),
819     .class_init    = ccw_machine_class_init,
820     .interfaces = (InterfaceInfo[]) {
821         { TYPE_NMI },
822         { TYPE_HOTPLUG_HANDLER},
823         { }
824     },
825 };
826 
827 bool css_migration_enabled(void)
828 {
829     return get_machine_class()->css_migration_enabled;
830 }
831 
832 #define DEFINE_CCW_MACHINE(suffix, verstr, latest)                            \
833     static void ccw_machine_##suffix##_class_init(ObjectClass *oc,            \
834                                                   void *data)                 \
835     {                                                                         \
836         MachineClass *mc = MACHINE_CLASS(oc);                                 \
837         ccw_machine_##suffix##_class_options(mc);                             \
838         mc->desc = "Virtual s390x machine (version " verstr ")";              \
839         if (latest) {                                                         \
840             mc->alias = "s390-ccw-virtio";                                    \
841             mc->is_default = true;                                            \
842         }                                                                     \
843     }                                                                         \
844     static void ccw_machine_##suffix##_instance_init(Object *obj)             \
845     {                                                                         \
846         MachineState *machine = MACHINE(obj);                                 \
847         current_mc = S390_CCW_MACHINE_CLASS(MACHINE_GET_CLASS(machine));          \
848         ccw_machine_##suffix##_instance_options(machine);                     \
849     }                                                                         \
850     static const TypeInfo ccw_machine_##suffix##_info = {                     \
851         .name = MACHINE_TYPE_NAME("s390-ccw-virtio-" verstr),                 \
852         .parent = TYPE_S390_CCW_MACHINE,                                      \
853         .class_init = ccw_machine_##suffix##_class_init,                      \
854         .instance_init = ccw_machine_##suffix##_instance_init,                \
855     };                                                                        \
856     static void ccw_machine_register_##suffix(void)                           \
857     {                                                                         \
858         type_register_static(&ccw_machine_##suffix##_info);                   \
859     }                                                                         \
860     type_init(ccw_machine_register_##suffix)
861 
862 static void ccw_machine_9_0_instance_options(MachineState *machine)
863 {
864 }
865 
866 static void ccw_machine_9_0_class_options(MachineClass *mc)
867 {
868 }
869 DEFINE_CCW_MACHINE(9_0, "9.0", true);
870 
871 static void ccw_machine_8_2_instance_options(MachineState *machine)
872 {
873     ccw_machine_9_0_instance_options(machine);
874 }
875 
876 static void ccw_machine_8_2_class_options(MachineClass *mc)
877 {
878     ccw_machine_9_0_class_options(mc);
879     compat_props_add(mc->compat_props, hw_compat_8_2, hw_compat_8_2_len);
880 }
881 DEFINE_CCW_MACHINE(8_2, "8.2", false);
882 
883 static void ccw_machine_8_1_instance_options(MachineState *machine)
884 {
885     ccw_machine_8_2_instance_options(machine);
886 }
887 
888 static void ccw_machine_8_1_class_options(MachineClass *mc)
889 {
890     ccw_machine_8_2_class_options(mc);
891     compat_props_add(mc->compat_props, hw_compat_8_1, hw_compat_8_1_len);
892     mc->smp_props.drawers_supported = false;
893     mc->smp_props.books_supported = false;
894 }
895 DEFINE_CCW_MACHINE(8_1, "8.1", false);
896 
897 static void ccw_machine_8_0_instance_options(MachineState *machine)
898 {
899     ccw_machine_8_1_instance_options(machine);
900 }
901 
902 static void ccw_machine_8_0_class_options(MachineClass *mc)
903 {
904     ccw_machine_8_1_class_options(mc);
905     compat_props_add(mc->compat_props, hw_compat_8_0, hw_compat_8_0_len);
906 }
907 DEFINE_CCW_MACHINE(8_0, "8.0", false);
908 
909 static void ccw_machine_7_2_instance_options(MachineState *machine)
910 {
911     ccw_machine_8_0_instance_options(machine);
912 }
913 
914 static void ccw_machine_7_2_class_options(MachineClass *mc)
915 {
916     ccw_machine_8_0_class_options(mc);
917     compat_props_add(mc->compat_props, hw_compat_7_2, hw_compat_7_2_len);
918 }
919 DEFINE_CCW_MACHINE(7_2, "7.2", false);
920 
921 static void ccw_machine_7_1_instance_options(MachineState *machine)
922 {
923     static const S390FeatInit qemu_cpu_feat = { S390_FEAT_LIST_QEMU_V7_1 };
924 
925     ccw_machine_7_2_instance_options(machine);
926     s390_cpudef_featoff_greater(16, 1, S390_FEAT_PAIE);
927     s390_set_qemu_cpu_model(0x8561, 15, 1, qemu_cpu_feat);
928 }
929 
930 static void ccw_machine_7_1_class_options(MachineClass *mc)
931 {
932     S390CcwMachineClass *s390mc = S390_CCW_MACHINE_CLASS(mc);
933     static GlobalProperty compat[] = {
934         { TYPE_S390_PCI_DEVICE, "interpret", "off", },
935         { TYPE_S390_PCI_DEVICE, "forwarding-assist", "off", },
936     };
937 
938     ccw_machine_7_2_class_options(mc);
939     compat_props_add(mc->compat_props, hw_compat_7_1, hw_compat_7_1_len);
940     compat_props_add(mc->compat_props, compat, G_N_ELEMENTS(compat));
941     s390mc->max_threads = S390_MAX_CPUS;
942 }
943 DEFINE_CCW_MACHINE(7_1, "7.1", false);
944 
945 static void ccw_machine_7_0_instance_options(MachineState *machine)
946 {
947     static const S390FeatInit qemu_cpu_feat = { S390_FEAT_LIST_QEMU_V7_0 };
948 
949     ccw_machine_7_1_instance_options(machine);
950     s390_set_qemu_cpu_model(0x8561, 15, 1, qemu_cpu_feat);
951 }
952 
953 static void ccw_machine_7_0_class_options(MachineClass *mc)
954 {
955     ccw_machine_7_1_class_options(mc);
956     compat_props_add(mc->compat_props, hw_compat_7_0, hw_compat_7_0_len);
957 }
958 DEFINE_CCW_MACHINE(7_0, "7.0", false);
959 
960 static void ccw_machine_6_2_instance_options(MachineState *machine)
961 {
962     static const S390FeatInit qemu_cpu_feat = { S390_FEAT_LIST_QEMU_V6_2 };
963 
964     ccw_machine_7_0_instance_options(machine);
965     s390_set_qemu_cpu_model(0x3906, 14, 2, qemu_cpu_feat);
966 }
967 
968 static void ccw_machine_6_2_class_options(MachineClass *mc)
969 {
970     ccw_machine_7_0_class_options(mc);
971     compat_props_add(mc->compat_props, hw_compat_6_2, hw_compat_6_2_len);
972 }
973 DEFINE_CCW_MACHINE(6_2, "6.2", false);
974 
975 static void ccw_machine_6_1_instance_options(MachineState *machine)
976 {
977     ccw_machine_6_2_instance_options(machine);
978     s390_cpudef_featoff_greater(16, 1, S390_FEAT_NNPA);
979     s390_cpudef_featoff_greater(16, 1, S390_FEAT_VECTOR_PACKED_DECIMAL_ENH2);
980     s390_cpudef_featoff_greater(16, 1, S390_FEAT_BEAR_ENH);
981     s390_cpudef_featoff_greater(16, 1, S390_FEAT_RDP);
982     s390_cpudef_featoff_greater(16, 1, S390_FEAT_PAI);
983 }
984 
985 static void ccw_machine_6_1_class_options(MachineClass *mc)
986 {
987     ccw_machine_6_2_class_options(mc);
988     compat_props_add(mc->compat_props, hw_compat_6_1, hw_compat_6_1_len);
989     mc->smp_props.prefer_sockets = true;
990 }
991 DEFINE_CCW_MACHINE(6_1, "6.1", false);
992 
993 static void ccw_machine_6_0_instance_options(MachineState *machine)
994 {
995     static const S390FeatInit qemu_cpu_feat = { S390_FEAT_LIST_QEMU_V6_0 };
996 
997     ccw_machine_6_1_instance_options(machine);
998     s390_set_qemu_cpu_model(0x2964, 13, 2, qemu_cpu_feat);
999 }
1000 
1001 static void ccw_machine_6_0_class_options(MachineClass *mc)
1002 {
1003     ccw_machine_6_1_class_options(mc);
1004     compat_props_add(mc->compat_props, hw_compat_6_0, hw_compat_6_0_len);
1005 }
1006 DEFINE_CCW_MACHINE(6_0, "6.0", false);
1007 
1008 static void ccw_machine_5_2_instance_options(MachineState *machine)
1009 {
1010     ccw_machine_6_0_instance_options(machine);
1011 }
1012 
1013 static void ccw_machine_5_2_class_options(MachineClass *mc)
1014 {
1015     ccw_machine_6_0_class_options(mc);
1016     compat_props_add(mc->compat_props, hw_compat_5_2, hw_compat_5_2_len);
1017 }
1018 DEFINE_CCW_MACHINE(5_2, "5.2", false);
1019 
1020 static void ccw_machine_5_1_instance_options(MachineState *machine)
1021 {
1022     ccw_machine_5_2_instance_options(machine);
1023 }
1024 
1025 static void ccw_machine_5_1_class_options(MachineClass *mc)
1026 {
1027     ccw_machine_5_2_class_options(mc);
1028     compat_props_add(mc->compat_props, hw_compat_5_1, hw_compat_5_1_len);
1029 }
1030 DEFINE_CCW_MACHINE(5_1, "5.1", false);
1031 
1032 static void ccw_machine_5_0_instance_options(MachineState *machine)
1033 {
1034     ccw_machine_5_1_instance_options(machine);
1035 }
1036 
1037 static void ccw_machine_5_0_class_options(MachineClass *mc)
1038 {
1039     ccw_machine_5_1_class_options(mc);
1040     compat_props_add(mc->compat_props, hw_compat_5_0, hw_compat_5_0_len);
1041 }
1042 DEFINE_CCW_MACHINE(5_0, "5.0", false);
1043 
1044 static void ccw_machine_4_2_instance_options(MachineState *machine)
1045 {
1046     ccw_machine_5_0_instance_options(machine);
1047 }
1048 
1049 static void ccw_machine_4_2_class_options(MachineClass *mc)
1050 {
1051     ccw_machine_5_0_class_options(mc);
1052     mc->fixup_ram_size = s390_fixup_ram_size;
1053     compat_props_add(mc->compat_props, hw_compat_4_2, hw_compat_4_2_len);
1054 }
1055 DEFINE_CCW_MACHINE(4_2, "4.2", false);
1056 
1057 static void ccw_machine_4_1_instance_options(MachineState *machine)
1058 {
1059     static const S390FeatInit qemu_cpu_feat = { S390_FEAT_LIST_QEMU_V4_1 };
1060     ccw_machine_4_2_instance_options(machine);
1061     s390_set_qemu_cpu_model(0x2964, 13, 2, qemu_cpu_feat);
1062 }
1063 
1064 static void ccw_machine_4_1_class_options(MachineClass *mc)
1065 {
1066     ccw_machine_4_2_class_options(mc);
1067     compat_props_add(mc->compat_props, hw_compat_4_1, hw_compat_4_1_len);
1068 }
1069 DEFINE_CCW_MACHINE(4_1, "4.1", false);
1070 
1071 static void ccw_machine_4_0_instance_options(MachineState *machine)
1072 {
1073     static const S390FeatInit qemu_cpu_feat = { S390_FEAT_LIST_QEMU_V4_0 };
1074     ccw_machine_4_1_instance_options(machine);
1075     s390_set_qemu_cpu_model(0x2827, 12, 2, qemu_cpu_feat);
1076 }
1077 
1078 static void ccw_machine_4_0_class_options(MachineClass *mc)
1079 {
1080     ccw_machine_4_1_class_options(mc);
1081     compat_props_add(mc->compat_props, hw_compat_4_0, hw_compat_4_0_len);
1082 }
1083 DEFINE_CCW_MACHINE(4_0, "4.0", false);
1084 
1085 static void ccw_machine_3_1_instance_options(MachineState *machine)
1086 {
1087     static const S390FeatInit qemu_cpu_feat = { S390_FEAT_LIST_QEMU_V3_1 };
1088     ccw_machine_4_0_instance_options(machine);
1089     s390_cpudef_featoff_greater(14, 1, S390_FEAT_MULTIPLE_EPOCH);
1090     s390_cpudef_group_featoff_greater(14, 1, S390_FEAT_GROUP_MULTIPLE_EPOCH_PTFF);
1091     s390_set_qemu_cpu_model(0x2827, 12, 2, qemu_cpu_feat);
1092 }
1093 
1094 static void ccw_machine_3_1_class_options(MachineClass *mc)
1095 {
1096     ccw_machine_4_0_class_options(mc);
1097     compat_props_add(mc->compat_props, hw_compat_3_1, hw_compat_3_1_len);
1098 }
1099 DEFINE_CCW_MACHINE(3_1, "3.1", false);
1100 
1101 static void ccw_machine_3_0_instance_options(MachineState *machine)
1102 {
1103     ccw_machine_3_1_instance_options(machine);
1104 }
1105 
1106 static void ccw_machine_3_0_class_options(MachineClass *mc)
1107 {
1108     S390CcwMachineClass *s390mc = S390_CCW_MACHINE_CLASS(mc);
1109 
1110     s390mc->hpage_1m_allowed = false;
1111     ccw_machine_3_1_class_options(mc);
1112     compat_props_add(mc->compat_props, hw_compat_3_0, hw_compat_3_0_len);
1113 }
1114 DEFINE_CCW_MACHINE(3_0, "3.0", false);
1115 
1116 static void ccw_machine_2_12_instance_options(MachineState *machine)
1117 {
1118     ccw_machine_3_0_instance_options(machine);
1119     s390_cpudef_featoff_greater(11, 1, S390_FEAT_PPA15);
1120     s390_cpudef_featoff_greater(11, 1, S390_FEAT_BPB);
1121 }
1122 
1123 static void ccw_machine_2_12_class_options(MachineClass *mc)
1124 {
1125     ccw_machine_3_0_class_options(mc);
1126     compat_props_add(mc->compat_props, hw_compat_2_12, hw_compat_2_12_len);
1127 }
1128 DEFINE_CCW_MACHINE(2_12, "2.12", false);
1129 
1130 static void ccw_machine_2_11_instance_options(MachineState *machine)
1131 {
1132     static const S390FeatInit qemu_cpu_feat = { S390_FEAT_LIST_QEMU_V2_11 };
1133     ccw_machine_2_12_instance_options(machine);
1134 
1135     /* before 2.12 we emulated the very first z900 */
1136     s390_set_qemu_cpu_model(0x2064, 7, 1, qemu_cpu_feat);
1137 }
1138 
1139 static void ccw_machine_2_11_class_options(MachineClass *mc)
1140 {
1141     static GlobalProperty compat[] = {
1142         { TYPE_SCLP_EVENT_FACILITY, "allow_all_mask_sizes", "off", },
1143     };
1144 
1145     ccw_machine_2_12_class_options(mc);
1146     compat_props_add(mc->compat_props, hw_compat_2_11, hw_compat_2_11_len);
1147     compat_props_add(mc->compat_props, compat, G_N_ELEMENTS(compat));
1148 }
1149 DEFINE_CCW_MACHINE(2_11, "2.11", false);
1150 
1151 static void ccw_machine_2_10_instance_options(MachineState *machine)
1152 {
1153     ccw_machine_2_11_instance_options(machine);
1154 }
1155 
1156 static void ccw_machine_2_10_class_options(MachineClass *mc)
1157 {
1158     ccw_machine_2_11_class_options(mc);
1159     compat_props_add(mc->compat_props, hw_compat_2_10, hw_compat_2_10_len);
1160 }
1161 DEFINE_CCW_MACHINE(2_10, "2.10", false);
1162 
1163 static void ccw_machine_2_9_instance_options(MachineState *machine)
1164 {
1165     ccw_machine_2_10_instance_options(machine);
1166     s390_cpudef_featoff_greater(12, 1, S390_FEAT_ESOP);
1167     s390_cpudef_featoff_greater(12, 1, S390_FEAT_SIDE_EFFECT_ACCESS_ESOP2);
1168     s390_cpudef_featoff_greater(12, 1, S390_FEAT_ZPCI);
1169     s390_cpudef_featoff_greater(12, 1, S390_FEAT_ADAPTER_INT_SUPPRESSION);
1170     s390_cpudef_featoff_greater(12, 1, S390_FEAT_ADAPTER_EVENT_NOTIFICATION);
1171 }
1172 
1173 static void ccw_machine_2_9_class_options(MachineClass *mc)
1174 {
1175     S390CcwMachineClass *s390mc = S390_CCW_MACHINE_CLASS(mc);
1176     static GlobalProperty compat[] = {
1177         { TYPE_S390_STATTRIB, "migration-enabled", "off", },
1178     };
1179 
1180     ccw_machine_2_10_class_options(mc);
1181     compat_props_add(mc->compat_props, hw_compat_2_9, hw_compat_2_9_len);
1182     compat_props_add(mc->compat_props, compat, G_N_ELEMENTS(compat));
1183     s390mc->css_migration_enabled = false;
1184 }
1185 DEFINE_CCW_MACHINE(2_9, "2.9", false);
1186 
1187 static void ccw_machine_2_8_instance_options(MachineState *machine)
1188 {
1189     ccw_machine_2_9_instance_options(machine);
1190 }
1191 
1192 static void ccw_machine_2_8_class_options(MachineClass *mc)
1193 {
1194     static GlobalProperty compat[] = {
1195         { TYPE_S390_FLIC_COMMON, "adapter_routes_max_batch", "64", },
1196     };
1197 
1198     ccw_machine_2_9_class_options(mc);
1199     compat_props_add(mc->compat_props, hw_compat_2_8, hw_compat_2_8_len);
1200     compat_props_add(mc->compat_props, compat, G_N_ELEMENTS(compat));
1201 }
1202 DEFINE_CCW_MACHINE(2_8, "2.8", false);
1203 
1204 static void ccw_machine_2_7_instance_options(MachineState *machine)
1205 {
1206     ccw_machine_2_8_instance_options(machine);
1207 }
1208 
1209 static void ccw_machine_2_7_class_options(MachineClass *mc)
1210 {
1211     S390CcwMachineClass *s390mc = S390_CCW_MACHINE_CLASS(mc);
1212 
1213     s390mc->cpu_model_allowed = false;
1214     ccw_machine_2_8_class_options(mc);
1215     compat_props_add(mc->compat_props, hw_compat_2_7, hw_compat_2_7_len);
1216 }
1217 DEFINE_CCW_MACHINE(2_7, "2.7", false);
1218 
1219 static void ccw_machine_2_6_instance_options(MachineState *machine)
1220 {
1221     ccw_machine_2_7_instance_options(machine);
1222 }
1223 
1224 static void ccw_machine_2_6_class_options(MachineClass *mc)
1225 {
1226     S390CcwMachineClass *s390mc = S390_CCW_MACHINE_CLASS(mc);
1227     static GlobalProperty compat[] = {
1228         { TYPE_S390_IPL, "iplbext_migration", "off", },
1229          { TYPE_VIRTUAL_CSS_BRIDGE, "css_dev_path", "off", },
1230     };
1231 
1232     s390mc->ri_allowed = false;
1233     ccw_machine_2_7_class_options(mc);
1234     compat_props_add(mc->compat_props, hw_compat_2_6, hw_compat_2_6_len);
1235     compat_props_add(mc->compat_props, compat, G_N_ELEMENTS(compat));
1236 }
1237 DEFINE_CCW_MACHINE(2_6, "2.6", false);
1238 
1239 static void ccw_machine_2_5_instance_options(MachineState *machine)
1240 {
1241     ccw_machine_2_6_instance_options(machine);
1242 }
1243 
1244 static void ccw_machine_2_5_class_options(MachineClass *mc)
1245 {
1246     ccw_machine_2_6_class_options(mc);
1247     compat_props_add(mc->compat_props, hw_compat_2_5, hw_compat_2_5_len);
1248 }
1249 DEFINE_CCW_MACHINE(2_5, "2.5", false);
1250 
1251 static void ccw_machine_2_4_instance_options(MachineState *machine)
1252 {
1253     ccw_machine_2_5_instance_options(machine);
1254 }
1255 
1256 static void ccw_machine_2_4_class_options(MachineClass *mc)
1257 {
1258     static GlobalProperty compat[] = {
1259         { TYPE_S390_SKEYS, "migration-enabled", "off", },
1260         { "virtio-blk-ccw", "max_revision", "0", },
1261         { "virtio-balloon-ccw", "max_revision", "0", },
1262         { "virtio-serial-ccw", "max_revision", "0", },
1263         { "virtio-9p-ccw", "max_revision", "0", },
1264         { "virtio-rng-ccw", "max_revision", "0", },
1265         { "virtio-net-ccw", "max_revision", "0", },
1266         { "virtio-scsi-ccw", "max_revision", "0", },
1267         { "vhost-scsi-ccw", "max_revision", "0", },
1268     };
1269 
1270     ccw_machine_2_5_class_options(mc);
1271     compat_props_add(mc->compat_props, hw_compat_2_4, hw_compat_2_4_len);
1272     compat_props_add(mc->compat_props, compat, G_N_ELEMENTS(compat));
1273 }
1274 DEFINE_CCW_MACHINE(2_4, "2.4", false);
1275 
1276 static void ccw_machine_register_types(void)
1277 {
1278     type_register_static(&ccw_machine_info);
1279 }
1280 
1281 type_init(ccw_machine_register_types)
1282