This was preventing wow64 from working on Apple Silicon/Rosetta.
Based on a patch by Tim Clem tclem@codeweavers.com.
From: Brendan Shanks bshanks@codeweavers.com
Based on a patch by Tim Clem tclem@codeweavers.com.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=54367 --- server/mach.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+)
diff --git a/server/mach.c b/server/mach.c index 6051396a1bf..4965248d388 100644 --- a/server/mach.c +++ b/server/mach.c @@ -31,6 +31,9 @@ #ifdef HAVE_SYS_SYSCALL_H #include <sys/syscall.h> #endif +#ifdef HAVE_SYS_SYSCTL_H +#include <sys/sysctl.h> +#endif
#include "ntstatus.h" #define WIN32_NO_STATUS @@ -74,6 +77,25 @@ static mach_port_t get_process_port( struct process *process ) return process->trace_data; }
+static int is_rosetta( void ) +{ + static int rosetta_status, did_check = 0; + if (!did_check) + { + /* returns 0 for native process or on error, 1 for translated */ + int ret = 0; + size_t size = sizeof(ret); + if (sysctlbyname( "sysctl.proc_translated", &ret, &size, NULL, 0 ) == -1) + rosetta_status = 0; + else + rosetta_status = ret; + + did_check = 1; + } + + return rosetta_status; +} + /* initialize the process control mechanism */ void init_tracing_mechanism(void) { @@ -165,6 +187,14 @@ void get_thread_context( struct thread *thread, context_t *context, unsigned int /* all other regs are handled on the client side */ assert( flags == SERVER_CTX_DEBUG_REGISTERS );
+ if (is_rosetta()) + { + /* getting debug registers of a translated process is not supported cross-process, return all zeroes */ + memset( &context->debug, 0, sizeof(context->debug) ); + context->flags |= SERVER_CTX_DEBUG_REGISTERS; + return; + } + if (thread->unix_pid == -1 || !process_port || mach_port_extract_right( process_port, thread->unix_tid, MACH_MSG_TYPE_COPY_SEND, &port, &type )) @@ -251,6 +281,16 @@ void set_thread_context( struct thread *thread, const context_t *context, unsign return; }
+ if (is_rosetta()) + { + /* Setting debug registers of a translated process is not supported cross-process + * (and even in-process, setting debug registers never has the desired effect). + */ + fprintf( stderr, "%04x: set_thread_context failed - Rosetta does not support debug registers\n", thread->id ); + set_error( STATUS_UNSUCCESSFUL ); + return; + } + /* get the debug state to determine which flavor to use */ ret = thread_get_state(port, x86_DEBUG_STATE, (thread_state_t)&state, &count); if (ret)
Hi,
It looks like your patch introduced the new failures shown below. Please investigate and fix them before resubmitting your patch. If they are not new, fixing them anyway would help a lot. Otherwise please ask for the known failures list to be updated.
The tests also ran into some preexisting test failures. If you know how to fix them that would be helpful. See the TestBot job for the details:
The full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=129232
Your paranoid android.
=== debian11 (32 bit report) ===
ntoskrnl.exe: driver_pnp.c:707: Test failed: Got 1 remove events.
This indeed resolved that bug, still can’t really run anything with WoW64 though.
Alexandre Julliard (@julliard) commented about server/mach.c:
return; }
- if (is_rosetta())
- {
/* Setting debug registers of a translated process is not supported cross-process
* (and even in-process, setting debug registers never has the desired effect).
*/
fprintf( stderr, "%04x: set_thread_context failed - Rosetta does not support debug registers\n", thread->id );
set_error( STATUS_UNSUCCESSFUL );
In general we don't want to print errors from the server, there's no guarantee that its stderr corresponds to the running app.
If it's important to show the message the error should be propagated to the client and printed there.