Blob Blame History Raw
From f17bc0302100c885c84ebd06cd003aad9774cbb4 Mon Sep 17 00:00:00 2001
From: Mark Salter <msalter@redhat.com>
Date: Thu, 13 Mar 2014 13:16:27 -0400
Subject: [PATCH] Fix aarch64 support for 64K pagesize

A given AArch64 kernel may be using 4K or 64K pagesizes. When running
on a kernel with 64K pagesize, this check causes an intentionally
generated segfault:

  js/src/gc/Memory.cpp:

  void
  InitMemorySubsystem()
  {
      if (size_t(sysconf(_SC_PAGESIZE)) != PageSize)
         MOZ_CRASH();
  }

This happens because PageSize is fixed to 4K at build time. This mess
has been cleaned up in mozjs-24 by eliminating the build-time PageSize
definition. That is too intrusive for mosjs17, so just set PageSize
to 64K at build time and eliminate the check. This will work with both
4K and 64K aarch64 kernels.

Signed-off-by: Mark Salter <msalter@redhat.com>
---
 js/src/gc/Heap.h     |  2 +-
 js/src/gc/Memory.cpp |  3 +++
 3 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/js/src/gc/Heap.h b/js/src/gc/Heap.h
index 1cfd269..f4dbcda 100644
--- a/js/src/gc/Heap.h
+++ b/js/src/gc/Heap.h
@@ -113,7 +113,7 @@ struct Cell
 #if defined(SOLARIS) && (defined(__sparc) || defined(__sparcv9))
 const size_t PageShift = 13;
 const size_t ArenaShift = PageShift;
-#elif defined(__powerpc__)
+#elif defined(__powerpc__) || defined(__aarch64__)
 const size_t PageShift = 16;
 const size_t ArenaShift = 12;
 #else
diff --git a/js/src/gc/Memory.cpp b/js/src/gc/Memory.cpp
index 5b386a2..e5ad018 100644
--- a/js/src/gc/Memory.cpp
+++ b/js/src/gc/Memory.cpp
@@ -302,8 +302,11 @@ GetPageFaultCount()
 void
 InitMemorySubsystem()
 {
+    /* aarch64 may have 64KB or 4KB pages */
+#ifndef __aarch64__
     if (size_t(sysconf(_SC_PAGESIZE)) != PageSize)
         MOZ_CRASH();
+#endif
 }
 
 void *
-- 
1.8.5.3