This is an archive of the discontinued LLVM Phabricator instance.

[lldb][AArch64] Annotate synchronous tag faults
ClosedPublic

Authored by DavidSpickett on Jun 30 2021, 3:05 AM.

Details

Summary

In the latest Linux kernels synchronous tag faults
include the tag bits in their address.
This change adds logical and allocation tags to the
description of synchronous tag faults.
(asynchronous faults have no address)

Process 1626 stopped

  • thread #1, name = 'a.out', stop reason = signal SIGSEGV: sync tag check fault (fault address: 0x900fffff7ff9010 logical tag: 0x9 allocation tag: 0x0)

This extends the existing description and will
show as much as it can on the rare occasion something
fails.

This change supports AArch64 MTE only but other
architectures could be added by extending the
switch at the start of AnnotateSyncTagCheckFault.
The rest of the function is generic code.

Tests have been added for synchronous and asynchronous
MTE faults.

Diff Detail

Event Timeline

DavidSpickett created this revision.Jun 30 2021, 3:05 AM
DavidSpickett requested review of this revision.Jun 30 2021, 3:05 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 30 2021, 3:05 AM
DavidSpickett added a subscriber: pcc.

@pcc This makes use of the kernel changes you did, let me know if I have anything wrong.

Note that the situation where you can't read the allocation tag isn't testable, but the code will just show the logical tag in the event it did happen.

omjavaid accepted this revision.Jul 12 2021, 3:11 AM
omjavaid added inline comments.
lldb/test/API/linux/aarch64/mte_tag_faults/main.c
30

Can we add a bit more detail on what this and following mmap step is doing.?

This revision is now accepted and ready to land.Jul 12 2021, 3:11 AM
pcc added a comment.Jul 12 2021, 6:14 PM

Programs must enable the tagged address ABI to
receive these signals and are also opting into the
presence of these tag bits.

This is actually independent of the tagged address ABI. For siginfo data structures read via ptrace(PTRACE_GETSIGINFO) we will always have the tag in si_addr provided that the kernel is new enough. It's only the signal delivery via sigaction where the user program needs to opt in (via SA_EXPOSE_TAGBITS), and that is again independent of the tagged address ABI.

lldb/test/API/linux/aarch64/mte_tag_faults/main.c
39

This seems like a bit of a roundabout way to set the address tag to 10. Why not just set it directly? i.e.

char *tagged_buf = buf + (10ULL << 56);

Or wrap that in a function to make things more self documenting. Then you don't need to set the inclusion mask in the prctl call.

  • Removed use of tagged address ABI
  • Set pointer tags with a function instead of generator intrinsic
  • Add a memory access to confirm mapping was done properly
  • Add a few more comments about mmap and others
DavidSpickett edited the summary of this revision. (Show Details)Jul 13 2021, 8:40 AM
DavidSpickett marked an inline comment as done.

This is actually independent of the tagged address ABI.

Thanks for the info, I keep thinking I need to enable it but never do. Updated the test case and commit msg.

clang-format the test file.

DavidSpickett marked an inline comment as done.Jul 13 2021, 8:44 AM

Account for fault addresses not being granule aligned by asking
for fault_addr to fault_addr+1 which always gives you 1 tag back.
(same trick we do in "memory tag read" if we only have a start address)

Correct potentitally -> potentially.

This revision was landed with ongoing or failed builds.Jul 29 2021, 2:26 AM
This revision was automatically updated to reflect the committed changes.