[all-commits] [llvm/llvm-project] da2e61: [lldb][AArch64] Add memory tag reading to lldb-server

David Spickett via All-commits all-commits at lists.llvm.org
Thu Jun 24 09:03:09 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: da2e614f56b196b37175e2babfac8ed7b43ab624
      https://github.com/llvm/llvm-project/commit/da2e614f56b196b37175e2babfac8ed7b43ab624
  Author: David Spickett <david.spickett at linaro.org>
  Date:   2021-06-24 (Thu, 24 Jun 2021)

  Changed paths:
    M lldb/include/lldb/Host/common/NativeProcessProtocol.h
    M lldb/include/lldb/Host/linux/Ptrace.h
    M lldb/include/lldb/Utility/StringExtractorGDBRemote.h
    M lldb/source/Host/common/NativeProcessProtocol.cpp
    M lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
    M lldb/source/Plugins/Process/Linux/NativeProcessLinux.h
    M lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux.h
    M lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp
    M lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.h
    M lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
    M lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h
    M lldb/source/Utility/StringExtractorGDBRemote.cpp
    A lldb/test/API/tools/lldb-server/memory-tagging/Makefile
    A lldb/test/API/tools/lldb-server/memory-tagging/TestGdbRemoteMemoryTagging.py
    A lldb/test/API/tools/lldb-server/memory-tagging/main.c

  Log Message:
  -----------
  [lldb][AArch64] Add memory tag reading to lldb-server

This adds memory tag reading using the new "qMemTags"
packet and ptrace on AArch64 Linux.

This new packet is following the one used by GDB.
(https://sourceware.org/gdb/current/onlinedocs/gdb/General-Query-Packets.html)

On AArch64 Linux we use ptrace's PEEKMTETAGS to read
tags and we assume that lldb has already checked that the
memory region actually has tagging enabled.

We do not assume that lldb has expanded the requested range
to granules and expand it again to be sure.
(although lldb will be sending aligned ranges because it happens
to need them client side anyway)
Also we don't assume untagged addresses. So for AArch64 we'll
remove the top byte before using them. (the top byte includes
MTE and other non address data)

To do the ptrace read NativeProcessLinux will ask the native
register context for a memory tag manager based on the
type in the packet. This also gives you the ptrace numbers you need.
(it's called a register context but it also has non register data,
so it saves adding another per platform sub class)

The only supported platform for this is AArch64 Linux and the only
supported tag type is MTE allocation tags. Anything else will
error.

Ptrace can return a partial result but for lldb-server we will
be treating that as an error. To succeed we need to get all the tags
we expect.

(Note that the protocol leaves room for logical tags to be
read via qMemTags but this is not going to be implemented for lldb
at this time.)

Reviewed By: omjavaid

Differential Revision: https://reviews.llvm.org/D95601




More information about the All-commits mailing list