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