Commit graph

6668 commits

Author SHA1 Message Date
Alexandre Julliard a72c7bbc0c ntdll: Add a Wine-specific process info class for the LDT copy. 2022-11-11 11:56:45 +01:00
Martin Storsjö e05a869702 ntdll: Readd the missed initialization of the thread register on arm.
This was missed in d3a68e434e.

Signed-off-by: Martin Storsjö <martin@martin.st>
2022-11-11 11:14:21 +01:00
Paul Gofman 77fcef99b8 ntdll/tests: Add tests for memory address requirements. 2022-11-10 22:00:35 +01:00
Paul Gofman 7e8bb68f95 ntdll: Support HighestEndingAddress in NtAllocateVirtualMemoryEx(). 2022-11-10 22:00:35 +01:00
Paul Gofman 5d583498e8 ntdll: Factor out allocate_virtual_memory(). 2022-11-10 22:00:35 +01:00
Paul Gofman dab4be7fd4 ntdll: Pass limit instead of zero_bits to map_view(). 2022-11-10 22:00:35 +01:00
Rémi Bernon fe3c5e93e2 ntdll: Implement RtlSetUserFlagsHeap.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=53741
2022-11-10 22:00:35 +01:00
Rémi Bernon bba4fa0fbb ntdll: Check block user flags in RtlGetUserInfoHeap.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=53741
2022-11-10 22:00:35 +01:00
Rémi Bernon 0f6e908405 ntdll: Check block user flags in RtlSetUserValueHeap.
Adding the same user flags as native, for Global/Local allocs, and
returning the pointer from Global/LocalHandle by default.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=53741
2022-11-10 22:00:35 +01:00
Rémi Bernon 2ed75be4c5 ntdll: Store the user flags in the heap block flags.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=53741
2022-11-10 22:00:35 +01:00
Rémi Bernon d9313b4e9e ntdll: Introduce a new heap block_set_flags helper.
To clear and set block flags independently of the block size.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=53741
2022-11-10 22:00:35 +01:00
Alexandre Julliard 4b65a7027f ntdll: Use a proper Unix syscall for RtlGetSystemTimePrecise(). 2022-11-10 10:38:12 +01:00
Alexandre Julliard 1fe7b8dd6d ntdll: Use a proper Unix syscall for unwind_builtin_dll(). 2022-11-10 10:33:37 +01:00
Alexandre Julliard 1d1690782b ntdll: Use a proper Unix syscall for init_builtin_dll(). 2022-11-10 10:33:37 +01:00
Alexandre Julliard f7332ab4a6 ntdll: Use a proper Unix syscall for load_so_dll(). 2022-11-10 10:33:37 +01:00
Alexandre Julliard 2a5191a74a ntdll: Use a separate function pointer for the TEB hack on ARM64. 2022-11-10 10:33:32 +01:00
Alexandre Julliard d3a68e434e ntdll: Move the initialization of the thread register into signal_start_thread().
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-11-10 09:50:53 +01:00
Alexandre Julliard 6ecc803950 ntdll: Use a pthread key for the TEB on all platforms.
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-11-10 09:50:41 +01:00
Martin Storsjö 464d3c86dc ntdll: Write ret_len with the right size in user_mode_callback_return on arm64.
This fixes a regression since
4069a8b384.

