delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2025/10/26/11:15:56

DMARC-Filter: OpenDMARC Filter v1.4.2 delorie.com 59QFFtID4060306
Authentication-Results: delorie.com; dmarc=pass (p=none dis=none) header.from=cygwin.com
Authentication-Results: delorie.com; spf=pass smtp.mailfrom=cygwin.com
DKIM-Filter: OpenDKIM Filter v2.11.0 delorie.com 59QFFtID4060306
Authentication-Results: delorie.com;
dkim=pass (1024-bit key, unprotected) header.d=cygwin.com header.i=@cygwin.com header.a=rsa-sha256 header.s=default header.b=smkJMzSw
X-Recipient: archive-cygwin AT delorie DOT com
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DFD903858D32
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com;
s=default; t=1761491753;
bh=rRgHEqiAVep8EW1YG63qa6P1SDeK9H+wcmEzkF2z92U=;
h=Date:Subject:To:References:In-Reply-To:List-Id:List-Unsubscribe:
List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:
From;
b=smkJMzSweXsNlz6GX2sfnk5y2pepfHzlZaVcr8lvqEi0ju2JAeCsA2mb4Xi5XLK3C
bqtU9rK0bp0rRUX8Q609RSdlLHJAGowqOeo3trYK5MuQ0mguauuVJdkz29oZpW8znL
vUl/hCCFLPMeiHMTJbMfPKFJrBk/RTPsPy8AAkGQ=
X-Original-To: cygwin AT cygwin DOT com
Delivered-To: cygwin AT cygwin DOT com
DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9A6C43858D26
ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 9A6C43858D26
ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1761491637; cv=none;
b=Khuzu2YdDD2LP3zpFkUdGDctapGNUkMtVZEKF6yGz0UgjaXq5JeydUVdfCQkSrU5Rb8KoALDptHn9lSa78UI3EsXgj3J7nfgjJ20sgQ9Ok3xJWA1Xd1fmSPo9XuD1AUX3nD/O0KGbKFpdTusWniY86vgJXLnLQZkoDyx2VaW0HI=
ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key;
t=1761491637; c=relaxed/simple;
bh=E5DVklSOhlJcGiwtZXhLSdpIbrVv2Qo5i+Jy8BMoptA=;
h=Message-ID:Date:MIME-Version:From:Subject:To:DKIM-Signature;
b=F5WFKQqtrEymUOArLBIY/C3Ag0POZvG17v5RUQeWrjh8zsiB2yaWV+Ey16EMy6p4gAuSVRj7RHtyaFg/Hn+q1v8dmovq57oX8CUIzTlEbyyE5OqQv0AwJWqMir0gL9OVbDhFdwjkCr6GaxJIfg51J+tP//YZIAVyPC0dU2RsFU0=
ARC-Authentication-Results: i=1; server2.sourceware.org
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9A6C43858D26
Message-ID: <9519d953-a6c8-4814-a8f3-969efe72495a@SystematicSW.ab.ca>
Date: Sun, 26 Oct 2025 09:13:54 -0600
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Subject: Re: XSAVE-related segfaults observed under wine
To: cygwin AT cygwin DOT com
References: <87bjq9457k DOT fsf AT protonmail DOT com> <871pmqotzu DOT fsf AT protonmail DOT com>
Organization: Systematic Software
In-Reply-To: <871pmqotzu.fsf@protonmail.com>
X-Rspamd-Server: rspamout04
X-Rspamd-Queue-Id: D2EEB6000A
X-Stat-Signature: 36xfkuyrzwfw8oua8r67p5nd6co3tw76
X-Session-Marker: 427269616E2E496E676C69734053797374656D6174696353572E61622E6361
X-Session-ID: U2FsdGVkX1+0AZByqUTtNRCVcS/rgvHmIW9AE5hkvww=
X-HE-Tag: 1761491635-61832
X-HE-Meta: U2FsdGVkX1+glvg3CmIDjFBzHSD/G6Oif2wlKO//cGPzynmNsDOJCs7VppcHHDrQluY0JBhJhhYoz0EIvhBC/FmGQoqCtMMN44xdLxLHgzgLKx25lI0ASm8ix9uoNgKi9dlnDimFkLHJWBJiw5XyNB8OnXTuWmci0pUsNmdNC67e3GdzbnhObdhJ2RB6CPruRQTIpqBa5yR6zFysD8OrISwe3KWqKWaAWZZM0/IHyZBsaKAIfZrSnh32VTo1p/gE+0L1+bGAL0o25O66H/UOqdrWopnlBrO+x6+oIJW2S/5TLQySV0AvBeu2fNkkndNIhlsnHHhqBIbsEYVDD0583ci4PBgeXWDW0KFnZjZ2NQqL59I3NPtk6mJ5pzX/AsEQ3YCOcqQNVh8vpNn9LN0S2Q==
X-BeenThere: cygwin AT cygwin DOT com
X-Mailman-Version: 2.1.30
List-Id: General Cygwin discussions and problem reports <cygwin.cygwin.com>
List-Unsubscribe: <https://cygwin.com/mailman/options/cygwin>,
<mailto:cygwin-request AT cygwin DOT com?subject=unsubscribe>
List-Archive: <https://cygwin.com/pipermail/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-request AT cygwin DOT com?subject=help>
List-Subscribe: <https://cygwin.com/mailman/listinfo/cygwin>,
<mailto:cygwin-request AT cygwin DOT com?subject=subscribe>
From: Brian Inglis via Cygwin <cygwin AT cygwin DOT com>
Reply-To: cygwin AT cygwin DOT com
Cc: Brian Inglis <Brian DOT Inglis AT SystematicSW DOT ab DOT ca>
Errors-To: cygwin-bounces~archive-cygwin=delorie DOT com AT cygwin DOT com
Sender: "Cygwin" <cygwin-bounces~archive-cygwin=delorie DOT com AT cygwin DOT com>
X-MIME-Autoconverted: from base64 to 8bit by delorie.com id 59QFFtID4060306

On 2025-10-26 04:10, Pip Cet via Cygwin wrote:
> Pip Cet <pipcet AT protonmail DOT com> 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 <pipcet AT protonmail DOT com>
> 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 <pipcet AT protonmail DOT com>
> ---
>   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)

Wonder if it might be clearer ;^> to orq \$63,%rbx; incq %rbx?

-- 
Take care. Thanks, Brian Inglis              Calgary, Alberta, Canada

La perfection est atteinte                   Perfection is achieved
non pas lorsqu'il n'y a plus rien à ajouter  not when there is no more to add
mais lorsqu'il n'y a plus rien à retrancher  but when there is no more to cut
                                 -- Antoine de Saint-Exupéry

-- 
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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019