Adding MIPS 32-bit and 64-bit support for Scudo.
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
Thank you for this. I am curious, what did you test this on?
I have no experience on MIPS, would you be able to provide some help in case of any breakage?
Hi,
Thank you for this. I am curious, what did you test this on?
I have no experience on MIPS, would you be able to provide some help in case of any breakage?
I have tested this on a mips64 little endian machine. All tests are passing.
Yes, I will be happy to help if there is any breakage.
Regards,
Sagar
Sagar, rL301158 broke the buildbot clang-cmake-mips starting with http://lab.llvm.org:8011/builders/clang-cmake-mips/builds/3179 . Can you investigate?
Hi Simon,
I am investigating the failure. Meanwhile I'll revert the commit.
Regards,
Sagar
Added 64-bit atomic functions for mips32 which are required in sanitizer common.
We needed to add these function because we were getting undefined references to sync_fetch_and_add_8, sync_val_compare_and_swap_8 functions.
Still LGTM for the Scudo side of things, but not being familiar with MIPS and the platform in general, I don't think I can provide appropriate feedback on the atomic modifications done in sanitizer_common.
If someone else could have a look at it, that would be great.
This appears functionally correct, but really requires documentation explaining the implementation.
My other concern is that having a single global lock for all atomic functions may be something of a bottleneck in terms of performance. The lock could be duplicated on a per template basis to avoid unnecessary contention but I'd really prefer if we could simply use template specialisation to handle 64bit types.
lib/sanitizer_common/sanitizer_atomic_clang_other.h | ||
---|---|---|
20 | This preprocessor define check I believe to too broad. Instead it should be: #if defined(_MIPS_SIM) && _MIPS_SIM == _ABIO32 As it's O32 that cannot use 64 bit atomics. | |
29–32 | This structure definition is strange. I am guessing that you're allocating a typical MIPS sized cache into the data section, with a lock and padding, the purpose of the padding to avoid spurious ll/sc failures due to writes near the lock. I understand that you're using a single global lock for __mips_sync_* , so that you can update types larger than a word on MIPS32 platforms, as they do not have larger than word sized atomic updates. This hunk really needs a (long) comment to explain the reasoning and implementation. |
LGTM with inline comments addressed.
Please add comments for the bug addition to lib/sanitizer_common/sanitizer_atomic_clang_other.h, other maintainers will not necessarily know why MIPS requires an internal spinlock for 8 byte atomics.
lib/sanitizer_common/sanitizer_atomic_clang.h | ||
---|---|---|
84 | The casts of (u64) for cmpv and xchg should be reinterpret_cast<u64> rather than C-style casts. C style casts trigger conversions whereas we want to reinterpret the bit pattern. | |
lib/sanitizer_common/sanitizer_atomic_clang_other.h | ||
20 | Prefix this hunk with a comment saying that MIPS32 or code compiled for the O32 ABI on MIPS does not support atomics > 4 bytes. To address this lack of functionality, the sanitizer library provides helper methods which use an internal spin lock mechanism to emulate atomic operations when the size is 8 bytes. | |
148 | reinterpret_cast<u64> rather than (u64). |
Committed in revision 305682.
Thanks to Simon for the review and for fixing the build breakage.
The casts of (u64) for cmpv and xchg should be reinterpret_cast<u64> rather than C-style casts. C style casts trigger conversions whereas we want to reinterpret the bit pattern.