From 1553bbdf81f1cebe3663f4c32bf9dc6b2b4c0569 Mon Sep 17 00:00:00 2001 From: Than Ngo Date: Sat, 20 Jul 2024 14:18:35 +0200 Subject: [PATCH] update powerpc patches --- chromium.spec | 22 +++-- fix-study-crash.patch | 24 +++++ memory-allocator-dcheck-assert-fix.patch | 22 +++++ partition-alloc-4k-detect.patch | 112 +++++++++++++++++++++++ 4 files changed, 171 insertions(+), 9 deletions(-) create mode 100644 fix-study-crash.patch create mode 100644 memory-allocator-dcheck-assert-fix.patch create mode 100644 partition-alloc-4k-detect.patch diff --git a/chromium.spec b/chromium.spec index e2bf7ce4..d23c49a0 100644 --- a/chromium.spec +++ b/chromium.spec @@ -453,16 +453,17 @@ Patch400: fix-rustc.patch Patch401: fix-rust-linking.patch Patch402: fix-breakpad-compile.patch Patch403: fix-partition-alloc-compile.patch -Patch404: 0002-Add-ppc64-trap-instructions.patch +Patch404: fix-study-crash.patch +Patch405: memory-allocator-dcheck-assert-fix.patch +Patch406: 0002-Add-ppc64-trap-instructions.patch Patch407: fix-ppc64-linux-syscalls-headers.patch -Patch409: use-sysconf-page-size-on-ppc64.patch +Patch408: use-sysconf-page-size-on-ppc64.patch +Patch409: partition-alloc-4k-detect.patch Patch410: dawn-fix-typos.patch Patch411: dawn-fix-ppc64le-detection.patch -Patch412: fix-swiftshader-compile.patch - # Suppress harmless compiler warning messages that appear on ppc64 due to arch-specific warning flags being passed Patch413: fix-unknown-warning-option-messages.diff @@ -1158,15 +1159,17 @@ Qt6 UI for chromium. %patch -P401 -p1 -b .fix-rust-linking %patch -P402 -p1 -b .fix-breakpad-compile %patch -P403 -p1 -b .fix-partition-alloc-compile -%patch -P404 -p1 -b .0002-Add-ppc64-trap-instructions +%patch -P404 -p1 -b .fix-study-crash +%patch -P405 -p1 -b .memory-allocator-dcheck-assert-fix +%patch -P406 -p1 -b .0002-Add-ppc64-trap-instructions %patch -P407 -p1 -b .fix-ppc64-linux-syscalls-headers -%patch -P409 -p1 -b .use-sysconf-page-size-on-ppc64 +%patch -P408 -p1 -b .use-sysconf-page-size-on-ppc64 +%patch -P409 -p1 -b .partition-alloc-4k-detect %patch -P410 -p1 -b .dawn-fix-typos %patch -P411 -p1 -b .dawn-fix-ppc64le-detection -%patch -P412 -p1 -b .fix-swiftshader-compile.patch %patch -P413 -p1 -b .fix-unknown-warning-option-messages %endif @@ -1970,8 +1973,9 @@ getent group chrome-remote-desktop >/dev/null || groupadd -r chrome-remote-deskt %endif %changelog -* Thu Jul 18 2024 Than Ngo - 126.0.6478.182-2 -- fixed condition for is_cfi/use_thin_lto on aarch64/ppc64le +* Sat Jul 20 2024 Than Ngo - 126.0.6478.182-2 +- fix condition for is_cfi/use_thin_lto on aarch64/ppc64le +- update powerpc patches * Tue Jul 16 2024 Than Ngo - 126.0.6478.182-1 - update to 126.0.6478.182 diff --git a/fix-study-crash.patch b/fix-study-crash.patch new file mode 100644 index 00000000..2ba9d4b6 --- /dev/null +++ b/fix-study-crash.patch @@ -0,0 +1,24 @@ +--- a/components/variations/proto/study.proto ++++ b/components/variations/proto/study.proto +@@ -264,6 +264,9 @@ + // A Mac-only value, indicating an x86-64 binary running on an arm64 host + // via "Rosetta 2" binary translation. + TRANSLATED_X86_64 = 4; ++ ++ // A POSIX-only value, indicating an OpenPOWER host ++ PPC64 = 5; + } + + // Enum to pass as optional bool. +--- a/components/variations/service/variations_field_trial_creator_base.cc ++++ b/components/variations/service/variations_field_trial_creator_base.cc +@@ -109,6 +109,9 @@ + if (process_arch == "x86") { + return Study::X86_32; + } ++ if (process_arch == "PPC_64") { ++ return Study::PPC64; ++ } + if (process_arch == "x86_64") { + std::string os_arch = base::SysInfo::OperatingSystemArchitecture(); + if (base::StartsWith(os_arch, "arm", diff --git a/memory-allocator-dcheck-assert-fix.patch b/memory-allocator-dcheck-assert-fix.patch new file mode 100644 index 00000000..6d1b2be4 --- /dev/null +++ b/memory-allocator-dcheck-assert-fix.patch @@ -0,0 +1,22 @@ +--- a/base/allocator/partition_allocator/src/partition_alloc/partition_bucket.cc ++++ b/base/allocator/partition_allocator/src/partition_alloc/partition_bucket.cc +@@ -506,6 +506,9 @@ + partition_page_count <= kMaxPartitionPagesPerRegularSlotSpan; + partition_page_count++) { + size_t candidate_size = partition_page_count * PartitionPageSize(); ++ if (candidate_size > kMaxBucketed) { ++ break; ++ } + size_t waste = candidate_size % slot_size; + if (waste <= .02 * SystemPageSize()) { + return partition_page_count * NumSystemPagesPerPartitionPage(); +@@ -522,6 +525,9 @@ + size_t system_page_count = + partition_page_count * NumSystemPagesPerPartitionPage() - slack; + size_t candidate_size = system_page_count * SystemPageSize(); ++ if (candidate_size > kMaxBucketed) { ++ break; ++ } + size_t waste = candidate_size % slot_size; + if (waste < best_waste) { + best_waste = waste; diff --git a/partition-alloc-4k-detect.patch b/partition-alloc-4k-detect.patch new file mode 100644 index 00000000..a0a3f959 --- /dev/null +++ b/partition-alloc-4k-detect.patch @@ -0,0 +1,112 @@ +--- a/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_constants.h ++++ b/base/allocator/partition_allocator/src/partition_alloc/partition_alloc_constants.h +@@ -100,21 +100,21 @@ + // other constant values, we pack _all_ `PartitionRoot::Alloc` sizes perfectly + // up against the end of a system page. + +-#if defined(_MIPS_ARCH_LOONGSON) || defined(ARCH_CPU_LOONGARCH64) ++#if (BUILDFLAG(IS_APPLE) && defined(ARCH_CPU_64_BITS)) || \ ++ defined(PARTITION_ALLOCATOR_CONSTANTS_POSIX_NONCONST_PAGE_SIZE) + PA_ALWAYS_INLINE PAGE_ALLOCATOR_CONSTANTS_DECLARE_CONSTEXPR size_t + PartitionPageShift() { +- return 16; // 64 KiB ++ return PageAllocationGranularityShift() + 2; + } +-#elif defined(ARCH_CPU_PPC64) ++#elif defined(_MIPS_ARCH_LOONGSON) || defined(ARCH_CPU_LOONGARCH64) + PA_ALWAYS_INLINE PAGE_ALLOCATOR_CONSTANTS_DECLARE_CONSTEXPR size_t + PartitionPageShift() { +- return 18; // 256 KiB ++ return 16; // 64 KiB + } +-#elif (BUILDFLAG(IS_APPLE) && defined(ARCH_CPU_64_BITS)) || \ +- defined(PARTITION_ALLOCATOR_CONSTANTS_POSIX_NONCONST_PAGE_SIZE) ++#elif defined(ARCH_CPU_PPC64) + PA_ALWAYS_INLINE PAGE_ALLOCATOR_CONSTANTS_DECLARE_CONSTEXPR size_t + PartitionPageShift() { +- return PageAllocationGranularityShift() + 2; ++ return 18; // 256 KiB + } + #else + PA_ALWAYS_INLINE PAGE_ALLOCATOR_CONSTANTS_DECLARE_CONSTEXPR size_t +--- a/base/allocator/partition_allocator/src/partition_alloc/page_allocator_constants.h ++++ b/base/allocator/partition_allocator/src/partition_alloc/page_allocator_constants.h +@@ -26,7 +26,8 @@ + #define PAGE_ALLOCATOR_CONSTANTS_DECLARE_CONSTEXPR __attribute__((const)) + + #elif (BUILDFLAG(IS_ANDROID) && defined(ARCH_CPU_64_BITS)) || \ +- (BUILDFLAG(IS_LINUX) && defined(ARCH_CPU_ARM64)) ++ (BUILDFLAG(IS_LINUX) && defined(ARCH_CPU_ARM64)) || \ ++ (BUILDFLAG(IS_LINUX) && defined(ARCH_CPU_PPC64)) + // This should work for all POSIX (if needed), but currently all other + // supported OS/architecture combinations use either hard-coded values + // (such as x86) or have means to determine these values without needing +@@ -86,17 +87,7 @@ + + PA_ALWAYS_INLINE PAGE_ALLOCATOR_CONSTANTS_DECLARE_CONSTEXPR size_t + PageAllocationGranularityShift() { +-#if BUILDFLAG(IS_WIN) || defined(ARCH_CPU_PPC64) +- // Modern ppc64 systems support 4kB (shift = 12) and 64kB (shift = 16) page +- // sizes. Since 64kB is the de facto standard on the platform and binaries +- // compiled for 64kB are likely to work on 4kB systems, 64kB is a good choice +- // here. +- return 16; // 64kB +-#elif defined(_MIPS_ARCH_LOONGSON) || defined(ARCH_CPU_LOONGARCH64) +- return 14; // 16kB +-#elif BUILDFLAG(IS_APPLE) && defined(ARCH_CPU_64_BITS) +- return static_cast(vm_page_shift); +-#elif defined(PARTITION_ALLOCATOR_CONSTANTS_POSIX_NONCONST_PAGE_SIZE) ++#if defined(PARTITION_ALLOCATOR_CONSTANTS_POSIX_NONCONST_PAGE_SIZE) + // arm64 supports 4kb (shift = 12), 16kb (shift = 14), and 64kb (shift = 16) + // page sizes. Retrieve from or initialize cache. + size_t shift = page_characteristics.shift.load(std::memory_order_relaxed); +@@ -106,6 +97,16 @@ + page_characteristics.shift.store(shift, std::memory_order_relaxed); + } + return shift; ++#elif BUILDFLAG(IS_WIN) || defined(ARCH_CPU_PPC64) ++ // Modern ppc64 systems support 4kB (shift = 12) and 64kB (shift = 16) page ++ // sizes. Since 64kB is the de facto standard on the platform and binaries ++ // compiled for 64kB are likely to work on 4kB systems, 64kB is a good choice ++ // here. ++ return 16; // 64kB ++#elif defined(_MIPS_ARCH_LOONGSON) || defined(ARCH_CPU_LOONGARCH64) ++ return 14; // 16kB ++#elif BUILDFLAG(IS_APPLE) && defined(ARCH_CPU_64_BITS) ++ return static_cast(vm_page_shift); + #else + return 12; // 4kB + #endif +--- a/base/allocator/partition_allocator/src/partition_alloc/address_space_randomization.h ++++ b/base/allocator/partition_allocator/src/partition_alloc/address_space_randomization.h +@@ -180,10 +180,10 @@ + #else // !BUILDFLAG(IS_AIX) && !defined(ARCH_CPU_BIG_ENDIAN) + + // Little-endian Linux PPC has 48 bits of virtual addressing. Use 46. +- PA_ALWAYS_INLINE constexpr uintptr_t ASLRMask() { ++ PA_ALWAYS_INLINE PAGE_ALLOCATOR_CONSTANTS_DECLARE_CONSTEXPR uintptr_t ASLRMask() { + return AslrMask(46); + } +- PA_ALWAYS_INLINE constexpr uintptr_t ASLROffset() { ++ PA_ALWAYS_INLINE PAGE_ALLOCATOR_CONSTANTS_DECLARE_CONSTEXPR uintptr_t ASLROffset() { + return AslrAddress(0); + } + +--- a/base/allocator/partition_allocator/src/partition_alloc/partition_page_constants.h ++++ b/base/allocator/partition_allocator/src/partition_alloc/partition_page_constants.h +@@ -17,10 +17,15 @@ + // PartitionPageSize() is 4 times the OS page size. + static constexpr size_t kMaxSlotsPerSlotSpan = 4 * (1 << 14) / kSmallestBucket; + #elif defined(PARTITION_ALLOCATOR_CONSTANTS_POSIX_NONCONST_PAGE_SIZE) ++#if defined(ARCH_CPU_PPC64) ++// System page size can be 4 or 64 kiB on Linux on ppc64. Use 64 kiB maximum. ++static constexpr size_t kMaxSlotsPerSlotSpan = 4 * (1 << 16) / kSmallestBucket; ++#else + // System page size can be 4, 16, or 64 kiB on Linux on arm64. 64 kiB is + // currently (kMaxSlotsPerSlotSpanBits == 13) not supported by the code, + // so we use the 16 kiB maximum (64 kiB will crash). + static constexpr size_t kMaxSlotsPerSlotSpan = 4 * (1 << 14) / kSmallestBucket; ++#endif + #elif BUILDFLAG(IS_LINUX) && defined(ARCH_CPU_PPC64) + // System page size is not a constant on OpenPOWER systems, but is either 4kiB + // or 64kiB (1 << 12 or 1 << 16)