target/arm: Add v8M stack checks for LDRD/STRD (imm)
commit910d7692e5b60f2c2d08cc3d6d36076e85b6a69d
authorPeter Maydell <peter.maydell@linaro.org>
Mon, 8 Oct 2018 13:55:04 +0000 (8 14:55 +0100)
committerPeter Maydell <peter.maydell@linaro.org>
Mon, 8 Oct 2018 13:55:04 +0000 (8 14:55 +0100)
treed117781d2b6012e3a029c6ced1f8de3e1675b45e
parent597610eb39f8a2d5c8146007c1ac37c623c23645
target/arm: Add v8M stack checks for LDRD/STRD (imm)

Add the v8M stack checks for:
 * LDRD (immediate)
 * STRD (immediate)

Loads and stores are more complicated than ADD/SUB/MOV, because we
must ensure that memory accesses below the stack limit are not
performed, so we can't simply do the check when we actually update
SP.

For these instructions, if the stack limit check triggers
we must not:
 * perform any memory access below the SP limit
 * update PC, SP or the load/store base register
but it is IMPDEF whether we:
 * perform any accesses above or equal to the SP limit
 * update destination registers for loads

For QEMU we choose to always check the limit before doing any other
part of the load or store, so we won't update any registers or
perform any memory accesses.

It is UNKNOWN whether the limit check triggers for a load or store
where the initial SP value is below the limit and one of the stores
would be below the limit, but the writeback moves SP to above the
limit.  For QEMU we choose to trigger the check in this situation.

Note that limit checks happen only for loads and stores which update
SP via writeback; they do not happen for loads and stores which
simply use SP as a base register.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 20181002163556.10279-9-peter.maydell@linaro.org
target/arm/translate.c