Skip to contentSkip to conversation

arm: Steps towards EL2 support round 6

PATCH Superseded Edgar E. Iglesias 3 participants 16 messages Feb 19, 2016 – Apr 29, 2016

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v2 cover arm: Steps towards EL2 support round 6

From: "Edgar E. Iglesias" <[email protected]>

Hi,

Another round of patches towards EL2 support. This one adds partial Instruction Syndrome generation for Data Aborts while running in AArch64.

I don't feel very confident with the way I collect the regsize info used to fill out the SF field. Feedback on that would be great.

Once we sort out the details on how this should be implemented we can fill out the parts needed for AArch32. Possibly in a future version of this same series.

Comments welcome!

Best regards,
Edgar

ChangeLog:

v1 -> v2:
* Reworked the syndrome generation code to reuse syn_data_abort for the encoding.
* Reworded a bunch of comments.
* Fixed thumb vs 16bit IL field issue.

Edgar E. Iglesias (8):
tcg: Add tcg_set_insn_param
gen-icount: Use tcg_set_insn_param
target-arm: Add the IL flag to syn_data_abort
target-arm: Add more fields to the data abort syndrome generator target-arm/translate-a64.c: Use extract32 in disas_ldst_reg_imm9 target-arm/translate-a64.c: Unify some of the ldst_reg decoding
target-arm: A64: Create Instruction Syndromes for Data Aborts
target-arm: Use isyn.swstep.ex to hold the is_ldex state

 include/exec/gen-icount.h  |  16 +++---
 target-arm/cpu.h           |   2 +-
 target-arm/internals.h     |  24 +++++++--
 target-arm/op_helper.c     |  41 +++++++++++++--
 target-arm/translate-a64.c | 123 ++++++++++++++++++++++++++++++++++++---------
 target-arm/translate.c     |  11 ++--
 target-arm/translate.h     |  27 ++++++++--
 tcg/tcg.h                  |   6 +++
 8 files changed, 201 insertions(+), 49 deletions(-)
Signature · 1 line
1.9.1
#1 lore raw

PATCH v2 1/8 tcg: Add tcg_set_insn_param

From: "Edgar E. Iglesias" <[email protected]>

Add tcg_set_insn_param as a mechanism to modify an insn parameter after emiting the insn. This is useful for icount and also for embedding fault information for a specific insn.

---
 tcg/tcg.h | 6 ++++++
 1 file changed, 6 insertions(+)
tcg/tcg.h +6 -0
index 83da5fb..00dd124 100644
@@ -585,6 +585,12 @@ struct TCGContext {
 
 extern TCGContext tcg_ctx;
 
+static inline void tcg_set_insn_param(int op_idx, int arg, TCGArg v)
+{
+    int op_argi = tcg_ctx.gen_op_buf[op_idx].args;
+    tcg_ctx.gen_opparam_buf[op_argi + arg] = v;
+}
+
 /* The number of opcodes emitted so far.  */
 static inline int tcg_op_buf_count(void)
 {
Signature · 1 line
1.9.1
#2 lore raw

PATCH v2 2/8 gen-icount: Use tcg_set_insn_param

In reply to Edgar E. Iglesias

From: "Edgar E. Iglesias" <[email protected]>

Use tcg_set_insn_param() instead of directly accessing internal tcg data structures to update an insn param.

---
 include/exec/gen-icount.h | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
include/exec/gen-icount.h +8 -8
index 05d89d3..a011324 100644
@@ -5,14 +5,13 @@
 
 /* Helpers for instruction counting code generation.  */
 
-static TCGArg *icount_arg;
+static int icount_start_insn_idx;
 static TCGLabel *icount_label;
 static TCGLabel *exitreq_label;
 
 static inline void gen_tb_start(TranslationBlock *tb)
 {
     TCGv_i32 count, flag, imm;
-    int i;
 
     exitreq_label = gen_new_label();
     flag = tcg_temp_new_i32();
@@ -31,13 +30,12 @@ static inline void gen_tb_start(TranslationBlock *tb)
                    -ENV_OFFSET + offsetof(CPUState, icount_decr.u32));
 
     imm = tcg_temp_new_i32();
+    /* We emit a movi with a dummy immediate argument. Keep the insn index
+     * of the movi so that we later (when we know the actual insn count)
+     * can update the immediate argument with the actual insn count.  */
+    icount_start_insn_idx = tcg_op_buf_count();
     tcg_gen_movi_i32(imm, 0xdeadbeef);
 
-    /* This is a horrid hack to allow fixing up the value later.  */
-    i = tcg_ctx.gen_last_op_idx;
-    i = tcg_ctx.gen_op_buf[i].args;
-    icount_arg = &tcg_ctx.gen_opparam_buf[i + 1];
-
     tcg_gen_sub_i32(count, count, imm);
     tcg_temp_free_i32(imm);
 
@@ -53,7 +51,9 @@ static void gen_tb_end(TranslationBlock *tb, int num_insns)
     tcg_gen_exit_tb((uintptr_t)tb + TB_EXIT_REQUESTED);
 
     if (tb->cflags & CF_USE_ICOUNT) {
-        *icount_arg = num_insns;
+        /* Update the num_insn immediate parameter now that we know
+         * the actual insn count.  */
+        tcg_set_insn_param(icount_start_insn_idx, 1, num_insns);
         gen_set_label(icount_label);
         tcg_gen_exit_tb((uintptr_t)tb + TB_EXIT_ICOUNT_EXPIRED);
     }
Signature · 1 line
1.9.1
#3 lore raw

PATCH v2 3/8 target-arm: Add the IL flag to syn_data_abort

In reply to Edgar E. Iglesias

From: "Edgar E. Iglesias" <[email protected]>

Add the IL flag to syn_data_abort(). Since we at the moment never set ISV, the IL flag is always set to one.

---
 target-arm/internals.h | 4 +++-
 target-arm/op_helper.c | 6 ++++--
 2 files changed, 7 insertions(+), 3 deletions(-)
target-arm/internals.h +3 -1
index 2e70272..34e2688 100644
@@ -384,9 +384,11 @@ static inline uint32_t syn_insn_abort(int same_el, int ea, int s1ptw, int fsc)
 }
 
 static inline uint32_t syn_data_abort(int same_el, int ea, int cm, int s1ptw,
-                                      int wnr, int fsc)
+                                      int wnr, int fsc,
+                                      bool is_16bit)
 {
     return (EC_DATAABORT << ARM_EL_EC_SHIFT) | (same_el << ARM_EL_EC_SHIFT)
+        | (is_16bit ? 0 : ARM_EL_IL)
         | (ea << 9) | (cm << 8) | (s1ptw << 7) | (wnr << 6) | fsc;
 }
 
