-
Notifications
You must be signed in to change notification settings - Fork 174
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
topology panic when using cpu generation newer than Penryn #1
Comments
seems adding two patches below we can use newer cpu generation than Penryn with topology defined.But still no luck with odd number cores.
When setting odd cores and topology, the MacOS won't boot, and gives out nothing(after opencore bootloader it just hanged with no panic and no log).Still digging, but already a big progress. |
Opencore support is added by acidanthera/OcSupportPkg#17 after release 0.5.2. |
When emulating a CPU model (like Skylake-Server in QEMU), the cpu name under system info may be unknown. It still not work when using 10/14/18-cores topology even with 0x0F01 specified. So it may not related to something Apple Hard check, may be cached related things?(QEMU may not handle cpu cache defination well when using odd cores topology. |
Finnally find some clues about this.
So lookup the code, the second one (which is recognized as 4 cores) is using leaf 4 information: if (Cpu->MaxId >= CPUID_CACHE_PARAMS && (Cpu->Model <= CPU_MODEL_PENRYN || Cpu->Hypervisor)) {
AsmCpuidEx (CPUID_CACHE_PARAMS, 0, &CpuidCacheEax.Uint32, &CpuidCacheEbx.Uint32, NULL, NULL);
if (CpuidCacheEax.Bits.CacheType != CPUID_CACHE_PARAMS_CACHE_TYPE_NULL) {
CoreCount = (UINT16)GetPowerOfTwo32 (CpuidCacheEax.Bits.MaximumAddressableIdsForProcessorCores + 1);
if (CoreCount < CpuidCacheEax.Bits.MaximumAddressableIdsForProcessorCores + 1) {
CoreCount *= 2;
}
Cpu->CoreCount = CoreCount;
//
// We should not be blindly relying on Cpu->Features & CPUID_FEATURE_HTT.
// On Penryn CPUs it is set even without Hyper Threading.
//
if (Cpu->ThreadCount < Cpu->CoreCount) {
Cpu->ThreadCount = Cpu->CoreCount;
}
}
} So it definately something wrong with cache params setting by QEMU. Apple have this code too: reg[eax] = 4; /* cpuid request 4 */
reg[ecx] = index; /* index starting at 0 */
cpuid(reg);
DBG("cpuid(4) index=%d eax=0x%x\n", index, reg[eax]);
cache_type = bitfield32(reg[eax], 4, 0);
if (cache_type == 0) {
break; /* no more caches */
}
cache_level = bitfield32(reg[eax], 7, 5);
cache_sharing = bitfield32(reg[eax], 25, 14) + 1;
info_p->cpuid_cores_per_package
= bitfield32(reg[eax], 31, 26) + 1;
cache_linesize = bitfield32(reg[ebx], 11, 0) + 1;
cache_partitions = bitfield32(reg[ebx], 21, 12) + 1;
cache_associativity = bitfield32(reg[ebx], 31, 22) + 1;
cache_sets = bitfield32(reg[ecx], 31, 0) + 1; So there are two ways to bypass this logic:
The first one works and the seconds doesn't yet.But we made a big progress now right? We can set odd number cores now. |
3-cores/6-threads <vcpu placement='static' current='6'>8</vcpu>
<vcpus>
<vcpu id='0' enabled='yes' hotpluggable='no' order='1'/>
<vcpu id='1' enabled='yes' hotpluggable='yes' order='2'/>
<vcpu id='2' enabled='yes' hotpluggable='yes' order='3'/>
<vcpu id='3' enabled='yes' hotpluggable='yes' order='4'/>
<vcpu id='4' enabled='yes' hotpluggable='yes' order='5'/>
<vcpu id='5' enabled='yes' hotpluggable='yes' order='6'/>
<vcpu id='6' enabled='no' hotpluggable='yes'/>
<vcpu id='7' enabled='no' hotpluggable='yes'/>
</vcpus>
<cputune>
<vcpupin vcpu='0' cpuset='6'/>
<vcpupin vcpu='1' cpuset='14'/>
<vcpupin vcpu='2' cpuset='7'/>
<vcpupin vcpu='3' cpuset='15'/>
<vcpupin vcpu='4' cpuset='5'/>
<vcpupin vcpu='5' cpuset='13'/>
</cputune>
<cpu mode='host-passthrough' check='none'>
<topology sockets='1' cores='4' threads='2'/>
</cpu> 5-cores/5-threads <vcpu placement='static' current='5'>8</vcpu>
<vcpus>
<vcpu id='0' enabled='yes' hotpluggable='no' order='1'/>
<vcpu id='1' enabled='yes' hotpluggable='yes' order='2'/>
<vcpu id='2' enabled='yes' hotpluggable='yes' order='3'/>
<vcpu id='3' enabled='yes' hotpluggable='yes' order='4'/>
<vcpu id='4' enabled='yes' hotpluggable='yes' order='5'/>
<vcpu id='5' enabled='no' hotpluggable='yes'/>
<vcpu id='6' enabled='no' hotpluggable='yes'/>
<vcpu id='7' enabled='no' hotpluggable='yes'/>
</vcpus>
<cputune>
<vcpupin vcpu='0' cpuset='6'/>
<vcpupin vcpu='1' cpuset='14'/>
<vcpupin vcpu='2' cpuset='7'/>
<vcpupin vcpu='3' cpuset='15'/>
<vcpupin vcpu='4' cpuset='8'/>
</cputune>
<cpu mode='host-passthrough' check='none'>
<topology sockets='1' cores='8' threads='1'/>
</cpu> |
Thanks for sharing the solution. I am not using odd cores, I am passing 8 cores and 2 threads each. With the topology skip patch I was able to have macOS properly recognize the cores/threads, however the CPU name shown is: Single-Core Intel Xeon. My CPU is an i7-6950X, if I try to passthrough my original CPU with
|
@sonoseco This is not error, only warning.Ingore it. |
@Leoyzen I've emulating the CPU for quite some time, however, I have a lot a audio issues and it seems that can be resolved by passing through the CPU. I still have the same issue as above, where Opencore hangs when using This is the opencore log: Edit: fixed the issue by using cpu and qemu:arg (adjusted to my config) from this XML: https://github.com/Pavo-IM/Hackinabox/blob/master/Catalina.xml |
QEMU patch regarding MSR_CORE_THREAD_COUNT: |
That actually only works for hvf, not kvm. Also see https://lkml.org/lkml/2020/9/16/977 |
@Leoyzen With Proxmox-VE I get the kernel early boot log using 1 sockets 6 cores ================OpenCore 0.7.2 log==================== ============= kernel log ============= Cache Topology Parameters: Logical Topology Parameters: Physical Topology Parameters: Backtrace (CPU 0), Frame : Return Address Mac OS version: Kernel version: System uptime in nanoseconds: 664522730 ** In Memory Panic Stackshot Succeeded ** Bytes Traced 699 (Uncompressed 720) ** |
Then find the codes in Qemu: case 4:
Then we run macOS successfully with 6/12 cores but no L3 cache show as flow:
|
Is setting sockets=3,cores=2 to get 6 cores total not a viable option? |
sockets=1,cores=6 may have better performace than sockets=3,cores=2 |
And now for KVM: https://lists.nongnu.org/archive/html/qemu-devel/2022-10/msg00579.html |
@Toolybird Awesome improvement. Is it usable now? I've been using AMD-Vanilla for some time but stuck at bigsur because of some unknown (nvme) bugs of msi motherboard. Maybe it's time to going back kvm-osx again. |
If you passthrough your cpu model and defined topology, you will see a kernel panic in MacOS.
The problem is divided to two part:
Fisrt is bootloader support(see disscusion here). This fixed in latest opencore.
The next is Apple MacOS support.
Apple use an undocumented Intel msr 0x35(see xen pr) to indentify topology when CPU Model newer than Penryn(Apple get the cpu topology from acpi when using Penryn, that's why Penryn works).
The xnu code related:
Of course not only the VM user faces the problem, but also AMD Vanilla users. So we definately can use the way of AMD Vanilla did(using patches), but we need some survey which patches works.
The text was updated successfully, but these errors were encountered: