Jacek Caban : ntdll: Store stack pointer in x86_64 syscall frame.
Alexandre Julliard
julliard at winehq.org
Wed Feb 17 16:23:33 CST 2021
Module: wine
Branch: master
Commit: 4e5b61bb068f90b84d2b0a168162ac3f8f0e9af0
URL: https://source.winehq.org/git/wine.git/?a=commit;h=4e5b61bb068f90b84d2b0a168162ac3f8f0e9af0
Author: Jacek Caban <jacek at codeweavers.com>
Date: Mon Feb 15 21:58:27 2021 +0100
ntdll: Store stack pointer in x86_64 syscall frame.
Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/ntdll/unix/signal_x86_64.c | 13 +++++--------
tools/winebuild/import.c | 2 ++
2 files changed, 7 insertions(+), 8 deletions(-)
diff --git a/dlls/ntdll/unix/signal_x86_64.c b/dlls/ntdll/unix/signal_x86_64.c
index d5a34c700f8..6477bf8a953 100644
--- a/dlls/ntdll/unix/signal_x86_64.c
+++ b/dlls/ntdll/unix/signal_x86_64.c
@@ -300,12 +300,9 @@ struct syscall_frame
WORD gs; /* 0092 */
WORD pad[2]; /* 0094 */
ULONG64 rbp; /* 0098 */
- ULONG64 thunk_addr;
- ULONG64 ret_addr;
};
-/* Should match the offset in call_user_apc_dispatcher(). */
-C_ASSERT( offsetof( struct syscall_frame, ret_addr ) == 0xa8);
+C_ASSERT( sizeof( struct syscall_frame ) == 0xa0);
struct amd64_thread_data
{
@@ -1944,7 +1941,7 @@ NTSTATUS WINAPI NtGetContextThread( HANDLE handle, CONTEXT *context )
}
if (needed_flags & CONTEXT_CONTROL)
{
- context->Rsp = (ULONG64)&frame->ret_addr;
+ context->Rsp = frame->rsp;
context->Rbp = frame->rbp;
context->Rip = frame->rip;
context->EFlags = frame->eflags;
@@ -2104,7 +2101,7 @@ __ASM_GLOBAL_FUNC( call_user_apc_dispatcher,
"movq 0x98(%rcx),%rdx\n\t" /* context->Rsp */
"jmp 2f\n\t"
"1:\tmovq 0x328(%rbx),%rax\n\t" /* amd64_thread_data()->syscall_frame */
- "leaq 0xa8(%rax),%rdx\n\t" /* &amd64_thread_data()->syscall_frame->ret_addr */
+ "movq 0x88(%rax),%rdx\n\t" /* frame->rsp */
"2:\tsubq $0x510,%rdx\n\t" /* sizeof(struct apc_stack_layout) */
"andq $~0xf,%rdx\n\t"
"addq $8,%rsp\n\t" /* pop return address */
@@ -2399,7 +2396,7 @@ static BOOL handle_syscall_fault( ucontext_t *sigcontext, EXCEPTION_RECORD *rec,
{
XMM_SAVE_AREA32 *fpu = FPU_sig(sigcontext);
- TRACE( "returning to user mode ip=%016lx ret=%08x\n", frame->ret_addr, rec->ExceptionCode );
+ TRACE( "returning to user mode ip=%016lx ret=%08x\n", frame->rip, rec->ExceptionCode );
RAX_sig(sigcontext) = rec->ExceptionCode;
RBX_sig(sigcontext) = frame->rbx;
RSI_sig(sigcontext) = frame->rsi;
@@ -2409,7 +2406,7 @@ static BOOL handle_syscall_fault( ucontext_t *sigcontext, EXCEPTION_RECORD *rec,
R13_sig(sigcontext) = frame->r13;
R14_sig(sigcontext) = frame->r14;
R15_sig(sigcontext) = frame->r15;
- RSP_sig(sigcontext) = (ULONG_PTR)&frame->ret_addr;
+ RSP_sig(sigcontext) = frame->rsp;
RIP_sig(sigcontext) = frame->rip;
if (fpu) *fpu = get_syscall_xsave( frame )->xsave;
amd64_thread_data()->syscall_frame = NULL;
diff --git a/tools/winebuild/import.c b/tools/winebuild/import.c
index 2db414b3b30..12ba189aa0a 100644
--- a/tools/winebuild/import.c
+++ b/tools/winebuild/import.c
@@ -1527,6 +1527,8 @@ void output_syscalls( DLLSPEC *spec )
output( "\tsubq $0xb,0x8(%%rbp)\n" );
output( "\tmovq 0x8(%%rbp),%%rbx\n" );
output( "\tmovq %%rbx,-0x28(%%rbp)\n" );
+ output( "\tleaq 0x10(%%rbp),%%rbx\n" );
+ output( "\tmovq %%rbx,-0x10(%%rbp)\n" );
output( "\tfxsave64 (%%rsp)\n" );
output( "\tmovq %%gs:0x30,%%rcx\n" );
output( "\tleaq -0x98(%%rbp),%%rbx\n" );
More information about the wine-cvs
mailing list