@samitouri / QOSamiQemu / commits / bb5c28962f

target/arm: add TCSO bitmasks to SCTLR

These are the bitmasks used to control the FEAT_MTE_STORE_ONLY feature. They are now named and setting these fields of SCTLR is ignored if MTE or MTE4 is disabled, as per convention. Signed-off-by: Gabriel Brookman <brookmangabriel@gmail.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Message-id: 20260529-feat-mte4-v7-2-ccbd3c14eb3c@gmail.com Signed-off-by: Peter Maydell <peter.maydell@linaro.org>

Gabriel Brookman committed May 29, 2026 at 12:52 UTC bb5c28962fdb18b225e018fa6aae61c3c6644112
3 files changed +21 -6
target/arm/cpu-features.h
+5
@@ -1196,6 +1196,11 @@ static inline bool isar_feature_aa64_mteperm(const ARMISARegisters *id)
1196 return FIELD_EX64_IDREG(id, ID_AA64PFR2, MTEPERM) >= 1;
1197 }
1198
1199 +static inline bool isar_feature_aa64_mte_store_only(const ARMISARegisters *id)
1200 +{
1201 + return FIELD_EX64_IDREG(id, ID_AA64PFR2, MTESTOREONLY) == 1;
1202 +}
1203 +
1204 static inline bool isar_feature_aa64_sme(const ARMISARegisters *id)
1205 {
1206 return FIELD_EX64_IDREG(id, ID_AA64PFR1, SME) != 0;
target/arm/cpu.h
+2
@@ -1468,6 +1468,8 @@ void pmu_init(ARMCPU *cpu);
1468 #define SCTLR_EnAS0 (1ULL << 55) /* FEAT_LS64_ACCDATA */
1469 #define SCTLR_EnALS (1ULL << 56) /* FEAT_LS64 */
1470 #define SCTLR_EPAN (1ULL << 57) /* FEAT_PAN3 */
1471 +#define SCTLR_TCSO0 (1ULL << 58) /* FEAT_MTE_STORE_ONLY */
1472 +#define SCTLR_TCSO (1ULL << 59) /* FEAT_MTE_STORE_ONLY */
1473 #define SCTLR_EnTP2 (1ULL << 60) /* FEAT_SME */
1474 #define SCTLR_NMI (1ULL << 61) /* FEAT_NMI */
1475 #define SCTLR_SPINTMASK (1ULL << 62) /* FEAT_NMI */
target/arm/helper.c
+14 -6
@@ -3300,12 +3300,20 @@ static void sctlr_write(CPUARMState *env, const ARMCPRegInfo *ri,
3300
3301 /* ??? Lots of these bits are not implemented. */
3302
3303 - if (ri->state == ARM_CP_STATE_AA64 && !cpu_isar_feature(aa64_mte, cpu)) {
3304 - if (ri->opc1 == 6) { /* SCTLR_EL3 */
3305 - value &= ~(SCTLR_ITFSB | SCTLR_TCF | SCTLR_ATA);
3306 - } else {
3307 - value &= ~(SCTLR_ITFSB | SCTLR_TCF0 | SCTLR_TCF |
3308 - SCTLR_ATA0 | SCTLR_ATA);
3303 + if (ri->state == ARM_CP_STATE_AA64) {
3304 + if (!cpu_isar_feature(aa64_mte, cpu)) {
3305 + if (ri->opc1 == 6) { /* SCTLR_EL3 */
3306 + value &= ~(SCTLR_ITFSB | SCTLR_TCF | SCTLR_ATA | SCTLR_TCSO);
3307 + } else {
3308 + value &= ~(SCTLR_ITFSB | SCTLR_TCF0 | SCTLR_TCF |
3309 + SCTLR_ATA0 | SCTLR_ATA | SCTLR_TCSO | SCTLR_TCSO0);
3310 + }
3311 + } else if (!cpu_isar_feature(aa64_mte_store_only, cpu)) { /* not mte4 */
3312 + if (ri->opc1 == 6) { /* SCTLR_EL3 */
3313 + value &= ~SCTLR_TCSO;
3314 + } else {
3315 + value &= ~(SCTLR_TCSO | SCTLR_TCSO0);
3316 + }
3317 }
3318 }
3319