From: Alexandru Elisei <alexandru.elisei@arm.com>
To: Andrew Jones <andrew.jones@linux.dev>
Cc: Vladimir Murzin <vladimir.murzin@arm.com>,
kvmarm@lists.linux.dev, nikos.nikoleris@arm.com,
eric.auger@redhat.com
Subject: Re: [PATCH v4] arm64: Add basic MTE test
Date: Thu, 6 Mar 2025 17:11:20 +0000 [thread overview]
Message-ID: <Z8nXOBGxEGS5il3N@raptor> (raw)
In-Reply-To: <20250306-e90b77df70c0a9be913a4e08@orel>
Hi Drew,
On Thu, Mar 06, 2025 at 04:45:06PM +0100, Andrew Jones wrote:
> On Thu, Feb 27, 2025 at 03:22:40PM +0000, Vladimir Murzin wrote:
> > Test tag storage access and tag mismatch for different MTE modes.
> >
> > Signed-off-by: Vladimir Murzin <vladimir.murzin@arm.com>
> > ---
> > arm/Makefile.arm64 | 8 +
> > arm/cstart64.S | 4 +-
> > arm/mte.c | 313 ++++++++++++++++++++++++++++++++++
> > arm/unittests.cfg | 19 +++
> > lib/arm64/asm/mmu.h | 1 +
> > lib/arm64/asm/pgtable-hwdef.h | 3 +
> > lib/arm64/asm/sysreg.h | 14 ++
> > 7 files changed, 361 insertions(+), 1 deletion(-)
> > create mode 100644 arm/mte.c
> >
>
> Unfortunately this is failing builds with clang.
>
> arm/mte.c:65:18: error: value size does not match register size specified by the constraint and modifier [-Werror,-Wasm-operand-widths]
> 65 | : "=&r" (r)
> | ^
> arm/mte.c:63:21: note: use constraint modifier "w"
> 63 | asm volatile ("ldr %0,[%1]\n"
> | ^~
> | %w0
> arm/mte.c:65:18: error: value size does not match register size specified by the constraint and modifier [-Werror,-Wasm-operand-widths]
> 65 | : "=&r" (r)
> | ^
> arm/mte.c:64:14: note: use constraint modifier "w"
> 64 | "str %0,[%2]\n"
> | ^~
> | %w0
> arm/mte.c:75:16: error: value size does not match register size specified by the constraint and modifier [-Werror,-Wasm-operand-widths]
> 75 | : "r" (val), "r" (addr)
> | ^
> arm/mte.c:72:21: note: use constraint modifier "w"
> 72 | asm volatile ("str %0,[%1]\n"
> | ^~
> | %w0
>
> Thanks,
> drew
>
That's unfortunate, I think it's because %0 specifies a 64bit register, but
the variable is declared as an unsigned int, which is 32 bits.
Can you give this a go:
diff --git a/arm/mte.c b/arm/mte.c
index f32203ce275a..9c266fcced5f 100644
--- a/arm/mte.c
+++ b/arm/mte.c
@@ -60,8 +60,8 @@ static inline void mem_read(unsigned int *addr, unsigned int *res)
{
unsigned int r;
- asm volatile ("ldr %0,[%1]\n"
- "str %0,[%2]\n"
+ asm volatile ("ldr %w0,[%1]\n"
+ "str %w0,[%2]\n"
: "=&r" (r)
: "r" (addr), "r" (res) : "memory");
}
@@ -69,7 +69,7 @@ static inline void mem_read(unsigned int *addr, unsigned int *res)
static inline void mem_write(unsigned int *addr, unsigned int val)
{
/* The NOP allows the same exception handler as mem_read() to be used. */
- asm volatile ("str %0,[%1]\n"
+ asm volatile ("str %w0,[%1]\n"
"nop\n"
:
: "r" (val), "r" (addr)
It compiles and works with gcc; with clang it compiles, but I cannot run
the test because kvm-unit-tests doesn't detect MTE support in the compiler.
$ ./configure --arch=arm64 --cc=clang --cross-prefix=aarch64-linux-gnu- --cflags='--target=aarch64-linux -march=armv8.5-a+memtag'
$ make -j32 clean && make -j32
$ ./run_tests.sh -g mte
config.mak: line 13: -march=armv8.5-a+memtag: command not found
config.mak: line 13: -march=armv8.5-a+memtag: command not found
SKIP mte-sync (1 tests, 1 skipped)
SKIP mte-async (1 tests, 1 skipped)
SKIP mte-asymm (1 tests, 1 skipped)
(the error I suppose it's because configure doesn't wrap CFLAGS in quotes
when writing config.mak).
Do you have any hints about enabling MTE in clang?
Thanks,
Alex
next prev parent reply other threads:[~2025-03-06 17:11 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-27 15:22 [PATCH v4] arm64: Add basic MTE test Vladimir Murzin
2025-03-06 14:11 ` Alexandru Elisei
2025-03-06 14:25 ` Vladimir Murzin
2025-03-06 15:31 ` Andrew Jones
2025-03-06 15:45 ` Andrew Jones
2025-03-06 17:11 ` Alexandru Elisei [this message]
2025-03-07 8:24 ` Andrew Jones
2025-03-07 9:26 ` Andrew Jones
2025-04-08 15:16 ` Andrew Jones
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=Z8nXOBGxEGS5il3N@raptor \
--to=alexandru.elisei@arm.com \
--cc=andrew.jones@linux.dev \
--cc=eric.auger@redhat.com \
--cc=kvmarm@lists.linux.dev \
--cc=nikos.nikoleris@arm.com \
--cc=vladimir.murzin@arm.com \
/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