- __cpuid_count (4, round, eax, ebx, ecx, edx);
+ if (round < cache->leaf4_valid)
+ /* Subleaf was queried before. Do not execute cpuid again. */
+ eax = cache->leaf4[round][0], ebx = cache->leaf4[round][1],
+ ecx = cache->leaf4[round][2], edx = cache->leaf4[round][3];
+ else if (round == cache->leaf4_valid
+ && round < sizeof(cache->leaf4)/sizeof(*cache->leaf4))
+ {
+ /* Cache the cpuid result if we have space. */
+ __cpuid_count (4, round, eax, ebx, ecx, edx);
+ cache->leaf4[round][0] = eax, cache->leaf4[round][1] = ebx;
+ cache->leaf4[round][2] = ecx, cache->leaf4[round][3] = edx;
+ cache->leaf4_valid++;
+ }
+ else
+ __cpuid_count (4, round, eax, ebx, ecx, edx);