Commit 95e7aee1 authored by Samuel Groß's avatar Samuel Groß Committed by V8 LUCI CQ

Reserve a minimally-sized virtual memory cage on older Windows versions

On Windows pre 8.1, reserving a large virtual memory region for the cage
is too expensive as it (apparently) creates PTEs. As such, we can only
create a cage with the minimum size and without guard regions.

Bug: chromium:1218005
Change-Id: Ib19b9a08f8c965d9739c1d539a0153b32a290826
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3212507Reviewed-by: 's avatarIgor Sheludko <ishell@chromium.org>
Commit-Queue: Samuel Groß <saelo@chromium.org>
Cr-Commit-Position: refs/heads/main@{#77296}
parent dc6e1c4e
......@@ -10,14 +10,32 @@
#include "src/base/lazy-instance.h"
#include "src/utils/allocation.h"
#if defined(V8_OS_WIN)
#include <windows.h>
// This has to come after windows.h.
#include <versionhelpers.h> // For IsWindows8Point1OrGreater().
#endif
namespace v8 {
namespace internal {
#ifdef V8_VIRTUAL_MEMORY_CAGE
bool V8VirtualMemoryCage::Initialize(PageAllocator* page_allocator) {
constexpr bool use_guard_regions = true;
return Initialize(page_allocator, kVirtualMemoryCageSize, use_guard_regions);
bool use_guard_regions = true;
size_t size = kVirtualMemoryCageSize;
#if defined(V8_OS_WIN)
if (!IsWindows8Point1OrGreater()) {
// On Windows pre 8.1, reserving virtual memory is an expensive operation,
// possibly because page table entries are created for the address range.
// For example, a 1TB reservation increases private memory usage by 2GB. As
// such, we can unfortunately only create a minimal cage on these version,
// without guard regions and without our desired security properties.
use_guard_regions = false;
size = kVirtualMemoryCageMinimumSize;
}
#endif
return Initialize(page_allocator, size, use_guard_regions);
}
bool V8VirtualMemoryCage::Initialize(v8::PageAllocator* page_allocator,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment