From: Szabolcs Nagy <szabolcs.nagy@arm.com>
To: Richard Earnshaw <rearnsha@arm.com>
Cc: libc-alpha@sourceware.org, dj@redhat.com
Subject: Re: [PATCH v3 8/8] aarch64: Add aarch64-specific files for memory tagging support
Date: Wed, 16 Dec 2020 15:26:07 +0000 [thread overview]
Message-ID: <20201216152606.GN24625@arm.com> (raw)
In-Reply-To: <20201123154236.25809-9-rearnsha@arm.com>
The 11/23/2020 15:42, Richard Earnshaw wrote:
> This final patch provides the architecture-specific implementation of
> the memory-tagging support hooks for aarch64.
...
> diff --git a/sysdeps/aarch64/Makefile b/sysdeps/aarch64/Makefile
> index d8e06d27b2..2e88fc84a4 100644
> --- a/sysdeps/aarch64/Makefile
> +++ b/sysdeps/aarch64/Makefile
> @@ -40,4 +40,9 @@ endif
>
> ifeq ($(subdir),misc)
> sysdep_headers += sys/ifunc.h
> +sysdep_routines += __mtag_tag_region __mtag_new_tag __mtag_address_get_tag
> +endif
> +
> +ifeq ($(subdir),string)
> +sysdep_routines += __mtag_memset_tag
> endif
this is ok, but i think all can go to misc.
> diff --git a/sysdeps/aarch64/__mtag_address_get_tag.S b/sysdeps/aarch64/__mtag_address_get_tag.S
> new file mode 100644
> index 0000000000..654c9d660c
> --- /dev/null
> +++ b/sysdeps/aarch64/__mtag_address_get_tag.S
> @@ -0,0 +1,31 @@
> +/* Copyright (C) 2020 Free Software Foundation, Inc.
> +
> + This file is part of the GNU C Library.
> +
> + The GNU C Library is free software; you can redistribute it and/or
> + modify it under the terms of the GNU Lesser General Public
> + License as published by the Free Software Foundation; either
> + version 2.1 of the License, or (at your option) any later version.
> +
> + The GNU C Library is distributed in the hope that it will be useful,
> + but WITHOUT ANY WARRANTY; without even the implied warranty of
> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> + Lesser General Public License for more details.
> +
> + You should have received a copy of the GNU Lesser General Public
> + License along with the GNU C Library. If not, see
> + <http://www.gnu.org/licenses/>. */
> +
> +#include <sysdep.h>
> +
i'd like the content after sysdep.h to be in
#ifdef _LIBC_MTAG
so we don't build unused armv8.5-a code into glibc
(which can cause trouble with old binutils).
> +#define ptr x0
> +
> + .arch armv8.5-a
> + .arch_extension memtag
> +
> +ENTRY (__libc_mtag_address_get_tag)
> +
> + ldg ptr, [ptr]
> + ret
> +END (__libc_mtag_address_get_tag)
> +libc_hidden_builtin_def (__libc_mtag_address_get_tag)
i think we don't need libc_hidden_builtin_def here:
that is only necessary when we make this a public api
(by adding it to a Versions file) but then we need
other changes like libc_hidden_proto on declarations
as well. as long as these are only used from libc.so
no magic is needed.
same for the other functions.
> diff --git a/sysdeps/aarch64/__mtag_memset_tag.S b/sysdeps/aarch64/__mtag_memset_tag.S
> new file mode 100644
> index 0000000000..bc98dc49d2
> --- /dev/null
> +++ b/sysdeps/aarch64/__mtag_memset_tag.S
> @@ -0,0 +1,46 @@
...
> +#include <sysdep.h>
> +/* Use the same register names and assignments as memset. */
> +#include "memset-reg.h"
> +
> + .arch armv8.5-a
> + .arch_extension memtag
> +
> +/* NB, only supported on variants with 64-bit pointers. */
> +
> +/* FIXME: This is a minimal implementation. We could do much better than
> + this for large values of COUNT. */
> +
> +ENTRY_ALIGN(__libc_mtag_memset_with_tag, 6)
this should be plain ENTRY
(which defaults to 2^6 alignment)
same for __libc_mtag_tag_region.
> +
> + and valw, valw, 255
> + orr valw, valw, valw, lsl 8
> + orr valw, valw, valw, lsl 16
> + orr val, val, val, lsl 32
> + mov dst, dstin
> +
> +L(loop):
> + stgp val, val, [dst], #16
> + subs count, count, 16
> + bne L(loop)
> + ldg dstin, [dstin] // Recover the tag created (might be untagged).
i think ldg is not needed: for now we only use
this on PROT_MTE enabled memory.
(calling the function with non-heap memory or
disabling mte on heap memory can be treated as
a bug. this decision can be changed later if
we want to expose public mtag api to user code:
in particular the unwinder for stack tagging
may want to use such api, but we don't need to
design that right now.)
same for __libc_mtag_tag_region.
> + ret
> +END (__libc_mtag_memset_with_tag)
> +libc_hidden_builtin_def (__libc_mtag_memset_with_tag)
> diff --git a/sysdeps/aarch64/__mtag_new_tag.S b/sysdeps/aarch64/__mtag_new_tag.S
> new file mode 100644
> index 0000000000..3a22995e9f
> --- /dev/null
> +++ b/sysdeps/aarch64/__mtag_new_tag.S
> @@ -0,0 +1,38 @@
...
> +#include <sysdep.h>
> +
> + .arch armv8.5-a
> + .arch_extension memtag
> +
> +/* NB, only supported on variants with 64-bit pointers. */
> +
> +/* FIXME: This is a minimal implementation. We could do better than
> + this for larger values of COUNT. */
this fixme is not needed here.
> +
> +#define ptr x0
> +#define xset x1
> +
> +ENTRY(__libc_mtag_new_tag)
> + // Guarantee that the new tag is not the same as now.
> + gmi xset, ptr, xzr
> + irg ptr, ptr, xset
> + ret
> +END (__libc_mtag_new_tag)
> +libc_hidden_builtin_def (__libc_mtag_new_tag)
...
rest looked ok.
next prev parent reply other threads:[~2020-12-16 15:26 UTC|newest]
Thread overview: 80+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-23 15:42 [PATCH v3 0/8] Memory " Richard Earnshaw
2020-11-23 15:42 ` [PATCH v3 1/8] config: Allow memory tagging to be enabled when configuring glibc Richard Earnshaw
2020-11-25 15:05 ` Siddhesh Poyarekar
2020-11-25 15:09 ` Richard Earnshaw (lists)
2020-11-25 15:10 ` Siddhesh Poyarekar
2020-11-25 15:12 ` Adhemerval Zanella
2020-11-25 16:11 ` Richard Earnshaw (lists)
2020-11-25 16:40 ` Adhemerval Zanella
2020-11-23 15:42 ` [PATCH v3 2/8] elf: Add a tunable to control use of tagged memory Richard Earnshaw
2020-11-25 15:08 ` Siddhesh Poyarekar
2020-11-25 16:35 ` H.J. Lu
2020-11-25 16:53 ` Siddhesh Poyarekar
2020-11-25 16:58 ` Richard Earnshaw
2020-11-25 17:12 ` Siddhesh Poyarekar
2020-11-25 17:24 ` Richard Earnshaw
2020-11-25 17:48 ` Siddhesh Poyarekar
2020-11-25 19:06 ` H.J. Lu
2020-11-26 0:47 ` Siddhesh Poyarekar
2020-11-26 14:15 ` Richard Earnshaw
2020-11-26 15:27 ` Siddhesh Poyarekar
2020-11-26 15:48 ` Richard Earnshaw
2020-11-26 15:50 ` H.J. Lu
2020-11-26 16:28 ` Richard Earnshaw
2020-11-26 16:51 ` H.J. Lu
2020-11-26 16:59 ` Richard Earnshaw
2020-11-26 17:06 ` H.J. Lu
2020-11-26 17:20 ` Szabolcs Nagy
2020-11-26 17:31 ` H.J. Lu
2020-11-26 17:56 ` Richard Earnshaw
2020-11-26 18:06 ` H.J. Lu
2020-11-26 18:06 ` Szabolcs Nagy
2020-11-26 18:09 ` H.J. Lu
2020-11-26 18:25 ` Andreas Schwab
2020-11-27 10:34 ` Szabolcs Nagy
2020-11-27 11:08 ` Florian Weimer
2020-11-27 2:59 ` Siddhesh Poyarekar
2020-11-27 10:32 ` Szabolcs Nagy
2020-11-27 11:14 ` Siddhesh Poyarekar
2020-11-26 16:04 ` Siddhesh Poyarekar
2020-11-26 16:19 ` H.J. Lu
2020-11-26 17:13 ` Siddhesh Poyarekar
2020-11-26 17:19 ` H.J. Lu
2020-11-27 2:45 ` Siddhesh Poyarekar
2020-11-27 10:40 ` Richard Earnshaw
2020-11-27 10:49 ` Richard Earnshaw
2020-11-27 11:32 ` Siddhesh Poyarekar
2020-11-27 11:51 ` Richard Earnshaw
2020-11-27 11:27 ` Siddhesh Poyarekar
2020-11-27 12:24 ` Richard Earnshaw
2020-11-27 14:54 ` H.J. Lu
2020-11-27 17:02 ` Szabolcs Nagy
2020-11-27 18:41 ` H.J. Lu
2020-11-27 14:52 ` H.J. Lu
2020-11-27 16:08 ` Richard Earnshaw
2020-11-27 18:37 ` H.J. Lu
2020-11-30 6:28 ` Siddhesh Poyarekar
2020-11-26 16:10 ` Szabolcs Nagy
2020-11-23 15:42 ` [PATCH v3 3/8] malloc: Basic support for memory tagging in the malloc() family Richard Earnshaw
2020-11-25 14:58 ` Florian Weimer
2020-11-25 17:32 ` Richard Earnshaw
2020-11-23 15:42 ` [PATCH v3 4/8] malloc: Clean up commentary Richard Earnshaw
2020-11-23 15:42 ` [PATCH v3 5/8] malloc: support MALLOC_CHECK_ in conjunction with _MTAG_ENABLE Richard Earnshaw
2020-11-23 15:42 ` [PATCH v3 6/8] linux: Add compatibility definitions to sys/prctl.h for MTE Richard Earnshaw
2020-11-25 15:26 ` Siddhesh Poyarekar
2020-11-23 15:42 ` [PATCH v3 7/8] aarch64: Add sysv specific enabling code for memory tagging Richard Earnshaw
2020-11-23 16:53 ` Szabolcs Nagy
2020-11-23 17:33 ` Richard Earnshaw (lists)
2020-11-25 15:34 ` Siddhesh Poyarekar
2020-11-25 16:06 ` Richard Earnshaw
2020-11-25 16:20 ` Siddhesh Poyarekar
2020-11-25 16:23 ` Siddhesh Poyarekar
2020-11-23 15:42 ` [PATCH v3 8/8] aarch64: Add aarch64-specific files for memory tagging support Richard Earnshaw
2020-12-16 15:26 ` Szabolcs Nagy [this message]
2020-11-24 10:12 ` [PATCH v3 0/8] Memory " Szabolcs Nagy
2020-11-25 14:49 ` Siddhesh Poyarekar
2020-11-25 15:48 ` Richard Earnshaw
2020-11-25 16:17 ` Siddhesh Poyarekar
2020-11-25 15:45 ` H.J. Lu
2020-12-17 3:57 ` DJ Delorie
2020-12-17 11:31 ` Richard Earnshaw
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=20201216152606.GN24625@arm.com \
--to=szabolcs.nagy@arm.com \
--cc=dj@redhat.com \
--cc=libc-alpha@sourceware.org \
--cc=rearnsha@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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).