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