diff mbox series

[12/13] target/arm: Add v8M stack checks for VLDM/VSTM

Message ID 20181002163556.10279-13-peter.maydell@linaro.org
State Superseded
Headers show
Series target/arm: Implement v8M stack limit checks | expand

Commit Message

Peter Maydell Oct. 2, 2018, 4:35 p.m. UTC
Add the v8M stack checks for the VLDM/VSTM
(aka VPUSH/VPOP) instructions. This code is currently
unreachable because we haven't yet implemented M profile
floating point support, but since the change is simple,
we add it now because otherwise we're likely to forget to
do it later.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>

---
 target/arm/translate.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

-- 
2.19.0

Comments

Philippe Mathieu-Daudé Oct. 3, 2018, 9:55 a.m. UTC | #1
On 02/10/2018 18:35, Peter Maydell wrote:
> Add the v8M stack checks for the VLDM/VSTM

> (aka VPUSH/VPOP) instructions. This code is currently

> unreachable because we haven't yet implemented M profile

> floating point support, but since the change is simple,

> we add it now because otherwise we're likely to forget to

> do it later.

> 

> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>

> ---

>  target/arm/translate.c | 12 ++++++++++++

>  1 file changed, 12 insertions(+)

> 

> diff --git a/target/arm/translate.c b/target/arm/translate.c

> index ef64d2559de..2d3a1be518b 100644

> --- a/target/arm/translate.c

> +++ b/target/arm/translate.c

> @@ -4229,6 +4229,18 @@ static int disas_vfp_insn(DisasContext *s, uint32_t insn)

>                  if (insn & (1 << 24)) /* pre-decrement */

>                      tcg_gen_addi_i32(addr, addr, -((insn & 0xff) << 2));

>  

> +                if (rn == 13 && w && s->v8m_stackcheck) {


Following previous patches style:

                   if (s->v8m_stackcheck && rn == 13 && w) {

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>


> +                    /*

> +                     * Here 'addr' is the lowest address we will store to,

> +                     * and is either the old SP (if post-increment) or

> +                     * the new SP (if pre-decrement). For post-increment

> +                     * where the old value is below the limit and the new

> +                     * value is above, it is UNKNOWN whether the limit check

> +                     * triggers; we choose to trigger.

> +                     */

> +                    gen_helper_v8m_stackcheck(cpu_env, addr);

> +                }

> +

>                  if (dp)

>                      offset = 8;

>                  else

>
Richard Henderson Oct. 3, 2018, 8:20 p.m. UTC | #2
On 10/2/18 11:35 AM, Peter Maydell wrote:
> Add the v8M stack checks for the VLDM/VSTM

> (aka VPUSH/VPOP) instructions. This code is currently

> unreachable because we haven't yet implemented M profile

> floating point support, but since the change is simple,

> we add it now because otherwise we're likely to forget to

> do it later.

> 

> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>

> ---

>  target/arm/translate.c | 12 ++++++++++++

>  1 file changed, 12 insertions(+)


Reviewed-by: Richard Henderson <richard.henderson@linaro.org>


r~
Richard Henderson Oct. 3, 2018, 8:21 p.m. UTC | #3
On 10/2/18 11:35 AM, Peter Maydell wrote:
> Add the v8M stack checks for the VLDM/VSTM

> (aka VPUSH/VPOP) instructions. This code is currently

> unreachable because we haven't yet implemented M profile

> floating point support, but since the change is simple,

> we add it now because otherwise we're likely to forget to

> do it later.

> 

> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>

> ---

>  target/arm/translate.c | 12 ++++++++++++

>  1 file changed, 12 insertions(+)


Reviewed-by: Richard Henderson <richard.henderson@linaro.org>


r~
diff mbox series

Patch

diff --git a/target/arm/translate.c b/target/arm/translate.c
index ef64d2559de..2d3a1be518b 100644
--- a/target/arm/translate.c
+++ b/target/arm/translate.c
@@ -4229,6 +4229,18 @@  static int disas_vfp_insn(DisasContext *s, uint32_t insn)
                 if (insn & (1 << 24)) /* pre-decrement */
                     tcg_gen_addi_i32(addr, addr, -((insn & 0xff) << 2));
 
+                if (rn == 13 && w && s->v8m_stackcheck) {
+                    /*
+                     * Here 'addr' is the lowest address we will store to,
+                     * and is either the old SP (if post-increment) or
+                     * the new SP (if pre-decrement). For post-increment
+                     * where the old value is below the limit and the new
+                     * value is above, it is UNKNOWN whether the limit check
+                     * triggers; we choose to trigger.
+                     */
+                    gen_helper_v8m_stackcheck(cpu_env, addr);
+                }
+
                 if (dp)
                     offset = 8;
                 else