diff mbox series

[RFC,RESEND,37/42] accel/hvf: Emulate HVC at EL2

Message ID 20250620172751.94231-38-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
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 target/arm/hvf/hvf.c | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Richard Henderson June 22, 2025, 3:28 a.m. UTC | #1
On 6/20/25 10:27, Philippe Mathieu-Daudé wrote:
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   target/arm/hvf/hvf.c | 6 ++++++
>   1 file changed, 6 insertions(+)
> 
> diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c
> index 3907ea8791e..a4f823f834d 100644
> --- a/target/arm/hvf/hvf.c
> +++ b/target/arm/hvf/hvf.c
> @@ -17,6 +17,7 @@
>   #include "system/hvf.h"
>   #include "system/hvf_int.h"
>   #include "system/hw_accel.h"
> +#include "system/tcg.h"
>   #include "hvf_arm.h"
>   #include "cpregs.h"
>   
> @@ -1117,6 +1118,8 @@ static void hvf_raise_exception(CPUState *cpu, uint32_t excp,
>       env->exception.syndrome = syndrome;
>   
>       arm_cpu_do_interrupt(cpu);
> +    cpu->interrupt_request &= ~CPU_INTERRUPT_EXITTB;

Why is this needed?

r~

> +    cpu->exception_index = -1;
>   }
>   
>   static void hvf_psci_cpu_off(ARMCPU *arm_cpu)
> @@ -2090,6 +2093,9 @@ int hvf_vcpu_exec(CPUState *cpu)
>                   /* SMCCC 1.3 section 5.2 says every unknown SMCCC call returns -1 */
>                   env->xregs[0] = -1;
>               }
> +        } else if (tcg_enabled()) {
> +            /* FIXME check we are called from EL1 (so EL0 -> UDEF) ? */
> +            hvf_raise_exception(cpu, EXCP_HVC, syn_aa64_hvc(0), 2);
>           } else {
>               trace_hvf_unknown_hvc(env->pc, env->xregs[0]);
>               hvf_raise_exception(cpu, EXCP_UDEF, syn_uncategorized(), 1);
diff mbox series

Patch

diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c
index 3907ea8791e..a4f823f834d 100644
--- a/target/arm/hvf/hvf.c
+++ b/target/arm/hvf/hvf.c
@@ -17,6 +17,7 @@ 
 #include "system/hvf.h"
 #include "system/hvf_int.h"
 #include "system/hw_accel.h"
+#include "system/tcg.h"
 #include "hvf_arm.h"
 #include "cpregs.h"
 
@@ -1117,6 +1118,8 @@  static void hvf_raise_exception(CPUState *cpu, uint32_t excp,
     env->exception.syndrome = syndrome;
 
     arm_cpu_do_interrupt(cpu);
+    cpu->interrupt_request &= ~CPU_INTERRUPT_EXITTB;
+    cpu->exception_index = -1;
 }
 
 static void hvf_psci_cpu_off(ARMCPU *arm_cpu)
@@ -2090,6 +2093,9 @@  int hvf_vcpu_exec(CPUState *cpu)
                 /* SMCCC 1.3 section 5.2 says every unknown SMCCC call returns -1 */
                 env->xregs[0] = -1;
             }
+        } else if (tcg_enabled()) {
+            /* FIXME check we are called from EL1 (so EL0 -> UDEF) ? */
+            hvf_raise_exception(cpu, EXCP_HVC, syn_aa64_hvc(0), 2);
         } else {
             trace_hvf_unknown_hvc(env->pc, env->xregs[0]);
             hvf_raise_exception(cpu, EXCP_UDEF, syn_uncategorized(), 1);