[compiler-rt] r367925 - [Sanitizer] Linux refactor shadow huge page mode handling
David Carlier via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 5 13:54:36 PDT 2019
Author: devnexen
Date: Mon Aug 5 13:54:36 2019
New Revision: 367925
URL: http://llvm.org/viewvc/llvm-project?rev=367925&view=rev
Log:
[Sanitizer] Linux refactor shadow huge page mode handling
Disabling Transparent huge page mode refactored in one function.
Reviewers: vitalybuka
Reviewed By: vitalybuka
Differential Revision: https://reviews.llvm.org/D65771
Modified:
compiler-rt/trunk/lib/asan/asan_shadow_setup.cpp
compiler-rt/trunk/lib/hwasan/hwasan_linux.cpp
compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.h
compiler-rt/trunk/lib/sanitizer_common/sanitizer_posix_libcdep.cpp
compiler-rt/trunk/lib/sanitizer_common/sanitizer_win.cpp
compiler-rt/trunk/lib/tsan/rtl/tsan_platform_posix.cpp
Modified: compiler-rt/trunk/lib/asan/asan_shadow_setup.cpp
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_shadow_setup.cpp?rev=367925&r1=367924&r2=367925&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_shadow_setup.cpp (original)
+++ compiler-rt/trunk/lib/asan/asan_shadow_setup.cpp Mon Aug 5 13:54:36 2019
@@ -37,7 +37,7 @@ void ReserveShadowMemoryRange(uptr beg,
size);
Abort();
}
- if (common_flags()->no_huge_pages_for_shadow) NoHugePagesInRegion(beg, size);
+ SetShadowRegionHugePageMode(beg, size);
if (common_flags()->use_madv_dontdump) DontDumpShadowMemory(beg, size);
}
Modified: compiler-rt/trunk/lib/hwasan/hwasan_linux.cpp
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/hwasan/hwasan_linux.cpp?rev=367925&r1=367924&r2=367925&view=diff
==============================================================================
--- compiler-rt/trunk/lib/hwasan/hwasan_linux.cpp (original)
+++ compiler-rt/trunk/lib/hwasan/hwasan_linux.cpp Mon Aug 5 13:54:36 2019
@@ -211,8 +211,7 @@ void InitThreads() {
static void MadviseShadowRegion(uptr beg, uptr end) {
uptr size = end - beg + 1;
- if (common_flags()->no_huge_pages_for_shadow)
- NoHugePagesInRegion(beg, size);
+ SetShadowRegionHugePageMode(beg, size);
if (common_flags()->use_madv_dontdump)
DontDumpShadowMemory(beg, size);
}
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.h?rev=367925&r1=367924&r2=367925&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.h (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.h Mon Aug 5 13:54:36 2019
@@ -131,7 +131,7 @@ void ReleaseMemoryPagesToOS(uptr beg, up
void IncreaseTotalMmap(uptr size);
void DecreaseTotalMmap(uptr size);
uptr GetRSS();
-bool NoHugePagesInRegion(uptr addr, uptr length);
+bool SetShadowRegionHugePageMode(uptr addr, uptr length);
bool DontDumpShadowMemory(uptr addr, uptr length);
// Check if the built VMA size matches the runtime one.
void CheckVMASize();
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_posix_libcdep.cpp
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_posix_libcdep.cpp?rev=367925&r1=367924&r2=367925&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_posix_libcdep.cpp (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_posix_libcdep.cpp Mon Aug 5 13:54:36 2019
@@ -68,9 +68,11 @@ void ReleaseMemoryPagesToOS(uptr beg, up
SANITIZER_MADVISE_DONTNEED);
}
-bool NoHugePagesInRegion(uptr addr, uptr size) {
+bool SetShadowRegionHugePageMode(uptr addr, uptr size) {
#ifdef MADV_NOHUGEPAGE // May not be defined on old systems.
- return madvise((char *)addr, size, MADV_NOHUGEPAGE) == 0;
+ if (common_flags()->no_huge_pages_for_shadow)
+ return madvise((char *)addr, size, MADV_NOHUGEPAGE) == 0;
+ return true;
#else
return true;
#endif // MADV_NOHUGEPAGE
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_win.cpp
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_win.cpp?rev=367925&r1=367924&r2=367925&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_win.cpp (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_win.cpp Mon Aug 5 13:54:36 2019
@@ -329,7 +329,7 @@ void ReleaseMemoryPagesToOS(uptr beg, up
// FIXME: add madvise-analog when we move to 64-bits.
}
-bool NoHugePagesInRegion(uptr addr, uptr size) {
+bool SetShadowRegionHugePageMode(uptr addr, uptr size) {
// FIXME: probably similar to ReleaseMemoryToOS.
return true;
}
Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_platform_posix.cpp
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_platform_posix.cpp?rev=367925&r1=367924&r2=367925&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_platform_posix.cpp (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_platform_posix.cpp Mon Aug 5 13:54:36 2019
@@ -30,14 +30,13 @@ static const char kShadowMemoryMappingHi
"TSAN_OPTIONS=%s=0\n";
static void NoHugePagesInShadow(uptr addr, uptr size) {
- if (common_flags()->no_huge_pages_for_shadow)
- if (!NoHugePagesInRegion(addr, size)) {
- Printf(kShadowMemoryMappingWarning, SanitizerToolName, addr, addr + size,
- "MADV_NOHUGEPAGE", errno);
- Printf(kShadowMemoryMappingHint, "MADV_NOHUGEPAGE",
- "no_huge_pages_for_shadow");
- Die();
- }
+ if (!SetShadowRegionHugePageMode(addr, size)) {
+ Printf(kShadowMemoryMappingWarning, SanitizerToolName, addr, addr + size,
+ "MADV_NOHUGEPAGE", errno);
+ Printf(kShadowMemoryMappingHint, "MADV_NOHUGEPAGE",
+ "no_huge_pages_for_shadow");
+ Die();
+ }
}
static void DontDumpShadow(uptr addr, uptr size) {
More information about the llvm-commits
mailing list