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