From 03612743660f446a1fb6927e9bed0522f4d5c5d8 Mon Sep 17 00:00:00 2001 From: Billy Laws Date: Tue, 8 Jul 2025 18:39:36 +0100 Subject: [PATCH] Windows: Support enabling hardware TSO on Asahi Relies on a wine-side patch to expose the prctl to the PE-side --- Source/Windows/ARM64EC/Module.cpp | 9 +++++++++ Source/Windows/WOW64/Module.cpp | 9 +++++++++ Source/Windows/include/winternl.h | 2 ++ 3 files changed, 20 insertions(+) diff --git a/Source/Windows/ARM64EC/Module.cpp b/Source/Windows/ARM64EC/Module.cpp index 38c262c01..c842e0d01 100644 --- a/Source/Windows/ARM64EC/Module.cpp +++ b/Source/Windows/ARM64EC/Module.cpp @@ -653,6 +653,15 @@ NTSTATUS ProcessInit() { const uintptr_t KiUserExceptionDispatcherFFS = reinterpret_cast(GetProcAddress(NtDll, "KiUserExceptionDispatcher")); Exception::KiUserExceptionDispatcher = NtDllRedirectionLUT[KiUserExceptionDispatcherFFS - NtDllBase] + NtDllBase; + FEX_CONFIG_OPT(TSOEnabled, TSOENABLED); + if (TSOEnabled()) { + BOOL Enable = TRUE; + NTSTATUS Status = NtSetInformationProcess(NtCurrentProcess(), ProcessFexHardwareTso, &Enable, sizeof(Enable)); + if (Status == STATUS_SUCCESS) { + CTX->SetHardwareTSOSupport(true); + } + } + FEX_CONFIG_OPT(ProfileStats, PROFILESTATS); FEX_CONFIG_OPT(StartupSleep, STARTUPSLEEP); FEX_CONFIG_OPT(StartupSleepProcName, STARTUPSLEEPPROCNAME); diff --git a/Source/Windows/WOW64/Module.cpp b/Source/Windows/WOW64/Module.cpp index c4f093ac6..248458ab0 100644 --- a/Source/Windows/WOW64/Module.cpp +++ b/Source/Windows/WOW64/Module.cpp @@ -520,6 +520,15 @@ void BTCpuProcessInit() { // wow64.dll will only initialise the cross-process queue if this is set GetTLS().Wow64Info().CpuFlags = WOW64_CPUFLAGS_SOFTWARE; + FEX_CONFIG_OPT(TSOEnabled, TSOENABLED); + if (TSOEnabled()) { + BOOL Enable = TRUE; + NTSTATUS Status = NtSetInformationProcess(NtCurrentProcess(), ProcessFexHardwareTso, &Enable, sizeof(Enable)); + if (Status == STATUS_SUCCESS) { + CTX->SetHardwareTSOSupport(true); + } + } + FEX_CONFIG_OPT(ProfileStats, PROFILESTATS); FEX_CONFIG_OPT(StartupSleep, STARTUPSLEEP); FEX_CONFIG_OPT(StartupSleepProcName, STARTUPSLEEPPROCNAME); diff --git a/Source/Windows/include/winternl.h b/Source/Windows/include/winternl.h index 3f680ba73..6714fa44a 100644 --- a/Source/Windows/include/winternl.h +++ b/Source/Windows/include/winternl.h @@ -452,6 +452,8 @@ typedef enum _MEMORY_INFORMATION_CLASS { MemoryFexStatsShm = 2000, } MEMORY_INFORMATION_CLASS; +#define ProcessFexHardwareTso (PROCESSINFOCLASS)2000 + typedef enum _KEY_VALUE_INFORMATION_CLASS { KeyValueBasicInformation, KeyValueFullInformation,