Message ID | 20190826151536.6771-3-richard.henderson@linaro.org |
---|---|
State | Superseded |
Headers | show |
Series | target/arm: Fix aarch64 illegal opcode exceptions | expand |
On Mon, Aug 26, 2019 at 5:15 PM Richard Henderson <richard.henderson@linaro.org> wrote: > > Make this a static function private to translate.c. > Thus we can use the same idiom between aarch64 and aarch32 > without actually sharing function implementations. > > Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Reviewed-by: Laurent Desnogues <laurent.desnogues@gmail.com> Thanks, Laurent > --- > target/arm/translate-vfp.inc.c | 3 +-- > target/arm/translate.c | 22 ++++++++++++---------- > 2 files changed, 13 insertions(+), 12 deletions(-) > > diff --git a/target/arm/translate-vfp.inc.c b/target/arm/translate-vfp.inc.c > index 5065d4524c..3e8ea80493 100644 > --- a/target/arm/translate-vfp.inc.c > +++ b/target/arm/translate-vfp.inc.c > @@ -108,8 +108,7 @@ static bool full_vfp_access_check(DisasContext *s, bool ignore_vfp_enabled) > > if (!s->vfp_enabled && !ignore_vfp_enabled) { > assert(!arm_dc_feature(s, ARM_FEATURE_M)); > - gen_exception_insn(s, s->pc_curr, EXCP_UDEF, syn_uncategorized(), > - default_exception_el(s)); > + unallocated_encoding(s); > return false; > } > > diff --git a/target/arm/translate.c b/target/arm/translate.c > index 2aac9aae68..66311580c0 100644 > --- a/target/arm/translate.c > +++ b/target/arm/translate.c > @@ -1231,6 +1231,13 @@ static void gen_exception_bkpt_insn(DisasContext *s, uint32_t syn) > s->base.is_jmp = DISAS_NORETURN; > } > > +static void unallocated_encoding(DisasContext *s) > +{ > + /* Unallocated and reserved encodings are uncategorized */ > + gen_exception_insn(s, s->pc_curr, EXCP_UDEF, syn_uncategorized(), > + default_exception_el(s)); > +} > + > /* Force a TB lookup after an instruction that changes the CPU state. */ > static inline void gen_lookup_tb(DisasContext *s) > { > @@ -1261,8 +1268,7 @@ static inline void gen_hlt(DisasContext *s, int imm) > return; > } > > - gen_exception_insn(s, s->pc_curr, EXCP_UDEF, syn_uncategorized(), > - default_exception_el(s)); > + unallocated_encoding(s); > } > > static inline void gen_add_data_offset(DisasContext *s, unsigned int insn, > @@ -7574,8 +7580,7 @@ static void gen_srs(DisasContext *s, > } > > if (undef) { > - gen_exception_insn(s, s->pc_curr, EXCP_UDEF, syn_uncategorized(), > - default_exception_el(s)); > + unallocated_encoding(s); > return; > } > > @@ -9196,8 +9201,7 @@ static void disas_arm_insn(DisasContext *s, unsigned int insn) > break; > default: > illegal_op: > - gen_exception_insn(s, s->pc_curr, EXCP_UDEF, syn_uncategorized(), > - default_exception_el(s)); > + unallocated_encoding(s); > break; > } > } > @@ -10882,8 +10886,7 @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn) > } > return; > illegal_op: > - gen_exception_insn(s, s->pc_curr, EXCP_UDEF, syn_uncategorized(), > - default_exception_el(s)); > + unallocated_encoding(s); > } > > static void disas_thumb_insn(DisasContext *s, uint32_t insn) > @@ -11706,8 +11709,7 @@ static void disas_thumb_insn(DisasContext *s, uint32_t insn) > return; > illegal_op: > undef: > - gen_exception_insn(s, s->pc_curr, EXCP_UDEF, syn_uncategorized(), > - default_exception_el(s)); > + unallocated_encoding(s); > } > > static bool insn_crosses_page(CPUARMState *env, DisasContext *s) > -- > 2.17.1 >
diff --git a/target/arm/translate-vfp.inc.c b/target/arm/translate-vfp.inc.c index 5065d4524c..3e8ea80493 100644 --- a/target/arm/translate-vfp.inc.c +++ b/target/arm/translate-vfp.inc.c @@ -108,8 +108,7 @@ static bool full_vfp_access_check(DisasContext *s, bool ignore_vfp_enabled) if (!s->vfp_enabled && !ignore_vfp_enabled) { assert(!arm_dc_feature(s, ARM_FEATURE_M)); - gen_exception_insn(s, s->pc_curr, EXCP_UDEF, syn_uncategorized(), - default_exception_el(s)); + unallocated_encoding(s); return false; } diff --git a/target/arm/translate.c b/target/arm/translate.c index 2aac9aae68..66311580c0 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -1231,6 +1231,13 @@ static void gen_exception_bkpt_insn(DisasContext *s, uint32_t syn) s->base.is_jmp = DISAS_NORETURN; } +static void unallocated_encoding(DisasContext *s) +{ + /* Unallocated and reserved encodings are uncategorized */ + gen_exception_insn(s, s->pc_curr, EXCP_UDEF, syn_uncategorized(), + default_exception_el(s)); +} + /* Force a TB lookup after an instruction that changes the CPU state. */ static inline void gen_lookup_tb(DisasContext *s) { @@ -1261,8 +1268,7 @@ static inline void gen_hlt(DisasContext *s, int imm) return; } - gen_exception_insn(s, s->pc_curr, EXCP_UDEF, syn_uncategorized(), - default_exception_el(s)); + unallocated_encoding(s); } static inline void gen_add_data_offset(DisasContext *s, unsigned int insn, @@ -7574,8 +7580,7 @@ static void gen_srs(DisasContext *s, } if (undef) { - gen_exception_insn(s, s->pc_curr, EXCP_UDEF, syn_uncategorized(), - default_exception_el(s)); + unallocated_encoding(s); return; } @@ -9196,8 +9201,7 @@ static void disas_arm_insn(DisasContext *s, unsigned int insn) break; default: illegal_op: - gen_exception_insn(s, s->pc_curr, EXCP_UDEF, syn_uncategorized(), - default_exception_el(s)); + unallocated_encoding(s); break; } } @@ -10882,8 +10886,7 @@ static void disas_thumb2_insn(DisasContext *s, uint32_t insn) } return; illegal_op: - gen_exception_insn(s, s->pc_curr, EXCP_UDEF, syn_uncategorized(), - default_exception_el(s)); + unallocated_encoding(s); } static void disas_thumb_insn(DisasContext *s, uint32_t insn) @@ -11706,8 +11709,7 @@ static void disas_thumb_insn(DisasContext *s, uint32_t insn) return; illegal_op: undef: - gen_exception_insn(s, s->pc_curr, EXCP_UDEF, syn_uncategorized(), - default_exception_el(s)); + unallocated_encoding(s); } static bool insn_crosses_page(CPUARMState *env, DisasContext *s)
Make this a static function private to translate.c. Thus we can use the same idiom between aarch64 and aarch32 without actually sharing function implementations. Signed-off-by: Richard Henderson <richard.henderson@linaro.org> --- target/arm/translate-vfp.inc.c | 3 +-- target/arm/translate.c | 22 ++++++++++++---------- 2 files changed, 13 insertions(+), 12 deletions(-) -- 2.17.1