Skip to contentSkip to conversation

Dynamic instance properties in TYPE_ARM_CPU

DISCUSSION Eduardo Habkost 3 participants 4 messages Oct 26, 2020 – Oct 29, 2020

lore
Share & tools
lore
#0 lore raw

I've been trying to clean up the qdev property code (to bridge the gaps between qdev and QOM, and between QOM and QAPI), and I've noticed that TYPE_ARM_CPU is the only remaining user of qdev_property_add_static().

qdev_property_add_static() has a misleading name: it won't register a static property. It is actually a hack to use a static Property variable (defined using DEFINE_PROP*), but register it as a dynamic instance property.

Dynamic instance properties make introspection hard. What can we do to get rid of them in TYPE_ARM_CPU?

Can we just register all the properties unconditionally, and error out on realize if the requested CPU configuration is incompatible with the available CPU features?

The following properties are registered as dynamic instance properties at arm_cpu_post_init():
"cntfrq", "reset-cbar", "reset-hivecs", "rvbar", "has_el2", "has_el3", "cfgend", "vfp", "neon", "dsp", "has-mpu", "pmsav7-dregion", "secure-memory", "pmu", "idau", "init-svtor", "tag-memory", "secure-tag-memory".

Signature · 1 line
Eduardo
#1 lore raw
Quoted 5 lines · Eduardo Habkost

I've been trying to clean up the qdev property code (to bridge the gaps between qdev and QOM, and between QOM and QAPI), and I've noticed that TYPE_ARM_CPU is the only remaining user of qdev_property_add_static().

Quoted 7 lines

qdev_property_add_static() has a misleading name: it won't register a static property. It is actually a hack to use a static Property variable (defined using DEFINE_PROP*), but register it as a dynamic instance property.

Dynamic instance properties make introspection hard. What can we do to get rid of them in TYPE_ARM_CPU?

I'm in principle in favour of this because the Arm handling of this is a bit odd and it would make sense to bring it into line with how other parts of QEMU work. (Do other CPU architectures just provide the properties on all CPUs?)

Quoted 3 lines

Can we just register all the properties unconditionally, and error out on realize if the requested CPU configuration is incompatible with the available CPU features?

I think you would probably also need to check for and adjust board/SoC code which assumes that presence of a property implies that it's OK to set it, eg this in virt.c:

        if (object_property_find(cpuobj, "reset-cbar")) {
            object_property_set_int(cpuobj, "reset-cbar",
                                    vms->memmap[VIRT_CPUPERIPHS].base,
                                    &error_abort);
        }

or which uses presence-of-property as its check for "does the CPU support this feature", eg this;

                /*
                 * The property exists only if MemTag is supported.
                 * If it is, we must allocate the ram to back that up.
                 */
                if (!object_property_find(cpuobj, "tag-memory")) {
                    error_report("MTE requested, but not supported "
                                 "by the guest CPU");
                    exit(1);
                }
Quoted 6 lines

The following properties are registered as dynamic instance properties at arm_cpu_post_init():
"cntfrq", "reset-cbar", "reset-hivecs", "rvbar", "has_el2", "has_el3", "cfgend", "vfp", "neon", "dsp", "has-mpu", "pmsav7-dregion", "secure-memory", "pmu", "idau", "init-svtor", "tag-memory", "secure-tag-memory".

thanks
-- PMM

#2 lore raw
In reply to Eduardo Habkost
Quoted 17 lines · Eduardo Habkost

I've been trying to clean up the qdev property code (to bridge the gaps between qdev and QOM, and between QOM and QAPI), and I've noticed that TYPE_ARM_CPU is the only remaining user of qdev_property_add_static().

qdev_property_add_static() has a misleading name: it won't register a static property. It is actually a hack to use a static Property variable (defined using DEFINE_PROP*), but register it as a dynamic instance property.

Dynamic instance properties make introspection hard. What can we do to get rid of them in TYPE_ARM_CPU?

Can we just register all the properties unconditionally, and error out on realize if the requested CPU configuration is incompatible with the available CPU features?

Quoted 6 lines

The following properties are registered as dynamic instance properties at arm_cpu_post_init():
"cntfrq", "reset-cbar", "reset-hivecs", "rvbar", "has_el2", "has_el3", "cfgend", "vfp", "neon", "dsp", "has-mpu", "pmsav7-dregion", "secure-memory", "pmu", "idau", "init-svtor", "tag-memory", "secure-tag-memory".

Hi Eduardo,

Are properties added at runtime with

if (this_config_wants_this_property)

    object_property_add(...)

also considered dynamic instance properties? If so, then arm as many more than the ones listed above. And, if not, then it should be pretty easy to convert the ones listed above to this if-want-add pattern.

Thanks,
drew

#3 lore raw
Quoted 29 lines · Andrew Jones
Quoted 17 lines · Eduardo Habkost

I've been trying to clean up the qdev property code (to bridge the gaps between qdev and QOM, and between QOM and QAPI), and I've noticed that TYPE_ARM_CPU is the only remaining user of qdev_property_add_static().

qdev_property_add_static() has a misleading name: it won't register a static property. It is actually a hack to use a static Property variable (defined using DEFINE_PROP*), but register it as a dynamic instance property.

Dynamic instance properties make introspection hard. What can we do to get rid of them in TYPE_ARM_CPU?

Can we just register all the properties unconditionally, and error out on realize if the requested CPU configuration is incompatible with the available CPU features?

Quoted 6 lines

The following properties are registered as dynamic instance properties at arm_cpu_post_init():
"cntfrq", "reset-cbar", "reset-hivecs", "rvbar", "has_el2", "has_el3", "cfgend", "vfp", "neon", "dsp", "has-mpu", "pmsav7-dregion", "secure-memory", "pmu", "idau", "init-svtor", "tag-memory", "secure-tag-memory".

Hi Eduardo,

Are properties added at runtime with

Quoted 7 lines

if (this_config_wants_this_property)

    object_property_add(...)

also considered dynamic instance properties? If so, then arm as many more than the ones listed above. And, if not, then it should be pretty easy to convert the ones listed above to this if-want-add pattern.

Yeah, all object_property_add() calls are also dynamic instance properties.

Being conditional makes them more difficult to convert to introspectable class properties (unless the condition is a function of class information only).

Signature · 1 line
Eduardo