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