Make filter check for SSE4a

This commit is contained in:
offtkp 2024-08-28 23:18:05 +03:00
parent 96afa3d8ee
commit 4f6fe82936
1 changed files with 5 additions and 4 deletions

View File

@ -5,6 +5,7 @@
#include <mutex>
#include <Zydis/Zydis.h>
#include <xbyak/xbyak.h>
#include <xbyak/xbyak_util.h>
#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<ZydisMnemonic, PatchInfo> 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.