Pip Cet <[email protected]> writes: > This is about a bug which was observed when running msys2 binaries in > Wine under recent Linux kernels on new Intel/AMD CPUs that support the > PKU/PKRU feature, but it appears to be a bug in Cygwin; specifically, > in:
I don't think this was ever merged, but I'm not aware of any remaining objections. Rebased patch follows: >From 7ed7da412248ec0b2d27157980d4c2f6fe63398c Mon Sep 17 00:00:00 2001 From: Pip Cet <[email protected]> Date: Sun, 26 Oct 2025 10:01:33 +0000 Subject: [PATCH] Cygwin: Fix segfault when XSAVE area sizes are unaligned On recent AMD and Intel CPUs, the PKU/PKRU feature reports an XSAVE storage area of just 8 bytes. This is exposed to Cygwin code when we run in Wine under Linux. The xsave64 instruction requires a memory area aligned to 64 bytes; in the setting above, we would no longer meet that requirement, causing segfaults and abnormal program termination. This fix aligns the size of the structure we allocate on the stack before performing an xsave64 to the next 64-byte multiple; the old code already guarantees that structures of such size are aligned properly for xsave64. This fixes the issue on Linux and hopefully avoid it on future Windows systems which expose such features. Signed-off-by: Pip Cet <[email protected]> --- winsup/cygwin/scripts/gendef | 2 ++ 1 file changed, 2 insertions(+) diff --git a/winsup/cygwin/scripts/gendef b/winsup/cygwin/scripts/gendef index d60d45431..2dc9bce53 100755 --- a/winsup/cygwin/scripts/gendef +++ b/winsup/cygwin/scripts/gendef @@ -243,6 +243,8 @@ sigdelayed: xorl %ecx,%ecx cpuid # get necessary space for xsave movq %rbx,%rcx + addq \$63, %rbx + andq \$-64, %rbx # align to next 64-byte multiple addq \$0x48,%rbx # 0x18 for alignment, 0x30 for additional space subq %rbx,%rsp movl %ebx,0x24(%rsp) -- 2.51.1 -- Problem reports: https://cygwin.com/problems.html FAQ: https://cygwin.com/faq/ Documentation: https://cygwin.com/docs.html Unsubscribe info: https://cygwin.com/ml/#unsubscribe-simple

