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