mirror of
https://github.com/FEX-Emu/FEX.git
synced 2026-10-06 14:00:16 +02:00
Windows: Enable downstream kernel-side unaligned atomic handling
This commit is contained in:
1 parent
04259f031d
commit
24d61e1125
4 files changed
+25
-5
No files matched your search
@@ -640,7 +640,6 @@ NTSTATUS ProcessInit() {
|
||||
|
||||
SignalDelegator = fextl::make_unique<FEX::DummyHandlers::DummySignalDelegator>();
|
||||
SyscallHandler = fextl::make_unique<Exception::ECSyscallHandler>();
|
||||
Exception::HandlerConfig.emplace();
|
||||
|
||||
const auto NtDll = GetModuleHandle("ntdll.dll");
|
||||
const bool IsWine = !!GetProcAddress(NtDll, "wine_get_version");
|
||||
@@ -654,7 +653,7 @@ NTSTATUS ProcessInit() {
|
||||
CTX->SetSignalDelegator(SignalDelegator.get());
|
||||
CTX->SetSyscallHandler(SyscallHandler.get());
|
||||
CTX->InitCore();
|
||||
|
||||
Exception::HandlerConfig.emplace(*CTX);
|
||||
InvalidationTracker.emplace(*CTX, Threads);
|
||||
|
||||
HandleImageMap(NtDllBase);
|
||||
|
||||
@@ -1,18 +1,32 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
#pragma once
|
||||
|
||||
#include <FEXCore/Core/Context.h>
|
||||
#include <FEXCore/Config/Config.h>
|
||||
#include <FEXCore/Utils/ArchHelpers/Arm64.h>
|
||||
|
||||
namespace FEX::Windows {
|
||||
class TSOHandlerConfig final {
|
||||
public:
|
||||
TSOHandlerConfig() {
|
||||
TSOHandlerConfig(FEXCore::Context::Context& CTX) {
|
||||
if (HalfBarrierTSOEnabled()) {
|
||||
UnalignedHandlerType = FEXCore::ArchHelpers::Arm64::UnalignedHandlerType::HalfBarrier;
|
||||
} else {
|
||||
UnalignedHandlerType = FEXCore::ArchHelpers::Arm64::UnalignedHandlerType::NonAtomic;
|
||||
}
|
||||
|
||||
if (TSOEnabled()) {
|
||||
BOOL Enable = TRUE;
|
||||
NTSTATUS Status = NtSetInformationProcess(NtCurrentProcess(), ProcessFexHardwareTso, &Enable, sizeof(Enable));
|
||||
if (Status == STATUS_SUCCESS) {
|
||||
CTX.SetHardwareTSOSupport(true);
|
||||
}
|
||||
}
|
||||
|
||||
uint64_t Flags =
|
||||
(StrictInProcessSplitLocks() ? FEX_UNALIGN_ATOMIC_STRICT_SPLIT_LOCKS : 0) | FEX_UNALIGN_ATOMIC_BACKPATCH | FEX_UNALIGN_ATOMIC_EMULATE;
|
||||
|
||||
NtSetInformationProcess(NtCurrentProcess(), ProcessFexUnalignAtomic, &Flags, sizeof(Flags));
|
||||
}
|
||||
|
||||
FEXCore::ArchHelpers::Arm64::UnalignedHandlerType GetUnalignedHandlerType() const {
|
||||
@@ -20,7 +34,9 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
FEX_CONFIG_OPT(TSOEnabled, TSOENABLED);
|
||||
FEX_CONFIG_OPT(HalfBarrierTSOEnabled, HALFBARRIERTSOENABLED);
|
||||
FEX_CONFIG_OPT(StrictInProcessSplitLocks, STRICTINPROCESSSPLITLOCKS);
|
||||
|
||||
FEXCore::ArchHelpers::Arm64::UnalignedHandlerType UnalignedHandlerType {FEXCore::ArchHelpers::Arm64::UnalignedHandlerType::HalfBarrier};
|
||||
};
|
||||
|
||||
@@ -523,7 +523,6 @@ void BTCpuProcessInit() {
|
||||
|
||||
SignalDelegator = fextl::make_unique<FEX::DummyHandlers::DummySignalDelegator>();
|
||||
SyscallHandler = fextl::make_unique<WowSyscallHandler>();
|
||||
Context::HandlerConfig.emplace();
|
||||
const auto NtDll = GetModuleHandle("ntdll.dll");
|
||||
const bool IsWine = !!GetProcAddress(NtDll, "wine_get_version");
|
||||
OvercommitTracker.emplace(IsWine);
|
||||
@@ -538,7 +537,7 @@ void BTCpuProcessInit() {
|
||||
CTX->SetSignalDelegator(SignalDelegator.get());
|
||||
CTX->SetSyscallHandler(SyscallHandler.get());
|
||||
CTX->InitCore();
|
||||
|
||||
Context::HandlerConfig.emplace(*CTX);
|
||||
InvalidationTracker.emplace(*CTX, Threads);
|
||||
|
||||
auto NtDllX86 = reinterpret_cast<SYSTEM_DLL_INIT_BLOCK*>(GetProcAddress(NtDll, "LdrSystemDllInitBlock"))->ntdll_handle;
|
||||
|
||||
@@ -455,6 +455,12 @@ typedef enum _MEMORY_INFORMATION_CLASS {
|
||||
#define SystemEmulationBasicInformation (SYSTEM_INFORMATION_CLASS)62
|
||||
|
||||
#define ProcessFexHardwareTso (PROCESSINFOCLASS)2000
|
||||
#define ProcessFexUnalignAtomic (PROCESSINFOCLASS)2001
|
||||
|
||||
// These match the prctl flag values
|
||||
#define FEX_UNALIGN_ATOMIC_EMULATE (1ULL << 0)
|
||||
#define FEX_UNALIGN_ATOMIC_BACKPATCH (1ULL << 1)
|
||||
#define FEX_UNALIGN_ATOMIC_STRICT_SPLIT_LOCKS (1ULL << 2)
|
||||
|
||||
typedef enum _KEY_VALUE_INFORMATION_CLASS {
|
||||
KeyValueBasicInformation,
|
||||
|
||||
Reference in new issue
Block a user