XSAVE-related segfaults observed under wine

Brian Inglis Brian.Inglis@SystematicSW.ab.ca
Fri Jun 27 19:18:50 GMT 2025


On 2025-06-27 11:45, Jeremy Drake via Cygwin wrote:
> On Fri, 27 Jun 2025, Corinna Vinschen via Cygwin wrote:
>> On Jun 27 14:41, Pip Cet via Cygwin wrote:
>>> My suggested fix is to align the value in %rbx to the next 64-byte
>>> multiple after the "cpuid" instruction is executed, by performing the
>>> assembler equivalent of $rbx += 63; $rbx &= -64; I tried this:
>>>
>>> diff --git a/winsup/cygwin/scripts/gendef b/winsup/cygwin/scripts/gendef
>>> index 861a2405b..d681fde3f 100755
>>> --- a/winsup/cygwin/scripts/gendef
>>> +++ b/winsup/cygwin/scripts/gendef
>>> @@ -232,6 +232,8 @@ sigdelayed:
>>>   	movl	\$0x0d,%eax
>>>   	xorl	%ecx,%ecx
>>>   	cpuid	# get necessary space for xsave
>>> +	addq	\$63, %rbx
>>> +	andq	\$-64, %rbx # align to next 64-byte multiple
>>
>> what about a oneliner instead by just aligning rsp?  As in
>>
>>>   	movq	%rbx,%rcx
>>>   	addq	\$0x48,%rbx # 0x18 for alignment, 0x30 for additional space
> 
> If aligning via andq, does the 0x18 "for alignment" still need to be
> included?

I think that's a holdover from the non-xsave path above this section, and is the 
extra space needed here in the xsave path?
>>>   	subq	%rbx,%rsp
>>
>>    +     andq    \$-64, %rsp

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


More information about the Cygwin mailing list