Merge pull request #3772 from Sonicadvance1/fix_addrsize_override

FEXCore: Fixes address size override on GPR sources and destinations
This commit is contained in:
Ryan Houdek 2024-06-27 15:01:08 -07:00 committed by GitHub
commit 53b1d155cc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 22 additions and 0 deletions

View File

@ -4307,6 +4307,7 @@ AddressMode OpDispatchBuilder::DecodeAddress(const X86Tables::DecodedOp& Op, con
}
} else if (Operand.IsGPR()) {
// Not an address, let the caller deal with it
A.AddrSize = GPRSize;
} else if (Operand.IsGPRDirect()) {
A.Base = LoadGPRRegister(Operand.Data.GPR.GPR, GPRSize);
A.NonTSO |= IsNonTSOReg(AccessType, Operand.Data.GPR.GPR);

View File

@ -0,0 +1,21 @@
%ifdef CONFIG
{
"RegData": {
"RDX": "0x5152535455565758",
"R8": "0x5152535455565758"
}
}
%endif
; FEX-Emu had a bug where address size override was overriding destination and source sizes on operations not affecting memory.
; This showed up as a bug in OpenSSL where GCC was padding move instructions with the address size prefix, knowing that it wouldn't do anything.
; FEX interpreted this address size prefix as making the destination 32-bit resulting in zero-extending the 64-bit source.
; Ensure this doesn't happen again.
mov rdx, 0x414243444546748
mov r8, 0x5152535455565758
jmp .test
.test:
; Add a couple address size prefixes
db 0x67, 0x67
mov rdx, r8
hlt