Enable ppc64le build

i8e
Arkady L. Shane 10 months ago
parent 3475273f86
commit c72ab5d0b5
Signed by: tigro
GPG Key ID: 1EC08A25C9DB2503

File diff suppressed because it is too large Load Diff

@ -0,0 +1,23 @@
From 61dcf0ff9603e8f5b0a859fb0837c51527ebae43 Mon Sep 17 00:00:00 2001
From: Colin Samples <colin.samples+git@gmail.com>
Date: Fri, 1 Nov 2019 11:50:52 -0400
Subject: [PATCH] Add PPC64 support for libdav1d
---
third_party/dav1d/BUILD.gn | 21 ++++++++++++++++++++
third_party/dav1d/generate_configs.py | 28 ++-------------------------
third_party/dav1d/generate_source.py | 2 ++
3 files changed, 25 insertions(+), 26 deletions(-)
Index: chromium-120.0.6099.71/third_party/dav1d/generate_configs.py
===================================================================
--- chromium-120.0.6099.71.orig/third_party/dav1d/generate_configs.py
+++ chromium-120.0.6099.71/third_party/dav1d/generate_configs.py
@@ -203,6 +203,7 @@ def main():
linux_env = os.environ
linux_env['CC'] = 'clang'
+ GenerateConfig('config/linux/ppc64', linux_env)
GenerateConfig('config/linux/x64', linux_env)
noasm_dir = 'config/linux-noasm/x64'

