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