Page MenuHomePhabricator

[compiler-rt] TlsBaseAddr value for darwin arm64
ClosedPublic

Authored by devnexen on Oct 30 2021, 12:11 AM.

Details

Summary

getting the tls base address. unlike linux arm64, the tpidr_el0 returns always 0 (aka unused) thus using tpidrro_el0 instead clearing up the cpu id encoded in the lower bits.

Diff Detail

Event Timeline

devnexen created this revision.Oct 30 2021, 12:11 AM
devnexen requested review of this revision.Oct 30 2021, 12:11 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 30 2021, 12:11 AM
Herald added a subscriber: Restricted Project. · View Herald Transcript
devnexen updated this revision to Diff 383561.Oct 30 2021, 12:39 AM
devnexen updated this revision to Diff 383564.Oct 30 2021, 1:57 AM

Hi David, thanks for the patch! :)

I have no objections; before landing, can you help me understand and document in the commit message which problem this is solving or what it is improving?
I see that TlsBaseAddr() now also returns a non-zero value for arm64 and that it is only used in GetThreadStackAndTls() which has a couple of callers.

void GetThreadStackAndTls(bool main, uptr *stk_addr, uptr *stk_size, uptr *tls_addr, uptr *tls_size);
yln added a comment.Nov 8 2021, 9:46 AM

Note, I am getting the following warning when compiling your patch:

compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp:559:36: warning: value size does not match register size specified by the constraint and modifier [-Wasm-operand-widths]
  asm("mrs %0, tpidrro_el0" : "=r"(segbase));
                                   ^
compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp:559:12: note: use constraint modifier "w"
  asm("mrs %0, tpidrro_el0" : "=r"(segbase));
           ^~
           %w0

Note, I am getting the following warning when compiling your patch:

compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp:559:36: warning: value size does not match register size specified by the constraint and modifier [-Wasm-operand-widths]
  asm("mrs %0, tpidrro_el0" : "=r"(segbase));
                                   ^
compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp:559:12: note: use constraint modifier "w"
  asm("mrs %0, tpidrro_el0" : "=r"(segbase));
           ^~
           %w0

the warning is weird, I do not get this on my mac M1 arm64, compiled with Xcode clang.

devnexen updated this revision to Diff 385616.Nov 8 2021, 1:31 PM
devnexen edited the summary of this revision. (Show Details)

Note, I am getting the following warning when compiling your patch:

compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp:559:36: warning: value size does not match register size specified by the constraint and modifier [-Wasm-operand-widths]
  asm("mrs %0, tpidrro_el0" : "=r"(segbase));
                                   ^
compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp:559:12: note: use constraint modifier "w"
  asm("mrs %0, tpidrro_el0" : "=r"(segbase));
           ^~
           %w0

hopefully the last diff clears the warning even tough should be unnecessary.

yln accepted this revision.Nov 8 2021, 2:06 PM

Are there any tests that now pass (but didn't before)?

This revision is now accepted and ready to land.Nov 8 2021, 2:06 PM
This revision was landed with ongoing or failed builds.Nov 8 2021, 2:27 PM
This revision was automatically updated to reflect the committed changes.

next step would be the tlssize.