[AArch64] MTE corefile support

Teach GDB how to dump memory tags for AArch64 when using the gcore command
and how to read memory tag data back from a core file generated by GDB
(via gcore) or by the Linux kernel.

The format is documented in the Linux Kernel documentation [1].

Each tagged memory range (listed in /proc/<pid>/smaps) gets dumped to its
own PT_AARCH64_MEMTAG_MTE segment. A section named ".memtag" is created for each
of those segments when reading the core file back.

To save a little bit of space, given MTE tags only take 4 bits, the memory tags
are stored packed as 2 tags per byte.

When reading the data back, the tags are unpacked.

I've added a new testcase to exercise the feature.

Build-tested with --enable-targets=all and regression tested on aarch64-linux
Ubuntu 20.04.

[1] Documentation/arm64/memory-tagging-extension.rst (Core Dump Support)
This commit is contained in:
Luis Machado
2022-03-31 11:42:35 +01:00
parent d0ff5ca959
commit 68cffbbd44
17 changed files with 1048 additions and 8 deletions

View File

@@ -25765,6 +25765,25 @@ options that can be controlled at runtime and emulates the @code{prctl}
option @code{PR_SET_TAGGED_ADDR_CTRL}. For further information, see the
documentation in the Linux kernel.
@value{GDBN} supports dumping memory tag data to core files through the
@command{gcore} command and reading memory tag data from core files generated
by the @command{gcore} command or the Linux kernel.
When a process uses memory-mapped pages protected by memory tags (for
example, AArch64 MTE), this additional information will be recorded in
the core file in the event of a crash or if @value{GDBN} generates a core file
from the current process state.
The memory tag data will be used so developers can display the memory
tags from a particular memory region (using the @samp{m} modifier to the
@command{x} command, using the @command{print} command or using the various
@command{memory-tag} subcommands.
In the case of a crash, @value{GDBN} will attempt to retrieve the memory tag
information automatically from the core file, and will show one of the above
messages depending on whether the synchronous or asynchronous mode is selected.
@xref{Memory Tagging}. @xref{Memory}.
@node i386
@subsection x86 Architecture-specific Issues