diff --git a/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp --- a/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp +++ b/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp @@ -78,6 +78,11 @@ static const unsigned kShadowBaseAlignment = 32; +static cl::opt ClSystemPageSize( + "hwasan-sys-page-size", + cl::desc("System page size for ring buffer, such as 4K/8K/16K/64K"), + cl::Hidden, cl::init("4k")); + static cl::opt ClMemoryAccessCallbackPrefix("hwasan-memory-access-callback-prefix", cl::desc("Prefix for memory access callbacks"), @@ -246,6 +251,20 @@ return ClUseAfterScope && shouldInstrumentStack(TargetTriple); } +static uint64_t getSystemPageSizeBits() { + StringRef PageSizeStr(ClSystemPageSize.getValue()); + if (PageSizeStr.equals_insensitive("4k")) + return 12; + else if (PageSizeStr.equals_insensitive("8k")) + return 13; + else if (PageSizeStr.equals_insensitive("16k")) + return 14; + else if (PageSizeStr.equals_insensitive("64k")) + return 16; + else + report_fatal_error("unsupported page size: " + PageSizeStr); +} + /// An instrumentation pass implementing detection of addressability bugs /// using tagged pointers. class HWAddressSanitizer {