|
|
e54439c |
From 0e827b4f741e57538c24d90b63659dbdb0992cb0 Mon Sep 17 00:00:00 2001
|
|
|
e54439c |
From: Jorrit Jongma <jorrit@jongma.org>
|
|
|
e54439c |
Date: Tue, 12 Apr 2022 17:09:34 +0000
|
|
|
e54439c |
Subject: [PATCH] [Backport] [PA] Support 16kb pagesize on Linux+ARM64
|
|
|
63fa67d |
|
|
|
e54439c |
This makes the system pagesize a run-time property.
|
|
|
e54439c |
|
|
|
e54439c |
ARM64 supports 4kb, 16kb, and 64kb page sizes. Previously, only 4kb
|
|
|
e54439c |
was supported by Chromium. This patch adds 16kb support, as is used
|
|
|
e54439c |
for example by Asahi Linux on M1 Macs. The rare 64kb case is still
|
|
|
e54439c |
not supported due to further changes needed to SlotSpanMetadata.
|
|
|
e54439c |
|
|
|
e54439c |
The implementation follows the changes made to support run-time page
|
|
|
e54439c |
size on macOS. On macOS, the required constants are conveniently
|
|
|
e54439c |
injected before any code runs, while on Linux a function call is
|
|
|
e54439c |
needed, complicating initialization.
|
|
|
e54439c |
|
|
|
e54439c |
The new PageCharacteristics structure holds the page size and shift
|
|
|
e54439c |
as std::atomic<int> which are initialized on first use.
|
|
|
e54439c |
|
|
|
e54439c |
Bug: 1301788
|
|
|
e54439c |
Change-Id: I8ceead40de53ba7a2ec248bd6ef46f2a521dd29c
|
|
|
e54439c |
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3545665
|
|
|
e54439c |
Reviewed-by: Benoit Lize <lizeb@chromium.org>
|
|
|
e54439c |
Reviewed-by: Mark Mentovai <mark@chromium.org>
|
|
|
e54439c |
Commit-Queue: Mark Mentovai <mark@chromium.org>
|
|
|
e54439c |
Cr-Commit-Position: refs/heads/main@{#991588}
|
|
|
e54439c |
|
|
|
e54439c |
(adapted from commit a704c3a94179e6f3abb28f090d096ced72657d7c)
|
|
|
e54439c |
|
|
|
e54439c |
Bug-Fedora: 2144200
|
|
|
e54439c |
Task-number: QTBUG-108674
|
|
|
63fa67d |
---
|
|
|
63fa67d |
.../address_space_randomization.h | 15 ++++++
|
|
|
63fa67d |
.../page_allocator_constants.h | 51 +++++++++++++++++-
|
|
|
63fa67d |
.../partition_address_space.cc | 6 +++
|
|
|
63fa67d |
.../partition_allocator/partition_alloc.cc | 2 +-
|
|
|
63fa67d |
.../partition_alloc_constants.h | 5 +-
|
|
|
63fa67d |
.../address_space_randomization.h | 15 ++++++
|
|
|
63fa67d |
.../partition_allocator/page_allocator.cc | 8 +++
|
|
|
63fa67d |
.../page_allocator_constants.h | 52 ++++++++++++++++++-
|
|
|
63fa67d |
.../partition_allocator/partition_alloc.cc | 2 +-
|
|
|
63fa67d |
.../partition_alloc_constants.h | 5 +-
|
|
|
63fa67d |
10 files changed, 153 insertions(+), 8 deletions(-)
|
|
|
63fa67d |
|
|
|
63fa67d |
diff --git a/src/3rdparty/chromium/base/allocator/partition_allocator/address_space_randomization.h b/src/3rdparty/chromium/base/allocator/partition_allocator/address_space_randomization.h
|
|
|
63fa67d |
index e77003eab25..31ac05b86f5 100644
|
|
|
63fa67d |
--- a/src/3rdparty/chromium/base/allocator/partition_allocator/address_space_randomization.h
|
|
|
63fa67d |
+++ b/src/3rdparty/chromium/base/allocator/partition_allocator/address_space_randomization.h
|
|
|
63fa67d |
@@ -119,6 +119,21 @@ AslrMask(uintptr_t bits) {
|
|
|
63fa67d |
return AslrAddress(0x20000000ULL);
|
|
|
63fa67d |
}
|
|
|
63fa67d |
|
|
|
63fa67d |
+ #elif defined(OS_LINUX)
|
|
|
63fa67d |
+
|
|
|
63fa67d |
+ // Linux on arm64 can use 39, 42, 48, or 52-bit user space, depending on
|
|
|
63fa67d |
+ // page size and number of levels of translation pages used. We use
|
|
|
63fa67d |
+ // 39-bit as base as all setups should support this, lowered to 38-bit
|
|
|
63fa67d |
+ // as ASLROffset() could cause a carry.
|
|
|
63fa67d |
+ PAGE_ALLOCATOR_CONSTANTS_DECLARE_CONSTEXPR ALWAYS_INLINE uintptr_t
|
|
|
63fa67d |
+ ASLRMask() {
|
|
|
63fa67d |
+ return AslrMask(38);
|
|
|
63fa67d |
+ }
|
|
|
63fa67d |
+ PAGE_ALLOCATOR_CONSTANTS_DECLARE_CONSTEXPR ALWAYS_INLINE uintptr_t
|
|
|
63fa67d |
+ ASLROffset() {
|
|
|
63fa67d |
+ return AslrAddress(0x1000000000ULL);
|
|
|
63fa67d |
+ }
|
|
|
63fa67d |
+
|
|
|
63fa67d |
#else
|
|
|
63fa67d |
|
|
|
63fa67d |
// ARM64 on Linux has 39-bit user space. Use 38 bits since ASLROffset()
|
|
|
63fa67d |
diff --git a/src/3rdparty/chromium/base/allocator/partition_allocator/page_allocator_constants.h b/src/3rdparty/chromium/base/allocator/partition_allocator/page_allocator_constants.h
|
|
|
63fa67d |
index c42fe2835ff..dc7486608b9 100644
|
|
|
63fa67d |
--- a/src/3rdparty/chromium/base/allocator/partition_allocator/page_allocator_constants.h
|
|
|
63fa67d |
+++ b/src/3rdparty/chromium/base/allocator/partition_allocator/page_allocator_constants.h
|
|
|
63fa67d |
@@ -24,6 +24,31 @@
|
|
|
63fa67d |
// elimination.
|
|
|
63fa67d |
#define PAGE_ALLOCATOR_CONSTANTS_DECLARE_CONSTEXPR __attribute__((const))
|
|
|
63fa67d |
|
|
|
63fa67d |
+#elif defined(OS_LINUX) && defined(ARCH_CPU_ARM64)
|
|
|
63fa67d |
+// This should work for all POSIX (if needed), but currently all other
|
|
|
63fa67d |
+// supported OS/architecture combinations use either hard-coded values
|
|
|
63fa67d |
+// (such as x86) or have means to determine these values without needing
|
|
|
63fa67d |
+// atomics (such as macOS on arm64).
|
|
|
63fa67d |
+
|
|
|
63fa67d |
+// Page allocator constants are run-time constant
|
|
|
63fa67d |
+#define PAGE_ALLOCATOR_CONSTANTS_DECLARE_CONSTEXPR __attribute__((const))
|
|
|
63fa67d |
+
|
|
|
63fa67d |
+#include <unistd.h>
|
|
|
63fa67d |
+#include <atomic>
|
|
|
63fa67d |
+
|
|
|
63fa67d |
+namespace base::internal {
|
|
|
63fa67d |
+
|
|
|
63fa67d |
+// Holds the current page size and shift, where size = 1 << shift
|
|
|
63fa67d |
+// Use PageAllocationGranularity(), PageAllocationGranularityShift()
|
|
|
63fa67d |
+// to initialize and retrieve these values safely.
|
|
|
63fa67d |
+struct PageCharacteristics {
|
|
|
63fa67d |
+ std::atomic<int> size;
|
|
|
63fa67d |
+ std::atomic<int> shift;
|
|
|
63fa67d |
+};
|
|
|
63fa67d |
+extern PageCharacteristics page_characteristics;
|
|
|
63fa67d |
+
|
|
|
63fa67d |
+} // namespace base::internal
|
|
|
63fa67d |
+
|
|
|
63fa67d |
#else
|
|
|
63fa67d |
|
|
|
63fa67d |
// When defined, page size constants are fixed at compile time. When not
|
|
|
63fa67d |
@@ -36,11 +61,17 @@
|
|
|
63fa67d |
|
|
|
63fa67d |
#endif
|
|
|
63fa67d |
|
|
|
63fa67d |
+namespace base {
|
|
|
63fa67d |
+// Forward declaration, implementation below
|
|
|
63fa67d |
+PAGE_ALLOCATOR_CONSTANTS_DECLARE_CONSTEXPR ALWAYS_INLINE size_t
|
|
|
63fa67d |
+PageAllocationGranularity();
|
|
|
63fa67d |
+}
|
|
|
63fa67d |
+
|
|
|
63fa67d |
namespace {
|
|
|
63fa67d |
|
|
|
63fa67d |
#if !defined(OS_APPLE)
|
|
|
63fa67d |
|
|
|
63fa67d |
-constexpr ALWAYS_INLINE int PageAllocationGranularityShift() {
|
|
|
63fa67d |
+PAGE_ALLOCATOR_CONSTANTS_DECLARE_CONSTEXPR ALWAYS_INLINE int PageAllocationGranularityShift() {
|
|
|
63fa67d |
#if defined(OS_WIN) || defined(ARCH_CPU_PPC64)
|
|
|
63fa67d |
// Modern ppc64 systems support 4kB (shift = 12) and 64kB (shift = 16) page
|
|
|
63fa67d |
// sizes. Since 64kB is the de facto standard on the platform and binaries
|
|
|
63fa67d |
@@ -49,6 +80,15 @@ constexpr ALWAYS_INLINE int PageAllocationGranularityShift() {
|
|
|
63fa67d |
return 16; // 64kB
|
|
|
63fa67d |
#elif defined(_MIPS_ARCH_LOONGSON)
|
|
|
63fa67d |
return 14; // 16kB
|
|
|
63fa67d |
+#elif defined(OS_LINUX) && defined(ARCH_CPU_ARM64)
|
|
|
63fa67d |
+ // arm64 supports 4kb (shift = 12), 16kb (shift = 14), and 64kb (shift = 16)
|
|
|
63fa67d |
+ // page sizes. Retrieve from or initialize cache.
|
|
|
63fa67d |
+ int shift = base::internal::page_characteristics.shift.load(std::memory_order_relaxed);
|
|
|
63fa67d |
+ if (UNLIKELY(shift == 0)) {
|
|
|
63fa67d |
+ shift = __builtin_ctz((int)base::PageAllocationGranularity());
|
|
|
63fa67d |
+ base::internal::page_characteristics.shift.store(shift, std::memory_order_relaxed);
|
|
|
63fa67d |
+ }
|
|
|
63fa67d |
+ return shift;
|
|
|
63fa67d |
#else
|
|
|
63fa67d |
return 12; // 4kB
|
|
|
63fa67d |
#endif
|
|
|
63fa67d |
@@ -64,6 +104,15 @@ PAGE_ALLOCATOR_CONSTANTS_DECLARE_CONSTEXPR ALWAYS_INLINE size_t
|
|
|
63fa67d |
PageAllocationGranularity() {
|
|
|
63fa67d |
#if defined(OS_APPLE)
|
|
|
63fa67d |
return vm_page_size;
|
|
|
63fa67d |
+#elif defined(OS_LINUX) && defined(ARCH_CPU_ARM64)
|
|
|
63fa67d |
+ // arm64 supports 4kb, 16kb, and 64kb page sizes. Retrieve from or
|
|
|
63fa67d |
+ // initialize cache.
|
|
|
63fa67d |
+ int size = internal::page_characteristics.size.load(std::memory_order_relaxed);
|
|
|
63fa67d |
+ if (UNLIKELY(size == 0)) {
|
|
|
63fa67d |
+ size = getpagesize();
|
|
|
63fa67d |
+ internal::page_characteristics.size.store(size, std::memory_order_relaxed);
|
|
|
63fa67d |
+ }
|
|
|
63fa67d |
+ return size;
|
|
|
63fa67d |
#else
|
|
|
63fa67d |
return 1ULL << PageAllocationGranularityShift();
|
|
|
63fa67d |
#endif
|
|
|
63fa67d |
diff --git a/src/3rdparty/chromium/base/allocator/partition_allocator/partition_address_space.cc b/src/3rdparty/chromium/base/allocator/partition_allocator/partition_address_space.cc
|
|
|
63fa67d |
index 03883bcb113..90efc51c838 100644
|
|
|
63fa67d |
--- a/src/3rdparty/chromium/base/allocator/partition_allocator/partition_address_space.cc
|
|
|
63fa67d |
+++ b/src/3rdparty/chromium/base/allocator/partition_allocator/partition_address_space.cc
|
|
|
63fa67d |
@@ -75,6 +75,12 @@ void PartitionAddressSpace::UninitForTesting() {
|
|
|
63fa67d |
internal::AddressPoolManager::GetInstance()->ResetForTesting();
|
|
|
63fa67d |
}
|
|
|
63fa67d |
|
|
|
63fa67d |
+#if defined(OS_LINUX) && defined(ARCH_CPU_ARM64)
|
|
|
63fa67d |
+
|
|
|
63fa67d |
+PageCharacteristics page_characteristics;
|
|
|
63fa67d |
+
|
|
|
63fa67d |
+#endif // defined(OS_LINUX) && defined(ARCH_CPU_ARM64)
|
|
|
63fa67d |
+
|
|
|
63fa67d |
#endif // defined(PA_HAS_64_BITS_POINTERS)
|
|
|
63fa67d |
|
|
|
63fa67d |
} // namespace internal
|
|
|
63fa67d |
diff --git a/src/3rdparty/chromium/base/allocator/partition_allocator/partition_alloc.cc b/src/3rdparty/chromium/base/allocator/partition_allocator/partition_alloc.cc
|
|
|
63fa67d |
index daeb6d5cb17..7c434b5e697 100644
|
|
|
63fa67d |
--- a/src/3rdparty/chromium/base/allocator/partition_allocator/partition_alloc.cc
|
|
|
63fa67d |
+++ b/src/3rdparty/chromium/base/allocator/partition_allocator/partition_alloc.cc
|
|
|
63fa67d |
@@ -522,7 +522,7 @@ static size_t PartitionPurgePage(internal::PartitionPage<thread_safe>* page,
|
|
|
63fa67d |
#if defined(PAGE_ALLOCATOR_CONSTANTS_ARE_CONSTEXPR)
|
|
|
63fa67d |
constexpr size_t kMaxSlotCount =
|
|
|
63fa67d |
(PartitionPageSize() * kMaxPartitionPagesPerSlotSpan) / SystemPageSize();
|
|
|
63fa67d |
-#elif defined(OS_APPLE)
|
|
|
63fa67d |
+#elif defined(OS_APPLE) || (defined(OS_LINUX) && defined(ARCH_CPU_ARM64))
|
|
|
63fa67d |
// It's better for slot_usage to be stack-allocated and fixed-size, which
|
|
|
63fa67d |
// demands that its size be constexpr. On OS_APPLE, PartitionPageSize() is
|
|
|
63fa67d |
// always SystemPageSize() << 2, so regardless of what the run time page size
|
|
|
63fa67d |
diff --git a/src/3rdparty/chromium/base/allocator/partition_allocator/partition_alloc_constants.h b/src/3rdparty/chromium/base/allocator/partition_allocator/partition_alloc_constants.h
|
|
|
63fa67d |
index c8268ec30a0..f03ba1e4ab4 100644
|
|
|
63fa67d |
--- a/src/3rdparty/chromium/base/allocator/partition_allocator/partition_alloc_constants.h
|
|
|
63fa67d |
+++ b/src/3rdparty/chromium/base/allocator/partition_allocator/partition_alloc_constants.h
|
|
|
63fa67d |
@@ -57,10 +57,11 @@ PAGE_ALLOCATOR_CONSTANTS_DECLARE_CONSTEXPR ALWAYS_INLINE int
|
|
|
63fa67d |
PartitionPageShift() {
|
|
|
63fa67d |
return 18; // 256 KiB
|
|
|
63fa67d |
}
|
|
|
63fa67d |
-#elif defined(OS_APPLE)
|
|
|
63fa67d |
+#elif defined(OS_APPLE) || \
|
|
|
63fa67d |
+ (defined(OS_LINUX) && defined(ARCH_CPU_ARM64))
|
|
|
63fa67d |
PAGE_ALLOCATOR_CONSTANTS_DECLARE_CONSTEXPR ALWAYS_INLINE int
|
|
|
63fa67d |
PartitionPageShift() {
|
|
|
63fa67d |
- return vm_page_shift + 2;
|
|
|
63fa67d |
+ return PageAllocationGranularityShift() + 2;
|
|
|
63fa67d |
}
|
|
|
63fa67d |
#else
|
|
|
63fa67d |
PAGE_ALLOCATOR_CONSTANTS_DECLARE_CONSTEXPR ALWAYS_INLINE int
|
|
|
63fa67d |
diff --git a/src/3rdparty/chromium/third_party/pdfium/third_party/base/allocator/partition_allocator/address_space_randomization.h b/src/3rdparty/chromium/third_party/pdfium/third_party/base/allocator/partition_allocator/address_space_randomization.h
|
|
|
63fa67d |
index 28c8271fd68..3957e0cdf76 100644
|
|
|
63fa67d |
--- a/src/3rdparty/chromium/third_party/pdfium/third_party/base/allocator/partition_allocator/address_space_randomization.h
|
|
|
63fa67d |
+++ b/src/3rdparty/chromium/third_party/pdfium/third_party/base/allocator/partition_allocator/address_space_randomization.h
|
|
|
63fa67d |
@@ -120,6 +120,21 @@ AslrMask(uintptr_t bits) {
|
|
|
63fa67d |
return AslrAddress(0x20000000ULL);
|
|
|
63fa67d |
}
|
|
|
63fa67d |
|
|
|
63fa67d |
+ #elif defined(OS_LINUX)
|
|
|
63fa67d |
+
|
|
|
63fa67d |
+ // Linux on arm64 can use 39, 42, 48, or 52-bit user space, depending on
|
|
|
63fa67d |
+ // page size and number of levels of translation pages used. We use
|
|
|
63fa67d |
+ // 39-bit as base as all setups should support this, lowered to 38-bit
|
|
|
63fa67d |
+ // as ASLROffset() could cause a carry.
|
|
|
63fa67d |
+ PAGE_ALLOCATOR_CONSTANTS_DECLARE_CONSTEXPR ALWAYS_INLINE uintptr_t
|
|
|
63fa67d |
+ ASLRMask() {
|
|
|
63fa67d |
+ return AslrMask(38);
|
|
|
63fa67d |
+ }
|
|
|
63fa67d |
+ PAGE_ALLOCATOR_CONSTANTS_DECLARE_CONSTEXPR ALWAYS_INLINE uintptr_t
|
|
|
63fa67d |
+ ASLROffset() {
|
|
|
63fa67d |
+ return AslrAddress(0x1000000000ULL);
|
|
|
63fa67d |
+ }
|
|
|
63fa67d |
+
|
|
|
63fa67d |
#else
|
|
|
63fa67d |
|
|
|
63fa67d |
// ARM64 on Linux has 39-bit user space. Use 38 bits since kASLROffset
|
|
|
63fa67d |
diff --git a/src/3rdparty/chromium/third_party/pdfium/third_party/base/allocator/partition_allocator/page_allocator.cc b/src/3rdparty/chromium/third_party/pdfium/third_party/base/allocator/partition_allocator/page_allocator.cc
|
|
|
63fa67d |
index 91d00d2fbca..597d5f84cb1 100644
|
|
|
63fa67d |
--- a/src/3rdparty/chromium/third_party/pdfium/third_party/base/allocator/partition_allocator/page_allocator.cc
|
|
|
63fa67d |
+++ b/src/3rdparty/chromium/third_party/pdfium/third_party/base/allocator/partition_allocator/page_allocator.cc
|
|
|
63fa67d |
@@ -255,5 +255,13 @@ uint32_t GetAllocPageErrorCode() {
|
|
|
63fa67d |
return s_allocPageErrorCode;
|
|
|
63fa67d |
}
|
|
|
63fa67d |
|
|
|
63fa67d |
+#if defined(OS_LINUX) && defined(ARCH_CPU_ARM64)
|
|
|
63fa67d |
+
|
|
|
63fa67d |
+namespace internal {
|
|
|
63fa67d |
+PageCharacteristics page_characteristics;
|
|
|
63fa67d |
+}
|
|
|
63fa67d |
+
|
|
|
63fa67d |
+#endif // defined(OS_LINUX) && defined(ARCH_CPU_ARM64)
|
|
|
63fa67d |
+
|
|
|
63fa67d |
} // namespace base
|
|
|
63fa67d |
} // namespace pdfium
|
|
|
63fa67d |
diff --git a/src/3rdparty/chromium/third_party/pdfium/third_party/base/allocator/partition_allocator/page_allocator_constants.h b/src/3rdparty/chromium/third_party/pdfium/third_party/base/allocator/partition_allocator/page_allocator_constants.h
|
|
|
63fa67d |
index fdc65ac47b7..f826308839d 100644
|
|
|
63fa67d |
--- a/src/3rdparty/chromium/third_party/pdfium/third_party/base/allocator/partition_allocator/page_allocator_constants.h
|
|
|
63fa67d |
+++ b/src/3rdparty/chromium/third_party/pdfium/third_party/base/allocator/partition_allocator/page_allocator_constants.h
|
|
|
63fa67d |
@@ -24,6 +24,31 @@
|
|
|
63fa67d |
// elimination.
|
|
|
63fa67d |
#define PAGE_ALLOCATOR_CONSTANTS_DECLARE_CONSTEXPR __attribute__((const))
|
|
|
63fa67d |
|
|
|
63fa67d |
+#elif defined(OS_LINUX) && defined(ARCH_CPU_ARM64)
|
|
|
63fa67d |
+// This should work for all POSIX (if needed), but currently all other
|
|
|
63fa67d |
+// supported OS/architecture combinations use either hard-coded values
|
|
|
63fa67d |
+// (such as x86) or have means to determine these values without needing
|
|
|
63fa67d |
+// atomics (such as macOS on arm64).
|
|
|
63fa67d |
+
|
|
|
63fa67d |
+// Page allocator constants are run-time constant
|
|
|
63fa67d |
+#define PAGE_ALLOCATOR_CONSTANTS_DECLARE_CONSTEXPR __attribute__((const))
|
|
|
63fa67d |
+
|
|
|
63fa67d |
+#include <unistd.h>
|
|
|
63fa67d |
+#include <atomic>
|
|
|
63fa67d |
+
|
|
|
63fa67d |
+namespace pdfium::base::internal {
|
|
|
63fa67d |
+
|
|
|
63fa67d |
+// Holds the current page size and shift, where size = 1 << shift
|
|
|
63fa67d |
+// Use PageAllocationGranularity(), PageAllocationGranularityShift()
|
|
|
63fa67d |
+// to initialize and retrieve these values safely.
|
|
|
63fa67d |
+struct PageCharacteristics {
|
|
|
63fa67d |
+ std::atomic<int> size;
|
|
|
63fa67d |
+ std::atomic<int> shift;
|
|
|
63fa67d |
+};
|
|
|
63fa67d |
+extern PageCharacteristics page_characteristics;
|
|
|
63fa67d |
+
|
|
|
63fa67d |
+} // namespace base::internal
|
|
|
63fa67d |
+
|
|
|
63fa67d |
#else
|
|
|
63fa67d |
|
|
|
63fa67d |
// When defined, page size constants are fixed at compile time. When not
|
|
|
63fa67d |
@@ -37,11 +62,18 @@
|
|
|
63fa67d |
#endif
|
|
|
63fa67d |
|
|
|
63fa67d |
namespace pdfium {
|
|
|
63fa67d |
+
|
|
|
63fa67d |
+namespace base {
|
|
|
63fa67d |
+// Forward declaration, implementation below
|
|
|
63fa67d |
+PAGE_ALLOCATOR_CONSTANTS_DECLARE_CONSTEXPR ALWAYS_INLINE size_t
|
|
|
63fa67d |
+PageAllocationGranularity();
|
|
|
63fa67d |
+}
|
|
|
63fa67d |
+
|
|
|
63fa67d |
namespace {
|
|
|
63fa67d |
|
|
|
63fa67d |
#if !defined(OS_APPLE)
|
|
|
63fa67d |
|
|
|
63fa67d |
-constexpr ALWAYS_INLINE int PageAllocationGranularityShift() {
|
|
|
63fa67d |
+PAGE_ALLOCATOR_CONSTANTS_DECLARE_CONSTEXPR ALWAYS_INLINE int PageAllocationGranularityShift() {
|
|
|
63fa67d |
#if defined(OS_WIN) || defined(ARCH_CPU_PPC64)
|
|
|
63fa67d |
// Modern ppc64 systems support 4kB (shift = 12) and 64kB (shift = 16) page
|
|
|
63fa67d |
// sizes. Since 64kB is the de facto standard on the platform and binaries
|
|
|
63fa67d |
@@ -50,6 +82,15 @@ constexpr ALWAYS_INLINE int PageAllocationGranularityShift() {
|
|
|
63fa67d |
return 16; // 64kB
|
|
|
63fa67d |
#elif defined(_MIPS_ARCH_LOONGSON)
|
|
|
63fa67d |
return 14; // 16kB
|
|
|
63fa67d |
+#elif defined(OS_LINUX) && defined(ARCH_CPU_ARM64)
|
|
|
63fa67d |
+ // arm64 supports 4kb (shift = 12), 16kb (shift = 14), and 64kb (shift = 16)
|
|
|
63fa67d |
+ // page sizes. Retrieve from or initialize cache.
|
|
|
63fa67d |
+ int shift = base::internal::page_characteristics.shift.load(std::memory_order_relaxed);
|
|
|
63fa67d |
+ if (UNLIKELY(shift == 0)) {
|
|
|
63fa67d |
+ shift = __builtin_ctz((int)base::PageAllocationGranularity());
|
|
|
63fa67d |
+ base::internal::page_characteristics.shift.store(shift, std::memory_order_relaxed);
|
|
|
63fa67d |
+ }
|
|
|
63fa67d |
+ return shift;
|
|
|
63fa67d |
#else
|
|
|
63fa67d |
return 12; // 4kB
|
|
|
63fa67d |
#endif
|
|
|
63fa67d |
@@ -65,6 +106,15 @@ PAGE_ALLOCATOR_CONSTANTS_DECLARE_CONSTEXPR ALWAYS_INLINE size_t
|
|
|
63fa67d |
PageAllocationGranularity() {
|
|
|
63fa67d |
#if defined(OS_APPLE)
|
|
|
63fa67d |
return vm_page_size;
|
|
|
63fa67d |
+#elif defined(OS_LINUX) && defined(ARCH_CPU_ARM64)
|
|
|
63fa67d |
+ // arm64 supports 4kb, 16kb, and 64kb page sizes. Retrieve from or
|
|
|
63fa67d |
+ // initialize cache.
|
|
|
63fa67d |
+ int size = internal::page_characteristics.size.load(std::memory_order_relaxed);
|
|
|
63fa67d |
+ if (UNLIKELY(size == 0)) {
|
|
|
63fa67d |
+ size = getpagesize();
|
|
|
63fa67d |
+ internal::page_characteristics.size.store(size, std::memory_order_relaxed);
|
|
|
63fa67d |
+ }
|
|
|
63fa67d |
+ return size;
|
|
|
63fa67d |
#else
|
|
|
63fa67d |
return 1ULL << PageAllocationGranularityShift();
|
|
|
63fa67d |
#endif
|
|
|
63fa67d |
diff --git a/src/3rdparty/chromium/third_party/pdfium/third_party/base/allocator/partition_allocator/partition_alloc.cc b/src/3rdparty/chromium/third_party/pdfium/third_party/base/allocator/partition_allocator/partition_alloc.cc
|
|
|
63fa67d |
index 2e5e87fa7e6..89b9f6217a6 100644
|
|
|
63fa67d |
--- a/src/3rdparty/chromium/third_party/pdfium/third_party/base/allocator/partition_allocator/partition_alloc.cc
|
|
|
63fa67d |
+++ b/src/3rdparty/chromium/third_party/pdfium/third_party/base/allocator/partition_allocator/partition_alloc.cc
|
|
|
63fa67d |
@@ -486,7 +486,7 @@ static size_t PartitionPurgePage(internal::PartitionPage* page, bool discard) {
|
|
|
63fa67d |
#if defined(PAGE_ALLOCATOR_CONSTANTS_ARE_CONSTEXPR)
|
|
|
63fa67d |
constexpr size_t kMaxSlotCount =
|
|
|
63fa67d |
(PartitionPageSize() * kMaxPartitionPagesPerSlotSpan) / SystemPageSize();
|
|
|
63fa67d |
-#elif defined(OS_APPLE)
|
|
|
63fa67d |
+#elif defined(OS_APPLE) || (defined(OS_LINUX) && defined(ARCH_CPU_ARM64))
|
|
|
63fa67d |
// It's better for slot_usage to be stack-allocated and fixed-size, which
|
|
|
63fa67d |
// demands that its size be constexpr. On OS_APPLE, PartitionPageSize() is
|
|
|
63fa67d |
// always SystemPageSize() << 2, so regardless of what the run time page size
|
|
|
63fa67d |
diff --git a/src/3rdparty/chromium/third_party/pdfium/third_party/base/allocator/partition_allocator/partition_alloc_constants.h b/src/3rdparty/chromium/third_party/pdfium/third_party/base/allocator/partition_allocator/partition_alloc_constants.h
|
|
|
63fa67d |
index 71d63ba4146..a6d83626741 100644
|
|
|
63fa67d |
--- a/src/3rdparty/chromium/third_party/pdfium/third_party/base/allocator/partition_allocator/partition_alloc_constants.h
|
|
|
63fa67d |
+++ b/src/3rdparty/chromium/third_party/pdfium/third_party/base/allocator/partition_allocator/partition_alloc_constants.h
|
|
|
63fa67d |
@@ -50,10 +50,11 @@ PAGE_ALLOCATOR_CONSTANTS_DECLARE_CONSTEXPR ALWAYS_INLINE int
|
|
|
63fa67d |
PartitionPageShift() {
|
|
|
63fa67d |
return 18; // 256 KiB
|
|
|
63fa67d |
}
|
|
|
63fa67d |
-#elif defined(OS_APPLE)
|
|
|
63fa67d |
+#elif defined(OS_APPLE) || \
|
|
|
63fa67d |
+ (defined(OS_LINUX) && defined(ARCH_CPU_ARM64))
|
|
|
63fa67d |
PAGE_ALLOCATOR_CONSTANTS_DECLARE_CONSTEXPR ALWAYS_INLINE int
|
|
|
63fa67d |
PartitionPageShift() {
|
|
|
63fa67d |
- return vm_page_shift + 2;
|
|
|
63fa67d |
+ return PageAllocationGranularityShift() + 2;
|
|
|
63fa67d |
}
|
|
|
63fa67d |
#else
|
|
|
63fa67d |
PAGE_ALLOCATOR_CONSTANTS_DECLARE_CONSTEXPR ALWAYS_INLINE int
|
|
|
63fa67d |
--
|
|
|
e54439c |
2.38.1
|
|
|
63fa67d |
|