[PATCH 0/1] MR10210: kernelbase: Fix GetNativeSystemInfo() in an x86_64 process on ARM64.
In an emulated x86 or x86_64 process on ARM64, GetNativeSystemInfo() should return information as if the native system is x86_64 (assuming x86_64 emulation is supported). This is working correctly for x86 processes, but x86_64 processes are returning PROCESSOR_ARCHITECTURE_ARM64. Fixes test failure when running as x86_64 on ARM64: ``` process.c:2424: Test failed: Expected no difference for wProcessorArchitecture, got 9 and 12 process.c:2427: Test failed: Expected no difference for dwProcessorType, got 8664 and 0 ``` --- I listed all the possibilities to help reason about this. If native_machine is I386: - is_wow64 is FALSE - GetNativeSystemInfo equivalent to GetSystemInfo If native_machine is AMD64, process is I386: - is_wow64 is TRUE - native system info should have processor architecture AMD64 If native_machine is AMD64, process is AMD64: - is_wow64 is FALSE - GetNativeSystemInfo equivalent to GetSystemInfo If native_machine is ARM64, process is ARM64: - is_wow64 is FALSE - GetNativeSystemInfo equivalent to GetSystemInfo If native_machine is ARM64, process is I386: - is_wow64 is TRUE - native system info should have processor architecture AMD64 If native_machine is ARM64, process is AMD64: - is_wow64 is FALSE - GetNativeSystemInfo equivalent to GetSystemInfo -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10210
From: Brendan Shanks <bshanks@codeweavers.com> --- dlls/kernelbase/memory.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/dlls/kernelbase/memory.c b/dlls/kernelbase/memory.c index c0a3d65d341..fd06bddb543 100644 --- a/dlls/kernelbase/memory.c +++ b/dlls/kernelbase/memory.c @@ -209,18 +209,16 @@ void WINAPI DECLSPEC_HOTPATCH GetNativeSystemInfo( SYSTEM_INFO *si ) { SYSTEM_BASIC_INFORMATION basic_info; SYSTEM_CPU_INFORMATION cpu_info; + USHORT current_machine, native_machine; - if (is_wow64) - { - USHORT current_machine, native_machine; + RtlWow64GetProcessMachines( 0, ¤t_machine, &native_machine ); - RtlWow64GetProcessMachines( 0, ¤t_machine, &native_machine ); - if (native_machine != IMAGE_FILE_MACHINE_AMD64) - { - GetSystemInfo( si ); + if (!is_wow64 || native_machine != IMAGE_FILE_MACHINE_AMD64) + { + GetSystemInfo( si ); + if (is_wow64 && native_machine != IMAGE_FILE_MACHINE_AMD64) si->wProcessorArchitecture = PROCESSOR_ARCHITECTURE_AMD64; - return; - } + return; } if (!set_ntstatus( RtlGetNativeSystemInformation( SystemBasicInformation, -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10210
There is some uncertainty about the correct behavior, cf. !9740. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10210#note_130781
participants (3)
-
Alexandre Julliard (@julliard) -
Brendan Shanks -
Brendan Shanks (@bshanks)