Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Workaround broken special APC when running x64 on arm64 windows #102333

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/coreclr/vm/threads.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@

#ifdef FEATURE_SPECIAL_USER_MODE_APC
#include "asmconstants.h"
#include <versionhelpers.h>
#endif

static const PortableTailCallFrame g_sentinelTailCallFrame = { NULL, NULL };
Expand Down Expand Up @@ -8130,6 +8131,21 @@ void Thread::InitializeSpecialUserModeApc()

HMODULE hKernel32 = WszLoadLibrary(WINDOWS_KERNEL32_DLLNAME_W, NULL, LOAD_LIBRARY_SEARCH_SYSTEM32);

#ifdef HOST_AMD64
typedef BOOL (WINAPI *IsWow64Process2Proc)(HANDLE hProcess, USHORT *pProcessMachine, USHORT *pNativeMachine);

IsWow64Process2Proc pfnIsWow64Process2Proc = (IsWow64Process2Proc)GetProcAddress(hKernel32, "IsWow64Process2");
USHORT processMachine, hostMachine;
if (pfnIsWow64Process2Proc != nullptr &&
(*pfnIsWow64Process2Proc)(GetCurrentProcess(), &processMachine, &hostMachine) &&
(hostMachine == IMAGE_FILE_MACHINE_ARM64) &&
!IsWindowsVersionOrGreater(10, 0, 26100))
jkotas marked this conversation as resolved.
Show resolved Hide resolved
{
// Special user-mode APCs are broken on WOW64 processes (x64 running on Arm64 machine) with Windows older than 11.0.26100 (24H2)
return;
}
#endif // HOST_AMD64

// See if QueueUserAPC2 exists
QueueUserAPC2Proc pfnQueueUserAPC2Proc = (QueueUserAPC2Proc)GetProcAddress(hKernel32, "QueueUserAPC2");
if (pfnQueueUserAPC2Proc == nullptr)
Expand Down
Loading