This is an archive of the discontinued LLVM Phabricator instance.

[scudo] Overhaul hardware CRC32 feature detection
ClosedPublic

Authored by cryptoad on Nov 21 2017, 1:57 PM.

Details

Summary

This patch aims at condensing the hardware CRC32 feature detection and making
it slightly more effective on Android.

The following changes are included:

  • remove the CPUFeature enum, and get rid of one level of nesting of functions: we only used CRC32, so we just implement and use hasHardwareCRC32;
  • allow for a weak getauxval: the Android toolchain is compiled at API level 14 for Android ARM, meaning no getauxval at compile time, yet we will run on API level 27+ devices. The /proc/self/auxv fallback can work but is worthless for a process like init where the proc filesystem doesn't exist yet. If a weak getauxval doesn't exist, then fallback.
  • couple of extra corrections.

Event Timeline

cryptoad created this revision.Nov 21 2017, 1:57 PM
alekseyshl accepted this revision.Nov 21 2017, 2:43 PM
alekseyshl added inline comments.
lib/scudo/scudo_utils.cpp
102

I think it's worth moving this weak definition into sanitizer_common/sanitizer_getauxval.h (under proper ifdefs and comments, indeed), so everyone can can benefit from it.

This revision is now accepted and ready to land.Nov 21 2017, 2:43 PM
cryptoad updated this revision to Diff 123856.Nov 21 2017, 2:59 PM
cryptoad marked an inline comment as done.

Moving the weak definition of getauxval to the header, with comment.

cryptoad updated this revision to Diff 123956.Nov 22 2017, 9:15 AM

Couple of changes regarding consistency in the general area of the changes:

  • s/inline/INLINE/;
  • use & for the weak check of computeHardwareCRC32 since we are using that form everywhere else;
cryptoad closed this revision.Nov 22 2017, 10:30 AM