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