winehq.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2025
February
January
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
January
2003
December
November
October
September
August
July
June
May
April
March
February
January
2002
December
November
October
September
August
July
June
May
April
March
February
January
2001
December
November
October
September
August
July
June
May
April
March
February
List overview
wine-commits
February 2024
----- 2025 -----
February 2025
January 2025
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
January 2004
----- 2003 -----
December 2003
November 2003
October 2003
September 2003
August 2003
July 2003
June 2003
May 2003
April 2003
March 2003
February 2003
January 2003
----- 2002 -----
December 2002
November 2002
October 2002
September 2002
August 2002
July 2002
June 2002
May 2002
April 2002
March 2002
February 2002
January 2002
----- 2001 -----
December 2001
November 2001
October 2001
September 2001
August 2001
July 2001
June 2001
May 2001
April 2001
March 2001
February 2001
wine-commits@winehq.org
1 participants
716 discussions
Start a n
N
ew thread
Paul Gofman : ntdll: Support generic xstate config in context manipulation functions.
by Alexandre Julliard
27 Feb '24
27 Feb '24
Module: wine Branch: master Commit: beec1b57fbaf9034a05051ea2ceeba0ffdbf0857 URL:
https://gitlab.winehq.org/wine/wine/-/commit/beec1b57fbaf9034a05051ea2ceeba…
Author: Paul Gofman <pgofman(a)codeweavers.com> Date: Thu Jan 18 11:51:36 2024 -0600 ntdll: Support generic xstate config in context manipulation functions. --- dlls/ntdll/exception.c | 121 +++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 102 insertions(+), 19 deletions(-) diff --git a/dlls/ntdll/exception.c b/dlls/ntdll/exception.c index 529ff125242..1a216e3170b 100644 --- a/dlls/ntdll/exception.c +++ b/dlls/ntdll/exception.c @@ -586,6 +586,52 @@ static const struct context_parameters *context_get_parameters( ULONG context_fl return NULL; } +/* offset is from the start of XSAVE_AREA_HEADER. */ +static int next_compacted_xstate_offset( int off, UINT64 compaction_mask, int feature_idx ) +{ + const UINT64 feature_mask = (UINT64)1 << feature_idx; + + if (compaction_mask & feature_mask) off += user_shared_data->XState.Features[feature_idx].Size; + if (user_shared_data->XState.AlignedFeatures & (feature_mask << 1)) + off = (off + 63) & ~63; + return off; +} + +/* size includes XSAVE_AREA_HEADER but not XSAVE_FORMAT (legacy save area). */ +static int xstate_get_compacted_size( UINT64 mask ) +{ + UINT64 compaction_mask; + unsigned int i; + int off; + + compaction_mask = ((UINT64)1 << 63) | mask; + mask >>= 2; + off = sizeof(XSAVE_AREA_HEADER); + i = 2; + while (mask) + { + if (mask == 1) return off + user_shared_data->XState.Features[i].Size; + off = next_compacted_xstate_offset( off, compaction_mask, i ); + mask >>= 1; + ++i; + } + return off; +} + +static int xstate_get_size( UINT64 mask ) +{ + unsigned int i; + + mask >>= 2; + if (!mask) return sizeof(XSAVE_AREA_HEADER); + i = 2; + while (mask != 1) + { + mask >>= 1; + ++i; + } + return user_shared_data->XState.Features[i].Offset + user_shared_data->XState.Features[i].Size - sizeof(XSAVE_FORMAT); +} /********************************************************************** * RtlGetExtendedContextLength2 (NTDLL.@) @@ -611,12 +657,12 @@ NTSTATUS WINAPI RtlGetExtendedContextLength2( ULONG context_flags, ULONG *length if (!(supported_mask = RtlGetEnabledExtendedFeatures( ~(ULONG64)0) )) return STATUS_NOT_SUPPORTED; - compaction_mask &= supported_mask; - - size = p->context_size + p->context_ex_size + offsetof(XSTATE, YmmContext) + 63; + size = p->context_size + p->context_ex_size + 63; - if (compaction_mask & supported_mask & (1 << XSTATE_AVX)) - size += sizeof(YMMCONTEXT); + compaction_mask &= supported_mask & ~(ULONG64)3; + if (user_shared_data->XState.CompactionEnabled) size += xstate_get_compacted_size( compaction_mask ); + else if (compaction_mask) size += xstate_get_size( compaction_mask ); + else size += sizeof(XSAVE_AREA_HEADER); *length = size; return STATUS_SUCCESS; @@ -667,11 +713,11 @@ NTSTATUS WINAPI RtlInitializeExtendedContext2( void *context, ULONG context_flag xs = (XSTATE *)(((ULONG_PTR)c_ex + p->context_ex_size + 63) & ~(ULONG_PTR)63); c_ex->XState.Offset = (ULONG_PTR)xs - (ULONG_PTR)c_ex; - c_ex->XState.Length = offsetof(XSTATE, YmmContext); compaction_mask &= supported_mask; - if (compaction_mask & (1 << XSTATE_AVX)) - c_ex->XState.Length += sizeof(YMMCONTEXT); + if (user_shared_data->XState.CompactionEnabled) c_ex->XState.Length = xstate_get_compacted_size( compaction_mask ); + else if (compaction_mask & ~(ULONG64)3) c_ex->XState.Length = xstate_get_size( compaction_mask ); + else c_ex->XState.Length = sizeof(XSAVE_AREA_HEADER); memset( xs, 0, c_ex->XState.Length ); if (user_shared_data->XState.CompactionEnabled) @@ -705,6 +751,10 @@ NTSTATUS WINAPI RtlInitializeExtendedContext( void *context, ULONG context_flags void * WINAPI RtlLocateExtendedFeature2( CONTEXT_EX *context_ex, ULONG feature_id, XSTATE_CONFIGURATION *xstate_config, ULONG *length ) { + UINT64 feature_mask = (ULONG64)1 << feature_id; + XSAVE_AREA_HEADER *xs; + unsigned int offset, i; + TRACE( "context_ex %p, feature_id %lu, xstate_config %p, length %p.\n", context_ex, feature_id, xstate_config, length ); @@ -720,16 +770,31 @@ void * WINAPI RtlLocateExtendedFeature2( CONTEXT_EX *context_ex, ULONG feature_i return NULL; } - if (feature_id != XSTATE_AVX) + if (feature_id < 2 || feature_id >= 64) return NULL; + xs = (XSAVE_AREA_HEADER *)((BYTE *)context_ex + context_ex->XState.Offset); + if (length) - *length = sizeof(YMMCONTEXT); + *length = xstate_config->Features[feature_id].Size; + + if (xstate_config->CompactionEnabled) + { + if (!(xs->CompactionMask & feature_mask)) return NULL; + offset = sizeof(XSAVE_AREA_HEADER); + for (i = 2; i < feature_id; ++i) + offset = next_compacted_xstate_offset( offset, xs->CompactionMask, i ); + } + else + { + if (!(feature_mask & xstate_config->EnabledFeatures)) return NULL; + offset = xstate_config->Features[feature_id].Offset - sizeof(XSAVE_FORMAT); + } - if (context_ex->XState.Length < sizeof(XSTATE)) + if (context_ex->XState.Length < offset + xstate_config->Features[feature_id].Size) return NULL; - return (BYTE *)context_ex + context_ex->XState.Offset + offsetof(XSTATE, YmmContext); + return (BYTE *)xs + offset; } @@ -859,8 +924,9 @@ NTSTATUS WINAPI RtlCopyContext( CONTEXT *dst, DWORD context_flags, CONTEXT *src NTSTATUS WINAPI RtlCopyExtendedContext( CONTEXT_EX *dst, ULONG context_flags, CONTEXT_EX *src ) { const struct context_parameters *p; - XSTATE *dst_xs, *src_xs; + XSAVE_AREA_HEADER *dst_xs, *src_xs; ULONG64 feature_mask; + unsigned int i, off, size; TRACE( "dst %p, context_flags %#lx, src %p.\n", dst, context_flags, src ); @@ -875,18 +941,35 @@ NTSTATUS WINAPI RtlCopyExtendedContext( CONTEXT_EX *dst, ULONG context_flags, CO if (!(context_flags & 0x40)) return STATUS_SUCCESS; - if (dst->XState.Length < offsetof(XSTATE, YmmContext)) + if (dst->XState.Length < sizeof(XSAVE_AREA_HEADER)) return STATUS_BUFFER_OVERFLOW; - dst_xs = (XSTATE *)((BYTE *)dst + dst->XState.Offset); - src_xs = (XSTATE *)((BYTE *)src + src->XState.Offset); + dst_xs = (XSAVE_AREA_HEADER *)((BYTE *)dst + dst->XState.Offset); + src_xs = (XSAVE_AREA_HEADER *)((BYTE *)src + src->XState.Offset); - memset(dst_xs, 0, offsetof(XSTATE, YmmContext)); + memset(dst_xs, 0, sizeof(XSAVE_AREA_HEADER)); dst_xs->Mask = (src_xs->Mask & ~(ULONG64)3) & feature_mask; dst_xs->CompactionMask = user_shared_data->XState.CompactionEnabled ? ((ULONG64)1 << 63) | (src_xs->CompactionMask & feature_mask) : 0; - if (dst_xs->Mask & 4 && src->XState.Length >= sizeof(XSTATE) && dst->XState.Length >= sizeof(XSTATE)) - memcpy( &dst_xs->YmmContext, &src_xs->YmmContext, sizeof(dst_xs->YmmContext) ); + + if (dst_xs->CompactionMask) feature_mask &= dst_xs->CompactionMask; + feature_mask = dst_xs->Mask >> 2; + + i = 2; + off = sizeof(XSAVE_AREA_HEADER); + while (1) + { + if (feature_mask & 1) + { + if (!dst_xs->CompactionMask) off = user_shared_data->XState.Features[i].Offset - sizeof(XSAVE_FORMAT); + size = user_shared_data->XState.Features[i].Size; + if (src->XState.Length < off + size || dst->XState.Length < off + size) break; + memcpy( (BYTE *)dst_xs + off, (BYTE *)src_xs + off, size ); + } + if (!(feature_mask >>= 1)) break; + if (dst_xs->CompactionMask) off = next_compacted_xstate_offset( off, dst_xs->CompactionMask, i); + ++i; + } return STATUS_SUCCESS; }
1
0
0
0
Paul Gofman : ntdll: Don't copy xstate from / to syscall frame in usr1_handler().
by Alexandre Julliard
27 Feb '24
27 Feb '24
Module: wine Branch: master Commit: efd3d31082645fab83c6a4994705654edafa9163 URL:
https://gitlab.winehq.org/wine/wine/-/commit/efd3d31082645fab83c6a499470565…
Author: Paul Gofman <pgofman(a)codeweavers.com> Date: Thu Feb 1 12:17:14 2024 -0600 ntdll: Don't copy xstate from / to syscall frame in usr1_handler(). --- dlls/ntdll/unix/signal_i386.c | 44 ++++++++++++++++++++++++++++++----------- dlls/ntdll/unix/signal_x86_64.c | 34 ++++++++++++++++++++++++------- 2 files changed, 60 insertions(+), 18 deletions(-) diff --git a/dlls/ntdll/unix/signal_i386.c b/dlls/ntdll/unix/signal_i386.c index e9a86e68948..0e6b6dcee43 100644 --- a/dlls/ntdll/unix/signal_i386.c +++ b/dlls/ntdll/unix/signal_i386.c @@ -2107,24 +2107,46 @@ static void quit_handler( int signal, siginfo_t *siginfo, void *sigcontext ) */ static void usr1_handler( int signal, siginfo_t *siginfo, void *sigcontext ) { - struct xcontext xcontext; + ucontext_t *ucontext = sigcontext; init_handler( sigcontext ); - if (is_inside_syscall( sigcontext )) + + if (is_inside_syscall( ucontext )) { - DECLSPEC_ALIGN(64) XSTATE xs; - xcontext.c.ContextFlags = CONTEXT_FULL; - context_init_xstate( &xcontext.c, &xs ); + struct syscall_frame *frame = x86_thread_data()->syscall_frame; + ULONG64 saved_compaction = 0; + struct xcontext *context; - NtGetContextThread( GetCurrentThread(), &xcontext.c ); - wait_suspend( &xcontext.c ); - NtSetContextThread( GetCurrentThread(), &xcontext.c ); + context = (struct xcontext *)(((ULONG_PTR)ESP_sig(ucontext) - sizeof(*context)) & ~15); + if ((char *)context < (char *)ntdll_get_thread_data()->kernel_stack) + { + ERR_(seh)( "kernel stack overflow.\n" ); + return; + } + context->c.ContextFlags = CONTEXT_FULL; + NtGetContextThread( GetCurrentThread(), &context->c ); + if (xstate_extended_features()) + { + context_init_xstate( &context->c, &frame->xstate ); + saved_compaction = frame->xstate.CompactionMask; + } + wait_suspend( &context->c ); + if (xstate_extended_features()) frame->xstate.CompactionMask = saved_compaction; + if (context->c.ContextFlags & 0x40) + { + /* xstate is updated directly in frame's xstate */ + context->c.ContextFlags &= ~0x40; + frame->restore_flags |= 0x40; + } + NtSetContextThread( GetCurrentThread(), &context->c ); } else { - save_context( &xcontext, sigcontext ); - wait_suspend( &xcontext.c ); - restore_context( &xcontext, sigcontext ); + struct xcontext context; + + save_context( &context, ucontext ); + wait_suspend( &context.c ); + restore_context( &context, ucontext ); } } diff --git a/dlls/ntdll/unix/signal_x86_64.c b/dlls/ntdll/unix/signal_x86_64.c index b6586f88803..e08f6ad897a 100644 --- a/dlls/ntdll/unix/signal_x86_64.c +++ b/dlls/ntdll/unix/signal_x86_64.c @@ -2145,20 +2145,40 @@ static void quit_handler( int signal, siginfo_t *siginfo, void *sigcontext ) static void usr1_handler( int signal, siginfo_t *siginfo, void *sigcontext ) { ucontext_t *ucontext = init_handler( sigcontext ); - struct xcontext context; if (is_inside_syscall( ucontext )) { - DECLSPEC_ALIGN(64) XSTATE xs; - context.c.ContextFlags = CONTEXT_FULL | CONTEXT_SEGMENTS; - context_init_xstate( &context.c, &xs ); + struct syscall_frame *frame = amd64_thread_data()->syscall_frame; + ULONG64 saved_compaction = 0; + struct xcontext *context; - NtGetContextThread( GetCurrentThread(), &context.c ); - wait_suspend( &context.c ); - NtSetContextThread( GetCurrentThread(), &context.c ); + context = (struct xcontext *)(((ULONG_PTR)RSP_sig(ucontext) - sizeof(*context)) & ~15); + if ((char *)context < (char *)ntdll_get_thread_data()->kernel_stack) + { + ERR_(seh)( "kernel stack overflow.\n" ); + return; + } + context->c.ContextFlags = CONTEXT_FULL | CONTEXT_SEGMENTS; + NtGetContextThread( GetCurrentThread(), &context->c ); + if (xstate_extended_features()) + { + context_init_xstate( &context->c, &frame->xstate ); + saved_compaction = frame->xstate.CompactionMask; + } + wait_suspend( &context->c ); + if (xstate_extended_features()) frame->xstate.CompactionMask = saved_compaction; + if (context->c.ContextFlags & 0x40) + { + /* xstate is updated directly in frame's xstate */ + context->c.ContextFlags &= ~0x40; + frame->restore_flags |= 0x40; + } + NtSetContextThread( GetCurrentThread(), &context->c ); } else { + struct xcontext context; + save_context( &context, ucontext ); wait_suspend( &context.c ); restore_context( &context, ucontext );
1
0
0
0
Paul Gofman : ntdll: Mind context compaction mask in context_from_server().
by Alexandre Julliard
27 Feb '24
27 Feb '24
Module: wine Branch: master Commit: ba1e2d5dda84f64bd784ae1797ad2825d8b8f096 URL:
https://gitlab.winehq.org/wine/wine/-/commit/ba1e2d5dda84f64bd784ae1797ad28…
Author: Paul Gofman <pgofman(a)codeweavers.com> Date: Thu Feb 1 11:47:42 2024 -0600 ntdll: Mind context compaction mask in context_from_server(). --- dlls/ntdll/unix/signal_i386.c | 17 ++--------------- dlls/ntdll/unix/signal_x86_64.c | 5 ----- dlls/ntdll/unix/thread.c | 8 ++++---- 3 files changed, 6 insertions(+), 24 deletions(-) diff --git a/dlls/ntdll/unix/signal_i386.c b/dlls/ntdll/unix/signal_i386.c index 3ac12a35db6..e9a86e68948 100644 --- a/dlls/ntdll/unix/signal_i386.c +++ b/dlls/ntdll/unix/signal_i386.c @@ -607,7 +607,6 @@ struct xcontext { CONTEXT c; CONTEXT_EX c_ex; - ULONG64 host_compaction_mask; }; static inline XSAVE_AREA_HEADER *xstate_from_context( const CONTEXT *context ) @@ -831,11 +830,7 @@ static inline void save_context( struct xcontext *xcontext, const ucontext_t *si context->ContextFlags |= CONTEXT_FLOATING_POINT | CONTEXT_EXTENDED_REGISTERS; memcpy( context->ExtendedRegisters, fpux, sizeof(*fpux) ); if (!fpu) fpux_to_fpu( &context->FloatSave, fpux ); - if (xstate_extended_features() && (xs = XState_sig(fpux))) - { - context_init_xstate( context, xs ); - xcontext->host_compaction_mask = xs->CompactionMask; - } + if (xstate_extended_features() && (xs = XState_sig(fpux))) context_init_xstate( context, xs ); } if (!fpu && !fpux) save_fpu( context ); } @@ -876,15 +871,7 @@ static inline void restore_context( const struct xcontext *xcontext, ucontext_t SS_sig(sigcontext) = context->SegSs; if (fpu) *fpu = context->FloatSave; - if (fpux) - { - XSAVE_AREA_HEADER *xs; - - memcpy( fpux, context->ExtendedRegisters, sizeof(*fpux) ); - - if (xstate_extended_features() && (xs = XState_sig(fpux))) - xs->CompactionMask = xcontext->host_compaction_mask; - } + if (fpux) memcpy( fpux, context->ExtendedRegisters, sizeof(*fpux) ); if (!fpu && !fpux) restore_fpu( context ); } diff --git a/dlls/ntdll/unix/signal_x86_64.c b/dlls/ntdll/unix/signal_x86_64.c index 01bbd2e3572..b6586f88803 100644 --- a/dlls/ntdll/unix/signal_x86_64.c +++ b/dlls/ntdll/unix/signal_x86_64.c @@ -479,7 +479,6 @@ struct xcontext { CONTEXT c; CONTEXT_EX c_ex; - ULONG64 host_compaction_mask; }; static inline XSAVE_AREA_HEADER *xstate_from_context( const CONTEXT *context ) @@ -907,7 +906,6 @@ static void save_context( struct xcontext *xcontext, const ucontext_t *sigcontex * just reference sigcontext without overflowing 32 bit XState.Offset */ context_init_xstate( context, xs ); assert( xcontext->c_ex.XState.Offset == (BYTE *)xs - (BYTE *)&xcontext->c_ex ); - xcontext->host_compaction_mask = xs->CompactionMask; } } } @@ -921,7 +919,6 @@ static void save_context( struct xcontext *xcontext, const ucontext_t *sigcontex static void restore_context( const struct xcontext *xcontext, ucontext_t *sigcontext ) { const CONTEXT *context = &xcontext->c; - XSAVE_AREA_HEADER *xs; amd64_thread_data()->dr0 = context->Dr0; amd64_thread_data()->dr1 = context->Dr1; @@ -931,8 +928,6 @@ static void restore_context( const struct xcontext *xcontext, ucontext_t *sigcon amd64_thread_data()->dr7 = context->Dr7; set_sigcontext( context, sigcontext ); if (FPU_sig(sigcontext)) *FPU_sig(sigcontext) = context->FltSave; - if (xstate_extended_features() && (xs = XState_sig(FPU_sig(sigcontext)))) - xs->CompactionMask = xcontext->host_compaction_mask; leave_handler( sigcontext ); } diff --git a/dlls/ntdll/unix/thread.c b/dlls/ntdll/unix/thread.c index 578399f43f3..660d8389cae 100644 --- a/dlls/ntdll/unix/thread.c +++ b/dlls/ntdll/unix/thread.c @@ -691,7 +691,7 @@ static NTSTATUS context_from_server( void *dst, const context_t *from, USHORT ma XSTATE *xs = (XSTATE *)((char *)xctx + xctx->XState.Offset); xs->Mask &= ~4; - if (user_shared_data->XState.CompactionEnabled) xs->CompactionMask = 0x8000000000000004; + if (xs->CompactionMask) xs->CompactionMask = 0x8000000000000004; for (i = 0; i < ARRAY_SIZE( from->ymm.regs.ymm_high); i++) { if (!from->ymm.regs.ymm_high[i].low && !from->ymm.regs.ymm_high[i].high) continue; @@ -765,7 +765,7 @@ static NTSTATUS context_from_server( void *dst, const context_t *from, USHORT ma XSTATE *xs = (XSTATE *)((char *)xctx + xctx->XState.Offset); xs->Mask &= ~4; - if (user_shared_data->XState.CompactionEnabled) xs->CompactionMask = 0x8000000000000004; + if (xs->CompactionMask) xs->CompactionMask = 0x8000000000000004; for (i = 0; i < ARRAY_SIZE( from->ymm.regs.ymm_high); i++) { if (!from->ymm.regs.ymm_high[i].low && !from->ymm.regs.ymm_high[i].high) continue; @@ -840,7 +840,7 @@ static NTSTATUS context_from_server( void *dst, const context_t *from, USHORT ma XSTATE *xs = (XSTATE *)((char *)xctx + xctx->XState.Offset); xs->Mask &= ~4; - if (user_shared_data->XState.CompactionEnabled) xs->CompactionMask = 0x8000000000000004; + if (xs->CompactionMask) xs->CompactionMask = 0x8000000000000004; for (i = 0; i < ARRAY_SIZE( from->ymm.regs.ymm_high); i++) { if (!from->ymm.regs.ymm_high[i].low && !from->ymm.regs.ymm_high[i].high) continue; @@ -922,7 +922,7 @@ static NTSTATUS context_from_server( void *dst, const context_t *from, USHORT ma XSTATE *xs = (XSTATE *)((char *)xctx + xctx->XState.Offset); xs->Mask &= ~4; - if (user_shared_data->XState.CompactionEnabled) xs->CompactionMask = 0x8000000000000004; + if (xs->CompactionMask) xs->CompactionMask = 0x8000000000000004; for (i = 0; i < ARRAY_SIZE( from->ymm.regs.ymm_high); i++) { if (!from->ymm.regs.ymm_high[i].low && !from->ymm.regs.ymm_high[i].high) continue;
1
0
0
0
Alexandre Julliard : ntdll: Use a .seh handler in RtlUserThreadStart on ARM64EC.
by Alexandre Julliard
27 Feb '24
27 Feb '24
Module: wine Branch: master Commit: 631a43c577420c272cbab1741fc82373ab4c7805 URL:
https://gitlab.winehq.org/wine/wine/-/commit/631a43c577420c272cbab1741fc823…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Tue Feb 27 16:49:42 2024 +0100 ntdll: Use a .seh handler in RtlUserThreadStart on ARM64EC. --- dlls/ntdll/signal_arm64ec.c | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/dlls/ntdll/signal_arm64ec.c b/dlls/ntdll/signal_arm64ec.c index 5fc4b113a97..9174eafc3e3 100644 --- a/dlls/ntdll/signal_arm64ec.c +++ b/dlls/ntdll/signal_arm64ec.c @@ -1740,17 +1740,25 @@ void WINAPI RtlRaiseException( struct _EXCEPTION_RECORD * rec) /*********************************************************************** * RtlUserThreadStart (NTDLL.@) */ -void WINAPI RtlUserThreadStart( PRTL_THREAD_START_ROUTINE entry, void *arg ) +void __attribute__((naked)) RtlUserThreadStart( PRTL_THREAD_START_ROUTINE entry, void *arg ) { - __TRY - { - pBaseThreadInitThunk( 0, (LPTHREAD_START_ROUTINE)entry, arg ); - } - __EXCEPT(call_unhandled_exception_filter) - { - NtTerminateProcess( GetCurrentProcess(), GetExceptionCode() ); - } - __ENDTRY + asm( ".seh_proc RtlUserThreadStart\n\t" + "stp x29, x30, [sp, #-16]!\n\t" + ".seh_save_fplr_x 16\n\t" + ".seh_endprologue\n\t" + "adrp x11, pBaseThreadInitThunk\n\t" + "ldr x11, [x11, #:lo12:pBaseThreadInitThunk]\n\t" + "adr x10, $iexit_thunk$cdecl$v$i8i8i8\n\t" + "mov x2, x1\n\t" + "mov x1, x0\n\t" + "mov x0, #0\n\t" + "adrp x16, __os_arm64x_dispatch_icall\n\t" + "ldr x16, [x16, #:lo12:__os_arm64x_dispatch_icall]\n\t" + "blr x16\n\t" + "blr x11\n\t" + "brk #1\n\t" + ".seh_handler call_unhandled_exception_handler, @except\n\t" + ".seh_endproc" ); }
1
0
0
0
Alexandre Julliard : ntdll: Use a .seh handler in DbgUiRemoteBreakin on ARM64EC.
by Alexandre Julliard
27 Feb '24
27 Feb '24
Module: wine Branch: master Commit: 8e26b7e0077dc3eab5d3ce9fc322e1484f31824f URL:
https://gitlab.winehq.org/wine/wine/-/commit/8e26b7e0077dc3eab5d3ce9fc322e1…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Tue Feb 27 16:48:25 2024 +0100 ntdll: Use a .seh handler in DbgUiRemoteBreakin on ARM64EC. --- dlls/ntdll/signal_arm64ec.c | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/dlls/ntdll/signal_arm64ec.c b/dlls/ntdll/signal_arm64ec.c index a2b21f51ead..5fc4b113a97 100644 --- a/dlls/ntdll/signal_arm64ec.c +++ b/dlls/ntdll/signal_arm64ec.c @@ -1792,26 +1792,30 @@ __ASM_GLOBAL_FUNC( "#process_breakpoint", "mov w0, #0\n\t" /* ExceptionContinueExecution */ "ret" ) + /*********************************************************************** * DbgUiRemoteBreakin (NTDLL.@) */ -void WINAPI DbgUiRemoteBreakin( void *arg ) +void __attribute__((naked)) DbgUiRemoteBreakin( void *arg ) { - if (NtCurrentTeb()->Peb->BeingDebugged) - { - __TRY - { - DbgBreakPoint(); - } - __EXCEPT_ALL - { - /* do nothing */ - } - __ENDTRY - } - RtlExitUserThread( STATUS_SUCCESS ); + asm( ".seh_proc DbgUiRemoteBreakin\n\t" + "stp x29, x30, [sp, #-16]!\n\t" + ".seh_save_fplr_x 16\n\t" + ".seh_endprologue\n\t" + ".seh_handler DbgUiRemoteBreakin_handler, @except\n\t" + "ldr x0, [x18, #0x60]\n\t" /* NtCurrentTeb()->Peb */ + "ldrb w0, [x0, 0x02]\n\t" /* peb->BeingDebugged */ + "cbz w0, 1f\n\t" + "bl DbgBreakPoint\n" + "1:\tmov w0, #0\n\t" + "bl RtlExitUserThread\n" + "DbgUiRemoteBreakin_handler:\n\t" + "mov sp, x1\n\t" /* frame */ + "b 1b\n\t" + ".seh_endproc" ); } + /********************************************************************** * DbgBreakPoint (NTDLL.@) */
1
0
0
0
Alexandre Julliard : ntdll: Always use .seh handlers on ARM.
by Alexandre Julliard
27 Feb '24
27 Feb '24
Module: wine Branch: master Commit: 58e68a1b8a1ff84f09b25de65c20904bcce484d8 URL:
https://gitlab.winehq.org/wine/wine/-/commit/58e68a1b8a1ff84f09b25de65c2090…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Tue Feb 27 16:46:47 2024 +0100 ntdll: Always use .seh handlers on ARM. --- dlls/ntdll/signal_arm.c | 49 ------------------------------------------------- 1 file changed, 49 deletions(-) diff --git a/dlls/ntdll/signal_arm.c b/dlls/ntdll/signal_arm.c index 4fe2d8bd96a..834d52fb83b 100644 --- a/dlls/ntdll/signal_arm.c +++ b/dlls/ntdll/signal_arm.c @@ -907,7 +907,6 @@ USHORT WINAPI RtlCaptureStackBackTrace( ULONG skip, ULONG count, PVOID *buffer, /*********************************************************************** * RtlUserThreadStart (NTDLL.@) */ -#ifdef __WINE_PE_BUILD __ASM_GLOBAL_FUNC( RtlUserThreadStart, ".seh_endprologue\n\t" "mov r2, r1\n\t" @@ -918,20 +917,6 @@ __ASM_GLOBAL_FUNC( RtlUserThreadStart, "blx ip\n" "1:\t.long " __ASM_NAME("pBaseThreadInitThunk") "\n\t" ".seh_handler " __ASM_NAME("call_unhandled_exception_handler") ", %except" ) -#else -void WINAPI RtlUserThreadStart( PRTL_THREAD_START_ROUTINE entry, void *arg ) -{ - __TRY - { - pBaseThreadInitThunk( 0, (LPTHREAD_START_ROUTINE)entry, arg ); - } - __EXCEPT(call_unhandled_exception_filter) - { - NtTerminateProcess( GetCurrentProcess(), GetExceptionCode() ); - } - __ENDTRY -} -#endif /****************************************************************** * LdrInitializeThunk (NTDLL.@) @@ -946,7 +931,6 @@ void WINAPI LdrInitializeThunk( CONTEXT *context, ULONG_PTR unk2, ULONG_PTR unk3 /*********************************************************************** * process_breakpoint */ -#ifdef __WINE_PE_BUILD __ASM_GLOBAL_FUNC( process_breakpoint, ".seh_endprologue\n\t" ".seh_handler process_breakpoint_handler, %except\n\t" @@ -958,25 +942,10 @@ __ASM_GLOBAL_FUNC( process_breakpoint, "str r0, [r2, #0x40]\n\t" "mov r0, #0\n\t" /* ExceptionContinueExecution */ "bx lr" ) -#else -void WINAPI process_breakpoint(void) -{ - __TRY - { - DbgBreakPoint(); - } - __EXCEPT_ALL - { - /* do nothing */ - } - __ENDTRY -} -#endif /*********************************************************************** * DbgUiRemoteBreakin (NTDLL.@) */ -#ifdef __WINE_PE_BUILD __ASM_GLOBAL_FUNC( DbgUiRemoteBreakin, ".seh_endprologue\n\t" ".seh_handler DbgUiRemoteBreakin_handler, %except\n\t" @@ -990,24 +959,6 @@ __ASM_GLOBAL_FUNC( DbgUiRemoteBreakin, "DbgUiRemoteBreakin_handler:\n\t" "mov sp, r1\n\t" /* frame */ "b 1b" ) -#else -void WINAPI DbgUiRemoteBreakin( void *arg ) -{ - if (NtCurrentTeb()->Peb->BeingDebugged) - { - __TRY - { - DbgBreakPoint(); - } - __EXCEPT_ALL - { - /* do nothing */ - } - __ENDTRY - } - RtlExitUserThread( STATUS_SUCCESS ); -} -#endif /********************************************************************** * DbgBreakPoint (NTDLL.@)
1
0
0
0
Alexandre Julliard : wow64: Use a .seh handler for the simulation loop.
by Alexandre Julliard
27 Feb '24
27 Feb '24
Module: wine Branch: master Commit: 89336772f810cf0ecc456d5a94ad766fb92e87e1 URL:
https://gitlab.winehq.org/wine/wine/-/commit/89336772f810cf0ecc456d5a94ad76…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Tue Feb 27 16:20:55 2024 +0100 wow64: Use a .seh handler for the simulation loop. --- dlls/wow64/syscall.c | 75 +++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 63 insertions(+), 12 deletions(-) diff --git a/dlls/wow64/syscall.c b/dlls/wow64/syscall.c index 78338f7ef6a..9f1f324ce35 100644 --- a/dlls/wow64/syscall.c +++ b/dlls/wow64/syscall.c @@ -940,25 +940,75 @@ NTSTATUS WINAPI Wow64SystemServiceEx( UINT num, UINT *args ) /********************************************************************** - * simulate_filter + * cpu_simulate */ +#ifdef __aarch64__ +extern void DECLSPEC_NORETURN cpu_simulate( void (*func)(void) ); +__ASM_GLOBAL_FUNC( cpu_simulate, + "stp x29, x30, [sp, #-32]!\n\t" + ".seh_save_fplr_x 32\n\t" + ".seh_endprologue\n\t" + ".seh_handler cpu_simulate_handler, @except\n\t" + "str x0, [sp, #16]\n" + ".Lcpu_simulate_loop:\n\t" + "ldr x0, [sp, #16]\n\t" + "blr x0\n\t" + "b .Lcpu_simulate_loop" ) +__ASM_GLOBAL_FUNC( cpu_simulate_handler, + "stp x29, x30, [sp, #-32]!\n\t" + ".seh_save_fplr_x 32\n\t" + ".seh_endprologue\n\t" + "mov x19, x0\n\t" /* record */ + "mov x20, x1\n\t" /* frame */ + "stp x0, x2, [sp, #16]\n\t" /* record, context */ + "add x0, sp, #16\n\t" + "bl Wow64PassExceptionToGuest\n\t" + "mov x20, x0\n\t" /* frame */ + "adr x1, .Lcpu_simulate_loop\n\t" /* target */ + "mov x19, x2\n\t" /* record */ + "bl RtlUnwind\n\t" + "brk #1" ) + +#elif defined __WINE_PE_BUILD +extern void DECLSPEC_NORETURN cpu_simulate( void (*func)(void) ); +__ASM_GLOBAL_FUNC( cpu_simulate, + "subq $0x28, %rsp\n\t" + ".seh_stackalloc 0x28\n\t" + ".seh_endprologue\n\t" + ".seh_handler cpu_simulate_handler, @except\n\t" + "movq %rcx,0x20(%rsp)\n" + ".Lcpu_simulate_loop:\n\t" + "call *0x20(%rsp)\n\t" + "jmp .Lcpu_simulate_loop" ) +__ASM_GLOBAL_FUNC( cpu_simulate_handler, + "subq $0x38, %rsp\n\t" + ".seh_stackalloc 0x38\n\t" + ".seh_endprologue\n\t" + "movq %rcx,%rsi\n\t" /* record */ + "movq %rcx,0x20(%rsp)\n\t" + "movq %rdx,%rdi\n\t" /* frame */ + "movq %r8,0x28(%rsp)\n\t" /* context */ + "leaq 0x20(%rsp),%rcx\n\t" + "call Wow64PassExceptionToGuest\n\t" + "movq %rdi,%rcx\n\t" /* frame */ + "leaq .Lcpu_simulate_loop(%rip), %rdx\n\t" /* target */ + "movq %rsi,%r8\n\t" /* record */ + "call RtlUnwind\n\t" + "int3" ) +#else static LONG CALLBACK simulate_filter( EXCEPTION_POINTERS *ptrs ) { Wow64PassExceptionToGuest( ptrs ); return EXCEPTION_EXECUTE_HANDLER; } - -/********************************************************************** - * cpu_simulate - */ -static void cpu_simulate(void) +static void cpu_simulate( void (*func)(void) ) { for (;;) { __TRY { - pBTCpuSimulate(); + func(); } __EXCEPT( simulate_filter ) { @@ -967,6 +1017,7 @@ static void cpu_simulate(void) __ENDTRY } } +#endif /********************************************************************** @@ -1039,7 +1090,7 @@ void WINAPI Wow64ApcRoutine( ULONG_PTR arg1, ULONG_PTR arg2, ULONG_PTR arg3, CON ctx.Eip = pLdrSystemDllInitBlock->pKiUserApcDispatcher; frame.wow_context = &stack->context; pBTCpuSetContext( GetCurrentThread(), GetCurrentProcess(), NULL, &ctx ); - cpu_simulate(); + cpu_simulate( pBTCpuSimulate ); } break; @@ -1065,7 +1116,7 @@ void WINAPI Wow64ApcRoutine( ULONG_PTR arg1, ULONG_PTR arg2, ULONG_PTR arg3, CON ctx.R3 = arg3; frame.wow_context = &stack->context; pBTCpuSetContext( GetCurrentThread(), GetCurrentProcess(), NULL, &ctx ); - cpu_simulate(); + cpu_simulate( pBTCpuSimulate ); } break; } @@ -1128,7 +1179,7 @@ NTSTATUS WINAPI Wow64KiUserCallbackDispatcher( ULONG id, void *args, ULONG len, pBTCpuSetContext( GetCurrentThread(), GetCurrentProcess(), NULL, &ctx ); if (!__wine_setjmpex( &frame.jmpbuf, NULL )) - cpu_simulate(); + cpu_simulate( pBTCpuSimulate ); else pBTCpuSetContext( GetCurrentThread(), GetCurrentProcess(), NULL, &orig_ctx ); } @@ -1153,7 +1204,7 @@ NTSTATUS WINAPI Wow64KiUserCallbackDispatcher( ULONG id, void *args, ULONG len, pBTCpuSetContext( GetCurrentThread(), GetCurrentProcess(), NULL, &ctx ); if (!__wine_setjmpex( &frame.jmpbuf, NULL )) - cpu_simulate(); + cpu_simulate( pBTCpuSimulate ); else pBTCpuSetContext( GetCurrentThread(), GetCurrentProcess(), NULL, &orig_ctx ); } @@ -1177,7 +1228,7 @@ void WINAPI Wow64LdrpInitialize( CONTEXT *context ) RtlRunOnceExecuteOnce( &init_done, process_init, NULL, NULL ); thread_init(); - cpu_simulate(); + cpu_simulate( pBTCpuSimulate ); }
1
0
0
0
Alexandre Julliard : wow64: Update Wow64RaiseException behavior to match i386 hardware exceptions.
by Alexandre Julliard
27 Feb '24
27 Feb '24
Module: wine Branch: master Commit: 259b92d13e2d2c67876006ff0485e7031f4ec7bf URL:
https://gitlab.winehq.org/wine/wine/-/commit/259b92d13e2d2c67876006ff0485e7…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Tue Feb 27 16:02:18 2024 +0100 wow64: Update Wow64RaiseException behavior to match i386 hardware exceptions. --- dlls/wow64/syscall.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/dlls/wow64/syscall.c b/dlls/wow64/syscall.c index db51948057f..78338f7ef6a 100644 --- a/dlls/wow64/syscall.c +++ b/dlls/wow64/syscall.c @@ -1330,11 +1330,13 @@ NTSTATUS WINAPI Wow64RaiseException( int code, EXCEPTION_RECORD *rec ) int_rec.ExceptionCode = EXCEPTION_INT_DIVIDE_BY_ZERO; break; case 0x01: /* single-step */ + ctx32.i386.EFlags &= ~0x100; + pBTCpuSetContext( GetCurrentThread(), GetCurrentProcess(), NULL, &ctx32.i386 ); int_rec.ExceptionCode = EXCEPTION_SINGLE_STEP; break; case 0x03: /* breakpoint */ int_rec.ExceptionCode = EXCEPTION_BREAKPOINT; - int_rec.ExceptionAddress = (void *)(ULONG_PTR)(ctx32.i386.Eip + 1); + int_rec.ExceptionAddress = (void *)(ULONG_PTR)(ctx32.i386.Eip - 1); int_rec.NumberParameters = 1; break; case 0x04: /* overflow */ @@ -1352,6 +1354,9 @@ NTSTATUS WINAPI Wow64RaiseException( int code, EXCEPTION_RECORD *rec ) case 0x0c: /* stack fault */ int_rec.ExceptionCode = EXCEPTION_STACK_OVERFLOW; break; + case 0x0d: /* general protection fault */ + int_rec.ExceptionCode = EXCEPTION_PRIV_INSTRUCTION; + break; case 0x29: /* __fastfail */ int_rec.ExceptionCode = STATUS_STACK_BUFFER_OVERRUN; int_rec.ExceptionFlags = EH_NONCONTINUABLE; @@ -1360,7 +1365,7 @@ NTSTATUS WINAPI Wow64RaiseException( int code, EXCEPTION_RECORD *rec ) first_chance = FALSE; break; case 0x2d: /* debug service */ - ctx32.i386.Eip++; + ctx32.i386.Eip += 3; pBTCpuSetContext( GetCurrentThread(), GetCurrentProcess(), NULL, &ctx32.i386 ); int_rec.ExceptionCode = EXCEPTION_BREAKPOINT; int_rec.ExceptionAddress = (void *)(ULONG_PTR)ctx32.i386.Eip; @@ -1368,8 +1373,6 @@ NTSTATUS WINAPI Wow64RaiseException( int code, EXCEPTION_RECORD *rec ) int_rec.ExceptionInformation[0] = ctx32.i386.Eax; break; default: - ctx32.i386.Eip -= 2; - pBTCpuSetContext( GetCurrentThread(), GetCurrentProcess(), NULL, &ctx32.i386 ); int_rec.ExceptionCode = EXCEPTION_ACCESS_VIOLATION; int_rec.ExceptionAddress = (void *)(ULONG_PTR)ctx32.i386.Eip; int_rec.NumberParameters = 2;
1
0
0
0
Alexandre Julliard : winebuild: Remove some no longer used support for ELF ARM platforms.
by Alexandre Julliard
27 Feb '24
27 Feb '24
Module: wine Branch: master Commit: 4e25c07689d4958cd070f0589dab8a2d06004bb9 URL:
https://gitlab.winehq.org/wine/wine/-/commit/4e25c07689d4958cd070f0589dab8a…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Tue Feb 27 12:51:46 2024 +0100 winebuild: Remove some no longer used support for ELF ARM platforms. --- tools/winebuild/build.h | 2 -- tools/winebuild/import.c | 42 +++++++++++-------------------------- tools/winebuild/spec32.c | 25 ++++------------------ tools/winebuild/utils.c | 54 +++--------------------------------------------- 4 files changed, 19 insertions(+), 104 deletions(-) diff --git a/tools/winebuild/build.h b/tools/winebuild/build.h index af7861275a3..a469a0e9042 100644 --- a/tools/winebuild/build.h +++ b/tools/winebuild/build.h @@ -301,8 +301,6 @@ extern const char *get_asm_export_section(void); extern const char *get_asm_rodata_section(void); extern const char *get_asm_rsrc_section(void); extern const char *get_asm_string_section(void); -extern const char *arm64_page( const char *sym ); -extern const char *arm64_pageoff( const char *sym ); extern void output_function_header( const char *func, int global ); extern void output_function_size( const char *name ); extern void output_gnu_stack_note(void); diff --git a/tools/winebuild/import.c b/tools/winebuild/import.c index a2473efc5ba..eb9f0205eb5 100644 --- a/tools/winebuild/import.c +++ b/tools/winebuild/import.c @@ -777,19 +777,7 @@ static void output_import_thunk( const char *name, const char *table, int pos ) case CPU_x86_64: output( "\tjmpq *%s+%d(%%rip)\n", table, pos ); break; - case CPU_ARM: - output( "\tldr ip, 1f\n"); - output( "\tldr pc, [ip]\n"); - output( "1:\t.long %s+%u\n", table, pos ); - break; - case CPU_ARM64: - output( "\tadrp x16, %s\n", arm64_page( table ) ); - output( "\tadd x16, x16, #%s\n", arm64_pageoff( table ) ); - if (pos & ~0x7fff) output( "\tadd x16, x16, #%u\n", pos & ~0x7fff ); - output( "\tldr x16, [x16, #%u]\n", pos & 0x7fff ); - output( "\tbr x16\n" ); - break; - case CPU_ARM64EC: + default: assert( 0 ); break; } @@ -1077,9 +1065,7 @@ static void output_delayed_import_thunks( const DLLSPEC *spec ) output_cfi( ".cfi_adjust_cfa_offset -0x98" ); output( "\tjmp *%%rax\n" ); break; - case CPU_ARM: - case CPU_ARM64: - case CPU_ARM64EC: + default: assert( 0 ); break; } @@ -1109,9 +1095,7 @@ static void output_delayed_import_thunks( const DLLSPEC *spec ) output( "\tleaq .L__wine_delay_IAT+%d(%%rip),%%rax\n", iat_pos ); output( "\tjmp %s\n", asm_name(module_func) ); break; - case CPU_ARM: - case CPU_ARM64: - case CPU_ARM64EC: + default: assert( 0 ); break; } @@ -1274,14 +1258,12 @@ void output_stubs( DLLSPEC *spec ) case CPU_ARM64EC: output( "\t.seh_proc %s\n", arm64_name(name) ); output( "\t.seh_endprologue\n" ); - output( "\tadrp x0, %s\n", arm64_page(".L__wine_spec_file_name") ); - output( "\tadd x0, x0, #%s\n", arm64_pageoff(".L__wine_spec_file_name") ); + output( "\tadrp x0, .L__wine_spec_file_name\n" ); + output( "\tadd x0, x0, #:lo12:.L__wine_spec_file_name\n" ); if (exp_name) { - char *sym = strmake( ".L%s_string", name ); - output( "\tadrp x1, %s\n", arm64_page( sym ) ); - output( "\tadd x1, x1, #%s\n", arm64_pageoff( sym ) ); - free( sym ); + output( "\tadrp x1, .L%s_string\n", name ); + output( "\tadd x1, x1, #:lo12:.L%s_string\n", name ); } else output( "\tmov x1, %u\n", odp->ordinal ); @@ -1532,7 +1514,7 @@ static void build_windows_import_lib( const char *lib_name, DLLSPEC *spec, struc output( "\tstp x6, x7, [sp, #64]\n" ); output( "\tmov x1, x16\n" ); output( "\tadrp x0, %s\n", asm_name( import_desc ) ); - output( "\tadd x0, x0, #%s\n", asm_name( import_desc ) ); + output( "\tadd x0, x0, #:lo12:%s\n", asm_name( import_desc ) ); output( "\tbl __delayLoadHelper2\n" ); output( "\tmov x16, x0\n" ); output( "\tldp x0, x1, [sp, #16]\n" ); @@ -1677,15 +1659,15 @@ static void build_windows_import_lib( const char *lib_name, DLLSPEC *spec, struc output( "1:\t.long %s\n", asm_name( imp_name ) ); break; case CPU_ARM64: - output( "\tadrp x16, %s\n", arm64_page( asm_name( imp_name ) ) ); - output( "\tadd x16, x16, #%s\n", arm64_pageoff( asm_name( imp_name ) ) ); + output( "\tadrp x16, %s\n", asm_name( imp_name ) ); + output( "\tadd x16, x16, #:lo12:%s\n", asm_name( imp_name ) ); output( "\tbr x16\n" ); if (is_delay) { output( "\n\t.section .text$1\n" ); output( ".L__wine_delay_import:\n" ); - output( "\tadrp x16, %s\n", arm64_page( asm_name( imp_name ) ) ); - output( "\tadd x16, x16, #%s\n", arm64_pageoff( asm_name( imp_name ) ) ); + output( "\tadrp x16, %s\n", asm_name( imp_name ) ); + output( "\tadd x16, x16, #:lo12:%s\n", asm_name( imp_name ) ); output( "\tb %s\n", asm_name( delay_load ) ); } break; diff --git a/tools/winebuild/spec32.c b/tools/winebuild/spec32.c index e7d195d3081..7e41f2d5a3d 100644 --- a/tools/winebuild/spec32.c +++ b/tools/winebuild/spec32.c @@ -352,8 +352,8 @@ static void output_relay_debug( struct exports *exports ) output( "\tstp x8, x9, [SP,#-16]!\n" ); output( "\tmov w1, #%u\n", odp->u.func.args_str_offset << 16 ); if (i - exports->base) output( "\tadd w1, w1, #%u\n", i - exports->base ); - output( "\tadrp x0, %s\n", arm64_page(".L__wine_spec_relay_descr") ); - output( "\tadd x0, x0, #%s\n", arm64_pageoff(".L__wine_spec_relay_descr") ); + output( "\tadrp x0, .L__wine_spec_relay_descr\n" ); + output( "\tadd x0, x0, #:lo12:.L__wine_spec_relay_descr\n" ); output( "\tldr x3, [x0, #8]\n"); output( "\tblr x3\n"); output( "\tmov sp, x29\n" ); @@ -636,25 +636,8 @@ void output_module( DLLSPEC *spec ) output( "\t.skip %u\n", 65536 + page_size ); break; default: - switch (target.cpu) - { - case CPU_i386: - case CPU_x86_64: - output( "\n\t.section \".init\",\"ax\"\n" ); - output( "\tjmp 1f\n" ); - break; - case CPU_ARM: - output( "\n\t.section \".text\",\"ax\"\n" ); - output( "\tb 1f\n" ); - break; - case CPU_ARM64: - output( "\n\t.section \".init\",\"ax\"\n" ); - output( "\tb 1f\n" ); - break; - case CPU_ARM64EC: - assert( 0 ); - break; - } + output( "\n\t.section \".init\",\"ax\"\n" ); + output( "\tjmp 1f\n" ); output( "__wine_spec_pe_header:\n" ); output( "\t.skip %u\n", 65536 + page_size ); output( "1:\n" ); diff --git a/tools/winebuild/utils.c b/tools/winebuild/utils.c index 258a644b494..62f05e535b6 100644 --- a/tools/winebuild/utils.c +++ b/tools/winebuild/utils.c @@ -823,15 +823,8 @@ const char *asm_name( const char *sym ) /* return the assembly name for an ARM64/ARM64EC function */ const char *arm64_name( const char *sym ) { - switch (target.platform) - { - case PLATFORM_MINGW: - case PLATFORM_WINDOWS: - if (target.cpu == CPU_ARM64EC) return strmake( "\"#%s\"", sym ); - /* fall through */ - default: - return asm_name( sym ); - } + if (target.cpu == CPU_ARM64EC) return strmake( "\"#%s\"", sym ); + return asm_name( sym ); } /* return an assembly function declaration for a C function name */ @@ -967,16 +960,7 @@ void output_gnu_stack_note(void) case PLATFORM_APPLE: break; default: - switch (target.cpu) - { - case CPU_ARM: - case CPU_ARM64: - output( "\t.section .note.GNU-stack,\"\",%%progbits\n" ); - break; - default: - output( "\t.section .note.GNU-stack,\"\",@progbits\n" ); - break; - } + output( "\t.section .note.GNU-stack,\"\",@progbits\n" ); break; } } @@ -1067,35 +1051,3 @@ const char *get_asm_string_section(void) default: return ".section .rodata"; } } - -const char *arm64_page( const char *sym ) -{ - static char *buffer; - - switch (target.platform) - { - case PLATFORM_APPLE: - free( buffer ); - buffer = strmake( "%s@PAGE", sym ); - return buffer; - default: - return sym; - } -} - -const char *arm64_pageoff( const char *sym ) -{ - static char *buffer; - - free( buffer ); - switch (target.platform) - { - case PLATFORM_APPLE: - buffer = strmake( "%s@PAGEOFF", sym ); - break; - default: - buffer = strmake( ":lo12:%s", sym ); - break; - } - return buffer; -}
1
0
0
0
Fabian Maurer : win32u: Sync dpi awareness changes from user32.
by Alexandre Julliard
27 Feb '24
27 Feb '24
Module: wine Branch: master Commit: 8351a45cb2e650dcc0fc695fc3ce0ad8f32ca5fe URL:
https://gitlab.winehq.org/wine/wine/-/commit/8351a45cb2e650dcc0fc695fc3ce0a…
Author: Fabian Maurer <dark.shadow4(a)web.de> Date: Sat Feb 24 22:20:07 2024 +0100 win32u: Sync dpi awareness changes from user32. --- dlls/user32/sysparams.c | 2 ++ dlls/win32u/sysparams.c | 11 +++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/dlls/user32/sysparams.c b/dlls/user32/sysparams.c index 9fa37a292d1..a3f768ff66d 100644 --- a/dlls/user32/sysparams.c +++ b/dlls/user32/sysparams.c @@ -655,6 +655,7 @@ BOOL WINAPI AreDpiAwarenessContextsEqual( DPI_AWARENESS_CONTEXT ctx1, DPI_AWAREN /*********************************************************************** * GetAwarenessFromDpiAwarenessContext (USER32.@) + * copied into win32u, make sure to keep that in sync */ DPI_AWARENESS WINAPI GetAwarenessFromDpiAwarenessContext( DPI_AWARENESS_CONTEXT context ) { @@ -738,6 +739,7 @@ DPI_AWARENESS_CONTEXT WINAPI GetThreadDpiAwarenessContext(void) /********************************************************************** * SetThreadDpiAwarenessContext (USER32.@) + * copied into win32u, make sure to keep that in sync */ DPI_AWARENESS_CONTEXT WINAPI SetThreadDpiAwarenessContext( DPI_AWARENESS_CONTEXT context ) { diff --git a/dlls/win32u/sysparams.c b/dlls/win32u/sysparams.c index 7dc807bb909..a31d586a5b6 100644 --- a/dlls/win32u/sysparams.c +++ b/dlls/win32u/sysparams.c @@ -2187,7 +2187,7 @@ UINT get_win_monitor_dpi( HWND hwnd ) return system_dpi; } -/* see GetAwarenessFromDpiAwarenessContext */ +/* copied from user32 GetAwarenessFromDpiAwarenessContext, make sure to keep that in sync */ static DPI_AWARENESS get_awareness_from_dpi_awareness_context( DPI_AWARENESS_CONTEXT context ) { switch ((ULONG_PTR)context) @@ -2195,14 +2195,18 @@ static DPI_AWARENESS get_awareness_from_dpi_awareness_context( DPI_AWARENESS_CON case 0x10: case 0x11: case 0x12: + case 0x22: case 0x80000010: case 0x80000011: case 0x80000012: + case 0x80000022: return (ULONG_PTR)context & 3; case (ULONG_PTR)DPI_AWARENESS_CONTEXT_UNAWARE: case (ULONG_PTR)DPI_AWARENESS_CONTEXT_SYSTEM_AWARE: case (ULONG_PTR)DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE: return ~(ULONG_PTR)context; + case (ULONG_PTR)DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2: + return ~(ULONG_PTR)DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE; default: return DPI_AWARENESS_INVALID; } @@ -2249,6 +2253,7 @@ UINT get_system_dpi(void) /********************************************************************** * SetThreadDpiAwarenessContext (win32u.so) + * copied from user32, make sure to keep that in sync */ DPI_AWARENESS_CONTEXT WINAPI SetThreadDpiAwarenessContext( DPI_AWARENESS_CONTEXT context ) { @@ -2265,7 +2270,9 @@ DPI_AWARENESS_CONTEXT WINAPI SetThreadDpiAwarenessContext( DPI_AWARENESS_CONTEXT prev = NtUserGetProcessDpiAwarenessContext( GetCurrentProcess() ) & 3; prev |= 0x80000010; /* restore to process default */ } - if (((ULONG_PTR)context & ~(ULONG_PTR)0x13) == 0x80000000) info->dpi_awareness = 0; + if (((ULONG_PTR)context & ~(ULONG_PTR)0x33) == 0x80000000) info->dpi_awareness = 0; + else if (context == DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2 || context == (DPI_AWARENESS_CONTEXT)0x22) + info->dpi_awareness = 0x22; else info->dpi_awareness = val | 0x10; return ULongToHandle( prev ); }
1
0
0
0
← Newer
1
...
5
6
7
8
9
10
11
...
72
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
Results per page:
10
25
50
100
200