qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Richard Henderson <richard.henderson@linaro.org>
To: qemu-devel@nongnu.org
Cc: qemu-arm@nongnu.org
Subject: [PATCH 03/18] target/arm: Move and expand parameters to exception_target_el
Date: Mon, 23 May 2022 13:47:27 -0700	[thread overview]
Message-ID: <20220523204742.740932-4-richard.henderson@linaro.org> (raw)
In-Reply-To: <20220523204742.740932-1-richard.henderson@linaro.org>

Move exception_target_el out of line.
Add cur_el parameter, because 2 of 3 users already have that handy.
Add psyn parameter in preparation for more code movement.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 target/arm/internals.h  | 15 +--------------
 target/arm/op_helper.c  | 17 ++++++++++++++++-
 target/arm/tlb_helper.c | 10 ++++++----
 3 files changed, 23 insertions(+), 19 deletions(-)

diff --git a/target/arm/internals.h b/target/arm/internals.h
index 03363b0f32..a71f795628 100644
--- a/target/arm/internals.h
+++ b/target/arm/internals.h
@@ -1091,20 +1091,7 @@ typedef struct ARMVAParameters {
 ARMVAParameters aa64_va_parameters(CPUARMState *env, uint64_t va,
                                    ARMMMUIdx mmu_idx, bool data);
 
-static inline int exception_target_el(CPUARMState *env)
-{
-    int target_el = MAX(1, arm_current_el(env));
-
-    /*
-     * No such thing as secure EL1 if EL3 is aarch32,
-     * so update the target EL to EL3 in this case.
-     */
-    if (arm_is_secure(env) && !arm_el_is_aa64(env, 3) && target_el == 1) {
-        target_el = 3;
-    }
-
-    return target_el;
-}
+int exception_target_el(CPUARMState *env, int cur_el, uint32_t *psyn);
 
 /* Determine if allocation tags are available.  */
 static inline bool allocation_tag_access_enabled(CPUARMState *env, int el,
diff --git a/target/arm/op_helper.c b/target/arm/op_helper.c
index 61e9c1d903..6858b8980d 100644
--- a/target/arm/op_helper.c
+++ b/target/arm/op_helper.c
@@ -28,6 +28,21 @@
 #define SIGNBIT (uint32_t)0x80000000
 #define SIGNBIT64 ((uint64_t)1 << 63)
 
+int exception_target_el(CPUARMState *env, int cur_el, uint32_t *psyn)
+{
+    int target_el = MAX(1, cur_el);
+
+    /*
+     * No such thing as secure EL1 if EL3 is aarch32,
+     * so update the target EL to EL3 in this case.
+     */
+    if (arm_is_secure(env) && !arm_el_is_aa64(env, 3) && target_el == 1) {
+        target_el = 3;
+    }
+
+    return target_el;
+}
+
 void raise_exception(CPUARMState *env, uint32_t excp, uint32_t syndrome,
                      uint32_t cur_or_target_el)
 {
@@ -35,7 +50,7 @@ void raise_exception(CPUARMState *env, uint32_t excp, uint32_t syndrome,
     int target_el = cur_or_target_el;
 
     if (cur_or_target_el == 0) {
-        target_el = exception_target_el(env);
+        target_el = exception_target_el(env, 0, &syndrome);
     }
 
     if (target_el == 1 && (arm_hcr_el2_eff(env) & HCR_TGE)) {
diff --git a/target/arm/tlb_helper.c b/target/arm/tlb_helper.c
index 6421e16202..573e18f830 100644
--- a/target/arm/tlb_helper.c
+++ b/target/arm/tlb_helper.c
@@ -85,11 +85,13 @@ void arm_deliver_fault(ARMCPU *cpu, vaddr addr,
                        int mmu_idx, ARMMMUFaultInfo *fi)
 {
     CPUARMState *env = &cpu->env;
-    int target_el;
+    int cur_el, target_el;
     bool same_el;
     uint32_t syn, exc, fsr, fsc;
 
-    target_el = exception_target_el(env);
+    cur_el = arm_current_el(env);
+    target_el = exception_target_el(env, cur_el, NULL);
+
     if (fi->stage2) {
         target_el = 2;
         env->cp15.hpfar_el2 = extract64(fi->s2addr, 12, 47) << 4;
@@ -97,7 +99,7 @@ void arm_deliver_fault(ARMCPU *cpu, vaddr addr,
             env->cp15.hpfar_el2 |= HPFAR_NS;
         }
     }
-    same_el = (arm_current_el(env) == target_el);
+    same_el = cur_el == target_el;
 
     fsr = compute_fsr_fsc(env, fi, target_el, mmu_idx, &fsc);
 
@@ -139,7 +141,7 @@ void arm_cpu_do_unaligned_access(CPUState *cs, vaddr vaddr,
 void helper_exception_pc_alignment(CPUARMState *env, target_ulong pc)
 {
     ARMMMUFaultInfo fi = { .type = ARMFault_Alignment };
-    int target_el = exception_target_el(env);
+    int target_el = exception_target_el(env, arm_current_el(env), NULL);
     int mmu_idx = cpu_mmu_index(env, true);
     uint32_t fsc;
 
-- 
2.34.1



  parent reply	other threads:[~2022-05-23 20:51 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-23 20:47 [PATCH 00/18] target/arm: tidy exception routing Richard Henderson
2022-05-23 20:47 ` [PATCH 01/18] target/arm: Allow raise_exception to handle finding target EL Richard Henderson
2022-05-30 12:44   ` Peter Maydell
2022-05-30 16:39     ` Richard Henderson
2022-05-30 19:01       ` Peter Maydell
2022-05-30 19:51         ` Richard Henderson
2022-05-23 20:47 ` [PATCH 02/18] target/arm: Use arm_current_el for simple exceptions Richard Henderson
2022-05-30 12:42   ` Peter Maydell
2022-05-23 20:47 ` Richard Henderson [this message]
2022-05-23 20:47 ` [PATCH 04/18] target/arm: Move HCR_TGE check into exception_target_el Richard Henderson
2022-05-23 20:47 ` [PATCH 05/18] target/arm: Move arm_singlestep_active out of line Richard Henderson
2022-05-31 12:03   ` Peter Maydell
2022-05-23 20:47 ` [PATCH 06/18] target/arm: Move arm_generate_debug_exceptions " Richard Henderson
2022-05-31 12:03   ` Peter Maydell
2022-05-23 20:47 ` [PATCH 07/18] target/arm: Hoist arm_current_el in arm_generate_debug_exceptions Richard Henderson
2022-05-31 12:04   ` Peter Maydell
2022-05-31 14:31     ` Richard Henderson
2022-05-23 20:47 ` [PATCH 08/18] target/arm: Use is_a64 " Richard Henderson
2022-05-31 12:05   ` Peter Maydell
2022-05-23 20:47 ` [PATCH 09/18] target/arm: Move exception_bkpt_insn to debug_helper.c Richard Henderson
2022-05-23 20:47 ` [PATCH 10/18] target/arm: Move arm_debug_exception_fsr " Richard Henderson
2022-05-23 20:47 ` [PATCH 11/18] target/arm: Move arm_debug_target_el to internals.h Richard Henderson
2022-05-31 12:06   ` Peter Maydell
2022-05-23 20:47 ` [PATCH 12/18] target/arm: Create raise_exception_debug Richard Henderson
2022-05-23 20:47 ` [PATCH 13/18] target/arm: Move MDCR_TDE test into exception_target_el Richard Henderson
2022-05-23 20:47 ` [PATCH 14/18] target/arm: Mark exception helpers as noreturn Richard Henderson
2022-05-31 12:06   ` Peter Maydell
2022-05-23 20:47 ` [PATCH 15/18] target/arm: Create helper_exception_swstep Richard Henderson
2022-05-23 20:47 ` [PATCH 16/18] target/arm: Remove TBFLAG_ANY.DEBUG_TARGET_EL Richard Henderson
2022-05-23 20:47 ` [PATCH 17/18] target/arm: Add cur_el parameter to arm_generate_debug_exceptions Richard Henderson
2022-05-31 12:07   ` Peter Maydell
2022-05-31 14:34     ` Richard Henderson
2022-05-23 20:47 ` [PATCH 18/18] target/arm: Remove route_to_el2 case from sve_exception_el Richard Henderson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220523204742.740932-4-richard.henderson@linaro.org \
    --to=richard.henderson@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).