From 5815d9de9b0b6e6c02309ebe998718f6e10bac8b Mon Sep 17 00:00:00 2001 From: Amber Lin Date: Thu, 12 Oct 2017 14:22:42 -0400 Subject: [PATCH] Fix endless loop Fix a while loop that can cause forever loop when cpuid instruction doesn't work properly. Change-Id: Iefa49d23b40c994eb4369621974a7d3c4067e47a Signed-off-by: Amber Lin --- src/topology.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/topology.c b/src/topology.c index ef22517bb3..0a5b5d8cab 100644 --- a/src/topology.c +++ b/src/topology.c @@ -354,7 +354,8 @@ static int cpuid_find_num_cache_leaves(uint32_t op) do { ++idx; cpuid_count(op, idx, &eax.full, &ebx.full, &ecx, &edx); - } while (eax.split.type != CACHE_TYPE_NULL); + /* Modern systems have cache levels up to 3. */ + } while (eax.split.type != CACHE_TYPE_NULL && idx < 4); return idx; }