Message ID | 20250317142819.900029-4-peter.maydell@linaro.org (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | target/arm: Remove TYPE_AARCH64_CPU class | expand |
Peter Maydell <peter.maydell@linaro.org> writes: > Instead of having the TYPE_AARCH64_CPU subclass set > CPUClass::gdb_arch_name to a different function, make the > TYPE_ARM_CPU implementation of the method handle AArch64. > > For the moment we make the "is this AArch64?" function test "is the > CPU of TYPE_AARCH64_CPU?", so that this produces no behavioural > change. When we've moved all the gdbstub related methods across to > the base class, we will be able to change this to be "does the CPU > have the ARM_FEATURE_AARCH64 feature?". > > Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
On 17/3/25 15:28, Peter Maydell wrote: > Instead of having the TYPE_AARCH64_CPU subclass set > CPUClass::gdb_arch_name to a different function, make the > TYPE_ARM_CPU implementation of the method handle AArch64. > > For the moment we make the "is this AArch64?" function test "is the > CPU of TYPE_AARCH64_CPU?", so that this produces no behavioural > change. When we've moved all the gdbstub related methods across to > the base class, we will be able to change this to be "does the CPU > have the ARM_FEATURE_AARCH64 feature?". > > Signed-off-by: Peter Maydell <peter.maydell@linaro.org> > --- > target/arm/internals.h | 6 ++++++ > target/arm/cpu.c | 3 +++ > target/arm/cpu64.c | 6 ------ > 3 files changed, 9 insertions(+), 6 deletions(-) Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
diff --git a/target/arm/internals.h b/target/arm/internals.h index bb962389192..a14c269fa5a 100644 --- a/target/arm/internals.h +++ b/target/arm/internals.h @@ -1691,6 +1691,12 @@ void aarch64_add_sve_properties(Object *obj); void aarch64_add_sme_properties(Object *obj); #endif +/* Return true if the gdbstub is presenting an AArch64 CPU */ +static inline bool arm_gdbstub_is_aarch64(ARMCPU *cpu) +{ + return object_dynamic_cast(OBJECT(cpu), TYPE_AARCH64_CPU); +} + /* Read the CONTROL register as the MRS instruction would. */ uint32_t arm_v7m_mrs_control(CPUARMState *env, uint32_t secure); diff --git a/target/arm/cpu.c b/target/arm/cpu.c index 01786ac7879..d69403fda90 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -2647,6 +2647,9 @@ static const gchar *arm_gdb_arch_name(CPUState *cs) ARMCPU *cpu = ARM_CPU(cs); CPUARMState *env = &cpu->env; + if (arm_gdbstub_is_aarch64(cpu)) { + return "aarch64"; + } if (arm_feature(env, ARM_FEATURE_IWMMXT)) { return "iwmmxt"; } diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c index 8188ede5cc8..020b32f21e9 100644 --- a/target/arm/cpu64.c +++ b/target/arm/cpu64.c @@ -813,11 +813,6 @@ static void aarch64_cpu_finalizefn(Object *obj) { } -static const gchar *aarch64_gdb_arch_name(CPUState *cs) -{ - return "aarch64"; -} - static void aarch64_cpu_class_init(ObjectClass *oc, void *data) { CPUClass *cc = CPU_CLASS(oc); @@ -825,7 +820,6 @@ static void aarch64_cpu_class_init(ObjectClass *oc, void *data) cc->gdb_read_register = aarch64_cpu_gdb_read_register; cc->gdb_write_register = aarch64_cpu_gdb_write_register; cc->gdb_core_xml_file = "aarch64-core.xml"; - cc->gdb_arch_name = aarch64_gdb_arch_name; object_class_property_add_bool(oc, "aarch64", aarch64_cpu_get_aarch64, aarch64_cpu_set_aarch64);
Instead of having the TYPE_AARCH64_CPU subclass set CPUClass::gdb_arch_name to a different function, make the TYPE_ARM_CPU implementation of the method handle AArch64. For the moment we make the "is this AArch64?" function test "is the CPU of TYPE_AARCH64_CPU?", so that this produces no behavioural change. When we've moved all the gdbstub related methods across to the base class, we will be able to change this to be "does the CPU have the ARM_FEATURE_AARCH64 feature?". Signed-off-by: Peter Maydell <peter.maydell@linaro.org> --- target/arm/internals.h | 6 ++++++ target/arm/cpu.c | 3 +++ target/arm/cpu64.c | 6 ------ 3 files changed, 9 insertions(+), 6 deletions(-)