4 * Copyright 2012, 2020 IBM Corp.
5 * Copyright (c) 2009 Alexander Graf <agraf@suse.de>
6 * Author(s): Cornelia Huck <cornelia.huck@de.ibm.com>
7 * Janosch Frank <frankja@linux.ibm.com>
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
14 #include "qemu/osdep.h"
15 #include "qapi/error.h"
17 #include "hw/boards.h"
18 #include "exec/address-spaces.h"
19 #include "exec/ram_addr.h"
20 #include "hw/s390x/s390-virtio-hcall.h"
21 #include "hw/s390x/sclp.h"
22 #include "hw/s390x/s390_flic.h"
23 #include "hw/s390x/ioinst.h"
24 #include "hw/s390x/css.h"
25 #include "virtio-ccw.h"
26 #include "qemu/config-file.h"
27 #include "qemu/ctype.h"
28 #include "qemu/error-report.h"
29 #include "qemu/option.h"
30 #include "qemu/qemu-print.h"
31 #include "s390-pci-bus.h"
32 #include "sysemu/reset.h"
33 #include "hw/s390x/storage-keys.h"
34 #include "hw/s390x/storage-attributes.h"
35 #include "hw/s390x/event-facility.h"
37 #include "hw/s390x/s390-virtio-ccw.h"
38 #include "hw/s390x/css-bridge.h"
39 #include "hw/s390x/ap-bridge.h"
40 #include "migration/register.h"
41 #include "cpu_models.h"
43 #include "hw/qdev-properties.h"
44 #include "hw/s390x/tod.h"
45 #include "sysemu/sysemu.h"
46 #include "sysemu/balloon.h"
47 #include "hw/s390x/pv.h"
48 #include "migration/blocker.h"
50 static Error
*pv_mig_blocker
;
52 S390CPU
*s390_cpu_addr2state(uint16_t cpu_addr
)
54 static MachineState
*ms
;
57 ms
= MACHINE(qdev_get_machine());
58 g_assert(ms
->possible_cpus
);
61 /* CPU address corresponds to the core_id and the index */
62 if (cpu_addr
>= ms
->possible_cpus
->len
) {
65 return S390_CPU(ms
->possible_cpus
->cpus
[cpu_addr
].cpu
);
68 static S390CPU
*s390x_new_cpu(const char *typename
, uint32_t core_id
,
71 S390CPU
*cpu
= S390_CPU(object_new(typename
));
74 object_property_set_int(OBJECT(cpu
), core_id
, "core-id", &err
);
78 object_property_set_bool(OBJECT(cpu
), true, "realized", &err
);
81 object_unref(OBJECT(cpu
));
83 error_propagate(errp
, err
);
89 static void s390_init_cpus(MachineState
*machine
)
91 MachineClass
*mc
= MACHINE_GET_CLASS(machine
);
94 /* initialize possible_cpus */
95 mc
->possible_cpu_arch_ids(machine
);
97 for (i
= 0; i
< machine
->smp
.cpus
; i
++) {
98 s390x_new_cpu(machine
->cpu_type
, i
, &error_fatal
);
102 static const char *const reset_dev_types
[] = {
103 TYPE_VIRTUAL_CSS_BRIDGE
,
104 "s390-sclp-event-facility",
109 static void subsystem_reset(void)
114 for (i
= 0; i
< ARRAY_SIZE(reset_dev_types
); i
++) {
115 dev
= DEVICE(object_resolve_path_type("", reset_dev_types
[i
], NULL
));
122 static int virtio_ccw_hcall_notify(const uint64_t *args
)
124 uint64_t subch_id
= args
[0];
125 uint64_t queue
= args
[1];
127 int cssid
, ssid
, schid
, m
;
129 if (ioinst_disassemble_sch_ident(subch_id
, &m
, &cssid
, &ssid
, &schid
)) {
132 sch
= css_find_subch(m
, cssid
, ssid
, schid
);
133 if (!sch
|| !css_subch_visible(sch
)) {
136 if (queue
>= VIRTIO_QUEUE_MAX
) {
139 virtio_queue_notify(virtio_ccw_get_vdev(sch
), queue
);
144 static int virtio_ccw_hcall_early_printk(const uint64_t *args
)
146 uint64_t mem
= args
[0];
148 if (mem
< ram_size
) {
155 static void virtio_ccw_register_hcalls(void)
157 s390_register_virtio_hypercall(KVM_S390_VIRTIO_CCW_NOTIFY
,
158 virtio_ccw_hcall_notify
);
159 /* Tolerate early printk. */
160 s390_register_virtio_hypercall(KVM_S390_VIRTIO_NOTIFY
,
161 virtio_ccw_hcall_early_printk
);
164 static void s390_memory_init(MemoryRegion
*ram
)
166 MemoryRegion
*sysmem
= get_system_memory();
167 Error
*local_err
= NULL
;
169 /* allocate RAM for core */
170 memory_region_add_subregion(sysmem
, 0, ram
);
173 * Configure the maximum page size. As no memory devices were created
174 * yet, this is the page size of initial memory only.
176 s390_set_max_pagesize(qemu_maxrampagesize(), &local_err
);
178 error_report_err(local_err
);
181 /* Initialize storage key device */
183 /* Initialize storage attributes device */
184 s390_stattrib_init();
187 static void s390_init_ipl_dev(const char *kernel_filename
,
188 const char *kernel_cmdline
,
189 const char *initrd_filename
, const char *firmware
,
190 const char *netboot_fw
, bool enforce_bios
)
192 Object
*new = object_new(TYPE_S390_IPL
);
193 DeviceState
*dev
= DEVICE(new);
194 char *netboot_fw_prop
;
196 if (kernel_filename
) {
197 qdev_prop_set_string(dev
, "kernel", kernel_filename
);
199 if (initrd_filename
) {
200 qdev_prop_set_string(dev
, "initrd", initrd_filename
);
202 qdev_prop_set_string(dev
, "cmdline", kernel_cmdline
);
203 qdev_prop_set_string(dev
, "firmware", firmware
);
204 qdev_prop_set_bit(dev
, "enforce_bios", enforce_bios
);
205 netboot_fw_prop
= object_property_get_str(new, "netboot_fw", &error_abort
);
206 if (!strlen(netboot_fw_prop
)) {
207 qdev_prop_set_string(dev
, "netboot_fw", netboot_fw
);
209 g_free(netboot_fw_prop
);
210 object_property_add_child(qdev_get_machine(), TYPE_S390_IPL
,
213 qdev_init_nofail(dev
);
216 static void s390_create_virtio_net(BusState
*bus
, const char *name
)
220 for (i
= 0; i
< nb_nics
; i
++) {
221 NICInfo
*nd
= &nd_table
[i
];
225 nd
->model
= g_strdup("virtio");
228 qemu_check_nic_model(nd
, "virtio");
230 dev
= qdev_create(bus
, name
);
231 qdev_set_nic_properties(dev
, nd
);
232 qdev_init_nofail(dev
);
236 static void s390_create_sclpconsole(const char *type
, Chardev
*chardev
)
240 dev
= qdev_create(sclp_get_event_facility_bus(), type
);
241 qdev_prop_set_chr(dev
, "chardev", chardev
);
242 qdev_init_nofail(dev
);
245 static void ccw_init(MachineState
*machine
)
248 VirtualCssBus
*css_bus
;
252 /* init memory + setup max page size. Required for the CPU model */
253 s390_memory_init(machine
->ram
);
255 /* init CPUs (incl. CPU model) early so s390_has_feature() works */
256 s390_init_cpus(machine
);
260 /* init the SIGP facility */
263 /* create AP bridge and bus(es) */
267 css_bus
= virtual_css_bus_init();
268 s390_init_ipl_dev(machine
->kernel_filename
, machine
->kernel_cmdline
,
269 machine
->initrd_filename
, "s390-ccw.img",
270 "s390-netboot.img", true);
272 dev
= qdev_create(NULL
, TYPE_S390_PCI_HOST_BRIDGE
);
273 object_property_add_child(qdev_get_machine(), TYPE_S390_PCI_HOST_BRIDGE
,
275 qdev_init_nofail(dev
);
277 /* register hypercalls */
278 virtio_ccw_register_hcalls();
280 s390_enable_css_support(s390_cpu_addr2state(0));
282 ret
= css_create_css_image(VIRTUAL_CSSID
, true);
285 if (css_migration_enabled()) {
286 css_register_vmstate();
289 /* Create VirtIO network adapters */
290 s390_create_virtio_net(BUS(css_bus
), "virtio-net-ccw");
294 s390_create_sclpconsole("sclpconsole", serial_hd(0));
297 s390_create_sclpconsole("sclplmconsole", serial_hd(1));
300 /* init the TOD clock */
304 static void s390_cpu_plug(HotplugHandler
*hotplug_dev
,
305 DeviceState
*dev
, Error
**errp
)
307 MachineState
*ms
= MACHINE(hotplug_dev
);
308 S390CPU
*cpu
= S390_CPU(dev
);
310 g_assert(!ms
->possible_cpus
->cpus
[cpu
->env
.core_id
].cpu
);
311 ms
->possible_cpus
->cpus
[cpu
->env
.core_id
].cpu
= OBJECT(dev
);
313 if (dev
->hotplugged
) {
314 raise_irq_cpu_hotplug();
318 static inline void s390_do_cpu_ipl(CPUState
*cs
, run_on_cpu_data arg
)
320 S390CPU
*cpu
= S390_CPU(cs
);
322 s390_ipl_prepare_cpu(cpu
);
323 s390_cpu_set_state(S390_CPU_STATE_OPERATING
, cpu
);
326 static void s390_machine_unprotect(S390CcwMachineState
*ms
)
328 s390_pv_vm_disable();
330 migrate_del_blocker(pv_mig_blocker
);
331 error_free_or_abort(&pv_mig_blocker
);
332 qemu_balloon_inhibit(false);
335 static int s390_machine_protect(S390CcwMachineState
*ms
)
337 Error
*local_err
= NULL
;
341 * Ballooning on protected VMs needs support in the guest for
342 * sharing and unsharing balloon pages. Block ballooning for
343 * now, until we have a solution to make at least Linux guests
344 * either support it or fail gracefully.
346 qemu_balloon_inhibit(true);
347 error_setg(&pv_mig_blocker
,
348 "protected VMs are currently not migrateable.");
349 rc
= migrate_add_blocker(pv_mig_blocker
, &local_err
);
351 qemu_balloon_inhibit(false);
352 error_report_err(local_err
);
353 error_free_or_abort(&pv_mig_blocker
);
358 rc
= s390_pv_vm_enable();
360 qemu_balloon_inhibit(false);
361 migrate_del_blocker(pv_mig_blocker
);
362 error_free_or_abort(&pv_mig_blocker
);
368 /* Set SE header and unpack */
369 rc
= s390_ipl_prepare_pv_header();
375 rc
= s390_ipl_pv_unpack();
380 /* Verify integrity */
381 rc
= s390_pv_verify();
388 s390_machine_unprotect(ms
);
392 static void s390_pv_prepare_reset(S390CcwMachineState
*ms
)
399 /* Unsharing requires all cpus to be stopped */
401 s390_cpu_set_state(S390_CPU_STATE_STOPPED
, S390_CPU(cs
));
404 s390_pv_perf_clear_reset();
407 static void s390_machine_reset(MachineState
*machine
)
409 S390CcwMachineState
*ms
= S390_CCW_MACHINE(machine
);
410 enum s390_reset reset_type
;
414 /* get the reset parameters, reset them once done */
415 s390_ipl_get_reset_request(&cs
, &reset_type
);
417 /* all CPUs are paused and synchronized at this point */
422 switch (reset_type
) {
423 case S390_RESET_EXTERNAL
:
424 case S390_RESET_REIPL
:
426 s390_machine_unprotect(ms
);
429 qemu_devices_reset();
432 /* configure and start the ipl CPU only */
433 run_on_cpu(cs
, s390_do_cpu_ipl
, RUN_ON_CPU_NULL
);
435 case S390_RESET_MODIFIED_CLEAR
:
437 * Susbsystem reset needs to be done before we unshare memory
438 * and lose access to VIRTIO structures in guest memory.
442 s390_pv_prepare_reset(ms
);
444 run_on_cpu(t
, s390_do_cpu_full_reset
, RUN_ON_CPU_NULL
);
446 run_on_cpu(cs
, s390_do_cpu_load_normal
, RUN_ON_CPU_NULL
);
448 case S390_RESET_LOAD_NORMAL
:
450 * Susbsystem reset needs to be done before we unshare memory
451 * and lose access to VIRTIO structures in guest memory.
454 s390_pv_prepare_reset(ms
);
459 run_on_cpu(t
, s390_do_cpu_reset
, RUN_ON_CPU_NULL
);
461 run_on_cpu(cs
, s390_do_cpu_initial_reset
, RUN_ON_CPU_NULL
);
462 run_on_cpu(cs
, s390_do_cpu_load_normal
, RUN_ON_CPU_NULL
);
464 case S390_RESET_PV
: /* Subcode 10 */
472 run_on_cpu(t
, s390_do_cpu_full_reset
, RUN_ON_CPU_NULL
);
474 run_on_cpu(cs
, s390_do_cpu_reset
, RUN_ON_CPU_NULL
);
476 if (s390_machine_protect(ms
)) {
477 s390_pv_inject_reset_error(cs
);
479 * Continue after the diag308 so the guest knows something
482 s390_cpu_set_state(S390_CPU_STATE_OPERATING
, cpu
);
486 run_on_cpu(cs
, s390_do_cpu_load_normal
, RUN_ON_CPU_NULL
);
489 g_assert_not_reached();
491 s390_ipl_clear_reset_request();
494 static void s390_machine_device_plug(HotplugHandler
*hotplug_dev
,
495 DeviceState
*dev
, Error
**errp
)
497 if (object_dynamic_cast(OBJECT(dev
), TYPE_CPU
)) {
498 s390_cpu_plug(hotplug_dev
, dev
, errp
);
502 static void s390_machine_device_unplug_request(HotplugHandler
*hotplug_dev
,
503 DeviceState
*dev
, Error
**errp
)
505 if (object_dynamic_cast(OBJECT(dev
), TYPE_CPU
)) {
506 error_setg(errp
, "CPU hot unplug not supported on this machine");
511 static CpuInstanceProperties
s390_cpu_index_to_props(MachineState
*ms
,
514 MachineClass
*mc
= MACHINE_GET_CLASS(ms
);
515 const CPUArchIdList
*possible_cpus
= mc
->possible_cpu_arch_ids(ms
);
517 assert(cpu_index
< possible_cpus
->len
);
518 return possible_cpus
->cpus
[cpu_index
].props
;
521 static const CPUArchIdList
*s390_possible_cpu_arch_ids(MachineState
*ms
)
524 unsigned int max_cpus
= ms
->smp
.max_cpus
;
526 if (ms
->possible_cpus
) {
527 g_assert(ms
->possible_cpus
&& ms
->possible_cpus
->len
== max_cpus
);
528 return ms
->possible_cpus
;
531 ms
->possible_cpus
= g_malloc0(sizeof(CPUArchIdList
) +
532 sizeof(CPUArchId
) * max_cpus
);
533 ms
->possible_cpus
->len
= max_cpus
;
534 for (i
= 0; i
< ms
->possible_cpus
->len
; i
++) {
535 ms
->possible_cpus
->cpus
[i
].type
= ms
->cpu_type
;
536 ms
->possible_cpus
->cpus
[i
].vcpus_count
= 1;
537 ms
->possible_cpus
->cpus
[i
].arch_id
= i
;
538 ms
->possible_cpus
->cpus
[i
].props
.has_core_id
= true;
539 ms
->possible_cpus
->cpus
[i
].props
.core_id
= i
;
542 return ms
->possible_cpus
;
545 static HotplugHandler
*s390_get_hotplug_handler(MachineState
*machine
,
548 if (object_dynamic_cast(OBJECT(dev
), TYPE_CPU
)) {
549 return HOTPLUG_HANDLER(machine
);
554 static void s390_hot_add_cpu(MachineState
*machine
,
555 const int64_t id
, Error
**errp
)
559 g_assert(machine
->possible_cpus
->cpus
[0].cpu
);
560 oc
= OBJECT_CLASS(CPU_GET_CLASS(machine
->possible_cpus
->cpus
[0].cpu
));
562 s390x_new_cpu(object_class_get_name(oc
), id
, errp
);
565 static void s390_nmi(NMIState
*n
, int cpu_index
, Error
**errp
)
567 CPUState
*cs
= qemu_get_cpu(cpu_index
);
569 s390_cpu_restart(S390_CPU(cs
));
572 static ram_addr_t
s390_fixup_ram_size(ram_addr_t sz
)
574 /* same logic as in sclp.c */
575 int increment_size
= 20;
578 while ((sz
>> increment_size
) > MAX_STORAGE_INCREMENTS
) {
581 newsz
= sz
>> increment_size
<< increment_size
;
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
));
592 static void ccw_machine_class_init(ObjectClass
*oc
, void *data
)
594 MachineClass
*mc
= MACHINE_CLASS(oc
);
595 NMIClass
*nc
= NMI_CLASS(oc
);
596 HotplugHandlerClass
*hc
= HOTPLUG_HANDLER_CLASS(oc
);
597 S390CcwMachineClass
*s390mc
= S390_MACHINE_CLASS(mc
);
599 s390mc
->ri_allowed
= true;
600 s390mc
->cpu_model_allowed
= true;
601 s390mc
->css_migration_enabled
= true;
602 s390mc
->hpage_1m_allowed
= true;
604 mc
->reset
= s390_machine_reset
;
605 mc
->hot_add_cpu
= s390_hot_add_cpu
;
606 mc
->block_default_type
= IF_VIRTIO
;
611 mc
->max_cpus
= S390_MAX_CPUS
;
612 mc
->has_hotpluggable_cpus
= true;
613 assert(!mc
->get_hotplug_handler
);
614 mc
->get_hotplug_handler
= s390_get_hotplug_handler
;
615 mc
->cpu_index_to_instance_props
= s390_cpu_index_to_props
;
616 mc
->possible_cpu_arch_ids
= s390_possible_cpu_arch_ids
;
617 /* it is overridden with 'host' cpu *in kvm_arch_init* */
618 mc
->default_cpu_type
= S390_CPU_TYPE_NAME("qemu");
619 hc
->plug
= s390_machine_device_plug
;
620 hc
->unplug_request
= s390_machine_device_unplug_request
;
621 nc
->nmi_monitor_handler
= s390_nmi
;
622 mc
->default_ram_id
= "s390.ram";
625 static inline bool machine_get_aes_key_wrap(Object
*obj
, Error
**errp
)
627 S390CcwMachineState
*ms
= S390_CCW_MACHINE(obj
);
629 return ms
->aes_key_wrap
;
632 static inline void machine_set_aes_key_wrap(Object
*obj
, bool value
,
635 S390CcwMachineState
*ms
= S390_CCW_MACHINE(obj
);
637 ms
->aes_key_wrap
= value
;
640 static inline bool machine_get_dea_key_wrap(Object
*obj
, Error
**errp
)
642 S390CcwMachineState
*ms
= S390_CCW_MACHINE(obj
);
644 return ms
->dea_key_wrap
;
647 static inline void machine_set_dea_key_wrap(Object
*obj
, bool value
,
650 S390CcwMachineState
*ms
= S390_CCW_MACHINE(obj
);
652 ms
->dea_key_wrap
= value
;
655 static S390CcwMachineClass
*current_mc
;
658 * Get the class of the s390-ccw-virtio machine that is currently in use.
659 * Note: libvirt is using the "none" machine to probe for the features of the
660 * host CPU, so in case this is called with the "none" machine, the function
661 * returns the TYPE_S390_CCW_MACHINE base class. In this base class, all the
662 * various "*_allowed" variables are enabled, so that the *_allowed() wrappers
663 * below return the correct default value for the "none" machine.
665 * Attention! Do *not* add additional new wrappers for CPU features (e.g. like
666 * the ri_allowed() wrapper) via this mechanism anymore. CPU features should
667 * be handled via the CPU models, i.e. checking with cpu_model_allowed() during
668 * CPU initialization and s390_has_feat() later should be sufficient.
670 static S390CcwMachineClass
*get_machine_class(void)
672 if (unlikely(!current_mc
)) {
674 * No s390 ccw machine was instantiated, we are likely to
675 * be called for the 'none' machine. The properties will
676 * have their after-initialization values.
678 current_mc
= S390_MACHINE_CLASS(
679 object_class_by_name(TYPE_S390_CCW_MACHINE
));
684 bool ri_allowed(void)
686 return get_machine_class()->ri_allowed
;
689 bool cpu_model_allowed(void)
691 return get_machine_class()->cpu_model_allowed
;
694 bool hpage_1m_allowed(void)
696 return get_machine_class()->hpage_1m_allowed
;
699 static char *machine_get_loadparm(Object
*obj
, Error
**errp
)
701 S390CcwMachineState
*ms
= S390_CCW_MACHINE(obj
);
703 return g_memdup(ms
->loadparm
, sizeof(ms
->loadparm
));
706 static void machine_set_loadparm(Object
*obj
, const char *val
, Error
**errp
)
708 S390CcwMachineState
*ms
= S390_CCW_MACHINE(obj
);
711 for (i
= 0; i
< sizeof(ms
->loadparm
) && val
[i
]; i
++) {
712 uint8_t c
= qemu_toupper(val
[i
]); /* mimic HMC */
714 if (('A' <= c
&& c
<= 'Z') || ('0' <= c
&& c
<= '9') || (c
== '.') ||
718 error_setg(errp
, "LOADPARM: invalid character '%c' (ASCII 0x%02x)",
724 for (; i
< sizeof(ms
->loadparm
); i
++) {
725 ms
->loadparm
[i
] = ' '; /* pad right with spaces */
728 static inline void s390_machine_initfn(Object
*obj
)
730 object_property_add_bool(obj
, "aes-key-wrap",
731 machine_get_aes_key_wrap
,
732 machine_set_aes_key_wrap
);
733 object_property_set_description(obj
, "aes-key-wrap",
734 "enable/disable AES key wrapping using the CPACF wrapping key");
735 object_property_set_bool(obj
, true, "aes-key-wrap", NULL
);
737 object_property_add_bool(obj
, "dea-key-wrap",
738 machine_get_dea_key_wrap
,
739 machine_set_dea_key_wrap
);
740 object_property_set_description(obj
, "dea-key-wrap",
741 "enable/disable DEA key wrapping using the CPACF wrapping key");
742 object_property_set_bool(obj
, true, "dea-key-wrap", NULL
);
743 object_property_add_str(obj
, "loadparm",
744 machine_get_loadparm
, machine_set_loadparm
);
745 object_property_set_description(obj
, "loadparm",
746 "Up to 8 chars in set of [A-Za-z0-9. ] (lower case chars converted"
747 " to upper case) to pass to machine loader, boot manager,"
748 " and guest kernel");
751 static const TypeInfo ccw_machine_info
= {
752 .name
= TYPE_S390_CCW_MACHINE
,
753 .parent
= TYPE_MACHINE
,
755 .instance_size
= sizeof(S390CcwMachineState
),
756 .instance_init
= s390_machine_initfn
,
757 .class_size
= sizeof(S390CcwMachineClass
),
758 .class_init
= ccw_machine_class_init
,
759 .interfaces
= (InterfaceInfo
[]) {
761 { TYPE_HOTPLUG_HANDLER
},
766 bool css_migration_enabled(void)
768 return get_machine_class()->css_migration_enabled
;
771 #define DEFINE_CCW_MACHINE(suffix, verstr, latest) \
772 static void ccw_machine_##suffix##_class_init(ObjectClass *oc, \
775 MachineClass *mc = MACHINE_CLASS(oc); \
776 ccw_machine_##suffix##_class_options(mc); \
777 mc->desc = "VirtIO-ccw based S390 machine v" verstr; \
779 mc->alias = "s390-ccw-virtio"; \
780 mc->is_default = true; \
783 static void ccw_machine_##suffix##_instance_init(Object *obj) \
785 MachineState *machine = MACHINE(obj); \
786 current_mc = S390_MACHINE_CLASS(MACHINE_GET_CLASS(machine)); \
787 ccw_machine_##suffix##_instance_options(machine); \
789 static const TypeInfo ccw_machine_##suffix##_info = { \
790 .name = MACHINE_TYPE_NAME("s390-ccw-virtio-" verstr), \
791 .parent = TYPE_S390_CCW_MACHINE, \
792 .class_init = ccw_machine_##suffix##_class_init, \
793 .instance_init = ccw_machine_##suffix##_instance_init, \
795 static void ccw_machine_register_##suffix(void) \
797 type_register_static(&ccw_machine_##suffix##_info); \
799 type_init(ccw_machine_register_##suffix)
801 static void ccw_machine_5_1_instance_options(MachineState
*machine
)
805 static void ccw_machine_5_1_class_options(MachineClass
*mc
)
808 DEFINE_CCW_MACHINE(5_1
, "5.1", true);
810 static void ccw_machine_5_0_instance_options(MachineState
*machine
)
812 ccw_machine_5_1_instance_options(machine
);
815 static void ccw_machine_5_0_class_options(MachineClass
*mc
)
817 ccw_machine_5_1_class_options(mc
);
818 compat_props_add(mc
->compat_props
, hw_compat_5_0
, hw_compat_5_0_len
);
820 DEFINE_CCW_MACHINE(5_0
, "5.0", false);
822 static void ccw_machine_4_2_instance_options(MachineState
*machine
)
824 ccw_machine_5_0_instance_options(machine
);
827 static void ccw_machine_4_2_class_options(MachineClass
*mc
)
829 ccw_machine_5_0_class_options(mc
);
830 mc
->fixup_ram_size
= s390_fixup_ram_size
;
831 compat_props_add(mc
->compat_props
, hw_compat_4_2
, hw_compat_4_2_len
);
833 DEFINE_CCW_MACHINE(4_2
, "4.2", false);
835 static void ccw_machine_4_1_instance_options(MachineState
*machine
)
837 static const S390FeatInit qemu_cpu_feat
= { S390_FEAT_LIST_QEMU_V4_1
};
838 ccw_machine_4_2_instance_options(machine
);
839 s390_set_qemu_cpu_model(0x2964, 13, 2, qemu_cpu_feat
);
842 static void ccw_machine_4_1_class_options(MachineClass
*mc
)
844 ccw_machine_4_2_class_options(mc
);
845 compat_props_add(mc
->compat_props
, hw_compat_4_1
, hw_compat_4_1_len
);
847 DEFINE_CCW_MACHINE(4_1
, "4.1", false);
849 static void ccw_machine_4_0_instance_options(MachineState
*machine
)
851 static const S390FeatInit qemu_cpu_feat
= { S390_FEAT_LIST_QEMU_V4_0
};
852 ccw_machine_4_1_instance_options(machine
);
853 s390_set_qemu_cpu_model(0x2827, 12, 2, qemu_cpu_feat
);
856 static void ccw_machine_4_0_class_options(MachineClass
*mc
)
858 ccw_machine_4_1_class_options(mc
);
859 compat_props_add(mc
->compat_props
, hw_compat_4_0
, hw_compat_4_0_len
);
861 DEFINE_CCW_MACHINE(4_0
, "4.0", false);
863 static void ccw_machine_3_1_instance_options(MachineState
*machine
)
865 static const S390FeatInit qemu_cpu_feat
= { S390_FEAT_LIST_QEMU_V3_1
};
866 ccw_machine_4_0_instance_options(machine
);
867 s390_cpudef_featoff_greater(14, 1, S390_FEAT_MULTIPLE_EPOCH
);
868 s390_cpudef_group_featoff_greater(14, 1, S390_FEAT_GROUP_MULTIPLE_EPOCH_PTFF
);
869 s390_set_qemu_cpu_model(0x2827, 12, 2, qemu_cpu_feat
);
872 static void ccw_machine_3_1_class_options(MachineClass
*mc
)
874 ccw_machine_4_0_class_options(mc
);
875 compat_props_add(mc
->compat_props
, hw_compat_3_1
, hw_compat_3_1_len
);
877 DEFINE_CCW_MACHINE(3_1
, "3.1", false);
879 static void ccw_machine_3_0_instance_options(MachineState
*machine
)
881 ccw_machine_3_1_instance_options(machine
);
884 static void ccw_machine_3_0_class_options(MachineClass
*mc
)
886 S390CcwMachineClass
*s390mc
= S390_MACHINE_CLASS(mc
);
888 s390mc
->hpage_1m_allowed
= false;
889 ccw_machine_3_1_class_options(mc
);
890 compat_props_add(mc
->compat_props
, hw_compat_3_0
, hw_compat_3_0_len
);
892 DEFINE_CCW_MACHINE(3_0
, "3.0", false);
894 static void ccw_machine_2_12_instance_options(MachineState
*machine
)
896 ccw_machine_3_0_instance_options(machine
);
897 s390_cpudef_featoff_greater(11, 1, S390_FEAT_PPA15
);
898 s390_cpudef_featoff_greater(11, 1, S390_FEAT_BPB
);
901 static void ccw_machine_2_12_class_options(MachineClass
*mc
)
903 ccw_machine_3_0_class_options(mc
);
904 compat_props_add(mc
->compat_props
, hw_compat_2_12
, hw_compat_2_12_len
);
906 DEFINE_CCW_MACHINE(2_12
, "2.12", false);
908 static void ccw_machine_2_11_instance_options(MachineState
*machine
)
910 static const S390FeatInit qemu_cpu_feat
= { S390_FEAT_LIST_QEMU_V2_11
};
911 ccw_machine_2_12_instance_options(machine
);
913 /* before 2.12 we emulated the very first z900 */
914 s390_set_qemu_cpu_model(0x2064, 7, 1, qemu_cpu_feat
);
917 static void ccw_machine_2_11_class_options(MachineClass
*mc
)
919 static GlobalProperty compat
[] = {
920 { TYPE_SCLP_EVENT_FACILITY
, "allow_all_mask_sizes", "off", },
923 ccw_machine_2_12_class_options(mc
);
924 compat_props_add(mc
->compat_props
, hw_compat_2_11
, hw_compat_2_11_len
);
925 compat_props_add(mc
->compat_props
, compat
, G_N_ELEMENTS(compat
));
927 DEFINE_CCW_MACHINE(2_11
, "2.11", false);
929 static void ccw_machine_2_10_instance_options(MachineState
*machine
)
931 ccw_machine_2_11_instance_options(machine
);
934 static void ccw_machine_2_10_class_options(MachineClass
*mc
)
936 ccw_machine_2_11_class_options(mc
);
937 compat_props_add(mc
->compat_props
, hw_compat_2_10
, hw_compat_2_10_len
);
939 DEFINE_CCW_MACHINE(2_10
, "2.10", false);
941 static void ccw_machine_2_9_instance_options(MachineState
*machine
)
943 ccw_machine_2_10_instance_options(machine
);
944 s390_cpudef_featoff_greater(12, 1, S390_FEAT_ESOP
);
945 s390_cpudef_featoff_greater(12, 1, S390_FEAT_SIDE_EFFECT_ACCESS_ESOP2
);
946 s390_cpudef_featoff_greater(12, 1, S390_FEAT_ZPCI
);
947 s390_cpudef_featoff_greater(12, 1, S390_FEAT_ADAPTER_INT_SUPPRESSION
);
948 s390_cpudef_featoff_greater(12, 1, S390_FEAT_ADAPTER_EVENT_NOTIFICATION
);
951 static void ccw_machine_2_9_class_options(MachineClass
*mc
)
953 S390CcwMachineClass
*s390mc
= S390_MACHINE_CLASS(mc
);
954 static GlobalProperty compat
[] = {
955 { TYPE_S390_STATTRIB
, "migration-enabled", "off", },
958 ccw_machine_2_10_class_options(mc
);
959 compat_props_add(mc
->compat_props
, hw_compat_2_9
, hw_compat_2_9_len
);
960 compat_props_add(mc
->compat_props
, compat
, G_N_ELEMENTS(compat
));
961 s390mc
->css_migration_enabled
= false;
963 DEFINE_CCW_MACHINE(2_9
, "2.9", false);
965 static void ccw_machine_2_8_instance_options(MachineState
*machine
)
967 ccw_machine_2_9_instance_options(machine
);
970 static void ccw_machine_2_8_class_options(MachineClass
*mc
)
972 static GlobalProperty compat
[] = {
973 { TYPE_S390_FLIC_COMMON
, "adapter_routes_max_batch", "64", },
976 ccw_machine_2_9_class_options(mc
);
977 compat_props_add(mc
->compat_props
, hw_compat_2_8
, hw_compat_2_8_len
);
978 compat_props_add(mc
->compat_props
, compat
, G_N_ELEMENTS(compat
));
980 DEFINE_CCW_MACHINE(2_8
, "2.8", false);
982 static void ccw_machine_2_7_instance_options(MachineState
*machine
)
984 ccw_machine_2_8_instance_options(machine
);
987 static void ccw_machine_2_7_class_options(MachineClass
*mc
)
989 S390CcwMachineClass
*s390mc
= S390_MACHINE_CLASS(mc
);
991 s390mc
->cpu_model_allowed
= false;
992 ccw_machine_2_8_class_options(mc
);
993 compat_props_add(mc
->compat_props
, hw_compat_2_7
, hw_compat_2_7_len
);
995 DEFINE_CCW_MACHINE(2_7
, "2.7", false);
997 static void ccw_machine_2_6_instance_options(MachineState
*machine
)
999 ccw_machine_2_7_instance_options(machine
);
1002 static void ccw_machine_2_6_class_options(MachineClass
*mc
)
1004 S390CcwMachineClass
*s390mc
= S390_MACHINE_CLASS(mc
);
1005 static GlobalProperty compat
[] = {
1006 { TYPE_S390_IPL
, "iplbext_migration", "off", },
1007 { TYPE_VIRTUAL_CSS_BRIDGE
, "css_dev_path", "off", },
1010 s390mc
->ri_allowed
= false;
1011 ccw_machine_2_7_class_options(mc
);
1012 compat_props_add(mc
->compat_props
, hw_compat_2_6
, hw_compat_2_6_len
);
1013 compat_props_add(mc
->compat_props
, compat
, G_N_ELEMENTS(compat
));
1015 DEFINE_CCW_MACHINE(2_6
, "2.6", false);
1017 static void ccw_machine_2_5_instance_options(MachineState
*machine
)
1019 ccw_machine_2_6_instance_options(machine
);
1022 static void ccw_machine_2_5_class_options(MachineClass
*mc
)
1024 ccw_machine_2_6_class_options(mc
);
1025 compat_props_add(mc
->compat_props
, hw_compat_2_5
, hw_compat_2_5_len
);
1027 DEFINE_CCW_MACHINE(2_5
, "2.5", false);
1029 static void ccw_machine_2_4_instance_options(MachineState
*machine
)
1031 ccw_machine_2_5_instance_options(machine
);
1034 static void ccw_machine_2_4_class_options(MachineClass
*mc
)
1036 static GlobalProperty compat
[] = {
1037 { TYPE_S390_SKEYS
, "migration-enabled", "off", },
1038 { "virtio-blk-ccw", "max_revision", "0", },
1039 { "virtio-balloon-ccw", "max_revision", "0", },
1040 { "virtio-serial-ccw", "max_revision", "0", },
1041 { "virtio-9p-ccw", "max_revision", "0", },
1042 { "virtio-rng-ccw", "max_revision", "0", },
1043 { "virtio-net-ccw", "max_revision", "0", },
1044 { "virtio-scsi-ccw", "max_revision", "0", },
1045 { "vhost-scsi-ccw", "max_revision", "0", },
1048 ccw_machine_2_5_class_options(mc
);
1049 compat_props_add(mc
->compat_props
, hw_compat_2_4
, hw_compat_2_4_len
);
1050 compat_props_add(mc
->compat_props
, compat
, G_N_ELEMENTS(compat
));
1052 DEFINE_CCW_MACHINE(2_4
, "2.4", false);
1054 static void ccw_machine_register_types(void)
1056 type_register_static(&ccw_machine_info
);
1059 type_init(ccw_machine_register_types
)