[compiler-rt] r330598 - [scudo] Read ARM feature bits using Fuchsia APIs.
Kostya Kortchinsky via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 23 07:53:13 PDT 2018
Author: cryptoad
Date: Mon Apr 23 07:53:13 2018
New Revision: 330598
URL: http://llvm.org/viewvc/llvm-project?rev=330598&view=rev
Log:
[scudo] Read ARM feature bits using Fuchsia APIs.
Summary:
Fuchsia uses zx_system_get_features in lieu of getauxval.
Use this call when checking for CRC32 support.
Reviewers: cryptoad
Reviewed By: cryptoad
Subscribers: delcypher, llvm-commits, #sanitizers, kristof.beyls, chrib
Differential Revision: https://reviews.llvm.org/D45896
Modified:
compiler-rt/trunk/lib/scudo/scudo_utils.cpp
Modified: compiler-rt/trunk/lib/scudo/scudo_utils.cpp
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/scudo/scudo_utils.cpp?rev=330598&r1=330597&r2=330598&view=diff
==============================================================================
--- compiler-rt/trunk/lib/scudo/scudo_utils.cpp (original)
+++ compiler-rt/trunk/lib/scudo/scudo_utils.cpp Mon Apr 23 07:53:13 2018
@@ -17,7 +17,10 @@
# include <cpuid.h>
#elif defined(__arm__) || defined(__aarch64__)
# include "sanitizer_common/sanitizer_getauxval.h"
-# if SANITIZER_POSIX
+# if SANITIZER_FUCHSIA
+# include <zircon/syscalls.h>
+# include <zircon/features.h>
+# elif SANITIZER_POSIX
# include "sanitizer_common/sanitizer_posix.h"
# include <fcntl.h>
# endif
@@ -110,9 +113,17 @@ INLINE bool areBionicGlobalsInitialized(
}
bool hasHardwareCRC32() {
+#if SANITIZER_FUCHSIA
+ u32 HWCap;
+ zx_status_t Status = zx_system_get_features(ZX_FEATURE_KIND_CPU, &HWCap);
+ if (Status != ZX_OK || (HWCap & ZX_ARM64_FEATURE_ISA_CRC32) == 0)
+ return false;
+ return true;
+#else
if (&getauxval && areBionicGlobalsInitialized())
return !!(getauxval(AT_HWCAP) & HWCAP_CRC32);
return hasHardwareCRC32ARMPosix();
+#endif // SANITIZER_FUCHSIA
}
#else
bool hasHardwareCRC32() { return false; }
More information about the llvm-commits
mailing list