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