[Skiboot] [PATCH] core/cpu: fix next_ungarded_primary
Nicholas Piggin
npiggin at gmail.com
Fri Nov 27 15:27:50 AEDT 2020
next_unguarded_primary dereferences NULL CPU -> UB -> infinite loop
Fast reboot works again after this patch.
Fixes: 98f5834253c7e ("cpu: Keep track of the "ec_primary" in big core more")
Signed-off-by: Nicholas Piggin <npiggin at gmail.com>
---
core/cpu.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/core/cpu.c b/core/cpu.c
index ff0442a8a..d30bef8e0 100644
--- a/core/cpu.c
+++ b/core/cpu.c
@@ -823,11 +823,9 @@ struct cpu_thread *first_ungarded_cpu(void)
struct cpu_thread *next_ungarded_primary(struct cpu_thread *cpu)
{
- bool is_primary;
do {
- cpu = next_cpu(cpu);
- is_primary = cpu == cpu->primary || cpu == cpu->ec_primary;
- } while(cpu && (cpu->state == cpu_state_unavailable || !is_primary));
+ cpu = next_ungarded_cpu(cpu);
+ } while (cpu && !(cpu == cpu->primary || cpu == cpu->ec_primary));
return cpu;
}
--
2.23.0
More information about the Skiboot
mailing list