Philippe Mathieu-Daudé <phi...@redhat.com> writes:
> Signed-off-by: Philippe Mathieu-Daudé <phi...@redhat.com> Reviewed-by: Alex Bennée <alex.ben...@linaro.org> > --- > target/arm/helper.c | 73 ----------------------------------------- > target/arm/v7m_helper.c | 73 +++++++++++++++++++++++++++++++++++++++++ > 2 files changed, 73 insertions(+), 73 deletions(-) > > diff --git a/target/arm/helper.c b/target/arm/helper.c > index b4fd9b42d7..cf76010ea1 100644 > --- a/target/arm/helper.c > +++ b/target/arm/helper.c > @@ -7885,79 +7885,6 @@ void HELPER(v7m_preserve_fp_state)(CPUARMState *env) > */ > } > > -/* > - * Write to v7M CONTROL.SPSEL bit for the specified security bank. > - * This may change the current stack pointer between Main and Process > - * stack pointers if it is done for the CONTROL register for the current > - * security state. > - */ > -void write_v7m_control_spsel_for_secstate(CPUARMState *env, > - bool new_spsel, > - bool secstate) > -{ > - bool old_is_psp = v7m_using_psp(env); > - > - env->v7m.control[secstate] = > - deposit32(env->v7m.control[secstate], > - R_V7M_CONTROL_SPSEL_SHIFT, > - R_V7M_CONTROL_SPSEL_LENGTH, new_spsel); > - > - if (secstate == env->v7m.secure) { > - bool new_is_psp = v7m_using_psp(env); > - uint32_t tmp; > - > - if (old_is_psp != new_is_psp) { > - tmp = env->v7m.other_sp; > - env->v7m.other_sp = env->regs[13]; > - env->regs[13] = tmp; > - } > - } > -} > - > -/* > - * Write to v7M CONTROL.SPSEL bit. This may change the current > - * stack pointer between Main and Process stack pointers. > - */ > -void write_v7m_control_spsel(CPUARMState *env, bool new_spsel) > -{ > - write_v7m_control_spsel_for_secstate(env, new_spsel, env->v7m.secure); > -} > - > -/* Switch M profile security state between NS and S */ > -void switch_v7m_security_state(CPUARMState *env, bool new_secstate) > -{ > - uint32_t new_ss_msp, new_ss_psp; > - > - if (env->v7m.secure == new_secstate) { > - return; > - } > - > - /* > - * All the banked state is accessed by looking at env->v7m.secure > - * except for the stack pointer; rearrange the SP appropriately. > - */ > - new_ss_msp = env->v7m.other_ss_msp; > - new_ss_psp = env->v7m.other_ss_psp; > - > - if (v7m_using_psp(env)) { > - env->v7m.other_ss_psp = env->regs[13]; > - env->v7m.other_ss_msp = env->v7m.other_sp; > - } else { > - env->v7m.other_ss_msp = env->regs[13]; > - env->v7m.other_ss_psp = env->v7m.other_sp; > - } > - > - env->v7m.secure = new_secstate; > - > - if (v7m_using_psp(env)) { > - env->regs[13] = new_ss_psp; > - env->v7m.other_sp = new_ss_msp; > - } else { > - env->regs[13] = new_ss_msp; > - env->v7m.other_sp = new_ss_psp; > - } > -} > - > static uint32_t *get_v7m_sp_ptr(CPUARMState *env, bool secure, bool > threadmode, > bool spsel) > { > diff --git a/target/arm/v7m_helper.c b/target/arm/v7m_helper.c > index 321154966e..558e143039 100644 > --- a/target/arm/v7m_helper.c > +++ b/target/arm/v7m_helper.c > @@ -88,6 +88,79 @@ uint32_t HELPER(v7m_tt)(CPUARMState *env, uint32_t addr, > uint32_t op) > > #else > > +/* > + * Write to v7M CONTROL.SPSEL bit for the specified security bank. > + * This may change the current stack pointer between Main and Process > + * stack pointers if it is done for the CONTROL register for the current > + * security state. > + */ > +void write_v7m_control_spsel_for_secstate(CPUARMState *env, > + bool new_spsel, > + bool secstate) > +{ > + bool old_is_psp = v7m_using_psp(env); > + > + env->v7m.control[secstate] = > + deposit32(env->v7m.control[secstate], > + R_V7M_CONTROL_SPSEL_SHIFT, > + R_V7M_CONTROL_SPSEL_LENGTH, new_spsel); > + > + if (secstate == env->v7m.secure) { > + bool new_is_psp = v7m_using_psp(env); > + uint32_t tmp; > + > + if (old_is_psp != new_is_psp) { > + tmp = env->v7m.other_sp; > + env->v7m.other_sp = env->regs[13]; > + env->regs[13] = tmp; > + } > + } > +} > + > +/* > + * Write to v7M CONTROL.SPSEL bit. This may change the current > + * stack pointer between Main and Process stack pointers. > + */ > +void write_v7m_control_spsel(CPUARMState *env, bool new_spsel) > +{ > + write_v7m_control_spsel_for_secstate(env, new_spsel, env->v7m.secure); > +} > + > +/* Switch M profile security state between NS and S */ > +void switch_v7m_security_state(CPUARMState *env, bool new_secstate) > +{ > + uint32_t new_ss_msp, new_ss_psp; > + > + if (env->v7m.secure == new_secstate) { > + return; > + } > + > + /* > + * All the banked state is accessed by looking at env->v7m.secure > + * except for the stack pointer; rearrange the SP appropriately. > + */ > + new_ss_msp = env->v7m.other_ss_msp; > + new_ss_psp = env->v7m.other_ss_psp; > + > + if (v7m_using_psp(env)) { > + env->v7m.other_ss_psp = env->regs[13]; > + env->v7m.other_ss_msp = env->v7m.other_sp; > + } else { > + env->v7m.other_ss_msp = env->regs[13]; > + env->v7m.other_ss_psp = env->v7m.other_sp; > + } > + > + env->v7m.secure = new_secstate; > + > + if (v7m_using_psp(env)) { > + env->regs[13] = new_ss_psp; > + env->v7m.other_sp = new_ss_msp; > + } else { > + env->regs[13] = new_ss_msp; > + env->v7m.other_sp = new_ss_psp; > + } > +} > + > void HELPER(v7m_bxns)(CPUARMState *env, uint32_t dest) > { > /* -- Alex Bennée