diff --git a/compiler-rt/lib/asan/asan_shadow_setup.cpp b/compiler-rt/lib/asan/asan_shadow_setup.cpp index 68b0ba183dcc..fc9bf51e1b58 100644 --- a/compiler-rt/lib/asan/asan_shadow_setup.cpp +++ b/compiler-rt/lib/asan/asan_shadow_setup.cpp @@ -37,7 +37,7 @@ void ReserveShadowMemoryRange(uptr beg, uptr end, const char *name) { 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); } diff --git a/compiler-rt/lib/hwasan/hwasan_linux.cpp b/compiler-rt/lib/hwasan/hwasan_linux.cpp index d932976489e9..051ec2fb9cc3 100644 --- a/compiler-rt/lib/hwasan/hwasan_linux.cpp +++ b/compiler-rt/lib/hwasan/hwasan_linux.cpp @@ -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); } diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_common.h b/compiler-rt/lib/sanitizer_common/sanitizer_common.h index f81341c47094..224e23a6be32 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_common.h +++ b/compiler-rt/lib/sanitizer_common/sanitizer_common.h @@ -131,7 +131,7 @@ void ReleaseMemoryPagesToOS(uptr beg, uptr end); 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(); diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_posix_libcdep.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_posix_libcdep.cpp index 7aad0b141276..ad8a1ec99301 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_posix_libcdep.cpp +++ b/compiler-rt/lib/sanitizer_common/sanitizer_posix_libcdep.cpp @@ -68,9 +68,11 @@ void ReleaseMemoryPagesToOS(uptr beg, uptr end) { 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 diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_win.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_win.cpp index c32fbbeadf5f..14c8d5dbe8ec 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_win.cpp +++ b/compiler-rt/lib/sanitizer_common/sanitizer_win.cpp @@ -329,7 +329,7 @@ void ReleaseMemoryPagesToOS(uptr beg, uptr end) { // 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; } diff --git a/compiler-rt/lib/tsan/rtl/tsan_platform_posix.cpp b/compiler-rt/lib/tsan/rtl/tsan_platform_posix.cpp index 3c9e45561d37..1f9afd1767ca 100644 --- a/compiler-rt/lib/tsan/rtl/tsan_platform_posix.cpp +++ b/compiler-rt/lib/tsan/rtl/tsan_platform_posix.cpp @@ -30,14 +30,13 @@ static const char kShadowMemoryMappingHint[] = "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) {