From 29cb416107217b1d12c7e9d0b9371ddc7a74f04b Mon Sep 17 00:00:00 2001 From: SChernykh Date: Sat, 15 May 2021 21:41:39 +0200 Subject: [PATCH] Fixed broken light mode mining on x86 --- src/crypto/randomx/jit_compiler_x86.cpp | 8 ++++---- src/crypto/randomx/jit_compiler_x86.hpp | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/crypto/randomx/jit_compiler_x86.cpp b/src/crypto/randomx/jit_compiler_x86.cpp index 3442e1f4f..d7ebc25fe 100644 --- a/src/crypto/randomx/jit_compiler_x86.cpp +++ b/src/crypto/randomx/jit_compiler_x86.cpp @@ -320,7 +320,7 @@ namespace randomx { vm_flags = flags; - generateProgramPrologue(prog, pcfg); + generateProgramPrologue(prog, pcfg, false); uint8_t* p; uint32_t n; @@ -339,7 +339,7 @@ namespace randomx { } void JitCompilerX86::generateProgramLight(Program& prog, ProgramConfiguration& pcfg, uint32_t datasetOffset) { - generateProgramPrologue(prog, pcfg); + generateProgramPrologue(prog, pcfg, true); emit(RandomX_CurrentConfig.codeReadDatasetLightSshInitTweaked, readDatasetLightInitSize, code, codePos); *(uint32_t*)(code + codePos) = 0xc381; codePos += 2; @@ -415,7 +415,7 @@ namespace randomx { } } - void JitCompilerX86::generateProgramPrologue(Program& prog, ProgramConfiguration& pcfg) { + void JitCompilerX86::generateProgramPrologue(Program& prog, ProgramConfiguration& pcfg, bool light) { codePos = ADDR(randomx_program_prologue_first_load) - ADDR(randomx_program_prologue); *(uint32_t*)(code + codePos + 4) = RandomX_CurrentConfig.ScratchpadL3Mask64_Calculated; *(uint32_t*)(code + codePos + 14) = RandomX_CurrentConfig.ScratchpadL3Mask64_Calculated; @@ -429,7 +429,7 @@ namespace randomx { # endif imul_rcp_storage = code + (ADDR(randomx_program_imul_rcp_store) - codePrologue) + 2; - imul_rcp_storage_used = 0; + imul_rcp_storage_used = light ? 0xFFFFFFFFUL : 0; memcpy(imul_rcp_storage - 34, &pcfg.eMask, sizeof(pcfg.eMask)); codePos = codePosFirst; diff --git a/src/crypto/randomx/jit_compiler_x86.hpp b/src/crypto/randomx/jit_compiler_x86.hpp index abc8e74f1..b1bd42aa8 100644 --- a/src/crypto/randomx/jit_compiler_x86.hpp +++ b/src/crypto/randomx/jit_compiler_x86.hpp @@ -107,7 +107,7 @@ namespace randomx { uint8_t* imul_rcp_storage = nullptr; uint32_t imul_rcp_storage_used = 0; - void generateProgramPrologue(Program&, ProgramConfiguration&); + void generateProgramPrologue(Program&, ProgramConfiguration&, bool light); void generateProgramEpilogue(Program&, ProgramConfiguration&); template static void genAddressReg(const Instruction&, const uint32_t src, uint8_t* code, uint32_t& codePos);