public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] aarch64: Use future HWCAP2_MTE in ifunc resolver
@ 2020-07-27  9:26 Szabolcs Nagy
  2020-07-27  9:54 ` Florian Weimer
  2020-07-27 13:52 ` Adhemerval Zanella
  0 siblings, 2 replies; 5+ messages in thread
From: Szabolcs Nagy @ 2020-07-27  9:26 UTC (permalink / raw)
  To: libc-alpha

Make glibc MTE-safe on systems where MTE is available. This allows
using heap tagging with an LD_PRELOADed malloc implementation that
enables MTE. We don't document this as guaranteed contract yet, so
glibc may not be MTE safe when HWCAP2_MTE is set (older glibcs
certainly aren't). This is mainly for testing and debugging.

The HWCAP flag is not exposed in public headers until Linux adds it
to its uapi. The HWCAP value reservation will be in Linux 5.9.

---
I'd like to commit this for 2.32, it is safe even if the hwcap value
changes because there is no mte safety guarantee (but there is no
reason for linux to change the value).

linux commit:
http://git.kernel.org/arm64/c/a46cec12f4a5

tested in qemu.
---
 sysdeps/aarch64/multiarch/strlen.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/sysdeps/aarch64/multiarch/strlen.c b/sysdeps/aarch64/multiarch/strlen.c
index 7c0352dd87..9440decf75 100644
--- a/sysdeps/aarch64/multiarch/strlen.c
+++ b/sysdeps/aarch64/multiarch/strlen.c
@@ -26,8 +26,14 @@
 # include <string.h>
 # include <init-arch.h>
 
-/* This should check HWCAP_MTE when it is available.  */
-#define MTE_ENABLED() (false)
+/* This should check HWCAP2_MTE when it is available: current
+   linux kernel does not expose it, but its value is reserved.
+   This is needed to make glibc MTE-safe on future systems in
+   case user code enables MTE. The ABI contract for enabling
+   MTE is not yet specified, but it can be useful for at least
+   debugging which does not need a contract.  */
+#define FUTURE_HWCAP2_MTE (1 << 18)
+#define MTE_ENABLED() (GLRO(dl_hwcap2) & FUTURE_HWCAP2_MTE)
 
 extern __typeof (__redirect_strlen) __strlen;
 
-- 
2.17.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] aarch64: Use future HWCAP2_MTE in ifunc resolver
  2020-07-27  9:26 [PATCH] aarch64: Use future HWCAP2_MTE in ifunc resolver Szabolcs Nagy
@ 2020-07-27  9:54 ` Florian Weimer
  2020-07-27 11:42   ` Szabolcs Nagy
  2020-07-27 13:52 ` Adhemerval Zanella
  1 sibling, 1 reply; 5+ messages in thread
From: Florian Weimer @ 2020-07-27  9:54 UTC (permalink / raw)
  To: Szabolcs Nagy; +Cc: libc-alpha

* Szabolcs Nagy:

> Make glibc MTE-safe on systems where MTE is available. This allows
> using heap tagging with an LD_PRELOADed malloc implementation that
> enables MTE. We don't document this as guaranteed contract yet, so
> glibc may not be MTE safe when HWCAP2_MTE is set (older glibcs
> certainly aren't). This is mainly for testing and debugging.
>
> The HWCAP flag is not exposed in public headers until Linux adds it
> to its uapi. The HWCAP value reservation will be in Linux 5.9.

It's not yet in Linus' tree, though?

I think this is safe because the MTE code will run just fine on non-MTE
systems (if the bit is repurposed after all), right?

Thanks,
Florian


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] aarch64: Use future HWCAP2_MTE in ifunc resolver
  2020-07-27  9:54 ` Florian Weimer
@ 2020-07-27 11:42   ` Szabolcs Nagy
  2020-07-27 11:47     ` Florian Weimer
  0 siblings, 1 reply; 5+ messages in thread
From: Szabolcs Nagy @ 2020-07-27 11:42 UTC (permalink / raw)
  To: Florian Weimer; +Cc: libc-alpha

The 07/27/2020 11:54, Florian Weimer wrote:
> * Szabolcs Nagy:
> 
> > Make glibc MTE-safe on systems where MTE is available. This allows
> > using heap tagging with an LD_PRELOADed malloc implementation that
> > enables MTE. We don't document this as guaranteed contract yet, so
> > glibc may not be MTE safe when HWCAP2_MTE is set (older glibcs
> > certainly aren't). This is mainly for testing and debugging.
> >
> > The HWCAP flag is not exposed in public headers until Linux adds it
> > to its uapi. The HWCAP value reservation will be in Linux 5.9.
> 
> It's not yet in Linus' tree, though?
> 
> I think this is safe because the MTE code will run just fine on non-MTE
> systems (if the bit is repurposed after all), right?

yes.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] aarch64: Use future HWCAP2_MTE in ifunc resolver
  2020-07-27 11:42   ` Szabolcs Nagy
@ 2020-07-27 11:47     ` Florian Weimer
  0 siblings, 0 replies; 5+ messages in thread
