Merge pull request #3129 from SChernykh/dev

Fix: protectRX flushed CPU cache only on MacOS/iOS
This commit is contained in:
xmrig 2022-09-22 07:02:28 +07:00 committed by GitHub
commit bc4dd11761
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -112,13 +112,19 @@ bool xmrig::VirtualMemory::protectRWX(void *p, size_t size)
bool xmrig::VirtualMemory::protectRX(void *p, size_t size)
{
bool result = true;
# if defined(XMRIG_OS_APPLE) && defined(XMRIG_ARM)
pthread_jit_write_protect_np(true);
flushInstructionCache(p, size);
return true;
# else
return mprotect(p, size, PROT_READ | PROT_EXEC) == 0;
result = (mprotect(p, size, PROT_READ | PROT_EXEC) == 0);
# endif
# if defined(XMRIG_ARM)
flushInstructionCache(p, size);
# endif
return result;
}