Message ID | 20210115224645.1196742-21-richard.henderson@linaro.org |
---|---|
State | New |
Headers | show |
Series | target-arm: Implement ARMv8.5-MemTag, user mode | expand |
On Fri, 15 Jan 2021 at 22:47, Richard Henderson <richard.henderson@linaro.org> wrote: > > Signed-off-by: Richard Henderson <richard.henderson@linaro.org> > --- > target/arm/cpu.c | 16 ++++++++++++++++ > 1 file changed, 16 insertions(+) > > diff --git a/target/arm/cpu.c b/target/arm/cpu.c > index abc0affd00..5e613a747a 100644 > --- a/target/arm/cpu.c > +++ b/target/arm/cpu.c > @@ -208,6 +208,22 @@ static void arm_cpu_reset(DeviceState *dev) > * Do not modify this without other changes. > */ > env->cp15.tcr_el[1].raw_tcr = (3ULL << 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; > + } > + > # ifdef TARGET_TAGGED_ADDRESSES > env->untagged_addr_mask = -1; > # endif > -- Reviewed-by: Peter Maydell <peter.maydell@linaro.org> thanks -- PMM
diff --git a/target/arm/cpu.c b/target/arm/cpu.c index abc0affd00..5e613a747a 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -208,6 +208,22 @@ static void arm_cpu_reset(DeviceState *dev) * Do not modify this without other changes. */ env->cp15.tcr_el[1].raw_tcr = (3ULL << 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; + } + # ifdef TARGET_TAGGED_ADDRESSES env->untagged_addr_mask = -1; # endif
Signed-off-by: Richard Henderson <richard.henderson@linaro.org> --- target/arm/cpu.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) -- 2.25.1