* [RFC PATCH RESEND] x86/cpu: Avoid endless loop to get the number of cache leaves
@ 2018-12-06 7:26 Pu Wen
2018-12-06 10:37 ` Borislav Petkov
0 siblings, 1 reply; 4+ messages in thread
From: Pu Wen @ 2018-12-06 7:26 UTC (permalink / raw)
To: bp, tglx, mingo, hpa, x86; +Cc: linux-kernel, Pu Wen
To get the number of cache leaves on AMD or Hygon platform, it should
get the value of cpuid leaf 0x8000001d. But on certain broken platform
such as a not fullly implemented virtual platform(for example Xen),
the value of the cpuid leaf will nerver be CTYPE_NULL, so the kernel
will run into an endless loop.
To fix this problem, add a new enum type CTYPE_MAX to limit the maximum
cpuid accessing.
Signed-off-by: Pu Wen <puwen@hygon.cn>
---
arch/x86/kernel/cpu/cacheinfo.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/arch/x86/kernel/cpu/cacheinfo.c b/arch/x86/kernel/cpu/cacheinfo.c
index dc1b934..7bd167f 100644
--- a/arch/x86/kernel/cpu/cacheinfo.c
+++ b/arch/x86/kernel/cpu/cacheinfo.c
@@ -121,7 +121,8 @@ enum _cache_type {
CTYPE_NULL = 0,
CTYPE_DATA = 1,
CTYPE_INST = 2,
- CTYPE_UNIFIED = 3
+ CTYPE_UNIFIED = 3,
+ CTYPE_MAX = 4
};
union _cpuid4_leaf_eax {
@@ -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);
return i;
}
--
2.7.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [RFC PATCH RESEND] x86/cpu: Avoid endless loop to get the number of cache leaves
2018-12-06 7:26 [RFC PATCH RESEND] x86/cpu: Avoid endless loop to get the number of cache leaves Pu Wen
@ 2018-12-06 10:37 ` Borislav Petkov
2018-12-08 3:52 ` Pu Wen
2018-12-08 3:56 ` Pu Wen
0 siblings, 2 replies; 4+ messages in thread
From: Borislav Petkov @ 2018-12-06 10:37 UTC (permalink / raw)
To: Pu Wen; +Cc: tglx, mingo, hpa, x86, linux-kernel
On Thu, Dec 06, 2018 at 03:26:13PM +0800, Pu Wen wrote:
> To get the number of cache leaves on AMD or Hygon platform, it should
> get the value of cpuid leaf 0x8000001d. But on certain broken platform
> such as a not fullly implemented virtual platform(for example Xen),
> the value of the cpuid leaf will nerver be CTYPE_NULL, so the kernel
> will run into an endless loop.
>
> To fix this problem, add a new enum type CTYPE_MAX to limit the maximum
> cpuid accessing.
>
> Signed-off-by: Pu Wen <puwen@hygon.cn>
> ---
> arch/x86/kernel/cpu/cacheinfo.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
Did you not see my reply to this last time?
https://lkml.kernel.org/r/20181115172155.GB25056@zn.tnic
--
Regards/Gruss,
Boris.
Good mailing practices for 400: avoid top-posting and trim the reply.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [RFC PATCH RESEND] x86/cpu: Avoid endless loop to get the number of cache leaves
2018-12-06 10:37 ` Borislav Petkov
@ 2018-12-08 3:52 ` Pu Wen
2018-12-08 3:56 ` Pu Wen
1 sibling, 0 replies; 4+ messages in thread
From: Pu Wen @ 2018-12-08 3:52 UTC (permalink / raw)
To: Borislav Petkov
Cc: tglx@linutronix.de, mingo@redhat.com, hpa@zytor.com,
x86@kernel.org, linux-kernel@vger.kernel.org
On 2018/12/6 18:37, Borislav Petkov wrote:
> Did you not see my reply to this last time?
>
> https://lkml.kernel.org/r/20181115172155.GB25056@zn.tnic
I'm sorry that there is something wrong with my mail filter. So I was
not notified about your reply for many days. :)
I just found your reply and replied to it.
Thx.
--
Regards,
Pu Wen
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [RFC PATCH RESEND] x86/cpu: Avoid endless loop to get the number of cache leaves
2018-12-06 10:37 ` Borislav Petkov
2018-12-08 3:52 ` Pu Wen
@ 2018-12-08 3:56 ` Pu Wen
1 sibling, 0 replies; 4+ messages in thread
From: Pu Wen @ 2018-12-08 3:56 UTC (permalink / raw)
To: Borislav Petkov
Cc: tglx@linutronix.de, mingo@redhat.com, hpa@zytor.com,
x86@kernel.org, linux-kernel@vger.kernel.org
On 2018/12/6 18:37, Borislav Petkov wrote:
> Did you not see my reply to this last time?
>
> https://lkml.kernel.org/r/20181115172155.GB25056@zn.tnic
I'm sorry that there is something wrong with my mail filter. So I was
not notified about your reply for many days. :)
I just found your reply and replied to it.
Thx.
--
Regards,
Pu Wen
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2018-12-08 3:57 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-12-06 7:26 [RFC PATCH RESEND] x86/cpu: Avoid endless loop to get the number of cache leaves Pu Wen
2018-12-06 10:37 ` Borislav Petkov
2018-12-08 3:52 ` Pu Wen
2018-12-08 3:56 ` Pu Wen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox