[all-commits] [llvm/llvm-project] 88fdce: [lldb] Remove non address bits from memory read ar...

David Spickett via All-commits all-commits at lists.llvm.org
Tue Jan 11 05:24:22 PST 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 88fdce5be696c7ef992cffce9da9ec6895a1abfc
      https://github.com/llvm/llvm-project/commit/88fdce5be696c7ef992cffce9da9ec6895a1abfc
  Author: David Spickett <david.spickett at linaro.org>
  Date:   2022-01-11 (Tue, 11 Jan 2022)

  Changed paths:
    M lldb/source/Commands/CommandObjectMemory.cpp
    A lldb/test/API/linux/aarch64/tagged_memory_read/Makefile
    A lldb/test/API/linux/aarch64/tagged_memory_read/TestAArch64LinuxTaggedMemoryRead.py
    A lldb/test/API/linux/aarch64/tagged_memory_read/main.c
    M llvm/docs/ReleaseNotes.rst

  Log Message:
  -----------
  [lldb] Remove non address bits from memory read arguments

Addresses on AArch64 can have top byte tags, memory tags and pointer
authentication signatures in the upper bits.

While testing memory tagging I found that memory read couldn't
read a range if the two addresses had different tags. The same
could apply to signed pointers given the right circumstance.

(lldb) memory read mte_buf_alt_tag mte_buf+16
error: end address (0x900fffff7ff8010) must be greater than the start
address (0xa00fffff7ff8000).

Or it would try to read a lot more memory than expected.

(lldb) memory read mte_buf mte_buf_alt_tag+16
error: Normally, 'memory read' will not read over 1024 bytes of data.
error: Please use --force to override this restriction just once.
error: or set target.max-memory-read-size if you will often need a
larger limit.

Fix this by removing non address bits before we calculate the read
range. A test is added for AArch64 Linux that confirms this by using
the top byte ignore feature.

This means that if you do read with a tagged pointer the output
does not include those tags. This is potentially confusing but I think
overall it's better that we don't pretend that we're reading memory
from a range that the process is unable to map.

(lldb) p ptr1
(char *) $4 = 0x3400fffffffff140 "\x80\xf1\xff\xff\xff\xff"
(lldb) p ptr2
(char *) $5 = 0x5600fffffffff140 "\x80\xf1\xff\xff\xff\xff"
(lldb) memory read ptr1 ptr2+16
0xfffffffff140: 80 f1 ff ff ff ff 00 00 38 70 bc f7 ff ff 00 00  ........8p......

Reviewed By: omjavaid, danielkiss

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




More information about the All-commits mailing list