From 3e4743512d56a0e50521744f754e453a5cd2f595 Mon Sep 17 00:00:00 2001 From: Ryan Houdek Date: Wed, 11 Sep 2019 23:25:19 -0700 Subject: [PATCH] Stub FXSave and FXRStor instructions. Necessary for launching dynamic apps from ld.so --- Source/Interface/Core/OpcodeDispatcher.cpp | 12 ++++++++++++ Source/Interface/Core/OpcodeDispatcher.h | 3 +++ Source/Interface/Core/X86Tables.cpp | 4 ++-- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/Source/Interface/Core/OpcodeDispatcher.cpp b/Source/Interface/Core/OpcodeDispatcher.cpp index 631f2061c..24b5a4406 100644 --- a/Source/Interface/Core/OpcodeDispatcher.cpp +++ b/Source/Interface/Core/OpcodeDispatcher.cpp @@ -3150,6 +3150,14 @@ void OpDispatchBuilder::MOVDDUPOp(OpcodeArgs) { StoreResult(Op, Res); } +void OpDispatchBuilder::FXSaveOp(OpcodeArgs) { +} + +void OpDispatchBuilder::FXRStoreOp(OpcodeArgs) { +} + + + #undef OpcodeArgs void InstallOpcodeHandlers() { @@ -3457,6 +3465,10 @@ constexpr uint16_t PF_F2 = 3; {OPD(FEXCore::X86Tables::TYPE_GROUP_14, PF_66, 3), 1, &OpDispatchBuilder::PSRLDQ}, {OPD(FEXCore::X86Tables::TYPE_GROUP_14, PF_66, 7), 1, &OpDispatchBuilder::PSLL<16, true>}, + // GROUP 15 + {OPD(FEXCore::X86Tables::TYPE_GROUP_15, PF_NONE, 0), 1, &OpDispatchBuilder::FXSaveOp}, + {OPD(FEXCore::X86Tables::TYPE_GROUP_15, PF_NONE, 1), 1, &OpDispatchBuilder::FXRStoreOp}, + // GROUP 16 {OPD(FEXCore::X86Tables::TYPE_GROUP_16, PF_NONE, 0), 8, &OpDispatchBuilder::NOPOp}, {OPD(FEXCore::X86Tables::TYPE_GROUP_16, PF_F3, 0), 8, &OpDispatchBuilder::NOPOp}, diff --git a/Source/Interface/Core/OpcodeDispatcher.h b/Source/Interface/Core/OpcodeDispatcher.h index 1265f0ba0..715b56661 100644 --- a/Source/Interface/Core/OpcodeDispatcher.h +++ b/Source/Interface/Core/OpcodeDispatcher.h @@ -125,6 +125,9 @@ public: template void SHUFOp(OpcodeArgs); + void FXSaveOp(OpcodeArgs); + void FXRStoreOp(OpcodeArgs); + #undef OpcodeArgs /** diff --git a/Source/Interface/Core/X86Tables.cpp b/Source/Interface/Core/X86Tables.cpp index 4db981122..f697f92da 100644 --- a/Source/Interface/Core/X86Tables.cpp +++ b/Source/Interface/Core/X86Tables.cpp @@ -1294,8 +1294,8 @@ void InitializeInfoTables() { {OPD(TYPE_GROUP_14, PF_F2, 7), 1, X86InstInfo{"", TYPE_INVALID, FLAGS_NONE, 0, nullptr}}, // GROUP 15 - {OPD(TYPE_GROUP_15, PF_NONE, 0), 1, X86InstInfo{"FXSAVE", TYPE_MMX, FLAGS_NONE, 0, nullptr}}, // MMX/x87 - {OPD(TYPE_GROUP_15, PF_NONE, 1), 1, X86InstInfo{"FXRSTOR", TYPE_MMX, FLAGS_NONE, 0, nullptr}}, // MMX/x87 + {OPD(TYPE_GROUP_15, PF_NONE, 0), 1, X86InstInfo{"FXSAVE", TYPE_INST, FLAGS_MODRM | FLAGS_SF_MOD_DST, 0, nullptr}}, // MMX/x87 + {OPD(TYPE_GROUP_15, PF_NONE, 1), 1, X86InstInfo{"FXRSTOR", TYPE_INST, FLAGS_MODRM, 0, nullptr}}, // MMX/x87 {OPD(TYPE_GROUP_15, PF_NONE, 2), 1, X86InstInfo{"LDMXCSR", TYPE_INST, FLAGS_MODRM | FLAGS_SF_MOD_DST | FLAGS_SF_MOD_MEM_ONLY, 0, nullptr}}, {OPD(TYPE_GROUP_15, PF_NONE, 3), 1, X86InstInfo{"STMXCSR", TYPE_INST, FLAGS_MODRM | FLAGS_SF_MOD_DST | FLAGS_SF_MOD_MEM_ONLY, 0, nullptr}}, {OPD(TYPE_GROUP_15, PF_NONE, 4), 1, X86InstInfo{"XSAVE", TYPE_PRIV, FLAGS_NONE, 0, nullptr}},