fix(quickemu): improve TSC flag detection for macOS on AMD CPUs#1808
Merged
flexiondotorg merged 2 commits intomasterfrom Jan 24, 2026
Merged
fix(quickemu): improve TSC flag detection for macOS on AMD CPUs#1808flexiondotorg merged 2 commits intomasterfrom
flexiondotorg merged 2 commits intomasterfrom
Conversation
Contributor
There was a problem hiding this comment.
1 issue found across 1 file
Confidence score: 4/5
- Safe to merge overall; the only noted issue is a moderate-severity duplication of the
+invtscflag handling. - Duplicate
+invtscaddition inquickemucould lead to redundant CPU flag configuration (already handled viaconfigure_cpu_flagfor AMD). - Pay close attention to
quickemu- duplicate+invtscflag handling.
Prompt for AI agents (all issues)
Check if these issues are valid — if so, understand the root cause of each and fix them.
<file name="quickemu">
<violation number="1" location="quickemu:477">
P2: Duplicate `+invtsc` flag: The `invtsc` flag is already processed by the loop above (line 468) via `configure_cpu_flag`, which will add `+invtsc` for AMD CPUs thanks to the `check_cpu_flag` fix. Adding it again here causes duplication. Remove `+invtsc` from this line since only `+tsc` and `+tsc-deadline` are the additional flags needed.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
The invtsc flag is already added by the configure_cpu_flag loop when check_cpu_flag recognises constant_tsc as equivalent to invtsc on AMD. Adding it again in the AMD-specific TSC block caused duplication. Only +tsc and +tsc-deadline are needed as additional flags.
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.
Summary
macOS Monterey and newer can freeze on AMD Ryzen 4000U/5000U mobile CPUs when run as guests under QEMU/KVM. The root cause is a mismatch in how the host reports TSC capabilities and what macOS/QEMU expect.
Technical explanation
constant_tscwhile macOS/QEMU expectinvtsc. Functionally these indicate the same behaviour (an invariant, non-stopped TSC), but quickemu did not recogniseconstant_tscas equivalent toinvtscfor AMD hosts.What this fix does
check_cpu_flagto recogniseconstant_tscas equivalent toinvtscon AMD hosts.+tsc,+tsc-deadline,+invtsc.Important caveat
This is the best mitigation we can apply at the quickemu wrapper level. If macOS still freezes after this change the limitation is likely in QEMU/KVM's TSC virtualisation on these specific mobile CPU architectures and will need fixes upstream.
Fallback options if this fix doesn't resolve the issue
Related issue
Closes #1273