[PATCH] D57924: [safestack] Move sysconf(_SC_PAGESIZE) back where it was before r351506

Vitaly Buka via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 7 14:59:15 PST 2019


vitalybuka updated this revision to Diff 185874.
vitalybuka added a comment.

remove pageSize


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D57924/new/

https://reviews.llvm.org/D57924

Files:
  compiler-rt/lib/safestack/safestack.cc


Index: compiler-rt/lib/safestack/safestack.cc
===================================================================
--- compiler-rt/lib/safestack/safestack.cc
+++ compiler-rt/lib/safestack/safestack.cc
@@ -82,9 +82,6 @@
 /// size rlimit is set to infinity.
 const unsigned kDefaultUnsafeStackSize = 0x2800000;
 
-/// Runtime page size obtained through sysconf
-unsigned pageSize;
-
 // Per-thread unsafe stack information. It's not frequently accessed, so there
 // it can be kept out of the tcb in normal thread-local variables.
 __thread void *unsafe_stack_start = nullptr;
@@ -93,8 +90,8 @@
 
 inline void *unsafe_stack_alloc(size_t size, size_t guard) {
   SFS_CHECK(size + guard >= size);
-  void *addr = Mmap(nullptr, RoundUpTo(size + guard, pageSize),
-                    PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0);
+  void *addr = Mmap(nullptr, size + guard, PROT_READ | PROT_WRITE,
+                    MAP_PRIVATE | MAP_ANON, -1, 0);
   SFS_CHECK(MAP_FAILED != addr);
   Mprotect(addr, guard, PROT_NONE);
   return (char *)addr + guard;
@@ -229,7 +226,6 @@
 
   SFS_CHECK(size);
   size = RoundUpTo(size, kStackAlign);
-  SFS_CHECK((guard & (pageSize - 1)) == 0);
 
   void *addr = unsafe_stack_alloc(size, guard);
   struct tinfo *tinfo = reinterpret_cast<struct tinfo *>(addr);
@@ -264,8 +260,6 @@
 __attribute__((constructor(0)))
 #endif
 void __safestack_init() {
-  pageSize = sysconf(_SC_PAGESIZE);
-
   // Determine the stack size for the main thread.
   size_t size = kDefaultUnsafeStackSize;
   size_t guard = 4096;
@@ -276,7 +270,6 @@
 
   // Allocate unsafe stack for main thread
   void *addr = unsafe_stack_alloc(size, guard);
-
   unsafe_stack_setup(addr, size, guard);
 
   // Setup the cleanup handler


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D57924.185874.patch
Type: text/x-patch
Size: 1739 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190207/8896d429/attachment.bin>


More information about the llvm-commits mailing list