Commit 249c590a authored by HardenedBSD Sync Service's avatar HardenedBSD Sync Service
Browse files

Merge remote-tracking branch 'freebsd/stable/13' into hardened/13-stable/master

parents ebea6da4 fb231965
......@@ -2098,12 +2098,19 @@ static void GetPcSpBp(void *context, uptr *pc, uptr *sp, uptr *bp) {
*sp = ucontext->uc_mcontext.gregs[REG_UESP];
# endif
#elif defined(__powerpc__) || defined(__powerpc64__)
# if SANITIZER_FREEBSD
ucontext_t *ucontext = (ucontext_t *)context;
*pc = ucontext->uc_mcontext.mc_srr0;
*sp = ucontext->uc_mcontext.mc_frame[1];
*bp = ucontext->uc_mcontext.mc_frame[31];
# else
ucontext_t *ucontext = (ucontext_t*)context;
*pc = ucontext->uc_mcontext.regs->nip;
*sp = ucontext->uc_mcontext.regs->gpr[PT_R1];
// The powerpc{,64}-linux ABIs do not specify r31 as the frame
// pointer, but GCC always uses r31 when we need a frame pointer.
*bp = ucontext->uc_mcontext.regs->gpr[PT_R31];
# endif
#elif defined(__sparc__)
#if defined(__arch64__) || defined(__sparcv9)
#define STACK_BIAS 2047
......@@ -2187,17 +2194,6 @@ void CheckASLR() {
GetArgv()[0]);
Die();
}
#elif SANITIZER_PPC64V2
// Disable ASLR for Linux PPC64LE.
int old_personality = personality(0xffffffff);
if (old_personality != -1 && (old_personality & ADDR_NO_RANDOMIZE) == 0) {
VReport(1, "WARNING: Program is being run with address space layout "
"randomization (ASLR) enabled which prevents the thread and "
"memory sanitizers from working on powerpc64le.\n"
"ASLR will be disabled and the program re-executed.\n");
CHECK_NE(personality(old_personality | ADDR_NO_RANDOMIZE), -1);
ReExec();
}
#elif SANITIZER_FREEBSD
int aslr_pie;
uptr len = sizeof(aslr_pie);
......@@ -2227,6 +2223,18 @@ void CheckASLR() {
"and binaries compiled with PIE\n");
Die();
}
# elif SANITIZER_PPC64V2
// Disable ASLR for Linux PPC64LE.
int old_personality = personality(0xffffffff);
if (old_personality != -1 && (old_personality & ADDR_NO_RANDOMIZE) == 0) {
VReport(1,
"WARNING: Program is being run with address space layout "
"randomization (ASLR) enabled which prevents the thread and "
"memory sanitizers from working on powerpc64le.\n"
"ASLR will be disabled and the program re-executed.\n");
CHECK_NE(personality(old_personality | ADDR_NO_RANDOMIZE), -1);
ReExec();
}
#else
// Do nothing
#endif
......@@ -2251,9 +2259,9 @@ void CheckMPROTECT() {
Printf("This sanitizer is not compatible with enabled MPROTECT\n");
Die();
}
#else
# else
// Do nothing
#endif
# endif
}
void CheckNoDeepBind(const char *filename, int flag) {
......
......@@ -12,7 +12,22 @@
#include <cstdint>
#include <mutex>
#ifdef __linux__
#include <sys/platform/ppc.h>
#elif defined(__FreeBSD__)
#include <sys/types.h>
#include <sys/sysctl.h>
#define __ppc_get_timebase __builtin_ppc_get_timebase
uint64_t __ppc_get_timebase_freq (void)
{
uint64_t tb_freq = 0;
size_t length = sizeof(tb_freq);
sysctlbyname("kern.timecounter.tc.timebase.frequency", &tb_freq, &length, nullptr, 0);
return tb_freq;
}
#endif
#include "xray_defs.h"
......
......@@ -32,11 +32,38 @@ SUBDIR+= xray-fdr
SUBDIR+= xray-profiling
.endif # amd64
.if ${MACHINE_ARCH} == "powerpc64" || ${MACHINE_ARCH} == "powerpc64le"
SUBDIR+= include
SUBDIR+= asan
SUBDIR+= asan-preinit
SUBDIR+= asan_cxx
SUBDIR+= asan_dynamic
SUBDIR+= msan
SUBDIR+= msan_cxx
SUBDIR+= stats
SUBDIR+= stats_client
SUBDIR+= tsan
SUBDIR+= tsan_cxx
SUBDIR+= ubsan_minimal
SUBDIR+= ubsan_standalone
SUBDIR+= ubsan_standalone_cxx
.endif # powerpc64 || powerpc64le
.if ${MACHINE_ARCH} == "powerpc64le"
SUBDIR+= xray
SUBDIR+= xray-basic
SUBDIR+= xray-fdr
SUBDIR+= xray-profiling
.endif # powerpc64le
.if ${MACHINE_CPUARCH} == "riscv"
SUBDIR+= include
SUBDIR+= asan
SUBDIR+= asan-preinit
SUBDIR+= asan_cxx
SUBDIR+= asan_dynamic
SUBDIR+= stats
SUBDIR+= stats_client
SUBDIR+= ubsan_minimal
SUBDIR+= ubsan_standalone
SUBDIR+= ubsan_standalone_cxx
......
......@@ -38,9 +38,18 @@ SRCS+= xray/xray_flags.cpp
SRCS+= xray/xray_init.cpp
SRCS+= xray/xray_interface.cpp
SRCS+= xray/xray_log_interface.cpp
SRCS+= xray/xray_trampoline_x86_64.S
SRCS+= xray/xray_utils.cpp
.if ${MACHINE_CPUARCH} == amd64
SRCS+= xray/xray_trampoline_x86_64.S
SRCS+= xray/xray_x86_64.cpp
.endif # amd64
.if ${MACHINE_ARCH} == powerpc64le
SRCS+= xray/xray_powerpc64.cpp
SRCS+= xray/xray_trampoline_powerpc64.cpp
SRCS+= xray/xray_trampoline_powerpc64_asm.S
.endif # powerpc64le
.PATH: ${CRTSRC}/include/xray
INCSDIR= ${CLANGDIR}/include/xray
......
......@@ -197,7 +197,7 @@ tunable_mbinit(void *dummy)
* map.
*/
if (PMAP_HAS_DMAP) {
extpg = mb_use_ext_pgs;
extpg = 1;
TUNABLE_INT_FETCH("kern.ipc.mb_use_ext_pgs", &extpg);
mb_use_ext_pgs = extpg != 0;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment