diff mbox

[v1,16/22] target-arm: A64: Forbid ERET to unimplemented ELs

Message ID 1399356506-5609-17-git-send-email-edgar.iglesias@gmail.com
State New
Headers show

Commit Message

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

Check for EL2 support before returning to it.

Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
---
 target-arm/op_helper.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

Comments

Peter Crosthwaite May 7, 2014, 6:04 a.m. UTC | #1
On Tue, May 6, 2014 at 4:08 PM, Edgar E. Iglesias
<edgar.iglesias@gmail.com> wrote:
> From: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com>
>
> Check for EL2 support before returning to it.
>
> Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>

Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>

> ---
>  target-arm/op_helper.c | 8 +++-----
>  1 file changed, 3 insertions(+), 5 deletions(-)
>
> diff --git a/target-arm/op_helper.c b/target-arm/op_helper.c
> index 770c776..f1ae05e 100644
> --- a/target-arm/op_helper.c
> +++ b/target-arm/op_helper.c
> @@ -411,12 +411,10 @@ void HELPER(exception_return)(CPUARMState *env)
>          env->regs[15] = env->elr_el[ELR_EL_IDX(1)] & ~0x1;
>      } else {
>          new_el = extract32(spsr, 2, 2);
> -        if (new_el > cur_el) {
> +        if (new_el > cur_el
> +            || (new_el == 2 && !arm_feature(env, ARM_FEATURE_EL2))) {
>              /* Disallow returns to higher ELs than the current one.  */
> -            goto illegal_return;
> -        }
> -        if (new_el > 1) {
> -            /* Return to unimplemented EL */
> +            /* Disallow returns to unimplemented ELs.  */
>              goto illegal_return;
>          }
>          if (extract32(spsr, 1, 1)) {
> --
> 1.8.3.2
>
>
Peter Maydell May 7, 2014, 9 a.m. UTC | #2
On 6 May 2014 07:08, Edgar E. Iglesias <edgar.iglesias@gmail.com> wrote:
> From: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com>
>
> Check for EL2 support before returning to it.
>
> Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
> ---
>  target-arm/op_helper.c | 8 +++-----
>  1 file changed, 3 insertions(+), 5 deletions(-)
>
> diff --git a/target-arm/op_helper.c b/target-arm/op_helper.c
> index 770c776..f1ae05e 100644
> --- a/target-arm/op_helper.c
> +++ b/target-arm/op_helper.c
> @@ -411,12 +411,10 @@ void HELPER(exception_return)(CPUARMState *env)
>          env->regs[15] = env->elr_el[ELR_EL_IDX(1)] & ~0x1;
>      } else {
>          new_el = extract32(spsr, 2, 2);
> -        if (new_el > cur_el) {
> +        if (new_el > cur_el
> +            || (new_el == 2 && !arm_feature(env, ARM_FEATURE_EL2))) {
>              /* Disallow returns to higher ELs than the current one.  */
> -            goto illegal_return;
> -        }
> -        if (new_el > 1) {
> -            /* Return to unimplemented EL */
> +            /* Disallow returns to unimplemented ELs.  */

Merge the comments rather than having two one-liners one after
the other, please.
 /* Disallow return to an EL which is unimplemented or higher
  * than the current one.
  */

thanks
-- PMM
Edgar E. Iglesias May 8, 2014, 12:14 a.m. UTC | #3
On Wed, May 07, 2014 at 10:00:11AM +0100, Peter Maydell wrote:
> On 6 May 2014 07:08, Edgar E. Iglesias <edgar.iglesias@gmail.com> wrote:
> > From: "Edgar E. Iglesias" <edgar.iglesias@xilinx.com>
> >
> > Check for EL2 support before returning to it.
> >
> > Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
> > ---
> >  target-arm/op_helper.c | 8 +++-----
> >  1 file changed, 3 insertions(+), 5 deletions(-)
> >
> > diff --git a/target-arm/op_helper.c b/target-arm/op_helper.c
> > index 770c776..f1ae05e 100644
> > --- a/target-arm/op_helper.c
> > +++ b/target-arm/op_helper.c
> > @@ -411,12 +411,10 @@ void HELPER(exception_return)(CPUARMState *env)
> >          env->regs[15] = env->elr_el[ELR_EL_IDX(1)] & ~0x1;
> >      } else {
> >          new_el = extract32(spsr, 2, 2);
> > -        if (new_el > cur_el) {
> > +        if (new_el > cur_el
> > +            || (new_el == 2 && !arm_feature(env, ARM_FEATURE_EL2))) {
> >              /* Disallow returns to higher ELs than the current one.  */
> > -            goto illegal_return;
> > -        }
> > -        if (new_el > 1) {
> > -            /* Return to unimplemented EL */
> > +            /* Disallow returns to unimplemented ELs.  */
> 
> Merge the comments rather than having two one-liners one after
> the other, please.
>  /* Disallow return to an EL which is unimplemented or higher
>   * than the current one.
>   */

Fixed for v2, thanks.

Cheers,
Edgar
diff mbox

Patch

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