Message ID | 20250404223521.38781-4-philmd@linaro.org (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | target/arm: Remove some TARGET_AARCH64 uses (MTE & gdbstub) | expand |
On 4/4/25 15:35, Philippe Mathieu-Daudé wrote: > static void arm_cpu_initfn(Object *obj) > { > ARMCPU *cpu = ARM_CPU(obj); > @@ -1482,16 +1489,16 @@ static void arm_cpu_initfn(Object *obj) > QLIST_INIT(&cpu->el_change_hooks); > > #ifdef CONFIG_USER_ONLY > -# ifdef TARGET_AARCH64 > - /* > - * The linux kernel defaults to 512-bit for SVE, and 256-bit for SME. > - * These values were chosen to fit within the default signal frame. > - * See documentation for /proc/sys/abi/{sve,sme}_default_vector_length, > - * and our corresponding cpu property. > - */ > - cpu->sve_default_vq = 4; > - cpu->sme_default_vq = 2; > -# endif > + if (arm_cpu_is_64bit(cpu)) { arm_feature(&cpu->env, ARM_FEATURE_AARCH64) is a better test, but env->features is initialized by the child instance_init. We could move this to arm_cpu_post_init, so that features is initialized. Alternately, we could just make this unconditional, since these fields are always present but only read from aarch64 code. r~
diff --git a/target/arm/cpu.c b/target/arm/cpu.c index 95afa9b72f1..ef95f31f249 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -1471,6 +1471,13 @@ uint64_t arm_cpu_mp_affinity(ARMCPU *cpu) return cpu->mp_affinity; } +#ifdef CONFIG_USER_ONLY +static bool arm_cpu_is_64bit(ARMCPU *cpu) +{ + return !!object_dynamic_cast(OBJECT(cpu), TYPE_AARCH64_CPU); +} +#endif + static void arm_cpu_initfn(Object *obj) { ARMCPU *cpu = ARM_CPU(obj); @@ -1482,16 +1489,16 @@ static void arm_cpu_initfn(Object *obj) QLIST_INIT(&cpu->el_change_hooks); #ifdef CONFIG_USER_ONLY -# ifdef TARGET_AARCH64 - /* - * The linux kernel defaults to 512-bit for SVE, and 256-bit for SME. - * These values were chosen to fit within the default signal frame. - * See documentation for /proc/sys/abi/{sve,sme}_default_vector_length, - * and our corresponding cpu property. - */ - cpu->sve_default_vq = 4; - cpu->sme_default_vq = 2; -# endif + if (arm_cpu_is_64bit(cpu)) { + /* + * The linux kernel defaults to 512-bit for SVE, and 256-bit for SME. + * These values were chosen to fit within the default signal frame. + * See documentation for /proc/sys/abi/{sve,sme}_default_vector_length, + * and our corresponding cpu property. + */ + cpu->sve_default_vq = 4; + cpu->sme_default_vq = 2; + } #else /* Our inbound IRQ and FIQ lines */ if (kvm_enabled()) {
Introduce the QOM arm_cpu_is_64bit() helper, which checks whether a vCPU parent class is TYPE_AARCH64_CPU. Use it in arm_cpu_initfn() to remove a TARGET_AARCH64 definition use. Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> --- target/arm/cpu.c | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-)