From 4f6fe8293640347b910bc9555185e12b6cb4c009 Mon Sep 17 00:00:00 2001 From: offtkp Date: Wed, 28 Aug 2024 23:18:05 +0300 Subject: [PATCH] Make filter check for SSE4a --- src/core/cpu_patches.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/core/cpu_patches.cpp b/src/core/cpu_patches.cpp index 857c1537..29c9fa88 100644 --- a/src/core/cpu_patches.cpp +++ b/src/core/cpu_patches.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include "common/assert.h" #include "common/types.h" #include "core/tls.h" @@ -289,9 +290,9 @@ static bool FilterTcbAccess(const ZydisDecodedOperand* operands) { dst_op.reg.value <= ZYDIS_REGISTER_R15; } -// For instructions that always need to be patched -static bool FilterAlwaysTrue(const ZydisDecodedOperand*) { - return true; +static bool FilterNoSSE4a(const ZydisDecodedOperand*) { + Xbyak::util::Cpu cpu; + return !cpu.has(Xbyak::util::Cpu::tSSE4a); } static void GenerateTcbAccess(const ZydisDecodedOperand* operands, Xbyak::CodeGenerator& c) { @@ -483,7 +484,7 @@ static const std::unordered_map Patches = { {ZYDIS_MNEMONIC_MOV, {FilterTcbAccess, GenerateTcbAccess, false}}, #endif - {ZYDIS_MNEMONIC_INSERTQ, {FilterAlwaysTrue, GenerateINSERTQ, true}}, + {ZYDIS_MNEMONIC_INSERTQ, {FilterNoSSE4a, GenerateINSERTQ, true}}, #ifdef __APPLE__ // BMI1 instructions that are not supported by Rosetta 2 on Apple Silicon.