target/arm: MTE user mode disassembly
PATCH 2/5 target/arm: MTE user mode disassembly
From: Rémi Denis-Courmont <[email protected]>
This adds TCG disassembler support for the EL0-accessible instructions from ARMv8.5-MemTag, and sets corresponding feature bit in the "maximum" emulated CPU.
--- target/arm/cpu64.c | 7 ++ target/arm/helper.c | 30 +++++ target/arm/translate-a64.c | 236 +++++++++++++++++++++++++++++++++++-- 3 files changed, 266 insertions(+), 7 deletions(-)
target/arm/cpu64.c +7 -0
@@ -665,6 +665,13 @@ static void aarch64_max_initfn(Object *obj) t = cpu->isar.id_aa64pfr1; t =FIELD_DP64 (t,ID_AA64PFR1 ,BT ,1 ); +#ifdef CONFIG_USER_ONLY +/* All MTE instructions and processor states are supported for user +* mode. This corresponds to feature field value 1 (field value 2 +* implies MemTag memory support). +*/ + t =FIELD_DP64 (t,ID_AA64PFR1 ,MTE ,1 ); +#endif cpu->isar.id_aa64pfr1 = t; t = cpu->isar.id_aa64mmfr1;
target/arm/helper.c +30 -0
@@ -6839,6 +6839,33 @@ static const ARMCPRegInfo dcpodp_reg[] = { };#endif /*CONFIG_USER_ONLY*/ +static uint64_t tco_read (CPUARMState *env,const ARMCPRegInfo *ri) +{ +return env->pstate &PSTATE_TCO ; +} + +static void tco_write (CPUARMState *env,const ARMCPRegInfo *ri,uint64_t val) +{ +if (val &PSTATE_TCO ) { + env->pstate |=PSTATE_TCO ; + }else { + env->pstate &= ~PSTATE_TCO ; + } +} + +static const ARMCPRegInfo mte_reginfo[] = { + { .name ="DC_GVA" , .state =ARM_CP_STATE_AA64 , + .opc0 =1 , .opc1 =3 , .crn =7 , .crm =4 , .opc2 =3 , + .access =PL0_W , .type =ARM_CP_NOP }, + { .name ="DC_GZVA" , .state =ARM_CP_STATE_AA64 , + .opc0 =1 , .opc1 =3 , .crn =7 , .crm =4 , .opc2 =4 , + .access =PL0_W , .type =ARM_CP_DC_ZVA }, + { .name ="TCO" , .state =ARM_CP_STATE_AA64 , + .opc0 =3 , .opc1 =3 , .crn =4 , .crm =2 , .opc2 =7 , + .access =PL0_RW , .type =ARM_CP_NO_RAW , + .readfn = tco_read, .writefn = tco_write }, +REGINFO_SENTINEL +};#endif static CPAccessResult access_predinv(CPUARMState *env, const ARMCPRegInfo *ri,
@@ -7956,6 +7983,9 @@ void register_cp_regs_for_features(ARMCPU *cpu) } }#endif /*CONFIG_USER_ONLY*/ +if (cpu_isar_feature (aa64_mte, cpu)) { +define_arm_cp_regs (cpu, mte_reginfo); + }#endif if (cpu_isar_feature (any_predinv, cpu)) {
target/arm/translate-a64.c +229 -7
323 lines not on this page · raw message
Signature · 1 line
2.25.1
target/arm/translate-a64.c static void gen_adc_CC(int sf, TCGv_i64 dest, TCGv_i64 t0, TCGv_i64 t1) · line 844
Quoted 12 lines · Rémi Denis-Courmont
target/arm/translate-a64.c +12
-0+/* Extract an Allocation Tag from an address */ +static void gen_extract_tag (TCGv_i64 dest,TCGv_i64 source) +{ +TCGv_i64 sign =tcg_temp_new_i64 (); + +/* See ARMv8.5-A AllocationTagFromAddress pseudocode */ +tcg_gen_extract_i64 (sign, source,55 ,1 ); +tcg_gen_extract_i64 (dest, source,56 ,4 ); +tcg_gen_add_i64 (dest, dest, sign); +tcg_gen_andi_i64 (dest, dest,0xf ); +tcg_temp_free_i64 (sign); +}
In addition to everything else, I see that you're working from quite an old beta version of the memtag spec.
Please grab the most recent Arm ARM, F.a:
https://developer.arm.com/docs/ddi0487/latest
The current version does not really distinguish between logical and physical tags, so there is no add:
bits(4) AArch64.AllocationTagFromAddress(bits(64) tagged_address)
return tagged_address<59:56>;
r~