Skip to content

fix(quickemu): improve TSC flag detection for macOS on AMD CPUs#1808

Merged
flexiondotorg merged 2 commits intomasterfrom
macos-ryzen
Jan 24, 2026
Merged

fix(quickemu): improve TSC flag detection for macOS on AMD CPUs#1808
flexiondotorg merged 2 commits intomasterfrom
macos-ryzen

Conversation

@flexiondotorg
Copy link
Member

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

  • AMD reports the TSC feature as constant_tsc while macOS/QEMU expect invtsc. Functionally these indicate the same behaviour (an invariant, non-stopped TSC), but quickemu did not recognise constant_tsc as equivalent to invtsc for AMD hosts.

What this fix does

  1. Improve check_cpu_flag to recognise constant_tsc as equivalent to invtsc on AMD hosts.
  2. Add explicit TSC flags for macOS guests on 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

  • Use macOS Big Sur (11.x) which has more lenient TSC requirements.
  • Use AMD Ryzen 6000U series or desktop Ryzen CPUs; these are known to work.
  • Use an Intel host; Intel hosts do not exhibit this issue.

Related issue

Closes #1273

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 +invtsc flag handling.
  • Duplicate +invtsc addition in quickemu could lead to redundant CPU flag configuration (already handled via configure_cpu_flag for AMD).
  • Pay close attention to quickemu - duplicate +invtsc flag 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.
@flexiondotorg flexiondotorg merged commit 9cc54ff into master Jan 24, 2026
5 checks passed
@flexiondotorg flexiondotorg deleted the macos-ryzen branch January 24, 2026 02:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: macOS locks up running Quickemu on AMD Ryzen 4000 or 5000 series mobile CPUs?

1 participant