target/arm: Introduce gen_exception_insn
Create a new wrapper function that passes the default exception target to gen_exception_insn_el. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Message-id: 20220609202901.1177572-13-richard.henderson@linaro.org Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
		
							parent
							
								
									8c5d24dc7d
								
							
						
					
					
						commit
						486d6c9699
					
				@ -1816,8 +1816,7 @@ static void gen_sysreg_undef(DisasContext *s, bool isread,
 | 
				
			|||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
        syndrome = syn_uncategorized();
 | 
					        syndrome = syn_uncategorized();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    gen_exception_insn_el(s, s->pc_curr, EXCP_UDEF, syndrome,
 | 
					    gen_exception_insn(s, s->pc_curr, EXCP_UDEF, syndrome);
 | 
				
			||||||
                          default_exception_el(s));
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* MRS - move from system register
 | 
					/* MRS - move from system register
 | 
				
			||||||
@ -2069,8 +2068,8 @@ static void disas_exc(DisasContext *s, uint32_t insn)
 | 
				
			|||||||
        switch (op2_ll) {
 | 
					        switch (op2_ll) {
 | 
				
			||||||
        case 1:                                                     /* SVC */
 | 
					        case 1:                                                     /* SVC */
 | 
				
			||||||
            gen_ss_advance(s);
 | 
					            gen_ss_advance(s);
 | 
				
			||||||
            gen_exception_insn_el(s, s->base.pc_next, EXCP_SWI,
 | 
					            gen_exception_insn(s, s->base.pc_next, EXCP_SWI,
 | 
				
			||||||
                                  syn_aa64_svc(imm16), default_exception_el(s));
 | 
					                               syn_aa64_svc(imm16));
 | 
				
			||||||
            break;
 | 
					            break;
 | 
				
			||||||
        case 2:                                                     /* HVC */
 | 
					        case 2:                                                     /* HVC */
 | 
				
			||||||
            if (s->current_el == 0) {
 | 
					            if (s->current_el == 0) {
 | 
				
			||||||
@ -14725,8 +14724,7 @@ static void aarch64_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu)
 | 
				
			|||||||
         * Illegal execution state. This has priority over BTI
 | 
					         * Illegal execution state. This has priority over BTI
 | 
				
			||||||
         * exceptions, but comes after instruction abort exceptions.
 | 
					         * exceptions, but comes after instruction abort exceptions.
 | 
				
			||||||
         */
 | 
					         */
 | 
				
			||||||
        gen_exception_insn_el(s, s->pc_curr, EXCP_UDEF,
 | 
					        gen_exception_insn(s, s->pc_curr, EXCP_UDEF, syn_illegalstate());
 | 
				
			||||||
                              syn_illegalstate(), default_exception_el(s));
 | 
					 | 
				
			||||||
        return;
 | 
					        return;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -14757,9 +14755,8 @@ static void aarch64_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu)
 | 
				
			|||||||
            if (s->btype != 0
 | 
					            if (s->btype != 0
 | 
				
			||||||
                && s->guarded_page
 | 
					                && s->guarded_page
 | 
				
			||||||
                && !btype_destination_ok(insn, s->bt, s->btype)) {
 | 
					                && !btype_destination_ok(insn, s->bt, s->btype)) {
 | 
				
			||||||
                gen_exception_insn_el(s, s->pc_curr, EXCP_UDEF,
 | 
					                gen_exception_insn(s, s->pc_curr, EXCP_UDEF,
 | 
				
			||||||
                                      syn_btitrap(s->btype),
 | 
					                                   syn_btitrap(s->btype));
 | 
				
			||||||
                                      default_exception_el(s));
 | 
					 | 
				
			||||||
                return;
 | 
					                return;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
 | 
				
			|||||||
@ -765,8 +765,7 @@ static bool trans_NOCP(DisasContext *s, arg_nocp *a)
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (a->cp != 10) {
 | 
					    if (a->cp != 10) {
 | 
				
			||||||
        gen_exception_insn_el(s, s->pc_curr, EXCP_NOCP,
 | 
					        gen_exception_insn(s, s->pc_curr, EXCP_NOCP, syn_uncategorized());
 | 
				
			||||||
                              syn_uncategorized(), default_exception_el(s));
 | 
					 | 
				
			||||||
        return true;
 | 
					        return true;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -100,8 +100,7 @@ bool mve_eci_check(DisasContext *s)
 | 
				
			|||||||
        return true;
 | 
					        return true;
 | 
				
			||||||
    default:
 | 
					    default:
 | 
				
			||||||
        /* Reserved value: INVSTATE UsageFault */
 | 
					        /* Reserved value: INVSTATE UsageFault */
 | 
				
			||||||
        gen_exception_insn_el(s, s->pc_curr, EXCP_INVSTATE, syn_uncategorized(),
 | 
					        gen_exception_insn(s, s->pc_curr, EXCP_INVSTATE, syn_uncategorized());
 | 
				
			||||||
                              default_exception_el(s));
 | 
					 | 
				
			||||||
        return false;
 | 
					        return false;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -1106,6 +1106,11 @@ void gen_exception_insn_el(DisasContext *s, uint64_t pc, int excp,
 | 
				
			|||||||
    gen_exception_insn_el_v(s, pc, excp, syn, tcg_constant_i32(target_el));
 | 
					    gen_exception_insn_el_v(s, pc, excp, syn, tcg_constant_i32(target_el));
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void gen_exception_insn(DisasContext *s, uint64_t pc, int excp, uint32_t syn)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    gen_exception_insn_el(s, pc, excp, syn, default_exception_el(s));
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void gen_exception_bkpt_insn(DisasContext *s, uint32_t syn)
 | 
					static void gen_exception_bkpt_insn(DisasContext *s, uint32_t syn)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    gen_set_condexec(s);
 | 
					    gen_set_condexec(s);
 | 
				
			||||||
@ -1117,8 +1122,7 @@ static void gen_exception_bkpt_insn(DisasContext *s, uint32_t syn)
 | 
				
			|||||||
void unallocated_encoding(DisasContext *s)
 | 
					void unallocated_encoding(DisasContext *s)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    /* Unallocated and reserved encodings are uncategorized */
 | 
					    /* Unallocated and reserved encodings are uncategorized */
 | 
				
			||||||
    gen_exception_insn_el(s, s->pc_curr, EXCP_UDEF, syn_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.  */
 | 
					/* Force a TB lookup after an instruction that changes the CPU state.  */
 | 
				
			||||||
@ -2731,8 +2735,6 @@ static bool msr_banked_access_decode(DisasContext *s, int r, int sysm, int rn,
 | 
				
			|||||||
     * an exception and return false. Otherwise it will return true,
 | 
					     * an exception and return false. Otherwise it will return true,
 | 
				
			||||||
     * and set *tgtmode and *regno appropriately.
 | 
					     * and set *tgtmode and *regno appropriately.
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    int exc_target = default_exception_el(s);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    /* These instructions are present only in ARMv8, or in ARMv7 with the
 | 
					    /* These instructions are present only in ARMv8, or in ARMv7 with the
 | 
				
			||||||
     * Virtualization Extensions.
 | 
					     * Virtualization Extensions.
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
@ -2869,8 +2871,7 @@ static bool msr_banked_access_decode(DisasContext *s, int r, int sysm, int rn,
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
undef:
 | 
					undef:
 | 
				
			||||||
    /* If we get here then some access check did not pass */
 | 
					    /* If we get here then some access check did not pass */
 | 
				
			||||||
    gen_exception_insn_el(s, s->pc_curr, EXCP_UDEF,
 | 
					    gen_exception_insn(s, s->pc_curr, EXCP_UDEF, syn_uncategorized());
 | 
				
			||||||
                          syn_uncategorized(), exc_target);
 | 
					 | 
				
			||||||
    return false;
 | 
					    return false;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -8583,8 +8584,7 @@ static bool trans_LE(DisasContext *s, arg_LE *a)
 | 
				
			|||||||
        tmp = load_cpu_field(v7m.ltpsize);
 | 
					        tmp = load_cpu_field(v7m.ltpsize);
 | 
				
			||||||
        tcg_gen_brcondi_i32(TCG_COND_EQ, tmp, 4, skipexc);
 | 
					        tcg_gen_brcondi_i32(TCG_COND_EQ, tmp, 4, skipexc);
 | 
				
			||||||
        tcg_temp_free_i32(tmp);
 | 
					        tcg_temp_free_i32(tmp);
 | 
				
			||||||
        gen_exception_insn_el(s, s->pc_curr, EXCP_INVSTATE, syn_uncategorized(),
 | 
					        gen_exception_insn(s, s->pc_curr, EXCP_INVSTATE, syn_uncategorized());
 | 
				
			||||||
                              default_exception_el(s));
 | 
					 | 
				
			||||||
        gen_set_label(skipexc);
 | 
					        gen_set_label(skipexc);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -9054,8 +9054,7 @@ static void disas_arm_insn(DisasContext *s, unsigned int insn)
 | 
				
			|||||||
     * UsageFault exception.
 | 
					     * UsageFault exception.
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    if (arm_dc_feature(s, ARM_FEATURE_M)) {
 | 
					    if (arm_dc_feature(s, ARM_FEATURE_M)) {
 | 
				
			||||||
        gen_exception_insn_el(s, s->pc_curr, EXCP_INVSTATE, syn_uncategorized(),
 | 
					        gen_exception_insn(s, s->pc_curr, EXCP_INVSTATE, syn_uncategorized());
 | 
				
			||||||
                              default_exception_el(s));
 | 
					 | 
				
			||||||
        return;
 | 
					        return;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -9064,8 +9063,7 @@ static void disas_arm_insn(DisasContext *s, unsigned int insn)
 | 
				
			|||||||
         * Illegal execution state. This has priority over BTI
 | 
					         * Illegal execution state. This has priority over BTI
 | 
				
			||||||
         * exceptions, but comes after instruction abort exceptions.
 | 
					         * exceptions, but comes after instruction abort exceptions.
 | 
				
			||||||
         */
 | 
					         */
 | 
				
			||||||
        gen_exception_insn_el(s, s->pc_curr, EXCP_UDEF,
 | 
					        gen_exception_insn(s, s->pc_curr, EXCP_UDEF, syn_illegalstate());
 | 
				
			||||||
                              syn_illegalstate(), default_exception_el(s));
 | 
					 | 
				
			||||||
        return;
 | 
					        return;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -9634,8 +9632,7 @@ static void thumb_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu)
 | 
				
			|||||||
         * Illegal execution state. This has priority over BTI
 | 
					         * Illegal execution state. This has priority over BTI
 | 
				
			||||||
         * exceptions, but comes after instruction abort exceptions.
 | 
					         * exceptions, but comes after instruction abort exceptions.
 | 
				
			||||||
         */
 | 
					         */
 | 
				
			||||||
        gen_exception_insn_el(dc, dc->pc_curr, EXCP_UDEF,
 | 
					        gen_exception_insn(dc, dc->pc_curr, EXCP_UDEF, syn_illegalstate());
 | 
				
			||||||
                              syn_illegalstate(), default_exception_el(dc));
 | 
					 | 
				
			||||||
        return;
 | 
					        return;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -9708,8 +9705,8 @@ static void thumb_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu)
 | 
				
			|||||||
         */
 | 
					         */
 | 
				
			||||||
        tcg_remove_ops_after(dc->insn_eci_rewind);
 | 
					        tcg_remove_ops_after(dc->insn_eci_rewind);
 | 
				
			||||||
        dc->condjmp = 0;
 | 
					        dc->condjmp = 0;
 | 
				
			||||||
        gen_exception_insn_el(dc, dc->pc_curr, EXCP_INVSTATE, syn_uncategorized(),
 | 
					        gen_exception_insn(dc, dc->pc_curr, EXCP_INVSTATE,
 | 
				
			||||||
                              default_exception_el(dc));
 | 
					                           syn_uncategorized());
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    arm_post_translate_insn(dc);
 | 
					    arm_post_translate_insn(dc);
 | 
				
			||||||
 | 
				
			|||||||
@ -281,6 +281,7 @@ MemOp pow2_align(unsigned i);
 | 
				
			|||||||
void unallocated_encoding(DisasContext *s);
 | 
					void unallocated_encoding(DisasContext *s);
 | 
				
			||||||
void gen_exception_insn_el(DisasContext *s, uint64_t pc, int excp,
 | 
					void gen_exception_insn_el(DisasContext *s, uint64_t pc, int excp,
 | 
				
			||||||
                           uint32_t syn, uint32_t target_el);
 | 
					                           uint32_t syn, uint32_t target_el);
 | 
				
			||||||
 | 
					void gen_exception_insn(DisasContext *s, uint64_t pc, int excp, uint32_t syn);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Return state of Alternate Half-precision flag, caller frees result */
 | 
					/* Return state of Alternate Half-precision flag, caller frees result */
 | 
				
			||||||
static inline TCGv_i32 get_ahp_flag(void)
 | 
					static inline TCGv_i32 get_ahp_flag(void)
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user