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