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