target/arm: Implement ARMv8.5-MemTag, system mode
v8 cover target/arm: Implement ARMv8.5-MemTag, system mode
Version 8 incorporates quite a bit of review (thanks, PMM):
* Include HCR_DCT in the HCR_EL2 update.
* Use a separate decode function for ADDG/SUBG.
* Use the system arm_cpu_do_unaligned_access for user-only as well.
* Fix alignment for LDG.
* Fix no-fault for mte_probe1.
* Rearrage how tagged pages are recorded.
and perhaps most visibly, for those tracking the kernel patches:
* Add arm,armv8.5-memtag to the dtb.
r~
In need of review:
0010-target-arm-Revise-decoding-for-disas_add_sub_imm.patch 0011-target-arm-Implement-the-ADDG-SUBG-instructions.patch 0014-target-arm-Define-arm_cpu_do_unaligned_access-for.patch 0015-target-arm-Implement-LDG-STG-ST2G-instructions.patch 0025-target-arm-Implement-helper_mte_check1.patch 0028-target-arm-Use-mte_checkN-for-sve-unpredicated-lo.patch 0029-target-arm-Use-mte_checkN-for-sve-unpredicated-st.patch 0030-target-arm-Use-mte_check1-for-sve-LD1R.patch 0031-target-arm-Tidy-trans_LD1R_zpri.patch 0032-target-arm-Add-arm_tlb_bti_gp.patch 0033-target-arm-Add-mte-helpers-for-sve-scalar-int-loa.patch 0034-target-arm-Add-mte-helpers-for-sve-scalar-int-sto.patch 0035-target-arm-Add-mte-helpers-for-sve-scalar-int-ff-.patch 0036-target-arm-Handle-TBI-for-sve-scalar-int-memory-o.patch 0037-target-arm-Add-mte-helpers-for-sve-scatter-gather.patch 0038-target-arm-Complete-TBI-clearing-for-user-only-fo.patch 0041-target-arm-Always-pass-cacheattr-to-get_phys_addr.patch 0042-target-arm-Cache-the-Tagged-bit-for-a-page-in-Mem.patch 0043-target-arm-Create-tagged-ram-when-MTE-is-enabled.patch 0044-target-arm-Add-allocation-tag-storage-for-system-.patch 0045-target-arm-Enable-MTE.patch
Richard Henderson (45):
target/arm: Add isar tests for mte
target/arm: Improve masking of SCR RES0 bits target/arm: Add support for MTE to SCTLR_ELx target/arm: Add support for MTE to HCR_EL2 and SCR_EL3 target/arm: Rename DISAS_UPDATE to DISAS_UPDATE_EXIT target/arm: Add DISAS_UPDATE_NOCHAIN
target/arm: Add MTE system registers
target/arm: Add MTE bits to tb_flags
target/arm: Implement the IRG instruction target/arm: Revise decoding for disas_add_sub_imm target/arm: Implement the ADDG, SUBG instructions target/arm: Implement the GMI instruction target/arm: Implement the SUBP instruction target/arm: Define arm_cpu_do_unaligned_access for user-only target/arm: Implement LDG, STG, ST2G instructions target/arm: Implement the STGP instruction target/arm: Restrict the values of DCZID.BS under TCG target/arm: Simplify DC_ZVA
target/arm: Implement the LDGM, STGM, STZGM instructions target/arm: Implement the access tag cache flushes target/arm: Move regime_el to internals.h target/arm: Move regime_tcr to internals.h target/arm: Add gen_mte_check1
target/arm: Add gen_mte_checkN
target/arm: Implement helper_mte_check1
target/arm: Implement helper_mte_checkN
target/arm: Add helper_mte_check_zva
target/arm: Use mte_checkN for sve unpredicated loads target/arm: Use mte_checkN for sve unpredicated stores target/arm: Use mte_check1 for sve LD1R
target/arm: Tidy trans_LD1R_zpri
target/arm: Add arm_tlb_bti_gp
target/arm: Add mte helpers for sve scalar + int loads target/arm: Add mte helpers for sve scalar + int stores target/arm: Add mte helpers for sve scalar + int ff/nf loads target/arm: Handle TBI for sve scalar + int memory ops target/arm: Add mte helpers for sve scatter/gather memory ops target/arm: Complete TBI clearing for user-only for SVE target/arm: Implement data cache set allocation tags target/arm: Set PSTATE.TCO on exception entry target/arm: Always pass cacheattr to get_phys_addr target/arm: Cache the Tagged bit for a page in MemTxAttrs target/arm: Create tagged ram when MTE is enabled target/arm: Add allocation tag storage for system mode target/arm: Enable MTE
include/hw/arm/boot.h | 3 + target/arm/cpu.h | 50 +- target/arm/helper-a64.h | 16 + target/arm/helper-sve.h | 488 ++++++++++++ target/arm/helper.h | 2 + target/arm/internals.h | 153 +++- target/arm/translate-a64.h | 5 + target/arm/translate.h | 23 +- hw/arm/boot.c | 12 +- hw/arm/virt.c | 57 +- target/arm/cpu.c | 77 +- target/arm/cpu64.c | 1 + target/arm/helper-a64.c | 94 +-- target/arm/helper.c | 423 +++++++--- target/arm/m_helper.c | 11 +- target/arm/mte_helper.c | 901 +++++++++++++++++++++ target/arm/op_helper.c | 16 + target/arm/sve_helper.c | 616 +++++++++++--- target/arm/tlb_helper.c | 13 +- target/arm/translate-a64.c | 652 +++++++++++++-- target/arm/translate-sve.c | 1366 +++++++++++++++++++++----------- target/arm/translate-vfp.inc.c | 2 +- target/arm/translate.c | 16 +- target/arm/Makefile.objs | 1 + 24 files changed, 4164 insertions(+), 834 deletions(-) create mode 100644 target/arm/mte_helper.c
Signature · 1 line
2.25.1
PATCH v8 1/45 target/arm: Add isar tests for mte
--- target/arm/cpu.h | 10 ++++++++++ 1 file changed, 10 insertions(+)
target/arm/cpu.h +10 -0
@@ -3814,6 +3814,16 @@ static inline bool isar_feature_aa64_bti(const ARMISARegisters *id)return FIELD_EX64 (id->id_aa64pfr1,ID_AA64PFR1 ,BT ) !=0 ; } +static inline bool isar_feature_aa64_mte_insn_reg (const ARMISARegisters *id) +{ +return FIELD_EX64 (id->id_aa64pfr1,ID_AA64PFR1 ,MTE ) !=0 ; +} + +static inline bool isar_feature_aa64_mte (const ARMISARegisters *id) +{ +return FIELD_EX64 (id->id_aa64pfr1,ID_AA64PFR1 ,MTE ) >=2 ; +} +static inline bool isar_feature_aa64_pmu_8_1 (const ARMISARegisters *id) { return FIELD_EX64(id->id_aa64dfr0, ID_AA64DFR0, PMUVER) >= 4 &&
Signature · 1 line
2.25.1
PATCH v8 2/45 target/arm: Improve masking of SCR RES0 bits
In reply to Richard HendersonProtect reads of aa64 id registers with ARM_CP_STATE_AA64. Use this as a simpler test than arm_el_is_aa64, since EL3 cannot change mode.
--- target/arm/helper.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-)
target/arm/helper.c +8 -7
@@ -2011,9 +2011,16 @@ static void scr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value)uint32_t valid_mask =0x3fff ;ARMCPU *cpu =env_archcpu (env); -if (arm_el_is_aa64 (env,3 )) { +if (ri->state ==ARM_CP_STATE_AA64 ) { value |=SCR_FW |SCR_AW ;/* these two bits are RES1. */ valid_mask &= ~SCR_NET ; + +if (cpu_isar_feature (aa64_lor, cpu)) { + valid_mask |=SCR_TLOR ; + } +if (cpu_isar_feature (aa64_pauth, cpu)) { + valid_mask |=SCR_API |SCR_APK ; + } }else { valid_mask &= ~(SCR_RW |SCR_ST ); }
@@ -2032,12 +2039,6 @@ static void scr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value) valid_mask &= ~SCR_SMD ; } } -if (cpu_isar_feature (aa64_lor, cpu)) { - valid_mask |=SCR_TLOR ; - } -if (cpu_isar_feature (aa64_pauth, cpu)) { - valid_mask |=SCR_API |SCR_APK ; - }/* Clear all-context RES0 bits. */ value &= valid_mask;
Signature · 1 line
2.25.1
PATCH v8 3/45 target/arm: Add support for MTE to SCTLR_ELx
In reply to Richard HendersonThis does not attempt to rectify all of the res0 bits, but does clear the mte bits when not enabled. Since there is no high-part mapping of SCTLR, aa32 mode cannot write to these bits.
--- target/arm/helper.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-)
target/arm/helper.c +17 -6
@@ -4698,6 +4698,22 @@ static void sctlr_write(CPUARMState *env, const ARMCPRegInfo *ri, {ARMCPU *cpu =env_archcpu (env); +if (arm_feature (env,ARM_FEATURE_PMSA ) && !cpu->has_mpu) { +/* M bit is RAZ/WI for PMSA with no MPU implemented */ + value &= ~SCTLR_M ; + } + +/* ??? Lots of these bits are not implemented. */ + +if (ri->state ==ARM_CP_STATE_AA64 && !cpu_isar_feature (aa64_mte, cpu)) { +if (ri->opc1 ==6 ) {/* SCTLR_EL3 */ + value &= ~(SCTLR_ITFSB |SCTLR_TCF |SCTLR_ATA ); + }else { + value &= ~(SCTLR_ITFSB |SCTLR_TCF0 |SCTLR_TCF | +SCTLR_ATA0 |SCTLR_ATA ); + } + } +if (raw_read (env, ri) == value) {/* Skip the TLB flush if nothing actually changed; Linux likes * to do a lot of pointless SCTLR writes.
@@ -4705,13 +4721,8 @@ static void sctlr_write(CPUARMState *env, const ARMCPRegInfo *ri,return ; } -if (arm_feature (env,ARM_FEATURE_PMSA ) && !cpu->has_mpu) { -/* M bit is RAZ/WI for PMSA with no MPU implemented */ - value &= ~SCTLR_M ; - } -raw_write (env, ri, value); -/* ??? Lots of these bits are not implemented. */ +/* This may enable/disable the MMU, so do a TLB flush. */ tlb_flush (CPU (cpu));
Signature · 1 line
2.25.1
PATCH v8 4/45 target/arm: Add support for MTE to HCR_EL2 and SCR_EL3
In reply to Richard Henderson---
v8: Include HCR_DCT.
--- target/arm/helper.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-)
target/arm/helper.c +11 -3
@@ -2021,6 +2021,9 @@ static void scr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value)if (cpu_isar_feature (aa64_pauth, cpu)) { valid_mask |=SCR_API |SCR_APK ; } +if (cpu_isar_feature (aa64_mte, cpu)) { + valid_mask |=SCR_ATA ; + } }else { valid_mask &= ~(SCR_RW |SCR_ST ); }
@@ -5248,17 +5251,22 @@ static void do_hcr_write(CPUARMState *env, uint64_t value, uint64_t valid_mask)if (cpu_isar_feature (aa64_pauth, cpu)) { valid_mask |=HCR_API |HCR_APK ; } +if (cpu_isar_feature (aa64_mte, cpu)) { + valid_mask |=HCR_ATA |HCR_DCT |HCR_TID5 ; + } }/* Clear RES0 bits. */ value &= valid_mask; -/* These bits change the MMU setup: +/* +* These bits change the MMU setup: * HCR_VM enables stage 2 translation * HCR_PTW forbids certain page-table setups -* HCR_DC Disables stage1 and enables stage2 translation +* HCR_DC disables stage1 and enables stage2 translation +* HCR_DCT enables tagging on (disabled) stage1 translation */ -if ((env->cp15.hcr_el2 ^ value) & (HCR_VM |HCR_PTW |HCR_DC )) { +if ((env->cp15.hcr_el2 ^ value) & (HCR_VM |HCR_PTW |HCR_DC |HCR_DCT )) {tlb_flush (CPU (cpu)); } env->cp15.hcr_el2 = value;
Signature · 1 line
2.25.1
PATCH v8 5/45 target/arm: Rename DISAS_UPDATE to DISAS_UPDATE_EXIT
In reply to Richard HendersonEmphasize that the is_jmp option exits to the main loop.
--- target/arm/translate.h | 14 ++++++++------ target/arm/translate-a64.c | 8 ++++---- target/arm/translate-vfp.inc.c | 2 +- target/arm/translate.c | 12 ++++++------ 4 files changed, 19 insertions(+), 17 deletions(-)
target/arm/translate.h +8 -6
@@ -148,7 +148,8 @@ static inline void disas_set_insn_syndrome(DisasContext *s, uint32_t syn)/* is_jmp field values */ #define DISAS_JUMP DISAS_TARGET_0/* only pc was modified dynamically */ -#define DISAS_UPDATE DISAS_TARGET_1/* cpu state was modified dynamically */ +/* CPU state was modified dynamically; exit to main loop for interrupts. */ +#define DISAS_UPDATE_EXIT DISAS_TARGET_1/* These instructions trap after executing, so the A32/T32 decoder must * defer them until after the conditional execution state has been updated. * WFI also needs special handling when single-stepping.
@@ -164,11 +165,12 @@ static inline void disas_set_insn_syndrome(DisasContext *s, uint32_t syn)* custom end-of-TB code) */ #define DISAS_BX_EXCRET DISAS_TARGET_8 -/* For instructions which want an immediate exit to the main loop, -* as opposed to attempting to use lookup_and_goto_ptr. Unlike -* DISAS_UPDATE this doesn't write the PC on exiting the translation -* loop so you need to ensure something (gen_a64_set_pc_im or runtime -* helper) has done so before we reach return from cpu_tb_exec. +/* +* For instructions which want an immediate exit to the main loop, as opposed +* to attempting to use lookup_and_goto_ptr. Unlike DISAS_UPDATE_EXIT, this +* doesn't write the PC on exiting the translation loop so you need to ensure +* something (gen_a64_set_pc_im or runtime helper) has done so before we reach +* return from cpu_tb_exec. */ #define DISAS_EXIT DISAS_TARGET_9
target/arm/translate-a64.c +4 -4
@@ -1616,7 +1616,7 @@ static void handle_msr_i(DisasContext *s, uint32_t insn,gen_helper_msr_i_daifclear (cpu_env, t1);tcg_temp_free_i32 (t1);/* For DAIFClear, exit the cpu loop to re-evaluate pending IRQs. */ - s->base.is_jmp =DISAS_UPDATE ; + s->base.is_jmp =DISAS_UPDATE_EXIT ;break ;default :
@@ -1795,7 +1795,7 @@ static void handle_sys(DisasContext *s, uint32_t insn, bool isread,if ((tb_cflags (s->base.tb) &CF_USE_ICOUNT ) && (ri->type &ARM_CP_IO )) {/* I/O operations must end the TB here (whether read or write) */ - s->base.is_jmp =DISAS_UPDATE ; + s->base.is_jmp =DISAS_UPDATE_EXIT ; }if (!isread && !(ri->type &ARM_CP_SUPPRESS_TB_END )) {/*
@@ -1810,7 +1810,7 @@ static void handle_sys(DisasContext *s, uint32_t insn, bool isread,* but allow this to be suppressed by the register definition * (usually only necessary to work around guest bugs). */ - s->base.is_jmp =DISAS_UPDATE ; + s->base.is_jmp =DISAS_UPDATE_EXIT ; } }
@@ -14304,7 +14304,7 @@ static void aarch64_tr_tb_stop(DisasContextBase *dcbase, CPUState *cpu)gen_goto_tb (dc,1 , dc->base.pc_next);break ;default : -case DISAS_UPDATE : +case DISAS_UPDATE_EXIT :gen_a64_set_pc_im (dc->base.pc_next);/* fall through */ case DISAS_EXIT :
target/arm/translate-vfp.inc.c +1 -1
@@ -2861,6 +2861,6 @@ static bool trans_VLLDM_VLSTM(DisasContext *s, arg_VLLDM_VLSTM *a)tcg_temp_free_i32 (fptr);/* End the TB, because we have updated FP control bits */ - s->base.is_jmp =DISAS_UPDATE ; + s->base.is_jmp =DISAS_UPDATE_EXIT ;return true; }
target/arm/translate.c +6 -6
@@ -2876,7 +2876,7 @@ static void gen_msr_banked(DisasContext *s, int r, int sysm, int rn)tcg_temp_free_i32 (tcg_tgtmode);tcg_temp_free_i32 (tcg_regno);tcg_temp_free_i32 (tcg_reg); - s->base.is_jmp =DISAS_UPDATE ; + s->base.is_jmp =DISAS_UPDATE_EXIT ; }static void gen_mrs_banked (DisasContext *s,int r,int sysm,int rn)
@@ -2898,7 +2898,7 @@ static void gen_mrs_banked(DisasContext *s, int r, int sysm, int rn)tcg_temp_free_i32 (tcg_tgtmode);tcg_temp_free_i32 (tcg_regno);store_reg (s, rn, tcg_reg); - s->base.is_jmp =DISAS_UPDATE ; + s->base.is_jmp =DISAS_UPDATE_EXIT ; }/* Store value to PC as for an exception return (ie don't
@@ -6153,7 +6153,7 @@ static void gen_srs(DisasContext *s,tcg_temp_free_i32 (tmp); }tcg_temp_free_i32 (addr); - s->base.is_jmp =DISAS_UPDATE ; + s->base.is_jmp =DISAS_UPDATE_EXIT ; }/* Generate a label used for skipping this instruction */
@@ -9202,7 +9202,7 @@ static bool trans_SETEND(DisasContext *s, arg_SETEND *a) }if (a->E != (s->be_data ==MO_BE )) {gen_helper_setend (cpu_env); - s->base.is_jmp =DISAS_UPDATE ; + s->base.is_jmp =DISAS_UPDATE_EXIT ; }return true; }
@@ -9925,7 +9925,7 @@ static void arm_tr_tb_stop(DisasContextBase *dcbase, CPUState *cpu)break ;case DISAS_NEXT :case DISAS_TOO_MANY : -case DISAS_UPDATE : +case DISAS_UPDATE_EXIT :gen_set_pc_im (dc, dc->base.pc_next);/* fall through */ default :
@@ -9952,7 +9952,7 @@ static void arm_tr_tb_stop(DisasContextBase *dcbase, CPUState *cpu)case DISAS_JUMP :gen_goto_ptr ();break ; -case DISAS_UPDATE : +case DISAS_UPDATE_EXIT :gen_set_pc_im (dc, dc->base.pc_next);/* fall through */ default :
Signature · 1 line
2.25.1
PATCH v8 6/45 target/arm: Add DISAS_UPDATE_NOCHAIN
In reply to Richard HendersonAdd an option that writes back the PC, like DISAS_UPDATE_EXIT, but does not exit back to the main loop.
--- target/arm/translate.h | 2 ++ target/arm/translate-a64.c | 3 +++ target/arm/translate.c | 4 ++++ 3 files changed, 9 insertions(+)
target/arm/translate.h +2 -0
@@ -173,6 +173,8 @@ static inline void disas_set_insn_syndrome(DisasContext *s, uint32_t syn)* return from cpu_tb_exec. */ #define DISAS_EXIT DISAS_TARGET_9 +/* CPU state was modified dynamically; no need to exit, but do not chain. */ +#define DISAS_UPDATE_NOCHAIN DISAS_TARGET_10#ifdef TARGET_AARCH64 void a64_translate_init (void );
target/arm/translate-a64.c +3 -0
@@ -14310,6 +14310,9 @@ static void aarch64_tr_tb_stop(DisasContextBase *dcbase, CPUState *cpu)case DISAS_EXIT :tcg_gen_exit_tb (NULL ,0 );break ; +case DISAS_UPDATE_NOCHAIN : +gen_a64_set_pc_im (dc->base.pc_next); +/* fall through */ case DISAS_JUMP :tcg_gen_lookup_and_goto_ptr ();break ;
target/arm/translate.c +4 -0
@@ -9926,6 +9926,7 @@ static void arm_tr_tb_stop(DisasContextBase *dcbase, CPUState *cpu)case DISAS_NEXT :case DISAS_TOO_MANY :case DISAS_UPDATE_EXIT : +case DISAS_UPDATE_NOCHAIN :gen_set_pc_im (dc, dc->base.pc_next);/* fall through */ default :
@@ -9949,6 +9950,9 @@ static void arm_tr_tb_stop(DisasContextBase *dcbase, CPUState *cpu)case DISAS_TOO_MANY :gen_goto_tb (dc,1 , dc->base.pc_next);break ; +case DISAS_UPDATE_NOCHAIN : +gen_set_pc_im (dc, dc->base.pc_next); +/* fall through */ case DISAS_JUMP :gen_goto_ptr ();break ;
Signature · 1 line
2.25.1
PATCH v8 7/45 target/arm: Add MTE system registers
In reply to Richard HendersonThis is TFSRE0_EL1, TFSR_EL1, TFSR_EL2, TFSR_EL3,RGSR_EL1, GCR_EL1, GMID_EL1, and PSTATE.TCO.
---
v3: Add GMID; add access_mte.
v4: Define only TCO at mte_insn_reg.
v6: Define RAZ/WI version of TCO at mte_insn_reg;
honor TID5 for GMID_EL1; fix TFS crn/crm; recalc hflags after TCO.
--- target/arm/cpu.h | 4 ++ target/arm/internals.h | 9 ++++ target/arm/helper.c | 94 ++++++++++++++++++++++++++++++++++++++ target/arm/translate-a64.c | 21 +++++++++ 4 files changed, 128 insertions(+)
target/arm/cpu.h +4 -0
@@ -502,6 +502,9 @@ typedef struct CPUARMState {uint64_t pmccfiltr_el0;/* Performance Monitor Filter Register */ uint64_t vpidr_el2;/* Virtualization Processor ID Register */ uint64_t vmpidr_el2;/* Virtualization Multiprocessor ID Register */ +uint64_t tfsr_el[4 ];/* tfsre0_el1 is index 0. */ +uint64_t gcr_el1; +uint64_t rgsr_el1; } cp15;struct {
@@ -1282,6 +1285,7 @@ void pmu_init(ARMCPU *cpu);#define PSTATE_SS (1U << 21)#define PSTATE_PAN (1U << 22)#define PSTATE_UAO (1U << 23) +#define PSTATE_TCO (1U << 25)#define PSTATE_V (1U << 28)#define PSTATE_C (1U << 29)#define PSTATE_Z (1U << 30)
target/arm/internals.h +9 -0
@@ -1159,6 +1159,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_mte (id)) { + valid |=PSTATE_TCO ; + }return valid; }
@@ -1234,4 +1237,10 @@ void arm_log_exception(int idx);#endif /* !CONFIG_USER_ONLY */ +/* +* The log2 of the words in the tag block, for GMID_EL1.BS. +* The is the maximum, 256 bytes, which manipulates 64-bits of tags. +*/ +#define GMID_EL1_BS 6 +#endif
target/arm/helper.c +94 -0
112 lines not on this page · raw message
target/arm/translate-a64.c +21 -0
@@ -1619,6 +1619,27 @@ static void handle_msr_i(DisasContext *s, uint32_t insn, s->base.is_jmp =DISAS_UPDATE_EXIT ;break ; +case 0x1c :/* TCO */ +if (dc_isar_feature (aa64_mte, s)) { +/* Full MTE is enabled -- set the TCO bit as directed. */ +if (crm &1 ) { +set_pstate_bits (PSTATE_TCO ); + }else { +clear_pstate_bits (PSTATE_TCO ); + } + t1 =tcg_const_i32 (s->current_el); +gen_helper_rebuild_hflags_a64 (cpu_env, t1); +tcg_temp_free_i32 (t1); +/* Many factors, including TCO, go into MTE_ACTIVE. */ + s->base.is_jmp =DISAS_UPDATE_NOCHAIN ; + }else if (dc_isar_feature (aa64_mte_insn_reg, s)) { +/* Only "instructions accessible at EL0" -- PSTATE.TCO is WI. */ + s->base.is_jmp =DISAS_NEXT ; + }else { + goto do_unallocated; + } +break ; +default : do_unallocated:unallocated_encoding (s);
Signature · 1 line
2.25.1
PATCH v8 8/45 target/arm: Add MTE bits to tb_flags
In reply to Richard HendersonCache the composite ATA setting.
Cache when MTE is fully enabled, i.e. access to tags are enabled and tag checks affect the PE. Do this for both the normal context and the UNPRIV context.
---
v3: Remove stub helper_mte_check; moved to a later patch.
v6: Add mte0_active and ata bits; drop reviewed-by.
--- target/arm/cpu.h | 12 ++++++++---- target/arm/internals.h | 18 +++++++++++++++++ target/arm/translate.h | 5 +++++ target/arm/helper.c | 40 ++++++++++++++++++++++++++++++++++++++ target/arm/translate-a64.c | 4 ++++ 5 files changed, 75 insertions(+), 4 deletions(-)
target/arm/cpu.h +8 -4
@@ -3187,10 +3187,10 @@ typedef ARMCPU ArchCPU;* | | | TBFLAG_A32 | | * | | +-----+----------+ TBFLAG_AM32 | * | TBFLAG_ANY | |TBFLAG_M32| | -* | | +-+----------+--------------| -* | | | TBFLAG_A64 | -* +--------------+---------+---------------------------+ -* 31 20 15 0 +* | +-----------+----------+--------------| +* | | TBFLAG_A64 | +* +--------------+-------------------------------------+ +* 31 20 0 * * Unless otherwise noted, these bits are cached in env->hflags. */
@@ -3257,6 +3257,10 @@ FIELD(TBFLAG_A64, BT, 9, 1) FIELD(TBFLAG_A64, BTYPE, 10, 2) /* Not cached. */ FIELD(TBFLAG_A64, TBID, 12, 2) FIELD(TBFLAG_A64, UNPRIV, 14, 1) +FIELD(TBFLAG_A64, ATA, 15, 1) +FIELD(TBFLAG_A64, TCMA, 16, 2) +FIELD(TBFLAG_A64, MTE_ACTIVE, 18, 1) +FIELD (TBFLAG_A64 ,MTE0_ACTIVE ,19 ,1 )/** * cpu_mmu_index:
target/arm/internals.h +18 -0
@@ -1198,6 +1198,24 @@ static inline int exception_target_el(CPUARMState *env)return target_el; } +/* Determine if allocation tags are available. */ +static inline bool allocation_tag_access_enabled (CPUARMState *env,int el, +uint64_t sctlr) +{ +if (el <3 + &&arm_feature (env,ARM_FEATURE_EL3 ) + && !(env->cp15.scr_el3 &SCR_ATA )) { +return false; + } +if (el <2 + &&arm_feature (env,ARM_FEATURE_EL2 ) + && !(arm_hcr_el2_eff (env) &HCR_ATA )) { +return false; + } + sctlr &= (el ==0 ?SCTLR_ATA0 :SCTLR_ATA ); +return sctlr !=0 ; +} +#ifndef CONFIG_USER_ONLY /* Security attributes for an address, as returned by v8m_security_lookup. */
target/arm/translate.h +5 -0
@@ -30,6 +30,7 @@ typedef struct DisasContext {ARMMMUIdx mmu_idx;/* MMU index to use for normal loads/stores */ uint8_t tbii;/* TBI1|TBI0 for insns */ uint8_t tbid;/* TBI1|TBI0 for data */ +uint8_t tcma;/* TCMA1|TCMA0 for MTE */ bool ns;/* Use non-secure CPREG bank on access */ int fp_excp_el;/* FP exception EL or 0 if enabled */ int sve_excp_el;/* SVE exception EL or 0 if enabled */
@@ -77,6 +78,10 @@ typedef struct DisasContext {bool unpriv;/* True if v8.3-PAuth is active. */ bool pauth_active; +/* True if v8.5-MTE access to tags is enabled. */ +bool ata; +/* True if v8.5-MTE tag checks affect the PE; index with is_unpriv. */ +bool mte_active[2 ];/* True with v8.5-BTI and SCTLR_ELx.BT* set. */ bool bt;/* True if any CP15 access is trapped by HSTR_EL2 */
target/arm/helper.c +40 -0
@@ -10655,6 +10655,16 @@ static int aa64_va_parameter_tbid(uint64_t tcr, ARMMMUIdx mmu_idx) } } +static int aa64_va_parameter_tcma (uint64_t tcr,ARMMMUIdx mmu_idx) +{ +if (regime_has_2_ranges (mmu_idx)) { +return extract64 (tcr,57 ,2 ); + }else { +/* Replicate the single TCMA bit so we always have 2 bits. */ +return extract32 (tcr,30 ,1 ) *3 ; + } +} +ARMVAParameters aa64_va_parameters (CPUARMState *env,uint64_t va,ARMMMUIdx mmu_idx,bool data) {
@@ -12679,6 +12689,36 @@ static uint32_t rebuild_hflags_a64(CPUARMState *env, int el, int fp_el, } } +if (cpu_isar_feature (aa64_mte,env_archcpu (env))) { +/* +* Set MTE_ACTIVE if any access may be Checked, and leave clear +* if all accesses must be Unchecked: +* 1) If no TBI, then there are no tags in the address to check, +* 2) If Tag Check Override, then all accesses are Unchecked, +* 3) If Tag Check Fail == 0, then Checked access have no effect, +* 4) If no Allocation Tag Access, then all accesses are Unchecked. +*/ +if (allocation_tag_access_enabled (env, el, sctlr)) { + flags =FIELD_DP32 (flags,TBFLAG_A64 ,ATA ,1 ); +if (tbid + && !(env->pstate &PSTATE_TCO ) + && (sctlr & (el ==0 ?SCTLR_TCF0 :SCTLR_TCF ))) { + flags =FIELD_DP32 (flags,TBFLAG_A64 ,MTE_ACTIVE ,1 ); + } + } +/* And again for unprivileged accesses, if required. */ +if (FIELD_EX32 (flags,TBFLAG_A64 ,UNPRIV ) + && tbid + && !(env->pstate &PSTATE_TCO ) + && (sctlr &SCTLR_TCF0 ) + &&allocation_tag_access_enabled (env,0 , sctlr)) { + flags =FIELD_DP32 (flags,TBFLAG_A64 ,MTE0_ACTIVE ,1 ); + } +/* Cache TCMA as well as TBI. */ + flags =FIELD_DP32 (flags,TBFLAG_A64 ,TCMA , +aa64_va_parameter_tcma (tcr, mmu_idx)); + } +return rebuild_hflags_common (env, fp_el, mmu_idx, flags); }
target/arm/translate-a64.c +4 -0
@@ -14183,6 +14183,7 @@ static void aarch64_tr_init_disas_context(DisasContextBase *dcbase, dc->mmu_idx =core_to_aa64_mmu_idx (core_mmu_idx); dc->tbii =FIELD_EX32 (tb_flags,TBFLAG_A64 ,TBII ); dc->tbid =FIELD_EX32 (tb_flags,TBFLAG_A64 ,TBID ); + dc->tcma =FIELD_EX32 (tb_flags,TBFLAG_A64 ,TCMA ); dc->current_el =arm_mmu_idx_to_el (dc->mmu_idx);#if !defined(CONFIG_USER_ONLY ) dc->user = (dc->current_el ==0 );
@@ -14194,6 +14195,9 @@ static void aarch64_tr_init_disas_context(DisasContextBase *dcbase, dc->bt =FIELD_EX32 (tb_flags,TBFLAG_A64 ,BT ); dc->btype =FIELD_EX32 (tb_flags,TBFLAG_A64 ,BTYPE ); dc->unpriv =FIELD_EX32 (tb_flags,TBFLAG_A64 ,UNPRIV ); + dc->ata =FIELD_EX32 (tb_flags,TBFLAG_A64 ,ATA ); + dc->mte_active[0 ] =FIELD_EX32 (tb_flags,TBFLAG_A64 ,MTE_ACTIVE ); + dc->mte_active[1 ] =FIELD_EX32 (tb_flags,TBFLAG_A64 ,MTE0_ACTIVE ); dc->vec_len =0 ; dc->vec_stride =0 ; dc->cp_regs = arm_cpu->cp_regs;
Signature · 1 line
2.25.1
PATCH v8 9/45 target/arm: Implement the IRG instruction
In reply to Richard Henderson---
v2: Update to 00eac5.
Merge choose_random_nonexcluded_tag into helper_irg since that pseudo function no longer exists separately.
v6: Remove obsolete logical/physical tag distinction;
implement inline for !ATA.
--- target/arm/helper-a64.h | 2 ++ target/arm/internals.h | 5 +++ target/arm/mte_helper.c | 72 ++++++++++++++++++++++++++++++++++++++ target/arm/translate-a64.c | 18 ++++++++++ target/arm/Makefile.objs | 1 + 5 files changed, 98 insertions(+) create mode 100644 target/arm/mte_helper.c
target/arm/helper-a64.h +2 -0
@@ -103,3 +103,5 @@ DEF_HELPER_FLAGS_3(autda, TCG_CALL_NO_WG, i64, env, i64, i64) DEF_HELPER_FLAGS_3(autdb, TCG_CALL_NO_WG, i64, env, i64, i64) DEF_HELPER_FLAGS_2(xpaci, TCG_CALL_NO_RWG_SE, i64, env, i64) DEF_HELPER_FLAGS_2(xpacd, TCG_CALL_NO_RWG_SE, i64, env, i64) + +DEF_HELPER_FLAGS_3 (irg,TCG_CALL_NO_RWG , i64, env, i64, i64)
target/arm/internals.h +5 -0
@@ -1261,4 +1261,9 @@ void arm_log_exception(int idx);*/ #define GMID_EL1_BS 6 +static inline uint64_t address_with_allocation_tag (uint64_t ptr,int rtag) +{ +return deposit64 (ptr,56 ,4 , rtag); +} +#endif
target/arm/mte_helper.c new file +72 -0
72 lines not on this page · raw message
target/arm/translate-a64.c +18 -0
@@ -226,6 +226,12 @@ static TCGv_i64 clean_data_tbi(DisasContext *s, TCGv_i64 addr)return clean; } +/* Insert a zero tag into src, with the result at dst. */ +static void gen_address_with_allocation_tag0 (TCGv_i64 dst,TCGv_i64 src) +{ +tcg_gen_andi_i64 (dst, src, ~MAKE_64BIT_MASK (56 ,4 )); +} + typedef struct DisasCompare64 { TCGCond cond; TCGv_i64 value;
@@ -5284,6 +5290,18 @@ static void disas_data_proc_2src(DisasContext *s, uint32_t insn)case 3 :/* SDIV */ handle_div (s, true, sf, rm, rn, rd);break ; +case 4 :/* IRG */ +if (sf ==0 || !dc_isar_feature (aa64_mte_insn_reg, s)) { + goto do_unallocated; + } +if (s->ata) { +gen_helper_irg (cpu_reg_sp (s, rd), cpu_env, +cpu_reg_sp (s, rn),cpu_reg (s, rm)); + }else { +gen_address_with_allocation_tag0 (cpu_reg_sp (s, rd), +cpu_reg_sp (s, rn)); + } +break ;case 8 :/* LSLV */ handle_shift_reg (s,A64_SHIFT_TYPE_LSL , sf, rm, rn, rd);break ;
target/arm/Makefile.objs +1 -0
@@ -86,3 +86,4 @@ obj-$(CONFIG_SOFTMMU) += psci.o obj-$(TARGET_AARCH64) += translate-a64.o helper-a64.o obj-$(TARGET_AARCH64) += translate-sve.o sve_helper.o obj-$(TARGET_AARCH64) += pauth_helper.o +obj-$(TARGET_AARCH64) += mte_helper.o
Signature · 1 line
2.25.1
PATCH v8 10/45 target/arm: Revise decoding for disas_add_sub_imm
In reply to Richard HendersonThe current Arm ARM has adjusted the official decode of "Add/subtract (immediate)" so that the shift field is only bit 22, and bit 23 is part of the op1 field of the parent category "Data processing - immediate".
--- target/arm/translate-a64.c | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-)
target/arm/translate-a64.c +8 -15
@@ -3754,22 +3754,22 @@ static void disas_pc_rel_adr(DisasContext *s, uint32_t insn)/* * Add/subtract (immediate) * -* 31 30 29 28 24 23 22 21 10 9 5 4 0 -* +--+--+--+-----------+-----+-------------+-----+-----+ -* |sf|op| S| 1 0 0 0 1 |shift| imm12 | Rn | Rd | -* +--+--+--+-----------+-----+-------------+-----+-----+ +* 31 30 29 28 23 22 21 10 9 5 4 0 +* +--+--+--+-------------+--+-------------+-----+-----+ +* |sf|op| S| 1 0 0 0 1 0 |sh| imm12 | Rn | Rd | +* +--+--+--+-------------+--+-------------+-----+-----+ * * sf: 0 -> 32bit, 1 -> 64bit * op: 0 -> add , 1 -> sub * S: 1 -> set flags -* shift: 00 -> LSL imm by 0, 01 -> LSL imm by 12 +* sh: 1 -> LSL imm by 12 */ static void disas_add_sub_imm (DisasContext *s,uint32_t insn) {int rd =extract32 (insn,0 ,5 );int rn =extract32 (insn,5 ,5 );uint64_t imm =extract32 (insn,10 ,12 ); -int shift =extract32 (insn,22 ,2 ); +bool shift =extract32 (insn,22 ,1 );bool setflags =extract32 (insn,29 ,1 );bool sub_op =extract32 (insn,30 ,1 );bool is_64bit =extract32 (insn,31 ,1 );
@@ -3778,15 +3778,8 @@ static void disas_add_sub_imm(DisasContext *s, uint32_t insn)TCGv_i64 tcg_rd = setflags ?cpu_reg (s, rd) :cpu_reg_sp (s, rd);TCGv_i64 tcg_result; -switch (shift) { -case 0x0 : -break ; -case 0x1 : +if (shift) { imm <<=12 ; -break ; -default : -unallocated_encoding (s); -return ; } tcg_result =tcg_temp_new_i64 ();
@@ -4174,7 +4167,7 @@ static void disas_data_proc_imm(DisasContext *s, uint32_t insn)case 0x20 :case 0x21 :/* PC-rel. addressing */ disas_pc_rel_adr (s, insn);break ; -case 0x22 :case 0x23 :/* Add/subtract (immediate) */ +case 0x22 :/* Add/subtract (immediate) */ disas_add_sub_imm (s, insn);break ;case 0x24 :/* Logical (immediate) */
Signature · 1 line
2.25.1
Re: [PATCH v8 10/45] target/arm: Revise decoding for disas_add_sub_imm
Quoted 11 lines · Richard Henderson
The current Arm ARM has adjusted the official decode of "Add/subtract (immediate)" so that the shift field is only bit 22, and bit 23 is part of the op1 field of the parent category "Data processing - immediate".
Suggested-by Peter Maydell <[email protected]>Signed-off-by Richard Henderson <[email protected]>--- target/arm/translate-a64.c | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-)
thanks
-- PMM
PATCH v8 11/45 target/arm: Implement the ADDG, SUBG instructions
In reply to Richard Henderson---
v2: Shift offset in translate; use extract32.
v6: Implement inline for !ATA.
v8: Use separate decode function.
--- target/arm/helper-a64.h | 1 + target/arm/internals.h | 9 +++++++ target/arm/mte_helper.c | 10 ++++++++ target/arm/translate-a64.c | 51 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 71 insertions(+)
target/arm/helper-a64.h +1 -0
@@ -105,3 +105,4 @@ DEF_HELPER_FLAGS_2(xpaci, TCG_CALL_NO_RWG_SE, i64, env, i64) DEF_HELPER_FLAGS_2(xpacd, TCG_CALL_NO_RWG_SE, i64, env, i64) DEF_HELPER_FLAGS_3(irg, TCG_CALL_NO_RWG, i64, env, i64, i64) +DEF_HELPER_FLAGS_4 (addsubg,TCG_CALL_NO_RWG_SE , i64, env, i64, s32, i32)
target/arm/internals.h +9 -0
@@ -1261,6 +1261,15 @@ void arm_log_exception(int idx);*/ #define GMID_EL1_BS 6 +/* We associate one allocation tag per 16 bytes, the minimum. */ +#define LOG2_TAG_GRANULE 4 +#define TAG_GRANULE (1 << LOG2_TAG_GRANULE) + +static inline int allocation_tag_from_addr (uint64_t ptr) +{ +return extract64 (ptr,56 ,4 ); +} +static inline uint64_t address_with_allocation_tag (uint64_t ptr,int rtag) {return deposit64 (ptr,56 ,4 , rtag);
target/arm/mte_helper.c +10 -0
@@ -70,3 +70,13 @@ uint64_t HELPER(irg)(CPUARMState *env, uint64_t rn, uint64_t rm)return address_with_allocation_tag (rn, rtag); } + +uint64_t HELPER (addsubg )(CPUARMState *env,uint64_t ptr, +int32_t offset,uint32_t tag_offset) +{ +int start_tag =allocation_tag_from_addr (ptr); +uint16_t exclude =extract32 (env->cp15.gcr_el1,0 ,16 ); +int rtag =choose_nonexcluded_tag (start_tag, tag_offset, exclude); + +return address_with_allocation_tag (ptr + offset, rtag); +}
target/arm/translate-a64.c +51 -0
63 lines not on this page · raw message
Signature · 1 line
2.25.1
Re: [PATCH v8 11/45] target/arm: Implement the ADDG, SUBG instructions
Quoted 9 lines · Richard Henderson
Signed-off-by Richard Henderson <[email protected]>+/*
+ * Add/subtract (immediate, with tags)
+ *
+ * 31 30 29 28 23 22 21 16 14 10 9 5 4 0
+ * +--+--+--+-------------+--+---------+--+-------+-----+-----+
+ * |sf|op| S| 1 0 0 0 1 0 |o2| uimm6 |o3| uimm4 | Rn | Rd |
+ * +--+--+--+-------------+--+---------+--+-------+-----+-----+
Bit 23 should be '1'.
Quoted 5 lines
+ *
+ * op: 0 -> add, 1 -> sub
+ */target/arm/translate-a64.c +2
-0+static void disas_add_sub_imm_with_tags (DisasContext *s,uint32_t insn) +{
target/arm/translate-a64.c static void disas_add_sub_imm(DisasContext *s, uint32_t insn) · line 3832
Quoted 10 lines
target/arm/translate-a64.c +10
-0+int rd =extract32 (insn,0 ,5 ); +int rn =extract32 (insn,5 ,5 ); +int uimm4 =extract32 (insn,10 ,4 ); +int uimm6 =extract32 (insn,16 ,6 ); +bool sub_op =extract32 (insn,30 ,1 ); +TCGv_i64 tcg_rn, tcg_rd; +int imm; + +/* Test all of sf=1, S=0, o2=0, o3=0. */ + if ((insn & 0xc040e000u) != 0x80000000u ||
This bit pattern doesn't seem to match the comment:0xc is 0b1100 so that's sf and op, not sf and S; 0xe is 0b1110 so that's testing the top bit of uimm4 as well as op3. I think it should be 0xa040c000. Though the existence of this bug suggests that it would be clearer to test the individual fields :-)
Otherwise
Interestingly clang (6.0.0) gets pretty close to optimizing the field test version:
bool foo(uint32_t insn) {
return (insn & 0xa040c000) != 0x80000000u;
}
bool bar(uint32_t insn) {
bool sf = extract32(insn, 31, 1);
bool s = extract32(insn, 29, 1);
bool o2 = extract32(insn, 22, 1);
int op2 = extract32(insn, 14, 2);
return sf != 1 || s != 0 || o2 != 0 || op2 != 0;
}
gives
0000000000000000 <foo>:
0: 81 e7 00 c0 40 a0 and $0xa040c000,%edi 6: 81 ff 00 00 00 80 cmp $0x80000000,%edi c: 0f 95 c0 setne %al f: c3 retq
0000000000000010 <bar>:
10: 89 f8 mov %edi,%eax 12: 25 00 00 00 a0 and $0xa0000000,%eax 17: 3d 00 00 00 80 cmp $0x80000000,%eax 1c: 75 0a jne 28 <bar+0x18> 1e: f7 c7 00 c0 40 00 test $0x40c000,%edi 24: 0f 95 c0 setne %al 27: c3 retq 28: b0 01 mov $0x1,%al 2a: c3 retq
(I don't know why it's split it into two tests: it's not that it's testing "must be 1" in one part and "must be 0" in the other because it has checked both sf and s in the first comparison.)
gcc (7.4.0) makes more of a hash of it though:
10: 89 f8 mov %edi,%eax 12: 89 fa mov %edi,%edx 14: c1 e8 1f shr $0x1f,%eax 17: c1 ea 1d shr $0x1d,%edx 1a: 83 f0 01 xor $0x1,%eax 1d: 09 d0 or %edx,%eax 1f: 83 e0 01 and $0x1,%eax 22: 75 13 jne 37 <bar+0x27> 24: 89 f8 mov %edi,%eax 26: c1 ef 16 shr $0x16,%edi 29: c1 e8 0e shr $0xe,%eax 2c: 83 e7 01 and $0x1,%edi 2f: 83 e0 03 and $0x3,%eax 32: 09 f8 or %edi,%eax 34: 0f 95 c0 setne %al 37: f3 c3 repz retq
thanks
-- PMM
PATCH v8 12/45 target/arm: Implement the GMI instruction
In reply to Richard Henderson---
v6: Inline the operation.
--- target/arm/translate-a64.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
target/arm/translate-a64.c +15 -0
@@ -5346,6 +5346,21 @@ static void disas_data_proc_2src(DisasContext *s, uint32_t insn) cpu_reg_sp(s, rn)); }break ; +case 5 :/* GMI */ +if (sf ==0 || !dc_isar_feature (aa64_mte_insn_reg, s)) { + goto do_unallocated; + }else { +TCGv_i64 t1 =tcg_const_i64 (1 ); +TCGv_i64 t2 =tcg_temp_new_i64 (); + +tcg_gen_extract_i64 (t2,cpu_reg_sp (s, rn),56 ,4 ); +tcg_gen_shl_i64 (t1, t1, t2); +tcg_gen_or_i64 (cpu_reg (s, rd),cpu_reg (s, rm), t1); + +tcg_temp_free_i64 (t1); +tcg_temp_free_i64 (t2); + } +break ;case 8 :/* LSLV */ handle_shift_reg (s,A64_SHIFT_TYPE_LSL , sf, rm, rn, rd);break ;
Signature · 1 line
2.25.1
PATCH v8 13/45 target/arm: Implement the SUBP instruction
In reply to Richard Henderson---
v2: Fix extraction length.
--- target/arm/translate-a64.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-)
target/arm/translate-a64.c +22 -2
@@ -5315,19 +5315,39 @@ static void handle_crc32(DisasContext *s,*/ static void disas_data_proc_2src (DisasContext *s,uint32_t insn) { -unsigned int sf, rm, opcode, rn, rd; +unsigned int sf, rm, opcode, rn, rd, setflag; sf =extract32 (insn,31 ,1 ); + setflag =extract32 (insn,29 ,1 ); rm =extract32 (insn,16 ,5 ); opcode =extract32 (insn,10 ,6 ); rn =extract32 (insn,5 ,5 ); rd =extract32 (insn,0 ,5 ); -if (extract32 (insn,29 ,1 )) { +if (setflag && opcode !=0 ) {unallocated_encoding (s);return ; }switch (opcode) { +case 0 :/* SUBP(S) */ +if (sf ==0 || !dc_isar_feature (aa64_mte_insn_reg, s)) { + goto do_unallocated; + }else { +TCGv_i64 tcg_n, tcg_m, tcg_d; + + tcg_n =read_cpu_reg_sp (s, rn, true); + tcg_m =read_cpu_reg_sp (s, rm, true); +tcg_gen_sextract_i64 (tcg_n, tcg_n,0 ,56 ); +tcg_gen_sextract_i64 (tcg_m, tcg_m,0 ,56 ); + tcg_d =cpu_reg (s, rd); + +if (setflag) { +gen_sub_CC (true, tcg_d, tcg_n, tcg_m); + }else { +tcg_gen_sub_i64 (tcg_d, tcg_n, tcg_m); + } + } +break ;case 2 :/* UDIV */ handle_div (s, false, sf, rm, rn, rd);break ;
Signature · 1 line
2.25.1
PATCH v8 14/45 target/arm: Define arm_cpu_do_unaligned_access for user-only
In reply to Richard HendersonUse the same code as system mode, so that we generate the same exception + syndrome for the unaligned access.
For the moment, if MTE is enabled so that this path is reachable, this would generate a SIGSEGV in the user-only cpu_loop. Decoding the syndrome to produce the proper SIGBUS will be done later.
---
v8: Raise the normal data exception + syndrome.
--- target/arm/cpu.c | 2 +- target/arm/tlb_helper.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)
target/arm/cpu.c +1 -1
@@ -2169,8 +2169,8 @@ static void arm_cpu_class_init(ObjectClass *oc, void *data) cc->tlb_fill = arm_cpu_tlb_fill; cc->debug_excp_handler = arm_debug_excp_handler; cc->debug_check_watchpoint = arm_debug_check_watchpoint; -#if !defined(CONFIG_USER_ONLY ) cc->do_unaligned_access = arm_cpu_do_unaligned_access; +#if !defined(CONFIG_USER_ONLY ) cc->do_transaction_failed = arm_cpu_do_transaction_failed; cc->adjust_watchpoint_address = arm_adjust_watchpoint_address;#endif /* CONFIG_TCG && !CONFIG_USER_ONLY */
target/arm/tlb_helper.c +2 -2
@@ -10,8 +10,6 @@#include "internals.h" #include "exec/exec-all.h" -#if !defined(CONFIG_USER_ONLY ) - static inline uint32_t merge_syn_data_abort(uint32_t template_syn, unsigned int target_el, bool same_el, bool ea,
@@ -122,6 +120,8 @@ void arm_cpu_do_unaligned_access(CPUState *cs, vaddr vaddr,arm_deliver_fault (cpu, vaddr, access_type, mmu_idx, &fi); } +#if !defined(CONFIG_USER_ONLY ) +/* * arm_cpu_do_transaction_failed: handle a memory system error response * (eg "no device/memory present at address") by raising an external abort
Signature · 1 line
2.25.1
Re: [PATCH v8 14/45] target/arm: Define arm_cpu_do_unaligned_access for user-only
Quoted 11 lines · Richard Henderson
Use the same code as system mode, so that we generate the same exception + syndrome for the unaligned access.
For the moment, if MTE is enabled so that this path is reachable, this would generate a SIGSEGV in the user-only
cpu_loop. Decoding the syndrome to produce the proper SIGBUS will be done later.Signed-off-by Richard Henderson <[email protected]>---
v8: Raise the normal data exception + syndrome.
thanks
-- PMM
PATCH v8 15/45 target/arm: Implement LDG, STG, ST2G instructions
In reply to Richard Henderson---
v2: Split out allocation_tag_mem. Handle atomicity of stores.
v3: Add X[t] input to these insns; require pre-cleaned addresses.
v5: Fix !32-byte aligned operation of st2g.
v6: Fix op2 extract, stg pre/post-index, stores vs sp, commentary;
use pre-computed ata.
v7: Fix STZG iteration (stephen long)
v8: Merge gen_probe_access patch; align address for ldg (pmm)
--- target/arm/helper-a64.h | 7 ++ target/arm/helper.h | 2 + target/arm/mte_helper.c | 194 +++++++++++++++++++++++++++++++++++++ target/arm/op_helper.c | 16 +++ target/arm/translate-a64.c | 172 +++++++++++++++++++++++++++++++- 5 files changed, 386 insertions(+), 5 deletions(-)
target/arm/helper-a64.h +7 -0
@@ -106,3 +106,10 @@ DEF_HELPER_FLAGS_2(xpacd, TCG_CALL_NO_RWG_SE, i64, env, i64) DEF_HELPER_FLAGS_3(irg, TCG_CALL_NO_RWG, i64, env, i64, i64) DEF_HELPER_FLAGS_4(addsubg, TCG_CALL_NO_RWG_SE, i64, env, i64, s32, i32) +DEF_HELPER_FLAGS_3(ldg, TCG_CALL_NO_WG, i64, env, i64, i64) +DEF_HELPER_FLAGS_3(stg, TCG_CALL_NO_WG, void, env, i64, i64) +DEF_HELPER_FLAGS_3(stg_parallel, TCG_CALL_NO_WG, void, env, i64, i64) +DEF_HELPER_FLAGS_2(stg_stub, TCG_CALL_NO_WG, void, env, i64) +DEF_HELPER_FLAGS_3(st2g, TCG_CALL_NO_WG, void, env, i64, i64) +DEF_HELPER_FLAGS_3(st2g_parallel, TCG_CALL_NO_WG, void, env, i64, i64) +DEF_HELPER_FLAGS_2 (st2g_stub,TCG_CALL_NO_WG , void, env, i64)
target/arm/helper.h +2 -0
@@ -96,6 +96,8 @@ DEF_HELPER_FLAGS_1(rebuild_hflags_a32_newel, TCG_CALL_NO_RWG, void, env) DEF_HELPER_FLAGS_2(rebuild_hflags_a32, TCG_CALL_NO_RWG, void, env, int) DEF_HELPER_FLAGS_2(rebuild_hflags_a64, TCG_CALL_NO_RWG, void, env, int) +DEF_HELPER_FLAGS_5(probe_access, TCG_CALL_NO_WG, void, env, tl, i32, i32, i32) + DEF_HELPER_1(vfp_get_fpscr, i32, env)DEF_HELPER_2 (vfp_set_fpscr, void, env, i32)
target/arm/mte_helper.c +194 -0
203 lines not on this page · raw message
target/arm/op_helper.c +16 -0
@@ -935,3 +935,19 @@ uint32_t HELPER(ror_cc)(CPUARMState *env, uint32_t x, uint32_t i)return ((uint32_t )x >> shift) | (x << (32 - shift)); } } + +void HELPER (probe_access )(CPUARMState *env,target_ulong ptr, +uint32_t access_type,uint32_t mmu_idx, +uint32_t size) +{ +uint32_t in_page = -((uint32_t )ptr |TARGET_PAGE_SIZE ); +uintptr_t ra =GETPC (); + +if (likely (size <= in_page)) { +probe_access (env, ptr, size, access_type, mmu_idx, ra); + }else { +probe_access (env, ptr, in_page, access_type, mmu_idx, ra); +probe_access (env, ptr + in_page, size - in_page, + access_type, mmu_idx, ra); + } +}
target/arm/translate-a64.c +167 -5
192 lines not on this page · raw message
Signature · 1 line
2.25.1
Re: [PATCH v8 15/45] target/arm: Implement LDG, STG, ST2G instructions
Quoted 10 lines · Richard Henderson
Signed-off-by Richard Henderson <[email protected]>---
v2: Split outallocation_tag_mem. Handle atomicity of stores.
v3: Add X[t] input to these insns; require pre-cleaned addresses.
v5: Fix !32-byte aligned operation of st2g.
v6: Fix op2 extract, stg pre/post-index, stores vs sp, commentary;
use pre-computed ata.
v7: Fix STZG iteration (stephen long)
v8: Mergegen_probe_accesspatch; align address for ldg (pmm)
thanks
-- PMM
PATCH v8 16/45 target/arm: Implement the STGP instruction
In reply to Richard Henderson---
v3: Handle atomicity, require pre-cleaned address.
v6: Fix constant offset shift, non-checked address, use pre-computed ata.
--- target/arm/translate-a64.c | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-)
target/arm/translate-a64.c +26 -3
@@ -2690,7 +2690,7 @@ static void disas_ld_lit(DisasContext *s, uint32_t insn)* +-----+-------+---+---+-------+---+-------+-------+------+------+ * * opc: LDP/STP/LDNP/STNP 00 -> 32 bit, 10 -> 64 bit -* LDPSW 01 +* LDPSW/STGP 01 * LDP/STP/LDNP/STNP (SIMD) 00 -> 32 bit, 01 -> 64 bit, 10 -> 128 bit * V: 0 -> GPR, 1 -> Vector * idx: 00 -> signed offset with non-temporal hint, 01 -> post-index,
@@ -2715,6 +2715,7 @@ static void disas_ldst_pair(DisasContext *s, uint32_t insn)bool is_signed = false;bool postindex = false;bool wback = false; +bool set_tag = false;TCGv_i64 clean_addr, dirty_addr;
@@ -2727,6 +2728,14 @@ static void disas_ldst_pair(DisasContext *s, uint32_t insn)if (is_vector) { size =2 + opc; + }else if (opc ==1 && !is_load) { +/* STGP */ +if (!dc_isar_feature (aa64_mte_insn_reg, s) || index ==0 ) { +unallocated_encoding (s); +return ; + } + size =3 ; + set_tag = true; }else { size =2 +extract32 (opc,1 ,1 ); is_signed =extract32 (opc,0 ,1 );
@@ -2767,7 +2776,7 @@ static void disas_ldst_pair(DisasContext *s, uint32_t insn)return ; } - offset <<= size; + offset <<= (set_tag ?LOG2_TAG_GRANULE : size);if (rn ==31 ) {gen_check_sp_alignment (s);
@@ -2777,8 +2786,22 @@ static void disas_ldst_pair(DisasContext *s, uint32_t insn)if (!postindex) {tcg_gen_addi_i64 (dirty_addr, dirty_addr, offset); } - clean_addr =clean_data_tbi (s, dirty_addr); +if (set_tag) { +if (!s->ata) { +/* +* TODO: We could rely on the stores below, at least for +* system mode, if we arrange to add MO_ALIGN_16. +*/ +gen_helper_stg_stub (cpu_env, dirty_addr); + }else if (tb_cflags (s->base.tb) &CF_PARALLEL ) { +gen_helper_stg_parallel (cpu_env, dirty_addr, dirty_addr); + }else { +gen_helper_stg (cpu_env, dirty_addr, dirty_addr); + } + } + + clean_addr =clean_data_tbi (s, dirty_addr);if (is_vector) {if (is_load) {do_fp_ld (s, rt, clean_addr, size);
Signature · 1 line
2.25.1
PATCH v8 17/45 target/arm: Restrict the values of DCZID.BS under TCG
In reply to Richard HendersonWe can simplify our DC_ZVA if we recognize that the largest BS that we actually use in system mode is 64. Let us just assert that it fits within TARGET_PAGE_SIZE.
For DC_GVA and STZGM, we want to be able to write whole bytes of tag memory, so assert that BS is >= 2 * TAG_GRANULE, or 32.
--- target/arm/cpu.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)
target/arm/cpu.c +24 -0
@@ -1758,6 +1758,30 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) }#endif +if (tcg_enabled ()) { +int dcz_blocklen =4 << cpu->dcz_blocksize; + +/* +* We only support DCZ blocklen that fits on one page. +* +* Architectually this is always true. However TARGET_PAGE_SIZE +* is variable and, for compatibility with -machine virt-2.7, +* is only 1KiB, as an artifact of legacy ARMv5 subpage support. +* But even then, while the largest architectural DCZ blocklen +* is 2KiB, no cpu actually uses such a large blocklen. +*/ +assert (dcz_blocklen <=TARGET_PAGE_SIZE ); + +/* +* We only support DCZ blocksize >= 2*TAG_GRANULE, which is to say +* both nibbles of each byte storing tag data may be written at once. +* Since TAG_GRANULE is 16, this means that blocklen must be >= 32. +*/ +if (cpu_isar_feature (aa64_mte, cpu)) { +assert (dcz_blocklen >=2 *TAG_GRANULE ); + } + } +qemu_init_vcpu (cs);cpu_reset (cs);
Signature · 1 line
2.25.1
PATCH v8 18/45 target/arm: Simplify DC_ZVA
In reply to Richard HendersonNow that we know that the operation is on a single page, we need not loop over pages while probing.
--- target/arm/helper-a64.c | 94 +++++++++++------------------------------ 1 file changed, 25 insertions(+), 69 deletions(-)
target/arm/helper-a64.c +25 -69
@@ -1119,85 +1119,41 @@ void HELPER(dc_zva)(CPUARMState *env, uint64_t vaddr_in)* (which matches the usual QEMU behaviour of not implementing either * alignment faults or any memory attribute handling). */ - -ARMCPU *cpu =env_archcpu (env); -uint64_t blocklen =4 << cpu->dcz_blocksize; +int blocklen =4 <<env_archcpu (env)->dcz_blocksize;uint64_t vaddr = vaddr_in & ~(blocklen -1 ); +int mmu_idx =cpu_mmu_index (env, false); +void *mem; + +/* +* Trapless lookup. In addition to actual invalid page, may +* return NULL for I/O, watchpoints, clean pages, etc. +*/ + mem =tlb_vaddr_to_host (env, vaddr,MMU_DATA_STORE , mmu_idx);#ifndef CONFIG_USER_ONLY - { +if (unlikely (!mem)) { +uintptr_t ra =GETPC (); +/* -* Slightly awkwardly, QEMU's TARGET_PAGE_SIZE may be less than -* the block size so we might have to do more than one TLB lookup. -* We know that in fact for any v8 CPU the page size is at least 4K -* and the block size must be 2K or less, but TARGET_PAGE_SIZE is only -* 1K as an artefact of legacy v5 subpage support being present in the -* same QEMU executable. So in practice the hostaddr[] array has -* two entries, given the current setting of TARGET_PAGE_BITS_MIN. +* Trap if accessing an invalid page. DC_ZVA requires that we supply +* the original pointer for an invalid page. But watchpoints require +* that we probe the actual space. So do both. */ -int maxidx =DIV_ROUND_UP (blocklen,TARGET_PAGE_SIZE ); -void *hostaddr[DIV_ROUND_UP (2 * KiB,1 <<TARGET_PAGE_BITS_MIN )]; -int try, i; -unsigned mmu_idx =cpu_mmu_index (env, false); -TCGMemOpIdx oi =make_memop_idx (MO_UB , mmu_idx); + (void )probe_write (env, vaddr_in,1 , mmu_idx, ra); + mem =probe_write (env, vaddr, blocklen, mmu_idx, ra); -assert (maxidx <=ARRAY_SIZE (hostaddr)); - -for (try =0 ; try <2 ; try++) { - -for (i =0 ; i < maxidx; i++) { - hostaddr[i] =tlb_vaddr_to_host (env, - vaddr +TARGET_PAGE_SIZE * i, -1 , mmu_idx); -if (!hostaddr[i]) { -break ; - } - } -if (i == maxidx) { -/* -* If it's all in the TLB it's fair game for just writing to; -* we know we don't need to update dirty status, etc. -*/ -for (i =0 ; i < maxidx -1 ; i++) { -memset (hostaddr[i],0 ,TARGET_PAGE_SIZE ); - } -memset (hostaddr[i],0 , blocklen - (i *TARGET_PAGE_SIZE )); -return ; - } +if (unlikely (!mem)) {/* -* OK, try a store and see if we can populate the tlb. This -* might cause an exception if the memory isn't writable, -* in which case we will longjmp out of here. We must for -* this purpose use the actual register value passed to us -* so that we get the fault address right. +* The only remaining reason for mem == NULL is I/O. +* Just do a series of byte writes as the architecture demands. */ -helper_ret_stb_mmu (env, vaddr_in,0 , oi,GETPC ()); -/* Now we can populate the other TLB entries, if any */ -for (i =0 ; i < maxidx; i++) { -uint64_t va = vaddr +TARGET_PAGE_SIZE * i; -if (va != (vaddr_in &TARGET_PAGE_MASK )) { -helper_ret_stb_mmu (env, va,0 , oi,GETPC ()); - } +for (int i =0 ; i < blocklen; i++) { +cpu_stb_mmuidx_ra (env, vaddr + i,0 , mmu_idx, ra); } - } - -/* -* Slow path (probably attempt to do this to an I/O device or -* similar, or clearing of a block of code we have translations -* cached for). Just do a series of byte writes as the architecture -* demands. It's not worth trying to use a cpu_physical_memory_map(), -* memset(), unmap() sequence here because: -* + we'd need to account for the blocksize being larger than a page -* + the direct-RAM access case is almost always going to be dealt -* with in the fastpath code above, so there's no speed benefit -* + we would have to deal with the map returning NULL because the -* bounce buffer was in use -*/ -for (i =0 ; i < blocklen; i++) { -helper_ret_stb_mmu (env, vaddr + i,0 , oi,GETPC ()); +return ; } } -#else -memset (g2h (vaddr),0 , blocklen);#endif + +memset (mem,0 , blocklen); }
Signature · 1 line
2.25.1
PATCH v8 19/45 target/arm: Implement the LDGM, STGM, STZGM instructions
In reply to Richard Henderson---
v3: Require pre-cleaned addresses.
v6: Check full mte enabled. Reorg the helpers.
--- target/arm/helper-a64.h | 3 ++ target/arm/translate.h | 2 + target/arm/mte_helper.c | 84 ++++++++++++++++++++++++++++++++++++++ target/arm/translate-a64.c | 72 ++++++++++++++++++++++++++++---- 4 files changed, 153 insertions(+), 8 deletions(-)
target/arm/helper-a64.h +3 -0
@@ -113,3 +113,6 @@ DEF_HELPER_FLAGS_2(stg_stub, TCG_CALL_NO_WG, void, env, i64) DEF_HELPER_FLAGS_3(st2g, TCG_CALL_NO_WG, void, env, i64, i64) DEF_HELPER_FLAGS_3(st2g_parallel, TCG_CALL_NO_WG, void, env, i64, i64) DEF_HELPER_FLAGS_2(st2g_stub, TCG_CALL_NO_WG, void, env, i64) +DEF_HELPER_FLAGS_2(ldgm, TCG_CALL_NO_WG, i64, env, i64) +DEF_HELPER_FLAGS_3(stgm, TCG_CALL_NO_WG, void, env, i64, i64) +DEF_HELPER_FLAGS_3 (stzgm_tags,TCG_CALL_NO_WG , void, env, i64, i64)
target/arm/translate.h +2 -0
@@ -91,6 +91,8 @@ typedef struct DisasContext {* < 0, set by the current instruction. */ int8_t btype; +/* A copy of cpu->dcz_blocksize. */ +uint8_t dcz_blocksize;/* True if this page is guarded. */ bool guarded_page;/* Bottom two bits of XScale c15_cpar coprocessor access control reg */
target/arm/mte_helper.c +84 -0
87 lines not on this page · raw message
target/arm/translate-a64.c +64 -8
116 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH v8 20/45 target/arm: Implement the access tag cache flushes
In reply to Richard HendersonLike the regular data cache flushes, these are nops within qemu.
---
v6: Split out and handle el0 cache ops properly.
--- target/arm/helper.c | 65 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+)
target/arm/helper.c +65 -0
@@ -6929,6 +6929,32 @@ static const ARMCPRegInfo mte_reginfo[] = { .opc0 = 3, .opc1 = 3, .crn = 4, .crm = 2, .opc2 = 7, .type = ARM_CP_NO_RAW, .access = PL0_RW, .readfn = tco_read, .writefn = tco_write }, + { .name = "DC_IGVAC", .state = ARM_CP_STATE_AA64, + .opc0 = 1, .opc1 = 0, .crn = 7, .crm = 6, .opc2 = 3, + .type = ARM_CP_NOP, .access = PL1_W, + .accessfn = aa64_cacheop_poc_access }, + { .name = "DC_IGSW", .state = ARM_CP_STATE_AA64, + .opc0 = 1, .opc1 = 0, .crn = 7, .crm = 6, .opc2 = 4, + .type = ARM_CP_NOP, .access = PL1_W, .accessfn = access_tsw }, + { .name = "DC_IGDVAC", .state = ARM_CP_STATE_AA64, + .opc0 = 1, .opc1 = 0, .crn = 7, .crm = 6, .opc2 = 5, + .type = ARM_CP_NOP, .access = PL1_W, + .accessfn = aa64_cacheop_poc_access }, + { .name = "DC_IGDSW", .state = ARM_CP_STATE_AA64, + .opc0 = 1, .opc1 = 0, .crn = 7, .crm = 6, .opc2 = 6, + .type = ARM_CP_NOP, .access = PL1_W, .accessfn = access_tsw }, + { .name = "DC_CGSW", .state = ARM_CP_STATE_AA64, + .opc0 = 1, .opc1 = 0, .crn = 7, .crm = 10, .opc2 = 4, + .type = ARM_CP_NOP, .access = PL1_W, .accessfn = access_tsw }, + { .name = "DC_CGDSW", .state = ARM_CP_STATE_AA64, + .opc0 = 1, .opc1 = 0, .crn = 7, .crm = 10, .opc2 = 6, + .type = ARM_CP_NOP, .access = PL1_W, .accessfn = access_tsw }, + { .name = "DC_CIGSW", .state = ARM_CP_STATE_AA64, + .opc0 = 1, .opc1 = 0, .crn = 7, .crm = 14, .opc2 = 4, + .type = ARM_CP_NOP, .access = PL1_W, .accessfn = access_tsw }, + { .name = "DC_CIGDSW", .state = ARM_CP_STATE_AA64, + .opc0 = 1, .opc1 = 0, .crn = 7, .crm = 14, .opc2 = 6, + .type = ARM_CP_NOP, .access = PL1_W, .accessfn = access_tsw }, REGINFO_SENTINEL };
@@ -6938,6 +6964,43 @@ static const ARMCPRegInfo mte_tco_ro_reginfo[] = { .type = ARM_CP_CONST, .access = PL0_RW, },REGINFO_SENTINEL }; + +static const ARMCPRegInfo mte_el0_cacheop_reginfo[] = { + { .name ="DC_CGVAC" , .state =ARM_CP_STATE_AA64 , + .opc0 =1 , .opc1 =3 , .crn =7 , .crm =10 , .opc2 =3 , + .type =ARM_CP_NOP , .access =PL0_W , + .accessfn = aa64_cacheop_poc_access }, + { .name ="DC_CGDVAC" , .state =ARM_CP_STATE_AA64 , + .opc0 =1 , .opc1 =3 , .crn =7 , .crm =10 , .opc2 =5 , + .type =ARM_CP_NOP , .access =PL0_W , + .accessfn = aa64_cacheop_poc_access }, + { .name ="DC_CGVAP" , .state =ARM_CP_STATE_AA64 , + .opc0 =1 , .opc1 =3 , .crn =7 , .crm =12 , .opc2 =3 , + .type =ARM_CP_NOP , .access =PL0_W , + .accessfn = aa64_cacheop_poc_access }, + { .name ="DC_CGDVAP" , .state =ARM_CP_STATE_AA64 , + .opc0 =1 , .opc1 =3 , .crn =7 , .crm =12 , .opc2 =5 , + .type =ARM_CP_NOP , .access =PL0_W , + .accessfn = aa64_cacheop_poc_access }, + { .name ="DC_CGVADP" , .state =ARM_CP_STATE_AA64 , + .opc0 =1 , .opc1 =3 , .crn =7 , .crm =13 , .opc2 =3 , + .type =ARM_CP_NOP , .access =PL0_W , + .accessfn = aa64_cacheop_poc_access }, + { .name ="DC_CGDVADP" , .state =ARM_CP_STATE_AA64 , + .opc0 =1 , .opc1 =3 , .crn =7 , .crm =13 , .opc2 =5 , + .type =ARM_CP_NOP , .access =PL0_W , + .accessfn = aa64_cacheop_poc_access }, + { .name ="DC_CIGVAC" , .state =ARM_CP_STATE_AA64 , + .opc0 =1 , .opc1 =3 , .crn =7 , .crm =14 , .opc2 =3 , + .type =ARM_CP_NOP , .access =PL0_W , + .accessfn = aa64_cacheop_poc_access }, + { .name ="DC_CIGDVAC" , .state =ARM_CP_STATE_AA64 , + .opc0 =1 , .opc1 =3 , .crn =7 , .crm =14 , .opc2 =5 , + .type =ARM_CP_NOP , .access =PL0_W , + .accessfn = aa64_cacheop_poc_access }, +REGINFO_SENTINEL +}; +#endif static CPAccessResult access_predinv(CPUARMState *env, const ARMCPRegInfo *ri,
@@ -8071,8 +8134,10 @@ void register_cp_regs_for_features(ARMCPU *cpu)*/ if (cpu_isar_feature (aa64_mte, cpu)) {define_arm_cp_regs (cpu, mte_reginfo); +define_arm_cp_regs (cpu, mte_el0_cacheop_reginfo); }else if (cpu_isar_feature (aa64_mte_insn_reg, cpu)) {define_arm_cp_regs (cpu, mte_tco_ro_reginfo); +define_arm_cp_regs (cpu, mte_el0_cacheop_reginfo); }#endif
Signature · 1 line
2.25.1
PATCH v8 21/45 target/arm: Move regime_el to internals.h
In reply to Richard HendersonWe will shortly need this in mte_helper.c as well.
--- target/arm/internals.h | 36 ++++++++++++++++++++++++++++++++++++ target/arm/helper.c | 36 ------------------------------------ 2 files changed, 36 insertions(+), 36 deletions(-)
target/arm/internals.h +36 -0
@@ -913,6 +913,42 @@ static inline bool regime_is_pan(CPUARMState *env, ARMMMUIdx mmu_idx) } } +/* Return the exception level which controls this address translation regime */ +static inline uint32_t regime_el (CPUARMState *env,ARMMMUIdx mmu_idx) +{ +switch (mmu_idx) { +case ARMMMUIdx_E20_0: +case ARMMMUIdx_E20_2: +case ARMMMUIdx_E20_2_PAN: +case ARMMMUIdx_Stage2: +case ARMMMUIdx_E2: +return 2 ; +case ARMMMUIdx_SE3: +return 3 ; +case ARMMMUIdx_SE10_0: +return arm_el_is_aa64 (env,3 ) ?1 :3 ; +case ARMMMUIdx_SE10_1: +case ARMMMUIdx_SE10_1_PAN: +case ARMMMUIdx_Stage1_E0: +case ARMMMUIdx_Stage1_E1: +case ARMMMUIdx_Stage1_E1_PAN: +case ARMMMUIdx_E10_0: +case ARMMMUIdx_E10_1: +case ARMMMUIdx_E10_1_PAN: +case ARMMMUIdx_MPrivNegPri: +case ARMMMUIdx_MUserNegPri: +case ARMMMUIdx_MPriv: +case ARMMMUIdx_MUser: +case ARMMMUIdx_MSPrivNegPri: +case ARMMMUIdx_MSUserNegPri: +case ARMMMUIdx_MSPriv: +case ARMMMUIdx_MSUser: +return 1 ; +default : +g_assert_not_reached (); + } +} +/* Return the FSR value for a debug exception (watchpoint, hardware * breakpoint or BKPT insn) targeting the specified exception level. */
target/arm/helper.c +0 -36
@@ -9793,42 +9793,6 @@ void arm_cpu_do_interrupt(CPUState *cs) }#endif /* !CONFIG_USER_ONLY */ -/* Return the exception level which controls this address translation regime */ -static uint32_t regime_el (CPUARMState *env,ARMMMUIdx mmu_idx) -{ -switch (mmu_idx) { -case ARMMMUIdx_E20_0: -case ARMMMUIdx_E20_2: -case ARMMMUIdx_E20_2_PAN: -case ARMMMUIdx_Stage2: -case ARMMMUIdx_E2: -return 2 ; -case ARMMMUIdx_SE3: -return 3 ; -case ARMMMUIdx_SE10_0: -return arm_el_is_aa64 (env,3 ) ?1 :3 ; -case ARMMMUIdx_SE10_1: -case ARMMMUIdx_SE10_1_PAN: -case ARMMMUIdx_Stage1_E0: -case ARMMMUIdx_Stage1_E1: -case ARMMMUIdx_Stage1_E1_PAN: -case ARMMMUIdx_E10_0: -case ARMMMUIdx_E10_1: -case ARMMMUIdx_E10_1_PAN: -case ARMMMUIdx_MPrivNegPri: -case ARMMMUIdx_MUserNegPri: -case ARMMMUIdx_MPriv: -case ARMMMUIdx_MUser: -case ARMMMUIdx_MSPrivNegPri: -case ARMMMUIdx_MSUserNegPri: -case ARMMMUIdx_MSPriv: -case ARMMMUIdx_MSUser: -return 1 ; -default : -g_assert_not_reached (); - } -} -uint64_t arm_sctlr (CPUARMState *env,int el) {/* Only EL0 needs to be adjusted for EL1&0 or EL2&0. */
Signature · 1 line
2.25.1
PATCH v8 22/45 target/arm: Move regime_tcr to internals.h
In reply to Richard HendersonWe will shortly need this in mte_helper.c as well.
--- target/arm/internals.h | 9 +++++++++ target/arm/helper.c | 9 --------- 2 files changed, 9 insertions(+), 9 deletions(-)
target/arm/internals.h +9 -0
@@ -949,6 +949,15 @@ static inline uint32_t regime_el(CPUARMState *env, ARMMMUIdx mmu_idx) } } +/* Return the TCR controlling this translation regime */ +static inline TCR *regime_tcr (CPUARMState *env,ARMMMUIdx mmu_idx) +{ +if (mmu_idx == ARMMMUIdx_Stage2) { +return &env->cp15.vtcr_el2; + } +return &env->cp15.tcr_el[regime_el (env, mmu_idx)]; +} +/* Return the FSR value for a debug exception (watchpoint, hardware * breakpoint or BKPT insn) targeting the specified exception level. */
target/arm/helper.c +0 -9
@@ -9875,15 +9875,6 @@ static inline uint64_t regime_ttbr(CPUARMState *env, ARMMMUIdx mmu_idx,#endif /* !CONFIG_USER_ONLY */ -/* Return the TCR controlling this translation regime */ -static inline TCR *regime_tcr (CPUARMState *env,ARMMMUIdx mmu_idx) -{ -if (mmu_idx == ARMMMUIdx_Stage2) { -return &env->cp15.vtcr_el2; - } -return &env->cp15.tcr_el[regime_el (env, mmu_idx)]; -} -/* Convert a possible stage1+2 MMU index into the appropriate * stage 1 MMU index */
Signature · 1 line
2.25.1
PATCH v8 23/45 target/arm: Add gen_mte_check1
In reply to Richard HendersonReplace existing uses of check_data_tbi in translate-a64.c that perform a single logical memory access. Leave the helper blank for now to reduce the patch size.
--- target/arm/helper-a64.h | 1 + target/arm/internals.h | 8 +++ target/arm/translate-a64.h | 2 + target/arm/mte_helper.c | 8 +++ target/arm/translate-a64.c | 100 ++++++++++++++++++++++++++++--------- 5 files changed, 95 insertions(+), 24 deletions(-)
target/arm/helper-a64.h +1 -0
@@ -104,6 +104,7 @@ DEF_HELPER_FLAGS_3(autdb, TCG_CALL_NO_WG, i64, env, i64, i64) DEF_HELPER_FLAGS_2(xpaci, TCG_CALL_NO_RWG_SE, i64, env, i64) DEF_HELPER_FLAGS_2(xpacd, TCG_CALL_NO_RWG_SE, i64, env, i64) +DEF_HELPER_FLAGS_3(mte_check1, TCG_CALL_NO_WG, i64, env, i32, i64) DEF_HELPER_FLAGS_3(irg, TCG_CALL_NO_RWG, i64, env, i64, i64) DEF_HELPER_FLAGS_4(addsubg, TCG_CALL_NO_RWG_SE, i64, env, i64, s32, i32)DEF_HELPER_FLAGS_3 (ldg,TCG_CALL_NO_WG , i64, env, i64, i64)
target/arm/internals.h +8 -0
@@ -1310,6 +1310,14 @@ void arm_log_exception(int idx);#define LOG2_TAG_GRANULE 4#define TAG_GRANULE (1 << LOG2_TAG_GRANULE) +/* Bits within a descriptor passed to the helper_mte_check* functions. */ +FIELD(MTEDESC, MIDX, 0, 4) +FIELD(MTEDESC, TBI, 4, 2) +FIELD(MTEDESC, TCMA, 6, 2) +FIELD(MTEDESC, WRITE, 8, 1) +FIELD(MTEDESC, ESIZE, 9, 5) +FIELD(MTEDESC, TSIZE, 14, 10) /* mte_checkN only */ +static inline int allocation_tag_from_addr (uint64_t ptr) {return extract64 (ptr,56 ,4 );
target/arm/translate-a64.h +2 -0
@@ -40,6 +40,8 @@ TCGv_ptr get_fpstatus_ptr(bool);bool logic_imm_decode_wmask (uint64_t *result,unsigned int immn,unsigned int imms,unsigned int immr);bool sve_access_check (DisasContext *s); +TCGv_i64 gen_mte_check1 (DisasContext *s,TCGv_i64 addr,bool is_write, +bool tag_checked,int log2_size);/* We should have at some point before trying to access an FP register * done the necessary access check, so assert that
target/arm/mte_helper.c +8 -0
@@ -358,3 +358,11 @@ void HELPER(stzgm_tags)(CPUARMState *env, uint64_t ptr, uint64_t val)memset (mem, tag_pair, tag_bytes); } } + +/* +* Perform an MTE checked access for a single logical or atomic access. +*/ +uint64_t HELPER (mte_check1 )(CPUARMState *env,uint32_t desc,uint64_t ptr) +{ +return ptr; +}
target/arm/translate-a64.c +76 -24
206 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH v8 24/45 target/arm: Add gen_mte_checkN
In reply to Richard HendersonReplace existing uses of check_data_tbi in translate-a64.c that perform multiple logical memory access. Leave the helper blank for now to reduce the patch size.
--- target/arm/helper-a64.h | 1 + target/arm/translate-a64.h | 2 ++ target/arm/mte_helper.c | 8 +++++ target/arm/translate-a64.c | 71 +++++++++++++++++++++++++++++--------- 4 files changed, 66 insertions(+), 16 deletions(-)
target/arm/helper-a64.h +1 -0
@@ -105,6 +105,7 @@ DEF_HELPER_FLAGS_2(xpaci, TCG_CALL_NO_RWG_SE, i64, env, i64) DEF_HELPER_FLAGS_2(xpacd, TCG_CALL_NO_RWG_SE, i64, env, i64) DEF_HELPER_FLAGS_3(mte_check1, TCG_CALL_NO_WG, i64, env, i32, i64) +DEF_HELPER_FLAGS_3(mte_checkN, TCG_CALL_NO_WG, i64, env, i32, i64) DEF_HELPER_FLAGS_3(irg, TCG_CALL_NO_RWG, i64, env, i64, i64) DEF_HELPER_FLAGS_4(addsubg, TCG_CALL_NO_RWG_SE, i64, env, i64, s32, i32)DEF_HELPER_FLAGS_3 (ldg,TCG_CALL_NO_WG , i64, env, i64, i64)
target/arm/translate-a64.h +2 -0
@@ -42,6 +42,8 @@ bool logic_imm_decode_wmask(uint64_t *result, unsigned int immn,bool sve_access_check (DisasContext *s);TCGv_i64 gen_mte_check1 (DisasContext *s,TCGv_i64 addr,bool is_write,bool tag_checked,int log2_size); +TCGv_i64 gen_mte_checkN (DisasContext *s,TCGv_i64 addr,bool is_write, +bool tag_checked,int count,int log2_esize);/* We should have at some point before trying to access an FP register * done the necessary access check, so assert that
target/arm/mte_helper.c +8 -0
@@ -366,3 +366,11 @@ uint64_t HELPER(mte_check1)(CPUARMState *env, uint32_t desc, uint64_t ptr) {return ptr; } + +/* +* Perform an MTE checked access for multiple logical accesses. +*/ +uint64_t HELPER (mte_checkN )(CPUARMState *env,uint32_t desc,uint64_t ptr) +{ +return ptr; +}
target/arm/translate-a64.c +55 -16
131 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH v8 25/45 target/arm: Implement helper_mte_check1
In reply to Richard HendersonFill out the stub that was added earlier.
---
v8: Remove ra argument to mte_probe1 (pmm).
--- target/arm/internals.h | 48 +++++++++++++++ target/arm/mte_helper.c | 132 +++++++++++++++++++++++++++++++++++++++- 2 files changed, 179 insertions(+), 1 deletion(-)
target/arm/internals.h +48 -0
@@ -1318,6 +1318,10 @@ FIELD(MTEDESC, WRITE, 8, 1) FIELD(MTEDESC, ESIZE, 9, 5) FIELD(MTEDESC, TSIZE, 14, 10) /* mte_checkN only */ +bool mte_probe1 (CPUARMState *env,uint32_t desc,uint64_t ptr); +uint64_t mte_check1 (CPUARMState *env,uint32_t desc, +uint64_t ptr,uintptr_t ra); +static inline int allocation_tag_from_addr (uint64_t ptr) {return extract64 (ptr,56 ,4 );
@@ -1328,4 +1332,48 @@ static inline uint64_t address_with_allocation_tag(uint64_t ptr, int rtag) return deposit64(ptr, 56, 4, rtag); } +/* Return true if tbi bits mean that the access is checked. */ +static inline bool tbi_check (uint32_t desc,int bit55) +{ +return (desc >> (R_MTEDESC_TBI_SHIFT + bit55)) &1 ; +} + +/* Return true if tcma bits mean that the access is unchecked. */ +static inline bool tcma_check (uint32_t desc,int bit55,int ptr_tag) +{ +/* +* We had extracted bit55 and ptr_tag for other reasons, so fold +* (ptr<59:55> == 00000 || ptr<59:55> == 11111) into a single test. +*/ +bool match = ((ptr_tag + bit55) &0xf ) ==0 ; +bool tcma = (desc >> (R_MTEDESC_TCMA_SHIFT + bit55)) &1 ; +return tcma && match; +} + +/* +* For TBI, ideally, we would do nothing. Proper behaviour on fault is +* for the tag to be present in the FAR_ELx register. But for user-only +* mode, we do not have a TLB with which to implement this, so we must +* remove the top byte. +*/ +static inline uint64_t useronly_clean_ptr (uint64_t ptr) +{ +/* TBI is known to be enabled. */ +#ifdef CONFIG_USER_ONLY + ptr =sextract64 (ptr,0 ,56 ); +#endif +return ptr; +} + +static inline uint64_t useronly_maybe_clean_ptr (uint32_t desc,uint64_t ptr) +{ +#ifdef CONFIG_USER_ONLY +int64_t clean_ptr =sextract64 (ptr,0 ,56 ); +if (tbi_check (desc, clean_ptr <0 )) { + ptr = clean_ptr; + } +#endif +return ptr; +} +#endif
target/arm/mte_helper.c +131 -1
143 lines not on this page · raw message
Signature · 1 line
2.25.1
Re: [PATCH v8 25/45] target/arm: Implement helper_mte_check1
Quoted 10 lines · Richard Henderson
Fill out the stub that was added earlier.
Signed-off-by Richard Henderson <[email protected]>---
v8: Remove ra argument tomte_probe1(pmm).--- target/arm/internals.h | 48 +++++++++++++++ target/arm/mte_helper.c | 132 +++++++++++++++++++++++++++++++++++++++- 2 files changed, 179 insertions(+), 1 deletion(-)
thanks
-- PMM
PATCH v8 26/45 target/arm: Implement helper_mte_checkN
In reply to Richard HendersonFill out the stub that was added earlier.
---
v7: Fix page crossing test (szabolcs nagy).
--- target/arm/internals.h | 2 + target/arm/mte_helper.c | 165 +++++++++++++++++++++++++++++++++++++++- 2 files changed, 166 insertions(+), 1 deletion(-)
target/arm/internals.h +2 -0
@@ -1321,6 +1321,8 @@ FIELD(MTEDESC, TSIZE, 14, 10) /* mte_checkN only */bool mte_probe1 (CPUARMState *env,uint32_t desc,uint64_t ptr);uint64_t mte_check1 (CPUARMState *env,uint32_t desc,uint64_t ptr,uintptr_t ra); +uint64_t mte_checkN (CPUARMState *env,uint32_t desc, +uint64_t ptr,uintptr_t ra);static inline int allocation_tag_from_addr (uint64_t ptr) {
target/arm/mte_helper.c +164 -1
171 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH v8 27/45 target/arm: Add helper_mte_check_zva
In reply to Richard HendersonUse a special helper for DC_ZVA, rather than the more general mte_checkN.
--- target/arm/helper-a64.h | 1 + target/arm/mte_helper.c | 106 +++++++++++++++++++++++++++++++++++++ target/arm/translate-a64.c | 16 +++++- 3 files changed, 122 insertions(+), 1 deletion(-)
target/arm/helper-a64.h +1 -0
@@ -106,6 +106,7 @@ DEF_HELPER_FLAGS_2(xpacd, TCG_CALL_NO_RWG_SE, i64, env, i64) DEF_HELPER_FLAGS_3(mte_check1, TCG_CALL_NO_WG, i64, env, i32, i64) DEF_HELPER_FLAGS_3(mte_checkN, TCG_CALL_NO_WG, i64, env, i32, i64) +DEF_HELPER_FLAGS_3(mte_check_zva, TCG_CALL_NO_WG, i64, env, i32, i64) DEF_HELPER_FLAGS_3(irg, TCG_CALL_NO_RWG, i64, env, i64, i64) DEF_HELPER_FLAGS_4(addsubg, TCG_CALL_NO_RWG_SE, i64, env, i64, s32, i32)DEF_HELPER_FLAGS_3 (ldg,TCG_CALL_NO_WG , i64, env, i64, i64)
target/arm/mte_helper.c +106 -0
109 lines not on this page · raw message
target/arm/translate-a64.c +15 -1
@@ -1857,7 +1857,21 @@ static void handle_sys(DisasContext *s, uint32_t insn, bool isread,return ;case ARM_CP_DC_ZVA :/* Writes clear the aligned block of memory which rt points into. */ - tcg_rt =clean_data_tbi (s,cpu_reg (s, rt)); +if (s->mte_active[0 ]) { +TCGv_i32 t_desc; +int desc =0 ; + + desc =FIELD_DP32 (desc,MTEDESC ,MIDX ,get_mem_index (s)); + desc =FIELD_DP32 (desc,MTEDESC ,TBI , s->tbid); + desc =FIELD_DP32 (desc,MTEDESC ,TCMA , s->tcma); + t_desc =tcg_const_i32 (desc); + + tcg_rt =new_tmp_a64 (s); +gen_helper_mte_check_zva (tcg_rt, cpu_env, t_desc,cpu_reg (s, rt)); +tcg_temp_free_i32 (t_desc); + }else { + tcg_rt =clean_data_tbi (s,cpu_reg (s, rt)); + }gen_helper_dc_zva (cpu_env, tcg_rt);return ;default :
Signature · 1 line
2.25.1
PATCH v8 28/45 target/arm: Use mte_checkN for sve unpredicated loads
In reply to Richard Henderson---
v8: Drop the out-of-line helper (pmm).
--- target/arm/translate-sve.c | 61 +++++++++++++++++++++----------------- 1 file changed, 33 insertions(+), 28 deletions(-)
target/arm/translate-sve.c +33 -28
@@ -4342,71 +4342,76 @@ static void do_ldr(DisasContext *s, uint32_t vofs, int len, int rn, int imm)int len_remain = len %8 ;int nparts = len /8 +ctpop8 (len_remain);int midx =get_mem_index (s); -TCGv_i64 addr, t0, t1; +TCGv_i64 dirty_addr, clean_addr, t0, t1; - addr =tcg_temp_new_i64 (); - t0 =tcg_temp_new_i64 (); + dirty_addr =tcg_temp_new_i64 (); +tcg_gen_addi_i64 (dirty_addr,cpu_reg_sp (s, rn), imm); + clean_addr =gen_mte_checkN (s, dirty_addr, false, rn !=31 , len,MO_8 ); +tcg_temp_free_i64 (dirty_addr); -/* Note that unpredicated load/store of vector/predicate registers +/* +* Note that unpredicated load/store of vector/predicate registers * are defined as a stream of bytes, which equates to little-endian -* operations on larger quantities. There is no nice way to force -* a little-endian load for aarch64_be-linux-user out of line. -* +* operations on larger quantities. * Attempt to keep code expansion to a minimum by limiting the * amount of unrolling done. */ if (nparts <=4 ) {int i; + t0 =tcg_temp_new_i64 ();for (i =0 ; i < len_align; i +=8 ) { -tcg_gen_addi_i64 (addr,cpu_reg_sp (s, rn), imm + i); -tcg_gen_qemu_ld_i64 (t0, addr, midx,MO_LEQ ); +tcg_gen_qemu_ld_i64 (t0, clean_addr, midx,MO_LEQ );tcg_gen_st_i64 (t0, cpu_env, vofs + i); +tcg_gen_addi_i64 (clean_addr,cpu_reg_sp (s, rn),8 ); } +tcg_temp_free_i64 (t0); }else {TCGLabel *loop =gen_new_label ();TCGv_ptr tp, i =tcg_const_local_ptr (0 ); +/* Copy the clean address into a local temp, live across the loop. */ + t0 = clean_addr; + clean_addr =tcg_temp_local_new_i64 (); +tcg_gen_mov_i64 (clean_addr, t0); +tcg_temp_free_i64 (t0); +gen_set_label (loop); -/* Minimize the number of local temps that must be re-read from -* the stack each iteration. Instead, re-compute values other -* than the loop counter. -*/ + t0 =tcg_temp_new_i64 (); +tcg_gen_qemu_ld_i64 (t0, clean_addr, midx,MO_LEQ ); +tcg_gen_addi_i64 (clean_addr, clean_addr,8 ); + tp =tcg_temp_new_ptr (); -tcg_gen_addi_ptr (tp, i, imm); -tcg_gen_extu_ptr_i64 (addr, tp); -tcg_gen_add_i64 (addr, addr,cpu_reg_sp (s, rn)); - -tcg_gen_qemu_ld_i64 (t0, addr, midx,MO_LEQ ); -tcg_gen_add_ptr (tp, cpu_env, i);tcg_gen_addi_ptr (i, i,8 );tcg_gen_st_i64 (t0, tp, vofs);tcg_temp_free_ptr (tp); +tcg_temp_free_i64 (t0);tcg_gen_brcondi_ptr (TCG_COND_LTU , i, len_align, loop);tcg_temp_free_ptr (i); } -/* Predicate register loads can be any multiple of 2. +/* +* Predicate register loads can be any multiple of 2. * Note that we still store the entire 64-bit unit into cpu_env. */ if (len_remain) { -tcg_gen_addi_i64 (addr,cpu_reg_sp (s, rn), imm + len_align); - + t0 =tcg_temp_new_i64 ();switch (len_remain) {case 2 :case 4 :case 8 : -tcg_gen_qemu_ld_i64 (t0, addr, midx,MO_LE |ctz32 (len_remain)); +tcg_gen_qemu_ld_i64 (t0, clean_addr, midx, +MO_LE |ctz32 (len_remain));break ;case 6 : t1 =tcg_temp_new_i64 (); -tcg_gen_qemu_ld_i64 (t0, addr, midx,MO_LEUL ); -tcg_gen_addi_i64 (addr, addr,4 ); -tcg_gen_qemu_ld_i64 (t1, addr, midx,MO_LEUW ); +tcg_gen_qemu_ld_i64 (t0, clean_addr, midx,MO_LEUL ); +tcg_gen_addi_i64 (clean_addr, clean_addr,4 ); +tcg_gen_qemu_ld_i64 (t1, clean_addr, midx,MO_LEUW );tcg_gen_deposit_i64 (t0, t0, t1,32 ,32 );tcg_temp_free_i64 (t1);break ;
@@ -4415,9 +4420,9 @@ static void do_ldr(DisasContext *s, uint32_t vofs, int len, int rn, int imm)g_assert_not_reached (); }tcg_gen_st_i64 (t0, cpu_env, vofs + len_align); +tcg_temp_free_i64 (t0); } -tcg_temp_free_i64 (addr); -tcg_temp_free_i64 (t0); +tcg_temp_free_i64 (clean_addr); }/* Similarly for stores. */
Signature · 1 line
2.25.1
Re: [PATCH v8 28/45] target/arm: Use mte_checkN for sve unpredicated loads
Quoted 8 lines · Richard Henderson
Signed-off-by Richard Henderson <[email protected]>---
v8: Drop the out-of-line helper (pmm).--- target/arm/translate-sve.c | 61 +++++++++++++++++++++----------------- 1 file changed, 33 insertions(+), 28 deletions(-)
thanks
-- PMM
PATCH v8 29/45 target/arm: Use mte_checkN for sve unpredicated stores
In reply to Richard Henderson---
v8: Drop the out-of-line helper (pmm).
--- target/arm/translate-sve.c | 61 +++++++++++++++++++++----------------- 1 file changed, 33 insertions(+), 28 deletions(-)
target/arm/translate-sve.c +33 -28
@@ -4432,10 +4432,12 @@ static void do_str(DisasContext *s, uint32_t vofs, int len, int rn, int imm)int len_remain = len %8 ;int nparts = len /8 +ctpop8 (len_remain);int midx =get_mem_index (s); -TCGv_i64 addr, t0; +TCGv_i64 dirty_addr, clean_addr, t0; - addr =tcg_temp_new_i64 (); - t0 =tcg_temp_new_i64 (); + dirty_addr =tcg_temp_new_i64 (); +tcg_gen_addi_i64 (dirty_addr,cpu_reg_sp (s, rn), imm); + clean_addr =gen_mte_checkN (s, dirty_addr, false, rn !=31 , len,MO_8 ); +tcg_temp_free_i64 (dirty_addr);/* Note that unpredicated load/store of vector/predicate registers * are defined as a stream of bytes, which equates to little-endian
@@ -4448,33 +4450,35 @@ static void do_str(DisasContext *s, uint32_t vofs, int len, int rn, int imm)if (nparts <=4 ) {int i; + t0 =tcg_temp_new_i64 ();for (i =0 ; i < len_align; i +=8 ) {tcg_gen_ld_i64 (t0, cpu_env, vofs + i); -tcg_gen_addi_i64 (addr,cpu_reg_sp (s, rn), imm + i); -tcg_gen_qemu_st_i64 (t0, addr, midx,MO_LEQ ); +tcg_gen_qemu_st_i64 (t0, clean_addr, midx,MO_LEQ ); +tcg_gen_addi_i64 (clean_addr,cpu_reg_sp (s, rn),8 ); } +tcg_temp_free_i64 (t0); }else {TCGLabel *loop =gen_new_label (); -TCGv_ptr t2, i =tcg_const_local_ptr (0 ); +TCGv_ptr tp, i =tcg_const_local_ptr (0 ); + +/* Copy the clean address into a local temp, live across the loop. */ + t0 = clean_addr; + clean_addr =tcg_temp_local_new_i64 (); +tcg_gen_mov_i64 (clean_addr, t0); +tcg_temp_free_i64 (t0);gen_set_label (loop); - t2 =tcg_temp_new_ptr (); -tcg_gen_add_ptr (t2, cpu_env, i); -tcg_gen_ld_i64 (t0, t2, vofs); - -/* Minimize the number of local temps that must be re-read from -* the stack each iteration. Instead, re-compute values other -* than the loop counter. -*/ -tcg_gen_addi_ptr (t2, i, imm); -tcg_gen_extu_ptr_i64 (addr, t2); -tcg_gen_add_i64 (addr, addr,cpu_reg_sp (s, rn)); -tcg_temp_free_ptr (t2); - -tcg_gen_qemu_st_i64 (t0, addr, midx,MO_LEQ ); - + t0 =tcg_temp_new_i64 (); + tp =tcg_temp_new_ptr (); +tcg_gen_add_ptr (tp, cpu_env, i); +tcg_gen_ld_i64 (t0, tp, vofs);tcg_gen_addi_ptr (i, i,8 ); +tcg_temp_free_ptr (tp); + +tcg_gen_qemu_st_i64 (t0, clean_addr, midx,MO_LEQ ); +tcg_gen_addi_i64 (clean_addr, clean_addr,8 ); +tcg_temp_free_i64 (t0);tcg_gen_brcondi_ptr (TCG_COND_LTU , i, len_align, loop);tcg_temp_free_ptr (i);
@@ -4482,29 +4486,30 @@ static void do_str(DisasContext *s, uint32_t vofs, int len, int rn, int imm)/* Predicate register stores can be any multiple of 2. */ if (len_remain) { + t0 =tcg_temp_new_i64 ();tcg_gen_ld_i64 (t0, cpu_env, vofs + len_align); -tcg_gen_addi_i64 (addr,cpu_reg_sp (s, rn), imm + len_align);switch (len_remain) {case 2 :case 4 :case 8 : -tcg_gen_qemu_st_i64 (t0, addr, midx,MO_LE |ctz32 (len_remain)); +tcg_gen_qemu_st_i64 (t0, clean_addr, midx, +MO_LE |ctz32 (len_remain));break ;case 6 : -tcg_gen_qemu_st_i64 (t0, addr, midx,MO_LEUL ); -tcg_gen_addi_i64 (addr, addr,4 ); +tcg_gen_qemu_st_i64 (t0, clean_addr, midx,MO_LEUL ); +tcg_gen_addi_i64 (clean_addr, clean_addr,4 );tcg_gen_shri_i64 (t0, t0,32 ); -tcg_gen_qemu_st_i64 (t0, addr, midx,MO_LEUW ); +tcg_gen_qemu_st_i64 (t0, clean_addr, midx,MO_LEUW );break ;default :g_assert_not_reached (); } +tcg_temp_free_i64 (t0); } -tcg_temp_free_i64 (addr); -tcg_temp_free_i64 (t0); +tcg_temp_free_i64 (clean_addr); }static bool trans_LDR_zri (DisasContext *s,arg_rri *a)
Signature · 1 line
2.25.1
Re: [PATCH v8 29/45] target/arm: Use mte_checkN for sve unpredicated stores
Quoted 7 lines · Richard Henderson
Signed-off-by Richard Henderson <[email protected]>---
v8: Drop the out-of-line helper (pmm).--- target/arm/translate-sve.c | 61 +++++++++++++++++++++----------------- 1 file changed, 33 insertions(+), 28 deletions(-)
thanks
-- PMM
PATCH v8 30/45 target/arm: Use mte_check1 for sve LD1R
In reply to Richard Henderson--- target/arm/translate-sve.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
target/arm/translate-sve.c +4 -2
@@ -4892,7 +4892,7 @@ static bool trans_LD1R_zpri(DisasContext *s, arg_rpri_load *a)unsigned esz = dtype_esz[a->dtype];unsigned msz =dtype_msz (a->dtype);TCGLabel *over =gen_new_label (); -TCGv_i64 temp; +TCGv_i64 temp, clean_addr;/* If the guarding predicate has no bits set, no load occurs. */ if (psz <=8 ) {
@@ -4915,7 +4915,9 @@ static bool trans_LD1R_zpri(DisasContext *s, arg_rpri_load *a)/* Load the data. */ temp =tcg_temp_new_i64 ();tcg_gen_addi_i64 (temp,cpu_reg_sp (s, a->rn), a->imm << msz); -tcg_gen_qemu_ld_i64 (temp, temp,get_mem_index (s), + clean_addr =gen_mte_check1 (s, temp, false, true, msz); + +tcg_gen_qemu_ld_i64 (temp, clean_addr,get_mem_index (s), s->be_data | dtype_mop[a->dtype]);/* Broadcast to *all* elements. */
Signature · 1 line
2.25.1
Re: [PATCH v8 30/45] target/arm: Use mte_check1 for sve LD1R
Quoted 5 lines · Richard Henderson
Signed-off-by Richard Henderson <[email protected]>--- target/arm/translate-sve.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
thanks
-- PMM
PATCH v8 31/45 target/arm: Tidy trans_LD1R_zpri
In reply to Richard HendersonMove the variable declarations to the top of the function, but do not create a new label before sve_access_check.
---
v8: Split out from previous patch (pmm).
--- target/arm/translate-sve.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
target/arm/translate-sve.c +7 -5
@@ -4883,17 +4883,19 @@ static bool trans_LD1RQ_zpri(DisasContext *s, arg_rpri_load *a)/* Load and broadcast element. */ static bool trans_LD1R_zpri (DisasContext *s,arg_rpri_load *a) { -if (!sve_access_check (s)) { -return true; - } -unsigned vsz =vec_full_reg_size (s);unsigned psz =pred_full_reg_size (s);unsigned esz = dtype_esz[a->dtype];unsigned msz =dtype_msz (a->dtype); -TCGLabel *over =gen_new_label (); +TCGLabel *over;TCGv_i64 temp, clean_addr; +if (!sve_access_check (s)) { +return true; + } + + over =gen_new_label (); +/* If the guarding predicate has no bits set, no load occurs. */ if (psz <=8 ) {/* Reduce the pred_esz_masks value simply to reduce the
Signature · 1 line
2.25.1
Re: [PATCH v8 31/45] target/arm: Tidy trans_LD1R_zpri
Quoted 8 lines · Richard Henderson
Move the variable declarations to the top of the function, but do not create a new label before
sve_access_check.Signed-off-by Richard Henderson <[email protected]>---
v8: Split out from previous patch (pmm).
---
thanks
-- PMM
PATCH v8 32/45 target/arm: Add arm_tlb_bti_gp
In reply to Richard HendersonIntroduce an lvalue macro to wrap target_tlb_bit0.
--- target/arm/cpu.h | 13 +++++++++++++ target/arm/helper.c | 2 +- target/arm/translate-a64.c | 2 +- 3 files changed, 15 insertions(+), 2 deletions(-)
target/arm/cpu.h +13 -0
@@ -3393,6 +3393,19 @@ static inline uint64_t *aa64_vfp_qreg(CPUARMState *env, unsigned regno)/* Shared between translate-sve.c and sve_helper.c. */ extern const uint64_t pred_esz_masks[4 ]; +/* Helper for the macros below, validating the argument type. */ +static inline MemTxAttrs *typecheck_memtxattrs (MemTxAttrs *x) +{ +return x; +} + +/* +* Lvalue macros for ARM TLB bits that we must cache in the TCG TLB. +* Using these should be a bit more self-documenting than using the +* generic target bits directly. +*/ +#define arm_tlb_bti_gp (x) (typecheck_memtxattrs(x)->target_tlb_bit0) +/* * Naming convention for isar_feature functions: * Functions which test 32-bit ID registers should have _aa32_ in
target/arm/helper.c +1 -1
@@ -11079,7 +11079,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, target_ulong address, }/* When in aarch64 mode, and BTI is enabled, remember GP in the IOTLB. */ if (aarch64 && guarded &&cpu_isar_feature (aa64_bti, cpu)) { - txattrs->target_tlb_bit0 = true; +arm_tlb_bti_gp (txattrs) = true; }if (cacheattrs !=NULL ) {
target/arm/translate-a64.c +1 -1
@@ -14446,7 +14446,7 @@ static bool is_guarded_page(CPUARMState *env, DisasContext *s)* table entry even for that case. */ return (tlb_hit (entry->addr_code, addr) && -env_tlb (env)->d[mmu_idx].iotlb[index].attrs.target_tlb_bit0); +arm_tlb_bti_gp (&env_tlb (env)->d[mmu_idx].iotlb[index].attrs));#endif }
Signature · 1 line
2.25.1
Re: [PATCH v8 32/45] target/arm: Add arm_tlb_bti_gp
Quoted 6 lines · Richard Henderson
Introduce an lvalue macro to wrap
target_tlb_bit0.Signed-off-by Richard Henderson <[email protected]>target/arm/cpu.h +2
-0+/* Helper for the macros below, validating the argument type. */ +static inline MemTxAttrs *typecheck_memtxattrs (MemTxAttrs *x)
target/arm/cpu.h static inline uint64_t *aa64_vfp_qreg(CPUARMState *env, unsigned regno) · line 3407
Quoted 10 lines
target/arm/cpu.h +10
-0+{ +return x; +} + +/* +* Lvalue macros for ARM TLB bits that we must cache in the TCG TLB. +* Using these should be a bit more self-documenting than using the +* generic target bits directly. +*/ +#define arm_tlb_bti_gp (x) (typecheck_memtxattrs(x)->target_tlb_bit0)
It seems unlikely that we wouldn't get a compile failure if we passed something other than a MemTxAttrs* to this macro, given the specificity of the field name, but I guess it gives us a less confusing compiler error ?
thanks
-- PMM
Re: [PATCH v8 32/45] target/arm: Add arm_tlb_bti_gp
Quoted 15 lines · Peter Maydell
Quoted 13 lines · Richard Henderson
Introduce an lvalue macro to wrap
target_tlb_bit0.Signed-off-by Richard Henderson <[email protected]>target/arm/cpu.h +9
-0+/* Helper for the macros below, validating the argument type. */ +static inline MemTxAttrs *typecheck_memtxattrs (MemTxAttrs *x) +{ +return x; +} + +/* +* Lvalue macros for ARM TLB bits that we must cache in the TCG TLB. +* Using these should be a bit more self-documenting than using the
Quoted 8 lines
Quoted 3 lines
+ * generic target bits directly.
+ */
+#definearm_tlb_bti_gp(x)(typecheck_memtxattrs(x)->target_tlb_bit0)It seems unlikely that we wouldn't get a compile failure if we passed something other than a MemTxAttrs* to this macro, given the specificity of the field name, but I guess it gives us a less confusing compiler error ?
Yes, it's a quite clear error with the function. But you're right, we could probably get away without it.
r~
Quoted 6 lines
Reviewed-by Peter Maydell <[email protected]>thanks
-- PMM
PATCH v8 33/45 target/arm: Add mte helpers for sve scalar + int loads
In reply to Richard HendersonBecause the elements are sequential, we can eliminate many tests all at once when the tag hits TCMA, or if the page(s) are not Tagged.
--- target/arm/cpu.h | 1 + target/arm/helper-sve.h | 58 ++++++++++ target/arm/internals.h | 6 + target/arm/sve_helper.c | 218 ++++++++++++++++++++++++++++++------- target/arm/translate-sve.c | 186 ++++++++++++++++++++++--------- 5 files changed, 378 insertions(+), 91 deletions(-)
target/arm/cpu.h +1 -0
@@ -3405,6 +3405,7 @@ static inline MemTxAttrs *typecheck_memtxattrs(MemTxAttrs *x)* generic target bits directly. */ #define arm_tlb_bti_gp (x) (typecheck_memtxattrs(x)->target_tlb_bit0) +#define arm_tlb_mte_tagged (x) (typecheck_memtxattrs(x)->target_tlb_bit1)/* * Naming convention for isar_feature functions:
target/arm/helper-sve.h +58 -0
64 lines not on this page · raw message
target/arm/internals.h +6 -0
@@ -1310,6 +1310,12 @@ void arm_log_exception(int idx);#define LOG2_TAG_GRANULE 4#define TAG_GRANULE (1 << LOG2_TAG_GRANULE) +/* +* The SVE simd_data field, for memory ops, contains either +* rd (5 bits) or a shift count (2 bits). +*/ +#define SVE_MTEDESC_SHIFT 5 +/* Bits within a descriptor passed to the helper_mte_check* functions. */ FIELD(MTEDESC, MIDX, 0, 4)FIELD (MTEDESC ,TBI ,4 ,2 )
target/arm/sve_helper.c +179 -39
253 lines not on this page · raw message
target/arm/translate-sve.c +134 -52
237 lines not on this page · raw message
Signature · 1 line
2.25.1
Re: [PATCH v8 33/45] target/arm: Add mte helpers for sve scalar + int loads
Quoted 4 lines · Richard Henderson
Because the elements are sequential, we can eliminate many tests all at once when the tag hits TCMA, or if the page(s) are not Tagged.
Quoted 8 lines
Signed-off-by Richard Henderson <[email protected]>--- target/arm/cpu.h | 1 + target/arm/helper-sve.h | 58 ++++++++++ target/arm/internals.h | 6 + target/arm/sve_helper.c | 218 ++++++++++++++++++++++++++++++------- target/arm/translate-sve.c | 186 ++++++++++++++++++++++--------- 5 files changed, 378 insertions(+), 91 deletions(-)
thanks
-- PMM
PATCH v8 34/45 target/arm: Add mte helpers for sve scalar + int stores
In reply to Richard HendersonBecause the elements are sequential, we can eliminate many tests all at once when the tag hits TCMA, or if the page(s) are not Tagged.
--- target/arm/helper-sve.h | 47 +++++++++++ target/arm/sve_helper.c | 95 ++++++++++++++++------ target/arm/translate-sve.c | 162 ++++++++++++++++++++++++------------- 3 files changed, 226 insertions(+), 78 deletions(-)
target/arm/helper-sve.h +47 -0
@@ -1363,6 +1363,53 @@ DEF_HELPER_FLAGS_4(sve_st1hd_be_r, TCG_CALL_NO_WG, void, env, ptr, tl, i32) DEF_HELPER_FLAGS_4(sve_st1sd_le_r, TCG_CALL_NO_WG, void, env, ptr, tl, i32) DEF_HELPER_FLAGS_4(sve_st1sd_be_r, TCG_CALL_NO_WG, void, env, ptr, tl, i32) +DEF_HELPER_FLAGS_4(sve_st1bb_r_mte, TCG_CALL_NO_WG, void, env, ptr, tl, i32) +DEF_HELPER_FLAGS_4(sve_st2bb_r_mte, TCG_CALL_NO_WG, void, env, ptr, tl, i32) +DEF_HELPER_FLAGS_4(sve_st3bb_r_mte, TCG_CALL_NO_WG, void, env, ptr, tl, i32) +DEF_HELPER_FLAGS_4(sve_st4bb_r_mte, TCG_CALL_NO_WG, void, env, ptr, tl, i32) + +DEF_HELPER_FLAGS_4(sve_st1hh_le_r_mte, TCG_CALL_NO_WG, void, env, ptr, tl, i32) +DEF_HELPER_FLAGS_4(sve_st2hh_le_r_mte, TCG_CALL_NO_WG, void, env, ptr, tl, i32) +DEF_HELPER_FLAGS_4(sve_st3hh_le_r_mte, TCG_CALL_NO_WG, void, env, ptr, tl, i32) +DEF_HELPER_FLAGS_4(sve_st4hh_le_r_mte, TCG_CALL_NO_WG, void, env, ptr, tl, i32) + +DEF_HELPER_FLAGS_4(sve_st1hh_be_r_mte, TCG_CALL_NO_WG, void, env, ptr, tl, i32) +DEF_HELPER_FLAGS_4(sve_st2hh_be_r_mte, TCG_CALL_NO_WG, void, env, ptr, tl, i32) +DEF_HELPER_FLAGS_4(sve_st3hh_be_r_mte, TCG_CALL_NO_WG, void, env, ptr, tl, i32) +DEF_HELPER_FLAGS_4(sve_st4hh_be_r_mte, TCG_CALL_NO_WG, void, env, ptr, tl, i32) + +DEF_HELPER_FLAGS_4(sve_st1ss_le_r_mte, TCG_CALL_NO_WG, void, env, ptr, tl, i32) +DEF_HELPER_FLAGS_4(sve_st2ss_le_r_mte, TCG_CALL_NO_WG, void, env, ptr, tl, i32) +DEF_HELPER_FLAGS_4(sve_st3ss_le_r_mte, TCG_CALL_NO_WG, void, env, ptr, tl, i32) +DEF_HELPER_FLAGS_4(sve_st4ss_le_r_mte, TCG_CALL_NO_WG, void, env, ptr, tl, i32) + +DEF_HELPER_FLAGS_4(sve_st1ss_be_r_mte, TCG_CALL_NO_WG, void, env, ptr, tl, i32) +DEF_HELPER_FLAGS_4(sve_st2ss_be_r_mte, TCG_CALL_NO_WG, void, env, ptr, tl, i32) +DEF_HELPER_FLAGS_4(sve_st3ss_be_r_mte, TCG_CALL_NO_WG, void, env, ptr, tl, i32) +DEF_HELPER_FLAGS_4(sve_st4ss_be_r_mte, TCG_CALL_NO_WG, void, env, ptr, tl, i32) + +DEF_HELPER_FLAGS_4(sve_st1dd_le_r_mte, TCG_CALL_NO_WG, void, env, ptr, tl, i32) +DEF_HELPER_FLAGS_4(sve_st2dd_le_r_mte, TCG_CALL_NO_WG, void, env, ptr, tl, i32) +DEF_HELPER_FLAGS_4(sve_st3dd_le_r_mte, TCG_CALL_NO_WG, void, env, ptr, tl, i32) +DEF_HELPER_FLAGS_4(sve_st4dd_le_r_mte, TCG_CALL_NO_WG, void, env, ptr, tl, i32) + +DEF_HELPER_FLAGS_4(sve_st1dd_be_r_mte, TCG_CALL_NO_WG, void, env, ptr, tl, i32) +DEF_HELPER_FLAGS_4(sve_st2dd_be_r_mte, TCG_CALL_NO_WG, void, env, ptr, tl, i32) +DEF_HELPER_FLAGS_4(sve_st3dd_be_r_mte, TCG_CALL_NO_WG, void, env, ptr, tl, i32) +DEF_HELPER_FLAGS_4(sve_st4dd_be_r_mte, TCG_CALL_NO_WG, void, env, ptr, tl, i32) + +DEF_HELPER_FLAGS_4(sve_st1bh_r_mte, TCG_CALL_NO_WG, void, env, ptr, tl, i32) +DEF_HELPER_FLAGS_4(sve_st1bs_r_mte, TCG_CALL_NO_WG, void, env, ptr, tl, i32) +DEF_HELPER_FLAGS_4(sve_st1bd_r_mte, TCG_CALL_NO_WG, void, env, ptr, tl, i32) + +DEF_HELPER_FLAGS_4(sve_st1hs_le_r_mte, TCG_CALL_NO_WG, void, env, ptr, tl, i32) +DEF_HELPER_FLAGS_4(sve_st1hd_le_r_mte, TCG_CALL_NO_WG, void, env, ptr, tl, i32) +DEF_HELPER_FLAGS_4(sve_st1hs_be_r_mte, TCG_CALL_NO_WG, void, env, ptr, tl, i32) +DEF_HELPER_FLAGS_4(sve_st1hd_be_r_mte, TCG_CALL_NO_WG, void, env, ptr, tl, i32) + +DEF_HELPER_FLAGS_4(sve_st1sd_le_r_mte, TCG_CALL_NO_WG, void, env, ptr, tl, i32) +DEF_HELPER_FLAGS_4(sve_st1sd_be_r_mte, TCG_CALL_NO_WG, void, env, ptr, tl, i32) +DEF_HELPER_FLAGS_6 (sve_ldbsu_zsu,TCG_CALL_NO_WG , void, env, ptr, ptr, ptr, tl, i32) DEF_HELPER_FLAGS_6(sve_ldhsu_le_zsu, TCG_CALL_NO_WG,
target/arm/sve_helper.c +72 -23
116 lines not on this page · raw message
target/arm/translate-sve.c +107 -55
180 lines not on this page · raw message
Signature · 1 line
2.25.1
Re: [PATCH v8 34/45] target/arm: Add mte helpers for sve scalar + int stores
Quoted 6 lines · Richard Henderson
Because the elements are sequential, we can eliminate many tests all at once when the tag hits TCMA, or if the page(s) are not Tagged.
Signed-off-by Richard Henderson <[email protected]>---
thanks
-- PMM
PATCH v8 35/45 target/arm: Add mte helpers for sve scalar + int ff/nf loads
In reply to Richard HendersonBecause the elements are sequential, we can eliminate many tests all at once when the tag hits TCMA, or if the page(s) are not Tagged.
--- target/arm/helper-sve.h | 98 ++++++++++++++++ target/arm/sve_helper.c | 99 ++++++++++++++-- target/arm/translate-sve.c | 232 +++++++++++++++++++++++++------------ 3 files changed, 343 insertions(+), 86 deletions(-)
target/arm/helper-sve.h +98 -0
@@ -1285,6 +1285,55 @@ DEF_HELPER_FLAGS_4(sve_ldff1sds_be_r, TCG_CALL_NO_WG, void, env, ptr, tl, i32) DEF_HELPER_FLAGS_4(sve_ldff1dd_le_r, TCG_CALL_NO_WG, void, env, ptr, tl, i32) DEF_HELPER_FLAGS_4(sve_ldff1dd_be_r, TCG_CALL_NO_WG, void, env, ptr, tl, i32) +DEF_HELPER_FLAGS_4(sve_ldff1bb_r_mte, TCG_CALL_NO_WG, void, env, ptr, tl, i32) +DEF_HELPER_FLAGS_4(sve_ldff1bhu_r_mte, TCG_CALL_NO_WG, void, env, ptr, tl, i32) +DEF_HELPER_FLAGS_4(sve_ldff1bsu_r_mte, TCG_CALL_NO_WG, void, env, ptr, tl, i32) +DEF_HELPER_FLAGS_4(sve_ldff1bdu_r_mte, TCG_CALL_NO_WG, void, env, ptr, tl, i32) +DEF_HELPER_FLAGS_4(sve_ldff1bhs_r_mte, TCG_CALL_NO_WG, void, env, ptr, tl, i32) +DEF_HELPER_FLAGS_4(sve_ldff1bss_r_mte, TCG_CALL_NO_WG, void, env, ptr, tl, i32) +DEF_HELPER_FLAGS_4(sve_ldff1bds_r_mte, TCG_CALL_NO_WG, void, env, ptr, tl, i32) + +DEF_HELPER_FLAGS_4 (sve_ldff1hh_le_r_mte,TCG_CALL_NO_WG , + void, env, ptr, tl, i32) +DEF_HELPER_FLAGS_4 (sve_ldff1hsu_le_r_mte,TCG_CALL_NO_WG , + void, env, ptr, tl, i32) +DEF_HELPER_FLAGS_4 (sve_ldff1hdu_le_r_mte,TCG_CALL_NO_WG , + void, env, ptr, tl, i32) +DEF_HELPER_FLAGS_4 (sve_ldff1hss_le_r_mte,TCG_CALL_NO_WG , + void, env, ptr, tl, i32) +DEF_HELPER_FLAGS_4 (sve_ldff1hds_le_r_mte,TCG_CALL_NO_WG , + void, env, ptr, tl, i32) + +DEF_HELPER_FLAGS_4 (sve_ldff1hh_be_r_mte,TCG_CALL_NO_WG , + void, env, ptr, tl, i32) +DEF_HELPER_FLAGS_4 (sve_ldff1hsu_be_r_mte,TCG_CALL_NO_WG , + void, env, ptr, tl, i32) +DEF_HELPER_FLAGS_4 (sve_ldff1hdu_be_r_mte,TCG_CALL_NO_WG , + void, env, ptr, tl, i32) +DEF_HELPER_FLAGS_4 (sve_ldff1hss_be_r_mte,TCG_CALL_NO_WG , + void, env, ptr, tl, i32) +DEF_HELPER_FLAGS_4 (sve_ldff1hds_be_r_mte,TCG_CALL_NO_WG , + void, env, ptr, tl, i32) + +DEF_HELPER_FLAGS_4 (sve_ldff1ss_le_r_mte,TCG_CALL_NO_WG , + void, env, ptr, tl, i32) +DEF_HELPER_FLAGS_4 (sve_ldff1sdu_le_r_mte,TCG_CALL_NO_WG , + void, env, ptr, tl, i32) +DEF_HELPER_FLAGS_4 (sve_ldff1sds_le_r_mte,TCG_CALL_NO_WG , + void, env, ptr, tl, i32) + +DEF_HELPER_FLAGS_4 (sve_ldff1ss_be_r_mte,TCG_CALL_NO_WG , + void, env, ptr, tl, i32) +DEF_HELPER_FLAGS_4 (sve_ldff1sdu_be_r_mte,TCG_CALL_NO_WG , + void, env, ptr, tl, i32) +DEF_HELPER_FLAGS_4 (sve_ldff1sds_be_r_mte,TCG_CALL_NO_WG , + void, env, ptr, tl, i32) + +DEF_HELPER_FLAGS_4 (sve_ldff1dd_le_r_mte,TCG_CALL_NO_WG , + void, env, ptr, tl, i32) +DEF_HELPER_FLAGS_4 (sve_ldff1dd_be_r_mte,TCG_CALL_NO_WG , + void, env, ptr, tl, i32) + DEF_HELPER_FLAGS_4(sve_ldnf1bb_r, TCG_CALL_NO_WG, void, env, ptr, tl, i32) DEF_HELPER_FLAGS_4(sve_ldnf1bhu_r, TCG_CALL_NO_WG, void, env, ptr, tl, i32)DEF_HELPER_FLAGS_4 (sve_ldnf1bsu_r,TCG_CALL_NO_WG , void, env, ptr, tl, i32)
@@ -1316,6 +1365,55 @@ DEF_HELPER_FLAGS_4(sve_ldnf1sds_be_r, TCG_CALL_NO_WG, void, env, ptr, tl, i32) DEF_HELPER_FLAGS_4(sve_ldnf1dd_le_r, TCG_CALL_NO_WG, void, env, ptr, tl, i32) DEF_HELPER_FLAGS_4(sve_ldnf1dd_be_r, TCG_CALL_NO_WG, void, env, ptr, tl, i32) +DEF_HELPER_FLAGS_4(sve_ldnf1bb_r_mte, TCG_CALL_NO_WG, void, env, ptr, tl, i32) +DEF_HELPER_FLAGS_4(sve_ldnf1bhu_r_mte, TCG_CALL_NO_WG, void, env, ptr, tl, i32) +DEF_HELPER_FLAGS_4(sve_ldnf1bsu_r_mte, TCG_CALL_NO_WG, void, env, ptr, tl, i32) +DEF_HELPER_FLAGS_4(sve_ldnf1bdu_r_mte, TCG_CALL_NO_WG, void, env, ptr, tl, i32) +DEF_HELPER_FLAGS_4(sve_ldnf1bhs_r_mte, TCG_CALL_NO_WG, void, env, ptr, tl, i32) +DEF_HELPER_FLAGS_4(sve_ldnf1bss_r_mte, TCG_CALL_NO_WG, void, env, ptr, tl, i32) +DEF_HELPER_FLAGS_4(sve_ldnf1bds_r_mte, TCG_CALL_NO_WG, void, env, ptr, tl, i32) + +DEF_HELPER_FLAGS_4 (sve_ldnf1hh_le_r_mte,TCG_CALL_NO_WG , + void, env, ptr, tl, i32) +DEF_HELPER_FLAGS_4 (sve_ldnf1hsu_le_r_mte,TCG_CALL_NO_WG , + void, env, ptr, tl, i32) +DEF_HELPER_FLAGS_4 (sve_ldnf1hdu_le_r_mte,TCG_CALL_NO_WG , + void, env, ptr, tl, i32) +DEF_HELPER_FLAGS_4 (sve_ldnf1hss_le_r_mte,TCG_CALL_NO_WG , + void, env, ptr, tl, i32) +DEF_HELPER_FLAGS_4 (sve_ldnf1hds_le_r_mte,TCG_CALL_NO_WG , + void, env, ptr, tl, i32) + +DEF_HELPER_FLAGS_4 (sve_ldnf1hh_be_r_mte,TCG_CALL_NO_WG , + void, env, ptr, tl, i32) +DEF_HELPER_FLAGS_4 (sve_ldnf1hsu_be_r_mte,TCG_CALL_NO_WG , + void, env, ptr, tl, i32) +DEF_HELPER_FLAGS_4 (sve_ldnf1hdu_be_r_mte,TCG_CALL_NO_WG , + void, env, ptr, tl, i32) +DEF_HELPER_FLAGS_4 (sve_ldnf1hss_be_r_mte,TCG_CALL_NO_WG , + void, env, ptr, tl, i32) +DEF_HELPER_FLAGS_4 (sve_ldnf1hds_be_r_mte,TCG_CALL_NO_WG , + void, env, ptr, tl, i32) + +DEF_HELPER_FLAGS_4 (sve_ldnf1ss_le_r_mte,TCG_CALL_NO_WG , + void, env, ptr, tl, i32) +DEF_HELPER_FLAGS_4 (sve_ldnf1sdu_le_r_mte,TCG_CALL_NO_WG , + void, env, ptr, tl, i32) +DEF_HELPER_FLAGS_4 (sve_ldnf1sds_le_r_mte,TCG_CALL_NO_WG , + void, env, ptr, tl, i32) + +DEF_HELPER_FLAGS_4 (sve_ldnf1ss_be_r_mte,TCG_CALL_NO_WG , + void, env, ptr, tl, i32) +DEF_HELPER_FLAGS_4 (sve_ldnf1sdu_be_r_mte,TCG_CALL_NO_WG , + void, env, ptr, tl, i32) +DEF_HELPER_FLAGS_4 (sve_ldnf1sds_be_r_mte,TCG_CALL_NO_WG , + void, env, ptr, tl, i32) + +DEF_HELPER_FLAGS_4 (sve_ldnf1dd_le_r_mte,TCG_CALL_NO_WG , + void, env, ptr, tl, i32) +DEF_HELPER_FLAGS_4 (sve_ldnf1dd_be_r_mte,TCG_CALL_NO_WG , + void, env, ptr, tl, i32) + DEF_HELPER_FLAGS_4(sve_st1bb_r, TCG_CALL_NO_WG, void, env, ptr, tl, i32) DEF_HELPER_FLAGS_4(sve_st2bb_r, TCG_CALL_NO_WG, void, env, ptr, tl, i32)DEF_HELPER_FLAGS_4 (sve_st3bb_r,TCG_CALL_NO_WG , void, env, ptr, tl, i32)
target/arm/sve_helper.c +87 -12
165 lines not on this page · raw message
target/arm/translate-sve.c +158 -74
270 lines not on this page · raw message
Signature · 1 line
2.25.1
Re: [PATCH v8 35/45] target/arm: Add mte helpers for sve scalar + int ff/nf loads
Quoted 10 lines · Richard Henderson
Because the elements are sequential, we can eliminate many tests all at once when the tag hits TCMA, or if the page(s) are not Tagged.
Signed-off-by Richard Henderson <[email protected]>--- target/arm/helper-sve.h | 98 ++++++++++++++++ target/arm/sve_helper.c | 99 ++++++++++++++-- target/arm/translate-sve.c | 232 +++++++++++++++++++++++++------------ 3 files changed, 343 insertions(+), 86 deletions(-)
thanks
-- PMM
PATCH v8 36/45 target/arm: Handle TBI for sve scalar + int memory ops
In reply to Richard HendersonWe still need to handle tbi for user-only when mte is inactive.
--- target/arm/translate-a64.h | 1 + target/arm/translate-a64.c | 2 +- target/arm/translate-sve.c | 6 ++++-- 3 files changed, 6 insertions(+), 3 deletions(-)
target/arm/translate-a64.h +1 -0
@@ -40,6 +40,7 @@ TCGv_ptr get_fpstatus_ptr(bool);bool logic_imm_decode_wmask (uint64_t *result,unsigned int immn,unsigned int imms,unsigned int immr);bool sve_access_check (DisasContext *s); +TCGv_i64 clean_data_tbi (DisasContext *s,TCGv_i64 addr);TCGv_i64 gen_mte_check1 (DisasContext *s,TCGv_i64 addr,bool is_write,bool tag_checked,int log2_size); TCGv_i64 gen_mte_checkN(DisasContext *s, TCGv_i64 addr, bool is_write,
target/arm/translate-a64.c +1 -1
@@ -215,7 +215,7 @@ static void gen_a64_set_pc(DisasContext *s, TCGv_i64 src)* of the write-back address. */ -static TCGv_i64 clean_data_tbi (DisasContext *s,TCGv_i64 addr) +TCGv_i64 clean_data_tbi (DisasContext *s,TCGv_i64 addr) {TCGv_i64 clean =new_tmp_a64 (s);#ifdef CONFIG_USER_ONLY
target/arm/translate-sve.c +4 -2
@@ -4587,9 +4587,8 @@ static void do_mem_zpa(DisasContext *s, int zt, int pg, TCGv_i64 addr,* For e.g. LD4, there are not enough arguments to pass all 4 * registers as pointers, so encode the regno into the data field. * For consistency, do this even for LD1. -* TODO: mte_n check here while callers are updated. */ -if (mte_n && s->mte_active[0 ]) { +if (s->mte_active[0 ]) {int msz =dtype_msz (dtype); desc =FIELD_DP32 (desc,MTEDESC ,MIDX ,get_mem_index (s));
@@ -4599,7 +4598,10 @@ static void do_mem_zpa(DisasContext *s, int zt, int pg, TCGv_i64 addr, desc =FIELD_DP32 (desc,MTEDESC ,ESIZE ,1 << msz); desc =FIELD_DP32 (desc,MTEDESC ,TSIZE , mte_n << msz); desc <<=SVE_MTEDESC_SHIFT ; + }else { + addr =clean_data_tbi (s, addr); } + desc =simd_desc (vsz, vsz, zt | desc); t_desc =tcg_const_i32 (desc); t_pg =tcg_temp_new_ptr ();
Signature · 1 line
2.25.1
Re: [PATCH v8 36/45] target/arm: Handle TBI for sve scalar + int memory ops
Quoted 4 lines · Richard Henderson
We still need to handle tbi for user-only when mte is inactive.
Signed-off-by Richard Henderson <[email protected]>
thanks
-- PMM
PATCH v8 37/45 target/arm: Add mte helpers for sve scatter/gather memory ops
In reply to Richard HendersonBecause the elements are non-sequential, we cannot eliminate many tests straight away like we can for sequential operations. But we often have the PTE details handy, so we can test for Tagged.
--- target/arm/helper-sve.h | 285 ++++++++++++++++ target/arm/sve_helper.c | 185 +++++++++-- target/arm/translate-sve.c | 650 +++++++++++++++++++++++++------------ 3 files changed, 872 insertions(+), 248 deletions(-)
target/arm/helper-sve.h +285 -0
@@ -1617,6 +1617,115 @@ DEF_HELPER_FLAGS_6(sve_ldsds_le_zd, TCG_CALL_NO_WG,DEF_HELPER_FLAGS_6 (sve_ldsds_be_zd,TCG_CALL_NO_WG , void, env, ptr, ptr, ptr, tl, i32) +DEF_HELPER_FLAGS_6 (sve_ldbsu_zsu_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) +DEF_HELPER_FLAGS_6 (sve_ldhsu_le_zsu_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) +DEF_HELPER_FLAGS_6 (sve_ldhsu_be_zsu_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) +DEF_HELPER_FLAGS_6 (sve_ldss_le_zsu_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) +DEF_HELPER_FLAGS_6 (sve_ldss_be_zsu_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) +DEF_HELPER_FLAGS_6 (sve_ldbss_zsu_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) +DEF_HELPER_FLAGS_6 (sve_ldhss_le_zsu_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) +DEF_HELPER_FLAGS_6 (sve_ldhss_be_zsu_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) + +DEF_HELPER_FLAGS_6 (sve_ldbsu_zss_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) +DEF_HELPER_FLAGS_6 (sve_ldhsu_le_zss_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) +DEF_HELPER_FLAGS_6 (sve_ldhsu_be_zss_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) +DEF_HELPER_FLAGS_6 (sve_ldss_le_zss_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) +DEF_HELPER_FLAGS_6 (sve_ldss_be_zss_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) +DEF_HELPER_FLAGS_6 (sve_ldbss_zss_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) +DEF_HELPER_FLAGS_6 (sve_ldhss_le_zss_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) +DEF_HELPER_FLAGS_6 (sve_ldhss_be_zss_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) + +DEF_HELPER_FLAGS_6 (sve_ldbdu_zsu_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) +DEF_HELPER_FLAGS_6 (sve_ldhdu_le_zsu_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) +DEF_HELPER_FLAGS_6 (sve_ldhdu_be_zsu_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) +DEF_HELPER_FLAGS_6 (sve_ldsdu_le_zsu_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) +DEF_HELPER_FLAGS_6 (sve_ldsdu_be_zsu_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) +DEF_HELPER_FLAGS_6 (sve_lddd_le_zsu_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) +DEF_HELPER_FLAGS_6 (sve_lddd_be_zsu_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) +DEF_HELPER_FLAGS_6 (sve_ldbds_zsu_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) +DEF_HELPER_FLAGS_6 (sve_ldhds_le_zsu_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) +DEF_HELPER_FLAGS_6 (sve_ldhds_be_zsu_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) +DEF_HELPER_FLAGS_6 (sve_ldsds_le_zsu_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) +DEF_HELPER_FLAGS_6 (sve_ldsds_be_zsu_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) + +DEF_HELPER_FLAGS_6 (sve_ldbdu_zss_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) +DEF_HELPER_FLAGS_6 (sve_ldhdu_le_zss_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) +DEF_HELPER_FLAGS_6 (sve_ldhdu_be_zss_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) +DEF_HELPER_FLAGS_6 (sve_ldsdu_le_zss_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) +DEF_HELPER_FLAGS_6 (sve_ldsdu_be_zss_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) +DEF_HELPER_FLAGS_6 (sve_lddd_le_zss_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) +DEF_HELPER_FLAGS_6 (sve_lddd_be_zss_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) +DEF_HELPER_FLAGS_6 (sve_ldbds_zss_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) +DEF_HELPER_FLAGS_6 (sve_ldhds_le_zss_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) +DEF_HELPER_FLAGS_6 (sve_ldhds_be_zss_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) +DEF_HELPER_FLAGS_6 (sve_ldsds_le_zss_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) +DEF_HELPER_FLAGS_6 (sve_ldsds_be_zss_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) + +DEF_HELPER_FLAGS_6 (sve_ldbdu_zd_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) +DEF_HELPER_FLAGS_6 (sve_ldhdu_le_zd_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) +DEF_HELPER_FLAGS_6 (sve_ldhdu_be_zd_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) +DEF_HELPER_FLAGS_6 (sve_ldsdu_le_zd_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) +DEF_HELPER_FLAGS_6 (sve_ldsdu_be_zd_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) +DEF_HELPER_FLAGS_6 (sve_lddd_le_zd_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) +DEF_HELPER_FLAGS_6 (sve_lddd_be_zd_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) +DEF_HELPER_FLAGS_6 (sve_ldbds_zd_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) +DEF_HELPER_FLAGS_6 (sve_ldhds_le_zd_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) +DEF_HELPER_FLAGS_6 (sve_ldhds_be_zd_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) +DEF_HELPER_FLAGS_6 (sve_ldsds_le_zd_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) +DEF_HELPER_FLAGS_6 (sve_ldsds_be_zd_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) +DEF_HELPER_FLAGS_6 (sve_ldffbsu_zsu,TCG_CALL_NO_WG , void, env, ptr, ptr, ptr, tl, i32) DEF_HELPER_FLAGS_6(sve_ldffhsu_le_zsu, TCG_CALL_NO_WG,
@@ -1726,6 +1835,115 @@ DEF_HELPER_FLAGS_6(sve_ldffsds_le_zd, TCG_CALL_NO_WG,DEF_HELPER_FLAGS_6 (sve_ldffsds_be_zd,TCG_CALL_NO_WG , void, env, ptr, ptr, ptr, tl, i32) +DEF_HELPER_FLAGS_6 (sve_ldffbsu_zsu_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) +DEF_HELPER_FLAGS_6 (sve_ldffhsu_le_zsu_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) +DEF_HELPER_FLAGS_6 (sve_ldffhsu_be_zsu_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) +DEF_HELPER_FLAGS_6 (sve_ldffss_le_zsu_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) +DEF_HELPER_FLAGS_6 (sve_ldffss_be_zsu_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) +DEF_HELPER_FLAGS_6 (sve_ldffbss_zsu_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) +DEF_HELPER_FLAGS_6 (sve_ldffhss_le_zsu_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) +DEF_HELPER_FLAGS_6 (sve_ldffhss_be_zsu_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) + +DEF_HELPER_FLAGS_6 (sve_ldffbsu_zss_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) +DEF_HELPER_FLAGS_6 (sve_ldffhsu_le_zss_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) +DEF_HELPER_FLAGS_6 (sve_ldffhsu_be_zss_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) +DEF_HELPER_FLAGS_6 (sve_ldffss_le_zss_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) +DEF_HELPER_FLAGS_6 (sve_ldffss_be_zss_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) +DEF_HELPER_FLAGS_6 (sve_ldffbss_zss_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) +DEF_HELPER_FLAGS_6 (sve_ldffhss_le_zss_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) +DEF_HELPER_FLAGS_6 (sve_ldffhss_be_zss_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) + +DEF_HELPER_FLAGS_6 (sve_ldffbdu_zsu_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) +DEF_HELPER_FLAGS_6 (sve_ldffhdu_le_zsu_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) +DEF_HELPER_FLAGS_6 (sve_ldffhdu_be_zsu_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) +DEF_HELPER_FLAGS_6 (sve_ldffsdu_le_zsu_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) +DEF_HELPER_FLAGS_6 (sve_ldffsdu_be_zsu_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) +DEF_HELPER_FLAGS_6 (sve_ldffdd_le_zsu_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) +DEF_HELPER_FLAGS_6 (sve_ldffdd_be_zsu_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) +DEF_HELPER_FLAGS_6 (sve_ldffbds_zsu_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) +DEF_HELPER_FLAGS_6 (sve_ldffhds_le_zsu_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) +DEF_HELPER_FLAGS_6 (sve_ldffhds_be_zsu_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) +DEF_HELPER_FLAGS_6 (sve_ldffsds_le_zsu_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) +DEF_HELPER_FLAGS_6 (sve_ldffsds_be_zsu_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) + +DEF_HELPER_FLAGS_6 (sve_ldffbdu_zss_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) +DEF_HELPER_FLAGS_6 (sve_ldffhdu_le_zss_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) +DEF_HELPER_FLAGS_6 (sve_ldffhdu_be_zss_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) +DEF_HELPER_FLAGS_6 (sve_ldffsdu_le_zss_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) +DEF_HELPER_FLAGS_6 (sve_ldffsdu_be_zss_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) +DEF_HELPER_FLAGS_6 (sve_ldffdd_le_zss_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) +DEF_HELPER_FLAGS_6 (sve_ldffdd_be_zss_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) +DEF_HELPER_FLAGS_6 (sve_ldffbds_zss_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) +DEF_HELPER_FLAGS_6 (sve_ldffhds_le_zss_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) +DEF_HELPER_FLAGS_6 (sve_ldffhds_be_zss_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) +DEF_HELPER_FLAGS_6 (sve_ldffsds_le_zss_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) +DEF_HELPER_FLAGS_6 (sve_ldffsds_be_zss_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) + +DEF_HELPER_FLAGS_6 (sve_ldffbdu_zd_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) +DEF_HELPER_FLAGS_6 (sve_ldffhdu_le_zd_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) +DEF_HELPER_FLAGS_6 (sve_ldffhdu_be_zd_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) +DEF_HELPER_FLAGS_6 (sve_ldffsdu_le_zd_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) +DEF_HELPER_FLAGS_6 (sve_ldffsdu_be_zd_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) +DEF_HELPER_FLAGS_6 (sve_ldffdd_le_zd_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) +DEF_HELPER_FLAGS_6 (sve_ldffdd_be_zd_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) +DEF_HELPER_FLAGS_6 (sve_ldffbds_zd_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) +DEF_HELPER_FLAGS_6 (sve_ldffhds_le_zd_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) +DEF_HELPER_FLAGS_6 (sve_ldffhds_be_zd_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) +DEF_HELPER_FLAGS_6 (sve_ldffsds_le_zd_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) +DEF_HELPER_FLAGS_6 (sve_ldffsds_be_zd_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) +DEF_HELPER_FLAGS_6 (sve_stbs_zsu,TCG_CALL_NO_WG , void, env, ptr, ptr, ptr, tl, i32) DEF_HELPER_FLAGS_6(sve_sths_le_zsu, TCG_CALL_NO_WG,
@@ -1793,4 +2011,71 @@ DEF_HELPER_FLAGS_6(sve_stdd_le_zd, TCG_CALL_NO_WG,DEF_HELPER_FLAGS_6 (sve_stdd_be_zd,TCG_CALL_NO_WG , void, env, ptr, ptr, ptr, tl, i32) +DEF_HELPER_FLAGS_6 (sve_stbs_zsu_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) +DEF_HELPER_FLAGS_6 (sve_sths_le_zsu_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) +DEF_HELPER_FLAGS_6 (sve_sths_be_zsu_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) +DEF_HELPER_FLAGS_6 (sve_stss_le_zsu_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) +DEF_HELPER_FLAGS_6 (sve_stss_be_zsu_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) + +DEF_HELPER_FLAGS_6 (sve_stbs_zss_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) +DEF_HELPER_FLAGS_6 (sve_sths_le_zss_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) +DEF_HELPER_FLAGS_6 (sve_sths_be_zss_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) +DEF_HELPER_FLAGS_6 (sve_stss_le_zss_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) +DEF_HELPER_FLAGS_6 (sve_stss_be_zss_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) + +DEF_HELPER_FLAGS_6 (sve_stbd_zsu_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) +DEF_HELPER_FLAGS_6 (sve_sthd_le_zsu_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) +DEF_HELPER_FLAGS_6 (sve_sthd_be_zsu_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) +DEF_HELPER_FLAGS_6 (sve_stsd_le_zsu_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) +DEF_HELPER_FLAGS_6 (sve_stsd_be_zsu_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) +DEF_HELPER_FLAGS_6 (sve_stdd_le_zsu_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) +DEF_HELPER_FLAGS_6 (sve_stdd_be_zsu_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) + +DEF_HELPER_FLAGS_6 (sve_stbd_zss_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) +DEF_HELPER_FLAGS_6 (sve_sthd_le_zss_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) +DEF_HELPER_FLAGS_6 (sve_sthd_be_zss_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) +DEF_HELPER_FLAGS_6 (sve_stsd_le_zss_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) +DEF_HELPER_FLAGS_6 (sve_stsd_be_zss_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) +DEF_HELPER_FLAGS_6 (sve_stdd_le_zss_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) +DEF_HELPER_FLAGS_6 (sve_stdd_be_zss_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) + +DEF_HELPER_FLAGS_6 (sve_stbd_zd_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) +DEF_HELPER_FLAGS_6 (sve_sthd_le_zd_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) +DEF_HELPER_FLAGS_6 (sve_sthd_be_zd_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) +DEF_HELPER_FLAGS_6 (sve_stsd_le_zd_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) +DEF_HELPER_FLAGS_6 (sve_stsd_be_zd_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) +DEF_HELPER_FLAGS_6 (sve_stdd_le_zd_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) +DEF_HELPER_FLAGS_6 (sve_stdd_be_zd_mte,TCG_CALL_NO_WG , + void, env, ptr, ptr, ptr, tl, i32) +DEF_HELPER_FLAGS_4 (sve2_pmull_h,TCG_CALL_NO_RWG , void, ptr, ptr, ptr, i32)
target/arm/sve_helper.c +153 -32
268 lines not on this page · raw message
target/arm/translate-sve.c +434 -216
761 lines not on this page · raw message
Signature · 1 line
2.25.1
Re: [PATCH v8 37/45] target/arm: Add mte helpers for sve scatter/gather memory ops
Quoted 7 lines · Richard Henderson
Because the elements are non-sequential, we cannot eliminate many tests straight away like we can for sequential operations. But we often have the PTE details handy, so we can test for Tagged.
Signed-off-by Richard Henderson <[email protected]>---
thanks
-- PMM
PATCH v8 38/45 target/arm: Complete TBI clearing for user-only for SVE
In reply to Richard HendersonThere are a number of paths by which the TBI is still intact for user-only in the SVE helpers.
Because we currently always set TBI for user-only, we do not need to pass down the actual TBI setting from above, and we can remove the top byte in the inner-most primitives, so that none are forgotten. Moreover, this keeps the "dirty" pointer around at the higher levels, where we need it for any MTE checking.
Since the normal case, especially for user-only, goes through RAM, this clearing merely adds two insns per page lookup, which will be completely in the noise.
--- target/arm/sve_helper.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-)
target/arm/sve_helper.c +17 -2
@@ -3966,14 +3966,16 @@ static void sve_##NAME##_host(void *vd, intptr_t reg_off, void *host) \ static void sve_##NAME##_tlb(CPUARMState *env, void *vd, intptr_t reg_off, \target_ulong addr,uintptr_t ra) \ { \ - *(TYPEE *)(vd +H (reg_off)) = (TYPEM )TLB (env, addr, ra); \ + *(TYPEE *)(vd +H (reg_off)) = \ + (TYPEM )TLB (env,useronly_clean_ptr (addr), ra); \ }#define DO_ST_TLB (NAME ,H ,TYPEE ,TYPEM ,TLB ) \ static void sve_##NAME##_tlb(CPUARMState *env, void *vd, intptr_t reg_off, \ target_ulong addr, uintptr_t ra) \ { \ - TLB(env, addr, (TYPEM)*(TYPEE *)(vd + H(reg_off)), ra); \ + TLB(env, useronly_clean_ptr(addr), \ + (TYPEM)*(TYPEE *)(vd + H(reg_off)), ra); \ }#define DO_LD_PRIM_1 (NAME ,H ,TE ,TM ) \
@@ -4091,6 +4093,19 @@ static bool sve_probe_page(SVEHostPage *info, bool nofault,int flags; addr += mem_off; + +/* +* User-only currently always issues with TBI. See the comment +* above useronly_clean_ptr. Usually we clean this top byte away +* during translation, but we can't do that for e.g. vector + imm +* addressing modes. +* +* We currently always enable TBI for user-only, and do not provide +* a way to turn it off. So clean the pointer unconditionally here, +* rather than look it up here, or pass it down from above. +*/ + addr =useronly_clean_ptr (addr); + flags =probe_access_flags (env, addr, access_type, mmu_idx, nofault, &info->host, retaddr); info->flags = flags;
Signature · 1 line
2.25.1
Re: [PATCH v8 38/45] target/arm: Complete TBI clearing for user-only for SVE
Quoted 10 lines · Richard Henderson
There are a number of paths by which the TBI is still intact for user-only in the SVE helpers.
Because we currently always set TBI for user-only, we do not need to pass down the actual TBI setting from above, and we can remove the top byte in the inner-most primitives, so that none are forgotten. Moreover, this keeps the "dirty" pointer around at the higher levels, where we need it for any MTE checking.
Quoted 3 lines
Since the normal case, especially for user-only, goes through RAM, this clearing merely adds two insns per page lookup, which will be completely in the noise.
Can we have an assert() somewhere suitable that TBI is set? That way if we ever do have an SVE-capable linux-user which doesn't set TBI for some reason we'll get a useful reminder that we need to fix something.
Otherwise
thanks
-- PMM
Re: [PATCH v8 38/45] target/arm: Complete TBI clearing for user-only for SVE
Quoted 12 lines · Peter Maydell
Quoted 10 lines · Richard Henderson
There are a number of paths by which the TBI is still intact for user-only in the SVE helpers.
Because we currently always set TBI for user-only, we do not need to pass down the actual TBI setting from above, and we can remove the top byte in the inner-most primitives, so that none are forgotten. Moreover, this keeps the "dirty" pointer around at the higher levels, where we need it for any MTE checking.
Quoted 8 lines
Quoted 3 lines
Since the normal case, especially for user-only, goes through RAM, this clearing merely adds two insns per page lookup, which will be completely in the noise.
Can we have an
assert()somewhere suitable that TBI is set? That way if we ever do have an SVE-capable linux-user which doesn't set TBI for some reason we'll get a useful reminder that we need to fix something.
At what level would you like such an assert?
At present we have, in arm_cpu_reset,
/*
* Enable TBI0 and TBI1. While the real kernel only enables TBI0,
* turning on both here will produce smaller code and otherwise
* make no difference to the user-level emulation.
*/
env->cp15.tcr_el[1].raw_tcr = (3ULL << 37);
r~
Re: [PATCH v8 38/45] target/arm: Complete TBI clearing for user-only for SVE
Quoted 18 lines · Richard Henderson
Quoted 16 lines · Peter Maydell
Quoted 13 lines · Richard Henderson
There are a number of paths by which the TBI is still intact for user-only in the SVE helpers.
Because we currently always set TBI for user-only, we do not need to pass down the actual TBI setting from above, and we can remove the top byte in the inner-most primitives, so that none are forgotten. Moreover, this keeps the "dirty" pointer around at the higher levels, where we need it for any MTE checking.
Since the normal case, especially for user-only, goes through RAM, this clearing merely adds two insns per page lookup, which will be completely in the noise.
Quoted 6 lines
Quoted 4 lines
Can we have an
assert()somewhere suitable that TBI is set? That way if we ever do have an SVE-capable linux-user which doesn't set TBI for some reason we'll get a useful reminder that we need to fix something.At what level would you like such an assert?
I don't particularly care, as long as we get notified if our assumption that TBI is always set gets broken (ie we change that bit of CPU reset code for some reason).
thanks
-- PMM
PATCH v8 39/45 target/arm: Implement data cache set allocation tags
In reply to Richard HendersonThis is DC GVA and DC GZVA, and the tag check for DC ZVA.
---
v2: Use allocation_tag_mem + memset.
v3: Require pre-cleaned addresses.
v6: Move DCZ block size assert to cpu realize.
Perform a tag check for DC ZVA.
--- target/arm/cpu.h | 4 +++- target/arm/helper.c | 16 ++++++++++++++++ target/arm/translate-a64.c | 39 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 58 insertions(+), 1 deletion(-)
target/arm/cpu.h +3 -1
@@ -2360,7 +2360,9 @@ static inline uint64_t cpreg_to_kvm_id(uint32_t cpregid)#define ARM_CP_NZCV (ARM_CP_SPECIAL | 0x0300)#define ARM_CP_CURRENTEL (ARM_CP_SPECIAL | 0x0400)#define ARM_CP_DC_ZVA (ARM_CP_SPECIAL | 0x0500) -#define ARM_LAST_SPECIAL ARM_CP_DC_ZVA +#define ARM_CP_DC_GVA (ARM_CP_SPECIAL | 0x0600) +#define ARM_CP_DC_GZVA (ARM_CP_SPECIAL | 0x0700) +#define ARM_LAST_SPECIAL ARM_CP_DC_GZVA#define ARM_CP_FPU 0x1000#define ARM_CP_SVE 0x2000#define ARM_CP_NO_GDB 0x4000
target/arm/helper.c +16 -0
@@ -6998,6 +6998,22 @@ static const ARMCPRegInfo mte_el0_cacheop_reginfo[] = { .opc0 = 1, .opc1 = 3, .crn = 7, .crm = 14, .opc2 = 5, .type = ARM_CP_NOP, .access = PL0_W, .accessfn = aa64_cacheop_poc_access }, + { .name = "DC_GVA", .state = ARM_CP_STATE_AA64, + .opc0 = 1, .opc1 = 3, .crn = 7, .crm = 4, .opc2 = 3, + .access = PL0_W, .type = ARM_CP_DC_GVA, +#ifndef CONFIG_USER_ONLY +/* Avoid overhead of an access check that always passes in user-mode */ + .accessfn = aa64_zva_access, +#endif + }, + { .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_GZVA, +#ifndef CONFIG_USER_ONLY +/* Avoid overhead of an access check that always passes in user-mode */ + .accessfn = aa64_zva_access, +#endif + },REGINFO_SENTINEL };
target/arm/translate-a64.c +39 -0
@@ -1874,6 +1874,45 @@ static void handle_sys(DisasContext *s, uint32_t insn, bool isread, }gen_helper_dc_zva (cpu_env, tcg_rt);return ; +case ARM_CP_DC_GVA : + { +TCGv_i64 clean_addr, tag; + +/* +* DC_GVA, like DC_ZVA, requires that we supply the original +* pointer for an invalid page. Probe that address first. +*/ + tcg_rt =cpu_reg (s, rt); + clean_addr =clean_data_tbi (s, tcg_rt); +gen_probe_access (s, clean_addr,MMU_DATA_STORE ,MO_8 ); + +if (s->ata) { +/* Extract the tag from the register to match STZGM. */ + tag =tcg_temp_new_i64 (); +tcg_gen_shri_i64 (tag, tcg_rt,56 ); +gen_helper_stzgm_tags (cpu_env, clean_addr, tag); +tcg_temp_free_i64 (tag); + } + } +return ; +case ARM_CP_DC_GZVA : + { +TCGv_i64 clean_addr, tag; + +/* For DC_GZVA, we can rely on DC_ZVA for the proper fault. */ + tcg_rt =cpu_reg (s, rt); + clean_addr =clean_data_tbi (s, tcg_rt); +gen_helper_dc_zva (cpu_env, clean_addr); + +if (s->ata) { +/* Extract the tag from the register to match STZGM. */ + tag =tcg_temp_new_i64 (); +tcg_gen_shri_i64 (tag, tcg_rt,56 ); +gen_helper_stzgm_tags (cpu_env, clean_addr, tag); +tcg_temp_free_i64 (tag); + } + } +return ;default :break ; }
Signature · 1 line
2.25.1
PATCH v8 40/45 target/arm: Set PSTATE.TCO on exception entry
In reply to Richard HendersonD1.10 specifies that exception handlers begin with tag checks overridden.
---
v2: Only set if MTE feature present.
--- target/arm/helper.c | 3 +++ 1 file changed, 3 insertions(+)
target/arm/helper.c +3 -0
@@ -9704,6 +9704,9 @@ static void arm_cpu_do_interrupt_aarch64(CPUState *cs)break ; } } +if (cpu_isar_feature (aa64_mte, cpu)) { + new_mode |=PSTATE_TCO ; + }pstate_write (env,PSTATE_DAIF | new_mode); env->aarch64 =1 ;
Signature · 1 line
2.25.1
PATCH v8 41/45 target/arm: Always pass cacheattr to get_phys_addr
In reply to Richard HendersonWe need to check the memattr of a page in order to determine whether it is Tagged for MTE. Between Stage1 and Stage2, this becomes simpler if we always collect this data, instead of occasionally being presented with NULL.
Use the nonnull attribute to allow the compiler to check that all pointer arguments are non-null.
--- target/arm/internals.h | 3 ++- target/arm/helper.c | 60 ++++++++++++++++++++--------------------- target/arm/m_helper.c | 11 +++++--- target/arm/tlb_helper.c | 4 ++- 4 files changed, 42 insertions(+), 36 deletions(-)
target/arm/internals.h +2 -1
@@ -1294,7 +1294,8 @@ bool get_phys_addr(CPUARMState *env, target_ulong address, MMUAccessType access_type, ARMMMUIdx mmu_idx, hwaddr *phys_ptr, MemTxAttrs *attrs, int *prot, target_ulong *page_size, - ARMMMUFaultInfo *fi, ARMCacheAttrs *cacheattrs); + ARMMMUFaultInfo *fi, ARMCacheAttrs *cacheattrs) + __attribute__((nonnull));void arm_log_exception (int idx);
target/arm/helper.c +30 -30
95 lines not on this page · raw message
target/arm/m_helper.c +7 -4
@@ -187,12 +187,13 @@ static bool v7m_stack_write(ARMCPU *cpu, uint32_t addr, uint32_t value,hwaddr physaddr;int prot;ARMMMUFaultInfo fi = {}; +ARMCacheAttrs cacheattrs = {};bool secure = mmu_idx &ARM_MMU_IDX_M_S ;int exc;bool exc_secure;if (get_phys_addr (env, addr,MMU_DATA_STORE , mmu_idx, &physaddr, - &attrs, &prot, &page_size, &fi,NULL )) { + &attrs, &prot, &page_size, &fi, &cacheattrs)) {/* MPU/SAU lookup failed */ if (fi.type == ARMFault_QEMU_SFault) {if (mode ==STACK_LAZYFP ) {
@@ -279,13 +280,14 @@ static bool v7m_stack_read(ARMCPU *cpu, uint32_t *dest, uint32_t addr,hwaddr physaddr;int prot;ARMMMUFaultInfo fi = {}; +ARMCacheAttrs cacheattrs = {};bool secure = mmu_idx &ARM_MMU_IDX_M_S ;int exc;bool exc_secure;uint32_t value;if (get_phys_addr (env, addr,MMU_DATA_LOAD , mmu_idx, &physaddr, - &attrs, &prot, &page_size, &fi,NULL )) { + &attrs, &prot, &page_size, &fi, &cacheattrs)) {/* MPU/SAU lookup failed */ if (fi.type == ARMFault_QEMU_SFault) { qemu_log_mask(CPU_LOG_INT,
@@ -1928,6 +1930,7 @@ static bool v7m_read_half_insn(ARMCPU *cpu, ARMMMUIdx mmu_idx,V8M_SAttributes sattrs = {};MemTxAttrs attrs = {};ARMMMUFaultInfo fi = {}; +ARMCacheAttrs cacheattrs = {};MemTxResult txres;target_ulong page_size;hwaddr physaddr;
@@ -1945,8 +1948,8 @@ static bool v7m_read_half_insn(ARMCPU *cpu, ARMMMUIdx mmu_idx, "...really SecureFault with SFSR.INVEP\n");return false; } -if (get_phys_addr (env, addr,MMU_INST_FETCH , mmu_idx, - &physaddr, &attrs, &prot, &page_size, &fi,NULL )) { +if (get_phys_addr (env, addr,MMU_INST_FETCH , mmu_idx, &physaddr, + &attrs, &prot, &page_size, &fi, &cacheattrs)) {/* the MPU lookup failed */ env->v7m.cfsr[env->v7m.secure] |=R_V7M_CFSR_IACCVIOL_MASK ;armv7m_nvic_set_pending (env->nvic,ARMV7M_EXCP_MEM , env->v7m.secure);
target/arm/tlb_helper.c +3 -1
@@ -166,6 +166,7 @@ bool arm_cpu_tlb_fill(CPUState *cs, vaddr address, int size,int prot, ret;MemTxAttrs attrs = {};ARMMMUFaultInfo fi = {}; +ARMCacheAttrs cacheattrs = {};/* * Walk the page table and (if the mapping exists) add the page
@@ -175,7 +176,8 @@ bool arm_cpu_tlb_fill(CPUState *cs, vaddr address, int size,*/ ret =get_phys_addr (&cpu->env, address, access_type,core_to_arm_mmu_idx (&cpu->env, mmu_idx), - &phys_addr, &attrs, &prot, &page_size, &fi,NULL ); + &phys_addr, &attrs, &prot, &page_size, + &fi, &cacheattrs);if (likely (!ret)) {/* * Map a single [sub]page. Regions smaller than our declared
Signature · 1 line
2.25.1
Re: [PATCH v8 41/45] target/arm: Always pass cacheattr to get_phys_addr
Quoted 10 lines · Richard Henderson
We need to check the memattr of a page in order to determine whether it is Tagged for MTE. Between Stage1 and Stage2, this becomes simpler if we always collect this data, instead of occasionally being presented with NULL.
Use the nonnull attribute to allow the compiler to check that all pointer arguments are non-null.
Signed-off-by Richard Henderson <[email protected]>
thanks
-- PMM
PATCH v8 42/45 target/arm: Cache the Tagged bit for a page in MemTxAttrs
In reply to Richard HendersonThis "bit" is a particular value of the page's MemAttr.
---
v6: Test HCR_EL2.{DC,DCT}; test Stage2 attributes.
v8: Fill in cacheattrs for S1 disabled; retain tagging when
combining attributes; set mte_tagging in arm_cpu_tlb_fill.
--- target/arm/helper.c | 48 ++++++++++++++++++++++++++++++++++++++--- target/arm/tlb_helper.c | 5 +++++ 2 files changed, 50 insertions(+), 3 deletions(-)
target/arm/helper.c +45 -3
@@ -11834,9 +11834,19 @@ static uint8_t combine_cacheattr_nibble(uint8_t s1, uint8_t s2)*/ static ARMCacheAttrs combine_cacheattrs (ARMCacheAttrs s1,ARMCacheAttrs s2) { -uint8_t s1lo =extract32 (s1.attrs,0 ,4 ), s2lo =extract32 (s2.attrs,0 ,4 ); -uint8_t s1hi =extract32 (s1.attrs,4 ,4 ), s2hi =extract32 (s2.attrs,4 ,4 ); +uint8_t s1lo, s2lo, s1hi, s2hi;ARMCacheAttrs ret; +bool tagged = false; + +if (s1.attrs ==0xf0 ) { + tagged = true; + s1.attrs =0xff ; + } + + s1lo =extract32 (s1.attrs,0 ,4 ); + s2lo =extract32 (s2.attrs,0 ,4 ); + s1hi =extract32 (s1.attrs,4 ,4 ); + s2hi =extract32 (s2.attrs,4 ,4 );/* Combine shareability attributes (table D4-43) */ if (s1.shareability ==2 || s2.shareability ==2 ) {
@@ -11884,6 +11894,11 @@ static ARMCacheAttrs combine_cacheattrs(ARMCacheAttrs s1, ARMCacheAttrs s2) } } +/* TODO: CombineS1S2Desc does not consider transient, only WB, RWA. */ +if (tagged && ret.attrs ==0xff ) { + ret.attrs =0xf0 ; + } +return ret; }
@@ -11963,8 +11978,11 @@ bool get_phys_addr(CPUARMState *env, target_ulong address,* Normal Non-Shareable, * Inner Write-Back Read-Allocate Write-Allocate, * Outer Write-Back Read-Allocate Write-Allocate. +* Do not overwrite Tagged within attrs. */ - cacheattrs->attrs =0xff ; +if (cacheattrs->attrs !=0xf0 ) { + cacheattrs->attrs =0xff ; + } cacheattrs->shareability =0 ; } *cacheattrs =combine_cacheattrs (*cacheattrs, cacheattrs2);
@@ -12029,6 +12047,9 @@ bool get_phys_addr(CPUARMState *env, target_ulong address,/* Definitely a real MMU, not an MPU */ if (regime_translation_disabled (env, mmu_idx)) { +uint64_t hcr; +uint8_t memattr; +/* * MMU disabled. S1 addresses within aa64 translation regimes are * still checked for bounds -- see AArch64.TranslateAddressS1Off.
@@ -12066,6 +12087,27 @@ bool get_phys_addr(CPUARMState *env, target_ulong address, *phys_ptr = address; *prot =PAGE_READ |PAGE_WRITE |PAGE_EXEC ; *page_size =TARGET_PAGE_SIZE ; + +/* Fill in cacheattr a-la AArch64.TranslateAddressS1Off. */ + hcr =arm_hcr_el2_eff (env); + cacheattrs->shareability =0 ; +if (hcr &HCR_DC ) { +if (hcr &HCR_DCT ) { + memattr =0xf0 ;/* Tagged, Normal, WB, RWA */ + }else { + memattr =0xff ;/* Normal, WB, RWA */ + } + }else if (access_type ==MMU_INST_FETCH ) { +if (regime_sctlr (env, mmu_idx) &SCTLR_I ) { + memattr =0xee ;/* Normal, WT, RA, NT */ + }else { + memattr =0x44 ;/* Normal, NC, No */ + } + cacheattrs->shareability =2 ;/* outersharable */ + }else { + memattr =0x00 ;/* Device, nGnRnE */ + } + cacheattrs->attrs = memattr;return 0 ; }
target/arm/tlb_helper.c +5 -0
@@ -188,6 +188,11 @@ bool arm_cpu_tlb_fill(CPUState *cs, vaddr address, int size, phys_addr &=TARGET_PAGE_MASK ; address &=TARGET_PAGE_MASK ; } +/* Notice and record tagged memory. */ +if (cpu_isar_feature (aa64_mte, cpu) && cacheattrs.attrs ==0xf0 ) { +arm_tlb_mte_tagged (&attrs) = true; + } +tlb_set_page_with_attrs (cs, address, phys_addr, attrs, prot, mmu_idx, page_size);return true;
Signature · 1 line
2.25.1
Re: [PATCH v8 42/45] target/arm: Cache the Tagged bit for a page in MemTxAttrs
Quoted 13 lines · Richard Henderson
This "bit" is a particular value of the page's MemAttr.
Signed-off-by Richard Henderson <[email protected]>---
v6: Test HCR_EL2.{DC,DCT}; test Stage2 attributes.
v8: Fill in cacheattrs for S1 disabled; retain tagging when
combining attributes; setmte_tagginginarm_cpu_tlb_fill.--- target/arm/helper.c | 48 ++++++++++++++++++++++++++++++++++++++--- target/arm/tlb_helper.c | 5 +++++ 2 files changed, 50 insertions(+), 3 deletions(-)
target/arm/helper.c bool get_phys_addr(CPUARMState *env, target_ulong address, · line 12106
Quoted 7 lines
target/arm/helper.c +7
-0+ }else if (access_type ==MMU_INST_FETCH ) { +if (regime_sctlr (env, mmu_idx) &SCTLR_I ) { + memattr =0xee ;/* Normal, WT, RA, NT */ + }else { + memattr =0x44 ;/* Normal, NC, No */ + } + cacheattrs->shareability =2 ;/* outersharable */
"outer shareable"
Otherwise
thanks
-- PMM
PATCH v8 43/45 target/arm: Create tagged ram when MTE is enabled
In reply to Richard Henderson---
v5: Assign cs->num_ases to the final value first.
Downgrade to ID_AA64PFR1.MTE=1 if tag memory is not available.
v6: Add secure tag memory for EL3.
v8: Add arm,armv8.5-memtag.
--- include/hw/arm/boot.h | 3 +++ target/arm/cpu.h | 6 +++++ hw/arm/boot.c | 12 ++++++--- hw/arm/virt.c | 57 +++++++++++++++++++++++++++++++++++++++++-- target/arm/cpu.c | 51 +++++++++++++++++++++++++++++++++++--- 5 files changed, 121 insertions(+), 8 deletions(-)
include/hw/arm/boot.h +3 -0
@@ -116,6 +116,9 @@ struct arm_boot_info {*/ bool secure_board_setup; +/* If set, all ram objects have tag memory objects. */ +bool tag_memory; +arm_endianness endianness; };
target/arm/cpu.h +6 -0
@@ -792,6 +792,10 @@ struct ARMCPU {/* MemoryRegion to use for secure physical accesses */ MemoryRegion *secure_memory; +/* MemoryRegion to use for allocation tag accesses */ +MemoryRegion *tag_memory; +MemoryRegion *secure_tag_memory; +/* For v8M, pointer to the IDAU interface provided by board/SoC */ Object *idau;
@@ -2985,6 +2989,8 @@ typedef enum ARMMMUIdxBit {typedef enum ARMASIdx { ARMASIdx_NS =0 , ARMASIdx_S =1 , + ARMASIdx_TagNS =2 , + ARMASIdx_TagS =3 , }ARMASIdx ;/* Return the Exception Level targeted by debug exceptions. */
hw/arm/boot.c +9 -3
@@ -427,7 +427,7 @@ static void set_kernel_args_old(const struct arm_boot_info *info,static int fdt_add_memory_node (void *fdt,uint32_t acells,hwaddr mem_base,uint32_t scells,hwaddr mem_len, -int numa_node_id) +int numa_node_id,bool tag_memory) {char *nodename;int ret;
@@ -446,6 +446,10 @@ static int fdt_add_memory_node(void *fdt, uint32_t acells, hwaddr mem_base, ret =qemu_fdt_setprop_cell (fdt, nodename,"numa-node-id" , numa_node_id); } +if (tag_memory) { +qemu_fdt_setprop (fdt, nodename,"arm,armv8.5-memtag" ,"" ,0 ); + } + out:g_free (nodename);return ret;
@@ -534,6 +538,7 @@ int arm_load_dtb(hwaddr addr, const struct arm_boot_info *binfo,hwaddr mem_base, mem_len;char **node_path;Error *err =NULL ; +bool tag_memory;if (binfo->dtb_filename) {char *filename;
@@ -599,12 +604,13 @@ int arm_load_dtb(hwaddr addr, const struct arm_boot_info *binfo, }g_strfreev (node_path); + tag_memory = binfo->tag_memory;if (ms->numa_state !=NULL && ms->numa_state->num_nodes >0 ) { mem_base = binfo->loader_start;for (i =0 ; i < ms->numa_state->num_nodes; i++) { mem_len = ms->numa_state->nodes[i].node_mem; rc =fdt_add_memory_node (fdt, acells, mem_base, - scells, mem_len, i); + scells, mem_len, i, tag_memory);if (rc <0 ) {fprintf (stderr,"couldn't add /memory@%" PRIx64" node\n" , mem_base);
@@ -615,7 +621,7 @@ int arm_load_dtb(hwaddr addr, const struct arm_boot_info *binfo, } }else { rc =fdt_add_memory_node (fdt, acells, binfo->loader_start, - scells, binfo->ram_size,-1 ); + scells, binfo->ram_size,-1 , tag_memory);if (rc <0 ) {fprintf (stderr,"couldn't add /memory@%" PRIx64" node\n" , binfo->loader_start);
hw/arm/virt.c +55 -2
91 lines not on this page · raw message
target/arm/cpu.c +48 -3
71 lines not on this page · raw message
Signature · 1 line
2.25.1
Re: [PATCH v8 43/45] target/arm: Create tagged ram when MTE is enabled
hw/arm/boot.c static int fdt_add_memory_node(void *fdt, uint32_t acells, hwaddr mem_base, · line 451
Quoted 11 lines · Richard Henderson
Signed-off-by Richard Henderson <[email protected]>---
v5: Assigncs->num_asesto the final value first.
Downgrade to ID_AA64PFR1.MTE=1 if tag memory is not available.
v6: Add secure tag memory for EL3.
v8: Add arm,armv8.5-memtag.hw/arm/boot.c +3
-0+if (tag_memory) { +qemu_fdt_setprop (fdt, nodename,"arm,armv8.5-memtag" ,"" ,0 ); + }
Catalin mentioned in a recent email that the plan is not to require the dt to specify whether memory nodes support tags. Could we keep the dtb-modification parts in a separate patch so it's easier to drop them (or to commit the actual emulation support first and the dtb changes later), please?
thanks
-- PMM
PATCH v8 44/45 target/arm: Add allocation tag storage for system mode
In reply to Richard HendersonLook up the physical address for the given virtual address, convert that to a tag physical address, and finally return the host address that backs it.
--- target/arm/mte_helper.c | 126 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 126 insertions(+)
target/arm/mte_helper.c +126 -0
@@ -21,6 +21,7 @@#include "cpu.h" #include "internals.h" #include "exec/exec-all.h" +#include "exec/ram_addr.h" #include "exec/cpu_ldst.h" #include "exec/helper-proto.h"
@@ -74,8 +75,133 @@ static uint8_t *allocation_tag_mem(CPUARMState *env, int ptr_mmu_idx, int ptr_size, MMUAccessType tag_access, int tag_size, uintptr_t ra) { +#ifdef CONFIG_USER_ONLY/* Tag storage not implemented. */ return NULL; +#else +uintptr_t index; +CPUIOTLBEntry *iotlbentry; +int in_page, flags; +ram_addr_t ptr_ra; +hwaddr ptr_paddr, tag_paddr, xlat; +MemoryRegion *mr; +ARMASIdx tag_asi; +AddressSpace *tag_as; +void *host; + +/* +* Probe the first byte of the virtual address. This raises an +* exception for inaccessible pages, and resolves the virtual address +* into the softmmu tlb. +* +* When RA == 0, this is for mte_probe1. The page is expected to be +* valid. Indicate to probe_access_flags no-fault, then assert that +* we received a valid page. +*/ + flags =probe_access_flags (env, ptr, ptr_access, ptr_mmu_idx, + ra ==0 , &host, ra); +assert (!(flags &TLB_INVALID_MASK )); + +/* +* Find the iotlbentry for ptr. This *must* be present in the TLB +* because we just found the mapping. +* TODO: Perhaps there should be a cputlb helper that returns a +* matching tlb entry + iotlb entry. +*/ + index =tlb_index (env, ptr_mmu_idx, ptr); +# ifdef CONFIG_DEBUG_TCG + { +CPUTLBEntry *entry =tlb_entry (env, ptr_mmu_idx, ptr); +target_ulong comparator = (ptr_access ==MMU_DATA_LOAD + ? entry->addr_read + :tlb_addr_write (entry)); +g_assert (tlb_hit (comparator, ptr)); + } +# endif + iotlbentry = &env_tlb (env)->d[ptr_mmu_idx].iotlb[index]; + +/* If the virtual page MemAttr != Tagged, access unchecked. */ +if (!arm_tlb_mte_tagged (&iotlbentry->attrs)) { +return NULL ; + } + +/* If not normal memory, there is no tag storage: access unchecked. */ +if (unlikely (flags &TLB_MMIO )) { +qemu_log_mask (LOG_GUEST_ERROR , +"Page @ 0x%" PRIx64" indicates Tagged Normal memory " +"but is Device memory\n" , ptr); +return NULL ; + } + +/* +* The Normal memory access can extend to the next page. E.g. a single +* 8-byte access to the last byte of a page will check only the last +* tag on the first page. +* Any page access exception has priority over tag check exception. +*/ + in_page = -(ptr |TARGET_PAGE_MASK ); +if (unlikely (ptr_size > in_page)) { +void *ignore; + flags |=probe_access_flags (env, ptr + in_page, ptr_access, + ptr_mmu_idx, false, &ignore, ra); + } + +/* Any debug exception has priority over a tag check exception. */ +if (unlikely (flags &TLB_WATCHPOINT )) { +int wp = ptr_access ==MMU_DATA_LOAD ?BP_MEM_READ :BP_MEM_WRITE ; +cpu_check_watchpoint (env_cpu (env), ptr, ptr_size, + iotlbentry->attrs, wp, ra); + } + +/* +* Find the physical address within the normal mem space. +* The memory region lookup must succeed because TLB_MMIO was +* not set in the cputlb lookup above. +*/ + mr =memory_region_from_host (host, &ptr_ra); +tcg_debug_assert (mr !=NULL ); +tcg_debug_assert (memory_region_is_ram (mr)); + ptr_paddr = ptr_ra; +do { + ptr_paddr += mr->addr; + mr = mr->container; + }while (mr); + +/* Convert to the physical address in tag space. */ + tag_paddr = ptr_paddr >> (LOG2_TAG_GRANULE +1 ); + +/* Look up the address in tag space. */ + tag_asi = iotlbentry->attrs.secure ? ARMASIdx_TagS : ARMASIdx_TagNS; + tag_as =cpu_get_address_space (env_cpu (env), tag_asi); + mr =address_space_translate (tag_as, tag_paddr, &xlat,NULL , + tag_access ==MMU_DATA_STORE , + iotlbentry->attrs); + +/* +* Note that @mr will never be NULL. If there is nothing in the address +* space at @tag_paddr, the translation will return the unallocated memory +* region. For our purposes, the result must be ram. +*/ +if (unlikely (!memory_region_is_ram (mr))) { +/* ??? Failure is a board configuration error. */ +qemu_log_mask (LOG_UNIMP , +"Tag Memory @ 0x%" HWADDR_PRIx" not found for " +"Normal Memory @ 0x%" HWADDR_PRIx"\n" , + tag_paddr, ptr_paddr); +return NULL ; + } + +/* +* Ensure the tag memory is dirty on write, for migration. +* Tag memory can never contain code or display memory (vga). +*/ +if (tag_access ==MMU_DATA_STORE ) { +ram_addr_t tag_ra =memory_region_get_ram_addr (mr) + xlat; +cpu_physical_memory_set_dirty_flag (tag_ra,DIRTY_MEMORY_MIGRATION ); + } + +return memory_region_get_ram_ptr (mr) + xlat; +#endif }uint64_t HELPER (irg )(CPUARMState *env,uint64_t rn,uint64_t rm)
Signature · 1 line
2.25.1
Re: [PATCH v8 44/45] target/arm: Add allocation tag storage for system mode
target/arm/mte_helper.c static uint8_t *allocation_tag_mem(CPUARMState *env, int ptr_mmu_idx, · line 129
Quoted 13 lines · Richard Henderson
Look up the physical address for the given virtual address, convert that to a tag physical address, and finally return the host address that backs it.
Signed-off-by Richard Henderson <[email protected]>--- target/arm/mte_helper.c | 126 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 126 insertions(+)target/arm/mte_helper.c +2
-0+/* If not normal memory, there is no tag storage: access unchecked. */ +if (unlikely (flags &TLB_MMIO )) {
Comment says we're checking a memory attribute, but the code is checking for TLB_MMIO, which isn't the same thing.
thanks
-- PMM
Re: [PATCH v8 44/45] target/arm: Add allocation tag storage for system mode
Quoted 13 lines · Peter Maydell
Quoted 10 lines · Richard Henderson
Look up the physical address for the given virtual address, convert that to a tag physical address, and finally return the host address that backs it.
Signed-off-by Richard Henderson <[email protected]>--- target/arm/mte_helper.c | 126 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 126 insertions(+)
Quoted 5 lines
target/arm/mte_helper.c static uint8_t *allocation_tag_mem(CPUARMState *env, int ptr_mmu_idx, · line 129
Quoted 2 lines
target/arm/mte_helper.c +2
-0+/* If not normal memory, there is no tag storage: access unchecked. */ +if (unlikely (flags &TLB_MMIO )) {Comment says we're checking a memory attribute, but the code is checking for
TLB_MMIO, which isn't the same thing.
Comment is not trying to allude to Normal vs Device, but "ram" vs "mmio" in the qemu sense.
r~
Re: [PATCH v8 44/45] target/arm: Add allocation tag storage for system mode
Quoted 15 lines · Richard Henderson
Quoted 13 lines · Peter Maydell
Quoted 10 lines · Richard Henderson
Look up the physical address for the given virtual address, convert that to a tag physical address, and finally return the host address that backs it.
Signed-off-by Richard Henderson <[email protected]>--- target/arm/mte_helper.c | 126 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 126 insertions(+)
Quoted 8 lines
Quoted 5 lines
target/arm/mte_helper.c static uint8_t *allocation_tag_mem(CPUARMState *env, int ptr_mmu_idx, · line 129
Quoted 2 lines
target/arm/mte_helper.c +2
-0+/* If not normal memory, there is no tag storage: access unchecked. */ +if (unlikely (flags &TLB_MMIO )) {Comment says we're checking a memory attribute, but the code is checking for
TLB_MMIO, which isn't the same thing.Comment is not trying to allude to Normal vs Device, but "ram" vs "mmio" in the qemu sense.
Oh, I see: maybe "if not backed by host RAM, then" ? I tend to assume "normal memory" means "Normal memory" :-)
thanks
-- PMM
Re: [PATCH v8 44/45] target/arm: Add allocation tag storage for system mode
Quoted 8 lines · Peter Maydell
Quoted 5 lines
Quoted 2 lines
Comment says we're checking a memory attribute, but the code is checking for
TLB_MMIO, which isn't the same thing.Comment is not trying to allude to Normal vs Device, but "ram" vs "mmio" in the qemu sense.
Oh, I see: maybe "if not backed by host RAM, then" ? I tend to assume "normal memory" means "Normal memory" :-)
Sure, changed. Also noticed two more places where calling via mte_probe1 should not fault.
r~
Hi Richard,
I am currently doing research with MTE, and Arm's FVP leaves a lot to be desired. Is there some way I can get access to your QEMU changes that enable MTE for system emulation? Thanks.
Quoted 116 lines · Richard Henderson
Version 8 incorporates quite a bit of review (thanks, PMM):
* Include
HCR_DCTin theHCR_EL2update.
* Use a separate decode function for ADDG/SUBG.
* Use the systemarm_cpu_do_unaligned_accessfor user-only as well.
* Fix alignment for LDG.
* Fix no-fault formte_probe1.
* Rearrage how tagged pages are recorded.and perhaps most visibly, for those tracking the kernel patches:
* Add arm,armv8.5-memtag to the dtb.
r~
In need of review:
0010-target-arm-Revise-decoding-for-disas_add_sub_imm.patch 0011-target-arm-Implement-the-ADDG-SUBG-instructions.patch 0014-target-arm-Define-arm_cpu_do_unaligned_access-for.patch 0015-target-arm-Implement-LDG-STG-ST2G-instructions.patch 0025-target-arm-Implement-helper_mte_check1.patch 0028-target-arm-Use-mte_checkN-for-sve-unpredicated-lo.patch 0029-target-arm-Use-mte_checkN-for-sve-unpredicated-st.patch 0030-target-arm-Use-mte_check1-for-sve-LD1R.patch 0031-target-arm-Tidy-trans_LD1R_zpri.patch 0032-target-arm-Add-arm_tlb_bti_gp.patch 0033-target-arm-Add-mte-helpers-for-sve-scalar-int-loa.patch 0034-target-arm-Add-mte-helpers-for-sve-scalar-int-sto.patch 0035-target-arm-Add-mte-helpers-for-sve-scalar-int-ff-.patch 0036-target-arm-Handle-TBI-for-sve-scalar-int-memory-o.patch 0037-target-arm-Add-mte-helpers-for-sve-scatter-gather.patch 0038-target-arm-Complete-TBI-clearing-for-user-only-fo.patch 0041-target-arm-Always-pass-cacheattr-to-get_phys_addr.patch 0042-target-arm-Cache-the-Tagged-bit-for-a-page-in-Mem.patch 0043-target-arm-Create-tagged-ram-when-MTE-is-enabled.patch 0044-target-arm-Add-allocation-tag-storage-for-system-.patch 0045-target-arm-Enable-MTE.patchRichard Henderson (45):
target/arm: Add isar tests for mte
target/arm: Improve masking of SCR RES0 bits target/arm: Add support for MTE toSCTLR_ELxtarget/arm: Add support for MTE toHCR_EL2andSCR_EL3target/arm: RenameDISAS_UPDATEtoDISAS_UPDATE_EXITtarget/arm: AddDISAS_UPDATE_NOCHAIN
target/arm: Add MTE system registers
target/arm: Add MTE bits totb_flags
target/arm: Implement the IRG instruction target/arm: Revise decoding fordisas_add_sub_immtarget/arm: Implement the ADDG, SUBG instructions target/arm: Implement the GMI instruction target/arm: Implement the SUBP instruction target/arm: Definearm_cpu_do_unaligned_accessfor user-only target/arm: Implement LDG, STG, ST2G instructions target/arm: Implement the STGP instruction target/arm: Restrict the values of DCZID.BS under TCG target/arm: SimplifyDC_ZVA
target/arm: Implement the LDGM, STGM, STZGM instructions target/arm: Implement the access tag cache flushes target/arm: Moveregime_eltointernals.htarget/arm: Moveregime_tcrtointernals.htarget/arm: Addgen_mte_check1
target/arm: Addgen_mte_checkN
target/arm: Implementhelper_mte_check1
target/arm: Implementhelper_mte_checkN
target/arm: Addhelper_mte_check_zva
target/arm: Usemte_checkNfor sve unpredicated loads target/arm: Usemte_checkNfor sve unpredicated stores target/arm: Usemte_check1for sve LD1R
target/arm: Tidytrans_LD1R_zpri
target/arm: Addarm_tlb_bti_gp
target/arm: Add mte helpers for sve scalar + int loads target/arm: Add mte helpers for sve scalar + int stores target/arm: Add mte helpers for sve scalar + int ff/nf loads target/arm: Handle TBI for sve scalar + int memory ops target/arm: Add mte helpers for sve scatter/gather memory ops target/arm: Complete TBI clearing for user-only for SVE target/arm: Implement data cache set allocation tags target/arm: Set PSTATE.TCO on exception entry target/arm: Always pass cacheattr toget_phys_addrtarget/arm: Cache the Tagged bit for a page in MemTxAttrs target/arm: Create tagged ram when MTE is enabled target/arm: Add allocation tag storage for system mode target/arm: Enable MTEinclude/hw/arm/boot.h | 3 + target/arm/cpu.h | 50 +- target/arm/helper-a64.h | 16 + target/arm/helper-sve.h | 488 ++++++++++++ target/arm/helper.h | 2 + target/arm/internals.h | 153 +++- target/arm/translate-a64.h | 5 + target/arm/translate.h | 23 +- hw/arm/boot.c | 12 +- hw/arm/virt.c | 57 +- target/arm/cpu.c | 77 +- target/arm/cpu64.c | 1 + target/arm/helper-a64.c | 94 +-- target/arm/helper.c | 423 +++++++--- target/arm/m_helper.c | 11 +- target/arm/mte_helper.c | 901 +++++++++++++++++++++ target/arm/op_helper.c | 16 + target/arm/sve_helper.c | 616 +++++++++++--- target/arm/tlb_helper.c | 13 +- target/arm/translate-a64.c | 652 +++++++++++++-- target/arm/translate-sve.c | 1366 +++++++++++++++++++++----------- target/arm/translate-vfp.inc.c | 2 +- target/arm/translate.c | 16 +- target/arm/Makefile.objs | 1 + 24 files changed, 4164 insertions(+), 834 deletions(-) create mode 100644 target/arm/mte_helper.c
Quoted 4 lines
--
2.25.1
--
Derrick McKee
Phone: (703) 957-9362
Email: [email protected]
Quoted 5 lines · Derrick McKee
Hi Richard,
I am currently doing research with MTE, and Arm's FVP leaves a lot to be desired. Is there some way I can get access to your QEMU changes that enable MTE for system emulation? Thanks.
You can apply this patch set to qemu master. ;-)
But more seriously, this patch set is in the tree at
https://github.com/rth7680/qemu/tree/tgt-arm-mte
r~
Quoted 16 lines
Quoted 13 lines · Richard Henderson
Version 8 incorporates quite a bit of review (thanks, PMM):
* Include
HCR_DCTin theHCR_EL2update.
* Use a separate decode function for ADDG/SUBG.
* Use the systemarm_cpu_do_unaligned_accessfor user-only as well.
* Fix alignment for LDG.
* Fix no-fault formte_probe1.
* Rearrage how tagged pages are recorded.and perhaps most visibly, for those tracking the kernel patches:
* Add arm,armv8.5-memtag to the dtb.
PATCH v8 45/45 target/arm: Enable MTE
In reply to Richard HendersonWe now implement all of the components of MTE, without actually supporting any tagged memory. All MTE instructions will work, trivially, so we can enable support.
---
v6: Delay user-only cpu reset bits to the user-only patch set.
--- target/arm/cpu64.c | 1 + 1 file changed, 1 insertion(+)
target/arm/cpu64.c +1 -0
@@ -654,6 +654,7 @@ static void aarch64_max_initfn(Object *obj) t = cpu->isar.id_aa64pfr1; t =FIELD_DP64 (t,ID_AA64PFR1 ,BT ,1 ); + t =FIELD_DP64 (t,ID_AA64PFR1 ,MTE ,2 ); cpu->isar.id_aa64pfr1 = t; t = cpu->isar.id_aa64mmfr1;
Signature · 1 line
2.25.1
Re: [PATCH v8 45/45] target/arm: Enable MTE
Quoted 17 lines · Richard Henderson
We now implement all of the components of MTE, without actually supporting any tagged memory. All MTE instructions will work, trivially, so we can enable support.
Signed-off-by Richard Henderson <[email protected]>---
v6: Delay user-only cpu reset bits to the user-only patch set.--- target/arm/cpu64.c | 1 + 1 file changed, 1 insertion(+)target/arm/cpu64.c +0
-0
target/arm/cpu64.c static void aarch64_max_initfn(Object *obj) · line 658
Quoted 5 lines
target/arm/cpu64.c +1
-0@@ -654,6 +654,7 @@ static void aarch64_max_initfn(Object *obj) t = cpu->isar.id_aa64pfr1; t =FIELD_DP64 (t,ID_AA64PFR1 ,BT ,1 ); + t =FIELD_DP64 (t,ID_AA64PFR1 ,MTE ,2 ); cpu->isar.id_aa64pfr1 = t;
Worth a brief comment
/* Will be downgraded to 1 if board provides no tag memory */
?
Otherwise
thanks
-- PMM
Patchew URL: https://patchew.org/QEMU/[email protected]/
Patchew URL: https://patchew.org/QEMU/[email protected]/
Hi,
This series seems to have some coding style problems. See output below for more information:
Subject: [PATCH v8 00/45] target/arm: Implement ARMv8.5-MemTag, system mode
Type: series
Message-id: [email protected]
=== TEST SCRIPT BEGIN ===
#!/bin/bash
git rev-parse base > /dev/null || exit 0
git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram./scripts/checkpatch.pl --mailback base..
=== TEST SCRIPT END ===
From https://github.com/patchew-project/qemu
* [new tag] patchew/[email protected] -> patchew/[email protected]
Switched to a new branch 'test'
1231ec5 target/arm: Enable MTE
caf48f0 target/arm: Add allocation tag storage for system mode 86926ba target/arm: Create tagged ram when MTE is enabled dc24d39 target/arm: Cache the Tagged bit for a page in MemTxAttrs b3fdcfe target/arm: Always pass cacheattr to get_phys_addr 52dae54 target/arm: Set PSTATE.TCO on exception entry 9d92dcf target/arm: Implement data cache set allocation tags 985b40f target/arm: Complete TBI clearing for user-only for SVE d22a925 target/arm: Add mte helpers for sve scatter/gather memory ops 26d1ba5 target/arm: Handle TBI for sve scalar + int memory ops 5dc33b2 target/arm: Add mte helpers for sve scalar + int ff/nf loads 457edf5 target/arm: Add mte helpers for sve scalar + int stores 7e68033 target/arm: Add mte helpers for sve scalar + int loads df0ee49 target/arm: Add arm_tlb_bti_gp
46870d1 target/arm: Tidy trans_LD1R_zpri
661859f target/arm: Use mte_check1 for sve LD1R
c067218 target/arm: Use mte_checkN for sve unpredicated stores abbc5d1 target/arm: Use mte_checkN for sve unpredicated loads da2c53d target/arm: Add helper_mte_check_zva
a947bd3 target/arm: Implement helper_mte_checkN
017e09e target/arm: Implement helper_mte_check1
060a546 target/arm: Add gen_mte_checkN
349cca3 target/arm: Add gen_mte_check1
bcb99d2 target/arm: Move regime_tcr to internals.h
3e1b548 target/arm: Move regime_el to internals.h
e03f1b4 target/arm: Implement the access tag cache flushes d6ad4b5 target/arm: Implement the LDGM, STGM, STZGM instructions e16594d target/arm: Simplify DC_ZVA
dc1d79a target/arm: Restrict the values of DCZID.BS under TCG 1291525 target/arm: Implement the STGP instruction
1b4d84d target/arm: Implement LDG, STG, ST2G instructions 54c306b target/arm: Define arm_cpu_do_unaligned_access for user-only 56adc0c target/arm: Implement the SUBP instruction
e1d7cf7 target/arm: Implement the GMI instruction
2890f30 target/arm: Implement the ADDG, SUBG instructions 912b9bf target/arm: Revise decoding for disas_add_sub_imm 63945d2 target/arm: Implement the IRG instruction
22de2b3 target/arm: Add MTE bits to tb_flags
45f22ac target/arm: Add MTE system registers
2fbb1da target/arm: Add DISAS_UPDATE_NOCHAIN
e4d0611 target/arm: Rename DISAS_UPDATE to DISAS_UPDATE_EXIT d0f228b target/arm: Add support for MTE to HCR_EL2 and SCR_EL3 a5b3055 target/arm: Add support for MTE to SCTLR_ELx abdfb70 target/arm: Improve masking of SCR RES0 bits 40707f0 target/arm: Add isar tests for mte
=== OUTPUT BEGIN ===
1/45 Checking commit 40707f09f121 (target/arm: Add isar tests for mte)
2/45 Checking commit abdfb70dea3d (target/arm: Improve masking of SCR RES0 bits) 3/45 Checking commit a5b305518974 (target/arm: Add support for MTE to SCTLR_ELx) 4/45 Checking commit d0f228b9f5f4 (target/arm: Add support for MTE to HCR_EL2 and SCR_EL3) 5/45 Checking commit e4d06118aebc (target/arm: Rename DISAS_UPDATE to DISAS_UPDATE_EXIT) 6/45 Checking commit 2fbb1dafd99c (target/arm: Add DISAS_UPDATE_NOCHAIN) 7/45 Checking commit 45f22acdd599 (target/arm: Add MTE system registers) 8/45 Checking commit 22de2b35721f (target/arm: Add MTE bits to tb_flags) 9/45 Checking commit 63945d282302 (target/arm: Implement the IRG instruction)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #45:
new file mode 100644
total: 0 errors, 1 warnings, 120 lines checked
Patch 9/45 has style problems, please review. If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
10/45 Checking commit 912b9bf152c9 (target/arm: Revise decoding for disas_add_sub_imm) 11/45 Checking commit 2890f308b67c (target/arm: Implement the ADDG, SUBG instructions) 12/45 Checking commit e1d7cf7b3195 (target/arm: Implement the GMI instruction) 13/45 Checking commit 56adc0c58443 (target/arm: Implement the SUBP instruction) 14/45 Checking commit 54c306b84778 (target/arm: Define arm_cpu_do_unaligned_access for user-only) 15/45 Checking commit 1b4d84d4bf40 (target/arm: Implement LDG, STG, ST2G instructions) 16/45 Checking commit 129152540330 (target/arm: Implement the STGP instruction) 17/45 Checking commit dc1d79a46ea9 (target/arm: Restrict the values of DCZID.BS under TCG) 18/45 Checking commit e16594db4ee6 (target/arm: Simplify DC_ZVA)
19/45 Checking commit d6ad4b51f761 (target/arm: Implement the LDGM, STGM, STZGM instructions) 20/45 Checking commit e03f1b492eb8 (target/arm: Implement the access tag cache flushes) 21/45 Checking commit 3e1b548f5665 (target/arm: Move regime_el to internals.h) 22/45 Checking commit bcb99d2cb0d5 (target/arm: Move regime_tcr to internals.h) 23/45 Checking commit 349cca39015e (target/arm: Add gen_mte_check1)
24/45 Checking commit 060a546b2de1 (target/arm: Add gen_mte_checkN)
25/45 Checking commit 017e09edd952 (target/arm: Implement helper_mte_check1)
26/45 Checking commit a947bd38a095 (target/arm: Implement helper_mte_checkN)
27/45 Checking commit da2c53dcc0e2 (target/arm: Add helper_mte_check_zva)
28/45 Checking commit abbc5d1dd1f3 (target/arm: Use mte_checkN for sve unpredicated loads) 29/45 Checking commit c067218f4474 (target/arm: Use mte_checkN for sve unpredicated stores) 30/45 Checking commit 661859ff9984 (target/arm: Use mte_check1 for sve LD1R)
31/45 Checking commit 46870d1ed93b (target/arm: Tidy trans_LD1R_zpri)
32/45 Checking commit df0ee49681ee (target/arm: Add arm_tlb_bti_gp)
33/45 Checking commit 7e68033a5c5e (target/arm: Add mte helpers for sve scalar + int loads) 34/45 Checking commit 457edf568b72 (target/arm: Add mte helpers for sve scalar + int stores) 35/45 Checking commit 5dc33b2a8bb2 (target/arm: Add mte helpers for sve scalar + int ff/nf loads) 36/45 Checking commit 26d1ba548fc0 (target/arm: Handle TBI for sve scalar + int memory ops) 37/45 Checking commit d22a9255942c (target/arm: Add mte helpers for sve scatter/gather memory ops) 38/45 Checking commit 985b40fb259c (target/arm: Complete TBI clearing for user-only for SVE)
ERROR: spaces required around that '*' (ctx:VxV)
#42: FILE: target/arm/sve_helper.c:3978:
+ (TYPEM)*(TYPEE *)(vd + H(reg_off)), ra); \
^total: 1 errors, 0 warnings, 37 lines checked
Patch 38/45 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
39/45 Checking commit 9d92dcf8187b (target/arm: Implement data cache set allocation tags) 40/45 Checking commit 52dae54ca0f4 (target/arm: Set PSTATE.TCO on exception entry) 41/45 Checking commit b3fdcfe39e1d (target/arm: Always pass cacheattr to get_phys_addr) 42/45 Checking commit dc24d3963608 (target/arm: Cache the Tagged bit for a page in MemTxAttrs) 43/45 Checking commit 86926ba74d36 (target/arm: Create tagged ram when MTE is enabled) 44/45 Checking commit caf48f000954 (target/arm: Add allocation tag storage for system mode) 45/45 Checking commit 1231ec5cb04a (target/arm: Enable MTE)
=== OUTPUT END ===
Test command exited with code: 1
The full log is available at
http://patchew.org/logs/[email protected]/testing.checkpatch/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to [email protected]
Quoted 9 lines · Richard Henderson
Version 8 incorporates quite a bit of review (thanks, PMM):
* Include
HCR_DCTin theHCR_EL2update.
* Use a separate decode function for ADDG/SUBG.
* Use the systemarm_cpu_do_unaligned_accessfor user-only as well.
* Fix alignment for LDG.
* Fix no-fault formte_probe1.
* Rearrage how tagged pages are recorded.
I think I've reviewed everything that didn't already have review now.
thanks
-- PMM