]> git.proxmox.com Git - mirror_qemu.git/blame - hw/s390x/s390-virtio-ccw.c
s390x/tod-kvm: don't save/restore the TOD in PV guests
[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
03d83ecf
JF
369 /* Will return 0 if API is not available since it's not vital */
370 rc = s390_pv_query_info();
371 if (rc) {
372 goto out_err;
373 }
374
c3347ed0
JF
375 /* Set SE header and unpack */
376 rc = s390_ipl_prepare_pv_header();
377 if (rc) {
378 goto out_err;
379 }
380
381 /* Decrypt image */
382 rc = s390_ipl_pv_unpack();
383 if (rc) {
384 goto out_err;
385 }
386
387 /* Verify integrity */
388 rc = s390_pv_verify();
389 if (rc) {
390 goto out_err;
391 }
392 return rc;
393
394out_err:
395 s390_machine_unprotect(ms);
396 return rc;
397}
398
c3347ed0
JF
399static void s390_pv_prepare_reset(S390CcwMachineState *ms)
400{
401 CPUState *cs;
402
403 if (!s390_is_pv()) {
404 return;
405 }
406 /* Unsharing requires all cpus to be stopped */
407 CPU_FOREACH(cs) {
408 s390_cpu_set_state(S390_CPU_STATE_STOPPED, S390_CPU(cs));
409 }
410 s390_pv_unshare();
9a432597 411 s390_pv_prep_reset();
c3347ed0
JF
412}
413
a0628599 414static void s390_machine_reset(MachineState *machine)
6286b419 415{
c3347ed0 416 S390CcwMachineState *ms = S390_CCW_MACHINE(machine);
a30fb811
DH
417 enum s390_reset reset_type;
418 CPUState *cs, *t;
c3347ed0 419 S390CPU *cpu;
6286b419 420
a30fb811
DH
421 /* get the reset parameters, reset them once done */
422 s390_ipl_get_reset_request(&cs, &reset_type);
423
424 /* all CPUs are paused and synchronized at this point */
6286b419 425 s390_cmma_reset();
6286b419 426
c3347ed0
JF
427 cpu = S390_CPU(cs);
428
a30fb811
DH
429 switch (reset_type) {
430 case S390_RESET_EXTERNAL:
431 case S390_RESET_REIPL:
c3347ed0
JF
432 if (s390_is_pv()) {
433 s390_machine_unprotect(ms);
434 }
435
a30fb811
DH
436 qemu_devices_reset();
437 s390_crypto_reset();
438
439 /* configure and start the ipl CPU only */
440 run_on_cpu(cs, s390_do_cpu_ipl, RUN_ON_CPU_NULL);
441 break;
442 case S390_RESET_MODIFIED_CLEAR:
c3347ed0
JF
443 /*
444 * Susbsystem reset needs to be done before we unshare memory
445 * and lose access to VIRTIO structures in guest memory.
446 */
447 subsystem_reset();
448 s390_crypto_reset();
449 s390_pv_prepare_reset(ms);
a30fb811
DH
450 CPU_FOREACH(t) {
451 run_on_cpu(t, s390_do_cpu_full_reset, RUN_ON_CPU_NULL);
452 }
a30fb811
DH
453 run_on_cpu(cs, s390_do_cpu_load_normal, RUN_ON_CPU_NULL);
454 break;
455 case S390_RESET_LOAD_NORMAL:
c3347ed0
JF
456 /*
457 * Susbsystem reset needs to be done before we unshare memory
458 * and lose access to VIRTIO structures in guest memory.
459 */
460 subsystem_reset();
461 s390_pv_prepare_reset(ms);
a30fb811 462 CPU_FOREACH(t) {
ec922733
JF
463 if (t == cs) {
464 continue;
465 }
a30fb811
DH
466 run_on_cpu(t, s390_do_cpu_reset, RUN_ON_CPU_NULL);
467 }
a30fb811 468 run_on_cpu(cs, s390_do_cpu_initial_reset, RUN_ON_CPU_NULL);
c3347ed0
JF
469 run_on_cpu(cs, s390_do_cpu_load_normal, RUN_ON_CPU_NULL);
470 break;
471 case S390_RESET_PV: /* Subcode 10 */
472 subsystem_reset();
473 s390_crypto_reset();
474
475 CPU_FOREACH(t) {
476 if (t == cs) {
477 continue;
478 }
479 run_on_cpu(t, s390_do_cpu_full_reset, RUN_ON_CPU_NULL);
480 }
481 run_on_cpu(cs, s390_do_cpu_reset, RUN_ON_CPU_NULL);
482
483 if (s390_machine_protect(ms)) {
fbc1384c 484 s390_pv_inject_reset_error(cs);
c3347ed0
JF
485 /*
486 * Continue after the diag308 so the guest knows something
487 * went wrong.
488 */
489 s390_cpu_set_state(S390_CPU_STATE_OPERATING, cpu);
490 return;
491 }
492
a30fb811
DH
493 run_on_cpu(cs, s390_do_cpu_load_normal, RUN_ON_CPU_NULL);
494 break;
495 default:
496 g_assert_not_reached();
497 }
e2c6cd56
CW
498
499 CPU_FOREACH(t) {
500 run_on_cpu(t, s390_do_cpu_set_diag318, RUN_ON_CPU_HOST_ULONG(0));
501 }
a30fb811 502 s390_ipl_clear_reset_request();
6286b419
DH
503}
504
502edbf8
MR
505static void s390_machine_device_plug(HotplugHandler *hotplug_dev,
506 DeviceState *dev, Error **errp)
507{
508 if (object_dynamic_cast(OBJECT(dev), TYPE_CPU)) {
509 s390_cpu_plug(hotplug_dev, dev, errp);
510 }
511}
512
f2f3beb0
DH
513static void s390_machine_device_unplug_request(HotplugHandler *hotplug_dev,
514 DeviceState *dev, Error **errp)
515{
516 if (object_dynamic_cast(OBJECT(dev), TYPE_CPU)) {
517 error_setg(errp, "CPU hot unplug not supported on this machine");
518 return;
519 }
520}
521
81ce6aa5 522static CpuInstanceProperties s390_cpu_index_to_props(MachineState *ms,
4dc3b151
DH
523 unsigned cpu_index)
524{
81ce6aa5
DH
525 MachineClass *mc = MACHINE_GET_CLASS(ms);
526 const CPUArchIdList *possible_cpus = mc->possible_cpu_arch_ids(ms);
4dc3b151 527
81ce6aa5
DH
528 assert(cpu_index < possible_cpus->len);
529 return possible_cpus->cpus[cpu_index].props;
4dc3b151
DH
530}
531
532static const CPUArchIdList *s390_possible_cpu_arch_ids(MachineState *ms)
533{
534 int i;
ae71ed86 535 unsigned int max_cpus = ms->smp.max_cpus;
4dc3b151
DH
536
537 if (ms->possible_cpus) {
538 g_assert(ms->possible_cpus && ms->possible_cpus->len == max_cpus);
539 return ms->possible_cpus;
540 }
541
542 ms->possible_cpus = g_malloc0(sizeof(CPUArchIdList) +
543 sizeof(CPUArchId) * max_cpus);
544 ms->possible_cpus->len = max_cpus;
545 for (i = 0; i < ms->possible_cpus->len; i++) {
d342eb76 546 ms->possible_cpus->cpus[i].type = ms->cpu_type;
4dc3b151
DH
547 ms->possible_cpus->cpus[i].vcpus_count = 1;
548 ms->possible_cpus->cpus[i].arch_id = i;
549 ms->possible_cpus->cpus[i].props.has_core_id = true;
550 ms->possible_cpus->cpus[i].props.core_id = i;
551 }
552
553 return ms->possible_cpus;
554}
555
502edbf8
MR
556static HotplugHandler *s390_get_hotplug_handler(MachineState *machine,
557 DeviceState *dev)
558{
559 if (object_dynamic_cast(OBJECT(dev), TYPE_CPU)) {
560 return HOTPLUG_HANDLER(machine);
561 }
562 return NULL;
563}
564
6286b419
DH
565static void s390_nmi(NMIState *n, int cpu_index, Error **errp)
566{
567 CPUState *cs = qemu_get_cpu(cpu_index);
568
0fc60ca5 569 s390_cpu_restart(S390_CPU(cs));
6286b419
DH
570}
571
5c30ef93
CB
572static ram_addr_t s390_fixup_ram_size(ram_addr_t sz)
573{
574 /* same logic as in sclp.c */
575 int increment_size = 20;
576 ram_addr_t newsz;
577
578 while ((sz >> increment_size) > MAX_STORAGE_INCREMENTS) {
579 increment_size++;
580 }
581 newsz = sz >> increment_size << increment_size;
582
583 if (sz != newsz) {
584 qemu_printf("Ram size %" PRIu64 "MB was fixed up to %" PRIu64
585 "MB to match machine restrictions. Consider updating "
586 "the guest definition.\n", (uint64_t) (sz / MiB),
587 (uint64_t) (newsz / MiB));
588 }
589 return newsz;
590}
591
d07aa7c7
AK
592static void ccw_machine_class_init(ObjectClass *oc, void *data)
593{
594 MachineClass *mc = MACHINE_CLASS(oc);
3dd7852f 595 NMIClass *nc = NMI_CLASS(oc);
502edbf8 596 HotplugHandlerClass *hc = HOTPLUG_HANDLER_CLASS(oc);
b1af5872 597 S390CcwMachineClass *s390mc = S390_CCW_MACHINE_CLASS(mc);
d07aa7c7 598
9700230b 599 s390mc->ri_allowed = true;
e73316d5 600 s390mc->cpu_model_allowed = true;
e996583e 601 s390mc->css_migration_enabled = true;
28221f9c 602 s390mc->hpage_1m_allowed = true;
d07aa7c7 603 mc->init = ccw_init;
db3b2566 604 mc->reset = s390_machine_reset;
d07aa7c7
AK
605 mc->block_default_type = IF_VIRTIO;
606 mc->no_cdrom = 1;
607 mc->no_floppy = 1;
d07aa7c7
AK
608 mc->no_parallel = 1;
609 mc->no_sdcard = 1;
f42dc44a 610 mc->max_cpus = S390_MAX_CPUS;
4dc3b151 611 mc->has_hotpluggable_cpus = true;
debbdc00 612 assert(!mc->get_hotplug_handler);
502edbf8 613 mc->get_hotplug_handler = s390_get_hotplug_handler;
4dc3b151
DH
614 mc->cpu_index_to_instance_props = s390_cpu_index_to_props;
615 mc->possible_cpu_arch_ids = s390_possible_cpu_arch_ids;
b6805e12
IM
616 /* it is overridden with 'host' cpu *in kvm_arch_init* */
617 mc->default_cpu_type = S390_CPU_TYPE_NAME("qemu");
502edbf8 618 hc->plug = s390_machine_device_plug;
f2f3beb0 619 hc->unplug_request = s390_machine_device_unplug_request;
3dd7852f 620 nc->nmi_monitor_handler = s390_nmi;
3a12fc61 621 mc->default_ram_id = "s390.ram";
d07aa7c7
AK
622}
623
2eb1cd07
TK
624static inline bool machine_get_aes_key_wrap(Object *obj, Error **errp)
625{
626 S390CcwMachineState *ms = S390_CCW_MACHINE(obj);
627
628 return ms->aes_key_wrap;
629}
630
631static inline void machine_set_aes_key_wrap(Object *obj, bool value,
632 Error **errp)
633{
634 S390CcwMachineState *ms = S390_CCW_MACHINE(obj);
635
636 ms->aes_key_wrap = value;
637}
638
639static inline bool machine_get_dea_key_wrap(Object *obj, Error **errp)
640{
641 S390CcwMachineState *ms = S390_CCW_MACHINE(obj);
642
643 return ms->dea_key_wrap;
644}
645
646static inline void machine_set_dea_key_wrap(Object *obj, bool value,
647 Error **errp)
648{
649 S390CcwMachineState *ms = S390_CCW_MACHINE(obj);
650
651 ms->dea_key_wrap = value;
652}
653
59d1ce44
MR
654static inline bool machine_get_zpcii_disable(Object *obj, Error **errp)
655{
656 S390CcwMachineState *ms = S390_CCW_MACHINE(obj);
657
658 return ms->zpcii_disable;
659}
660
661static inline void machine_set_zpcii_disable(Object *obj, bool value,
662 Error **errp)
663{
664 S390CcwMachineState *ms = S390_CCW_MACHINE(obj);
665
666 ms->zpcii_disable = value;
667}
668
cec8bbf7 669static S390CcwMachineClass *current_mc;
9700230b 670
3e0209bb
TH
671/*
672 * Get the class of the s390-ccw-virtio machine that is currently in use.
673 * Note: libvirt is using the "none" machine to probe for the features of the
674 * host CPU, so in case this is called with the "none" machine, the function
675 * returns the TYPE_S390_CCW_MACHINE base class. In this base class, all the
676 * various "*_allowed" variables are enabled, so that the *_allowed() wrappers
677 * below return the correct default value for the "none" machine.
678 *
679 * Attention! Do *not* add additional new wrappers for CPU features (e.g. like
680 * the ri_allowed() wrapper) via this mechanism anymore. CPU features should
681 * be handled via the CPU models, i.e. checking with cpu_model_allowed() during
682 * CPU initialization and s390_has_feat() later should be sufficient.
683 */
cec8bbf7
HP
684static S390CcwMachineClass *get_machine_class(void)
685{
686 if (unlikely(!current_mc)) {
392529cb 687 /*
cec8bbf7
HP
688 * No s390 ccw machine was instantiated, we are likely to
689 * be called for the 'none' machine. The properties will
690 * have their after-initialization values.
691 */
b1af5872 692 current_mc = S390_CCW_MACHINE_CLASS(
cec8bbf7 693 object_class_by_name(TYPE_S390_CCW_MACHINE));
9700230b 694 }
cec8bbf7 695 return current_mc;
9700230b
FZ
696}
697
cec8bbf7 698bool ri_allowed(void)
e73316d5 699{
cec8bbf7
HP
700 return get_machine_class()->ri_allowed;
701}
702
703bool cpu_model_allowed(void)
704{
cec8bbf7 705 return get_machine_class()->cpu_model_allowed;
e73316d5
CB
706}
707
28221f9c
JF
708bool hpage_1m_allowed(void)
709{
28221f9c
JF
710 return get_machine_class()->hpage_1m_allowed;
711}
712
7104bae9
FA
713static char *machine_get_loadparm(Object *obj, Error **errp)
714{
715 S390CcwMachineState *ms = S390_CCW_MACHINE(obj);
716
d6645483 717 /* make a NUL-terminated string */
148d25e0 718 return g_strndup((char *) ms->loadparm, sizeof(ms->loadparm));
7104bae9
FA
719}
720
721static void machine_set_loadparm(Object *obj, const char *val, Error **errp)
722{
723 S390CcwMachineState *ms = S390_CCW_MACHINE(obj);
724 int i;
725
726 for (i = 0; i < sizeof(ms->loadparm) && val[i]; i++) {
95a5befc 727 uint8_t c = qemu_toupper(val[i]); /* mimic HMC */
7104bae9
FA
728
729 if (('A' <= c && c <= 'Z') || ('0' <= c && c <= '9') || (c == '.') ||
730 (c == ' ')) {
731 ms->loadparm[i] = c;
732 } else {
733 error_setg(errp, "LOADPARM: invalid character '%c' (ASCII 0x%02x)",
734 c, c);
735 return;
736 }
737 }
738
739 for (; i < sizeof(ms->loadparm); i++) {
740 ms->loadparm[i] = ' '; /* pad right with spaces */
741 }
742}
2eb1cd07
TK
743static inline void s390_machine_initfn(Object *obj)
744{
745 object_property_add_bool(obj, "aes-key-wrap",
746 machine_get_aes_key_wrap,
d2623129 747 machine_set_aes_key_wrap);
2eb1cd07 748 object_property_set_description(obj, "aes-key-wrap",
7eecec7d 749 "enable/disable AES key wrapping using the CPACF wrapping key");
5325cc34 750 object_property_set_bool(obj, "aes-key-wrap", true, NULL);
2eb1cd07
TK
751
752 object_property_add_bool(obj, "dea-key-wrap",
753 machine_get_dea_key_wrap,
d2623129 754 machine_set_dea_key_wrap);
2eb1cd07 755 object_property_set_description(obj, "dea-key-wrap",
7eecec7d 756 "enable/disable DEA key wrapping using the CPACF wrapping key");
5325cc34 757 object_property_set_bool(obj, "dea-key-wrap", true, NULL);
7104bae9 758 object_property_add_str(obj, "loadparm",
d2623129 759 machine_get_loadparm, machine_set_loadparm);
7104bae9
FA
760 object_property_set_description(obj, "loadparm",
761 "Up to 8 chars in set of [A-Za-z0-9. ] (lower case chars converted"
762 " to upper case) to pass to machine loader, boot manager,"
7eecec7d 763 " and guest kernel");
59d1ce44
MR
764
765 object_property_add_bool(obj, "zpcii-disable",
766 machine_get_zpcii_disable,
767 machine_set_zpcii_disable);
768 object_property_set_description(obj, "zpcii-disable",
769 "disable zPCI interpretation facilties");
770 object_property_set_bool(obj, "zpcii-disable", false, NULL);
2eb1cd07
TK
771}
772
d07aa7c7
AK
773static const TypeInfo ccw_machine_info = {
774 .name = TYPE_S390_CCW_MACHINE,
775 .parent = TYPE_MACHINE,
c4d3c0a2 776 .abstract = true,
2eb1cd07
TK
777 .instance_size = sizeof(S390CcwMachineState),
778 .instance_init = s390_machine_initfn,
9700230b 779 .class_size = sizeof(S390CcwMachineClass),
d07aa7c7 780 .class_init = ccw_machine_class_init,
3dd7852f
AK
781 .interfaces = (InterfaceInfo[]) {
782 { TYPE_NMI },
502edbf8 783 { TYPE_HOTPLUG_HANDLER},
3dd7852f
AK
784 { }
785 },
a5c95808
CH
786};
787
52629b3b
HP
788bool css_migration_enabled(void)
789{
790 return get_machine_class()->css_migration_enabled;
791}
792
4fca6548
JF
793#define DEFINE_CCW_MACHINE(suffix, verstr, latest) \
794 static void ccw_machine_##suffix##_class_init(ObjectClass *oc, \
795 void *data) \
796 { \
797 MachineClass *mc = MACHINE_CLASS(oc); \
798 ccw_machine_##suffix##_class_options(mc); \
ec8c2936 799 mc->desc = "Virtual s390x machine (version " verstr ")"; \
4fca6548
JF
800 if (latest) { \
801 mc->alias = "s390-ccw-virtio"; \
ea0ac7f6 802 mc->is_default = true; \
4fca6548
JF
803 } \
804 } \
805 static void ccw_machine_##suffix##_instance_init(Object *obj) \
806 { \
807 MachineState *machine = MACHINE(obj); \
b1af5872 808 current_mc = S390_CCW_MACHINE_CLASS(MACHINE_GET_CLASS(machine)); \
4fca6548
JF
809 ccw_machine_##suffix##_instance_options(machine); \
810 } \
811 static const TypeInfo ccw_machine_##suffix##_info = { \
812 .name = MACHINE_TYPE_NAME("s390-ccw-virtio-" verstr), \
813 .parent = TYPE_S390_CCW_MACHINE, \
814 .class_init = ccw_machine_##suffix##_class_init, \
815 .instance_init = ccw_machine_##suffix##_instance_init, \
816 }; \
817 static void ccw_machine_register_##suffix(void) \
818 { \
819 type_register_static(&ccw_machine_##suffix##_info); \
820 } \
0e6aac87 821 type_init(ccw_machine_register_##suffix)
4fca6548 822
f514e147
CH
823static void ccw_machine_7_2_instance_options(MachineState *machine)
824{
825}
826
827static void ccw_machine_7_2_class_options(MachineClass *mc)
828{
829}
830DEFINE_CCW_MACHINE(7_2, "7.2", true);
831
0ca70366
CH
832static void ccw_machine_7_1_instance_options(MachineState *machine)
833{
9f17bfda 834 static const S390FeatInit qemu_cpu_feat = { S390_FEAT_LIST_QEMU_V7_1 };
59d1ce44 835 S390CcwMachineState *ms = S390_CCW_MACHINE(machine);
9f17bfda 836
f514e147 837 ccw_machine_7_2_instance_options(machine);
1d41de5f 838 s390_cpudef_featoff_greater(16, 1, S390_FEAT_PAIE);
9f17bfda 839 s390_set_qemu_cpu_model(0x8561, 15, 1, qemu_cpu_feat);
59d1ce44 840 ms->zpcii_disable = true;
0ca70366
CH
841}
842
843static void ccw_machine_7_1_class_options(MachineClass *mc)
844{
f514e147
CH
845 ccw_machine_7_2_class_options(mc);
846 compat_props_add(mc->compat_props, hw_compat_7_1, hw_compat_7_1_len);
0ca70366 847}
f514e147 848DEFINE_CCW_MACHINE(7_1, "7.1", false);
0ca70366 849
01854af2
CH
850static void ccw_machine_7_0_instance_options(MachineState *machine)
851{
4f9b6c7d
DM
852 static const S390FeatInit qemu_cpu_feat = { S390_FEAT_LIST_QEMU_V7_0 };
853
0ca70366 854 ccw_machine_7_1_instance_options(machine);
4f9b6c7d 855 s390_set_qemu_cpu_model(0x8561, 15, 1, qemu_cpu_feat);
01854af2
CH
856}
857
858static void ccw_machine_7_0_class_options(MachineClass *mc)
859{
0ca70366
CH
860 ccw_machine_7_1_class_options(mc);
861 compat_props_add(mc->compat_props, hw_compat_7_0, hw_compat_7_0_len);
01854af2 862}
0ca70366 863DEFINE_CCW_MACHINE(7_0, "7.0", false);
01854af2 864
52e64f5b
YW
865static void ccw_machine_6_2_instance_options(MachineState *machine)
866{
8a4eafb6
DM
867 static const S390FeatInit qemu_cpu_feat = { S390_FEAT_LIST_QEMU_V6_2 };
868
01854af2 869 ccw_machine_7_0_instance_options(machine);
8a4eafb6 870 s390_set_qemu_cpu_model(0x3906, 14, 2, qemu_cpu_feat);
52e64f5b
YW
871}
872
873static void ccw_machine_6_2_class_options(MachineClass *mc)
874{
01854af2
CH
875 ccw_machine_7_0_class_options(mc);
876 compat_props_add(mc->compat_props, hw_compat_6_2, hw_compat_6_2_len);
52e64f5b 877}
01854af2 878DEFINE_CCW_MACHINE(6_2, "6.2", false);
52e64f5b 879
da7e13c0
CH
880static void ccw_machine_6_1_instance_options(MachineState *machine)
881{
52e64f5b 882 ccw_machine_6_2_instance_options(machine);
30e398f7
CB
883 s390_cpudef_featoff_greater(16, 1, S390_FEAT_NNPA);
884 s390_cpudef_featoff_greater(16, 1, S390_FEAT_VECTOR_PACKED_DECIMAL_ENH2);
885 s390_cpudef_featoff_greater(16, 1, S390_FEAT_BEAR_ENH);
886 s390_cpudef_featoff_greater(16, 1, S390_FEAT_RDP);
887 s390_cpudef_featoff_greater(16, 1, S390_FEAT_PAI);
da7e13c0
CH
888}
889
890static void ccw_machine_6_1_class_options(MachineClass *mc)
891{
52e64f5b
YW
892 ccw_machine_6_2_class_options(mc);
893 compat_props_add(mc->compat_props, hw_compat_6_1, hw_compat_6_1_len);
2b526199 894 mc->smp_props.prefer_sockets = true;
da7e13c0 895}
52e64f5b 896DEFINE_CCW_MACHINE(6_1, "6.1", false);
da7e13c0 897
576a00bd
CH
898static void ccw_machine_6_0_instance_options(MachineState *machine)
899{
463e50da
DH
900 static const S390FeatInit qemu_cpu_feat = { S390_FEAT_LIST_QEMU_V6_0 };
901
da7e13c0 902 ccw_machine_6_1_instance_options(machine);
463e50da 903 s390_set_qemu_cpu_model(0x2964, 13, 2, qemu_cpu_feat);
576a00bd
CH
904}
905
906static void ccw_machine_6_0_class_options(MachineClass *mc)
907{
da7e13c0
CH
908 ccw_machine_6_1_class_options(mc);
909 compat_props_add(mc->compat_props, hw_compat_6_0, hw_compat_6_0_len);
576a00bd 910}
da7e13c0 911DEFINE_CCW_MACHINE(6_0, "6.0", false);
576a00bd 912
3ff3c5d3
CH
913static void ccw_machine_5_2_instance_options(MachineState *machine)
914{
576a00bd 915 ccw_machine_6_0_instance_options(machine);
3ff3c5d3
CH
916}
917
918static void ccw_machine_5_2_class_options(MachineClass *mc)
919{
576a00bd
CH
920 ccw_machine_6_0_class_options(mc);
921 compat_props_add(mc->compat_props, hw_compat_5_2, hw_compat_5_2_len);
3ff3c5d3 922}
576a00bd 923DEFINE_CCW_MACHINE(5_2, "5.2", false);
3ff3c5d3 924
541aaa1d
CH
925static void ccw_machine_5_1_instance_options(MachineState *machine)
926{
3ff3c5d3 927 ccw_machine_5_2_instance_options(machine);
541aaa1d
CH
928}
929
930static void ccw_machine_5_1_class_options(MachineClass *mc)
931{
3ff3c5d3
CH
932 ccw_machine_5_2_class_options(mc);
933 compat_props_add(mc->compat_props, hw_compat_5_1, hw_compat_5_1_len);
541aaa1d 934}
3ff3c5d3 935DEFINE_CCW_MACHINE(5_1, "5.1", false);
541aaa1d 936
3eb74d20
CH
937static void ccw_machine_5_0_instance_options(MachineState *machine)
938{
541aaa1d 939 ccw_machine_5_1_instance_options(machine);
3eb74d20
CH
940}
941
942static void ccw_machine_5_0_class_options(MachineClass *mc)
943{
541aaa1d
CH
944 ccw_machine_5_1_class_options(mc);
945 compat_props_add(mc->compat_props, hw_compat_5_0, hw_compat_5_0_len);
3eb74d20 946}
541aaa1d 947DEFINE_CCW_MACHINE(5_0, "5.0", false);
3eb74d20 948
9aec2e52
CH
949static void ccw_machine_4_2_instance_options(MachineState *machine)
950{
3eb74d20 951 ccw_machine_5_0_instance_options(machine);
9aec2e52
CH
952}
953
954static void ccw_machine_4_2_class_options(MachineClass *mc)
955{
3eb74d20 956 ccw_machine_5_0_class_options(mc);
5c30ef93 957 mc->fixup_ram_size = s390_fixup_ram_size;
5f258577 958 compat_props_add(mc->compat_props, hw_compat_4_2, hw_compat_4_2_len);
9aec2e52 959}
3eb74d20 960DEFINE_CCW_MACHINE(4_2, "4.2", false);
9aec2e52 961
9bf2650b
CH
962static void ccw_machine_4_1_instance_options(MachineState *machine)
963{
faa40177 964 static const S390FeatInit qemu_cpu_feat = { S390_FEAT_LIST_QEMU_V4_1 };
9aec2e52 965 ccw_machine_4_2_instance_options(machine);
faa40177 966 s390_set_qemu_cpu_model(0x2964, 13, 2, qemu_cpu_feat);
9bf2650b
CH
967}
968
969static void ccw_machine_4_1_class_options(MachineClass *mc)
970{
9aec2e52
CH
971 ccw_machine_4_2_class_options(mc);
972 compat_props_add(mc->compat_props, hw_compat_4_1, hw_compat_4_1_len);
9bf2650b 973}
9aec2e52 974DEFINE_CCW_MACHINE(4_1, "4.1", false);
9bf2650b 975
8c7b0c73
CH
976static void ccw_machine_4_0_instance_options(MachineState *machine)
977{
08ef92d5 978 static const S390FeatInit qemu_cpu_feat = { S390_FEAT_LIST_QEMU_V4_0 };
9bf2650b 979 ccw_machine_4_1_instance_options(machine);
08ef92d5 980 s390_set_qemu_cpu_model(0x2827, 12, 2, qemu_cpu_feat);
8c7b0c73
CH
981}
982
983static void ccw_machine_4_0_class_options(MachineClass *mc)
984{
9bf2650b
CH
985 ccw_machine_4_1_class_options(mc);
986 compat_props_add(mc->compat_props, hw_compat_4_0, hw_compat_4_0_len);
8c7b0c73 987}
9bf2650b 988DEFINE_CCW_MACHINE(4_0, "4.0", false);
8c7b0c73 989
9ca056d6
CH
990static void ccw_machine_3_1_instance_options(MachineState *machine)
991{
d646b16b 992 static const S390FeatInit qemu_cpu_feat = { S390_FEAT_LIST_QEMU_V3_1 };
8c7b0c73 993 ccw_machine_4_0_instance_options(machine);
84176c79
CW
994 s390_cpudef_featoff_greater(14, 1, S390_FEAT_MULTIPLE_EPOCH);
995 s390_cpudef_group_featoff_greater(14, 1, S390_FEAT_GROUP_MULTIPLE_EPOCH_PTFF);
d646b16b 996 s390_set_qemu_cpu_model(0x2827, 12, 2, qemu_cpu_feat);
9ca056d6
CH
997}
998
999static void ccw_machine_3_1_class_options(MachineClass *mc)
1000{
8c7b0c73 1001 ccw_machine_4_0_class_options(mc);
abd93cc7 1002 compat_props_add(mc->compat_props, hw_compat_3_1, hw_compat_3_1_len);
9ca056d6 1003}
8c7b0c73 1004DEFINE_CCW_MACHINE(3_1, "3.1", false);
9ca056d6 1005
2c5a2eef 1006static void ccw_machine_3_0_instance_options(MachineState *machine)
7a9cb3ad 1007{
9ca056d6 1008 ccw_machine_3_1_instance_options(machine);
7a9cb3ad
CH
1009}
1010
2c5a2eef 1011static void ccw_machine_3_0_class_options(MachineClass *mc)
7a9cb3ad 1012{
b1af5872 1013 S390CcwMachineClass *s390mc = S390_CCW_MACHINE_CLASS(mc);
28221f9c
JF
1014
1015 s390mc->hpage_1m_allowed = false;
9ca056d6 1016 ccw_machine_3_1_class_options(mc);
ddb3235d 1017 compat_props_add(mc->compat_props, hw_compat_3_0, hw_compat_3_0_len);
7a9cb3ad 1018}
9ca056d6 1019DEFINE_CCW_MACHINE(3_0, "3.0", false);
7a9cb3ad 1020
67ee0cef
CH
1021static void ccw_machine_2_12_instance_options(MachineState *machine)
1022{
2c5a2eef 1023 ccw_machine_3_0_instance_options(machine);
87273151
CB
1024 s390_cpudef_featoff_greater(11, 1, S390_FEAT_PPA15);
1025 s390_cpudef_featoff_greater(11, 1, S390_FEAT_BPB);
67ee0cef
CH
1026}
1027
1028static void ccw_machine_2_12_class_options(MachineClass *mc)
1029{
2c5a2eef 1030 ccw_machine_3_0_class_options(mc);
0d47310b 1031 compat_props_add(mc->compat_props, hw_compat_2_12, hw_compat_2_12_len);
67ee0cef 1032}
7a9cb3ad 1033DEFINE_CCW_MACHINE(2_12, "2.12", false);
67ee0cef 1034
70d8d9a0
CH
1035static void ccw_machine_2_11_instance_options(MachineState *machine)
1036{
35b4df64 1037 static const S390FeatInit qemu_cpu_feat = { S390_FEAT_LIST_QEMU_V2_11 };
67ee0cef 1038 ccw_machine_2_12_instance_options(machine);
35b4df64
DH
1039
1040 /* before 2.12 we emulated the very first z900 */
1041 s390_set_qemu_cpu_model(0x2064, 7, 1, qemu_cpu_feat);
70d8d9a0
CH
1042}
1043
1044static void ccw_machine_2_11_class_options(MachineClass *mc)
1045{
88cbe073 1046 static GlobalProperty compat[] = {
6c36bddf 1047 { TYPE_SCLP_EVENT_FACILITY, "allow_all_mask_sizes", "off", },
88cbe073
MAL
1048 };
1049
67ee0cef 1050 ccw_machine_2_12_class_options(mc);
43df70a9 1051 compat_props_add(mc->compat_props, hw_compat_2_11, hw_compat_2_11_len);
88cbe073 1052 compat_props_add(mc->compat_props, compat, G_N_ELEMENTS(compat));
70d8d9a0 1053}
67ee0cef 1054DEFINE_CCW_MACHINE(2_11, "2.11", false);
70d8d9a0 1055
10890873
CH
1056static void ccw_machine_2_10_instance_options(MachineState *machine)
1057{
70d8d9a0 1058 ccw_machine_2_11_instance_options(machine);
10890873
CH
1059}
1060
1061static void ccw_machine_2_10_class_options(MachineClass *mc)
1062{
70d8d9a0 1063 ccw_machine_2_11_class_options(mc);
503224f4 1064 compat_props_add(mc->compat_props, hw_compat_2_10, hw_compat_2_10_len);
10890873 1065}
70d8d9a0 1066DEFINE_CCW_MACHINE(2_10, "2.10", false);
10890873 1067
113725a6
CH
1068static void ccw_machine_2_9_instance_options(MachineState *machine)
1069{
10890873 1070 ccw_machine_2_10_instance_options(machine);
7223bcce
JH
1071 s390_cpudef_featoff_greater(12, 1, S390_FEAT_ESOP);
1072 s390_cpudef_featoff_greater(12, 1, S390_FEAT_SIDE_EFFECT_ACCESS_ESOP2);
3b00f702
YMZ
1073 s390_cpudef_featoff_greater(12, 1, S390_FEAT_ZPCI);
1074 s390_cpudef_featoff_greater(12, 1, S390_FEAT_ADAPTER_INT_SUPPRESSION);
1075 s390_cpudef_featoff_greater(12, 1, S390_FEAT_ADAPTER_EVENT_NOTIFICATION);
113725a6
CH
1076}
1077
1078static void ccw_machine_2_9_class_options(MachineClass *mc)
1079{
b1af5872 1080 S390CcwMachineClass *s390mc = S390_CCW_MACHINE_CLASS(mc);
88cbe073 1081 static GlobalProperty compat[] = {
6c36bddf 1082 { TYPE_S390_STATTRIB, "migration-enabled", "off", },
88cbe073 1083 };
52629b3b 1084
10890873 1085 ccw_machine_2_10_class_options(mc);
3e803152 1086 compat_props_add(mc->compat_props, hw_compat_2_9, hw_compat_2_9_len);
88cbe073 1087 compat_props_add(mc->compat_props, compat, G_N_ELEMENTS(compat));
52629b3b 1088 s390mc->css_migration_enabled = false;
113725a6 1089}
10890873 1090DEFINE_CCW_MACHINE(2_9, "2.9", false);
113725a6 1091
61823988
CH
1092static void ccw_machine_2_8_instance_options(MachineState *machine)
1093{
113725a6 1094 ccw_machine_2_9_instance_options(machine);
61823988
CH
1095}
1096
1097static void ccw_machine_2_8_class_options(MachineClass *mc)
1098{
88cbe073 1099 static GlobalProperty compat[] = {
6c36bddf 1100 { TYPE_S390_FLIC_COMMON, "adapter_routes_max_batch", "64", },
88cbe073
MAL
1101 };
1102
113725a6 1103 ccw_machine_2_9_class_options(mc);
edc24ccd 1104 compat_props_add(mc->compat_props, hw_compat_2_8, hw_compat_2_8_len);
88cbe073 1105 compat_props_add(mc->compat_props, compat, G_N_ELEMENTS(compat));
61823988 1106}
113725a6 1107DEFINE_CCW_MACHINE(2_8, "2.8", false);
61823988 1108
946e55f3
CH
1109static void ccw_machine_2_7_instance_options(MachineState *machine)
1110{
61823988 1111 ccw_machine_2_8_instance_options(machine);
946e55f3
CH
1112}
1113
1114static void ccw_machine_2_7_class_options(MachineClass *mc)
1115{
b1af5872 1116 S390CcwMachineClass *s390mc = S390_CCW_MACHINE_CLASS(mc);
e73316d5
CB
1117
1118 s390mc->cpu_model_allowed = false;
61823988 1119 ccw_machine_2_8_class_options(mc);
5a995064 1120 compat_props_add(mc->compat_props, hw_compat_2_7, hw_compat_2_7_len);
946e55f3 1121}
61823988 1122DEFINE_CCW_MACHINE(2_7, "2.7", false);
946e55f3 1123
4fca6548 1124static void ccw_machine_2_6_instance_options(MachineState *machine)
c4d3c0a2 1125{
946e55f3 1126 ccw_machine_2_7_instance_options(machine);
c4d3c0a2
CB
1127}
1128
4fca6548 1129static void ccw_machine_2_6_class_options(MachineClass *mc)
84b48ad6 1130{
b1af5872 1131 S390CcwMachineClass *s390mc = S390_CCW_MACHINE_CLASS(mc);
88cbe073 1132 static GlobalProperty compat[] = {
6c36bddf
EH
1133 { TYPE_S390_IPL, "iplbext_migration", "off", },
1134 { TYPE_VIRTUAL_CSS_BRIDGE, "css_dev_path", "off", },
88cbe073 1135 };
9700230b
FZ
1136
1137 s390mc->ri_allowed = false;
946e55f3 1138 ccw_machine_2_7_class_options(mc);
ff8f261f 1139 compat_props_add(mc->compat_props, hw_compat_2_6, hw_compat_2_6_len);
88cbe073 1140 compat_props_add(mc->compat_props, compat, G_N_ELEMENTS(compat));
84b48ad6 1141}
946e55f3 1142DEFINE_CCW_MACHINE(2_6, "2.6", false);
84b48ad6 1143
4fca6548
JF
1144static void ccw_machine_2_5_instance_options(MachineState *machine)
1145{
946e55f3 1146 ccw_machine_2_6_instance_options(machine);
4fca6548 1147}
84b48ad6 1148
4fca6548 1149static void ccw_machine_2_5_class_options(MachineClass *mc)
b21b7598 1150{
946e55f3 1151 ccw_machine_2_6_class_options(mc);
fe759610 1152 compat_props_add(mc->compat_props, hw_compat_2_5, hw_compat_2_5_len);
4fca6548
JF
1153}
1154DEFINE_CCW_MACHINE(2_5, "2.5", false);
b21b7598 1155
4fca6548
JF
1156static void ccw_machine_2_4_instance_options(MachineState *machine)
1157{
1158 ccw_machine_2_5_instance_options(machine);
b21b7598
CH
1159}
1160
4fca6548
JF
1161static void ccw_machine_2_4_class_options(MachineClass *mc)
1162{
88cbe073 1163 static GlobalProperty compat[] = {
6c36bddf
EH
1164 { TYPE_S390_SKEYS, "migration-enabled", "off", },
1165 { "virtio-blk-ccw", "max_revision", "0", },
1166 { "virtio-balloon-ccw", "max_revision", "0", },
1167 { "virtio-serial-ccw", "max_revision", "0", },
1168 { "virtio-9p-ccw", "max_revision", "0", },
1169 { "virtio-rng-ccw", "max_revision", "0", },
1170 { "virtio-net-ccw", "max_revision", "0", },
1171 { "virtio-scsi-ccw", "max_revision", "0", },
1172 { "vhost-scsi-ccw", "max_revision", "0", },
88cbe073
MAL
1173 };
1174
946e55f3 1175 ccw_machine_2_5_class_options(mc);
2f99b9c2 1176 compat_props_add(mc->compat_props, hw_compat_2_4, hw_compat_2_4_len);
88cbe073 1177 compat_props_add(mc->compat_props, compat, G_N_ELEMENTS(compat));
4fca6548
JF
1178}
1179DEFINE_CCW_MACHINE(2_4, "2.4", false);
b21b7598 1180
d07aa7c7 1181static void ccw_machine_register_types(void)
a5c95808 1182{
d07aa7c7 1183 type_register_static(&ccw_machine_info);
a5c95808
CH
1184}
1185
d07aa7c7 1186type_init(ccw_machine_register_types)