diff --git a/src/core/arm/nce/arm_nce.cpp b/src/core/arm/nce/arm_nce.cpp index 946bcad123..f6ecefaacb 100644 --- a/src/core/arm/nce/arm_nce.cpp +++ b/src/core/arm/nce/arm_nce.cpp @@ -137,8 +137,6 @@ HaltReason ArmNce::ReturnToRunCodeByExceptionLevelChange(int tid, void *tpidr) { YUZU_NAKED_END #else HaltReason ArmNce::ReturnToRunCodeByExceptionLevelChange(void* tid, void *tpidr) { - DEBUG_ASSERT(TlsGetValue(ContextKey) == tpidr); - RaiseException(ExceptionLevelChangeSignal, 0, 0, nullptr); // TODO: pass tpidr through arguments? __builtin_unreachable(); } @@ -229,7 +227,7 @@ static_assert(offsetof(HostContext, host_sp) == 0xE0); // TODO: don't use magic void ArmNce::BreakFromRunCodeSignalHandler(int sig, void *info, void *raw_context) { NativeExecutionParameters* tpidr = static_cast(GetGuestParameters()); -#if defined(__APPLE__) +#if defined(__APPLE__) || defined(_WIN32) if (tpidr->is_actually_running) { tpidr->is_actually_running = false; #else @@ -309,7 +307,7 @@ void ArmNce::GuestMemoryFaultSignalHandler(int sig, void* raw_info, void* raw_co return; ret: -#ifndef __APPLE__ +#if defined(__linux__) asm volatile( "msr TPIDR_EL0, %0\n" :: "r"(nep)); @@ -457,7 +455,7 @@ HaltReason ArmNce::RunThread(Kernel::KThread* thread) { #if defined(__APPLE__) ASSERT(pthread_setspecific(ContextKey, &thread_params) == 0); #elif defined(_WIN32) - ASSERT(TlsSetValue(ContextKey, &thread_params) == 0); + ASSERT_MSG(TlsSetValue(ContextKey, &thread_params) == 0, "Failed to set TLS value: id {}, error {}", ContextKey, GetLastError()); #endif // Move non-critical operations outside the locked section diff --git a/src/core/arm/nce/arm_nce.h b/src/core/arm/nce/arm_nce.h index 3663d24d44..f7d546a59f 100644 --- a/src/core/arm/nce/arm_nce.h +++ b/src/core/arm/nce/arm_nce.h @@ -37,9 +37,9 @@ constexpr pthread_key_t ContextKey = 210; #define ExceptionLevelChangeSignal 0xE0000001 inline thread_local bool is_host_fault = false; -static const u32 ContextKey = TlsAlloc(); -static const u32 NCEStorage = TlsAlloc(); -static const u64 TlsSlots = offsetof(TEB, TlsSlots); +inline u32 ContextKey = TlsAlloc(); +inline u32 NCEStorage = TlsAlloc(); +constexpr u64 TlsSlots = offsetof(TEB, TlsSlots); #endif