[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-arm] [PATCH 10/13] target/arm: Add v8M stack checks for T32 load/s
From: |
Peter Maydell |
Subject: |
[Qemu-arm] [PATCH 10/13] target/arm: Add v8M stack checks for T32 load/store single |
Date: |
Tue, 2 Oct 2018 17:35:53 +0100 |
Add v8M stack checks for the instructions in the T32
"load/store single" encoding class: these are the
"immediate pre-indexed" and "immediate, post-indexed"
LDR and STR instructions.
Signed-off-by: Peter Maydell <address@hidden>
---
target/arm/translate.c | 23 ++++++++++++++++++++++-
1 file changed, 22 insertions(+), 1 deletion(-)
diff --git a/target/arm/translate.c b/target/arm/translate.c
index 3fb378a492d..65df8d6975c 100644
--- a/target/arm/translate.c
+++ b/target/arm/translate.c
@@ -11624,7 +11624,6 @@ static void disas_thumb2_insn(DisasContext *s, uint32_t
insn)
imm = -imm;
/* Fall through. */
case 0xf: /* Pre-increment. */
- tcg_gen_addi_i32(addr, addr, imm);
writeback = 1;
break;
default:
@@ -11636,6 +11635,28 @@ static void disas_thumb2_insn(DisasContext *s,
uint32_t insn)
issinfo = writeback ? ISSInvalid : rs;
+ if (s->v8m_stackcheck && rn == 13 && writeback) {
+ /*
+ * Stackcheck. Here we know 'addr' is the current SP;
+ * if imm is +ve we're moving SP up, else down. It is
+ * UNKNOWN whether the limit check triggers when SP starts
+ * below the limit and ends up above it; we chose to do so.
+ */
+ if ((int32_t)imm < 0) {
+ TCGv_i32 newsp = tcg_temp_new_i32();
+
+ tcg_gen_addi_i32(newsp, addr, imm);
+ gen_helper_v8m_stackcheck(cpu_env, newsp);
+ tcg_temp_free_i32(newsp);
+ } else {
+ gen_helper_v8m_stackcheck(cpu_env, addr);
+ }
+ }
+
+ if (writeback && !postinc) {
+ tcg_gen_addi_i32(addr, addr, imm);
+ }
+
if (insn & (1 << 20)) {
/* Load. */
tmp = tcg_temp_new_i32();
--
2.19.0
- Re: [Qemu-arm] [Qemu-devel] [PATCH 06/13] target/arm: Add v8M stack checks on exception entry, (continued)
- [Qemu-arm] [PATCH 09/13] target/arm: Add v8M stack checks for Thumb2 LDM/STM, Peter Maydell, 2018/10/02
- [Qemu-arm] [PATCH 07/13] target/arm: Add v8M stack limit checks on NS function calls, Peter Maydell, 2018/10/02
- [Qemu-arm] [PATCH 08/13] target/arm: Add v8M stack checks for LDRD/STRD (imm), Peter Maydell, 2018/10/02
- [Qemu-arm] [PATCH 10/13] target/arm: Add v8M stack checks for T32 load/store single,
Peter Maydell <=
- [Qemu-arm] [PATCH 11/13] target/arm: Add v8M stack checks for Thumb push/pop, Peter Maydell, 2018/10/02
- [Qemu-arm] [PATCH 13/13] target/arm: Add v8M stack checks for MSR to SP_NS, Peter Maydell, 2018/10/02
- [Qemu-arm] [PATCH 12/13] target/arm: Add v8M stack checks for VLDM/VSTM, Peter Maydell, 2018/10/02