All of lore.kernel.org
 help / color / mirror / Atom feed
From: Richard Henderson <richard.henderson@linaro.org>
To: qemu-devel@nongnu.org
Cc: peter.maydell@linaro.org
Subject: [PATCH v6 24/31] linux-user/aarch64: Implement PROT_MTE
Date: Tue,  9 Feb 2021 16:02:16 -0800	[thread overview]
Message-ID: <20210210000223.884088-25-richard.henderson@linaro.org> (raw)
In-Reply-To: <20210210000223.884088-1-richard.henderson@linaro.org>

Remember the PROT_MTE bit as PAGE_MTE/PAGE_TARGET_2.
Otherwise this does not yet have effect.

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 include/exec/cpu-all.h    |  1 +
 linux-user/syscall_defs.h |  1 +
 target/arm/cpu.h          |  1 +
 linux-user/mmap.c         | 22 ++++++++++++++--------
 4 files changed, 17 insertions(+), 8 deletions(-)

diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h
index d6ad774c01..09b9be845d 100644
--- a/include/exec/cpu-all.h
+++ b/include/exec/cpu-all.h
@@ -284,6 +284,7 @@ extern intptr_t qemu_host_page_mask;
 #endif
 /* Target-specific bits that will be used via page_get_flags().  */
 #define PAGE_TARGET_1  0x0080
+#define PAGE_TARGET_2  0x0200
 
 #if defined(CONFIG_USER_ONLY)
 void page_dump(FILE *f);
diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h
index f98c1c1c8d..46a960fccb 100644
--- a/linux-user/syscall_defs.h
+++ b/linux-user/syscall_defs.h
@@ -1311,6 +1311,7 @@ struct target_winsize {
 
 #ifdef TARGET_AARCH64
 #define TARGET_PROT_BTI         0x10
+#define TARGET_PROT_MTE         0x20
 #endif
 
 /* Common */
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
index 558ad1466b..e3e61ce7ab 100644
--- a/target/arm/cpu.h
+++ b/target/arm/cpu.h
@@ -3606,6 +3606,7 @@ static inline MemTxAttrs *typecheck_memtxattrs(MemTxAttrs *x)
  * AArch64 usage of the PAGE_TARGET_* bits for linux-user.
  */
 #define PAGE_BTI  PAGE_TARGET_1
+#define PAGE_MTE  PAGE_TARGET_2
 
 #ifdef TARGET_TAGGED_ADDRESSES
 /**
diff --git a/linux-user/mmap.c b/linux-user/mmap.c
index 6690384752..85e218ab1d 100644
--- a/linux-user/mmap.c
+++ b/linux-user/mmap.c
@@ -84,18 +84,24 @@ static int validate_prot_to_pageflags(int *host_prot, int prot)
                | (prot & PROT_EXEC ? PROT_READ : 0);
 
 #ifdef TARGET_AARCH64
-    /*
-     * The PROT_BTI bit is only accepted if the cpu supports the feature.
-     * Since this is the unusual case, don't bother checking unless
-     * the bit has been requested.  If set and valid, record the bit
-     * within QEMU's page_flags.
-     */
-    if (prot & TARGET_PROT_BTI) {
+    {
         ARMCPU *cpu = ARM_CPU(thread_cpu);
-        if (cpu_isar_feature(aa64_bti, cpu)) {
+
+        /*
+         * The PROT_BTI bit is only accepted if the cpu supports the feature.
+         * Since this is the unusual case, don't bother checking unless
+         * the bit has been requested.  If set and valid, record the bit
+         * within QEMU's page_flags.
+         */
+        if ((prot & TARGET_PROT_BTI) && cpu_isar_feature(aa64_bti, cpu)) {
             valid |= TARGET_PROT_BTI;
             page_flags |= PAGE_BTI;
         }
+        /* Similarly for the PROT_MTE bit. */
+        if ((prot & TARGET_PROT_MTE) && cpu_isar_feature(aa64_mte, cpu)) {
+            valid |= TARGET_PROT_MTE;
+            page_flags |= PAGE_MTE;
+        }
     }
 #endif
 
-- 
2.25.1



  parent reply	other threads:[~2021-02-10  0:24 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-10  0:01 [PATCH v6 00/31] target-arm: Implement ARMv8.5-MemTag, user mode Richard Henderson
2021-02-10  0:01 ` [PATCH v6 01/31] tcg: Introduce target-specific page data for user-only Richard Henderson
2021-02-10  0:01 ` [PATCH v6 02/31] linux-user: Introduce PAGE_ANON Richard Henderson
2021-02-10  0:01 ` [PATCH v6 03/31] exec: Use uintptr_t for guest_base Richard Henderson
2021-02-10  0:01 ` [PATCH v6 04/31] exec: Use uintptr_t in cpu_ldst.h Richard Henderson
2021-02-10  0:01 ` [PATCH v6 05/31] exec: Improve types for guest_addr_valid Richard Henderson
2021-02-10  0:01 ` [PATCH v6 06/31] linux-user: Check for overflow in access_ok Richard Henderson
2021-02-10  0:01 ` [PATCH v6 07/31] linux-user: Tidy VERIFY_READ/VERIFY_WRITE Richard Henderson
2021-02-10  0:02 ` [PATCH v6 08/31] bsd-user: " Richard Henderson
2021-02-10  0:02 ` [PATCH v6 09/31] linux-user: Do not use guest_addr_valid for h2g_valid Richard Henderson
2021-02-10  0:02 ` [PATCH v6 10/31] linux-user: Fix guest_addr_valid vs reserved_va Richard Henderson
2021-02-10  0:02 ` [PATCH v6 11/31] exec: Introduce cpu_untagged_addr Richard Henderson
2021-02-10  0:02 ` [PATCH v6 12/31] exec: Use cpu_untagged_addr in g2h; split out g2h_untagged Richard Henderson
2021-02-10  0:02 ` [PATCH v6 13/31] linux-user: Explicitly untag memory management syscalls Richard Henderson
2021-02-10  0:02 ` [PATCH v6 14/31] linux-user: Use guest_range_valid in access_ok Richard Henderson
2021-02-10  0:02 ` [PATCH v6 15/31] exec: Rename guest_{addr,range}_valid to *_untagged Richard Henderson
2021-02-10  0:02 ` [PATCH v6 16/31] linux-user: Use cpu_untagged_addr in access_ok; split out *_untagged Richard Henderson
2021-02-10  0:02 ` [PATCH v6 17/31] linux-user: Move lock_user et al out of line Richard Henderson
2021-02-10  0:02 ` [PATCH v6 18/31] linux-user: Fix types in uaccess.c Richard Henderson
2021-02-10  0:02 ` [PATCH v6 19/31] linux-user: Handle tags in lock_user/unlock_user Richard Henderson
2021-02-10 11:05   ` Peter Maydell
2021-02-10  0:02 ` [PATCH v6 20/31] linux-user/aarch64: Implement PR_TAGGED_ADDR_ENABLE Richard Henderson
2021-02-10  0:02 ` [PATCH v6 21/31] target/arm: Improve gen_top_byte_ignore Richard Henderson
2021-02-10  0:02 ` [PATCH v6 22/31] target/arm: Use the proper TBI settings for linux-user Richard Henderson
2021-02-10  0:02 ` [PATCH v6 23/31] linux-user/aarch64: Implement PR_MTE_TCF and PR_MTE_TAG Richard Henderson
2021-02-10  0:02 ` Richard Henderson [this message]
2021-02-10  0:02 ` [PATCH v6 25/31] target/arm: Split out syndrome.h from internals.h Richard Henderson
2021-02-10  0:02 ` [PATCH v6 26/31] linux-user/aarch64: Pass syndrome to EXC_*_ABORT Richard Henderson
2021-02-10  0:02 ` [PATCH v6 27/31] linux-user/aarch64: Signal SEGV_MTESERR for sync tag check fault Richard Henderson
2021-02-10  0:02 ` [PATCH v6 28/31] linux-user/aarch64: Signal SEGV_MTEAERR for async tag check error Richard Henderson
2021-02-10  0:02 ` [PATCH v6 29/31] target/arm: Add allocation tag storage for user mode Richard Henderson
2021-02-10  0:02 ` [PATCH v6 30/31] target/arm: Enable MTE for user-only Richard Henderson
2021-02-10  0:02 ` [PATCH v6 31/31] tests/tcg/aarch64: Add mte smoke tests Richard Henderson
2021-02-11 10:44 ` [PATCH v6 00/31] target-arm: Implement ARMv8.5-MemTag, user mode Peter Maydell
2021-02-11 19:46   ` Peter Maydell
2021-02-11 11:10 ` no-reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210210000223.884088-25-richard.henderson@linaro.org \
    --to=richard.henderson@linaro.org \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.