diff mbox

[[PATCH] 2/7] target-arm: Extend helpers to route exceptions

Message ID 1427483446-31900-3-git-send-email-greg.bellows@linaro.org
State New
Headers show

Commit Message

Greg Bellows March 27, 2015, 7:10 p.m. UTC
Updated the various helper routines to set the target EL as needed.

Signed-off-by: Greg Bellows <greg.bellows@linaro.org>
---
 target-arm/op_helper.c | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Peter Maydell April 16, 2015, 5:51 p.m. UTC | #1
On 27 March 2015 at 19:10, Greg Bellows <greg.bellows@linaro.org> wrote:
> Updated the various helper routines to set the target EL as needed.
>
> Signed-off-by: Greg Bellows <greg.bellows@linaro.org>
> ---
>  target-arm/op_helper.c | 5 +++++
>  1 file changed, 5 insertions(+)
>
> diff --git a/target-arm/op_helper.c b/target-arm/op_helper.c
> index 72a973a..aa175b5 100644
> --- a/target-arm/op_helper.c
> +++ b/target-arm/op_helper.c
> @@ -306,6 +306,7 @@ void HELPER(access_check_cp_reg)(CPUARMState *env, void *rip, uint32_t syndrome)
>      if (arm_feature(env, ARM_FEATURE_XSCALE) && ri->cp < 14
>          && extract32(env->cp15.c15_cpar, ri->cp, 1) == 0) {
>          env->exception.syndrome = syndrome;
> +        env->exception.target_el = MAX(arm_current_el(env), 1);

Again, I don't think we should have all these MAX()es.

-- PMM
Greg Bellows April 21, 2015, 10:13 p.m. UTC | #2
On Thu, Apr 16, 2015 at 12:51 PM, Peter Maydell <peter.maydell@linaro.org>
wrote:

> On 27 March 2015 at 19:10, Greg Bellows <greg.bellows@linaro.org> wrote:
> > Updated the various helper routines to set the target EL as needed.
> >
> > Signed-off-by: Greg Bellows <greg.bellows@linaro.org>
> > ---
> >  target-arm/op_helper.c | 5 +++++
> >  1 file changed, 5 insertions(+)
> >
> > diff --git a/target-arm/op_helper.c b/target-arm/op_helper.c
> > index 72a973a..aa175b5 100644
> > --- a/target-arm/op_helper.c
> > +++ b/target-arm/op_helper.c
> > @@ -306,6 +306,7 @@ void HELPER(access_check_cp_reg)(CPUARMState *env,
> void *rip, uint32_t syndrome)
> >      if (arm_feature(env, ARM_FEATURE_XSCALE) && ri->cp < 14
> >          && extract32(env->cp15.c15_cpar, ri->cp, 1) == 0) {
> >          env->exception.syndrome = syndrome;
> > +        env->exception.target_el = MAX(arm_current_el(env), 1);
>
> Again, I don't think we should have all these MAX()es.
>

​Added a dedicated function for determining the exception el.  Note this is
different than the one needed in translate as they take different input
criteria. I can create a common core function with two wrappers, but that
seems excessive.​


>
> -- PMM
>
diff mbox

Patch

diff --git a/target-arm/op_helper.c b/target-arm/op_helper.c
index 72a973a..aa175b5 100644
--- a/target-arm/op_helper.c
+++ b/target-arm/op_helper.c
@@ -306,6 +306,7 @@  void HELPER(access_check_cp_reg)(CPUARMState *env, void *rip, uint32_t syndrome)
     if (arm_feature(env, ARM_FEATURE_XSCALE) && ri->cp < 14
         && extract32(env->cp15.c15_cpar, ri->cp, 1) == 0) {
         env->exception.syndrome = syndrome;
+        env->exception.target_el = MAX(arm_current_el(env), 1);
         raise_exception(env, EXCP_UDEF);
     }
 
@@ -363,6 +364,7 @@  void HELPER(msr_i_pstate)(CPUARMState *env, uint32_t op, uint32_t imm)
      * to catch that case at translate time.
      */
     if (arm_current_el(env) == 0 && !(env->cp15.sctlr_el[1] & SCTLR_UMA)) {
+        env->exception.target_el = MAX(arm_current_el(env), 1);
         raise_exception(env, EXCP_UDEF);
     }
 
@@ -422,6 +424,7 @@  void HELPER(pre_hvc)(CPUARMState *env)
 
     if (undef) {
         env->exception.syndrome = syn_uncategorized();
+        env->exception.target_el = MAX(arm_current_el(env), 1);
         raise_exception(env, EXCP_UDEF);
     }
 }
@@ -452,11 +455,13 @@  void HELPER(pre_smc)(CPUARMState *env, uint32_t syndrome)
     } else if (!secure && cur_el == 1 && (env->cp15.hcr_el2 & HCR_TSC)) {
         /* In NS EL1, HCR controlled routing to EL2 has priority over SMD. */
         env->exception.syndrome = syndrome;
+        env->exception.target_el = 2;
         raise_exception(env, EXCP_HYP_TRAP);
     }
 
     if (undef) {
         env->exception.syndrome = syn_uncategorized();
+        env->exception.target_el = MAX(arm_current_el(env), 1);
         raise_exception(env, EXCP_UDEF);
     }
 }