diff mbox

[v3,15/22] target-arm: A64: Forbid ERET to unimplemented ELs

Message ID 1400491383-6725-16-git-send-email-edgar.iglesias@gmail.com
State New
Headers show

Commit Message

Edgar E. Iglesias May 19, 2014, 9:22 a.m. UTC
From: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com>

Check for EL2 support before returning to it.

Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
---
 target-arm/op_helper.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

Comments

Peter Maydell May 21, 2014, 7:06 p.m. UTC | #1
On 19 May 2014 10:22, Edgar E. Iglesias <edgar.iglesias@gmail.com> wrote:
> From: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com>
>
> Check for EL2 support before returning to it.
>
> Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
> Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
> ---
>  target-arm/op_helper.c | 11 +++++------
>  1 file changed, 5 insertions(+), 6 deletions(-)
>
> diff --git a/target-arm/op_helper.c b/target-arm/op_helper.c
> index a6eedb2..d89755a 100644
> --- a/target-arm/op_helper.c
> +++ b/target-arm/op_helper.c
> @@ -411,12 +411,11 @@ void HELPER(exception_return)(CPUARMState *env)
>          env->regs[15] = env->elr_el[1] & ~0x1;
>      } else {
>          new_el = extract32(spsr, 2, 2);
> -        if (new_el > cur_el) {
> -            /* Disallow returns to higher ELs than the current one.  */
> -            goto illegal_return;
> -        }

...you just added this if() in the previous patch. Suggest
squashing the two together.

> -        if (new_el > 1) {
> -            /* Return to unimplemented EL */
> +        if (new_el > cur_el
> +            || (new_el == 2 && !arm_feature(env, ARM_FEATURE_EL2))) {
> +            /* Disallow return to an EL which is unimplemented or higher
> +             * than the current one.
> +             */
>              goto illegal_return;
>          }
>          if (extract32(spsr, 1, 1)) {
> --
> 1.8.3.2
>

thanks
-- PMM
Edgar E. Iglesias May 21, 2014, 11:56 p.m. UTC | #2
On Wed, May 21, 2014 at 08:06:32PM +0100, Peter Maydell wrote:
> On 19 May 2014 10:22, Edgar E. Iglesias <edgar.iglesias@gmail.com> wrote:
> > From: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com>
> >
> > Check for EL2 support before returning to it.
> >
> > Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
> > Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
> > ---
> >  target-arm/op_helper.c | 11 +++++------
> >  1 file changed, 5 insertions(+), 6 deletions(-)
> >
> > diff --git a/target-arm/op_helper.c b/target-arm/op_helper.c
> > index a6eedb2..d89755a 100644
> > --- a/target-arm/op_helper.c
> > +++ b/target-arm/op_helper.c
> > @@ -411,12 +411,11 @@ void HELPER(exception_return)(CPUARMState *env)
> >          env->regs[15] = env->elr_el[1] & ~0x1;
> >      } else {
> >          new_el = extract32(spsr, 2, 2);
> > -        if (new_el > cur_el) {
> > -            /* Disallow returns to higher ELs than the current one.  */
> > -            goto illegal_return;
> > -        }
> 
> ...you just added this if() in the previous patch. Suggest
> squashing the two together.

Squashed

> 
> > -        if (new_el > 1) {
> > -            /* Return to unimplemented EL */
> > +        if (new_el > cur_el
> > +            || (new_el == 2 && !arm_feature(env, ARM_FEATURE_EL2))) {
> > +            /* Disallow return to an EL which is unimplemented or higher
> > +             * than the current one.
> > +             */
> >              goto illegal_return;
> >          }
> >          if (extract32(spsr, 1, 1)) {
> > --
> > 1.8.3.2
> >
> 
> thanks
> -- PMM
diff mbox

Patch

diff --git a/target-arm/op_helper.c b/target-arm/op_helper.c
index a6eedb2..d89755a 100644
--- a/target-arm/op_helper.c
+++ b/target-arm/op_helper.c
@@ -411,12 +411,11 @@  void HELPER(exception_return)(CPUARMState *env)
         env->regs[15] = env->elr_el[1] & ~0x1;
     } else {
         new_el = extract32(spsr, 2, 2);
-        if (new_el > cur_el) {
-            /* Disallow returns to higher ELs than the current one.  */
-            goto illegal_return;
-        }
-        if (new_el > 1) {
-            /* Return to unimplemented EL */
+        if (new_el > cur_el
+            || (new_el == 2 && !arm_feature(env, ARM_FEATURE_EL2))) {
+            /* Disallow return to an EL which is unimplemented or higher
+             * than the current one.
+             */
             goto illegal_return;
         }
         if (extract32(spsr, 1, 1)) {