[PATCH v3 2/2] aarch64: Add memory tagging support for setjmp/longjmp routines
Yury Khrustalev
yury.khrustalev@arm.com
Mon Mar 16 09:21:35 GMT 2026
On Thu, Mar 12, 2026 at 12:36:48PM +0200, Claudiu Zissulescu wrote:
> > >
> > > This patch relies on the USE_MTAG macro, which must be defined through
> > > the --enable-memory-tagging option.
> >
> > This flag also enables heap tagging in malloc. We probably shouldn't
> > enable both with the same flag as the use cases could be quite
> > different.
>
> I can add a different one. However, the above flag needs to be reworked as
> the name and its documentation is too wide.
>
> > > + LIBC_TRY_CC_OPTION([$CFLAGS $CPPFLAGS -Werror -fsanitize=memtag-stack -march=armv8.5-a+memtag],
> >
> > This check fails on GCC 15.2.1. Will the support be added in GCC 16?
> >
> Yes.
>
>
> > > +ifeq (yes,$(have-memtag-sanitizer))
> > > +tests += tst-mte-jmp \
> > > + tst-mte-stack
> >
> > Nit: this usually should be written as
> >
> > +tests += \
> > + tst-mte-jmp \
> > + tst-mte-stack \
> > + # tests
> >
> Noted.
>
> > > +CFLAGS-tst-mte-jmp.c += -fsanitize=memtag-stack -march=armv8.5-a+memtag
> > > +LDFLAGS-tst-mte-jmp += -Wl,-z,memtag-stack -Wl,-z,memtag-mode=sync
> > > +CFLAGS-tst-mte-stack.c += -fsanitize=memtag-stack -march=armv8.5-a+memtag -w
> >
> > Probably don't use -w? What are the warnings that need to be suppressed?
>
> gcc16 complains about the sink value not being use. I'll find a better way
> to deal with that.
>
> >
> > > +LDFLAGS-tst-mte-stack += -Wl,-z,memtag-stack -Wl,-z,memtag-mode=sync
> >
> > What about testing sync mode?
>
> We can have the same tests executed with async mode too. However, this patch
> doesn't test the hardware capabilities, but the feature of handling mte
> enabled stacks.
The patch contains code that processes sync and async use cases, but we
only test one part of this code. I was merely pointing out that we can
increase test coverage here.
>
> > +
> > > +#undef count
> > > +#undef tmp
> > > +#endif
> > > +
> >
> > Is this guaranteed to work with stack tagging implemented by other
> > compilers? Is there a spec for this ABI?
>
> The above is design to handle the output of the only compiler which can
> generate MTE and compile glibc which I know. Please, let me know if there
> are any other compilers that do that, as well as their documentation
> covering their MTE implementation.
To be clear, what I was trying to point out here was that I think this code
is, in fact, describing some new ABI, and that to me this means that we should
have some form of documentation describing this ABI.
The best way to do that would be to get this added to the Arm ABI document
along with other quirks related to setjmp / longjmp.
We at Arm can help you describe this but you are in the best position to
explain to us what you need from this MTE use case.
Thanks,
Yury
More information about the Libc-alpha
mailing list