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