Intel CPUs: Fix counting of CPU cores
Detection for a hyper-threading CPU was not compatible with multicore CPUs. When using CPUID eax==4, also need to set ecx=0. CAR init tested on real hardware with hyper-threading model_f25 and under qemu 0.15.1 with multicore CPU. Change-Id: I28ac8790f94652e4ba8ff88fe7812c812f967608 Signed-off-by: Kyösti Mälkki <kyosti.malkki@gmail.com> Reviewed-on: http://review.coreboot.org/1172 Tested-by: build bot (Jenkins) Reviewed-by: Anton Kochkov <anton.kochkov@gmail.com>
This commit is contained in:
parent
15cf0adc3e
commit
df0fbc7455
|
@ -127,16 +127,36 @@ bsp_init:
|
||||||
|
|
||||||
post_code(0x24)
|
post_code(0x24)
|
||||||
|
|
||||||
/* For a hyper-threading processor, cache must not be disabled
|
movl $1, %eax
|
||||||
* on an AP on the same physical package with the BSP.
|
|
||||||
*/
|
|
||||||
movl $01, %eax
|
|
||||||
cpuid
|
cpuid
|
||||||
btl $28, %edx
|
btl $28, %edx
|
||||||
jnc sipi_complete
|
jnc sipi_complete
|
||||||
bswapl %ebx
|
bswapl %ebx
|
||||||
cmpb $01, %bh
|
movzx %bh, %edi
|
||||||
jbe sipi_complete
|
cmpb $1, %bh
|
||||||
|
jbe sipi_complete /* only one LAPIC ID in package */
|
||||||
|
|
||||||
|
movl $0, %eax
|
||||||
|
cpuid
|
||||||
|
movb $1, %bl
|
||||||
|
cmpl $4, %eax
|
||||||
|
jb cores_counted
|
||||||
|
movl $4, %eax
|
||||||
|
movl $0, %ecx
|
||||||
|
cpuid
|
||||||
|
shr $26, %eax
|
||||||
|
movb %al, %bl
|
||||||
|
inc %bl
|
||||||
|
|
||||||
|
cores_counted:
|
||||||
|
movl %edi, %eax
|
||||||
|
divb %bl
|
||||||
|
cmpb $1, %al
|
||||||
|
jbe sipi_complete /* only LAPIC ID of a core */
|
||||||
|
|
||||||
|
/* For a hyper-threading processor, cache must not be disabled
|
||||||
|
* on an AP on the same physical package with the BSP.
|
||||||
|
*/
|
||||||
|
|
||||||
hyper_threading_cpu:
|
hyper_threading_cpu:
|
||||||
|
|
||||||
|
@ -202,7 +222,7 @@ ap_init:
|
||||||
ap_halt:
|
ap_halt:
|
||||||
cli
|
cli
|
||||||
1: hlt
|
1: hlt
|
||||||
jnz 1b
|
jmp 1b
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -28,8 +28,11 @@ int intel_ht_sibling(void)
|
||||||
apic_ids = 1;
|
apic_ids = 1;
|
||||||
|
|
||||||
core_ids = 1;
|
core_ids = 1;
|
||||||
if (cpuid_eax(0) >= 4)
|
if (cpuid_eax(0) >= 4) {
|
||||||
core_ids += (cpuid_eax(4) >> 26) & 0x3f;
|
struct cpuid_result result;
|
||||||
|
result = cpuid_ext(4, 0);
|
||||||
|
core_ids += (result.eax >> 26) & 0x3f;
|
||||||
|
}
|
||||||
|
|
||||||
threads = (apic_ids / core_ids);
|
threads = (apic_ids / core_ids);
|
||||||
return !!(lapicid() & (threads-1));
|
return !!(lapicid() & (threads-1));
|
||||||
|
|
Loading…
Reference in New Issue