Signed-off-by: Christian Borntraeger <address@hidden>
---
hw/intc/s390_flic.c | 11 +++++++++--
hw/intc/s390_flic_kvm.c | 8 +++++++-
hw/s390x/s390-virtio-ccw.c | 8 ++++++--
include/hw/s390x/s390_flic.h | 1 +
target/s390x/cpu_models.c | 6 ++++++
target/s390x/kvm.c | 8 +-------
6 files changed, 30 insertions(+), 12 deletions(-)
diff --git a/hw/intc/s390_flic.c b/hw/intc/s390_flic.c
index 6eaf178..08040fe 100644
--- a/hw/intc/s390_flic.c
+++ b/hw/intc/s390_flic.c
@@ -1,7 +1,7 @@
/*
* QEMU S390x floating interrupt controller (flic)
*
- * Copyright 2014 IBM Corp.
+ * Copyright 2014,2017 IBM Corp.
* Author(s): Jens Freimann <address@hidden>
* Cornelia Huck <address@hidden>
*
@@ -49,6 +49,13 @@ void s390_flic_init(void)
qdev_init_nofail(dev);
}
+void s390_flic_enable_ais(void)
+{
+ S390FLICState *fs = s390_get_flic();
+
+ fs->ais_supported = true;
+}
+
static int qemu_s390_register_io_adapter(S390FLICState *fs, uint32_t id,
uint8_t isc, bool swap,
bool is_maskable, uint8_t flags)
@@ -186,7 +193,7 @@ static void s390_flic_common_realize(DeviceState *dev,
Error **errp)
return;
}
- fs->ais_supported = s390_has_feat(S390_FEAT_ADAPTER_INT_SUPPRESSION);
+ fs->ais_supported = false;
}
static void s390_flic_class_init(ObjectClass *oc, void *data)
diff --git a/hw/intc/s390_flic_kvm.c b/hw/intc/s390_flic_kvm.c
index 7ead17a..a655567 100644
--- a/hw/intc/s390_flic_kvm.c
+++ b/hw/intc/s390_flic_kvm.c
@@ -1,7 +1,7 @@
/*
* QEMU S390x KVM floating interrupt controller (flic)
*
- * Copyright 2014 IBM Corp.
+ * Copyright 2014,2017 IBM Corp.
* Author(s): Jens Freimann <address@hidden>
* Cornelia Huck <address@hidden>
*
@@ -557,6 +557,12 @@ static void kvm_s390_flic_realize(DeviceState *dev, Error
**errp)
test_attr.group = KVM_DEV_FLIC_CLEAR_IO_IRQ;
flic_state->clear_io_supported = !ioctl(flic_state->fd,
KVM_HAS_DEVICE_ATTR, test_attr);
+ /* try enable the AIS facility */
+ test_attr.group = KVM_DEV_FLIC_AISM_ALL;
+ if (!ioctl(flic_state->fd, KVM_HAS_DEVICE_ATTR, test_attr)) {
+ kvm_vm_enable_cap(kvm_state, KVM_CAP_S390_AIS, 0);
+ }
+
return;
fail:
error_propagate(errp, errp_local);
diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c
index fafbc6d..11d4dc4 100644
--- a/hw/s390x/s390-virtio-ccw.c
+++ b/hw/s390x/s390-virtio-ccw.c
@@ -279,11 +279,15 @@ static void ccw_init(MachineState *machine)
s390_sclp_init();
s390_memory_init(machine->ram_size);
+ /*
+ * This might also enable some KVM features like AIS, so it must
+ * be called before the CPU model
+ */
+ s390_flic_init();
+
/* init CPUs (incl. CPU model) early so s390_has_feature() works */
s390_init_cpus(machine);
- s390_flic_init();
-
/* get a BUS */
css_bus = virtual_css_bus_init();
s390_init_ipl_dev(machine->kernel_filename, machine->kernel_cmdline,
diff --git a/include/hw/s390x/s390_flic.h b/include/hw/s390x/s390_flic.h
index 7aab6ef..ac4e170 100644
--- a/include/hw/s390x/s390_flic.h
+++ b/include/hw/s390x/s390_flic.h
@@ -90,6 +90,7 @@ void s390_flic_init(void);
S390FLICState *s390_get_flic(void);
bool ais_needed(void *opaque);
+void s390_flic_enable_ais(void);
#ifdef CONFIG_KVM
DeviceState *s390_flic_kvm_create(void);
diff --git a/target/s390x/cpu_models.c b/target/s390x/cpu_models.c
index 5169379..03ff583 100644
--- a/target/s390x/cpu_models.c
+++ b/target/s390x/cpu_models.c
@@ -23,6 +23,7 @@
#include "qapi/qobject-input-visitor.h"
#include "qapi/qmp/qbool.h"
#ifndef CONFIG_USER_ONLY
+#include "hw/s390x/s390_flic.h"
#include "sysemu/arch_init.h"
#endif
@@ -901,6 +902,11 @@ static inline void apply_cpu_model(const S390CPUModel
*model, Error **errp)
applied_model = *model;
}
}
+
+ if (model &&
+ test_bit(S390_FEAT_ADAPTER_INT_SUPPRESSION, model->features)) {
+ s390_flic_enable_ais();
+ }
#endif
}
diff --git a/target/s390x/kvm.c b/target/s390x/kvm.c
index ebb75ca..6c5c57e 100644
--- a/target/s390x/kvm.c
+++ b/target/s390x/kvm.c
@@ -311,13 +311,7 @@ int kvm_arch_init(MachineState *ms, KVMState *s)
}
}
- /*
- * The migration interface for ais was introduced with kernel 4.13
- * but the capability itself had been active since 4.12. As migration
- * support is considered necessary let's disable ais in the 2.10
- * machine.
- */
- /* kvm_vm_enable_cap(s, KVM_CAP_S390_AIS, 0); */
+ /* The AIS enablement happens in the flic realize */
qemu_mutex_init(&qemu_sigp_mutex);