[RFC PATCH-for-9.0 02/11] target/arm: Add target_aarch64_available() helper

Philippe Mathieu-Daudé posted 11 patches 1 year ago
Maintainers: Peter Maydell <peter.maydell@linaro.org>, "Philippe Mathieu-Daudé" <philmd@linaro.org>, Paolo Bonzini <pbonzini@redhat.com>, "Daniel P. Berrangé" <berrange@redhat.com>, Eduardo Habkost <eduardo@habkost.net>
[RFC PATCH-for-9.0 02/11] target/arm: Add target_aarch64_available() helper
Posted by Philippe Mathieu-Daudé 1 year ago
We want to build HW models once, but don't want to
register types when all prerequisites are satisfied. Add
the target_aarch64_available() to know at runtime whether
TARGET_AARCH64 is built-in.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 target/arm/cpu-qom.h | 2 ++
 target/arm/cpu.c     | 9 +++++++++
 2 files changed, 11 insertions(+)

diff --git a/target/arm/cpu-qom.h b/target/arm/cpu-qom.h
index 02b914c876..bf6b3604ed 100644
--- a/target/arm/cpu-qom.h
+++ b/target/arm/cpu-qom.h
@@ -33,4 +33,6 @@ typedef struct AArch64CPUClass AArch64CPUClass;
 DECLARE_CLASS_CHECKERS(AArch64CPUClass, AARCH64_CPU,
                        TYPE_AARCH64_CPU)
 
+bool target_aarch64_available(void);
+
 #endif
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
index 25e9d2ae7b..1990c04089 100644
--- a/target/arm/cpu.c
+++ b/target/arm/cpu.c
@@ -2548,3 +2548,12 @@ static void arm_cpu_register_types(void)
 }
 
 type_init(arm_cpu_register_types)
+
+bool target_aarch64_available(void)
+{
+#ifdef TARGET_AARCH64
+    return true;
+#else
+    return false;
+#endif
+}
-- 
2.41.0


Re: [RFC PATCH-for-9.0 02/11] target/arm: Add target_aarch64_available() helper
Posted by Philippe Mathieu-Daudé 1 year ago
On 22/11/23 19:30, Philippe Mathieu-Daudé wrote:
> We want to build HW models once, but don't want to
> register types when all prerequisites are satisfied. Add
> the target_aarch64_available() to know at runtime whether
> TARGET_AARCH64 is built-in.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   target/arm/cpu-qom.h | 2 ++
>   target/arm/cpu.c     | 9 +++++++++
>   2 files changed, 11 insertions(+)
> 
> diff --git a/target/arm/cpu-qom.h b/target/arm/cpu-qom.h
> index 02b914c876..bf6b3604ed 100644
> --- a/target/arm/cpu-qom.h
> +++ b/target/arm/cpu-qom.h
> @@ -33,4 +33,6 @@ typedef struct AArch64CPUClass AArch64CPUClass;
>   DECLARE_CLASS_CHECKERS(AArch64CPUClass, AARCH64_CPU,
>                          TYPE_AARCH64_CPU)
>   
> +bool target_aarch64_available(void);
> +
>   #endif
> diff --git a/target/arm/cpu.c b/target/arm/cpu.c
> index 25e9d2ae7b..1990c04089 100644
> --- a/target/arm/cpu.c
> +++ b/target/arm/cpu.c
> @@ -2548,3 +2548,12 @@ static void arm_cpu_register_types(void)
>   }
>   
>   type_init(arm_cpu_register_types)
> +
> +bool target_aarch64_available(void)
> +{
> +#ifdef TARGET_AARCH64
> +    return true;
> +#else
> +    return false;
> +#endif
> +}

I forgot to precise here, what was discussed during the previous 2
years. Eventually qemu-system-arm is absorbed by qemu-system-aarch64,
but to keep backward compatibility we add a new qemu-system-arm wrapper
which simply calls 'qemu-system-aarch64 --32bit-only' (or better named
option) forwarding the same command line. target_aarch64_available()
then becomes:

   bool target_aarch64_available(void)
   {
     return option_32bit_only == false;
   }