-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a script to pull and patch PartitionAlloc
- Loading branch information
Showing
2 changed files
with
102 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
diff --git a/base/allocator/partition_allocator/partition_bucket.cc b/base/allocator/partition_allocator/partition_bucket.cc | ||
index 6434ee54..c27030dd 100644 | ||
--- a/base/allocator/partition_allocator/partition_bucket.cc | ||
+++ b/base/allocator/partition_allocator/partition_bucket.cc | ||
@@ -41,6 +41,9 @@ | ||
#include "base/allocator/partition_allocator/starscan/state_bitmap.h" | ||
#endif // BUILDFLAG(STARSCAN) | ||
|
||
+#include <sys/mman.h> | ||
+#include <ia2_get_pkey.h> | ||
+ | ||
namespace partition_alloc::internal { | ||
|
||
namespace { | ||
@@ -187,6 +190,18 @@ uintptr_t ReserveMemoryFromPool(pool_handle pool, | ||
#endif | ||
|
||
PA_DCHECK(!(reserved_address % kSuperPageSize)); | ||
+ | ||
+ // TODO: This call to ia2_get_pkey will always return a pkey between 1 and 15. For shared | ||
+ // allocations (i.e. pkey 0) we currently use the glibc allocator. Ideally we should propagate the | ||
+ // allocator's pkey down to this function when allocations trigger calls to it so we can use the | ||
+ // same allocator for shared and private allocations. | ||
+ size_t pkey = ::ia2_get_pkey(); | ||
+ int rc = pkey_mprotect((void *)reserved_address, requested_size, PROT_READ | PROT_WRITE, pkey); | ||
+ if (rc != 0) { | ||
+ printf("Compartment %zu failed to pkey_mprotect reserved heap memory (%d)", pkey, rc); | ||
+ exit(-1); | ||
+ } | ||
+ | ||
return reserved_address; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
#!/bin/bash | ||
|
||
set -Eeuo pipefail | ||
|
||
REPO_ROOT=$(pwd) | ||
REPO_CHROMIUM=$REPO_ROOT/external/chromium | ||
REPO_SRC=$REPO_CHROMIUM/src | ||
NEW_CHROMIUM=$REPO_ROOT/chromium | ||
NEW_SRC=$NEW_CHROMIUM/src | ||
DEPOT_TOOLS=$REPO_ROOT/depot_tools | ||
|
||
# Download depot_tools | ||
if [[ -d "$DEPOT_TOOLS" ]]; | ||
then | ||
rm -rf $DEPOT_TOOLS | ||
fi | ||
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git $DEPOT_TOOLS | ||
export PATH=$PATH:$DEPOT_TOOLS | ||
|
||
# Download chromium | ||
if [[ -d "$NEW_CHROMIUM" ]]; | ||
then | ||
rm -rf $NEW_CHROMIUM | ||
fi | ||
mkdir $NEW_CHROMIUM | ||
pushd $NEW_CHROMIUM | ||
fetch --nohooks --no-history chromium | ||
pushd src | ||
git log -1 --format="%H" > $REPO_ROOT/chromium_commit | ||
# ./build/install-build-deps.sh | ||
gclient runhooks | ||
gn gen out/Default | ||
autoninja -C out/Default base/allocator/partition_allocator:partition_alloc | ||
git apply $REPO_ROOT/scripts/partition_alloc/partition_alloc.diff | ||
|
||
popd | ||
popd | ||
|
||
if [[ -d "$REPO_CHROMIUM" ]]; | ||
then | ||
rm -rf $REPO_CHROMIUM | ||
fi | ||
|
||
mkdir -p $REPO_SRC | ||
|
||
mkdir $REPO_SRC/build | ||
cp $NEW_SRC/build/build_config.h $NEW_SRC/build/buildflag.h $NEW_SRC/build/precompile.h $REPO_SRC/build | ||
mkdir -p $REPO_SRC/testing/gtest/include/gtest | ||
cp $NEW_SRC/testing/gtest/include/gtest/gtest_prod.h $REPO_SRC/testing/gtest/include/gtest | ||
mkdir -p $REPO_SRC/third_party/googletest/src/googletest/include/gtest | ||
cp $NEW_SRC/third_party/googletest/src/googletest/include/gtest/gtest_prod.h $REPO_SRC/third_party/googletest/src/googletest/include/gtest | ||
mkdir -p $REPO_SRC/third_party/lss | ||
cp $NEW_SRC/third_party/lss/linux_syscall_support.h $REPO_SRC/third_party/lss | ||
mkdir -p $REPO_SRC/base/allocator | ||
cp -r $NEW_SRC/base/allocator/partition_allocator $REPO_SRC/base/allocator | ||
|
||
# Copy over the generated headers | ||
OUT_PARTITION_ALLOC=$NEW_SRC/out/Default/gen/base/allocator/partition_allocator | ||
REPO_PARTITION_ALLOC=$REPO_SRC/base/allocator/partition_allocator | ||
|
||
cp $OUT_PARTITION_ALLOC/partition_alloc_base/debug/debugging_buildflags.h $REPO_PARTITION_ALLOC/partition_alloc_base/debug | ||
cp $OUT_PARTITION_ALLOC/partition_alloc_buildflags.h $REPO_PARTITION_ALLOC | ||
cp $OUT_PARTITION_ALLOC/chromeos_buildflags.h $REPO_PARTITION_ALLOC | ||
cp $OUT_PARTITION_ALLOC/chromecast_buildflags.h $REPO_PARTITION_ALLOC | ||
cp $OUT_PARTITION_ALLOC/logging_buildflags.h $REPO_PARTITION_ALLOC | ||
|
||
rm -rf $NEW_CHROMIUM | ||
rm -rf $DEPOT_TOOLS | ||
|