Fix thread_invoke and thread_dispatch TSC non-monotonic panic on Darwin 25.4.0+#215
Open
laobamac wants to merge 2 commits intoAMD-OSX:masterfrom
Open
Fix thread_invoke and thread_dispatch TSC non-monotonic panic on Darwin 25.4.0+#215laobamac wants to merge 2 commits intoAMD-OSX:masterfrom
laobamac wants to merge 2 commits intoAMD-OSX:masterfrom
Conversation
VGerris
reviewed
Apr 14, 2026
VGerris
left a comment
There was a problem hiding this comment.
tested on Lenovo Legion laptop with update from 26.3 to 26.4.1 , works for me
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR addresses a kernel panic issue that occurs on AMD systems (specifically observed on laptops) when updating to Darwin Kernel Version 25.4.0 (macOS 26.4 Beta/RC).
The existing AMD kernel patch for bypassing the non-monotonic time panic (TSC sync issue) in
thread_invokeandthread_dispatchfails to apply on Darwin 25.4.0 due to a structure shift in the XNU kernel.Root Cause Analysis
Upon analyzing the disassembled XNU kernel, it is evident that the offset for the TSC tracking variables within the
threadstruct has shifted by 8 bytes.In Darwin <= 25.3.x, the comparison instruction in
thread_invokelooks like this:Click to see
However, in Darwin 25.4.0, the struct has grown, and the instruction uses a new offset of
0x490:Click to see
Why the current patch fails:
The current patch looks for the signature
48 00 00 80 04 00 00 0F 00 00 00 00 00with the mask48 00 00 F0 FF FF FF FF 00 00 00 00 00.Because the mask applies
F0to the target byte, it successfully matches values from80 04to8F 04(0x480-0x48F). When the offset shifted to90 04(0x490), the masking logic no longer matches the expected0x80, causing the patch engine to skip this instruction entirely. This results in an immediate panic on boot.(Note: The first patch handling
thread_quantum_expireandthread_unblockremains unaffected, as their offsets (0x250and0x58) have not changed in this Darwin release.)Testing