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