188 lines
8.2 KiB
Diff
188 lines
8.2 KiB
Diff
From 5aadb50aa4d5220ff38c25fc7c5333ffd0abbc27 Mon Sep 17 00:00:00 2001
|
|
From: Daniel Kolesa <daniel@octaforge.org>
|
|
Date: Sun, 13 Sep 2020 00:10:49 +0200
|
|
Subject: [PATCH] ppc64le musl bits
|
|
|
|
---
|
|
sandbox/linux/bpf_dsl/seccomp_macros.h | 6 +++---
|
|
sandbox/linux/seccomp-bpf/syscall.cc | 4 ++--
|
|
.../abseil-cpp/absl/base/internal/unscaledcycleclock.h | 2 +-
|
|
.../src/client/linux/dump_writer_common/thread_info.cc | 7 +++++--
|
|
.../src/client/linux/dump_writer_common/ucontext_reader.cc | 7 +++++--
|
|
.../breakpad/src/client/linux/handler/exception_handler.cc | 5 +++++
|
|
.../crashpad/crashpad/snapshot/linux/signal_context.h | 2 +-
|
|
third_party/crashpad/crashpad/util/linux/thread_info.h | 1 +
|
|
third_party/lss/linux_syscall_support.h | 4 ++++
|
|
9 files changed, 27 insertions(+), 11 deletions(-)
|
|
|
|
diff --git a/sandbox/linux/bpf_dsl/seccomp_macros.h b/sandbox/linux/bpf_dsl/seccomp_macros.h
|
|
index a6aec544e0..2a4a7f1bca 100644
|
|
--- a/sandbox/linux/bpf_dsl/seccomp_macros.h
|
|
+++ b/sandbox/linux/bpf_dsl/seccomp_macros.h
|
|
@@ -16,7 +16,7 @@
|
|
#if defined(__mips__)
|
|
// sys/user.h in eglibc misses size_t definition
|
|
#include <stddef.h>
|
|
-#elif defined(__powerpc64__)
|
|
+#elif defined(__powerpc64__) && defined(__GLIBC__)
|
|
// Manually define greg_t on ppc64
|
|
typedef unsigned long long greg_t;
|
|
#endif
|
|
@@ -361,11 +361,11 @@ typedef struct pt_regs regs_struct;
|
|
#define SECCOMP_ARCH AUDIT_ARCH_PPC64
|
|
#endif
|
|
|
|
-#define SECCOMP_REG(_ctx, _reg) ((_ctx)->uc_mcontext.regs->gpr[_reg])
|
|
+#define SECCOMP_REG(_ctx, _reg) (((struct pt_regs *)(_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_IP(_ctx) ((struct pt_regs *)(_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)
|
|
diff --git a/sandbox/linux/seccomp-bpf/syscall.cc b/sandbox/linux/seccomp-bpf/syscall.cc
|
|
index 10fa5fd070..30b7b3851f 100644
|
|
--- a/sandbox/linux/seccomp-bpf/syscall.cc
|
|
+++ b/sandbox/linux/seccomp-bpf/syscall.cc
|
|
@@ -497,9 +497,9 @@ void Syscall::PutValueInUcontext(intptr_t ret_val, ucontext_t* ctx) {
|
|
// 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);
|
|
+ ((struct pt_regs *)ctx->uc_mcontext.regs)->ccr |= (1 << 28);
|
|
} else {
|
|
- ctx->uc_mcontext.regs->ccr &= ~(1 << 28);
|
|
+ ((struct pt_regs *)ctx->uc_mcontext.regs)->ccr &= ~(1 << 28);
|
|
}
|
|
#endif
|
|
SECCOMP_RESULT(ctx) = static_cast<greg_t>(ret_val);
|
|
diff --git a/third_party/abseil-cpp/absl/base/internal/unscaledcycleclock.h b/third_party/abseil-cpp/absl/base/internal/unscaledcycleclock.h
|
|
index cdce9bf8a8..73d77dda4d 100644
|
|
--- a/third_party/abseil-cpp/absl/base/internal/unscaledcycleclock.h
|
|
+++ b/third_party/abseil-cpp/absl/base/internal/unscaledcycleclock.h
|
|
@@ -46,7 +46,7 @@
|
|
|
|
// The following platforms have an implementation of a hardware counter.
|
|
#if defined(__i386__) || defined(__x86_64__) || defined(__aarch64__) || \
|
|
- defined(__powerpc__) || defined(__ppc__) || \
|
|
+ ((defined(__powerpc__) || defined(__ppc__)) && defined(__GLIBC__)) || \
|
|
defined(_M_IX86) || defined(_M_X64)
|
|
#define ABSL_HAVE_UNSCALED_CYCLECLOCK_IMPLEMENTATION 1
|
|
#else
|
|
diff --git a/third_party/breakpad/breakpad/src/client/linux/dump_writer_common/thread_info.cc b/third_party/breakpad/breakpad/src/client/linux/dump_writer_common/thread_info.cc
|
|
index 03afec7a58..0264ecf135 100644
|
|
--- a/third_party/breakpad/breakpad/src/client/linux/dump_writer_common/thread_info.cc
|
|
+++ b/third_party/breakpad/breakpad/src/client/linux/dump_writer_common/thread_info.cc
|
|
@@ -273,6 +273,9 @@ void ThreadInfo::FillCPUContext(RawContextCPU* out) const {
|
|
|
|
#elif defined(__powerpc64__)
|
|
|
|
+#include <asm/elf.h>
|
|
+#include <asm/ptrace.h>
|
|
+
|
|
uintptr_t ThreadInfo::GetInstructionPointer() const {
|
|
return mcontext.gp_regs[PT_NIP];
|
|
}
|
|
@@ -290,9 +293,9 @@ void ThreadInfo::FillCPUContext(RawContextCPU* out) const {
|
|
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.fpregs[i] = ((uint64_t *)&mcontext.fp_regs)[i];
|
|
|
|
- out->float_save.fpscr = mcontext.fp_regs[NFPREG-1];
|
|
+ out->float_save.fpscr = ((uint64_t *)&mcontext.fp_regs)[ELF_NFPREG-1];
|
|
|
|
for (int i = 0; i < MD_VECTORSAVEAREA_PPC_VR_COUNT; i++)
|
|
out->vector_save.save_vr[i] = \
|
|
diff --git a/third_party/breakpad/breakpad/src/client/linux/dump_writer_common/ucontext_reader.cc b/third_party/breakpad/breakpad/src/client/linux/dump_writer_common/ucontext_reader.cc
|
|
index 7620cf6f79..54e373611f 100644
|
|
--- a/third_party/breakpad/breakpad/src/client/linux/dump_writer_common/ucontext_reader.cc
|
|
+++ b/third_party/breakpad/breakpad/src/client/linux/dump_writer_common/ucontext_reader.cc
|
|
@@ -257,6 +257,9 @@ void UContextReader::FillCPUContext(RawContextCPU *out, const ucontext_t *uc) {
|
|
|
|
#elif defined(__powerpc64__)
|
|
|
|
+#include <asm/elf.h>
|
|
+#include <asm/ptrace.h>
|
|
+
|
|
uintptr_t UContextReader::GetStackPointer(const ucontext_t* uc) {
|
|
return uc->uc_mcontext.gp_regs[MD_CONTEXT_PPC64_REG_SP];
|
|
}
|
|
@@ -280,9 +283,9 @@ void UContextReader::FillCPUContext(RawContextCPU* out, const ucontext_t* uc,
|
|
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.fpregs[i] = ((uint64_t *)&uc->uc_mcontext.fp_regs)[i];
|
|
|
|
- out->float_save.fpscr = uc->uc_mcontext.fp_regs[NFPREG-1];
|
|
+ out->float_save.fpscr = ((uint64_t *)&uc->uc_mcontext.fp_regs)[ELF_NFPREG-1];
|
|
|
|
for (int i = 0; i < MD_VECTORSAVEAREA_PPC_VR_COUNT; i++)
|
|
out->vector_save.save_vr[i] =
|
|
diff --git a/third_party/breakpad/breakpad/src/client/linux/handler/exception_handler.cc b/third_party/breakpad/breakpad/src/client/linux/handler/exception_handler.cc
|
|
index 826c9e0c21..9bb4f6a3e4 100644
|
|
--- a/third_party/breakpad/breakpad/src/client/linux/handler/exception_handler.cc
|
|
+++ b/third_party/breakpad/breakpad/src/client/linux/handler/exception_handler.cc
|
|
@@ -105,6 +105,11 @@
|
|
#define PR_SET_PTRACER 0x59616d61
|
|
#endif
|
|
|
|
+/* musl hack, can't include asm/ptrace.h as that causes conflicts */
|
|
+#if defined(__powerpc64__) && !defined(PT_NIP)
|
|
+#define PT_NIP 32
|
|
+#endif
|
|
+
|
|
namespace google_breakpad {
|
|
|
|
namespace {
|
|
diff --git a/third_party/crashpad/crashpad/snapshot/linux/signal_context.h b/third_party/crashpad/crashpad/snapshot/linux/signal_context.h
|
|
index a1f2da2591..e6a5bd72ab 100644
|
|
--- a/third_party/crashpad/crashpad/snapshot/linux/signal_context.h
|
|
+++ b/third_party/crashpad/crashpad/snapshot/linux/signal_context.h
|
|
@@ -469,7 +469,7 @@ struct MContext64 {
|
|
SignalThreadContext64 gp_regs;
|
|
SignalFloatContext64 fp_regs;
|
|
SignalVectorContext64 *v_regs;
|
|
- int64_t vmx_reserve[69];
|
|
+ int64_t vmx_reserve[101];
|
|
};
|
|
|
|
struct ContextTraits64 : public Traits64 {
|
|
diff --git a/third_party/crashpad/crashpad/util/linux/thread_info.h b/third_party/crashpad/crashpad/util/linux/thread_info.h
|
|
index dea0d1f39e..b203e5b2f2 100644
|
|
--- a/third_party/crashpad/crashpad/util/linux/thread_info.h
|
|
+++ b/third_party/crashpad/crashpad/util/linux/thread_info.h
|
|
@@ -30,6 +30,7 @@
|
|
|
|
#if defined(ARCH_CPU_PPC64_FAMILY)
|
|
#include <sys/ucontext.h>
|
|
+#include <asm/ptrace.h>
|
|
#endif
|
|
|
|
namespace crashpad {
|
|
diff --git a/third_party/lss/linux_syscall_support.h b/third_party/lss/linux_syscall_support.h
|
|
index 4c02137faa..259c5726d7 100644
|
|
--- a/third_party/lss/linux_syscall_support.h
|
|
+++ b/third_party/lss/linux_syscall_support.h
|
|
@@ -4223,9 +4223,13 @@ struct kernel_statfs {
|
|
}
|
|
#endif
|
|
#if defined(__NR_fstatat64)
|
|
+ // musl does #define fstatat64 fstatat
|
|
+ #undef fstatat64
|
|
LSS_INLINE _syscall4(int, fstatat64, int, d,
|
|
const char *, p,
|
|
struct kernel_stat64 *, b, int, f)
|
|
+ // set it back like it was
|
|
+ #define fstatat64 fstatat
|
|
#endif
|
|
#if defined(__NR_waitpid)
|
|
// waitpid is polyfilled below when not available.
|
|
--
|
|
2.28.0
|
|
|