wine/dlls/ntdll
Jinoh Kang 057467bff9 ntdll: Fix restoring X16 and X17 in ARM64 syscall dispatcher.
Today, NtContinue() on ARM64 does not restore X16 and X17 from the
context.

This is because the values for X16 and X17 are overwritten when the
current thread returns to the "user mode" (PE side) via
__wine_syscall_dispatcher, which in turn uses them as scratch registers
for restoring SP and PC respectively.

We cannot avoid using scratch registers when restoring SP and PC.  This
is because ARMv8 does not have an unprivileged (EL0) instruction that
loads SP and PC from memory or non-GPR architectural state.

Fix this by making ARM64 __wine_syscall_dispatcher perform a full
context restore via raise(SIGUSR2) when NtContinue() is used.

Since raising a signal is quite expensive, it should be done only when
necessary. To achieve this, split the ARM64 syscall dispatcher's
returning behaviour into a fast path (that does not involve signals) and
a slow path (that involves signals):

- If CONTEXT_INTEGER is not set, the dispatcher takes the fast path:
  the X16 and X17 registers are clobbered as usual.

- If X16 == PC and X17 == SP, the dispatcher also takes the fast path:
  it can safely use X16 and X17 without corrupting the register values,
  since those two registers already have the desired values.

  This fast path is used in call_user_apc_dispatcher(),
  call_user_exception_dispatcher(), and call_init_thunk().

- Otherwise, the dispatcher takes the slow path: it raises SIGUSR2 and
  does full context restore in the signal handler.

Fixes: 88e336214d
2023-07-17 11:11:44 +02:00
..
tests ntdll/tests: Update some more todos that succeed with the new wow64 architecture. 2023-07-11 18:34:17 +02:00
unix ntdll: Fix restoring X16 and X17 in ARM64 syscall dispatcher. 2023-07-17 11:11:44 +02:00
actctx.c ntdll: Fail loudly if RtlActivateActivationContextEx fails to allocate memory. 2023-07-13 23:42:46 +02:00
atom.c
crypt.c
debugbuffer.c
env.c
error.c
error.h
exception.c
handletable.c
heap.c
large_int.c
loader.c
locale.c
locale_private.h
make_errors
Makefile.in
math.c
misc.c
ntdll.spec ntdll: Implement RtlWow64GetSharedInfoProcess(). 2023-07-11 18:34:17 +02:00
ntdll_misc.h
path.c
printf.c
printf.h
process.c ntdll: Implement RtlWow64GetSharedInfoProcess(). 2023-07-11 18:34:17 +02:00
reg.c
relay.c
resource.c
rtl.c
rtlbitmap.c
rtlstr.c
sec.c
signal_arm.c
signal_arm64.c
signal_i386.c
signal_x86_64.c
string.c
sync.c
thread.c
threadpool.c
time.c
unixlib.h
version.c
version.rc
wcstring.c