target-arm/op_helper.c +4 -2
index 538887c..7e845d5 100644
@@ -115,7 +115,8 @@ void tlb_fill(CPUState *cs, target_ulong addr, int is_write, int mmu_idx,
             syn = syn_insn_abort(same_el, 0, fi.s1ptw, syn);
             exc = EXCP_PREFETCH_ABORT;
         } else {
-            syn = syn_data_abort(same_el, 0, 0, fi.s1ptw, is_write == 1, syn);
+            syn = syn_data_abort(same_el, 0, 0, fi.s1ptw, is_write == 1, syn,
+                                 1);
             if (is_write == 1 && arm_feature(env, ARM_FEATURE_V6)) {
                 fsr |= (1 << 11);
             }
@@ -161,7 +162,8 @@ void arm_cpu_do_unaligned_access(CPUState *cs, vaddr vaddr, int is_write,
     }
 
     raise_exception(env, EXCP_DATA_ABORT,
-                    syn_data_abort(same_el, 0, 0, 0, is_write == 1, 0x21),
+                    syn_data_abort(same_el, 0, 0, 0, is_write == 1, 0x21,
+                                   1),
                     target_el);
 }
 
Signature · 1 line
1.9.1
#4 lore raw

PATCH v2 4/8 target-arm: Add more fields to the data abort syndrome generator

In reply to Edgar E. Iglesias

From: "Edgar E. Iglesias" <[email protected]>

Add the following flags to the data abort syndrome generator:
* isv - Instruction syndrome valid
* sas - Syndrome access size
* sse - Syndrome sign extend
* srt - Syndrome register transfer
* sf - Sixty-Four bit register width
* ar - Acquire/Release

These flags are not yet used, so this patch has no functional change.

---
 target-arm/internals.h | 20 ++++++++++++++++++--
 target-arm/op_helper.c |  8 ++++++--
 2 files changed, 24 insertions(+), 4 deletions(-)
target-arm/internals.h +18 -2
index 34e2688..4e9d9f5 100644
@@ -383,13 +383,29 @@ static inline uint32_t syn_insn_abort(int same_el, int ea, int s1ptw, int fsc)
         | (ea << 9) | (s1ptw << 7) | fsc;
 }
 
