// Copyright 2024 the V8 project authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef V8_WASM_WASM_CODE_POINTER_TABLE_H_ #define V8_WASM_WASM_CODE_POINTER_TABLE_H_ #include "include/v8-internal.h" #include "src/common/segmented-table.h" #if !V8_ENABLE_WEBASSEMBLY #error This header should only be included if WebAssembly is enabled. #endif // !V8_ENABLE_WEBASSEMBLY namespace v8::internal::wasm { // Defines the entries in the WasmCodePointerTable and specifies the encoding. // When entries are in use, they contain the address of a valid Wasm code entry, // while free entries contain an index to the next element in the freelist. // // All reads and writes use relaxed memory ordering and need to be synchronized // by the caller. struct WasmCodePointerTableEntry { … }; // A table for storing valid Wasm code entrypoints. This table allows enforcing // forward-edge CFI for Wasm calls: // * The table gets write-protected (e.g. with pkeys) to prevent corruption of // entries. // * At write time, we will check that the value is a valid entrypoint as // tracked in our CFI metadata. // * Wasm calls can then be replaced with a bounds-checked table lookup + call // to enforce that only valid entrypoints can be called. // // All methods are thread-safe if not specified otherwise. class V8_EXPORT_PRIVATE WasmCodePointerTable : public SegmentedTable<WasmCodePointerTableEntry, kCodePointerTableReservationSize> { … }; V8_EXPORT_PRIVATE WasmCodePointerTable* GetProcessWideWasmCodePointerTable(); } // namespace v8::internal::wasm #endif // V8_WASM_WASM_CODE_POINTER_TABLE_H_