[Qemu-devel] [PATCH 06/20] target/arm: Fix arm_current_el for user-only

Richard Henderson posted 20 patches 7 years, 2 months ago
There is a newer version of this series
[Qemu-devel] [PATCH 06/20] target/arm: Fix arm_current_el for user-only
Posted by Richard Henderson 7 years, 2 months ago
Saves about 12k code size in qemu-aarch64.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 target/arm/cpu.h | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/target/arm/cpu.h b/target/arm/cpu.h
index 2d6d7d03aa..aedaf2631e 100644
--- a/target/arm/cpu.h
+++ b/target/arm/cpu.h
@@ -1958,6 +1958,9 @@ static inline bool arm_v7m_is_handler_mode(CPUARMState *env)
  */
 static inline int arm_current_el(CPUARMState *env)
 {
+#ifdef CONFIG_USER_ONLY
+    return 0;
+#else
     if (arm_feature(env, ARM_FEATURE_M)) {
         return arm_v7m_is_handler_mode(env) ||
             !(env->v7m.control[env->v7m.secure] & 1);
@@ -1984,6 +1987,7 @@ static inline int arm_current_el(CPUARMState *env)
 
         return 1;
     }
+#endif
 }
 
 typedef struct ARMCPRegInfo ARMCPRegInfo;
-- 
2.17.1


Re: [Qemu-devel] [PATCH 06/20] target/arm: Fix arm_current_el for user-only
Posted by Peter Maydell 7 years, 2 months ago
On 9 August 2018 at 05:21, Richard Henderson
<richard.henderson@linaro.org> wrote:
> Saves about 12k code size in qemu-aarch64.
>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
>  target/arm/cpu.h | 4 ++++
>  1 file changed, 4 insertions(+)
>
> diff --git a/target/arm/cpu.h b/target/arm/cpu.h
> index 2d6d7d03aa..aedaf2631e 100644
> --- a/target/arm/cpu.h
> +++ b/target/arm/cpu.h
> @@ -1958,6 +1958,9 @@ static inline bool arm_v7m_is_handler_mode(CPUARMState *env)
>   */
>  static inline int arm_current_el(CPUARMState *env)
>  {
> +#ifdef CONFIG_USER_ONLY
> +    return 0;
> +#else
>      if (arm_feature(env, ARM_FEATURE_M)) {
>          return arm_v7m_is_handler_mode(env) ||
>              !(env->v7m.control[env->v7m.secure] & 1);
> @@ -1984,6 +1987,7 @@ static inline int arm_current_el(CPUARMState *env)
>
>          return 1;
>      }
> +#endif

Again, the #ifdeffery here should be unnecessary ? env->pstate,
env->uncached_cpsr, etc should be set so that we return the
right thing.

thanks
-- PMM

Re: [Qemu-devel] [PATCH 06/20] target/arm: Fix arm_current_el for user-only
Posted by Richard Henderson 7 years, 2 months ago
On 08/17/2018 09:03 AM, Peter Maydell wrote:
> On 9 August 2018 at 05:21, Richard Henderson
> <richard.henderson@linaro.org> wrote:
>> Saves about 12k code size in qemu-aarch64.
>>
>> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
>> ---
>>  target/arm/cpu.h | 4 ++++
>>  1 file changed, 4 insertions(+)
>>
>> diff --git a/target/arm/cpu.h b/target/arm/cpu.h
>> index 2d6d7d03aa..aedaf2631e 100644
>> --- a/target/arm/cpu.h
>> +++ b/target/arm/cpu.h
>> @@ -1958,6 +1958,9 @@ static inline bool arm_v7m_is_handler_mode(CPUARMState *env)
>>   */
>>  static inline int arm_current_el(CPUARMState *env)
>>  {
>> +#ifdef CONFIG_USER_ONLY
>> +    return 0;
>> +#else
>>      if (arm_feature(env, ARM_FEATURE_M)) {
>>          return arm_v7m_is_handler_mode(env) ||
>>              !(env->v7m.control[env->v7m.secure] & 1);
>> @@ -1984,6 +1987,7 @@ static inline int arm_current_el(CPUARMState *env)
>>
>>          return 1;
>>      }
>> +#endif
> 
> Again, the #ifdeffery here should be unnecessary ? env->pstate,
> env->uncached_cpsr, etc should be set so that we return the
> right thing.

We get the right result, but you should have a look at how large the expansion
of this function is.


r~