v8/test/cctest/wasm
Igor Sheludko 449ece383b Reland "[rwx][mac] Support fast W^X permission switching on Apple Silicon (M1)"
This is a reland of commit 9d31f8663a
There were issues with --future flag implications on M1.

Original change's description:
> [rwx][mac] Support fast W^X permission switching on Apple Silicon (M1)
>
> ... for V8 code space. The feature is currently disabled.
>
> In order to use fast W^X permission switching we must allocate
> executable pages with readable writable executable permissions (RWX).
> However, MacOS on ARM64 ("Apple M1"/Apple Silicon) prohibits further
> permission changing of RWX memory pages. This means that the code page
> headers must be allocated with RWX permissions too because otherwise
> it wouldn't be possible to allocate a large code page over the freed
> regular code page and vice versa.
>
> When enabled, the new machinery works as follows:
>
> 1) when memory region is reserved for allocating executable pages, the
>    whole region is committed with RWX permissions and then decommitted,
> 2) since reconfiguration of RWX page permissions is not allowed on
>    MacOS on ARM64 ("Apple M1"/Apple Silicon), there must be no attempts
>    to change them,
> 3) the request to set RWX permissions in the executable page region
>    just recommits the pages without changing permissions (see (1), they
>    were already allocated as RWX and then discarded),
> 4) in order to make executable pages inaccessible one must use
>    OS::DiscardSystemPages() instead of OS::DecommitPages() or
>    setting permissions to kNoAccess because the latter two are not
>    allowed by the MacOS (see (2)).
> 5) since code space page headers are allocated as RWX pages it's also
>    necessary to switch between W^X modes when updating the data in the
>    page headers (i.e. when marking, updating stats, wiring pages in
>    lists, etc.). The new CodePageHeaderModificationScope class is used
>    in the respective places. On unrelated configurations it's a no-op.
>
> The fast permission switching can't be used for V8 configuration with
> enabled pointer compression and disabled external code space because
> a) the pointer compression cage has to be reserved with MAP_JIT flag
>    which is too expensive,
> b) in case of shared pointer compression cage if the code range will
>    be deleted while the cage is still alive then attempt to configure
>    permissions of pages that were previously set to RWX will fail.
>
> This also CL extends the unmapper unit tests with permissions tracking
> for discarded pages.
>
> Bug: v8:12797
> Change-Id: Idb28cbc481306477589eee9962d2e75167d87c61
> Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3579303
> Reviewed-by: Nico Hartmann <nicohartmann@chromium.org>
> Reviewed-by: Clemens Backes <clemensb@chromium.org>
> Reviewed-by: Michael Lippautz <mlippautz@chromium.org>
> Commit-Queue: Igor Sheludko <ishell@chromium.org>
> Cr-Commit-Position: refs/heads/main@{#80238}

Bug: v8:12797
Change-Id: I0fe86666f31bad37d7074e217555c95900d2afba
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3610433
Reviewed-by: Nico Hartmann <nicohartmann@chromium.org>
Reviewed-by: Michael Lippautz <mlippautz@chromium.org>
Commit-Queue: Igor Sheludko <ishell@chromium.org>
Reviewed-by: Clemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/main@{#80259}
2022-04-28 14:08:11 +00:00
..
DIR_METADATA Add DIR_METADATA files to v8. 2020-10-20 22:12:28 +00:00
OWNERS Add DIR_METADATA files to v8. 2020-10-20 22:12:28 +00:00
test-backing-store.cc [wasm] Move test-backing-store.cc to wasm directory 2021-03-03 13:07:01 +00:00
test-c-wasm-entry.cc [ext-code-space] Migrate WasmExportedFunctionData code field to CodeT 2021-06-18 14:10:43 +00:00
test-compilation-cache.cc [wasm] Initialize memory protection key permissions 2021-12-20 13:58:33 +00:00
test-gc.cc [wasm] flag_liftoff_only should disable wasm-dynamic-tiering in cctest 2022-04-11 14:59:35 +00:00
test-grow-memory.cc [base] Move utils/vector.h to base/vector.h 2021-06-18 13:33:13 +00:00
test-jump-table-assembler.cc Reland "[rwx][mac] Support fast W^X permission switching on Apple Silicon (M1)" 2022-04-28 14:08:11 +00:00
test-liftoff-for-fuzzing.cc Reland "[wasm] Add tests for NaN detection in Liftoff" 2021-09-14 08:41:58 +00:00
test-liftoff-inspection.cc [liftoff] Move more options into LiftoffOptions 2022-04-19 16:21:21 +00:00
test-run-wasm-64.cc [cleanup] Fix -Wshadow warnings in cctest/wasm 2021-09-24 22:39:54 +00:00
test-run-wasm-asmjs.cc [test][cleanup] Rename WASM_*_LOCAL to WASM_LOCAL_* 2020-12-17 21:19:14 +00:00
test-run-wasm-atomics64.cc [maglev] Generic binary operations 2022-03-14 14:39:06 +00:00
test-run-wasm-atomics.cc [maglev] Generic binary operations 2022-03-14 14:39:06 +00:00
test-run-wasm-bulk-memory.cc [wasm] Small refactoring for module types 2022-01-27 14:52:20 +00:00
test-run-wasm-exceptions.cc [wasm] Remove --experimental-wasm-reftypes flag 2021-12-13 14:29:15 +00:00
test-run-wasm-interpreter.cc [wasm-gc] Merge anyref and externref 2022-03-01 22:12:59 +00:00
test-run-wasm-js.cc [cleanup] Fix -Wshadow warnings in cctest/wasm 2021-09-24 22:39:54 +00:00
test-run-wasm-memory64.cc [wasm] Disable trap handling for memory64 2021-07-08 11:03:08 +00:00
test-run-wasm-module.cc Reland "[wasm] Add --wasm-dynamic-tiering to --future" 2021-12-14 15:06:37 +00:00
test-run-wasm-relaxed-simd.cc [wasm-simd] Remove F32x4RecipApprox and F32x4RecipSqrtApprox 2022-04-22 17:37:19 +00:00
test-run-wasm-sign-extension.cc [test][cleanup] Rename WASM_*_LOCAL to WASM_LOCAL_* 2020-12-17 21:19:14 +00:00
test-run-wasm-simd-liftoff.cc [wasm] Do not enforce LE for globals and WasmValue 2021-06-10 18:08:38 +00:00
test-run-wasm-simd.cc [wasm-simd][arm64] Use Bic(x, imm) for And(x, [Not](imm)) when possible 2022-04-19 10:09:37 +00:00
test-run-wasm-wrappers.cc [ext-code-space] Avoid Code <-> CodeT conversions in runtime, pt.4 2021-12-14 18:42:55 +00:00
test-run-wasm.cc [wasm] Remove --experimental-wasm-reftypes flag 2021-12-13 14:29:15 +00:00
test-streaming-compilation.cc [test] Make cctest run one test, with maybe custom platform 2022-04-05 09:39:18 +00:00
test-wasm-breakpoints.cc [debugger] Explicitly encode debugger statements in didPause 2021-12-02 10:41:43 +00:00
test-wasm-codegen.cc [zone] Cleanup zone allocations in src/wasm and tests 2020-07-10 12:11:55 +00:00
test-wasm-import-wrapper-cache.cc [wasm] Add suspend wrapper stub 2022-01-14 16:45:42 +00:00
test-wasm-metrics.cc [test] Make cctest run one test, with maybe custom platform 2022-04-05 09:39:18 +00:00
test-wasm-serialization.cc Reland "[wasm] Add --wasm-dynamic-tiering to --future" 2021-12-14 15:06:37 +00:00
test-wasm-shared-engine.cc [isolate][cleanup] Remove pointer to WasmEngine 2021-06-21 09:09:25 +00:00
test-wasm-stack.cc [debug] Add new 'CreateMessageFromException' function 2022-01-12 12:49:53 +00:00
test-wasm-trap-position.cc [inspector] Capture stack trace only once for JSError objects. 2022-01-10 14:55:18 +00:00
wasm-atomics-utils.h [maglev] Generic binary operations 2022-03-14 14:39:06 +00:00
wasm-run-utils.cc [wasm] Introduce AssemblerBufferCache 2022-04-25 11:56:51 +00:00
wasm-run-utils.h Fix typos, intial* -> initial* 2022-03-23 13:20:33 +00:00
wasm-simd-utils.cc [wasm-relaxed-simd][x64] Prototype relaxed min and max 2021-10-21 00:58:24 +00:00
wasm-simd-utils.h [wasm-relaxed-simd][x64] Prototype relaxed min and max 2021-10-21 00:58:24 +00:00