Repository navigation
Linux: a native runtime, no Wine - #526
spidercraft wants to merge 71 commits into
Conversation
A texture UAV read as float and used atomically in the same program got the float handle for its atomic: dxil-spirv then emitted OpAtomicOr on a float texel pointer (invalid SPIR-V), and the NVIDIA compiler crashed in vkCreateComputePipelines when GTA VI entered its world (two programs: c12c1f7296419a5b, 8358f9eef7931421). With the type in the key the atomic gets its own uint handle; all dumped SPIR-V validates.
Since the world bring-up, main no longer builds on Linux: victory-gpu names host_resource outside its cfg(windows), and victory-hle reaches Windows-only modules (xmem, files, lifecycle, the text entry dialog). This gates those uses only, as the smallest base for a native Linux runtime: - view_format and the D3D12 allocator hookup are Windows-only, like what they call. - XLaunchNewGame ends the title only on Windows; the text entry dialog answers "dismissed" elsewhere. - translate --validate / --pipelines refuse to start off Windows (no host DXIL validator or D3D12 there); translation itself runs. - Tests that parse the test binary as a PE image, or use Windows title paths, are ignored off Windows with the reason. Tested: Linux (CachyOS, rustc 1.98.1): cargo test --workspace passes (162 passed, 13 ignored). cargo check --target x86_64-pc-windows-msvc --all-targets gives the same diagnostics as before (none). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Title code calls our exports, and is called by us, with the Windows x64 convention. `extern "system"` is that convention only on Windows; on Linux it is SysV, so a native Linux runtime would receive the title's arguments in the wrong registers. `"win64"` is the same convention on every x86-64 host, so this changes nothing on Windows. Callbacks we hand to the host's own APIs stay `"system"` (the crash reporter's exception handlers, the write watch handler, window and dialog procedures, EnumWindows, our TLS callback, the probe test's CreateThread start routine). The title fixture keeps `"system"`: it is built only as a Windows PE. Tested: cargo check --workspace --all-targets --all-features for x86_64-pc-windows-msvc: no diagnostics; on Linux cargo test --workspace passes (162 passed, 13 ignored). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
docs/linux.md: what the native Linux runtime supplies in place of the Windows loader, kernel and system DLLs, where each part lives, and the rules every part follows (win64 ABI, one handle table, one region table, no Wine and no system DLL forwarding). - victory-loader::linux: the platform; for now the last-error and region-table seams (teb, vm) the other parts call. - victory-hle::linux: our implementation of the DLLs HostPolicy passes through on Windows; host::imp::resolve looks imports up there on Linux (exports by ordinal are named #<n>). - libc as a direct dependency on Linux. Tested: cargo test --workspace on Linux; Windows target type-checks with no diagnostics. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Guest thread spawn (a plain host thread for now), SEH image registration and the handle table, with the signatures the loader, kernel32 and file slices code against while they are built in parallel. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The title reserves, commits, protects and queries memory with Windows semantics, and the xmem port needs shared physical pages on Linux. The region table gives VirtualAlloc/Free/Protect/Query those semantics over mmap: 64 KiB granularity, reserve vs commit, large pages (MAP_HUGETLB, else MADV_HUGEPAGE), MEM_RESET, guard pages with a take_guard hook for the fault handler, placeholders, memfd sections with views and aliases, and a physical page pool. Host memory is answered from the kernel's own table (PROCMAP_QUERY, else /proc/self/maps). Guest heap blocks are host malloc blocks, so either side can free what the other allocated; HeapSize reports the exact size through a slack byte at the end of each block. Tested: cargo test -p victory-loader linux::vm (11), victory-hle linux:: (5) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Title code on Linux needs the kernel32 objects it creates, waits for and locks with, implemented over futexes since nothing on the host serves them. - handles: the one handle table (values 4, 8, ... reused, pseudo handles -1 and -2, named objects) and the wait engine. A waiting thread links a per-thread futex word to each object; `update` changes an object under the one wait lock and wakes its waiters, each of which re-checks its own wait. So `Waitable::try_acquire` keeps its signature for the file and socket slices; `signalled` and `take_abandoned` default sensibly. No lock is held while sleeping. - Events (named, manual and auto reset), mutexes (owner, recursion, abandonment at owner exit), semaphores, thread objects (signalled with their exit code), the process object. - SuspendThread's engine: a signal that parks the thread only in title code; inside a wait or lock sleep the thread parks before it next tries for anything, so a suspended thread is given no lock or signal (the lesson of Leonida's runtime). - CRITICAL_SECTION, SRWLOCK, CONDITION_VARIABLE, INIT_ONCE and WaitOnAddress live in the title's own memory at Windows sizes; the condition variable keeps the two fixes Leonida's runtime needed (read the sequence before counting; only wakes uncount sleepers). - The process: ids, ExitProcess, command line, environment (our changes over the host's), start-up info, last error, debugger checks, EncodePointer, FlushProcessWriteBuffers. Tested: cargo test -p victory-hle linux:: (22 tests: wake ordering, timed-out sleeper vs wake, wait-all all-or-nothing, mutex abandonment, a suspended waiter takes nothing, layouts). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
On Linux nothing maps the title for us, so linux::image maps the original image itself: at its preferred base (MAP_FIXED_NOREPLACE) or relocated on a 64 KiB boundary, sections copied and protected, then made known to the region table and the exception dispatcher. Binding, title DLLs (found without regard to case), delay-load slots, TLS callbacks, DllMain and spawn_main keep the shape of the Windows path, so the front end shares it. thunks.rs now builds on both: the unimplemented-import stub is the same. Every thread that runs title code gets a TEB at its GS base (wrgsbase, else arch_prctl) with its real stack bounds, the PEB (image base, process parameters, empty loader lists), last error, TlsSlots, TlsExpansionSlots and FLS storage, at Windows offsets checked by a test. Static TLS hands out the indices itself (exe 0, DLLs 1.. in load order), so unlike Windows nothing is patched; every thread has a block for every image. Guest threads start with the Windows x87 control word and MXCSR, run the attached images' thread notices, and ExitThread resumes at their guest frame without unwinding title frames. The new probe-title fixture is a CRT-free DLL for the hle-probe to import on Linux, where there is no system DLL to rename. Tested: cargo test --workspace on Linux (171 passed, 13 ignored; the new load_probe_linux maps, binds and calls hle-probe and runs its CRT DllMain and TLS callbacks on guest threads); Windows cargo check --all-targets --all-features clean; cargo xtask policy. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The Windows path's config, manifest, storage, console, title DLLs, binding and late LoadLibrary handling are portable now that the Linux loader has the same shape, so run() serves both, with cfg only where they differ: no prepared copy, no files mounts yet (that module is not ported), crash reporting and console timers stay Windows-only, and the PEB gets the process parameters. On Linux the DLLs the title ships beside its exe (vcruntime140, msvcp140, ...) are mapped, since no host DLL stands in. Tested: victory run on the title maps its executable at its preferred base with TLS index 0 and its seven DLLs, binds them; --execute starts the guest main thread and stops in vcruntime140's DllMain, whose InitializeCriticalSectionEx (kernel32) is not implemented yet. Windows cargo check clean. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Title threads on Linux start through the loader's guest-thread spawn; the title sizes and pins its job threads from the processor facts, so those come from the host's real topology. - CreateThread / CreateRemoteThreadEx (CREATE_SUSPENDED, the group affinity and ideal processor attributes), thread handles signalled with the exit code, OpenThread, SuspendThread / ResumeThread, Sleep, SwitchToThread, GetCurrentThreadStackLimits. - Priorities and ideal processors are remembered and read back; affinity masks pin the host thread (sched_setaffinity), a processor this machine lacks folding onto one it has. - TLS slots behind victory_loader::linux::teb::tls_slots (a thread-local until the TEB holds them at gs:[0x1480]); index 0 never handed out. FLS with its callbacks at thread exit and on FlsFree for every thread. - GetLogicalProcessorInformation(Ex) from sysfs: cores with their SMT siblings numbered next to each other, caches, packages, one NUMA node and one group. GetNativeSystemInfo, GlobalMemoryStatusEx, IsProcessorFeaturePresent from cpuid. Tested: cargo test -p victory-hle linux:: (31 tests); layout asserts for SYSTEM_INFO, SYSTEM_LOGICAL_PROCESSOR_INFORMATION(_EX) record sizes, MEMORYSTATUSEX, GROUP_AFFINITY, PROCESSOR_NUMBER. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The title and the files module open, read, list and manage files through kernel32; on Linux nothing served it. Host paths spelled the Windows way (either separator, an optional drive that means nothing on the host) are resolved without regard to case one component at a time, as NTFS would find them, and the errors are Windows' (FILE_NOT_FOUND vs PATH_NOT_FOUND, ALREADY_EXISTS after CREATE_ALWAYS/OPEN_ALWAYS, ...). OVERLAPPED transfers complete inside the call, signal their event and post to the associated completion port, which is one of the answers Windows gives; ports, GetOverlappedResult and CancelIo follow from that. handles::Object gains set_signal so the file layer can set an event the sync slice owns. Tested: cargo test -p victory-hle linux:: (16) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The title reads the time, keeps lock-free lists and runs work, timers and waits on the system thread pool; on Linux all of it is ours. - Time: QueryPerformanceCounter at 10 MHz (CLOCK_MONOTONIC), tick counts including sleep (CLOCK_BOOTTIME), FILETIME and SYSTEMTIME now (UTC and local), FileTimeToSystemTime and back with Windows' range checks. - SLIST_HEADER in the x64 layout, lock-free with cmpxchg16b (inline asm: the intrinsic becomes a libatomic call in debug builds) and a sequence against ABA. - The thread pool: work, timers (one-shot and periodic, relative and absolute due times, disarm and close while a callback runs) and waits on any waitable handle, QueueUserWorkItem, WaitFor...Callbacks with cancel, DisassociateCurrentThreadFromCallback. Workers are guest threads added on demand; timers and waits are kept by host threads that never run title code. Tested: cargo test -p victory-hle linux:: (41 tests), 60 more runs of them six at a time with no failure. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The plan keeps one D3D12 code path: on Linux the host D3D12 is vkd3d-proton built as native libraries and loaded at run time (`hostlib`, `VICTORY_VKD3D`). Its COM is SysV there, as is `extern "system"`, so the windows-rs vtables match it unchanged. The `windows` crate itself does not build on Linux (its `windows-future` needs Windows-only parts of windows-core), so `victory-windows` generates the same Direct3D, D3D12 and DXGI bindings with windows-bindgen at build time, plus the few core items windows-core only has on Windows; users name it `windows`. The validator runs against DXC's libdxil.so with the same vtable slots, but only when VICTORY_DXIL names it: 1.10.2605 traps on some of our modules. Tested: cargo test -p victory-shader --features host, 69 passed with VICTORY_VKD3D set (VALU and pipeline tests on the RTX 5090 through vkd3d-proton 3.2), 69 passed without it (device tests skip); Windows cargo check clean. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Clippy's points in the new files (no busy-wait look-alike in the suspend handshake, a volatile read in a test loop, checked division), the handle-table example as text so it is no ignored doctest, and the status of the slice in docs/linux.md, with the signal SuspendThread takes so the signal slice knows it. Tested: cargo test --workspace on Linux (203 passed, 13 ignored); cargo clippy -p victory-hle shows nothing in src/linux; the Windows target type-checks with no diagnostics; victory census --missing over the game lists none of this slice's imports. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
KMutex::new(true) recorded the creator's id but gave the creator no thread object, so a host thread that created a mutex owned and exited holding it never abandoned it: every later wait for it timed out. Tested: cargo test --workspace on Linux (203 passed, 13 ignored); the mutex test now creates one owned on a thread that exits. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Grand Theft Auto VI plays its sound through Spatial Audio: it makes an MMDeviceEnumerator with CoCreateInstance, activates ISpatialAudioClient on the default render device and fills 10 ms buffers of static channel objects each time the stream's event is set. On Windows that is the host's WASAPI; on Linux mmdevapi.rs serves one device with those interfaces, and a device thread sets the event, downmixes the objects to stereo and plays them. audio_out.rs plays through PulseAudio, which PipeWire also serves, via libpulse-simple loaded with dlopen: three C functions, no crate and no build-time headers, and a machine without a sound server keeps running on a silent clock. cpal would pull in alsa-sys and a link-time libasound for the same job. combase.rs: CoInitializeEx and friends, CoCreateInstance (our device enumerator, REGDB_E_CLASSNOTREG otherwise), task memory, CoCreateGuid, StringFromGUID2, PropVariantClear, the WinRT start-up, error and HSTRING functions vccorlib140 imports, and the helpers our COM objects share. oleaut32.rs: BSTRs, also by ordinal. handles.rs gets a stand-in Event with the sync slice's signatures (new, set, reset); that slice's version replaces it. Tested: cargo test -p victory-hle on Linux (spatial stream passes with the event, device and property lookups as the title makes them, HSTRING and BSTR layouts); the ignored a_tone_reaches_the_sound_server played a tone through PipeWire. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Bink plays a video's sound through xaudio2_9.dll (ordinal 1, XAudio2Create), the host's on Windows. Ours runs one guest thread per engine with a pass every 10 ms: engine and voice callbacks with no lock held (so OnBufferEnd may submit the next buffer), source voices decoded from the title's buffers (integer PCM and float, plain or extensible) and linearly resampled to the mastering rate, submix voices by stage, output matrices and volumes, then the mastering voice downmixed to stereo into an audio_out stream whose blocking writes pace the passes. Loops, flushes, discontinuities and GetState behave as documented; effects and filters are kept but not run, as reverb is silent on Windows today. FAudio would give the same voice model, but in C with a SysV ABI: every method and callback would still need a win64 shim here, and it is not installed by default. Tested: cargo test -p victory-hle on Linux (buffer completion and stream-end callbacks with a resubmit from OnBufferEnd, flush of a stopped voice, a 24 kHz source through a submix, default matrices, structure layouts). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The kernel32 slice kept TLS slots in a thread-local until threads had a TEB; with the loader's TEBs in place, tls_slots() returns gs:[0x1480] of a thread that has one, so title code reading its TEB directly and TlsGetValue agree. Threads without a TEB keep the thread-local. Tested: cargo test --workspace on Linux: 211 passed, 13 ignored. The real executable now reaches its first UCRT start-up call. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The title and the DLLs it ships (msvcp140, vcruntime140, ...) import about 250 UCRT functions through the api-ms-win-crt-* sets. On Linux nothing serves them, and glibc's are the wrong ABI and the wrong semantics: long is 32 bits, wchar_t 16, errno numbers differ above 34, printf has its own specifiers and buffer rules, the _s functions report through the invalid-parameter handler. One module per API set (ucrt_runtime, heap, string, convert, math, stdio, time, locale, environment, filesystem, utility), plus the printf and scanf engines (ucrt_format, ucrt_scan) that stdio lists. The C locale only. Heap blocks are plain host malloc blocks; _aligned_* keep the UCRT's layout. The FILE keeps the UCRT's first 48 bytes so msvcp140's basic_filebuf can work through _get_stream_buffer_pointers. _beginthreadex goes through the kernel32 slice's CreateThread when it exists, else the guest thread seam. Tested: cargo test --workspace (207 passed, 13 ignored; 45 new); victory census --missing on the game: 0 missing in every api-ms-win-crt row; Windows cargo check with stub CC: no diagnostics; cargo xtask policy ok. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Title code and msvcp140 convert, compare and case-map text and ask for the user's locale through kernel32. Code pages are UTF-8, 1252 (CP_ACP) and 437 (CP_OEMCP), as on an English console, with Windows' handling of ill-formed UTF-8. Comparison and LCMapString sort keys share one four-level word sort; FormatMessage serves the system texts the runtime reports. The user locale is en-US unless LC_ALL or LANG maps cleanly to a known locale. An opt-in test reads a file of the game dump (VICTORY_GAME_DIR), named in another case, through an overlapped handle. Tested: cargo test --workspace (198 passed, 13 ignored); victory-hle linux:: with VICTORY_GAME_DIR (26); Windows cargo check clean Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts: # crates/victory-hle/src/linux/mod.rs # docs/linux.md
The calling-convention change covered extern "system" only. exit, abort, terminate and _invalid_parameter_noinfo_noreturn in the kernel module, and the CRT file functions in the files module (with the host CRT functions they forward to), were extern "C": the Windows x64 convention on Windows, SysV on Linux, so on Linux exit(code) read a garbage code. They are "win64" now; nothing changes on Windows. On Linux, exit also runs our UCRT's shutdown (the title's atexit table, the EXE's thread_local destructors, stream buffers), which the host CRT's exit does on Windows. Tested: cargo test --workspace on Linux: 255 passed, 13 ignored; Windows target type-checks with no diagnostics. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Title code expects Windows SEH: faults and RaiseException dispatched through the images' .pdata to the language handlers in its own vcruntime, with RtlUnwindEx, STATUS_UNWIND_CONSOLIDATE for C++ catch blocks, vectored handlers and the unhandled-exception filter. On Linux nothing provides that, so victory-loader::linux now does: - context.rs: CONTEXT, EXCEPTION_RECORD, DISPATCHER_CONTEXT and the rest with their Windows layouts checked by a test. - unwind.rs: the function-table registry (images from register_image, RtlAddFunctionTable, table callbacks), RtlLookupFunctionEntry and RtlVirtualUnwind for every unwind code, chained info and both epilogue forms. A pc in our own code gets a boundary entry: walks end there. - seh.rs: the two-phase dispatcher, RtlUnwindEx, RtlRestoreContext, vectored and continue handlers, the top-level filter, and a crash report in the Windows reporter's format (crash_log.rs, now shared with crash.rs) to stderr and crashes.log before the process ends. - asm.rs: every call into title code goes through one routine with hand-built unwind data (saved nonvolatiles and a machine frame), so a title walk started in a handler crosses our Rust frames and nested or collided cases are answered as ntdll does; capture_stub! gives an export its caller's context. - signals.rs: SIGSEGV/SIGBUS/SIGILL/SIGFPE/SIGTRAP in title code become exceptions dispatched on the faulting stack; faults in our own code go to the handler before ours. A hook lets the region table report PAGE_GUARD hits. victory-hle::linux serves the Rtl* names, RaiseException, the vectored handler functions, UnhandledExceptionFilter and a few small neighbours; the portable kernel module's SetUnhandledExceptionFilter now reaches the dispatcher on Linux. The asset policy allows .cpp for the guest fixture (tests/fixtures/seh-probe, our own code built with clang-cl). Tested: cargo test --workspace (178 passed, 13 ignored), incl. unwind code units, raise and fault dispatch, and seh_guest: __try/__except/ __finally, C++ throw/catch through the static vcruntime, vectored handlers, a backtrace and an unhandled fault's report and exit status; the SEH tests also in release; Windows cargo check (no diagnostics); cargo xtask policy. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts: # crates/victory-hle/src/linux/mod.rs # docs/linux.md
kernel32_process stubbed FormatMessageA/W (always "not found") and kernel32_text implements them for system messages; whichever module came first in modules() hid the other. The stub is gone, and a test fails when two modules serving one DLL export the same name. Tested: cargo test --workspace on Linux: 292 passed, 13 ignored. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- The sync slice's Event implements Object::set_signal, which the file layer calls to set an OVERLAPPED's event; it went to the trait's default (false) before, so waiters on it never woke. The overlapped test now uses the real event and waits on it. - The PE mapper records each image's headers and sections in the region table with the protection VirtualQuery reports on Windows, and forgets the image when it is unmapped. Tested: cargo test --workspace on Linux: 292 passed, 13 ignored; the probe test checks PAGE_READONLY headers and PAGE_EXECUTE_READ code. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Resolves the module lists and the status table. Two kernel32 functions came from both the process and the exception slices; one copy of each stays: DebugBreak from kernel32_exception (raises EXCEPTION_BREAKPOINT with the caller's context; an int3 in our own frame was a host fault), IsDebuggerPresent from kernel32_process (reads TracerPid). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The policy of modules::net on Windows, on Linux sockets: the title can talk to itself over loopback (it binds a TCP listener), connects and datagram sends anywhere else fail with WSAENETUNREACH, a bind to all interfaces is narrowed to loopback, and lookups answer localhost and address literals only (WSAHOST_NOT_FOUND otherwise). ws2_32.rs translates what differs from Linux: sockaddr families, fd_set (select runs on poll), hostent and addrinfo layouts, socket option levels and names, MSG_WAITALL, and errno to WSA codes; the exports the title takes by ordinal are listed under their Winsock 1.1 numbers. winhttp.rs: sessions open, WinHttpConnect fails with ERROR_WINHTTP_CANNOT_CONNECT for every server as it does for off-machine ones on Windows, so the request functions only ever see invalid handles; closing an async session sends HANDLE_CLOSING; and WinHttpCrackUrl is real, since libHttpClient and XCurl parse URLs with it. Tested: cargo test -p victory-hle on Linux (loopback listener, accept, select, non-blocking recv, unreachable destinations, offline lookups, URL cracking into pointers and buffers, structure layouts). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
On Linux every submission copied the title's GPU memory whole (5-13 GB per world frame, about 0.5 fps): there is no GetWriteWatch, and the Windows guard on view memory was off. The region table now guards every 64 KiB block a copy took (private memory and views alike) with mprotect, and the fault handler takes the first write to one before anything else sees it, from title code or ours: the block is writable again and counts written. The state the handler touches is one bit per block in a lazily backed reservation: lock-free and allocation-free. The table keeps answering the protection the title set, and every change of protection or mapping (commit, decommit, release, VirtualProtect, views, physical pages, aliases) opens the guarded blocks it touches first. It also knows which blocks show the same section pages, so a page shown at several addresses is guarded at all of them and a write through any counts for each; writes into the pool outside the views (DirectStorage's write_physical and page windows, freed pages reading zero) open the blocks showing them. Kernel writes (read(2) into a guarded block returns EFAULT) are opened first in the Linux file layer (ReadFile, the UCRT's read) and in DirectStorage's raw reads, as Windows does. A write fault on a block another thread just opened is retried after a write probe (an atomic or of zero) says it is writable. victory-gpu's journal is shared: only "pages written since the last asking" is per OS (GetWriteWatch plus the view guard on Windows, the region table on Linux). Windows behaviour is unchanged. Tested: cargo test --workspace (414 passed, 12 ignored; new vm::tests::guarded_blocks_see_every_writer and writes_through_any_alias_count), Windows cargo check (no diagnostics), cargo xtask policy. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The first compile in DXC's libdxcompiler (the indirect argument clamp, at the world's first indirect execution) installs LLVM's own handlers for SIGSEGV, SIGBUS, SIGILL and SIGFPE (SA_RESETHAND). After it, the next fault in title code did not reach our handler and the kernel ended the process: a title exception from then on, and with write watching the next write to a guarded block (seen: title-main storing into the 174 MB buffer, a core and no line from us). LLVM registers once per process, so the clamp's DXIL is now compiled once, at the host device's creation (before any copy guards title memory), and signals::reclaim() puts our handlers back right after it. Tested: argument_clamp_builds with VICTORY_DXCOMPILER now checks the handler is ours after the compile (it was LLVM's before); cargo test --workspace (414 passed, 12 ignored); Windows cargo check. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
docs/linux.md: write watching is done on Linux (how the region table guards, what the kernel cannot do and who opens for it). watch::open steps over bitmap words with nothing guarded: releasing a big reservation walked every block of it. Tested: cargo test --workspace (414 passed, 12 ignored), cargo xtask policy. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Check on Linux, not Windows: pass. Head
On: AMD Ryzen 7 5700, 62 GB RAM, Artix Linux 7.3.4-artix1-2, rustc 1.98.1 (the repo's pinned toolchain), cargo-xwin 0.24.1. No game data. Automated check only: the code itself was not reviewed. |
… length The world load stalled in most runs on the RTX 5090: one host submission never finished and the title's watchdog ended the run. It was not a spinning shader: each stall came with an NVIDIA Xid 13 "SM Warp Exception: MMU Fault" in the kernel log, after which the channel stops and the fence is never signalled. With the lists' commands serialized and a GPU breadcrumb per command, the faulting command was a dispatch of compute 72f552f4553fb5f9 every time. Dropping its raw (offen) buffer loads, alone, let the run reach the world; dropping its structured loads or its images did not. Its raw offsets come from data arithmetic ((x - 1) * stride and the like) that wraps to near 2^32. The console's buffer loads bound such an offset by the record count and read 0; through vkd3d-proton's robust raw access chains on NVIDIA 620.73 they faulted instead. Descriptor QA (vkd3d-proton built with enable_descriptor_qa) found no bad descriptor, never freeing slot and shadow resources changed nothing, and no view runs past its host buffer. Every raw buffer load, store and atomic through a view now takes its byte offset bounded by RAW_OFFSET_MAX (0x7FFF_FFF0): still past any view, so reads give 0 and writes are dropped, as on the console; the bound keeps offset plus access below 2^31. Root SRVs are bare addresses on vkd3d-proton (nothing bounds them), and the mesh programs' vertex fetch builds descriptors without a record limit around them, at indices from data. Each root SRV now gets a user-data dword (at its parameter's own index) with the bytes its host buffer holds from the address; loads not wholly within it read offset 0 and return 0, and a root SRV with no host memory behind it is bound to scratch with length 0 instead of being left unset. All raw loads go through one helper (raw_load) for this. Tested: 6 runs in a row reach the world and stay there for 200 s (0.6-0.8 fps, 960-5300 draws a frame), no watchdog, no Xid; before, 4 of 5 runs stalled at the world load (12 of 14 with diagnostics builds). cargo test --workspace 414 passed, 12 ignored; victory-shader (host) and victory-gpu device tests on vkd3d-proton pass, with two new ones (raw offsets past the limit, root SRV length); Windows type-check clean; cargo xtask policy. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Finding the world-load stall needed the command the GPU never finished: the 5-second watcher only listed a stuck list's last commands, and dispatches without barriers between them overlap, so even a timestamp says little about which one hangs. With timing on (diagnostics builds), each noted command now ends with a global UAV barrier and a marker-out write of its index to a mapped read-back dword (WriteBufferImmediate; vkd3d-proton writes it with vkCmdWriteBufferMarkerAMD at bottom of pipe). A list still running after 5 s names the first command not finished and logs every command of the list. The barrier serializes a timed list's commands, which also makes the per-command times exact. VICTORY_SHADER_SAVE=<dir> saves each shader container the title passes, as <hash>.<stage>, so `victory shader-info --disasm` and `victory translate --pipelines` (with VKD3D_SHADER_DUMP_PATH for the SPIR-V) can take one program apart. The files go where the user says, never into the repository. Tested: the stall runs named compute 72f552f4553fb5f9 as the unfinished command in serialized lists (and the fix in the previous commit removed the stall); cargo test --workspace 414 passed, 12 ignored; Windows type-check clean; cargo xtask policy. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Linux hardware test on an 8 GB Radeon RX 7600 (Navi 33), Mesa RADV 26.2.5, SDL 3.4.18. I built the Linux runtime at d46727f, native vkd3d-proton at 30b0eb9bc12d and used Microsoft's Linux DXC v1.9.2609. I used the default Series X profile and a local save that had completed first-boot setup. The native runtime used its own storage implementation. The account picker responded to keyboard input. The illustrated load advanced to the “Vice City, Two Years Ago” chapter card. The runtime logged 240 successful mesh pipeline creations before I stopped the run. In four successive intervals during the transition it reported 0.9, 0.5, 0.9 and 1.0 fps. The final visible frame was black. Player movement and a visible world remain unverified. On the same PC, the Windows runtime at ffe310e under Wine 11.21 exited at the first mesh pipeline, both with the default storage implementation and with a Leonida provider. Across these tests the graphics software versions also differ, so this comparison identifies a working route to the chapter card without establishing the cause of the difference. CPU validation of the shaders used in this runI matched all 1,257 distinct shader containers seen during startup, loading and the first scene to the local installation. For each build I called the same translator as the native runtime and checked every emitted module with Microsoft's Linux DXIL validator (DXC v1.9.2609).
All 958 baseline successes still validated. Of the 45 additional successes, 37 were compute, six pixel and two mesh shaders. On the #180 + #193 build, applying the signature ordering change alone cleared the remaining mesh output-signature error. The #704 integration also includes its descriptor-heap prerequisites cbb50b8, 3c81420 and e8d3b64 and builds natively. Rendering and frame rate on that build are still unverified. |
|
Tested Intel CPU boot crash (
|
x3ero0
left a comment
There was a problem hiding this comment.
One gap in the offline socket policy on Linux, with a fix in spidercraft#1. Reviewed and tested at d46727f on Linux x86-64 (NVIDIA): cargo test --workspace passes there.
| pub extern "win64" fn listen(s: Socket, backlog: i32) -> i32 { | ||
| let fd = fd_or_fail!(s); | ||
| // SAFETY: plain call on our descriptor. | ||
| if unsafe { libc::listen(fd, backlog) } != 0 { os_fail() } else { 0 } | ||
| } |
There was a problem hiding this comment.
listen goes straight to the kernel, and Linux binds an unbound socket to all interfaces at that point (0.0.0.0 and a port it chooses), so other machines can connect in. That gets around the narrowing bind does. Winsock returns WSAEINVAL for listen on an unbound socket, so refusing it here matches Windows.
The same happens with a first sendto from an unbound datagram socket: it is bound to 0.0.0.0 and can then receive datagrams from the network.
spidercraft#1 fixes both against this branch, with a test: listen fails with WSAEINVAL unless the socket has a loopback address, and sendto binds an unbound datagram socket to loopback first.
|
Ran GTA VI on this branch natively (RTX 4070, Arch) and hit three bugs. Fixes against
|
|
Test report for Setup: RTX 5080, driver 620.70, Ryzen 7 9800X3D, CachyOS (kernel 7.3.5), KDE Wayland, SDL3 on Wayland. Native vkd3d-proton built from Sandbox: Build and tests
Title runs
What the log gives as causes
With DXC the indirect draws run, more of the title's pipelines get requested (hence the higher counts), frames get slower (mean 2.2 fps against 3.2 in run 4), and the scene is still dark. So on this card the missing picture is not the dropped indirect execution. On the DXC dependency: without Single machine, one GPU, runs of a few minutes; I did not play past the opening sequence. |
|
Automated triage for the maintainers. Closing because it is outside the project's scope (VIctory targets Windows hosts; ports, launchers and tooling for other platforms are not being taken). Native Linux runtime, 38,000 lines over 155 files (own loader, SEH, a new crate with a build script, libc and serde_json, a docs/linux.md design document, an edit to xtask/src/policy.rs): a port, out of scope. If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution. |
The PR was 131 commits behind main; its conflicts are resolved here: - calling convention: the PR's `extern "win64"` everywhere wins, since every function title code calls is win64 on both platforms (docs/linux.md). - dxgi: keeps main's `crate::device::is_device` (every device interface level), which the PR's narrower `[device::IID]` broke for Device1..8. - crash.rs: main's richer detail (memory_at, instruction_bytes, the C++ throw) is fed into the PR's shared `crash_log::Report` format. - thunks.rs: main's crash-log write for a trapped import, plus the PR's Linux ThunkBlock; both test modules kept. - lower.rs: main's `nonuniform_handles`/`wave_ops` and the PR's `annotations` test fields coexist; both test bodies kept. - files.rs/storage.rs/xuser.rs/lifecycle.rs: PR's Linux doc text and win64 signatures, with main's test bodies which need Windows-only cfgs. Three follow-up fixes from the PR's review comments are applied on top: - ws2_32: an unbound socket never gets all interfaces (x3ero0's review, spidercraft/VIctory#1). - GetProcAddress reads the exports of title DLLs we mapped, cmpxchg16b fixed registers, deterministic heap test (onpeek, #2). - AMD-only Zen 2 instructions (clzero, SSE4a extrq/insertq) emulated in the SIGILL handler (toothpaste011, #3). Also adds a Nix flake, a dev shell (default and windows-cross), a shell.nix shim and .envrc, and allowlists .nix/.envrc in the asset policy.
…ave empty bodies GDK manifests often write TitleId as 0x639AA8DD, which from_str_radix rejected, leaving the id 0. A self-closing element also took the text up to the next tag as its body. Fixes Marvisak#526. Tested: cargo test -p victory-hle (138 pass), clippy, fmt, xtask policy. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
What
A native Linux build of the runtime:
victory run <exe> --executeruns the title as an ELF program, with no Wine and no Windows DLL. The title's x86-64 code still runs unchanged in our process; on Linux we also supply what the Windows loader, kernel and system DLLs supply on Windows. The Windows build is unchanged (it type-checks with no diagnostics after every commit here). The design, the rules each part follows and the status are indocs/linux.md.Builds on #523 and #524 (their commits are the first two here) and includes #177's commits, the fix for image atomics on float-read textures that NVIDIA's compiler crashed on (with the test from #226).
Where things live
victory-loader/src/linux/{image,teb,tls,thread}.rsEXCEPTION_RECORD/CONTEXT,.pdatadispatcher and unwinder, host frames between title frames, crash reportvictory-loader/src/linux/{seh,signals,unwind,context,asm}.rsVirtualAlloc(64 KiB granularity, guard pages, placeholders, memfd physical pool)victory-loader/src/linux/vm.rsHostPolicypasses through on Windows: kernel32/ntdll (handle table, waits, locks, threads, thread pool, time, memory, heap, files, text), the UCRT, ws2_32/winhttp (offline), bcrypt, crypt32, advapi32, COM, user32, XAudio2, Spatial Audio, Media Foundation stubsvictory-hle/src/linux/<dll>_<slice>.rs, found byhost::imp::resolveon Linuxvictory-hle/src/modules/*(per-OS host functions only where they differ)windows0.62 does not build on Linux)victory-gpu,victory-shader,crates/victory-windowsThe title-facing ABI is
win64everywhere (#524); the CRT-style exports (exit, the CRT file functions) wereextern "C"and are fixed here too.How to run
docs/linux.md: build vkd3d-proton natively (meson), pointVICTORY_VKD3Dat it; optionally Microsoft's DXC Linux release forVICTORY_DXIL/VICTORY_DXCOMPILER(Arch'sdirectx-shader-compiler1.10.2605 asserts on every shader). SDL3 and the Vulkan loader come from the distribution.Tested
Linux (CachyOS, Ryzen 9 7950X3D, RTX 5090, NVIDIA 620.73):
cargo test --workspace: 416 passed, 0 failed, 12 ignored, without game data. Guest code under test is PE fixtures we build withlld-linkagainst an xwin SDK (skipped without it): the loader probe, an SEH fixture (__try/__exceptaround real faults, C++ throw/catch/rethrow across threads, unhandled-fault report), and device tests withVICTORY_VKD3D(compute, clear and readback, pipelines from translated shaders, 120 frames to a window).cargo check --workspace --all-targets --all-features --target x86_64-pc-windows-msvc: no diagnostics.victory translate --validateover the title's shaders on Linux: the same validated counts as the validator reports there; every emitted vertex, pixel and mesh program makes a pipeline.Two fixes found on Linux that also concern Windows
victory-loader/src/linux/{vm,watch}.rs, the GPU journal invictory-gpu/src/watch.rsshared): world copies of title memory fell from 6-11 GB to 0.2-0.4 GB a frame (0.6 to 1.1-1.8 fps). Overlaps the Windows-side work in GPU: remember unmapped guarded view blocks instead of re-copying them every submission #464 and GPU: ask whether guarded memory is a view once per block, not per asking #490 only invictory-gpu/src/watch.rs.victory-shader/src/emit/lower.rs): a compute program in the world load computes raw offsets that wrap to near 2^32; the console reads 0 there, while on vkd3d-proton/NVIDIA the access hit an MMU fault (kernelXid 13), the channel stopped and the submission's fence never signalled, which is what stalled most world loads (before: 4 of 5 runs ended by the title's watchdog; after: none in 9). Offsets are now kept at or below0x7FFF_FFF0(still past any view: reads give 0, writes drop). The same commit bounds root SRV reads by their host buffer's length, which overlaps GPU: bind root SRVs as one-view tables bounded to their host copy #493 (root SRVs as bounded one-view tables); if GPU: bind root SRVs as one-view tables bounded to their host copy #493 lands first this part can go.Not done yet
No game data in the repository, the tests or this description.
🤖 Generated with Claude Code