diff mbox series

[RFC,21/27] target/arm: make further preparation for the exception code to move

Message ID 20230104215835.24692-22-farosas@suse.de (mailing list archive)
State New, archived
Headers show
Series target/arm: Allow CONFIG_TCG=n builds | expand

Commit Message

Fabiano Rosas Jan. 4, 2023, 9:58 p.m. UTC
From: Claudio Fontana <cfontana@suse.de>

the exception code needs some adjustment before being exposed to
KVM-only builds. We need to call arm_rebuild_hflags only when TCG is
enabled, or we will error out.

The direct call to helper_rebuild_hflags_a64(env, new_el) will not
be possible when extracting out to common code,
it seems safe to replace it with a call to arm_rebuild_hflags, since
the write to pstate is already done.

Signed-off-by: Claudio Fontana <cfontana@suse.de>
Signed-off-by: Fabiano Rosas <farosas@suse.de>
---
 target/arm/helper.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

Comments

Richard Henderson Jan. 5, 2023, 5:02 a.m. UTC | #1
On 1/4/23 13:58, Fabiano Rosas wrote:
> From: Claudio Fontana<cfontana@suse.de>
> 
> the exception code needs some adjustment before being exposed to
> KVM-only builds. We need to call arm_rebuild_hflags only when TCG is
> enabled, or we will error out.
> 
> The direct call to helper_rebuild_hflags_a64(env, new_el) will not
> be possible when extracting out to common code,
> it seems safe to replace it with a call to arm_rebuild_hflags, since
> the write to pstate is already done.
> 
> Signed-off-by: Claudio Fontana<cfontana@suse.de>
> Signed-off-by: Fabiano Rosas<farosas@suse.de>
> ---
>   target/arm/helper.c | 10 ++++++++--
>   1 file changed, 8 insertions(+), 2 deletions(-)

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

r~
diff mbox series

Patch

diff --git a/target/arm/helper.c b/target/arm/helper.c
index bea1ef242a..a536d77611 100644
--- a/target/arm/helper.c
+++ b/target/arm/helper.c
@@ -1131,7 +1131,9 @@  static void take_aarch32_exception(CPUARMState *env, int new_mode,
         env->regs[14] = env->regs[15] + offset;
     }
     env->regs[15] = newpc;
-    arm_rebuild_hflags(env);
+    if (tcg_enabled()) {
+        arm_rebuild_hflags(env);
+    }
 }
 
 static void arm_cpu_do_interrupt_aarch32_hyp(CPUState *cs)
@@ -1687,7 +1689,11 @@  static void arm_cpu_do_interrupt_aarch64(CPUState *cs)
     pstate_write(env, PSTATE_DAIF | new_mode);
     env->aarch64 = true;
     aarch64_restore_sp(env, new_el);
-    helper_rebuild_hflags_a64(env, new_el);
+
+    if (tcg_enabled()) {
+        /* pstate already written, so we can use arm_rebuild_hflags here */
+        arm_rebuild_hflags(env);
+    }
 
     env->pc = addr;