diff mbox series

[RFC,RESEND,35/42] target/arm: Emulate EL2 under TCG

Message ID 20250620172751.94231-36-philmd@linaro.org
State New
Headers show
Series accel/split/arm: Run EL2 using TCG and EL1/EL0 in hardware with HVF | expand

Commit Message

Philippe Mathieu-Daudé June 20, 2025, 5:27 p.m. UTC
When using hardware acceleration and TCG is available,
expose EL2 and EL3 features as available (they will be
emulated).

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 target/arm/cpu64.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

Comments

Richard Henderson June 22, 2025, 3:20 a.m. UTC | #1
On 6/20/25 10:27, Philippe Mathieu-Daudé wrote:
> When using hardware acceleration and TCG is available,
> expose EL2 and EL3 features as available (they will be
> emulated).
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   target/arm/cpu64.c | 7 +++++--
>   1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c
> index 200da1c489b..b5c2796f3a1 100644
> --- a/target/arm/cpu64.c
> +++ b/target/arm/cpu64.c
> @@ -738,20 +738,23 @@ static void aarch64_a53_initfn(Object *obj)
>   
>   static void aarch64_host_initfn(Object *obj)
>   {
> -#if defined(CONFIG_KVM)
>       ARMCPU *cpu = ARM_CPU(obj);
> +#if defined(CONFIG_KVM)
>       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);
>       }
>   #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();
>   #endif
> +    if (tcg_enabled()) {
> +        set_feature(&cpu->env, ARM_FEATURE_EL2);
> +        set_feature(&cpu->env, ARM_FEATURE_EL3);
> +    }
>   }
>   
>   static void aarch64_max_initfn(Object *obj)

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~
diff mbox series

Patch

diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c
index 200da1c489b..b5c2796f3a1 100644
--- a/target/arm/cpu64.c
+++ b/target/arm/cpu64.c
@@ -738,20 +738,23 @@  static void aarch64_a53_initfn(Object *obj)
 
 static void aarch64_host_initfn(Object *obj)
 {
-#if defined(CONFIG_KVM)
     ARMCPU *cpu = ARM_CPU(obj);
+#if defined(CONFIG_KVM)
     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);
     }
 #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();
 #endif
+    if (tcg_enabled()) {
+        set_feature(&cpu->env, ARM_FEATURE_EL2);
+        set_feature(&cpu->env, ARM_FEATURE_EL3);
+    }
 }
 
 static void aarch64_max_initfn(Object *obj)