From: Gabriel Brookman <brookmangabriel@gmail.com>
To: qemu-devel@nongnu.org
Cc: Peter Maydell <peter.maydell@linaro.org>,
Gustavo Romero <gustavo.romero@linaro.org>,
qemu-arm@nongnu.org,
Gabriel Brookman <brookmangabriel@gmail.com>
Subject: [PATCH RFC v2 02/10] tests/tcg: added test for MTE FAR
Date: Sun, 16 Nov 2025 20:40:19 -0500 [thread overview]
Message-ID: <20251116-feat-mte4-v2-2-9a7122b7fa76@gmail.com> (raw)
In-Reply-To: <20251116-feat-mte4-v2-0-9a7122b7fa76@gmail.com>
This functionality was previously enabled but not advertised or tested.
This commit adds a new test, mte-9, that tests the code for proper
full-address reporting. FEAT_MTE_TAGGED_FAR requires that FAR_ELx
report the full logical address, including tag bits.
Signed-off-by: Gabriel Brookman <brookmangabriel@gmail.com>
---
tests/tcg/aarch64/Makefile.target | 2 +-
tests/tcg/aarch64/mte-9.c | 48 +++++++++++++++++++++++++++++++++++++++
2 files changed, 49 insertions(+), 1 deletion(-)
diff --git a/tests/tcg/aarch64/Makefile.target b/tests/tcg/aarch64/Makefile.target
index 9fa8687453..b491cfb5e1 100644
--- a/tests/tcg/aarch64/Makefile.target
+++ b/tests/tcg/aarch64/Makefile.target
@@ -64,7 +64,7 @@ AARCH64_TESTS += bti-2
# MTE Tests
ifneq ($(CROSS_CC_HAS_ARMV8_MTE),)
-AARCH64_TESTS += mte-1 mte-2 mte-3 mte-4 mte-5 mte-6 mte-7 mte-8
+AARCH64_TESTS += mte-1 mte-2 mte-3 mte-4 mte-5 mte-6 mte-7 mte-8 mte-9
mte-%: CFLAGS += $(CROSS_CC_HAS_ARMV8_MTE)
endif
diff --git a/tests/tcg/aarch64/mte-9.c b/tests/tcg/aarch64/mte-9.c
new file mode 100644
index 0000000000..9626a90c13
--- /dev/null
+++ b/tests/tcg/aarch64/mte-9.c
@@ -0,0 +1,48 @@
+/*
+ * Memory tagging, full-address reporting.
+ *
+ * Copyright (c) 2021 Linaro Ltd
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include "mte.h"
+
+static void *faulting_ptr;
+
+void pass(int sig, siginfo_t *info, void *uc)
+{
+ assert(faulting_ptr == info->si_addr);
+ exit(0);
+}
+
+int main(int ac, char **av)
+{
+ struct sigaction sa;
+ int *p0, *p1, *p2;
+ long excl = 1;
+
+ enable_mte(PR_MTE_TCF_SYNC);
+ p0 = alloc_mte_mem(sizeof(*p0));
+
+ /* Create two differently tagged pointers. */
+ asm("irg %0,%1,%2" : "=r"(p1) : "r"(p0), "r"(excl));
+ asm("gmi %0,%1,%0" : "+r"(excl) : "r" (p1));
+ assert(excl != 1);
+ asm("irg %0,%1,%2" : "=r"(p2) : "r"(p0), "r"(excl));
+ assert(p1 != p2);
+
+ /* Store the tag from the first pointer. */
+ asm("stg %0, [%0]" : : "r"(p1));
+
+ *p1 = 0;
+
+ memset(&sa, 0, sizeof(sa));
+ sa.sa_sigaction = pass;
+ sa.sa_flags = SA_SIGINFO;
+ sigaction(SIGSEGV, &sa, NULL);
+
+ faulting_ptr = p2;
+ *p2 = 0;
+
+ abort();
+}
--
2.51.2
next prev parent reply other threads:[~2025-11-17 1:43 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-17 1:40 [PATCH RFC v2 00/10] target/arm: add support for MTE4 Gabriel Brookman
2025-11-17 1:40 ` [PATCH RFC v2 01/10] target/arm: explicitly disable MTE4 for max Gabriel Brookman
2025-11-17 9:48 ` Richard Henderson
2025-11-17 1:40 ` Gabriel Brookman [this message]
2025-11-17 9:51 ` [PATCH RFC v2 02/10] tests/tcg: added test for MTE FAR Richard Henderson
2025-11-17 1:40 ` [PATCH RFC v2 03/10] target/arm: add TCSO bitmasks to SCTLR Gabriel Brookman
2025-11-17 15:14 ` Richard Henderson
2025-11-17 1:40 ` [PATCH RFC v2 04/10] target/arm: add FEAT_MTE_STORE_ONLY logic Gabriel Brookman
2025-11-17 15:26 ` Richard Henderson
2025-11-17 1:40 ` [PATCH RFC v2 05/10] tests/tcg: added test for MTE write-only Gabriel Brookman
2025-11-17 15:39 ` Richard Henderson
2025-11-17 1:40 ` [PATCH RFC v2 06/10] target/arm: add canonical and no-address tag logic Gabriel Brookman
2025-11-17 16:18 ` Richard Henderson
2025-11-17 1:40 ` [PATCH RFC v2 07/10] target/arm: ldg on canonical tag loads the tag Gabriel Brookman
2025-11-17 16:26 ` Richard Henderson
2025-11-18 17:31 ` brookmangabriel
2025-11-17 1:40 ` [PATCH RFC v2 08/10] target/arm: storing to canonical tags faults Gabriel Brookman
2025-11-19 7:48 ` Richard Henderson
2025-11-17 1:40 ` [PATCH RFC v2 09/10] tests/tcg: added test for MTE canonical and NAT Gabriel Brookman
2025-11-19 7:49 ` Richard Henderson
2025-11-17 1:40 ` [PATCH RFC v2 10/10] docs: added MTE4 features to docs Gabriel Brookman
2025-11-19 7:51 ` Richard Henderson
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=20251116-feat-mte4-v2-2-9a7122b7fa76@gmail.com \
--to=brookmangabriel@gmail.com \
--cc=gustavo.romero@linaro.org \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).