Toward class init of cpu features
Subsystems (8)
cover Toward class init of cpu features
The specific problem I'm trying to solve is the location and representation of the coprocessor register hash table for ARM cpus, but in the process affects how cpu initialization might be done for all targets.
At present, each cpu (for all targets) is initialized separately. For some, like ARM, we apply QOM properties and then build a hash table of all coprocessor regs that are valid for the cpu. For others, like m68k and ppc, we build tables of all valid instructions (ppc is slowly moving away from constructed tables to decodetree, but the migration is not complete).
Importantly, this happens N times for smp system emulation, for each cpu instance, meaning we do N times the work on startup as necessary. For system emulation this isn't so bad, as N is generally small-ish, but it certainly could be improved.
More importantly, this happens for each thread in user-only emulation. This is much more significant because threads can be short-lived, and there can be many hundreds of them, each one performing what amounts to redundant initialization.
The "obvious" solution is to make better use of the cpu class object. Construct data structures once to be shared with all instances.
The immediate problem encountered here is that of QOM properties, which are used to control how each object is configured.
The first couple of patches here create a new QOM "class property", which is sufficient to allow command-line parameters to find their way to the correct bit of code to interpret them. (Pardon the roughness in these patches, RFC and all.) The restriction I add here is that all class properties must be applied before the first object is created, which gives for a definite point at which the properties must have be applied and we can construct data structures based on those values.
However, I wind up banging my head against the wall later, when it comes to the first qmp_query_cpu_model_expansion properties. This wants to create an object, apply properties, and see what stuck. Adding a query of the class properties is fine, but I can't set any of them because of the object creation. And if I tweak the location of the class property set vs the object create, that only allows the first such probe to succeed, because the second will still have had an object created.
I can imagine a way out of this, e.g. by keeping a ref count of the number of instantiated objects, and allowing class properties to change when that count is zero. But it feels like I really should know what QMP is attempting to do here, rather than work around it blindly.
r~
Richard Henderson (40):
qdev: Don't always force the global property array non-null
qom: Introduce class_late_init
qom: Create class properties
target/arm: Remove aarch64_cpu_finalizefn
target/arm: Create arm_cpu_register_parent
target/arm: Remove AArch64CPUClass
target/arm: Create TYPE_ARM_V7M_CPU
target/arm: Pass ARMCPUClass to ARMCPUInfo.class_init target/arm: Utilize arm-cpu instance_post_init hook target/arm: Copy dtb_compatible from ARMCPUClass target/arm: Copy features from ARMCPUClass
target/arm: Copy isar and friends from ARMCPUClass hw/arm/bcm2836: Set mp-affinity property in realize target/arm: Rename arm_cpu_mp_affinity
target/arm: Create arm_cpu_mp_affinity
target/arm: Represent the entire MPIDR_EL1
target/arm: Copy cp_regs from ARMCPUClass
target/arm: Create cpreg definition functions with GHashTable arg target/arm: Move most cpu initialization to the class target/arm: Merge kvm64.c with kvm.c
target/arm: Remove aarch64 check from aarch64_host_object_init target/arm: Hoist feature and dtb_compatible from KVM, HVF target/arm: Probe KVM host into ARMCPUClass target/arm/hvf: Probe host into ARMCPUClass target/arm/hvf: Use offsetof in hvf_arm_get_host_cpu_features target/arm: Rename 'cpu' to 'acc' in class init functions target/arm: Split out strongarm_class_init
target/arm: Split out xscale*_class_init
target/arm: Remove m-profile has_vfp and has_dsp properties target/arm: Move feature bit propagation to class init target/arm: Get and set class properties in the monitor target/arm: Move "midr" to class property
target/arm: Move "cntfrq" to class property
target/arm: Move "reset-hivecs" to class property target/arm: Move "has_el2" to class property
target/arm: Move "has_el3" to class property
target/arm: Move "cfgend" to class property
target/arm: Move "vfp" and "neon" to class properties target/arm: Move "has-mpu" and "pmsav7-dregion" to class properties target/arm: Move "pmu" to class property
hw/core/qdev-prop-internal.h | 2 + include/hw/arm/armsse.h | 3 +- include/hw/arm/armv7m.h | 2 - include/qom/object.h | 67 ++ include/qom/qom-qobject.h | 28 + target/arm/cpregs.h | 33 +- target/arm/cpu-qom.h | 171 ++- target/arm/cpu.h | 89 +- target/arm/hvf_arm.h | 2 +- target/arm/internals.h | 6 +- target/arm/kvm_arm.h | 217 +--- hw/arm/allwinner-h3.c | 14 +- hw/arm/armsse.c | 53 +- hw/arm/armv7m.c | 12 - hw/arm/aspeed_ast2600.c | 9 +- hw/arm/bcm2836.c | 7 +- hw/arm/digic.c | 11 +- hw/arm/exynos4210.c | 18 +- hw/arm/integratorcp.c | 12 +- hw/arm/musca.c | 14 +- hw/arm/npcm7xx.c | 16 +- hw/arm/realview.c | 20 +- hw/arm/sbsa-ref.c | 2 +- hw/arm/versatilepb.c | 12 +- hw/arm/vexpress.c | 19 +- hw/arm/virt-acpi-build.c | 2 +- hw/arm/virt.c | 47 +- hw/arm/xilinx_zynq.c | 15 +- hw/arm/xlnx-versal-virt.c | 3 +- hw/arm/xlnx-zynqmp.c | 17 +- hw/core/cpu-common.c | 61 +- hw/core/qdev-properties.c | 79 +- hw/core/qdev.c | 2 + hw/cpu/a15mpcore.c | 14 +- hw/cpu/a9mpcore.c | 6 +- hw/intc/armv7m_nvic.c | 2 +- hw/misc/xlnx-versal-crl.c | 4 +- qom/object.c | 249 ++++- qom/object_interfaces.c | 13 + qom/qom-qmp-cmds.c | 37 + target/arm/arm-powerctl.c | 2 +- target/arm/cpu.c | 1195 +++++++++++--------- target/arm/cpu64.c | 1014 +++++++++-------- target/arm/cpu_tcg.c | 1486 +++++++++++++------------ target/arm/helper.c | 96 +- target/arm/hvf/hvf.c | 94 +- target/arm/kvm.c | 2006 +++++++++++++++++++++++++++++++--- target/arm/kvm64.c | 1632 --------------------------- target/arm/monitor.c | 21 +- target/arm/psci.c | 2 +- target/arm/meson.build | 2 +- 51 files changed, 4765 insertions(+), 4175 deletions(-) delete mode 100644 target/arm/kvm64.c
Signature · 1 line
2.34.1
RFC PATCH 1/40 qdev: Don't always force the global property array non-null
Only qdev_prop_register_global requires a non-null array. The other instances can simply exit early.
--- hw/core/qdev-properties.c | 43 ++++++++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 16 deletions(-)
hw/core/qdev-properties.c +27 -16
@@ -739,29 +739,31 @@ void qdev_prop_set_enum(DeviceState *dev, const char *name, int value) &error_abort); } -static GPtrArray *global_props (void ) -{ -static GPtrArray *gp; - -if (!gp) { - gp =g_ptr_array_new (); - } - -return gp; -} +static GPtrArray *global_properties;void qdev_prop_register_global (GlobalProperty *prop) { -g_ptr_array_add (global_props (), prop); +GPtrArray *props = global_properties; + +if (!props) { + props =g_ptr_array_new (); + global_properties = props; + } + +g_ptr_array_add (props, prop); }const GlobalProperty *qdev_find_global_prop (Object *obj,const char *name) { -GPtrArray *props =global_props (); +GPtrArray *props = global_properties;const GlobalProperty *p;int i; +if (!props) { +return NULL ; + } +for (i =0 ; i < props->len; i++) { p =g_ptr_array_index (props, i); if (object_dynamic_cast(obj, p->driver)
@@ -774,14 +776,19 @@ const GlobalProperty *qdev_find_global_prop(Object *obj,int qdev_prop_check_globals (void ) { +GPtrArray *props = global_properties;int i, ret =0 ; -for (i =0 ; i <global_props ()->len; i++) { +if (!props) { +return 0 ; + } + +for (i =0 ; i < props->len; i++) {GlobalProperty *prop;ObjectClass *oc;DeviceClass *dc; - prop =g_ptr_array_index (global_props (), i); + prop =g_ptr_array_index (props, i);if (prop->used) {continue ; }
@@ -806,8 +813,12 @@ int qdev_prop_check_globals(void)void qdev_prop_set_globals (DeviceState *dev) { -object_apply_global_props (OBJECT (dev),global_props (), - dev->hotplugged ?NULL : &error_fatal); +GPtrArray *props = global_properties; + +if (props) { +object_apply_global_props (OBJECT (dev), props, + dev->hotplugged ?NULL : &error_fatal); + } }/* --- 64bit unsigned int 'size' type --- */
Signature · 1 line
2.34.1
Re: [RFC PATCH 01/40] qdev: Don't always force the global property array non-null
Quoted 7 lines · Richard Henderson
Only
qdev_prop_register_globalrequires a non-null array. The other instances can simply exit early.Signed-off-by Richard Henderson <[email protected]>--- hw/core/qdev-properties.c | 43 ++++++++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 16 deletions(-)
RFC PATCH 2/40 qom: Introduce class_late_init
In reply to Richard HendersonCreate a new class initialization hook, to be called immediately before creation of the first instance. Most class initialization happens quite early, which makes interaction between classes difficult. E.g. cpu objects often depend on the accellerator, or the global properties coming from the command-line.
--- include/qom/object.h | 4 ++++ qom/object.c | 55 +++++++++++++++++++++++++++++++++++++------- 2 files changed, 51 insertions(+), 8 deletions(-)
include/qom/object.h +4 -0
@@ -402,6 +402,9 @@ struct Object* parent class initialization has occurred, but before the class itself * is initialized. This is the function to use to undo the effects of * memcpy from the parent class to the descendants. +* @class_late_init: This function is called for all base classes just +* before the first object is created. This is the function to use to +* apply properties (which are interpreted quite late). * @class_data: Data to pass to the @class_init, * @class_base_init. This can be useful when building dynamic * classes.
@@ -425,6 +428,7 @@ struct TypeInfovoid (*class_init)(ObjectClass *klass,void *data);void (*class_base_init)(ObjectClass *klass,void *data); +bool (*class_late_init)(ObjectClass *klass,Error **errp);void *class_data;InterfaceInfo *interfaces;
qom/object.c +47 -8
133 lines not on this page · raw message
Signature · 1 line
2.34.1
RFC PATCH 3/40 qom: Create class properties
In reply to Richard HendersonThese properties apply to the class itself, as opposed to object_class_property_* in which the property is attached to the class but applies to each object instance.
Apply global properties via a class_late_init on DeviceClass.
--- hw/core/qdev-prop-internal.h | 2 + include/qom/object.h | 63 ++++++++++++ include/qom/qom-qobject.h | 28 +++++ hw/core/cpu-common.c | 61 ++++++++--- hw/core/qdev-properties.c | 36 +++++++ hw/core/qdev.c | 2 + qom/object.c | 194 +++++++++++++++++++++++++++++++++++ qom/object_interfaces.c | 13 +++ qom/qom-qmp-cmds.c | 37 +++++++ 9 files changed, 419 insertions(+), 17 deletions(-)
hw/core/qdev-prop-internal.h +2 -0
@@ -25,4 +25,6 @@ void qdev_propinfo_get_int32(Object *obj, Visitor *v, const char *name,void qdev_propinfo_get_size32 (Object *obj,Visitor *v,const char *name,void *opaque,Error **errp); +bool device_class_late_init (ObjectClass *class,Error **errp); +#endif
include/qom/object.h +63 -0
101 lines not on this page · raw message
include/qom/qom-qobject.h +28 -0
@@ -40,4 +40,32 @@ bool object_property_set_qobject(Object *obj, const char *name, struct QObject *value, struct Error **errp); +/* +* class_property_get_qobject: +* @cls: the class object +* @name: the name of the property +* @errp: returns an error if this function fails +* +* Returns: the value of the property, converted to QObject, or NULL if +* an error occurs. +*/ +struct QObject *class_property_get_qobject (ObjectClass *cls, +const char *name, +struct Error **errp); + +/** +* class_property_set_qobject: +* @cls: the class object +* @name: the name of the property +* @value: The value that will be written to the property. +* @errp: returns an error if this function fails +* +* Writes a property to a class object. +* +* Returns: %true on success, %false on failure. +*/ +bool class_property_set_qobject (ObjectClass *cls, +const char *name,struct QObject *value, +struct Error **errp); +#endif
hw/core/cpu-common.c +44 -17
81 lines not on this page · raw message
hw/core/qdev-properties.c +36 -0
@@ -6,6 +6,7 @@#include "qemu/ctype.h" #include "qemu/error-report.h" #include "qapi/visitor.h" +#include "qapi/string-input-visitor.h" #include "qemu/units.h" #include "qemu/cutils.h" #include "qdev-prop-internal.h"
@@ -821,6 +822,41 @@ void qdev_prop_set_globals(DeviceState *dev) } } +bool device_class_late_init (ObjectClass *class,Error **errp) +{ +GPtrArray *props = global_properties; +int i, len = props ? props->len :0 ; + +for (i =0 ; i < len; i++) { +GlobalProperty *p =g_ptr_array_index (props, i); +ClassProperty *cp; +Visitor *v; +bool ok; + +if (object_class_dynamic_cast (class, p->driver) ==NULL ) { +continue ; + } + + cp =class_property_find (class, p->property); +if (!cp) { +/* The property may be on the object. */ +continue ; + } + p->used = true; + + v =string_input_visitor_new (p->value); + ok =class_property_set (class, cp, v, errp); +visit_free (v); + +if (!ok) { +error_prepend (errp,"can't apply global %s.%s=%s: " , + p->driver, p->property, p->value); +return false; + } + } +return true; +} +/* --- 64bit unsigned int 'size' type --- */ static void get_size(Object *obj, Visitor *v, const char *name, void *opaque,
hw/core/qdev.c +2 -0
@@ -40,6 +40,7 @@#include "hw/qdev-clock.h" #include "migration/vmstate.h" #include "trace.h" +#include "qdev-prop-internal.h" static bool qdev_hot_added = false;bool qdev_hot_removed = false;
@@ -901,6 +902,7 @@ static const TypeInfo device_type_info = { .instance_finalize = device_finalize, .class_base_init = device_class_base_init, .class_init = device_class_init, + .class_late_init = device_class_late_init, .abstract = true, .class_size = sizeof(DeviceClass), .interfaces = (InterfaceInfo []) {
qom/object.c +194 -0
236 lines not on this page · raw message
qom/object_interfaces.c +13 -0
@@ -203,6 +203,7 @@ bool type_print_class_properties(const char *type)ObjectClass *klass;ObjectPropertyIterator iter;ObjectProperty *prop; +ClassProperty *cprop;GPtrArray *array;int i;
@@ -212,6 +213,7 @@ bool type_print_class_properties(const char *type) } array =g_ptr_array_new (); +object_class_property_iter_init (&iter, klass);while ((prop =object_property_iter_next (&iter))) {if (!prop->set) {
@@ -222,6 +224,17 @@ bool type_print_class_properties(const char *type)object_property_help (prop->name, prop->type, prop->defval, prop->description)); } + +class_property_iter_init (&iter, klass); +while ((cprop =class_property_iter_next (&iter))) { +if (!cprop->set) { +continue ; + } +g_ptr_array_add (array, +object_property_help (cprop->name, cprop->type, +NULL , cprop->description)); + } +g_ptr_array_sort (array, (GCompareFunc )qemu_pstrcmp0);if (array->len >0 ) {qemu_printf ("%s options:\n" , type);
qom/qom-qmp-cmds.c +37 -0
@@ -34,6 +34,7 @@ ObjectPropertyInfoList *qmp_qom_list(const char *path, Error **errp)bool ambiguous = false;ObjectPropertyInfoList *props =NULL ;ObjectProperty *prop; +ClassProperty *cprop;ObjectPropertyIterator iter; obj =object_resolve_path (path, &ambiguous);
@@ -57,6 +58,16 @@ ObjectPropertyInfoList *qmp_qom_list(const char *path, Error **errp) value->type =g_strdup (prop->type); } +class_property_iter_init (&iter,object_get_class (obj)); +while ((cprop =class_property_iter_next (&iter))) { +ObjectPropertyInfo *value =g_new0 (ObjectPropertyInfo,1 ); + +QAPI_LIST_PREPEND (props, value); + + value->name =g_strdup (cprop->name); + value->type =g_strdup (cprop->type); + } +return props; }
@@ -124,6 +135,7 @@ ObjectPropertyInfoList *qmp_device_list_properties(const char *typename,ObjectClass *klass;Object *obj;ObjectProperty *prop; +ClassProperty *cprop;ObjectPropertyIterator iter;ObjectPropertyInfoList *prop_list =NULL ;
@@ -172,6 +184,18 @@ ObjectPropertyInfoList *qmp_device_list_properties(const char *typename,QAPI_LIST_PREPEND (prop_list, info); } +class_property_iter_init (&iter, klass); +while ((cprop =class_property_iter_next (&iter))) { +ObjectPropertyInfo *info; + + info =g_new0 (ObjectPropertyInfo,1 ); + info->name =g_strdup (cprop->name); + info->type =g_strdup (cprop->type); + info->description =g_strdup (cprop->description); + +QAPI_LIST_PREPEND (prop_list, info); + } +object_unref (obj);return prop_list;
@@ -183,6 +207,7 @@ ObjectPropertyInfoList *qmp_qom_list_properties(const char *typename,ObjectClass *klass;Object *obj =NULL ;ObjectProperty *prop; +ClassProperty *cprop;ObjectPropertyIterator iter;ObjectPropertyInfoList *prop_list =NULL ;
@@ -216,6 +241,18 @@ ObjectPropertyInfoList *qmp_qom_list_properties(const char *typename,QAPI_LIST_PREPEND (prop_list, info); } +class_property_iter_init (&iter, klass); +while ((cprop =class_property_iter_next (&iter))) { +ObjectPropertyInfo *info; + + info =g_malloc0 (sizeof (*info)); + info->name =g_strdup (cprop->name); + info->type =g_strdup (cprop->type); + info->description =g_strdup (cprop->description); + +QAPI_LIST_PREPEND (prop_list, info); + } +object_unref (obj);return prop_list;
Signature · 1 line
2.34.1
RFC PATCH 4/40 target/arm: Remove aarch64_cpu_finalizefn
In reply to Richard HendersonIf the instance_finalize hook is NULL, the hook is not called. There is no need to install an empty function.
--- target/arm/cpu64.c | 5 ----- 1 file changed, 5 deletions(-)
target/arm/cpu64.c +0 -5
@@ -1351,10 +1351,6 @@ static void aarch64_cpu_set_aarch64(Object *obj, bool value, Error **errp) } } -static void aarch64_cpu_finalizefn (Object *obj) -{ -} -static gchar *aarch64_gdb_arch_name (CPUState *cs) {return g_strdup ("aarch64" );
@@ -1412,7 +1408,6 @@ static const TypeInfo aarch64_cpu_type_info = { .name = TYPE_AARCH64_CPU, .parent = TYPE_ARM_CPU, .instance_size = sizeof(ARMCPU), - .instance_finalize = aarch64_cpu_finalizefn, .abstract = true, .class_size = sizeof(AArch64CPUClass), .class_init = aarch64_cpu_class_init,
Signature · 1 line
2.34.1
Re: [RFC PATCH 04/40] target/arm: Remove aarch64_cpu_finalizefn
Quoted 7 lines · Richard Henderson
If the
instance_finalizehook is NULL, the hook is not called. There is no need to install an empty function.Signed-off-by Richard Henderson <[email protected]>--- target/arm/cpu64.c | 5 ----- 1 file changed, 5 deletions(-)
RFC PATCH 5/40 target/arm: Create arm_cpu_register_parent
In reply to Richard HendersonCreate an arm cpu class with a specific abstract parent class.
--- target/arm/cpu-qom.h | 7 ++++++- target/arm/cpu.c | 4 ++-- 2 files changed, 8 insertions(+), 3 deletions(-)
target/arm/cpu-qom.h +6 -1
@@ -37,9 +37,14 @@ typedef struct ARMCPUInfo {void (*class_init)(ObjectClass *oc,void *data); } ARMCPUInfo; -void arm_cpu_register (const ARMCPUInfo *info); +void arm_cpu_register_parent (const ARMCPUInfo *info,const char *parent);void aarch64_cpu_register (const ARMCPUInfo *info); +static inline void arm_cpu_register (const ARMCPUInfo *info) +{ +arm_cpu_register_parent (info,TYPE_ARM_CPU ); +} +/** * ARMCPUClass: * @parent_realize: The parent class' realize handler.
target/arm/cpu.c +2 -2
@@ -2260,10 +2260,10 @@ static void cpu_register_class_init(ObjectClass *oc, void *data) acc->info = data; } -void arm_cpu_register (const ARMCPUInfo *info) +void arm_cpu_register_parent (const ARMCPUInfo *info,const char *parent) {TypeInfo type_info = { - .parent =TYPE_ARM_CPU , + .parent = parent, .instance_size =sizeof (ARMCPU ), .instance_align = __alignof__(ARMCPU ), .instance_init = arm_cpu_instance_init,
Signature · 1 line
2.34.1
Re: [RFC PATCH 05/40] target/arm: Create arm_cpu_register_parent
Quoted 7 lines · Richard Henderson
Create an arm cpu class with a specific abstract parent class.
Signed-off-by Richard Henderson <[email protected]>--- target/arm/cpu-qom.h | 7 ++++++- target/arm/cpu.c | 4 ++-- 2 files changed, 8 insertions(+), 3 deletions(-)
RFC PATCH 6/40 target/arm: Remove AArch64CPUClass
In reply to Richard HendersonThe class structure is a plain wrapper around ARMCPUClass. We really only need the QOM class, TYPE_AARCH64_CPU. The instance init and fallback class init functions are identical to the same ones over in cpu.c. Make arm_cpu_post_init static.
--- target/arm/cpu-qom.h | 19 ++++++------------- target/arm/cpu.h | 2 -- target/arm/cpu.c | 2 +- target/arm/cpu64.c | 33 +-------------------------------- 4 files changed, 8 insertions(+), 48 deletions(-)
target/arm/cpu-qom.h +6 -13
@@ -26,6 +26,7 @@struct arm_boot_info ;#define TYPE_ARM_CPU "arm-cpu" +#define TYPE_AARCH64_CPU "aarch64-cpu"OBJECT_DECLARE_CPU_TYPE (ARMCPU , ARMCPUClass,ARM_CPU )
@@ -38,13 +39,17 @@ typedef struct ARMCPUInfo { } ARMCPUInfo;void arm_cpu_register_parent (const ARMCPUInfo *info,const char *parent); -void aarch64_cpu_register (const ARMCPUInfo *info);static inline void arm_cpu_register (const ARMCPUInfo *info) {arm_cpu_register_parent (info,TYPE_ARM_CPU ); } +static inline void aarch64_cpu_register (const ARMCPUInfo *info) +{ +arm_cpu_register_parent (info,TYPE_AARCH64_CPU ); +} +/** * ARMCPUClass: * @parent_realize: The parent class' realize handler.
@@ -62,18 +67,6 @@ struct ARMCPUClass {ResettablePhases parent_phases; }; - -#define TYPE_AARCH64_CPU "aarch64-cpu" -typedef struct AArch64CPUClass AArch64CPUClass ; -DECLARE_CLASS_CHECKERS (AArch64CPUClass,AARCH64_CPU , - TYPE_AARCH64_CPU) - -struct AArch64CPUClass { -/*< private >*/ -ARMCPUClass parent_class; -/*< public >*/ -}; -void register_cp_regs_for_features (ARMCPU *cpu);void init_cpreg_list (ARMCPU *cpu);
target/arm/cpu.h +0 -2
@@ -1076,8 +1076,6 @@ struct ArchCPU {unsigned int gt_cntfrq_period_ns (ARMCPU *cpu); -void arm_cpu_post_init (Object *obj); -uint64_t arm_cpu_mp_affinity (int idx,uint8_t clustersz);#ifndef CONFIG_USER_ONLY
target/arm/cpu.c +1 -1
@@ -1324,7 +1324,7 @@ unsigned int gt_cntfrq_period_ns(ARMCPU *cpu) NANOSECONDS_PER_SECOND / cpu->gt_cntfrq_hz : 1; } -void arm_cpu_post_init (Object *obj) +static void arm_cpu_post_init (Object *obj) {ARMCPU *cpu =ARM_CPU (obj);
target/arm/cpu64.c +1 -32
@@ -1373,43 +1373,12 @@ static void aarch64_cpu_class_init(ObjectClass *oc, void *data) "execution state "); } -static void aarch64_cpu_instance_init (Object *obj) -{ -ARMCPUClass *acc =ARM_CPU_GET_CLASS (obj); - - acc->info->initfn (obj); -arm_cpu_post_init (obj); -} - -static void cpu_register_class_init (ObjectClass *oc,void *data) -{ -ARMCPUClass *acc =ARM_CPU_CLASS (oc); - - acc->info = data; -} - -void aarch64_cpu_register (const ARMCPUInfo *info) -{ -TypeInfo type_info = { - .parent =TYPE_AARCH64_CPU , - .instance_size =sizeof (ARMCPU ), - .instance_init = aarch64_cpu_instance_init, - .class_size =sizeof (ARMCPUClass), - .class_init = info->class_init ?: cpu_register_class_init, - .class_data = (void *)info, - }; - - type_info.name =g_strdup_printf ("%s-" TYPE_ARM_CPU , info->name); -type_register (&type_info); -g_free ((void *)type_info.name); -} -static const TypeInfo aarch64_cpu_type_info = { .name =TYPE_AARCH64_CPU , .parent =TYPE_ARM_CPU , .instance_size =sizeof (ARMCPU ), .abstract = true, - .class_size =sizeof (AArch64CPUClass), + .class_size =sizeof (ARMCPUClass), .class_init = aarch64_cpu_class_init, };
Signature · 1 line
2.34.1
Re: [RFC PATCH 06/40] target/arm: Remove AArch64CPUClass
Quoted 5 lines · Richard Henderson
The class structure is a plain wrapper around ARMCPUClass. We really only need the QOM class,
TYPE_AARCH64_CPU. The instance init and fallback class init functions are identical to the same ones over incpu.c. Makearm_cpu_post_initstatic.
Quoted 7 lines
Signed-off-by Richard Henderson <[email protected]>--- target/arm/cpu-qom.h | 19 ++++++------------- target/arm/cpu.h | 2 -- target/arm/cpu.c | 2 +- target/arm/cpu64.c | 33 +-------------------------------- 4 files changed, 8 insertions(+), 48 deletions(-)
Nice!
RFC PATCH 7/40 target/arm: Create TYPE_ARM_V7M_CPU
In reply to Richard HendersonCreate a new intermediate abstract class for v7m, like we do for aarch64. The initialization of ARMCPUClass.info follows the concrete class, so remove that init from arm_v7m_class_init.
--- target/arm/cpu-qom.h | 6 ++++++ target/arm/cpu_tcg.c | 36 ++++++++++++++++++++++-------------- 2 files changed, 28 insertions(+), 14 deletions(-)
target/arm/cpu-qom.h +6 -0
@@ -26,6 +26,7 @@struct arm_boot_info ;#define TYPE_ARM_CPU "arm-cpu" +#define TYPE_ARM_V7M_CPU "arm-v7m-cpu"#define TYPE_AARCH64_CPU "aarch64-cpu"OBJECT_DECLARE_CPU_TYPE (ARMCPU , ARMCPUClass,ARM_CPU )
@@ -45,6 +46,11 @@ static inline void arm_cpu_register(const ARMCPUInfo *info)arm_cpu_register_parent (info,TYPE_ARM_CPU ); } +static inline void arm_v7m_cpu_register (const ARMCPUInfo *info) +{ +arm_cpu_register_parent (info,TYPE_ARM_V7M_CPU ); +} +static inline void aarch64_cpu_register (const ARMCPUInfo *info) {arm_cpu_register_parent (info,TYPE_AARCH64_CPU );
target/arm/cpu_tcg.c +22 -14
@@ -1056,10 +1056,8 @@ static const struct TCGCPUOps arm_v7m_tcg_ops = {static void arm_v7m_class_init (ObjectClass *oc,void *data) { -ARMCPUClass *acc =ARM_CPU_CLASS (oc);CPUClass *cc =CPU_CLASS (oc); - acc->info = data;#ifdef CONFIG_TCG cc->tcg_ops = &arm_v7m_tcg_ops;#endif /* CONFIG_TCG */
@@ -1149,18 +1147,6 @@ static const ARMCPUInfo arm_tcg_cpus[] = { { .name = "cortex-a8", .initfn = cortex_a8_initfn }, { .name = "cortex-a9", .initfn = cortex_a9_initfn }, { .name = "cortex-a15", .initfn = cortex_a15_initfn }, - { .name = "cortex-m0", .initfn = cortex_m0_initfn, - .class_init = arm_v7m_class_init }, - { .name = "cortex-m3", .initfn = cortex_m3_initfn, - .class_init = arm_v7m_class_init }, - { .name = "cortex-m4", .initfn = cortex_m4_initfn, - .class_init = arm_v7m_class_init }, - { .name = "cortex-m7", .initfn = cortex_m7_initfn, - .class_init = arm_v7m_class_init }, - { .name = "cortex-m33", .initfn = cortex_m33_initfn, - .class_init = arm_v7m_class_init }, - { .name = "cortex-m55", .initfn = cortex_m55_initfn, - .class_init = arm_v7m_class_init }, { .name = "cortex-r5", .initfn = cortex_r5_initfn }, { .name = "cortex-r5f", .initfn = cortex_r5f_initfn }, { .name = "ti925t", .initfn = ti925t_initfn },
@@ -1187,6 +1173,24 @@ static const ARMCPUInfo arm_tcg_cpus[] = {#endif }; +static const ARMCPUInfo arm_v7m_tcg_cpus[] = { + { .name ="cortex-m0" , .initfn = cortex_m0_initfn }, + { .name ="cortex-m3" , .initfn = cortex_m3_initfn }, + { .name ="cortex-m4" , .initfn = cortex_m4_initfn }, + { .name ="cortex-m7" , .initfn = cortex_m7_initfn }, + { .name ="cortex-m33" , .initfn = cortex_m33_initfn }, + { .name ="cortex-m55" , .initfn = cortex_m55_initfn }, +}; + +static const TypeInfo arm_v7m_cpu_type_info = { + .name =TYPE_ARM_V7M_CPU , + .parent =TYPE_ARM_CPU , + .instance_size =sizeof (ARMCPU ), + .abstract = true, + .class_size =sizeof (ARMCPUClass), + .class_init = arm_v7m_class_init, +}; +static const TypeInfo idau_interface_type_info = { .name =TYPE_IDAU_INTERFACE , .parent =TYPE_INTERFACE ,
@@ -1197,10 +1201,14 @@ static void arm_tcg_cpu_register_types(void) {size_t i; +type_register_static (&arm_v7m_cpu_type_info);type_register_static (&idau_interface_type_info);for (i =0 ; i <ARRAY_SIZE (arm_tcg_cpus); ++i) {arm_cpu_register (&arm_tcg_cpus[i]); } +for (i =0 ; i <ARRAY_SIZE (arm_v7m_tcg_cpus); ++i) { +arm_v7m_cpu_register (&arm_v7m_tcg_cpus[i]); + } }type_init (arm_tcg_cpu_register_types)
Signature · 1 line
2.34.1
Re: [RFC PATCH 07/40] target/arm: Create TYPE_ARM_V7M_CPU
Quoted 9 lines · Richard Henderson
Create a new intermediate abstract class for v7m, like we do for aarch64. The initialization of ARMCPUClass.info follows the concrete class, so remove that init from
arm_v7m_class_init.Signed-off-by Richard Henderson <[email protected]>--- target/arm/cpu-qom.h | 6 ++++++ target/arm/cpu_tcg.c | 36 ++++++++++++++++++++++-------------- 2 files changed, 28 insertions(+), 14 deletions(-)
Nice again.
RFC PATCH 8/40 target/arm: Pass ARMCPUClass to ARMCPUInfo.class_init
In reply to Richard HendersonStreamline new instances of this hook, so that we always go through arm_cpu_leaf_class_init first, performing common tasks, and have resolved the ARMCPUClass.
--- target/arm/cpu-qom.h | 2 +- target/arm/cpu.c | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-)
target/arm/cpu-qom.h +1 -1
@@ -36,7 +36,7 @@ OBJECT_DECLARE_CPU_TYPE(ARMCPU, ARMCPUClass, ARM_CPU)typedef struct ARMCPUInfo {const char *name;void (*initfn)(Object *obj); -void (*class_init)(ObjectClass *oc,void *data); +void (*class_init)(ARMCPUClass *acc); }ARMCPUInfo ;void arm_cpu_register_parent (const ARMCPUInfo *info,const char *parent);
target/arm/cpu.c +7 -3
@@ -2253,11 +2253,15 @@ static void arm_cpu_instance_init(Object *obj)arm_cpu_post_init (obj); } -static void cpu_register_class_init (ObjectClass *oc,void *data) +static void arm_cpu_leaf_class_init (ObjectClass *oc,void *data) {ARMCPUClass *acc =ARM_CPU_CLASS (oc); +const ARMCPUInfo *info = data; - acc->info = data; + acc->info = info; +if (info->class_init) { + info->class_init (acc); + } }void arm_cpu_register_parent (const ARMCPUInfo *info,const char *parent)
@@ -2268,7 +2272,7 @@ void arm_cpu_register_parent(const ARMCPUInfo *info, const char *parent) .instance_align = __alignof__(ARMCPU), .instance_init = arm_cpu_instance_init, .class_size = sizeof(ARMCPUClass), - .class_init = info->class_init ?: cpu_register_class_init, + .class_init = arm_cpu_leaf_class_init, .class_data = (void *)info, };
Signature · 1 line
2.34.1
Re: [RFC PATCH 08/40] target/arm: Pass ARMCPUClass to ARMCPUInfo.class_init
Quoted 9 lines · Richard Henderson
Streamline new instances of this hook, so that we always go through
arm_cpu_leaf_class_initfirst, performing common tasks, and have resolved the ARMCPUClass.Signed-off-by Richard Henderson <[email protected]>--- target/arm/cpu-qom.h | 2 +- target/arm/cpu.c | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-)
RFC PATCH 9/40 target/arm: Utilize arm-cpu instance_post_init hook
In reply to Richard HendersonRather than call arm_cpu_post_init ourselves from the object instance_init, let QOM handle this.
--- target/arm/cpu.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-)
target/arm/cpu.c +2 -9
@@ -2245,14 +2245,6 @@ static void arm_cpu_class_init(ObjectClass *oc, void *data)#endif /* CONFIG_TCG */ } -static void arm_cpu_instance_init (Object *obj) -{ -ARMCPUClass *acc =ARM_CPU_GET_CLASS (obj); - - acc->info->initfn (obj); -arm_cpu_post_init (obj); -} -static void arm_cpu_leaf_class_init (ObjectClass *oc,void *data) {ARMCPUClass *acc =ARM_CPU_CLASS (oc);
@@ -2270,7 +2262,7 @@ void arm_cpu_register_parent(const ARMCPUInfo *info, const char *parent) .parent = parent, .instance_size = sizeof(ARMCPU), .instance_align = __alignof__(ARMCPU), - .instance_init = arm_cpu_instance_init, + .instance_init = info->initfn, .class_size = sizeof(ARMCPUClass), .class_init = arm_cpu_leaf_class_init, .class_data = (void *)info,
@@ -2287,6 +2279,7 @@ static const TypeInfo arm_cpu_type_info = { .instance_size = sizeof(ARMCPU), .instance_align = __alignof__(ARMCPU), .instance_init = arm_cpu_initfn, + .instance_post_init = arm_cpu_post_init, .instance_finalize = arm_cpu_finalizefn, .abstract = true, .class_size = sizeof(ARMCPUClass),
Signature · 1 line
2.34.1
RFC PATCH 10/40 target/arm: Copy dtb_compatible from ARMCPUClass
In reply to Richard HendersonMove the default initialization of dtb_compatible to arm_cpu_class_init, and copy back to the instance in arm_cpu_init. Further class overrides will come in a future patch.
--- target/arm/cpu-qom.h | 3 +++ target/arm/cpu.c | 15 ++++++++++----- 2 files changed, 13 insertions(+), 5 deletions(-)
target/arm/cpu-qom.h +3 -0
@@ -71,6 +71,9 @@ struct ARMCPUClass {const ARMCPUInfo *info;DeviceRealize parent_realize;ResettablePhases parent_phases; + +/* 'compatible' string for this CPU for Linux device trees */ +const char *dtb_compatible; };void register_cp_regs_for_features (ARMCPU *cpu);
target/arm/cpu.c +10 -5
@@ -1181,6 +1181,7 @@ uint64_t arm_cpu_mp_affinity(int idx, uint8_t clustersz)static void arm_cpu_initfn (Object *obj) {ARMCPU *cpu =ARM_CPU (obj); +ARMCPUClass *acc =ARM_CPU_GET_CLASS (cpu);cpu_set_cpustate_pointers (cpu); cpu->cp_regs = g_hash_table_new_full(g_direct_hash, g_direct_equal,
@@ -1189,6 +1190,8 @@ static void arm_cpu_initfn(Object *obj)QLIST_INIT (&cpu->pre_el_change_hooks);QLIST_INIT (&cpu->el_change_hooks); + cpu->dtb_compatible = acc->dtb_compatible; +#ifdef CONFIG_USER_ONLY # ifdef TARGET_AARCH64 /*
@@ -1220,11 +1223,6 @@ static void arm_cpu_initfn(Object *obj) "pmu-interrupt", 1);#endif -/* DTB consumers generally don't in fact care what the 'compatible' -* string is, so always provide some string and trust that a hypothetical -* picky DTB consumer will also provide a helpful error message. -*/ - cpu->dtb_compatible ="qemu,unknown" ; cpu->psci_version =QEMU_PSCI_VERSION_0_1 ;/* By default assume PSCI v0.1 */ cpu->kvm_target =QEMU_KVM_ARM_TARGET_NONE ;
@@ -2243,6 +2241,13 @@ static void arm_cpu_class_init(ObjectClass *oc, void *data)#ifdef CONFIG_TCG cc->tcg_ops = &arm_tcg_ops;#endif /* CONFIG_TCG */ + +/* +* DTB consumers generally don't in fact care what the 'compatible' +* string is, so always provide some string and trust that a hypothetical +* picky DTB consumer will also provide a helpful error message. +*/ + acc->dtb_compatible ="qemu,unknown" ; }static void arm_cpu_leaf_class_init (ObjectClass *oc,void *data)
Signature · 1 line
2.34.1
RFC PATCH 11/40 target/arm: Copy features from ARMCPUClass
In reply to Richard HendersonCreate a features member in ARMCPUClass and copy to the instance in arm_cpu_init. Settings of this value will come in a future patch.
--- target/arm/cpu-qom.h | 18 ++++++++++++++++++ target/arm/cpu.c | 1 + 2 files changed, 19 insertions(+)
target/arm/cpu-qom.h +18 -0
@@ -74,8 +74,26 @@ struct ARMCPUClass {/* 'compatible' string for this CPU for Linux device trees */ const char *dtb_compatible; + +/* Internal CPU feature flags. */ +uint64_t features; }; +static inline int arm_class_feature (ARMCPUClass *acc,int feature) +{ +return (acc->features & (1ULL << feature)) !=0 ; +} + +static inline void set_class_feature (ARMCPUClass *acc,int feature) +{ + acc->features |=1ULL << feature; +} + +static inline void unset_class_feature (ARMCPUClass *acc,int feature) +{ + acc->features &= ~(1ULL << feature); +} +void register_cp_regs_for_features (ARMCPU *cpu);void init_cpreg_list (ARMCPU *cpu);
target/arm/cpu.c +1 -0
@@ -1191,6 +1191,7 @@ static void arm_cpu_initfn(Object *obj)QLIST_INIT (&cpu->el_change_hooks); cpu->dtb_compatible = acc->dtb_compatible; + cpu->env.features = acc->features;#ifdef CONFIG_USER_ONLY # ifdef TARGET_AARCH64
Signature · 1 line
2.34.1
Re: [RFC PATCH 11/40] target/arm: Copy features from ARMCPUClass
Quoted 26 lines · Richard Henderson
Create a features member in ARMCPUClass and copy to the instance in
arm_cpu_init. Settings of this value will come in a future patch.Signed-off-by Richard Henderson <[email protected]>--- target/arm/cpu-qom.h | 18 ++++++++++++++++++ target/arm/cpu.c | 1 + 2 files changed, 19 insertions(+)target/arm/cpu-qom.h +7
-0@@ -74,8 +74,26 @@ struct ARMCPUClass {/* 'compatible' string for this CPU for Linux device trees */ const char *dtb_compatible; + +/* Internal CPU feature flags. */ +uint64_t features; }; +static inline int arm_class_feature (ARMCPUClass *acc,int feature) +{ +return (acc->features & (1ULL << feature)) !=0 ; +}
target/arm/cpu-qom.h struct ARMCPUClass { · line 95
Quoted 10 lines
target/arm/cpu-qom.h +10
-0+ +static inline void set_class_feature (ARMCPUClass *acc,int feature) +{ + acc->features |=1ULL << feature; +} + +static inline void unset_class_feature (ARMCPUClass *acc,int feature) +{ + acc->features &= ~(1ULL << feature); +}
These helpers are not used until patch #19 "target/arm: Move most cpu initialization to the class".
Quoted 15 lines
target/arm/cpu-qom.h +0
-0void register_cp_regs_for_features (ARMCPU *cpu);void init_cpreg_list (ARMCPU *cpu);target/arm/cpu.c +1
-0@@ -1191,6 +1191,7 @@ static void arm_cpu_initfn(Object *obj)QLIST_INIT (&cpu->el_change_hooks); cpu->dtb_compatible = acc->dtb_compatible; + cpu->env.features = acc->features;#ifdef CONFIG_USER_ONLY # ifdef TARGET_AARCH64
Re: [RFC PATCH 11/40] target/arm: Copy features from ARMCPUClass
Quoted 30 lines · Philippe Mathieu-Daudé
Quoted 29 lines · Richard Henderson
Create a features member in ARMCPUClass and copy to the instance in arm_cpu_init. Settings of this value will come in a future patch.
Signed-off-by Richard Henderson <[email protected]>---
target/arm/cpu-qom.h| 18 ++++++++++++++++++
target/arm/cpu.c | 1 +2 files changed, 19 insertions(+)target/arm/cpu-qom.h +12
-0@@ -74,8 +74,26 @@ struct ARMCPUClass { /* 'compatible' string for this CPU for Linux device trees */ const char *dtb_compatible; + + /* Internal CPU feature flags. */ + uint64_t features; }; +static inline int arm_class_feature (ARMCPUClass *acc,int feature) +{ + return (acc->features & (1ULL << feature)) != 0; +} + +static inline void set_class_feature (ARMCPUClass *acc,int feature) +{ + acc->features |= 1ULL << feature; +}
Quoted 8 lines
target/arm/cpu-qom.h struct ARMCPUClass { · line 95
Quoted 5 lines
target/arm/cpu-qom.h +5
-0+ +static inline void unset_class_feature (ARMCPUClass *acc,int feature) +{ + acc->features &= ~(1ULL << feature); +}These helpers are not used until patch #19 "target/arm: Move most cpu initialization to the class".
I know, but I thought it clearer to introduce them with the field.
r~
Quoted 14 lines
Quoted 13 lines
target/arm/cpu-qom.h +0
-0void register_cp_regs_for_features(ARMCPU *cpu); void init_cpreg_list(ARMCPU *cpu);target/arm/cpu.c +1
-0@@ -1191,6 +1191,7 @@ static void arm_cpu_initfn(Object *obj) QLIST_INIT(&cpu->el_change_hooks); cpu->dtb_compatible = acc->dtb_compatible; + cpu->env.features = acc->features; #ifdef CONFIG_USER_ONLY # ifdef TARGET_AARCH64
Philippe Mathieu-Daudé
Reviewed-byRe: [RFC PATCH 11/40] target/arm: Copy features from ARMCPUClass
Quoted 20 lines · Richard Henderson
Quoted 11 lines · Philippe Mathieu-Daudé
Quoted 8 lines · Richard Henderson
Create a features member in ARMCPUClass and copy to the instance in arm_cpu_init. Settings of this value will come in a future patch.
Signed-off-by Richard Henderson <[email protected]>---
target/arm/cpu-qom.h| 18 ++++++++++++++++++
target/arm/cpu.c | 1 +2 files changed, 19 insertions(+)Quoted 7 lines
target/arm/cpu-qom.h struct ARMCPUClass { · line 95
Quoted 4 lines
target/arm/cpu-qom.h +4
-0+static inline void unset_class_feature (ARMCPUClass *acc,int feature) +{ + acc->features &= ~(1ULL << feature); +}These helpers are not used until patch #19 "target/arm: Move most cpu initialization to the class".
Quoted 1 line
I know, but I thought it clearer to introduce them with the field.
Fine.
RFC PATCH 12/40 target/arm: Copy isar and friends from ARMCPUClass
In reply to Richard HendersonCreate a block of cpregs in ARMCPUClass and copy to the instance in arm_cpu_init. Settings of these values will come in a future patch.
--- target/arm/cpu-qom.h | 98 ++++++++++++++++++++++++++++++++++++++++++++ target/arm/cpu.h | 43 ++----------------- target/arm/cpu.c | 28 ++++++++++++- 3 files changed, 128 insertions(+), 41 deletions(-)
target/arm/cpu-qom.h +98 -0
@@ -56,6 +56,45 @@ static inline void aarch64_cpu_register(const ARMCPUInfo *info)arm_cpu_register_parent (info,TYPE_AARCH64_CPU ); } +typedef struct ARMISARegisters { +uint32_t id_isar0; +uint32_t id_isar1; +uint32_t id_isar2; +uint32_t id_isar3; +uint32_t id_isar4; +uint32_t id_isar5; +uint32_t id_isar6; +uint32_t id_mmfr0; +uint32_t id_mmfr1; +uint32_t id_mmfr2; +uint32_t id_mmfr3; +uint32_t id_mmfr4; +uint32_t id_mmfr5; +uint32_t id_pfr0; +uint32_t id_pfr1; +uint32_t id_pfr2; +uint32_t mvfr0; +uint32_t mvfr1; +uint32_t mvfr2; +uint32_t id_dfr0; +uint32_t id_dfr1; +uint32_t dbgdidr; +uint32_t dbgdevid; +uint32_t dbgdevid1; +uint64_t id_aa64isar0; +uint64_t id_aa64isar1; +uint64_t id_aa64pfr0; +uint64_t id_aa64pfr1; +uint64_t id_aa64mmfr0; +uint64_t id_aa64mmfr1; +uint64_t id_aa64mmfr2; +uint64_t id_aa64dfr0; +uint64_t id_aa64dfr1; +uint64_t id_aa64zfr0; +uint64_t id_aa64smfr0; +uint64_t reset_pmcr_el0; +}ARMISARegisters ; +/** * ARMCPUClass: * @parent_realize: The parent class' realize handler.
@@ -77,6 +116,65 @@ struct ARMCPUClass {/* Internal CPU feature flags. */ uint64_t features; + +/* +* The instance init functions for implementation-specific subclasses +* set these fields to specify the implementation-dependent values of +* various constant registers and reset values of non-constant +* registers. +* Some of these might become QOM properties eventually. +* Field names match the official register names as defined in the +* ARMv7AR ARM Architecture Reference Manual. A reset_ prefix +* is used for reset values of non-constant registers; no reset_ +* prefix means a constant register. +* Some of these registers are split out into a substructure that +* is shared with the translators to control the ISA. +* +* Note that if you add an ID register to the ARMISARegisters struct +* you need to also update the 32-bit and 64-bit versions of the +* kvm_arm_get_host_cpu_features() function to correctly populate the +* field by reading the value from the KVM vCPU. +*/ +ARMISARegisters isar; + +uint64_t midr; +uint64_t ctr; +uint64_t pmceid0; +uint64_t pmceid1; +uint64_t id_aa64afr0; +uint64_t id_aa64afr1; +uint64_t clidr; +/* +* The elements of this array are the CCSIDR values for each cache, +* in the order L1DCache, L1ICache, L2DCache, L2ICache, etc. +*/ +uint64_t ccsidr[16 ]; + +uint32_t revidr; +uint32_t id_afr0; +uint32_t reset_fpsid; +uint32_t reset_sctlr; +uint32_t reset_auxcr; + +/* PMSAv7 MPU number of supported regions */ +uint32_t pmsav7_dregion; +/* v8M SAU number of supported regions */ +uint32_t sau_sregion; + +/* DCZ blocksize, in log_2(words), ie low 4 bits of DCZID_EL0 */ +uint32_t dcz_blocksize; + +/* Configurable aspects of GIC cpu interface (which is part of the CPU) */ +int gic_num_lrs;/* number of list registers */ +int gic_vpribits;/* number of virtual priority bits */ +int gic_vprebits;/* number of virtual preemption bits */ +int gic_pribits;/* number of physical priority bits */ + +/* +* [QEMU_]KVM_ARM_TARGET_* constant for this CPU, or +* QEMU_KVM_ARM_TARGET_NONE if the kernel doesn't support this CPU type. +*/ +uint32_t kvm_target; };static inline int arm_class_feature (ARMCPUClass *acc,int feature)
target/arm/cpu.h +3 -40
60 lines not on this page · raw message
target/arm/cpu.c +27 -1
@@ -1192,6 +1192,32 @@ static void arm_cpu_initfn(Object *obj) cpu->dtb_compatible = acc->dtb_compatible; cpu->env.features = acc->features; + cpu->isar = acc->isar; + + cpu->midr = acc->midr; + cpu->ctr = acc->ctr; + cpu->pmceid0 = acc->pmceid0; + cpu->pmceid1 = acc->pmceid1; + cpu->id_aa64afr0 = acc->id_aa64afr0; + cpu->id_aa64afr1 = acc->id_aa64afr1; + cpu->clidr = acc->clidr; + +QEMU_BUILD_BUG_ON (sizeof (cpu->ccsidr) !=sizeof (acc->ccsidr)); +memcpy (cpu->ccsidr, acc->ccsidr,sizeof (acc->ccsidr)); + + cpu->revidr = acc->revidr; + cpu->id_afr0 = acc->id_afr0; + cpu->reset_fpsid = acc->reset_fpsid; + cpu->reset_sctlr = acc->reset_sctlr; + cpu->reset_auxcr = acc->reset_auxcr; + cpu->pmsav7_dregion = acc->pmsav7_dregion; + cpu->sau_sregion = acc->sau_sregion; + cpu->dcz_blocksize = acc->dcz_blocksize; + cpu->gic_num_lrs = acc->gic_num_lrs; + cpu->gic_vpribits = acc->gic_vpribits; + cpu->gic_vprebits = acc->gic_vprebits; + cpu->gic_pribits = acc->gic_pribits; + cpu->kvm_target = acc->kvm_target;#ifdef CONFIG_USER_ONLY # ifdef TARGET_AARCH64
@@ -1225,7 +1251,6 @@ static void arm_cpu_initfn(Object *obj)#endif cpu->psci_version =QEMU_PSCI_VERSION_0_1 ;/* By default assume PSCI v0.1 */ - cpu->kvm_target =QEMU_KVM_ARM_TARGET_NONE ;if (tcg_enabled () ||hvf_enabled ()) {/* TCG and HVF implement PSCI 1.1 */
@@ -2249,6 +2274,7 @@ static void arm_cpu_class_init(ObjectClass *oc, void *data)* picky DTB consumer will also provide a helpful error message. */ acc->dtb_compatible ="qemu,unknown" ; + acc->kvm_target =QEMU_KVM_ARM_TARGET_NONE ; }static void arm_cpu_leaf_class_init (ObjectClass *oc,void *data)
Signature · 1 line
2.34.1
RFC PATCH 13/40 hw/arm/bcm2836: Set mp-affinity property in realize
In reply to Richard HendersonThere was even a TODO comment that we ought to be using a cpu property, but we failed to update when the property was added. Use ARM_AFF1_SHIFT instead of the bare constant 8.
--- hw/arm/bcm2836.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
hw/arm/bcm2836.c +5 -2
@@ -130,8 +130,11 @@ static void bcm2836_realize(DeviceState *dev, Error **errp) qdev_get_gpio_in_named(DEVICE(&s->control), "gpu-fiq", 0)); for (n = 0; n < BCM283X_NCPUS; n++) { - /* TODO: this should be converted to a property of ARM_CPU */ - s->cpu[n].core.mp_affinity = (bc->clusterid << 8) | n; + if (!object_property_set_int(OBJECT(&s->cpu[n].core), "mp-affinity", + (bc->clusterid << ARM_AFF1_SHIFT) | n, + errp)) { + return; + } /* set periphbase/CBAR value for CPU-local registers */ if (!object_property_set_int(OBJECT(&s->cpu[n].core), "reset-cbar",
Signature · 1 line
2.34.1
Re: [RFC PATCH 13/40] hw/arm/bcm2836: Set mp-affinity property in realize
Quoted 17 lines · Richard Henderson
There was even a TODO comment that we ought to be using a cpu property, but we failed to update when the property was added. Use
ARM_AFF1_SHIFTinstead of the bare constant 8.Signed-off-by Richard Henderson <[email protected]>--- hw/arm/bcm2836.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)hw/arm/bcm2836.c +0
-0@@ -130,8 +130,11 @@ static void bcm2836_realize(DeviceState *dev, Error **errp) qdev_get_gpio_in_named(DEVICE(&s->control), "gpu-fiq", 0));for (n =0 ; n <BCM283X_NCPUS ; n++) {
hw/arm/bcm2836.c static void bcm2836_realize(DeviceState *dev, Error **errp) · line 140
Quoted 10 lines
hw/arm/bcm2836.c +5
-2-/* TODO: this should be converted to a property of ARM_CPU */ - s->cpu[n].core.mp_affinity = (bc->clusterid <<8 ) | n; +if (!object_property_set_int (OBJECT (&s->cpu[n].core),"mp-affinity" , + (bc->clusterid <<ARM_AFF1_SHIFT ) | n, + errp)) { +return ; + }/* set periphbase/CBAR value for CPU-local registers */ if (!object_property_set_int(OBJECT(&s->cpu[n].core), "reset-cbar",
Eh I have almost the same patch locally:
-- >8 --
$ git show 5f675655c844154f3760967296e82adf5d8d7c24
hw/arm/bcm2836.c +2 -2
@@ -130,8 +130,8 @@ static void bcm2836_realize(DeviceState *dev, Error **errp) qdev_get_gpio_in_named(DEVICE(&s->control), "gpu-fiq", 0)); for (n = 0; n < BCM283X_NCPUS; n++) { - /* TODO: this should be converted to a property of ARM_CPU */ - s->cpu[n].core.mp_affinity = (bc->clusterid << 8) | n; + object_property_set_int(OBJECT(&s->cpu[n].core), "mp-affinity", + (bc->clusterid << 8) | n, &error_abort); /* set periphbase/CBAR value for CPU-local registers */ if (!object_property_set_int(OBJECT(&s->cpu[n].core),
"reset-cbar",
---
Yours is better (ARM_AFF1_SHIFT & checks return value).
Re: [RFC PATCH 13/40] hw/arm/bcm2836: Set mp-affinity property in realize
Quoted 30 lines · Philippe Mathieu-Daudé
Quoted 16 lines · Richard Henderson
There was even a TODO comment that we ought to be using a cpu property, but we failed to update when the property was added. Use
ARM_AFF1_SHIFTinstead of the bare constant 8.Signed-off-by Richard Henderson <[email protected]>---
hw/arm/bcm2836.c| 7 +++++--1 file changed, 5 insertions(+), 2 deletions(-)hw/arm/bcm2836.c +0
-0@@ -130,8 +130,11 @@ static void bcm2836_realize(DeviceState *dev, Error **errp) qdev_get_gpio_in_named(DEVICE(&s->control), "gpu-fiq", 0));hw/arm/bcm2836.c static void bcm2836_realize(DeviceState *dev, · line 139
Quoted 10 lines
hw/arm/bcm2836.c +5
-2for (n = 0; n < BCM283X_NCPUS; n++) { - /* TODO: this should be converted to a property of ARM_CPU */ - s->cpu[n].core.mp_affinity = (bc->clusterid << 8) | n; + if (!object_property_set_int(OBJECT(&s->cpu[n].core),"mp-affinity" , + (bc->clusterid <<ARM_AFF1_SHIFT ) | n, + errp)) { + return; + }Eh I have almost the same patch locally:
Quoted 1 line
Yours is better (
ARM_AFF1_SHIFT& checks return value).
Cherry-picking your patch I had to add "target/arm/cpu-qom.h" to avoid:
../hw/arm/bcm2836.c:146:56: error: use of undeclared identifier 'ARM_AFF1_SHIFT'
(bc->clusterid << ARM_AFF1_SHIFT) | n,
^This definition is not QOM related, I guess I'll move it to "hw/arm/cpu-defs.h" along with ARM_CPU_vIRQ/FIQ and GTIMER* definitions from "cpu.h".
RFC PATCH 14/40 target/arm: Rename arm_cpu_mp_affinity
In reply to Richard HendersonRename to arm_build_mp_affinity. This frees up the name for other usage, and emphasizes that the cpu object is not involved.
--- target/arm/cpu.h | 2 +- hw/arm/npcm7xx.c | 2 +- hw/arm/sbsa-ref.c | 2 +- hw/arm/virt.c | 2 +- target/arm/cpu.c | 6 +++--- 5 files changed, 7 insertions(+), 7 deletions(-)
target/arm/cpu.h +1 -1
@@ -1037,7 +1037,7 @@ struct ArchCPU {unsigned int gt_cntfrq_period_ns (ARMCPU *cpu); -uint64_t arm_cpu_mp_affinity (int idx,uint8_t clustersz); +uint64_t arm_build_mp_affinity (int idx,uint8_t clustersz);#ifndef CONFIG_USER_ONLY extern const VMStateDescription vmstate_arm_cpu;
hw/arm/npcm7xx.c +1 -1
@@ -462,7 +462,7 @@ static void npcm7xx_realize(DeviceState *dev, Error **errp)/* CPUs */ for (i =0 ; i < nc->num_cpus; i++) {object_property_set_int (OBJECT (&s->cpu[i]),"mp-affinity" , -arm_cpu_mp_affinity (i,NPCM7XX_MAX_NUM_CPUS ), +arm_build_mp_affinity (i,NPCM7XX_MAX_NUM_CPUS ), &error_abort);object_property_set_int (OBJECT (&s->cpu[i]),"reset-cbar" ,NPCM7XX_GIC_CPU_IF_ADDR , &error_abort);
hw/arm/sbsa-ref.c +1 -1
@@ -165,7 +165,7 @@ static bool cpu_type_valid(const char *cpu)static uint64_t sbsa_ref_cpu_mp_affinity (SBSAMachineState *sms,int idx) {uint8_t clustersz =ARM_DEFAULT_CPUS_PER_CLUSTER ; -return arm_cpu_mp_affinity (idx, clustersz); +return arm_build_mp_affinity (idx, clustersz); }/*
hw/arm/virt.c +1 -1
@@ -1700,7 +1700,7 @@ static uint64_t virt_cpu_mp_affinity(VirtMachineState *vms, int idx) clustersz =GICV3_TARGETLIST_BITS ; } } -return arm_cpu_mp_affinity (idx, clustersz); +return arm_build_mp_affinity (idx, clustersz); } static inline bool *virt_get_high_memmap_enabled(VirtMachineState *vms,
target/arm/cpu.c +3 -3
@@ -1171,7 +1171,7 @@ static void arm_cpu_dump_state(CPUState *cs, FILE *f, int flags) } } -uint64_t arm_cpu_mp_affinity (int idx,uint8_t clustersz) +uint64_t arm_build_mp_affinity (int idx,uint8_t clustersz) {uint32_t Aff1 = idx / clustersz;uint32_t Aff0 = idx % clustersz;
@@ -1927,8 +1927,8 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp)* so these bits always RAZ. */ if (cpu->mp_affinity ==ARM64_AFFINITY_INVALID ) { - cpu->mp_affinity =arm_cpu_mp_affinity (cs->cpu_index, -ARM_DEFAULT_CPUS_PER_CLUSTER ); + cpu->mp_affinity =arm_build_mp_affinity (cs->cpu_index, +ARM_DEFAULT_CPUS_PER_CLUSTER ); }if (cpu->reset_hivecs) {
Signature · 1 line
2.34.1
Re: [RFC PATCH 14/40] target/arm: Rename arm_cpu_mp_affinity
Quoted 11 lines · Richard Henderson
Rename to
arm_build_mp_affinity. This frees up the name for other usage, and emphasizes that the cpu object is not involved.Signed-off-by Richard Henderson <[email protected]>--- target/arm/cpu.h | 2 +- hw/arm/npcm7xx.c | 2 +- hw/arm/sbsa-ref.c | 2 +- hw/arm/virt.c | 2 +- target/arm/cpu.c | 6 +++--- 5 files changed, 7 insertions(+), 7 deletions(-)
RFC PATCH 15/40 target/arm: Create arm_cpu_mp_affinity
In reply to Richard HendersonWrapper to return the mp affinity bits from the cpu.
--- target/arm/cpu.h | 5 +++++ hw/arm/virt-acpi-build.c | 2 +- hw/arm/virt.c | 6 +++--- hw/arm/xlnx-versal-virt.c | 3 ++- hw/misc/xlnx-versal-crl.c | 4 ++-- target/arm/arm-powerctl.c | 2 +- target/arm/hvf/hvf.c | 4 ++-- target/arm/psci.c | 2 +- 8 files changed, 17 insertions(+), 11 deletions(-)
target/arm/cpu.h +5 -0
@@ -1039,6 +1039,11 @@ unsigned int gt_cntfrq_period_ns(ARMCPU *cpu);uint64_t arm_build_mp_affinity (int idx,uint8_t clustersz); +static inline uint64_t arm_cpu_mp_affinity (ARMCPU *cpu) +{ +return cpu->mp_affinity; +} +#ifndef CONFIG_USER_ONLY extern const VMStateDescription vmstate_arm_cpu;
hw/arm/virt-acpi-build.c +1 -1
@@ -759,7 +759,7 @@ build_madt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)build_append_int_noprefix (table_data, vgic_interrupt,4 );build_append_int_noprefix (table_data,0 ,8 );/* GICR Base Address*/ /* MPIDR */ -build_append_int_noprefix (table_data, armcpu->mp_affinity,8 ); +build_append_int_noprefix (table_data,arm_cpu_mp_affinity (armcpu),8 );/* Processor Power Efficiency Class */ build_append_int_noprefix (table_data,0 ,1 );/* Reserved */
hw/arm/virt.c +3 -3
@@ -391,7 +391,7 @@ static void fdt_add_cpu_nodes(const VirtMachineState *vms)for (cpu =0 ; cpu < smp_cpus; cpu++) {ARMCPU *armcpu =ARM_CPU (qemu_get_cpu (cpu)); -if (armcpu->mp_affinity &ARM_AFF3_MASK ) { +if (arm_cpu_mp_affinity (armcpu) &ARM_AFF3_MASK ) { addr_cells =2 ;break ; }
@@ -418,10 +418,10 @@ static void fdt_add_cpu_nodes(const VirtMachineState *vms)if (addr_cells ==2 ) {qemu_fdt_setprop_u64 (ms->fdt, nodename,"reg" , - armcpu->mp_affinity); +arm_cpu_mp_affinity (armcpu)); }else {qemu_fdt_setprop_cell (ms->fdt, nodename,"reg" , - armcpu->mp_affinity); +arm_cpu_mp_affinity (armcpu)); }if (ms->possible_cpus->cpus[cs->cpu_index].props.has_node_id) {
hw/arm/xlnx-versal-virt.c +2 -1
@@ -104,7 +104,8 @@ static void fdt_add_cpu_nodes(VersalVirt *s, uint32_t psci_conduit)ARMCPU *armcpu =ARM_CPU (qemu_get_cpu (i));qemu_fdt_add_subnode (s->fdt, name); -qemu_fdt_setprop_cell (s->fdt, name,"reg" , armcpu->mp_affinity); +qemu_fdt_setprop_cell (s->fdt, name,"reg" , +arm_cpu_mp_affinity (armcpu));if (psci_conduit !=QEMU_PSCI_CONDUIT_DISABLED ) {qemu_fdt_setprop_string (s->fdt, name,"enable-method" ,"psci" ); }
hw/misc/xlnx-versal-crl.c +2 -2
@@ -67,9 +67,9 @@ static void crl_reset_cpu(XlnxVersalCRL *s, ARMCPU *armcpu, bool rst_old, bool rst_new) {if (rst_new) { -arm_set_cpu_off (armcpu->mp_affinity); +arm_set_cpu_off (arm_cpu_mp_affinity (armcpu)); }else { -arm_set_cpu_on_and_reset (armcpu->mp_affinity); +arm_set_cpu_on_and_reset (arm_cpu_mp_affinity (armcpu)); } }
target/arm/arm-powerctl.c +1 -1
@@ -36,7 +36,7 @@ CPUState *arm_get_cpu_by_id(uint64_t id)CPU_FOREACH (cpu) {ARMCPU *armcpu =ARM_CPU (cpu); -if (armcpu->mp_affinity == id) { +if (arm_cpu_mp_affinity (armcpu) == id) {return cpu; } }
target/arm/hvf/hvf.c +2 -2
@@ -645,7 +645,7 @@ static void hvf_raise_exception(CPUState *cpu, uint32_t excp,static void hvf_psci_cpu_off (ARMCPU *arm_cpu) { -int32_t ret =arm_set_cpu_off (arm_cpu->mp_affinity); +int32_t ret =arm_set_cpu_off (arm_cpu_mp_affinity (arm_cpu));assert (ret ==QEMU_ARM_POWERCTL_RET_SUCCESS ); }
@@ -674,7 +674,7 @@ static bool hvf_handle_psci_call(CPUState *cpu)int32_t ret =0 ;trace_hvf_psci_call (param[0 ], param[1 ], param[2 ], param[3 ], - arm_cpu->mp_affinity); +arm_cpu_mp_affinity (arm_cpu));switch (param[0 ]) {case QEMU_PSCI_0_2_FN_PSCI_VERSION :
target/arm/psci.c +1 -1
@@ -215,7 +215,7 @@ err:return ; cpu_off: - ret =arm_set_cpu_off (cpu->mp_affinity); + ret =arm_set_cpu_off (arm_cpu_mp_affinity (cpu));/* notreached */ /* sanity check in case something failed */ assert (ret ==QEMU_ARM_POWERCTL_RET_SUCCESS );
Signature · 1 line
2.34.1
Re: [RFC PATCH 15/40] target/arm: Create arm_cpu_mp_affinity
Quoted 13 lines · Richard Henderson
Wrapper to return the mp affinity bits from the cpu.
Signed-off-by Richard Henderson <[email protected]>--- target/arm/cpu.h | 5 +++++ hw/arm/virt-acpi-build.c | 2 +- hw/arm/virt.c | 6 +++--- hw/arm/xlnx-versal-virt.c | 3 ++- hw/misc/xlnx-versal-crl.c | 4 ++-- target/arm/arm-powerctl.c | 2 +- target/arm/hvf/hvf.c | 4 ++-- target/arm/psci.c | 2 +- 8 files changed, 17 insertions(+), 11 deletions(-)
RFC PATCH 16/40 target/arm: Represent the entire MPIDR_EL1
In reply to Richard HendersonReplace ARMCPU.mp_affinity with CPUARMState.cp15.mpidr_el1, setting the additional bits as required. In particular, always set the U bit when there is only one cpu in the system. Remove the mp_is_up bit which attempted to do the same thing.
--- target/arm/cpu.h | 7 ++-- target/arm/cpu.c | 80 +++++++++++++++++++++++++++++++++++++------- target/arm/cpu_tcg.c | 1 - target/arm/helper.c | 25 ++------------ target/arm/hvf/hvf.c | 2 +- target/arm/kvm64.c | 4 +-- 6 files changed, 75 insertions(+), 44 deletions(-)
target/arm/cpu.h +2 -5
@@ -935,9 +935,6 @@ struct ArchCPU {/* KVM steal time */ OnOffAuto kvm_steal_time; -/* Uniprocessor system with MP extensions */ -bool mp_is_up; -/* True if we tried kvm_arm_host_cpu_features() during CPU instance_init * and the probe failed (so we need to report the error in realize) */
@@ -977,7 +974,7 @@ struct ArchCPU {uint64_t id_aa64afr0;uint64_t id_aa64afr1;uint64_t clidr; -uint64_t mp_affinity;/* MP ID without feature bits */ +uint64_t mpidr_el1;/* The elements of this array are the CCSIDR values for each cache, * in the order L1DCache, L1ICache, L2DCache, L2ICache, etc. */
@@ -1041,7 +1038,7 @@ uint64_t arm_build_mp_affinity(int idx, uint8_t clustersz);static inline uint64_t arm_cpu_mp_affinity (ARMCPU *cpu) { -return cpu->mp_affinity; +return cpu->mpidr_el1 &ARM64_AFFINITY_MASK ; }#ifndef CONFIG_USER_ONLY
target/arm/cpu.c +67 -13
112 lines not on this page · raw message
target/arm/cpu_tcg.c +0 -1
@@ -848,7 +848,6 @@ static void cortex_r5_initfn(Object *obj) cpu->isar.id_isar4 =0x0010142 ; cpu->isar.id_isar5 =0x0 ; cpu->isar.id_isar6 =0x0 ; - cpu->mp_is_up = true; cpu->pmsav7_dregion =16 ; cpu->isar.reset_pmcr_el0 =0x41151800 ;define_arm_cp_regs (cpu, cortexr5_cp_reginfo);
target/arm/helper.c +3 -22
@@ -4087,24 +4087,6 @@ static uint64_t midr_read(CPUARMState *env, const ARMCPRegInfo *ri)return raw_read (env, ri); } -static uint64_t mpidr_read_val (CPUARMState *env) -{ -ARMCPU *cpu =env_archcpu (env); -uint64_t mpidr = cpu->mp_affinity; - -if (arm_feature (env,ARM_FEATURE_V7MP )) { - mpidr |= (1U <<31 ); -/* Cores which are uniprocessor (non-coherent) -* but still implement the MP extensions set -* bit 30. (For instance, Cortex-R5). -*/ -if (cpu->mp_is_up) { - mpidr |= (1u <<30 ); - } - } -return mpidr; -} -static uint64_t mpidr_read (CPUARMState *env,const ARMCPRegInfo *ri) {unsigned int cur_el =arm_current_el (env);
@@ -4112,7 +4094,7 @@ static uint64_t mpidr_read(CPUARMState *env, const ARMCPRegInfo *ri)if (arm_is_el2_enabled (env) && cur_el ==1 ) {return env->cp15.vmpidr_el2; } -return mpidr_read_val (env); +return env_archcpu (env)->mpidr_el1; }static const ARMCPRegInfo lpae_cp_reginfo[] = {
@@ -7940,7 +7922,6 @@ void register_cp_regs_for_features(ARMCPU *cpu)if (arm_feature (env,ARM_FEATURE_EL2 ) || (arm_feature (env,ARM_FEATURE_EL3 ) &&arm_feature (env,ARM_FEATURE_V8 ))) { -uint64_t vmpidr_def =mpidr_read_val (env);ARMCPRegInfo vpidr_regs[] = { { .name ="VPIDR" , .state =ARM_CP_STATE_AA32 , .cp =15 , .opc1 =4 , .crn =0 , .crm =0 , .opc2 =0 ,
@@ -7956,12 +7937,12 @@ void register_cp_regs_for_features(ARMCPU *cpu) { .name = "VMPIDR", .state = ARM_CP_STATE_AA32, .cp = 15, .opc1 = 4, .crn = 0, .crm = 0, .opc2 = 5, .access = PL2_RW, .accessfn = access_el3_aa32ns, - .resetvalue = vmpidr_def, + .resetvalue = cpu->mpidr_el1, .type = ARM_CP_ALIAS | ARM_CP_EL3_NO_EL2_C_NZ, .fieldoffset = offsetoflow32(CPUARMState, cp15.vmpidr_el2) }, { .name = "VMPIDR_EL2", .state = ARM_CP_STATE_AA64, .opc0 = 3, .opc1 = 4, .crn = 0, .crm = 0, .opc2 = 5, - .access = PL2_RW, .resetvalue = vmpidr_def, + .access = PL2_RW, .resetvalue = cpu->mpidr_el1, .type = ARM_CP_EL3_NO_EL2_C_NZ, .fieldoffset = offsetof(CPUARMState, cp15.vmpidr_el2) }, };
target/arm/hvf/hvf.c +1 -1
@@ -607,7 +607,7 @@ int hvf_arch_init_vcpu(CPUState *cpu)assert_hvf_ok (ret); ret =hv_vcpu_set_sys_reg (cpu->hvf->fd,HV_SYS_REG_MPIDR_EL1 , - arm_cpu->mp_affinity); + arm_cpu->mpidr_el1);assert_hvf_ok (ret); ret =hv_vcpu_get_sys_reg (cpu->hvf->fd,HV_SYS_REG_ID_AA64PFR0_EL1 , &pfr);
target/arm/kvm64.c +2 -2
@@ -914,11 +914,11 @@ int kvm_arch_init_vcpu(CPUState *cs)* Currently KVM has its own idea about MPIDR assignment, so we * override our defaults with what we get from KVM. */ - ret =kvm_get_one_reg (cs,ARM64_SYS_REG (ARM_CPU_ID_MPIDR ), &mpidr); + ret =kvm_get_one_reg (cs,ARM64_SYS_REG (ARM_CPU_ID_MPIDR ), + &cpu->mpidr_el1);if (ret) {return ret; } - cpu->mp_affinity = mpidr &ARM64_AFFINITY_MASK ;kvm_arm_init_debug (cs);
Signature · 1 line
2.34.1
Re: [RFC PATCH 16/40] target/arm: Represent the entire MPIDR_EL1
Quoted 7 lines · Richard Henderson
Replace ARMCPU.mp_affinity with CPUARMState.cp15.mpidr_el1, setting the additional bits as required. In particular, always set the U bit when there is only one cpu in the system. Remove the
mp_is_upbit which attempted to do the same thing.Signed-off-by Richard Henderson <[email protected]>
Quoted 8 lines
--- target/arm/cpu.h | 7 ++-- target/arm/cpu.c | 80 +++++++++++++++++++++++++++++++++++++------- target/arm/cpu_tcg.c | 1 - target/arm/helper.c | 25 ++------------ target/arm/hvf/hvf.c | 2 +- target/arm/kvm64.c | 4 +-- 6 files changed, 75 insertions(+), 44 deletions(-)
Based purely on the diffstat it's not super-obvious why this is an improvement. What's the rationale ?
Side note, we don't currently handle the MT bit, where some CPUs end up putting the cpu number in the Aff1 field rather than Aff0. We ideally ought to handle that too.
thanks
-- PMM
Re: [RFC PATCH 16/40] target/arm: Represent the entire MPIDR_EL1
Quoted 18 lines · Peter Maydell
Quoted 7 lines · Richard Henderson
Replace ARMCPU.mp_affinity with CPUARMState.cp15.mpidr_el1, setting the additional bits as required. In particular, always set the U bit when there is only one cpu in the system. Remove the
mp_is_upbit which attempted to do the same thing.Signed-off-by Richard Henderson <[email protected]>Quoted 8 lines
--- target/arm/cpu.h | 7 ++-- target/arm/cpu.c | 80 +++++++++++++++++++++++++++++++++++++------- target/arm/cpu_tcg.c | 1 - target/arm/helper.c | 25 ++------------ target/arm/hvf/hvf.c | 2 +- target/arm/kvm64.c | 4 +-- 6 files changed, 75 insertions(+), 44 deletions(-)
Quoted 2 lines
Based purely on the diffstat it's not super-obvious why this is an improvement. What's the rationale ?
It gets rid of cpu->mp_is_up, set only by cortex-r5, and then generalizes.
Quoted 3 lines
Side note, we don't currently handle the MT bit, where some CPUs end up putting the cpu number in the Aff1 field rather than Aff0. We ideally ought to handle that too.
Would that be set by the board as well? I don't think we model cpu packages/clusters/whatchacallums at that level currently.
r~
Re: [RFC PATCH 16/40] target/arm: Represent the entire MPIDR_EL1
Quoted 23 lines · Richard Henderson
Quoted 18 lines · Peter Maydell
Quoted 7 lines · Richard Henderson
Replace ARMCPU.mp_affinity with CPUARMState.cp15.mpidr_el1, setting the additional bits as required. In particular, always set the U bit when there is only one cpu in the system. Remove the
mp_is_upbit which attempted to do the same thing.Signed-off-by Richard Henderson <[email protected]>Quoted 8 lines
--- target/arm/cpu.h | 7 ++-- target/arm/cpu.c | 80 +++++++++++++++++++++++++++++++++++++------- target/arm/cpu_tcg.c | 1 - target/arm/helper.c | 25 ++------------ target/arm/hvf/hvf.c | 2 +- target/arm/kvm64.c | 4 +-- 6 files changed, 75 insertions(+), 44 deletions(-)Quoted 2 lines
Based purely on the diffstat it's not super-obvious why this is an improvement. What's the rationale ?
Quoted 8 lines
It gets rid of
cpu->mp_is_up, set only by cortex-r5, and then generalizes.Quoted 3 lines
Side note, we don't currently handle the MT bit, where some CPUs end up putting the cpu number in the Aff1 field rather than Aff0. We ideally ought to handle that too.
Would that be set by the board as well? I don't think we model cpu packages/clusters/whatchacallums at that level currently.
It's a fixed property of the CPU implementation, same as mp_is_up. We currently mismodel Cortex-A55, Cortex-A76 and Neoverse-N1, which should all be setting the MT bit in MPIDR and having the cpu number in Aff1. See this thread:
https://lore.kernel.org/qemu-devel/CAFEAcA9P2-v94p8H8+ktnf-Yf-rucbGySXE6AGPdwvDxXfP=ZA@mail.gmail.com/
+ if (arm_feature(env, ARM_FEATURE_V7MP)) {
+ cpu->mpidr_el1 |= (1u << 31); /* M */
+ if (cpu->core_count == 1) {
+ cpu->mpidr_el1 |= 1 << 30; /* U */
+ }
+ }
This is wrong, incidentally -- a single Cortex A9, A53, etc does not set the U bit. (It's "a cluster with 1 core in it", not "a uniprocessor system".) The reason mp_is_up is set only by the R5 model is because "we implement the MP extensions but consider ourselves to be not part of a cluster" is a behaviour of only this CPU. I forget why I didn't implement it as an ARM_FEATURE_FOO bit.
thanks
-- PMM
Re: [RFC PATCH 16/40] target/arm: Represent the entire MPIDR_EL1
Quoted 10 lines · Peter Maydell
target/arm/cpu.c +6
-0+if (arm_feature (env,ARM_FEATURE_V7MP )) { + cpu->mpidr_el1 |= (1u <<31 );/* M */ +if (cpu->core_count ==1 ) { + cpu->mpidr_el1 |=1 <<30 ;/* U */ + } + }This is wrong, incidentally -- a single Cortex A9, A53, etc does not set the U bit. (It's "a cluster with 1 core in it", not "a uniprocessor system".)
Hmph. It would have been handy to have the "uniprocessor" term defined somewhere in the architecture manual, since they appear to be using it in a specialized way.
r~
RFC PATCH 17/40 target/arm: Copy cp_regs from ARMCPUClass
In reply to Richard HendersonCreate a hash table of cpregs in ARMCPUClass and copy to the instance in arm_cpu_init. Population of this new table will come in a future patch.
--- target/arm/cpu-qom.h | 3 +++ target/arm/cpu.c | 23 +++++++++++++++++++++-- 2 files changed, 24 insertions(+), 2 deletions(-)
target/arm/cpu-qom.h +3 -0
@@ -111,6 +111,9 @@ struct ARMCPUClass {DeviceRealize parent_realize;ResettablePhases parent_phases; +/* Coprocessor information */ +GHashTable *cp_regs; +/* 'compatible' string for this CPU for Linux device trees */ const char *dtb_compatible;
target/arm/cpu.c +21 -2
@@ -1178,14 +1178,29 @@ uint64_t arm_build_mp_affinity(int idx, uint8_t clustersz)return (Aff1 <<ARM_AFF1_SHIFT ) | Aff0; } +static void copy_cp_regs_1 (gpointer key,gpointer value,gpointer user) +{ +GHashTable *new_table = user; +ARMCPRegInfo *new_reg =g_memdup (value,sizeof (ARMCPRegInfo)); +bool ok =g_hash_table_insert (new_table, key, new_reg); +g_assert (ok); +} + +static GHashTable *copy_cp_regs (GHashTable *cp_regs) +{ +GHashTable *ret =g_hash_table_new_full (g_direct_hash, g_direct_equal, +NULL , g_free); + +g_hash_table_foreach (cp_regs, copy_cp_regs_1, ret); +return ret; +} +static void arm_cpu_initfn (Object *obj) {ARMCPU *cpu =ARM_CPU (obj);ARMCPUClass *acc =ARM_CPU_GET_CLASS (cpu);cpu_set_cpustate_pointers (cpu); - cpu->cp_regs =g_hash_table_new_full (g_direct_hash, g_direct_equal, -NULL , g_free);QLIST_INIT (&cpu->pre_el_change_hooks);QLIST_INIT (&cpu->el_change_hooks);
@@ -1219,6 +1234,8 @@ static void arm_cpu_initfn(Object *obj) cpu->gic_pribits = acc->gic_pribits; cpu->kvm_target = acc->kvm_target; + cpu->cp_regs =copy_cp_regs (acc->cp_regs); +#ifdef CONFIG_USER_ONLY # ifdef TARGET_AARCH64 /*
@@ -2337,6 +2354,8 @@ static void arm_cpu_leaf_class_init(ObjectClass *oc, void *data)const ARMCPUInfo *info = data; acc->info = info; + acc->cp_regs =g_hash_table_new_full (g_direct_hash, g_direct_equal, +NULL , g_free);if (info->class_init) { info->class_init (acc); }
Signature · 1 line
2.34.1
RFC PATCH 18/40 target/arm: Create cpreg definition functions with GHashTable arg
In reply to Richard HendersonThis will allow registration of cpregs at the class level.
--- target/arm/cpregs.h | 33 +++++++++++++++++++++++++++---- target/arm/helper.c | 47 +++++++++++++++++++++++++-------------------- 2 files changed, 55 insertions(+), 25 deletions(-)
target/arm/cpregs.h +29 -4
@@ -381,16 +381,33 @@ struct ARMCPRegInfo {#define CPREG_FIELD64 (env, ri) \ (*(uint64_t *)((char *)(env) + (ri)->fieldoffset)) -void define_one_arm_cp_reg_with_opaque (ARMCPU *cpu,const ARMCPRegInfo *reg, -void *opaque); +void define_one_arm_cp_reg_with_table (GHashTable *cp_regs,uint64_t features, +const ARMCPRegInfo *reg,void *opaque); + +void define_arm_cp_regs_with_table (GHashTable *cp_regs,uint64_t features, +const ARMCPRegInfo *regs, +void *opaque,size_t len); + +static inline void +define_one_arm_cp_reg_with_opaque (ARMCPU *cpu,const ARMCPRegInfo *reg, +void *opaque) +{ +define_one_arm_cp_reg_with_table (cpu->cp_regs, cpu->env.features, + reg, opaque); +}static inline void define_one_arm_cp_reg (ARMCPU *cpu,const ARMCPRegInfo *regs) {define_one_arm_cp_reg_with_opaque (cpu, regs,NULL ); } -void define_arm_cp_regs_with_opaque_len (ARMCPU *cpu,const ARMCPRegInfo *regs, -void *opaque,size_t len); +static inline void +define_arm_cp_regs_with_opaque_len (ARMCPU *cpu,const ARMCPRegInfo *regs, +void *opaque,size_t len) +{ +define_arm_cp_regs_with_table (cpu->cp_regs, cpu->env.features, + regs, opaque, len); +}#define define_arm_cp_regs_with_opaque (CPU ,REGS ,OPAQUE ) \ do { \
@@ -402,6 +419,14 @@ void define_arm_cp_regs_with_opaque_len(ARMCPU *cpu, const ARMCPRegInfo *regs,#define define_arm_cp_regs (CPU ,REGS ) \ define_arm_cp_regs_with_opaque(CPU, REGS, NULL) +#define define_arm_cp_regs_with_class (ACC ,REGS ,OPAQUE ) \ + do { \ + QEMU_BUILD_BUG_ON(ARRAY_SIZE(REGS) == 0); \ + ARMCPUClass *acc_ = (ACC); \ + define_arm_cp_regs_with_table(acc_->cp_regs, acc_->features, \ + REGS, OPAQUE, ARRAY_SIZE(REGS)); \ + } while (0) +const ARMCPRegInfo *get_arm_cp_reginfo (GHashTable *cpregs,uint32_t encoded_cp);/*
target/arm/helper.c +26 -21
136 lines not on this page · raw message
Signature · 1 line
2.34.1
RFC PATCH 19/40 target/arm: Move most cpu initialization to the class
In reply to Richard HendersonQuite a lot of the cpu definition is constant, and can be initialized once with the type, rather than for each object instance. For now, leave the "host" cpu with the object init.
Note that the "max" class (and even a converted "host") must be delayed until accellerator init, which itself is delayed until after board init, which already creates all of the types. Thus we invent our own hook.
--- target/arm/cpu-qom.h | 3 +- target/arm/internals.h | 6 +- target/arm/cpu.c | 23 +- target/arm/cpu64.c | 227 +++++++++---------- target/arm/cpu_tcg.c | 496 ++++++++++++++++++----------------------- 5 files changed, 355 insertions(+), 400 deletions(-)
target/arm/cpu-qom.h +2 -1
@@ -35,8 +35,9 @@ OBJECT_DECLARE_CPU_TYPE(ARMCPU, ARMCPUClass, ARM_CPU)typedef struct ARMCPUInfo {const char *name; -void (*initfn)(Object *obj); +void (*object_init)(Object *obj);void (*class_init)(ARMCPUClass *acc); +bool (*class_late_init)(ARMCPUClass *acc,Error **errp); }ARMCPUInfo ;void arm_cpu_register_parent (const ARMCPUInfo *info,const char *parent);
target/arm/internals.h +3 -3
@@ -1347,14 +1347,14 @@ void arm_cpu_lpa2_finalize(ARMCPU *cpu, Error **errp);#endif #ifdef CONFIG_USER_ONLY -static inline void define_cortex_a72_a57_a53_cp_reginfo (ARMCPU *cpu) { } +static inline void define_cortex_a72_a57_a53_cp_reginfo (ARMCPUClass *acc) { }#else -void define_cortex_a72_a57_a53_cp_reginfo (ARMCPU *cpu); +void define_cortex_a72_a57_a53_cp_reginfo (ARMCPUClass *acc);#endif bool el_is_in_host (CPUARMState *env,int el); -void aa32_max_features (ARMCPU *cpu); +void aa32_max_features (ARMCPUClass *acc);int exception_target_el (CPUARMState *env);bool arm_singlestep_active (CPUARMState *env);bool arm_generate_debug_exceptions (CPUARMState *env);
target/arm/cpu.c +18 -5
@@ -2351,23 +2351,35 @@ static void arm_cpu_class_init(ObjectClass *oc, void *data)static void arm_cpu_leaf_class_init (ObjectClass *oc,void *data) {ARMCPUClass *acc =ARM_CPU_CLASS (oc); -const ARMCPUInfo *info = data; - acc->info = info; acc->cp_regs =g_hash_table_new_full (g_direct_hash, g_direct_equal,NULL , g_free); -if (info->class_init) { - info->class_init (acc); + + acc->info = data; +if (acc->info->class_init) { + acc->info->class_init (acc); } } +static bool arm_cpu_class_late_init (ObjectClass *oc,Error **errp) +{ +ARMCPUClass *acc =ARM_CPU_CLASS (oc); + +if (acc->info->class_late_init) { +if (!acc->info->class_late_init (acc, errp)) { +return false; + } + } +return true; +} +void arm_cpu_register_parent (const ARMCPUInfo *info,const char *parent) {TypeInfo type_info = { .parent = parent, .instance_size =sizeof (ARMCPU ), .instance_align = __alignof__(ARMCPU ), - .instance_init = info->initfn, + .instance_init = info->object_init, .class_size =sizeof (ARMCPUClass), .class_init = arm_cpu_leaf_class_init, .class_data = (void *)info,
@@ -2389,6 +2401,7 @@ static const TypeInfo arm_cpu_type_info = { .abstract = true, .class_size = sizeof(ARMCPUClass), .class_init = arm_cpu_class_init, + .class_late_init = arm_cpu_class_late_init, };static void arm_cpu_register_types (void )
target/arm/cpu64.c +115 -112
334 lines not on this page · raw message
target/arm/cpu_tcg.c +217 -279
803 lines not on this page · raw message
Signature · 1 line
2.34.1
RFC PATCH 20/40 target/arm: Merge kvm64.c with kvm.c
In reply to Richard HendersonWith appropriate sorting of functions, this allows quite a number of prototypes to be removed from kvm_arm.h, and the corresponding functions made static.
--- target/arm/kvm_arm.h | 190 ---- target/arm/kvm.c | 2048 +++++++++++++++++++++++++++++++++++++--- target/arm/kvm64.c | 1632 -------------------------------- target/arm/meson.build | 2 +- 4 files changed, 1896 insertions(+), 1976 deletions(-) delete mode 100644 target/arm/kvm64.c
target/arm/kvm_arm.h +0 -190
@@ -18,32 +18,6 @@#define KVM_ARM_VGIC_V2 (1 << 0)#define KVM_ARM_VGIC_V3 (1 << 1) -/** -* kvm_arm_vcpu_init: -* @cs: CPUState -* -* Initialize (or reinitialize) the VCPU by invoking the -* KVM_ARM_VCPU_INIT ioctl with the CPU type and feature -* bitmask specified in the CPUState. -* -* Returns: 0 if success else < 0 error code -*/ -int kvm_arm_vcpu_init (CPUState *cs); - -/** -* kvm_arm_vcpu_finalize: -* @cs: CPUState -* @feature: feature to finalize -* -* Finalizes the configuration of the specified VCPU feature by -* invoking the KVM_ARM_VCPU_FINALIZE ioctl. Features requiring -* this are documented in the "KVM_ARM_VCPU_FINALIZE" section of -* KVM's API documentation. -* -* Returns: 0 if success else < 0 error code -*/ -int kvm_arm_vcpu_finalize (CPUState *cs,int feature); -/** * kvm_arm_register_device: * @mr: memory region for this device
@@ -65,37 +39,6 @@ int kvm_arm_vcpu_finalize(CPUState *cs, int feature);void kvm_arm_register_device (MemoryRegion *mr,uint64_t devid,uint64_t group,uint64_t attr,int dev_fd,uint64_t addr_ormask); -/** -* kvm_arm_init_cpreg_list: -* @cpu: ARMCPU -* -* Initialize the ARMCPU cpreg list according to the kernel's -* definition of what CPU registers it knows about (and throw away -* the previous TCG-created cpreg list). -* -* Returns: 0 if success, else < 0 error code -*/ -int kvm_arm_init_cpreg_list (ARMCPU *cpu); - -/** -* kvm_arm_reg_syncs_via_cpreg_list: -* @regidx: KVM register index -* -* Return true if this KVM register should be synchronized via the -* cpreg list of arbitrary system registers, false if it is synchronized -* by hand using code in kvm_arch_get/put_registers(). -*/ -bool kvm_arm_reg_syncs_via_cpreg_list (uint64_t regidx); - -/** -* kvm_arm_cpreg_level: -* @regidx: KVM register index -* -* Return the level of this coprocessor/system register. Return value is -* either KVM_PUT_RUNTIME_STATE, KVM_PUT_RESET_STATE, or KVM_PUT_FULL_STATE. -*/ -int kvm_arm_cpreg_level (uint64_t regidx); -/** * write_list_to_kvmstate: * @cpu: ARMCPU
@@ -155,34 +98,6 @@ void kvm_arm_cpu_post_load(ARMCPU *cpu);*/ void kvm_arm_reset_vcpu (ARMCPU *cpu); -/** -* kvm_arm_init_serror_injection: -* @cs: CPUState -* -* Check whether KVM can set guest SError syndrome. -*/ -void kvm_arm_init_serror_injection (CPUState *cs); - -/** -* kvm_get_vcpu_events: -* @cpu: ARMCPU -* -* Get VCPU related state from kvm. -* -* Returns: 0 if success else < 0 error code -*/ -int kvm_get_vcpu_events (ARMCPU *cpu); - -/** -* kvm_put_vcpu_events: -* @cpu: ARMCPU -* -* Put VCPU related state to kvm. -* -* Returns: 0 if success else < 0 error code -*/ -int kvm_put_vcpu_events (ARMCPU *cpu); -#ifdef CONFIG_KVM /** * kvm_arm_create_scratch_host_vcpu:
@@ -214,28 +129,6 @@ bool kvm_arm_create_scratch_host_vcpu(const uint32_t *cpus_to_try,*/ void kvm_arm_destroy_scratch_host_vcpu (int *fdarray); -/** -* ARMHostCPUFeatures: information about the host CPU (identified -* by asking the host kernel) -*/ -typedef struct ARMHostCPUFeatures { -ARMISARegisters isar; -uint64_t features; -uint32_t target; -const char *dtb_compatible; -}ARMHostCPUFeatures ; - -/** -* kvm_arm_get_host_cpu_features: -* @ahcf: ARMHostCPUClass to fill in -* -* Probe the capabilities of the host kernel's preferred CPU and fill -* in the ARMHostCPUClass struct accordingly. -* -* Returns true on success and false otherwise. -*/ -bool kvm_arm_get_host_cpu_features (ARMHostCPUFeatures *ahcf); -/** * kvm_arm_sve_get_vls: * @cs: CPUState
@@ -274,14 +167,6 @@ void kvm_arm_add_vcpu_properties(Object *obj);*/ void kvm_arm_steal_time_finalize (ARMCPU *cpu,Error **errp); -/** -* kvm_arm_steal_time_supported: -* -* Returns: true if KVM can enable steal time reporting -* and false otherwise. -*/ -bool kvm_arm_steal_time_supported (void ); -/** * kvm_arm_aarch32_supported: *
@@ -315,44 +200,6 @@ bool kvm_arm_sve_supported(void);*/ int kvm_arm_get_max_vm_ipa_size (MachineState *ms,bool *fixed_ipa); -/** -* kvm_arm_sync_mpstate_to_kvm: -* @cpu: ARMCPU -* -* If supported set the KVM MP_STATE based on QEMU's model. -* -* Returns 0 on success and -1 on failure. -*/ -int kvm_arm_sync_mpstate_to_kvm (ARMCPU *cpu); - -/** -* kvm_arm_sync_mpstate_to_qemu: -* @cpu: ARMCPU -* -* If supported get the MP_STATE from KVM and store in QEMU's model. -* -* Returns 0 on success and aborts on failure. -*/ -int kvm_arm_sync_mpstate_to_qemu (ARMCPU *cpu); - -/** -* kvm_arm_get_virtual_time: -* @cs: CPUState -* -* Gets the VCPU's virtual counter and stores it in the KVM CPU state. -*/ -void kvm_arm_get_virtual_time (CPUState *cs); - -/** -* kvm_arm_put_virtual_time: -* @cs: CPUState -* -* Sets the VCPU's virtual counter to the value stored in the KVM CPU state. -*/ -void kvm_arm_put_virtual_time (CPUState *cs); - -void kvm_arm_vm_state_change (void *opaque,bool running,RunState state); -int kvm_arm_vgic_probe (void );void kvm_arm_pmu_set_irq (CPUState *cs,int irq);
@@ -471,43 +318,6 @@ static inline const char *gicv3_class_name(void) } } -/** -* kvm_arm_handle_debug: -* @cs: CPUState -* @debug_exit: debug part of the KVM exit structure -* -* Returns: TRUE if the debug exception was handled. -*/ -bool kvm_arm_handle_debug (CPUState *cs,struct kvm_debug_exit_arch *debug_exit); - -/** -* kvm_arm_hw_debug_active: -* @cs: CPU State -* -* Return: TRUE if any hardware breakpoints in use. -*/ -bool kvm_arm_hw_debug_active (CPUState *cs); - -/** -* kvm_arm_copy_hw_debug_data: -* @ptr: kvm_guest_debug_arch structure -* -* Copy the architecture specific debug registers into the -* kvm_guest_debug ioctl structure. -*/ -struct kvm_guest_debug_arch ; -void kvm_arm_copy_hw_debug_data (struct kvm_guest_debug_arch *ptr); - -/** -* kvm_arm_verify_ext_dabt_pending: -* @cs: CPUState -* -* Verify the fault status code wrt the Ext DABT injection -* -* Returns: true if the fault status code is as expected, false otherwise -*/ -bool kvm_arm_verify_ext_dabt_pending (CPUState *cs); -/** * its_class_name: *
target/arm/kvm.c +1895 -153
2,160 lines not on this page · raw message
target/arm/kvm64.c deleted +0 -1632
608 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.34.1
Part of the diff is not shown here. View the raw message.
RFC PATCH 21/40 target/arm: Remove aarch64 check from aarch64_host_object_init
In reply to Richard HendersonSince kvm32 was removed, all kvm hosts support aarch64.
--- target/arm/cpu64.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
target/arm/cpu64.c +2 -4
@@ -1095,10 +1095,8 @@ static void aarch64_host_object_init(Object *obj)#if defined(CONFIG_KVM )ARMCPU *cpu =ARM_CPU (obj);kvm_arm_set_cpu_features_from_host (cpu); -if (arm_feature (&cpu->env,ARM_FEATURE_AARCH64 )) { -aarch64_add_sve_properties (obj); -aarch64_add_pauth_properties (obj); - } +aarch64_add_sve_properties (obj); +aarch64_add_pauth_properties (obj);#elif defined(CONFIG_HVF )ARMCPU *cpu =ARM_CPU (obj);hvf_arm_set_cpu_features_from_host (cpu);
Signature · 1 line
2.34.1
Re: [RFC PATCH 21/40] target/arm: Remove aarch64 check from aarch64_host_object_init
Quoted 1 line · Richard Henderson
Since kvm32 was removed
Maybe add here:
(see commit 82bf7ae84c: "target/arm: Remove KVM support for 32-bit Arm hosts")
Quoted 12 lines
, all kvm hosts support aarch64.
Signed-off-by Richard Henderson <[email protected]>--- target/arm/cpu64.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)target/arm/cpu64.c +0
-0
target/arm/cpu64.c static void aarch64_host_object_init(Object *obj) · line 1098
Quoted 4 lines
target/arm/cpu64.c +0
-1@@ -1095,10 +1095,8 @@ static void aarch64_host_object_init(Object *obj)#if defined(CONFIG_KVM )ARMCPU *cpu =ARM_CPU (obj);kvm_arm_set_cpu_features_from_host (cpu); -if (arm_feature (&cpu->env,ARM_FEATURE_AARCH64 )) {
Worth asserting this feature is enabled? I don't think so, so:
Quoted 8 lines
target/arm/cpu64.c +2
-3-aarch64_add_sve_properties (obj); - aarch64_add_pauth_properties(obj); - } +aarch64_add_sve_properties (obj); +aarch64_add_pauth_properties (obj);#elif defined(CONFIG_HVF )ARMCPU *cpu =ARM_CPU (obj);hvf_arm_set_cpu_features_from_host (cpu);
Re: [RFC PATCH 21/40] target/arm: Remove aarch64 check from aarch64_host_object_init
Quoted 26 lines · Philippe Mathieu-Daudé
Quoted 1 line · Richard Henderson
Since kvm32 was removed
Maybe add here:
(see commit
82bf7ae84c: "target/arm: Remove KVM support for 32-bit Arm hosts")Quoted 12 lines
, all kvm hosts support aarch64.
Signed-off-by Richard Henderson <[email protected]>---
target/arm/cpu64.c| 6 ++----1 file changed, 2 insertions(+), 4 deletions(-)target/arm/cpu64.c +0
-0target/arm/cpu64.c static void aarch64_host_object_init(Object *obj) · line 1098
Quoted 4 lines
target/arm/cpu64.c +0
-1@@ -1095,10 +1095,8 @@ static void aarch64_host_object_init(Object *obj) #if defined(CONFIG_KVM) ARMCPU *cpu = ARM_CPU(obj); kvm_arm_set_cpu_features_from_host(cpu); - if (arm_feature(&cpu->env, ARM_FEATURE_AARCH64)) {Worth asserting this feature is enabled? I don't think so, so:
Quoted 1 line
Reviewed-by Philippe Mathieu-Daudé <[email protected]>
Indeed not. In the next patch we hoist this feature setting out of kvm+hvf to common code just above here.
r~
Quoted 10 lines
Quoted 9 lines
target/arm/cpu64.c +2
-3- aarch64_add_sve_properties(obj); - aarch64_add_pauth_properties(obj); - } + aarch64_add_sve_properties(obj); + aarch64_add_pauth_properties(obj); #elif defined(CONFIG_HVF) ARMCPU *cpu = ARM_CPU(obj); hvf_arm_set_cpu_features_from_host(cpu);
RFC PATCH 22/40 target/arm: Hoist feature and dtb_compatible from KVM, HVF
In reply to Richard HendersonThese settings are generic and identical between the two host accelerators.
--- target/arm/cpu64.c | 23 ++++++++++++++++++++++- target/arm/hvf/hvf.c | 13 +------------ target/arm/kvm.c | 29 ++--------------------------- 3 files changed, 25 insertions(+), 40 deletions(-)
target/arm/cpu64.c +22 -1
@@ -1090,6 +1090,21 @@ static void aarch64_neoverse_n1_class_init(ARMCPUClass *cpu) cpu->isar.reset_pmcr_el0 =0x410c3000 ; } +static void aarch64_host_class_init (ARMCPUClass *acc) +{ +/* +* While we don't know all the host details, we can assume at +* least v8 with VFPv4+Neon; this in turn implies most of the +* other feature bits. +*/ + acc->dtb_compatible ="arm,arm-v8" ; +set_class_feature (acc,ARM_FEATURE_V8 ); +set_class_feature (acc,ARM_FEATURE_NEON ); +set_class_feature (acc,ARM_FEATURE_GENERIC_TIMER ); +set_class_feature (acc,ARM_FEATURE_AARCH64 ); +set_class_feature (acc,ARM_FEATURE_PMU ); +} +static void aarch64_host_object_init (Object *obj) {#if defined(CONFIG_KVM )
@@ -1122,8 +1137,12 @@ static bool aarch64_max_class_late_init(ARMCPUClass *cpu, Error **errp)return true; } -/* '-cpu max' for TCG: we currently do this as "A57 with extra things" */ +/* +* '-cpu max' for TCG: we currently do this as "A57 with extra things" +* Retain the more generic dtb_compatible setting from host_class_init. +*/ aarch64_a57_class_init (cpu); + cpu->dtb_compatible ="arm,arm-v8" ;/* * Reset MIDR so the guest doesn't mistake our 'max' CPU type for a real
@@ -1316,10 +1335,12 @@ static const ARMCPUInfo aarch64_cpus[] = { .class_init = aarch64_a64fx_class_init, .object_init = aarch64_a64fx_object_init }, { .name = "max", + .class_init = aarch64_host_class_init, .class_late_init = aarch64_max_class_late_init, .object_init = aarch64_max_object_init }, #if defined(CONFIG_KVM) || defined(CONFIG_HVF) { .name = "host", + .class_init = aarch64_host_class_init, .object_init = aarch64_host_object_init }, #endif };
target/arm/hvf/hvf.c +1 -12
@@ -97,10 +97,8 @@ static HVFVTimer vtimer;typedef struct ARMHostCPUFeatures {ARMISARegisters isar; -uint64_t features;uint64_t midr;uint32_t reset_sctlr; -const char *dtb_compatible; }ARMHostCPUFeatures ;static ARMHostCPUFeatures arm_host_cpu_features;
@@ -489,13 +487,6 @@ static bool hvf_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf)hv_vcpu_exit_t *exit;int i; - ahcf->dtb_compatible ="arm,arm-v8" ; - ahcf->features = (1ULL <<ARM_FEATURE_V8 ) | - (1ULL <<ARM_FEATURE_NEON ) | - (1ULL <<ARM_FEATURE_AARCH64 ) | - (1ULL <<ARM_FEATURE_PMU ) | - (1ULL <<ARM_FEATURE_GENERIC_TIMER ); -/* We set up a small vcpu to extract host registers */ if (hv_vcpu_create (&fd, &exit,NULL ) !=HV_SUCCESS ) {
@@ -532,7 +523,7 @@ static bool hvf_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf)void hvf_arm_set_cpu_features_from_host (ARMCPU *cpu) { -if (!arm_host_cpu_features.dtb_compatible) { +if (!arm_host_cpu_features.reset_sctlr) {if (!hvf_enabled () || !hvf_arm_get_host_cpu_features (&arm_host_cpu_features)) {/*
@@ -544,9 +535,7 @@ void hvf_arm_set_cpu_features_from_host(ARMCPU *cpu) } } - cpu->dtb_compatible = arm_host_cpu_features.dtb_compatible; cpu->isar = arm_host_cpu_features.isar; - cpu->env.features = arm_host_cpu_features.features; cpu->midr = arm_host_cpu_features.midr; cpu->reset_sctlr = arm_host_cpu_features.reset_sctlr; }
target/arm/kvm.c +2 -27
@@ -50,9 +50,7 @@ static bool cap_has_inject_ext_dabt;*/ typedef struct ARMHostCPUFeatures {ARMISARegisters isar; -uint64_t features;uint32_t target; -const char *dtb_compatible; }ARMHostCPUFeatures ;static ARMHostCPUFeatures arm_host_cpu_features;
@@ -1567,7 +1565,6 @@ static bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf)int fdarray[3 ];bool sve_supported;bool pmu_supported = false; -uint64_t features =0 ;int err;/* Old kernels may not know about the PREFERRED_TARGET ioctl: however
@@ -1615,7 +1612,6 @@ static bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf) } ahcf->target = init.target; - ahcf->dtb_compatible ="arm,arm-v8" ; err =read_sys_reg64 (fdarray[2 ], &ahcf->isar.id_aa64pfr0,ARM64_SYS_REG (3 ,0 ,0 ,4 ,0 ));
@@ -1760,31 +1756,12 @@ static bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf)kvm_arm_destroy_scratch_host_vcpu (fdarray); -if (err <0 ) { -return false; - } - -/* -* We can assume any KVM supporting CPU is at least a v8 -* with VFPv4+Neon; this in turn implies most of the other -* feature bits. -*/ - features |=1ULL <<ARM_FEATURE_V8 ; - features |=1ULL <<ARM_FEATURE_NEON ; - features |=1ULL <<ARM_FEATURE_AARCH64 ; - features |=1ULL <<ARM_FEATURE_PMU ; - features |=1ULL <<ARM_FEATURE_GENERIC_TIMER ; - - ahcf->features = features; - -return true; +return !err; }void kvm_arm_set_cpu_features_from_host (ARMCPU *cpu) { -CPUARMState *env = &cpu->env; - -if (!arm_host_cpu_features.dtb_compatible) { +if (!arm_host_cpu_features.isar.id_aa64pfr0) {if (!kvm_enabled () || !kvm_arm_get_host_cpu_features (&arm_host_cpu_features)) {/* We can't report this error yet, so flag that we need to
@@ -1797,9 +1774,7 @@ void kvm_arm_set_cpu_features_from_host(ARMCPU *cpu) } cpu->kvm_target = arm_host_cpu_features.target; - cpu->dtb_compatible = arm_host_cpu_features.dtb_compatible; cpu->isar = arm_host_cpu_features.isar; - env->features = arm_host_cpu_features.features; }/**
Signature · 1 line
2.34.1
RFC PATCH 23/40 target/arm: Probe KVM host into ARMCPUClass
In reply to Richard HendersonWe can now store these values into ARMCPUClass instead of into a temporary ARMHostCPUFeatures structure.
--- target/arm/kvm_arm.h | 14 ++--- target/arm/cpu64.c | 18 +++++-- target/arm/kvm.c | 119 +++++++++++++++++-------------------------- 3 files changed, 69 insertions(+), 82 deletions(-)
target/arm/kvm_arm.h +8 -6
@@ -140,13 +140,15 @@ void kvm_arm_destroy_scratch_host_vcpu(int *fdarray);uint32_t kvm_arm_sve_get_vls (CPUState *cs);/** -* kvm_arm_set_cpu_features_from_host: -* @cpu: ARMCPU to set the features for +* kvm_arm_get_host_cpu_features: +* @acc: ARMCPUClass to fill in * -* Set up the ARMCPU struct fields up to match the information probed -* from the host CPU. +* Probe the capabilities of the host kernel's preferred CPU and fill +* in the ARMCPUClass struct accordingly. +* +* Returns true on success and false otherwise. */ -void kvm_arm_set_cpu_features_from_host (ARMCPU *cpu); +bool kvm_arm_get_host_cpu_features (ARMCPUClass *acc,Error **errp);/** * kvm_arm_add_vcpu_properties:
@@ -245,7 +247,7 @@ static inline bool kvm_arm_steal_time_supported(void)/* * These functions should never actually be called without KVM support. */ -static inline void kvm_arm_set_cpu_features_from_host (ARMCPU *cpu) +static inline bool kvm_arm_get_host_cpu_features (ARMCPUClass *c,Error **e) {g_assert_not_reached (); }
target/arm/cpu64.c +15 -3
@@ -1105,11 +1105,21 @@ static void aarch64_host_class_init(ARMCPUClass *acc)set_class_feature (acc,ARM_FEATURE_PMU ); } +static bool aarch64_host_class_late_init (ARMCPUClass *acc,Error **errp) +{ +if (kvm_enabled ()) { +return kvm_arm_get_host_cpu_features (acc, errp); + } +if (hvf_enabled ()) { +return true; + } +error_setg (errp,"The 'host' CPU type can only be used with KVM or HVF" ); +return false; +} +static void aarch64_host_object_init (Object *obj) {#if defined(CONFIG_KVM ) -ARMCPU *cpu =ARM_CPU (obj); -kvm_arm_set_cpu_features_from_host (cpu);aarch64_add_sve_properties (obj);aarch64_add_pauth_properties (obj);#elif defined(CONFIG_HVF )
@@ -1134,7 +1144,8 @@ static bool aarch64_max_class_late_init(ARMCPUClass *cpu, Error **errp)uint32_t u;if (kvm_enabled () ||hvf_enabled ()) { -return true; +/* With KVM or HVF, '-cpu max' is identical to '-cpu host' */ +return aarch64_host_class_late_init (cpu, errp); }/*
@@ -1341,6 +1352,7 @@ static const ARMCPUInfo aarch64_cpus[] = {#if defined(CONFIG_KVM ) || defined(CONFIG_HVF ) { .name = "host", .class_init = aarch64_host_class_init, + .class_late_init = aarch64_host_class_late_init, .object_init = aarch64_host_object_init },#endif };
target/arm/kvm.c +46 -73
220 lines not on this page · raw message
Signature · 1 line
2.34.1
RFC PATCH 24/40 target/arm/hvf: Probe host into ARMCPUClass
In reply to Richard HendersonWe can now store these values into ARMCPUClass instead of into a temporary ARMHostCPUFeatures structure.
--- target/arm/cpu.h | 5 ---- target/arm/hvf_arm.h | 2 +- target/arm/cpu.c | 13 ---------- target/arm/cpu64.c | 4 +-- target/arm/hvf/hvf.c | 59 +++++++++++--------------------------------- 5 files changed, 17 insertions(+), 66 deletions(-)
target/arm/cpu.h +0 -5
@@ -935,11 +935,6 @@ struct ArchCPU {/* KVM steal time */ OnOffAuto kvm_steal_time; -/* True if we tried kvm_arm_host_cpu_features() during CPU instance_init -* and the probe failed (so we need to report the error in realize) -*/ -bool host_cpu_probe_failed; -/* Specify the number of cores in this CPU cluster. Used for the L2CTLR * register. */
target/arm/hvf_arm.h +1 -1
@@ -13,6 +13,6 @@#include "cpu.h" -void hvf_arm_set_cpu_features_from_host (ARMCPU *cpu); +bool hvf_arm_get_host_cpu_features (ARMCPUClass *acc,Error **errp);#endif
target/arm/cpu.c +0 -13
@@ -1584,19 +1584,6 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp)Error *local_err =NULL ;bool no_aa32 = false; -/* If we needed to query the host kernel for the CPU features -* then it's possible that might have failed in the initfn, but -* this is the first point where we can report it. -*/ -if (cpu->host_cpu_probe_failed) { -if (!kvm_enabled () && !hvf_enabled ()) { -error_setg (errp,"The 'host' CPU type can only be used with KVM or HVF" ); - }else { -error_setg (errp,"Failed to retrieve host CPU features" ); - } -return ; - } -#ifndef CONFIG_USER_ONLY /* The NVIC and M-profile CPU are two halves of a single piece of * hardware; trying to use one without the other is a command line
target/arm/cpu64.c +1 -3
@@ -1111,7 +1111,7 @@ static bool aarch64_host_class_late_init(ARMCPUClass *acc, Error **errp)return kvm_arm_get_host_cpu_features (acc, errp); }if (hvf_enabled ()) { -return true; +return hvf_arm_get_host_cpu_features (acc, errp); }error_setg (errp,"The 'host' CPU type can only be used with KVM or HVF" );return false;
@@ -1123,8 +1123,6 @@ static void aarch64_host_object_init(Object *obj)aarch64_add_sve_properties (obj);aarch64_add_pauth_properties (obj);#elif defined(CONFIG_HVF ) -ARMCPU *cpu =ARM_CPU (obj); -hvf_arm_set_cpu_features_from_host (cpu);aarch64_add_pauth_properties (obj);#else g_assert_not_reached ();
target/arm/hvf/hvf.c +15 -44
101 lines not on this page · raw message
Signature · 1 line
2.34.1
Re: [RFC PATCH 24/40] target/arm/hvf: Probe host into ARMCPUClass
Quoted 11 lines · Richard Henderson
We can now store these values into ARMCPUClass instead of into a temporary ARMHostCPUFeatures structure.
Signed-off-by Richard Henderson <[email protected]>--- target/arm/cpu.h | 5 ---- target/arm/hvf_arm.h | 2 +- target/arm/cpu.c | 13 ---------- target/arm/cpu64.c | 4 +-- target/arm/hvf/hvf.c | 59 +++++++++++--------------------------------- 5 files changed, 17 insertions(+), 66 deletions(-)
RFC PATCH 25/40 target/arm/hvf: Use offsetof in hvf_arm_get_host_cpu_features
In reply to Richard HendersonUse an offsetof vs ARMCPUClass, which means that the regs[] array may be static const, and we can include midr in the list.
--- target/arm/hvf/hvf.c | 38 ++++++++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 14 deletions(-)
target/arm/hvf/hvf.c +24 -14
@@ -459,19 +459,29 @@ static uint64_t hvf_get_reg(CPUState *cpu, int rt)bool hvf_arm_get_host_cpu_features (ARMCPUClass *acc,Error **errp) { -const struct isar_regs { -int reg; -uint64_t *val; +static const struct isar_regs { +int reg, offset; } regs[] = { - {HV_SYS_REG_ID_AA64PFR0_EL1 , &acc->isar.id_aa64pfr0 }, - {HV_SYS_REG_ID_AA64PFR1_EL1 , &acc->isar.id_aa64pfr1 }, - {HV_SYS_REG_ID_AA64DFR0_EL1 , &acc->isar.id_aa64dfr0 }, - {HV_SYS_REG_ID_AA64DFR1_EL1 , &acc->isar.id_aa64dfr1 }, - {HV_SYS_REG_ID_AA64ISAR0_EL1 , &acc->isar.id_aa64isar0 }, - {HV_SYS_REG_ID_AA64ISAR1_EL1 , &acc->isar.id_aa64isar1 }, - {HV_SYS_REG_ID_AA64MMFR0_EL1 , &acc->isar.id_aa64mmfr0 }, - {HV_SYS_REG_ID_AA64MMFR1_EL1 , &acc->isar.id_aa64mmfr1 }, - {HV_SYS_REG_ID_AA64MMFR2_EL1 , &acc->isar.id_aa64mmfr2 }, + {HV_SYS_REG_ID_AA64PFR0_EL1 , + offsetof(ARMCPUClass, isar.id_aa64pfr0) }, + {HV_SYS_REG_ID_AA64PFR1_EL1 , + offsetof(ARMCPUClass, isar.id_aa64pfr1) }, + {HV_SYS_REG_ID_AA64DFR0_EL1 , + offsetof(ARMCPUClass, isar.id_aa64dfr0) }, + {HV_SYS_REG_ID_AA64DFR1_EL1 , + offsetof(ARMCPUClass, isar.id_aa64dfr1) }, + {HV_SYS_REG_ID_AA64ISAR0_EL1 , + offsetof(ARMCPUClass, isar.id_aa64isar0) }, + {HV_SYS_REG_ID_AA64ISAR1_EL1 , + offsetof(ARMCPUClass, isar.id_aa64isar1) }, + {HV_SYS_REG_ID_AA64MMFR0_EL1 , + offsetof(ARMCPUClass, isar.id_aa64mmfr0) }, + {HV_SYS_REG_ID_AA64MMFR1_EL1 , + offsetof(ARMCPUClass, isar.id_aa64mmfr1) }, + {HV_SYS_REG_ID_AA64MMFR2_EL1 , + offsetof(ARMCPUClass, isar.id_aa64mmfr2) }, + {HV_SYS_REG_MIDR_EL1 , + offsetof(ARMCPUClass , midr) }, };hv_vcpu_t fd;hv_return_t r =HV_SUCCESS ;
@@ -485,9 +495,9 @@ bool hvf_arm_get_host_cpu_features(ARMCPUClass *acc, Error **errp) }for (i =0 ; i <ARRAY_SIZE (regs); i++) { - r |=hv_vcpu_get_sys_reg (fd, regs[i].reg, regs[i].val); +uint64_t *p = (void *)acc + regs[i].offset; + r |=hv_vcpu_get_sys_reg (fd, regs[i].reg, p); } - r |=hv_vcpu_get_sys_reg (fd,HV_SYS_REG_MIDR_EL1 , &acc->midr); r |=hv_vcpu_destroy (fd);/*
Signature · 1 line
2.34.1
RFC PATCH 26/40 target/arm: Rename 'cpu' to 'acc' in class init functions
In reply to Richard HendersonThese were previously left 'misnamed' to minimize the size of the patch. Rename them all in bulk with no other change.
--- target/arm/cpu64.c | 858 ++++++++++++++-------------- target/arm/cpu_tcg.c | 1260 +++++++++++++++++++++--------------------- 2 files changed, 1059 insertions(+), 1059 deletions(-)
target/arm/cpu64.c +429 -429
@@ -36,82 +36,82 @@#include "hw/qdev-properties.h" #include "internals.h" -static void aarch64_a35_class_init (ARMCPUClass *cpu) +static void aarch64_a35_class_init (ARMCPUClass *acc) { - cpu->dtb_compatible ="arm,cortex-a35" ; -set_class_feature (cpu,ARM_FEATURE_V8 ); -set_class_feature (cpu,ARM_FEATURE_NEON ); -set_class_feature (cpu,ARM_FEATURE_GENERIC_TIMER ); -set_class_feature (cpu,ARM_FEATURE_AARCH64 ); -set_class_feature (cpu,ARM_FEATURE_CBAR_RO ); -set_class_feature (cpu,ARM_FEATURE_EL2 ); -set_class_feature (cpu,ARM_FEATURE_EL3 ); -set_class_feature (cpu,ARM_FEATURE_PMU ); + acc->dtb_compatible ="arm,cortex-a35" ; +set_class_feature (acc,ARM_FEATURE_V8 ); +set_class_feature (acc,ARM_FEATURE_NEON ); +set_class_feature (acc,ARM_FEATURE_GENERIC_TIMER ); +set_class_feature (acc,ARM_FEATURE_AARCH64 ); +set_class_feature (acc,ARM_FEATURE_CBAR_RO ); +set_class_feature (acc,ARM_FEATURE_EL2 ); +set_class_feature (acc,ARM_FEATURE_EL3 ); +set_class_feature (acc,ARM_FEATURE_PMU );/* From B2.2 AArch64 identification registers. */ - cpu->midr =0x411fd040 ; - cpu->revidr =0 ; - cpu->ctr =0x84448004 ; - cpu->isar.id_pfr0 =0x00000131 ; - cpu->isar.id_pfr1 =0x00011011 ; - cpu->isar.id_dfr0 =0x03010066 ; - cpu->id_afr0 =0 ; - cpu->isar.id_mmfr0 =0x10201105 ; - cpu->isar.id_mmfr1 =0x40000000 ; - cpu->isar.id_mmfr2 =0x01260000 ; - cpu->isar.id_mmfr3 =0x02102211 ; - cpu->isar.id_isar0 =0x02101110 ; - cpu->isar.id_isar1 =0x13112111 ; - cpu->isar.id_isar2 =0x21232042 ; - cpu->isar.id_isar3 =0x01112131 ; - cpu->isar.id_isar4 =0x00011142 ; - cpu->isar.id_isar5 =0x00011121 ; - cpu->isar.id_aa64pfr0 =0x00002222 ; - cpu->isar.id_aa64pfr1 =0 ; - cpu->isar.id_aa64dfr0 =0x10305106 ; - cpu->isar.id_aa64dfr1 =0 ; - cpu->isar.id_aa64isar0 =0x00011120 ; - cpu->isar.id_aa64isar1 =0 ; - cpu->isar.id_aa64mmfr0 =0x00101122 ; - cpu->isar.id_aa64mmfr1 =0 ; - cpu->clidr =0x0a200023 ; - cpu->dcz_blocksize =4 ; + acc->midr =0x411fd040 ; + acc->revidr =0 ; + acc->ctr =0x84448004 ; + acc->isar.id_pfr0 =0x00000131 ; + acc->isar.id_pfr1 =0x00011011 ; + acc->isar.id_dfr0 =0x03010066 ; + acc->id_afr0 =0 ; + acc->isar.id_mmfr0 =0x10201105 ; + acc->isar.id_mmfr1 =0x40000000 ; + acc->isar.id_mmfr2 =0x01260000 ; + acc->isar.id_mmfr3 =0x02102211 ; + acc->isar.id_isar0 =0x02101110 ; + acc->isar.id_isar1 =0x13112111 ; + acc->isar.id_isar2 =0x21232042 ; + acc->isar.id_isar3 =0x01112131 ; + acc->isar.id_isar4 =0x00011142 ; + acc->isar.id_isar5 =0x00011121 ; + acc->isar.id_aa64pfr0 =0x00002222 ; + acc->isar.id_aa64pfr1 =0 ; + acc->isar.id_aa64dfr0 =0x10305106 ; + acc->isar.id_aa64dfr1 =0 ; + acc->isar.id_aa64isar0 =0x00011120 ; + acc->isar.id_aa64isar1 =0 ; + acc->isar.id_aa64mmfr0 =0x00101122 ; + acc->isar.id_aa64mmfr1 =0 ; + acc->clidr =0x0a200023 ; + acc->dcz_blocksize =4 ;/* From B2.4 AArch64 Virtual Memory control registers */ - cpu->reset_sctlr =0x00c50838 ; + acc->reset_sctlr =0x00c50838 ;/* From B2.10 AArch64 performance monitor registers */ - cpu->isar.reset_pmcr_el0 =0x410a3000 ; + acc->isar.reset_pmcr_el0 =0x410a3000 ;/* From B2.29 Cache ID registers */ - cpu->ccsidr[0 ] =0x700fe01a ;/* 32KB L1 dcache */ - cpu->ccsidr[1 ] =0x201fe00a ;/* 32KB L1 icache */ - cpu->ccsidr[2 ] =0x703fe03a ;/* 512KB L2 cache */ + acc->ccsidr[0 ] =0x700fe01a ;/* 32KB L1 dcache */ + acc->ccsidr[1 ] =0x201fe00a ;/* 32KB L1 icache */ + acc->ccsidr[2 ] =0x703fe03a ;/* 512KB L2 cache */ /* From B3.5 VGIC Type register */ - cpu->gic_num_lrs =4 ; - cpu->gic_vpribits =5 ; - cpu->gic_vprebits =5 ; - cpu->gic_pribits =5 ; + acc->gic_num_lrs =4 ; + acc->gic_vpribits =5 ; + acc->gic_vprebits =5 ; + acc->gic_pribits =5 ;/* From C6.4 Debug ID Register */ - cpu->isar.dbgdidr =0x3516d000 ; + acc->isar.dbgdidr =0x3516d000 ;/* From C6.5 Debug Device ID Register */ - cpu->isar.dbgdevid =0x00110f13 ; + acc->isar.dbgdevid =0x00110f13 ;/* From C6.6 Debug Device ID Register 1 */ - cpu->isar.dbgdevid1 =0x2 ; + acc->isar.dbgdevid1 =0x2 ;/* From Cortex-A35 SIMD and Floating-point Support r1p0 */ /* From 3.2 AArch32 register summary */ - cpu->reset_fpsid =0x41034043 ; + acc->reset_fpsid =0x41034043 ;/* From 2.2 AArch64 register summary */ - cpu->isar.mvfr0 =0x10110222 ; - cpu->isar.mvfr1 =0x12111111 ; - cpu->isar.mvfr2 =0x00000043 ; + acc->isar.mvfr0 =0x10110222 ; + acc->isar.mvfr1 =0x12111111 ; + acc->isar.mvfr2 =0x00000043 ;/* These values are the same with A53/A57/A72. */ -define_cortex_a72_a57_a53_cp_reginfo (cpu); +define_cortex_a72_a57_a53_cp_reginfo (acc); }void arm_cpu_sve_finalize (ARMCPU *cpu,Error **errp)
@@ -676,338 +676,338 @@ void arm_cpu_lpa2_finalize(ARMCPU *cpu, Error **errp) cpu->isar.id_aa64mmfr0 = t; } -static void aarch64_a57_class_init (ARMCPUClass *cpu) +static void aarch64_a57_class_init (ARMCPUClass *acc) { - cpu->dtb_compatible ="arm,cortex-a57" ; -set_class_feature (cpu,ARM_FEATURE_V8 ); -set_class_feature (cpu,ARM_FEATURE_NEON ); -set_class_feature (cpu,ARM_FEATURE_GENERIC_TIMER ); -set_class_feature (cpu,ARM_FEATURE_AARCH64 ); -set_class_feature (cpu,ARM_FEATURE_CBAR_RO ); -set_class_feature (cpu,ARM_FEATURE_EL2 ); -set_class_feature (cpu,ARM_FEATURE_EL3 ); -set_class_feature (cpu,ARM_FEATURE_PMU ); - cpu->kvm_target =QEMU_KVM_ARM_TARGET_CORTEX_A57 ; - cpu->midr =0x411fd070 ; - cpu->revidr =0x00000000 ; - cpu->reset_fpsid =0x41034070 ; - cpu->isar.mvfr0 =0x10110222 ; - cpu->isar.mvfr1 =0x12111111 ; - cpu->isar.mvfr2 =0x00000043 ; - cpu->ctr =0x8444c004 ; - cpu->reset_sctlr =0x00c50838 ; - cpu->isar.id_pfr0 =0x00000131 ; - cpu->isar.id_pfr1 =0x00011011 ; - cpu->isar.id_dfr0 =0x03010066 ; - cpu->id_afr0 =0x00000000 ; - cpu->isar.id_mmfr0 =0x10101105 ; - cpu->isar.id_mmfr1 =0x40000000 ; - cpu->isar.id_mmfr2 =0x01260000 ; - cpu->isar.id_mmfr3 =0x02102211 ; - cpu->isar.id_isar0 =0x02101110 ; - cpu->isar.id_isar1 =0x13112111 ; - cpu->isar.id_isar2 =0x21232042 ; - cpu->isar.id_isar3 =0x01112131 ; - cpu->isar.id_isar4 =0x00011142 ; - cpu->isar.id_isar5 =0x00011121 ; - cpu->isar.id_isar6 =0 ; - cpu->isar.id_aa64pfr0 =0x00002222 ; - cpu->isar.id_aa64dfr0 =0x10305106 ; - cpu->isar.id_aa64isar0 =0x00011120 ; - cpu->isar.id_aa64mmfr0 =0x00001124 ; - cpu->isar.dbgdidr =0x3516d000 ; - cpu->isar.dbgdevid =0x01110f13 ; - cpu->isar.dbgdevid1 =0x2 ; - cpu->isar.reset_pmcr_el0 =0x41013000 ; - cpu->clidr =0x0a200023 ; - cpu->ccsidr[0 ] =0x701fe00a ;/* 32KB L1 dcache */ - cpu->ccsidr[1 ] =0x201fe012 ;/* 48KB L1 icache */ - cpu->ccsidr[2 ] =0x70ffe07a ;/* 2048KB L2 cache */ - cpu->dcz_blocksize =4 ;/* 64 bytes */ - cpu->gic_num_lrs =4 ; - cpu->gic_vpribits =5 ; - cpu->gic_vprebits =5 ; - cpu->gic_pribits =5 ; -define_cortex_a72_a57_a53_cp_reginfo (cpu); + acc->dtb_compatible ="arm,cortex-a57" ; +set_class_feature (acc,ARM_FEATURE_V8 ); +set_class_feature (acc,ARM_FEATURE_NEON ); +set_class_feature (acc,ARM_FEATURE_GENERIC_TIMER ); +set_class_feature (acc,ARM_FEATURE_AARCH64 ); +set_class_feature (acc,ARM_FEATURE_CBAR_RO ); +set_class_feature (acc,ARM_FEATURE_EL2 ); +set_class_feature (acc,ARM_FEATURE_EL3 ); +set_class_feature (acc,ARM_FEATURE_PMU ); + acc->kvm_target =QEMU_KVM_ARM_TARGET_CORTEX_A57 ; + acc->midr =0x411fd070 ; + acc->revidr =0x00000000 ; + acc->reset_fpsid =0x41034070 ; + acc->isar.mvfr0 =0x10110222 ; + acc->isar.mvfr1 =0x12111111 ; + acc->isar.mvfr2 =0x00000043 ; + acc->ctr =0x8444c004 ; + acc->reset_sctlr =0x00c50838 ; + acc->isar.id_pfr0 =0x00000131 ; + acc->isar.id_pfr1 =0x00011011 ; + acc->isar.id_dfr0 =0x03010066 ; + acc->id_afr0 =0x00000000 ; + acc->isar.id_mmfr0 =0x10101105 ; + acc->isar.id_mmfr1 =0x40000000 ; + acc->isar.id_mmfr2 =0x01260000 ; + acc->isar.id_mmfr3 =0x02102211 ; + acc->isar.id_isar0 =0x02101110 ; + acc->isar.id_isar1 =0x13112111 ; + acc->isar.id_isar2 =0x21232042 ; + acc->isar.id_isar3 =0x01112131 ; + acc->isar.id_isar4 =0x00011142 ; + acc->isar.id_isar5 =0x00011121 ; + acc->isar.id_isar6 =0 ; + acc->isar.id_aa64pfr0 =0x00002222 ; + acc->isar.id_aa64dfr0 =0x10305106 ; + acc->isar.id_aa64isar0 =0x00011120 ; + acc->isar.id_aa64mmfr0 =0x00001124 ; + acc->isar.dbgdidr =0x3516d000 ; + acc->isar.dbgdevid =0x01110f13 ; + acc->isar.dbgdevid1 =0x2 ; + acc->isar.reset_pmcr_el0 =0x41013000 ; + acc->clidr =0x0a200023 ; + acc->ccsidr[0 ] =0x701fe00a ;/* 32KB L1 dcache */ + acc->ccsidr[1 ] =0x201fe012 ;/* 48KB L1 icache */ + acc->ccsidr[2 ] =0x70ffe07a ;/* 2048KB L2 cache */ + acc->dcz_blocksize =4 ;/* 64 bytes */ + acc->gic_num_lrs =4 ; + acc->gic_vpribits =5 ; + acc->gic_vprebits =5 ; + acc->gic_pribits =5 ; +define_cortex_a72_a57_a53_cp_reginfo (acc); } -static void aarch64_a53_class_init (ARMCPUClass *cpu) +static void aarch64_a53_class_init (ARMCPUClass *acc) { - cpu->dtb_compatible ="arm,cortex-a53" ; -set_class_feature (cpu,ARM_FEATURE_V8 ); -set_class_feature (cpu,ARM_FEATURE_NEON ); -set_class_feature (cpu,ARM_FEATURE_GENERIC_TIMER ); -set_class_feature (cpu,ARM_FEATURE_AARCH64 ); -set_class_feature (cpu,ARM_FEATURE_CBAR_RO ); -set_class_feature (cpu,ARM_FEATURE_EL2 ); -set_class_feature (cpu,ARM_FEATURE_EL3 ); -set_class_feature (cpu,ARM_FEATURE_PMU ); - cpu->kvm_target =QEMU_KVM_ARM_TARGET_CORTEX_A53 ; - cpu->midr =0x410fd034 ; - cpu->revidr =0x00000000 ; - cpu->reset_fpsid =0x41034070 ; - cpu->isar.mvfr0 =0x10110222 ; - cpu->isar.mvfr1 =0x12111111 ; - cpu->isar.mvfr2 =0x00000043 ; - cpu->ctr =0x84448004 ;/* L1Ip = VIPT */ - cpu->reset_sctlr =0x00c50838 ; - cpu->isar.id_pfr0 =0x00000131 ; - cpu->isar.id_pfr1 =0x00011011 ; - cpu->isar.id_dfr0 =0x03010066 ; - cpu->id_afr0 =0x00000000 ; - cpu->isar.id_mmfr0 =0x10101105 ; - cpu->isar.id_mmfr1 =0x40000000 ; - cpu->isar.id_mmfr2 =0x01260000 ; - cpu->isar.id_mmfr3 =0x02102211 ; - cpu->isar.id_isar0 =0x02101110 ; - cpu->isar.id_isar1 =0x13112111 ; - cpu->isar.id_isar2 =0x21232042 ; - cpu->isar.id_isar3 =0x01112131 ; - cpu->isar.id_isar4 =0x00011142 ; - cpu->isar.id_isar5 =0x00011121 ; - cpu->isar.id_isar6 =0 ; - cpu->isar.id_aa64pfr0 =0x00002222 ; - cpu->isar.id_aa64dfr0 =0x10305106 ; - cpu->isar.id_aa64isar0 =0x00011120 ; - cpu->isar.id_aa64mmfr0 =0x00001122 ;/* 40 bit physical addr */ - cpu->isar.dbgdidr =0x3516d000 ; - cpu->isar.dbgdevid =0x00110f13 ; - cpu->isar.dbgdevid1 =0x1 ; - cpu->isar.reset_pmcr_el0 =0x41033000 ; - cpu->clidr =0x0a200023 ; - cpu->ccsidr[0 ] =0x700fe01a ;/* 32KB L1 dcache */ - cpu->ccsidr[1 ] =0x201fe00a ;/* 32KB L1 icache */ - cpu->ccsidr[2 ] =0x707fe07a ;/* 1024KB L2 cache */ - cpu->dcz_blocksize =4 ;/* 64 bytes */ - cpu->gic_num_lrs =4 ; - cpu->gic_vpribits =5 ; - cpu->gic_vprebits =5 ; - cpu->gic_pribits =5 ; -define_cortex_a72_a57_a53_cp_reginfo (cpu); + acc->dtb_compatible ="arm,cortex-a53" ; +set_class_feature (acc,ARM_FEATURE_V8 ); +set_class_feature (acc,ARM_FEATURE_NEON ); +set_class_feature (acc,ARM_FEATURE_GENERIC_TIMER ); +set_class_feature (acc,ARM_FEATURE_AARCH64 ); +set_class_feature (acc,ARM_FEATURE_CBAR_RO ); +set_class_feature (acc,ARM_FEATURE_EL2 ); +set_class_feature (acc,ARM_FEATURE_EL3 ); +set_class_feature (acc,ARM_FEATURE_PMU ); + acc->kvm_target =QEMU_KVM_ARM_TARGET_CORTEX_A53 ; + acc->midr =0x410fd034 ; + acc->revidr =0x00000000 ; + acc->reset_fpsid =0x41034070 ; + acc->isar.mvfr0 =0x10110222 ; + acc->isar.mvfr1 =0x12111111 ; + acc->isar.mvfr2 =0x00000043 ; + acc->ctr =0x84448004 ;/* L1Ip = VIPT */ + acc->reset_sctlr =0x00c50838 ; + acc->isar.id_pfr0 =0x00000131 ; + acc->isar.id_pfr1 =0x00011011 ; + acc->isar.id_dfr0 =0x03010066 ; + acc->id_afr0 =0x00000000 ; + acc->isar.id_mmfr0 =0x10101105 ; + acc->isar.id_mmfr1 =0x40000000 ; + acc->isar.id_mmfr2 =0x01260000 ; + acc->isar.id_mmfr3 =0x02102211 ; + acc->isar.id_isar0 =0x02101110 ; + acc->isar.id_isar1 =0x13112111 ; + acc->isar.id_isar2 =0x21232042 ; + acc->isar.id_isar3 =0x01112131 ; + acc->isar.id_isar4 =0x00011142 ; + acc->isar.id_isar5 =0x00011121 ; + acc->isar.id_isar6 =0 ; + acc->isar.id_aa64pfr0 =0x00002222 ; + acc->isar.id_aa64dfr0 =0x10305106 ; + acc->isar.id_aa64isar0 =0x00011120 ; + acc->isar.id_aa64mmfr0 =0x00001122 ;/* 40 bit physical addr */ + acc->isar.dbgdidr =0x3516d000 ; + acc->isar.dbgdevid =0x00110f13 ; + acc->isar.dbgdevid1 =0x1 ; + acc->isar.reset_pmcr_el0 =0x41033000 ; + acc->clidr =0x0a200023 ; + acc->ccsidr[0 ] =0x700fe01a ;/* 32KB L1 dcache */ + acc->ccsidr[1 ] =0x201fe00a ;/* 32KB L1 icache */ + acc->ccsidr[2 ] =0x707fe07a ;/* 1024KB L2 cache */ + acc->dcz_blocksize =4 ;/* 64 bytes */ + acc->gic_num_lrs =4 ; + acc->gic_vpribits =5 ; + acc->gic_vprebits =5 ; + acc->gic_pribits =5 ; +define_cortex_a72_a57_a53_cp_reginfo (acc); } -static void aarch64_a55_class_init (ARMCPUClass *cpu) +static void aarch64_a55_class_init (ARMCPUClass *acc) { - cpu->dtb_compatible ="arm,cortex-a55" ; -set_class_feature (cpu,ARM_FEATURE_V8 ); -set_class_feature (cpu,ARM_FEATURE_NEON ); -set_class_feature (cpu,ARM_FEATURE_GENERIC_TIMER ); -set_class_feature (cpu,ARM_FEATURE_AARCH64 ); -set_class_feature (cpu,ARM_FEATURE_CBAR_RO ); -set_class_feature (cpu,ARM_FEATURE_EL2 ); -set_class_feature (cpu,ARM_FEATURE_EL3 ); -set_class_feature (cpu,ARM_FEATURE_PMU ); + acc->dtb_compatible ="arm,cortex-a55" ; +set_class_feature (acc,ARM_FEATURE_V8 ); +set_class_feature (acc,ARM_FEATURE_NEON ); +set_class_feature (acc,ARM_FEATURE_GENERIC_TIMER ); +set_class_feature (acc,ARM_FEATURE_AARCH64 ); +set_class_feature (acc,ARM_FEATURE_CBAR_RO ); +set_class_feature (acc,ARM_FEATURE_EL2 ); +set_class_feature (acc,ARM_FEATURE_EL3 ); +set_class_feature (acc,ARM_FEATURE_PMU );/* Ordered by B2.4 AArch64 registers by functional group */ - cpu->clidr =0x82000023 ; - cpu->ctr =0x84448004 ;/* L1Ip = VIPT */ - cpu->dcz_blocksize =4 ;/* 64 bytes */ - cpu->isar.id_aa64dfr0 =0x0000000010305408ull ; - cpu->isar.id_aa64isar0 =0x0000100010211120ull ; - cpu->isar.id_aa64isar1 =0x0000000000100001ull ; - cpu->isar.id_aa64mmfr0 =0x0000000000101122ull ; - cpu->isar.id_aa64mmfr1 =0x0000000010212122ull ; - cpu->isar.id_aa64mmfr2 =0x0000000000001011ull ; - cpu->isar.id_aa64pfr0 =0x0000000010112222ull ; - cpu->isar.id_aa64pfr1 =0x0000000000000010ull ; - cpu->id_afr0 =0x00000000 ; - cpu->isar.id_dfr0 =0x04010088 ; - cpu->isar.id_isar0 =0x02101110 ; - cpu->isar.id_isar1 =0x13112111 ; - cpu->isar.id_isar2 =0x21232042 ; - cpu->isar.id_isar3 =0x01112131 ; - cpu->isar.id_isar4 =0x00011142 ; - cpu->isar.id_isar5 =0x01011121 ; - cpu->isar.id_isar6 =0x00000010 ; - cpu->isar.id_mmfr0 =0x10201105 ; - cpu->isar.id_mmfr1 =0x40000000 ; - cpu->isar.id_mmfr2 =0x01260000 ; - cpu->isar.id_mmfr3 =0x02122211 ; - cpu->isar.id_mmfr4 =0x00021110 ; - cpu->isar.id_pfr0 =0x10010131 ; - cpu->isar.id_pfr1 =0x00011011 ; - cpu->isar.id_pfr2 =0x00000011 ; - cpu->midr =0x412FD050 ;/* r2p0 */ - cpu->revidr =0 ; + acc->clidr =0x82000023 ; + acc->ctr =0x84448004 ;/* L1Ip = VIPT */ + acc->dcz_blocksize =4 ;/* 64 bytes */ + acc->isar.id_aa64dfr0 =0x0000000010305408ull ; + acc->isar.id_aa64isar0 =0x0000100010211120ull ; + acc->isar.id_aa64isar1 =0x0000000000100001ull ; + acc->isar.id_aa64mmfr0 =0x0000000000101122ull ; + acc->isar.id_aa64mmfr1 =0x0000000010212122ull ; + acc->isar.id_aa64mmfr2 =0x0000000000001011ull ; + acc->isar.id_aa64pfr0 =0x0000000010112222ull ; + acc->isar.id_aa64pfr1 =0x0000000000000010ull ; + acc->id_afr0 =0x00000000 ; + acc->isar.id_dfr0 =0x04010088 ; + acc->isar.id_isar0 =0x02101110 ; + acc->isar.id_isar1 =0x13112111 ; + acc->isar.id_isar2 =0x21232042 ; + acc->isar.id_isar3 =0x01112131 ; + acc->isar.id_isar4 =0x00011142 ; + acc->isar.id_isar5 =0x01011121 ; + acc->isar.id_isar6 =0x00000010 ; + acc->isar.id_mmfr0 =0x10201105 ; + acc->isar.id_mmfr1 =0x40000000 ; + acc->isar.id_mmfr2 =0x01260000 ; + acc->isar.id_mmfr3 =0x02122211 ; + acc->isar.id_mmfr4 =0x00021110 ; + acc->isar.id_pfr0 =0x10010131 ; + acc->isar.id_pfr1 =0x00011011 ; + acc->isar.id_pfr2 =0x00000011 ; + acc->midr =0x412FD050 ;/* r2p0 */ + acc->revidr =0 ;/* From B2.23 CCSIDR_EL1 */ - cpu->ccsidr[0 ] =0x700fe01a ;/* 32KB L1 dcache */ - cpu->ccsidr[1 ] =0x200fe01a ;/* 32KB L1 icache */ - cpu->ccsidr[2 ] =0x703fe07a ;/* 512KB L2 cache */ + acc->ccsidr[0 ] =0x700fe01a ;/* 32KB L1 dcache */ + acc->ccsidr[1 ] =0x200fe01a ;/* 32KB L1 icache */ + acc->ccsidr[2 ] =0x703fe07a ;/* 512KB L2 cache */ /* From B2.96 SCTLR_EL3 */ - cpu->reset_sctlr =0x30c50838 ; + acc->reset_sctlr =0x30c50838 ;/* From B4.45 ICH_VTR_EL2 */ - cpu->gic_num_lrs =4 ; - cpu->gic_vpribits =5 ; - cpu->gic_vprebits =5 ; - cpu->gic_pribits =5 ; + acc->gic_num_lrs =4 ; + acc->gic_vpribits =5 ; + acc->gic_vprebits =5 ; + acc->gic_pribits =5 ; - cpu->isar.mvfr0 =0x10110222 ; - cpu->isar.mvfr1 =0x13211111 ; - cpu->isar.mvfr2 =0x00000043 ; + acc->isar.mvfr0 =0x10110222 ; + acc->isar.mvfr1 =0x13211111 ; + acc->isar.mvfr2 =0x00000043 ;/* From D5.4 AArch64 PMU register summary */ - cpu->isar.reset_pmcr_el0 =0x410b3000 ; + acc->isar.reset_pmcr_el0 =0x410b3000 ; } -static void aarch64_a72_class_init (ARMCPUClass *cpu) +static void aarch64_a72_class_init (ARMCPUClass *acc) { - cpu->dtb_compatible ="arm,cortex-a72" ; -set_class_feature (cpu,ARM_FEATURE_V8 ); -set_class_feature (cpu,ARM_FEATURE_NEON ); -set_class_feature (cpu,ARM_FEATURE_GENERIC_TIMER ); -set_class_feature (cpu,ARM_FEATURE_AARCH64 ); -set_class_feature (cpu,ARM_FEATURE_CBAR_RO ); -set_class_feature (cpu,ARM_FEATURE_EL2 ); -set_class_feature (cpu,ARM_FEATURE_EL3 ); -set_class_feature (cpu,ARM_FEATURE_PMU ); - cpu->midr =0x410fd083 ; - cpu->revidr =0x00000000 ; - cpu->reset_fpsid =0x41034080 ; - cpu->isar.mvfr0 =0x10110222 ; - cpu->isar.mvfr1 =0x12111111 ; - cpu->isar.mvfr2 =0x00000043 ; - cpu->ctr =0x8444c004 ; - cpu->reset_sctlr =0x00c50838 ; - cpu->isar.id_pfr0 =0x00000131 ; - cpu->isar.id_pfr1 =0x00011011 ; - cpu->isar.id_dfr0 =0x03010066 ; - cpu->id_afr0 =0x00000000 ; - cpu->isar.id_mmfr0 =0x10201105 ; - cpu->isar.id_mmfr1 =0x40000000 ; - cpu->isar.id_mmfr2 =0x01260000 ; - cpu->isar.id_mmfr3 =0x02102211 ; - cpu->isar.id_isar0 =0x02101110 ; - cpu->isar.id_isar1 =0x13112111 ; - cpu->isar.id_isar2 =0x21232042 ; - cpu->isar.id_isar3 =0x01112131 ; - cpu->isar.id_isar4 =0x00011142 ; - cpu->isar.id_isar5 =0x00011121 ; - cpu->isar.id_aa64pfr0 =0x00002222 ; - cpu->isar.id_aa64dfr0 =0x10305106 ; - cpu->isar.id_aa64isar0 =0x00011120 ; - cpu->isar.id_aa64mmfr0 =0x00001124 ; - cpu->isar.dbgdidr =0x3516d000 ; - cpu->isar.dbgdevid =0x01110f13 ; - cpu->isar.dbgdevid1 =0x2 ; - cpu->isar.reset_pmcr_el0 =0x41023000 ; - cpu->clidr =0x0a200023 ; - cpu->ccsidr[0 ] =0x701fe00a ;/* 32KB L1 dcache */ - cpu->ccsidr[1 ] =0x201fe012 ;/* 48KB L1 icache */ - cpu->ccsidr[2 ] =0x707fe07a ;/* 1MB L2 cache */ - cpu->dcz_blocksize =4 ;/* 64 bytes */ - cpu->gic_num_lrs =4 ; - cpu->gic_vpribits =5 ; - cpu->gic_vprebits =5 ; - cpu->gic_pribits =5 ; -define_cortex_a72_a57_a53_cp_reginfo (cpu); + acc->dtb_compatible ="arm,cortex-a72" ; +set_class_feature (acc,ARM_FEATURE_V8 ); +set_class_feature (acc,ARM_FEATURE_NEON ); +set_class_feature (acc,ARM_FEATURE_GENERIC_TIMER ); +set_class_feature (acc,ARM_FEATURE_AARCH64 ); +set_class_feature (acc,ARM_FEATURE_CBAR_RO ); +set_class_feature (acc,ARM_FEATURE_EL2 ); +set_class_feature (acc,ARM_FEATURE_EL3 ); +set_class_feature (acc,ARM_FEATURE_PMU ); + acc->midr =0x410fd083 ; + acc->revidr =0x00000000 ; + acc->reset_fpsid =0x41034080 ; + acc->isar.mvfr0 =0x10110222 ; + acc->isar.mvfr1 =0x12111111 ; + acc->isar.mvfr2 =0x00000043 ; + acc->ctr =0x8444c004 ; + acc->reset_sctlr =0x00c50838 ; + acc->isar.id_pfr0 =0x00000131 ; + acc->isar.id_pfr1 =0x00011011 ; + acc->isar.id_dfr0 =0x03010066 ; + acc->id_afr0 =0x00000000 ; + acc->isar.id_mmfr0 =0x10201105 ; + acc->isar.id_mmfr1 =0x40000000 ; + acc->isar.id_mmfr2 =0x01260000 ; + acc->isar.id_mmfr3 =0x02102211 ; + acc->isar.id_isar0 =0x02101110 ; + acc->isar.id_isar1 =0x13112111 ; + acc->isar.id_isar2 =0x21232042 ; + acc->isar.id_isar3 =0x01112131 ; + acc->isar.id_isar4 =0x00011142 ; + acc->isar.id_isar5 =0x00011121 ; + acc->isar.id_aa64pfr0 =0x00002222 ; + acc->isar.id_aa64dfr0 =0x10305106 ; + acc->isar.id_aa64isar0 =0x00011120 ; + acc->isar.id_aa64mmfr0 =0x00001124 ; + acc->isar.dbgdidr =0x3516d000 ; + acc->isar.dbgdevid =0x01110f13 ; + acc->isar.dbgdevid1 =0x2 ; + acc->isar.reset_pmcr_el0 =0x41023000 ; + acc->clidr =0x0a200023 ; + acc->ccsidr[0 ] =0x701fe00a ;/* 32KB L1 dcache */ + acc->ccsidr[1 ] =0x201fe012 ;/* 48KB L1 icache */ + acc->ccsidr[2 ] =0x707fe07a ;/* 1MB L2 cache */ + acc->dcz_blocksize =4 ;/* 64 bytes */ + acc->gic_num_lrs =4 ; + acc->gic_vpribits =5 ; + acc->gic_vprebits =5 ; + acc->gic_pribits =5 ; +define_cortex_a72_a57_a53_cp_reginfo (acc); } -static void aarch64_a76_class_init (ARMCPUClass *cpu) +static void aarch64_a76_class_init (ARMCPUClass *acc) { - cpu->dtb_compatible ="arm,cortex-a76" ; -set_class_feature (cpu,ARM_FEATURE_V8 ); -set_class_feature (cpu,ARM_FEATURE_NEON ); -set_class_feature (cpu,ARM_FEATURE_GENERIC_TIMER ); -set_class_feature (cpu,ARM_FEATURE_AARCH64 ); -set_class_feature (cpu,ARM_FEATURE_CBAR_RO ); -set_class_feature (cpu,ARM_FEATURE_EL2 ); -set_class_feature (cpu,ARM_FEATURE_EL3 ); -set_class_feature (cpu,ARM_FEATURE_PMU ); + acc->dtb_compatible ="arm,cortex-a76" ; +set_class_feature (acc,ARM_FEATURE_V8 ); +set_class_feature (acc,ARM_FEATURE_NEON ); +set_class_feature (acc,ARM_FEATURE_GENERIC_TIMER ); +set_class_feature (acc,ARM_FEATURE_AARCH64 ); +set_class_feature (acc,ARM_FEATURE_CBAR_RO ); +set_class_feature (acc,ARM_FEATURE_EL2 ); +set_class_feature (acc,ARM_FEATURE_EL3 ); +set_class_feature (acc,ARM_FEATURE_PMU );/* Ordered by B2.4 AArch64 registers by functional group */ - cpu->clidr =0x82000023 ; - cpu->ctr =0x8444C004 ; - cpu->dcz_blocksize =4 ; - cpu->isar.id_aa64dfr0 =0x0000000010305408ull ; - cpu->isar.id_aa64isar0 =0x0000100010211120ull ; - cpu->isar.id_aa64isar1 =0x0000000000100001ull ; - cpu->isar.id_aa64mmfr0 =0x0000000000101122ull ; - cpu->isar.id_aa64mmfr1 =0x0000000010212122ull ; - cpu->isar.id_aa64mmfr2 =0x0000000000001011ull ; - cpu->isar.id_aa64pfr0 =0x1100000010111112ull ;/* GIC filled in later */ - cpu->isar.id_aa64pfr1 =0x0000000000000010ull ; - cpu->id_afr0 =0x00000000 ; - cpu->isar.id_dfr0 =0x04010088 ; - cpu->isar.id_isar0 =0x02101110 ; - cpu->isar.id_isar1 =0x13112111 ; - cpu->isar.id_isar2 =0x21232042 ; - cpu->isar.id_isar3 =0x01112131 ; - cpu->isar.id_isar4 =0x00010142 ; - cpu->isar.id_isar5 =0x01011121 ; - cpu->isar.id_isar6 =0x00000010 ; - cpu->isar.id_mmfr0 =0x10201105 ; - cpu->isar.id_mmfr1 =0x40000000 ; - cpu->isar.id_mmfr2 =0x01260000 ; - cpu->isar.id_mmfr3 =0x02122211 ; - cpu->isar.id_mmfr4 =0x00021110 ; - cpu->isar.id_pfr0 =0x10010131 ; - cpu->isar.id_pfr1 =0x00010000 ;/* GIC filled in later */ - cpu->isar.id_pfr2 =0x00000011 ; - cpu->midr =0x414fd0b1 ;/* r4p1 */ - cpu->revidr =0 ; + acc->clidr =0x82000023 ; + acc->ctr =0x8444C004 ; + acc->dcz_blocksize =4 ; + acc->isar.id_aa64dfr0 =0x0000000010305408ull ; + acc->isar.id_aa64isar0 =0x0000100010211120ull ; + acc->isar.id_aa64isar1 =0x0000000000100001ull ; + acc->isar.id_aa64mmfr0 =0x0000000000101122ull ; + acc->isar.id_aa64mmfr1 =0x0000000010212122ull ; + acc->isar.id_aa64mmfr2 =0x0000000000001011ull ; + acc->isar.id_aa64pfr0 =0x1100000010111112ull ;/* GIC filled in later */ + acc->isar.id_aa64pfr1 =0x0000000000000010ull ; + acc->id_afr0 =0x00000000 ; + acc->isar.id_dfr0 =0x04010088 ; + acc->isar.id_isar0 =0x02101110 ; + acc->isar.id_isar1 =0x13112111 ; + acc->isar.id_isar2 =0x21232042 ; + acc->isar.id_isar3 =0x01112131 ; + acc->isar.id_isar4 =0x00010142 ; + acc->isar.id_isar5 =0x01011121 ; + acc->isar.id_isar6 =0x00000010 ; + acc->isar.id_mmfr0 =0x10201105 ; + acc->isar.id_mmfr1 =0x40000000 ; + acc->isar.id_mmfr2 =0x01260000 ; + acc->isar.id_mmfr3 =0x02122211 ; + acc->isar.id_mmfr4 =0x00021110 ; + acc->isar.id_pfr0 =0x10010131 ; + acc->isar.id_pfr1 =0x00010000 ;/* GIC filled in later */ + acc->isar.id_pfr2 =0x00000011 ; + acc->midr =0x414fd0b1 ;/* r4p1 */ + acc->revidr =0 ;/* From B2.18 CCSIDR_EL1 */ - cpu->ccsidr[0 ] =0x701fe01a ;/* 64KB L1 dcache */ - cpu->ccsidr[1 ] =0x201fe01a ;/* 64KB L1 icache */ - cpu->ccsidr[2 ] =0x707fe03a ;/* 512KB L2 cache */ + acc->ccsidr[0 ] =0x701fe01a ;/* 64KB L1 dcache */ + acc->ccsidr[1 ] =0x201fe01a ;/* 64KB L1 icache */ + acc->ccsidr[2 ] =0x707fe03a ;/* 512KB L2 cache */ /* From B2.93 SCTLR_EL3 */ - cpu->reset_sctlr =0x30c50838 ; + acc->reset_sctlr =0x30c50838 ;/* From B4.23 ICH_VTR_EL2 */ - cpu->gic_num_lrs =4 ; - cpu->gic_vpribits =5 ; - cpu->gic_vprebits =5 ; - cpu->gic_pribits =5 ; + acc->gic_num_lrs =4 ; + acc->gic_vpribits =5 ; + acc->gic_vprebits =5 ; + acc->gic_pribits =5 ;/* From B5.1 AdvSIMD AArch64 register summary */ - cpu->isar.mvfr0 =0x10110222 ; - cpu->isar.mvfr1 =0x13211111 ; - cpu->isar.mvfr2 =0x00000043 ; + acc->isar.mvfr0 =0x10110222 ; + acc->isar.mvfr1 =0x13211111 ; + acc->isar.mvfr2 =0x00000043 ;/* From D5.1 AArch64 PMU register summary */ - cpu->isar.reset_pmcr_el0 =0x410b3000 ; + acc->isar.reset_pmcr_el0 =0x410b3000 ; } -static void aarch64_a64fx_class_init (ARMCPUClass *cpu) +static void aarch64_a64fx_class_init (ARMCPUClass *acc) { - cpu->dtb_compatible ="arm,a64fx" ; -set_class_feature (cpu,ARM_FEATURE_V8 ); -set_class_feature (cpu,ARM_FEATURE_NEON ); -set_class_feature (cpu,ARM_FEATURE_GENERIC_TIMER ); -set_class_feature (cpu,ARM_FEATURE_AARCH64 ); -set_class_feature (cpu,ARM_FEATURE_EL2 ); -set_class_feature (cpu,ARM_FEATURE_EL3 ); -set_class_feature (cpu,ARM_FEATURE_PMU ); - cpu->midr =0x461f0010 ; - cpu->revidr =0x00000000 ; - cpu->ctr =0x86668006 ; - cpu->reset_sctlr =0x30000180 ; - cpu->isar.id_aa64pfr0 =0x0000000101111111 ;/* No RAS Extensions */ - cpu->isar.id_aa64pfr1 =0x0000000000000000 ; - cpu->isar.id_aa64dfr0 =0x0000000010305408 ; - cpu->isar.id_aa64dfr1 =0x0000000000000000 ; - cpu->id_aa64afr0 =0x0000000000000000 ; - cpu->id_aa64afr1 =0x0000000000000000 ; - cpu->isar.id_aa64mmfr0 =0x0000000000001122 ; - cpu->isar.id_aa64mmfr1 =0x0000000011212100 ; - cpu->isar.id_aa64mmfr2 =0x0000000000001011 ; - cpu->isar.id_aa64isar0 =0x0000000010211120 ; - cpu->isar.id_aa64isar1 =0x0000000000010001 ; - cpu->isar.id_aa64zfr0 =0x0000000000000000 ; - cpu->clidr =0x0000000080000023 ; - cpu->ccsidr[0 ] =0x7007e01c ;/* 64KB L1 dcache */ - cpu->ccsidr[1 ] =0x2007e01c ;/* 64KB L1 icache */ - cpu->ccsidr[2 ] =0x70ffe07c ;/* 8MB L2 cache */ - cpu->dcz_blocksize =6 ;/* 256 bytes */ - cpu->gic_num_lrs =4 ; - cpu->gic_vpribits =5 ; - cpu->gic_vprebits =5 ; - cpu->gic_pribits =5 ; - cpu->isar.reset_pmcr_el0 =0x46014040 ; + acc->dtb_compatible ="arm,a64fx" ; +set_class_feature (acc,ARM_FEATURE_V8 ); +set_class_feature (acc,ARM_FEATURE_NEON ); +set_class_feature (acc,ARM_FEATURE_GENERIC_TIMER ); +set_class_feature (acc,ARM_FEATURE_AARCH64 ); +set_class_feature (acc,ARM_FEATURE_EL2 ); +set_class_feature (acc,ARM_FEATURE_EL3 ); +set_class_feature (acc,ARM_FEATURE_PMU ); + acc->midr =0x461f0010 ; + acc->revidr =0x00000000 ; + acc->ctr =0x86668006 ; + acc->reset_sctlr =0x30000180 ; + acc->isar.id_aa64pfr0 =0x0000000101111111 ;/* No RAS Extensions */ + acc->isar.id_aa64pfr1 =0x0000000000000000 ; + acc->isar.id_aa64dfr0 =0x0000000010305408 ; + acc->isar.id_aa64dfr1 =0x0000000000000000 ; + acc->id_aa64afr0 =0x0000000000000000 ; + acc->id_aa64afr1 =0x0000000000000000 ; + acc->isar.id_aa64mmfr0 =0x0000000000001122 ; + acc->isar.id_aa64mmfr1 =0x0000000011212100 ; + acc->isar.id_aa64mmfr2 =0x0000000000001011 ; + acc->isar.id_aa64isar0 =0x0000000010211120 ; + acc->isar.id_aa64isar1 =0x0000000000010001 ; + acc->isar.id_aa64zfr0 =0x0000000000000000 ; + acc->clidr =0x0000000080000023 ; + acc->ccsidr[0 ] =0x7007e01c ;/* 64KB L1 dcache */ + acc->ccsidr[1 ] =0x2007e01c ;/* 64KB L1 icache */ + acc->ccsidr[2 ] =0x70ffe07c ;/* 8MB L2 cache */ + acc->dcz_blocksize =6 ;/* 256 bytes */ + acc->gic_num_lrs =4 ; + acc->gic_vpribits =5 ; + acc->gic_vprebits =5 ; + acc->gic_pribits =5 ; + acc->isar.reset_pmcr_el0 =0x46014040 ;/* TODO: Add A64FX specific HPC extension registers */ }
@@ -1023,71 +1023,71 @@ static void aarch64_a64fx_object_init(Object *obj) | (1 << 3); /* 512bit */ } -static void aarch64_neoverse_n1_class_init (ARMCPUClass *cpu) +static void aarch64_neoverse_n1_class_init (ARMCPUClass *acc) { - cpu->dtb_compatible ="arm,neoverse-n1" ; -set_class_feature (cpu,ARM_FEATURE_V8 ); -set_class_feature (cpu,ARM_FEATURE_NEON ); -set_class_feature (cpu,ARM_FEATURE_GENERIC_TIMER ); -set_class_feature (cpu,ARM_FEATURE_AARCH64 ); -set_class_feature (cpu,ARM_FEATURE_CBAR_RO ); -set_class_feature (cpu,ARM_FEATURE_EL2 ); -set_class_feature (cpu,ARM_FEATURE_EL3 ); -set_class_feature (cpu,ARM_FEATURE_PMU ); + acc->dtb_compatible ="arm,neoverse-n1" ; +set_class_feature (acc,ARM_FEATURE_V8 ); +set_class_feature (acc,ARM_FEATURE_NEON ); +set_class_feature (acc,ARM_FEATURE_GENERIC_TIMER ); +set_class_feature (acc,ARM_FEATURE_AARCH64 ); +set_class_feature (acc,ARM_FEATURE_CBAR_RO ); +set_class_feature (acc,ARM_FEATURE_EL2 ); +set_class_feature (acc,ARM_FEATURE_EL3 ); +set_class_feature (acc,ARM_FEATURE_PMU );/* Ordered by B2.4 AArch64 registers by functional group */ - cpu->clidr =0x82000023 ; - cpu->ctr =0x8444c004 ; - cpu->dcz_blocksize =4 ; - cpu->isar.id_aa64dfr0 =0x0000000110305408ull ; - cpu->isar.id_aa64isar0 =0x0000100010211120ull ; - cpu->isar.id_aa64isar1 =0x0000000000100001ull ; - cpu->isar.id_aa64mmfr0 =0x0000000000101125ull ; - cpu->isar.id_aa64mmfr1 =0x0000000010212122ull ; - cpu->isar.id_aa64mmfr2 =0x0000000000001011ull ; - cpu->isar.id_aa64pfr0 =0x1100000010111112ull ;/* GIC filled in later */ - cpu->isar.id_aa64pfr1 =0x0000000000000020ull ; - cpu->id_afr0 =0x00000000 ; - cpu->isar.id_dfr0 =0x04010088 ; - cpu->isar.id_isar0 =0x02101110 ; - cpu->isar.id_isar1 =0x13112111 ; - cpu->isar.id_isar2 =0x21232042 ; - cpu->isar.id_isar3 =0x01112131 ; - cpu->isar.id_isar4 =0x00010142 ; - cpu->isar.id_isar5 =0x01011121 ; - cpu->isar.id_isar6 =0x00000010 ; - cpu->isar.id_mmfr0 =0x10201105 ; - cpu->isar.id_mmfr1 =0x40000000 ; - cpu->isar.id_mmfr2 =0x01260000 ; - cpu->isar.id_mmfr3 =0x02122211 ; - cpu->isar.id_mmfr4 =0x00021110 ; - cpu->isar.id_pfr0 =0x10010131 ; - cpu->isar.id_pfr1 =0x00010000 ;/* GIC filled in later */ - cpu->isar.id_pfr2 =0x00000011 ; - cpu->midr =0x414fd0c1 ;/* r4p1 */ - cpu->revidr =0 ; + acc->clidr =0x82000023 ; + acc->ctr =0x8444c004 ; + acc->dcz_blocksize =4 ; + acc->isar.id_aa64dfr0 =0x0000000110305408ull ; + acc->isar.id_aa64isar0 =0x0000100010211120ull ; + acc->isar.id_aa64isar1 =0x0000000000100001ull ; + acc->isar.id_aa64mmfr0 =0x0000000000101125ull ; + acc->isar.id_aa64mmfr1 =0x0000000010212122ull ; + acc->isar.id_aa64mmfr2 =0x0000000000001011ull ; + acc->isar.id_aa64pfr0 =0x1100000010111112ull ;/* GIC filled in later */ + acc->isar.id_aa64pfr1 =0x0000000000000020ull ; + acc->id_afr0 =0x00000000 ; + acc->isar.id_dfr0 =0x04010088 ; + acc->isar.id_isar0 =0x02101110 ; + acc->isar.id_isar1 =0x13112111 ; + acc->isar.id_isar2 =0x21232042 ; + acc->isar.id_isar3 =0x01112131 ; + acc->isar.id_isar4 =0x00010142 ; + acc->isar.id_isar5 =0x01011121 ; + acc->isar.id_isar6 =0x00000010 ; + acc->isar.id_mmfr0 =0x10201105 ; + acc->isar.id_mmfr1 =0x40000000 ; + acc->isar.id_mmfr2 =0x01260000 ; + acc->isar.id_mmfr3 =0x02122211 ; + acc->isar.id_mmfr4 =0x00021110 ; + acc->isar.id_pfr0 =0x10010131 ; + acc->isar.id_pfr1 =0x00010000 ;/* GIC filled in later */ + acc->isar.id_pfr2 =0x00000011 ; + acc->midr =0x414fd0c1 ;/* r4p1 */ + acc->revidr =0 ;/* From B2.23 CCSIDR_EL1 */ - cpu->ccsidr[0 ] =0x701fe01a ;/* 64KB L1 dcache */ - cpu->ccsidr[1 ] =0x201fe01a ;/* 64KB L1 icache */ - cpu->ccsidr[2 ] =0x70ffe03a ;/* 1MB L2 cache */ + acc->ccsidr[0 ] =0x701fe01a ;/* 64KB L1 dcache */ + acc->ccsidr[1 ] =0x201fe01a ;/* 64KB L1 icache */ + acc->ccsidr[2 ] =0x70ffe03a ;/* 1MB L2 cache */ /* From B2.98 SCTLR_EL3 */ - cpu->reset_sctlr =0x30c50838 ; + acc->reset_sctlr =0x30c50838 ;/* From B4.23 ICH_VTR_EL2 */ - cpu->gic_num_lrs =4 ; - cpu->gic_vpribits =5 ; - cpu->gic_vprebits =5 ; - cpu->gic_pribits =5 ; + acc->gic_num_lrs =4 ; + acc->gic_vpribits =5 ; + acc->gic_vprebits =5 ; + acc->gic_pribits =5 ;/* From B5.1 AdvSIMD AArch64 register summary */ - cpu->isar.mvfr0 =0x10110222 ; - cpu->isar.mvfr1 =0x13211111 ; - cpu->isar.mvfr2 =0x00000043 ; + acc->isar.mvfr0 =0x10110222 ; + acc->isar.mvfr1 =0x13211111 ; + acc->isar.mvfr2 =0x00000043 ;/* From D5.1 AArch64 PMU register summary */ - cpu->isar.reset_pmcr_el0 =0x410c3000 ; + acc->isar.reset_pmcr_el0 =0x410c3000 ; }static void aarch64_host_class_init (ARMCPUClass *acc)
@@ -1136,22 +1136,22 @@ static void aarch64_host_object_init(Object *obj)* The version of '-cpu max' for qemu-system-arm is defined in cpu.c; * this version only needs to handle 64 bits. */ -static bool aarch64_max_class_late_init (ARMCPUClass *cpu,Error **errp) +static bool aarch64_max_class_late_init (ARMCPUClass *acc,Error **errp) {uint64_t t;uint32_t u;if (kvm_enabled () ||hvf_enabled ()) {/* With KVM or HVF, '-cpu max' is identical to '-cpu host' */ -return aarch64_host_class_late_init (cpu, errp); +return aarch64_host_class_late_init (acc, errp); }/* * '-cpu max' for TCG: we currently do this as "A57 with extra things" * Retain the more generic dtb_compatible setting from host_class_init. */ -aarch64_a57_class_init (cpu); - cpu->dtb_compatible ="arm,arm-v8" ; +aarch64_a57_class_init (acc); + acc->dtb_compatible ="arm,arm-v8" ;/* * Reset MIDR so the guest doesn't mistake our 'max' CPU type for a real
@@ -1170,18 +1170,18 @@ static bool aarch64_max_class_late_init(ARMCPUClass *cpu, Error **errp) t =FIELD_DP64 (t,MIDR_EL1 ,PARTNUM ,'Q' ); t =FIELD_DP64 (t,MIDR_EL1 ,VARIANT ,0 ); t =FIELD_DP64 (t,MIDR_EL1 ,REVISION ,0 ); - cpu->midr = t; + acc->midr = t;/* * We're going to set FEAT_S2FWB, which mandates that CLIDR_EL1.{LoUU,LoUIS} * are zero. */ - u = cpu->clidr; + u = acc->clidr; u =FIELD_DP32 (u,CLIDR_EL1 ,LOUIS ,0 ); u =FIELD_DP32 (u,CLIDR_EL1 ,LOUU ,0 ); - cpu->clidr = u; + acc->clidr = u; - t = cpu->isar.id_aa64isar0; + t = acc->isar.id_aa64isar0; t =FIELD_DP64 (t,ID_AA64ISAR0 ,AES ,2 );/* FEAT_PMULL */ t =FIELD_DP64 (t,ID_AA64ISAR0 ,SHA1 ,1 );/* FEAT_SHA1 */ t =FIELD_DP64 (t,ID_AA64ISAR0 ,SHA2 ,2 );/* FEAT_SHA512 */
@@ -1196,9 +1196,9 @@ static bool aarch64_max_class_late_init(ARMCPUClass *cpu, Error **errp) t =FIELD_DP64 (t,ID_AA64ISAR0 ,TS ,2 );/* FEAT_FlagM2 */ t =FIELD_DP64 (t,ID_AA64ISAR0 ,TLB ,2 );/* FEAT_TLBIRANGE */ t =FIELD_DP64 (t,ID_AA64ISAR0 ,RNDR ,1 );/* FEAT_RNG */ - cpu->isar.id_aa64isar0 = t; + acc->isar.id_aa64isar0 = t; - t = cpu->isar.id_aa64isar1; + t = acc->isar.id_aa64isar1; t =FIELD_DP64 (t,ID_AA64ISAR1 ,DPB ,2 );/* FEAT_DPB2 */ t =FIELD_DP64 (t,ID_AA64ISAR1 ,JSCVT ,1 );/* FEAT_JSCVT */ t =FIELD_DP64 (t,ID_AA64ISAR1 ,FCMA ,1 );/* FEAT_FCMA */
@@ -1209,9 +1209,9 @@ static bool aarch64_max_class_late_init(ARMCPUClass *cpu, Error **errp) t =FIELD_DP64 (t,ID_AA64ISAR1 ,BF16 ,1 );/* FEAT_BF16 */ t =FIELD_DP64 (t,ID_AA64ISAR1 ,DGH ,1 );/* FEAT_DGH */ t =FIELD_DP64 (t,ID_AA64ISAR1 ,I8MM ,1 );/* FEAT_I8MM */ - cpu->isar.id_aa64isar1 = t; + acc->isar.id_aa64isar1 = t; - t = cpu->isar.id_aa64pfr0; + t = acc->isar.id_aa64pfr0; t =FIELD_DP64 (t,ID_AA64PFR0 ,FP ,1 );/* FEAT_FP16 */ t =FIELD_DP64 (t,ID_AA64PFR0 ,ADVSIMD ,1 );/* FEAT_FP16 */ t =FIELD_DP64 (t,ID_AA64PFR0 ,RAS ,2 );/* FEAT_RASv1p1 + FEAT_DoubleFault */
@@ -1220,9 +1220,9 @@ static bool aarch64_max_class_late_init(ARMCPUClass *cpu, Error **errp) t =FIELD_DP64 (t,ID_AA64PFR0 ,DIT ,1 );/* FEAT_DIT */ t =FIELD_DP64 (t,ID_AA64PFR0 ,CSV2 ,2 );/* FEAT_CSV2_2 */ t =FIELD_DP64 (t,ID_AA64PFR0 ,CSV3 ,1 );/* FEAT_CSV3 */ - cpu->isar.id_aa64pfr0 = t; + acc->isar.id_aa64pfr0 = t; - t = cpu->isar.id_aa64pfr1; + t = acc->isar.id_aa64pfr1; t =FIELD_DP64 (t,ID_AA64PFR1 ,BT ,1 );/* FEAT_BTI */ t =FIELD_DP64 (t,ID_AA64PFR1 ,SSBS ,2 );/* FEAT_SSBS2 */ /*
@@ -1234,17 +1234,17 @@ static bool aarch64_max_class_late_init(ARMCPUClass *cpu, Error **errp) t =FIELD_DP64 (t,ID_AA64PFR1 ,RAS_FRAC ,0 );/* FEAT_RASv1p1 + FEAT_DoubleFault */ t =FIELD_DP64 (t,ID_AA64PFR1 ,SME ,1 );/* FEAT_SME */ t =FIELD_DP64 (t,ID_AA64PFR1 ,CSV2_FRAC ,0 );/* FEAT_CSV2_2 */ - cpu->isar.id_aa64pfr1 = t; + acc->isar.id_aa64pfr1 = t; - t = cpu->isar.id_aa64mmfr0; + t = acc->isar.id_aa64mmfr0; t =FIELD_DP64 (t,ID_AA64MMFR0 ,PARANGE ,6 );/* FEAT_LPA: 52 bits */ t =FIELD_DP64 (t,ID_AA64MMFR0 ,TGRAN16 ,1 );/* 16k pages supported */ t =FIELD_DP64 (t,ID_AA64MMFR0 ,TGRAN16_2 ,2 );/* 16k stage2 supported */ t =FIELD_DP64 (t,ID_AA64MMFR0 ,TGRAN64_2 ,2 );/* 64k stage2 supported */ t =FIELD_DP64 (t,ID_AA64MMFR0 ,TGRAN4_2 ,2 );/* 4k stage2 supported */ - cpu->isar.id_aa64mmfr0 = t; + acc->isar.id_aa64mmfr0 = t; - t = cpu->isar.id_aa64mmfr1; + t = acc->isar.id_aa64mmfr1; t =FIELD_DP64 (t,ID_AA64MMFR1 ,HAFDBS ,2 );/* FEAT_HAFDBS */ t =FIELD_DP64 (t,ID_AA64MMFR1 ,VMIDBITS ,2 );/* FEAT_VMID16 */ t =FIELD_DP64 (t,ID_AA64MMFR1 ,VH ,1 );/* FEAT_VHE */
@@ -1254,9 +1254,9 @@ static bool aarch64_max_class_late_init(ARMCPUClass *cpu, Error **errp) t =FIELD_DP64 (t,ID_AA64MMFR1 ,XNX ,1 );/* FEAT_XNX */ t =FIELD_DP64 (t,ID_AA64MMFR1 ,ETS ,1 );/* FEAT_ETS */ t =FIELD_DP64 (t,ID_AA64MMFR1 ,HCX ,1 );/* FEAT_HCX */ - cpu->isar.id_aa64mmfr1 = t; + acc->isar.id_aa64mmfr1 = t; - t = cpu->isar.id_aa64mmfr2; + t = acc->isar.id_aa64mmfr2; t =FIELD_DP64 (t,ID_AA64MMFR2 ,CNP ,1 );/* FEAT_TTCNP */ t =FIELD_DP64 (t,ID_AA64MMFR2 ,UAO ,1 );/* FEAT_UAO */ t =FIELD_DP64 (t,ID_AA64MMFR2 ,IESB ,1 );/* FEAT_IESB */
@@ -1268,9 +1268,9 @@ static bool aarch64_max_class_late_init(ARMCPUClass *cpu, Error **errp) t =FIELD_DP64 (t,ID_AA64MMFR2 ,BBM ,2 );/* FEAT_BBM at level 2 */ t =FIELD_DP64 (t,ID_AA64MMFR2 ,EVT ,2 );/* FEAT_EVT */ t =FIELD_DP64 (t,ID_AA64MMFR2 ,E0PD ,1 );/* FEAT_E0PD */ - cpu->isar.id_aa64mmfr2 = t; + acc->isar.id_aa64mmfr2 = t; - t = cpu->isar.id_aa64zfr0; + t = acc->isar.id_aa64zfr0; t =FIELD_DP64 (t,ID_AA64ZFR0 ,SVEVER ,1 ); t =FIELD_DP64 (t,ID_AA64ZFR0 ,AES ,2 );/* FEAT_SVE_PMULL128 */ t =FIELD_DP64 (t,ID_AA64ZFR0 ,BITPERM ,1 );/* FEAT_SVE_BitPerm */
@@ -1280,14 +1280,14 @@ static bool aarch64_max_class_late_init(ARMCPUClass *cpu, Error **errp) t =FIELD_DP64 (t,ID_AA64ZFR0 ,I8MM ,1 );/* FEAT_I8MM */ t =FIELD_DP64 (t,ID_AA64ZFR0 ,F32MM ,1 );/* FEAT_F32MM */ t =FIELD_DP64 (t,ID_AA64ZFR0 ,F64MM ,1 );/* FEAT_F64MM */ - cpu->isar.id_aa64zfr0 = t; + acc->isar.id_aa64zfr0 = t; - t = cpu->isar.id_aa64dfr0; + t = acc->isar.id_aa64dfr0; t =FIELD_DP64 (t,ID_AA64DFR0 ,DEBUGVER ,9 );/* FEAT_Debugv8p4 */ t =FIELD_DP64 (t,ID_AA64DFR0 ,PMUVER ,6 );/* FEAT_PMUv3p5 */ - cpu->isar.id_aa64dfr0 = t; + acc->isar.id_aa64dfr0 = t; - t = cpu->isar.id_aa64smfr0; + t = acc->isar.id_aa64smfr0; t =FIELD_DP64 (t,ID_AA64SMFR0 ,F32F32 ,1 );/* FEAT_SME */ t =FIELD_DP64 (t,ID_AA64SMFR0 ,B16F32 ,1 );/* FEAT_SME */ t =FIELD_DP64 (t,ID_AA64SMFR0 ,F16F32 ,1 );/* FEAT_SME */
@@ -1295,18 +1295,18 @@ static bool aarch64_max_class_late_init(ARMCPUClass *cpu, Error **errp) t =FIELD_DP64 (t,ID_AA64SMFR0 ,F64F64 ,1 );/* FEAT_SME_F64F64 */ t =FIELD_DP64 (t,ID_AA64SMFR0 ,I16I64 ,0xf );/* FEAT_SME_I16I64 */ t =FIELD_DP64 (t,ID_AA64SMFR0 ,FA64 ,1 );/* FEAT_SME_FA64 */ - cpu->isar.id_aa64smfr0 = t; + acc->isar.id_aa64smfr0 = t;/* Replicate the same data to the 32-bit id registers. */ -aa32_max_features (cpu); +aa32_max_features (acc);#ifdef CONFIG_USER_ONLY /* * For usermode -cpu max we can use a larger and more efficient DCZ * blocksize since we don't have to follow what the hardware does. */ - cpu->ctr =0x80038003 ;/* 32 byte I and D cacheline size, VIPT icache */ - cpu->dcz_blocksize =7 ;/* 512 bytes */ + acc->ctr =0x80038003 ;/* 32 byte I and D cacheline size, VIPT icache */ + acc->dcz_blocksize =7 ;/* 512 bytes */ #endif return true; }
target/arm/cpu_tcg.c +630 -630
1,492 lines not on this page · raw message
Signature · 1 line
2.34.1
Re: [RFC PATCH 26/40] target/arm: Rename 'cpu' to 'acc' in class init functions
Quoted 8 lines · Richard Henderson
These were previously left 'misnamed' to minimize the size of the patch. Rename them all in bulk with no other change.
Signed-off-by Richard Henderson <[email protected]>--- target/arm/cpu64.c | 858 ++++++++++++++-------------- target/arm/cpu_tcg.c | 1260 +++++++++++++++++++++--------------------- 2 files changed, 1059 insertions(+), 1059 deletions(-)
RFC PATCH 27/40 target/arm: Split out strongarm_class_init
In reply to Richard HendersonUse an intermediate function to share code between sa1100_class_init and sa1110_class_init.
--- target/arm/cpu_tcg.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)
target/arm/cpu_tcg.c +9 -6
@@ -837,21 +837,24 @@ static void ti925t_class_init(ARMCPUClass *acc) acc->reset_sctlr =0x00000070 ; } -static void sa1100_class_init (ARMCPUClass *acc) +static void strongarm_class_init (ARMCPUClass *acc) { - acc->dtb_compatible ="intel,sa1100" ;set_class_feature (acc,ARM_FEATURE_STRONGARM );set_class_feature (acc,ARM_FEATURE_DUMMY_C15_REGS ); - acc->midr =0x4401A11B ; acc->reset_sctlr =0x00000070 ; } +static void sa1100_class_init (ARMCPUClass *acc) +{ +strongarm_class_init (acc); + acc->dtb_compatible ="intel,sa1100" ; + acc->midr =0x4401A11B ; +} +static void sa1110_class_init (ARMCPUClass *acc) { -set_class_feature (acc,ARM_FEATURE_STRONGARM ); -set_class_feature (acc,ARM_FEATURE_DUMMY_C15_REGS ); +strongarm_class_init (acc); acc->midr =0x6901B119 ; - acc->reset_sctlr =0x00000070 ; }static void pxa250_class_init (ARMCPUClass *acc)
Signature · 1 line
2.34.1
Re: [RFC PATCH 27/40] target/arm: Split out strongarm_class_init
Quoted 7 lines · Richard Henderson
Use an intermediate function to share code between
sa1100_class_initandsa1110_class_init.Signed-off-by Richard Henderson <[email protected]>--- target/arm/cpu_tcg.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)
RFC PATCH 28/40 target/arm: Split out xscale*_class_init
In reply to Richard HendersonUse two intermediate functions to share code between the 13 variants of pxa*_class_init.
--- target/arm/cpu_tcg.c | 81 +++++++++++++------------------------------- 1 file changed, 23 insertions(+), 58 deletions(-)
target/arm/cpu_tcg.c +23 -58
@@ -857,120 +857,85 @@ static void sa1110_class_init(ARMCPUClass *acc) acc->midr =0x6901B119 ; } -static void pxa250_class_init (ARMCPUClass *acc) +static void xscale_class_init (ARMCPUClass *acc) { acc->dtb_compatible ="marvell,xscale" ;set_class_feature (acc,ARM_FEATURE_V5 );set_class_feature (acc,ARM_FEATURE_XSCALE ); - acc->midr =0x69052100 ; acc->ctr =0xd172172 ; acc->reset_sctlr =0x00000078 ; } +static void pxa250_class_init (ARMCPUClass *acc) +{ +xscale_class_init (acc); + acc->midr =0x69052100 ; +} +static void pxa255_class_init (ARMCPUClass *acc) { - acc->dtb_compatible ="marvell,xscale" ; -set_class_feature (acc,ARM_FEATURE_V5 ); -set_class_feature (acc,ARM_FEATURE_XSCALE ); +xscale_class_init (acc); acc->midr =0x69052d00 ; - acc->ctr =0xd172172 ; - acc->reset_sctlr =0x00000078 ; }static void pxa260_class_init (ARMCPUClass *acc) { - acc->dtb_compatible ="marvell,xscale" ; -set_class_feature (acc,ARM_FEATURE_V5 ); -set_class_feature (acc,ARM_FEATURE_XSCALE ); +xscale_class_init (acc); acc->midr =0x69052903 ; - acc->ctr =0xd172172 ; - acc->reset_sctlr =0x00000078 ; }static void pxa261_class_init (ARMCPUClass *acc) { - acc->dtb_compatible ="marvell,xscale" ; -set_class_feature (acc,ARM_FEATURE_V5 ); -set_class_feature (acc,ARM_FEATURE_XSCALE ); +xscale_class_init (acc); acc->midr =0x69052d05 ; - acc->ctr =0xd172172 ; - acc->reset_sctlr =0x00000078 ; }static void pxa262_class_init (ARMCPUClass *acc) { - acc->dtb_compatible ="marvell,xscale" ; -set_class_feature (acc,ARM_FEATURE_V5 ); -set_class_feature (acc,ARM_FEATURE_XSCALE ); +xscale_class_init (acc); acc->midr =0x69052d06 ; - acc->ctr =0xd172172 ; - acc->reset_sctlr =0x00000078 ; +} + +static void xscale_iwmmxt_class_init (ARMCPUClass *acc) +{ +xscale_class_init (acc); +set_class_feature (acc,ARM_FEATURE_IWMMXT ); }static void pxa270a0_class_init (ARMCPUClass *acc) { - acc->dtb_compatible ="marvell,xscale" ; -set_class_feature (acc,ARM_FEATURE_V5 ); -set_class_feature (acc,ARM_FEATURE_XSCALE ); -set_class_feature (acc,ARM_FEATURE_IWMMXT ); +xscale_iwmmxt_class_init (acc); acc->midr =0x69054110 ; - acc->ctr =0xd172172 ; - acc->reset_sctlr =0x00000078 ; }static void pxa270a1_class_init (ARMCPUClass *acc) { - acc->dtb_compatible ="marvell,xscale" ; -set_class_feature (acc,ARM_FEATURE_V5 ); -set_class_feature (acc,ARM_FEATURE_XSCALE ); -set_class_feature (acc,ARM_FEATURE_IWMMXT ); +xscale_iwmmxt_class_init (acc); acc->midr =0x69054111 ; - acc->ctr =0xd172172 ; - acc->reset_sctlr =0x00000078 ; }static void pxa270b0_class_init (ARMCPUClass *acc) { - acc->dtb_compatible ="marvell,xscale" ; -set_class_feature (acc,ARM_FEATURE_V5 ); -set_class_feature (acc,ARM_FEATURE_XSCALE ); -set_class_feature (acc,ARM_FEATURE_IWMMXT ); +xscale_iwmmxt_class_init (acc); acc->midr =0x69054112 ; - acc->ctr =0xd172172 ; - acc->reset_sctlr =0x00000078 ; }static void pxa270b1_class_init (ARMCPUClass *acc) { - acc->dtb_compatible ="marvell,xscale" ; -set_class_feature (acc,ARM_FEATURE_V5 ); -set_class_feature (acc,ARM_FEATURE_XSCALE ); -set_class_feature (acc,ARM_FEATURE_IWMMXT ); +xscale_iwmmxt_class_init (acc); acc->midr =0x69054113 ; - acc->ctr =0xd172172 ; - acc->reset_sctlr =0x00000078 ; }static void pxa270c0_class_init (ARMCPUClass *acc) { - acc->dtb_compatible ="marvell,xscale" ; -set_class_feature (acc,ARM_FEATURE_V5 ); -set_class_feature (acc,ARM_FEATURE_XSCALE ); -set_class_feature (acc,ARM_FEATURE_IWMMXT ); +xscale_iwmmxt_class_init (acc); acc->midr =0x69054114 ; - acc->ctr =0xd172172 ; - acc->reset_sctlr =0x00000078 ; }static void pxa270c5_class_init (ARMCPUClass *acc) { - acc->dtb_compatible ="marvell,xscale" ; -set_class_feature (acc,ARM_FEATURE_V5 ); -set_class_feature (acc,ARM_FEATURE_XSCALE ); -set_class_feature (acc,ARM_FEATURE_IWMMXT ); +xscale_iwmmxt_class_init (acc); acc->midr =0x69054117 ; - acc->ctr =0xd172172 ; - acc->reset_sctlr =0x00000078 ; }#ifdef CONFIG_TCG
Signature · 1 line
2.34.1
Re: [RFC PATCH 28/40] target/arm: Split out xscale*_class_init
Quoted 7 lines · Richard Henderson
Use two intermediate functions to share code between the 13 variants of pxa*_class_init.
Signed-off-by Richard Henderson <[email protected]>--- target/arm/cpu_tcg.c | 81 +++++++++++++------------------------------- 1 file changed, 23 insertions(+), 58 deletions(-)
Yay :)
RFC PATCH 29/40 target/arm: Remove m-profile has_vfp and has_dsp properties
In reply to Richard HendersonReplace the properties with separate cpu classes that have these features disabled. These stand in the way of moving all id-register properties to the cpu class level, because of the case of SSE200, which has one cortex-m33 with dsp+vfp and one without.
Create the full set of m-profile cpus with and without the corresponding options. As per
https://developer.arm.com/documentation/102787/0100
cortex m-{4,7,33,55} have a configurable fpu, while only cortex-m33 has a configurable dsp (we don't implement m35).
The armv7m boards besides armsse will be able to use
-cpu cortex-mX-nofpu
instead of
-cpu cortex-mX,has_fpu=off.
--- include/hw/arm/armsse.h | 3 +- include/hw/arm/armv7m.h | 2 - target/arm/cpu.h | 2 - hw/arm/armsse.c | 53 +++++++++++++++------------ hw/arm/armv7m.c | 12 ------ hw/arm/musca.c | 14 +++---- target/arm/cpu.c | 30 +-------------- target/arm/cpu_tcg.c | 81 +++++++++++++++++++++++++++++++++++++++++ 8 files changed, 118 insertions(+), 79 deletions(-)
include/hw/arm/armsse.h +1 -2
@@ -123,6 +123,7 @@ OBJECT_DECLARE_TYPE(ARMSSE, ARMSSEClass,*/ #define TYPE_IOTKIT "iotkit"#define TYPE_SSE200 "sse-200" +#define TYPE_SSE200_B "sse-200-b"#define TYPE_SSE300 "sse-300"/* We have an IRQ splitter and an OR gate input for each external PPC
@@ -221,8 +222,6 @@ struct ARMSSE {uint32_t exp_numirq;uint32_t sram_addr_width;uint32_t init_svtor; -bool cpu_fpu[SSE_MAX_CPUS ]; -bool cpu_dsp[SSE_MAX_CPUS ]; };typedef struct ARMSSEInfo ARMSSEInfo ;
include/hw/arm/armv7m.h +0 -2
@@ -97,8 +97,6 @@ struct ARMv7MState {uint32_t init_nsvtor;bool enable_bitband; bool start_powered_off; -bool vfp; - bool dsp; };#endif
target/arm/cpu.h +0 -2
@@ -897,8 +897,6 @@ struct ArchCPU {bool has_vfp;/* CPU has Neon */ bool has_neon; -/* CPU has M-profile DSP extension */ -bool has_dsp;/* CPU has memory protection unit */ bool has_mpu;
hw/arm/armsse.c +30 -23
107 lines not on this page · raw message
hw/arm/armv7m.c +0 -12
@@ -323,16 +323,6 @@ static void armv7m_realize(DeviceState *dev, Error **errp)return ; } } -if (object_property_find (OBJECT (s->cpu),"vfp" )) { -if (!object_property_set_bool (OBJECT (s->cpu),"vfp" , s->vfp, errp)) { -return ; - } - } -if (object_property_find (OBJECT (s->cpu),"dsp" )) { -if (!object_property_set_bool (OBJECT (s->cpu),"dsp" , s->dsp, errp)) { -return ; - } - }/* * Tell the CPU where the NVIC is; it will fail realize if it doesn't
@@ -528,8 +518,6 @@ static Property armv7m_properties[] = {DEFINE_PROP_BOOL ("enable-bitband" , ARMv7MState, enable_bitband, false),DEFINE_PROP_BOOL ("start-powered-off" , ARMv7MState, start_powered_off, false), -DEFINE_PROP_BOOL ("vfp" , ARMv7MState, vfp, true), -DEFINE_PROP_BOOL ("dsp" , ARMv7MState, dsp, true), DEFINE_PROP_END_OF_LIST(), };
hw/arm/musca.c +5 -9
@@ -377,8 +377,12 @@ static void musca_init(MachineState *machine) mms->s32kclk =clock_new (OBJECT (machine),"S32KCLK" );clock_set_hz (mms->s32kclk,S32KCLK_FRQ ); +/* +* Musca-A takes the default SSE-200 FPU/DSP settings (ie no for +* CPU0 and yes for CPU1); Musca-B1 explicitly enables them for CPU0. +*/ object_initialize_child (OBJECT (machine),"sse-200" , &mms->sse, -TYPE_SSE200 ); + mmc->type ==MUSCA_A ?TYPE_SSE200 :TYPE_SSE200_B ); ssedev =DEVICE (&mms->sse);object_property_set_link (OBJECT (&mms->sse),"memory" ,OBJECT (system_memory), &error_fatal);
@@ -387,14 +391,6 @@ static void musca_init(MachineState *machine)qdev_prop_set_uint32 (ssedev,"SRAM_ADDR_WIDTH" , mmc->sram_addr_width);qdev_connect_clock_in (ssedev,"MAINCLK" , mms->sysclk);qdev_connect_clock_in (ssedev,"S32KCLK" , mms->s32kclk); -/* -* Musca-A takes the default SSE-200 FPU/DSP settings (ie no for -* CPU0 and yes for CPU1); Musca-B1 explicitly enables them for CPU0. -*/ -if (mmc->type ==MUSCA_B1 ) { -qdev_prop_set_bit (ssedev,"CPU0_FPU" , true); -qdev_prop_set_bit (ssedev,"CPU0_DSP" , true); - }sysbus_realize (SYS_BUS_DEVICE (&mms->sse), &error_fatal);/*
target/arm/cpu.c +1 -29
@@ -1305,9 +1305,6 @@ static Property arm_cpu_has_vfp_property =static Property arm_cpu_has_neon_property =DEFINE_PROP_BOOL ("neon" ,ARMCPU , has_neon, true); -static Property arm_cpu_has_dsp_property = -DEFINE_PROP_BOOL ("dsp" ,ARMCPU , has_dsp, true); -static Property arm_cpu_has_mpu_property =DEFINE_PROP_BOOL ("has-mpu" ,ARMCPU , has_mpu, true);
@@ -1428,7 +1425,7 @@ static void arm_cpu_post_init(Object *obj) ?cpu_isar_feature (aa64_fp_simd, cpu) : cpu_isar_feature(aa32_vfp, cpu)) { cpu->has_vfp = true; -if (!kvm_enabled ()) { +if (!kvm_enabled () && !arm_feature (&cpu->env,ARM_FEATURE_M )) {qdev_property_add_static (DEVICE (obj), &arm_cpu_has_vfp_property); } }
@@ -1440,11 +1437,6 @@ static void arm_cpu_post_init(Object *obj) } } -if (arm_feature (&cpu->env,ARM_FEATURE_M ) && -arm_feature (&cpu->env,ARM_FEATURE_THUMB_DSP )) { -qdev_property_add_static (DEVICE (obj), &arm_cpu_has_dsp_property); - } -if (arm_feature (&cpu->env,ARM_FEATURE_PMSA )) {qdev_property_add_static (DEVICE (obj), &arm_cpu_has_mpu_property);if (arm_feature (&cpu->env,ARM_FEATURE_V7 )) {
@@ -1801,26 +1793,6 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) cpu->isar.mvfr1 = u; } -if (arm_feature (env,ARM_FEATURE_M ) && !cpu->has_dsp) { -uint32_t u; - -unset_feature (env,ARM_FEATURE_THUMB_DSP ); - - u = cpu->isar.id_isar1; - u =FIELD_DP32 (u,ID_ISAR1 ,EXTEND ,1 ); - cpu->isar.id_isar1 = u; - - u = cpu->isar.id_isar2; - u =FIELD_DP32 (u,ID_ISAR2 ,MULTU ,1 ); - u =FIELD_DP32 (u,ID_ISAR2 ,MULTS ,1 ); - cpu->isar.id_isar2 = u; - - u = cpu->isar.id_isar3; - u =FIELD_DP32 (u,ID_ISAR3 ,SIMD ,1 ); - u =FIELD_DP32 (u,ID_ISAR3 ,SATURATE ,0 ); - cpu->isar.id_isar3 = u; - } -/* Some features automatically imply others: */ if (arm_feature (env,ARM_FEATURE_V8 )) {if (arm_feature (env,ARM_FEATURE_M )) {
target/arm/cpu_tcg.c +81 -0
121 lines not on this page · raw message
Signature · 1 line
2.34.1
RFC PATCH 30/40 target/arm: Move feature bit propagation to class init
In reply to Richard HendersonWith the introduction of aarch64_host_class_init, we have enough feature bits set to do propagation early. Move the tcg consistency checks to class_late_init, after we have populated all of the id registers.
--- target/arm/cpu.c | 162 ++++++++++++++++++++++------------------------- 1 file changed, 77 insertions(+), 85 deletions(-)
target/arm/cpu.c +77 -85
@@ -1369,14 +1369,6 @@ static void arm_cpu_post_init(Object *obj) {ARMCPU *cpu =ARM_CPU (obj); -/* M profile implies PMSA. We have to do this here rather than -* in realize with the other feature-implication checks because -* we look at the PMSA bit to see if we should add some properties. -*/ -if (arm_feature (&cpu->env,ARM_FEATURE_M )) { -set_feature (&cpu->env,ARM_FEATURE_PMSA ); - } -if (arm_feature (&cpu->env,ARM_FEATURE_CBAR ) ||arm_feature (&cpu->env,ARM_FEATURE_CBAR_RO )) {qdev_property_add_static (DEVICE (obj), &arm_cpu_reset_cbar_property);
@@ -1574,7 +1566,6 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp)CPUARMState *env = &cpu->env;int pagebits;Error *local_err =NULL ; -bool no_aa32 = false;#ifndef CONFIG_USER_ONLY /* The NVIC and M-profile CPU are two halves of a single piece of
@@ -1793,82 +1784,6 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) cpu->isar.mvfr1 = u; } -/* Some features automatically imply others: */ -if (arm_feature (env,ARM_FEATURE_V8 )) { -if (arm_feature (env,ARM_FEATURE_M )) { -set_feature (env,ARM_FEATURE_V7 ); - }else { -set_feature (env,ARM_FEATURE_V7VE ); - } - } - -/* -* There exist AArch64 cpus without AArch32 support. When KVM -* queries ID_ISAR0_EL1 on such a host, the value is UNKNOWN. -* Similarly, we cannot check ID_AA64PFR0 without AArch64 support. -* As a general principle, we also do not make ID register -* consistency checks anywhere unless using TCG, because only -* for TCG would a consistency-check failure be a QEMU bug. -*/ -if (arm_feature (&cpu->env,ARM_FEATURE_AARCH64 )) { - no_aa32 = !cpu_isar_feature (aa64_aa32, cpu); - } - -if (arm_feature (env,ARM_FEATURE_V7VE )) { -/* v7 Virtualization Extensions. In real hardware this implies -* EL2 and also the presence of the Security Extensions. -* For QEMU, for backwards-compatibility we implement some -* CPUs or CPU configs which have no actual EL2 or EL3 but do -* include the various other features that V7VE implies. -* Presence of EL2 itself is ARM_FEATURE_EL2, and of the -* Security Extensions is ARM_FEATURE_EL3. -*/ -assert (!tcg_enabled () || no_aa32 || -cpu_isar_feature (aa32_arm_div, cpu)); -set_feature (env,ARM_FEATURE_LPAE ); -set_feature (env,ARM_FEATURE_V7 ); - } -if (arm_feature (env,ARM_FEATURE_V7 )) { -set_feature (env,ARM_FEATURE_VAPA ); -set_feature (env,ARM_FEATURE_THUMB2 ); -set_feature (env,ARM_FEATURE_MPIDR ); -if (!arm_feature (env,ARM_FEATURE_M )) { -set_feature (env,ARM_FEATURE_V6K ); - }else { -set_feature (env,ARM_FEATURE_V6 ); - } - -/* Always define VBAR for V7 CPUs even if it doesn't exist in -* non-EL3 configs. This is needed by some legacy boards. -*/ -set_feature (env,ARM_FEATURE_VBAR ); - } -if (arm_feature (env,ARM_FEATURE_V6K )) { -set_feature (env,ARM_FEATURE_V6 ); -set_feature (env,ARM_FEATURE_MVFR ); - } -if (arm_feature (env,ARM_FEATURE_V6 )) { -set_feature (env,ARM_FEATURE_V5 ); -if (!arm_feature (env,ARM_FEATURE_M )) { -assert (!tcg_enabled () || no_aa32 || -cpu_isar_feature (aa32_jazelle, cpu)); -set_feature (env,ARM_FEATURE_AUXCR ); - } - } -if (arm_feature (env,ARM_FEATURE_V5 )) { -set_feature (env,ARM_FEATURE_V4T ); - } -if (arm_feature (env,ARM_FEATURE_LPAE )) { -set_feature (env,ARM_FEATURE_V7MP ); - } -if (arm_feature (env,ARM_FEATURE_CBAR_RO )) { -set_feature (env,ARM_FEATURE_CBAR ); - } -if (arm_feature (env,ARM_FEATURE_THUMB2 ) && - !arm_feature (env,ARM_FEATURE_M )) { -set_feature (env,ARM_FEATURE_THUMB_DSP ); - } -/* * We rely on no XScale CPU having VFP so we can use the same bits in the * TB flags field for VECSTRIDE and XSCALE_CPAR.
@@ -2318,6 +2233,67 @@ static void arm_cpu_leaf_class_init(ObjectClass *oc, void *data)if (acc->info->class_init) { acc->info->class_init (acc); } + +/* Some features automatically imply others: */ +if (arm_class_feature (acc,ARM_FEATURE_V8 )) { +if (arm_class_feature (acc,ARM_FEATURE_M )) { +set_class_feature (acc,ARM_FEATURE_V7 ); + }else { +set_class_feature (acc,ARM_FEATURE_V7VE ); + } + } +if (arm_class_feature (acc,ARM_FEATURE_V7VE )) { +/* +* v7 Virtualization Extensions. In real hardware this implies +* EL2 and also the presence of the Security Extensions. +* For QEMU, for backwards-compatibility we implement some +* CPUs or CPU configs which have no actual EL2 or EL3 but do +* include the various other features that V7VE implies. +*/ +set_class_feature (acc,ARM_FEATURE_LPAE ); +set_class_feature (acc,ARM_FEATURE_V7 ); + } +if (arm_class_feature (acc,ARM_FEATURE_V7 )) { +set_class_feature (acc,ARM_FEATURE_VAPA ); +set_class_feature (acc,ARM_FEATURE_THUMB2 ); +set_class_feature (acc,ARM_FEATURE_MPIDR ); +if (!arm_class_feature (acc,ARM_FEATURE_M )) { +set_class_feature (acc,ARM_FEATURE_V6K ); + }else { +set_class_feature (acc,ARM_FEATURE_V6 ); + } +/* +* Always define VBAR for V7 CPUs even if it doesn't exist in +* non-EL3 configs. This is needed by some legacy boards. +*/ +set_class_feature (acc,ARM_FEATURE_VBAR ); + } +if (arm_class_feature (acc,ARM_FEATURE_V6K )) { +set_class_feature (acc,ARM_FEATURE_V6 ); +set_class_feature (acc,ARM_FEATURE_MVFR ); + } +if (arm_class_feature (acc,ARM_FEATURE_V6 )) { +set_class_feature (acc,ARM_FEATURE_V5 ); +if (!arm_class_feature (acc,ARM_FEATURE_M )) { +set_class_feature (acc,ARM_FEATURE_AUXCR ); + } + } +if (arm_class_feature (acc,ARM_FEATURE_V5 )) { +set_class_feature (acc,ARM_FEATURE_V4T ); + } +if (arm_class_feature (acc,ARM_FEATURE_LPAE )) { +set_class_feature (acc,ARM_FEATURE_V7MP ); + } +if (arm_class_feature (acc,ARM_FEATURE_CBAR_RO )) { +set_class_feature (acc,ARM_FEATURE_CBAR ); + } +if (arm_class_feature (acc,ARM_FEATURE_THUMB2 ) && + !arm_class_feature (acc,ARM_FEATURE_M )) { +set_class_feature (acc,ARM_FEATURE_THUMB_DSP ); + } +if (arm_class_feature (acc,ARM_FEATURE_M )) { +set_class_feature (acc,ARM_FEATURE_PMSA ); + } }static bool arm_cpu_class_late_init (ObjectClass *oc,Error **errp)
@@ -2329,6 +2305,22 @@ static bool arm_cpu_class_late_init(ObjectClass *oc, Error **errp)return false; } } + +/* Run some consistency checks for TCG. */ +if (tcg_enabled ()) { +bool no_aa32 =arm_class_feature (acc,ARM_FEATURE_AARCH64 ) && + !class_isar_feature (aa64_aa32, acc); + +if (!no_aa32) { +if (arm_class_feature (acc,ARM_FEATURE_V7VE )) { +assert (class_isar_feature (aa32_arm_div, acc)); + } +if (arm_class_feature (acc,ARM_FEATURE_V6 ) && + !arm_class_feature (acc,ARM_FEATURE_M )) { +assert (class_isar_feature (aa32_jazelle, acc)); + } + } + }return true; }
Signature · 1 line
2.34.1
RFC PATCH 31/40 target/arm: Get and set class properties in the monitor
In reply to Richard HendersonSetting is not actually functional here, because it is always done after the creation of the first object, and so will generate an error. But at least it's a different error than 'Property not found'.
--- target/arm/monitor.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-)
target/arm/monitor.c +16 -5
@@ -89,7 +89,7 @@ QEMU_BUILD_BUG_ON(ARM_MAX_VQ > 16);* will attempt to set them. If there are dependencies between features, * then the order that considers those dependencies must be used. */ -static const char *cpu_model_advertised_features[] = { +static const char *const cpu_model_advertised_features[] = {"aarch64" ,"pmu" ,"sve" ,"sve128" ,"sve256" ,"sve384" ,"sve512" ,"sve640" ,"sve768" ,"sve896" ,"sve1024" ,"sve1152" ,"sve1280" ,
@@ -159,7 +159,7 @@ CpuModelExpansionInfo *qmp_query_cpu_model_expansion(CpuModelExpansionType type, } } - obj =object_new (object_class_get_name (oc)); + obj =object_new_with_class (oc);if (qdict_in) {Visitor *visitor;
@@ -175,7 +175,10 @@ CpuModelExpansionInfo *qmp_query_cpu_model_expansion(CpuModelExpansionType type, i =0 ;while ((name = cpu_model_advertised_features[i++]) !=NULL ) {if (qdict_get (qdict_in, name)) { -if (!object_property_set (obj, name, visitor, &err)) { +ClassProperty *cp =class_property_find (oc, name); +if (cp + ? !class_property_set (oc, cp, visitor, &err) + : !object_property_set (obj, name, visitor, &err)) {break ; } }
@@ -207,12 +210,20 @@ CpuModelExpansionInfo *qmp_query_cpu_model_expansion(CpuModelExpansionType type, i =0 ;while ((name = cpu_model_advertised_features[i++]) !=NULL ) {ObjectProperty *prop =object_property_find (obj, name); -if (prop) { -QObject *value; +QObject *value =NULL ; +if (prop) {assert (prop->get); value =object_property_get_qobject (obj, name, &error_abort); + }else { +ClassProperty *cprop =class_property_find (oc, name); +if (cprop) { +assert (cprop->get); + value =class_property_get_qobject (oc, name, &error_abort); + } + } +if (value) {qdict_put_obj (qdict_out, name, value); } }
Signature · 1 line
2.34.1
RFC PATCH 32/40 target/arm: Move "midr" to class property
In reply to Richard HendersonWith the movement of the property, we can remove the field from the cpu entirely, using only the class.
--- target/arm/cpu.h | 1 - hw/arm/xilinx_zynq.c | 9 ++++++--- hw/intc/armv7m_nvic.c | 2 +- target/arm/cpu.c | 18 ++++++++++++++++-- target/arm/helper.c | 14 ++++++++------ 5 files changed, 31 insertions(+), 13 deletions(-)
target/arm/cpu.h +0 -1
@@ -956,7 +956,6 @@ struct ArchCPU {* field by reading the value from the KVM vCPU. */ ARMISARegisters isar; -uint64_t midr;uint32_t revidr;uint32_t reset_fpsid;uint64_t ctr;
hw/arm/xilinx_zynq.c +6 -3
@@ -177,6 +177,7 @@ static inline int zynq_init_spi_flashes(uint32_t base_addr, qemu_irq irq,static void zynq_init (MachineState *machine) {ZynqMachineState *zynq_machine =ZYNQ_MACHINE (machine); +ObjectClass *cpu_class;ARMCPU *cpu;MemoryRegion *address_space_mem =get_system_memory ();MemoryRegion *ocm_ram =g_new (MemoryRegion,1 );
@@ -191,7 +192,11 @@ static void zynq_init(MachineState *machine)exit (EXIT_FAILURE ); } - cpu =ARM_CPU (object_new (machine->cpu_type)); + cpu_class =object_class_by_name (machine->cpu_type); + +class_property_set_uint (cpu_class,"midr" ,ZYNQ_BOARD_MIDR , &error_fatal); + + cpu =ARM_CPU (object_new_with_class (cpu_class));/* By default A9 CPUs have EL3 enabled. This board does not * currently support EL3 so the CPU EL3 property is disabled before
@@ -201,8 +206,6 @@ static void zynq_init(MachineState *machine)object_property_set_bool (OBJECT (cpu),"has_el3" , false, &error_fatal); } -object_property_set_int (OBJECT (cpu),"midr" ,ZYNQ_BOARD_MIDR , - &error_fatal);object_property_set_int (OBJECT (cpu),"reset-cbar" ,MPCORE_PERIPHBASE , &error_fatal);qdev_realize (DEVICE (cpu),NULL , &error_fatal);
hw/intc/armv7m_nvic.c +1 -1
@@ -1039,7 +1039,7 @@ static uint32_t nvic_readl(NVICState *s, uint32_t offset, MemTxAttrs attrs) }return cpu->revidr;case 0xd00 :/* CPUID Base. */ -return cpu->midr; +return ARM_CPU_GET_CLASS (cpu)->midr;case 0xd04 :/* Interrupt Control State (ICSR) */ /* VECTACTIVE */ val = cpu->env.v7m.exception;
target/arm/cpu.c +16 -2
@@ -1209,7 +1209,6 @@ static void arm_cpu_initfn(Object *obj) cpu->env.features = acc->features; cpu->isar = acc->isar; - cpu->midr = acc->midr; cpu->ctr = acc->ctr; cpu->pmceid0 = acc->pmceid0; cpu->pmceid1 = acc->pmceid1;
@@ -2120,7 +2119,6 @@ static void cpu_arm_get_mp_affinity(Object *obj, Visitor *v, const char *name, }static Property arm_cpu_properties[] = { -DEFINE_PROP_UINT64 ("midr" ,ARMCPU , midr,0 ),DEFINE_PROP_INT32 ("node-id" ,ARMCPU , node_id,CPU_UNSET_NUMA_NODE_ID ),DEFINE_PROP_INT32 ("core-count" ,ARMCPU , core_count,-1 ),DEFINE_PROP_END_OF_LIST ()
@@ -2173,6 +2171,17 @@ static const struct TCGCPUOps arm_tcg_ops = { };#endif /* CONFIG_TCG */ +static bool arm_class_prop_uint64_ofs (ObjectClass *oc,Visitor *v, +const char *name,void *opaque, +Error **errp) +{ +ARMCPUClass *acc =ARM_CPU_CLASS (oc); +uintptr_t ofs = (uintptr_t )opaque; +uint64_t *ptr = (void *)acc + ofs; + +return visit_type_uint64 (v, name, ptr, errp); +} +static void arm_cpu_class_init (ObjectClass *oc,void *data) {ARMCPUClass *acc =ARM_CPU_CLASS (oc);
@@ -2220,6 +2229,11 @@ static void arm_cpu_class_init(ObjectClass *oc, void *data)*/ acc->dtb_compatible ="qemu,unknown" ; acc->kvm_target =QEMU_KVM_ARM_TARGET_NONE ; + +class_property_add (oc,"midr" ,"uint64" ,NULL , + arm_class_prop_uint64_ofs, + arm_class_prop_uint64_ofs, + (void *)(uintptr_t )offsetof(ARMCPUClass , midr)); }static void arm_cpu_leaf_class_init (ObjectClass *oc,void *data)
target/arm/helper.c +8 -6
@@ -7443,6 +7443,8 @@ void register_cp_regs_for_features(ARMCPU *cpu) {/* Register all the coprocessor registers based on feature bits */ CPUARMState *env = &cpu->env; +ARMCPUClass *acc =ARM_CPU_GET_CLASS (cpu); +if (arm_feature (env,ARM_FEATURE_M )) {/* M profile has no coprocessor registers */ return ;
@@ -7926,12 +7928,12 @@ void register_cp_regs_for_features(ARMCPU *cpu) { .name = "VPIDR", .state = ARM_CP_STATE_AA32, .cp = 15, .opc1 = 4, .crn = 0, .crm = 0, .opc2 = 0, .access = PL2_RW, .accessfn = access_el3_aa32ns, - .resetvalue = cpu->midr, + .resetvalue = acc->midr, .type = ARM_CP_ALIAS | ARM_CP_EL3_NO_EL2_C_NZ, .fieldoffset = offsetoflow32(CPUARMState, cp15.vpidr_el2) }, { .name = "VPIDR_EL2", .state = ARM_CP_STATE_AA64, .opc0 = 3, .opc1 = 4, .crn = 0, .crm = 0, .opc2 = 0, - .access = PL2_RW, .resetvalue = cpu->midr, + .access = PL2_RW, .resetvalue = acc->midr, .type = ARM_CP_EL3_NO_EL2_C_NZ, .fieldoffset = offsetof(CPUARMState, cp15.vpidr_el2) }, { .name = "VMPIDR", .state = ARM_CP_STATE_AA32,
@@ -8106,7 +8108,7 @@ void register_cp_regs_for_features(ARMCPU *cpu)*/ { .name = "MIDR", .cp = 15, .crn = 0, .crm = 0, .opc1 = 0, .opc2 = CP_ANY, - .access = PL1_R, .resetvalue = cpu->midr, + .access = PL1_R, .resetvalue = acc->midr, .writefn = arm_cp_write_ignore, .raw_writefn = raw_write, .readfn = midr_read, .fieldoffset = offsetof(CPUARMState, cp15.c0_cpuid),
@@ -8131,16 +8133,16 @@ void register_cp_regs_for_features(ARMCPU *cpu)ARMCPRegInfo id_v8_midr_cp_reginfo[] = { { .name ="MIDR_EL1" , .state =ARM_CP_STATE_BOTH , .opc0 =3 , .opc1 =0 , .crn =0 , .crm =0 , .opc2 =0 , - .access =PL1_R , .type =ARM_CP_NO_RAW , .resetvalue = cpu->midr, + .access =PL1_R , .type =ARM_CP_NO_RAW , .resetvalue = acc->midr, .fieldoffset = offsetof(CPUARMState, cp15.c0_cpuid), .readfn = midr_read },/* crn = 0 op1 = 0 crm = 0 op2 = 4,7 : AArch32 aliases of MIDR */ { .name ="MIDR" , .type =ARM_CP_ALIAS |ARM_CP_CONST , .cp =15 , .crn =0 , .crm =0 , .opc1 =0 , .opc2 =4 , - .access =PL1_R , .resetvalue = cpu->midr }, + .access =PL1_R , .resetvalue = acc->midr }, { .name ="MIDR" , .type =ARM_CP_ALIAS |ARM_CP_CONST , .cp =15 , .crn =0 , .crm =0 , .opc1 =0 , .opc2 =7 , - .access =PL1_R , .resetvalue = cpu->midr }, + .access =PL1_R , .resetvalue = acc->midr }, { .name ="REVIDR_EL1" , .state =ARM_CP_STATE_BOTH , .opc0 =3 , .opc1 =0 , .crn =0 , .crm =0 , .opc2 =6 , .access =PL1_R ,
Signature · 1 line
2.34.1
Re: [RFC PATCH 32/40] target/arm: Move "midr" to class property
Quoted 11 lines · Richard Henderson
With the movement of the property, we can remove the field from the cpu entirely, using only the class.
Signed-off-by Richard Henderson <[email protected]>--- target/arm/cpu.h | 1 - hw/arm/xilinx_zynq.c | 9 ++++++--- hw/intc/armv7m_nvic.c | 2 +- target/arm/cpu.c | 18 ++++++++++++++++-- target/arm/helper.c | 14 ++++++++------ 5 files changed, 31 insertions(+), 13 deletions(-)
Lovely.
Perhaps later arm_class_prop_uint64_ofs() can grow into a generic QOM TYPE macro.
RFC PATCH 33/40 target/arm: Move "cntfrq" to class property
In reply to Richard HendersonWith the movement of the property, we can remove the field from the cpu entirely, using only the class.
--- target/arm/cpu-qom.h | 3 +++ target/arm/cpu.h | 3 --- hw/arm/aspeed_ast2600.c | 6 +++-- target/arm/cpu.c | 50 +++++++++++++++++++++++------------------ target/arm/helper.c | 3 ++- 5 files changed, 37 insertions(+), 28 deletions(-)
target/arm/cpu-qom.h +3 -0
@@ -154,6 +154,9 @@ struct ARMCPUClass {*/ uint64_t ccsidr[16 ]; +/* Generic timer counter frequency, in Hz */ +uint64_t gt_cntfrq_hz; +uint32_t revidr;uint32_t id_afr0;uint32_t reset_fpsid;
target/arm/cpu.h +0 -3
@@ -1019,9 +1019,6 @@ struct ArchCPU {ARMVQMap sve_vq;ARMVQMap sme_vq; - -/* Generic timer counter frequency, in Hz */ -uint64_t gt_cntfrq_hz; };unsigned int gt_cntfrq_period_ns (ARMCPU *cpu);
hw/arm/aspeed_ast2600.c +4 -2
@@ -145,6 +145,7 @@ static void aspeed_soc_ast2600_init(Object *obj) {AspeedSoCState *s =ASPEED_SOC (obj);AspeedSoCClass *sc =ASPEED_SOC_GET_CLASS (s); +ObjectClass *cpu_class;int i;char socname[8 ];char typename[64 ];
@@ -153,6 +154,9 @@ static void aspeed_soc_ast2600_init(Object *obj)g_assert_not_reached (); } + cpu_class =object_class_by_name (sc->cpu_type); +class_property_set_uint (cpu_class,"cntfrq" ,1125000000 , &error_abort); +for (i =0 ; i < sc->num_cpus; i++) {object_initialize_child (obj,"cpu[*]" , &s->cpu[i], sc->cpu_type); }
@@ -305,8 +309,6 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp)object_property_set_int (OBJECT (&s->cpu[i]),"mp-affinity" ,aspeed_calc_affinity (i), &error_abort); -object_property_set_int (OBJECT (&s->cpu[i]),"cntfrq" ,1125000000 , - &error_abort);object_property_set_bool (OBJECT (&s->cpu[i]),"neon" , false, &error_abort); object_property_set_link(OBJECT(&s->cpu[i]), "memory",
target/arm/cpu.c +28 -22
98 lines not on this page · raw message
target/arm/helper.c +2 -1
@@ -2977,8 +2977,9 @@ void arm_gt_hvtimer_cb(void *opaque)static void arm_gt_cntfrq_reset (CPUARMState *env,const ARMCPRegInfo *opaque) {ARMCPU *cpu =env_archcpu (env); +ARMCPUClass *acc =ARM_CPU_GET_CLASS (cpu); - cpu->env.cp15.c14_cntfrq = cpu->gt_cntfrq_hz; + cpu->env.cp15.c14_cntfrq = acc->gt_cntfrq_hz; }static const ARMCPRegInfo generic_timer_cp_reginfo[] = {
Signature · 1 line
2.34.1
Re: [RFC PATCH 33/40] target/arm: Move "cntfrq" to class property
Quoted 14 lines · Richard Henderson
With the movement of the property, we can remove the field from the cpu entirely, using only the class.
Signed-off-by Richard Henderson <[email protected]>--- target/arm/cpu-qom.h | 3 +++ target/arm/cpu.h | 3 --- hw/arm/aspeed_ast2600.c | 6 +++-- target/arm/cpu.c | 50 +++++++++++++++++++++++------------------ target/arm/helper.c | 3 ++- 5 files changed, 37 insertions(+), 28 deletions(-)
target/arm/cpu.c static bool arm_cpu_class_late_init(ObjectClass *oc, Error **errp) · line 2322
Quoted 5 lines
target/arm/cpu.c +2
-0@@ -2320,6 +2318,14 @@ static bool arm_cpu_class_late_init(ObjectClass *oc, Error **errp) } } +#ifndef CONFIG_USER_ONLY +/* TODO: Perhaps better to put this check in a property set hook. */
Quoted 5 lines
target/arm/cpu.c +5
-0+if (!acc->gt_cntfrq_hz) { +error_setg (errp,"Invalid CNTFRQ: %" PRId64"Hz" , acc->gt_cntfrq_hz); +return false; + } +#endif /* CONFIG_USER_ONLY */
RFC PATCH 34/40 target/arm: Move "reset-hivecs" to class property
In reply to Richard HendersonRemove the reset_hivecs variable entirely and create property accessor functions that directly read/write a bit of the reset value of SCTLR.
--- target/arm/cpu.h | 1 - hw/arm/digic.c | 11 ++++----- hw/arm/npcm7xx.c | 9 ++++---- hw/arm/xlnx-zynqmp.c | 11 +++++---- target/arm/cpu.c | 55 +++++++++++++++++++++++++++++++++----------- 5 files changed, 59 insertions(+), 28 deletions(-)
target/arm/cpu.h +0 -1
@@ -973,7 +973,6 @@ struct ArchCPU {uint64_t ccsidr[16 ];uint64_t reset_cbar;uint32_t reset_auxcr; -bool reset_hivecs;/* * Intermediate values used during property parsing.
hw/arm/digic.c +5 -6
@@ -34,9 +34,13 @@static void digic_init (Object *obj) {DigicState *s =DIGIC (obj); +const char *cpu_type =ARM_CPU_TYPE_NAME ("arm946" ); +ObjectClass *cpu_class =object_class_by_name (cpu_type);int i; -object_initialize_child (obj,"cpu" , &s->cpu,ARM_CPU_TYPE_NAME ("arm946" )); +class_property_set_bool (cpu_class,"reset-hivecs" , true, &error_abort); + +object_initialize_child (obj,"cpu" , &s->cpu, cpu_type);for (i =0 ; i <DIGIC4_NB_TIMERS ; i++) { g_autofree char *name = g_strdup_printf("timer[%d]", i);
@@ -52,11 +56,6 @@ static void digic_realize(DeviceState *dev, Error **errp)SysBusDevice *sbd;int i; -if (!object_property_set_bool (OBJECT (&s->cpu),"reset-hivecs" , true, - errp)) { -return ; - } -if (!qdev_realize (DEVICE (&s->cpu),NULL , errp)) {return ; }
hw/arm/npcm7xx.c +5 -4
@@ -390,11 +390,14 @@ static qemu_irq npcm7xx_irq(NPCM7xxState *s, int n)static void npcm7xx_init (Object *obj) {NPCM7xxState *s =NPCM7XX (obj); +const char *cpu_type =ARM_CPU_TYPE_NAME ("cortex-a9" ); +ObjectClass *cpu_class =object_class_by_name (cpu_type);int i; +class_property_set_bool (cpu_class,"reset-hivecs" , true, &error_abort); +for (i =0 ; i <NPCM7XX_MAX_NUM_CPUS ; i++) { -object_initialize_child (obj,"cpu[*]" , &s->cpu[i], -ARM_CPU_TYPE_NAME ("cortex-a9" )); +object_initialize_child (obj,"cpu[*]" , &s->cpu[i], cpu_type); }object_initialize_child (obj,"a9mpcore" , &s->a9mpcore,TYPE_A9MPCORE_PRIV );
@@ -466,8 +469,6 @@ static void npcm7xx_realize(DeviceState *dev, Error **errp) &error_abort);object_property_set_int (OBJECT (&s->cpu[i]),"reset-cbar" ,NPCM7XX_GIC_CPU_IF_ADDR , &error_abort); -object_property_set_bool (OBJECT (&s->cpu[i]),"reset-hivecs" , true, - &error_abort);/* Disable security extensions. */ object_property_set_bool(OBJECT(&s->cpu[i]), "has_el3", false,
hw/arm/xlnx-zynqmp.c +7 -4
@@ -243,8 +243,6 @@ static void xlnx_zynqmp_create_rpu(MachineState *ms, XlnxZynqMPState *s, s->boot_cpu_ptr = &s->rpu_cpu[i]; } -object_property_set_bool (OBJECT (&s->rpu_cpu[i]),"reset-hivecs" , true, - &error_abort);if (!qdev_realize (DEVICE (&s->rpu_cpu[i]),NULL , errp)) {return ; }
@@ -375,6 +373,8 @@ static void xlnx_zynqmp_init(Object *obj) {MachineState *ms =MACHINE (qdev_get_machine ());XlnxZynqMPState *s =XLNX_ZYNQMP (obj); +const char *cpu_type; +ObjectClass *cpu_class;int i;int num_apus =MIN (ms->smp.cpus,XLNX_ZYNQMP_NUM_APU_CPUS );
@@ -382,10 +382,13 @@ static void xlnx_zynqmp_init(Object *obj) TYPE_CPU_CLUSTER);qdev_prop_set_uint32 (DEVICE (&s->apu_cluster),"cluster-id" ,0 ); + cpu_type =ARM_CPU_TYPE_NAME ("cortex-a53" ); + cpu_class =object_class_by_name (cpu_type); +class_property_set_bool (cpu_class,"reset-hivecs" , true, &error_abort); +for (i =0 ; i < num_apus; i++) {object_initialize_child (OBJECT (&s->apu_cluster),"apu-cpu[*]" , - &s->apu_cpu[i], -ARM_CPU_TYPE_NAME ("cortex-a53" )); + &s->apu_cpu[i], cpu_type); }object_initialize_child (obj,"gic" , &s->gic,gic_class_name ());
target/arm/cpu.c +42 -13
91 lines not on this page · raw message
Signature · 1 line
2.34.1
RFC PATCH 35/40 target/arm: Move "has_el2" to class property
In reply to Richard HendersonWith the movement of the property, we can remove the field from the cpu entirely, using only the class. However, late initialization of the "max" cpu, due to its interaction with "host", means that we cannot leave the class property undefined when EL2 is not supported. Adjust the class field to OnOffAuto and generate an error if enabled when not supported.
--- target/arm/cpu-qom.h | 4 +++ target/arm/cpu.h | 3 -- hw/arm/allwinner-h3.c | 9 ++++-- hw/arm/vexpress.c | 10 +++--- hw/arm/virt.c | 22 ++++++++----- hw/arm/xlnx-zynqmp.c | 3 +- hw/cpu/a15mpcore.c | 9 +++--- target/arm/cpu.c | 74 ++++++++++++++++++++++++++++++++++++------- 8 files changed, 98 insertions(+), 36 deletions(-)
target/arm/cpu-qom.h +4 -0
@@ -22,6 +22,7 @@#include "hw/core/cpu.h" #include "qom/object.h" +#include "qapi/qapi-types-common.h" struct arm_boot_info ;
@@ -182,6 +183,9 @@ struct ARMCPUClass {* QEMU_KVM_ARM_TARGET_NONE if the kernel doesn't support this CPU type. */ uint32_t kvm_target; + +/* CPU has virtualization extension */ +OnOffAuto has_el2; };static inline int arm_class_feature (ARMCPUClass *acc,int feature)
target/arm/cpu.h +0 -3
@@ -25,7 +25,6 @@#include "hw/registerfields.h" #include "cpu-qom.h" #include "exec/cpu-defs.h" -#include "qapi/qapi-types-common.h" /* ARM processors have a weak memory model */ #define TCG_GUEST_DEFAULT_MO (0)
@@ -887,8 +886,6 @@ struct ArchCPU {/* Current power state, access guarded by BQL */ ARMPSCIState power_state; -/* CPU has virtualization extension */ -bool has_el2;/* CPU has security extension */ bool has_el3;/* CPU has PMU (Performance Monitor Unit) */
hw/arm/allwinner-h3.c +6 -3
@@ -188,12 +188,16 @@ void allwinner_h3_bootrom_setup(AwH3State *s, BlockBackend *blk)static void allwinner_h3_init (Object *obj) {AwH3State *s =AW_H3 (obj); +const char *cpu_type =ARM_CPU_TYPE_NAME ("cortex-a7" ); +ObjectClass *cpu_class =object_class_by_name (cpu_type); s->memmap = allwinner_h3_memmap; +/* ??? This is the default for A7. */ +class_property_set_bool (cpu_class,"has_el2" , true, &error_abort); +for (int i =0 ; i <AW_H3_NUM_CPUS ; i++) { -object_initialize_child (obj,"cpu[*]" , &s->cpus[i], -ARM_CPU_TYPE_NAME ("cortex-a7" )); +object_initialize_child (obj,"cpu[*]" , &s->cpus[i], cpu_type); }object_initialize_child (obj,"gic" , &s->gic,TYPE_ARM_GIC );
@@ -244,7 +248,6 @@ static void allwinner_h3_realize(DeviceState *dev, Error **errp)/* All exception levels required */ qdev_prop_set_bit (DEVICE (&s->cpus[i]),"has_el3" , true); -qdev_prop_set_bit (DEVICE (&s->cpus[i]),"has_el2" , true);/* Mark realized */ qdev_realize (DEVICE (&s->cpus[i]),NULL , &error_fatal);
hw/arm/vexpress.c +5 -5
@@ -208,6 +208,11 @@ static void init_cpus(MachineState *ms, const char *cpu_type,SysBusDevice *busdev;int n;unsigned int smp_cpus = ms->smp.cpus; +ObjectClass *cpu_class =object_class_by_name (cpu_type); + +if (!virt) { +class_property_set_bool (cpu_class,"has_el2" , false,NULL ); + }/* Create the actual CPUs */ for (n =0 ; n < smp_cpus; n++) {
@@ -216,11 +221,6 @@ static void init_cpus(MachineState *ms, const char *cpu_type,if (!secure) {object_property_set_bool (cpuobj,"has_el3" , false,NULL ); } -if (!virt) { -if (object_property_find (cpuobj,"has_el2" )) { -object_property_set_bool (cpuobj,"has_el2" , false,NULL ); - } - }if (object_property_find (cpuobj,"reset-cbar" )) { object_property_set_int(cpuobj, "reset-cbar", periphbase,
hw/arm/virt.c +14 -8
@@ -2018,6 +2018,7 @@ static void machvirt_init(MachineState *machine)MemoryRegion *secure_sysmem =NULL ;MemoryRegion *tag_sysmem =NULL ;MemoryRegion *secure_tag_sysmem =NULL ; +ObjectClass *cpu_class;int n, virt_max_cpus;bool firmware_loaded;bool aarch64 = true;
@@ -2032,6 +2033,16 @@ static void machvirt_init(MachineState *machine) possible_cpus = mc->possible_cpu_arch_ids (machine); +assert (possible_cpus->len == max_cpus); +for (n =0 ; n < max_cpus; n++) { +assert (strcmp (machine->cpu_type, possible_cpus->cpus[n].type) ==0 ); + } + + cpu_class =object_class_by_name (machine->cpu_type); +if (!vms->virt) { +class_property_set_bool (cpu_class,"has_el2" , false, &error_abort); + } +/* * In accelerated mode, the memory map is computed earlier in kvm_type() * to create a VM with the right number of IPA bits.
@@ -2046,7 +2057,7 @@ static void machvirt_init(MachineState *machine)* we are about to deal with. Once this is done, get rid of * the object. */ - cpuobj =object_new (possible_cpus->cpus[0 ].type); + cpuobj =object_new_with_class (cpu_class); armcpu =ARM_CPU (cpuobj); pa_bits =arm_pamax (armcpu);
@@ -2143,8 +2154,7 @@ static void machvirt_init(MachineState *machine)create_fdt (vms); -assert (possible_cpus->len == max_cpus); -for (n =0 ; n < possible_cpus->len; n++) { +for (n =0 ; n < max_cpus; n++) {Object *cpuobj;CPUState *cs;
@@ -2152,7 +2162,7 @@ static void machvirt_init(MachineState *machine)break ; } - cpuobj =object_new (possible_cpus->cpus[n].type); + cpuobj =object_new_with_class (cpu_class);object_property_set_int (cpuobj,"mp-affinity" , possible_cpus->cpus[n].arch_id,NULL );
@@ -2168,10 +2178,6 @@ static void machvirt_init(MachineState *machine)object_property_set_bool (cpuobj,"has_el3" , false,NULL ); } -if (!vms->virt &&object_property_find (cpuobj,"has_el2" )) { -object_property_set_bool (cpuobj,"has_el2" , false,NULL ); - } -if (vmc->kvm_no_adjvtime &&object_property_find (cpuobj,"kvm-no-adjvtime" )) {object_property_set_bool (cpuobj,"kvm-no-adjvtime" , true,NULL );
hw/arm/xlnx-zynqmp.c +1 -2
@@ -385,6 +385,7 @@ static void xlnx_zynqmp_init(Object *obj) cpu_type =ARM_CPU_TYPE_NAME ("cortex-a53" ); cpu_class =object_class_by_name (cpu_type);class_property_set_bool (cpu_class,"reset-hivecs" , true, &error_abort); +class_property_set_bool (cpu_class,"has_el2" , s->virt, &error_abort);for (i =0 ; i < num_apus; i++) { object_initialize_child(OBJECT(&s->apu_cluster), "apu-cpu[*]",
@@ -529,8 +530,6 @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp)object_property_set_bool (OBJECT (&s->apu_cpu[i]),"has_el3" , s->secure,NULL ); -object_property_set_bool (OBJECT (&s->apu_cpu[i]),"has_el2" , s->virt, -NULL );object_property_set_int (OBJECT (&s->apu_cpu[i]),"reset-cbar" ,GIC_BASE_ADDR , &error_abort); object_property_set_int(OBJECT(&s->apu_cpu[i]), "core-count",
hw/cpu/a15mpcore.c +5 -4
@@ -55,7 +55,6 @@ static void a15mp_priv_realize(DeviceState *dev, Error **errp)int i;bool has_el3;bool has_el2 = false; -Object *cpuobj; gicdev =DEVICE (&s->gic);qdev_prop_set_uint32 (gicdev,"num-cpu" , s->num_cpu);
@@ -65,13 +64,15 @@ static void a15mp_priv_realize(DeviceState *dev, Error **errp)/* Make the GIC's TZ support match the CPUs. We assume that * either all the CPUs have TZ, or none do. */ - cpuobj =OBJECT (qemu_get_cpu (0 )); +Object *cpuobj =OBJECT (qemu_get_cpu (0 )); +ObjectClass *cpucls =object_get_class (cpuobj); + has_el3 =object_property_find (cpuobj,"has_el3" ) &&object_property_get_bool (cpuobj,"has_el3" , &error_abort);qdev_prop_set_bit (gicdev,"has-security-extensions" , has_el3); +/* Similarly for virtualization support */ - has_el2 =object_property_find (cpuobj,"has_el2" ) && -object_property_get_bool (cpuobj,"has_el2" , &error_abort); + has_el2 =class_property_get_bool (cpucls,"has_el2" ,NULL );qdev_prop_set_bit (gicdev,"has-virtualization-extensions" , has_el2); }
target/arm/cpu.c +63 -11
110 lines not on this page · raw message
Signature · 1 line
2.34.1
RFC PATCH 36/40 target/arm: Move "has_el3" to class property
In reply to Richard HendersonWith the movement of the property, we can remove the field from the cpu entirely, using only the class.
--- target/arm/cpu-qom.h | 2 ++ target/arm/cpu.h | 2 -- hw/arm/allwinner-h3.c | 5 ++- hw/arm/exynos4210.c | 18 +++++----- hw/arm/integratorcp.c | 12 ++++--- hw/arm/npcm7xx.c | 5 +-- hw/arm/realview.c | 20 +++++------ hw/arm/versatilepb.c | 12 ++++--- hw/arm/vexpress.c | 9 +++-- hw/arm/virt.c | 5 +-- hw/arm/xilinx_zynq.c | 14 ++++---- hw/arm/xlnx-zynqmp.c | 3 +- hw/cpu/a15mpcore.c | 5 ++- hw/cpu/a9mpcore.c | 6 ++-- target/arm/cpu.c | 78 +++++++++++++++++++++++++------------------ 15 files changed, 102 insertions(+), 94 deletions(-)
target/arm/cpu-qom.h +2 -0
@@ -184,6 +184,8 @@ struct ARMCPUClass {*/ uint32_t kvm_target; +/* CPU has security extension */ +OnOffAuto has_el3;/* CPU has virtualization extension */ OnOffAuto has_el2; };
target/arm/cpu.h +0 -2
@@ -886,8 +886,6 @@ struct ArchCPU {/* Current power state, access guarded by BQL */ ARMPSCIState power_state; -/* CPU has security extension */ -bool has_el3;/* CPU has PMU (Performance Monitor Unit) */ bool has_pmu;/* CPU has VFP */
hw/arm/allwinner-h3.c +2 -3
@@ -193,7 +193,9 @@ static void allwinner_h3_init(Object *obj) s->memmap = allwinner_h3_memmap; +/* All exception levels required. */ /* ??? This is the default for A7. */ +class_property_set_bool (cpu_class,"has_el3" , true, &error_abort);class_property_set_bool (cpu_class,"has_el2" , true, &error_abort);for (int i =0 ; i <AW_H3_NUM_CPUS ; i++) {
@@ -246,9 +248,6 @@ static void allwinner_h3_realize(DeviceState *dev, Error **errp)qdev_prop_set_bit (DEVICE (&s->cpus[i]),"start-powered-off" , i >0 ); -/* All exception levels required */ -qdev_prop_set_bit (DEVICE (&s->cpus[i]),"has_el3" , true); -/* Mark realized */ qdev_realize (DEVICE (&s->cpus[i]),NULL , &error_fatal); }
hw/arm/exynos4210.c +10 -8
@@ -548,18 +548,20 @@ static void exynos4210_realize(DeviceState *socdev, Error **errp)Exynos4210State *s =EXYNOS4210_SOC (socdev);MemoryRegion *system_mem =get_system_memory ();SysBusDevice *busdev; +ObjectClass *cpu_class;DeviceState *dev, *uart[4 ], *pl330[3 ];int i, n; -for (n =0 ; n <EXYNOS4210_NCPUS ; n++) { -Object *cpuobj =object_new (ARM_CPU_TYPE_NAME ("cortex-a9" )); + cpu_class =object_class_by_name (ARM_CPU_TYPE_NAME ("cortex-a9" )); -/* By default A9 CPUs have EL3 enabled. This board does not currently -* support EL3 so the CPU EL3 property is disabled before realization. -*/ -if (object_property_find (cpuobj,"has_el3" )) { -object_property_set_bool (cpuobj,"has_el3" , false, &error_fatal); - } +/* +* By default A9 CPUs have EL3 enabled. This board does not currently +* support EL3 so the CPU EL3 property is disabled. +*/ +class_property_set_bool (cpu_class,"has_el3" , false, &error_abort); + +for (n =0 ; n <EXYNOS4210_NCPUS ; n++) { +Object *cpuobj =object_new_with_class (cpu_class); s->cpu[n] =ARM_CPU (cpuobj); object_property_set_int(cpuobj, "mp-affinity",
hw/arm/integratorcp.c +7 -5
@@ -595,17 +595,19 @@ static void integratorcp_init(MachineState *machine)qemu_irq pic[32 ];DeviceState *dev, *sic, *icp;DriveInfo *dinfo; +ObjectClass *cpu_class;int i; - cpuobj =object_new (machine->cpu_type); + cpu_class =object_class_by_name (machine->cpu_type); -/* By default ARM1176 CPUs have EL3 enabled. This board does not +/* +* By default ARM1176 CPUs have EL3 enabled. This board does not * currently support EL3 so the CPU EL3 property is disabled before * realization. */ -if (object_property_find (cpuobj,"has_el3" )) { -object_property_set_bool (cpuobj,"has_el3" , false, &error_fatal); - } +class_property_set_bool (cpu_class,"has_el3" , false,NULL ); + + cpuobj =object_new_with_class (cpu_class);qdev_realize (DEVICE (cpuobj),NULL , &error_fatal);
hw/arm/npcm7xx.c +1 -4
@@ -395,6 +395,7 @@ static void npcm7xx_init(Object *obj)int i;class_property_set_bool (cpu_class,"reset-hivecs" , true, &error_abort); +class_property_set_bool (cpu_class,"has_el3" , false, &error_abort);for (i =0 ; i <NPCM7XX_MAX_NUM_CPUS ; i++) {object_initialize_child (obj,"cpu[*]" , &s->cpu[i], cpu_type);
@@ -470,10 +471,6 @@ static void npcm7xx_realize(DeviceState *dev, Error **errp)object_property_set_int (OBJECT (&s->cpu[i]),"reset-cbar" ,NPCM7XX_GIC_CPU_IF_ADDR , &error_abort); -/* Disable security extensions. */ -object_property_set_bool (OBJECT (&s->cpu[i]),"has_el3" , false, - &error_abort); -if (!qdev_realize (DEVICE (&s->cpu[i]),NULL , errp)) {return ; }
hw/arm/realview.c +10 -10
@@ -81,6 +81,7 @@ static void realview_init(MachineState *machine,MemoryRegion *ram_hack =g_new (MemoryRegion,1 );DeviceState *dev, *sysctl, *gpio2, *pl041;SysBusDevice *busdev; +ObjectClass *cpu_class;qemu_irq pic[64 ];PCIBus *pci_bus =NULL ;NICInfo *nd;
@@ -115,22 +116,21 @@ static void realview_init(MachineState *machine,break ; } -for (n =0 ; n < smp_cpus; n++) { -Object *cpuobj =object_new (machine->cpu_type); + cpu_class =object_class_by_name (machine->cpu_type); +/* +* By default A9, A15 and ARM1176 CPUs have EL3 enabled. This board +* does not currently support EL3 so the CPU EL3 property is disabled +* before realization. +*/ +class_property_set_bool (cpu_class,"has_el3" , false,NULL ); -/* By default A9,A15 and ARM1176 CPUs have EL3 enabled. This board -* does not currently support EL3 so the CPU EL3 property is disabled -* before realization. -*/ -if (object_property_find (cpuobj,"has_el3" )) { -object_property_set_bool (cpuobj,"has_el3" , false, &error_fatal); - } +for (n =0 ; n < smp_cpus; n++) { +Object *cpuobj =object_new_with_class (cpu_class);if (is_pb && is_mpcore) {object_property_set_int (cpuobj,"reset-cbar" , periphbase, &error_fatal); } -qdev_realize (DEVICE (cpuobj),NULL , &error_fatal); cpu_irq[n] =qdev_get_gpio_in (DEVICE (cpuobj),ARM_CPU_IRQ );
hw/arm/versatilepb.c +7 -5
@@ -182,6 +182,7 @@ static struct arm_boot_info versatile_binfo;static void versatile_init (MachineState *machine,int board_id) { +ObjectClass *cpu_class;Object *cpuobj;ARMCPU *cpu;MemoryRegion *sysmem =get_system_memory ();
@@ -206,15 +207,16 @@ static void versatile_init(MachineState *machine, int board_id)exit (1 ); } - cpuobj =object_new (machine->cpu_type); + cpu_class =object_class_by_name (machine->cpu_type); -/* By default ARM1176 CPUs have EL3 enabled. This board does not +/* +* By default ARM1176 CPUs have EL3 enabled. This board does not * currently support EL3 so the CPU EL3 property is disabled before * realization. */ -if (object_property_find (cpuobj,"has_el3" )) { -object_property_set_bool (cpuobj,"has_el3" , false, &error_fatal); - } +class_property_set_bool (cpu_class,"has_el3" , false,NULL ); + + cpuobj =object_new_with_class (cpu_class);qdev_realize (DEVICE (cpuobj),NULL , &error_fatal);
hw/arm/vexpress.c +4 -5
@@ -210,17 +210,16 @@ static void init_cpus(MachineState *ms, const char *cpu_type,unsigned int smp_cpus = ms->smp.cpus;ObjectClass *cpu_class =object_class_by_name (cpu_type); +if (!secure) { +class_property_set_bool (cpu_class,"has_el3" , false,NULL ); + }if (!virt) {class_property_set_bool (cpu_class,"has_el2" , false,NULL ); }/* Create the actual CPUs */ for (n =0 ; n < smp_cpus; n++) { -Object *cpuobj =object_new (cpu_type); - -if (!secure) { -object_property_set_bool (cpuobj,"has_el3" , false,NULL ); - } +Object *cpuobj =object_new_with_class (cpu_class);if (object_property_find (cpuobj,"reset-cbar" )) { object_property_set_int(cpuobj, "reset-cbar", periphbase,
hw/arm/virt.c +1 -4
@@ -2039,6 +2039,7 @@ static void machvirt_init(MachineState *machine) } cpu_class =object_class_by_name (machine->cpu_type); +class_property_set_bool (cpu_class,"has_el3" , vms->secure, &error_abort);if (!vms->virt) {class_property_set_bool (cpu_class,"has_el2" , false, &error_abort); }
@@ -2174,10 +2175,6 @@ static void machvirt_init(MachineState *machine) aarch64 &=object_property_get_bool (cpuobj,"aarch64" ,NULL ); -if (!vms->secure) { -object_property_set_bool (cpuobj,"has_el3" , false,NULL ); - } -if (vmc->kvm_no_adjvtime &&object_property_find (cpuobj,"kvm-no-adjvtime" )) {object_property_set_bool (cpuobj,"kvm-no-adjvtime" , true,NULL );
hw/arm/xilinx_zynq.c +6 -8
@@ -194,17 +194,15 @@ static void zynq_init(MachineState *machine) cpu_class =object_class_by_name (machine->cpu_type); -class_property_set_uint (cpu_class,"midr" ,ZYNQ_BOARD_MIDR , &error_fatal); - - cpu =ARM_CPU (object_new_with_class (cpu_class)); - -/* By default A9 CPUs have EL3 enabled. This board does not +/* +* By default A9 CPUs have EL3 enabled. This board does not * currently support EL3 so the CPU EL3 property is disabled before * realization. */ -if (object_property_find (OBJECT (cpu),"has_el3" )) { -object_property_set_bool (OBJECT (cpu),"has_el3" , false, &error_fatal); - } +class_property_set_bool (cpu_class,"has_el3" , false, &error_abort); +class_property_set_uint (cpu_class,"midr" ,ZYNQ_BOARD_MIDR , &error_abort); + + cpu =ARM_CPU (object_new_with_class (cpu_class));object_property_set_int (OBJECT (cpu),"reset-cbar" ,MPCORE_PERIPHBASE , &error_fatal);
hw/arm/xlnx-zynqmp.c +1 -2
@@ -385,6 +385,7 @@ static void xlnx_zynqmp_init(Object *obj) cpu_type =ARM_CPU_TYPE_NAME ("cortex-a53" ); cpu_class =object_class_by_name (cpu_type);class_property_set_bool (cpu_class,"reset-hivecs" , true, &error_abort); +class_property_set_bool (cpu_class,"has_el3" , s->secure, &error_abort);class_property_set_bool (cpu_class,"has_el2" , s->virt, &error_abort);for (i =0 ; i < num_apus; i++) {
@@ -528,8 +529,6 @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp) s->boot_cpu_ptr = &s->apu_cpu[i]; } -object_property_set_bool (OBJECT (&s->apu_cpu[i]),"has_el3" , s->secure, -NULL );object_property_set_int (OBJECT (&s->apu_cpu[i]),"reset-cbar" ,GIC_BASE_ADDR , &error_abort); object_property_set_int(OBJECT(&s->apu_cpu[i]), "core-count",
hw/cpu/a15mpcore.c +2 -3
@@ -53,7 +53,6 @@ static void a15mp_priv_realize(DeviceState *dev, Error **errp)DeviceState *gicdev;SysBusDevice *busdev;int i; -bool has_el3;bool has_el2 = false; gicdev =DEVICE (&s->gic);
@@ -66,9 +65,9 @@ static void a15mp_priv_realize(DeviceState *dev, Error **errp)*/ Object *cpuobj =OBJECT (qemu_get_cpu (0 ));ObjectClass *cpucls =object_get_class (cpuobj); +bool has_el3; - has_el3 =object_property_find (cpuobj,"has_el3" ) && -object_property_get_bool (cpuobj,"has_el3" , &error_abort); + has_el3 =class_property_get_bool (cpucls,"has_el3" ,NULL );qdev_prop_set_bit (gicdev,"has-security-extensions" , has_el3);/* Similarly for virtualization support */
hw/cpu/a9mpcore.c +4 -2
@@ -55,9 +55,12 @@ static void a9mp_priv_realize(DeviceState *dev, Error **errp)bool has_el3;CPUState *cpu0;Object *cpuobj; +ObjectClass *cpucls; cpu0 =qemu_get_cpu (0 ); cpuobj =OBJECT (cpu0); + cpucls =object_get_class (cpuobj); +if (strcmp (object_get_typename (cpuobj),ARM_CPU_TYPE_NAME ("cortex-a9" ))) {/* We might allow Cortex-A5 once we model it */ error_setg(errp,
@@ -81,8 +84,7 @@ static void a9mp_priv_realize(DeviceState *dev, Error **errp)/* Make the GIC's TZ support match the CPUs. We assume that * either all the CPUs have TZ, or none do. */ - has_el3 =object_property_find (cpuobj,"has_el3" ) && -object_property_get_bool (cpuobj,"has_el3" , &error_abort); + has_el3 =class_property_get_bool (cpucls,"has_el3" , &error_abort);qdev_prop_set_bit (gicdev,"has-security-extensions" , has_el3);if (!sysbus_realize (SYS_BUS_DEVICE (&s->gic), errp)) {
target/arm/cpu.c +45 -33
120 lines not on this page · raw message
Signature · 1 line
2.34.1
RFC PATCH 37/40 target/arm: Move "cfgend" to class property
In reply to Richard HendersonRemove the cfgend variable entirely and reuse the property accessor functions created for reset-hivecs. This removes the last setting of cpu->reset_sctlr, to we can remove that as well, using only the class value.
--- target/arm/cpu.h | 8 -------- target/arm/cpu.c | 26 ++++++++++++-------------- target/arm/helper.c | 4 ++-- 3 files changed, 14 insertions(+), 24 deletions(-)
target/arm/cpu.h +0 -8
@@ -954,7 +954,6 @@ struct ArchCPU {uint32_t revidr;uint32_t reset_fpsid;uint64_t ctr; -uint32_t reset_sctlr;uint64_t pmceid0;uint64_t pmceid1;uint32_t id_afr0;
@@ -987,13 +986,6 @@ struct ArchCPU {int gic_vprebits;/* number of virtual preemption bits */ int gic_pribits;/* number of physical priority bits */ -/* Whether the cfgend input is high (i.e. this CPU should reset into -* big-endian mode). This setting isn't used directly: instead it modifies -* the reset_sctlr value to have SCTLR_B or SCTLR_EE set, depending on the -* architecture version. -*/ -bool cfgend; - QLIST_HEAD(, ARMELChangeHook) pre_el_change_hooks; QLIST_HEAD(, ARMELChangeHook) el_change_hooks;
target/arm/cpu.c +12 -14
@@ -1222,7 +1222,6 @@ static void arm_cpu_initfn(Object *obj) cpu->revidr = acc->revidr; cpu->id_afr0 = acc->id_afr0; cpu->reset_fpsid = acc->reset_fpsid; - cpu->reset_sctlr = acc->reset_sctlr; cpu->reset_auxcr = acc->reset_auxcr; cpu->pmsav7_dregion = acc->pmsav7_dregion; cpu->sau_sregion = acc->sau_sregion;
@@ -1280,9 +1279,6 @@ static void arm_cpu_initfn(Object *obj)static Property arm_cpu_reset_cbar_property =DEFINE_PROP_UINT64 ("reset-cbar" ,ARMCPU , reset_cbar,0 ); -static Property arm_cpu_cfgend_property = -DEFINE_PROP_BOOL ("cfgend" ,ARMCPU , cfgend, false); -static Property arm_cpu_has_vfp_property =DEFINE_PROP_BOOL ("vfp" ,ARMCPU , has_vfp, true);
@@ -1442,8 +1438,6 @@ static void arm_cpu_post_init(Object *obj) &cpu->psci_conduit, OBJ_PROP_FLAG_READWRITE); -qdev_property_add_static (DEVICE (obj), &arm_cpu_cfgend_property); -if (kvm_enabled ()) {kvm_arm_add_vcpu_properties (obj); }
@@ -1771,14 +1765,6 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp)return ; } -if (cpu->cfgend) { -if (arm_feature (&cpu->env,ARM_FEATURE_V7 )) { - cpu->reset_sctlr |=SCTLR_EE ; - }else { - cpu->reset_sctlr |=SCTLR_B ; - } - } -if (!cpu->has_pmu) {unset_feature (env,ARM_FEATURE_PMU ); }
@@ -2306,6 +2292,18 @@ static void arm_cpu_leaf_class_init(ObjectClass *oc, void *data) }#ifndef CONFIG_USER_ONLY +/* +* When the cfgend input is high, the CPU should reset into +* big-endian mode. Modify the reset_sctlr value to have SCTLR_B +* or SCTLR_EE set, depending on the architecture version. +*/ +class_property_add (oc,"cfgend" ,"bool" ,NULL , + arm_class_prop_get_sctlrbit, + arm_class_prop_set_sctlrbit, + (void *)(uintptr_t ) + (arm_class_feature (acc,ARM_FEATURE_V7 ) + ?SCTLR_EE :SCTLR_B )); +if (arm_class_feature (acc,ARM_FEATURE_GENERIC_TIMER )) { class_property_add(oc, "cntfrq", "uint64", NULL, arm_class_prop_uint64_ofs,
target/arm/helper.c +2 -2
@@ -7995,7 +7995,7 @@ void register_cp_regs_for_features(ARMCPU *cpu) .access = PL3_RW, .raw_writefn = raw_write, .writefn = sctlr_write, .fieldoffset = offsetof(CPUARMState, cp15.sctlr_el[3]), - .resetvalue = cpu->reset_sctlr }, + .resetvalue = acc->reset_sctlr }, };define_arm_cp_regs (cpu, el3_regs);
@@ -8331,7 +8331,7 @@ void register_cp_regs_for_features(ARMCPU *cpu) .access = PL1_RW, .accessfn = access_tvm_trvm, .bank_fieldoffsets = { offsetof(CPUARMState, cp15.sctlr_s), offsetof(CPUARMState, cp15.sctlr_ns) }, - .writefn = sctlr_write, .resetvalue = cpu->reset_sctlr, + .writefn = sctlr_write, .resetvalue = acc->reset_sctlr, .raw_writefn = raw_write, };if (arm_feature (env,ARM_FEATURE_XSCALE )) {
Signature · 1 line
2.34.1
Re: [RFC PATCH 37/40] target/arm: Move "cfgend" to class property
Quoted 3 lines · Richard Henderson
Remove the cfgend variable entirely and reuse the property accessor functions created for reset-hivecs. This removes the last setting of
cpu->reset_sctlr, to we can remove that
s/to/so/?
Quoted 8 lines
as well, using only the class value.
Signed-off-by Richard Henderson <[email protected]>--- target/arm/cpu.h | 8 -------- target/arm/cpu.c | 26 ++++++++++++-------------- target/arm/helper.c | 4 ++-- 3 files changed, 14 insertions(+), 24 deletions(-)
RFC PATCH 38/40 target/arm: Move "vfp" and "neon" to class properties
In reply to Richard HendersonWith the movement of the properties, we can remove the fields from the cpu entirely, using only the class.
--- target/arm/cpu-qom.h | 4 + target/arm/cpu.h | 4 - hw/arm/aspeed_ast2600.c | 3 +- target/arm/cpu.c | 340 +++++++++++++++++++++------------------- 4 files changed, 186 insertions(+), 165 deletions(-)
target/arm/cpu-qom.h +4 -0
@@ -188,6 +188,10 @@ struct ARMCPUClass {OnOffAuto has_el3;/* CPU has virtualization extension */ OnOffAuto has_el2; +/* CPU has VFP */ +OnOffAuto has_vfp; +/* CPU has Neon */ +OnOffAuto has_neon; };static inline int arm_class_feature (ARMCPUClass *acc,int feature)
target/arm/cpu.h +0 -4
@@ -888,10 +888,6 @@ struct ArchCPU {/* CPU has PMU (Performance Monitor Unit) */ bool has_pmu; -/* CPU has VFP */ -bool has_vfp; -/* CPU has Neon */ -bool has_neon;/* CPU has memory protection unit */ bool has_mpu;
hw/arm/aspeed_ast2600.c +1 -2
@@ -156,6 +156,7 @@ static void aspeed_soc_ast2600_init(Object *obj) cpu_class =object_class_by_name (sc->cpu_type);class_property_set_uint (cpu_class,"cntfrq" ,1125000000 , &error_abort); +class_property_set_bool (cpu_class,"neon" , false, &error_abort);for (i =0 ; i < sc->num_cpus; i++) {object_initialize_child (obj,"cpu[*]" , &s->cpu[i], sc->cpu_type);
@@ -309,8 +310,6 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp)object_property_set_int (OBJECT (&s->cpu[i]),"mp-affinity" ,aspeed_calc_affinity (i), &error_abort); -object_property_set_bool (OBJECT (&s->cpu[i]),"neon" , false, - &error_abort);object_property_set_link (OBJECT (&s->cpu[i]),"memory" ,OBJECT (s->memory), &error_abort);
target/arm/cpu.c +181 -159
387 lines not on this page · raw message
Signature · 1 line
2.34.1
RFC PATCH 39/40 target/arm: Move "has-mpu" and "pmsav7-dregion" to class properties
In reply to Richard HendersonWith the movement of the properties, we can remove the has_mpu field from the cpu entirely, using only the class. The pmsav7_dregion field must stay in the cpu to handle the usage with VMSTATE_VARRAY_UINT32.
--- target/arm/cpu-qom.h | 3 ++ target/arm/cpu.h | 2 - target/arm/cpu.c | 117 ++++++++++++++++++++++++------------------- target/arm/helper.c | 3 +- 4 files changed, 71 insertions(+), 54 deletions(-)
target/arm/cpu-qom.h +3 -0
@@ -192,6 +192,9 @@ struct ARMCPUClass {OnOffAuto has_vfp;/* CPU has Neon */ OnOffAuto has_neon; + +/* CPU has memory protection unit */ +bool has_mpu; };static inline int arm_class_feature (ARMCPUClass *acc,int feature)
target/arm/cpu.h +0 -2
@@ -889,8 +889,6 @@ struct ArchCPU {/* CPU has PMU (Performance Monitor Unit) */ bool has_pmu; -/* CPU has memory protection unit */ -bool has_mpu;/* PMSAv7 MPU number of supported regions */ uint32_t pmsav7_dregion;/* v8M SAU number of supported regions */
target/arm/cpu.c +66 -51
156 lines not on this page · raw message
target/arm/helper.c +2 -1
@@ -4804,8 +4804,9 @@ static void sctlr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) {ARMCPU *cpu =env_archcpu (env); +ARMCPUClass *acc =ARM_CPU_GET_CLASS (cpu); -if (arm_feature (env,ARM_FEATURE_PMSA ) && !cpu->has_mpu) { +if (arm_feature (env,ARM_FEATURE_PMSA ) && !acc->has_mpu) {/* M bit is RAZ/WI for PMSA with no MPU implemented */ value &= ~SCTLR_M ; }
Signature · 1 line
2.34.1
RFC PATCH 40/40 target/arm: Move "pmu" to class property
In reply to Richard HendersonWith the movement of the property, we can remove the field from the cpu entirely, using only the class. Properly detect support in kvm_arm_get_host_cpu_features rather than adjust much later in kvm_arch_init_vcpu.
--- target/arm/cpu-qom.h | 2 ++ target/arm/cpu.h | 3 --- target/arm/kvm_arm.h | 13 ---------- hw/arm/virt.c | 12 +++++----- target/arm/cpu.c | 57 ++++++++++++++++++++------------------------ target/arm/kvm.c | 24 +++++++++++-------- 6 files changed, 48 insertions(+), 63 deletions(-)
target/arm/cpu-qom.h +2 -0
@@ -192,6 +192,8 @@ struct ARMCPUClass {OnOffAuto has_vfp;/* CPU has Neon */ OnOffAuto has_neon; +/* CPU has PMU (Performance Monitor Unit) */ +OnOffAuto has_pmu;/* CPU has memory protection unit */ bool has_mpu;
target/arm/cpu.h +0 -3
@@ -886,9 +886,6 @@ struct ArchCPU {/* Current power state, access guarded by BQL */ ARMPSCIState power_state; -/* CPU has PMU (Performance Monitor Unit) */ -bool has_pmu; -/* PMSAv7 MPU number of supported regions */ uint32_t pmsav7_dregion;/* v8M SAU number of supported regions */
target/arm/kvm_arm.h +0 -13
@@ -177,14 +177,6 @@ void kvm_arm_steal_time_finalize(ARMCPU *cpu, Error **errp);*/ bool kvm_arm_aarch32_supported (void ); -/** -* kvm_arm_pmu_supported: -* -* Returns: true if KVM can enable the PMU -* and false otherwise. -*/ -bool kvm_arm_pmu_supported (void ); -/** * kvm_arm_sve_supported: *
@@ -229,11 +221,6 @@ static inline bool kvm_arm_aarch32_supported(void)return false; } -static inline bool kvm_arm_pmu_supported (void ) -{ -return false; -} -static inline bool kvm_arm_sve_supported (void ) {return false;
hw/arm/virt.c +6 -6
@@ -605,7 +605,6 @@ static void fdt_add_pmu_nodes(const VirtMachineState *vms)MachineState *ms =MACHINE (vms);if (!arm_feature (&armcpu->env,ARM_FEATURE_PMU )) { -assert (!object_property_get_bool (OBJECT (armcpu),"pmu" ,NULL ));return ; }
@@ -1951,9 +1950,11 @@ static void virt_cpu_post_init(VirtMachineState *vms, MemoryRegion *sysmem)int max_cpus =MACHINE (vms)->smp.max_cpus;bool aarch64, pmu, steal_time;CPUState *cpu; +ObjectClass *cpu_class; + cpu_class =object_get_class (OBJECT (first_cpu)); aarch64 =object_property_get_bool (OBJECT (first_cpu),"aarch64" ,NULL ); - pmu =object_property_get_bool (OBJECT (first_cpu),"pmu" ,NULL ); + pmu =class_property_get_bool (cpu_class,"pmu" ,NULL ); steal_time =object_property_get_bool (OBJECT (first_cpu),"kvm-steal-time" ,NULL );
@@ -2043,6 +2044,9 @@ static void machvirt_init(MachineState *machine)if (!vms->virt) {class_property_set_bool (cpu_class,"has_el2" , false, &error_abort); } +if (vmc->no_pmu) { +class_property_set_bool (cpu_class,"pmu" , false, &error_abort); + }/* * In accelerated mode, the memory map is computed earlier in kvm_type()
@@ -2185,10 +2189,6 @@ static void machvirt_init(MachineState *machine)object_property_set_bool (cpuobj,"kvm-steal-time" , false,NULL ); } -if (vmc->no_pmu &&object_property_find (cpuobj,"pmu" )) { -object_property_set_bool (cpuobj,"pmu" , false,NULL ); - } -if (vmc->no_tcg_lpa2 &&object_property_find (cpuobj,"lpa2" )) {object_property_set_bool (cpuobj,"lpa2" , false,NULL ); }
target/arm/cpu.c +26 -31
87 lines not on this page · raw message
target/arm/kvm.c +14 -10
@@ -239,7 +239,13 @@ void kvm_arm_add_vcpu_properties(Object *obj) "Set off to disable KVM steal time."); } -bool kvm_arm_pmu_supported (void ) +/** +* kvm_arm_pmu_supported: +* +* Returns: true if KVM can enable the PMU +* and false otherwise. +*/ +static bool kvm_arm_pmu_supported (void ) {return kvm_check_extension (kvm_state,KVM_CAP_ARM_PMU_V3 ); }
@@ -1463,7 +1469,7 @@ void kvm_arm_pmu_init(CPUState *cs) .attr = KVM_ARM_VCPU_PMU_V3_INIT, }; -if (!ARM_CPU (cs)->has_pmu) { +if (!arm_feature (&ARM_CPU (cs)->env,ARM_FEATURE_PMU )) {return ; }if (!kvm_arm_set_device_attr (cs, &attr,"PMU" )) {
@@ -1480,7 +1486,7 @@ void kvm_arm_pmu_set_irq(CPUState *cs, int irq) .attr = KVM_ARM_VCPU_PMU_V3_IRQ, }; -if (!ARM_CPU (cs)->has_pmu) { +if (!arm_feature (&ARM_CPU (cs)->env,ARM_FEATURE_PMU )) {return ; }if (!kvm_arm_set_device_attr (cs, &attr,"PMU" )) {
@@ -1594,6 +1600,9 @@ bool kvm_arm_get_host_cpu_features(ARMCPUClass *acc, Error **errp)if (kvm_arm_pmu_supported ()) { init.features[0 ] |=1 <<KVM_ARM_VCPU_PMU_V3 ; pmu_supported = true; + }else { +/* This was optimistically set in aarch64_host_class_init. */ +unset_class_feature (acc,ARM_FEATURE_PMU ); }if (!kvm_arm_create_scratch_host_vcpu (cpus_to_try, fdarray, &init)) {
@@ -1877,7 +1886,6 @@ int kvm_arch_init_vcpu(CPUState *cs) {int ret;ARMCPU *cpu =ARM_CPU (cs); -CPUARMState *env = &cpu->env;uint64_t psciver; if (cpu->kvm_target == QEMU_KVM_ARM_TARGET_NONE ||
@@ -1900,13 +1908,9 @@ int kvm_arch_init_vcpu(CPUState *cs)if (!arm_feature (&cpu->env,ARM_FEATURE_AARCH64 )) { cpu->kvm_init_features[0 ] |=1 <<KVM_ARM_VCPU_EL1_32BIT ; } -if (!kvm_check_extension (cs->kvm_state,KVM_CAP_ARM_PMU_V3 )) { - cpu->has_pmu = false; - } -if (cpu->has_pmu) { +if (arm_feature (&cpu->env,ARM_FEATURE_PMU )) { +assert (kvm_arm_pmu_supported ()); cpu->kvm_init_features[0 ] |=1 <<KVM_ARM_VCPU_PMU_V3 ; - }else { - env->features &= ~(1ULL <<ARM_FEATURE_PMU ); }if (cpu_isar_feature (aa64_sve, cpu)) {assert (kvm_arm_sve_supported ());
Signature · 1 line
2.34.1
Quoted 5 lines · Richard Henderson
Richard Henderson (40):
target/arm: Removeaarch64_cpu_finalizefn
target/arm: Createarm_cpu_register_parent
target/arm: Remove AArch64CPUClass
target/arm: CreateTYPE_ARM_V7M_CPU
...
Quoted 1 line
target/arm: Utilize arm-cpu
instance_post_inithook
...
Quoted 4 lines
hw/arm/bcm2836: Set mp-affinity property in realize target/arm: Rename
arm_cpu_mp_affinitytarget/arm: Createarm_cpu_mp_affinitytarget/arm: Represent the entireMPIDR_EL1
I meant to say: Peter, at least this handfull of patches ought to be useful cleanup regardless of the rest of the series.
r~
Quoted 17 lines · Richard Henderson
The specific problem I'm trying to solve is the location and representation of the coprocessor register hash table for ARM cpus, but in the process affects how cpu initialization might be done for all targets.
At present, each cpu (for all targets) is initialized separately. For some, like ARM, we apply QOM properties and then build a hash table of all coprocessor regs that are valid for the cpu. For others, like m68k and ppc, we build tables of all valid instructions (ppc is slowly moving away from constructed tables to decodetree, but the migration is not complete).
Importantly, this happens N times for smp system emulation, for each cpu instance, meaning we do N times the work on startup as necessary. For system emulation this isn't so bad, as N is generally small-ish, but it certainly could be improved.
Quoted 7 lines
More importantly, this happens for each thread in user-only emulation. This is much more significant because threads can be short-lived, and there can be many hundreds of them, each one performing what amounts to redundant initialization.
The "obvious" solution is to make better use of the cpu class object. Construct data structures once to be shared with all instances.
The trouble with this idea is that not all instances of the same class are actually necessarily the same. For instance, if you have a system with both (a) a Cortex-A53 with a PMU, and
(b) a Cortex-A53 without a PMU, then they're both instances of the same class, but they shouldn't be sharing the coprocessor register hashtable because they don't have an identical set of system registers.
This kind of same-CPU-type-heterogenous-configuration system is not something we're currently using on A-profile, but we do have it for M-profile (the sse200 has a dual-core setup where only one of the CPUs has an FPU), so it's not totally outlandish.
thanks
-- PMM
Quoted 8 lines · Peter Maydell
The trouble with this idea is that not all instances of the same class are actually necessarily the same. For instance, if you have a system with both (a) a Cortex-A53 with a PMU, and
(b) a Cortex-A53 without a PMU, then they're both instances of the same class, but they shouldn't be sharing the coprocessor register hashtable because they don't have an identical set of system registers.
Quoted 4 lines
This kind of same-CPU-type-heterogenous-configuration system is not something we're currently using on A-profile, but we do have it for M-profile (the sse200 has a dual-core setup where only one of the CPUs has an FPU), so it's not totally outlandish.
Yes, I know. See patch 29 where I moved the vfp and dsp properties off of the m-profile cpus and created new cpu classes instead, specifically for the sse220.
It's not scalable, I'll grant you, but it's hard to design for something we're not using. What we use now, apart from the sse200, are common properties set on the command-line.
If we were presented with the class properties early enough, we could create sub-classes with the desired properties before instantiating the objects that go with.
Anyway, it seems like we ought to have some solution that does not involve repeating the same id register finalization + cpregs hash table construction per cpu -- especially for user-only.
r~
Quoted 15 lines · Richard Henderson
Quoted 8 lines · Peter Maydell
The trouble with this idea is that not all instances of the same class are actually necessarily the same. For instance, if you have a system with both (a) a Cortex-A53 with a PMU, and
(b) a Cortex-A53 without a PMU, then they're both instances of the same class, but they shouldn't be sharing the coprocessor register hashtable because they don't have an identical set of system registers.Quoted 4 lines
This kind of same-CPU-type-heterogenous-configuration system is not something we're currently using on A-profile, but we do have it for M-profile (the sse200 has a dual-core setup where only one of the CPUs has an FPU), so it's not totally outlandish.
Quoted 5 lines
Yes, I know. See patch 29 where I moved the vfp and dsp properties off of the m-profile cpus and created new cpu classes instead, specifically for the sse220.
It's not scalable, I'll grant you, but it's hard to design for something we're not using. What we use now, apart from the sse200, are common properties set on the command-line.
We also set some properties in code -- eg aspeed_ast2600.c clears the 'neon' property on its CPUs, lots of the boards clear has_el3 and has_el2, etc. I hadn't got as far as patch 29, but looking at it now that looks like a pretty strong indication that this is the wrong way to go. It creates 3 extra cortex-m33 CPU classes, and if we find another thing that ought to be a CPU property then we'll be up to 8; and the mess propagates up into the SSE-200 class, which is also no longer able to be configured in the normal way by setting properties on it, and it becomes visible in user-facing command line stuff.
I think our object model pretty strongly wants "create object; set properties on it that only affect this object you created; realize it", and having one particular subset of objects that doesn't work the same way is going to be very confusing.
thanks
-- PMM
Quoted 3 lines · Peter Maydell
We also set some properties in code -- eg
aspeed_ast2600.cclears the 'neon' property on its CPUs, lots of the boards clearhas_el3andhas_el2, etc.
Yes indeed, but in all of those cases we want all of the cpus to act identically. Those are all easily handled (patches 35, 36, 38).
Quoted 5 lines
I hadn't got as far as patch 29, but
looking at it now that looks like a pretty strong indication that this is the wrong way to go. It creates 3 extra cortex-m33 CPU classes, and if we find another thing that ought to be a CPU property then we'll be up to 8;
If we find another thing that needs to be different between cpus, you mean?
Quoted 1 line
and it becomes visible in user-facing command line stuff.
No it doesn't -- command line is *not* affected, because both before and after, all properties are applied identically to all objects.
QMP is affected, which is where I stopped and started asking questions about what QMP is actually trying to do.
Quoted 4 lines
I think our object model pretty strongly wants "create object; set properties on it that only affect this object you created; realize it", and having one particular subset of objects that doesn't work the same way is going to be very confusing.
Eh, I didn't think it's particularly confusing as a concept. The code is rough, buy what one might expect from an RFC.
We really ought to have *some* solution to not repeating property + feature + isar interpretation on a per-cpu basis. I'd be delighted to hear alternatives.
r~
Quoted 8 lines · Richard Henderson
Quoted 3 lines · Peter Maydell
We also set some properties in code -- eg
aspeed_ast2600.cclears the 'neon' property on its CPUs, lots of the boards clearhas_el3andhas_el2, etc.Yes indeed, but in all of those cases we want all of the cpus to act identically. Those are all easily handled (patches 35, 36, 38).
That's just a happenstance of how the boards create them. There's no inherent reason that every CPU of a particular type in the system has to have identical properties.
Quoted 7 lines
Quoted 5 lines
I hadn't got as far as patch 29, but
looking at it now that looks like a pretty strong indication that this is the wrong way to go. It creates 3 extra cortex-m33 CPU classes, and if we find another thing that ought to be a CPU property then we'll be up to 8;If we find another thing that needs to be different between cpus, you mean?
Yes. But conceptually we already have lots of those, we just happen not to be using them right this instant.
Quoted 10 lines
Quoted 4 lines
I think our object model pretty strongly wants "create object; set properties on it that only affect this object you created; realize it", and having one particular subset of objects that doesn't work the same way is going to be very confusing.
Eh, I didn't think it's particularly confusing as a concept. The code is rough, buy what one might expect from an RFC.
We really ought to have *some* solution to not repeating property + feature + isar interpretation on a per-cpu basis. I'd be delighted to hear alternatives.
Hash "cpu type plus property settings plus ID registers", and look them up to see if we've already created the cpregs hashtable for an existing CPU?
-- PMM
Quoted 35 lines · Peter Maydell
Quoted 15 lines · Richard Henderson
Quoted 8 lines · Peter Maydell
The trouble with this idea is that not all instances of the same class are actually necessarily the same. For instance, if you have a system with both (a) a Cortex-A53 with a PMU, and
(b) a Cortex-A53 without a PMU, then they're both instances of the same class, but they shouldn't be sharing the coprocessor register hashtable because they don't have an identical set of system registers.Quoted 4 lines
This kind of same-CPU-type-heterogenous-configuration system is not something we're currently using on A-profile, but we do have it for M-profile (the sse200 has a dual-core setup where only one of the CPUs has an FPU), so it's not totally outlandish.
Quoted 5 lines
Yes, I know. See patch 29 where I moved the vfp and dsp properties off of the m-profile cpus and created new cpu classes instead, specifically for the sse220.
It's not scalable, I'll grant you, but it's hard to design for something we're not using. What we use now, apart from the sse200, are common properties set on the command-line.
We also set some properties in code -- eg
aspeed_ast2600.cclears the 'neon' property on its CPUs, lots of the boards clearhas_el3andhas_el2, etc. I hadn't got as far as patch 29, but looking at it now that looks like a pretty strong indication that this is the wrong way to go. It creates 3 extra cortex-m33 CPU classes, and if we find another thing that ought to be a CPU property then we'll be up to 8; and the mess propagates up into the SSE-200 class, which is also no longer able to be configured in the normal way by setting properties on it, and it becomes visible in user-facing command line stuff.
Quoted 4 lines
I think our object model pretty strongly wants "create object; set properties on it that only affect this object you created; realize it", and having one particular subset of objects that doesn't work the same way is going to be very confusing.
What about cloning objects after they are realised? After all that is what we do for the core CPUClass in user-mode.
Quoted 3 lines
thanks
-- PMM
Signature · 2 lines
Alex Bennée Virtualisation Tech Lead @ Linaro
Quoted 2 lines · Alex Bennée
What about cloning objects after they are realised? After all that is what we do for the core CPUClass in user-mode.
No we don't. Where do you get that idea?
r~
Quoted 5 lines · Richard Henderson
Quoted 2 lines · Alex Bennée
What about cloning objects after they are realised? After all that is what we do for the core CPUClass in user-mode.
No we don't. Where do you get that idea?
Well linux-user does cpu_copy which involves a create step followed by a reset and then a bunch of copying state across. Can we assume all CPUs get reset before they are actively used?
Would it be too hacky to defer the creation of those hash tables to the reset phase and skip it if already defined?
Signature · 2 lines
Alex Bennée Virtualisation Tech Lead @ Linaro
Quoted 4 lines · Alex Bennée
Quoted 1 line · Richard Henderson
On 1/6/23 15:43, Alex Bennée wrote:
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
What about cloning objects after they are realised? After all that is what we do for the core CPUClass in user-mode.
No we don't. Where do you get that idea?
Well linux-user does
cpu_copywhich involves a create step followed by a reset and then a bunch of copying state across. Can we assume all CPUs get reset before they are actively used?
The hash table creation happens during qdev_realize, there in cpu_create.
Quoted 2 lines
Would it be too hacky to defer the creation of those hash tables to the reset phase and skip it if already defined?
Even then you have the copy after the reset, so no, that won't work.
r~