From d044062b26e2f2b429d6cbde9c102db851da6742 Mon Sep 17 00:00:00 2001 From: Richard Henderson Date: Thu, 4 Mar 2021 18:46:45 -0500 Subject: [PATCH] target/arm: Enable MTE for user-only Backports e32328645ed6fc4f20f0164dfc9ce1bf7e667cc4 --- qemu/target/arm/cpu.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/qemu/target/arm/cpu.c b/qemu/target/arm/cpu.c index dcdd0092..989e1006 100644 --- a/qemu/target/arm/cpu.c +++ b/qemu/target/arm/cpu.c @@ -201,6 +201,21 @@ static void arm_cpu_reset(CPUState *s) * Note that this must match useronly_clean_ptr. */ env->cp15.tcr_el[1].raw_tcr = (1ULL << 37); + + /* Enable MTE */ + if (cpu_isar_feature(aa64_mte, cpu)) { + /* Enable tag access, but leave TCF0 as No Effect (0). */ + env->cp15.sctlr_el[1] |= SCTLR_ATA0; + /* + * Exclude all tags, so that tag 0 is always used. + * This corresponds to Linux current->thread.gcr_incl = 0. + * + * Set RRND, so that helper_irg() will generate a seed later. + * Here in cpu_reset(), the crypto subsystem has not yet been + * initialized. + */ + env->cp15.gcr_el1 = 0x1ffff; + } #else /* Reset into the highest available EL */ if (arm_feature(env, ARM_FEATURE_EL3)) {