-static inline uint32_t syn_data_abort(int same_el, int ea, int cm, int s1ptw,
+static inline uint32_t syn_data_abort(int same_el, int isv,
+                                      int sas, int sse, int srt,
+                                      int sf, int ar,
+                                      int ea, int cm, int s1ptw,
                                       int wnr, int fsc,
                                       bool is_16bit)
 {
-    return (EC_DATAABORT << ARM_EL_EC_SHIFT) | (same_el << ARM_EL_EC_SHIFT)
+    uint32_t v;
+    v = (EC_DATAABORT << ARM_EL_EC_SHIFT) | (same_el << ARM_EL_EC_SHIFT)
         | (is_16bit ? 0 : ARM_EL_IL)
         | (ea << 9) | (cm << 8) | (s1ptw << 7) | (wnr << 6) | fsc;
+
+    /* Insn Syndrome fields are RES0 if ISV is unset.  */
+    if (isv) {
+        v |= (isv << 24) | (sas << 22) | (sse << 21) | (srt << 16)
+             | (sf << 15) | (ar << 14);
+    } else {
+        /* If ISV is zero, the IL field should be set to one.
+         * See ARM ARMv8 D7.2.27 for more details.
+         */
+        v |= ARM_EL_IL;
+    }
+    return v;
 }
 
 static inline uint32_t syn_swstep(int same_el, int isv, int ex)
target-arm/op_helper.c +6 -2
index 7e845d5..2522d3c 100644
@@ -115,7 +115,9 @@ void tlb_fill(CPUState *cs, target_ulong addr, int is_write, int mmu_idx,
             syn = syn_insn_abort(same_el, 0, fi.s1ptw, syn);
             exc = EXCP_PREFETCH_ABORT;
         } else {
-            syn = syn_data_abort(same_el, 0, 0, fi.s1ptw, is_write == 1, syn,
+            syn = syn_data_abort(same_el,
+                                 0, 0, 0, 0, 0, 0,
+                                 0, 0, fi.s1ptw, is_write == 1, syn,
                                  1);
             if (is_write == 1 && arm_feature(env, ARM_FEATURE_V6)) {
                 fsr |= (1 << 11);
@@ -162,7 +164,9 @@ void arm_cpu_do_unaligned_access(CPUState *cs, vaddr vaddr, int is_write,
     }
 
     raise_exception(env, EXCP_DATA_ABORT,
-                    syn_data_abort(same_el, 0, 0, 0, is_write == 1, 0x21,
+                    syn_data_abort(same_el,
+                                   0, 0, 0, 0, 0, 0,
+                                   0, 0, 0, is_write == 1, 0x21,
                                    1),
                     target_el);
 }
Signature · 1 line
1.9.1
#5 lore raw

Re: [PATCH v2 4/8] target-arm: Add more fields to the data abort syndrome generator

Quoted 23 lines · Edgar E. Iglesias

From: "Edgar E. Iglesias" <[email protected]>

Add the following flags to the data abort syndrome generator:
* isv - Instruction syndrome valid
* sas - Syndrome access size
* sse - Syndrome sign extend
* srt - Syndrome register transfer
* sf - Sixty-Four bit register width
* ar - Acquire/Release

These flags are not yet used, so this patch has no functional change.

---
 target-arm/internals.h | 20 ++++++++++++++++++--
 target-arm/op_helper.c |  8 ++++++--
 2 files changed, 24 insertions(+), 4 deletions(-)
target-arm/internals.h +0 -0
index 34e2688..4e9d9f5 100644

target-arm/internals.h static inline uint32_t syn_insn_abort(int same_el, int ea, int s1ptw, int fsc) · line 391

Quoted 10 lines
target-arm/internals.h +4 -1
@@ -383,13 +383,29 @@ static inline uint32_t syn_insn_abort(int same_el, int ea, int s1ptw, int fsc)
         | (ea << 9) | (s1ptw << 7) | fsc;
 }
 
-static inline uint32_t syn_data_abort(int same_el, int ea, int cm, int s1ptw,
+static inline uint32_t syn_data_abort(int same_el, int isv,
+                                      int sas, int sse, int srt,
+                                      int sf, int ar,
+                                      int ea, int cm, int s1ptw,
                                       int wnr, int fsc,
                                       bool is_16bit)

Everywhere we call this (both now and once the full patchset has been applied) isv is a constant (either 0 or 1). I think it might be cleaner to define both a syn_data_abort_with_isv() and a syn_data_abort_no_isv(). Then the no_isv version doesn't need all the arguments that are zeroes.

thanks
-- PMM

#6 lore raw

Re: [PATCH v2 4/8] target-arm: Add more fields to the data abort syndrome generator

Quoted 28 lines · Peter Maydell
Quoted 26 lines · Edgar E. Iglesias

From: "Edgar E. Iglesias" <[email protected]>

Add the following flags to the data abort syndrome generator:
* isv - Instruction syndrome valid
* sas - Syndrome access size
* sse - Syndrome sign extend
* srt - Syndrome register transfer
* sf - Sixty-Four bit register width
* ar - Acquire/Release

These flags are not yet used, so this patch has no functional change.

---
  target-arm/internals.h | 20 ++++++++++++++++++--
  target-arm/op_helper.c |  8 ++++++--
  2 files changed, 24 insertions(+), 4 deletions(-)
target-arm/internals.h +0 -0
index 34e2688..4e9d9f5 100644
@@ -383,13 +383,29 @@ static inline uint32_t syn_insn_abort(int same_el, int ea, int s1ptw, int fsc)
          | (ea << 9) | (s1ptw << 7) | fsc;
  }
 
Quoted 12 lines

target-arm/internals.h static inline uint32_t syn_insn_abort(int same_el, int ea, int s1ptw, int fsc) · line 391

Quoted 7 lines
target-arm/internals.h +4 -1
-static inline uint32_t syn_data_abort(int same_el, int ea, int cm, int s1ptw,
+static inline uint32_t syn_data_abort(int same_el, int isv,
+                                      int sas, int sse, int srt,
+                                      int sf, int ar,
+                                      int ea, int cm, int s1ptw,
                                        int wnr, int fsc,
                                        bool is_16bit)

Everywhere we call this (both now and once the full patchset has been applied) isv is a constant (either 0 or 1). I think it might be cleaner to define both a syn_data_abort_with_isv() and a syn_data_abort_no_isv(). Then the no_isv version doesn't need all the arguments that are zeroes.

Alternatively, we could define a function similar to LSInstructionSyndrome from ARMv8 ARM pseudocode, but which will pack the instruction syndrome from its components into a value of ISS<24:14>.

Best regards,
Sergey

#7 lore raw

Re: [PATCH v2 4/8] target-arm: Add more fields to the data abort syndrome generator

In reply to Peter Maydell
Quoted 28 lines · Peter Maydell
Quoted 26 lines · Edgar E. Iglesias

From: "Edgar E. Iglesias" <[email protected]>

Add the following flags to the data abort syndrome generator:
* isv - Instruction syndrome valid
* sas - Syndrome access size
* sse - Syndrome sign extend
* srt - Syndrome register transfer
* sf - Sixty-Four bit register width
* ar - Acquire/Release

These flags are not yet used, so this patch has no functional change.

---
 target-arm/internals.h | 20 ++++++++++++++++++--
 target-arm/op_helper.c |  8 ++++++--
 2 files changed, 24 insertions(+), 4 deletions(-)
target-arm/internals.h +0 -0
index 34e2688..4e9d9f5 100644
@@ -383,13 +383,29 @@ static inline uint32_t syn_insn_abort(int same_el, int ea, int s1ptw, int fsc)
         | (ea << 9) | (s1ptw << 7) | fsc;
 }
 
Quoted 13 lines

target-arm/internals.h static inline uint32_t syn_insn_abort(int same_el, int ea, int s1ptw, int fsc) · line 391

Quoted 7 lines
target-arm/internals.h +4 -1
-static inline uint32_t syn_data_abort(int same_el, int ea, int cm, int s1ptw,
+static inline uint32_t syn_data_abort(int same_el, int isv,
+                                      int sas, int sse, int srt,
+                                      int sf, int ar,
+                                      int ea, int cm, int s1ptw,
                                       int wnr, int fsc,
                                       bool is_16bit)

Everywhere we call this (both now and once the full patchset has been applied) isv is a constant (either 0 or 1). I think it might be cleaner to define both a syn_data_abort_with_isv() and a syn_data_abort_no_isv(). Then the no_isv version doesn't need all the arguments that are zeroes.

Hi Peter,

Finally getting back to this :-)

In v3, I've added two separate functions as suggested.

Cheers,
Edgar

#8 lore raw

PATCH v2 5/8 target-arm/translate-a64.c: Use extract32 in disas_ldst_reg_imm9

In reply to Edgar E. Iglesias

From: "Edgar E. Iglesias" <[email protected]>

Use extract32 instead of open coding the bit masking when decoding is_signed and is_extended. This streamlines the decoding with some of the other ldst variants.

No functional change.

---
 target-arm/translate-a64.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
target-arm/translate-a64.c +2 -2
index 7f65aea..bf31f8a 100644
@@ -2117,8 +2117,8 @@ static void disas_ldst_reg_imm9(DisasContext *s, uint32_t insn)
             return;
         }
         is_store = (opc == 0);
-        is_signed = opc & (1<<1);
-        is_extended = (size < 3) && (opc & 1);
+        is_signed = extract32(opc, 1, 1);
+        is_extended = (size < 3) && extract32(opc, 0, 1);
     }
 
     switch (idx) {
Signature · 1 line
1.9.1
#9 lore raw

PATCH v2 6/8 target-arm/translate-a64.c: Unify some of the ldst_reg decoding

In reply to Edgar E. Iglesias

From: "Edgar E. Iglesias" <[email protected]>

The various load/store variants under disas_ldst_reg can all reuse the same decoding for opc, size, rt and is_vector.

This patch unifies the decoding in preparation for generating instruction syndromes for data aborts.
This will allow us to reduce the number of places to hook in updates to the load/store state needed to generate the insn syndromes.

No functional change.

---
 target-arm/translate-a64.c | 41 +++++++++++++++++++++++------------------
 1 file changed, 23 insertions(+), 18 deletions(-)
target-arm/translate-a64.c +23 -18
index bf31f8a..9e26d5e 100644
@@ -2075,19 +2075,19 @@ static void disas_ldst_pair(DisasContext *s, uint32_t insn)
  * size: 00 -> 8 bit, 01 -> 16 bit, 10 -> 32 bit, 11 -> 64bit
  * opc: 00 -> store, 01 -> loadu, 10 -> loads 64, 11 -> loads 32
  */
-static void disas_ldst_reg_imm9(DisasContext *s, uint32_t insn)
+static void disas_ldst_reg_imm9(DisasContext *s, uint32_t insn,
+                                int opc,
+                                int size,
+                                int rt,
+                                bool is_vector)
 {
-    int rt = extract32(insn, 0, 5);
     int rn = extract32(insn, 5, 5);
     int imm9 = sextract32(insn, 12, 9);
-    int opc = extract32(insn, 22, 2);
-    int size = extract32(insn, 30, 2);
     int idx = extract32(insn, 10, 2);
     bool is_signed = false;
     bool is_store = false;
     bool is_extended = false;
     bool is_unpriv = (idx == 2);
-    bool is_vector = extract32(insn, 26, 1);
     bool post_index;
     bool writeback;
 
@@ -2194,19 +2194,19 @@ static void disas_ldst_reg_imm9(DisasContext *s, uint32_t insn)
  * Rn: address register or SP for base
  * Rm: offset register or ZR for offset
  */
-static void disas_ldst_reg_roffset(DisasContext *s, uint32_t insn)
+static void disas_ldst_reg_roffset(DisasContext *s, uint32_t insn,
+                                   int opc,
+                                   int size,
+                                   int rt,
+                                   bool is_vector)
 {
-    int rt = extract32(insn, 0, 5);
     int rn = extract32(insn, 5, 5);
     int shift = extract32(insn, 12, 1);
     int rm = extract32(insn, 16, 5);
-    int opc = extract32(insn, 22, 2);
     int opt = extract32(insn, 13, 3);
-    int size = extract32(insn, 30, 2);
     bool is_signed = false;
     bool is_store = false;
     bool is_extended = false;
-    bool is_vector = extract32(insn, 26, 1);
 
     TCGv_i64 tcg_rm;
     TCGv_i64 tcg_addr;
@@ -2283,14 +2283,14 @@ static void disas_ldst_reg_roffset(DisasContext *s, uint32_t insn)
  * Rn: base address register (inc SP)
  * Rt: target register
  */
-static void disas_ldst_reg_unsigned_imm(DisasContext *s, uint32_t insn)
+static void disas_ldst_reg_unsigned_imm(DisasContext *s, uint32_t insn,
+                                        int opc,
+                                        int size,
+                                        int rt,
+                                        bool is_vector)
 {
-    int rt = extract32(insn, 0, 5);
     int rn = extract32(insn, 5, 5);
     unsigned int imm12 = extract32(insn, 10, 12);
-    bool is_vector = extract32(insn, 26, 1);
-    int size = extract32(insn, 30, 2);
-    int opc = extract32(insn, 22, 2);
     unsigned int offset;
 
     TCGv_i64 tcg_addr;
@@ -2349,20 +2349,25 @@ static void disas_ldst_reg_unsigned_imm(DisasContext *s, uint32_t insn)
 /* Load/store register (all forms) */
 static void disas_ldst_reg(DisasContext *s, uint32_t insn)
 {
+    int rt = extract32(insn, 0, 5);
+    int opc = extract32(insn, 22, 2);
+    bool is_vector = extract32(insn, 26, 1);
+    int size = extract32(insn, 30, 2);
+
     switch (extract32(insn, 24, 2)) {
     case 0:
         if (extract32(insn, 21, 1) == 1 && extract32(insn, 10, 2) == 2) {
-            disas_ldst_reg_roffset(s, insn);
+            disas_ldst_reg_roffset(s, insn, opc, size, rt, is_vector);
         } else {
             /* Load/store register (unscaled immediate)
              * Load/store immediate pre/post-indexed
              * Load/store register unprivileged
              */
-            disas_ldst_reg_imm9(s, insn);
+            disas_ldst_reg_imm9(s, insn, opc, size, rt, is_vector);
         }
         break;
     case 1:
-        disas_ldst_reg_unsigned_imm(s, insn);
+        disas_ldst_reg_unsigned_imm(s, insn, opc, size, rt, is_vector);
         break;
     default:
         unallocated_encoding(s);
Signature · 1 line
1.9.1
#10 lore raw

PATCH v2 7/8 target-arm: A64: Create Instruction Syndromes for Data Aborts

In reply to Edgar E. Iglesias

From: "Edgar E. Iglesias" <[email protected]>

Add support for generating the instruction syndrome for Data Aborts. These syndromes are used by hypervisors for example to trap and emulate memory accesses.

We save the decoded data out-of-band with the TBs at translation time. When exceptions hit, the extra data attached to the TB is used to recreate the state needed to encode instruction syndromes. This avoids the need to emit moves with every load/store.

Based on a suggestion from Peter Maydell.

---
 target-arm/cpu.h           |  2 +-
 target-arm/op_helper.c     | 47 +++++++++++++++++++++++-------
 target-arm/translate-a64.c | 72 +++++++++++++++++++++++++++++++++++++++++++++-
 target-arm/translate.c     |  5 +++-
 target-arm/translate.h     | 14 +++++++++
 5 files changed, 127 insertions(+), 13 deletions(-)
target-arm/cpu.h +1 -1
index 1623821..c3ade8d 100644
@@ -95,7 +95,7 @@
 struct arm_boot_info;
 
 #define NB_MMU_MODES 7
-#define TARGET_INSN_START_EXTRA_WORDS 1
+#define TARGET_INSN_START_EXTRA_WORDS 2
 
 /* We currently assume float and double are IEEE single and double
    precision respectively.
target-arm/op_helper.c +37 -10

71 lines not on this page · raw message

target-arm/translate-a64.c +71 -1

132 lines not on this page · raw message

target-arm/translate.c +4 -1
index e69145d..7d83c94 100644
@@ -11406,7 +11406,8 @@ void gen_intermediate_code(CPUARMState *env, TranslationBlock *tb)
       }
     do {
         tcg_gen_insn_start(dc->pc,
-                           (dc->condexec_cond << 4) | (dc->condexec_mask >> 1));
+                           (dc->condexec_cond << 4) | (dc->condexec_mask >> 1),
+                           0);
         num_insns++;
 
 #ifdef CONFIG_USER_ONLY
@@ -11722,8 +11723,10 @@ void restore_state_to_opc(CPUARMState *env, TranslationBlock *tb,
     if (is_a64(env)) {
         env->pc = data[0];
         env->condexec_bits = 0;
+        env->exception.syndrome = data[2] << 14;
     } else {
         env->regs[15] = data[0];
         env->condexec_bits = data[1];
+        env->exception.syndrome = data[2] << 14;
     }
 }
target-arm/translate.h +14 -0
index 53ef971..e002c90 100644
@@ -58,6 +58,20 @@ typedef struct DisasContext {
     bool ss_same_el;
     /* Bottom two bits of XScale c15_cpar coprocessor access control reg */
     int c15_cpar;
+    /* State needed to create the Data Abort template syndrome.  */
+    struct {
+        /* Data Abort section.  */
+        struct {
+            bool valid;
+            unsigned int sas;
+            bool sse;
+            unsigned int srt;
+            bool sf;
+            bool ar;
+        } dabt;
+    } isyn;
+    /* TCG op index of the current insn_start.  */
+    int insn_start_idx;
 #define TMP_A64_MAX 16
     int tmp_a64_count;
     TCGv_i64 tmp_a64[TMP_A64_MAX];
Signature · 1 line
1.9.1
#11 lore raw

Re: [PATCH v2 7/8] target-arm: A64: Create Instruction Syndromes for Data Aborts

Quoted 28 lines · Edgar E. Iglesias

From: "Edgar E. Iglesias" <[email protected]>

Add support for generating the instruction syndrome for Data Aborts. These syndromes are used by hypervisors for example to trap and emulate memory accesses.

We save the decoded data out-of-band with the TBs at translation time. When exceptions hit, the extra data attached to the TB is used to recreate the state needed to encode instruction syndromes. This avoids the need to emit moves with every load/store.

Based on a suggestion from Peter Maydell.

---
 target-arm/cpu.h           |  2 +-
 target-arm/op_helper.c     | 47 +++++++++++++++++++++++-------
 target-arm/translate-a64.c | 72 +++++++++++++++++++++++++++++++++++++++++++++-
 target-arm/translate.c     |  5 +++-
 target-arm/translate.h     | 14 +++++++++
 5 files changed, 127 insertions(+), 13 deletions(-)
target-arm/cpu.h +0 -0
index 1623821..c3ade8d 100644

target-arm/cpu.h line 98

Quoted 5 lines
target-arm/cpu.h +1 -1
@@ -95,7 +95,7 @@
 struct arm_boot_info;
 
 #define NB_MMU_MODES 7
-#define TARGET_INSN_START_EXTRA_WORDS 1
+#define TARGET_INSN_START_EXTRA_WORDS 2

A comment saying what our two extra words are would probably be helpful.

Quoted 11 lines
target-arm/cpu.h +7 -0
 /* We currently assume float and double are IEEE single and double
    precision respectively.
 
+static inline uint32_t merge_syn_data_abort(uint32_t template_syn,
+                                            unsigned int target_el,
+                                            bool same_el,
+                                            bool s1ptw, int is_write,
+                                            int fsc)
+{
+   uint32_t syn;

target-arm/cpu.h

Quoted 10 lines
target-arm/cpu.h +10 -0
+
+    if (target_el != 2 || s1ptw) {
+        /* ISV is only set for data aborts routed to EL2 and
+         * never for stage-1 page table walks faulting on stage 2.
+         *
+         * See ARMv8 specs, D7-1974:
+         * ISS encoding for an exception from a Data Abort, the
+         * ISV field.
+         */
+        template_syn = 0;

IL should be set if ISV is clear, but this template_syn value doesn't have that. It might be simpler to just
return syn_data_abort_no_isv(stuff);
here rather than using the OR-fields-together code path.

+ }
+ /* Fields: IL, ISV, SAS, SSE, SRT, SF and AR come from the template

+     * syndrome created at translation time.
+     * Now we create the runtime syndrome with the remaining fields.
+     */
+    syn = syn_data_abort(same_el,
+                         0, 0, 0, 0, 0, 0,
+                         0, 0, s1ptw, is_write == 1, fsc,
+                         0);

Since you pass in 0 for isv here, the IL bit will always be set in syn and thus in the returned value, even if the template_syn value from translate time said it should be clear.

+    /* Merge runtime syndrome with the template syndrome.  */
+    syn |= template_syn;
+    return syn;

+}

Quoted 30 lines
target-arm/translate-a64.c +18 -0
index 9e26d5e..5250c08 100644
@@ -1803,6 +1803,24 @@ static void gen_store_exclusive(DisasContext *s, int rd, int rt, int rt2,
 }
 #endif
 
+static void disas_ldr_update_isyn_sse_sf(DisasContext *s, int size,
+                                        bool is_signed, int opc)
+{
+    int opc0 = extract32(opc, 0, 1);
+    int regsize;
+
+    s->isyn.dabt.sse = is_signed;
+    /* Update the Sixty-Four bit (SF) registersize. This logic is derived
+     * from the ARMv8 specs for LDR (Shared decode for all encodings).
+     */
+    if (is_signed) {
+        regsize = opc0 ? 32 : 64;
+    } else {
+        regsize = size == 3 ? 64 : 32;
+    }
+    s->isyn.dabt.sf = regsize == 64;
+}
+
 /* C3.3.6 Load/store exclusive
  *
  *  31 30 29         24  23  22   21  20  16  15  14   10 9    5 4    0

target-arm/translate-a64.c static void disas_ldst_excl(DisasContext *s, uint32_t insn) · line 1881

Quoted 5 lines
target-arm/translate-a64.c +2 -0
@@ -1859,6 +1877,12 @@ static void disas_ldst_excl(DisasContext *s, uint32_t insn)
         } else {
             do_gpr_ld(s, tcg_rt, tcg_addr, size, false, false);
         }
+
+        /* Generate ISV for non-exclusive accesses including LASR.  */

The comment says "for non-exclusive accesses" but aren't we going to end up generating one for all accesses given where we are in the code ?

Quoted 8 lines
target-arm/translate-a64.c +4 -0
+        s->isyn.dabt.valid = true;
+        s->isyn.dabt.sse = false;
+        s->isyn.dabt.sf = size == 3 ? 64 : 32;
+        s->isyn.dabt.ar = is_lasr;
     }
 }
 

target-arm/translate-a64.c static void disas_ld_lit(DisasContext *s, uint32_t insn) · line 1932

Quoted 8 lines
target-arm/translate-a64.c +5 -0
@@ -1901,6 +1925,11 @@ static void disas_ld_lit(DisasContext *s, uint32_t insn)
         }
         size = 2 + extract32(opc, 0, 1);
         is_signed = extract32(opc, 1, 1);
+
+        /* Enable ISV generation.  */
+        s->isyn.dabt.valid = true;
+        s->isyn.dabt.sse = is_signed;
+        s->isyn.dabt.sf = size == 3 ? 64 : 32;

This code to update syndrome values ought to work, but it feels a little fragile in the face of future changes which might introduce code paths which add new guest load/store ops but don't set the syndrome info right.

How would it look if we instead set the syndrome information in the lower level functions which directly call the tcg_gen_qemu_ld/st functions? You'd need to pass more arguments into those functions, of course, but I think that would make it easier to review and be confident that we set the syndrome correctly for all the cases that we need to.

Quoted 49 lines
target-arm/translate-a64.c +19 -1
@@ -2685,6 +2737,23 @@ static void disas_ldst(DisasContext *s, uint32_t insn)
         unallocated_encoding(s);
         break;
     }
+
+    /* The saved insn syndrome state in insn_start is already zero (invalid).
+     * We only update it if we have a valid insn syndrome to save.
+     */
+    if (s->isyn.dabt.valid) {
+        isyn32 = syn_data_abort(0,
+                                s->isyn.dabt.valid,
+                                s->isyn.dabt.sas,
+                                s->isyn.dabt.sse,
+                                s->isyn.dabt.srt,
+                                s->isyn.dabt.sf,
+                                s->isyn.dabt.ar,
+                                0, 0, 0, 0, 0, false);
+        /* We don't use the lower 14 bits.  */
+        isyn32 >>= 14;
+        tcg_set_insn_param(s->insn_start_idx, 2, isyn32);
+    }
 }
 
 /* C3.4.6 PC-rel. addressing
@@ -11087,7 +11156,8 @@ void gen_intermediate_code_a64(ARMCPU *cpu, TranslationBlock *tb)
     tcg_clear_temp_count();
 
     do {
-        tcg_gen_insn_start(dc->pc, 0);
+        dc->insn_start_idx = tcg_op_buf_count();
+        tcg_gen_insn_start(dc->pc, 0, 0);
         num_insns++;
 
         if (unlikely(!QTAILQ_EMPTY(&cs->breakpoints))) {
target-arm/translate.c +2 -1
index e69145d..7d83c94 100644
@@ -11406,7 +11406,8 @@ void gen_intermediate_code(CPUARMState *env, TranslationBlock *tb)
       }
     do {
         tcg_gen_insn_start(dc->pc,
-                           (dc->condexec_cond << 4) | (dc->condexec_mask >> 1));
+                           (dc->condexec_cond << 4) | (dc->condexec_mask >> 1),
+                           0);
         num_insns++;
 
 #ifdef CONFIG_USER_ONLY

target-arm/translate.c void restore_state_to_opc(CPUARMState *env, TranslationBlock *tb, · line 11730

Quoted 8 lines
target-arm/translate.c +2 -0
@@ -11722,8 +11723,10 @@ void restore_state_to_opc(CPUARMState *env, TranslationBlock *tb,
     if (is_a64(env)) {
         env->pc = data[0];
         env->condexec_bits = 0;
+        env->exception.syndrome = data[2] << 14;
     } else {
         env->regs[15] = data[0];
         env->condexec_bits = data[1];
+        env->exception.syndrome = data[2] << 14;

We should have a symbolic constant rather than this hardcoded 14 (here and where we put the word into the insn stream).

Quoted 28 lines
target-arm/translate.c +0 -0
     }
 }
target-arm/translate.h +14 -1
index 53ef971..e002c90 100644
@@ -58,6 +58,20 @@ typedef struct DisasContext {
     bool ss_same_el;
     /* Bottom two bits of XScale c15_cpar coprocessor access control reg */
     int c15_cpar;
