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