summaryrefslogtreecommitdiff
path: root/Source/Core/Common/x64CPUDetect.cpp
diff options
context:
space:
mode:
authorPierre Bourdon <delroth@gmail.com>2022-06-23 07:34:34 +0200
committerGitHub <noreply@github.com>2022-06-23 07:34:34 +0200
commit2bd72dfc6f956c27337934e9a1a2652a05bd976f (patch)
treebe474f698546a7659a81a382729e7a5d0a8b2ac3 /Source/Core/Common/x64CPUDetect.cpp
parentc8e716234e479d8b9714962a498648441c11e112 (diff)
parent29ddd0e6f05d0489a0e92e0014d2db10dfcd4095 (diff)
Merge pull request #10758 from shuffle2/x64-on-arm64
windows: detect and warn if running x64 dolphin on arm64
Diffstat (limited to 'Source/Core/Common/x64CPUDetect.cpp')
-rw-r--r--Source/Core/Common/x64CPUDetect.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/Source/Core/Common/x64CPUDetect.cpp b/Source/Core/Common/x64CPUDetect.cpp
index 644d485ed8..5f90246302 100644
--- a/Source/Core/Common/x64CPUDetect.cpp
+++ b/Source/Core/Common/x64CPUDetect.cpp
@@ -3,12 +3,17 @@
#include "Common/CPUDetect.h"
+#ifdef _WIN32
+#include <processthreadsapi.h>
+#endif
+
#include <cstring>
#include <string>
#include <thread>
#include "Common/CommonTypes.h"
#include "Common/Intrinsics.h"
+#include "Common/MsgHandler.h"
#ifndef _WIN32
@@ -48,6 +53,29 @@ static u64 xgetbv(u32 index)
}
constexpr u32 XCR_XFEATURE_ENABLED_MASK = _XCR_XFEATURE_ENABLED_MASK;
+static void WarnIfRunningUnderEmulation()
+{
+ // Starting with win11, arm64 windows can run x64 processes under emulation.
+ // This detects such a scenario and informs the user they probably want to run a native build.
+ PROCESS_MACHINE_INFORMATION info{};
+ if (!GetProcessInformation(GetCurrentProcess(), ProcessMachineTypeInfo, &info, sizeof(info)))
+ {
+ // Possibly we are running on version of windows which doesn't support ProcessMachineTypeInfo.
+ return;
+ }
+ if (info.MachineAttributes & MACHINE_ATTRIBUTES::KernelEnabled)
+ {
+ // KernelEnabled will be set if process arch matches the kernel arch - how we want people to run
+ // dolphin.
+ return;
+ }
+
+ // The process is not native; could use IsWow64Process2 to get native machine type, but for now
+ // we can assume it is arm64.
+ PanicAlertFmtT("This build of Dolphin is not natively compiled for your CPU.\n"
+ "Please run the ARM64 build of Dolphin for a better experience.");
+}
+
#else
static u64 xgetbv(u32 index)
@@ -69,6 +97,10 @@ CPUInfo::CPUInfo()
// Detects the various CPU features
void CPUInfo::Detect()
{
+#ifdef _WIN32
+ WarnIfRunningUnderEmulation();
+#endif
+
#ifdef _M_X86_64
Mode64bit = true;
OS64bit = true;