From 0212dafaaa86499da8b60526cf0a093806466421 Mon Sep 17 00:00:00 2001 From: gkoehler Date: Sat, 19 Aug 2023 00:47:51 +0000 Subject: [PATCH] Check for powerpc64 cores that fail to start If the core failed to start (because opal_start_cpu didn't return OPAL_SUCCESS), or failed to identify, then don't use the core. Eduardo Pires told ppc@ in April 2023 about a machine that froze at boot; cpu1 had failed to start with error -14 OPAL_WRONG_STATE. See https://marc.info/?l=openbsd-ppc&m=168106893329069&w=2 ok miod@ --- sys/arch/powerpc64/powerpc64/cpu.c | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/sys/arch/powerpc64/powerpc64/cpu.c b/sys/arch/powerpc64/powerpc64/cpu.c index 922d34489c1..01014b8231e 100644 --- a/sys/arch/powerpc64/powerpc64/cpu.c +++ b/sys/arch/powerpc64/powerpc64/cpu.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cpu.c,v 1.26 2023/06/15 22:18:07 cheloha Exp $ */ +/* $OpenBSD: cpu.c,v 1.27 2023/08/19 00:47:51 gkoehler Exp $ */ /* * Copyright (c) 2020 Mark Kettenis @@ -196,16 +196,20 @@ cpu_attach(struct device *parent, struct device *dev, void *aux) ci->ci_initstack_end = km_alloc(PAGE_SIZE, &kv_any, &kp_zero, &kd_waitok) + PAGE_SIZE; - opal_start_cpu(ci->ci_pir, (vaddr_t)cpu_hatch); - - atomic_setbits_int(&ci->ci_flags, CPUF_IDENTIFY); - membar_sync(); - - while ((ci->ci_flags & CPUF_IDENTIFIED) == 0 && - --timeout) - delay(1000); - if (timeout == 0) { - printf(" failed to identify"); + if (opal_start_cpu(ci->ci_pir, (vaddr_t)cpu_hatch) == + OPAL_SUCCESS) { + atomic_setbits_int(&ci->ci_flags, CPUF_IDENTIFY); + membar_sync(); + + while ((ci->ci_flags & CPUF_IDENTIFIED) == 0 && + --timeout) + delay(1000); + if (timeout == 0) { + printf(" failed to identify"); + ci->ci_flags = 0; + } + } else { + printf(" failed to start"); ci->ci_flags = 0; } } @@ -385,6 +389,8 @@ cpu_boot_secondary_processors(void) if (CPU_IS_PRIMARY(ci)) continue; + if ((ci->ci_flags & CPUF_PRESENT) == 0) + continue; ci->ci_randseed = (arc4random() & 0x7fffffff) + 1; cpu_boot_secondary(ci); -- 2.20.1