+    /* State needed to create the Data Abort template syndrome.  */
+    struct {
+        /* Data Abort section.  */
+        struct {
+            bool valid;
+            unsigned int sas;
+            bool sse;
+            unsigned int srt;
+            bool sf;
+            bool ar;
+        } dabt;
+    } isyn;
+    /* TCG op index of the current insn_start.  */
+    int insn_start_idx;
 #define TMP_A64_MAX 16
     int tmp_a64_count;
     TCGv_i64 tmp_a64[TMP_A64_MAX];
--
Quoted 1 line

1.9.1

thanks
-- PMM

#12 lore raw

Re: [PATCH v2 7/8] target-arm: A64: Create Instruction Syndromes for Data Aborts

Quoted 32 lines · Peter Maydell
Quoted 30 lines · Edgar E. Iglesias

From: "Edgar E. Iglesias" <[email protected]>

Add support for generating the instruction syndrome for Data Aborts. These syndromes are used by hypervisors for example to trap and emulate memory accesses.

We save the decoded data out-of-band with the TBs at translation time. When exceptions hit, the extra data attached to the TB is used to recreate the state needed to encode instruction syndromes. This avoids the need to emit moves with every load/store.

Based on a suggestion from Peter Maydell.

---
 target-arm/cpu.h           |  2 +-
 target-arm/op_helper.c     | 47 +++++++++++++++++++++++-------
 target-arm/translate-a64.c | 72 +++++++++++++++++++++++++++++++++++++++++++++-
 target-arm/translate.c     |  5 +++-
 target-arm/translate.h     | 14 +++++++++
 5 files changed, 127 insertions(+), 13 deletions(-)
