[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v6 29/31] target/arm: Add allocation tag storage for user mode
From: |
Richard Henderson |
Subject: |
[PATCH v6 29/31] target/arm: Add allocation tag storage for user mode |
Date: |
Tue, 9 Feb 2021 16:02:21 -0800 |
Use the now-saved PAGE_ANON and PAGE_MTE bits,
and the per-page saved data.
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
target/arm/mte_helper.c | 29 +++++++++++++++++++++++++++--
1 file changed, 27 insertions(+), 2 deletions(-)
diff --git a/target/arm/mte_helper.c b/target/arm/mte_helper.c
index d55f8d1e1e..1c569336ea 100644
--- a/target/arm/mte_helper.c
+++ b/target/arm/mte_helper.c
@@ -78,8 +78,33 @@ static uint8_t *allocation_tag_mem(CPUARMState *env, int
ptr_mmu_idx,
int tag_size, uintptr_t ra)
{
#ifdef CONFIG_USER_ONLY
- /* Tag storage not implemented. */
- return NULL;
+ uint64_t clean_ptr = useronly_clean_ptr(ptr);
+ int flags = page_get_flags(clean_ptr);
+ uint8_t *tags;
+ uintptr_t index;
+
+ if (!(flags & (ptr_access == MMU_DATA_STORE ? PAGE_WRITE : PAGE_READ))) {
+ /* SIGSEGV */
+ arm_cpu_tlb_fill(env_cpu(env), ptr, ptr_size, ptr_access,
+ ptr_mmu_idx, false, ra);
+ g_assert_not_reached();
+ }
+
+ /* Require both MAP_ANON and PROT_MTE for the page. */
+ if (!(flags & PAGE_ANON) || !(flags & PAGE_MTE)) {
+ return NULL;
+ }
+
+ tags = page_get_target_data(clean_ptr);
+ if (tags == NULL) {
+ size_t alloc_size = TARGET_PAGE_SIZE >> (LOG2_TAG_GRANULE + 1);
+ tags = page_alloc_target_data(clean_ptr, alloc_size);
+ assert(tags != NULL);
+ }
+
+ index = extract32(ptr, LOG2_TAG_GRANULE + 1,
+ TARGET_PAGE_BITS - LOG2_TAG_GRANULE - 1);
+ return tags + index;
#else
uintptr_t index;
CPUIOTLBEntry *iotlbentry;
--
2.25.1
- [PATCH v6 12/31] exec: Use cpu_untagged_addr in g2h; split out g2h_untagged, (continued)
- [PATCH v6 12/31] exec: Use cpu_untagged_addr in g2h; split out g2h_untagged, Richard Henderson, 2021/02/09
- [PATCH v6 10/31] linux-user: Fix guest_addr_valid vs reserved_va, Richard Henderson, 2021/02/09
- [PATCH v6 11/31] exec: Introduce cpu_untagged_addr, Richard Henderson, 2021/02/09
- [PATCH v6 16/31] linux-user: Use cpu_untagged_addr in access_ok; split out *_untagged, Richard Henderson, 2021/02/09
- [PATCH v6 18/31] linux-user: Fix types in uaccess.c, Richard Henderson, 2021/02/09
- [PATCH v6 15/31] exec: Rename guest_{addr,range}_valid to *_untagged, Richard Henderson, 2021/02/09
- [PATCH v6 17/31] linux-user: Move lock_user et al out of line, Richard Henderson, 2021/02/09
- [PATCH v6 20/31] linux-user/aarch64: Implement PR_TAGGED_ADDR_ENABLE, Richard Henderson, 2021/02/09
- [PATCH v6 30/31] target/arm: Enable MTE for user-only, Richard Henderson, 2021/02/09
- [PATCH v6 27/31] linux-user/aarch64: Signal SEGV_MTESERR for sync tag check fault, Richard Henderson, 2021/02/09
- [PATCH v6 29/31] target/arm: Add allocation tag storage for user mode,
Richard Henderson <=
- [PATCH v6 31/31] tests/tcg/aarch64: Add mte smoke tests, Richard Henderson, 2021/02/09
- [PATCH v6 23/31] linux-user/aarch64: Implement PR_MTE_TCF and PR_MTE_TAG, Richard Henderson, 2021/02/09
- [PATCH v6 19/31] linux-user: Handle tags in lock_user/unlock_user, Richard Henderson, 2021/02/09
- [PATCH v6 22/31] target/arm: Use the proper TBI settings for linux-user, Richard Henderson, 2021/02/09
- [PATCH v6 24/31] linux-user/aarch64: Implement PROT_MTE, Richard Henderson, 2021/02/09
- [PATCH v6 21/31] target/arm: Improve gen_top_byte_ignore, Richard Henderson, 2021/02/09
- [PATCH v6 26/31] linux-user/aarch64: Pass syndrome to EXC_*_ABORT, Richard Henderson, 2021/02/09
- [PATCH v6 28/31] linux-user/aarch64: Signal SEGV_MTEAERR for async tag check error, Richard Henderson, 2021/02/09
- [PATCH v6 25/31] target/arm: Split out syndrome.h from internals.h, Richard Henderson, 2021/02/09