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