target-arm/cpu.h +0 -0
index 1623821..c3ade8d 100644
@@ -95,7 +95,7 @@
 struct arm_boot_info;
 
Quoted 5 lines

target-arm/cpu.h line 98

Quoted 3 lines
target-arm/cpu.h +1 -1
 #define NB_MMU_MODES 7
-#define TARGET_INSN_START_EXTRA_WORDS 1
+#define TARGET_INSN_START_EXTRA_WORDS 2

A comment saying what our two extra words are would probably be helpful.

Yes, I've added a comment.

Quoted 38 lines
Quoted 12 lines
target-arm/cpu.h +7 -0
 /* We currently assume float and double are IEEE single and double
    precision respectively.
 
+static inline uint32_t merge_syn_data_abort(uint32_t template_syn,
+                                            unsigned int target_el,
+                                            bool same_el,
+                                            bool s1ptw, int is_write,
+                                            int fsc)
+{
+   uint32_t syn;

target-arm/cpu.h

Quoted 10 lines
target-arm/cpu.h +10 -0
+
+    if (target_el != 2 || s1ptw) {
+        /* ISV is only set for data aborts routed to EL2 and
+         * never for stage-1 page table walks faulting on stage 2.
+         *
+         * See ARMv8 specs, D7-1974:
+         * ISS encoding for an exception from a Data Abort, the
+         * ISV field.
+         */
+        template_syn = 0;

