[PATCH 07/18] target/arm: Hoist arm_current_el in arm_generate_debug_exceptions

Richard Henderson posted 18 patches 3 years, 1 month ago
There is a newer version of this series
[PATCH 07/18] target/arm: Hoist arm_current_el in arm_generate_debug_exceptions
Posted by Richard Henderson 3 years, 1 month ago
Read this value once in the main function, and pass it
around between the subroutines.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 target/arm/debug_helper.c | 21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)

diff --git a/target/arm/debug_helper.c b/target/arm/debug_helper.c
index 20a0e4261a..2bbf065b3a 100644
--- a/target/arm/debug_helper.c
+++ b/target/arm/debug_helper.c
@@ -13,9 +13,8 @@
 
 
 /* See AArch64.GenerateDebugExceptionsFrom() in ARM ARM pseudocode */
-static bool aa64_generate_debug_exceptions(CPUARMState *env)
+static bool aa64_generate_debug_exceptions(CPUARMState *env, int cur_el)
 {
-    int cur_el = arm_current_el(env);
     int debug_el;
 
     if (cur_el == 3) {
@@ -43,18 +42,16 @@ static bool aa64_generate_debug_exceptions(CPUARMState *env)
     return debug_el > cur_el;
 }
 
-static bool aa32_generate_debug_exceptions(CPUARMState *env)
+static bool aa32_generate_debug_exceptions(CPUARMState *env, int cur_el)
 {
-    int el = arm_current_el(env);
-
-    if (el == 0 && arm_el_is_aa64(env, 1)) {
-        return aa64_generate_debug_exceptions(env);
+    if (cur_el == 0 && arm_el_is_aa64(env, 1)) {
+        return aa64_generate_debug_exceptions(env, cur_el);
     }
 
     if (arm_is_secure(env)) {
         int spd;
 
-        if (el == 0 && (env->cp15.sder & 1)) {
+        if (cur_el == 0 && (env->cp15.sder & 1)) {
             /*
              * SDER.SUIDEN means debug exceptions from Secure EL0
              * are always enabled. Otherwise they are controlled by
@@ -82,7 +79,7 @@ static bool aa32_generate_debug_exceptions(CPUARMState *env)
         }
     }
 
-    return el != 2;
+    return cur_el != 2;
 }
 
 /*
@@ -99,10 +96,12 @@ static bool aa32_generate_debug_exceptions(CPUARMState *env)
  */
 bool arm_generate_debug_exceptions(CPUARMState *env)
 {
+    int cur_el = arm_current_el(env);
+
     if (env->aarch64) {
-        return aa64_generate_debug_exceptions(env);
+        return aa64_generate_debug_exceptions(env, cur_el);
     } else {
-        return aa32_generate_debug_exceptions(env);
+        return aa32_generate_debug_exceptions(env, cur_el);
     }
 }
 
-- 
2.34.1
Re: [PATCH 07/18] target/arm: Hoist arm_current_el in arm_generate_debug_exceptions
Posted by Peter Maydell 3 years, 1 month ago
On Mon, 23 May 2022 at 21:58, Richard Henderson
<richard.henderson@linaro.org> wrote:
>
> Read this value once in the main function, and pass it
> around between the subroutines.
>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---

What's the benefit from doing this ?

thanks
-- PMM
Re: [PATCH 07/18] target/arm: Hoist arm_current_el in arm_generate_debug_exceptions
Posted by Richard Henderson 3 years, 1 month ago
On 5/31/22 05:04, Peter Maydell wrote:
> On Mon, 23 May 2022 at 21:58, Richard Henderson
> <richard.henderson@linaro.org> wrote:
>>
>> Read this value once in the main function, and pass it
>> around between the subroutines.
>>
>> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
>> ---
> 
> What's the benefit from doing this ?

Just trying to reduce the number of times that arm_current_el is computed within these 
tightly coupled functions.


r~