Brendan Shanks : wow64cpu: Use different JMP instruction to work around Rosetta bug.

Alexandre Julliard julliard at winehq.org
Mon Apr 18 16:08:47 CDT 2022


Module: wine
Branch: master
Commit: 6d19495ed7baea31dc27a46bcd039db8152d274b
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=6d19495ed7baea31dc27a46bcd039db8152d274b

Author: Brendan Shanks <bshanks at codeweavers.com>
Date:   Thu Apr 14 10:19:07 2022 -0700

wow64cpu: Use different JMP instruction to work around Rosetta bug.

Rosetta 2 on macOS 11 and 12 (before 12.4) does not support the 0xEA JMP
instruction, use the indirect form instead.

Signed-off-by: Brendan Shanks <bshanks at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/wow64cpu/cpu.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/dlls/wow64cpu/cpu.c b/dlls/wow64cpu/cpu.c
index a029b251be0..34c3f3ad493 100644
--- a/dlls/wow64cpu/cpu.c
+++ b/dlls/wow64cpu/cpu.c
@@ -33,7 +33,9 @@ WINE_DEFAULT_DEBUG_CHANNEL(wow);
 #include "pshpack1.h"
 struct thunk_32to64
 {
-    BYTE  ljmp;   /* ljmp %cs:1f */
+    BYTE  ljmp;   /* jump far, absolute indirect */
+    BYTE  modrm;  /* address=disp32, opcode=5 */
+    DWORD op;
     DWORD addr;
     WORD  cs;
 };
@@ -195,7 +197,9 @@ NTSTATUS WINAPI BTCpuProcessInit(void)
     ds64_sel = context.SegDs;
     fs32_sel = context.SegFs;
 
-    thunk->ljmp = 0xea;
+    thunk->ljmp = 0xff;
+    thunk->modrm = 0x2d;
+    thunk->op   = PtrToUlong( &thunk->addr );
     thunk->addr = PtrToUlong( syscall_32to64 );
     thunk->cs   = cs64_sel;
     NtProtectVirtualMemory( GetCurrentProcess(), (void **)&thunk, &size, PAGE_EXECUTE_READ, &old_prot );




More information about the wine-cvs mailing list