IL should be set if ISV is clear, but this template_syn value doesn't have that. It might be simpler to just
return syn_data_abort_no_isv(stuff);
here rather than using the OR-fields-together code path.

target-arm/op_helper.c +9 -0
+    }
+    /* Fields: IL, ISV, SAS, SSE, SRT, SF and AR come from the template
+     * syndrome created at translation time.
+     * Now we create the runtime syndrome with the remaining fields.
+     */
+    syn = syn_data_abort(same_el,
+                         0, 0, 0, 0, 0, 0,
+                         0, 0, s1ptw, is_write == 1, fsc,
+                         0);
Quoted 3 lines

Since you pass in 0 for isv here, the IL bit will always be set in syn and thus in the returned value, even if the template_syn value from translate time said it should be clear.

Thanks, I've reworked this code. Hopefully fixing this issues.

Quoted 36 lines
target-arm/op_helper.c +4 -0
+    /* Merge runtime syndrome with the template syndrome.  */
+    syn |= template_syn;
+    return syn;
+}
Quoted 31 lines
target-arm/translate-a64.c +18 -0
index 9e26d5e..5250c08 100644
@@ -1803,6 +1803,24 @@ static void gen_store_exclusive(DisasContext *s, int rd, int rt, int rt2,
 }
 #endif
 
