mirror of
https://github.com/yuzu-emu/unicorn.git
synced 2024-12-22 19:05:32 +00:00
target/arm: Add support for FEAT_DIT, Data Independent Timing
Add support for FEAT_DIT. DIT (Data Independent Timing) is a required feature for ARMv8.4. Since virtual machine execution is largely nondeterministic and TCG is outside of the security domain, it's implemented as a NOP. Backports dc8b18534ea1dcc90d80ad9a61a3b0aa7eb312fb
This commit is contained in:
parent
4e482764e2
commit
d8458f14af
|
@ -1118,6 +1118,7 @@ void pmu_init(ARMCPU *cpu);
|
|||
#define CPSR_IT_2_7 (0xfc00U)
|
||||
#define CPSR_GE (0xfU << 16)
|
||||
#define CPSR_IL (1U << 20)
|
||||
#define CPSR_DIT (1U << 21)
|
||||
#define CPSR_PAN (1U << 22)
|
||||
#define CPSR_J (1U << 24)
|
||||
#define CPSR_IT_0_1 (3U << 25)
|
||||
|
@ -1185,6 +1186,7 @@ void pmu_init(ARMCPU *cpu);
|
|||
#define PSTATE_SS (1U << 21)
|
||||
#define PSTATE_PAN (1U << 22)
|
||||
#define PSTATE_UAO (1U << 23)
|
||||
#define PSTATE_DIT (1U << 24)
|
||||
#define PSTATE_TCO (1U << 25)
|
||||
#define PSTATE_V (1U << 28)
|
||||
#define PSTATE_C (1U << 29)
|
||||
|
@ -3727,6 +3729,11 @@ static inline bool isar_feature_aa32_tts2uxn(const ARMISARegisters *id)
|
|||
return FIELD_EX32(id->id_mmfr4, ID_MMFR4, XNX) != 0;
|
||||
}
|
||||
|
||||
static inline bool isar_feature_aa32_dit(const ARMISARegisters *id)
|
||||
{
|
||||
return FIELD_EX32(id->id_pfr0, ID_PFR0, DIT) != 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* 64-bit feature tests via id registers.
|
||||
*/
|
||||
|
@ -3976,6 +3983,11 @@ static inline bool isar_feature_aa64_tts2uxn(const ARMISARegisters *id)
|
|||
return FIELD_EX64(id->id_aa64mmfr1, ID_AA64MMFR1, XNX) != 0;
|
||||
}
|
||||
|
||||
static inline bool isar_feature_aa64_dit(const ARMISARegisters *id)
|
||||
{
|
||||
return FIELD_EX64(id->id_aa64pfr0, ID_AA64PFR0, DIT) != 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Feature tests for "does this exist in either 32-bit or 64-bit?"
|
||||
*/
|
||||
|
|
|
@ -4123,6 +4123,24 @@ static const ARMCPRegInfo uao_reginfo = {
|
|||
.readfn = aa64_uao_read, .writefn = aa64_uao_write
|
||||
};
|
||||
|
||||
static uint64_t aa64_dit_read(CPUARMState *env, const ARMCPRegInfo *ri)
|
||||
{
|
||||
return env->pstate & PSTATE_DIT;
|
||||
}
|
||||
|
||||
static void aa64_dit_write(CPUARMState *env, const ARMCPRegInfo *ri,
|
||||
uint64_t value)
|
||||
{
|
||||
env->pstate = (env->pstate & ~PSTATE_DIT) | (value & PSTATE_DIT);
|
||||
}
|
||||
|
||||
static const ARMCPRegInfo dit_reginfo = {
|
||||
.name = "DIT", .state = ARM_CP_STATE_AA64,
|
||||
.opc0 = 3, .opc1 = 3, .crn = 4, .crm = 2, .opc2 = 5,
|
||||
.type = ARM_CP_NO_RAW, .access = PL0_RW,
|
||||
.readfn = aa64_dit_read, .writefn = aa64_dit_write
|
||||
};
|
||||
|
||||
static CPAccessResult aa64_cacheop_poc_access(CPUARMState *env,
|
||||
const ARMCPRegInfo *ri,
|
||||
bool isread)
|
||||
|
@ -7880,6 +7898,10 @@ void register_cp_regs_for_features(ARMCPU *cpu)
|
|||
define_arm_cp_regs(cpu, vhe_reginfo);
|
||||
}
|
||||
|
||||
if (cpu_isar_feature(aa64_dit, cpu)) {
|
||||
define_one_arm_cp_reg(cpu, &dit_reginfo);
|
||||
}
|
||||
|
||||
if (cpu_isar_feature(aa64_sve, cpu)) {
|
||||
define_one_arm_cp_reg(cpu, &zcr_el1_reginfo);
|
||||
if (arm_feature(env, ARM_FEATURE_EL2)) {
|
||||
|
|
|
@ -1224,6 +1224,9 @@ static inline uint32_t aarch32_cpsr_valid_mask(uint64_t features,
|
|||
if (isar_feature_aa32_pan(id)) {
|
||||
valid |= CPSR_PAN;
|
||||
}
|
||||
if (isar_feature_aa32_dit(id)) {
|
||||
valid |= CPSR_DIT;
|
||||
}
|
||||
|
||||
return valid;
|
||||
}
|
||||
|
@ -1242,6 +1245,9 @@ static inline uint32_t aarch64_pstate_valid_mask(const ARMISARegisters *id)
|
|||
if (isar_feature_aa64_uao(id)) {
|
||||
valid |= PSTATE_UAO;
|
||||
}
|
||||
if (isar_feature_aa64_dit(id)) {
|
||||
valid |= PSTATE_DIT;
|
||||
}
|
||||
if (isar_feature_aa64_mte(id)) {
|
||||
valid |= PSTATE_TCO;
|
||||
}
|
||||
|
|
|
@ -1892,6 +1892,18 @@ static void handle_msr_i(DisasContext *s, uint32_t insn,
|
|||
tcg_temp_free_i32(tcg_ctx, t1);
|
||||
break;
|
||||
|
||||
case 0x1a: /* DIT */
|
||||
if (!dc_isar_feature(aa64_dit, s)) {
|
||||
goto do_unallocated;
|
||||
}
|
||||
if (crm & 1) {
|
||||
set_pstate_bits(s, PSTATE_DIT);
|
||||
} else {
|
||||
clear_pstate_bits(s, PSTATE_DIT);
|
||||
}
|
||||
/* There's no need to rebuild hflags because DIT is a nop */
|
||||
break;
|
||||
|
||||
case 0x1e: /* DAIFSet */
|
||||
t1 = tcg_const_i32(tcg_ctx, crm);
|
||||
gen_helper_msr_i_daifset(tcg_ctx, tcg_ctx->cpu_env, t1);
|
||||
|
|
Loading…
Reference in a new issue