diff mbox

[08/11] target-arm: Forbid mode switch to Mon from Secure EL1

Message ID 1455556977-3644-9-git-send-email-peter.maydell@linaro.org (mailing list archive)
State New, archived
Headers show

Commit Message

Peter Maydell Feb. 15, 2016, 5:22 p.m. UTC
In v8 trying to switch mode to Mon from Secure EL1 is an
illegal mode switch. (In v7 this is impossible as all secure
modes except User are at EL3.) We can handle this case by
making a switch to Mon valid only if the current EL is 3,
which then gives the correct answer whether EL3 is AArch32
or AArch64.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 target-arm/helper.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Sergey Fedorov Feb. 18, 2016, 5:43 p.m. UTC | #1
On 15.02.2016 20:22, Peter Maydell wrote:
> In v8 trying to switch mode to Mon from Secure EL1 is an
> illegal mode switch. (In v7 this is impossible as all secure
> modes except User are at EL3.) We can handle this case by
> making a switch to Mon valid only if the current EL is 3,
> which then gives the correct answer whether EL3 is AArch32
> or AArch64.
>
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>

Reviewed-by: Sergey Fedorov <serge.fdrv@gmail.com>

> ---
>  target-arm/helper.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/target-arm/helper.c b/target-arm/helper.c
> index 4074b97..e7b3eb3 100644
> --- a/target-arm/helper.c
> +++ b/target-arm/helper.c
> @@ -5188,7 +5188,7 @@ static int bad_mode_switch(CPUARMState *env, int mode)
>          return !arm_feature(env, ARM_FEATURE_EL2)
>              || arm_current_el(env) < 2 || arm_is_secure(env);
>      case ARM_CPU_MODE_MON:
> -        return !arm_is_secure(env);
> +        return arm_current_el(env) < 3;
>      default:
>          return 1;
>      }
diff mbox

Patch

diff --git a/target-arm/helper.c b/target-arm/helper.c
index 4074b97..e7b3eb3 100644
--- a/target-arm/helper.c
+++ b/target-arm/helper.c
@@ -5188,7 +5188,7 @@  static int bad_mode_switch(CPUARMState *env, int mode)
         return !arm_feature(env, ARM_FEATURE_EL2)
             || arm_current_el(env) < 2 || arm_is_secure(env);
     case ARM_CPU_MODE_MON:
-        return !arm_is_secure(env);
+        return arm_current_el(env) < 3;
     default:
         return 1;
     }