+static void disas_ldr_update_isyn_sse_sf(DisasContext *s, int size,
+                                        bool is_signed, int opc)
+{
+    int opc0 = extract32(opc, 0, 1);
+    int regsize;
+
+    s->isyn.dabt.sse = is_signed;
+    /* Update the Sixty-Four bit (SF) registersize. This logic is derived
+     * from the ARMv8 specs for LDR (Shared decode for all encodings).
+     */
+    if (is_signed) {
+        regsize = opc0 ? 32 : 64;
+    } else {
+        regsize = size == 3 ? 64 : 32;
+    }
+    s->isyn.dabt.sf = regsize == 64;
+}
+
 /* C3.3.6 Load/store exclusive
  *
  *  31 30 29         24  23  22   21  20  16  15  14   10 9    5 4    0
@@ -1859,6 +1877,12 @@ static void disas_ldst_excl(DisasContext *s, uint32_t insn)
Quoted 8 lines

target-arm/translate-a64.c static void disas_ldst_excl(DisasContext *s, uint32_t insn) · line 1881

Quoted 5 lines
target-arm/translate-a64.c +2 -0
         } else {
             do_gpr_ld(s, tcg_rt, tcg_addr, size, false, false);
         }
+
+        /* Generate ISV for non-exclusive accesses including LASR.  */

The comment says "for non-exclusive accesses" but aren't we going to end up generating one for all accesses given where we are in the code ?

My understanding is that it's only for the case where is_excl gets set and we end up calling gen_load/store_exclusive that we shouldn't create the ISS. For other loads/stores, including load acquires, we should create one I think.

Quoted 23 lines
Quoted 9 lines
target-arm/translate-a64.c +4 -0
+        s->isyn.dabt.valid = true;
+        s->isyn.dabt.sse = false;
+        s->isyn.dabt.sf = size == 3 ? 64 : 32;
+        s->isyn.dabt.ar = is_lasr;
     }
 }
 

target-arm/translate-a64.c static void disas_ld_lit(DisasContext *s, uint32_t insn) · line 1932

Quoted 8 lines
target-arm/translate-a64.c +5 -0
@@ -1901,6 +1925,11 @@ static void disas_ld_lit(DisasContext *s, uint32_t insn)
         }
         size = 2 + extract32(opc, 0, 1);
         is_signed = extract32(opc, 1, 1);
+
+        /* Enable ISV generation.  */
+        s->isyn.dabt.valid = true;
+        s->isyn.dabt.sse = is_signed;
+        s->isyn.dabt.sf = size == 3 ? 64 : 32;

This code to update syndrome values ought to work, but it feels a little fragile in the face of future changes which might introduce code paths which add new guest load/store ops but don't set the syndrome info right.

Quoted 6 lines

How would it look if we instead set the syndrome information in the lower level functions which directly call the tcg_gen_qemu_ld/st functions? You'd need to pass more arguments into those functions, of course, but I think that would make it easier to review and be confident that we set the syndrome correctly for all the cases that we need to.

I've massaged the code to be more explicit about ISS generation, moving the setup closer to tcg_gen_qemu_ld/st as you suggest. It looks OK, I'll include the new version in v3.

Quoted 49 lines
Quoted 49 lines
target-arm/translate-a64.c +19 -1
@@ -2685,6 +2737,23 @@ static void disas_ldst(DisasContext *s, uint32_t insn)
         unallocated_encoding(s);
         break;
     }
+
+    /* The saved insn syndrome state in insn_start is already zero (invalid).
+     * We only update it if we have a valid insn syndrome to save.
+     */
+    if (s->isyn.dabt.valid) {
+        isyn32 = syn_data_abort(0,
+                                s->isyn.dabt.valid,
+                                s->isyn.dabt.sas,
+                                s->isyn.dabt.sse,
+                                s->isyn.dabt.srt,
+                                s->isyn.dabt.sf,
+                                s->isyn.dabt.ar,
+                                0, 0, 0, 0, 0, false);
+        /* We don't use the lower 14 bits.  */
+        isyn32 >>= 14;
+        tcg_set_insn_param(s->insn_start_idx, 2, isyn32);
+    }
 }
 
 /* C3.4.6 PC-rel. addressing
@@ -11087,7 +11156,8 @@ void gen_intermediate_code_a64(ARMCPU *cpu, TranslationBlock *tb)
     tcg_clear_temp_count();
 
     do {
-        tcg_gen_insn_start(dc->pc, 0);
+        dc->insn_start_idx = tcg_op_buf_count();
+        tcg_gen_insn_start(dc->pc, 0, 0);
         num_insns++;
 
         if (unlikely(!QTAILQ_EMPTY(&cs->breakpoints))) {
target-arm/translate.c +2 -1
index e69145d..7d83c94 100644
@@ -11406,7 +11406,8 @@ void gen_intermediate_code(CPUARMState *env, TranslationBlock *tb)
       }
     do {
         tcg_gen_insn_start(dc->pc,
-                           (dc->condexec_cond << 4) | (dc->condexec_mask >> 1));
+                           (dc->condexec_cond << 4) | (dc->condexec_mask >> 1),
+                           0);
         num_insns++;
 
Quoted 13 lines

target-arm/translate.c void restore_state_to_opc(CPUARMState *env, TranslationBlock *tb, · line 11730

Quoted 10 lines
target-arm/translate.c +2 -0
 #ifdef CONFIG_USER_ONLY
@@ -11722,8 +11723,10 @@ void restore_state_to_opc(CPUARMState *env, TranslationBlock *tb,
     if (is_a64(env)) {
         env->pc = data[0];
         env->condexec_bits = 0;
+        env->exception.syndrome = data[2] << 14;
     } else {
         env->regs[15] = data[0];
         env->condexec_bits = data[1];
+        env->exception.syndrome = data[2] << 14;

We should have a symbolic constant rather than this hardcoded 14 (here and where we put the word into the insn stream).

Added one.

Cheers,
Edgar

Quoted 33 lines
Quoted 29 lines
target-arm/translate.c +0 -0
     }
 }
target-arm/translate.h +14 -1
index 53ef971..e002c90 100644
@@ -58,6 +58,20 @@ typedef struct DisasContext {
     bool ss_same_el;
     /* Bottom two bits of XScale c15_cpar coprocessor access control reg */
     int c15_cpar;
