Skip to content

Commit 2890419

Browse files
backesV8 LUCI CQ
authored andcommitted
[wasm] Disable permission switching if MAP_JIT is available
The combination of --wasm-write-protect-code-memory and MAP_JIT was not handled correctly. We were trying to unnecessarily switch permissions, and a DCHECK was failing because the writers count was not increased previously (because the {CodeSpaceWriteScope} uses a separate implementation if MAP_JIT is available). This CL fixes the issues by explicitly setting {WasmCodeAllocator::protect_code_memory_} to false if MAP_JIT is being used. [email protected] Bug: v8:12070 Change-Id: Ifb05ba01f8e2e7781d7c29fe80d1144a3d65543b Cq-Include-Trybots: luci.v8.try:v8_mac_arm64_rel_ng Cq-Include-Trybots: luci.v8.try:v8_mac_arm64_dbg_ng Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3089159 Reviewed-by: Jakob Kummerow <[email protected]> Commit-Queue: Clemens Backes <[email protected]> Cr-Commit-Position: refs/heads/master@{#76233}
1 parent 615feab commit 2890419

2 files changed

Lines changed: 4 additions & 0 deletions

File tree

src/wasm/wasm-code-manager.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,7 @@ constexpr size_t WasmCodeAllocator::kMaxCodeSpaceSize;
515515

516516
WasmCodeAllocator::WasmCodeAllocator(std::shared_ptr<Counters> async_counters)
517517
: protect_code_memory_(
518+
!V8_HAS_PTHREAD_JIT_WRITE_PROTECT &&
518519
FLAG_wasm_write_protect_code_memory &&
519520
!GetWasmCodeManager()->HasMemoryProtectionKeySupport()),
520521
async_counters_(std::move(async_counters)) {

src/wasm/wasm-code-manager.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -560,6 +560,9 @@ class WasmCodeAllocator {
560560
// End of fields protected by {mutex_}.
561561
//////////////////////////////////////////////////////////////////////////////
562562

563+
// {protect_code_memory_} is true if traditional memory permission switching
564+
// is used to protect code space. It is false if {MAP_JIT} on Mac or PKU is
565+
// being used, or protection is completely disabled.
563566
const bool protect_code_memory_;
564567
std::atomic<size_t> committed_code_space_{0};
565568
std::atomic<size_t> generated_code_size_{0};

0 commit comments

Comments
 (0)