2013-07-16 11:04:04 +04:00
|
|
|
/*
|
2014-04-17 17:59:48 +04:00
|
|
|
* QEMU S390x floating interrupt controller (flic)
|
2013-07-16 11:04:04 +04:00
|
|
|
*
|
|
|
|
* Copyright 2014 IBM Corp.
|
|
|
|
* Author(s): Jens Freimann <jfrei@linux.vnet.ibm.com>
|
2014-04-17 17:59:48 +04:00
|
|
|
* Cornelia Huck <cornelia.huck@de.ibm.com>
|
2013-07-16 11:04:04 +04:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2016-01-26 21:17:19 +03:00
|
|
|
#include "qemu/osdep.h"
|
2013-07-16 11:04:04 +04:00
|
|
|
#include "qemu/error-report.h"
|
Include qemu/main-loop.h less
In my "build everything" tree, changing qemu/main-loop.h triggers a
recompile of some 5600 out of 6600 objects (not counting tests and
objects that don't depend on qemu/osdep.h). It includes block/aio.h,
which in turn includes qemu/event_notifier.h, qemu/notify.h,
qemu/processor.h, qemu/qsp.h, qemu/queue.h, qemu/thread-posix.h,
qemu/thread.h, qemu/timer.h, and a few more.
Include qemu/main-loop.h only where it's needed. Touching it now
recompiles only some 1700 objects. For block/aio.h and
qemu/event_notifier.h, these numbers drop from 5600 to 2800. For the
others, they shrink only slightly.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20190812052359.30071-21-armbru@redhat.com>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
2019-08-12 08:23:50 +03:00
|
|
|
#include "qemu/main-loop.h"
|
2019-05-23 17:35:07 +03:00
|
|
|
#include "qemu/module.h"
|
2013-07-16 11:04:04 +04:00
|
|
|
#include "hw/sysbus.h"
|
2017-02-17 10:00:59 +03:00
|
|
|
#include "hw/s390x/ioinst.h"
|
2013-07-16 11:04:04 +04:00
|
|
|
#include "hw/s390x/s390_flic.h"
|
2019-08-12 08:23:51 +03:00
|
|
|
#include "hw/qdev-properties.h"
|
2017-02-17 10:00:59 +03:00
|
|
|
#include "hw/s390x/css.h"
|
2013-07-16 11:04:04 +04:00
|
|
|
#include "trace.h"
|
2016-12-09 15:51:46 +03:00
|
|
|
#include "qapi/error.h"
|
2017-07-04 00:34:14 +03:00
|
|
|
#include "hw/s390x/s390-virtio-ccw.h"
|
2013-07-16 11:04:04 +04:00
|
|
|
|
2018-01-29 15:56:23 +03:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2018-01-29 15:56:21 +03:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2014-04-17 17:59:48 +04:00
|
|
|
S390FLICState *s390_get_flic(void)
|
2013-09-05 15:54:39 +04:00
|
|
|
{
|
2017-03-17 12:28:30 +03:00
|
|
|
static S390FLICState *fs;
|
2013-09-05 15:54:39 +04:00
|
|
|
|
2014-04-17 17:59:48 +04:00
|
|
|
if (!fs) {
|
2018-01-29 15:56:08 +03:00
|
|
|
fs = S390_FLIC_COMMON(object_resolve_path_type("",
|
|
|
|
TYPE_S390_FLIC_COMMON,
|
|
|
|
NULL));
|
2013-09-05 15:54:39 +04:00
|
|
|
}
|
2014-04-17 17:59:48 +04:00
|
|
|
return fs;
|
2013-09-05 15:54:39 +04:00
|
|
|
}
|
|
|
|
|
2014-04-17 17:59:48 +04:00
|
|
|
void s390_flic_init(void)
|
2013-07-16 11:04:04 +04:00
|
|
|
{
|
2014-04-17 17:59:48 +04:00
|
|
|
DeviceState *dev;
|
2013-07-16 11:04:04 +04:00
|
|
|
|
2018-01-29 15:56:07 +03:00
|
|
|
if (kvm_enabled()) {
|
qdev: Convert uses of qdev_create() with Coccinelle
This is the transformation explained in the commit before previous.
Takes care of just one pattern that needs conversion. More to come in
this series.
Coccinelle script:
@ depends on !(file in "hw/arm/highbank.c")@
expression bus, type_name, dev, expr;
@@
- dev = qdev_create(bus, type_name);
+ dev = qdev_new(type_name);
... when != dev = expr
- qdev_init_nofail(dev);
+ qdev_realize_and_unref(dev, bus, &error_fatal);
@@
expression bus, type_name, dev, expr;
identifier DOWN;
@@
- dev = DOWN(qdev_create(bus, type_name));
+ dev = DOWN(qdev_new(type_name));
... when != dev = expr
- qdev_init_nofail(DEVICE(dev));
+ qdev_realize_and_unref(DEVICE(dev), bus, &error_fatal);
@@
expression bus, type_name, expr;
identifier dev;
@@
- DeviceState *dev = qdev_create(bus, type_name);
+ DeviceState *dev = qdev_new(type_name);
... when != dev = expr
- qdev_init_nofail(dev);
+ qdev_realize_and_unref(dev, bus, &error_fatal);
@@
expression bus, type_name, dev, expr, errp;
symbol true;
@@
- dev = qdev_create(bus, type_name);
+ dev = qdev_new(type_name);
... when != dev = expr
- object_property_set_bool(OBJECT(dev), true, "realized", errp);
+ qdev_realize_and_unref(dev, bus, errp);
@@
expression bus, type_name, expr, errp;
identifier dev;
symbol true;
@@
- DeviceState *dev = qdev_create(bus, type_name);
+ DeviceState *dev = qdev_new(type_name);
... when != dev = expr
- object_property_set_bool(OBJECT(dev), true, "realized", errp);
+ qdev_realize_and_unref(dev, bus, errp);
The first rule exempts hw/arm/highbank.c, because it matches along two
control flow paths there, with different @type_name. Covered by the
next commit's manual conversions.
Missing #include "qapi/error.h" added manually.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20200610053247.1583243-10-armbru@redhat.com>
[Conflicts in hw/misc/empty_slot.c and hw/sparc/leon3.c resolved]
2020-06-10 08:31:58 +03:00
|
|
|
dev = qdev_new(TYPE_KVM_S390_FLIC);
|
2018-01-29 15:56:07 +03:00
|
|
|
object_property_add_child(qdev_get_machine(), TYPE_KVM_S390_FLIC,
|
qom: Drop parameter @errp of object_property_add() & friends
The only way object_property_add() can fail is when a property with
the same name already exists. Since our property names are all
hardcoded, failure is a programming error, and the appropriate way to
handle it is passing &error_abort.
Same for its variants, except for object_property_add_child(), which
additionally fails when the child already has a parent. Parentage is
also under program control, so this is a programming error, too.
We have a bit over 500 callers. Almost half of them pass
&error_abort, slightly fewer ignore errors, one test case handles
errors, and the remaining few callers pass them to their own callers.
The previous few commits demonstrated once again that ignoring
programming errors is a bad idea.
Of the few ones that pass on errors, several violate the Error API.
The Error ** argument must be NULL, &error_abort, &error_fatal, or a
pointer to a variable containing NULL. Passing an argument of the
latter kind twice without clearing it in between is wrong: if the
first call sets an error, it no longer points to NULL for the second
call. ich9_pm_add_properties(), sparc32_ledma_realize(),
sparc32_dma_realize(), xilinx_axidma_realize(), xilinx_enet_realize()
are wrong that way.
When the one appropriate choice of argument is &error_abort, letting
users pick the argument is a bad idea.
Drop parameter @errp and assert the preconditions instead.
There's one exception to "duplicate property name is a programming
error": the way object_property_add() implements the magic (and
undocumented) "automatic arrayification". Don't drop @errp there.
Instead, rename object_property_add() to object_property_try_add(),
and add the obvious wrapper object_property_add().
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20200505152926.18877-15-armbru@redhat.com>
[Two semantic rebase conflicts resolved]
2020-05-05 18:29:22 +03:00
|
|
|
OBJECT(dev));
|
2018-01-29 15:56:07 +03:00
|
|
|
} else {
|
qdev: Convert uses of qdev_create() with Coccinelle
This is the transformation explained in the commit before previous.
Takes care of just one pattern that needs conversion. More to come in
this series.
Coccinelle script:
@ depends on !(file in "hw/arm/highbank.c")@
expression bus, type_name, dev, expr;
@@
- dev = qdev_create(bus, type_name);
+ dev = qdev_new(type_name);
... when != dev = expr
- qdev_init_nofail(dev);
+ qdev_realize_and_unref(dev, bus, &error_fatal);
@@
expression bus, type_name, dev, expr;
identifier DOWN;
@@
- dev = DOWN(qdev_create(bus, type_name));
+ dev = DOWN(qdev_new(type_name));
... when != dev = expr
- qdev_init_nofail(DEVICE(dev));
+ qdev_realize_and_unref(DEVICE(dev), bus, &error_fatal);
@@
expression bus, type_name, expr;
identifier dev;
@@
- DeviceState *dev = qdev_create(bus, type_name);
+ DeviceState *dev = qdev_new(type_name);
... when != dev = expr
- qdev_init_nofail(dev);
+ qdev_realize_and_unref(dev, bus, &error_fatal);
@@
expression bus, type_name, dev, expr, errp;
symbol true;
@@
- dev = qdev_create(bus, type_name);
+ dev = qdev_new(type_name);
... when != dev = expr
- object_property_set_bool(OBJECT(dev), true, "realized", errp);
+ qdev_realize_and_unref(dev, bus, errp);
@@
expression bus, type_name, expr, errp;
identifier dev;
symbol true;
@@
- DeviceState *dev = qdev_create(bus, type_name);
+ DeviceState *dev = qdev_new(type_name);
... when != dev = expr
- object_property_set_bool(OBJECT(dev), true, "realized", errp);
+ qdev_realize_and_unref(dev, bus, errp);
The first rule exempts hw/arm/highbank.c, because it matches along two
control flow paths there, with different @type_name. Covered by the
next commit's manual conversions.
Missing #include "qapi/error.h" added manually.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20200610053247.1583243-10-armbru@redhat.com>
[Conflicts in hw/misc/empty_slot.c and hw/sparc/leon3.c resolved]
2020-06-10 08:31:58 +03:00
|
|
|
dev = qdev_new(TYPE_QEMU_S390_FLIC);
|
2014-04-17 17:59:48 +04:00
|
|
|
object_property_add_child(qdev_get_machine(), TYPE_QEMU_S390_FLIC,
|
qom: Drop parameter @errp of object_property_add() & friends
The only way object_property_add() can fail is when a property with
the same name already exists. Since our property names are all
hardcoded, failure is a programming error, and the appropriate way to
handle it is passing &error_abort.
Same for its variants, except for object_property_add_child(), which
additionally fails when the child already has a parent. Parentage is
also under program control, so this is a programming error, too.
We have a bit over 500 callers. Almost half of them pass
&error_abort, slightly fewer ignore errors, one test case handles
errors, and the remaining few callers pass them to their own callers.
The previous few commits demonstrated once again that ignoring
programming errors is a bad idea.
Of the few ones that pass on errors, several violate the Error API.
The Error ** argument must be NULL, &error_abort, &error_fatal, or a
pointer to a variable containing NULL. Passing an argument of the
latter kind twice without clearing it in between is wrong: if the
first call sets an error, it no longer points to NULL for the second
call. ich9_pm_add_properties(), sparc32_ledma_realize(),
sparc32_dma_realize(), xilinx_axidma_realize(), xilinx_enet_realize()
are wrong that way.
When the one appropriate choice of argument is &error_abort, letting
users pick the argument is a bad idea.
Drop parameter @errp and assert the preconditions instead.
There's one exception to "duplicate property name is a programming
error": the way object_property_add() implements the magic (and
undocumented) "automatic arrayification". Don't drop @errp there.
Instead, rename object_property_add() to object_property_try_add(),
and add the obvious wrapper object_property_add().
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20200505152926.18877-15-armbru@redhat.com>
[Two semantic rebase conflicts resolved]
2020-05-05 18:29:22 +03:00
|
|
|
OBJECT(dev));
|
2013-07-16 11:04:04 +04:00
|
|
|
}
|
sysbus: Convert to sysbus_realize() etc. with Coccinelle
Convert from qdev_realize(), qdev_realize_and_unref() with null @bus
argument to sysbus_realize(), sysbus_realize_and_unref().
Coccinelle script:
@@
expression dev, errp;
@@
- qdev_realize(DEVICE(dev), NULL, errp);
+ sysbus_realize(SYS_BUS_DEVICE(dev), errp);
@@
expression sysbus_dev, dev, errp;
@@
+ sysbus_dev = SYS_BUS_DEVICE(dev);
- qdev_realize_and_unref(dev, NULL, errp);
+ sysbus_realize_and_unref(sysbus_dev, errp);
- sysbus_dev = SYS_BUS_DEVICE(dev);
@@
expression sysbus_dev, dev, errp;
expression expr;
@@
sysbus_dev = SYS_BUS_DEVICE(dev);
... when != dev = expr;
- qdev_realize_and_unref(dev, NULL, errp);
+ sysbus_realize_and_unref(sysbus_dev, errp);
@@
expression dev, errp;
@@
- qdev_realize_and_unref(DEVICE(dev), NULL, errp);
+ sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), errp);
@@
expression dev, errp;
@@
- qdev_realize_and_unref(dev, NULL, errp);
+ sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), errp);
Whitespace changes minimized manually.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Acked-by: Alistair Francis <alistair.francis@wdc.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20200610053247.1583243-46-armbru@redhat.com>
[Conflicts in hw/misc/empty_slot.c and hw/sparc/leon3.c resolved]
2020-06-10 08:32:34 +03:00
|
|
|
sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
|
2013-07-16 11:04:04 +04:00
|
|
|
}
|
|
|
|
|
2013-07-15 19:45:03 +04:00
|
|
|
static int qemu_s390_register_io_adapter(S390FLICState *fs, uint32_t id,
|
|
|
|
uint8_t isc, bool swap,
|
2017-03-07 06:07:44 +03:00
|
|
|
bool is_maskable, uint8_t flags)
|
2013-07-15 19:45:03 +04:00
|
|
|
{
|
|
|
|
/* nothing to do */
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-07-15 19:45:03 +04:00
|
|
|
static int qemu_s390_io_adapter_map(S390FLICState *fs, uint32_t id,
|
|
|
|
uint64_t map_addr, bool do_map)
|
|
|
|
{
|
|
|
|
/* nothing to do */
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int qemu_s390_add_adapter_routes(S390FLICState *fs,
|
|
|
|
AdapterRoutes *routes)
|
|
|
|
{
|
|
|
|
return -ENOSYS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void qemu_s390_release_adapter_routes(S390FLICState *fs,
|
|
|
|
AdapterRoutes *routes)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-01-27 15:03:44 +03:00
|
|
|
static int qemu_s390_clear_io_flic(S390FLICState *fs, uint16_t subchannel_id,
|
|
|
|
uint16_t subchannel_nr)
|
|
|
|
{
|
2018-01-29 15:56:21 +03:00
|
|
|
QEMUS390FLICState *flic = s390_get_qemu_flic(fs);
|
2018-01-29 15:56:15 +03:00
|
|
|
QEMUS390FlicIO *cur, *next;
|
|
|
|
uint8_t isc;
|
|
|
|
|
2024-01-02 18:35:25 +03:00
|
|
|
g_assert(bql_locked());
|
2018-01-29 15:56:15 +03:00
|
|
|
if (!(flic->pending & FLIC_PENDING_IO)) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* check all iscs */
|
|
|
|
for (isc = 0; isc < 8; isc++) {
|
|
|
|
if (QLIST_EMPTY(&flic->io[isc])) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* 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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* update our indicator bit */
|
|
|
|
if (QLIST_EMPTY(&flic->io[isc])) {
|
|
|
|
flic->pending &= ~ISC_TO_PENDING_IO(isc);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
2016-01-27 15:03:44 +03:00
|
|
|
}
|
|
|
|
|
2017-02-17 09:23:44 +03:00
|
|
|
static int qemu_s390_modify_ais_mode(S390FLICState *fs, uint8_t isc,
|
|
|
|
uint16_t mode)
|
|
|
|
{
|
2018-01-29 15:56:21 +03:00
|
|
|
QEMUS390FLICState *flic = s390_get_qemu_flic(fs);
|
2017-02-17 09:23:44 +03:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2017-02-17 10:00:59 +03:00
|
|
|
static int qemu_s390_inject_airq(S390FLICState *fs, uint8_t type,
|
|
|
|
uint8_t isc, uint8_t flags)
|
|
|
|
{
|
2018-01-29 15:56:21 +03:00
|
|
|
QEMUS390FLICState *flic = s390_get_qemu_flic(fs);
|
2018-01-29 15:56:23 +03:00
|
|
|
S390FLICStateClass *fsc = s390_get_flic_class(fs);
|
2017-02-17 10:00:59 +03:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2018-01-29 15:56:11 +03:00
|
|
|
fsc->inject_io(fs, 0, 0, 0, io_int_word);
|
2017-02-17 10:00:59 +03:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2018-01-29 15:56:13 +03:00
|
|
|
static void qemu_s390_flic_notify(uint32_t type)
|
|
|
|
{
|
|
|
|
CPUState *cs;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* We have to make all CPUs see CPU_INTERRUPT_HARD, so they might
|
2018-01-29 15:56:16 +03:00
|
|
|
* consider it. We will kick all running CPUs and only relevant
|
|
|
|
* sleeping ones.
|
2018-01-29 15:56:13 +03:00
|
|
|
*/
|
|
|
|
CPU_FOREACH(cs) {
|
2018-01-29 15:56:16 +03:00
|
|
|
S390CPU *cpu = S390_CPU(cs);
|
|
|
|
|
|
|
|
cs->interrupt_request |= CPU_INTERRUPT_HARD;
|
|
|
|
|
|
|
|
/* ignore CPUs that are not sleeping */
|
qmp: expose s390-specific CPU info
Presently s390x is the only architecture not exposing specific
CPU information via QMP query-cpus. Upstream discussion has shown
that it could make sense to report the architecture specific CPU
state, e.g. to detect that a CPU has been stopped.
With this change the output of query-cpus will look like this on
s390:
[
{"arch": "s390", "current": true,
"props": {"core-id": 0}, "cpu-state": "operating", "CPU": 0,
"qom_path": "/machine/unattached/device[0]",
"halted": false, "thread_id": 63115},
{"arch": "s390", "current": false,
"props": {"core-id": 1}, "cpu-state": "stopped", "CPU": 1,
"qom_path": "/machine/unattached/device[1]",
"halted": true, "thread_id": 63116}
]
This change doesn't add the s390-specific data to HMP 'info cpus'.
A follow-on patch will remove all architecture specific information
from there.
Signed-off-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
Reviewed-by: David Hildenbrand <david@redhat.com>
Reviewed-by: Christian Borntraeger <borntraeger@de.ibm.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <1518797321-28356-2-git-send-email-mihajlov@linux.vnet.ibm.com>
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
Signed-off-by: Cornelia Huck <cohuck@redhat.com>
2018-02-16 19:08:37 +03:00
|
|
|
if (s390_cpu_get_state(cpu) != S390_CPU_STATE_OPERATING &&
|
|
|
|
s390_cpu_get_state(cpu) != S390_CPU_STATE_LOAD) {
|
2018-01-29 15:56:16 +03:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* 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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-01-29 15:56:13 +03:00
|
|
|
cpu_interrupt(cs, CPU_INTERRUPT_HARD);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t qemu_s390_flic_dequeue_service(QEMUS390FLICState *flic)
|
|
|
|
{
|
|
|
|
uint32_t tmp;
|
|
|
|
|
2024-01-02 18:35:25 +03:00
|
|
|
g_assert(bql_locked());
|
2018-01-29 15:56:13 +03:00
|
|
|
g_assert(flic->pending & FLIC_PENDING_SERVICE);
|
|
|
|
tmp = flic->service_param;
|
|
|
|
flic->service_param = 0;
|
|
|
|
flic->pending &= ~FLIC_PENDING_SERVICE;
|
|
|
|
|
|
|
|
return tmp;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* caller has to free the returned object */
|
|
|
|
QEMUS390FlicIO *qemu_s390_flic_dequeue_io(QEMUS390FLICState *flic, uint64_t cr6)
|
|
|
|
{
|
|
|
|
QEMUS390FlicIO *io;
|
|
|
|
uint8_t isc;
|
|
|
|
|
2024-01-02 18:35:25 +03:00
|
|
|
g_assert(bql_locked());
|
2018-01-29 15:56:13 +03:00
|
|
|
if (!(flic->pending & CR6_TO_PENDING_IO(cr6))) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void qemu_s390_flic_dequeue_crw_mchk(QEMUS390FLICState *flic)
|
|
|
|
{
|
2024-01-02 18:35:25 +03:00
|
|
|
g_assert(bql_locked());
|
2018-01-29 15:56:13 +03:00
|
|
|
g_assert(flic->pending & FLIC_PENDING_MCHK_CR);
|
|
|
|
flic->pending &= ~FLIC_PENDING_MCHK_CR;
|
|
|
|
}
|
|
|
|
|
2018-01-29 15:56:10 +03:00
|
|
|
static void qemu_s390_inject_service(S390FLICState *fs, uint32_t parm)
|
|
|
|
{
|
2018-01-29 15:56:21 +03:00
|
|
|
QEMUS390FLICState *flic = s390_get_qemu_flic(fs);
|
2018-01-29 15:56:10 +03:00
|
|
|
|
2024-01-02 18:35:25 +03:00
|
|
|
g_assert(bql_locked());
|
2018-01-29 15:56:13 +03:00
|
|
|
/* multiplexing is good enough for sclp - kvm does it internally as well */
|
|
|
|
flic->service_param |= parm;
|
|
|
|
flic->pending |= FLIC_PENDING_SERVICE;
|
2018-01-29 15:56:10 +03:00
|
|
|
|
2018-01-29 15:56:13 +03:00
|
|
|
qemu_s390_flic_notify(FLIC_PENDING_SERVICE);
|
2018-01-29 15:56:10 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
2018-01-29 15:56:13 +03:00
|
|
|
const uint8_t isc = IO_INT_WORD_ISC(io_int_word);
|
2018-01-29 15:56:21 +03:00
|
|
|
QEMUS390FLICState *flic = s390_get_qemu_flic(fs);
|
2018-01-29 15:56:13 +03:00
|
|
|
QEMUS390FlicIO *io;
|
2018-01-29 15:56:10 +03:00
|
|
|
|
2024-01-02 18:35:25 +03:00
|
|
|
g_assert(bql_locked());
|
2018-01-29 15:56:13 +03:00
|
|
|
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));
|
2018-01-29 15:56:10 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static void qemu_s390_inject_crw_mchk(S390FLICState *fs)
|
|
|
|
{
|
2018-01-29 15:56:21 +03:00
|
|
|
QEMUS390FLICState *flic = s390_get_qemu_flic(fs);
|
2018-01-29 15:56:13 +03:00
|
|
|
|
2024-01-02 18:35:25 +03:00
|
|
|
g_assert(bql_locked());
|
2018-01-29 15:56:13 +03:00
|
|
|
flic->pending |= FLIC_PENDING_MCHK_CR;
|
|
|
|
|
|
|
|
qemu_s390_flic_notify(FLIC_PENDING_MCHK_CR);
|
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool qemu_s390_flic_has_io(QEMUS390FLICState *flic, uint64_t cr6)
|
|
|
|
{
|
|
|
|
/* called without lock via cc->has_work, will be validated under lock */
|
|
|
|
return !!(flic->pending & CR6_TO_PENDING_IO(cr6));
|
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
2018-01-29 15:56:10 +03:00
|
|
|
|
2018-01-29 15:56:13 +03:00
|
|
|
bool qemu_s390_flic_has_any(QEMUS390FLICState *flic)
|
|
|
|
{
|
2024-01-02 18:35:25 +03:00
|
|
|
g_assert(bql_locked());
|
2018-01-29 15:56:13 +03:00
|
|
|
return !!flic->pending;
|
2018-01-29 15:56:10 +03:00
|
|
|
}
|
|
|
|
|
2017-02-17 09:23:44 +03:00
|
|
|
static void qemu_s390_flic_reset(DeviceState *dev)
|
|
|
|
{
|
|
|
|
QEMUS390FLICState *flic = QEMU_S390_FLIC(dev);
|
2018-01-29 15:56:13 +03:00
|
|
|
QEMUS390FlicIO *cur, *next;
|
|
|
|
int isc;
|
2017-02-17 09:23:44 +03:00
|
|
|
|
2024-01-02 18:35:25 +03:00
|
|
|
g_assert(bql_locked());
|
2017-02-17 09:23:44 +03:00
|
|
|
flic->simm = 0;
|
|
|
|
flic->nimm = 0;
|
2018-01-29 15:56:13 +03:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
2017-02-17 09:23:44 +03:00
|
|
|
}
|
|
|
|
|
2017-05-16 13:58:44 +03:00
|
|
|
bool ais_needed(void *opaque)
|
|
|
|
{
|
|
|
|
S390FLICState *s = opaque;
|
|
|
|
|
|
|
|
return s->ais_supported;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const VMStateDescription qemu_s390_flic_vmstate = {
|
|
|
|
.name = "qemu-s390-flic",
|
|
|
|
.version_id = 1,
|
|
|
|
.minimum_version_id = 1,
|
|
|
|
.needed = ais_needed,
|
2023-12-21 06:16:15 +03:00
|
|
|
.fields = (const VMStateField[]) {
|
2017-05-16 13:58:44 +03:00
|
|
|
VMSTATE_UINT8(simm, QEMUS390FLICState),
|
|
|
|
VMSTATE_UINT8(nimm, QEMUS390FLICState),
|
|
|
|
VMSTATE_END_OF_LIST()
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2018-01-29 15:56:13 +03:00
|
|
|
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]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-07-15 19:45:03 +04:00
|
|
|
static void qemu_s390_flic_class_init(ObjectClass *oc, void *data)
|
|
|
|
{
|
2017-02-17 09:23:44 +03:00
|
|
|
DeviceClass *dc = DEVICE_CLASS(oc);
|
2013-07-15 19:45:03 +04:00
|
|
|
S390FLICStateClass *fsc = S390_FLIC_COMMON_CLASS(oc);
|
|
|
|
|
2017-02-17 09:23:44 +03:00
|
|
|
dc->reset = qemu_s390_flic_reset;
|
2017-05-16 13:58:44 +03:00
|
|
|
dc->vmsd = &qemu_s390_flic_vmstate;
|
2013-07-15 19:45:03 +04:00
|
|
|
fsc->register_io_adapter = qemu_s390_register_io_adapter;
|
2013-07-15 19:45:03 +04:00
|
|
|
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;
|
2016-01-27 15:03:44 +03:00
|
|
|
fsc->clear_io_irq = qemu_s390_clear_io_flic;
|
2017-02-17 09:23:44 +03:00
|
|
|
fsc->modify_ais_mode = qemu_s390_modify_ais_mode;
|
2017-02-17 10:00:59 +03:00
|
|
|
fsc->inject_airq = qemu_s390_inject_airq;
|
2018-01-29 15:56:10 +03:00
|
|
|
fsc->inject_service = qemu_s390_inject_service;
|
|
|
|
fsc->inject_io = qemu_s390_inject_io;
|
|
|
|
fsc->inject_crw_mchk = qemu_s390_inject_crw_mchk;
|
2013-07-15 19:45:03 +04:00
|
|
|
}
|
|
|
|
|
2016-12-09 15:51:46 +03:00
|
|
|
static Property s390_flic_common_properties[] = {
|
|
|
|
DEFINE_PROP_UINT32("adapter_routes_max_batch", S390FLICState,
|
|
|
|
adapter_routes_max_batch, ADAPTER_ROUTES_MAX_GSI),
|
2024-05-09 20:00:33 +03:00
|
|
|
DEFINE_PROP_BOOL("migration-enabled", S390FLICState,
|
|
|
|
migration_enabled, true),
|
2016-12-09 15:51:46 +03:00
|
|
|
DEFINE_PROP_END_OF_LIST(),
|
|
|
|
};
|
|
|
|
|
|
|
|
static void s390_flic_common_realize(DeviceState *dev, Error **errp)
|
|
|
|
{
|
2017-02-17 09:23:44 +03:00
|
|
|
S390FLICState *fs = S390_FLIC_COMMON(dev);
|
|
|
|
uint32_t max_batch = fs->adapter_routes_max_batch;
|
2016-12-09 15:51:46 +03:00
|
|
|
|
|
|
|
if (max_batch > ADAPTER_ROUTES_MAX_GSI) {
|
2017-06-14 16:39:48 +03:00
|
|
|
error_setg(errp, "flic property adapter_routes_max_batch too big"
|
|
|
|
" (%d > %d)", max_batch, ADAPTER_ROUTES_MAX_GSI);
|
2017-06-14 08:25:58 +03:00
|
|
|
return;
|
2016-12-09 15:51:46 +03:00
|
|
|
}
|
2017-02-17 09:23:44 +03:00
|
|
|
|
2017-06-14 08:25:58 +03:00
|
|
|
fs->ais_supported = s390_has_feat(S390_FEAT_ADAPTER_INT_SUPPRESSION);
|
2016-12-09 15:51:46 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static void s390_flic_class_init(ObjectClass *oc, void *data)
|
|
|
|
{
|
|
|
|
DeviceClass *dc = DEVICE_CLASS(oc);
|
|
|
|
|
2020-01-10 18:30:32 +03:00
|
|
|
device_class_set_props(dc, s390_flic_common_properties);
|
2016-12-09 15:51:46 +03:00
|
|
|
dc->realize = s390_flic_common_realize;
|
|
|
|
}
|
|
|
|
|
2014-04-17 17:59:48 +04:00
|
|
|
static const TypeInfo qemu_s390_flic_info = {
|
|
|
|
.name = TYPE_QEMU_S390_FLIC,
|
|
|
|
.parent = TYPE_S390_FLIC_COMMON,
|
|
|
|
.instance_size = sizeof(QEMUS390FLICState),
|
2018-01-29 15:56:13 +03:00
|
|
|
.instance_init = qemu_s390_flic_instance_init,
|
2013-07-15 19:45:03 +04:00
|
|
|
.class_init = qemu_s390_flic_class_init,
|
2014-04-17 17:59:48 +04:00
|
|
|
};
|
2013-07-16 11:04:04 +04:00
|
|
|
|
2016-12-09 15:51:46 +03:00
|
|
|
|
2014-04-17 17:59:48 +04:00
|
|
|
static const TypeInfo s390_flic_common_info = {
|
|
|
|
.name = TYPE_S390_FLIC_COMMON,
|
2013-07-16 11:04:04 +04:00
|
|
|
.parent = TYPE_SYS_BUS_DEVICE,
|
2014-04-17 17:59:48 +04:00
|
|
|
.instance_size = sizeof(S390FLICState),
|
2016-12-09 15:51:46 +03:00
|
|
|
.class_init = s390_flic_class_init,
|
2014-04-17 17:59:48 +04:00
|
|
|
.class_size = sizeof(S390FLICStateClass),
|
2013-07-16 11:04:04 +04:00
|
|
|
};
|
|
|
|
|
2014-04-17 17:59:48 +04:00
|
|
|
static void qemu_s390_flic_register_types(void)
|
2013-07-16 11:04:04 +04:00
|
|
|
{
|
2014-04-17 17:59:48 +04:00
|
|
|
type_register_static(&s390_flic_common_info);
|
|
|
|
type_register_static(&qemu_s390_flic_info);
|
2013-07-16 11:04:04 +04:00
|
|
|
}
|
|
|
|
|
2014-04-17 17:59:48 +04:00
|
|
|
type_init(qemu_s390_flic_register_types)
|
2017-07-04 00:34:14 +03:00
|
|
|
|
2017-07-11 17:54:38 +03:00
|
|
|
static bool adapter_info_so_needed(void *opaque)
|
|
|
|
{
|
2024-05-17 09:15:53 +03:00
|
|
|
S390FLICState *fs = s390_get_flic();
|
2024-05-09 20:00:33 +03:00
|
|
|
|
|
|
|
return fs->migration_enabled;
|
2017-07-11 17:54:38 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
const VMStateDescription vmstate_adapter_info_so = {
|
|
|
|
.name = "s390_adapter_info/summary_offset",
|
|
|
|
.version_id = 1,
|
|
|
|
.minimum_version_id = 1,
|
|
|
|
.needed = adapter_info_so_needed,
|
2023-12-21 06:16:15 +03:00
|
|
|
.fields = (const VMStateField[]) {
|
2017-07-11 17:54:38 +03:00
|
|
|
VMSTATE_UINT32(summary_offset, AdapterInfo),
|
|
|
|
VMSTATE_END_OF_LIST()
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-07-04 00:34:14 +03:00
|
|
|
const VMStateDescription vmstate_adapter_info = {
|
|
|
|
.name = "s390_adapter_info",
|
|
|
|
.version_id = 1,
|
|
|
|
.minimum_version_id = 1,
|
2023-12-21 06:16:15 +03:00
|
|
|
.fields = (const VMStateField[]) {
|
2017-07-04 00:34:14 +03:00
|
|
|
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()
|
|
|
|
},
|
2023-12-21 06:16:15 +03:00
|
|
|
.subsections = (const VMStateDescription * const []) {
|
2017-07-11 17:54:38 +03:00
|
|
|
&vmstate_adapter_info_so,
|
|
|
|
NULL
|
|
|
|
}
|
2017-07-04 00:34:14 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
const VMStateDescription vmstate_adapter_routes = {
|
|
|
|
|
|
|
|
.name = "s390_adapter_routes",
|
|
|
|
.version_id = 1,
|
|
|
|
.minimum_version_id = 1,
|
2023-12-21 06:16:15 +03:00
|
|
|
.fields = (const VMStateField[]) {
|
2017-07-04 00:34:14 +03:00
|
|
|
VMSTATE_STRUCT(adapter, AdapterRoutes, 1, vmstate_adapter_info,
|
|
|
|
AdapterInfo),
|
|
|
|
VMSTATE_END_OF_LIST()
|
|
|
|
}
|
|
|
|
};
|