[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 5/7] target/arm: Move aarch64 CPU property code to TYPE_ARM_CP
From: |
Peter Maydell |
Subject: |
[PATCH v2 5/7] target/arm: Move aarch64 CPU property code to TYPE_ARM_CPU |
Date: |
Tue, 29 Apr 2025 14:21:58 +0100 |
The only thing we have left in the TYPE_AARCH64_CPU class that makes
it different to TYPE_ARM_CPU is that we register the handling of the
"aarch64" property there.
Move the handling of this property to the base class, where we make
it a property of the object rather than of the class, and add it
to the CPU if it has the ARM_FEATURE_AARCH64 property present at
init. This is in line with how we handle other Arm CPU properties,
and should not change which CPUs it's visible for.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
target/arm/cpu.c | 36 ++++++++++++++++++++++++++++++++++++
target/arm/cpu64.c | 33 ---------------------------------
2 files changed, 36 insertions(+), 33 deletions(-)
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
index 5e951675c60..73a2a197667 100644
--- a/target/arm/cpu.c
+++ b/target/arm/cpu.c
@@ -1610,6 +1610,35 @@ static void arm_set_pmu(Object *obj, bool value, Error
**errp)
cpu->has_pmu = value;
}
+static bool aarch64_cpu_get_aarch64(Object *obj, Error **errp)
+{
+ ARMCPU *cpu = ARM_CPU(obj);
+
+ return arm_feature(&cpu->env, ARM_FEATURE_AARCH64);
+}
+
+static void aarch64_cpu_set_aarch64(Object *obj, bool value, Error **errp)
+{
+ ARMCPU *cpu = ARM_CPU(obj);
+
+ /*
+ * At this time, this property is only allowed if KVM is enabled. This
+ * restriction allows us to avoid fixing up functionality that assumes a
+ * uniform execution state like do_interrupt.
+ */
+ if (value == false) {
+ if (!kvm_enabled() || !kvm_arm_aarch32_supported()) {
+ error_setg(errp, "'aarch64' feature cannot be disabled "
+ "unless KVM is enabled and 32-bit EL1 "
+ "is supported");
+ return;
+ }
+ unset_feature(&cpu->env, ARM_FEATURE_AARCH64);
+ } else {
+ set_feature(&cpu->env, ARM_FEATURE_AARCH64);
+ }
+}
+
unsigned int gt_cntfrq_period_ns(ARMCPU *cpu)
{
/*
@@ -1737,6 +1766,13 @@ void arm_cpu_post_init(Object *obj)
*/
arm_cpu_propagate_feature_implications(cpu);
+ if (arm_feature(&cpu->env, ARM_FEATURE_AARCH64)) {
+ object_property_add_bool(obj, "aarch64", aarch64_cpu_get_aarch64,
+ aarch64_cpu_set_aarch64);
+ object_property_set_description(obj, "aarch64",
+ "Set on/off to enable/disable aarch64 "
+ "execution state ");
+ }
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);
diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c
index 00629a5d1d1..e527465a3ca 100644
--- a/target/arm/cpu64.c
+++ b/target/arm/cpu64.c
@@ -781,45 +781,12 @@ static const ARMCPUInfo aarch64_cpus[] = {
#endif
};
-static bool aarch64_cpu_get_aarch64(Object *obj, Error **errp)
-{
- ARMCPU *cpu = ARM_CPU(obj);
-
- return arm_feature(&cpu->env, ARM_FEATURE_AARCH64);
-}
-
-static void aarch64_cpu_set_aarch64(Object *obj, bool value, Error **errp)
-{
- ARMCPU *cpu = ARM_CPU(obj);
-
- /* At this time, this property is only allowed if KVM is enabled. This
- * restriction allows us to avoid fixing up functionality that assumes a
- * uniform execution state like do_interrupt.
- */
- if (value == false) {
- if (!kvm_enabled() || !kvm_arm_aarch32_supported()) {
- error_setg(errp, "'aarch64' feature cannot be disabled "
- "unless KVM is enabled and 32-bit EL1 "
- "is supported");
- return;
- }
- unset_feature(&cpu->env, ARM_FEATURE_AARCH64);
- } else {
- set_feature(&cpu->env, ARM_FEATURE_AARCH64);
- }
-}
-
static void aarch64_cpu_finalizefn(Object *obj)
{
}
static void aarch64_cpu_class_init(ObjectClass *oc, const void *data)
{
- object_class_property_add_bool(oc, "aarch64", aarch64_cpu_get_aarch64,
- aarch64_cpu_set_aarch64);
- object_class_property_set_description(oc, "aarch64",
- "Set on/off to enable/disable
aarch64 "
- "execution state ");
}
static void aarch64_cpu_instance_init(Object *obj)
--
2.43.0
- [PATCH v2 0/7] target/arm: Remove TYPE_AARCH64_CPU class, Peter Maydell, 2025/04/29
- [PATCH v2 6/7] target/arm/kvm: don't check TYPE_AARCH64_CPU, Peter Maydell, 2025/04/29
- [PATCH v2 2/7] target/microblaze: Delay gdb_register_coprocessor() to realize, Peter Maydell, 2025/04/29
- [PATCH v2 1/7] target/microblaze: Use 'obj' in DEVICE() casts in mb_cpu_initfn(), Peter Maydell, 2025/04/29
- [PATCH v2 5/7] target/arm: Move aarch64 CPU property code to TYPE_ARM_CPU,
Peter Maydell <=
- [PATCH v2 3/7] hw/core/cpu-common: Don't init gdbstub until cpu_exec_realizefn(), Peter Maydell, 2025/04/29
- [PATCH v2 7/7] target/arm: Remove TYPE_AARCH64_CPU, Peter Maydell, 2025/04/29
- [PATCH v2 4/7] target/arm: Present AArch64 gdbstub based on ARM_FEATURE_AARCH64, Peter Maydell, 2025/04/29