From f11efcd32485ed6780685b7703a1c319cbfee838 Mon Sep 17 00:00:00 2001 From: DH Date: Thu, 13 Jul 2023 17:50:36 +0300 Subject: [PATCH] [rpcsx-os] use 8mb for alt stack --- rpcsx-os/main.cpp | 8 +++++--- rpcsx-os/ops.cpp | 8 ++++++-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/rpcsx-os/main.cpp b/rpcsx-os/main.cpp index 37d7db9e..ad02216c 100644 --- a/rpcsx-os/main.cpp +++ b/rpcsx-os/main.cpp @@ -1,3 +1,4 @@ +#include "align.hpp" #include "amdgpu/bridge/bridge.hpp" #include "backtrace.hpp" #include "bridge.hpp" @@ -85,14 +86,15 @@ handle_signal(int sig, siginfo_t *info, void *ucontext) { static void setupSigHandlers() { stack_t ss; - - ss.ss_sp = malloc(SIGSTKSZ); + auto sigStackSize = std::max( + SIGSTKSZ, utils::alignUp(8 * 1024 * 1024, sysconf(_SC_PAGE_SIZE))); + ss.ss_sp = malloc(sigStackSize); if (ss.ss_sp == NULL) { perror("malloc"); exit(EXIT_FAILURE); } - ss.ss_size = SIGSTKSZ; + ss.ss_size = sigStackSize; ss.ss_flags = 0; if (sigaltstack(&ss, NULL) == -1) { diff --git a/rpcsx-os/ops.cpp b/rpcsx-os/ops.cpp index 099a420c..bd276285 100644 --- a/rpcsx-os/ops.cpp +++ b/rpcsx-os/ops.cpp @@ -1,4 +1,5 @@ #include "ops.hpp" +#include "align.hpp" #include "io-device.hpp" #include "linker.hpp" #include "orbis/module/ModuleHandle.hpp" @@ -473,13 +474,16 @@ SysResult thr_new(orbis::Thread *thread, orbis::ptr param, std::thread{[=, childThread = Ref(childThread)] { stack_t ss; - ss.ss_sp = malloc(SIGSTKSZ); + auto sigStackSize = std::max( + SIGSTKSZ, ::utils::alignUp(8 * 1024 * 1024, sysconf(_SC_PAGE_SIZE))); + + ss.ss_sp = malloc(sigStackSize); if (ss.ss_sp == NULL) { perror("malloc"); exit(EXIT_FAILURE); } - ss.ss_size = SIGSTKSZ; + ss.ss_size = sigStackSize; ss.ss_flags = 0; if (sigaltstack(&ss, NULL) == -1) {