~ubuntu-support-team/binutils/+git/binutils-gdb:users/luisgpm/aarch64-mte-v3

Last commit made on 2020-07-16
Get this branch:
git clone -b users/luisgpm/aarch64-mte-v3 https://git.launchpad.net/~ubuntu-support-team/binutils/+git/binutils-gdb

Branch merges

Branch information

Name:
users/luisgpm/aarch64-mte-v3
Repository:
lp:~ubuntu-support-team/binutils/+git/binutils-gdb

Recent commits

46195ac... by Luis

Add memory tagging testcases

Add an AArch64-specific test and a more generic memory tagging test that
other architectures can run.

Even though architectures not supporting memory tagging can run the memory
tagging tests, the runtime check will make the tests bail out early, as it
would make no sense to proceed without proper support.

It is also tricky to do any further runtime tests for memory tagging, given
we'd need to deal with tags, and those are arch-specific. Therefore the
test in gdb.base is more of a smoke test.

If an architecture wants to implement memory tagging, then it makes sense to
have tests within gdb.arch instead.

gdb/testsuite/ChangeLog:

YYYY-MM-DD Luis Machado <email address hidden>

 * gdb.arch/aarch64-mte.c: New file.
 * gdb.arch/aarch64-mte.exp: New test.
 * gdb.base/memtag.c: New file.
 * gdb.base/memtag.exp: New test.
 * lib/gdb.exp (supports_memtag): New function.

59bdb29... by Luis

Add NEWS entry.

Mention the new packets and memory tagging features.

gdb/ChangeLog:

YYYY-MM-DD Luis Machado <email address hidden>

 * NEWS: Mention memory tagging changes.

df7edbc... by Luis

Document new "x" and "print" memory tagging extensions

Document the changes to the "print" and "x" commands to support memory
tagging.

gdb/doc/ChangeLog:

YYYY-MM-DD Luis Machado <email address hidden>

 * gdb.texinfo (Data): Document memory tagging changes to the "print"
 command.
 (Examining Memory): Document memory tagging changes to the "x"
 command.
 (Memory Tagging): Update with more information on changes to the "x"
 and "print" commands.

c809eaa... by Luis

Extend "x" and "print" commands to support memory tagging

Extend the "x" and "print" commands to make use of memory tagging
functionality, if supported by the architecture.

The "print" command will point out any possible tag mismatches it finds
when dealing with pointers, in case such a pointer is tagged. No additional
modifiers are needed.

Suppose we have a pointer "p" with value 0x1234 (logical tag 0x0) and that we
have an allocation tag of 0x1 for that particular area of memory. This is the
expected output:

(gdb) p/x p
Logical tag (0x0) does not match the allocation tag (0x1).
$1 = 0x1234

The "x" command has a new 'm' modifier that will enable displaying of
allocation tags alongside the data dump. It will display one allocation
tag per line.

AArch64 has a tag granule of 16 bytes, which means we can have one tag for
every 16 bytes of memory. In this case, this is what the "x" command will
display with the new 'm' modifier:

(gdb) x/32bxm p
<Allocation Tag 0x1 for range [0x1230,0x1240)>
0x1234: 0x01 0x02 0x00 0x00 0x00 0x00 0x00 0x00
0x123c: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
<Allocation Tag 0x1 for range [0x1240,0x1250)>
0x1244: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x124c: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00

(gdb) x/4gxm a
<Allocation Tag 0x1 for range [0x1230,0x1240)>
0x1234: 0x0000000000000201 0x0000000000000000
<Allocation Tag 0x1 for range [0x1240,0x1250)>
0x1244: 0x0000000000000000 0x0000000000000000

gdb/ChangeLog:

YYYY-MM-DD Luis Machado <email address hidden>

 * printcmd.c (decode_format): Handle the 'm' modifier.
 (do_examine): Display allocation tags when required/supported.
 (should_validate_memtags): New function.
 (print_command_1): Display memory tag mismatches.
 * valprint.h (struct format_data) <print_tags>: New field.

e92884e... by Luis

Documentation for the new mtag commands

Document the new "mtag" command prefix and all of its subcommands.

gdb/doc/ChangeLog:

YYYY-MM-DD Luis Machado <email address hidden>

 * gdb.textinfo (Memory Tagging): New subsection.
 (AArch64 Memory Tagging Extension): New subsection.

8b8f188... by Luis

New mtag commands

Add new commands under the "mtag" prefix to allow users to inspect, modify and
check memory tags in different ways.

The available subcommands are the following:

- mtag showltag <expression>: Shows the logical tag for a particular address.

- mtag setltag <expression> <tag>: Prints the address tagged with the logical
  tag <tag>.

- mtag showatag <expression>: Shows the allocation tag for a particular address.

- mtag setatag <expression> <length> <tags>: Sets one or more allocation tags to
  the specified tags.

- mtag check <expression>: Check if the logical tag in <address> matches its
  allocation tag.

These commands make use of the memory tagging gdbarch methods, and are still
available, but disabled, when memory tagging is not supported by the
architecture.

I've pondered about a way to make these commands invisible when memory tagging
is not available, but given the check is at runtime (and support may come and go
based on a process' configuration), that is a bit too late in the process to
either not include the commands or get rid of them.

Ideas are welcome.

gdb/ChangeLog:

YYYY-MM-DD Luis Machado <email address hidden>

 * printcmd.c: Include gdbsupport/rsp-low.h.
 (mtaglist): New static global.
 (process_print_command_args): Factored out of
 print_command_1.
 (print_command_1): Use process_print_command_args.
 (show_addr_not_tagged, show_memtag_unsupported, mtag_command)
 (mtag_showtag_command, mtag_showltag_command, mtag_showatag_command)
 (parse_setltag_input, mtag_setltag_command, parse_setatag_input)
 (mtag_setatag_command, mtag_check_command): New functions.
 (_initialize_printcmd): Add "mtag" prefix and subcommands.

gdbsupport/ChangeLog:

YYYY-MM-DD Luis Machado <email address hidden>

 * rsp-low.cc (fromhex): Change error message text to not be
 RSP-specific.

2976b5d... by Luis

AArch64: Add gdbserver MTE support

Adds the AArch64-specific memory tagging support (MTE) by implementing the
required hooks and checks for GDBserver.

gdbserver/ChangeLog:

YYYY-MM-DD Luis Machado <email address hidden>

 * Makefile.in (SFILES): Add /../gdb/nat/aarch64-mte-linux-ptrace.c.
 * configure.srv (aarch64*-*-linux*): Add arch/aarch64-mte-linux.o and
 nat/aarch64-mte-linux-ptrace.o.
 * linux-aarch64-low.cc: Include nat/aarch64-mte-linux-ptrace.h.
 (class aarch64_target) <supports_memory_tagging>
 <fetch_memtags, store_memtags>: New method overrides.
 (aarch64_target::supports_memory_tagging)
 (aarch64_target::fetch_memtags)
 (aarch64_target::store_memtags): New methods.

e2d3153... by Luis

AArch64: Report tag violation error information

Whenever a memory tag violation occurs, we get a SIGSEGV. Additional
information can be obtained through the siginfo data structure.

For AArch64 the Linux kernel may expose the fault address and tag
information, if we have a synchronous event. Otherwise there is
no fault address available.

gdb/ChangeLog:

YYYY-MM-DD Luis Machado <email address hidden>

 * aarch64-linux-tdep.c
 (aarch64_linux_handle_segmentation_fault): New function.
 (aarch64_linux_init_abi): Register
 aarch64_linux_handle_segmentation_fault as segmentation fault hook.
 * arch/aarch64-linux.h (SEGV_MTEAERR): Define.
 (SEGV_MTESERR): Define.

24e4b06... by Luis

AArch64: Add unit testing for logical tag set/get operations

Add some unit testing to exercise setting/getting logical tags in the
AArch64 implementation.

gdb/ChangeLog:

YYYY-MM-DD Luis Machado <email address hidden>

 * aarch64-linux-tdep.c: Include gdbsupport/selftest.h.
 (aarch64_linux_ltag_tests): New function.
 (_initialize_aarch64_linux_tdep): Register aarch64_linux_ltag_tests.

b2c6c98... by Luis

AArch64: Implement the memory tagging gdbarch hooks

This patch implements the memory tagging gdbarch hooks for AArch64, for
the MTE feature.

gdb/ChangeLog:

YYYY-MM-DD Luis Machado <email address hidden>

 * aarch64-linux-tdep.c: Include target.h, arch-utils.h, value.h.
 (aarch64_linux_get_atag, aarch64_linux_tagged_address_p)
 (aarch64_linux_memtag_mismatch_p, aarch64_linux_set_memtags)
 (aarch64_linux_get_memtag, aarch64_linux_memtag_to_string): New
 functions.
 (aarch64_linux_init_abi): Initialize MTE-related gdbarch hooks.
 * arch/aarch64-mte-linux.c (make_ltag_bits, make_ltag)
 (aarch64_linux_set_ltag, aarch64_linux_get_ltag): New functions.
 * arch/aarch64-mte-linux.h (MTE_LOGICAL_TAG_START_BIT)
 (MTE_LOGICAL_MAX_VALUE): Define.
 (make_ltag_bits, make_ltag, aarch64_linux_set_ltag)
 (aarch64_linux_get_ltag): New prototype.