public inbox for cygwin-patches@cygwin.com
 help / color / mirror / Atom feed
* [RFC] FAST_CWD warnings on ARM64 insider preview
@ 2021-05-18 18:56 Jeremy Drake
  2021-05-19  9:49 ` Corinna Vinschen
  0 siblings, 1 reply; 4+ messages in thread
From: Jeremy Drake @ 2021-05-18 18:56 UTC (permalink / raw)
  To: cygwin-patches

[-- Attachment #1: Type: text/plain, Size: 745 bytes --]

I have been trying out x86_64 msys2 (a fork of cygwin) on Windows insider
preview builds on ARM64, which added support for x86_64 emulation.  I was
getting the notorious FAST_CWD warnings, which were interfering with
MINGW CMake.  Last night late, I went looking at the cause, and found some
code that attempted to disable FAST_CWD warnings, but only on i686, and
trying to look at GetNativeSystemInfo, which was lying.  I quickly put
together this patch, and it seems to work.

Note I did this late at night, with no real regard to investigating or
matching code style.  This patch is currently more in an RFC state, if the
approach looks OK, and I'd be grateful for any pointers on getting it into
shape for evental acceptance.

Thanks,
Jeremy

[-- Attachment #2: Type: text/plain, Size: 2368 bytes --]

From 346dfb78fc5522d5d7288571d635303c69a5270a Mon Sep 17 00:00:00 2001
From: Jeremy Drake <cygwin@jdrake.com>
Date: Tue, 18 May 2021 00:48:52 -0700
Subject: [PATCH] cygwin: suppress FAST_CWD warnings on ARM64.

The old check was insufficient: new insider preview builds of Windows
allow running x86_64 process on ARM64.  The IsWow64Process2 function
seems to be the intended way to figure this situation out.
---
 winsup/cygwin/path.cc | 30 ++++++++++--------------------
 1 file changed, 10 insertions(+), 20 deletions(-)

diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc
index dd7048486..5c4adcd49 100644
--- a/winsup/cygwin/path.cc
+++ b/winsup/cygwin/path.cc
@@ -4708,29 +4708,19 @@ find_fast_cwd ()
     {
       bool warn = 1;
 
-#ifndef __x86_64__
-      #ifndef PROCESSOR_ARCHITECTURE_ARM64
-      #define PROCESSOR_ARCHITECTURE_ARM64 12
-      #endif
+#ifndef IMAGE_FILE_MACHINE_ARM64
+#define IMAGE_FILE_MACHINE_ARM64 0xAA64
+#endif
 
-      SYSTEM_INFO si;
+      USHORT procmachine, nativemachine;
 
       /* Check if we're running in WOW64 on ARM64.  Skip the warning as long as
-	 there's no solution for finding the FAST_CWD pointer on that system.
-
-	 2018-07-12: Apparently current ARM64 WOW64 has a bug:
-	 It's GetNativeSystemInfo returns PROCESSOR_ARCHITECTURE_INTEL in
-	 wProcessorArchitecture.  Since that's an invalid value (a 32 bit
-	 host system hosting a 32 bit emulator for itself?) we can use this
-	 value as an indicator to skip the message as well. */
-      if (wincap.is_wow64 ())
-	{
-	  GetNativeSystemInfo (&si);
-	  if (si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_ARM64
-	      || si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_INTEL)
-	    warn = 0;
-	}
-#endif /* !__x86_64__ */
+	 there's no solution for finding the FAST_CWD pointer on that system. */
+
+      typedef BOOL (WINAPI * IsWow64Process2_t)(HANDLE hProcess, USHORT *pProcessMachine, USHORT *pNativeMachine);
+      IsWow64Process2_t pfnIsWow64Process2 = (IsWow64Process2_t)GetProcAddress(GetModuleHandle("kernel32.dll"), "IsWow64Process2");
+      if (pfnIsWow64Process2 && pfnIsWow64Process2(GetCurrentProcess(), &procmachine, &nativemachine) && nativemachine == IMAGE_FILE_MACHINE_ARM64)
+	warn = 0;
 
       if (warn)
 	small_printf ("Cygwin WARNING:\n"
-- 
2.31.1.windows.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-05-20  7:17 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-18 18:56 [RFC] FAST_CWD warnings on ARM64 insider preview Jeremy Drake
2021-05-19  9:49 ` Corinna Vinschen
2021-05-19 18:02   ` Jeremy Drake
2021-05-20  7:17     ` Corinna Vinschen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).