Commit 019be504 authored by Igor Sheludko's avatar Igor Sheludko Committed by V8 LUCI CQ

[ext-code-space] Support V8 sandbox mode

Drive-by: fix multi-arch build.

Bug: v8:11880
Change-Id: I4e56370598117fec2a0131e5638d4bac3d84c52f
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3412083Reviewed-by: 's avatarSamuel Groß <saelo@chromium.org>
Auto-Submit: Igor Sheludko <ishell@chromium.org>
Reviewed-by: 's avatarJakob Kummerow <jkummerow@chromium.org>
Commit-Queue: Igor Sheludko <ishell@chromium.org>
Cr-Commit-Position: refs/heads/main@{#78759}
parent 9ccdfe13
...@@ -450,6 +450,7 @@ if (v8_multi_arch_build && ...@@ -450,6 +450,7 @@ if (v8_multi_arch_build &&
"clang_x64_pointer_compression") { "clang_x64_pointer_compression") {
v8_enable_pointer_compression = !v8_enable_pointer_compression v8_enable_pointer_compression = !v8_enable_pointer_compression
v8_enable_pointer_compression_shared_cage = v8_enable_pointer_compression v8_enable_pointer_compression_shared_cage = v8_enable_pointer_compression
v8_enable_external_code_space = v8_enable_pointer_compression
} }
# Check if it is a Chromium build and activate PAC/BTI if needed. # Check if it is a Chromium build and activate PAC/BTI if needed.
...@@ -516,10 +517,6 @@ assert(!v8_enable_sandboxed_pointers || v8_enable_sandbox, ...@@ -516,10 +517,6 @@ assert(!v8_enable_sandboxed_pointers || v8_enable_sandbox,
assert(!v8_enable_sandboxed_external_pointers || v8_enable_sandbox, assert(!v8_enable_sandboxed_external_pointers || v8_enable_sandbox,
"Sandboxed external pointers require the sandbox") "Sandboxed external pointers require the sandbox")
assert(
!v8_enable_sandboxed_external_pointers || !v8_enable_external_code_space,
"Sandboxed external pointers are not compatible with external code space YET")
assert( assert(
!v8_enable_pointer_compression_shared_cage || v8_enable_pointer_compression, !v8_enable_pointer_compression_shared_cage || v8_enable_pointer_compression,
"Can't share a pointer compression cage if pointers aren't compressed") "Can't share a pointer compression cage if pointers aren't compressed")
......
...@@ -3224,8 +3224,8 @@ Node* WasmGraphBuilder::BuildIndirectCall( ...@@ -3224,8 +3224,8 @@ Node* WasmGraphBuilder::BuildIndirectCall(
} }
} }
Node* WasmGraphBuilder::BuildLoadExternalPointerFromObject(Node* object, Node* WasmGraphBuilder::BuildLoadExternalPointerFromObject(
int offset) { Node* object, int offset, ExternalPointerTag tag) {
#ifdef V8_SANDBOXED_EXTERNAL_POINTERS #ifdef V8_SANDBOXED_EXTERNAL_POINTERS
Node* external_pointer = gasm_->LoadFromObject( Node* external_pointer = gasm_->LoadFromObject(
MachineType::Uint32(), object, wasm::ObjectAccess::ToTagged(offset)); MachineType::Uint32(), object, wasm::ObjectAccess::ToTagged(offset));
...@@ -3237,8 +3237,7 @@ Node* WasmGraphBuilder::BuildLoadExternalPointerFromObject(Node* object, ...@@ -3237,8 +3237,7 @@ Node* WasmGraphBuilder::BuildLoadExternalPointerFromObject(Node* object,
Node* scaled_index = gasm_->Int32Mul( Node* scaled_index = gasm_->Int32Mul(
external_pointer, gasm_->Int32Constant(kSystemPointerSize)); external_pointer, gasm_->Int32Constant(kSystemPointerSize));
Node* decoded_ptr = gasm_->Load(MachineType::Pointer(), table, scaled_index); Node* decoded_ptr = gasm_->Load(MachineType::Pointer(), table, scaled_index);
Node* tag = gasm_->IntPtrConstant(~kForeignForeignAddressTag); return gasm_->WordAnd(decoded_ptr, gasm_->IntPtrConstant(~tag));
return gasm_->WordAnd(decoded_ptr, tag);
#else #else
return gasm_->LoadFromObject(MachineType::Pointer(), object, return gasm_->LoadFromObject(MachineType::Pointer(), object,
wasm::ObjectAccess::ToTagged(offset)); wasm::ObjectAccess::ToTagged(offset));
...@@ -3286,11 +3285,9 @@ Node* WasmGraphBuilder::BuildCallRef(const wasm::FunctionSig* real_sig, ...@@ -3286,11 +3285,9 @@ Node* WasmGraphBuilder::BuildCallRef(const wasm::FunctionSig* real_sig,
wasm::ObjectAccess::ToTagged(WasmInternalFunction::kCodeOffset)); wasm::ObjectAccess::ToTagged(WasmInternalFunction::kCodeOffset));
Node* call_target; Node* call_target;
if (V8_EXTERNAL_CODE_SPACE_BOOL) { if (V8_EXTERNAL_CODE_SPACE_BOOL) {
CHECK(!V8_SANDBOXED_EXTERNAL_POINTERS_BOOL); // Not supported yet. call_target = BuildLoadExternalPointerFromObject(
call_target = gasm_->LoadImmutableFromObject( wrapper_code, CodeDataContainer::kCodeEntryPointOffset,
MachineType::Pointer(), wrapper_code, kCodeEntryPointTag);
wasm::ObjectAccess::ToTagged(
CodeDataContainer::kCodeEntryPointOffset));
} else { } else {
call_target = gasm_->IntAdd( call_target = gasm_->IntAdd(
......
...@@ -776,7 +776,9 @@ class WasmGraphBuilder { ...@@ -776,7 +776,9 @@ class WasmGraphBuilder {
Node* BuildMultiReturnFixedArrayFromIterable(const wasm::FunctionSig* sig, Node* BuildMultiReturnFixedArrayFromIterable(const wasm::FunctionSig* sig,
Node* iterable, Node* context); Node* iterable, Node* context);
Node* BuildLoadExternalPointerFromObject(Node* object, int offset); Node* BuildLoadExternalPointerFromObject(
Node* object, int offset,
ExternalPointerTag tag = kForeignForeignAddressTag);
Node* BuildLoadCallTargetFromExportedFunctionData(Node* function_data); Node* BuildLoadCallTargetFromExportedFunctionData(Node* function_data);
......
...@@ -914,7 +914,7 @@ ACCESSORS(CodeDataContainer, next_code_link, Object, kNextCodeLinkOffset) ...@@ -914,7 +914,7 @@ ACCESSORS(CodeDataContainer, next_code_link, Object, kNextCodeLinkOffset)
PtrComprCageBase CodeDataContainer::code_cage_base() const { PtrComprCageBase CodeDataContainer::code_cage_base() const {
#ifdef V8_EXTERNAL_CODE_SPACE #ifdef V8_EXTERNAL_CODE_SPACE
CHECK(!V8_SANDBOXED_EXTERNAL_POINTERS_BOOL); // TODO(v8:10391): consider protecting this value with the sandbox.
Address code_cage_base_hi = Address code_cage_base_hi =
ReadField<Tagged_t>(kCodeCageBaseUpper32BitsOffset); ReadField<Tagged_t>(kCodeCageBaseUpper32BitsOffset);
return PtrComprCageBase(code_cage_base_hi << 32); return PtrComprCageBase(code_cage_base_hi << 32);
...@@ -925,7 +925,6 @@ PtrComprCageBase CodeDataContainer::code_cage_base() const { ...@@ -925,7 +925,6 @@ PtrComprCageBase CodeDataContainer::code_cage_base() const {
void CodeDataContainer::set_code_cage_base(Address code_cage_base) { void CodeDataContainer::set_code_cage_base(Address code_cage_base) {
#ifdef V8_EXTERNAL_CODE_SPACE #ifdef V8_EXTERNAL_CODE_SPACE
CHECK(!V8_SANDBOXED_EXTERNAL_POINTERS_BOOL);
Tagged_t code_cage_base_hi = static_cast<Tagged_t>(code_cage_base >> 32); Tagged_t code_cage_base_hi = static_cast<Tagged_t>(code_cage_base >> 32);
WriteField<Tagged_t>(kCodeCageBaseUpper32BitsOffset, code_cage_base_hi); WriteField<Tagged_t>(kCodeCageBaseUpper32BitsOffset, code_cage_base_hi);
#else #else
......
...@@ -965,7 +965,8 @@ class CodeDataContainer::BodyDescriptor final : public BodyDescriptorBase { ...@@ -965,7 +965,8 @@ class CodeDataContainer::BodyDescriptor final : public BodyDescriptorBase {
if (V8_EXTERNAL_CODE_SPACE_BOOL) { if (V8_EXTERNAL_CODE_SPACE_BOOL) {
v->VisitCodePointer(obj, obj.RawCodeField(kCodeOffset)); v->VisitCodePointer(obj, obj.RawCodeField(kCodeOffset));
v->VisitExternalPointer(obj, obj.RawExternalPointerField(kCodeOffset)); v->VisitExternalPointer(
obj, obj.RawExternalPointerField(kCodeEntryPointOffset));
} }
} }
......
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