[PATCH] D15206: [compiler-rt] [safestack] Enable for aarch64

Adhemerval Zanella via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 3 13:41:43 PST 2015

zatrazz created this revision.
zatrazz added reviewers: rengolin, samsonov, eugenis, pcc, dvyukov.
zatrazz added a subscriber: llvm-commits.
Herald added subscribers: rengolin, aemerson.

This patch enables the safestack for aarch64. The frontend already have
it enabled on all supported architectures and no adjustment is required
in llvm.

The compiler-rt adjustments are basically add on the cmake configuration
to enable the tests and fix the pagesize debug check by getting its
value at runtime (since aarch64 has multiple pagesize depending of
kernel configuration).

All tests pass on aarch64-linux.



Index: lib/safestack/safestack.cc
--- lib/safestack/safestack.cc
+++ lib/safestack/safestack.cc
@@ -18,6 +18,7 @@
 #include <pthread.h>
 #include <stddef.h>
 #include <stdint.h>
+#include <unistd.h>
 #include <sys/resource.h>
 #include <sys/types.h>
 #include <sys/user.h>
@@ -68,6 +69,9 @@
 /// size rlimit is set to infinity.
 const unsigned kDefaultUnsafeStackSize = 0x2800000;
+/// Runtime page size obtained through sysconf
+static unsigned pageSize;
 // TODO: To make accessing the unsafe stack pointer faster, we plan to
 // eventually store it directly in the thread control block data structure on
 // platforms where this structure is pointed to by %fs or %gs. This is exactly
@@ -185,7 +189,7 @@
   CHECK_NE(size, 0);
   CHECK_EQ((size & (kStackAlign - 1)), 0);
-  CHECK_EQ((guard & (PAGE_SIZE - 1)), 0);
+  CHECK_EQ((guard & (pageSize - 1)), 0);
   void *addr = unsafe_stack_alloc(size, guard);
   struct tinfo *tinfo =
@@ -217,6 +221,7 @@
   void *addr = unsafe_stack_alloc(size, guard);
   unsafe_stack_setup(addr, size, guard);
+  pageSize = sysconf(_SC_PAGESIZE);
   // Initialize pthread interceptors for thread allocation
Index: cmake/config-ix.cmake
--- cmake/config-ix.cmake
+++ cmake/config-ix.cmake
@@ -280,7 +280,7 @@
 set(ALL_TSAN_SUPPORTED_ARCH ${X86_64} ${MIPS64} ${ARM64})
 set(ALL_UBSAN_SUPPORTED_ARCH ${X86} ${X86_64} ${ARM32} ${ARM64}
     ${MIPS32} ${MIPS64} ${PPC64})
+set(ALL_SAFESTACK_SUPPORTED_ARCH ${X86} ${X86_64} ${ARM64})

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D15206.41798.patch
Type: text/x-patch
Size: 1747 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151203/21eaffa9/attachment-0001.bin>

More information about the llvm-commits mailing list