summaryrefslogtreecommitdiff
path: root/hw/s390x/s390-virtio-ccw.c
diff options
context:
space:
mode:
Diffstat (limited to 'hw/s390x/s390-virtio-ccw.c')
-rw-r--r--hw/s390x/s390-virtio-ccw.c90
1 files changed, 67 insertions, 23 deletions
diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c
index 41ca6668e2..ce3921e4de 100644
--- a/hw/s390x/s390-virtio-ccw.c
+++ b/hw/s390x/s390-virtio-ccw.c
@@ -24,11 +24,13 @@
#include "qemu/config-file.h"
#include "s390-pci-bus.h"
#include "hw/s390x/storage-keys.h"
+#include "hw/s390x/storage-attributes.h"
#include "hw/compat.h"
#include "ipl.h"
#include "hw/s390x/s390-virtio-ccw.h"
#include "hw/s390x/css-bridge.h"
#include "migration/register.h"
+#include "cpu_models.h"
static const char *const reset_dev_types[] = {
TYPE_VIRTUAL_CSS_BRIDGE,
@@ -103,6 +105,8 @@ void s390_memory_init(ram_addr_t mem_size)
/* Initialize storage key device */
s390_skeys_init();
+ /* Initialize storage attributes device */
+ s390_stattrib_init();
}
static SaveVMHandlers savevm_gtod = {
@@ -119,6 +123,9 @@ static void ccw_init(MachineState *machine)
s390_sclp_init();
s390_memory_init(machine->ram_size);
+ /* init CPUs */
+ s390_init_cpus(machine);
+
s390_flic_init();
/* get a BUS */
@@ -135,9 +142,6 @@ static void ccw_init(MachineState *machine)
/* register hypercalls */
virtio_ccw_register_hcalls();
- /* init CPUs */
- s390_init_cpus(machine);
-
if (kvm_enabled()) {
kvm_s390_enable_css_support(s390_cpu_addr2state(0));
}
@@ -206,6 +210,8 @@ static void ccw_machine_class_init(ObjectClass *oc, void *data)
s390mc->ri_allowed = true;
s390mc->cpu_model_allowed = true;
+ s390mc->css_migration_enabled = true;
+ s390mc->gs_allowed = true;
mc->init = ccw_init;
mc->reset = s390_machine_reset;
mc->hot_add_cpu = s390_hot_add_cpu;
@@ -252,36 +258,51 @@ static inline void machine_set_dea_key_wrap(Object *obj, bool value,
ms->dea_key_wrap = value;
}
+static S390CcwMachineClass *current_mc;
+
+static S390CcwMachineClass *get_machine_class(void)
+{
+ if (unlikely(!current_mc)) {
+ /*
+ * No s390 ccw machine was instantiated, we are likely to
+ * be called for the 'none' machine. The properties will
+ * have their after-initialization values.
+ */
+ current_mc = S390_MACHINE_CLASS(
+ object_class_by_name(TYPE_S390_CCW_MACHINE));
+ }
+ return current_mc;
+}
+
bool ri_allowed(void)
{
+ if (!kvm_enabled()) {
+ return false;
+ }
+ /* for "none" machine this results in true */
+ return get_machine_class()->ri_allowed;
+}
+
+bool cpu_model_allowed(void)
+{
+ /* for "none" machine this results in true */
+ return get_machine_class()->cpu_model_allowed;
+}
+
+bool gs_allowed(void)
+{
if (kvm_enabled()) {
MachineClass *mc = MACHINE_GET_CLASS(qdev_get_machine());
if (object_class_dynamic_cast(OBJECT_CLASS(mc),
TYPE_S390_CCW_MACHINE)) {
S390CcwMachineClass *s390mc = S390_MACHINE_CLASS(mc);
- return s390mc->ri_allowed;
+ return s390mc->gs_allowed;
}
- /*
- * Make sure the "none" machine can have ri, otherwise it won't * be
- * unlocked in KVM and therefore the host CPU model might be wrong.
- */
+ /* Make sure the "none" machine can have gs */
return true;
}
- return 0;
-}
-
-bool cpu_model_allowed(void)
-{
- MachineClass *mc = MACHINE_GET_CLASS(qdev_get_machine());
- if (object_class_dynamic_cast(OBJECT_CLASS(mc),
- TYPE_S390_CCW_MACHINE)) {
- S390CcwMachineClass *s390mc = S390_MACHINE_CLASS(mc);
-
- return s390mc->cpu_model_allowed;
- }
- /* allow CPU model qmp queries with the "none" machine */
- return true;
+ return false;
}
static char *machine_get_loadparm(Object *obj, Error **errp)
@@ -376,6 +397,11 @@ static const TypeInfo ccw_machine_info = {
},
};
+bool css_migration_enabled(void)
+{
+ return get_machine_class()->css_migration_enabled;
+}
+
#define DEFINE_CCW_MACHINE(suffix, verstr, latest) \
static void ccw_machine_##suffix##_class_init(ObjectClass *oc, \
void *data) \
@@ -391,6 +417,7 @@ static const TypeInfo ccw_machine_info = {
static void ccw_machine_##suffix##_instance_init(Object *obj) \
{ \
MachineState *machine = MACHINE(obj); \
+ current_mc = S390_MACHINE_CLASS(MACHINE_GET_CLASS(machine)); \
ccw_machine_##suffix##_instance_options(machine); \
} \
static const TypeInfo ccw_machine_##suffix##_info = { \
@@ -406,7 +433,12 @@ static const TypeInfo ccw_machine_info = {
type_init(ccw_machine_register_##suffix)
#define CCW_COMPAT_2_9 \
- HW_COMPAT_2_9
+ HW_COMPAT_2_9 \
+ {\
+ .driver = TYPE_S390_STATTRIB,\
+ .property = "migration-enabled",\
+ .value = "off",\
+ },
#define CCW_COMPAT_2_8 \
HW_COMPAT_2_8 \
@@ -476,6 +508,9 @@ static const TypeInfo ccw_machine_info = {
static void ccw_machine_2_10_instance_options(MachineState *machine)
{
+ if (css_migration_enabled()) {
+ css_register_vmstate();
+ }
}
static void ccw_machine_2_10_class_options(MachineClass *mc)
@@ -486,12 +521,21 @@ DEFINE_CCW_MACHINE(2_10, "2.10", true);
static void ccw_machine_2_9_instance_options(MachineState *machine)
{
ccw_machine_2_10_instance_options(machine);
+ s390_cpudef_featoff_greater(12, 1, S390_FEAT_ESOP);
+ s390_cpudef_featoff_greater(12, 1, S390_FEAT_SIDE_EFFECT_ACCESS_ESOP2);
+ s390_cpudef_featoff_greater(12, 1, S390_FEAT_ZPCI);
+ s390_cpudef_featoff_greater(12, 1, S390_FEAT_ADAPTER_INT_SUPPRESSION);
+ s390_cpudef_featoff_greater(12, 1, S390_FEAT_ADAPTER_EVENT_NOTIFICATION);
}
static void ccw_machine_2_9_class_options(MachineClass *mc)
{
+ S390CcwMachineClass *s390mc = S390_MACHINE_CLASS(mc);
+
+ s390mc->gs_allowed = false;
ccw_machine_2_10_class_options(mc);
SET_MACHINE_COMPAT(mc, CCW_COMPAT_2_9);
+ s390mc->css_migration_enabled = false;
}
DEFINE_CCW_MACHINE(2_9, "2.9", false);