+    /* State needed to create the Data Abort template syndrome.  */
+    struct {
+        /* Data Abort section.  */
+        struct {
+            bool valid;
+            unsigned int sas;
+            bool sse;
+            unsigned int srt;
+            bool sf;
+            bool ar;
+        } dabt;
+    } isyn;
+    /* TCG op index of the current insn_start.  */
+    int insn_start_idx;
 #define TMP_A64_MAX 16
     int tmp_a64_count;
     TCGv_i64 tmp_a64[TMP_A64_MAX];
--
Quoted 1 line

1.9.1

thanks
-- PMM

#13 lore raw

PATCH v2 8/8 target-arm: Use isyn.swstep.ex to hold the is_ldex state

In reply to Edgar E. Iglesias

From: "Edgar E. Iglesias" <[email protected]>

Switch to using isyn.swstep.ex to hold the is_ldex state for SWStep syndrome generation.

No functional change.

---
 target-arm/translate-a64.c |  6 +++---
 target-arm/translate.c     |  6 +++---
 target-arm/translate.h     | 13 ++++++++-----
 3 files changed, 14 insertions(+), 11 deletions(-)
target-arm/translate-a64.c +3 -3
index 5250c08..ab249d1 100644
@@ -260,7 +260,7 @@ static void gen_step_complete_exception(DisasContext *s)
      * of the exception, and our syndrome information is always correct.
      */
     gen_ss_advance(s);
-    gen_exception(EXCP_UDEF, syn_swstep(s->ss_same_el, 1, s->is_ldex),
+    gen_exception(EXCP_UDEF, syn_swstep(s->ss_same_el, 1, s->isyn.swstep.ex),
                   default_exception_el(s));
     s->is_jmp = DISAS_EXC;
 }
@@ -1865,7 +1865,7 @@ static void disas_ldst_excl(DisasContext *s, uint32_t insn)
 
     if (is_excl) {
         if (!is_store) {
-            s->is_ldex = true;
+            s->isyn.swstep.ex = true;
             gen_load_exclusive(s, rt, rt2, tcg_addr, size, is_pair);
         } else {
             gen_store_exclusive(s, rs, rt, rt2, tcg_addr, size, is_pair);
@@ -11136,7 +11136,7 @@ void gen_intermediate_code_a64(ARMCPU *cpu, TranslationBlock *tb)
      */
     dc->ss_active = ARM_TBFLAG_SS_ACTIVE(tb->flags);
     dc->pstate_ss = ARM_TBFLAG_PSTATE_SS(tb->flags);
-    dc->is_ldex = false;
+    dc->isyn.swstep.ex = false;
     dc->ss_same_el = (arm_debug_target_el(env) == dc->current_el);
 
     init_tmp_a64_array(dc);
target-arm/translate.c +3 -3
index 7d83c94..5aee066 100644
@@ -250,7 +250,7 @@ static void gen_step_complete_exception(DisasContext *s)
      * of the exception, and our syndrome information is always correct.
      */
     gen_ss_advance(s);
-    gen_exception(EXCP_UDEF, syn_swstep(s->ss_same_el, 1, s->is_ldex),
+    gen_exception(EXCP_UDEF, syn_swstep(s->ss_same_el, 1, s->isyn.swstep.ex),
                   default_exception_el(s));
     s->is_jmp = DISAS_EXC;
 }
@@ -7431,7 +7431,7 @@ static void gen_load_exclusive(DisasContext *s, int rt, int rt2,
 {
     TCGv_i32 tmp = tcg_temp_new_i32();
 
-    s->is_ldex = true;
+    s->isyn.swstep.ex = true;
 
     switch (size) {
     case 0:
@@ -11341,7 +11341,7 @@ void gen_intermediate_code(CPUARMState *env, TranslationBlock *tb)
      */
     dc->ss_active = ARM_TBFLAG_SS_ACTIVE(tb->flags);
     dc->pstate_ss = ARM_TBFLAG_PSTATE_SS(tb->flags);
-    dc->is_ldex = false;
+    dc->isyn.swstep.ex = false;
     dc->ss_same_el = false; /* Can't be true since EL_d must be AArch64 */
 
     cpu_F0s = tcg_temp_new_i32();
target-arm/translate.h +8 -5
index e002c90..1c4c087 100644
@@ -49,11 +49,6 @@ typedef struct DisasContext {
      */
     bool ss_active;
     bool pstate_ss;
-    /* True if the insn just emitted was a load-exclusive instruction
-     * (necessary for syndrome information for single step exceptions),
-     * ie A64 LDX*, LDAX*, A32/T32 LDREX*, LDAEX*.
-     */
-    bool is_ldex;
     /* True if a single-step exception will be taken to the current EL */
     bool ss_same_el;
     /* Bottom two bits of XScale c15_cpar coprocessor access control reg */
@@ -69,6 +64,14 @@ typedef struct DisasContext {
             bool sf;
             bool ar;
         } dabt;
+        /* SWStep section.  */
+        struct {
+            /* True if the insn just emitted was a load-exclusive instruction
+             * (necessary for syndrome information for single step exceptions),
+             * ie A64 LDX*, LDAX*, A32/T32 LDREX*, LDAEX*.
+             */
+            bool ex;
+        } swstep;
     } isyn;
     /* TCG op index of the current insn_start.  */
     int insn_start_idx;
Signature · 1 line
1.9.1
#14 lore raw

Re: [PATCH v2 8/8] target-arm: Use isyn.swstep.ex to hold the is_ldex state

Quoted 8 lines · Edgar E. Iglesias

From: "Edgar E. Iglesias" <[email protected]>

Switch to using isyn.swstep.ex to hold the is_ldex state for SWStep syndrome generation.

No functional change.

What's the rationale for renaming the field? If this is groundwork for something else it might make more sense in a patchset with whatever is going to use this. Or is it just trying to make the swstep handling parallel the dabt syndrome info approach a bit more?

thanks
-- PMM

#15 lore raw

Re: [PATCH v2 8/8] target-arm: Use isyn.swstep.ex to hold the is_ldex state

Quoted 7 lines · Peter Maydell
Quoted 5 lines · Edgar E. Iglesias

From: "Edgar E. Iglesias" <[email protected]>

Switch to using isyn.swstep.ex to hold the is_ldex state for SWStep syndrome generation.

Quoted 8 lines
Quoted 3 lines

No functional change.

What's the rationale for renaming the field? If this is groundwork for something else it might make more sense in a patchset with whatever is going to use this. Or is it just trying to make the swstep handling parallel the dabt syndrome info approach a bit more?

Yes, the latter. I can drop this one...

Cheers,
Edgar