From: Florian Weimer @ 2020-07-27 11:47 UTC (permalink / raw)
  To: Szabolcs Nagy; +Cc: libc-alpha

* Szabolcs Nagy:

> The 07/27/2020 11:54, Florian Weimer wrote:
>> * Szabolcs Nagy:
>> 
>> > Make glibc MTE-safe on systems where MTE is available. This allows
>> > using heap tagging with an LD_PRELOADed malloc implementation that
>> > enables MTE. We don't document this as guaranteed contract yet, so
>> > glibc may not be MTE safe when HWCAP2_MTE is set (older glibcs
>> > certainly aren't). This is mainly for testing and debugging.
>> >
>> > The HWCAP flag is not exposed in public headers until Linux adds it
>> > to its uapi. The HWCAP value reservation will be in Linux 5.9.
>> 
>> It's not yet in Linus' tree, though?
>> 
>> I think this is safe because the MTE code will run just fine on non-MTE
>> systems (if the bit is repurposed after all), right?
>
> yes.

Okay, then this is fine for glibc 2.32.  Thanks.

Florian


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] aarch64: Use future HWCAP2_MTE in ifunc resolver
  2020-07-27  9:26 [PATCH] aarch64: Use future HWCAP2_MTE in ifunc resolver Szabolcs Nagy
  2020-07-27  9:54 ` Florian Weimer
@ 2020-07-27 13:52 ` Adhemerval Zanella
  1 sibling, 0 replies; 5+ messages in thread
From: Adhemerval Zanella @ 2020-07-27 13:52 UTC (permalink / raw)
  To: libc-alpha



On 27/07/2020 06:26, Szabolcs Nagy wrote:
> Make glibc MTE-safe on systems where MTE is available. This allows
> using heap tagging with an LD_PRELOADed malloc implementation that
> enables MTE. We don't document this as guaranteed contract yet, so
> glibc may not be MTE safe when HWCAP2_MTE is set (older glibcs
> certainly aren't). This is mainly for testing and debugging.
> 
> The HWCAP flag is not exposed in public headers until Linux adds it
> to its uapi. The HWCAP value reservation will be in Linux 5.9.
> 
> ---
> I'd like to commit this for 2.32, it is safe even if the hwcap value
> changes because there is no mte safety guarantee (but there is no
> reason for linux to change the value).
> 
> linux commit:
> http://git.kernel.org/arm64/c/a46cec12f4a5
> 
> tested in qemu.
> ---
>  sysdeps/aarch64/multiarch/strlen.c | 10 ++++++++--
>  1 file changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/sysdeps/aarch64/multiarch/strlen.c b/sysdeps/aarch64/multiarch/strlen.c
> index 7c0352dd87..9440decf75 100644
> --- a/sysdeps/aarch64/multiarch/strlen.c
> +++ b/sysdeps/aarch64/multiarch/strlen.c
> @@ -26,8 +26,14 @@
>  # include <string.h>
>  # include <init-arch.h>
>  
> -/* This should check HWCAP_MTE when it is available.  */
> -#define MTE_ENABLED() (false)
> +/* This should check HWCAP2_MTE when it is available: current
> +   linux kernel does not expose it, but its value is reserved.
> +   This is needed to make glibc MTE-safe on future systems in
> +   case user code enables MTE. The ABI contract for enabling

Double space after period.  Besides it, the patch is ok.

> +   MTE is not yet specified, but it can be useful for at least
> +   debugging which does not need a contract.  */
> +#define FUTURE_HWCAP2_MTE (1 << 18)
> +#define MTE_ENABLED() (GLRO(dl_hwcap2) & FUTURE_HWCAP2_MTE)
>  
>  extern __typeof (__redirect_strlen) __strlen;
>  
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-07-27 13:52 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-27  9:26 [PATCH] aarch64: Use future HWCAP2_MTE in ifunc resolver Szabolcs Nagy
2020-07-27  9:54 ` Florian Weimer
2020-07-27 11:42   ` Szabolcs Nagy
2020-07-27 11:47     ` Florian Weimer
2020-07-27 13:52 ` Adhemerval Zanella

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).