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