Bug 1586912: Don't ComputeRandomAllocationAddress on OpenBSD r=nbp
authorKurt Miller <kurt@intricatesoftware.com>
Mon, 04 Nov 2019 14:04:53 +0000
changeset 500375 747fc2e159baf123a82b85590b430f2b013b32ca
parent 500374 f88700daff3a2eaeadeab2b5bc2cf5b1cbc3fe57
child 500376 16931240f0f1a86dfc5ce68d0ecba21f1fde736d
push id114164
push useraiakab@mozilla.com
push dateTue, 05 Nov 2019 10:06:15 +0000
treeherdermozilla-inbound@4d585c7edc76 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnbp
bugs1586912
milestone72.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1586912: Don't ComputeRandomAllocationAddress on OpenBSD r=nbp OpenBSD already has a random mmap() Differential Revision: https://phabricator.services.mozilla.com/D51299
js/src/jit/ProcessExecutableMemory.cpp
--- a/js/src/jit/ProcessExecutableMemory.cpp
+++ b/js/src/jit/ProcessExecutableMemory.cpp
@@ -317,16 +317,22 @@ static void DecommitPages(void* addr, si
   }
 }
 #else  // !XP_WIN
 #  ifndef MAP_NORESERVE
 #    define MAP_NORESERVE 0
 #  endif
 
 static void* ComputeRandomAllocationAddress() {
+#ifdef __OpenBSD__
+  // OpenBSD already has random mmap and the idea that all x64 cpus
+  // have 48-bit address space is not correct. Returning nullptr
+  // allows OpenBSD do to the right thing.
+  return nullptr;
+#else
   uint64_t rand = js::GenerateRandomSeed();
 
 #  ifdef HAVE_64BIT_BUILD
   // x64 CPUs have a 48-bit address space and on some platforms the OS will
   // give us access to 47 bits, so to be safe we right shift by 18 to leave
   // 46 bits.
   rand >>= 18;
 #  else
@@ -336,16 +342,17 @@ static void* ComputeRandomAllocationAddr
   // relatively unpopulated across a variety of kernels.
   rand >>= 34;
   rand += 512 * 1024 * 1024;
 #  endif
 
   // Ensure page alignment.
   uintptr_t mask = ~uintptr_t(gc::SystemPageSize() - 1);
   return (void*)uintptr_t(rand & mask);
+#endif
 }
 
 static void* ReserveProcessExecutableMemory(size_t bytes) {
   // Note that randomAddr is just a hint: if the address is not available
   // mmap will pick a different address.
   void* randomAddr = ComputeRandomAllocationAddress();
   void* p = MozTaggedAnonymousMmap(randomAddr, bytes, PROT_NONE,
                                    MAP_NORESERVE | MAP_PRIVATE | MAP_ANON, -1,