mirror of https://github.com/xemu-project/xemu.git
xive: Link "cpu" property to XiveTCTX::cs pointer
The TCTX object has both a pointer and a "cpu" property pointing to the vCPU object. Confusing bugs could arise if these ever go out of sync. Change the property definition so that it explicitely sets the pointer. Signed-off-by: Greg Kurz <groug@kaod.org> Message-Id: <157383332669.165747.2484056603605646820.stgit@bahia.lan> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
This commit is contained in:
parent
719ed8461f
commit
411c2a619e
|
@ -580,19 +580,11 @@ static void xive_tctx_realize(DeviceState *dev, Error **errp)
|
||||||
XiveTCTX *tctx = XIVE_TCTX(dev);
|
XiveTCTX *tctx = XIVE_TCTX(dev);
|
||||||
PowerPCCPU *cpu;
|
PowerPCCPU *cpu;
|
||||||
CPUPPCState *env;
|
CPUPPCState *env;
|
||||||
Object *obj;
|
|
||||||
Error *local_err = NULL;
|
Error *local_err = NULL;
|
||||||
|
|
||||||
obj = object_property_get_link(OBJECT(dev), "cpu", &local_err);
|
assert(tctx->cs);
|
||||||
if (!obj) {
|
|
||||||
error_propagate(errp, local_err);
|
|
||||||
error_prepend(errp, "required link 'cpu' not found: ");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
cpu = POWERPC_CPU(obj);
|
|
||||||
tctx->cs = CPU(obj);
|
|
||||||
|
|
||||||
|
cpu = POWERPC_CPU(tctx->cs);
|
||||||
env = &cpu->env;
|
env = &cpu->env;
|
||||||
switch (PPC_INPUT(env)) {
|
switch (PPC_INPUT(env)) {
|
||||||
case PPC_FLAGS_INPUT_POWER9:
|
case PPC_FLAGS_INPUT_POWER9:
|
||||||
|
@ -662,6 +654,11 @@ static const VMStateDescription vmstate_xive_tctx = {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static Property xive_tctx_properties[] = {
|
||||||
|
DEFINE_PROP_LINK("cpu", XiveTCTX, cs, TYPE_CPU, CPUState *),
|
||||||
|
DEFINE_PROP_END_OF_LIST(),
|
||||||
|
};
|
||||||
|
|
||||||
static void xive_tctx_class_init(ObjectClass *klass, void *data)
|
static void xive_tctx_class_init(ObjectClass *klass, void *data)
|
||||||
{
|
{
|
||||||
DeviceClass *dc = DEVICE_CLASS(klass);
|
DeviceClass *dc = DEVICE_CLASS(klass);
|
||||||
|
@ -669,6 +666,7 @@ static void xive_tctx_class_init(ObjectClass *klass, void *data)
|
||||||
dc->desc = "XIVE Interrupt Thread Context";
|
dc->desc = "XIVE Interrupt Thread Context";
|
||||||
dc->realize = xive_tctx_realize;
|
dc->realize = xive_tctx_realize;
|
||||||
dc->vmsd = &vmstate_xive_tctx;
|
dc->vmsd = &vmstate_xive_tctx;
|
||||||
|
dc->props = xive_tctx_properties;
|
||||||
/*
|
/*
|
||||||
* Reason: part of XIVE interrupt controller, needs to be wired up
|
* Reason: part of XIVE interrupt controller, needs to be wired up
|
||||||
* by xive_tctx_create().
|
* by xive_tctx_create().
|
||||||
|
@ -691,8 +689,7 @@ Object *xive_tctx_create(Object *cpu, XiveRouter *xrtr, Error **errp)
|
||||||
obj = object_new(TYPE_XIVE_TCTX);
|
obj = object_new(TYPE_XIVE_TCTX);
|
||||||
object_property_add_child(cpu, TYPE_XIVE_TCTX, obj, &error_abort);
|
object_property_add_child(cpu, TYPE_XIVE_TCTX, obj, &error_abort);
|
||||||
object_unref(obj);
|
object_unref(obj);
|
||||||
object_ref(cpu);
|
object_property_set_link(obj, cpu, "cpu", &error_abort);
|
||||||
object_property_add_const_link(obj, "cpu", cpu, &error_abort);
|
|
||||||
object_property_set_bool(obj, true, "realized", &local_err);
|
object_property_set_bool(obj, true, "realized", &local_err);
|
||||||
if (local_err) {
|
if (local_err) {
|
||||||
goto error;
|
goto error;
|
||||||
|
@ -710,7 +707,6 @@ void xive_tctx_destroy(XiveTCTX *tctx)
|
||||||
{
|
{
|
||||||
Object *obj = OBJECT(tctx);
|
Object *obj = OBJECT(tctx);
|
||||||
|
|
||||||
object_unref(object_property_get_link(obj, "cpu", &error_abort));
|
|
||||||
object_unparent(obj);
|
object_unparent(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue