Check for powerpc64 cores that fail to start
authorgkoehler <gkoehler@openbsd.org>
Sat, 19 Aug 2023 00:47:51 +0000 (00:47 +0000)
committergkoehler <gkoehler@openbsd.org>
Sat, 19 Aug 2023 00:47:51 +0000 (00:47 +0000)
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

index 922d344..01014b8 100644 (file)
@@ -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 <kettenis@openbsd.org>
@@ -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);