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 "hw/s390x/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 "hw/s390x/pv.h"
47 #include "migration/blocker.h"
49 static Error
*pv_mig_blocker
;
51 S390CPU
*s390_cpu_addr2state(uint16_t cpu_addr
)
53 static MachineState
*ms
;
56 ms
= MACHINE(qdev_get_machine());
57 g_assert(ms
->possible_cpus
);
60 /* CPU address corresponds to the core_id and the index */
61 if (cpu_addr
>= ms
->possible_cpus
->len
) {
64 return S390_CPU(ms
->possible_cpus
->cpus
[cpu_addr
].cpu
);
67 static S390CPU
*s390x_new_cpu(const char *typename
, uint32_t core_id
,
70 S390CPU
*cpu
= S390_CPU(object_new(typename
));
73 if (!object_property_set_int(OBJECT(cpu
), "core-id", core_id
, errp
)) {
76 if (!qdev_realize(DEVICE(cpu
), NULL
, errp
)) {
82 object_unref(OBJECT(cpu
));
86 static void s390_init_cpus(MachineState
*machine
)
88 MachineClass
*mc
= MACHINE_GET_CLASS(machine
);
91 /* initialize possible_cpus */
92 mc
->possible_cpu_arch_ids(machine
);
94 for (i
= 0; i
< machine
->smp
.cpus
; i
++) {
95 s390x_new_cpu(machine
->cpu_type
, i
, &error_fatal
);
99 static const char *const reset_dev_types
[] = {
100 TYPE_VIRTUAL_CSS_BRIDGE
,
101 "s390-sclp-event-facility",
104 TYPE_S390_PCI_HOST_BRIDGE
,
107 static void subsystem_reset(void)
112 for (i
= 0; i
< ARRAY_SIZE(reset_dev_types
); i
++) {
113 dev
= DEVICE(object_resolve_path_type("", reset_dev_types
[i
], NULL
));
120 static int virtio_ccw_hcall_notify(const uint64_t *args
)
122 uint64_t subch_id
= args
[0];
123 uint64_t queue
= args
[1];
125 int cssid
, ssid
, schid
, m
;
127 if (ioinst_disassemble_sch_ident(subch_id
, &m
, &cssid
, &ssid
, &schid
)) {
130 sch
= css_find_subch(m
, cssid
, ssid
, schid
);
131 if (!sch
|| !css_subch_visible(sch
)) {
134 if (queue
>= VIRTIO_QUEUE_MAX
) {
137 virtio_queue_notify(virtio_ccw_get_vdev(sch
), queue
);
142 static int virtio_ccw_hcall_early_printk(const uint64_t *args
)
144 uint64_t mem
= args
[0];
146 if (mem
< ram_size
) {
153 static void virtio_ccw_register_hcalls(void)
155 s390_register_virtio_hypercall(KVM_S390_VIRTIO_CCW_NOTIFY
,
156 virtio_ccw_hcall_notify
);
157 /* Tolerate early printk. */
158 s390_register_virtio_hypercall(KVM_S390_VIRTIO_NOTIFY
,
159 virtio_ccw_hcall_early_printk
);
162 static void s390_memory_init(MemoryRegion
*ram
)
164 MemoryRegion
*sysmem
= get_system_memory();
166 /* allocate RAM for core */
167 memory_region_add_subregion(sysmem
, 0, ram
);
170 * Configure the maximum page size. As no memory devices were created
171 * yet, this is the page size of initial memory only.
173 s390_set_max_pagesize(qemu_maxrampagesize(), &error_fatal
);
174 /* Initialize storage key device */
176 /* Initialize storage attributes device */
177 s390_stattrib_init();
180 static void s390_init_ipl_dev(const char *kernel_filename
,
181 const char *kernel_cmdline
,
182 const char *initrd_filename
, const char *firmware
,
183 const char *netboot_fw
, bool enforce_bios
)
185 Object
*new = object_new(TYPE_S390_IPL
);
186 DeviceState
*dev
= DEVICE(new);
187 char *netboot_fw_prop
;
189 if (kernel_filename
) {
190 qdev_prop_set_string(dev
, "kernel", kernel_filename
);
192 if (initrd_filename
) {
193 qdev_prop_set_string(dev
, "initrd", initrd_filename
);
195 qdev_prop_set_string(dev
, "cmdline", kernel_cmdline
);
196 qdev_prop_set_string(dev
, "firmware", firmware
);
197 qdev_prop_set_bit(dev
, "enforce_bios", enforce_bios
);
198 netboot_fw_prop
= object_property_get_str(new, "netboot_fw", &error_abort
);
199 if (!strlen(netboot_fw_prop
)) {
200 qdev_prop_set_string(dev
, "netboot_fw", netboot_fw
);
202 g_free(netboot_fw_prop
);
203 object_property_add_child(qdev_get_machine(), TYPE_S390_IPL
,
206 qdev_realize(dev
, NULL
, &error_fatal
);
209 static void s390_create_virtio_net(BusState
*bus
, const char *name
)
213 for (i
= 0; i
< nb_nics
; i
++) {
214 NICInfo
*nd
= &nd_table
[i
];
218 nd
->model
= g_strdup("virtio");
221 qemu_check_nic_model(nd
, "virtio");
223 dev
= qdev_new(name
);
224 qdev_set_nic_properties(dev
, nd
);
225 qdev_realize_and_unref(dev
, bus
, &error_fatal
);
229 static void s390_create_sclpconsole(const char *type
, Chardev
*chardev
)
233 dev
= qdev_new(type
);
234 qdev_prop_set_chr(dev
, "chardev", chardev
);
235 qdev_realize_and_unref(dev
, sclp_get_event_facility_bus(), &error_fatal
);
238 static void ccw_init(MachineState
*machine
)
241 VirtualCssBus
*css_bus
;
245 /* init memory + setup max page size. Required for the CPU model */
246 s390_memory_init(machine
->ram
);
248 /* init CPUs (incl. CPU model) early so s390_has_feature() works */
249 s390_init_cpus(machine
);
253 /* init the SIGP facility */
256 /* create AP bridge and bus(es) */
260 css_bus
= virtual_css_bus_init();
261 s390_init_ipl_dev(machine
->kernel_filename
, machine
->kernel_cmdline
,
262 machine
->initrd_filename
, "s390-ccw.img",
263 "s390-netboot.img", true);
265 dev
= qdev_new(TYPE_S390_PCI_HOST_BRIDGE
);
266 object_property_add_child(qdev_get_machine(), TYPE_S390_PCI_HOST_BRIDGE
,
268 sysbus_realize_and_unref(SYS_BUS_DEVICE(dev
), &error_fatal
);
270 /* register hypercalls */
271 virtio_ccw_register_hcalls();
273 s390_enable_css_support(s390_cpu_addr2state(0));
275 ret
= css_create_css_image(VIRTUAL_CSSID
, true);
278 if (css_migration_enabled()) {
279 css_register_vmstate();
282 /* Create VirtIO network adapters */
283 s390_create_virtio_net(BUS(css_bus
), "virtio-net-ccw");
287 s390_create_sclpconsole("sclpconsole", serial_hd(0));
290 s390_create_sclpconsole("sclplmconsole", serial_hd(1));
293 /* init the TOD clock */
297 static void s390_cpu_plug(HotplugHandler
*hotplug_dev
,
298 DeviceState
*dev
, Error
**errp
)
300 MachineState
*ms
= MACHINE(hotplug_dev
);
301 S390CPU
*cpu
= S390_CPU(dev
);
303 g_assert(!ms
->possible_cpus
->cpus
[cpu
->env
.core_id
].cpu
);
304 ms
->possible_cpus
->cpus
[cpu
->env
.core_id
].cpu
= OBJECT(dev
);
306 if (dev
->hotplugged
) {
307 raise_irq_cpu_hotplug();
311 static inline void s390_do_cpu_ipl(CPUState
*cs
, run_on_cpu_data arg
)
313 S390CPU
*cpu
= S390_CPU(cs
);
315 s390_ipl_prepare_cpu(cpu
);
316 s390_cpu_set_state(S390_CPU_STATE_OPERATING
, cpu
);
319 static void s390_machine_unprotect(S390CcwMachineState
*ms
)
321 s390_pv_vm_disable();
323 migrate_del_blocker(pv_mig_blocker
);
324 error_free_or_abort(&pv_mig_blocker
);
325 ram_block_discard_disable(false);
328 static int s390_machine_protect(S390CcwMachineState
*ms
)
330 Error
*local_err
= NULL
;
334 * Discarding of memory in RAM blocks does not work as expected with
335 * protected VMs. Sharing and unsharing pages would be required. Disable
336 * it for now, until until we have a solution to make at least Linux
337 * guests either support it (e.g., virtio-balloon) or fail gracefully.
339 rc
= ram_block_discard_disable(true);
341 error_report("protected VMs: cannot disable RAM discard");
345 error_setg(&pv_mig_blocker
,
346 "protected VMs are currently not migrateable.");
347 rc
= migrate_add_blocker(pv_mig_blocker
, &local_err
);
349 ram_block_discard_disable(false);
350 error_report_err(local_err
);
351 error_free_or_abort(&pv_mig_blocker
);
356 rc
= s390_pv_vm_enable();
358 ram_block_discard_disable(false);
359 migrate_del_blocker(pv_mig_blocker
);
360 error_free_or_abort(&pv_mig_blocker
);
366 /* Set SE header and unpack */
367 rc
= s390_ipl_prepare_pv_header();
373 rc
= s390_ipl_pv_unpack();
378 /* Verify integrity */
379 rc
= s390_pv_verify();
386 s390_machine_unprotect(ms
);
390 static void s390_pv_prepare_reset(S390CcwMachineState
*ms
)
397 /* Unsharing requires all cpus to be stopped */
399 s390_cpu_set_state(S390_CPU_STATE_STOPPED
, S390_CPU(cs
));
402 s390_pv_prep_reset();
405 static void s390_machine_reset(MachineState
*machine
)
407 S390CcwMachineState
*ms
= S390_CCW_MACHINE(machine
);
408 enum s390_reset reset_type
;
412 /* get the reset parameters, reset them once done */
413 s390_ipl_get_reset_request(&cs
, &reset_type
);
415 /* all CPUs are paused and synchronized at this point */
420 switch (reset_type
) {
421 case S390_RESET_EXTERNAL
:
422 case S390_RESET_REIPL
:
424 s390_machine_unprotect(ms
);
427 qemu_devices_reset();
430 /* configure and start the ipl CPU only */
431 run_on_cpu(cs
, s390_do_cpu_ipl
, RUN_ON_CPU_NULL
);
433 case S390_RESET_MODIFIED_CLEAR
:
435 * Susbsystem reset needs to be done before we unshare memory
436 * and lose access to VIRTIO structures in guest memory.
440 s390_pv_prepare_reset(ms
);
442 run_on_cpu(t
, s390_do_cpu_full_reset
, RUN_ON_CPU_NULL
);
444 run_on_cpu(cs
, s390_do_cpu_load_normal
, RUN_ON_CPU_NULL
);
446 case S390_RESET_LOAD_NORMAL
:
448 * Susbsystem reset needs to be done before we unshare memory
449 * and lose access to VIRTIO structures in guest memory.
452 s390_pv_prepare_reset(ms
);
457 run_on_cpu(t
, s390_do_cpu_reset
, RUN_ON_CPU_NULL
);
459 run_on_cpu(cs
, s390_do_cpu_initial_reset
, RUN_ON_CPU_NULL
);
460 run_on_cpu(cs
, s390_do_cpu_load_normal
, RUN_ON_CPU_NULL
);
462 case S390_RESET_PV
: /* Subcode 10 */
470 run_on_cpu(t
, s390_do_cpu_full_reset
, RUN_ON_CPU_NULL
);
472 run_on_cpu(cs
, s390_do_cpu_reset
, RUN_ON_CPU_NULL
);
474 if (s390_machine_protect(ms
)) {
475 s390_pv_inject_reset_error(cs
);
477 * Continue after the diag308 so the guest knows something
480 s390_cpu_set_state(S390_CPU_STATE_OPERATING
, cpu
);
484 run_on_cpu(cs
, s390_do_cpu_load_normal
, RUN_ON_CPU_NULL
);
487 g_assert_not_reached();
489 s390_ipl_clear_reset_request();
492 static void s390_machine_device_plug(HotplugHandler
*hotplug_dev
,
493 DeviceState
*dev
, Error
**errp
)
495 if (object_dynamic_cast(OBJECT(dev
), TYPE_CPU
)) {
496 s390_cpu_plug(hotplug_dev
, dev
, errp
);
500 static void s390_machine_device_unplug_request(HotplugHandler
*hotplug_dev
,
501 DeviceState
*dev
, Error
**errp
)
503 if (object_dynamic_cast(OBJECT(dev
), TYPE_CPU
)) {
504 error_setg(errp
, "CPU hot unplug not supported on this machine");
509 static CpuInstanceProperties
s390_cpu_index_to_props(MachineState
*ms
,
512 MachineClass
*mc
= MACHINE_GET_CLASS(ms
);
513 const CPUArchIdList
*possible_cpus
= mc
->possible_cpu_arch_ids(ms
);
515 assert(cpu_index
< possible_cpus
->len
);
516 return possible_cpus
->cpus
[cpu_index
].props
;
519 static const CPUArchIdList
*s390_possible_cpu_arch_ids(MachineState
*ms
)
522 unsigned int max_cpus
= ms
->smp
.max_cpus
;
524 if (ms
->possible_cpus
) {
525 g_assert(ms
->possible_cpus
&& ms
->possible_cpus
->len
== max_cpus
);
526 return ms
->possible_cpus
;
529 ms
->possible_cpus
= g_malloc0(sizeof(CPUArchIdList
) +
530 sizeof(CPUArchId
) * max_cpus
);
531 ms
->possible_cpus
->len
= max_cpus
;
532 for (i
= 0; i
< ms
->possible_cpus
->len
; i
++) {
533 ms
->possible_cpus
->cpus
[i
].type
= ms
->cpu_type
;
534 ms
->possible_cpus
->cpus
[i
].vcpus_count
= 1;
535 ms
->possible_cpus
->cpus
[i
].arch_id
= i
;
536 ms
->possible_cpus
->cpus
[i
].props
.has_core_id
= true;
537 ms
->possible_cpus
->cpus
[i
].props
.core_id
= i
;
540 return ms
->possible_cpus
;
543 static HotplugHandler
*s390_get_hotplug_handler(MachineState
*machine
,
546 if (object_dynamic_cast(OBJECT(dev
), TYPE_CPU
)) {
547 return HOTPLUG_HANDLER(machine
);
552 static void s390_nmi(NMIState
*n
, int cpu_index
, Error
**errp
)
554 CPUState
*cs
= qemu_get_cpu(cpu_index
);
556 s390_cpu_restart(S390_CPU(cs
));
559 static ram_addr_t
s390_fixup_ram_size(ram_addr_t sz
)
561 /* same logic as in sclp.c */
562 int increment_size
= 20;
565 while ((sz
>> increment_size
) > MAX_STORAGE_INCREMENTS
) {
568 newsz
= sz
>> increment_size
<< increment_size
;
571 qemu_printf("Ram size %" PRIu64
"MB was fixed up to %" PRIu64
572 "MB to match machine restrictions. Consider updating "
573 "the guest definition.\n", (uint64_t) (sz
/ MiB
),
574 (uint64_t) (newsz
/ MiB
));
579 static void ccw_machine_class_init(ObjectClass
*oc
, void *data
)
581 MachineClass
*mc
= MACHINE_CLASS(oc
);
582 NMIClass
*nc
= NMI_CLASS(oc
);
583 HotplugHandlerClass
*hc
= HOTPLUG_HANDLER_CLASS(oc
);
584 S390CcwMachineClass
*s390mc
= S390_CCW_MACHINE_CLASS(mc
);
586 s390mc
->ri_allowed
= true;
587 s390mc
->cpu_model_allowed
= true;
588 s390mc
->css_migration_enabled
= true;
589 s390mc
->hpage_1m_allowed
= true;
591 mc
->reset
= s390_machine_reset
;
592 mc
->block_default_type
= IF_VIRTIO
;
597 mc
->max_cpus
= S390_MAX_CPUS
;
598 mc
->has_hotpluggable_cpus
= true;
599 assert(!mc
->get_hotplug_handler
);
600 mc
->get_hotplug_handler
= s390_get_hotplug_handler
;
601 mc
->cpu_index_to_instance_props
= s390_cpu_index_to_props
;
602 mc
->possible_cpu_arch_ids
= s390_possible_cpu_arch_ids
;
603 /* it is overridden with 'host' cpu *in kvm_arch_init* */
604 mc
->default_cpu_type
= S390_CPU_TYPE_NAME("qemu");
605 hc
->plug
= s390_machine_device_plug
;
606 hc
->unplug_request
= s390_machine_device_unplug_request
;
607 nc
->nmi_monitor_handler
= s390_nmi
;
608 mc
->default_ram_id
= "s390.ram";
611 static inline bool machine_get_aes_key_wrap(Object
*obj
, Error
**errp
)
613 S390CcwMachineState
*ms
= S390_CCW_MACHINE(obj
);
615 return ms
->aes_key_wrap
;
618 static inline void machine_set_aes_key_wrap(Object
*obj
, bool value
,
621 S390CcwMachineState
*ms
= S390_CCW_MACHINE(obj
);
623 ms
->aes_key_wrap
= value
;
626 static inline bool machine_get_dea_key_wrap(Object
*obj
, Error
**errp
)
628 S390CcwMachineState
*ms
= S390_CCW_MACHINE(obj
);
630 return ms
->dea_key_wrap
;
633 static inline void machine_set_dea_key_wrap(Object
*obj
, bool value
,
636 S390CcwMachineState
*ms
= S390_CCW_MACHINE(obj
);
638 ms
->dea_key_wrap
= value
;
641 static S390CcwMachineClass
*current_mc
;
644 * Get the class of the s390-ccw-virtio machine that is currently in use.
645 * Note: libvirt is using the "none" machine to probe for the features of the
646 * host CPU, so in case this is called with the "none" machine, the function
647 * returns the TYPE_S390_CCW_MACHINE base class. In this base class, all the
648 * various "*_allowed" variables are enabled, so that the *_allowed() wrappers
649 * below return the correct default value for the "none" machine.
651 * Attention! Do *not* add additional new wrappers for CPU features (e.g. like
652 * the ri_allowed() wrapper) via this mechanism anymore. CPU features should
653 * be handled via the CPU models, i.e. checking with cpu_model_allowed() during
654 * CPU initialization and s390_has_feat() later should be sufficient.
656 static S390CcwMachineClass
*get_machine_class(void)
658 if (unlikely(!current_mc
)) {
660 * No s390 ccw machine was instantiated, we are likely to
661 * be called for the 'none' machine. The properties will
662 * have their after-initialization values.
664 current_mc
= S390_CCW_MACHINE_CLASS(
665 object_class_by_name(TYPE_S390_CCW_MACHINE
));
670 bool ri_allowed(void)
672 return get_machine_class()->ri_allowed
;
675 bool cpu_model_allowed(void)
677 return get_machine_class()->cpu_model_allowed
;
680 bool hpage_1m_allowed(void)
682 return get_machine_class()->hpage_1m_allowed
;
685 static char *machine_get_loadparm(Object
*obj
, Error
**errp
)
687 S390CcwMachineState
*ms
= S390_CCW_MACHINE(obj
);
689 /* make a NUL-terminated string */
690 return g_strndup((char *) ms
->loadparm
, sizeof(ms
->loadparm
));
693 static void machine_set_loadparm(Object
*obj
, const char *val
, Error
**errp
)
695 S390CcwMachineState
*ms
= S390_CCW_MACHINE(obj
);
698 for (i
= 0; i
< sizeof(ms
->loadparm
) && val
[i
]; i
++) {
699 uint8_t c
= qemu_toupper(val
[i
]); /* mimic HMC */
701 if (('A' <= c
&& c
<= 'Z') || ('0' <= c
&& c
<= '9') || (c
== '.') ||
705 error_setg(errp
, "LOADPARM: invalid character '%c' (ASCII 0x%02x)",
711 for (; i
< sizeof(ms
->loadparm
); i
++) {
712 ms
->loadparm
[i
] = ' '; /* pad right with spaces */
715 static inline void s390_machine_initfn(Object
*obj
)
717 object_property_add_bool(obj
, "aes-key-wrap",
718 machine_get_aes_key_wrap
,
719 machine_set_aes_key_wrap
);
720 object_property_set_description(obj
, "aes-key-wrap",
721 "enable/disable AES key wrapping using the CPACF wrapping key");
722 object_property_set_bool(obj
, "aes-key-wrap", true, NULL
);
724 object_property_add_bool(obj
, "dea-key-wrap",
725 machine_get_dea_key_wrap
,
726 machine_set_dea_key_wrap
);
727 object_property_set_description(obj
, "dea-key-wrap",
728 "enable/disable DEA key wrapping using the CPACF wrapping key");
729 object_property_set_bool(obj
, "dea-key-wrap", true, NULL
);
730 object_property_add_str(obj
, "loadparm",
731 machine_get_loadparm
, machine_set_loadparm
);
732 object_property_set_description(obj
, "loadparm",
733 "Up to 8 chars in set of [A-Za-z0-9. ] (lower case chars converted"
734 " to upper case) to pass to machine loader, boot manager,"
735 " and guest kernel");
738 static const TypeInfo ccw_machine_info
= {
739 .name
= TYPE_S390_CCW_MACHINE
,
740 .parent
= TYPE_MACHINE
,
742 .instance_size
= sizeof(S390CcwMachineState
),
743 .instance_init
= s390_machine_initfn
,
744 .class_size
= sizeof(S390CcwMachineClass
),
745 .class_init
= ccw_machine_class_init
,
746 .interfaces
= (InterfaceInfo
[]) {
748 { TYPE_HOTPLUG_HANDLER
},
753 bool css_migration_enabled(void)
755 return get_machine_class()->css_migration_enabled
;
758 #define DEFINE_CCW_MACHINE(suffix, verstr, latest) \
759 static void ccw_machine_##suffix##_class_init(ObjectClass *oc, \
762 MachineClass *mc = MACHINE_CLASS(oc); \
763 ccw_machine_##suffix##_class_options(mc); \
764 mc->desc = "VirtIO-ccw based S390 machine v" verstr; \
766 mc->alias = "s390-ccw-virtio"; \
767 mc->is_default = true; \
770 static void ccw_machine_##suffix##_instance_init(Object *obj) \
772 MachineState *machine = MACHINE(obj); \
773 current_mc = S390_CCW_MACHINE_CLASS(MACHINE_GET_CLASS(machine)); \
774 ccw_machine_##suffix##_instance_options(machine); \
776 static const TypeInfo ccw_machine_##suffix##_info = { \
777 .name = MACHINE_TYPE_NAME("s390-ccw-virtio-" verstr), \
778 .parent = TYPE_S390_CCW_MACHINE, \
779 .class_init = ccw_machine_##suffix##_class_init, \
780 .instance_init = ccw_machine_##suffix##_instance_init, \
782 static void ccw_machine_register_##suffix(void) \
784 type_register_static(&ccw_machine_##suffix##_info); \
786 type_init(ccw_machine_register_##suffix)
788 static void ccw_machine_5_2_instance_options(MachineState
*machine
)
792 static void ccw_machine_5_2_class_options(MachineClass
*mc
)
795 DEFINE_CCW_MACHINE(5_2
, "5.2", true);
797 static void ccw_machine_5_1_instance_options(MachineState
*machine
)
799 ccw_machine_5_2_instance_options(machine
);
802 static void ccw_machine_5_1_class_options(MachineClass
*mc
)
804 ccw_machine_5_2_class_options(mc
);
805 compat_props_add(mc
->compat_props
, hw_compat_5_1
, hw_compat_5_1_len
);
807 DEFINE_CCW_MACHINE(5_1
, "5.1", false);
809 static void ccw_machine_5_0_instance_options(MachineState
*machine
)
811 ccw_machine_5_1_instance_options(machine
);
814 static void ccw_machine_5_0_class_options(MachineClass
*mc
)
816 ccw_machine_5_1_class_options(mc
);
817 compat_props_add(mc
->compat_props
, hw_compat_5_0
, hw_compat_5_0_len
);
819 DEFINE_CCW_MACHINE(5_0
, "5.0", false);
821 static void ccw_machine_4_2_instance_options(MachineState
*machine
)
823 ccw_machine_5_0_instance_options(machine
);
826 static void ccw_machine_4_2_class_options(MachineClass
*mc
)
828 ccw_machine_5_0_class_options(mc
);
829 mc
->fixup_ram_size
= s390_fixup_ram_size
;
830 compat_props_add(mc
->compat_props
, hw_compat_4_2
, hw_compat_4_2_len
);
832 DEFINE_CCW_MACHINE(4_2
, "4.2", false);
834 static void ccw_machine_4_1_instance_options(MachineState
*machine
)
836 static const S390FeatInit qemu_cpu_feat
= { S390_FEAT_LIST_QEMU_V4_1
};
837 ccw_machine_4_2_instance_options(machine
);
838 s390_set_qemu_cpu_model(0x2964, 13, 2, qemu_cpu_feat
);
841 static void ccw_machine_4_1_class_options(MachineClass
*mc
)
843 ccw_machine_4_2_class_options(mc
);
844 compat_props_add(mc
->compat_props
, hw_compat_4_1
, hw_compat_4_1_len
);
846 DEFINE_CCW_MACHINE(4_1
, "4.1", false);
848 static void ccw_machine_4_0_instance_options(MachineState
*machine
)
850 static const S390FeatInit qemu_cpu_feat
= { S390_FEAT_LIST_QEMU_V4_0
};
851 ccw_machine_4_1_instance_options(machine
);
852 s390_set_qemu_cpu_model(0x2827, 12, 2, qemu_cpu_feat
);
855 static void ccw_machine_4_0_class_options(MachineClass
*mc
)
857 ccw_machine_4_1_class_options(mc
);
858 compat_props_add(mc
->compat_props
, hw_compat_4_0
, hw_compat_4_0_len
);
860 DEFINE_CCW_MACHINE(4_0
, "4.0", false);
862 static void ccw_machine_3_1_instance_options(MachineState
*machine
)
864 static const S390FeatInit qemu_cpu_feat
= { S390_FEAT_LIST_QEMU_V3_1
};
865 ccw_machine_4_0_instance_options(machine
);
866 s390_cpudef_featoff_greater(14, 1, S390_FEAT_MULTIPLE_EPOCH
);
867 s390_cpudef_group_featoff_greater(14, 1, S390_FEAT_GROUP_MULTIPLE_EPOCH_PTFF
);
868 s390_set_qemu_cpu_model(0x2827, 12, 2, qemu_cpu_feat
);
871 static void ccw_machine_3_1_class_options(MachineClass
*mc
)
873 ccw_machine_4_0_class_options(mc
);
874 compat_props_add(mc
->compat_props
, hw_compat_3_1
, hw_compat_3_1_len
);
876 DEFINE_CCW_MACHINE(3_1
, "3.1", false);
878 static void ccw_machine_3_0_instance_options(MachineState
*machine
)
880 ccw_machine_3_1_instance_options(machine
);
883 static void ccw_machine_3_0_class_options(MachineClass
*mc
)
885 S390CcwMachineClass
*s390mc
= S390_CCW_MACHINE_CLASS(mc
);
887 s390mc
->hpage_1m_allowed
= false;
888 ccw_machine_3_1_class_options(mc
);
889 compat_props_add(mc
->compat_props
, hw_compat_3_0
, hw_compat_3_0_len
);
891 DEFINE_CCW_MACHINE(3_0
, "3.0", false);
893 static void ccw_machine_2_12_instance_options(MachineState
*machine
)
895 ccw_machine_3_0_instance_options(machine
);
896 s390_cpudef_featoff_greater(11, 1, S390_FEAT_PPA15
);
897 s390_cpudef_featoff_greater(11, 1, S390_FEAT_BPB
);
900 static void ccw_machine_2_12_class_options(MachineClass
*mc
)
902 ccw_machine_3_0_class_options(mc
);
903 compat_props_add(mc
->compat_props
, hw_compat_2_12
, hw_compat_2_12_len
);
905 DEFINE_CCW_MACHINE(2_12
, "2.12", false);
907 static void ccw_machine_2_11_instance_options(MachineState
*machine
)
909 static const S390FeatInit qemu_cpu_feat
= { S390_FEAT_LIST_QEMU_V2_11
};
910 ccw_machine_2_12_instance_options(machine
);
912 /* before 2.12 we emulated the very first z900 */
913 s390_set_qemu_cpu_model(0x2064, 7, 1, qemu_cpu_feat
);
916 static void ccw_machine_2_11_class_options(MachineClass
*mc
)
918 static GlobalProperty compat
[] = {
919 { TYPE_SCLP_EVENT_FACILITY
, "allow_all_mask_sizes", "off", },
922 ccw_machine_2_12_class_options(mc
);
923 compat_props_add(mc
->compat_props
, hw_compat_2_11
, hw_compat_2_11_len
);
924 compat_props_add(mc
->compat_props
, compat
, G_N_ELEMENTS(compat
));
926 DEFINE_CCW_MACHINE(2_11
, "2.11", false);
928 static void ccw_machine_2_10_instance_options(MachineState
*machine
)
930 ccw_machine_2_11_instance_options(machine
);
933 static void ccw_machine_2_10_class_options(MachineClass
*mc
)
935 ccw_machine_2_11_class_options(mc
);
936 compat_props_add(mc
->compat_props
, hw_compat_2_10
, hw_compat_2_10_len
);
938 DEFINE_CCW_MACHINE(2_10
, "2.10", false);
940 static void ccw_machine_2_9_instance_options(MachineState
*machine
)
942 ccw_machine_2_10_instance_options(machine
);
943 s390_cpudef_featoff_greater(12, 1, S390_FEAT_ESOP
);
944 s390_cpudef_featoff_greater(12, 1, S390_FEAT_SIDE_EFFECT_ACCESS_ESOP2
);
945 s390_cpudef_featoff_greater(12, 1, S390_FEAT_ZPCI
);
946 s390_cpudef_featoff_greater(12, 1, S390_FEAT_ADAPTER_INT_SUPPRESSION
);
947 s390_cpudef_featoff_greater(12, 1, S390_FEAT_ADAPTER_EVENT_NOTIFICATION
);
950 static void ccw_machine_2_9_class_options(MachineClass
*mc
)
952 S390CcwMachineClass
*s390mc
= S390_CCW_MACHINE_CLASS(mc
);
953 static GlobalProperty compat
[] = {
954 { TYPE_S390_STATTRIB
, "migration-enabled", "off", },
957 ccw_machine_2_10_class_options(mc
);
958 compat_props_add(mc
->compat_props
, hw_compat_2_9
, hw_compat_2_9_len
);
959 compat_props_add(mc
->compat_props
, compat
, G_N_ELEMENTS(compat
));
960 s390mc
->css_migration_enabled
= false;
962 DEFINE_CCW_MACHINE(2_9
, "2.9", false);
964 static void ccw_machine_2_8_instance_options(MachineState
*machine
)
966 ccw_machine_2_9_instance_options(machine
);
969 static void ccw_machine_2_8_class_options(MachineClass
*mc
)
971 static GlobalProperty compat
[] = {
972 { TYPE_S390_FLIC_COMMON
, "adapter_routes_max_batch", "64", },
975 ccw_machine_2_9_class_options(mc
);
976 compat_props_add(mc
->compat_props
, hw_compat_2_8
, hw_compat_2_8_len
);
977 compat_props_add(mc
->compat_props
, compat
, G_N_ELEMENTS(compat
));
979 DEFINE_CCW_MACHINE(2_8
, "2.8", false);
981 static void ccw_machine_2_7_instance_options(MachineState
*machine
)
983 ccw_machine_2_8_instance_options(machine
);
986 static void ccw_machine_2_7_class_options(MachineClass
*mc
)
988 S390CcwMachineClass
*s390mc
= S390_CCW_MACHINE_CLASS(mc
);
990 s390mc
->cpu_model_allowed
= false;
991 ccw_machine_2_8_class_options(mc
);
992 compat_props_add(mc
->compat_props
, hw_compat_2_7
, hw_compat_2_7_len
);
994 DEFINE_CCW_MACHINE(2_7
, "2.7", false);
996 static void ccw_machine_2_6_instance_options(MachineState
*machine
)
998 ccw_machine_2_7_instance_options(machine
);
1001 static void ccw_machine_2_6_class_options(MachineClass
*mc
)
1003 S390CcwMachineClass
*s390mc
= S390_CCW_MACHINE_CLASS(mc
);
1004 static GlobalProperty compat
[] = {
1005 { TYPE_S390_IPL
, "iplbext_migration", "off", },
1006 { TYPE_VIRTUAL_CSS_BRIDGE
, "css_dev_path", "off", },
1009 s390mc
->ri_allowed
= false;
1010 ccw_machine_2_7_class_options(mc
);
1011 compat_props_add(mc
->compat_props
, hw_compat_2_6
, hw_compat_2_6_len
);
1012 compat_props_add(mc
->compat_props
, compat
, G_N_ELEMENTS(compat
));
1014 DEFINE_CCW_MACHINE(2_6
, "2.6", false);
1016 static void ccw_machine_2_5_instance_options(MachineState
*machine
)
1018 ccw_machine_2_6_instance_options(machine
);
1021 static void ccw_machine_2_5_class_options(MachineClass
*mc
)
1023 ccw_machine_2_6_class_options(mc
);
1024 compat_props_add(mc
->compat_props
, hw_compat_2_5
, hw_compat_2_5_len
);
1026 DEFINE_CCW_MACHINE(2_5
, "2.5", false);
1028 static void ccw_machine_2_4_instance_options(MachineState
*machine
)
1030 ccw_machine_2_5_instance_options(machine
);
1033 static void ccw_machine_2_4_class_options(MachineClass
*mc
)
1035 static GlobalProperty compat
[] = {
1036 { TYPE_S390_SKEYS
, "migration-enabled", "off", },
1037 { "virtio-blk-ccw", "max_revision", "0", },
1038 { "virtio-balloon-ccw", "max_revision", "0", },
1039 { "virtio-serial-ccw", "max_revision", "0", },
1040 { "virtio-9p-ccw", "max_revision", "0", },
1041 { "virtio-rng-ccw", "max_revision", "0", },
1042 { "virtio-net-ccw", "max_revision", "0", },
1043 { "virtio-scsi-ccw", "max_revision", "0", },
1044 { "vhost-scsi-ccw", "max_revision", "0", },
1047 ccw_machine_2_5_class_options(mc
);
1048 compat_props_add(mc
->compat_props
, hw_compat_2_4
, hw_compat_2_4_len
);
1049 compat_props_add(mc
->compat_props
, compat
, G_N_ELEMENTS(compat
));
1051 DEFINE_CCW_MACHINE(2_4
, "2.4", false);
1053 static void ccw_machine_register_types(void)
1055 type_register_static(&ccw_machine_info
);
1058 type_init(ccw_machine_register_types
)