target/arm: Add BT and BTYPE to tb->flags

Backports commit 08f1434a71ddf2bdfdb034dcd24b24464d1efd72 from qemu
This commit is contained in:
Richard Henderson 2019-02-05 16:59:50 -05:00 committed by Lioncash
parent a99119ce39
commit cf3ac035bc
No known key found for this signature in database
GPG key ID: 4E3C3CC1031BA9C7
4 changed files with 23 additions and 7 deletions

View file

@ -2997,6 +2997,8 @@ FIELD(TBFLAG_A64, TBII, 0, 2)
FIELD(TBFLAG_A64, SVEEXC_EL, 2, 2) FIELD(TBFLAG_A64, SVEEXC_EL, 2, 2)
FIELD(TBFLAG_A64, ZCR_LEN, 4, 4) FIELD(TBFLAG_A64, ZCR_LEN, 4, 4)
FIELD(TBFLAG_A64, PAUTH_ACTIVE, 8, 1) FIELD(TBFLAG_A64, PAUTH_ACTIVE, 8, 1)
FIELD(TBFLAG_A64, BT, 9, 1)
FIELD(TBFLAG_A64, BTYPE, 10, 2)
static inline bool bswap_code(bool sctlr_b) static inline bool bswap_code(bool sctlr_b)
{ {

View file

@ -12840,6 +12840,7 @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc,
if (is_a64(env)) { if (is_a64(env)) {
ARMCPU *cpu = arm_env_get_cpu(env); ARMCPU *cpu = arm_env_get_cpu(env);
uint64_t sctlr;
*pc = env->pc; *pc = env->pc;
flags = FIELD_DP32(flags, TBFLAG_ANY, AARCH64_STATE, 1); flags = FIELD_DP32(flags, TBFLAG_ANY, AARCH64_STATE, 1);
@ -12884,6 +12885,12 @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc,
flags = FIELD_DP32(flags, TBFLAG_A64, ZCR_LEN, zcr_len); flags = FIELD_DP32(flags, TBFLAG_A64, ZCR_LEN, zcr_len);
} }
if (current_el == 0) {
/* FIXME: ARMv8.1-VHE S2 translation regime. */
sctlr = env->cp15.sctlr_el[1];
} else {
sctlr = env->cp15.sctlr_el[current_el];
}
if (cpu_isar_feature(aa64_pauth, cpu)) { if (cpu_isar_feature(aa64_pauth, cpu)) {
/* /*
* In order to save space in flags, we record only whether * In order to save space in flags, we record only whether
@ -12891,17 +12898,18 @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc,
* a nop, or "active" when some action must be performed. * a nop, or "active" when some action must be performed.
* The decision of which action to take is left to a helper. * The decision of which action to take is left to a helper.
*/ */
uint64_t sctlr;
if (current_el == 0) {
/* FIXME: ARMv8.1-VHE S2 translation regime. */
sctlr = env->cp15.sctlr_el[1];
} else {
sctlr = env->cp15.sctlr_el[current_el];
}
if (sctlr & (SCTLR_EnIA | SCTLR_EnIB | SCTLR_EnDA | SCTLR_EnDB)) { if (sctlr & (SCTLR_EnIA | SCTLR_EnIB | SCTLR_EnDA | SCTLR_EnDB)) {
flags = FIELD_DP32(flags, TBFLAG_A64, PAUTH_ACTIVE, 1); flags = FIELD_DP32(flags, TBFLAG_A64, PAUTH_ACTIVE, 1);
} }
} }
if (cpu_isar_feature(aa64_bti, cpu)) {
/* Note that SCTLR_EL[23].BT == SCTLR_BT1. */
if (sctlr & (current_el == 0 ? SCTLR_BT0 : SCTLR_BT1)) {
flags = FIELD_DP32(flags, TBFLAG_A64, BT, 1);
}
flags = FIELD_DP32(flags, TBFLAG_A64, BTYPE, env->btype);
}
} else { } else {
*pc = env->regs[15]; *pc = env->regs[15];
flags = FIELD_DP32(flags, TBFLAG_A32, THUMB, env->thumb); flags = FIELD_DP32(flags, TBFLAG_A32, THUMB, env->thumb);

View file

@ -14036,6 +14036,8 @@ static void aarch64_tr_init_disas_context(DisasContextBase *dcbase,
dc->sve_excp_el = FIELD_EX32(tb_flags, TBFLAG_A64, SVEEXC_EL); dc->sve_excp_el = FIELD_EX32(tb_flags, TBFLAG_A64, SVEEXC_EL);
dc->sve_len = (FIELD_EX32(tb_flags, TBFLAG_A64, ZCR_LEN) + 1) * 16; dc->sve_len = (FIELD_EX32(tb_flags, TBFLAG_A64, ZCR_LEN) + 1) * 16;
dc->pauth_active = FIELD_EX32(tb_flags, TBFLAG_A64, PAUTH_ACTIVE); dc->pauth_active = FIELD_EX32(tb_flags, TBFLAG_A64, PAUTH_ACTIVE);
dc->bt = FIELD_EX32(tb_flags, TBFLAG_A64, BT);
dc->btype = FIELD_EX32(tb_flags, TBFLAG_A64, BTYPE);
dc->vec_len = 0; dc->vec_len = 0;
dc->vec_stride = 0; dc->vec_stride = 0;
dc->cp_regs = arm_cpu->cp_regs; dc->cp_regs = arm_cpu->cp_regs;

View file

@ -70,6 +70,10 @@ typedef struct DisasContext {
bool pauth_active; bool pauth_active;
/* Bottom two bits of XScale c15_cpar coprocessor access control reg */ /* Bottom two bits of XScale c15_cpar coprocessor access control reg */
int c15_cpar; int c15_cpar;
/* True with v8.5-BTI and SCTLR_ELx.BT* set. */
bool bt;
/* A copy of PSTATE.BTYPE, which will be 0 without v8.5-BTI. */
uint8_t btype;
/* TCG op of the current insn_start. */ /* TCG op of the current insn_start. */
TCGOp *insn_start; TCGOp *insn_start;
#define TMP_A64_MAX 16 #define TMP_A64_MAX 16