Skip to content

Commit 6c7c325

Browse files
authored
Merge pull request #222 from git-for-windows/msys2-runtime-b80da35c1f6a619acf53be8db4a6691937dbefef
msys2-runtime: update to 3.5.7-2
2 parents 9457a26 + 04e0ce5 commit 6c7c325

File tree

3 files changed

+76
-6
lines changed

3 files changed

+76
-6
lines changed
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
From b80da35c1f6a619acf53be8db4a6691937dbefef Mon Sep 17 00:00:00 2001
2+
From: Johannes Schindelin <[email protected]>
3+
Date: Mon, 22 May 2023 13:36:27 +0200
4+
Subject: [PATCH 54/N] Cygwin: Adjust CWD magic to accommodate for the latest
5+
Windows previews
6+
7+
Reportedly a very recent internal build of Windows 11 once again changed
8+
the current working directory logic a bit, and Cygwin's "magic" (or:
9+
"technologically sufficiently advanced") code needs to be adjusted
10+
accordingly.
11+
12+
In particular, the following assembly code can be seen:
13+
14+
ntdll!RtlpReferenceCurrentDirectory
15+
16+
598 00000001`800c6925 488d0db4cd0f00 lea rcx,[ntdll!FastPebLock (00000001`801c36e0)]
17+
583 00000001`800c692c 4c897810 mov qword ptr [rax+10h],r15
18+
588 00000001`800c6930 0f1140c8 movups xmmword ptr [rax-38h],xmm0
19+
598 00000001`800c6934 e82774f4ff call ntdll!RtlEnterCriticalSection
20+
21+
The change necessarily looks a bit different than 4840a56325 (Cygwin:
22+
Adjust CWD magic to accommodate for the latest Windows previews,
23+
2023-05-22): The needle `\x48\x8d\x0d` is already present, as the first
24+
version of the hack after Windows 8.1 was released. In that code,
25+
though, the `call` to `RtlEnterCriticalSection` followed the `lea`
26+
instruction immediately, but now there are two more instructions
27+
separating them.
28+
29+
Note: In the long run, we may very well want to follow the insightful
30+
suggestion by a helpful Windows kernel engineer who pointed out that it
31+
may be less fragile to implement kind of a disassembler that has a
32+
better chance to adapt to the ever-changing code of
33+
`ntdll!RtlpReferenceCurrentDirectory` by skipping uninteresting
34+
instructions such as `mov %rsp,%rax`, `mov %rbx,0x20(%rax)`, `push %rsi`
35+
`sub $0x70,%rsp`, etc, and focuses on finding the `lea`, `call
36+
ntdll!RtlEnterCriticalSection` and `mov ..., rbx` instructions, much
37+
like it was prototyped out for ARM64 at
38+
https://gist.github.com/jeremyd2019/aa167df0a0ae422fa6ebaea5b60c80c9
39+
40+
Signed-off-by: Johannes Schindelin <[email protected]>
41+
---
42+
winsup/cygwin/path.cc | 12 ++++++++++++
43+
1 file changed, 12 insertions(+)
44+
45+
diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc
46+
index 38549ea..e78d84a 100644
47+
--- a/winsup/cygwin/path.cc
48+
+++ b/winsup/cygwin/path.cc
49+
@@ -4794,6 +4794,18 @@ find_fast_cwd_pointer ()
50+
%rcx for the subsequent RtlEnterCriticalSection call. */
51+
lock = (const uint8_t *) memmem ((const char *) use_cwd, 80,
52+
"\x48\x8d\x0d", 3);
53+
+ if (lock)
54+
+ {
55+
+ /* A recent Windows 11 Preview calls `lea rel(rip),%rcx' then
56+
+ a `mov` and a `movups` instruction, and only then
57+
+ `callq RtlEnterCriticalSection'.
58+
+ */
59+
+ if (memmem (lock + 7, 8, "\x4c\x89\x78\x10\x0f\x11\x40\xc8", 8))
60+
+ {
61+
+ call_rtl_offset = 15;
62+
+ }
63+
+ }
64+
+
65+
if (!lock)
66+
{
67+
/* Windows 8.1 Preview calls `lea rel(rip),%r12' then some unrelated

msys2-runtime/PKGBUILD

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
pkgbase=msys2-runtime
55
pkgname=('msys2-runtime' 'msys2-runtime-devel')
66
pkgver=3.5.7
7-
pkgrel=1
7+
pkgrel=2
88
pkgdesc="Cygwin POSIX emulation engine"
99
arch=('x86_64')
1010
url="https://www.cygwin.com/"
@@ -79,9 +79,10 @@ source=('msys2-runtime'::git+https://github.com/cygwin/cygwin#tag=cygwin-${pkgve
7979
0050-Use-MB_CUR_MAX-6-by-default.patch
8080
0051-Change-the-default-base-address-for-x86_64.patch
8181
0052-msys2-runtime-restore-fast-path-for-current-user-pri.patch
82-
0053-Fix-SSH-hangs.patch)
82+
0053-Fix-SSH-hangs.patch
83+
0054-Cygwin-Adjust-CWD-magic-to-accommodate-for-the-lates.patch)
8384
sha256sums=('67c44fa7fcae9dc63c71d71934a5f2b7c584d967279b0492646df9bc63bc3f16'
84-
'a403c45d6922cc6b6134683533dbe6667a2b7fb52ead71be3add2276296e861c'
85+
'6fce92782f8832044f3caa1fe22ec9b0e1f719c0bf78e2cd9e7398d1ce4edbed'
8586
'87d86c95008274731cf560d929ae5fb319d962591303b2690e11bfd60f4818e7'
8687
'c6d091cb51440638eb9fc59b35ba40f2b63e9e32a31a56c51a2aaec2445aa88e'
8788
'81ec264a45c03e03e2b901037b73e5042b9d54e0454b29d372114d0c853b82e0'
@@ -134,7 +135,8 @@ sha256sums=('67c44fa7fcae9dc63c71d71934a5f2b7c584d967279b0492646df9bc63bc3f16'
134135
'6631588e7c3633a105ab00a84484bc09853cac454e93da79cf3952ccfc900ae9'
135136
'87e59ef31ae84f3d86f4d7dc632b8e0fc0a37d9efdb9422b712c76ec6088dc59'
136137
'8c0603f8b1a2874488a43a9779be2c5ffd05ccf392b4e8fcc8b2a282470a68a2'
137-
'd441808c2f6dbbe5a6fa33bd7231ddcff2a8027292bd8325448b58a42412fd52')
138+
'd441808c2f6dbbe5a6fa33bd7231ddcff2a8027292bd8325448b58a42412fd52'
139+
'3850bf314368132b8a12dc7df440563153b9da64a412d4a5a100a8b710cc29f0')
138140

139141
# Helper macros to help make tasks easier #
140142
apply_patch_with_msg() {
@@ -241,7 +243,8 @@ prepare() {
241243
0050-Use-MB_CUR_MAX-6-by-default.patch \
242244
0051-Change-the-default-base-address-for-x86_64.patch \
243245
0052-msys2-runtime-restore-fast-path-for-current-user-pri.patch \
244-
0053-Fix-SSH-hangs.patch
246+
0053-Fix-SSH-hangs.patch \
247+
0054-Cygwin-Adjust-CWD-magic-to-accommodate-for-the-lates.patch
245248
}
246249

247250
build() {

msys2-runtime/msys2-runtime.commit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
882031da88370a60b08649bd808c49ebc2065a3e
1+
b80da35c1f6a619acf53be8db4a6691937dbefef

0 commit comments

Comments
 (0)