From bc8eb697940ebc876214cd696c8e402e9a8a2ea5 Mon Sep 17 00:00:00 2001 From: trustno1-coder <361337194+trustno1-coder@users.noreply.github.com> Date: Mon, 30 Nov 2026 15:24:32 -0800 Subject: [PATCH] Loader: SSE4a replacement off by default (VICTORY_PATCH_SSE4A=1 turns it on) A second thread reaching an insertq/extrq while the first replaces it can still end the run with 0xc000001d on Intel (#2393, #3775). #2585 makes that much rarer, not impossible; emulating each time never crashes this way. --- crates/victory-loader/src/console_insn.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/crates/victory-loader/src/console_insn.rs b/crates/victory-loader/src/console_insn.rs index f785ed71a..45a31078b 100644 --- a/crates/victory-loader/src/console_insn.rs +++ b/crates/victory-loader/src/console_insn.rs @@ -117,11 +117,15 @@ fn clzero_stub(at: usize, stub: usize, cmp: [u8; 3]) -> Option> { /// Whether SSE4a `extrq` / `insertq` with immediate length and index are replaced the first /// time they fault by a jump to the same operation in SSE2 ([`sse4a_stub`]). Run 19:19 of -/// 2026-11-28: one `insertq xmm0, xmm1, 16, 16` faulted about 3,700 times a second. On by -/// default; `VICTORY_PATCH_SSE4A=0` emulates each time, as before. +/// 2026-11-28: one `insertq xmm0, xmm1, 16, 16` faulted about 3,700 times a second. +/// +/// Off by default (`VICTORY_PATCH_SSE4A=1` turns it on): on Intel, a second thread that +/// reaches the instruction while the first is replacing it can still end the run with +/// `0xc000001d` (#2393, #3775). The late-fault fix (#2585) makes that much rarer but not +/// impossible; emulating each time never crashes this way. fn patches_sse4a() -> bool { static ON: std::sync::OnceLock = std::sync::OnceLock::new(); - *ON.get_or_init(|| std::env::var_os("VICTORY_PATCH_SSE4A").is_none_or(|v| v != "0")) + *ON.get_or_init(|| std::env::var_os("VICTORY_PATCH_SSE4A").is_some_and(|v| v == "1")) } /// `op xmm(reg), xmm(rm)` with `prefix`.