mirror of
https://github.com/FEX-Emu/FEX.git
synced 2026-10-06 10:00:16 +02:00
WOW64: Handle unaligned atomic accesses
This is done in EnsureConsistentState rather than as a VEH to avoid needing to go through all of wine's exception handling logic for such a hot path.
This commit is contained in:
1 parent
be4fcaf65c
commit
22b1fea96d
1 file changed
+27
@@ -204,6 +204,21 @@ namespace Context {
|
||||
Context::StoreWowContextFromState(TLS.ThreadState(), &TmpWowContext);
|
||||
return RtlWow64SetThreadContext(Thread, &TmpWowContext);
|
||||
}
|
||||
|
||||
bool HandleUnalignedAccess(CONTEXT *Context) {
|
||||
if (!GetTLS().ThreadState()->CPUBackend->IsAddressInCodeBuffer(Context->Pc)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
FEX_CONFIG_OPT(ParanoidTSO, PARANOIDTSO);
|
||||
const auto Result = FEXCore::ArchHelpers::Arm64::HandleUnalignedAccess(ParanoidTSO(), Context->Pc, &Context->X0);
|
||||
if (!Result.first) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Context->Pc += Result.second;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
namespace Logging {
|
||||
@@ -423,6 +438,18 @@ void BTCpuSimulate() {
|
||||
}
|
||||
}
|
||||
|
||||
NTSTATUS BTCpuResetToConsistentState(EXCEPTION_POINTERS *Ptrs) {
|
||||
auto *Context = Ptrs->ContextRecord;
|
||||
const auto *Exception = Ptrs->ExceptionRecord;
|
||||
|
||||
if (Exception->ExceptionCode == EXCEPTION_DATATYPE_MISALIGNMENT && Context::HandleUnalignedAccess(Context)) {
|
||||
LogMan::Msg::DFmt("Handled unaligned atomic: new pc: {:X}", Context->Pc);
|
||||
NtContinue(Context, FALSE);
|
||||
}
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
BOOLEAN WINAPI BTCpuIsProcessorFeaturePresent(UINT Feature) {
|
||||
switch (Feature) {
|
||||
case PF_FLOATING_POINT_PRECISION_ERRATA:
|
||||
|
||||
Reference in new issue
Block a user