[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1544237214-18766-1-git-send-email-puwen@hygon.cn>
Date: Sat, 8 Dec 2018 10:46:54 +0800
From: Pu Wen <puwen@...on.cn>
To: <bp@...en8.de>
CC: <tglx@...utronix.de>, <mingo@...hat.com>, <hpa@...or.com>,
<x86@...nel.org>, <linux-kernel@...r.kernel.org>,
Pu Wen <puwen@...on.cn>
Subject: Re: [PATCH] x86/cpu: Avoid endless loop to get the number of cache leaves
Sorry for the late reply :)
On 2018/11/16 1:22, Borislav Petkov wrote:
>> @@ -640,7 +641,7 @@ static int find_num_cache_leaves(struct cpuinfo_x86 *c)
>> /* Do cpuid(op) loop to find out num_cache_leaves */
>> cpuid_count(op, i, &eax, &ebx, &ecx, &edx);
>> cache_eax.full = eax;
>> - } while (cache_eax.split.type != CTYPE_NULL);
>> + } while (cache_eax.split.type != CTYPE_NULL && i != CTYPE_MAX);
> i is an int and CTYPE_MAX is enum _cache_type. Huh?
How about define CTYPE_MAX like this:
#define CTYPE_MAX 4
> This works by chance because CTYPE_MAX is 4 and the termination CPUID
> leaf is the 4th too.
It will return CTYPE_NULL when accessing the 4th CPUID leaf in most of
the cases, but in certain case it will not. So I think it's better to
restrict the maximum CPUID access times to 4 for kernel robustness.
--
Regards,
Pu Wen
Powered by blists - more mailing lists