From a6fc0a8be1056062296fdc76aacaa74c9fe5a999 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 [ROCm/ROCR-Runtime commit: 5815d9de9b0b6e6c02309ebe998718f6e10bac8b] --- projects/rocr-runtime/src/topology.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/projects/rocr-runtime/src/topology.c b/projects/rocr-runtime/src/topology.c index ef22517bb3..0a5b5d8cab 100644 --- a/projects/rocr-runtime/src/topology.c +++ b/projects/rocr-runtime/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; }