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