[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 16/17] target/arm: Enable MTE for user-only
From: |
Richard Henderson |
Subject: |
[PATCH v2 16/17] target/arm: Enable MTE for user-only |
Date: |
Thu, 4 Jun 2020 21:17:32 -0700 |
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
target/arm/cpu.c | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/target/arm/cpu.c b/target/arm/cpu.c
index 37b7cc2c9c..6395918524 100644
--- a/target/arm/cpu.c
+++ b/target/arm/cpu.c
@@ -39,6 +39,7 @@
#include "kvm_arm.h"
#include "disas/capstone.h"
#include "fpu/softfloat.h"
+#include "qemu/guest-random.h"
static void arm_cpu_set_pc(CPUState *cs, vaddr value)
{
@@ -191,6 +192,22 @@ static void arm_cpu_reset(DeviceState *dev)
/* Enable all PAC keys. */
env->cp15.sctlr_el[1] |= (SCTLR_EnIA | SCTLR_EnIB |
SCTLR_EnDA | SCTLR_EnDB);
+ /* 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.
+ */
+ env->cp15.gcr_el1 = 0xffff;
+ /* If RGSR == 0, NextRandomTagBit will always produce 0. */
+ do {
+ qemu_guest_getrandom_nofail(&env->cp15.rgsr_el1,
+ sizeof(env->cp15.rgsr_el1));
+ env->cp15.rgsr_el1 &= 0xffff0fu;
+ } while (env->cp15.rgsr_el1 == 0);
+ }
/* and to the FP/Neon instructions */
env->cp15.cpacr_el1 = deposit64(env->cp15.cpacr_el1, 20, 2, 3);
/* and to the SVE instructions */
--
2.25.1
- [PATCH v2 07/17] linux-user: Fix guest_addr_valid vs reserved_va, (continued)
- [PATCH v2 07/17] linux-user: Fix guest_addr_valid vs reserved_va, Richard Henderson, 2020/06/05
- [PATCH v2 10/17] linux-user/aarch64: Implement PR_MTE_TCF and PR_MTE_TAG, Richard Henderson, 2020/06/05
- [PATCH v2 11/17] linux-user/aarch64: Implement PROT_MTE, Richard Henderson, 2020/06/05
- [PATCH v2 12/17] linux-user/aarch64: Pass syndrome to EXC_*_ABORT, Richard Henderson, 2020/06/05
- [PATCH v2 14/17] linux-user/aarch64: Signal SEGV_MTEAERR for async tag check error, Richard Henderson, 2020/06/05
- [PATCH v2 13/17] linux-user/aarch64: Signal SEGV_MTESERR for sync tag check fault, Richard Henderson, 2020/06/05
- [PATCH v2 16/17] target/arm: Enable MTE for user-only,
Richard Henderson <=
- [PATCH v2 15/17] target/arm: Add allocation tag storage for user mode, Richard Henderson, 2020/06/05
- [PATCH v2 17/17] tests/tcg/aarch64: Add mte smoke tests, Richard Henderson, 2020/06/05
- Re: [PATCH v2 00/17] target-arm: Implement ARMv8.5-MemTag, user mode, Peter Maydell, 2020/06/25