Re: [PATCH 2/2] amd: uncore: Get correct number of cores sharing last level cache

From: Borislav Petkov
Date: Tue Jun 06 2017 - 13:45:13 EST


On Tue, Jun 06, 2017 at 12:15:30PM +0200, Peter Zijlstra wrote:
> Maybe something like:
>
> for (cache_level = 0; cache_level < 3; cache_level++) {
> cpuid_count(0x8000001d, cache_level, &eax, &ebx, &ecx, &edx);
>
> if ((eax & 0x1f) == 0) /* EAX[0:4] gives cache type */

if (!(eax & 0x1f))

> break;
>
> prev_eax = eax;
> }
>
> That way we'll not run off into the woods if CPUID goes funny (never
> trust a BIOS/virt monkey).

Yap, especially if there are CPUID functions with subleafs with holes in
them.

--
Regards/Gruss,
Boris.

Good mailing practices for 400: avoid top-posting and trim the reply.