Added generic secure JIT support for RandomX.

This commit is contained in:
XMRig 2020-12-11 23:17:54 +07:00
parent f9c0933f05
commit ec62ded279
No known key found for this signature in database
GPG key ID: 446A53638BE94409
19 changed files with 227 additions and 110 deletions

View file

@ -1,6 +1,7 @@
/*
Copyright (c) 2018-2019, tevador <tevador@gmail.com>
Copyright (c) 2019, SChernykh <https://github.com/SChernykh>
Copyright (c) 2018-2020, tevador <tevador@gmail.com>
Copyright (c) 2019-2020, SChernykh <https://github.com/SChernykh>
Copyright (c) 2019-2020, XMRig <https://github.com/xmrig>, <support@xmrig.com>
All rights reserved.
@ -28,9 +29,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "crypto/randomx/jit_compiler_a64.hpp"
#include "crypto/randomx/superscalar.hpp"
#include "crypto/common/VirtualMemory.h"
#include "crypto/randomx/program.hpp"
#include "crypto/randomx/reciprocal.h"
#include "crypto/randomx/superscalar.hpp"
#include "crypto/randomx/virtual_memory.hpp"
static bool hugePagesJIT = false;
@ -357,6 +359,21 @@ size_t JitCompilerA64::getCodeSize()
return CodeSize;
}
void JitCompilerA64::enableWriting()
{
xmrig::VirtualMemory::protectRW(code, CodeSize + CalcDatasetItemSize());
}
void JitCompilerA64::enableExecution()
{
xmrig::VirtualMemory::protectRX(code, CodeSize + CalcDatasetItemSize());
}
void JitCompilerA64::enableAll()
{
xmrig::VirtualMemory::protectRWX(code, CodeSize + CalcDatasetItemSize());
}
void JitCompilerA64::emitMovImmediate(uint32_t dst, uint32_t imm, uint8_t* code, uint32_t& codePos)
{
uint32_t k = codePos;