From 6fa91329150d24fc0fabed1a75ed41e3cbded70a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 21 Feb 2026 16:52:14 +0000 Subject: [PATCH 1/2] Bump external/Catch2 from `2de12cb` to `29c9844` Bumps [external/Catch2](https://github.com/catchorg/Catch2) from `2de12cb` to `29c9844`. - [Release notes](https://github.com/catchorg/Catch2/releases) - [Commits](https://github.com/catchorg/Catch2/compare/2de12cb05f1e54fc2a8f7a894f2a435297295efa...29c9844f688acb27c87338c39cd186ebfe41aa19) --- updated-dependencies: - dependency-name: external/Catch2 dependency-version: 29c9844f688acb27c87338c39cd186ebfe41aa19 dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- external/Catch2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external/Catch2 b/external/Catch2 index 2de12cb..29c9844 160000 --- a/external/Catch2 +++ b/external/Catch2 @@ -1 +1 @@ -Subproject commit 2de12cb05f1e54fc2a8f7a894f2a435297295efa +Subproject commit 29c9844f688acb27c87338c39cd186ebfe41aa19 From 918faed0d44c5900cef93879ae745a7c73f28ff0 Mon Sep 17 00:00:00 2001 From: Alan Jowett Date: Tue, 17 Mar 2026 15:05:28 -0700 Subject: [PATCH 2/2] Fix affinity cache corruption when restoring Mask=0 When KfRaiseIrql/KeLowerIrql cycles run before tests that check KeSetSystemAffinityThreadEx return value, the thread-local _usersim_group_affinity_cache can be left dirty. This happens because KeLowerIrql tries to restore the saved affinity {Mask=0} (the initial cache value meaning 'no override') via SetThreadGroupAffinity, which fails since Mask=0 is invalid--leaving the cache at {Mask=1}. Handle Mask=0 explicitly in usersim_set_current_thread_affinity by restoring the thread to the process-default affinity instead of passing the invalid zero mask to the OS. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: Alan Jowett --- src/ke.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/ke.cpp b/src/ke.cpp index 0a6591e..8d90398 100644 --- a/src/ke.cpp +++ b/src/ke.cpp @@ -157,6 +157,18 @@ usersim_set_current_thread_affinity(const GROUP_AFFINITY* new_affinity, GROUP_AF bool result; if (memcmp(new_affinity, &_usersim_group_affinity_cache, sizeof(*new_affinity)) == 0) { result = true; + } else if (new_affinity->Mask == 0) { + // Mask=0 means "no affinity override". We can't pass Mask=0 to + // SetThreadGroupAffinity (it requires at least one processor bit), + // so restore the thread to the process-default affinity instead. + DWORD_PTR process_mask = 0; + DWORD_PTR system_mask = 0; + if (GetProcessAffinityMask(GetCurrentProcess(), &process_mask, &system_mask) && process_mask != 0) { + GROUP_AFFINITY default_affinity = {}; + default_affinity.Mask = process_mask; + SetThreadGroupAffinity(GetCurrentThread(), &default_affinity, nullptr); + } + result = true; } else { result = SetThreadGroupAffinity(GetCurrentThread(), new_affinity, old_affinity); }