Skip to content

OcAppleKernelLib: Fix zero divisor in AMP topology initialization - #661

Open
lzhoang2801 wants to merge 1 commit into
acidanthera:masterfrom
lzhoang2801:fix/amp-package-capacity
Open

lzhoang2801 wants to merge 1 commit into
acidanthera:masterfrom
lzhoang2801:fix/amp-package-capacity

Conversation

@lzhoang2801

Copy link
Copy Markdown

The AMP patch in ProvideCurrentCpuInfo sets cpuid_cores_per_package to 128. If the logical APIC ID capacity is smaller than 128, XNU gets zero threads per core and divides by zero during boot. Use the logical APIC ID capacity that XNU sees as the replacement value.

Tested on multiple CPUs.

Fixes: dortania/bugtracker#336

The AMP path in ProvideCurrentCpuInfo hardcodes the package core ID
capacity to 128. When XNU sees a smaller logical APIC ID capacity,
dividing it by 128 gives zero. XNU then uses that result as a divisor
during topology initialization.

Use the logical APIC ID capacity exposed to XNU for the package patch
so the flattened topology has one thread per core.
@lzhoang2801
lzhoang2801 marked this pull request as draft November 10, 2026 15:39
@lzhoang2801
lzhoang2801 marked this pull request as ready for review November 10, 2026 16:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

12500H Efficiency Core Issue

1 participant