This is an archive of the discontinued LLVM Phabricator instance.

[lldb][AArch64] Linux corefile support for SME
ClosedPublic

Authored by DavidSpickett on Aug 22 2023, 3:07 AM.

Details

Summary

This adds the ability to read streaming SVE registers,
ZA, SVCR and SVG from core files.

Streaming SVE is in a new note NT_ARM_SSVE but otherwise
has the same format as SVE. So I've done the same as I
did for live processes and reused the existing SVE state
with an extra state for the mode variable.

ZA is in a note NT_ARM_ZA and again the handling matches
live processes. Except that it gets setup only once. A
disabled ZA reads as 0s as usual.

SVCR and SVG are pseudo registers, generated from the notes.

An important detail is that the notes represent what
you would have got if you read from ptrace at the time of
the crash.

This means that for a corefile in non-streaming mode,
there is still an NT_ARM_SSVE note and we check the header
flags to tell if it is active. We cannot just say if you
have the note you're in streaming mode.

The kernel does not provide register values for the inactive
mode and even if it did, they would be undefined, so if we find
streaming state, we ignore the non-streaming state.

Same for ZA, a disabled ZA still has the header in the note.

The tests do not cover all combinations but enough different
vector lengths, modes and ZA states to be confident.

Diff Detail

Event Timeline

DavidSpickett created this revision.Aug 22 2023, 3:07 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 22 2023, 3:07 AM
DavidSpickett requested review of this revision.Aug 22 2023, 3:07 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 22 2023, 3:07 AM

I did have some code to verify the arguments were passed correctly to the program but it made each core file 200k so I don't think it's worth it.

Matt added a subscriber: Matt.Aug 22 2023, 3:30 PM

Rebase, adjust to handling ZA as part of the SME register set.

Format with black.

DavidSpickett edited the summary of this revision. (Show Details)Sep 15 2023, 6:46 AM

sme_regs -> sme_pseudo_regs and rebase.

omjavaid accepted this revision.Sep 21 2023, 3:08 AM

This looks good with just one nit above.

lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.cpp
74–82

if (m_sve_data.GetByteSize() >= sizeof(sve::user_sve_header)) {
below seems redundant because IsSSVEEnabled returns true when

if (ssve_data.GetByteSize() >= sizeof(sve::user_sve_header))
  opt_regsets.Set(RegisterInfoPOSIX_arm64::eRegsetMaskSSVE);

has set it enabled.

This revision is now accepted and ready to land.Sep 21 2023, 3:08 AM

Remove redundant if.

DavidSpickett marked an inline comment as done.Sep 21 2023, 5:22 AM
This revision was landed with ongoing or failed builds.Sep 21 2023, 5:24 AM
This revision was automatically updated to reflect the committed changes.