From 19700736b8c9a142f3dc18eb9938615509ae665a Mon Sep 17 00:00:00 2001 From: MechaCat02 Date: Sun, 5 Jul 2026 20:21:49 +0200 Subject: [PATCH] [iterate-4E] Stage 1'a: enable host-atomic ReservationTable in native mode MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit native_active is now folded into parallel_active, so XENIA_NATIVE_THREADS=1 (a) enables kernel.reservations (lwarx/stwcx route through the inter-thread ReservationTable) and (b) sets kernel.parallel_active for the wall-clock vsync/coordination paths. Closes the PPCBUG-108 landmine flagged in the rework pressure-test: native mode runs guest code on multiple host threads concurrently, so the legacy per-PpcContext reservation fallback (which cannot observe cross-thread stores) is incorrect. Previously pure-native (no --parallel) left the table disabled — silently wrong in release, debug_assert in debug. Gate GREEN 3/3 (golden byte-identical, native renders, stress no-deadlock). Co-Authored-By: Claude Opus 4.8 --- crates/xenia-app/src/main.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/crates/xenia-app/src/main.rs b/crates/xenia-app/src/main.rs index 420c64f..eb7849a 100644 --- a/crates/xenia-app/src/main.rs +++ b/crates/xenia-app/src/main.rs @@ -1031,7 +1031,15 @@ fn cmd_exec_inner( let v = v.trim().to_ascii_lowercase(); v == "1" || v == "true" || v == "yes" }); - let parallel_active = parallel || parallel_via_env; + // iterate-4E: native-threads mode is a superset of parallel behavior (it + // delegates to the free-run executor and runs guest code on multiple host + // threads concurrently). Folding it into `parallel_active` is what enables + // the host-atomic ReservationTable below — MANDATORY under concurrency, else + // lwarx/stwcx on non-primary slots silently can't observe cross-thread + // stores (PPCBUG-108). Also flips `kernel.parallel_active` so the wall-clock + // vsync/coordination paths engage like `--parallel`. + let native_active = native_threads_enabled(); + let parallel_active = parallel || parallel_via_env || native_active; kernel.parallel_active = parallel_active; // AUDIT-032: default is `KernelState::xaudio_tick_enabled = true` now // that the dedicated worker eliminates HW-thread hijack regressions.