fix for crashes on TLS due to openorbis being W E I R D

This commit is contained in:
lizzie 2025-12-26 12:11:05 +00:00
parent c9c3762c8e
commit cf2d3a15bc
3 changed files with 30 additions and 3 deletions

View file

@ -196,7 +196,14 @@ struct Values {
linkage, false, "dump_audio_commands", Category::Audio, Specialization::Default, false};
// Core
SwitchableSetting<bool> use_multi_core{linkage, true, "use_multi_core", Category::Core};
SwitchableSetting<bool> use_multi_core{linkage,
#ifdef __OPENORBIS__
// Re-enable once proper TLS support is added
false,
#else
true,
#endif
"use_multi_core", Category::Core};
SwitchableSetting<MemoryLayout, true> memory_layout_mode{linkage,
MemoryLayout::Memory_4Gb,
"memory_layout_mode",

View file

@ -104,6 +104,7 @@ struct Ucontext {
}
static boost::container::static_vector<std::pair<void*, size_t>, 16> swap_regions;
extern "C" int sceKernelRemoveExceptionHandler(s32 sig_num);
static void SwapHandler(int sig, void* raw_context) {
auto& mctx = ((Orbis::Ucontext*)raw_context)->uc_mcontext;
if (std::ranges::find_if(swap_regions, [addr = mctx.mc_addr](auto const& e) {
@ -116,8 +117,8 @@ static void SwapHandler(int sig, void* raw_context) {
void* res = mmap(aligned_addr, page_size, PROT_READ | PROT_WRITE, MAP_FIXED | MAP_ANON | MAP_PRIVATE, -1, 0);
ASSERT(res != MAP_FAILED);
} else {
LOG_ERROR(HW_Memory, "fault in addr {:#x}", mctx.mc_addr);
sceSystemServiceLoadExec("EXIT", nullptr);
LOG_ERROR(HW_Memory, "fault in addr {:#x} at {:#x}", mctx.mc_addr, mctx.mc_rip); // print caller address
sceKernelRemoveExceptionHandler(SIGSEGV); // to not catch the next signal
}
}
void InitSwap() noexcept {