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