@ -0,0 +1,57 @@
From 40309fb53e39477490fd6928ebe67c4fb78de380 Mon Sep 17 00:00:00 2001
From: Shawn Anastasio <shawnanastasio@gmail.com>
Date: Sun, 10 Mar 2019 21:01:37 -0500
Subject: [PATCH] Add ppc64 target to libaom
---
third_party/libaom/BUILD.gn | 12 ++++++++++++
third_party/libaom/cmake_update.sh | 3 +++
2 files changed, 15 insertions(+)
Index: chromium-120.0.6099.71/third_party/libaom/BUILD.gn
===================================================================
--- chromium-120.0.6099.71.orig/third_party/libaom/BUILD.gn
+++ chromium-120.0.6099.71/third_party/libaom/BUILD.gn
@@ -248,6 +248,18 @@ if (current_cpu == "arm64") {
}
}
+if (current_cpu == "ppc64") {
+ source_set("libaom_intrinsics_vsx") {
+ configs -= [ "//build/config/compiler:chromium_code" ]
+ configs += [ "//build/config/compiler:no_chromium_code" ]
+ configs += [ ":libaom_config" ]
+ sources = [
+ "//third_party/libaom/source/libaom/aom_ports/ppc_cpudetect.c",
+ ]
+ sources += aom_av1_common_intrin_vsx
+ }
+}
+
static_library("libaom") {
check_includes = false
if (!is_debug && is_win) {
@@ -312,6 +324,9 @@ static_library("libaom") {
# This is needed by all arm boards due to aom_arm_cpu_caps()
sources += [ "source/libaom/aom_ports/aarch32_cpudetect.c" ]
}
+ if (current_cpu == "ppc64") {
+ deps += [ ":libaom_intrinsics_vsx" ]
+ }
if (is_android) {
deps += [ "//third_party/cpu_features:ndk_compat" ]
}
Index: chromium-120.0.6099.71/third_party/libaom/cmake_update.sh
===================================================================
--- chromium-120.0.6099.71.orig/third_party/libaom/cmake_update.sh
+++ chromium-120.0.6099.71/third_party/libaom/cmake_update.sh
@@ -187,6 +187,9 @@ gen_config_files linux/arm64-cpu-detect
"${toolchain}/arm64-linux-gcc.cmake -DCONFIG_RUNTIME_CPU_DETECT=1 \
${all_platforms}"
+reset_dirs linux/ppc64
+gen_config_files linux/ppc64 "${toolchain}/ppc-linux-gcc.cmake ${all_platforms}"
+
# Copy linux configurations and modify for Windows.
reset_dirs win/arm64-cpu-detect
cp "${CFG}/linux/arm64-cpu-detect/config"/* \

@ -0,0 +1,14 @@
Index: chromium-120.0.6099.71/third_party/highway/BUILD.gn
===================================================================
--- chromium-120.0.6099.71.orig/third_party/highway/BUILD.gn
+++ chromium-120.0.6099.71/third_party/highway/BUILD.gn
@@ -13,6 +13,9 @@ config("libhwy_external_config") {
# explicitly disabling AVX2 and AVX3 targets.
defines += [ "HWY_BROKEN_TARGETS=(HWY_AVX2|HWY_AVX3)" ]
}
+ if (target_cpu == "ppc64") {
+ defines += [ "TOOLCHAIN_MISS_ASM_HWCAP_H" ]
+ }
}
source_set("libhwy") {

@ -0,0 +1,33 @@
From e14024659e0fc2af3df6ec56ce39a8e93b75722d Mon Sep 17 00:00:00 2001
From: Colin Samples <colin.samples+git@gmail.com>
Date: Sun, 8 Dec 2019 19:25:02 -0500
Subject: [PATCH] Fix libdav1d compilation on clang ppc
---
src/ppc/dav1d_types.h | 15 +++++++++++++++
1 file changed, 15 insertions(+)
Index: chromium-120.0.6099.71/third_party/dav1d/libdav1d/src/ppc/dav1d_types.h
===================================================================
--- chromium-120.0.6099.71.orig/third_party/dav1d/libdav1d/src/ppc/dav1d_types.h
+++ chromium-120.0.6099.71/third_party/dav1d/libdav1d/src/ppc/dav1d_types.h
@@ -51,4 +51,19 @@
#define u16l_to_i32(v) ((i32x4) vec_mergel((u16x8) v, vec_splat_u16(0)))
#define i16l_to_i32(v) ((i32x4) vec_unpackl((i16x8)v))
+#if defined(__clang__)
+#undef vec_splats
+#define vec_splats(N) \
+ _Generic((N), \
+ unsigned char: ((u8x16)(N)), \
+ signed char: ((i8x16)(N)), \
+ unsigned short: ((u16x8)(N)), \
+ signed short: ((i16x8)(N)), \
+ unsigned int: ((u32x4)(N)), \
+ signed int: ((i32x4)(N)), \
+ unsigned long long: ((u64x2)(N)), \
+ signed long long: ((i64x2)(N)) \
+ )
+#endif
+
#endif /* DAV1D_SRC_PPC_TYPES_H */

@ -0,0 +1,27 @@
From ea104a841fca1ff4d5430915f1b7c52c6a642f13 Mon Sep 17 00:00:00 2001
From: Timothy Pearson <tpearson@raptorengineering.com>
Date: Fri, 21 Sep 2018 21:44:17 -0500
Subject: [PATCH] Force baseline POWER8 / AltiVec / VSX CPU features when on a
PPC64 platform in LE mode
---
BUILD.gn | 6 ++++++
1 file changed, 6 insertions(+)
Index: chromium-120.0.6099.71/v8/BUILD.gn
===================================================================
--- chromium-120.0.6099.71.orig/v8/BUILD.gn
+++ chromium-120.0.6099.71/v8/BUILD.gn
@@ -1340,6 +1340,12 @@ config("toolchain") {
}
if (host_byteorder == "little") {
defines += [ "V8_TARGET_ARCH_PPC_LE" ]
+ cflags += [
+ # Enable usage of AltiVec, VSX, and other POWER8 and higher features
+ "-mcpu=power8",
+ "-maltivec",
+ "-mvsx",
+ ]
} else if (host_byteorder == "big") {
defines += [ "V8_TARGET_ARCH_PPC_BE" ]
if (current_os == "aix") {

File diff suppressed because it is too large Load Diff

@ -0,0 +1,774 @@
From cda9400739dfa064907d822f00578bb51b24a404 Mon Sep 17 00:00:00 2001
From: Shawn Anastasio <shawnanastasio@yahoo.com>
Date: Fri, 17 Aug 2018 14:18:33 -0500
Subject: [PATCH] Implement support for ppc64 on Linux
This patch implements support for the ppc64 architecture on Linux systems.
Notable changes include:
* Modification of tests to support non-4K page sizes
* minidump_writer: Determine size of stack to capture based on page size
* dump_writer_common: Introduce member function GetVectorRegisters to
ThreadInfo on ppc64 systems. This allows Altivec/VMX registers to be
dumped like they are on OS X. linux_ptrace_dumper has been updated
to utilize this function along with the ptrace mode NT_PPC_VMX.
* processor/exploitability_unittest.cc: Tests were disabled on
non-x86 systems. They assume the system objdump is capable of
disassembling x86 binaries which is not the case on other
architectures.
To-do:
* tools/linux/md2core has been updated as well, but functionality
has not been confirmed and restoration of Altivec/VMX registers
has not been implemented
Note that proper functionality depends on updates to third_party/LSS
that introduce PPC64 support. An in-progress patch that allows
breakpad to build and run successfully is available at:
https://wiki.raptorcs.com/wiki/Porting/Chromium
---
.../dump_writer_common/raw_context_cpu.h | 2 +
.../linux/dump_writer_common/thread_info.cc | 56 ++++++++++++++++++-
.../linux/dump_writer_common/thread_info.h | 9 +++
.../dump_writer_common/ucontext_reader.cc | 42 ++++++++++++++
.../dump_writer_common/ucontext_reader.h | 3 +
src/client/linux/handler/exception_handler.cc | 22 +++++++-
src/client/linux/handler/exception_handler.h | 6 +-
.../handler/exception_handler_unittest.cc | 8 ++-
.../microdump_writer/microdump_writer.cc | 14 ++++-
.../microdump_writer_unittest.cc | 15 ++++-
.../minidump_writer/linux_core_dumper.cc | 8 ++-
.../linux/minidump_writer/linux_dumper.cc | 4 +-
.../linux/minidump_writer/linux_dumper.h | 3 +-
.../linux_dumper_unittest_helper.cc | 2 +
.../minidump_writer/linux_ptrace_dumper.cc | 19 +++++--
.../linux_ptrace_dumper_unittest.cc | 5 ++
.../linux/minidump_writer/minidump_writer.cc | 18 ++++--
.../linux/minidump_writer/minidump_writer.h | 2 +
.../minidump_writer_unittest.cc | 3 +
src/common/linux/memory_mapped_file.cc | 3 +-
.../linux/memory_mapped_file_unittest.cc | 7 ++-
src/common/memory_allocator_unittest.cc | 3 +-
src/processor/exploitability_linux.cc | 2 +
src/processor/exploitability_unittest.cc | 15 +++--
src/tools/linux/md2core/minidump-2-core.cc | 45 +++++++++++++++
25 files changed, 281 insertions(+), 35 deletions(-)
Index: chromium-120.0.6099.71/third_party/breakpad/breakpad/src/client/linux/dump_writer_common/raw_context_cpu.h
===================================================================
--- chromium-120.0.6099.71.orig/third_party/breakpad/breakpad/src/client/linux/dump_writer_common/raw_context_cpu.h
+++ chromium-120.0.6099.71/third_party/breakpad/breakpad/src/client/linux/dump_writer_common/raw_context_cpu.h
@@ -51,6 +51,8 @@ typedef MDRawContextRISCV64 RawContextCP
# else
# error "Unexpected __riscv_xlen"
# endif
+#elif defined(__powerpc64__)
+typedef MDRawContextPPC64 RawContextCPU;
#else
#error "This code has not been ported to your platform yet."
#endif
Index: chromium-120.0.6099.71/third_party/breakpad/breakpad/src/client/linux/dump_writer_common/thread_info.cc
===================================================================
--- chromium-120.0.6099.71.orig/third_party/breakpad/breakpad/src/client/linux/dump_writer_common/thread_info.cc
+++ chromium-120.0.6099.71/third_party/breakpad/breakpad/src/client/linux/dump_writer_common/thread_info.cc
@@ -336,7 +336,42 @@ void ThreadInfo::FillCPUContext(RawConte
#error "Unexpected __riscv_xlen"
#endif
}
-#endif // __riscv
+
+#elif defined(__powerpc64__)
+
+uintptr_t ThreadInfo::GetInstructionPointer() const {
+ return mcontext.gp_regs[PT_NIP];
+}
+
+void ThreadInfo::FillCPUContext(RawContextCPU* out) const {
+ out->context_flags = MD_CONTEXT_PPC64_FULL;
+ for (int i = 0; i < MD_CONTEXT_PPC64_GPR_COUNT; i++)
+ out->gpr[i] = mcontext.gp_regs[i];
+
+ out->lr = mcontext.gp_regs[PT_LNK];
+ out->srr0 = mcontext.gp_regs[PT_NIP];
+ out->srr1 = mcontext.gp_regs[PT_MSR];
+ out->cr = mcontext.gp_regs[PT_CCR];
+ out->xer = mcontext.gp_regs[PT_XER];
+ out->ctr = mcontext.gp_regs[PT_CTR];
+
+ for (int i = 0; i < MD_FLOATINGSAVEAREA_PPC_FPR_COUNT; i++)
+ out->float_save.fpregs[i] = mcontext.fp_regs[i];
+
+ out->float_save.fpscr = mcontext.fp_regs[NFPREG-1];
+
+ for (int i = 0; i < MD_VECTORSAVEAREA_PPC_VR_COUNT; i++)
+ out->vector_save.save_vr[i] = \
+ {(((uint64_t)vregs.vrregs[i][0]) << 32)
+ | vregs.vrregs[i][1],
+ (((uint64_t)vregs.vrregs[i][2]) << 32)
+ | vregs.vrregs[i][3]};
+
+ out->vrsave = vregs.vrsave;
+ out->vector_save.save_vscr = {0, vregs.vscr.vscr_word};
+ out->vector_save.save_vrvalid = 0xFFFFFFFF;
+}
+#endif // __powerpc64__
void ThreadInfo::GetGeneralPurposeRegisters(void** gp_regs, size_t* size) {
assert(gp_regs || size);
@@ -350,6 +385,11 @@ void ThreadInfo::GetGeneralPurposeRegist
*gp_regs = mcontext.__gregs;
if (size)
*size = sizeof(mcontext.__gregs);
+#elif defined(__powerpc64__)
+ if (gp_regs)
+ *gp_regs = mcontext.gp_regs;
+ if (size)
+ *size = sizeof(mcontext.gp_regs);
#else
if (gp_regs)
*gp_regs = &regs;
@@ -384,6 +424,11 @@ void ThreadInfo::GetFloatingPointRegiste
# else
# error "Unexpected __riscv_flen"
# endif
+#elif defined(__powerpc64__)
+ if (fp_regs)
+ *fp_regs = &mcontext.fp_regs;
+ if (size)
+ *size = sizeof(mcontext.fp_regs);
#else
if (fp_regs)
*fp_regs = &fpregs;
@@ -392,4 +437,13 @@ void ThreadInfo::GetFloatingPointRegiste
#endif
}
+#if defined(__powerpc64__)
+void ThreadInfo::GetVectorRegisters(void** v_regs, size_t* size) {
+ if (v_regs)
+ *v_regs = &vregs;
+ if (size)
+ *size = sizeof(vregs);
+}
+#endif
+
} // namespace google_breakpad
Index: chromium-120.0.6099.71/third_party/breakpad/breakpad/src/client/linux/dump_writer_common/thread_info.h
===================================================================
--- chromium-120.0.6099.71.orig/third_party/breakpad/breakpad/src/client/linux/dump_writer_common/thread_info.h
+++ chromium-120.0.6099.71/third_party/breakpad/breakpad/src/client/linux/dump_writer_common/thread_info.h
@@ -67,6 +67,10 @@ struct ThreadInfo {
// Use the structures defined in <sys/user.h>
struct user_regs_struct regs;
struct user_fpsimd_struct fpregs;
+#elif defined(__powerpc64__)
+ // Use the structures defined in <sys/ucontext.h>.
+ mcontext_t mcontext;
+ struct _libc_vrstate vregs;
#elif defined(__mips__) || defined(__riscv)
// Use the structure defined in <sys/ucontext.h>.
mcontext_t mcontext;
@@ -83,6 +87,11 @@ struct ThreadInfo {
// Returns the pointer and size of float point register area.
void GetFloatingPointRegisters(void** fp_regs, size_t* size);
+
+#if defined(__powerpc64__)
+ // Returns the pointer and size of the vector register area. (PPC64 only)
+ void GetVectorRegisters(void** v_regs, size_t* size);
+#endif
};
} // namespace google_breakpad
Index: chromium-120.0.6099.71/third_party/breakpad/breakpad/src/client/linux/dump_writer_common/ucontext_reader.cc
===================================================================
--- chromium-120.0.6099.71.orig/third_party/breakpad/breakpad/src/client/linux/dump_writer_common/ucontext_reader.cc
+++ chromium-120.0.6099.71/third_party/breakpad/breakpad/src/client/linux/dump_writer_common/ucontext_reader.cc
@@ -324,6 +324,48 @@ void UContextReader::FillCPUContext(RawC
#error "Unexpected __riscv_xlen"
#endif
}
+
+#elif defined(__powerpc64__)
+
+uintptr_t UContextReader::GetStackPointer(const ucontext_t* uc) {
+ return uc->uc_mcontext.gp_regs[MD_CONTEXT_PPC64_REG_SP];
+}
+
+uintptr_t UContextReader::GetInstructionPointer(const ucontext_t* uc) {
+ return uc->uc_mcontext.gp_regs[PT_NIP];
+}
+
+void UContextReader::FillCPUContext(RawContextCPU* out, const ucontext_t* uc,
+ const struct _libc_vrstate* vregs) {
+ out->context_flags = MD_CONTEXT_PPC64_FULL;
+
+ for (int i = 0; i < MD_CONTEXT_PPC64_GPR_COUNT; i++)
+ out->gpr[i] = uc->uc_mcontext.gp_regs[i];
+
+ out->lr = uc->uc_mcontext.gp_regs[PT_LNK];
+ out->srr0 = uc->uc_mcontext.gp_regs[PT_NIP];
+ out->srr1 = uc->uc_mcontext.gp_regs[PT_MSR];
+ out->cr = uc->uc_mcontext.gp_regs[PT_CCR];
+ out->xer = uc->uc_mcontext.gp_regs[PT_XER];
+ out->ctr = uc->uc_mcontext.gp_regs[PT_CTR];
+
+ for (int i = 0; i < MD_FLOATINGSAVEAREA_PPC_FPR_COUNT; i++)
+ out->float_save.fpregs[i] = uc->uc_mcontext.fp_regs[i];
+
+ out->float_save.fpscr = uc->uc_mcontext.fp_regs[NFPREG-1];
+
+ for (int i = 0; i < MD_VECTORSAVEAREA_PPC_VR_COUNT; i++)
+ out->vector_save.save_vr[i] =
+ {(((uint64_t)vregs->vrregs[i][0]) << 32)
+ | vregs->vrregs[i][1],
+ (((uint64_t)vregs->vrregs[i][2]) << 32)
+ | vregs->vrregs[i][3]};
+
+ out->vrsave = vregs->vrsave;
+ out->vector_save.save_vscr = {0, vregs->vscr.vscr_word};
+ out->vector_save.save_vrvalid = 0xFFFFFFFF;
+}
+
#endif
} // namespace google_breakpad
Index: chromium-120.0.6099.71/third_party/breakpad/breakpad/src/client/linux/dump_writer_common/ucontext_reader.h
===================================================================
--- chromium-120.0.6099.71.orig/third_party/breakpad/breakpad/src/client/linux/dump_writer_common/ucontext_reader.h
+++ chromium-120.0.6099.71/third_party/breakpad/breakpad/src/client/linux/dump_writer_common/ucontext_reader.h
@@ -54,6 +54,9 @@ struct UContextReader {
#elif defined(__aarch64__)
static void FillCPUContext(RawContextCPU* out, const ucontext_t* uc,
const struct fpsimd_context* fpregs);
+#elif defined(__powerpc64__)
+ static void FillCPUContext(RawContextCPU *out, const ucontext_t *uc,
+ const struct _libc_vrstate* vregs);
#else
static void FillCPUContext(RawContextCPU* out, const ucontext_t* uc);
#endif
Index: chromium-120.0.6099.71/third_party/breakpad/breakpad/src/client/linux/handler/exception_handler.cc
===================================================================
--- chromium-120.0.6099.71.orig/third_party/breakpad/breakpad/src/client/linux/handler/exception_handler.cc
+++ chromium-120.0.6099.71/third_party/breakpad/breakpad/src/client/linux/handler/exception_handler.cc
@@ -464,6 +464,13 @@ bool ExceptionHandler::HandleSignal(int
memcpy(&g_crash_context_.float_state, fp_ptr,
sizeof(g_crash_context_.float_state));
}
+#elif defined(__powerpc64__)
+ // On PPC64, we must copy VR state
+ ucontext_t* uc_ptr = (ucontext_t*)uc;
+ if (uc_ptr->uc_mcontext.v_regs) {
+ memcpy(&g_crash_context_.vector_state, uc_ptr->uc_mcontext.v_regs,
+ sizeof(g_crash_context_.vector_state));
+ }
#elif GOOGLE_BREAKPAD_CRASH_CONTEXT_HAS_FLOAT_STATE
ucontext_t* uc_ptr = (ucontext_t*)uc;
if (uc_ptr->uc_mcontext.fpregs) {
@@ -701,10 +708,18 @@ bool ExceptionHandler::WriteMinidump() {
}
#endif
-#if GOOGLE_BREAKPAD_CRASH_CONTEXT_HAS_FLOAT_STATE && !defined(__aarch64__)
+#if GOOGLE_BREAKPAD_CRASH_CONTEXT_HAS_FLOAT_STATE && !defined(__aarch64__) \
+ && !defined(__powerpc64__)
memcpy(&context.float_state, context.context.uc_mcontext.fpregs,
sizeof(context.float_state));
#endif
+
+#if defined(__powerpc64__)
+ // Vector registers must be copied on PPC64
+ memcpy(&context.vector_state, context.context.uc_mcontext.v_regs,
+ sizeof(context.vector_state));
+#endif
+
context.tid = sys_gettid();
// Add an exception stream to the minidump for better reporting.
@@ -725,6 +740,9 @@ bool ExceptionHandler::WriteMinidump() {
#elif defined(__mips__)
context.siginfo.si_addr =
reinterpret_cast<void*>(context.context.uc_mcontext.pc);
+#elif defined(__powerpc64__)
+ context.siginfo.si_addr =
+ reinterpret_cast<void*>(context.context.uc_mcontext.gp_regs[PT_NIP]);
#elif defined(__riscv)
context.siginfo.si_addr =
reinterpret_cast<void*>(context.context.uc_mcontext.__gregs[REG_PC]);
Index: chromium-120.0.6099.71/third_party/breakpad/breakpad/src/client/linux/handler/exception_handler.h
===================================================================
--- chromium-120.0.6099.71.orig/third_party/breakpad/breakpad/src/client/linux/handler/exception_handler.h
+++ chromium-120.0.6099.71/third_party/breakpad/breakpad/src/client/linux/handler/exception_handler.h
@@ -200,7 +200,11 @@ class ExceptionHandler {
siginfo_t siginfo;
pid_t tid; // the crashing thread.
ucontext_t context;
-#if GOOGLE_BREAKPAD_CRASH_CONTEXT_HAS_FLOAT_STATE
+#if defined(__powerpc64__)
+ // PPC64's FP state is a part of ucontext_t like MIPS but the vector
+ // state is not, so a struct is needed.
+ vstate_t vector_state;
+#elif GOOGLE_BREAKPAD_CRASH_CONTEXT_HAS_FLOAT_STATE
fpstate_t float_state;
#endif
};
Index: chromium-120.0.6099.71/third_party/breakpad/breakpad/src/client/linux/handler/exception_handler_unittest.cc
===================================================================
--- chromium-120.0.6099.71.orig/third_party/breakpad/breakpad/src/client/linux/handler/exception_handler_unittest.cc
+++ chromium-120.0.6099.71/third_party/breakpad/breakpad/src/client/linux/handler/exception_handler_unittest.cc
@@ -321,7 +321,7 @@ TEST(ExceptionHandlerTest, ParallelChild
ASSERT_EQ(SIGSEGV, WTERMSIG(status));
return;
} else {
- usleep(100000);
+ usleep(200000);
}
}
@@ -576,6 +576,8 @@ const unsigned char kIllegalInstruction[
#if defined(__mips__)
// mfc2 zero,Impl - usually illegal in userspace.
0x48, 0x00, 0x00, 0x48
+#elif defined(__powerpc64__)
+ 0x01, 0x01, 0x01, 0x01 // Crashes on a tested POWER9 cpu
#else
// This crashes with SIGILL on x86/x86-64/arm.
0xff, 0xff, 0xff, 0xff
@@ -771,10 +773,10 @@ TEST(ExceptionHandlerTest, InstructionPo
// These are defined here so the parent can use them to check the
// data from the minidump afterwards.
- // Use 4k here because the OS will hand out a single page even
+ // Use the page size here because the OS will hand out a single page even
// if a smaller size is requested, and this test wants to
// test the upper bound of the memory range.
- const uint32_t kMemorySize = 4096; // bytes
+ const uint32_t kMemorySize = getpagesize(); // bytes
const int kOffset = kMemorySize - sizeof(kIllegalInstruction);
const pid_t child = fork();
Index: chromium-120.0.6099.71/third_party/breakpad/breakpad/src/client/linux/microdump_writer/microdump_writer.cc
===================================================================
--- chromium-120.0.6099.71.orig/third_party/breakpad/breakpad/src/client/linux/microdump_writer/microdump_writer.cc
+++ chromium-120.0.6099.71/third_party/breakpad/breakpad/src/client/linux/microdump_writer/microdump_writer.cc
@@ -141,7 +141,9 @@ class MicrodumpWriter {
const MicrodumpExtraInfo& microdump_extra_info,
LinuxDumper* dumper)
: ucontext_(context ? &context->context : NULL),
-#if GOOGLE_BREAKPAD_CRASH_CONTEXT_HAS_FLOAT_STATE
+#if defined(__powerpc64__)
+ vector_state_(context ? &context->vector_state : NULL),
+#elif GOOGLE_BREAKPAD_CRASH_CONTEXT_HAS_FLOAT_STATE
float_state_(context ? &context->float_state : NULL),
#endif
dumper_(dumper),
@@ -348,6 +350,8 @@ class MicrodumpWriter {
# else
# error "Unexpected __riscv_xlen"
# endif
+#elif defined(__powerpc64__)
+ const char kArch[] = "ppc64";
#else
# error "This code has not been ported to your platform yet"
#endif
@@ -420,7 +424,9 @@ class MicrodumpWriter {
void DumpCPUState() {
RawContextCPU cpu;
my_memset(&cpu, 0, sizeof(RawContextCPU));
-#if GOOGLE_BREAKPAD_CRASH_CONTEXT_HAS_FLOAT_STATE
+#if defined(__powerpc64__)
+ UContextReader::FillCPUContext(&cpu, ucontext_, vector_state_);
+#elif GOOGLE_BREAKPAD_CRASH_CONTEXT_HAS_FLOAT_STATE
UContextReader::FillCPUContext(&cpu, ucontext_, float_state_);
#else
UContextReader::FillCPUContext(&cpu, ucontext_);
@@ -616,7 +622,9 @@ class MicrodumpWriter {
void* Alloc(unsigned bytes) { return dumper_->allocator()->Alloc(bytes); }
const ucontext_t* const ucontext_;
-#if GOOGLE_BREAKPAD_CRASH_CONTEXT_HAS_FLOAT_STATE
+#if defined(__powerpc64__)
+ const google_breakpad::vstate_t* const vector_state_;
+#elif GOOGLE_BREAKPAD_CRASH_CONTEXT_HAS_FLOAT_STATE
const google_breakpad::fpstate_t* const float_state_;
#endif
LinuxDumper* dumper_;
Index: chromium-120.0.6099.71/third_party/breakpad/breakpad/src/client/linux/microdump_writer/microdump_writer_unittest.cc
===================================================================
--- chromium-120.0.6099.71.orig/third_party/breakpad/breakpad/src/client/linux/microdump_writer/microdump_writer_unittest.cc
+++ chromium-120.0.6099.71/third_party/breakpad/breakpad/src/client/linux/microdump_writer/microdump_writer_unittest.cc
@@ -282,10 +282,19 @@ TEST(MicrodumpWriterTest, BasicWithMappi
CrashAndGetMicrodump(mappings, MicrodumpExtraInfo(), &buf);
ASSERT_TRUE(ContainsMicrodump(buf));
+ int page_size = getpagesize();
#ifdef __LP64__
- ASSERT_NE(std::string::npos,
- buf.find("M 0000000000001000 000000000000002A 0000000000001000 "
- "33221100554477668899AABBCCDDEEFF0 libfoo.so"));
+ // This test is only available for the following page sizes
+ ASSERT_TRUE((page_size == 4096) || (page_size == 65536));
+ if (page_size == 4096) {
+ ASSERT_NE(std::string::npos,
+ buf.find("M 0000000000001000 000000000000002A 0000000000001000 "
+ "33221100554477668899AABBCCDDEEFF0 libfoo.so"));
+ } else {
+ ASSERT_NE(std::string::npos,
+ buf.find("M 0000000000010000 000000000000002A 0000000000010000 "
+ "33221100554477668899AABBCCDDEEFF0 libfoo.so"));
+ }
#else
ASSERT_NE(std::string::npos,
buf.find("M 00001000 0000002A 00001000 "
Index: chromium-120.0.6099.71/third_party/breakpad/breakpad/src/client/linux/minidump_writer/linux_core_dumper.cc
===================================================================
--- chromium-120.0.6099.71.orig/third_party/breakpad/breakpad/src/client/linux/minidump_writer/linux_core_dumper.cc
+++ chromium-120.0.6099.71/third_party/breakpad/breakpad/src/client/linux/minidump_writer/linux_core_dumper.cc
@@ -118,6 +118,9 @@ bool LinuxCoreDumper::GetThreadInfoByInd
#elif defined(__riscv)
stack_pointer = reinterpret_cast<uint8_t*>(
info->mcontext.__gregs[MD_CONTEXT_RISCV_REG_SP]);
+#elif defined(__powerpc64__)
+ stack_pointer =
+ reinterpret_cast<uint8_t*>(info->mcontext.gp_regs[MD_CONTEXT_PPC64_REG_SP]);
#else
# error "This code hasn't been ported to your platform yet."
#endif
@@ -213,7 +216,10 @@ bool LinuxCoreDumper::EnumerateThreads()
memset(&info, 0, sizeof(ThreadInfo));
info.tgid = status->pr_pgrp;
info.ppid = status->pr_ppid;
-#if defined(__mips__)
+#if defined(__powerpc64__)
+ for (int i = 0; i < 31; i++)
+ info.mcontext.gp_regs[i] = status->pr_reg[i];
+#elif defined(__mips__)
# if defined(__ANDROID__)
for (int i = EF_R0; i <= EF_R31; i++)
info.mcontext.gregs[i - EF_R0] = status->pr_reg[i];
Index: chromium-120.0.6099.71/third_party/breakpad/breakpad/src/client/linux/minidump_writer/linux_dumper.cc
===================================================================
--- chromium-120.0.6099.71.orig/third_party/breakpad/breakpad/src/client/linux/minidump_writer/linux_dumper.cc
+++ chromium-120.0.6099.71/third_party/breakpad/breakpad/src/client/linux/minidump_writer/linux_dumper.cc
@@ -770,7 +770,9 @@ bool LinuxDumper::GetStackInfo(const voi
reinterpret_cast<uint8_t*>(int_stack_pointer & ~(page_size - 1));
// The number of bytes of stack which we try to capture.
- static const ptrdiff_t kStackToCapture = 32 * 1024;
+ // This now depends on page_size to avoid missing data
+ // on systems with larger page sizes.
+ static const ptrdiff_t kStackToCapture = 8 * page_size;
const MappingInfo* mapping = FindMapping(stack_pointer);
if (!mapping)
Index: chromium-120.0.6099.71/third_party/breakpad/breakpad/src/client/linux/minidump_writer/linux_dumper.h
===================================================================
--- chromium-120.0.6099.71.orig/third_party/breakpad/breakpad/src/client/linux/minidump_writer/linux_dumper.h
+++ chromium-120.0.6099.71/third_party/breakpad/breakpad/src/client/linux/minidump_writer/linux_dumper.h
@@ -64,7 +64,8 @@ namespace google_breakpad {
typedef Elf32_auxv_t elf_aux_entry;
#elif defined(__x86_64) || defined(__aarch64__) || \
(defined(__mips__) && _MIPS_SIM != _ABIO32) || \
- (defined(__riscv) && __riscv_xlen == 64)
+ (defined(__riscv) && __riscv_xlen == 64) || \
+ defined(__powerpc64__)
typedef Elf64_auxv_t elf_aux_entry;
#endif
Index: chromium-120.0.6099.71/third_party/breakpad/breakpad/src/client/linux/minidump_writer/linux_dumper_unittest_helper.cc
===================================================================
--- chromium-120.0.6099.71.orig/third_party/breakpad/breakpad/src/client/linux/minidump_writer/linux_dumper_unittest_helper.cc
+++ chromium-120.0.6099.71/third_party/breakpad/breakpad/src/client/linux/minidump_writer/linux_dumper_unittest_helper.cc
@@ -56,6 +56,8 @@
#define TID_PTR_REGISTER "$1"
#elif defined(__riscv)
#define TID_PTR_REGISTER "x4"
+#elif defined(__powerpc64__)
+#define TID_PTR_REGISTER "r8"
#else
#error This test has not been ported to this platform.
#endif
Index: chromium-120.0.6099.71/third_party/breakpad/breakpad/src/client/linux/minidump_writer/linux_ptrace_dumper.cc
===================================================================
--- chromium-120.0.6099.71.orig/third_party/breakpad/breakpad/src/client/linux/minidump_writer/linux_ptrace_dumper.cc
+++ chromium-120.0.6099.71/third_party/breakpad/breakpad/src/client/linux/minidump_writer/linux_ptrace_dumper.cc
@@ -152,19 +152,27 @@ bool LinuxPtraceDumper::CopyFromProcess(
return true;
}
-bool LinuxPtraceDumper::ReadRegisterSet(ThreadInfo* info, pid_t tid)
-{
+bool LinuxPtraceDumper::ReadRegisterSet(ThreadInfo* info, pid_t tid) {
#ifdef PTRACE_GETREGSET
struct iovec io;
info->GetGeneralPurposeRegisters(&io.iov_base, &io.iov_len);
- if (sys_ptrace(PTRACE_GETREGSET, tid, (void*)NT_PRSTATUS, (void*)&io) == -1) {
+ if (ptrace(PTRACE_GETREGSET, tid, (void*)NT_PRSTATUS, (void*)&io) == -1) {
return false;
}
info->GetFloatingPointRegisters(&io.iov_base, &io.iov_len);
- if (sys_ptrace(PTRACE_GETREGSET, tid, (void*)NT_FPREGSET, (void*)&io) == -1) {
+ if (ptrace(PTRACE_GETREGSET, tid, (void*)NT_FPREGSET, (void*)&io) == -1) {
return false;
}
+
+#if defined(__powerpc64__)
+ // Grab the vector registers on PPC64 too
+ info->GetVectorRegisters(&io.iov_base, &io.iov_len);
+ if (ptrace(PTRACE_GETREGSET, tid, (void*)NT_PPC_VMX, (void*)&io) == -1) {
+ return false;
+ }
+#endif // defined(__powerpc64__)
+
return true;
#else
return false;
@@ -312,6 +320,9 @@ bool LinuxPtraceDumper::GetThreadInfoByI
#elif defined(__riscv)
stack_pointer = reinterpret_cast<uint8_t*>(
info->mcontext.__gregs[MD_CONTEXT_RISCV_REG_SP]);
+#elif defined(__powerpc64__)
+ stack_pointer =
+ reinterpret_cast<uint8_t*>(info->mcontext.gp_regs[MD_CONTEXT_PPC64_REG_SP]);
#else
# error "This code hasn't been ported to your platform yet."
#endif
Index: chromium-120.0.6099.71/third_party/breakpad/breakpad/src/client/linux/minidump_writer/linux_ptrace_dumper_unittest.cc
===================================================================
--- chromium-120.0.6099.71.orig/third_party/breakpad/breakpad/src/client/linux/minidump_writer/linux_ptrace_dumper_unittest.cc
+++ chromium-120.0.6099.71/third_party/breakpad/breakpad/src/client/linux/minidump_writer/linux_ptrace_dumper_unittest.cc
@@ -470,6 +470,9 @@ TEST(LinuxPtraceDumperTest, VerifyStackR
#elif defined(__riscv)
pid_t* process_tid_location =
reinterpret_cast<pid_t*>(one_thread.mcontext.__gregs[4]);
+#elif defined(__powerpc64__)
+ pid_t* process_tid_location =
+ reinterpret_cast<pid_t*>(one_thread.mcontext.gp_regs[8]);
#else
#error This test has not been ported to this platform.
#endif
@@ -569,6 +572,8 @@ TEST_F(LinuxPtraceDumperTest, SanitizeSt
uintptr_t heap_addr = thread_info.mcontext.gregs[1];
#elif defined(__riscv)
uintptr_t heap_addr = thread_info.mcontext.__gregs[4];
+#elif defined(__powerpc64__)
+ uintptr_t heap_addr = thread_info.mcontext.gp_regs[8];
#else
#error This test has not been ported to this platform.
#endif
Index: chromium-120.0.6099.71/third_party/breakpad/breakpad/src/client/linux/minidump_writer/minidump_writer.cc
===================================================================
--- chromium-120.0.6099.71.orig/third_party/breakpad/breakpad/src/client/linux/minidump_writer/minidump_writer.cc
+++ chromium-120.0.6099.71/third_party/breakpad/breakpad/src/client/linux/minidump_writer/minidump_writer.cc
@@ -144,7 +144,9 @@ class MinidumpWriter {
: fd_(minidump_fd),
path_(minidump_path),
ucontext_(context ? &context->context : NULL),
-#if GOOGLE_BREAKPAD_CRASH_CONTEXT_HAS_FLOAT_STATE
+#if defined(__powerpc64__)
+ vector_state_(context ? &context->vector_state : NULL),
+#elif GOOGLE_BREAKPAD_CRASH_CONTEXT_HAS_FLOAT_STATE
float_state_(context ? &context->float_state : NULL),
#endif
dumper_(dumper),
@@ -476,7 +478,9 @@ class MinidumpWriter {
if (!cpu.Allocate())
return false;
my_memset(cpu.get(), 0, sizeof(RawContextCPU));
-#if GOOGLE_BREAKPAD_CRASH_CONTEXT_HAS_FLOAT_STATE
+#if defined(__powerpc64__)
+ UContextReader::FillCPUContext(cpu.get(), ucontext_, vector_state_);
+#elif GOOGLE_BREAKPAD_CRASH_CONTEXT_HAS_FLOAT_STATE
UContextReader::FillCPUContext(cpu.get(), ucontext_, float_state_);
#else
UContextReader::FillCPUContext(cpu.get(), ucontext_);
@@ -953,7 +957,7 @@ class MinidumpWriter {
dirent->location.rva = 0;
}
-#if defined(__i386__) || defined(__x86_64__) || defined(__mips__)
+#if defined(__i386__) || defined(__x86_64__) || defined(__mips__) || defined(__powerpc64__)
bool WriteCPUInformation(MDRawSystemInfo* sys_info) {
char vendor_id[sizeof(sys_info->cpu.x86_cpu_info.vendor_id) + 1] = {0};
static const char vendor_id_name[] = "vendor_id";
@@ -973,7 +977,9 @@ class MinidumpWriter {
// processor_architecture should always be set, do this first
sys_info->processor_architecture =
-#if defined(__mips__)
+#if defined(__powerpc64__)
+ MD_CPU_ARCHITECTURE_PPC64;
+#elif defined(__mips__)
# if _MIPS_SIM == _ABIO32
MD_CPU_ARCHITECTURE_MIPS;
# elif _MIPS_SIM == _ABI64
@@ -1440,7 +1446,9 @@ class MinidumpWriter {
const char* path_; // Path to the file where the minidum should be written.
const ucontext_t* const ucontext_; // also from the signal handler
-#if GOOGLE_BREAKPAD_CRASH_CONTEXT_HAS_FLOAT_STATE
+#if defined(__powerpc64__)
+ const google_breakpad::vstate_t* const vector_state_;
+#elif GOOGLE_BREAKPAD_CRASH_CONTEXT_HAS_FLOAT_STATE
const google_breakpad::fpstate_t* const float_state_; // ditto
#endif
LinuxDumper* dumper_;
Index: chromium-120.0.6099.71/third_party/breakpad/breakpad/src/client/linux/minidump_writer/minidump_writer.h
===================================================================
--- chromium-120.0.6099.71.orig/third_party/breakpad/breakpad/src/client/linux/minidump_writer/minidump_writer.h
+++ chromium-120.0.6099.71/third_party/breakpad/breakpad/src/client/linux/minidump_writer/minidump_writer.h
@@ -47,6 +47,8 @@ class ExceptionHandler;
#if defined(__aarch64__)
typedef struct fpsimd_context fpstate_t;
+#elif defined(__powerpc64__)
+typedef struct _libc_vrstate vstate_t;
#elif !defined(__ARM_EABI__) && !defined(__mips__)
typedef std::remove_pointer<fpregset_t>::type fpstate_t;
#endif
Index: chromium-120.0.6099.71/third_party/breakpad/breakpad/src/client/linux/minidump_writer/minidump_writer_unittest.cc
===================================================================
--- chromium-120.0.6099.71.orig/third_party/breakpad/breakpad/src/client/linux/minidump_writer/minidump_writer_unittest.cc
+++ chromium-120.0.6099.71/third_party/breakpad/breakpad/src/client/linux/minidump_writer/minidump_writer_unittest.cc
@@ -723,6 +723,9 @@ TEST(MinidumpWriterTest, InvalidStackPoi
#elif defined(__riscv)
context.context.uc_mcontext.__gregs[MD_CONTEXT_RISCV_REG_SP] =
invalid_stack_pointer;
+#elif defined(__powerpc64__)
+ context.context.uc_mcontext.gp_regs[MD_CONTEXT_PPC64_REG_SP] =
+ invalid_stack_pointer;
#else
# error "This code has not been ported to your platform yet."
#endif
Index: chromium-120.0.6099.71/third_party/breakpad/breakpad/src/common/linux/memory_mapped_file.cc
===================================================================
--- chromium-120.0.6099.71.orig/third_party/breakpad/breakpad/src/common/linux/memory_mapped_file.cc
+++ chromium-120.0.6099.71/third_party/breakpad/breakpad/src/common/linux/memory_mapped_file.cc
@@ -72,8 +72,7 @@ bool MemoryMappedFile::Map(const char* p
#if defined(__x86_64__) || defined(__aarch64__) || \
(defined(__mips__) && _MIPS_SIM == _ABI64) || \
- (defined(__riscv) && __riscv_xlen == 64)
-
+ (defined(__riscv) && __riscv_xlen == 64) || defined(__powerpc64__)
struct kernel_stat st;
if (sys_fstat(fd, &st) == -1 || st.st_size < 0) {
#else
Index: chromium-120.0.6099.71/third_party/breakpad/breakpad/src/common/linux/memory_mapped_file_unittest.cc
===================================================================
--- chromium-120.0.6099.71.orig/third_party/breakpad/breakpad/src/common/linux/memory_mapped_file_unittest.cc
+++ chromium-120.0.6099.71/third_party/breakpad/breakpad/src/common/linux/memory_mapped_file_unittest.cc
@@ -179,9 +179,10 @@ TEST_F(MemoryMappedFileTest, RemapAfterM
TEST_F(MemoryMappedFileTest, MapWithOffset) {
// Put more data in the test file this time. Offsets can only be
// done on page boundaries, so we need a two page file to test this.
- const int page_size = 4096;
- char data1[2 * page_size];
- size_t data1_size = sizeof(data1);
+ const int page_size = getpagesize();
+ char *data1 = static_cast<char*>(malloc(2 * page_size));
+ EXPECT_TRUE(data1 != NULL);
+ size_t data1_size = (2 * page_size);
for (size_t i = 0; i < data1_size; ++i) {
data1[i] = i & 0x7f;
}
Index: chromium-120.0.6099.71/third_party/breakpad/breakpad/src/common/memory_allocator_unittest.cc
===================================================================
--- chromium-120.0.6099.71.orig/third_party/breakpad/breakpad/src/common/memory_allocator_unittest.cc
+++ chromium-120.0.6099.71/third_party/breakpad/breakpad/src/common/memory_allocator_unittest.cc
@@ -60,8 +60,9 @@ TEST(PageAllocatorTest, LargeObject) {
EXPECT_EQ(0U, allocator.pages_allocated());
uint8_t* p = reinterpret_cast<uint8_t*>(allocator.Alloc(10000));
+ uint64_t expected_pages = 1 + ((10000 - 1) / getpagesize());
ASSERT_FALSE(p == NULL);
- EXPECT_EQ(3U, allocator.pages_allocated());
+ EXPECT_EQ(expected_pages, allocator.pages_allocated());
for (unsigned i = 1; i < 10; ++i) {
uint8_t* p = reinterpret_cast<uint8_t*>(allocator.Alloc(i));
ASSERT_FALSE(p == NULL);
Index: chromium-120.0.6099.71/third_party/breakpad/breakpad/src/tools/linux/md2core/minidump-2-core.cc
===================================================================
--- chromium-120.0.6099.71.orig/third_party/breakpad/breakpad/src/tools/linux/md2core/minidump-2-core.cc
+++ chromium-120.0.6099.71/third_party/breakpad/breakpad/src/tools/linux/md2core/minidump-2-core.cc
@@ -82,6 +82,8 @@
#define ELF_ARCH EM_AARCH64
#elif defined(__riscv)
#define ELF_ARCH EM_RISCV
+#elif defined(__powerpc64__)
+ #define ELF_ARCH EM_PPC64
#endif
#if defined(__arm__)
@@ -92,6 +94,8 @@ typedef user_regs user_regs_struct;
#elif defined (__mips__) || defined(__riscv)
// This file-local typedef simplifies the source code.
typedef gregset_t user_regs_struct;
+#elif defined(__powerpc64__)
+typedef struct pt_regs user_regs_struct;
#endif
using google_breakpad::MDTypeHelper;
@@ -324,6 +328,9 @@ struct CrashedProcess {
#if defined(__aarch64__)
user_fpsimd_struct fpregs;
#endif
+#if defined(__powerpc64__)
+ mcontext_t mcontext;
+#endif
uintptr_t stack_addr;
const uint8_t* stack;
size_t stack_length;
@@ -599,6 +606,38 @@ ParseThreadRegisters(CrashedProcess::Thr
#error "Unexpected __riscv_xlen"
#endif
}
+#elif defined(__powerpc64__)
+static void
+ParseThreadRegisters(CrashedProcess::Thread* thread,
+ const MinidumpMemoryRange& range) {
+ const MDRawContextPPC64* rawregs = range.GetData<MDRawContextPPC64>(0);
+
+ for (int i = 0; i < MD_CONTEXT_PPC64_GPR_COUNT; i++)
+ thread->mcontext.gp_regs[i] = rawregs->gpr[i];
+
+ thread->mcontext.gp_regs[PT_LNK] = rawregs->lr;
+ thread->mcontext.gp_regs[PT_NIP] = rawregs->srr0;
+ thread->mcontext.gp_regs[PT_MSR] = rawregs->srr1;
+ thread->mcontext.gp_regs[PT_CCR] = rawregs->cr;
+ thread->mcontext.gp_regs[PT_XER] = rawregs->xer;
+ thread->mcontext.gp_regs[PT_CTR] = rawregs->ctr;
+ thread->mcontext.v_regs->vrsave = rawregs->vrsave;
+
+ for (int i = 0; i < MD_FLOATINGSAVEAREA_PPC_FPR_COUNT; i++)
+ thread->mcontext.fp_regs[i] = rawregs->float_save.fpregs[i];
+
+ thread->mcontext.fp_regs[NFPREG-1] = rawregs->float_save.fpscr;
+
+ for (int i = 0; i < MD_VECTORSAVEAREA_PPC_VR_COUNT; i++) {
+ thread->mcontext.v_regs->vrregs[i][0] = rawregs->vector_save.save_vr[i].high >> 32;
+ thread->mcontext.v_regs->vrregs[i][1] = rawregs->vector_save.save_vr[i].high;
+ thread->mcontext.v_regs->vrregs[i][2] = rawregs->vector_save.save_vr[i].low >> 32;
+ thread->mcontext.v_regs->vrregs[i][3] = rawregs->vector_save.save_vr[i].low;
+ }
+
+ thread->mcontext.v_regs->vscr.vscr_word = rawregs->vector_save.save_vscr.low & 0xFFFFFFFF;
+}
+
#else
#error "This code has not been ported to your platform yet"
#endif
@@ -704,6 +743,12 @@ ParseSystemInfo(const Options& options,
# else
# error "Unexpected __riscv_xlen"
# endif
+#elif defined(__powerpc64__)
+ if (sysinfo->processor_architecture != MD_CPU_ARCHITECTURE_PPC64) {
+ fprintf(stderr,
+ "This version of minidump-2-core only supports PPC64.\n");
+ exit(1);
+ }
#else
#error "This code has not been ported to your platform yet"
#endif

@ -0,0 +1,37 @@
From b3a14db7637232d30c878cc1f1ad6d8037e81379 Mon Sep 17 00:00:00 2001
From: Shawn Anastasio <shawn@anastas.io>
Date: Tue, 15 Jan 2019 22:42:21 -0600
Subject: [PATCH] linux/seccomp-bpf: ppc64+glibc workaround in SIGSYS handler
Workaround for an apparent issue with glibc negating syscall
parameters. Observed on a ppc64le machine with glibc.
More investigation required.
---
sandbox/linux/seccomp-bpf/trap.cc | 14 ++++++++++++++
1 file changed, 14 insertions(+)
Index: chromium-120.0.6099.71/sandbox/linux/seccomp-bpf/trap.cc
===================================================================
--- chromium-120.0.6099.71.orig/sandbox/linux/seccomp-bpf/trap.cc
+++ chromium-120.0.6099.71/sandbox/linux/seccomp-bpf/trap.cc
@@ -232,6 +232,20 @@ void Trap::SigSys(int nr, LinuxSigInfo*
SetIsInSigHandler();
}
+#if defined(__powerpc64__)
+ // On ppc64+glibc, some syscalls seem to accidentally negate the first
+ // parameter which causes checks against it to fail. For now, manually
+ // negate them back.
+ // TODO(shawn@anastas.io): investigate this issue further
+ auto nr = SECCOMP_SYSCALL(ctx);
+ if (nr == __NR_openat || nr == __NR_mkdirat || nr == __NR_faccessat || nr == __NR_readlinkat ||
+ nr == __NR_renameat || nr == __NR_renameat2 || nr == __NR_newfstatat || nr == __NR_unlinkat) {
+ if (static_cast<int>(SECCOMP_PARM1(ctx)) > 0) {
+ SECCOMP_PARM1(ctx) = -SECCOMP_PARM1(ctx);
+ }
+ }
+#endif
+
// Copy the seccomp-specific data into a arch_seccomp_data structure. This
// is what we are showing to TrapFnc callbacks that the system call
// evaluator registered with the sandbox.

@ -0,0 +1,23 @@
From 0c65e40ae578b743b5f06956597ebc9700768d18 Mon Sep 17 00:00:00 2001
From: Shawn Anastasio <shawnanastasio@yahoo.com>
Date: Thu, 9 Aug 2018 22:45:47 -0500
Subject: [PATCH 1/1] sandbox: Enable seccomp_bpf for ppc64
---
sandbox/features.gni | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Index: chromium-120.0.6099.71/sandbox/features.gni
===================================================================
--- chromium-120.0.6099.71.orig/sandbox/features.gni
+++ chromium-120.0.6099.71/sandbox/features.gni
@@ -9,7 +9,8 @@
use_seccomp_bpf = (is_linux || is_chromeos || is_android) &&
(current_cpu == "x86" || current_cpu == "x64" ||
current_cpu == "arm" || current_cpu == "arm64" ||
- current_cpu == "mipsel" || current_cpu == "mips64el")
+ current_cpu == "mipsel" || current_cpu == "mips64el" ||
+ current_cpu == "ppc64")
# SSBD (Speculative Store Bypass Disable) is a mitigation of Spectre Variant 4.
# As Spectre Variant 4 can be mitigated by site isolation, opt-out SSBD on site

@ -0,0 +1,80 @@
From 036d209a3f1a771de9aed31dfbe804aaf91d1c27 Mon Sep 17 00:00:00 2001
From: Shawn Anastasio <shawnanastasio@yahoo.com>
Date: Thu, 9 Aug 2018 23:35:21 -0500
Subject: [PATCH] sandbox/linux: Implement partial support for ppc64 syscalls
and ucontext
Unlike other architectures, the ppc64 files currently rely on applicable
headers being provided by the system. It is sufficient for standard
GNU/Linux environments, but may require expansion elsewhere.
---
sandbox/linux/BUILD.gn | 2 ++
sandbox/linux/system_headers/linux_syscalls.h | 4 ++++
sandbox/linux/system_headers/linux_ucontext.h | 2 ++
sandbox/linux/system_headers/ppc64_linux_syscalls.h | 12 ++++++++++++
sandbox/linux/system_headers/ppc64_linux_ucontext.h | 12 ++++++++++++
5 files changed, 32 insertions(+)
create mode 100644 sandbox/linux/system_headers/ppc64_linux_syscalls.h
create mode 100644 sandbox/linux/system_headers/ppc64_linux_ucontext.h
Index: chromium-120.0.6099.71/sandbox/linux/BUILD.gn
===================================================================
--- chromium-120.0.6099.71.orig/sandbox/linux/BUILD.gn
+++ chromium-120.0.6099.71/sandbox/linux/BUILD.gn
@@ -383,6 +383,8 @@ component("sandbox_services") {
source_set("sandbox_services_headers") {
sources = [
+ "system_headers/ppc64_linux_syscalls.h",
+ "system_headers/ppc64_linux_ucontext.h",
"system_headers/arm64_linux_syscalls.h",
"system_headers/arm_linux_syscalls.h",
"system_headers/arm_linux_ucontext.h",
Index: chromium-120.0.6099.71/sandbox/linux/system_headers/linux_syscalls.h
===================================================================
--- chromium-120.0.6099.71.orig/sandbox/linux/system_headers/linux_syscalls.h
+++ chromium-120.0.6099.71/sandbox/linux/system_headers/linux_syscalls.h
@@ -35,5 +35,9 @@
#include "sandbox/linux/system_headers/arm64_linux_syscalls.h"
#endif
+#if defined(__powerpc64__)
+#include "sandbox/linux/system_headers/ppc64_linux_syscalls.h"
+#endif
+
#endif // SANDBOX_LINUX_SYSTEM_HEADERS_LINUX_SYSCALLS_H_
Index: chromium-120.0.6099.71/sandbox/linux/system_headers/ppc64_linux_syscalls.h
===================================================================
--- /dev/null
+++ chromium-120.0.6099.71/sandbox/linux/system_headers/ppc64_linux_syscalls.h
@@ -0,0 +1,12 @@
+// Copyright 2014 The Chromium 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 SANDBOX_LINUX_SYSTEM_HEADERS_PPC64_LINUX_SYSCALLS_H_
+#define SANDBOX_LINUX_SYSTEM_HEADERS_PPC64_LINUX_SYSCALLS_H_
+
+#include <asm/unistd.h>
+
+//TODO: is it necessary to redefine syscall numbers for PPC64?
+
+#endif // SANDBOX_LINUX_SYSTEM_HEADERS_PPC64_LINUX_SYSCALLS_H_
Index: chromium-120.0.6099.71/sandbox/linux/system_headers/ppc64_linux_ucontext.h
===================================================================
--- /dev/null
+++ chromium-120.0.6099.71/sandbox/linux/system_headers/ppc64_linux_ucontext.h
@@ -0,0 +1,12 @@
+// Copyright 2014 The Chromium 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 SANDBOX_LINUX_SYSTEM_HEADERS_PPC64_LINUX_UCONTEXT_H_
+#define SANDBOX_LINUX_SYSTEM_HEADERS_PPC64_LINUX_UCONTEXT_H_
+
+#include <sys/ucontext.h>
+
+//TODO: is it necessary to redefine ucontext on PPC64?
+
+#endif // SANDBOX_LINUX_SYSTEM_HEADERS_PPC64_LINUX_UCONTEXT_H_

@ -0,0 +1,22 @@
From c41cd6ac927f592b161abc04468d3c7a4be91995 Mon Sep 17 00:00:00 2001
From: Shawn Anastasio <shawnanastasio@yahoo.com>
Date: Tue, 23 Oct 2018 15:49:31 -0500
Subject: [PATCH] sandbox/linux: Update IsSyscallAllowed in broker_process.cc
---
sandbox/linux/syscall_broker/broker_process.cc | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Index: chromium-120.0.6099.71/sandbox/linux/syscall_broker/broker_process.cc
===================================================================
--- chromium-120.0.6099.71.orig/sandbox/linux/syscall_broker/broker_process.cc
+++ chromium-120.0.6099.71/sandbox/linux/syscall_broker/broker_process.cc
@@ -169,7 +169,7 @@ bool BrokerProcess::IsSyscallBrokerable(
#if defined(__NR_fstatat64)
case __NR_fstatat64:
#endif
-#if defined(__x86_64__) || defined(__aarch64__)
+#if defined(__x86_64__) || defined(__aarch64__) || defined(__powerpc64__)
case __NR_newfstatat:
#endif
return !fast_check || policy_->allowed_command_set.test(COMMAND_STAT);

@ -0,0 +1,638 @@
From da52663deec77f705d7d58b18484c3e28e563f10 Mon Sep 17 00:00:00 2001
From: Shawn Anastasio <shawnanastasio@yahoo.com>
Date: Tue, 18 Sep 2018 18:39:28 -0500
Subject: [PATCH] sandbox/linux: Update syscall helpers/lists for ppc64
---
.../seccomp-bpf-helpers/baseline_policy.cc | 8 +-
.../syscall_parameters_restrictions.cc | 2 +-
.../syscall_parameters_restrictions.h | 2 +-
.../linux/seccomp-bpf-helpers/syscall_sets.cc | 108 ++++++++++--------
.../linux/seccomp-bpf-helpers/syscall_sets.h | 6 +-
sandbox/linux/services/syscall_wrappers.cc | 2 +-
6 files changed, 73 insertions(+), 55 deletions(-)
Index: chromium-120.0.6099.71/sandbox/linux/seccomp-bpf-helpers/baseline_policy.cc
===================================================================
--- chromium-120.0.6099.71.orig/sandbox/linux/seccomp-bpf-helpers/baseline_policy.cc
+++ chromium-120.0.6099.71/sandbox/linux/seccomp-bpf-helpers/baseline_policy.cc
@@ -90,7 +90,8 @@ bool IsBaselinePolicyWatched(int sysno)
SyscallSets::IsPrctl(sysno) ||
SyscallSets::IsProcessGroupOrSession(sysno) ||
#if defined(__i386__) || \
- (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_32_BITS))
+ (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_32_BITS)) || \
+ defined(__powerpc64__)
SyscallSets::IsSocketCall(sysno) ||
#endif
#if defined(__arm__)
@@ -255,7 +256,7 @@ ResultExpr EvaluateSyscallImpl(int fs_de
}
#if defined(__i386__) || defined(__x86_64__) || defined(__mips__) || \
- defined(__aarch64__)
+ defined(__aarch64__) || defined(__powerpc64__)
if (sysno == __NR_mmap)
return RestrictMmapFlags();
#endif
@@ -276,7 +277,7 @@ ResultExpr EvaluateSyscallImpl(int fs_de
return RestrictPrctl();
#if defined(__x86_64__) || defined(__arm__) || defined(__mips__) || \
- defined(__aarch64__)
+ defined(__aarch64__) || defined(__powerpc64__)
if (sysno == __NR_socketpair) {
// Only allow AF_UNIX, PF_UNIX. Crash if anything else is seen.
static_assert(AF_UNIX == PF_UNIX,
@@ -340,7 +341,8 @@ ResultExpr EvaluateSyscallImpl(int fs_de
}
#if defined(__i386__) || \
- (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_32_BITS))
+ (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_32_BITS)) || \
+ defined(__powerpc64__)
if (SyscallSets::IsSocketCall(sysno))
return RestrictSocketcallCommand();
#endif
Index: chromium-120.0.6099.71/sandbox/linux/seccomp-bpf-helpers/syscall_parameters_restrictions.cc
===================================================================
--- chromium-120.0.6099.71.orig/sandbox/linux/seccomp-bpf-helpers/syscall_parameters_restrictions.cc
+++ chromium-120.0.6099.71/sandbox/linux/seccomp-bpf-helpers/syscall_parameters_restrictions.cc
@@ -36,7 +36,7 @@
#include "sandbox/linux/system_headers/linux_time.h"
#if (BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS)) && \
- !defined(__arm__) && !defined(__aarch64__) && \
+ !defined(__arm__) && !defined(__aarch64__) && !defined(__powerpc64__) && \
!defined(PTRACE_GET_THREAD_AREA)
// Also include asm/ptrace-abi.h since ptrace.h in older libc (for instance
// the one in Ubuntu 16.04 LTS) is missing PTRACE_GET_THREAD_AREA.
@@ -45,6 +45,11 @@
#include <asm/ptrace-abi.h>
#endif
+// On PPC64, TCGETS is defined in terms of struct termios, so we must include termios.h
+#ifdef __powerpc64__
+#include <termios.h>
+#endif
+
#if BUILDFLAG(IS_ANDROID)
#if !defined(F_DUPFD_CLOEXEC)
@@ -102,6 +107,15 @@ inline bool IsArchitectureMips() {
#endif
}
+inline bool IsArchitecturePPC64() {
+#if defined(__powerpc64__)
+ return true;
+#else
+ return false;
+#endif
+}
+
+
// Ubuntu's version of glibc has a race condition in sem_post that can cause
// it to call futex(2) with bogus op arguments. To workaround this, we need
// to allow those futex(2) calls to fail with EINVAL, instead of crashing the
@@ -269,9 +283,11 @@ ResultExpr RestrictFcntlCommands() {
// operator.
// Glibc overrides the kernel's O_LARGEFILE value. Account for this.
uint64_t kOLargeFileFlag = O_LARGEFILE;
- if (IsArchitectureX86_64() || IsArchitectureI386() || IsArchitectureMips())
+ if (IsArchitectureX86_64() || IsArchitectureI386() || IsArchitectureMips() \
+ || IsArchitecturePPC64())
kOLargeFileFlag = 0100000;
+
const Arg<int> cmd(1);
const Arg<long> long_arg(2);
@@ -294,8 +310,17 @@ ResultExpr RestrictFcntlCommands() {
F_SETLKW,
F_GETLK,
F_DUPFD,
- F_DUPFD_CLOEXEC},
- Allow())
+ F_DUPFD_CLOEXEC
+#if defined(__powerpc64__)
+// On PPC64, F_SETLK, F_GETLK, F_SETLKW are defined as the 64-bit variants
+// but glibc will sometimes still use the 32-bit versions. Allow both.
+ ,
+ 5, /* F_GETLK (32) */
+ 6, /* F_SETLK (32) */
+ 7 /* F_SETLKW (32) */
+#endif
+ },
+ Allow())
.Case(F_SETFL,
If((long_arg & ~kAllowedMask) == 0, Allow()).Else(CrashSIGSYS()))
.Case(F_ADD_SEALS,
@@ -304,7 +329,7 @@ ResultExpr RestrictFcntlCommands() {
// clang-format on
}
-#if defined(__i386__) || defined(__mips__)
+#if defined(__i386__) || defined(__mips__) || defined(__powerpc64__)
ResultExpr RestrictSocketcallCommand() {
// Unfortunately, we are unable to restrict the first parameter to
// socketpair(2). Whilst initially sounding bad, it's noteworthy that very
@@ -459,7 +484,7 @@ ResultExpr RestrictPtrace() {
#endif
return Switch(request)
.Cases({
-#if !defined(__aarch64__)
+#if !defined(__aarch64__) && !defined(__powerpc64__)
PTRACE_GETREGS, PTRACE_GETFPREGS, PTRACE_GET_THREAD_AREA,
PTRACE_GETREGSET,
#endif
Index: chromium-120.0.6099.71/sandbox/linux/seccomp-bpf-helpers/syscall_parameters_restrictions.h
===================================================================
--- chromium-120.0.6099.71.orig/sandbox/linux/seccomp-bpf-helpers/syscall_parameters_restrictions.h
+++ chromium-120.0.6099.71/sandbox/linux/seccomp-bpf-helpers/syscall_parameters_restrictions.h
@@ -52,7 +52,7 @@ SANDBOX_EXPORT bpf_dsl::ResultExpr Restr
// O_NONBLOCK | O_SYNC | O_LARGEFILE | O_CLOEXEC | O_NOATIME.
SANDBOX_EXPORT bpf_dsl::ResultExpr RestrictFcntlCommands();
-#if defined(__i386__) || defined(__mips__)
+#if defined(__i386__) || defined(__mips__) || defined(__powerpc64__)
// Restrict socketcall(2) to only allow socketpair(2), send(2), recv(2),
// sendto(2), recvfrom(2), shutdown(2), sendmsg(2) and recvmsg(2).
SANDBOX_EXPORT bpf_dsl::ResultExpr RestrictSocketcallCommand();
Index: chromium-120.0.6099.71/sandbox/linux/seccomp-bpf-helpers/syscall_sets.cc
===================================================================
--- chromium-120.0.6099.71.orig/sandbox/linux/seccomp-bpf-helpers/syscall_sets.cc
+++ chromium-120.0.6099.71/sandbox/linux/seccomp-bpf-helpers/syscall_sets.cc
@@ -29,7 +29,8 @@ bool SyscallSets::IsAllowedGettime(int s
switch (sysno) {
case __NR_gettimeofday:
#if defined(__i386__) || defined(__x86_64__) || \
- (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_32_BITS))
+ (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_32_BITS)) || \
+ defined(__powerpc64__)
case __NR_time:
#endif
return true;
@@ -52,12 +53,14 @@ bool SyscallSets::IsAllowedGettime(int s
case __NR_clock_nanosleep_time64: // Parameters filtered by RestrictClockID().
#endif
#if defined(__i386__) || \
- (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_32_BITS))
+ (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_32_BITS)) || \
+ defined(__powerpc64__)
case __NR_ftime: // Obsolete.
#endif
case __NR_settimeofday: // Privileged.
#if defined(__i386__) || \
- (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_32_BITS))
+ (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_32_BITS)) || \
+ defined(__powerpc64__)
case __NR_stime:
#endif
default:
@@ -136,7 +139,7 @@ bool SyscallSets::IsFileSystem(int sysno
case __NR_faccessat2:
case __NR_fchmodat:
case __NR_fchownat: // Should be called chownat ?
-#if defined(__x86_64__) || defined(__aarch64__)
+#if defined(__x86_64__) || defined(__aarch64__) || defined(__powerpc64__)
case __NR_newfstatat: // fstatat(). EPERM not a valid errno.
#elif defined(__i386__) || defined(__arm__) || \
(defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_32_BITS))
@@ -155,7 +158,7 @@ bool SyscallSets::IsFileSystem(int sysno
case __NR_memfd_create:
case __NR_mkdirat:
case __NR_mknodat:
-#if defined(__i386__)
+#if defined(__i386__) || defined(__powerpc64__)
case __NR_oldlstat:
case __NR_oldstat:
#endif
@@ -169,7 +172,8 @@ bool SyscallSets::IsFileSystem(int sysno
#endif
case __NR_statfs: // EPERM not a valid errno.
#if defined(__i386__) || defined(__arm__) || \
- (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_32_BITS))
+ (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_32_BITS)) || \
+ defined(__powerpc64__)
case __NR_statfs64:
#endif
case __NR_statx: // EPERM not a valid errno.
@@ -180,7 +184,8 @@ bool SyscallSets::IsFileSystem(int sysno
case __NR_truncate64:
#endif
case __NR_unlinkat:
-#if defined(__i386__) || defined(__x86_64__) || defined(__mips__)
+#if defined(__i386__) || defined(__x86_64__) || defined(__mips__) || \
+ defined(__powerpc64__)
case __NR_utime:
#endif
case __NR_utimensat: // New.
@@ -220,7 +225,8 @@ bool SyscallSets::IsAllowedFileSystemAcc
#endif
return true;
// TODO(jln): these should be denied gracefully as well (moved below).
-#if defined(__i386__) || defined(__x86_64__) || defined(__mips__)
+#if defined(__i386__) || defined(__x86_64__) || defined(__mips__) || \
+ defined(__powerpc64__)
case __NR_fadvise64: // EPERM not a valid errno.
#endif
#if defined(__i386__)
@@ -233,11 +239,12 @@ bool SyscallSets::IsAllowedFileSystemAcc
case __NR_flock: // EPERM not a valid errno.
case __NR_fstatfs: // Give information about the whole filesystem.
#if defined(__i386__) || defined(__arm__) || \
- (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_32_BITS))
+ (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_32_BITS)) || \
+ defined(__powerpc64__)
case __NR_fstatfs64:
#endif
case __NR_fsync: // EPERM not a valid errno.
-#if defined(__i386__)
+#if defined(__i386__) || defined(__powerpc64__)
case __NR_oldfstat:
#endif
#if defined(__i386__) || defined(__x86_64__) || defined(__mips__) || \
@@ -245,6 +252,8 @@ bool SyscallSets::IsAllowedFileSystemAcc
case __NR_sync_file_range: // EPERM not a valid errno.
#elif defined(__arm__)
case __NR_arm_sync_file_range: // EPERM not a valid errno.
+#elif defined(__powerpc64__)
+ case __NR_sync_file_range2: // EPERM not a valid errno.
#endif
default:
return false;
@@ -265,7 +274,8 @@ bool SyscallSets::IsDeniedFileSystemAcce
#endif
case __NR_getdents64: // EPERM not a valid errno.
#if defined(__i386__) || \
- (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_32_BITS))
+ (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_32_BITS)) || \
+ defined(__powerpc64__)
case __NR_readdir:
#endif
return true;
@@ -306,7 +316,7 @@ bool SyscallSets::IsGetSimpleId(int sysn
bool SyscallSets::IsProcessPrivilegeChange(int sysno) {
switch (sysno) {
case __NR_capset:
-#if defined(__i386__) || defined(__x86_64__)
+#if defined(__i386__) || defined(__x86_64__) || defined(__powerpc64__)
case __NR_ioperm: // Intel privilege.
case __NR_iopl: // Intel privilege.
#endif
@@ -362,7 +372,8 @@ bool SyscallSets::IsAllowedSignalHandlin
// overflow.
case __NR_sigaltstack:
#if defined(__i386__) || defined(__arm__) || \
- (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_32_BITS))
+ (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_32_BITS)) || \
+ defined(__powerpc64__)
case __NR_rt_sigtimedwait_time64:
case __NR_sigaction:
case __NR_sigprocmask:
@@ -378,7 +389,8 @@ bool SyscallSets::IsAllowedSignalHandlin
#endif
case __NR_signalfd4:
#if defined(__i386__) || defined(__arm__) || \
- (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_32_BITS))
+ (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_32_BITS)) || \
+ defined(__powerpc64__)
case __NR_sigpending:
case __NR_sigsuspend:
#endif
@@ -402,7 +414,7 @@ bool SyscallSets::IsAllowedOperationOnFd
#endif
case __NR_dup3:
#if defined(__x86_64__) || defined(__arm__) || defined(__mips__) || \
- defined(__aarch64__)
+ defined(__aarch64__) || defined(__powerpc64__)
case __NR_shutdown:
#endif
return true;
@@ -435,7 +447,7 @@ bool SyscallSets::IsAllowedProcessStartO
case __NR_exit_group:
case __NR_wait4:
case __NR_waitid:
-#if defined(__i386__)
+#if defined(__i386__) || defined(__powerpc64__)
case __NR_waitpid:
#endif
return true;
@@ -452,7 +464,7 @@ bool SyscallSets::IsAllowedProcessStartO
#endif
case __NR_set_tid_address:
case __NR_unshare:
-#if !defined(__mips__) && !defined(__aarch64__)
+#if !defined(__mips__) && !defined(__aarch64__) || defined(__powerpc64__)
case __NR_vfork:
#endif
default:
@@ -499,7 +511,7 @@ bool SyscallSets::IsAllowedEpoll(int sys
bool SyscallSets::IsDeniedGetOrModifySocket(int sysno) {
switch (sysno) {
#if defined(__x86_64__) || defined(__arm__) || defined(__mips__) || \
- defined(__aarch64__)
+ defined(__aarch64__) || defined(__powerpc64__)
case __NR_accept:
case __NR_accept4:
case __NR_bind:
@@ -514,7 +526,8 @@ bool SyscallSets::IsDeniedGetOrModifySoc
}
#if defined(__i386__) || \
- (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_32_BITS))
+ (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_32_BITS)) || \
+ defined(__powerpc64__)
// Big multiplexing system call for sockets.
bool SyscallSets::IsSocketCall(int sysno) {
switch (sysno) {
@@ -528,7 +541,8 @@ bool SyscallSets::IsSocketCall(int sysno
}
#endif
-#if defined(__x86_64__) || defined(__arm__) || defined(__mips__)
+#if defined(__x86_64__) || defined(__arm__) || defined(__mips__) || \
+ defined(__powerpc64__)
bool SyscallSets::IsNetworkSocketInformation(int sysno) {
switch (sysno) {
case __NR_getpeername:
@@ -553,7 +567,7 @@ bool SyscallSets::IsAllowedAddressSpaceA
case __NR_mincore:
case __NR_mlockall:
#if defined(__i386__) || defined(__x86_64__) || defined(__mips__) || \
- defined(__aarch64__)
+ defined(__aarch64__) || defined(__powerpc64__)
case __NR_mmap:
#endif
#if defined(__i386__) || defined(__arm__) || \
@@ -583,7 +597,8 @@ bool SyscallSets::IsAllowedGeneralIo(int
switch (sysno) {
case __NR_lseek:
#if defined(__i386__) || defined(__arm__) || \
- (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_32_BITS))
+ (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_32_BITS)) || \
+ defined(__powerpc64__)
case __NR__llseek:
#endif
#if !defined(__aarch64__)
@@ -603,26 +618,28 @@ bool SyscallSets::IsAllowedGeneralIo(int
case __NR_readv:
case __NR_pread64:
#if defined(__arm__) || \
- (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_32_BITS))
+ (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_32_BITS)) || \
+ defined(__powerpc64__)
case __NR_recv:
#endif
#if defined(__x86_64__) || defined(__arm__) || defined(__mips__) || \
- defined(__aarch64__)
+ defined(__aarch64__) || defined(__powerpc64__)
case __NR_recvfrom: // Could specify source.
case __NR_recvmsg: // Could specify source.
#endif
-#if defined(__i386__) || defined(__x86_64__)
+#if defined(__i386__) || defined(__x86_64__) || defined(__powerpc64__)
case __NR_select:
#endif
-#if defined(__i386__) || defined(__arm__) || defined(__mips__)
+#if defined(__i386__) || defined(__arm__) || defined(__mips__) || defined(__powerpc64__)
case __NR__newselect:
#endif
#if defined(__arm__) || \
- (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_32_BITS))
+ (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_32_BITS)) || \
+ defined(__powerpc64__)
case __NR_send:
#endif
#if defined(__x86_64__) || defined(__arm__) || defined(__mips__) || \
- defined(__aarch64__)
+ defined(__aarch64__) || defined(__powerpc64__)
case __NR_sendmsg: // Could specify destination.
case __NR_sendto: // Could specify destination.
#endif
@@ -678,7 +695,8 @@ bool SyscallSets::IsAllowedBasicSchedule
return true;
case __NR_getpriority:
#if defined(__i386__) || defined(__arm__) || \
- (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_32_BITS))
+ (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_32_BITS)) || \
+ defined(__powerpc64__)
case __NR_nice:
#endif
case __NR_setpriority:
@@ -690,7 +708,8 @@ bool SyscallSets::IsAllowedBasicSchedule
bool SyscallSets::IsAdminOperation(int sysno) {
switch (sysno) {
#if defined(__i386__) || defined(__arm__) || \
- (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_32_BITS))
+ (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_32_BITS)) || \
+ defined(__powerpc64__)
case __NR_bdflush:
#endif
case __NR_kexec_load:
@@ -706,7 +725,8 @@ bool SyscallSets::IsAdminOperation(int s
bool SyscallSets::IsKernelModule(int sysno) {
switch (sysno) {
-#if defined(__i386__) || defined(__x86_64__) || defined(__mips__)
+#if defined(__i386__) || defined(__x86_64__) || defined(__mips__) || \
+ defined(__powerpc64__)
case __NR_create_module:
case __NR_get_kernel_syms: // Should ENOSYS.
case __NR_query_module:
@@ -739,7 +759,8 @@ bool SyscallSets::IsFsControl(int sysno)
case __NR_swapoff:
case __NR_swapon:
#if defined(__i386__) || \
- (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_32_BITS))
+ (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_32_BITS)) || \
+ defined(__powerpc64__)
case __NR_umount:
#endif
case __NR_umount2:
@@ -755,7 +776,7 @@ bool SyscallSets::IsNuma(int sysno) {
case __NR_getcpu:
case __NR_mbind:
#if defined(__i386__) || defined(__x86_64__) || defined(__mips__) || \
- defined(__aarch64__)
+ defined(__aarch64__) || defined(__powerpc64__)
case __NR_migrate_pages:
#endif
case __NR_move_pages:
@@ -790,14 +811,15 @@ bool SyscallSets::IsGlobalProcessEnviron
switch (sysno) {
case __NR_acct: // Privileged.
#if defined(__i386__) || defined(__x86_64__) || defined(__mips__) || \
- defined(__aarch64__)
+ defined(__aarch64__) || defined(__powerpc64__)
case __NR_getrlimit:
#endif
-#if defined(__i386__) || defined(__arm__)
+#if defined(__i386__) || defined(__arm__) || defined(__powerpc64__)
case __NR_ugetrlimit:
#endif
#if defined(__i386__) || \
- (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_32_BITS))
+ (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_32_BITS)) || \
+ defined(__powerpc64__)
case __NR_ulimit:
#endif
case __NR_getrusage:
@@ -831,7 +853,7 @@ bool SyscallSets::IsGlobalSystemStatus(i
#endif
case __NR_sysinfo:
case __NR_uname:
-#if defined(__i386__)
+#if defined(__i386__) || defined(__powerpc64__)
case __NR_olduname:
case __NR_oldolduname:
#endif
@@ -915,7 +937,8 @@ bool SyscallSets::IsSystemVSemaphores(in
#if defined(__i386__) || defined(__x86_64__) || defined(__arm__) || \
defined(__aarch64__) || \
- (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS))
+ (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS)) || \
+ defined(__powerpc64__)
// These give a lot of ambient authority and bypass the setuid sandbox.
bool SyscallSets::IsSystemVSharedMemory(int sysno) {
switch (sysno) {
@@ -946,7 +969,8 @@ bool SyscallSets::IsSystemVMessageQueue(
#endif
#if defined(__i386__) || \
- (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_32_BITS))
+ (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_32_BITS)) || \
+ defined(__powerpc64__)
// Big system V multiplexing system call.
bool SyscallSets::IsSystemVIpc(int sysno) {
switch (sysno) {
@@ -966,7 +990,8 @@ bool SyscallSets::IsAnySystemV(int sysno
return IsSystemVMessageQueue(sysno) || IsSystemVSemaphores(sysno) ||
IsSystemVSharedMemory(sysno);
#elif defined(__i386__) || \
- (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_32_BITS))
+ (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_32_BITS)) || \
+ defined(__powerpc64__)
return IsSystemVIpc(sysno);
#endif
}
@@ -1023,7 +1048,8 @@ bool SyscallSets::IsFaNotify(int sysno)
bool SyscallSets::IsTimer(int sysno) {
switch (sysno) {
case __NR_getitimer:
-#if defined(__i386__) || defined(__x86_64__) || defined(__mips__)
+#if defined(__i386__) || defined(__x86_64__) || defined(__mips__) || \
+ defined(__powerpc64__)
case __NR_alarm:
#endif
case __NR_setitimer:
@@ -1105,18 +1131,22 @@ bool SyscallSets::IsMisc(int sysno) {
case __NR_syncfs:
case __NR_vhangup:
// The system calls below are not implemented.
-#if defined(__i386__) || defined(__x86_64__) || defined(__mips__)
+#if defined(__i386__) || defined(__x86_64__) || defined(__mips__) || \
+ defined(__powerpc64__)
case __NR_afs_syscall:
#endif
#if defined(__i386__) || \
- (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_32_BITS))
+ (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_32_BITS)) || \
+ defined(__powerpc64__)
case __NR_break:
#endif
-#if defined(__i386__) || defined(__x86_64__) || defined(__mips__)
+#if defined(__i386__) || defined(__x86_64__) || defined(__mips__) || \
+ defined(__powerpc64__)
case __NR_getpmsg:
#endif
#if defined(__i386__) || \
- (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_32_BITS))
+ (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_32_BITS)) || \
+ defined(__powerpc64__)
case __NR_gtty:
case __NR_idle:
case __NR_lock:
@@ -1124,20 +1154,22 @@ bool SyscallSets::IsMisc(int sysno) {
case __NR_prof:
case __NR_profil:
#endif
-#if defined(__i386__) || defined(__x86_64__) || defined(__mips__)
+#if defined(__i386__) || defined(__x86_64__) || defined(__mips__) || \
+ defined(__powerpc64__)
case __NR_putpmsg:
#endif
#if defined(__x86_64__)
case __NR_security:
#endif
#if defined(__i386__) || \
- (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_32_BITS))
+ (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_32_BITS)) || \
+ defined(__powerpc64__)
case __NR_stty:
#endif
-#if defined(__x86_64__)
+#if defined(__x86_64__) || defined(__powerpc64__)
case __NR_tuxcall:
#endif
-#if !defined(__aarch64__)
+#if !defined(__aarch64__) && !defined(__powerpc64__)
case __NR_vserver:
#endif
return true;
Index: chromium-120.0.6099.71/sandbox/linux/seccomp-bpf-helpers/syscall_sets.h
===================================================================
--- chromium-120.0.6099.71.orig/sandbox/linux/seccomp-bpf-helpers/syscall_sets.h
+++ chromium-120.0.6099.71/sandbox/linux/seccomp-bpf-helpers/syscall_sets.h
@@ -46,13 +46,14 @@ class SANDBOX_EXPORT SyscallSets {
static bool IsDeniedGetOrModifySocket(int sysno);
#if defined(__i386__) || \
- (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_32_BITS))
+ (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_32_BITS)) || \
+ defined(__powerpc64__)
// Big multiplexing system call for sockets.
static bool IsSocketCall(int sysno);
#endif
#if defined(__x86_64__) || defined(__arm__) || defined(__mips__) || \
- defined(__aarch64__)
+ defined(__aarch64__) || defined(__powerpc64__)
static bool IsNetworkSocketInformation(int sysno);
#endif
@@ -84,7 +85,8 @@ class SANDBOX_EXPORT SyscallSets {
#endif
#if defined(__i386__) || defined(__x86_64__) || defined(__arm__) || \
defined(__aarch64__) || \
- (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS))
+ (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS)) || \
+ defined(__powerpc64__)
// These give a lot of ambient authority and bypass the setuid sandbox.
static bool IsSystemVSharedMemory(int sysno);
#endif
@@ -95,7 +97,8 @@ class SANDBOX_EXPORT SyscallSets {
#endif
#if defined(__i386__) || \
- (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_32_BITS))
+ (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_32_BITS)) || \
+ defined(__powerpc64__)
// Big system V multiplexing system call.
static bool IsSystemVIpc(int sysno);
#endif
Index: chromium-120.0.6099.71/sandbox/linux/services/syscall_wrappers.cc
===================================================================
--- chromium-120.0.6099.71.orig/sandbox/linux/services/syscall_wrappers.cc
+++ chromium-120.0.6099.71/sandbox/linux/services/syscall_wrappers.cc
@@ -61,7 +61,7 @@ long sys_clone(unsigned long flags,
#if defined(ARCH_CPU_X86_64)
return syscall(__NR_clone, flags, child_stack, ptid, ctid, tls);
#elif defined(ARCH_CPU_X86) || defined(ARCH_CPU_ARM_FAMILY) || \
- defined(ARCH_CPU_MIPS_FAMILY)
+ defined(ARCH_CPU_MIPS_FAMILY) || defined(ARCH_CPU_PPC64_FAMILY)
// CONFIG_CLONE_BACKWARDS defined.
return syscall(__NR_clone, flags, child_stack, ptid, tls, ctid);
#endif

@ -0,0 +1,27 @@
From c9043a422fb4a5a6c72aaa1b907cea5f6a3061dd Mon Sep 17 00:00:00 2001
From: Shawn Anastasio <shawnanastasio@yahoo.com>
Date: Thu, 9 Aug 2018 19:10:24 -0500
Subject: [PATCH 1/4] sandbox/linux/bpf_dsl: Update syscall ranges for ppc64
---
sandbox/linux/bpf_dsl/linux_syscall_ranges.h | 7 +++++++
1 file changed, 7 insertions(+)
Index: chromium-120.0.6099.71/sandbox/linux/bpf_dsl/linux_syscall_ranges.h
===================================================================
--- chromium-120.0.6099.71.orig/sandbox/linux/bpf_dsl/linux_syscall_ranges.h
+++ chromium-120.0.6099.71/sandbox/linux/bpf_dsl/linux_syscall_ranges.h
@@ -56,6 +56,13 @@
#define MAX_PUBLIC_SYSCALL __NR_syscalls
#define MAX_SYSCALL MAX_PUBLIC_SYSCALL
+#elif defined(__powerpc64__)
+
+#include <asm/unistd.h>
+#define MIN_SYSCALL 0u
+#define MAX_PUBLIC_SYSCALL 386u
+#define MAX_SYSCALL MAX_PUBLIC_SYSCALL
+
#else
#error "Unsupported architecture"
#endif

@ -0,0 +1,26 @@
From 7468b266532bd607eb1f5292d758256d800b2eee Mon Sep 17 00:00:00 2001
From: Shawn Anastasio <shawnanastasio@yahoo.com>
Date: Fri, 10 Aug 2018 00:23:50 -0500
Subject: [PATCH] services/service_manager/sandbox/linux: Fix TCGETS
declaration on PPC64
---
.../sandbox/linux/bpf_renderer_policy_linux.cc | 5 +++++
1 file changed, 5 insertions(+)
Index: chromium-120.0.6099.71/sandbox/policy/linux/bpf_renderer_policy_linux.cc
===================================================================
--- chromium-120.0.6099.71.orig/sandbox/policy/linux/bpf_renderer_policy_linux.cc
+++ chromium-120.0.6099.71/sandbox/policy/linux/bpf_renderer_policy_linux.cc
@@ -15,6 +15,11 @@
#include "sandbox/linux/system_headers/linux_syscalls.h"
#include "sandbox/policy/linux/sandbox_linux.h"
+// On PPC64, TCGETS is defined in terms of struct termios, so we must include termios.h
+#ifdef __powerpc64__
+#include <termios.h>
+#endif
+
// TODO(vignatti): replace the local definitions below with #include
// <linux/dma-buf.h> once kernel version 4.6 becomes widely used.
#include <linux/types.h>

@ -0,0 +1,12 @@
Index: chromium-120.0.6099.71/third_party/angle/src/libANGLE/Constants.h
===================================================================
--- chromium-120.0.6099.71.orig/third_party/angle/src/libANGLE/Constants.h
+++ chromium-120.0.6099.71/third_party/angle/src/libANGLE/Constants.h
@@ -9,6 +9,7 @@
#ifndef LIBANGLE_CONSTANTS_H_
#define LIBANGLE_CONSTANTS_H_
+#include <cstddef>
#include "common/platform.h"
#include <stddef.h>

@ -0,0 +1,23 @@
From cc613c2e3bac8d4d1ff153700b819f964435923a Mon Sep 17 00:00:00 2001
From: Shawn Anastasio <shawnanastasio@yahoo.com>
Date: Tue, 4 Sep 2018 18:16:07 -0500
Subject: [PATCH] third_party/libvpx: Properly generate gni on ppc64
---
third_party/libvpx/BUILD.gn | 2 ++
third_party/libvpx/generate_gni.sh | 10 ++++++++++
2 files changed, 12 insertions(+)
Index: chromium-120.0.6099.71/third_party/libvpx/BUILD.gn
===================================================================
--- chromium-120.0.6099.71.orig/third_party/libvpx/BUILD.gn
+++ chromium-120.0.6099.71/third_party/libvpx/BUILD.gn
@@ -248,6 +248,8 @@ if (current_cpu == "x86" || (current_cpu
} else if (current_cpu == "x64") {
deps = [ ":libvpx_x86_64_headers" ]
sources = libvpx_srcs_x86_64_avx512
+ } else if (current_cpu == "ppc64") {
+ sources = libvpx_srcs_ppc64
}
}
}

@ -0,0 +1,22 @@
Index: chromium-120.0.6099.71/third_party/lss/linux_syscall_support.h
===================================================================
--- chromium-120.0.6099.71.orig/third_party/lss/linux_syscall_support.h
+++ chromium-120.0.6099.71/third_party/lss/linux_syscall_support.h
@@ -4638,7 +4638,7 @@ struct kernel_statx {
LSS_REG(2, buf);
LSS_BODY(void*, mmap2, "0"(__r2));
}
-#else
+#elif !defined(__powerpc64__) /* ppc64 doesn't have mmap2 */
#define __NR__mmap2 __NR_mmap2
LSS_INLINE _syscall6(void*, _mmap2, void*, s,
size_t, l, int, p,
@@ -4749,7 +4749,7 @@ struct kernel_statx {
#if defined(__i386__) || \
defined(__ARM_ARCH_3__) || defined(__ARM_EABI__) || \
(defined(__mips__) && _MIPS_SIM == _MIPS_SIM_ABI32) || \
- defined(__PPC__) || \
+ (defined(__PPC__) && !defined(__powerpc64__)) || \
(defined(__s390__) && !defined(__s390x__))
/* On these architectures, implement mmap() with mmap2(). */
LSS_INLINE void* LSS_NAME(mmap)(void *s, size_t l, int p, int f, int d,

@ -0,0 +1,22 @@
From 63e63a70766f3059ce5f1d06a95988ecf909b298 Mon Sep 17 00:00:00 2001
From: Shawn Anastasio <shawn@anastas.io>
Date: Wed, 24 Apr 2019 21:17:23 -0500
Subject: [PATCH] third_party/pffft: Include altivec.h on ppc64 with SIMD
enabled
---
third_party/pffft/src/pffft.c | 1 +
1 file changed, 1 insertion(+)
Index: chromium-120.0.6099.71/third_party/pffft/src/pffft.c
===================================================================
--- chromium-120.0.6099.71.orig/third_party/pffft/src/pffft.c
+++ chromium-120.0.6099.71/third_party/pffft/src/pffft.c
@@ -100,6 +100,7 @@
Altivec support macros
*/
#if !defined(PFFFT_SIMD_DISABLE) && (defined(__ppc__) || defined(__ppc64__))
+#include <altivec.h>
typedef vector float v4sf;
# define SIMD_SZ 4
# define VZERO() ((vector float) vec_splat_u8(0))

@ -0,0 +1,16 @@
--- a/v8/src/base/immediate-crash.h
+++ b/v8/src/base/immediate-crash.h
@@ -93,6 +93,13 @@
#define TRAP_SEQUENCE1_() asm volatile(".2byte 0x0001");
#define TRAP_SEQUENCE2_() asm volatile("")
+#elif V8_HOST_ARCH_PPC64
+
+#define TRAP_SEQUENCE1_() asm volatile("trap")
+// Intentionally empty: __builtin_unreachable() is always part of the sequence
+// (see IMMEDIATE_CRASH below)
+#define TRAP_SEQUENCE2_() asm volatile("")
+
#else
// Crash report accuracy will not be guaranteed on other architectures, but at

@ -0,0 +1,101 @@
Index: chromium-120.0.6099.71/third_party/highway/src/hwy/ops/ppc_vsx-inl.h
===================================================================
--- chromium-120.0.6099.71.orig/third_party/highway/src/hwy/ops/ppc_vsx-inl.h
+++ chromium-120.0.6099.71/third_party/highway/src/hwy/ops/ppc_vsx-inl.h
@@ -36,6 +36,8 @@
#include "hwy/ops/shared-inl.h"
+#undef __SIZEOF_INT128__
+
HWY_BEFORE_NAMESPACE();
namespace hwy {
namespace HWY_NAMESPACE {
@@ -2844,7 +2846,6 @@ struct CompressIsPartition {
namespace detail {
-#if HWY_TARGET > HWY_PPC10 || __BYTE_ORDER__ != __ORDER_LITTLE_ENDIAN__
// fallback for missing vec_extractm
template <size_t N>
HWY_INLINE uint64_t ExtractSignBits(Vec128<uint8_t, N> sign_bits,
@@ -2857,22 +2858,16 @@ HWY_INLINE uint64_t ExtractSignBits(Vec1
return extracted.raw[__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__];
}
-#endif // HWY_TARGET > HWY_PPC10
-
template <typename T, size_t N>
HWY_INLINE uint64_t BitsFromMask(hwy::SizeTag<1> /*tag*/,
Mask128<T, N> mask) {
const DFromM<decltype(mask)> d;
const Repartition<uint8_t, decltype(d)> du8;
const VFromD<decltype(du8)> sign_bits = BitCast(du8, VecFromMask(d, mask));
-#if HWY_TARGET <= HWY_PPC10 && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
- return static_cast<uint64_t>(vec_extractm(sign_bits.raw));
-#else
const __vector unsigned char kBitShuffle = {
120, 112, 104, 96, 88, 80, 72, 64, 56, 48, 40, 32, 24, 16, 8, 0
};
return ExtractSignBits(sign_bits, kBitShuffle);
-#endif // HWY_TARGET <= HWY_PPC10
}
template <typename T, size_t N>
@@ -2882,10 +2877,6 @@ HWY_INLINE uint64_t BitsFromMask(hwy::Si
const Repartition<uint8_t, decltype(d)> du8;
const VFromD<decltype(du8)> sign_bits = BitCast(du8, VecFromMask(d, mask));
-#if HWY_TARGET <= HWY_PPC10 && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
- const RebindToUnsigned<decltype(d)> du;
- return static_cast<uint64_t>(vec_extractm(BitCast(du, sign_bits).raw));
-#else
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
const __vector unsigned char kBitShuffle = {
112, 96, 80, 64, 48, 32, 16, 0, 128, 128, 128, 128, 128, 128, 128, 128};
@@ -2894,7 +2885,6 @@ HWY_INLINE uint64_t BitsFromMask(hwy::Si
128, 128, 128, 128, 128, 128, 128, 128, 112, 96, 80, 64, 48, 32, 16, 0};
#endif
return ExtractSignBits(sign_bits, kBitShuffle);
-#endif // HWY_TARGET <= HWY_PPC10
}
template <typename T, size_t N>
@@ -2903,10 +2893,6 @@ HWY_INLINE uint64_t BitsFromMask(hwy::Si
const DFromM<decltype(mask)> d;
const Repartition<uint8_t, decltype(d)> du8;
const VFromD<decltype(du8)> sign_bits = BitCast(du8, VecFromMask(d, mask));
-#if HWY_TARGET <= HWY_PPC10 && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
- const RebindToUnsigned<decltype(d)> du;
- return static_cast<uint64_t>(vec_extractm(BitCast(du, sign_bits).raw));
-#else
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
const __vector unsigned char kBitShuffle = {
96, 64, 32, 0, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128};
@@ -2915,7 +2901,6 @@ HWY_INLINE uint64_t BitsFromMask(hwy::Si
128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 96, 64, 32, 0};
#endif
return ExtractSignBits(sign_bits, kBitShuffle);
-#endif // HWY_TARGET <= HWY_PPC10
}
template <typename T, size_t N>
@@ -2924,10 +2909,6 @@ HWY_INLINE uint64_t BitsFromMask(hwy::Si
const DFromM<decltype(mask)> d;
const Repartition<uint8_t, decltype(d)> du8;
const VFromD<decltype(du8)> sign_bits = BitCast(du8, VecFromMask(d, mask));
-#if HWY_TARGET <= HWY_PPC10 && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
- const RebindToUnsigned<decltype(d)> du;
- return static_cast<uint64_t>(vec_extractm(BitCast(du, sign_bits).raw));
-#else
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
const __vector unsigned char kBitShuffle = {64, 0, 128, 128, 128, 128,
128, 128, 128, 128, 128, 128,
@@ -2938,7 +2919,6 @@ HWY_INLINE uint64_t BitsFromMask(hwy::Si
128, 128, 64, 0};
#endif
return ExtractSignBits(sign_bits, kBitShuffle);
-#endif // HWY_TARGET <= HWY_PPC10
}
// Returns the lowest N of the mask bits.

@ -0,0 +1,21 @@
From 82922bf486e9926a171152f61030dfcd53f017b8 Mon Sep 17 00:00:00 2001
From: Timothy Pearson <tpearson@raptorengineering.com>
Date: Thu, 30 Aug 2018 17:32:05 -0500
Subject: [PATCH] Include cstddef to fix build
size_t is not defined unless cstddef is included.
---
third_party/crashpad/crashpad/compat/linux/sys/user.h | 1 +
Index: chromium-120.0.6099.71/third_party/crashpad/crashpad/compat/linux/sys/user.h
===================================================================
--- chromium-120.0.6099.71.orig/third_party/crashpad/crashpad/compat/linux/sys/user.h
+++ chromium-120.0.6099.71/third_party/crashpad/crashpad/compat/linux/sys/user.h
@@ -15,6 +15,7 @@
#ifndef CRASHPAD_COMPAT_LINUX_SYS_USER_H_
#define CRASHPAD_COMPAT_LINUX_SYS_USER_H_
+#include <cstddef>
#include_next <sys/user.h>
#include <features.h>

@ -0,0 +1,76 @@
From 3c4705bfdda45feb860a1f121631773e5fe8e53f Mon Sep 17 00:00:00 2001
From: Shawn Anastasio <shawnanastasio@yahoo.com>
Date: Thu, 9 Aug 2018 19:11:26 -0500
Subject: [PATCH 1/4] sandbox/linux/bpf_dsl: Modify seccomp_macros to add
support for ppc64
---
sandbox/linux/bpf_dsl/seccomp_macros.h | 43 ++++++++++++++++++++++++++
1 file changed, 43 insertions(+)
Index: chromium-120.0.6099.71/sandbox/linux/bpf_dsl/seccomp_macros.h
===================================================================
--- chromium-120.0.6099.71.orig/sandbox/linux/bpf_dsl/seccomp_macros.h
+++ chromium-120.0.6099.71/sandbox/linux/bpf_dsl/seccomp_macros.h
@@ -14,6 +14,9 @@
#if defined(__mips__)
// sys/user.h in eglibc misses size_t definition
#include <stddef.h>
+#elif defined(__powerpc64__)
+// Manually define greg_t on ppc64
+typedef unsigned long long greg_t;
#endif
#endif
@@ -343,6 +346,51 @@ struct regs_struct {
#define SECCOMP_PT_PARM4(_regs) (_regs).regs[3]
#define SECCOMP_PT_PARM5(_regs) (_regs).regs[4]
#define SECCOMP_PT_PARM6(_regs) (_regs).regs[5]
+
+#elif defined(__powerpc64__)
+#include <asm/ptrace.h>
+
+typedef struct pt_regs regs_struct;
+
+#ifdef ARCH_CPU_LITTLE_ENDIAN
+#define SECCOMP_ARCH AUDIT_ARCH_PPC64LE
+#else
+#define SECCOMP_ARCH AUDIT_ARCH_PPC64
+#endif
+
+#define SECCOMP_REG(_ctx, _reg) ((_ctx)->uc_mcontext.regs->gpr[_reg])
+
+#define SECCOMP_RESULT(_ctx) SECCOMP_REG(_ctx, 3)
+#define SECCOMP_SYSCALL(_ctx) SECCOMP_REG(_ctx, 0)
+#define SECCOMP_IP(_ctx) (_ctx)->uc_mcontext.regs->nip
+#define SECCOMP_PARM1(_ctx) SECCOMP_REG(_ctx, 3)
+#define SECCOMP_PARM2(_ctx) SECCOMP_REG(_ctx, 4)
+#define SECCOMP_PARM3(_ctx) SECCOMP_REG(_ctx, 5)
+#define SECCOMP_PARM4(_ctx) SECCOMP_REG(_ctx, 6)
+#define SECCOMP_PARM5(_ctx) SECCOMP_REG(_ctx, 7)
+#define SECCOMP_PARM6(_ctx) SECCOMP_REG(_ctx, 8)
+
+#define SECCOMP_NR_IDX (offsetof(struct arch_seccomp_data, nr))
+#define SECCOMP_ARCH_IDX (offsetof(struct arch_seccomp_data, arch))
+#define SECCOMP_IP_MSB_IDX \
+ (offsetof(struct arch_seccomp_data, instruction_pointer) + 4)
+#define SECCOMP_IP_LSB_IDX \
+ (offsetof(struct arch_seccomp_data, instruction_pointer) + 0)
+#define SECCOMP_ARG_MSB_IDX(nr) \
+ (offsetof(struct arch_seccomp_data, args) + 8 * (nr) + 4)
+#define SECCOMP_ARG_LSB_IDX(nr) \
+ (offsetof(struct arch_seccomp_data, args) + 8 * (nr) + 0)
+
+#define SECCOMP_PT_RESULT(_regs) (_regs).gpr[3]
+#define SECCOMP_PT_SYSCALL(_regs) (_regs).gpr[0]
+#define SECCOMP_PT_IP(_regs) (_regs).nip
+#define SECCOMP_PT_PARM1(_regs) (_regs).gpr[3]
+#define SECCOMP_PT_PARM2(_regs) (_regs).gpr[4]
+#define SECCOMP_PT_PARM3(_regs) (_regs).gpr[5]
+#define SECCOMP_PT_PARM4(_regs) (_regs).gpr[6]
+#define SECCOMP_PT_PARM5(_regs) (_regs).gpr[7]
+#define SECCOMP_PT_PARM6(_regs) (_regs).gpr[8]
+
#else
#error Unsupported target platform

File diff suppressed because it is too large Load Diff

@ -0,0 +1,168 @@
Index: chromium-120.0.6099.71/third_party/lss/linux_syscall_support.h
===================================================================
--- chromium-120.0.6099.71.orig/third_party/lss/linux_syscall_support.h
+++ chromium-120.0.6099.71/third_party/lss/linux_syscall_support.h
@@ -87,7 +87,7 @@
* Porting to other related platforms should not be difficult.
*/
#if (defined(__i386__) || defined(__x86_64__) || defined(__ARM_ARCH_3__) || \
- defined(__mips__) || defined(__PPC__) || defined(__ARM_EABI__) || \
+ defined(__mips__) || defined(__PPC__) || defined(__powerpc64__) || defined(__ARM_EABI__) || \
defined(__aarch64__) || defined(__s390__) || defined(__e2k__) || \
(defined(__riscv) && __riscv_xlen == 64) || defined(__loongarch_lp64)) \
&& (defined(__linux) || defined(__ANDROID__))
@@ -399,7 +399,7 @@ struct kernel_stat64 {
unsigned __pad2;
unsigned long long st_blocks;
};
-#elif defined __PPC__
+#elif defined __PPC__ && !defined(__powerpc64__)
struct kernel_stat64 {
unsigned long long st_dev;
unsigned long long st_ino;
@@ -421,6 +421,28 @@ struct kernel_stat64 {
unsigned long __unused4;
unsigned long __unused5;
};
+#elif defined(__powerpc64__)
+struct kernel_stat64 {
+ unsigned long int st_dev;
+ unsigned long int st_ino;
+ unsigned int st_mode;
+ unsigned long int st_nlink;
+ unsigned int st_uid;
+ unsigned int st_gid;
+ unsigned long int st_rdev;
+ unsigned short int __pad2;
+ long int st_size;
+ long int st_blksize;
+ long int st_blocks;
+ long int st_atime_;
+ unsigned long int st_atime_nsec_;
+ long int st_mtime_;
+ unsigned long int st_mtime_nsec_;
+ long int st_ctime_;
+ unsigned long int st_ctime_nsec_;
+ unsigned long int __unused4;
+ unsigned long int __unused5;
+};
#elif defined(__e2k__)
struct kernel_stat64 {
unsigned long long st_dev;
@@ -537,7 +559,7 @@ struct kernel_stat {
uint64_t st_ctime_nsec_;
int64_t __unused4[3];
};
-#elif defined(__PPC__)
+#elif defined(__PPC__) && !defined(__powerpc64__)
typedef unsigned long kernel_blkcnt_t;
typedef unsigned long kernel_blksize_t;
typedef unsigned kernel_dev_t;
@@ -568,6 +590,37 @@ struct kernel_stat {
unsigned long __unused4;
unsigned long __unused5;
};
+#elif defined(__powerpc64__)
+typedef long int kernel_blkcnt_t;
+typedef long int kernel_blksize_t;
+typedef unsigned long int kernel_dev_t;
+typedef unsigned int kernel_gid_t;
+typedef unsigned long int kernel_ino_t;
+typedef unsigned int kernel_mode_t;
+typedef unsigned long int kernel_nlink_t;
+typedef long int kernel_off_t;
+typedef long int kernel_time_t;
+typedef unsigned int kernel_uid_t;
+struct kernel_stat {
+ kernel_dev_t st_dev;
+ kernel_ino_t st_ino;
+ kernel_mode_t st_mode;
+ kernel_nlink_t st_nlink;
+ kernel_uid_t st_uid;
+ kernel_gid_t st_gid;
+ kernel_dev_t st_rdev;
+ kernel_off_t st_size;
+ kernel_blksize_t st_blksize;
+ kernel_blkcnt_t st_blocks;
+ kernel_time_t st_atime_;
+ unsigned long int st_atime_nsec_;
+ kernel_time_t st_mtime_;
+ unsigned long int st_mtime_nsec_;
+ kernel_time_t st_ctime_;
+ unsigned long int st_ctime_nsec_;
+ unsigned long int __unused4;
+ unsigned long int __unused5;
+};
#elif (defined(__mips__) && _MIPS_SIM != _MIPS_SIM_ABI64)
typedef int kernel_blkcnt_t;
typedef int kernel_blksize_t;
@@ -1824,6 +1877,28 @@ struct kernel_statx {
#ifndef __NR_getcpu
#define __NR_getcpu 302
#endif
+
+/* Linux commit 86250b9d12caa1a3dee12a7cf638b7dd70eaadb6 (2010) adds
+ * direct socket system calls to PPC */
+#ifndef __NR_socket
+#define __NR_socket 326
+#endif
+#ifndef __NR_socketpair
+#define __NR_socketpair 333
+#endif
+#ifndef __NR_sendto
+#define __NR_sendto 335
+#endif
+#ifndef __NR_shutdown
+#define __NR_shutdown 338
+#endif
+#ifndef __NR_sendmsg
+#define __NR_sendmsg 341
+#endif
+#ifndef __NR_recvmsg
+#define __NR_recvmsg 342
+#endif
+
/* End of powerpc defininitions */
#elif defined(__s390__)
#ifndef __NR_quotactl
@@ -3363,6 +3438,11 @@ struct kernel_statx {
/* TODO(csilvers): consider wrapping some args up in a struct, like we
* do for i386's _syscall6, so we can compile successfully on gcc 2.95
*/
+ #ifdef __powerpc64__
+ /* TODO: implement clone() for ppc64.
+ * until then, use system libc */
+ #define sys_clone clone
+ #else
LSS_INLINE int LSS_NAME(clone)(int (*fn)(void *), void *child_stack,
int flags, void *arg, int *parent_tidptr,
void *newtls, int *child_tidptr) {
@@ -3433,6 +3513,7 @@ struct kernel_statx {
}
LSS_RETURN(int, __ret, __err);
}
+ #endif
#elif defined(__s390__)
#undef LSS_REG
#define LSS_REG(r, a) register unsigned long __r##r __asm__("r"#r) = (unsigned long) a
@@ -4783,7 +4864,7 @@ struct kernel_statx {
LSS_INLINE _syscall6(void*, mmap, void*, addr, size_t, length, int, prot,
int, flags, int, fd, int64_t, offset)
#endif
- #if defined(__PPC__)
+ #if defined(__PPC__) && !defined(__powerpc64__)
#undef LSS_SC_LOADARGS_0
#define LSS_SC_LOADARGS_0(dummy...)
#undef LSS_SC_LOADARGS_1
@@ -5173,7 +5254,11 @@ struct kernel_statx {
#endif
#if !defined(__NR_pipe)
+#if defined(__powerpc64__)
+ LSS_INLINE pid_t LSS_NAME(pipe)(int *pipefd) {
+#else
LSS_INLINE int LSS_NAME(pipe)(int *pipefd) {
+#endif
return LSS_NAME(pipe2)(pipefd, 0);
}
#endif

@ -0,0 +1,37 @@
From cca78240860abb63bbcfe94d1e5f04a1f23c527d Mon Sep 17 00:00:00 2001
From: Shawn Anastasio <shawnanastasio@yahoo.com>
Date: Thu, 9 Aug 2018 19:11:56 -0500
Subject: [PATCH 3/4] sandbox/linux/system_headers: Update linux seccomp header
for ppc64
---
sandbox/linux/system_headers/linux_seccomp.h | 10 ++++++++++
1 file changed, 10 insertions(+)
Index: chromium-120.0.6099.71/sandbox/linux/system_headers/linux_seccomp.h
===================================================================
--- chromium-120.0.6099.71.orig/sandbox/linux/system_headers/linux_seccomp.h
+++ chromium-120.0.6099.71/sandbox/linux/system_headers/linux_seccomp.h
@@ -38,6 +38,9 @@
#ifndef EM_AARCH64
#define EM_AARCH64 183
#endif
+#ifndef EM_PPC64
+#define EM_PPC64 21
+#endif
#ifndef __AUDIT_ARCH_64BIT
#define __AUDIT_ARCH_64BIT 0x80000000
@@ -70,6 +73,12 @@
#ifndef AUDIT_ARCH_AARCH64
#define AUDIT_ARCH_AARCH64 (EM_AARCH64 | __AUDIT_ARCH_64BIT | __AUDIT_ARCH_LE)
#endif
+#ifndef AUDIT_ARCH_PPC64
+#define AUDIT_ARCH_PPC64 (EM_PPC64 | __AUDIT_ARCH_64BIT)
+#endif
+#ifndef AUDIT_ARCH_PPC64LE
+#define AUDIT_ARCH_PPC64LE (EM_PPC64 | __AUDIT_ARCH_64BIT | __AUDIT_ARCH_LE)
+#endif
// For prctl.h
#ifndef PR_SET_SECCOMP

@ -0,0 +1,35 @@
--- a/third_party/libvpx/libvpx_srcs.gni
+++ b/third_party/libvpx/libvpx_srcs.gni
@@ -4302,6 +4302,7 @@
"//third_party/libvpx/source/libvpx/vp9/common/vp9_seg_common.c",
"//third_party/libvpx/source/libvpx/vp9/common/vp9_thread_common.c",
"//third_party/libvpx/source/libvpx/vp9/common/vp9_tile_common.c",
+ "//third_party/libvpx/source/libvpx/vp9/common/ppc/vp9_idct_vsx.c",
"//third_party/libvpx/source/libvpx/vp9/decoder/vp9_decodeframe.c",
"//third_party/libvpx/source/libvpx/vp9/decoder/vp9_decodemv.c",
"//third_party/libvpx/source/libvpx/vp9/decoder/vp9_decoder.c",
@@ -4340,6 +4341,7 @@
"//third_party/libvpx/source/libvpx/vp9/encoder/vp9_svc_layercontext.c",
"//third_party/libvpx/source/libvpx/vp9/encoder/vp9_tokenize.c",
"//third_party/libvpx/source/libvpx/vp9/encoder/vp9_treewriter.c",
+ "//third_party/libvpx/source/libvpx/vp9/encoder/ppc/vp9_quantize_vsx.c",
"//third_party/libvpx/source/libvpx/vp9/vp9_cx_iface.c",
"//third_party/libvpx/source/libvpx/vp9/vp9_dx_iface.c",
"//third_party/libvpx/source/libvpx/vp9/vp9_iface_common.c",
@@ -4368,6 +4370,16 @@
"//third_party/libvpx/source/libvpx/vpx_dsp/variance.c",
"//third_party/libvpx/source/libvpx/vpx_dsp/vpx_convolve.c",
"//third_party/libvpx/source/libvpx/vpx_dsp/vpx_dsp_rtcd.c",
+ "//third_party/libvpx/source/libvpx/vpx_dsp/ppc/deblock_vsx.c",
+ "//third_party/libvpx/source/libvpx/vpx_dsp/ppc/fdct32x32_vsx.c",
+ "//third_party/libvpx/source/libvpx/vpx_dsp/ppc/hadamard_vsx.c",
+ "//third_party/libvpx/source/libvpx/vpx_dsp/ppc/intrapred_vsx.c",
+ "//third_party/libvpx/source/libvpx/vpx_dsp/ppc/inv_txfm_vsx.c",
+ "//third_party/libvpx/source/libvpx/vpx_dsp/ppc/quantize_vsx.c",
+ "//third_party/libvpx/source/libvpx/vpx_dsp/ppc/sad_vsx.c",
+ "//third_party/libvpx/source/libvpx/vpx_dsp/ppc/subtract_vsx.c",
+ "//third_party/libvpx/source/libvpx/vpx_dsp/ppc/variance_vsx.c",
+ "//third_party/libvpx/source/libvpx/vpx_dsp/ppc/vpx_convolve_vsx.c",
"//third_party/libvpx/source/libvpx/vpx_mem/vpx_mem.c",
"//third_party/libvpx/source/libvpx/vpx_ports/ppc_cpudetect.c",
"//third_party/libvpx/source/libvpx/vpx_scale/generic/gen_scalers.c",

@ -0,0 +1,43 @@
Index: chromium-120.0.6099.71/third_party/dav1d/config/linux/ppc64/config.h
===================================================================
--- /dev/null
+++ chromium-120.0.6099.71/third_party/dav1d/config/linux/ppc64/config.h
@@ -0,0 +1,38 @@
+/*
+ * Autogenerated by the Meson build system.
+ * Do not edit, your changes will be lost.
+ */
+
+#pragma once
+
+#define ARCH_AARCH64 0
+
+#define ARCH_ARM 0
+
+#define ARCH_PPC64LE 1
+
+#define ARCH_X86 0
+
+#define ARCH_X86_32 0
+
+#define ARCH_X86_64 0
+
+#define CONFIG_16BPC 1
+
+#define CONFIG_8BPC 1
+
+// #define CONFIG_LOG 1 -- Logging is controlled by Chromium
+
+#define ENDIANNESS_BIG 0
+
+#define HAVE_ASM 1
+
+#define HAVE_CLOCK_GETTIME 1
+
+#define HAVE_DLSYM 1
+
+#define HAVE_GETAUXVAL 1
+
+#define HAVE_POSIX_MEMALIGN 1
+
+#define HAVE_UNISTD_H 1

@ -0,0 +1,23 @@
From 298df3dc44f7121cd8cb9a06b29fa3b16c959b8d Mon Sep 17 00:00:00 2001
From: Shawn Anastasio <shawnanastasio@yahoo.com>
Date: Thu, 9 Aug 2018 19:13:25 -0500
Subject: [PATCH 4/4] sandbox/linux/system_headers: Update linux signal header
for ppc64
---
sandbox/linux/system_headers/linux_signal.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Index: chromium-120.0.6099.71/sandbox/linux/system_headers/linux_signal.h
===================================================================
--- chromium-120.0.6099.71.orig/sandbox/linux/system_headers/linux_signal.h
+++ chromium-120.0.6099.71/sandbox/linux/system_headers/linux_signal.h
@@ -13,7 +13,7 @@
// (not undefined, but defined different values and in different memory
// layouts). So, fill the gap here.
#if defined(__i386__) || defined(__x86_64__) || defined(__arm__) || \
- defined(__aarch64__)
+ defined(__aarch64__) || defined(__powerpc64__)
#define LINUX_SIGHUP 1
#define LINUX_SIGINT 2

@ -0,0 +1,17 @@
Index: chromium-120.0.6099.71/third_party/crashpad/crashpad/util/net/http_transport_libcurl.cc
===================================================================
--- chromium-120.0.6099.71.orig/third_party/crashpad/crashpad/util/net/http_transport_libcurl.cc
+++ chromium-120.0.6099.71/third_party/crashpad/crashpad/util/net/http_transport_libcurl.cc
@@ -239,6 +239,12 @@ std::string UserAgent() {
#endif
#elif defined (ARCH_CPU_RISCV64)
static constexpr char arch[] = "riscv64";
+#elif defined(__powerpc64__)
+#if defined(ARCH_CPU_LITTLE_ENDIAN)
+ static constexpr char arch[] = "ppc64";
+#elif defined(ARCH_CPU_BIG_ENDIAN)
+ static constexpr char arch[] = "ppc64_be";
+#endif
#else
#error Port
#endif

@ -0,0 +1,376 @@
Index: chromium-120.0.6099.71/third_party/libvpx/source/libvpx/vp9/encoder/ppc/vp9_quantize_vsx.c
===================================================================
--- chromium-120.0.6099.71.orig/third_party/libvpx/source/libvpx/vp9/encoder/ppc/vp9_quantize_vsx.c
+++ chromium-120.0.6099.71/third_party/libvpx/source/libvpx/vp9/encoder/ppc/vp9_quantize_vsx.c
@@ -38,6 +38,28 @@ static INLINE int16x8_t vec_max_across(i
return vec_max(a, vec_perm(a, a, vec_perm16));
}
+static INLINE void
+vec_u64_store(vector unsigned long long vecu64, unsigned long offset, void *ptr)
+{
+#ifndef WORDS_BIGENDIAN
+ __asm__ ("xxswapd %x0, %x1"
+ : "=wa" (vecu64)
+ : "wa" (vecu64));
+#endif
+#if __GNUC__ >= 4
+ if (__builtin_constant_p (offset) && offset == 0)
+ __asm__ ("stxvd2x %x0,0,%1\n\t"
+ :
+ : "wa" (vecu64), "r" ((uintptr_t)ptr)
+ : "memory");
+ else
+#endif
+ __asm__ ("stxvd2x %x0,%1,%2\n\t"
+ :
+ : "wa" (vecu64), "r" (offset), "r" ((uintptr_t)ptr)
+ : "memory", "r0");
+}
+
void vp9_quantize_fp_vsx(const tran_low_t *coeff_ptr, intptr_t n_coeffs,
const int16_t *round_ptr, const int16_t *quant_ptr,
tran_low_t *qcoeff_ptr, tran_low_t *dqcoeff_ptr,
@@ -60,10 +82,10 @@ void vp9_quantize_fp_vsx(const tran_low_
qcoeff0 = vec_mulhi(vec_vaddshs(vec_abs(coeff0), round), quant);
zero_coeff0 = vec_cmpeq(qcoeff0, vec_zeros_s16);
qcoeff0 = vec_sign(qcoeff0, coeff0);
- vec_vsx_st(qcoeff0, 0, qcoeff_ptr);
+ vec_u64_store(qcoeff0, 0, qcoeff_ptr);
dqcoeff0 = vec_mladd(qcoeff0, dequant, vec_zeros_s16);
- vec_vsx_st(dqcoeff0, 0, dqcoeff_ptr);
+ vec_u64_store(dqcoeff0, 0, dqcoeff_ptr);
// Remove DC value from round and quant
round = vec_splat(round, 1);
@@ -76,10 +98,10 @@ void vp9_quantize_fp_vsx(const tran_low_
qcoeff1 = vec_mulhi(vec_vaddshs(vec_abs(coeff1), round), quant);
zero_coeff1 = vec_cmpeq(qcoeff1, vec_zeros_s16);
qcoeff1 = vec_sign(qcoeff1, coeff1);
- vec_vsx_st(qcoeff1, 16, qcoeff_ptr);
+ vec_u64_store(qcoeff1, 16, qcoeff_ptr);
dqcoeff1 = vec_mladd(qcoeff1, dequant, vec_zeros_s16);
- vec_vsx_st(dqcoeff1, 16, dqcoeff_ptr);
+ vec_u64_store(dqcoeff1, 16, dqcoeff_ptr);
eob = vec_max(vec_or(scan0, zero_coeff0), vec_or(scan1, zero_coeff1));
@@ -107,23 +129,23 @@ void vp9_quantize_fp_vsx(const tran_low_
qcoeff0 = vec_mulhi(vec_vaddshs(vec_abs(coeff0), round), quant);
zero_coeff0 = vec_cmpeq(qcoeff0, vec_zeros_s16);
qcoeff0 = vec_sign(qcoeff0, coeff0);
- vec_vsx_st(qcoeff0, off0, qcoeff_ptr);
+ vec_u64_store(qcoeff0, off0, qcoeff_ptr);
dqcoeff0 = vec_mladd(qcoeff0, dequant, vec_zeros_s16);
- vec_vsx_st(dqcoeff0, off0, dqcoeff_ptr);
+ vec_u64_store(dqcoeff0, off0, dqcoeff_ptr);
qcoeff1 = vec_mulhi(vec_vaddshs(vec_abs(coeff1), round), quant);
zero_coeff1 = vec_cmpeq(qcoeff1, vec_zeros_s16);
qcoeff1 = vec_sign(qcoeff1, coeff1);
- vec_vsx_st(qcoeff1, off1, qcoeff_ptr);
+ vec_u64_store(qcoeff1, off1, qcoeff_ptr);
dqcoeff1 = vec_mladd(qcoeff1, dequant, vec_zeros_s16);
- vec_vsx_st(dqcoeff1, off1, dqcoeff_ptr);
+ vec_u64_store(dqcoeff1, off1, dqcoeff_ptr);
qcoeff2 = vec_mulhi(vec_vaddshs(vec_abs(coeff2), round), quant);
zero_coeff2 = vec_cmpeq(qcoeff2, vec_zeros_s16);
qcoeff2 = vec_sign(qcoeff2, coeff2);
- vec_vsx_st(qcoeff2, off2, qcoeff_ptr);
+ vec_u64_store(qcoeff2, off2, qcoeff_ptr);
dqcoeff2 = vec_mladd(qcoeff2, dequant, vec_zeros_s16);
- vec_vsx_st(dqcoeff2, off2, dqcoeff_ptr);
+ vec_u64_store(dqcoeff2, off2, dqcoeff_ptr);
eob = vec_max(eob, vec_or(scan0, zero_coeff0));
eob2 = vec_max(vec_or(scan1, zero_coeff1), vec_or(scan2, zero_coeff2));
@@ -200,10 +222,10 @@ void vp9_quantize_fp_32x32_vsx(const tra
qcoeff0 = vec_and(qcoeff0, mask0);
zero_coeff0 = vec_cmpeq(qcoeff0, vec_zeros_s16);
qcoeff0 = vec_sign(qcoeff0, coeff0);
- vec_vsx_st(qcoeff0, 0, qcoeff_ptr);
+ vec_u64_store(qcoeff0, 0, qcoeff_ptr);
dqcoeff0 = dequantize_coeff_32(qcoeff0, dequant);
- vec_vsx_st(dqcoeff0, 0, dqcoeff_ptr);
+ vec_u64_store(dqcoeff0, 0, dqcoeff_ptr);
// Remove DC value from thres, round, quant and dequant
thres = vec_splat(thres, 1);
@@ -219,10 +241,10 @@ void vp9_quantize_fp_32x32_vsx(const tra
qcoeff1 = vec_and(qcoeff1, mask1);
zero_coeff1 = vec_cmpeq(qcoeff1, vec_zeros_s16);
qcoeff1 = vec_sign(qcoeff1, coeff1);
- vec_vsx_st(qcoeff1, 16, qcoeff_ptr);
+ vec_u64_store(qcoeff1, 16, qcoeff_ptr);
dqcoeff1 = dequantize_coeff_32(qcoeff1, dequant);
- vec_vsx_st(dqcoeff1, 16, dqcoeff_ptr);
+ vec_u64_store(dqcoeff1, 16, dqcoeff_ptr);
eob = vec_max(vec_or(scan0, zero_coeff0), vec_or(scan1, zero_coeff1));
@@ -260,17 +282,17 @@ void vp9_quantize_fp_32x32_vsx(const tra
qcoeff1 = vec_sign(qcoeff1, coeff1);
qcoeff2 = vec_sign(qcoeff2, coeff2);
- vec_vsx_st(qcoeff0, off0, qcoeff_ptr);
- vec_vsx_st(qcoeff1, off1, qcoeff_ptr);
- vec_vsx_st(qcoeff2, off2, qcoeff_ptr);
+ vec_u64_store(qcoeff0, off0, qcoeff_ptr);
+ vec_u64_store(qcoeff1, off1, qcoeff_ptr);
+ vec_u64_store(qcoeff2, off2, qcoeff_ptr);
dqcoeff0 = dequantize_coeff_32(qcoeff0, dequant);
dqcoeff1 = dequantize_coeff_32(qcoeff1, dequant);
dqcoeff2 = dequantize_coeff_32(qcoeff2, dequant);
- vec_vsx_st(dqcoeff0, off0, dqcoeff_ptr);
- vec_vsx_st(dqcoeff1, off1, dqcoeff_ptr);
- vec_vsx_st(dqcoeff2, off2, dqcoeff_ptr);
+ vec_u64_store(dqcoeff0, off0, dqcoeff_ptr);
+ vec_u64_store(dqcoeff1, off1, dqcoeff_ptr);
+ vec_u64_store(dqcoeff2, off2, dqcoeff_ptr);
eob = vec_max(eob, vec_or(scan0, zero_coeff0));
eob2 = vec_max(vec_or(scan1, zero_coeff1), vec_or(scan2, zero_coeff2));
Index: chromium-120.0.6099.71/third_party/libvpx/source/libvpx/vpx_dsp/ppc/fdct32x32_vsx.c
===================================================================
--- chromium-120.0.6099.71.orig/third_party/libvpx/source/libvpx/vpx_dsp/ppc/fdct32x32_vsx.c
+++ chromium-120.0.6099.71/third_party/libvpx/source/libvpx/vpx_dsp/ppc/fdct32x32_vsx.c
@@ -15,6 +15,28 @@
#include "vpx_dsp/ppc/txfm_common_vsx.h"
#include "vpx_dsp/ppc/types_vsx.h"
+static INLINE void
+vec_u64_store(vector unsigned long long vecu64, unsigned long offset, void *ptr)
+{
+#ifndef WORDS_BIGENDIAN
+ __asm__ ("xxswapd %x0, %x1"
+ : "=wa" (vecu64)
+ : "wa" (vecu64));
+#endif
+#if __GNUC__ >= 4
+ if (__builtin_constant_p (offset) && offset == 0)
+ __asm__ ("stxvd2x %x0,0,%1\n\t"
+ :
+ : "wa" (vecu64), "r" ((uintptr_t)ptr)
+ : "memory");
+ else
+#endif
+ __asm__ ("stxvd2x %x0,%1,%2\n\t"
+ :
+ : "wa" (vecu64), "r" (offset), "r" ((uintptr_t)ptr)
+ : "memory", "r0");
+}
+
// Returns ((a +/- b) * cospi16 + (2 << 13)) >> 14.
static INLINE void single_butterfly(int16x8_t a, int16x8_t b, int16x8_t *add,
int16x8_t *sub) {
@@ -164,45 +186,45 @@ static INLINE void load(const int16_t *a
}
static INLINE void store(tran_low_t *a, const int16x8_t *b) {
- vec_vsx_st(b[0], 0, a);
- vec_vsx_st(b[8], 0, a + 8);
- vec_vsx_st(b[16], 0, a + 16);
- vec_vsx_st(b[24], 0, a + 24);
-
- vec_vsx_st(b[1], 0, a + 32);
- vec_vsx_st(b[9], 0, a + 40);
- vec_vsx_st(b[17], 0, a + 48);
- vec_vsx_st(b[25], 0, a + 56);
-
- vec_vsx_st(b[2], 0, a + 64);
- vec_vsx_st(b[10], 0, a + 72);
- vec_vsx_st(b[18], 0, a + 80);
- vec_vsx_st(b[26], 0, a + 88);
-
- vec_vsx_st(b[3], 0, a + 96);
- vec_vsx_st(b[11], 0, a + 104);
- vec_vsx_st(b[19], 0, a + 112);
- vec_vsx_st(b[27], 0, a + 120);
-
- vec_vsx_st(b[4], 0, a + 128);
- vec_vsx_st(b[12], 0, a + 136);
- vec_vsx_st(b[20], 0, a + 144);
- vec_vsx_st(b[28], 0, a + 152);
-
- vec_vsx_st(b[5], 0, a + 160);
- vec_vsx_st(b[13], 0, a + 168);
- vec_vsx_st(b[21], 0, a + 176);
- vec_vsx_st(b[29], 0, a + 184);
-
- vec_vsx_st(b[6], 0, a + 192);
- vec_vsx_st(b[14], 0, a + 200);
- vec_vsx_st(b[22], 0, a + 208);
- vec_vsx_st(b[30], 0, a + 216);
-
- vec_vsx_st(b[7], 0, a + 224);
- vec_vsx_st(b[15], 0, a + 232);
- vec_vsx_st(b[23], 0, a + 240);
- vec_vsx_st(b[31], 0, a + 248);
+ vec_u64_store(b[0], 0, a);
+ vec_u64_store(b[8], 0, a + 8);
+ vec_u64_store(b[16], 0, a + 16);
+ vec_u64_store(b[24], 0, a + 24);
+
+ vec_u64_store(b[1], 0, a + 32);
+ vec_u64_store(b[9], 0, a + 40);
+ vec_u64_store(b[17], 0, a + 48);
+ vec_u64_store(b[25], 0, a + 56);
+
+ vec_u64_store(b[2], 0, a + 64);
+ vec_u64_store(b[10], 0, a + 72);
+ vec_u64_store(b[18], 0, a + 80);
+ vec_u64_store(b[26], 0, a + 88);
+
+ vec_u64_store(b[3], 0, a + 96);
+ vec_u64_store(b[11], 0, a + 104);
+ vec_u64_store(b[19], 0, a + 112);
+ vec_u64_store(b[27], 0, a + 120);
+
+ vec_u64_store(b[4], 0, a + 128);
+ vec_u64_store(b[12], 0, a + 136);
+ vec_u64_store(b[20], 0, a + 144);
+ vec_u64_store(b[28], 0, a + 152);
+
+ vec_u64_store(b[5], 0, a + 160);
+ vec_u64_store(b[13], 0, a + 168);
+ vec_u64_store(b[21], 0, a + 176);
+ vec_u64_store(b[29], 0, a + 184);
+
+ vec_u64_store(b[6], 0, a + 192);
+ vec_u64_store(b[14], 0, a + 200);
+ vec_u64_store(b[22], 0, a + 208);
+ vec_u64_store(b[30], 0, a + 216);
+
+ vec_u64_store(b[7], 0, a + 224);
+ vec_u64_store(b[15], 0, a + 232);
+ vec_u64_store(b[23], 0, a + 240);
+ vec_u64_store(b[31], 0, a + 248);
}
// Returns 1 if negative 0 if positive
Index: chromium-120.0.6099.71/third_party/libvpx/source/libvpx/vpx_dsp/ppc/quantize_vsx.c
===================================================================
--- chromium-120.0.6099.71.orig/third_party/libvpx/source/libvpx/vpx_dsp/ppc/quantize_vsx.c
+++ chromium-120.0.6099.71/third_party/libvpx/source/libvpx/vpx_dsp/ppc/quantize_vsx.c
@@ -13,6 +13,28 @@
#include "./vpx_dsp_rtcd.h"
#include "vpx_dsp/ppc/types_vsx.h"
+static INLINE void
+vec_u64_store(vector unsigned long long vecu64, unsigned long offset, void *ptr)
+{
+#ifndef WORDS_BIGENDIAN
+ __asm__ ("xxswapd %x0, %x1"
+ : "=wa" (vecu64)
+ : "wa" (vecu64));
+#endif
+#if __GNUC__ >= 4
+ if (__builtin_constant_p (offset) && offset == 0)
+ __asm__ ("stxvd2x %x0,0,%1\n\t"
+ :
+ : "wa" (vecu64), "r" ((uintptr_t)ptr)
+ : "memory");
+ else
+#endif
+ __asm__ ("stxvd2x %x0,%1,%2\n\t"
+ :
+ : "wa" (vecu64), "r" (offset), "r" ((uintptr_t)ptr)
+ : "memory", "r0");
+}
+
// Negate 16-bit integers in a when the corresponding signed 16-bit
// integer in b is negative.
static INLINE int16x8_t vec_sign(int16x8_t a, int16x8_t b) {
@@ -124,19 +146,19 @@ void vpx_quantize_b_vsx(const tran_low_t
qcoeff0 =
quantize_coeff(coeff0, coeff0_abs, round, quant, quant_shift, zero_mask0);
- vec_vsx_st(qcoeff0, 0, qcoeff_ptr);
+ vec_u64_store(qcoeff0, 0, qcoeff_ptr);
round = vec_splat(round, 1);
quant = vec_splat(quant, 1);
quant_shift = vec_splat(quant_shift, 1);
qcoeff1 =
quantize_coeff(coeff1, coeff1_abs, round, quant, quant_shift, zero_mask1);
- vec_vsx_st(qcoeff1, 16, qcoeff_ptr);
+ vec_u64_store(qcoeff1, 16, qcoeff_ptr);
dqcoeff0 = vec_mladd(qcoeff0, dequant, vec_zeros_s16);
- vec_vsx_st(dqcoeff0, 0, dqcoeff_ptr);
+ vec_u64_store(dqcoeff0, 0, dqcoeff_ptr);
dequant = vec_splat(dequant, 1);
dqcoeff1 = vec_mladd(qcoeff1, dequant, vec_zeros_s16);
- vec_vsx_st(dqcoeff1, 16, dqcoeff_ptr);
+ vec_u64_store(dqcoeff1, 16, dqcoeff_ptr);
eob = vec_max(nonzero_scanindex(qcoeff0, iscan_ptr, 0),
nonzero_scanindex(qcoeff1, iscan_ptr, 16));
@@ -164,17 +186,17 @@ void vpx_quantize_b_vsx(const tran_low_t
zero_mask1);
qcoeff2 = quantize_coeff(coeff2, coeff2_abs, round, quant, quant_shift,
zero_mask2);
- vec_vsx_st(qcoeff0, off0, qcoeff_ptr);
- vec_vsx_st(qcoeff1, off1, qcoeff_ptr);
- vec_vsx_st(qcoeff2, off2, qcoeff_ptr);
+ vec_u64_store(qcoeff0, off0, qcoeff_ptr);
+ vec_u64_store(qcoeff1, off1, qcoeff_ptr);
+ vec_u64_store(qcoeff2, off2, qcoeff_ptr);
dqcoeff0 = vec_mladd(qcoeff0, dequant, vec_zeros_s16);
dqcoeff1 = vec_mladd(qcoeff1, dequant, vec_zeros_s16);
dqcoeff2 = vec_mladd(qcoeff2, dequant, vec_zeros_s16);
- vec_vsx_st(dqcoeff0, off0, dqcoeff_ptr);
- vec_vsx_st(dqcoeff1, off1, dqcoeff_ptr);
- vec_vsx_st(dqcoeff2, off2, dqcoeff_ptr);
+ vec_u64_store(dqcoeff0, off0, dqcoeff_ptr);
+ vec_u64_store(dqcoeff1, off1, dqcoeff_ptr);
+ vec_u64_store(dqcoeff2, off2, dqcoeff_ptr);
eob = vec_max(eob, nonzero_scanindex(qcoeff0, iscan_ptr, off0));
eob2 = vec_max(nonzero_scanindex(qcoeff1, iscan_ptr, off1),
@@ -243,12 +265,12 @@ void vpx_quantize_b_32x32_vsx(const tran
qcoeff1 = quantize_coeff_32(coeff1, coeff1_abs, round, quant, quant_shift,
zero_mask1);
- vec_vsx_st(qcoeff0, 0, qcoeff_ptr);
- vec_vsx_st(qcoeff1, 16, qcoeff_ptr);
+ vec_u64_store(qcoeff0, 0, qcoeff_ptr);
+ vec_u64_store(qcoeff1, 16, qcoeff_ptr);
- vec_vsx_st(dequantize_coeff_32(qcoeff0, dequant), 0, dqcoeff_ptr);
+ vec_u64_store(dequantize_coeff_32(qcoeff0, dequant), 0, dqcoeff_ptr);
dequant = vec_splat(dequant, 1); // remove DC from dequant
- vec_vsx_st(dequantize_coeff_32(qcoeff1, dequant), 16, dqcoeff_ptr);
+ vec_u64_store(dequantize_coeff_32(qcoeff1, dequant), 16, dqcoeff_ptr);
eob = vec_max(nonzero_scanindex(qcoeff0, iscan_ptr, 0),
nonzero_scanindex(qcoeff1, iscan_ptr, 16));
@@ -276,13 +298,13 @@ void vpx_quantize_b_32x32_vsx(const tran
qcoeff2 = quantize_coeff_32(coeff2, coeff2_abs, round, quant, quant_shift,
zero_mask2);
- vec_vsx_st(qcoeff0, off0, qcoeff_ptr);
- vec_vsx_st(qcoeff1, off1, qcoeff_ptr);
- vec_vsx_st(qcoeff2, off2, qcoeff_ptr);
-
- vec_vsx_st(dequantize_coeff_32(qcoeff0, dequant), off0, dqcoeff_ptr);
- vec_vsx_st(dequantize_coeff_32(qcoeff1, dequant), off1, dqcoeff_ptr);
- vec_vsx_st(dequantize_coeff_32(qcoeff2, dequant), off2, dqcoeff_ptr);
+ vec_u64_store(qcoeff0, off0, qcoeff_ptr);
+ vec_u64_store(qcoeff1, off1, qcoeff_ptr);
+ vec_u64_store(qcoeff2, off2, qcoeff_ptr);
+
+ vec_u64_store(dequantize_coeff_32(qcoeff0, dequant), off0, dqcoeff_ptr);
+ vec_u64_store(dequantize_coeff_32(qcoeff1, dequant), off1, dqcoeff_ptr);
+ vec_u64_store(dequantize_coeff_32(qcoeff2, dequant), off2, dqcoeff_ptr);
eob = vec_max(eob, nonzero_scanindex(qcoeff0, iscan_ptr, off0));
eob2 = vec_max(nonzero_scanindex(qcoeff1, iscan_ptr, off1),

@ -0,0 +1,107 @@
From 1d44643a7c7cf650efd1093d22cd5bf859fdcb51 Mon Sep 17 00:00:00 2001
From: Shawn Anastasio <shawnanastasio@yahoo.com>
Date: Thu, 9 Aug 2018 20:52:13 -0500
Subject: [PATCH] sandbox/linux/seccomp-bpf: Add ppc64 syscall stub
---
sandbox/linux/seccomp-bpf/syscall.cc | 53 ++++++++++++++++++++++++++--
1 file changed, 51 insertions(+), 2 deletions(-)
Index: chromium-120.0.6099.71/sandbox/linux/seccomp-bpf/syscall.cc
===================================================================
--- chromium-120.0.6099.71.orig/sandbox/linux/seccomp-bpf/syscall.cc
+++ chromium-120.0.6099.71/sandbox/linux/seccomp-bpf/syscall.cc
@@ -18,7 +18,7 @@ namespace sandbox {
namespace {
#if defined(ARCH_CPU_X86_FAMILY) || defined(ARCH_CPU_ARM_FAMILY) || \
- defined(ARCH_CPU_MIPS_FAMILY)
+ defined(ARCH_CPU_MIPS_FAMILY) || defined (ARCH_CPU_PPC64_FAMILY)
// Number that's not currently used by any Linux kernel ABIs.
const int kInvalidSyscallNumber = 0x351d3;
#else
@@ -308,10 +308,54 @@ asm(// We need to be able to tell the ke
"2:ret\n"
".cfi_endproc\n"
".size SyscallAsm, .-SyscallAsm\n"
+#elif defined(__powerpc64__)
+ ".text\n"
+ ".align 4\n"
+ ".type SyscallAsm @function\n"
+ "SyscallAsm:\n"
+ ".cfi_startproc\n"
+
+ // Check if r3 is negative
+ "cmpdi 3, 0\n"
+ "bgt 2f\n"
+
+ // Load address of 3f into r3 and return
+ "mflr 10\n"
+ "bl 1f\n"
+ "1: mflr 3\n"
+ "mtlr 10\n"
+ "addi 3, 3, 4*13\n"
+ "blr\n"
+
+ // Load arguments from array into r3-8
+ // save param 3 in r10
+ "2:\n"
+ "mr 0, 3\n"
+ "ld 3, 0(4)\n"
+ "ld 5, 16(4)\n"
+ "ld 6, 24(4)\n"
+ "ld 7, 32(4)\n"
+ "ld 8, 40(4)\n"
+ "ld 4, 8(4)\n"
+ "li 9, 0\n"
+
+ // Enter kernel
+ "sc\n"
+
+ // Magic return address
+ "3:\n"
+ // Like MIPS, ppc64 return values are always positive.
+ // Check for error in cr0.SO and negate upon error
+ "bc 4, 3, 4f\n"
+ "neg 3, 3\n"
+ "4: blr\n"
+
+ ".cfi_endproc\n"
+ ".size SyscallAsm, .-SyscallAsm\n"
#endif
); // asm
-#if defined(__x86_64__)
+#if defined(__x86_64__) || defined(__powerpc64__)
extern "C" {
intptr_t SyscallAsm(intptr_t nr, const intptr_t args[6]);
}
@@ -425,6 +469,8 @@ intptr_t Syscall::Call(int nr,
ret = inout;
}
+#elif defined(__powerpc64__)
+ intptr_t ret = SyscallAsm(nr, args);
#else
#error "Unimplemented architecture"
#endif
@@ -441,8 +487,18 @@ void Syscall::PutValueInUcontext(intptr_
// needs to be changed back.
ret_val = -ret_val;
SECCOMP_PARM4(ctx) = 1;
- } else
+ } else {
SECCOMP_PARM4(ctx) = 0;
+ }
+#endif
+#if defined(__powerpc64__)
+ // Same as MIPS, need to invert ret and set error register (cr0.SO)
+ if (ret_val <= -1 && ret_val >= -4095) {
+ ret_val = -ret_val;
+ ctx->uc_mcontext.regs->ccr |= (1 << 28);
+ } else {
+ ctx->uc_mcontext.regs->ccr &= ~(1 << 28);
+ }
#endif
SECCOMP_RESULT(ctx) = static_cast<greg_t>(ret_val);
}

@ -0,0 +1,24 @@
From 6a852c4135864ba87b3cbdd0880d7cfecf7cd654 Mon Sep 17 00:00:00 2001
From: Shawn Anastasio <shawnanastasio@yahoo.com>
Date: Thu, 13 Sep 2018 15:12:22 -0500
Subject: [PATCH 5/6] sandbox/linux: update unit test for ppc64
---
sandbox/linux/seccomp-bpf-helpers/baseline_policy_unittest.cc | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Index: chromium-120.0.6099.71/sandbox/linux/seccomp-bpf-helpers/baseline_policy_unittest.cc
===================================================================
--- chromium-120.0.6099.71.orig/sandbox/linux/seccomp-bpf-helpers/baseline_policy_unittest.cc
+++ chromium-120.0.6099.71/sandbox/linux/seccomp-bpf-helpers/baseline_policy_unittest.cc
@@ -331,8 +331,10 @@ TEST_BASELINE_SIGSYS(__NR_timer_create)
#if !defined(__aarch64__)
TEST_BASELINE_SIGSYS(__NR_inotify_init)
+#if !defined(__powerpc64__)
TEST_BASELINE_SIGSYS(__NR_vserver)
#endif
+#endif
#if defined(LIBC_GLIBC) && !BUILDFLAG(IS_CHROMEOS_ASH)
BPF_TEST_C(BaselinePolicy, FutexEINVAL, BaselinePolicy) {

@ -0,0 +1,14 @@
Index: chromium-120.0.6099.71/sandbox/linux/seccomp-bpf-helpers/syscall_sets.cc
===================================================================
--- chromium-120.0.6099.71.orig/sandbox/linux/seccomp-bpf-helpers/syscall_sets.cc
+++ chromium-120.0.6099.71/sandbox/linux/seccomp-bpf-helpers/syscall_sets.cc
@@ -374,7 +374,9 @@ bool SyscallSets::IsAllowedSignalHandlin
#if defined(__i386__) || defined(__arm__) || \
(defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_32_BITS)) || \
defined(__powerpc64__)
+#if !defined(__powerpc64__)
case __NR_rt_sigtimedwait_time64:
+#endif
case __NR_sigaction:
case __NR_sigprocmask:
case __NR_sigreturn:

@ -0,0 +1,33 @@
Index: chromium-120.0.6099.71/sandbox/linux/system_headers/linux_stat.h
===================================================================
--- chromium-120.0.6099.71.orig/sandbox/linux/system_headers/linux_stat.h
+++ chromium-120.0.6099.71/sandbox/linux/system_headers/linux_stat.h
@@ -173,6 +173,28 @@ struct kernel_stat {
unsigned int __unused4;
unsigned int __unused5;
};
+#elif defined(__powerpc64__)
+struct kernel_stat {
+ unsigned long st_dev;
+ ino_t st_ino;
+ unsigned long st_nlink;
+ mode_t st_mode;
+ uid_t st_uid;
+ gid_t st_gid;
+ unsigned long st_rdev;
+ long st_size;
+ unsigned long st_blksize;
+ unsigned long st_blocks;
+ // unsigned long st_atime;
+ unsigned long st_atime_nsec;
+ //unsigned long st_mtime;
+ unsigned long st_mtime_nsec;
+ //unsigned long st_ctime;
+ unsigned long st_ctime_nsec;
+ unsigned long __unused4;
+ unsigned long __unused5;
+ unsigned long __unused6;
+};
#endif
#if !defined(AT_EMPTY_PATH)

@ -0,0 +1,91 @@
Index: chromium-120.0.6099.71/sandbox/policy/linux/bpf_utility_policy_linux.cc
===================================================================
--- chromium-120.0.6099.71.orig/sandbox/policy/linux/bpf_utility_policy_linux.cc
+++ chromium-120.0.6099.71/sandbox/policy/linux/bpf_utility_policy_linux.cc
@@ -34,7 +34,7 @@ ResultExpr UtilityProcessPolicy::Evaluat
case __NR_fdatasync:
case __NR_fsync:
#if defined(__i386__) || defined(__x86_64__) || defined(__mips__) || \
- defined(__aarch64__)
+ defined(__aarch64__) || defined(__powerpc64__)
case __NR_getrlimit:
#endif
#if defined(__i386__) || defined(__arm__)
Index: chromium-120.0.6099.71/sandbox/policy/linux/bpf_renderer_policy_linux.cc
===================================================================
--- chromium-120.0.6099.71.orig/sandbox/policy/linux/bpf_renderer_policy_linux.cc
+++ chromium-120.0.6099.71/sandbox/policy/linux/bpf_renderer_policy_linux.cc
@@ -87,7 +87,7 @@ ResultExpr RendererProcessPolicy::Evalua
case __NR_ftruncate64:
#endif
#if defined(__i386__) || defined(__x86_64__) || defined(__mips__) || \
- defined(__aarch64__)
+ defined(__aarch64__) || defined(__powerpc64__)
case __NR_getrlimit:
case __NR_setrlimit:
// We allow setrlimit to dynamically adjust the address space limit as
Index: chromium-120.0.6099.71/sandbox/linux/bpf_dsl/linux_syscall_ranges.h
===================================================================
--- chromium-120.0.6099.71.orig/sandbox/linux/bpf_dsl/linux_syscall_ranges.h
+++ chromium-120.0.6099.71/sandbox/linux/bpf_dsl/linux_syscall_ranges.h
@@ -58,9 +58,9 @@
#elif defined(__powerpc64__)
-#include <asm/unistd.h>
+#include <asm-generic/unistd.h>
#define MIN_SYSCALL 0u
-#define MAX_PUBLIC_SYSCALL 386u
+#define MAX_PUBLIC_SYSCALL __NR_syscalls
#define MAX_SYSCALL MAX_PUBLIC_SYSCALL
#else
Index: chromium-120.0.6099.71/sandbox/linux/services/credentials.cc
===================================================================
--- chromium-120.0.6099.71.orig/sandbox/linux/services/credentials.cc
+++ chromium-120.0.6099.71/sandbox/linux/services/credentials.cc
@@ -89,7 +89,9 @@ bool ChrootToSafeEmptyDir() {
int clone_flags = CLONE_FS | LINUX_SIGCHLD;
void* tls = nullptr;
-#if (defined(ARCH_CPU_X86_64) || defined(ARCH_CPU_ARM_FAMILY)) && \
+// RAJA this might be it...
+#if (defined(ARCH_CPU_X86_64) || defined(ARCH_CPU_ARM_FAMILY) || \
+ defined(ARCH_CPU_PPC64_FAMILY)) && \
!defined(MEMORY_SANITIZER)
// Use CLONE_VM | CLONE_VFORK as an optimization to avoid copying page tables.
// Since clone writes to the new child's TLS before returning, we must set a
@@ -97,6 +99,11 @@ bool ChrootToSafeEmptyDir() {
// glibc performs syscalls by calling a function pointer in TLS, so we do not
// attempt this optimization.
// TODO(crbug.com/1247458) Broken in MSan builds after LLVM f1bb30a4956f.
+ //
+ // NOTE: Without CLONE_VM, fontconfig will attempt to reload configuration
+ // in every thread. Since the rendered threads are sandboxed without
+ // filesystem access (e.g. to /etc/fonts/fonts.conf) this will cause font
+ // configuraiton loading failures and no fonts will be displayed!
clone_flags |= CLONE_VM | CLONE_VFORK | CLONE_SETTLS;
// PTHREAD_STACK_MIN can be dynamic in glibc2.34+, so it is not possible to
Index: chromium-120.0.6099.71/sandbox/linux/seccomp-bpf-helpers/sigsys_handlers.cc
===================================================================
--- chromium-120.0.6099.71.orig/sandbox/linux/seccomp-bpf-helpers/sigsys_handlers.cc
+++ chromium-120.0.6099.71/sandbox/linux/seccomp-bpf-helpers/sigsys_handlers.cc
@@ -357,7 +357,16 @@ intptr_t SIGSYSFstatatHandler(const stru
if (args.nr == __NR_fstatat_default) {
if (*reinterpret_cast<const char*>(args.args[1]) == '\0' &&
args.args[3] == static_cast<uint64_t>(AT_EMPTY_PATH)) {
- return syscall(__NR_fstat_default, static_cast<int>(args.args[0]),
+ int fd = static_cast<int>(args.args[0]);
+#if defined(__powerpc64__)
+ // On ppc64+glibc, some syscalls seem to accidentally negate the first
+ // parameter which causes checks against it to fail. For now, manually
+ // negate them back.
+ // TODO: Investigate the root cause and fix in glibc
+ if (fd < 0)
+ fd = -fd;
+#endif
+ return syscall(__NR_fstat_default, fd,
reinterpret_cast<default_stat_struct*>(args.args[2]));
}
return -reinterpret_cast<intptr_t>(fs_denied_errno);

@ -0,0 +1,13 @@
Index: chromium-120.0.6099.71/third_party/skia/src/core/SkRasterPipeline.h
===================================================================
--- chromium-120.0.6099.71.orig/third_party/skia/src/core/SkRasterPipeline.h
+++ chromium-120.0.6099.71/third_party/skia/src/core/SkRasterPipeline.h
@@ -24,7 +24,7 @@ enum SkColorType : int;
struct SkImageInfo;
struct skcms_TransferFunction;
-#if __has_cpp_attribute(clang::musttail) && !defined(__EMSCRIPTEN__) && !defined(SK_CPU_ARM32)
+#if __has_cpp_attribute(clang::musttail) && !defined(__EMSCRIPTEN__) && !defined(SK_CPU_ARM32) && !defined(__powerpc64__)
#define SK_HAS_MUSTTAIL 1
#else
#define SK_HAS_MUSTTAIL 0

@ -0,0 +1,48 @@
Index: chromium-120.0.6099.71/third_party/libvpx/generate_gni.sh
===================================================================
--- chromium-120.0.6099.71.orig/third_party/libvpx/generate_gni.sh
+++ chromium-120.0.6099.71/third_party/libvpx/generate_gni.sh
@@ -411,7 +411,7 @@ gen_config_files linux/mipsel "--target=
gen_config_files linux/mips64el "--target=mips64-linux-gcc ${all_platforms}"
gen_config_files linux/loongarch \
"--target=loongarch64-linux-gcc ${all_platforms}"
-gen_config_files linux/ppc64 "--target=ppc64le-linux-gcc ${all_platforms}"
+gen_config_files linux/ppc64 "--target=generic-gnu $HIGHBD ${all_platforms}"
gen_config_files linux/generic "--target=generic-gnu $HIGHBD ${all_platforms}"
gen_config_files win/arm64-highbd \
"--target=arm64-win64-vs15 ${all_platforms} ${HIGHBD}"
Index: chromium-120.0.6099.71/third_party/libvpx/source/libvpx/build/make/rtcd.pl
===================================================================
--- chromium-120.0.6099.71.orig/third_party/libvpx/source/libvpx/build/make/rtcd.pl
+++ chromium-120.0.6099.71/third_party/libvpx/source/libvpx/build/make/rtcd.pl
@@ -492,8 +492,9 @@ if ($opts{arch} eq 'x86') {
&require(@REQUIRES);
arm;
} elsif ($opts{arch} =~ /^ppc/ ) {
- @ALL_ARCHS = filter(qw/vsx/);
- ppc;
+ #@ALL_ARCHS = filter(qw/vsx/);
+ #ppc;
+ unoptimized;
} elsif ($opts{arch} =~ /loongarch/ ) {
@ALL_ARCHS = filter(qw/lsx lasx/);
loongarch;
Index: chromium-120.0.6099.71/third_party/libvpx/BUILD.gn
===================================================================
--- chromium-120.0.6099.71.orig/third_party/libvpx/BUILD.gn
+++ chromium-120.0.6099.71/third_party/libvpx/BUILD.gn
@@ -93,6 +93,14 @@ config("libvpx_config") {
"-Wno-sign-compare",
]
}
+
+ if (current_cpu == "ppc64") {
+ cflags += [
+ "-mcpu=power8",
+ "-maltivec",
+ "-mvsx",
+ ]
+ }
}
# This config is applied to targets that depend on libvpx.

@ -0,0 +1,23 @@
Index: chromium-120.0.6099.71/third_party/webrtc/rtc_base/system/arch.h
===================================================================
--- chromium-120.0.6099.71.orig/third_party/webrtc/rtc_base/system/arch.h
+++ chromium-120.0.6099.71/third_party/webrtc/rtc_base/system/arch.h
@@ -46,6 +46,18 @@
#endif
#if defined(__MIPSEL__)
#define WEBRTC_ARCH_LITTLE_ENDIAN
+#elif defined(__PPC__)
+#define WEBRTC_ARCH_PPC_FAMILY
+#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
+#define WEBRTC_ARCH_LITTLE_ENDIAN
+#else
+#define WEBRTC_ARCH_BIG_ENDIAN
+#endif
+#if defined(__LP64__)
+#define WEBRTC_ARCH_64_BITS
+#else
+#define WEBRTC_ARCH_32_BITS
+#endif
#else
#define WEBRTC_ARCH_BIG_ENDIAN
#endif

@ -0,0 +1,13 @@
Index: chromium-120.0.6099.71/sandbox/linux/services/credentials.cc
===================================================================
--- chromium-120.0.6099.71.orig/sandbox/linux/services/credentials.cc
+++ chromium-120.0.6099.71/sandbox/linux/services/credentials.cc
@@ -80,7 +80,7 @@ bool ChrootToSafeEmptyDir() {
pid_t pid = -1;
alignas(16) char stack_buf[PTHREAD_STACK_MIN];
#if defined(ARCH_CPU_X86_FAMILY) || defined(ARCH_CPU_ARM_FAMILY) || \
- defined(ARCH_CPU_MIPS_FAMILY)
+ defined(ARCH_CPU_MIPS_FAMILY) || defined(ARCH_CPU_PPC64_FAMILY)
// The stack grows downward.
void* stack = stack_buf + sizeof(stack_buf);
#else

@ -0,0 +1,19 @@
Index: chromium-120.0.6099.71/third_party/dawn/src/dawn/common/Platform.h
===================================================================
--- chromium-120.0.6099.71.orig/third_party/dawn/src/dawn/common/Platform.h
+++ chromium-120.0.6099.71/third_party/dawn/src/dawn/common/Platform.h
@@ -158,10 +158,12 @@
#elif defined(__s390x__)
#define DAWN_PLATFORM_IS_S390X 1
-#elif defined(__PPC__)
-#define DAWN_PLATFORM_IS_PPC 1
+// Order matters here
+// PPC64 also defines PPC, which can lead to detection failures on ppc64le systems
#elif defined(__PPC64__)
#define DAWN_PLATFORM_IS_PPC64 1
+#elif defined(__PPC__)
+#define DAWN_PLATFORM_IS_PPC 1
#else
#error "Unsupported platform."

@ -0,0 +1,32 @@
Index: chromium-120.0.6099.71/third_party/dawn/src/dawn/common/Platform.h
===================================================================
--- chromium-120.0.6099.71.orig/third_party/dawn/src/dawn/common/Platform.h
+++ chromium-120.0.6099.71/third_party/dawn/src/dawn/common/Platform.h
@@ -153,9 +153,9 @@
#define DAWN_PLATFORM_IS_MIPS64 1
#endif
-#elif defiend(__s390__)
+#elif defined(__s390__)
#define DAWN_PLATFORM_IS_S390 1
-#elif defiend(__s390x__)
+#elif defined(__s390x__)
#define DAWN_PLATFORM_IS_S390X 1
#elif defined(__PPC__)
Index: chromium-120.0.6099.71/third_party/dawn/src/dawn/common/Assert.cpp
===================================================================
--- chromium-120.0.6099.71.orig/third_party/dawn/src/dawn/common/Assert.cpp
+++ chromium-120.0.6099.71/third_party/dawn/src/dawn/common/Assert.cpp
@@ -52,9 +52,9 @@ void BreakPoint() {
__asm__ __volatile__("ebreak");
#elif DAWN_PLATFORM_IS(MIPS)
__asm__ __volatile__("break");
-#elif DAWN_PLATFORM_IS(S390) || DAWN_PLATFORM_IS_(S390X)
+#elif DAWN_PLATFORM_IS(S390) || DAWN_PLATFORM_IS(S390X)
__asm__ __volatile__(".word 0x0001");
-#elif DAWN_PLATFORM_IS(PPC) || DAWN_PLATFORM_IS_(PPC64)
+#elif DAWN_PLATFORM_IS(PPC) || DAWN_PLATFORM_IS(PPC64)
__asm__ __volatile__("twge 2,2");
#else
#error "Unsupported platform"

@ -0,0 +1,29 @@
Index: chromium-120.0.6099.71/third_party/breakpad/BUILD.gn
===================================================================
--- chromium-120.0.6099.71.orig/third_party/breakpad/BUILD.gn
+++ chromium-120.0.6099.71/third_party/breakpad/BUILD.gn
@@ -618,7 +618,6 @@ if (is_linux || is_chromeos || is_androi
"breakpad/src/client/minidump_file_writer.h",
"breakpad/src/common/convert_UTF.cc",
"breakpad/src/common/convert_UTF.h",
- "breakpad/src/common/linux/breakpad_getcontext.S",
"breakpad/src/common/linux/elf_core_dump.cc",
"breakpad/src/common/linux/elf_core_dump.h",
"breakpad/src/common/linux/elfutils.cc",
@@ -650,6 +649,8 @@ if (is_linux || is_chromeos || is_androi
configs += [ "//build/config/compiler:no_chromium_code" ]
public_configs = [ ":client_config" ]
+ defines = [ "HAVE_GETCONTEXT" ]
+
if (current_cpu == "arm" && is_chromeos_ash) {
# Avoid running out of registers in
# linux_syscall_support.h:sys_clone()'s inline assembly.
@@ -707,7 +708,6 @@ if (is_linux || is_chromeos || is_androi
"breakpad/src/client/linux/minidump_writer/minidump_writer_unittest.cc",
"breakpad/src/client/linux/minidump_writer/minidump_writer_unittest_utils.cc",
"breakpad/src/client/linux/minidump_writer/proc_cpuinfo_reader_unittest.cc",
- "breakpad/src/common/linux/breakpad_getcontext_unittest.cc",
"breakpad/src/common/linux/elf_core_dump_unittest.cc",
"breakpad/src/common/linux/file_id_unittest.cc",
"breakpad/src/common/linux/linux_libc_support_unittest.cc",

@ -0,0 +1,16 @@
kIndex: chromium-114.0.5735.45/base/allocator/partition_allocator/partition_alloc.gni
===================================================================
Index: chromium-120.0.6099.71/base/allocator/partition_allocator/partition_alloc.gni
===================================================================
--- chromium-120.0.6099.71.orig/base/allocator/partition_allocator/partition_alloc.gni
+++ chromium-120.0.6099.71/base/allocator/partition_allocator/partition_alloc.gni
@@ -16,7 +16,8 @@ if (is_nacl) {
# NaCl targets don't use 64-bit pointers.
has_64_bit_pointers = false
} else if (current_cpu == "x64" || current_cpu == "arm64" ||
- current_cpu == "loong64" || current_cpu == "riscv64") {
+ current_cpu == "loong64" || current_cpu == "riscv64" ||
+ current_cpu == "ppc64") {
has_64_bit_pointers = true
} else if (current_cpu == "x86" || current_cpu == "arm") {
has_64_bit_pointers = false

@ -0,0 +1,23 @@
Index: chromium-120.0.6099.71/sandbox/linux/system_headers/ppc64_linux_syscalls.h
===================================================================
--- chromium-120.0.6099.71.orig/sandbox/linux/system_headers/ppc64_linux_syscalls.h
+++ chromium-120.0.6099.71/sandbox/linux/system_headers/ppc64_linux_syscalls.h
@@ -8,5 +8,18 @@
#include <asm/unistd.h>
//TODO: is it necessary to redefine syscall numbers for PPC64?
+// Needed for Ubuntu/Debian/Centos/RHEL:
+#if !defined(__NR_shmget)
+#define __NR_shmget 395
+#endif
+#if !defined(__NR_shmdt)
+#define __NR_shmdt 398
+#endif
+#if !defined(__NR_shmctl)
+#define __NR_shmctl 396
+#endif
+#if !defined(__NR_shmat)
+#define __NR_shmat 397
+#endif
#endif // SANDBOX_LINUX_SYSTEM_HEADERS_PPC64_LINUX_SYSCALLS_H_

@ -0,0 +1,49 @@
Index: chromium-121.0.6167.75/build/toolchain/gcc_toolchain.gni
===================================================================
--- chromium-121.0.6167.75.orig/build/toolchain/gcc_toolchain.gni
+++ chromium-121.0.6167.75/build/toolchain/gcc_toolchain.gni
@@ -464,7 +464,13 @@ template("single_gcc_toolchain") {
# -soname flag is not available on aix ld
soname_flag = "-Wl,-soname=\"$soname\""
}
- link_command = "$ld -shared $soname_flag {{ldflags}}${extra_ldflags} -o \"$unstripped_sofile\" @\"$rspfile\" {{rlibs}}"
+ if (target_cpu == "ppc64") {
+ # Work around linker failures due to Rust libraries and the use of whole-archive
+ link_command = "$ld -shared $soname_flag -Wl,--start-group {{ldflags}}${extra_ldflags} -o \"$unstripped_sofile\" @\"$rspfile\" {{rlibs}} -Wl,--end-group"
+ }
+ else {
+ link_command = "$ld -shared $soname_flag {{ldflags}}${extra_ldflags} -o \"$unstripped_sofile\" @\"$rspfile\" {{rlibs}}"
+ }
# Generate a map file to be used for binary size analysis.
# Map file adds ~10% to the link time on a z620.
@@ -576,7 +582,13 @@ template("single_gcc_toolchain") {
whole_archive_flag = "-Wl,--whole-archive"
no_whole_archive_flag = "-Wl,--no-whole-archive"
}
- command = "$ld -shared {{ldflags}}${extra_ldflags} -o \"$unstripped_sofile\" $soname_flag @\"$rspfile\""
+ if (target_cpu == "ppc64") {
+ # Work around linker failures due to Rust libraries and the use of whole-archive
+ command = "$ld -shared -Wl,--start-group {{ldflags}}${extra_ldflags} -o \"$unstripped_sofile\" $soname_flag @\"$rspfile\" -Wl,--end-group"
+ }
+ else {
+ command = "$ld -shared {{ldflags}}${extra_ldflags} -o \"$unstripped_sofile\" $soname_flag @\"$rspfile\""
+ }
if (defined(invoker.strip)) {
strip_command = "${invoker.strip} -o \"$sofile\" \"$unstripped_sofile\""
@@ -636,7 +648,13 @@ template("single_gcc_toolchain") {
start_group_flag = "-Wl,--start-group"
end_group_flag = "-Wl,--end-group "
}
- link_command = "$ld {{ldflags}}${extra_ldflags} -o \"$unstripped_outfile\" $start_group_flag @\"$rspfile\" {{solibs}} $end_group_flag {{libs}} {{rlibs}}"
+ if (target_cpu == "ppc64") {
+ # Work around linker failures due to Rust libraries and the use of whole-archive
+ link_command = "$ld -Wl,--start-group {{ldflags}}${extra_ldflags} -o \"$unstripped_outfile\" @\"$rspfile\" {{solibs}} {{libs}} {{rlibs}} -Wl,--end-group"
+ }
+ else {
+ link_command = "$ld {{ldflags}}${extra_ldflags} -o \"$unstripped_outfile\" $start_group_flag @\"$rspfile\" {{solibs}} $end_group_flag {{libs}} {{rlibs}}"
+ }
# Generate a map file to be used for binary size analysis.
# Map file adds ~10% to the link time on a z620.

@ -0,0 +1,13 @@
author: Andres Salomon <dilinger@debian.org>
description: allow ppc64le to build by using proper rustc target
--- a/build/config/rust.gni
+++ b/build/config/rust.gni
@@ -191,6 +191,8 @@ rust_abi_target = ""
if (is_linux || is_chromeos) {
if (current_cpu == "arm64") {
rust_abi_target = "aarch64-unknown-linux-gnu"
+ } else if (current_cpu == "ppc64") {
+ rust_abi_target = "powerpc64le-unknown-linux-gnu"
} else if (current_cpu == "x86") {
rust_abi_target = "i686-unknown-linux-gnu"
} else if (current_cpu == "x64") {

@ -0,0 +1,26 @@
--- chromium-101.0.4951.54/third_party/swiftshader/third_party/llvm-10.0/BUILD.gn.orig 2022-05-15 10:30:50.887333316 +0200
+++ chromium-101.0.4951.54/third_party/swiftshader/third_party/llvm-10.0/BUILD.gn 2022-05-15 10:31:43.477318032 +0200
@@ -133,7 +133,6 @@ swiftshader_llvm_source_set("swiftshader_llvm") {
if (is_ubsan_vptr) {
sources = [
"llvm/lib/MC/MCWasmObjectTargetWriter.cpp",
- "llvm/lib/MC/MCXCOFFObjectTargetWriter.cpp",
"llvm/lib/Target/ARM/MCTargetDesc/ARMTargetStreamer.cpp",
"llvm/lib/Target/TargetIntrinsicInfo.cpp",
]
@@ -583,6 +582,7 @@ swiftshader_llvm_source_set("swiftshader_llvm_most") {
"llvm/lib/MC/MCAsmInfoCOFF.cpp",
"llvm/lib/MC/MCAsmInfoDarwin.cpp",
"llvm/lib/MC/MCAsmInfoELF.cpp",
+ "llvm/lib/MC/MCAsmInfoXCOFF.cpp",
"llvm/lib/MC/MCAsmMacro.cpp",
"llvm/lib/MC/MCAsmStreamer.cpp",
"llvm/lib/MC/MCAssembler.cpp",
@@ -637,6 +637,7 @@ swiftshader_llvm_source_set("swiftshader_llvm_most") {
"llvm/lib/MC/MCWin64EH.cpp",
"llvm/lib/MC/MCWinCOFFStreamer.cpp",
"llvm/lib/MC/MCWinEH.cpp",
+ "llvm/lib/MC/MCXCOFFObjectTargetWriter.cpp",
"llvm/lib/MC/MCXCOFFStreamer.cpp",
"llvm/lib/MC/MachObjectWriter.cpp",
"llvm/lib/MC/StringTableBuilder.cpp",

@ -0,0 +1,35 @@
Index: chromium-120.0.6099.71/build/config/compiler/BUILD.gn
===================================================================
--- chromium-120.0.6099.71.orig/build/config/compiler/BUILD.gn
+++ chromium-120.0.6099.71/build/config/compiler/BUILD.gn
@@ -1780,7 +1780,7 @@ config("default_warnings") {
# -Wno-class-memaccess warns about hash table and vector in blink.
# But the violation is intentional.
- if (!is_nacl) {
+ if ((!is_nacl) && (current_cpu != "ppc64")) {
cflags_cc += [ "-Wno-class-memaccess" ]
}
@@ -1790,7 +1790,9 @@ config("default_warnings") {
# Don't warn about "maybe" uninitialized. Clang doesn't include this
# in -Wall but gcc does, and it gives false positives.
- cflags += [ "-Wno-maybe-uninitialized" ]
+ if (current_cpu != "ppc64") {
+ cflags += [ "-Wno-maybe-uninitialized" ]
+ }
cflags += [ "-Wno-deprecated-declarations" ]
# -Wcomment gives too many false positives in the case a
@@ -1801,7 +1803,9 @@ config("default_warnings") {
# -Wpacked-not-aligned complains all generated mojom-shared-internal.h
# files.
- cflags += [ "-Wno-packed-not-aligned" ]
+ if (current_cpu != "ppc64") {
+ cflags += [ "-Wno-packed-not-aligned" ]
+ }
}
}

@ -0,0 +1,675 @@
Index: chromium-122.0.6261.57/third_party/skia/BUILD.gn
===================================================================
--- chromium-122.0.6261.57.orig/third_party/skia/BUILD.gn
+++ chromium-122.0.6261.57/third_party/skia/BUILD.gn
@@ -198,6 +198,12 @@ opts("skx") {
}
}
+opts("vsx") {
+ enabled = current_cpu == "ppc64"
+ sources = skia_opts.vsx_sources
+ cflags = [ "-mcpu=power9", "-mtune=power9" ]
+}
+
# Any feature of Skia that requires third-party code should be optional and use this template.
template("optional") {
if (invoker.enabled) {
@@ -1467,6 +1473,7 @@ skia_component("skia") {
":skx",
":typeface_fontations",
":vello",
+ ":vsx",
":webp_decode",
":wuffs",
":xml",
@@ -1644,7 +1651,10 @@ skia_static_library("pathkit") {
public_configs = [ ":skia_public" ]
configs = skia_library_configs
- deps = [ ":hsw" ]
+ deps = [
+ ":hsw",
+ ":vsx",
+ ]
sources = []
sources += skia_pathops_sources
Index: chromium-122.0.6261.57/third_party/skia/gn/skia/BUILD.gn
===================================================================
--- chromium-122.0.6261.57.orig/third_party/skia/gn/skia/BUILD.gn
+++ chromium-122.0.6261.57/third_party/skia/gn/skia/BUILD.gn
@@ -163,6 +163,8 @@ config("default") {
"-mfpmath=sse",
]
ldflags += [ "-m32" ]
+ } else if (current_cpu == "ppc64") {
+ cflags += [ "-mcpu=power9", "-mtune=power9" ]
}
if (malloc != "" && !is_win) {
Index: chromium-122.0.6261.57/third_party/skia/include/core/SkTypes.h
===================================================================
--- chromium-122.0.6261.57.orig/third_party/skia/include/core/SkTypes.h
+++ chromium-122.0.6261.57/third_party/skia/include/core/SkTypes.h
@@ -195,5 +195,44 @@ static constexpr uint32_t SK_InvalidGenI
*/
static constexpr uint32_t SK_InvalidUniqueID = 0;
+//////////////////////////////////////////////////////////////////////
+// PPC defines
+
+#if defined(__powerpc64__) || defined(__PPC64__)
+ #ifndef SK_CPU_PPC64
+ #define SK_CPU_PPC64
+ #endif
+ #undef SK_CPU_SSE_LEVEL
+#endif
+
+// Newer versions of clang and gcc for ppc64 ship with wrappers that translate
+// Intel vector intrinsics into PPC VSX instrinsics, so we can pretend to have
+// to be Intel. Currently, full API support for SSSE3 on POWER8 and later
+// processors.
+#if defined(__POWER8_VECTOR__) && defined(__has_include) && \
+ !defined(SK_CPU_SSE_LEVEL)
+
+ // Clang ships both Intel and PPC headers in its PPC version, storing the
+ // PPC compatibility in a subdirectory that the compiler will include before
+ // its standard library include directory.
+ #if (__has_include(<tmmintrin.h>) && !defined(__clang__)) || \
+ __has_include(<ppc_wrappers/tmmintrin.h>)
+ #define SK_CPU_SSE_LEVEL SK_CPU_SSE_LEVEL_SSSE3
+ #elif (__has_include(<emmintrin.h>) && !defined(__clang__)) || \
+ __has_include(<ppc_wrappers/emmintrin.h>)
+ #define SK_CPU_SSE_LEVEL SK_CPU_SSE_LEVEL_SSE2
+ #endif
+
+ #ifdef SK_CPU_SSE_LEVEL
+ #define SK_PPC64_HAS_SSE_COMPAT
+ #ifndef NO_WARN_X86_INTRINSICS
+ #define NO_WARN_X86_INTRINSICS
+ #endif
+ #if defined(__clang__)
+ #define SK_PPC64_CLANG_MFPPR_BUG
+ #endif
+ #endif
+#endif
+
#endif
Index: chromium-122.0.6261.57/third_party/skia/src/base/SkSpinlock.cpp
===================================================================
--- chromium-122.0.6261.57.orig/third_party/skia/src/base/SkSpinlock.cpp
+++ chromium-122.0.6261.57/third_party/skia/src/base/SkSpinlock.cpp
@@ -33,7 +33,8 @@
#endif
// Renamed from "pause" to avoid conflict with function defined in unistd.h
-#if SK_CPU_SSE_LEVEL >= SK_CPU_SSE_LEVEL_SSE2
+#if SK_CPU_SSE_LEVEL >= SK_CPU_SSE_LEVEL_SSE2 && \
+ !defined(SK_PPC64_CLANG_MFPPR_BUG)
#include <emmintrin.h>
static void do_pause() { _mm_pause(); }
#else
Index: chromium-122.0.6261.57/third_party/skia/src/opts/SkBitmapProcState_opts.h
===================================================================
--- chromium-122.0.6261.57.orig/third_party/skia/src/opts/SkBitmapProcState_opts.h
+++ chromium-122.0.6261.57/third_party/skia/src/opts/SkBitmapProcState_opts.h
@@ -21,7 +21,13 @@
// The rest are scattershot at the moment but I want to get them
// all migrated to be normal code inside SkBitmapProcState.cpp.
-#if SK_CPU_SSE_LEVEL >= SK_CPU_SSE_LEVEL_SSE2
+#if defined(SK_PPC64_HAS_SSE_COMPAT)
+ #if SK_CPU_SSE_LEVEL >= SK_CPU_SSE_LEVEL_SSSE3
+ #include <tmmintrin.h>
+ #else
+ #include <emmintrin.h>
+ #endif
+#elif SK_CPU_SSE_LEVEL >= SK_CPU_SSE_LEVEL_SSE2
#include <immintrin.h>
#elif defined(SK_ARM_HAS_NEON)
#include <arm_neon.h>
Index: chromium-122.0.6261.57/third_party/skia/src/opts/SkBlitRow_opts.h
===================================================================
--- chromium-122.0.6261.57.orig/third_party/skia/src/opts/SkBlitRow_opts.h
+++ chromium-122.0.6261.57/third_party/skia/src/opts/SkBlitRow_opts.h
@@ -69,7 +69,7 @@
#endif
#if SK_CPU_SSE_LEVEL >= SK_CPU_SSE_LEVEL_SSE2
- #include <immintrin.h>
+ #include <emmintrin.h>
static inline __m128i SkPMSrcOver_SSE2(const __m128i& src, const __m128i& dst) {
__m128i scale = _mm_sub_epi32(_mm_set1_epi32(256),
Index: chromium-122.0.6261.57/third_party/skia/src/opts/SkRasterPipeline_opts.h
===================================================================
--- chromium-122.0.6261.57.orig/third_party/skia/src/opts/SkRasterPipeline_opts.h
+++ chromium-122.0.6261.57/third_party/skia/src/opts/SkRasterPipeline_opts.h
@@ -1,5 +1,6 @@
/*
* Copyright 2018 Google Inc.
+ * Copyright 2023 Raptor Engineering, LLC
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
@@ -74,6 +75,8 @@ using NoCtx = const void*;
#define JUMPER_IS_SCALAR
#elif defined(SK_ARM_HAS_NEON)
#define JUMPER_IS_NEON
+#elif defined(SK_PPC64_HAS_SSE_COMPAT)
+ #define JUMPER_IS_VSX
#elif SK_CPU_SSE_LEVEL >= SK_CPU_SSE_LEVEL_SKX
#define JUMPER_IS_SKX
#elif SK_CPU_SSE_LEVEL >= SK_CPU_SSE_LEVEL_AVX2
@@ -106,6 +109,8 @@ using NoCtx = const void*;
#include <math.h>
#elif defined(JUMPER_IS_NEON)
#include <arm_neon.h>
+#elif defined(JUMPER_IS_VSX)
+ #include <emmintrin.h>
#else
#include <immintrin.h>
#endif
@@ -197,6 +202,182 @@ namespace SK_OPTS_NS {
ptr[3] = a;
}
+#elif defined(JUMPER_IS_VSX)
+ // Since we know we're using Clang, we can use its vector extensions.
+ template <typename T> using V = T __attribute__((ext_vector_type(4)));
+ using F = V<float >;
+ using I32 = V< int32_t>;
+ using U64 = V<uint64_t>;
+ using U32 = V<uint32_t>;
+ using U16 = V<uint16_t>;
+ using U8 = V<uint8_t >;
+
+ // We polyfill a few routines that Clang doesn't build into ext_vector_types.
+ SI F min(F a, F b) { return vec_min(a,b); }
+ SI I32 min(I32 a, I32 b) { return vec_min(a,b); }
+ SI U32 min(U32 a, U32 b) { return vec_min(a,b); }
+ SI F max(F a, F b) { return vec_max(a,b); }
+ SI I32 max(I32 a, I32 b) { return vec_max(a,b); }
+ SI U32 max(U32 a, U32 b) { return vec_max(a,b); }
+
+ SI F abs_ (F v) { return vec_abs(v); }
+ SI I32 abs_ (I32 v) { return vec_abs(v); }
+ SI F rcp_approx(F v) { return vec_re(v); }
+ SI F rcp_precise (F v) { F e = rcp_approx(v); return e * (2.0f - v * e); }
+ SI F rsqrt_approx (F v) { return vec_rsqrte(v); }
+
+ SI U16 pack(U32 v) { return __builtin_convertvector(v, U16); }
+ SI U8 pack(U16 v) { return __builtin_convertvector(v, U8); }
+
+ SI F if_then_else(I32 c, F t, F e) {
+ return vec_or((vector float)vec_and((vector float)c, (vector float)t), (vector float)vec_andc((vector float)e, (vector float)c));
+ }
+ SI I32 if_then_else(I32 c, I32 t, I32 e) {
+ return vec_or((vector unsigned int)vec_and((vector unsigned int)c, (vector unsigned int)t), (vector unsigned int)vec_andc((vector unsigned int)e, (vector unsigned int)c));
+ }
+
+ // In both AltiVec and SSE there is no horizontal element compare, unlike ARM. Fall back to scalar operations here...
+ SI bool any(I32 c) {
+ if (vec_extract((U32)c, 0) != 0) return 1;
+ if (vec_extract((U32)c, 1) != 0) return 1;
+ if (vec_extract((U32)c, 2) != 0) return 1;
+ if (vec_extract((U32)c, 3) != 0) return 1;
+ return 0;
+ }
+ SI bool all(I32 c) {
+ if (vec_extract((U32)c, 0) == 0) return 0;
+ if (vec_extract((U32)c, 1) == 0) return 0;
+ if (vec_extract((U32)c, 2) == 0) return 0;
+ if (vec_extract((U32)c, 3) == 0) return 0;
+ return 1;
+ }
+
+ SI F mad(F f, F m, F a) { return vec_madd(f,m,a); }
+ SI F floor_(F v) { return vec_floor(v); }
+ SI F ceil_(F v) { return vec_ceil(v); }
+ SI F sqrt_(F v) { return vec_sqrt(v); }
+ SI U32 round(F v) { return vec_cts((vector float)vec_rint(v), 0); }
+ SI U32 round(F v, F scale) { return vec_cts((vector float)vec_rint(v*scale), 0); }
+
+ template <typename T>
+ SI V<T> gather(const T* p, U32 ix) {
+ return {p[ix[0]], p[ix[1]], p[ix[2]], p[ix[3]]};
+ }
+ template <typename V, typename S>
+ SI void scatter_masked(V src, S* dst, U32 ix, I32 mask) {
+ V before = gather(dst, ix);
+ V after = if_then_else(mask, src, before);
+ dst[ix[0]] = after[0];
+ dst[ix[1]] = after[1];
+ dst[ix[2]] = after[2];
+ dst[ix[3]] = after[3];
+ }
+
+ // TODO
+ // Finish converting these functions from the SSE translation layer to native AltiVec / VSX
+ SI void load2(const uint16_t* ptr, U16* r, U16* g) {
+ __m128i _01;
+ _01 = _mm_loadu_si128(((__m128i*)ptr) + 0); // r0 g0 r1 g1 r2 g2 r3 g3
+ auto rg01_23 = _mm_shufflelo_epi16(_01, 0xD8); // r0 r1 g0 g1 r2 g2 r3 g3
+ auto rg = _mm_shufflehi_epi16(rg01_23, 0xD8); // r0 r1 g0 g1 r2 r3 g2 g3
+
+ auto R = _mm_shuffle_epi32(rg, 0x88); // r0 r1 r2 r3 r0 r1 r2 r3
+ auto G = _mm_shuffle_epi32(rg, 0xDD); // g0 g1 g2 g3 g0 g1 g2 g3
+ *r = sk_unaligned_load<U16>(&R);
+ *g = sk_unaligned_load<U16>(&G);
+ }
+
+ SI void store2(uint16_t* ptr, U16 r, U16 g) {
+ U32 rg = _mm_unpacklo_epi16(widen_cast<__m128i>(r), widen_cast<__m128i>(g));
+ _mm_storeu_si128((__m128i*)ptr + 0, rg);
+ }
+
+ SI void load3(const uint16_t* ptr, U16* r, U16* g, U16* b) {
+ __m128i _0, _1, _2, _3;
+ // Load slightly weirdly to make sure we don't load past the end of 4x48 bits.
+ auto _01 = _mm_loadu_si128((const __m128i*)(ptr + 0)) ,
+ _23 = _mm_srli_si128(_mm_loadu_si128((const __m128i*)(ptr + 4)), 4);
+
+ // Each _N holds R,G,B for pixel N in its lower 3 lanes (upper 5 are ignored).
+ _0 = _01;
+ _1 = _mm_srli_si128(_01, 6);
+ _2 = _23;
+ _3 = _mm_srli_si128(_23, 6);
+
+ // De-interlace to R,G,B.
+ auto _02 = _mm_unpacklo_epi16(_0, _2), // r0 r2 g0 g2 b0 b2 xx xx
+ _13 = _mm_unpacklo_epi16(_1, _3); // r1 r3 g1 g3 b1 b3 xx xx
+
+ auto R = _mm_unpacklo_epi16(_02, _13), // r0 r1 r2 r3 g0 g1 g2 g3
+ G = _mm_srli_si128(R, 8),
+ B = _mm_unpackhi_epi16(_02, _13); // b0 b1 b2 b3 xx xx xx xx
+
+ *r = sk_unaligned_load<U16>(&R);
+ *g = sk_unaligned_load<U16>(&G);
+ *b = sk_unaligned_load<U16>(&B);
+ }
+
+ SI void load4(const uint16_t* ptr, U16* r, U16* g, U16* b, U16* a) {
+ __m128i _01, _23;
+ _01 = _mm_loadu_si128(((__m128i*)ptr) + 0); // r0 g0 b0 a0 r1 g1 b1 a1
+ _23 = _mm_loadu_si128(((__m128i*)ptr) + 1); // r2 g2 b2 a2 r3 g3 b3 a3
+
+ auto _02 = _mm_unpacklo_epi16(_01, _23), // r0 r2 g0 g2 b0 b2 a0 a2
+ _13 = _mm_unpackhi_epi16(_01, _23); // r1 r3 g1 g3 b1 b3 a1 a3
+
+ auto rg = _mm_unpacklo_epi16(_02, _13), // r0 r1 r2 r3 g0 g1 g2 g3
+ ba = _mm_unpackhi_epi16(_02, _13); // b0 b1 b2 b3 a0 a1 a2 a3
+
+ *r = sk_unaligned_load<U16>((uint16_t*)&rg + 0);
+ *g = sk_unaligned_load<U16>((uint16_t*)&rg + 4);
+ *b = sk_unaligned_load<U16>((uint16_t*)&ba + 0);
+ *a = sk_unaligned_load<U16>((uint16_t*)&ba + 4);
+ }
+
+ SI void store4(uint16_t* ptr, U16 r, U16 g, U16 b, U16 a) {
+ auto rg = _mm_unpacklo_epi16(widen_cast<__m128i>(r), widen_cast<__m128i>(g)),
+ ba = _mm_unpacklo_epi16(widen_cast<__m128i>(b), widen_cast<__m128i>(a));
+
+ _mm_storeu_si128((__m128i*)ptr + 0, _mm_unpacklo_epi32(rg, ba));
+ _mm_storeu_si128((__m128i*)ptr + 1, _mm_unpackhi_epi32(rg, ba));
+ }
+
+ SI void load2(const float* ptr, F* r, F* g) {
+ F _01, _23;
+ _01 = _mm_loadu_ps(ptr + 0);
+ _23 = _mm_loadu_ps(ptr + 4);
+ *r = _mm_shuffle_ps(_01, _23, 0x88);
+ *g = _mm_shuffle_ps(_01, _23, 0xDD);
+ }
+
+ SI void store2(float* ptr, F r, F g) {
+ F _01 = _mm_unpacklo_ps(r, g),
+ _23 = _mm_unpackhi_ps(r, g);
+ _mm_storeu_ps(ptr + 0, _01);
+ _mm_storeu_ps(ptr + 4, _23);
+ }
+
+ SI void load4(const float* ptr, F* r, F* g, F* b, F* a) {
+ F _0, _1, _2, _3;
+ _0 = _mm_loadu_ps(ptr + 0);
+ _1 = _mm_loadu_ps(ptr + 4);
+ _2 = _mm_loadu_ps(ptr + 8);
+ _3 = _mm_loadu_ps(ptr +12);
+ _MM_TRANSPOSE4_PS(_0,_1,_2,_3);
+ *r = _0;
+ *g = _1;
+ *b = _2;
+ *a = _3;
+ }
+
+ SI void store4(float* ptr, F r, F g, F b, F a) {
+ _MM_TRANSPOSE4_PS(r,g,b,a);
+ _mm_storeu_ps(ptr + 0, r);
+ _mm_storeu_ps(ptr + 4, g);
+ _mm_storeu_ps(ptr + 8, b);
+ _mm_storeu_ps(ptr +12, a);
+ }
+
#elif defined(JUMPER_IS_NEON)
template <typename T> using V = Vec<4, T>;
using F = V<float >;
@@ -1004,6 +1185,15 @@ SI F from_half(U16 h) {
#elif defined(JUMPER_IS_HSW)
return _mm256_cvtph_ps((__m128i)h);
+// Disabled for now as this is not a particularly hot function
+// and there is no good reason to lock Chromium to POWER9+ yet.
+#elif 0 && defined(JUMPER_IS_VSX) && __has_builtin(__builtin_vsx_xvcvhpsp)
+ #if defined(SK_CPU_LENDIAN)
+ return __builtin_vsx_xvcvhpsp({h[0], 0, h[1], 0, h[2], 0, h[3], 0});
+ #else
+ return __builtin_vsx_xvcvhpsp({0, h[0], 0, h[1], 0, h[2], 0, h[3]});
+ #endif
+
#else
// Remember, a half is 1-5-10 (sign-exponent-mantissa) with 15 exponent bias.
U32 sem = expand(h),
@@ -1027,6 +1217,16 @@ SI U16 to_half(F f) {
#elif defined(JUMPER_IS_HSW)
return (U16)_mm256_cvtps_ph(f, _MM_FROUND_CUR_DIRECTION);
+// Disabled for now as this is not a particularly hot function
+// and there is no good reason to lock Chromium to POWER9+ yet.
+#elif 0 && defined(JUMPER_IS_VSX) && __has_builtin(__builtin_vsx_xvcvsphp)
+ __vector unsigned short v = __builtin_vsx_xvcvsphp(f);
+ #if defined(SK_CPU_LENDIAN)
+ return U16{v[0], v[2], v[4], v[6]};
+ #else
+ return U16{v[1], v[3], v[5], v[7]};
+ #endif
+
#else
// Remember, a float is 1-8-23 (sign-exponent-mantissa) with 127 exponent bias.
U32 sem = sk_bit_cast<U32>(f),
@@ -1102,7 +1302,7 @@ static constexpr size_t N = sizeof(F) /
// instead of {b,a} on the stack. Narrow stages work best for __vectorcall.
#define ABI __vectorcall
#define JUMPER_NARROW_STAGES 1
-#elif defined(__x86_64__) || defined(SK_CPU_ARM64)
+#elif defined(__x86_64__) || defined(SK_CPU_ARM64) || defined(SK_CPU_PPC64)
// These platforms are ideal for wider stages, and their default ABI is ideal.
#define ABI
#define JUMPER_NARROW_STAGES 0
@@ -4856,6 +5056,10 @@ SI F sqrt_(F x) {
float32x4_t lo,hi;
split(x, &lo,&hi);
return join<F>(sqrt(lo), sqrt(hi));
+#elif defined(JUMPER_IS_VSX)
+ vector float lo,hi;
+ split(x, &lo,&hi);
+ return join<F>(vec_sqrt(lo), vec_sqrt(hi));
#else
return F{
sqrtf(x[0]), sqrtf(x[1]), sqrtf(x[2]), sqrtf(x[3]),
@@ -4879,6 +5083,10 @@ SI F floor_(F x) {
__m128 lo,hi;
split(x, &lo,&hi);
return join<F>(_mm_floor_ps(lo), _mm_floor_ps(hi));
+#elif defined(JUMPER_IS_VSX)
+ vector float lo,hi;
+ split(x, &lo,&hi);
+ return join<F>(vec_floor(lo), vec_floor(hi));
#else
F roundtrip = cast<F>(cast<I32>(x));
return roundtrip - if_then_else(roundtrip > x, F_(1), F_(0));
@@ -4890,6 +5098,7 @@ SI F floor_(F x) {
// (2 * a * b + (1 << 15)) >> 16
// The result is a number on [-1, 1).
// Note: on neon this is a saturating multiply while the others are not.
+// Note: for POWER, the code below was borrowed from emmintrin.h
SI I16 scaled_mult(I16 a, I16 b) {
#if defined(JUMPER_IS_SKX)
return (I16)_mm256_mulhrs_epi16((__m256i)a, (__m256i)b);
@@ -4901,6 +5110,22 @@ SI I16 scaled_mult(I16 a, I16 b) {
return vqrdmulhq_s16(a, b);
#elif defined(JUMPER_IS_NEON)
return vqrdmulhq_s16(a, b);
+#elif defined(JUMPER_IS_VSX)
+ const vector unsigned int shift = vec_splats((unsigned int)14);
+ const vector int ones = vec_splats((signed int)1);
+ vector int c = vec_unpackh((vector short)a);
+ vector int d = vec_unpackh((vector short)b);
+ vector int e = vec_unpackl((vector short)b);
+ c = vec_mul(c, d);
+ d = vec_unpackl((vector short)a);
+ d = vec_mul(d, e);
+ c = vec_sr(c, shift);
+ d = vec_sr(d, shift);
+ c = vec_add(c, ones);
+ c = vec_sr(c,(vector unsigned int)ones);
+ d = vec_add(d, ones);
+ d = vec_sr(d,(vector unsigned int)ones);
+ return vec_pack(c, d);
#else
const I32 roundingTerm = I32_(1 << 14);
return cast<I16>((cast<I32>(a) * cast<I32>(b) + roundingTerm) >> 15);
@@ -4922,7 +5147,26 @@ SI U16 constrained_add(I16 a, U16 b) {
SkASSERT(-ib <= ia && ia <= 65535 - ib);
}
#endif
+
+ // Technically, trying to add a signed and unsigned vector invokes undefined behavior
+ // Just because it sort of seems to work on Intel/ARM on Clang doesn't mean it works everywhere...
+ // FIXME: For added fun, the existing Skia unit tests do NOT properly test for issues in the
+ // lowp bilerp path. Investigate and write an appropriate test case...
+#if defined(JUMPER_IS_VSX)
+ // Most POWER compilers end up doing some kind of width promotion that causes memory corruption
+ // and/or incorrect results. This shows up as snow and general graphics corruption, especially
+ // noticeable when trying to display a PNG at less than 50% size (resize the browser window down
+ // until the artifacts appear).
+ // Take the (likely invisible) loss of precision, convert b to a signed int immediately, and do
+ // a proper saturated add here. This seems to fully resolve the issue for all test cases Raptor
+ // has seen so far...
+ // In half precision mode, this function expects both input arguments to have been divided by
+ // two prior to being called, and returns the output without being multiplied back up by two
+ return vec_adds(a, (I16)b);
+#else
+ // Hic Sunt Dragones!
return b + sk_bit_cast<U16>(a);
+#endif
}
SI F fract(F x) { return x - floor_(x); }
@@ -5778,8 +6022,14 @@ STAGE_GP(bilerp_clamp_8888, const SkRast
// 2^-8 * v = 2^-9 * (tx*(R - L) + (R + L))
// v = 1/2 * (tx*(R - L) + (R + L))
auto lerpX = [&](U16 left, U16 right) -> U16 {
+#if defined(JUMPER_IS_VSX)
+ // constrained_add() on POWER is run in half precision mode to avoid undefined behavior
+ I16 width = (I16)(right - left) << 6;
+ U16 middle = (right + left) << 6;
+#else
I16 width = (I16)(right - left) << 7;
U16 middle = (right + left) << 7;
+#endif
// The constrained_add is the most subtle part of lerp. The first term is on the interval
// [-1, 1), and the second term is on the interval is on the interval [0, 1) because
// both terms are too high by a factor of 2 which will be handled below. (Both R and L are
@@ -5791,7 +6041,12 @@ STAGE_GP(bilerp_clamp_8888, const SkRast
U16 v2 = constrained_add(scaled_mult(tx, width), middle) + 1;
// Divide by 2 to calculate v and at the same time bring the intermediate value onto the
// interval [0, 1/2] to set up for the lerpY.
+#if defined(JUMPER_IS_VSX)
+ // constrained_add() on POWER is run in half precision mode to avoid undefined behavior
+ return v2;
+#else
return v2 >> 1;
+#endif
};
const uint32_t* ptr;
@@ -5825,9 +6080,15 @@ STAGE_GP(bilerp_clamp_8888, const SkRast
I16 width = (I16)bottom - (I16)top;
U16 middle = bottom + top;
// Add + 0x80 for rounding.
+#if defined(JUMPER_IS_VSX)
+ // constrained_add() on POWER is run in half precision mode to avoid undefined behavior
+ U16 blend = constrained_add(scaled_mult(ty, width) / 2, middle / 2) + (0x80 / 2);
+ return blend >> 7;
+#else
U16 blend = constrained_add(scaled_mult(ty, width), middle) + 0x80;
-
return blend >> 8;
+#endif
+
};
r = lerpY(topR, bottomR);
Index: chromium-122.0.6261.57/third_party/skia/src/opts/SkSwizzler_opts.h
===================================================================
--- chromium-122.0.6261.57.orig/third_party/skia/src/opts/SkSwizzler_opts.h
+++ chromium-122.0.6261.57/third_party/skia/src/opts/SkSwizzler_opts.h
@@ -12,7 +12,10 @@
#include "src/base/SkVx.h"
#include <utility>
-#if SK_CPU_SSE_LEVEL >= SK_CPU_SSE_LEVEL_SSSE3
+#if defined(SK_PPC64_HAS_SSE_COMPAT)
+ #include <emmintrin.h>
+ #include <tmmintrin.h>
+#elif SK_CPU_SSE_LEVEL >= SK_CPU_SSE_LEVEL_SSSE3
#include <immintrin.h>
#elif defined(SK_ARM_HAS_NEON)
#include <arm_neon.h>
Index: chromium-122.0.6261.57/third_party/skia/src/base/SkVx.h
===================================================================
--- chromium-122.0.6261.57.orig/third_party/skia/src/base/SkVx.h
+++ chromium-122.0.6261.57/third_party/skia/src/base/SkVx.h
@@ -42,7 +42,13 @@
#if SKVX_USE_SIMD
#if SK_CPU_SSE_LEVEL >= SK_CPU_SSE_LEVEL_SSE1
- #include <immintrin.h>
+ #if __PPC64__
+ #include <mmintrin.h>
+ #include <emmintrin.h>
+ #include <tmmintrin.h>
+ #else
+ #include <immintrin.h>
+ #endif
#elif defined(SK_ARM_HAS_NEON)
#include <arm_neon.h>
#elif defined(__wasm_simd128__)
Index: chromium-122.0.6261.57/third_party/skia/src/core/SkBlitMask_opts_ssse3.cpp
===================================================================
--- chromium-122.0.6261.57.orig/third_party/skia/src/core/SkBlitMask_opts_ssse3.cpp
+++ chromium-122.0.6261.57/third_party/skia/src/core/SkBlitMask_opts_ssse3.cpp
@@ -9,7 +9,7 @@
#include "src/core/SkBlitMask.h"
#include "src/core/SkOptsTargets.h"
-#if defined(SK_CPU_X86) && !defined(SK_ENABLE_OPTIMIZE_SIZE)
+#if (defined(SK_CPU_X86) || defined(SK_CPU_PPC64)) && !defined(SK_ENABLE_OPTIMIZE_SIZE)
// The order of these includes is important:
// 1) Select the target CPU architecture by defining SK_OPTS_TARGET and including SkOpts_SetTarget
Index: chromium-122.0.6261.57/third_party/skia/src/core/SkSwizzler_opts_ssse3.cpp
===================================================================
--- chromium-122.0.6261.57.orig/third_party/skia/src/core/SkSwizzler_opts_ssse3.cpp
+++ chromium-122.0.6261.57/third_party/skia/src/core/SkSwizzler_opts_ssse3.cpp
@@ -11,7 +11,7 @@
#include "src/core/SkOptsTargets.h"
#include "src/core/SkSwizzlePriv.h"
-#if defined(SK_CPU_X86) && !defined(SK_ENABLE_OPTIMIZE_SIZE)
+#if (defined(SK_CPU_X86) || defined(SK_CPU_PPC64)) && !defined(SK_ENABLE_OPTIMIZE_SIZE)
// The order of these includes is important:
// 1) Select the target CPU architecture by defining SK_OPTS_TARGET and including SkOpts_SetTarget
Index: chromium-122.0.6261.57/third_party/skia/src/core/SkBlitMask_opts.cpp
===================================================================
--- chromium-122.0.6261.57.orig/third_party/skia/src/core/SkBlitMask_opts.cpp
+++ chromium-122.0.6261.57/third_party/skia/src/core/SkBlitMask_opts.cpp
@@ -25,7 +25,7 @@ namespace SkOpts {
static bool init() {
#if defined(SK_ENABLE_OPTIMIZE_SIZE)
// All Init_foo functions are omitted when optimizing for size
- #elif defined(SK_CPU_X86)
+ #elif defined(SK_CPU_X86) || defined(SK_CPU_PPC64)
#if SK_CPU_SSE_LEVEL < SK_CPU_SSE_LEVEL_SSSE3
if (SkCpu::Supports(SkCpu::SSSE3)) { Init_BlitMask_ssse3(); }
#endif
Index: chromium-122.0.6261.57/third_party/skia/src/core/SkBitmapProcState_opts.cpp
===================================================================
--- chromium-122.0.6261.57.orig/third_party/skia/src/core/SkBitmapProcState_opts.cpp
+++ chromium-122.0.6261.57/third_party/skia/src/core/SkBitmapProcState_opts.cpp
@@ -26,7 +26,7 @@ namespace SkOpts {
static bool init() {
#if defined(SK_ENABLE_OPTIMIZE_SIZE)
// All Init_foo functions are omitted when optimizing for size
- #elif defined(SK_CPU_X86)
+ #elif defined(SK_CPU_X86) || defined(SK_CPU_PPC64)
#if SK_CPU_SSE_LEVEL < SK_CPU_SSE_LEVEL_SSSE3
if (SkCpu::Supports(SkCpu::SSSE3)) { Init_BitmapProcState_ssse3(); }
#endif
Index: chromium-122.0.6261.57/third_party/skia/src/core/SkCpu.h
===================================================================
--- chromium-122.0.6261.57.orig/third_party/skia/src/core/SkCpu.h
+++ chromium-122.0.6261.57/third_party/skia/src/core/SkCpu.h
@@ -55,7 +55,7 @@ inline bool SkCpu::Supports(uint32_t mas
// If we mask in compile-time known lower limits, the compiler can
// often compile away this entire function.
-#if SK_CPU_X86
+#if SK_CPU_X86 || defined(SK_CPU_PPC64)
#if SK_CPU_SSE_LEVEL >= SK_CPU_SSE_LEVEL_SSE1
features |= SSE1;
#endif
Index: chromium-122.0.6261.57/third_party/skia/src/core/SkBitmapProcState_opts_hsw.cpp
===================================================================
--- chromium-122.0.6261.57.orig/third_party/skia/src/core/SkBitmapProcState_opts_hsw.cpp
+++ chromium-122.0.6261.57/third_party/skia/src/core/SkBitmapProcState_opts_hsw.cpp
@@ -8,7 +8,7 @@
#include "include/private/base/SkFeatures.h"
#include "src/core/SkOptsTargets.h"
-#if defined(SK_CPU_X86) && !defined(SK_ENABLE_OPTIMIZE_SIZE)
+#if (defined(SK_CPU_X86) || defined(SK_CPU_PPC64)) && !defined(SK_ENABLE_OPTIMIZE_SIZE)
// The order of these includes is important:
// 1) Select the target CPU architecture by defining SK_OPTS_TARGET and including SkOpts_SetTarget
Index: chromium-122.0.6261.57/third_party/skia/src/core/SkBitmapProcState_opts_ssse3.cpp
===================================================================
--- chromium-122.0.6261.57.orig/third_party/skia/src/core/SkBitmapProcState_opts_ssse3.cpp
+++ chromium-122.0.6261.57/third_party/skia/src/core/SkBitmapProcState_opts_ssse3.cpp
@@ -8,7 +8,7 @@
#include "include/private/base/SkFeatures.h"
#include "src/core/SkOptsTargets.h"
-#if defined(SK_CPU_X86) && !defined(SK_ENABLE_OPTIMIZE_SIZE)
+#if (defined(SK_CPU_X86) || defined(SK_CPU_PPC64)) && !defined(SK_ENABLE_OPTIMIZE_SIZE)
// The order of these includes is important:
// 1) Select the target CPU architecture by defining SK_OPTS_TARGET and including SkOpts_SetTarget
Index: chromium-122.0.6261.57/third_party/skia/include/private/base/SkFeatures.h
===================================================================
--- chromium-122.0.6261.57.orig/third_party/skia/include/private/base/SkFeatures.h
+++ chromium-122.0.6261.57/third_party/skia/include/private/base/SkFeatures.h
@@ -63,6 +63,8 @@
#if defined(__i386) || defined(_M_IX86) || defined(__x86_64__) || defined(_M_X64)
#define SK_CPU_X86 1
+#elif defined(__powerpc64__) || defined(__PPC64__)
+ #define SK_CPU_PPC64 1
#endif
/**
Index: chromium-122.0.6261.57/third_party/skia/modules/skcms/src/skcms_internals.h
===================================================================
--- chromium-122.0.6261.57.orig/third_party/skia/modules/skcms/src/skcms_internals.h
+++ chromium-122.0.6261.57/third_party/skia/modules/skcms/src/skcms_internals.h
@@ -46,6 +46,7 @@ extern "C" {
&& !defined(__EMSCRIPTEN__) \
&& !defined(__arm__) \
&& !defined(__riscv) \
+ && !defined(__powerpc64__) \
&& !defined(_WIN32) && !defined(__SYMBIAN32__)
#define SKCMS_HAS_MUSTTAIL 1
#endif

@ -0,0 +1,60 @@
Index: chromium-120.0.6099.71/base/allocator/partition_allocator/src/partition_alloc/page_allocator_constants.h
===================================================================
--- chromium-120.0.6099.71.orig/base/allocator/partition_allocator/src/partition_alloc/page_allocator_constants.h
+++ chromium-120.0.6099.71/base/allocator/partition_allocator/src/partition_alloc/page_allocator_constants.h
@@ -172,7 +172,11 @@ SystemPageBaseMask() {
return ~SystemPageOffsetMask();
}
+#if defined(ARCH_CPU_PPC64)
+constexpr size_t kPageMetadataShift = 6; // 64 bytes per partition page.
+#else
constexpr size_t kPageMetadataShift = 5; // 32 bytes per partition page.
+#endif
constexpr size_t kPageMetadataSize = 1 << kPageMetadataShift;
} // namespace partition_alloc::internal
Index: chromium-120.0.6099.71/base/allocator/partition_allocator/src/partition_alloc/partition_page.h
===================================================================
--- chromium-120.0.6099.71.orig/base/allocator/partition_allocator/src/partition_alloc/partition_page.h
+++ chromium-120.0.6099.71/base/allocator/partition_allocator/src/partition_alloc/partition_page.h
@@ -90,7 +90,11 @@ struct SlotSpanMetadata {
// CHECK()ed in AllocNewSlotSpan().
// The maximum number of bits needed to cover all currently supported OSes.
+#if defined(ARCH_CPU_PPC64)
+ static constexpr size_t kMaxSlotsPerSlotSpanBits = 15;
+#else
static constexpr size_t kMaxSlotsPerSlotSpanBits = 13;
+#endif
static_assert(kMaxSlotsPerSlotSpan < (1 << kMaxSlotsPerSlotSpanBits), "");
// |marked_full| isn't equivalent to being full. Slot span is marked as full
@@ -104,7 +108,11 @@ struct SlotSpanMetadata {
private:
const uint32_t can_store_raw_size_ : 1;
uint32_t freelist_is_sorted_ : 1;
+#if defined(ARCH_CPU_PPC64)
+ uint32_t unused1_ : (64 - 1 - 2 * kMaxSlotsPerSlotSpanBits - 1 - 1);
+#else
uint32_t unused1_ : (32 - 1 - 2 * kMaxSlotsPerSlotSpanBits - 1 - 1);
+#endif
// If |in_empty_cache_|==1, |empty_cache_index| is undefined and mustn't be
// used.
uint16_t in_empty_cache_ : 1;
Index: chromium-120.0.6099.71/base/allocator/partition_allocator/src/partition_alloc/partition_page_constants.h
===================================================================
--- chromium-120.0.6099.71.orig/base/allocator/partition_allocator/src/partition_alloc/partition_page_constants.h
+++ chromium-120.0.6099.71/base/allocator/partition_allocator/src/partition_alloc/partition_page_constants.h
@@ -21,6 +21,11 @@ static constexpr size_t kMaxSlotsPerSlot
// 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;
+#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)
+// And PartitionPageSize() is 4 times the OS page size.
+static constexpr size_t kMaxSlotsPerSlotSpan = 4 * (1 << 16) / kSmallestBucket;
#else
// A slot span can "span" multiple PartitionPages, but then its slot size is
// larger, so it doesn't have as many slots.

@ -510,8 +510,87 @@ Patch357: chromium-122-clang16-disable-auto-upgrade-debug-info.patch
# set clang_lib path
Patch358: chromium-122-rust-clang_lib.patch
# PowerPC64 LE support
# Patches taken from Debian, Timothy Pearson's patchset
# https://salsa.debian.org/chromium-team/chromium/-/tree/master/debian/patches/ppc64le?ref_type=heads
Patch360: 0001-linux-seccomp-bpf-ppc64-glibc-workaround-in-SIGSYS-h.patch
Patch361: 0001-sandbox-Enable-seccomp_bpf-for-ppc64.patch
Patch362: 0001-services-service_manager-sandbox-linux-Fix-TCGETS-de.patch
Patch363: 0001-sandbox-linux-bpf_dsl-Update-syscall-ranges-for-ppc6.patch
Patch364: 0001-sandbox-linux-Implement-partial-support-for-ppc64-sy.patch
Patch365: 0001-sandbox-linux-Update-IsSyscallAllowed-in-broker_proc.patch
Patch366: 0001-sandbox-linux-Update-syscall-helpers-lists-for-ppc64.patch
Patch367: 0002-sandbox-linux-bpf_dsl-Modify-seccomp_macros-to-add-s.patch
Patch368: 0003-sandbox-linux-system_headers-Update-linux-seccomp-he.patch
Patch369: 0004-sandbox-linux-system_headers-Update-linux-signal-hea.patch
Patch370: 0005-sandbox-linux-seccomp-bpf-Add-ppc64-syscall-stub.patch
Patch371: 0005-sandbox-linux-update-unit-test-for-ppc64.patch
Patch372: 0006-sandbox-linux-disable-timedwait-time64-ppc64.patch
Patch373: 0007-sandbox-linux-add-ppc64-stat.patch
Patch374: Sandbox-linux-services-credentials.cc-PPC.patch
Patch375: 0008-sandbox-fix-ppc64le-glibc234.patch
Patch376: 0001-third_party-angle-Include-missing-header-cstddef-in-.patch
Patch377: 0001-Add-PPC64-support-for-boringssl.patch
Patch378: 0001-third_party-libvpx-Properly-generate-gni-on-ppc64.patch
Patch379: 0001-third_party-lss-Don-t-look-for-mmap2-on-ppc64.patch
Patch380: 0001-third_party-pffft-Include-altivec.h-on-ppc64-with-SI.patch
Patch381: 0002-third_party-lss-kernel-structs.patch
Patch382: Rtc_base-system-arch.h-PPC.patch
Patch383: 0002-Include-cstddef-to-fix-build.patch
Patch384: 0004-third_party-crashpad-port-curl-transport-ppc64.patch
Patch385: HACK-third_party-libvpx-use-generic-gnu.patch
Patch386: HACK-debian-clang-disable-skia-musttail.patch
Patch387: 0001-Add-ppc64-target-to-libaom.patch
Patch388: 0001-Add-pregenerated-config-for-libaom-on-ppc64.patch
Patch389: 0002-third_party-libvpx-Remove-bad-ppc64-config.patch
Patch390: 0002-third-party-boringssl-add-generated-files.patch
Patch391: 0003-third_party-libvpx-Add-ppc64-generated-config.patch
# Enabling VSX causes artifacts to appear in VP9 videos
Patch392: 0003-third_party-libvpx-Add-ppc64-vsx-files.patch
Patch393: 0003-third_party-ffmpeg-Add-ppc64-generated-config.patch
Patch394: 0004-third_party-libvpx-work-around-ambiguous-vsx.patch
# Enable VSX acceleration in Skia. Requires POWER8 or higher.
Patch395: skia-vsx-instructions.patch
Patch396: 0001-Implement-support-for-ppc64-on-Linux.patch
Patch397: 0001-Implement-support-for-PPC64-on-Linux.patch
Patch398: 0001-Force-baseline-POWER8-AltiVec-VSX-CPU-features-when-.patch
Patch399: fix-rustc.patch
Patch400: fix-rust-linking.patch
Patch401: fix-breakpad-compile.patch
Patch402: fix-partition-alloc-compile.patch
Patch403: 0002-Add-ppc64-trap-instructions.patch
Patch404: 0001-Fix-highway-ppc-hwcap.patch
Patch405: 0001-Add-PPC64-support-for-libdav1d.patch
Patch406: 0001-Fix-libdav1d-compilation-on-clang-ppc.patch
Patch407: fix-ppc64-linux-syscalls-headers.patch
Patch408: 0003-thirdparty-fix-dav1d-gn.patch
Patch409: use-sysconf-page-size-on-ppc64.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
# Needed on Debian while POWER8 remains the build target
# POWER9 enables hardware 128 bit vector support (ISA 3.0),
# and Highway gets confused when building in POWER8 mode
# (POWER8 compiler flags) on POWER9 hosts.
Patch414: 0002-Highway-disable-128-bit-vsx.patch
# upstream patches
Patch400: chromium-122-el8-support-64kpage.patch
Patch500: chromium-122-el8-support-64kpage.patch
# Old Yandex patch
Patch500: 0001-Yandex-as-default-search-engine.patch
@ -905,12 +984,17 @@ Requires: u2f-hidraw-policy
Requires: %{name}-common%{_isa} = %{version}-%{release}
# rhel 7: x86_64
# rhel 8+ and fedora 37+: x86_64 aarch64
# rhel 8 or newer: x86_64, aarch64
# fedora 38 or newer: x86_64, aarch64, ppc64le
%if 0%{?rhel} == 7
ExclusiveArch: x86_64
%else
%if 0%{?fedora} >= 40
ExclusiveArch: x86_64 aarch64 ppc64le
%else
ExclusiveArch: x86_64 aarch64
%endif
%endif
# FIXME
%if "%{_lib}" == "lib64"
@ -1263,9 +1347,79 @@ sed -i 's/std::string data_dir_basename = "chromium"/std::string data_dir_basena
%patch -P357 -p1 -b .clang16-disable-auto-upgrade-debug-info
%patch -P358 -p1 -b .rust-clang_lib
%ifarch ppc64le
%patch -P360 -p1 -b .0001-linux-seccomp-bpf-ppc64-glibc-workaround-in-SIGSYS-h
%patch -P361 -p1 -b .0001-sandbox-Enable-seccomp_bpf-for-ppc64
%patch -P362 -p1 -b .0001-services-service_manager-sandbox-linux-Fix-TCGETS-de
%patch -P363 -p1 -b .0001-sandbox-linux-bpf_dsl-Update-syscall-ranges-for-ppc6
%patch -P364 -p1 -b .0001-sandbox-linux-Implement-partial-support-for-ppc64-sy
%patch -P365 -p1 -b .0001-sandbox-linux-Update-IsSyscallAllowed-in-broker_proc
%patch -P366 -p1 -b .0001-sandbox-linux-Update-syscall-helpers-lists-for-ppc64
%patch -P367 -p1 -b .0002-sandbox-linux-bpf_dsl-Modify-seccomp_macros-to-add-s
%patch -P368 -p1 -b .0003-sandbox-linux-system_headers-Update-linux-seccomp-he
%patch -P369 -p1 -b .0004-sandbox-linux-system_headers-Update-linux-signal-hea
%patch -P370 -p1 -b .0005-sandbox-linux-seccomp-bpf-Add-ppc64-syscall-stub
%patch -P371 -p1 -b .0005-sandbox-linux-update-unit-test-for-ppc64
%patch -P372 -p1 -b .0006-sandbox-linux-disable-timedwait-time64-ppc64
%patch -P373 -p1 -b .0007-sandbox-linux-add-ppc64-stat
%patch -P374 -p1 -b .Sandbox-linux-services-credentials.cc-PPC
%patch -P375 -p1 -b .0008-sandbox-fix-ppc64le-glibc234
%patch -P376 -p1 -b .0001-third_party-angle-Include-missing-header-cstddef-in-
%patch -P377 -p1 -b .0001-Add-PPC64-support-for-boringssl
%patch -P378 -p1 -b .0001-third_party-libvpx-Properly-generate-gni-on-ppc64
%patch -P379 -p1 -b .0001-third_party-lss-Don-t-look-for-mmap2-on-ppc64
%patch -P380 -p1 -b .0001-third_party-pffft-Include-altivec.h-on-ppc64-with-SI
%patch -P381 -p1 -b .0002-third_party-lss-kernel-structs
%patch -P382 -p1 -b .Rtc_base-system-arch.h-PPC
%patch -P383 -p1 -b .0002-Include-cstddef-to-fix-build
%patch -P384 -p1 -b .0004-third_party-crashpad-port-curl-transport-ppc64
%patch -P385 -p1 -b .HACK-third_party-libvpx-use-generic-gnu
%patch -P386 -p1 -b .HACK-debian-clang-disable-skia-musttail
%patch -P387 -p1 -b .0001-Add-ppc64-target-to-libaom
%patch -P388 -p1 -b .0001-Add-pregenerated-config-for-libaom-on-ppc64
%patch -P389 -p1 -b .0002-third_party-libvpx-Remove-bad-ppc64-config
%patch -P390 -p1 -b .0002-third-party-boringssl-add-generated-files
%patch -P391 -p1 -b .0003-third_party-libvpx-Add-ppc64-generated-config
#patch -P392 -p1 -b .0003-third_party-libvpx-Add-ppc64-vsx-files
%patch -P393 -p1 -b .0003-third_party-ffmpeg-Add-ppc64-generated-config
%patch -P394 -p1 -b .0004-third_party-libvpx-work-around-ambiguous-vsx
%patch -P395 -p1 -b .skia-vsx-instructions
%patch -P396 -p1 -b .0001-Implement-support-for-ppc64-on-Linux
%patch -P397 -p1 -b .0001-Implement-support-for-PPC64-on-Linux
%patch -P398 -p1 -b .0001-Force-baseline-POWER8-AltiVec-VSX-CPU-features-when-
%patch -P399 -p1 -b .fix-rustc
%patch -P400 -p1 -b .fix-rust-linking
%patch -P401 -p1 -b .fix-breakpad-compile
%patch -P402 -p1 -b .fix-partition-alloc-compile
%patch -P403 -p1 -b .0002-Add-ppc64-trap-instructions
%patch -P404 -p1 -b .0001-Fix-highway-ppc-hwcap
%patch -P405 -p1 -b .0001-Add-PPC64-support-for-libdav1d
%patch -P406 -p1 -b .0001-Fix-libdav1d-compilation-on-clang-ppc
%patch -P407 -p1 -b .fix-ppc64-linux-syscalls-headers
%patch -P408 -p1 -b .0003-thirdparty-fix-dav1d-gn
%patch -P409 -p1 -b .use-sysconf-page-size-on-ppc64
%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
%patch -P414 -p1 -b .0002-Highway-disable-128-bit-vsx
%endif
%%ifarch aarch64
%if 0%{?rhel} == 8
%patch -P400 -p1 -b .el8-support-64kpage.patch
%patch -P500 -p1 -b .el8-support-64kpage.patch
%endif
%endif
@ -1484,6 +1638,10 @@ CHROMIUM_CORE_GN_DEFINES+=' use_gold=false'
CHROMIUM_CORE_GN_DEFINES+=' target_cpu="arm64"'
%endif
%ifarch ppc64le
CHROMIUM_CORE_GN_DEFINES+=' target_cpu="ppc64"'
%endif
CHROMIUM_CORE_GN_DEFINES+=' icu_use_data_file=true'
CHROMIUM_CORE_GN_DEFINES+=' target_os="linux"'
CHROMIUM_CORE_GN_DEFINES+=' current_os="linux"'
@ -1749,7 +1907,7 @@ mkdir -p %{buildroot}%{_mandir}/man1/
pushd %{builddir}
cp -a chrom*.pak resources.pak icudtl.dat libffmpeg.so %{buildroot}%{chromium_path}
cp -a locales/*.pak %{buildroot}%{chromium_path}/locales/
%ifarch x86_64 aarch64
%ifarch x86_64 aarch64 ppc64le
cp -a libvk_swiftshader.so %{buildroot}%{chromium_path}
cp -a libvulkan.so.1 %{buildroot}%{chromium_path}
cp -a vk_swiftshader_icd.json %{buildroot}%{chromium_path}
@ -1779,12 +1937,12 @@ pushd %{builddir}
%if %{build_clear_key_cdm}
%ifarch x86_64
cp -a ClearKeyCdm/_platform_specific/linux_x64/libclearkeycdm.so %{buildroot}%{chromium_path}
%else
%ifarch aarch64
cp -a ClearKeyCdm/_platform_specific/linux_arm64/libclearkeycdm.so %{buildroot}%{chromium_path}
%else
cp -a libclearkeycdm.so %{buildroot}%{chromium_path}
%endif
%endif
%ifarch aarch64
cp -a ClearKeyCdm/_platform_specific/linux_arm64/libclearkeycdm.so %{buildroot}%{chromium_path}
%endif
%ifarch ppc64le
cp -a ClearKeyCdm/_platform_specific/linux_ppc64/libclearkeycdm.so %{buildroot}%{chromium_path}
%endif
%endif
@ -1970,7 +2128,7 @@ getent group chrome-remote-desktop >/dev/null || groupadd -r chrome-remote-deskt
%if %{build_clear_key_cdm}
%{chromium_path}/libclearkeycdm.so
%endif
%ifarch x86_64 aarch64
%ifarch x86_64 aarch64 ppc64le
%{chromium_path}/libvk_swiftshader.so*
%{chromium_path}/libvulkan.so*
%{chromium_path}/vk_swiftshader_icd.json

Loading…
Cancel
Save