Commit 3285ad9e authored by Samuel Groß's avatar Samuel Groß Committed by V8 LUCI CQ

Reland "[sandbox] Increase ExternalPointerTable maximum capacity to 512MB"

This is a reland of commit d7fcbba8

The LSan support logic of the ExternalPointerTable has been optimized to
avoid timeouts on sanitizer bots

Original change's description:
> [sandbox] Increase ExternalPointerTable maximum capacity to 512MB
>
> Bug: v8:10391
> Change-Id: I383e11bdccf6fcaf13f29d25e1404545067d313e
> Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3891249
> Reviewed-by: Igor Sheludko <ishell@chromium.org>
> Commit-Queue: Samuel Groß <saelo@chromium.org>
> Cr-Commit-Position: refs/heads/main@{#83203}

Bug: v8:10391
Change-Id: If50156d6fecff7ca8ece5c350e7b08936f50daa6
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3905141
Commit-Queue: Samuel Groß <saelo@chromium.org>
Reviewed-by: 's avatarIgor Sheludko <ishell@chromium.org>
Cr-Commit-Position: refs/heads/main@{#83322}
parent 7d00a97a
......@@ -232,7 +232,7 @@ static_assert(kSandboxMinimumReservationSize > kPtrComprCageReservationSize,
// size allows omitting bounds checks on table accesses if the indices are
// guaranteed (e.g. through shifting) to be below the maximum index. This
// value must be a power of two.
static const size_t kExternalPointerTableReservationSize = 128 * MB;
static const size_t kExternalPointerTableReservationSize = 512 * MB;
// The maximum number of entries in an external pointer table.
static const size_t kMaxExternalPointers =
......@@ -241,7 +241,7 @@ static const size_t kMaxExternalPointers =
// The external pointer table indices stored in HeapObjects as external
// pointers are shifted to the left by this amount to guarantee that they are
// smaller than the maximum table size.
static const uint32_t kExternalPointerIndexShift = 8;
static const uint32_t kExternalPointerIndexShift = 6;
static_assert((1 << (32 - kExternalPointerIndexShift)) == kMaxExternalPointers,
"kExternalPointerTableReservationSize and "
"kExternalPointerIndexShift don't match");
......
......@@ -48,17 +48,6 @@ void ExternalPointerTable::Init(Isolate* isolate) {
isolate, "Failed to allocate mutex for ExternalPointerTable");
}
#if defined(LEAK_SANITIZER)
// Make the shadow table accessible.
if (!root_space->SetPagePermissions(
buffer_ + kExternalPointerTableReservationSize,
kExternalPointerTableReservationSize, PagePermissions::kReadWrite)) {
V8::FatalProcessOutOfMemory(isolate,
"Failed to allocate memory for the "
"ExternalPointerTable LSan shadow table");
}
#endif // LEAK_SANITIZER
// Allocate the initial block. Mutex must be held for that.
base::MutexGuard guard(mutex_);
Grow(isolate);
......@@ -240,6 +229,13 @@ uint32_t ExternalPointerTable::SweepAndCompact(Isolate* isolate) {
// attacker if they are still accessible, so use Decommit here which
// guarantees that the pages become inaccessible and will be zeroed out.
CHECK(root_space->DecommitPages(new_table_end, bytes_to_decommit));
#if defined(LEAK_SANITIZER)
Address new_shadow_table_end = buffer_ +
kExternalPointerTableReservationSize +
new_capacity * sizeof(Address);
CHECK(root_space->DecommitPages(new_shadow_table_end, bytes_to_decommit));
#endif // LEAK_SANITIZER
}
if (IsCompacting()) {
......@@ -307,6 +303,16 @@ ExternalPointerTable::Freelist ExternalPointerTable::Grow(Isolate* isolate) {
isolate, "Failed to grow the ExternalPointerTable backing buffer");
}
#if defined(LEAK_SANITIZER)
if (!root_space->SetPagePermissions(
buffer_ + kExternalPointerTableReservationSize +
old_capacity * sizeof(Address),
kBlockSize, PagePermissions::kReadWrite)) {
V8::FatalProcessOutOfMemory(
isolate, "Failed to grow the ExternalPointerTabl shadow table");
}
#endif // LEAK_SANITIZER
set_capacity(new_capacity);
// Schedule GC when the table's utilization crosses one of these thresholds.
......
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