/*
- * QEMU S390x KVM floating interrupt controller (flic)
+ * QEMU S390x floating interrupt controller (flic)
*
* Copyright 2014 IBM Corp.
*
* This work is licensed under the terms of the GNU GPL, version 2 or (at
* your option) any later version. See the COPYING file in the top-level
* directory.
*/
-#include <sys/ioctl.h>
+#include "qemu/osdep.h"
#include "qemu/error-report.h"
+#include "qemu/main-loop.h"
+#include "qemu/module.h"
#include "hw/sysbus.h"
-#include "sysemu/kvm.h"
-#include "migration/qemu-file.h"
+#include "hw/s390x/ioinst.h"
#include "hw/s390x/s390_flic.h"
+#include "hw/qdev-properties.h"
+#include "hw/s390x/css.h"
#include "trace.h"
+#include "cpu.h"
+#include "qapi/error.h"
+#include "hw/s390x/s390-virtio-ccw.h"
-#define FLIC_SAVE_INITIAL_SIZE getpagesize()
-#define FLIC_FAILED (-1UL)
-#define FLIC_SAVEVM_VERSION 1
+S390FLICStateClass *s390_get_flic_class(S390FLICState *fs)
+{
+ static S390FLICStateClass *class;
+
+ if (!class) {
+ /* we only have one flic device, so this is fine to cache */
+ class = S390_FLIC_COMMON_GET_CLASS(fs);
+ }
+ return class;
+}
+
+QEMUS390FLICState *s390_get_qemu_flic(S390FLICState *fs)
+{
+ static QEMUS390FLICState *flic;
+
+ if (!flic) {
+ /* we only have one flic device, so this is fine to cache */
+ flic = QEMU_S390_FLIC(fs);
+ }
+ return flic;
+}
+
+S390FLICState *s390_get_flic(void)
+{
+ static S390FLICState *fs;
+
+ if (!fs) {
+ fs = S390_FLIC_COMMON(object_resolve_path_type("",
+ TYPE_S390_FLIC_COMMON,
+ NULL));
+ }
+ return fs;
+}
void s390_flic_init(void)
{
DeviceState *dev;
- int r;
if (kvm_enabled()) {
- dev = qdev_create(NULL, "s390-flic");
- object_property_add_child(qdev_get_machine(), "s390-flic",
- OBJECT(dev), NULL);
- r = qdev_init(dev);
- if (r) {
- error_report("flic: couldn't create qdev");
- }
+ dev = qdev_create(NULL, TYPE_KVM_S390_FLIC);
+ object_property_add_child(qdev_get_machine(), TYPE_KVM_S390_FLIC,
+ OBJECT(dev), NULL);
+ } else {
+ dev = qdev_create(NULL, TYPE_QEMU_S390_FLIC);
+ object_property_add_child(qdev_get_machine(), TYPE_QEMU_S390_FLIC,
+ OBJECT(dev), NULL);
}
+ qdev_init_nofail(dev);
}
-/**
- * flic_get_all_irqs - store all pending irqs in buffer
- * @buf: pointer to buffer which is passed to kernel
- * @len: length of buffer
- * @flic: pointer to flic device state
- *
- * Returns: -ENOMEM if buffer is too small,
- * -EINVAL if attr.group is invalid,
- * -EFAULT if copying to userspace failed,
- * on success return number of stored interrupts
- */
-static int flic_get_all_irqs(KVMS390FLICState *flic,
- void *buf, int len)
+static int qemu_s390_register_io_adapter(S390FLICState *fs, uint32_t id,
+ uint8_t isc, bool swap,
+ bool is_maskable, uint8_t flags)
{
- struct kvm_device_attr attr = {
- .group = KVM_DEV_FLIC_GET_ALL_IRQS,
- .addr = (uint64_t) buf,
- .attr = len,
- };
- int rc;
+ /* nothing to do */
+ return 0;
+}
- rc = ioctl(flic->fd, KVM_GET_DEVICE_ATTR, &attr);
+static int qemu_s390_io_adapter_map(S390FLICState *fs, uint32_t id,
+ uint64_t map_addr, bool do_map)
+{
+ /* nothing to do */
+ return 0;
+}
- return rc == -1 ? -errno : rc;
+static int qemu_s390_add_adapter_routes(S390FLICState *fs,
+ AdapterRoutes *routes)
+{
+ return -ENOSYS;
}
-static void flic_enable_pfault(KVMS390FLICState *flic)
+static void qemu_s390_release_adapter_routes(S390FLICState *fs,
+ AdapterRoutes *routes)
{
- struct kvm_device_attr attr = {
- .group = KVM_DEV_FLIC_APF_ENABLE,
- };
- int rc;
+}
- rc = ioctl(flic->fd, KVM_SET_DEVICE_ATTR, &attr);
+static int qemu_s390_clear_io_flic(S390FLICState *fs, uint16_t subchannel_id,
+ uint16_t subchannel_nr)
+{
+ QEMUS390FLICState *flic = s390_get_qemu_flic(fs);
+ QEMUS390FlicIO *cur, *next;
+ uint8_t isc;
- if (rc) {
- fprintf(stderr, "flic: couldn't enable pfault\n");
+ g_assert(qemu_mutex_iothread_locked());
+ if (!(flic->pending & FLIC_PENDING_IO)) {
+ return 0;
}
-}
-static void flic_disable_wait_pfault(KVMS390FLICState *flic)
-{
- struct kvm_device_attr attr = {
- .group = KVM_DEV_FLIC_APF_DISABLE_WAIT,
- };
- int rc;
+ /* check all iscs */
+ for (isc = 0; isc < 8; isc++) {
+ if (QLIST_EMPTY(&flic->io[isc])) {
+ continue;
+ }
- rc = ioctl(flic->fd, KVM_SET_DEVICE_ATTR, &attr);
+ /* search and delete any matching one */
+ QLIST_FOREACH_SAFE(cur, &flic->io[isc], next, next) {
+ if (cur->id == subchannel_id && cur->nr == subchannel_nr) {
+ QLIST_REMOVE(cur, next);
+ g_free(cur);
+ }
+ }
- if (rc) {
- fprintf(stderr, "flic: couldn't disable pfault\n");
+ /* update our indicator bit */
+ if (QLIST_EMPTY(&flic->io[isc])) {
+ flic->pending &= ~ISC_TO_PENDING_IO(isc);
+ }
}
+ return 0;
}
-/** flic_enqueue_irqs - returns 0 on success
- * @buf: pointer to buffer which is passed to kernel
- * @len: length of buffer
- * @flic: pointer to flic device state
- *
- * Returns: -EINVAL if attr.group is unknown
- */
-static int flic_enqueue_irqs(void *buf, uint64_t len,
- KVMS390FLICState *flic)
+static int qemu_s390_modify_ais_mode(S390FLICState *fs, uint8_t isc,
+ uint16_t mode)
+{
+ QEMUS390FLICState *flic = s390_get_qemu_flic(fs);
+
+ switch (mode) {
+ case SIC_IRQ_MODE_ALL:
+ flic->simm &= ~AIS_MODE_MASK(isc);
+ flic->nimm &= ~AIS_MODE_MASK(isc);
+ break;
+ case SIC_IRQ_MODE_SINGLE:
+ flic->simm |= AIS_MODE_MASK(isc);
+ flic->nimm &= ~AIS_MODE_MASK(isc);
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
+static int qemu_s390_inject_airq(S390FLICState *fs, uint8_t type,
+ uint8_t isc, uint8_t flags)
{
- int rc;
- struct kvm_device_attr attr = {
- .group = KVM_DEV_FLIC_ENQUEUE,
- .addr = (uint64_t) buf,
- .attr = len,
- };
+ QEMUS390FLICState *flic = s390_get_qemu_flic(fs);
+ S390FLICStateClass *fsc = s390_get_flic_class(fs);
+ bool flag = flags & S390_ADAPTER_SUPPRESSIBLE;
+ uint32_t io_int_word = (isc << 27) | IO_INT_WORD_AI;
+
+ if (flag && (flic->nimm & AIS_MODE_MASK(isc))) {
+ trace_qemu_s390_airq_suppressed(type, isc);
+ return 0;
+ }
- rc = ioctl(flic->fd, KVM_SET_DEVICE_ATTR, &attr);
+ fsc->inject_io(fs, 0, 0, 0, io_int_word);
- return rc ? -errno : 0;
+ if (flag && (flic->simm & AIS_MODE_MASK(isc))) {
+ flic->nimm |= AIS_MODE_MASK(isc);
+ trace_qemu_s390_suppress_airq(isc, "Single-Interruption Mode",
+ "NO-Interruptions Mode");
+ }
+
+ return 0;
}
-/**
- * __get_all_irqs - store all pending irqs in buffer
- * @flic: pointer to flic device state
- * @buf: pointer to pointer to a buffer
- * @len: length of buffer
- *
- * Returns: return value of flic_get_all_irqs
- * Note: Retry and increase buffer size until flic_get_all_irqs
- * either returns a value >= 0 or a negative error code.
- * -ENOMEM is an exception, which means the buffer is too small
- * and we should try again. Other negative error codes can be
- * -EFAULT and -EINVAL which we ignore at this point
- */
-static int __get_all_irqs(KVMS390FLICState *flic,
- void **buf, int len)
+static void qemu_s390_flic_notify(uint32_t type)
{
- int r;
-
- do {
- /* returns -ENOMEM if buffer is too small and number
- * of queued interrupts on success */
- r = flic_get_all_irqs(flic, *buf, len);
- if (r >= 0) {
- break;
+ CPUState *cs;
+
+ /*
+ * We have to make all CPUs see CPU_INTERRUPT_HARD, so they might
+ * consider it. We will kick all running CPUs and only relevant
+ * sleeping ones.
+ */
+ CPU_FOREACH(cs) {
+ S390CPU *cpu = S390_CPU(cs);
+
+ cs->interrupt_request |= CPU_INTERRUPT_HARD;
+
+ /* ignore CPUs that are not sleeping */
+ if (s390_cpu_get_state(cpu) != S390_CPU_STATE_OPERATING &&
+ s390_cpu_get_state(cpu) != S390_CPU_STATE_LOAD) {
+ continue;
}
- len *= 2;
- *buf = g_try_realloc(*buf, len);
- if (!buf) {
- return -ENOMEM;
+
+ /* we always kick running CPUs for now, this is tricky */
+ if (cs->halted) {
+ /* don't check for subclasses, CPUs double check when waking up */
+ if (type & FLIC_PENDING_SERVICE) {
+ if (!(cpu->env.psw.mask & PSW_MASK_EXT)) {
+ continue;
+ }
+ } else if (type & FLIC_PENDING_IO) {
+ if (!(cpu->env.psw.mask & PSW_MASK_IO)) {
+ continue;
+ }
+ } else if (type & FLIC_PENDING_MCHK_CR) {
+ if (!(cpu->env.psw.mask & PSW_MASK_MCHECK)) {
+ continue;
+ }
+ }
}
- } while (r == -ENOMEM && len <= KVM_S390_FLIC_MAX_BUFFER);
+ cpu_interrupt(cs, CPU_INTERRUPT_HARD);
+ }
+}
+
+uint32_t qemu_s390_flic_dequeue_service(QEMUS390FLICState *flic)
+{
+ uint32_t tmp;
+
+ g_assert(qemu_mutex_iothread_locked());
+ g_assert(flic->pending & FLIC_PENDING_SERVICE);
+ tmp = flic->service_param;
+ flic->service_param = 0;
+ flic->pending &= ~FLIC_PENDING_SERVICE;
- return r;
+ return tmp;
}
-/**
- * kvm_flic_save - Save pending floating interrupts
- * @f: QEMUFile containing migration state
- * @opaque: pointer to flic device state
- *
- * Note: Pass buf and len to kernel. Start with one page and
- * increase until buffer is sufficient or maxium size is
- * reached
- */
-static void kvm_flic_save(QEMUFile *f, void *opaque)
+/* caller has to free the returned object */
+QEMUS390FlicIO *qemu_s390_flic_dequeue_io(QEMUS390FLICState *flic, uint64_t cr6)
{
- KVMS390FLICState *flic = opaque;
- int len = FLIC_SAVE_INITIAL_SIZE;
- void *buf;
- int count;
-
- flic_disable_wait_pfault((struct KVMS390FLICState *) opaque);
-
- buf = g_try_malloc0(len);
- if (!buf) {
- /* Storing FLIC_FAILED into the count field here will cause the
- * target system to fail when attempting to load irqs from the
- * migration state */
- error_report("flic: couldn't allocate memory");
- qemu_put_be64(f, FLIC_FAILED);
- return;
+ QEMUS390FlicIO *io;
+ uint8_t isc;
+
+ g_assert(qemu_mutex_iothread_locked());
+ if (!(flic->pending & CR6_TO_PENDING_IO(cr6))) {
+ return NULL;
}
- count = __get_all_irqs(flic, &buf, len);
- if (count < 0) {
- error_report("flic: couldn't retrieve irqs from kernel, rc %d",
- count);
- /* Storing FLIC_FAILED into the count field here will cause the
- * target system to fail when attempting to load irqs from the
- * migration state */
- qemu_put_be64(f, FLIC_FAILED);
- } else {
- qemu_put_be64(f, count);
- qemu_put_buffer(f, (uint8_t *) buf,
- count * sizeof(struct kvm_s390_irq));
+ for (isc = 0; isc < 8; isc++) {
+ if (QLIST_EMPTY(&flic->io[isc]) || !(cr6 & ISC_TO_ISC_BITS(isc))) {
+ continue;
+ }
+ io = QLIST_FIRST(&flic->io[isc]);
+ QLIST_REMOVE(io, next);
+
+ /* update our indicator bit */
+ if (QLIST_EMPTY(&flic->io[isc])) {
+ flic->pending &= ~ISC_TO_PENDING_IO(isc);
+ }
+ return io;
}
- g_free(buf);
+
+ return NULL;
}
-/**
- * kvm_flic_load - Load pending floating interrupts
- * @f: QEMUFile containing migration state
- * @opaque: pointer to flic device state
- * @version_id: version id for migration
- *
- * Returns: value of flic_enqueue_irqs, -EINVAL on error
- * Note: Do nothing when no interrupts where stored
- * in QEMUFile
- */
-static int kvm_flic_load(QEMUFile *f, void *opaque, int version_id)
+void qemu_s390_flic_dequeue_crw_mchk(QEMUS390FLICState *flic)
{
- uint64_t len = 0;
- uint64_t count = 0;
- void *buf = NULL;
- int r = 0;
-
- if (version_id != FLIC_SAVEVM_VERSION) {
- r = -EINVAL;
- goto out;
- }
+ g_assert(qemu_mutex_iothread_locked());
+ g_assert(flic->pending & FLIC_PENDING_MCHK_CR);
+ flic->pending &= ~FLIC_PENDING_MCHK_CR;
+}
- flic_enable_pfault((struct KVMS390FLICState *) opaque);
+static void qemu_s390_inject_service(S390FLICState *fs, uint32_t parm)
+{
+ QEMUS390FLICState *flic = s390_get_qemu_flic(fs);
- count = qemu_get_be64(f);
- len = count * sizeof(struct kvm_s390_irq);
- if (count == FLIC_FAILED) {
- r = -EINVAL;
- goto out;
- }
- if (count == 0) {
- r = 0;
- goto out;
- }
- buf = g_try_malloc0(len);
- if (!buf) {
- r = -ENOMEM;
- goto out;
- }
+ g_assert(qemu_mutex_iothread_locked());
+ /* multiplexing is good enough for sclp - kvm does it internally as well */
+ flic->service_param |= parm;
+ flic->pending |= FLIC_PENDING_SERVICE;
- if (qemu_get_buffer(f, (uint8_t *) buf, len) != len) {
- r = -EINVAL;
- goto out_free;
- }
- r = flic_enqueue_irqs(buf, len, (struct KVMS390FLICState *) opaque);
+ qemu_s390_flic_notify(FLIC_PENDING_SERVICE);
+}
+
+static void qemu_s390_inject_io(S390FLICState *fs, uint16_t subchannel_id,
+ uint16_t subchannel_nr, uint32_t io_int_parm,
+ uint32_t io_int_word)
+{
+ const uint8_t isc = IO_INT_WORD_ISC(io_int_word);
+ QEMUS390FLICState *flic = s390_get_qemu_flic(fs);
+ QEMUS390FlicIO *io;
-out_free:
- g_free(buf);
-out:
- return r;
+ g_assert(qemu_mutex_iothread_locked());
+ io = g_new0(QEMUS390FlicIO, 1);
+ io->id = subchannel_id;
+ io->nr = subchannel_nr;
+ io->parm = io_int_parm;
+ io->word = io_int_word;
+
+ QLIST_INSERT_HEAD(&flic->io[isc], io, next);
+ flic->pending |= ISC_TO_PENDING_IO(isc);
+
+ qemu_s390_flic_notify(ISC_TO_PENDING_IO(isc));
}
-static void kvm_s390_flic_realize(DeviceState *dev, Error **errp)
+static void qemu_s390_inject_crw_mchk(S390FLICState *fs)
{
- KVMS390FLICState *flic_state = KVM_S390_FLIC(dev);
- struct kvm_create_device cd = {0};
- int ret;
+ QEMUS390FLICState *flic = s390_get_qemu_flic(fs);
- flic_state->fd = -1;
- if (!kvm_check_extension(kvm_state, KVM_CAP_DEVICE_CTRL)) {
- trace_flic_no_device_api(errno);
- return;
- }
+ g_assert(qemu_mutex_iothread_locked());
+ flic->pending |= FLIC_PENDING_MCHK_CR;
- cd.type = KVM_DEV_TYPE_FLIC;
- ret = kvm_vm_ioctl(kvm_state, KVM_CREATE_DEVICE, &cd);
- if (ret < 0) {
- trace_flic_create_device(errno);
- return;
- }
- flic_state->fd = cd.fd;
+ qemu_s390_flic_notify(FLIC_PENDING_MCHK_CR);
+}
- /* Register savevm handler for floating interrupts */
- register_savevm(NULL, "s390-flic", 0, 1, kvm_flic_save,
- kvm_flic_load, (void *) flic_state);
+bool qemu_s390_flic_has_service(QEMUS390FLICState *flic)
+{
+ /* called without lock via cc->has_work, will be validated under lock */
+ return !!(flic->pending & FLIC_PENDING_SERVICE);
}
-static void kvm_s390_flic_unrealize(DeviceState *dev, Error **errp)
+bool qemu_s390_flic_has_io(QEMUS390FLICState *flic, uint64_t cr6)
{
- KVMS390FLICState *flic_state = KVM_S390_FLIC(dev);
+ /* called without lock via cc->has_work, will be validated under lock */
+ return !!(flic->pending & CR6_TO_PENDING_IO(cr6));
+}
- unregister_savevm(DEVICE(flic_state), "s390-flic", flic_state);
+bool qemu_s390_flic_has_crw_mchk(QEMUS390FLICState *flic)
+{
+ /* called without lock via cc->has_work, will be validated under lock */
+ return !!(flic->pending & FLIC_PENDING_MCHK_CR);
}
-static void kvm_s390_flic_reset(DeviceState *dev)
+bool qemu_s390_flic_has_any(QEMUS390FLICState *flic)
{
- KVMS390FLICState *flic = KVM_S390_FLIC(dev);
- struct kvm_device_attr attr = {
- .group = KVM_DEV_FLIC_CLEAR_IRQS,
- };
- int rc = 0;
+ g_assert(qemu_mutex_iothread_locked());
+ return !!flic->pending;
+}
- if (flic->fd == -1) {
- return;
+static void qemu_s390_flic_reset(DeviceState *dev)
+{
+ QEMUS390FLICState *flic = QEMU_S390_FLIC(dev);
+ QEMUS390FlicIO *cur, *next;
+ int isc;
+
+ g_assert(qemu_mutex_iothread_locked());
+ flic->simm = 0;
+ flic->nimm = 0;
+ flic->pending = 0;
+
+ /* remove all pending io interrupts */
+ for (isc = 0; isc < 8; isc++) {
+ QLIST_FOREACH_SAFE(cur, &flic->io[isc], next, next) {
+ QLIST_REMOVE(cur, next);
+ g_free(cur);
+ }
}
+}
- flic_disable_wait_pfault(flic);
+bool ais_needed(void *opaque)
+{
+ S390FLICState *s = opaque;
+
+ return s->ais_supported;
+}
- rc = ioctl(flic->fd, KVM_SET_DEVICE_ATTR, &attr);
- if (rc) {
- trace_flic_reset_failed(errno);
+static const VMStateDescription qemu_s390_flic_vmstate = {
+ .name = "qemu-s390-flic",
+ .version_id = 1,
+ .minimum_version_id = 1,
+ .needed = ais_needed,
+ .fields = (VMStateField[]) {
+ VMSTATE_UINT8(simm, QEMUS390FLICState),
+ VMSTATE_UINT8(nimm, QEMUS390FLICState),
+ VMSTATE_END_OF_LIST()
}
+};
- flic_enable_pfault(flic);
+static void qemu_s390_flic_instance_init(Object *obj)
+{
+ QEMUS390FLICState *flic = QEMU_S390_FLIC(obj);
+ int isc;
+
+ for (isc = 0; isc < 8; isc++) {
+ QLIST_INIT(&flic->io[isc]);
+ }
}
-static void kvm_s390_flic_class_init(ObjectClass *oc, void *data)
+static void qemu_s390_flic_class_init(ObjectClass *oc, void *data)
{
DeviceClass *dc = DEVICE_CLASS(oc);
+ S390FLICStateClass *fsc = S390_FLIC_COMMON_CLASS(oc);
+
+ dc->reset = qemu_s390_flic_reset;
+ dc->vmsd = &qemu_s390_flic_vmstate;
+ fsc->register_io_adapter = qemu_s390_register_io_adapter;
+ fsc->io_adapter_map = qemu_s390_io_adapter_map;
+ fsc->add_adapter_routes = qemu_s390_add_adapter_routes;
+ fsc->release_adapter_routes = qemu_s390_release_adapter_routes;
+ fsc->clear_io_irq = qemu_s390_clear_io_flic;
+ fsc->modify_ais_mode = qemu_s390_modify_ais_mode;
+ fsc->inject_airq = qemu_s390_inject_airq;
+ fsc->inject_service = qemu_s390_inject_service;
+ fsc->inject_io = qemu_s390_inject_io;
+ fsc->inject_crw_mchk = qemu_s390_inject_crw_mchk;
+}
+
+static Property s390_flic_common_properties[] = {
+ DEFINE_PROP_UINT32("adapter_routes_max_batch", S390FLICState,
+ adapter_routes_max_batch, ADAPTER_ROUTES_MAX_GSI),
+ DEFINE_PROP_END_OF_LIST(),
+};
+
+static void s390_flic_common_realize(DeviceState *dev, Error **errp)
+{
+ S390FLICState *fs = S390_FLIC_COMMON(dev);
+ uint32_t max_batch = fs->adapter_routes_max_batch;
+
+ if (max_batch > ADAPTER_ROUTES_MAX_GSI) {
+ error_setg(errp, "flic property adapter_routes_max_batch too big"
+ " (%d > %d)", max_batch, ADAPTER_ROUTES_MAX_GSI);
+ return;
+ }
- dc->realize = kvm_s390_flic_realize;
- dc->unrealize = kvm_s390_flic_unrealize;
- dc->reset = kvm_s390_flic_reset;
+ fs->ais_supported = s390_has_feat(S390_FEAT_ADAPTER_INT_SUPPRESSION);
}
-static const TypeInfo kvm_s390_flic_info = {
- .name = TYPE_KVM_S390_FLIC,
+static void s390_flic_class_init(ObjectClass *oc, void *data)
+{
+ DeviceClass *dc = DEVICE_CLASS(oc);
+
+ device_class_set_props(dc, s390_flic_common_properties);
+ dc->realize = s390_flic_common_realize;
+}
+
+static const TypeInfo qemu_s390_flic_info = {
+ .name = TYPE_QEMU_S390_FLIC,
+ .parent = TYPE_S390_FLIC_COMMON,
+ .instance_size = sizeof(QEMUS390FLICState),
+ .instance_init = qemu_s390_flic_instance_init,
+ .class_init = qemu_s390_flic_class_init,
+};
+
+
+static const TypeInfo s390_flic_common_info = {
+ .name = TYPE_S390_FLIC_COMMON,
.parent = TYPE_SYS_BUS_DEVICE,
- .instance_size = sizeof(KVMS390FLICState),
- .class_init = kvm_s390_flic_class_init,
+ .instance_size = sizeof(S390FLICState),
+ .class_init = s390_flic_class_init,
+ .class_size = sizeof(S390FLICStateClass),
};
-static void kvm_s390_flic_register_types(void)
+static void qemu_s390_flic_register_types(void)
{
- type_register_static(&kvm_s390_flic_info);
+ type_register_static(&s390_flic_common_info);
+ type_register_static(&qemu_s390_flic_info);
}
-type_init(kvm_s390_flic_register_types)
+type_init(qemu_s390_flic_register_types)
+
+static bool adapter_info_so_needed(void *opaque)
+{
+ return css_migration_enabled();
+}
+
+const VMStateDescription vmstate_adapter_info_so = {
+ .name = "s390_adapter_info/summary_offset",
+ .version_id = 1,
+ .minimum_version_id = 1,
+ .needed = adapter_info_so_needed,
+ .fields = (VMStateField[]) {
+ VMSTATE_UINT32(summary_offset, AdapterInfo),
+ VMSTATE_END_OF_LIST()
+ }
+};
+
+const VMStateDescription vmstate_adapter_info = {
+ .name = "s390_adapter_info",
+ .version_id = 1,
+ .minimum_version_id = 1,
+ .fields = (VMStateField[]) {
+ VMSTATE_UINT64(ind_offset, AdapterInfo),
+ /*
+ * We do not have to migrate neither the id nor the addresses.
+ * The id is set by css_register_io_adapter and the addresses
+ * are set based on the IndAddr objects after those get mapped.
+ */
+ VMSTATE_END_OF_LIST()
+ },
+ .subsections = (const VMStateDescription * []) {
+ &vmstate_adapter_info_so,
+ NULL
+ }
+};
+
+const VMStateDescription vmstate_adapter_routes = {
+
+ .name = "s390_adapter_routes",
+ .version_id = 1,
+ .minimum_version_id = 1,
+ .fields = (VMStateField[]) {
+ VMSTATE_STRUCT(adapter, AdapterRoutes, 1, vmstate_adapter_info,
+ AdapterInfo),
+ VMSTATE_END_OF_LIST()
+ }
+};