Signed-off-by: Martin Storsjö <martin@martin.st>
2022-11-09 21:23:48 +01:00
Torge Matthies efc45c5e3b ntdll: Fix incorrectly sized mov in user_mode_callback_return.
Signed-off-by: Torge Matthies <tmatthies@codeweavers.com>
2022-11-09 21:23:48 +01:00
Alexandre Julliard 988d9ddbf5 ntdll: Don't inline NtCurrentTeb() in Unix libraries.
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-11-09 21:10:29 +01:00
Brendan Shanks 13cc08e32d ntdll: Stop using deprecated kIOMasterPortDefault constant. 2022-11-08 21:32:53 +01:00
Brendan Shanks 3873d43461 ntdll: Suppress deprecation warnings when calling MPTaskIsPreemptive(). 2022-11-08 21:32:53 +01:00
Brendan Shanks e605bc17a5 ntdll: Fix runtime availability check for pthread_attr_set_qos_class_np. 2022-11-08 21:32:53 +01:00
Brendan Shanks 93577c0013 ntdll: Add native thread renaming for exception method. 2022-11-07 21:13:32 +01:00
Alexandre Julliard 4069a8b384 ntdll: Reimplement KeUserModeCallback in assembly on ARM64. 2022-11-07 21:13:31 +01:00
Alexandre Julliard b60d076b09 ntdll: Reimplement KeUserModeCallback in assembly on ARM. 2022-11-07 21:13:31 +01:00
Alexandre Julliard 8e9551f324 ntdll: Reimplement KeUserModeCallback in assembly on x86_64. 2022-11-07 21:13:31 +01:00
Alexandre Julliard d40017ecda ntdll: Reimplement KeUserModeCallback in assembly on i386. 2022-11-07 21:13:31 +01:00
Martin Storsjö a27b202a4d ntdll: Implement ARM EHABI unwinding.
This avoids relying on libunwind, which isn't always available,
and which can be brittle (e.g. current git master of libunwind fails, see
https://github.com/libunwind/libunwind/pull/203#issuecomment-984126066).

This allows unwinding with the EXIDX/EXTBL info which is used
normally for C++ exception handling/unwinding. This avoids needing
to keep the .so files unstripped and avoids needing libunwind to
load .debug_frame from disk instead of the already mapped
EXIDX/EXTBL.

This patch uses the dl_iterate_phdr function for finding the EXIDX
section; keeping this call within #ifdef linux to avoid breaking
someone's build, even though it probably is available on most unix
(or ELF) platforms.

Alternatively, we could add configure checks for this function.

This passes all my unwinding tests, for full ELF builds of Wine,
built with both GCC and Clang. (It also works for PE builds, where
only very few ELF bits need to be unwound.)

Signed-off-by: Martin Storsjö <martin@martin.st>
2022-11-07 20:15:02 +01:00
Martin Storsjö f760976803 ntdll: Add ARM EHABI unwind instructions in assembly functions.
On most ELF platforms on ARM, ARM EHABI is the unwind info
format normally used, instead of DWARF like on most other platforms.

Currently, when unwinding through ELF objects with libunwind, the
libraries don't have any .eh_frame section mapped at runtime (since
DWARF isn't used for unwinding). Instead, what happens is that
libunwind ends up loading .debug_frame from the libraries on disk
instead.

Therefore, currently, ELF unwinding relies on the .so files not being
stripped.

This patch adds the necessary EHABI unwinding instructions in the
assembly functions that currently have DWARF CFI instructions.

EHABI isn't signaled via any specific preprocessor macro, but
is signaled by the absence of other unwind mechanisms (such
as __ARM_DWARF_EH__ and __SEH__, or maybe SjLj).

Mark the asm functions in the preloaders as .cantunwind, to avoid
undefined references to __aeabi_unwind_cpp_pr* functions.

Also mark other assembly functions as .cantunwind; for
signal_exit_thread this is essential if the function is marked
with .fnstart/.fnend - otherwise exiting threads does hang.
(pthread_exit internally calls _Unwind_ForcedUnwind, which would
hang if signal_exit_thread had .fnstart without any matching unwind
info).

This would, in principle, allow unwinding through these functions with
libunwind, for versions of libunwind that can parse the EHABI unwind
info - see e.g.
4d779f55c0.
(This commit isn't yet in any current release AFAIK). Unwinding with
EHABI via libunwind would require a few tweaks to the libunwind interface
usage in unix/signal_arm.c though, since e.g. the unw_get_proc_info call
fails if there's no .eh_frame or .debug_frame available.

Signed-off-by: Martin Storsjö <martin@martin.st>
2022-11-07 10:28:18 +01:00
Jinoh Kang 53c4f638ef ntdll: Add CFI unwind info to __wine_syscall_dispatcher (i386).
This change is adding DWARF (CFI) unwind information to the
hand-written assembly of the `__wine_syscall_dispatcher` function.
This enables unwinding through the dispatcher from the Linux stack
into (and through) the Windows stack.

The general idea is that the `syscall_frame` struct contains the
content of the callee-save registers before the function call
(in particular the stack pointer and the return address).  At any
point of the execution, we have a pointer into the `syscall_frame`
in $ebx, $ecx, $ebp, or $esp.

For the CFI codes the general idea is that we are defining the
computations of the callee-save registers based on the
`syscall_frame` using DWARF’s `breg` instruction, rather than
relative to CFA.
2022-11-04 19:23:56 +01:00
Jinoh Kang 5aa2d45adf ntdll: Move CFI helper macros out of signal_x86_64.c. 2022-11-04 19:23:56 +01:00
Brendan Shanks ed666db8d8 ntdll: Set the QoS class of the main Wine thread on macOS. 2022-11-03 18:33:09 +01:00
Alexandre Julliard c302b28729 ntdll: Fix trace formats for 64-bit values on ARM64. 2022-11-03 18:33:09 +01:00
Stefan Dösinger 97bef536a3 ntdll: Fix building on Mojave / Xcode 11.3.1.
_STRUCT_X86_THREAD_FULL_STATE64 exists, but _STRUCT_MCONTEXT64_FULL and
_STRUCT_MCONTEXT_AVX64_FULL do not.
2022-11-02 17:19:24 +01:00
Fabian Maurer 57e37c2a91 ntdll/tests: Fix uninitialized read in ok (Coverity).
Signed-off-by: Fabian Maurer <dark.shadow4@web.de>
2022-11-02 14:43:23 +01:00
Brendan Shanks f726b6ba79 ntdll: Print correct thread rename trace if non-pseudo-handle to current thread is used. 2022-11-01 20:48:35 +01:00
Alexandre Julliard b1f59bc679 makefiles: Add support for multiple PE architectures. 2022-11-01 10:29:49 +01:00
Paul Gofman 039f8b16f6 ntdll: Move SO_REUSEADDR handling to server. 2022-10-31 20:41:45 +01:00
Nikolay Sivov fc5cb9b577 ntdll: Partially implement MemoryRegionInformation query.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2022-10-31 20:41:44 +01:00
Martin Storsjö 03d4ba67f4 ntdll: Use the local dwarf implementation on arm64.
This makes unwinding work if libunwind is unavailable.

The dwarf_virtual_unwind function is modelled heavily on the x86_64
version of it. (Going forward, if there are changes to either of them,
one should probably look at whether those changes should be mirrored
to the other one too.)

Signed-off-by: Martin Storsjö <martin@martin.st>
2022-10-31 12:11:55 +01:00
Martin Storsjö 6241f87cca ntdll: Add support for aarch64 in the dwarf implementation.
This is essentially about mapping dwarf register numbers to
aarch64 registers, and for updating the right CONTEXT variable
with the CFA.

Signed-off-by: Martin Storsjö <martin@martin.st>
2022-10-31 12:11:55 +01:00
Martin Storsjö 1b2e6d98bb ntdll: Move the dwarf reading routines to a shareable header.
Signed-off-by: Martin Storsjö <martin@martin.st>
2022-10-31 12:11:55 +01:00
Brendan Shanks c68f75e34e ntdll: Set native thread names on Linux when set with SetThreadDescription(). 2022-10-26 15:03:05 +02:00
Jinoh Kang dd5ce0295b ntdll/tests: Add more tests for \Device\NamedPipe and \Device\NamedPipe\. 2022-10-26 15:03:05 +02:00
Jinoh Kang 71959b6887 ntdll/tests: Add tests for pipe names. 2022-10-26 15:03:05 +02:00
Alexandre Julliard 6a91264918 makefiles: Store PE objects in subdirectories in the build tree.
This will make it possible to build multiple PE architectures.
2022-10-26 15:03:05 +02:00
Nikolay Sivov 853d9024b7 ntdll: Add some already implemented security descriptor exports.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
2022-10-25 11:01:42 +02:00
Michael Stefaniuc f5c573b199 ntdll: Use ARRAY_SIZE instead of open coding it. 2022-10-25 10:58:49 +02:00