Skip to content

Commit ff88a57

Browse files
committed
Fixed reading from the red zone
1 parent e758c1e commit ff88a57

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

doc/program.asm

+3-2
Original file line numberDiff line numberDiff line change
@@ -605,8 +605,9 @@ randomx_isn_155:
605605
rol rax, 31
606606
and eax, 24576
607607
or eax, 40896
608-
mov dword ptr [rsp-8], eax
609-
ldmxcsr dword ptr [rsp-8]
608+
push rax
609+
ldmxcsr dword ptr [rsp]
610+
pop rax
610611
randomx_isn_156:
611612
; FSUB_R f3, a2
612613
subpd xmm3, xmm10

src/assembly_generator_x86.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -535,8 +535,9 @@ namespace randomx {
535535
asmCode << "\trol rax, " << rotate << std::endl;
536536
asmCode << "\tand eax, 24576" << std::endl;
537537
asmCode << "\tor eax, 40896" << std::endl;
538-
asmCode << "\tmov dword ptr [rsp-8], eax" << std::endl;
539-
asmCode << "\tldmxcsr dword ptr [rsp-8]" << std::endl;
538+
asmCode << "\tpush rax" << std::endl;
539+
asmCode << "\tldmxcsr dword ptr [rsp]" << std::endl;
540+
asmCode << "\tpop rax" << std::endl;
540541
tracenop(instr);
541542
}
542543

src/jit_compiler_x86.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ namespace randomx {
194194
static const uint8_t REX_MAXPD[] = { 0x66, 0x41, 0x0f, 0x5f };
195195
static const uint8_t REX_DIVPD[] = { 0x66, 0x41, 0x0f, 0x5e };
196196
static const uint8_t SQRTPD[] = { 0x66, 0x0f, 0x51 };
197-
static const uint8_t AND_OR_MOV_LDMXCSR[] = { 0x25, 0x00, 0x60, 0x00, 0x00, 0x0D, 0xC0, 0x9F, 0x00, 0x00, 0x89, 0x44, 0x24, 0xF8, 0x0F, 0xAE, 0x54, 0x24, 0xF8 };
197+
static const uint8_t AND_OR_MOV_LDMXCSR[] = { 0x25, 0x00, 0x60, 0x00, 0x00, 0x0D, 0xC0, 0x9F, 0x00, 0x00, 0x50, 0x0F, 0xAE, 0x14, 0x24, 0x58 };
198198
static const uint8_t ROL_RAX[] = { 0x48, 0xc1, 0xc0 };
199199
static const uint8_t XOR_ECX_ECX[] = { 0x33, 0xC9 };
200200
static const uint8_t REX_CMP_R32I[] = { 0x41, 0x81 };

0 commit comments

Comments
 (0)