1 /* 2 * virtio ccw machine 3 * 4 * Copyright 2012 IBM Corp. 5 * Copyright (c) 2009 Alexander Graf <agraf@suse.de> 6 * Author(s): Cornelia Huck <cornelia.huck@de.ibm.com> 7 * 8 * This work is licensed under the terms of the GNU GPL, version 2 or (at 9 * your option) any later version. See the COPYING file in the top-level 10 * directory. 11 */ 12 13 #include "qemu/osdep.h" 14 #include "qapi/error.h" 15 #include "qemu-common.h" 16 #include "cpu.h" 17 #include "hw/boards.h" 18 #include "exec/address-spaces.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/error-report.h" 27 #include "s390-pci-bus.h" 28 #include "hw/s390x/storage-keys.h" 29 #include "hw/s390x/storage-attributes.h" 30 #include "hw/compat.h" 31 #include "ipl.h" 32 #include "hw/s390x/s390-virtio-ccw.h" 33 #include "hw/s390x/css-bridge.h" 34 #include "migration/register.h" 35 #include "cpu_models.h" 36 #include "qapi/qmp/qerror.h" 37 #include "hw/nmi.h" 38 39 S390CPU *s390_cpu_addr2state(uint16_t cpu_addr) 40 { 41 static MachineState *ms; 42 43 if (!ms) { 44 ms = MACHINE(qdev_get_machine()); 45 g_assert(ms->possible_cpus); 46 } 47 48 /* CPU address corresponds to the core_id and the index */ 49 if (cpu_addr >= ms->possible_cpus->len) { 50 return NULL; 51 } 52 return S390_CPU(ms->possible_cpus->cpus[cpu_addr].cpu); 53 } 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 Error *err = NULL; 60 61 object_property_set_int(OBJECT(cpu), core_id, "core-id", &err); 62 if (err != NULL) { 63 goto out; 64 } 65 object_property_set_bool(OBJECT(cpu), true, "realized", &err); 66 67 out: 68 object_unref(OBJECT(cpu)); 69 if (err) { 70 error_propagate(errp, err); 71 cpu = NULL; 72 } 73 return cpu; 74 } 75 76 static void s390_init_cpus(MachineState *machine) 77 { 78 MachineClass *mc = MACHINE_GET_CLASS(machine); 79 int i; 80 81 if (tcg_enabled() && max_cpus > 1) { 82 error_report("WARNING: SMP support on s390x is experimental!"); 83 } 84 85 /* initialize possible_cpus */ 86 mc->possible_cpu_arch_ids(machine); 87 88 for (i = 0; i < smp_cpus; i++) { 89 s390x_new_cpu(machine->cpu_type, i, &error_fatal); 90 } 91 } 92 93 static const char *const reset_dev_types[] = { 94 TYPE_VIRTUAL_CSS_BRIDGE, 95 "s390-sclp-event-facility", 96 "s390-flic", 97 "diag288", 98 }; 99 100 void subsystem_reset(void) 101 { 102 DeviceState *dev; 103 int i; 104 105 for (i = 0; i < ARRAY_SIZE(reset_dev_types); i++) { 106 dev = DEVICE(object_resolve_path_type("", reset_dev_types[i], NULL)); 107 if (dev) { 108 qdev_reset_all(dev); 109 } 110 } 111 } 112 113 static int virtio_ccw_hcall_notify(const uint64_t *args) 114 { 115 uint64_t subch_id = args[0]; 116 uint64_t queue = args[1]; 117 SubchDev *sch; 118 int cssid, ssid, schid, m; 119 120 if (ioinst_disassemble_sch_ident(subch_id, &m, &cssid, &ssid, &schid)) { 121 return -EINVAL; 122 } 123 sch = css_find_subch(m, cssid, ssid, schid); 124 if (!sch || !css_subch_visible(sch)) { 125 return -EINVAL; 126 } 127 if (queue >= VIRTIO_QUEUE_MAX) { 128 return -EINVAL; 129 } 130 virtio_queue_notify(virtio_ccw_get_vdev(sch), queue); 131 return 0; 132 133 } 134 135 static int virtio_ccw_hcall_early_printk(const uint64_t *args) 136 { 137 uint64_t mem = args[0]; 138 139 if (mem < ram_size) { 140 /* Early printk */ 141 return 0; 142 } 143 return -EINVAL; 144 } 145 146 static void virtio_ccw_register_hcalls(void) 147 { 148 s390_register_virtio_hypercall(KVM_S390_VIRTIO_CCW_NOTIFY, 149 virtio_ccw_hcall_notify); 150 /* Tolerate early printk. */ 151 s390_register_virtio_hypercall(KVM_S390_VIRTIO_NOTIFY, 152 virtio_ccw_hcall_early_printk); 153 } 154 155 static void s390_memory_init(ram_addr_t mem_size) 156 { 157 MemoryRegion *sysmem = get_system_memory(); 158 MemoryRegion *ram = g_new(MemoryRegion, 1); 159 160 /* allocate RAM for core */ 161 memory_region_allocate_system_memory(ram, NULL, "s390.ram", mem_size); 162 memory_region_add_subregion(sysmem, 0, ram); 163 164 /* Initialize storage key device */ 165 s390_skeys_init(); 166 /* Initialize storage attributes device */ 167 s390_stattrib_init(); 168 } 169 170 #define S390_TOD_CLOCK_VALUE_MISSING 0x00 171 #define S390_TOD_CLOCK_VALUE_PRESENT 0x01 172 173 static void gtod_save(QEMUFile *f, void *opaque) 174 { 175 uint64_t tod_low; 176 uint8_t tod_high; 177 int r; 178 179 r = s390_get_clock(&tod_high, &tod_low); 180 if (r) { 181 warn_report("Unable to get guest clock for migration: %s", 182 strerror(-r)); 183 error_printf("Guest clock will not be migrated " 184 "which could cause the guest to hang."); 185 qemu_put_byte(f, S390_TOD_CLOCK_VALUE_MISSING); 186 return; 187 } 188 189 qemu_put_byte(f, S390_TOD_CLOCK_VALUE_PRESENT); 190 qemu_put_byte(f, tod_high); 191 qemu_put_be64(f, tod_low); 192 } 193 194 static int gtod_load(QEMUFile *f, void *opaque, int version_id) 195 { 196 uint64_t tod_low; 197 uint8_t tod_high; 198 int r; 199 200 if (qemu_get_byte(f) == S390_TOD_CLOCK_VALUE_MISSING) { 201 warn_report("Guest clock was not migrated. This could " 202 "cause the guest to hang."); 203 return 0; 204 } 205 206 tod_high = qemu_get_byte(f); 207 tod_low = qemu_get_be64(f); 208 209 r = s390_set_clock(&tod_high, &tod_low); 210 if (r) { 211 error_report("Unable to set KVM guest TOD clock: %s", strerror(-r)); 212 } 213 214 return r; 215 } 216 217 static SaveVMHandlers savevm_gtod = { 218 .save_state = gtod_save, 219 .load_state = gtod_load, 220 }; 221 222 static void s390_init_ipl_dev(const char *kernel_filename, 223 const char *kernel_cmdline, 224 const char *initrd_filename, const char *firmware, 225 const char *netboot_fw, bool enforce_bios) 226 { 227 Object *new = object_new(TYPE_S390_IPL); 228 DeviceState *dev = DEVICE(new); 229 230 if (kernel_filename) { 231 qdev_prop_set_string(dev, "kernel", kernel_filename); 232 } 233 if (initrd_filename) { 234 qdev_prop_set_string(dev, "initrd", initrd_filename); 235 } 236 qdev_prop_set_string(dev, "cmdline", kernel_cmdline); 237 qdev_prop_set_string(dev, "firmware", firmware); 238 qdev_prop_set_string(dev, "netboot_fw", netboot_fw); 239 qdev_prop_set_bit(dev, "enforce_bios", enforce_bios); 240 object_property_add_child(qdev_get_machine(), TYPE_S390_IPL, 241 new, NULL); 242 object_unref(new); 243 qdev_init_nofail(dev); 244 } 245 246 static void s390_create_virtio_net(BusState *bus, const char *name) 247 { 248 int i; 249 250 for (i = 0; i < nb_nics; i++) { 251 NICInfo *nd = &nd_table[i]; 252 DeviceState *dev; 253 254 if (!nd->model) { 255 nd->model = g_strdup("virtio"); 256 } 257 258 qemu_check_nic_model(nd, "virtio"); 259 260 dev = qdev_create(bus, name); 261 qdev_set_nic_properties(dev, nd); 262 qdev_init_nofail(dev); 263 } 264 } 265 266 static void ccw_init(MachineState *machine) 267 { 268 int ret; 269 VirtualCssBus *css_bus; 270 DeviceState *dev; 271 272 s390_sclp_init(); 273 s390_memory_init(machine->ram_size); 274 275 /* init CPUs (incl. CPU model) early so s390_has_feature() works */ 276 s390_init_cpus(machine); 277 278 s390_flic_init(); 279 280 /* init the SIGP facility */ 281 s390_init_sigp(); 282 283 /* get a BUS */ 284 css_bus = virtual_css_bus_init(); 285 s390_init_ipl_dev(machine->kernel_filename, machine->kernel_cmdline, 286 machine->initrd_filename, "s390-ccw.img", 287 "s390-netboot.img", true); 288 289 /* 290 * We cannot easily make the pci host bridge conditional as older QEMUs 291 * always created it. Doing so would break migration across QEMU versions. 292 */ 293 dev = qdev_create(NULL, TYPE_S390_PCI_HOST_BRIDGE); 294 object_property_add_child(qdev_get_machine(), TYPE_S390_PCI_HOST_BRIDGE, 295 OBJECT(dev), NULL); 296 qdev_init_nofail(dev); 297 298 /* register hypercalls */ 299 virtio_ccw_register_hcalls(); 300 301 s390_enable_css_support(s390_cpu_addr2state(0)); 302 /* 303 * Non mcss-e enabled guests only see the devices from the default 304 * css, which is determined by the value of the squash_mcss property. 305 * Note: we must not squash non virtual devices to css 0xFE. 306 */ 307 if (css_bus->squash_mcss) { 308 ret = css_create_css_image(0, true); 309 } else { 310 ret = css_create_css_image(VIRTUAL_CSSID, true); 311 } 312 assert(ret == 0); 313 if (css_migration_enabled()) { 314 css_register_vmstate(); 315 } 316 317 /* Create VirtIO network adapters */ 318 s390_create_virtio_net(BUS(css_bus), "virtio-net-ccw"); 319 320 /* Register savevm handler for guest TOD clock */ 321 register_savevm_live(NULL, "todclock", 0, 1, &savevm_gtod, NULL); 322 } 323 324 static void s390_cpu_plug(HotplugHandler *hotplug_dev, 325 DeviceState *dev, Error **errp) 326 { 327 MachineState *ms = MACHINE(hotplug_dev); 328 S390CPU *cpu = S390_CPU(dev); 329 330 g_assert(!ms->possible_cpus->cpus[cpu->env.core_id].cpu); 331 ms->possible_cpus->cpus[cpu->env.core_id].cpu = OBJECT(dev); 332 333 if (dev->hotplugged) { 334 raise_irq_cpu_hotplug(); 335 } 336 } 337 338 static void s390_machine_reset(void) 339 { 340 S390CPU *ipl_cpu = S390_CPU(qemu_get_cpu(0)); 341 342 s390_cmma_reset(); 343 qemu_devices_reset(); 344 s390_crypto_reset(); 345 346 /* all cpus are stopped - configure and start the ipl cpu only */ 347 s390_ipl_prepare_cpu(ipl_cpu); 348 s390_cpu_set_state(CPU_STATE_OPERATING, ipl_cpu); 349 } 350 351 static void s390_machine_device_plug(HotplugHandler *hotplug_dev, 352 DeviceState *dev, Error **errp) 353 { 354 if (object_dynamic_cast(OBJECT(dev), TYPE_CPU)) { 355 s390_cpu_plug(hotplug_dev, dev, errp); 356 } 357 } 358 359 static void s390_machine_device_unplug_request(HotplugHandler *hotplug_dev, 360 DeviceState *dev, Error **errp) 361 { 362 if (object_dynamic_cast(OBJECT(dev), TYPE_CPU)) { 363 error_setg(errp, "CPU hot unplug not supported on this machine"); 364 return; 365 } 366 } 367 368 static CpuInstanceProperties s390_cpu_index_to_props(MachineState *machine, 369 unsigned cpu_index) 370 { 371 g_assert(machine->possible_cpus && cpu_index < machine->possible_cpus->len); 372 373 return machine->possible_cpus->cpus[cpu_index].props; 374 } 375 376 static const CPUArchIdList *s390_possible_cpu_arch_ids(MachineState *ms) 377 { 378 int i; 379 380 if (ms->possible_cpus) { 381 g_assert(ms->possible_cpus && ms->possible_cpus->len == max_cpus); 382 return ms->possible_cpus; 383 } 384 385 ms->possible_cpus = g_malloc0(sizeof(CPUArchIdList) + 386 sizeof(CPUArchId) * max_cpus); 387 ms->possible_cpus->len = max_cpus; 388 for (i = 0; i < ms->possible_cpus->len; i++) { 389 ms->possible_cpus->cpus[i].vcpus_count = 1; 390 ms->possible_cpus->cpus[i].arch_id = i; 391 ms->possible_cpus->cpus[i].props.has_core_id = true; 392 ms->possible_cpus->cpus[i].props.core_id = i; 393 } 394 395 return ms->possible_cpus; 396 } 397 398 static HotplugHandler *s390_get_hotplug_handler(MachineState *machine, 399 DeviceState *dev) 400 { 401 if (object_dynamic_cast(OBJECT(dev), TYPE_CPU)) { 402 return HOTPLUG_HANDLER(machine); 403 } 404 return NULL; 405 } 406 407 static void s390_hot_add_cpu(const int64_t id, Error **errp) 408 { 409 MachineState *machine = MACHINE(qdev_get_machine()); 410 ObjectClass *oc; 411 412 g_assert(machine->possible_cpus->cpus[0].cpu); 413 oc = OBJECT_CLASS(CPU_GET_CLASS(machine->possible_cpus->cpus[0].cpu)); 414 415 s390x_new_cpu(object_class_get_name(oc), id, errp); 416 } 417 418 static void s390_nmi(NMIState *n, int cpu_index, Error **errp) 419 { 420 CPUState *cs = qemu_get_cpu(cpu_index); 421 422 s390_cpu_restart(S390_CPU(cs)); 423 } 424 425 static void ccw_machine_class_init(ObjectClass *oc, void *data) 426 { 427 MachineClass *mc = MACHINE_CLASS(oc); 428 NMIClass *nc = NMI_CLASS(oc); 429 HotplugHandlerClass *hc = HOTPLUG_HANDLER_CLASS(oc); 430 S390CcwMachineClass *s390mc = S390_MACHINE_CLASS(mc); 431 432 s390mc->ri_allowed = true; 433 s390mc->cpu_model_allowed = true; 434 s390mc->css_migration_enabled = true; 435 s390mc->gs_allowed = true; 436 mc->init = ccw_init; 437 mc->reset = s390_machine_reset; 438 mc->hot_add_cpu = s390_hot_add_cpu; 439 mc->block_default_type = IF_VIRTIO; 440 mc->no_cdrom = 1; 441 mc->no_floppy = 1; 442 mc->no_serial = 1; 443 mc->no_parallel = 1; 444 mc->no_sdcard = 1; 445 mc->use_sclp = 1; 446 mc->max_cpus = S390_MAX_CPUS; 447 mc->has_hotpluggable_cpus = true; 448 mc->get_hotplug_handler = s390_get_hotplug_handler; 449 mc->cpu_index_to_instance_props = s390_cpu_index_to_props; 450 mc->possible_cpu_arch_ids = s390_possible_cpu_arch_ids; 451 /* it is overridden with 'host' cpu *in kvm_arch_init* */ 452 mc->default_cpu_type = S390_CPU_TYPE_NAME("qemu"); 453 hc->plug = s390_machine_device_plug; 454 hc->unplug_request = s390_machine_device_unplug_request; 455 nc->nmi_monitor_handler = s390_nmi; 456 } 457 458 static inline bool machine_get_aes_key_wrap(Object *obj, Error **errp) 459 { 460 S390CcwMachineState *ms = S390_CCW_MACHINE(obj); 461 462 return ms->aes_key_wrap; 463 } 464 465 static inline void machine_set_aes_key_wrap(Object *obj, bool value, 466 Error **errp) 467 { 468 S390CcwMachineState *ms = S390_CCW_MACHINE(obj); 469 470 ms->aes_key_wrap = value; 471 } 472 473 static inline bool machine_get_dea_key_wrap(Object *obj, Error **errp) 474 { 475 S390CcwMachineState *ms = S390_CCW_MACHINE(obj); 476 477 return ms->dea_key_wrap; 478 } 479 480 static inline void machine_set_dea_key_wrap(Object *obj, bool value, 481 Error **errp) 482 { 483 S390CcwMachineState *ms = S390_CCW_MACHINE(obj); 484 485 ms->dea_key_wrap = value; 486 } 487 488 static S390CcwMachineClass *current_mc; 489 490 static S390CcwMachineClass *get_machine_class(void) 491 { 492 if (unlikely(!current_mc)) { 493 /* 494 * No s390 ccw machine was instantiated, we are likely to 495 * be called for the 'none' machine. The properties will 496 * have their after-initialization values. 497 */ 498 current_mc = S390_MACHINE_CLASS( 499 object_class_by_name(TYPE_S390_CCW_MACHINE)); 500 } 501 return current_mc; 502 } 503 504 bool ri_allowed(void) 505 { 506 /* for "none" machine this results in true */ 507 return get_machine_class()->ri_allowed; 508 } 509 510 bool cpu_model_allowed(void) 511 { 512 /* for "none" machine this results in true */ 513 return get_machine_class()->cpu_model_allowed; 514 } 515 516 bool gs_allowed(void) 517 { 518 /* for "none" machine this results in true */ 519 return get_machine_class()->gs_allowed; 520 } 521 522 static char *machine_get_loadparm(Object *obj, Error **errp) 523 { 524 S390CcwMachineState *ms = S390_CCW_MACHINE(obj); 525 526 return g_memdup(ms->loadparm, sizeof(ms->loadparm)); 527 } 528 529 static void machine_set_loadparm(Object *obj, const char *val, Error **errp) 530 { 531 S390CcwMachineState *ms = S390_CCW_MACHINE(obj); 532 int i; 533 534 for (i = 0; i < sizeof(ms->loadparm) && val[i]; i++) { 535 uint8_t c = qemu_toupper(val[i]); /* mimic HMC */ 536 537 if (('A' <= c && c <= 'Z') || ('0' <= c && c <= '9') || (c == '.') || 538 (c == ' ')) { 539 ms->loadparm[i] = c; 540 } else { 541 error_setg(errp, "LOADPARM: invalid character '%c' (ASCII 0x%02x)", 542 c, c); 543 return; 544 } 545 } 546 547 for (; i < sizeof(ms->loadparm); i++) { 548 ms->loadparm[i] = ' '; /* pad right with spaces */ 549 } 550 } 551 static inline bool machine_get_squash_mcss(Object *obj, Error **errp) 552 { 553 S390CcwMachineState *ms = S390_CCW_MACHINE(obj); 554 555 return ms->s390_squash_mcss; 556 } 557 558 static inline void machine_set_squash_mcss(Object *obj, bool value, 559 Error **errp) 560 { 561 S390CcwMachineState *ms = S390_CCW_MACHINE(obj); 562 563 ms->s390_squash_mcss = value; 564 } 565 566 static inline void s390_machine_initfn(Object *obj) 567 { 568 object_property_add_bool(obj, "aes-key-wrap", 569 machine_get_aes_key_wrap, 570 machine_set_aes_key_wrap, NULL); 571 object_property_set_description(obj, "aes-key-wrap", 572 "enable/disable AES key wrapping using the CPACF wrapping key", 573 NULL); 574 object_property_set_bool(obj, true, "aes-key-wrap", NULL); 575 576 object_property_add_bool(obj, "dea-key-wrap", 577 machine_get_dea_key_wrap, 578 machine_set_dea_key_wrap, NULL); 579 object_property_set_description(obj, "dea-key-wrap", 580 "enable/disable DEA key wrapping using the CPACF wrapping key", 581 NULL); 582 object_property_set_bool(obj, true, "dea-key-wrap", NULL); 583 object_property_add_str(obj, "loadparm", 584 machine_get_loadparm, machine_set_loadparm, NULL); 585 object_property_set_description(obj, "loadparm", 586 "Up to 8 chars in set of [A-Za-z0-9. ] (lower case chars converted" 587 " to upper case) to pass to machine loader, boot manager," 588 " and guest kernel", 589 NULL); 590 object_property_add_bool(obj, "s390-squash-mcss", 591 machine_get_squash_mcss, 592 machine_set_squash_mcss, NULL); 593 object_property_set_description(obj, "s390-squash-mcss", 594 "enable/disable squashing subchannels into the default css", 595 NULL); 596 object_property_set_bool(obj, false, "s390-squash-mcss", NULL); 597 } 598 599 static const TypeInfo ccw_machine_info = { 600 .name = TYPE_S390_CCW_MACHINE, 601 .parent = TYPE_MACHINE, 602 .abstract = true, 603 .instance_size = sizeof(S390CcwMachineState), 604 .instance_init = s390_machine_initfn, 605 .class_size = sizeof(S390CcwMachineClass), 606 .class_init = ccw_machine_class_init, 607 .interfaces = (InterfaceInfo[]) { 608 { TYPE_NMI }, 609 { TYPE_HOTPLUG_HANDLER}, 610 { } 611 }, 612 }; 613 614 bool css_migration_enabled(void) 615 { 616 return get_machine_class()->css_migration_enabled; 617 } 618 619 #define DEFINE_CCW_MACHINE(suffix, verstr, latest) \ 620 static void ccw_machine_##suffix##_class_init(ObjectClass *oc, \ 621 void *data) \ 622 { \ 623 MachineClass *mc = MACHINE_CLASS(oc); \ 624 ccw_machine_##suffix##_class_options(mc); \ 625 mc->desc = "VirtIO-ccw based S390 machine v" verstr; \ 626 if (latest) { \ 627 mc->alias = "s390-ccw-virtio"; \ 628 mc->is_default = 1; \ 629 } \ 630 } \ 631 static void ccw_machine_##suffix##_instance_init(Object *obj) \ 632 { \ 633 MachineState *machine = MACHINE(obj); \ 634 current_mc = S390_MACHINE_CLASS(MACHINE_GET_CLASS(machine)); \ 635 ccw_machine_##suffix##_instance_options(machine); \ 636 } \ 637 static const TypeInfo ccw_machine_##suffix##_info = { \ 638 .name = MACHINE_TYPE_NAME("s390-ccw-virtio-" verstr), \ 639 .parent = TYPE_S390_CCW_MACHINE, \ 640 .class_init = ccw_machine_##suffix##_class_init, \ 641 .instance_init = ccw_machine_##suffix##_instance_init, \ 642 }; \ 643 static void ccw_machine_register_##suffix(void) \ 644 { \ 645 type_register_static(&ccw_machine_##suffix##_info); \ 646 } \ 647 type_init(ccw_machine_register_##suffix) 648 649 #define CCW_COMPAT_2_10 \ 650 HW_COMPAT_2_10 651 652 #define CCW_COMPAT_2_9 \ 653 HW_COMPAT_2_9 \ 654 {\ 655 .driver = TYPE_S390_STATTRIB,\ 656 .property = "migration-enabled",\ 657 .value = "off",\ 658 }, 659 660 #define CCW_COMPAT_2_8 \ 661 HW_COMPAT_2_8 \ 662 {\ 663 .driver = TYPE_S390_FLIC_COMMON,\ 664 .property = "adapter_routes_max_batch",\ 665 .value = "64",\ 666 }, 667 668 #define CCW_COMPAT_2_7 \ 669 HW_COMPAT_2_7 670 671 #define CCW_COMPAT_2_6 \ 672 HW_COMPAT_2_6 \ 673 {\ 674 .driver = TYPE_S390_IPL,\ 675 .property = "iplbext_migration",\ 676 .value = "off",\ 677 }, {\ 678 .driver = TYPE_VIRTUAL_CSS_BRIDGE,\ 679 .property = "css_dev_path",\ 680 .value = "off",\ 681 }, 682 683 #define CCW_COMPAT_2_5 \ 684 HW_COMPAT_2_5 685 686 #define CCW_COMPAT_2_4 \ 687 HW_COMPAT_2_4 \ 688 {\ 689 .driver = TYPE_S390_SKEYS,\ 690 .property = "migration-enabled",\ 691 .value = "off",\ 692 },{\ 693 .driver = "virtio-blk-ccw",\ 694 .property = "max_revision",\ 695 .value = "0",\ 696 },{\ 697 .driver = "virtio-balloon-ccw",\ 698 .property = "max_revision",\ 699 .value = "0",\ 700 },{\ 701 .driver = "virtio-serial-ccw",\ 702 .property = "max_revision",\ 703 .value = "0",\ 704 },{\ 705 .driver = "virtio-9p-ccw",\ 706 .property = "max_revision",\ 707 .value = "0",\ 708 },{\ 709 .driver = "virtio-rng-ccw",\ 710 .property = "max_revision",\ 711 .value = "0",\ 712 },{\ 713 .driver = "virtio-net-ccw",\ 714 .property = "max_revision",\ 715 .value = "0",\ 716 },{\ 717 .driver = "virtio-scsi-ccw",\ 718 .property = "max_revision",\ 719 .value = "0",\ 720 },{\ 721 .driver = "vhost-scsi-ccw",\ 722 .property = "max_revision",\ 723 .value = "0",\ 724 }, 725 726 static void ccw_machine_2_11_instance_options(MachineState *machine) 727 { 728 } 729 730 static void ccw_machine_2_11_class_options(MachineClass *mc) 731 { 732 } 733 DEFINE_CCW_MACHINE(2_11, "2.11", true); 734 735 static void ccw_machine_2_10_instance_options(MachineState *machine) 736 { 737 ccw_machine_2_11_instance_options(machine); 738 } 739 740 static void ccw_machine_2_10_class_options(MachineClass *mc) 741 { 742 ccw_machine_2_11_class_options(mc); 743 SET_MACHINE_COMPAT(mc, CCW_COMPAT_2_10); 744 } 745 DEFINE_CCW_MACHINE(2_10, "2.10", false); 746 747 static void ccw_machine_2_9_instance_options(MachineState *machine) 748 { 749 ccw_machine_2_10_instance_options(machine); 750 s390_cpudef_featoff_greater(12, 1, S390_FEAT_ESOP); 751 s390_cpudef_featoff_greater(12, 1, S390_FEAT_SIDE_EFFECT_ACCESS_ESOP2); 752 s390_cpudef_featoff_greater(12, 1, S390_FEAT_ZPCI); 753 s390_cpudef_featoff_greater(12, 1, S390_FEAT_ADAPTER_INT_SUPPRESSION); 754 s390_cpudef_featoff_greater(12, 1, S390_FEAT_ADAPTER_EVENT_NOTIFICATION); 755 } 756 757 static void ccw_machine_2_9_class_options(MachineClass *mc) 758 { 759 S390CcwMachineClass *s390mc = S390_MACHINE_CLASS(mc); 760 761 s390mc->gs_allowed = false; 762 ccw_machine_2_10_class_options(mc); 763 SET_MACHINE_COMPAT(mc, CCW_COMPAT_2_9); 764 s390mc->css_migration_enabled = false; 765 } 766 DEFINE_CCW_MACHINE(2_9, "2.9", false); 767 768 static void ccw_machine_2_8_instance_options(MachineState *machine) 769 { 770 ccw_machine_2_9_instance_options(machine); 771 } 772 773 static void ccw_machine_2_8_class_options(MachineClass *mc) 774 { 775 ccw_machine_2_9_class_options(mc); 776 SET_MACHINE_COMPAT(mc, CCW_COMPAT_2_8); 777 } 778 DEFINE_CCW_MACHINE(2_8, "2.8", false); 779 780 static void ccw_machine_2_7_instance_options(MachineState *machine) 781 { 782 ccw_machine_2_8_instance_options(machine); 783 } 784 785 static void ccw_machine_2_7_class_options(MachineClass *mc) 786 { 787 S390CcwMachineClass *s390mc = S390_MACHINE_CLASS(mc); 788 789 s390mc->cpu_model_allowed = false; 790 ccw_machine_2_8_class_options(mc); 791 SET_MACHINE_COMPAT(mc, CCW_COMPAT_2_7); 792 } 793 DEFINE_CCW_MACHINE(2_7, "2.7", false); 794 795 static void ccw_machine_2_6_instance_options(MachineState *machine) 796 { 797 ccw_machine_2_7_instance_options(machine); 798 } 799 800 static void ccw_machine_2_6_class_options(MachineClass *mc) 801 { 802 S390CcwMachineClass *s390mc = S390_MACHINE_CLASS(mc); 803 804 s390mc->ri_allowed = false; 805 ccw_machine_2_7_class_options(mc); 806 SET_MACHINE_COMPAT(mc, CCW_COMPAT_2_6); 807 } 808 DEFINE_CCW_MACHINE(2_6, "2.6", false); 809 810 static void ccw_machine_2_5_instance_options(MachineState *machine) 811 { 812 ccw_machine_2_6_instance_options(machine); 813 } 814 815 static void ccw_machine_2_5_class_options(MachineClass *mc) 816 { 817 ccw_machine_2_6_class_options(mc); 818 SET_MACHINE_COMPAT(mc, CCW_COMPAT_2_5); 819 } 820 DEFINE_CCW_MACHINE(2_5, "2.5", false); 821 822 static void ccw_machine_2_4_instance_options(MachineState *machine) 823 { 824 ccw_machine_2_5_instance_options(machine); 825 } 826 827 static void ccw_machine_2_4_class_options(MachineClass *mc) 828 { 829 ccw_machine_2_5_class_options(mc); 830 SET_MACHINE_COMPAT(mc, CCW_COMPAT_2_4); 831 } 832 DEFINE_CCW_MACHINE(2_4, "2.4", false); 833 834 static void ccw_machine_register_types(void) 835 { 836 type_register_static(&ccw_machine_info); 837 } 838 839 type_init(ccw_machine_register_types) 840