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