This is an archive of the discontinued LLVM Phabricator instance.

[lldb][AArch64] Add thread local storage tpidr register
ClosedPublic

Authored by DavidSpickett on Jun 9 2023, 4:13 AM.

Details

Summary

This register is used as the pointer to the current thread
local storage block and is read from NT_ARM_TLS on Linux.

Though tpidr will be present on all AArch64 Linux, I am soon
going to add a second register tpidr2 to this set.

tpidr is only present when SME is implemented, therefore the
NT_ARM_TLS set will change size. This is why I've added this
as a dynamic register set to save changes later.

Diff Detail

Event Timeline

DavidSpickett created this revision.Jun 9 2023, 4:13 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 9 2023, 4:13 AM
DavidSpickett requested review of this revision.Jun 9 2023, 4:13 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 9 2023, 4:13 AM

Correct size getter in read method. This just happened to work because the MTE
set also contains one register.

omjavaid accepted this revision.Jun 15 2023, 2:10 AM

This looks good to me, just a minor nit above. I have not run the test myself.

lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp
295

Do we need to read this register on every stop ? similar to SVE vg? May be consider moving this else if before SVE which is still optionally available in most cases.

This revision is now accepted and ready to land.Jun 15 2023, 2:10 AM
DavidSpickett planned changes to this revision.Jun 15 2023, 2:32 AM
DavidSpickett added inline comments.
lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_arm64.cpp
295

What is the criteria for "need to"? I assume for vg we need it because that tells us the vector length, so we can handle SVE changing per stop.

In this case this register is always the same size and only the value of it can be changed. So I think the answer is no we don't need to read it on every stop. I will move it.

(later if we have SME there will be a second register, but if you have SME it's always there it doesn't come and go)

Matt added a subscriber: Matt.Jun 15 2023, 7:49 PM

Move if up to before SVE registers.

This revision is now accepted and ready to land.Jun 16 2023, 7:42 AM

Always add the TLS regset mask value. It worked on my QEMU setup because
it also had the other extensions, but an armv8-a machine didn't.

DavidSpickett planned changes to this revision.Jun 16 2023, 8:10 AM

Also found that clang at -00 will only read tpidr once vs. the gcc I had that would read it fresh each time. I can't rely on either of those to happen, so will change the test to use assembly to directly read and write tpidr instead.

Change test so that we're reading with assembly and writing with lldb and
vice versa. Instead of trying to get clever and actually move the thread storage about.

This revision is now accepted and ready to land.Jun 19 2023, 3:44 AM
DavidSpickett edited the summary of this revision. (Show Details)Jun 19 2023, 4:50 AM