Module: wine Branch: master Commit: 5a1d431b4bf93424a415d5e3d113b1f16431fcb1 URL: https://gitlab.winehq.org/wine/wine/-/commit/5a1d431b4bf93424a415d5e3d113b1f...
Author: Alexandre Julliard julliard@winehq.org Date: Wed Mar 15 09:48:40 2023 +0100
ntdll: Implement NtWow64IsProcessorFeaturePresent().
---
dlls/ntdll/ntdll.spec | 2 ++ dlls/ntdll/rtl.c | 4 ++++ dlls/ntdll/tests/wow64.c | 18 ++++++++++++++++++ dlls/ntdll/unix/loader.c | 1 + dlls/ntdll/unix/virtual.c | 10 ++++++++++ dlls/wow64/syscall.c | 11 +++++++++++ dlls/wow64/syscall.h | 1 + include/winnt.h | 4 ++++ include/winternl.h | 1 + 9 files changed, 52 insertions(+)
diff --git a/dlls/ntdll/ntdll.spec b/dlls/ntdll/ntdll.spec index b0186eb7641..d5f6737e1aa 100644 --- a/dlls/ntdll/ntdll.spec +++ b/dlls/ntdll/ntdll.spec @@ -446,6 +446,7 @@ # @ stub NtWaitLowEventPair @ stdcall -syscall -arch=win32 NtWow64AllocateVirtualMemory64(long ptr int64 ptr long long) @ stdcall -syscall -arch=win32 NtWow64GetNativeSystemInformation(long ptr long ptr) +@ stdcall -syscall -arch=win32 NtWow64IsProcessorFeaturePresent(long) @ stdcall -syscall -arch=win32 NtWow64ReadVirtualMemory64(long int64 ptr int64 ptr) @ stdcall -syscall -arch=win32 NtWow64WriteVirtualMemory64(long int64 ptr int64 ptr) @ stdcall -syscall NtWriteFile(long long ptr ptr ptr ptr long ptr ptr) @@ -1478,6 +1479,7 @@ # @ stub ZwWaitLowEventPair @ stdcall -syscall -arch=win32 ZwWow64AllocateVirtualMemory64(long ptr int64 ptr long long) NtWow64AllocateVirtualMemory64 @ stdcall -syscall -arch=win32 ZwWow64GetNativeSystemInformation(long ptr long ptr) NtWow64GetNativeSystemInformation +@ stdcall -syscall -arch=win32 ZwWow64IsProcessorFeaturePresent(long) NtWow64IsProcessorFeaturePresent @ stdcall -syscall -arch=win32 ZwWow64ReadVirtualMemory64(long int64 ptr int64 ptr) NtWow64ReadVirtualMemory64 @ stdcall -syscall -arch=win32 ZwWow64WriteVirtualMemory64(long int64 ptr int64 ptr) NtWow64WriteVirtualMemory64 @ stdcall -private -syscall ZwWriteFile(long long ptr ptr ptr ptr long ptr ptr) NtWriteFile diff --git a/dlls/ntdll/rtl.c b/dlls/ntdll/rtl.c index 25927afce54..3305d770c13 100644 --- a/dlls/ntdll/rtl.c +++ b/dlls/ntdll/rtl.c @@ -2128,7 +2128,11 @@ void WINAPI RtlGetCurrentProcessorNumberEx(PROCESSOR_NUMBER *processor) */ BOOLEAN WINAPI RtlIsProcessorFeaturePresent( UINT feature ) { +#ifdef _WIN64 return feature < PROCESSOR_FEATURE_MAX && user_shared_data->ProcessorFeatures[feature]; +#else + return NtWow64IsProcessorFeaturePresent( feature ); +#endif }
/*********************************************************************** diff --git a/dlls/ntdll/tests/wow64.c b/dlls/ntdll/tests/wow64.c index ddb63b7cae8..111ea4ffa96 100644 --- a/dlls/ntdll/tests/wow64.c +++ b/dlls/ntdll/tests/wow64.c @@ -35,6 +35,7 @@ static NTSTATUS (WINAPI *pRtlWow64GetThreadSelectorEntry)(HANDLE,THREAD_DESCRIPT #else static NTSTATUS (WINAPI *pNtWow64AllocateVirtualMemory64)(HANDLE,ULONG64*,ULONG64,ULONG64*,ULONG,ULONG); static NTSTATUS (WINAPI *pNtWow64GetNativeSystemInformation)(SYSTEM_INFORMATION_CLASS,void*,ULONG,ULONG*); +static NTSTATUS (WINAPI *pNtWow64IsProcessorFeaturePresent)(ULONG); static NTSTATUS (WINAPI *pNtWow64ReadVirtualMemory64)(HANDLE,ULONG64,void*,ULONG64,ULONG64*); static NTSTATUS (WINAPI *pNtWow64WriteVirtualMemory64)(HANDLE,ULONG64,const void *,ULONG64,ULONG64*); #endif @@ -80,6 +81,7 @@ static void init(void) #else GET_PROC( NtWow64AllocateVirtualMemory64 ); GET_PROC( NtWow64GetNativeSystemInformation ); + GET_PROC( NtWow64IsProcessorFeaturePresent ); GET_PROC( NtWow64ReadVirtualMemory64 ); GET_PROC( NtWow64WriteVirtualMemory64 ); #endif @@ -991,6 +993,22 @@ static void test_nt_wow64(void) } else win_skip( "NtWow64GetNativeSystemInformation not supported\n" );
+ if (pNtWow64IsProcessorFeaturePresent) + { + ULONG i; + + for (i = 0; i < 64; i++) + ok( pNtWow64IsProcessorFeaturePresent( i ) == IsProcessorFeaturePresent( i ), + "mismatch %lu wow64 returned %lx\n", i, pNtWow64IsProcessorFeaturePresent( i )); + + if (native_machine == IMAGE_FILE_MACHINE_ARM64) + { + ok( !pNtWow64IsProcessorFeaturePresent( PF_ARM_V8_INSTRUCTIONS_AVAILABLE ), "ARM_V8 present\n" ); + ok( pNtWow64IsProcessorFeaturePresent( PF_MMX_INSTRUCTIONS_AVAILABLE ), "MMX not present\n" ); + } + } + else win_skip( "NtWow64IsProcessorFeaturePresent not supported\n" ); + NtClose( process ); }
diff --git a/dlls/ntdll/unix/loader.c b/dlls/ntdll/unix/loader.c index cde37c48b0d..1cadd2b10b6 100644 --- a/dlls/ntdll/unix/loader.c +++ b/dlls/ntdll/unix/loader.c @@ -350,6 +350,7 @@ static void * const syscalls[] = #ifndef _WIN64 NtWow64AllocateVirtualMemory64, NtWow64GetNativeSystemInformation, + NtWow64IsProcessorFeaturePresent, NtWow64ReadVirtualMemory64, NtWow64WriteVirtualMemory64, #endif diff --git a/dlls/ntdll/unix/virtual.c b/dlls/ntdll/unix/virtual.c index b1267ff0db5..c5318a3282d 100644 --- a/dlls/ntdll/unix/virtual.c +++ b/dlls/ntdll/unix/virtual.c @@ -69,6 +69,7 @@ #include "windef.h" #include "winnt.h" #include "winternl.h" +#include "ddk/wdm.h" #include "wine/list.h" #include "wine/rbtree.h" #include "unix_private.h" @@ -5334,4 +5335,13 @@ NTSTATUS WINAPI NtWow64GetNativeSystemInformation( SYSTEM_INFORMATION_CLASS clas } }
+/*********************************************************************** + * NtWow64IsProcessorFeaturePresent (NTDLL.@) + * ZwWow64IsProcessorFeaturePresent (NTDLL.@) + */ +NTSTATUS WINAPI NtWow64IsProcessorFeaturePresent( UINT feature ) +{ + return feature < PROCESSOR_FEATURE_MAX && user_shared_data->ProcessorFeatures[feature]; +} + #endif /* _WIN64 */ diff --git a/dlls/wow64/syscall.c b/dlls/wow64/syscall.c index d1c7421fabd..e79b8cd9ff6 100644 --- a/dlls/wow64/syscall.c +++ b/dlls/wow64/syscall.c @@ -622,6 +622,17 @@ NTSTATUS WINAPI wow64_NtSetDefaultUILanguage( UINT *args ) }
+/********************************************************************** + * wow64_NtWow64IsProcessorFeaturePresent + */ +NTSTATUS WINAPI wow64_NtWow64IsProcessorFeaturePresent( UINT *args ) +{ + UINT feature = get_ulong( &args ); + + return RtlIsProcessorFeaturePresent( feature ); +} + + /********************************************************************** * get_syscall_num */ diff --git a/dlls/wow64/syscall.h b/dlls/wow64/syscall.h index e91be71ebac..59586d3fbfa 100644 --- a/dlls/wow64/syscall.h +++ b/dlls/wow64/syscall.h @@ -251,6 +251,7 @@ SYSCALL_ENTRY( NtWaitForSingleObject ) \ SYSCALL_ENTRY( NtWow64AllocateVirtualMemory64 ) \ SYSCALL_ENTRY( NtWow64GetNativeSystemInformation ) \ + SYSCALL_ENTRY( NtWow64IsProcessorFeaturePresent ) \ SYSCALL_ENTRY( NtWow64ReadVirtualMemory64 ) \ SYSCALL_ENTRY( NtWow64WriteVirtualMemory64 ) \ SYSCALL_ENTRY( NtWriteFile ) \ diff --git a/include/winnt.h b/include/winnt.h index a7c69070a2c..66f6b7ad809 100644 --- a/include/winnt.h +++ b/include/winnt.h @@ -1072,6 +1072,10 @@ typedef enum _HEAP_INFORMATION_CLASS { #define PF_AVX_INSTRUCTIONS_AVAILABLE 39 #define PF_AVX2_INSTRUCTIONS_AVAILABLE 40 #define PF_AVX512F_INSTRUCTIONS_AVAILABLE 41 +#define PF_ERMS_AVAILABLE 42 +#define PF_ARM_V82_DP_INSTRUCTIONS_AVAILABLE 43 +#define PF_ARM_V83_JSCVT_INSTRUCTIONS_AVAILABLE 44 +#define PF_ARM_V83_LRCPC_INSTRUCTIONS_AVAILABLE 45
/* Execution state flags */ diff --git a/include/winternl.h b/include/winternl.h index ae7f0218b4a..339d3d86f78 100644 --- a/include/winternl.h +++ b/include/winternl.h @@ -4675,6 +4675,7 @@ NTSYSAPI NTSTATUS WINAPI RtlWow64SetThreadContext(HANDLE,const WOW64_CONTEXT*); #else NTSYSAPI NTSTATUS WINAPI NtWow64AllocateVirtualMemory64(HANDLE,ULONG64*,ULONG64,ULONG64*,ULONG,ULONG); NTSYSAPI NTSTATUS WINAPI NtWow64GetNativeSystemInformation(SYSTEM_INFORMATION_CLASS,void*,ULONG,ULONG*); +NTSYSAPI NTSTATUS WINAPI NtWow64IsProcessorFeaturePresent(UINT); NTSYSAPI NTSTATUS WINAPI NtWow64ReadVirtualMemory64(HANDLE,ULONG64,void*,ULONG64,ULONG64*); NTSYSAPI NTSTATUS WINAPI NtWow64WriteVirtualMemory64(HANDLE,ULONG64,const void*,ULONG64,ULONG64*); NTSYSAPI LONGLONG WINAPI RtlConvertLongToLargeInteger(LONG);