head -r333575's kernel: fails to boot old PowerMac G5 so-called "Quad Core", failing very early

Mark Millard via freebsd-ppc <[email protected]>
Newsgroups gmane.os.freebsd.devel.ppc
Message-ID <[email protected]>
I'd had to revert to the old kernel from the last time I'd
updated the old PowerMac G5 "Quad Core" for powerpc64 style
use [back in early Jan.]:

# uname -apKU
FreeBSD FBSDG5L 12.0-CURRENT FreeBSD 12.0-CURRENT  r327364M  powerpc powerpc64 1200054 1200063

because buildkernel instalkernel for -r333575 results for
all the following fail in the same way:

A) devel/powerpc64-xtoolchain-gcc based build
   (from /usr/ports/ -r469767 so before the upgrade to 6.4)
B) gcc 4.2.1 based build
C) system clang6 based build

These were all amd64 -> powerpc64 cross builds. Each is a
non-debug build --but with symbols.

The following 3 lines are displayed and nothing more
visible happens after that in the boot sequence, the
lines are the ones that start with:

GDB: no debug ports present
KDB: debugger backends:
KDB: current backend:

It does not display any Copyright notice line or even
clear the screen.

The old -r327364 kernel boots the old PowerMac G5 "Quad Core"
just fine (with the -r333575 world at this point).

So far, this much suggests the issue is not toolchain related,
although in all 3 cases devel/powerpc64-binutils is in use
so it can not be eliminated as easily.

[A problem is I'm very restricted on the amount of time
I can be involved in bisecting this and 333575-327364==6211
for the version span. Another problem is that, at the failure
stage, getting information about failure details is
problematical on the old PowerMac, even if I could apply
the time for such.]


For powerpc64 context I have:

# more /usr/src/sys/powerpc/conf/GENERIC64vtsc-NODBG
#
# GENERIC -- Custom configuration for the powerpc/powerpc64
#

include "GENERIC64"

ident   GENERIC64vtsc-NODBG

makeoptions     DEBUG=-g                # Build kernel with gdb(1) debug symbols

nooptions       PS3                     # Sony Playstation 3               HACK!!! to allow sc

options         KDB                     # Enable kernel debugger support

options         ALT_BREAK_TO_DEBUGGER
options         BREAK_TO_DEBUGGER

# For minimum debugger support (stable branch) use:
options         KDB_TRACE               # Print a stack trace for a panic
options         DDB                     # Enable the kernel debugger
options         GDB                     # HACK!!! ...

# Extra stuff:
#options        VERBOSE_SYSINIT         # Enable verbose sysinit messages
#options        BOOTVERBOSE=1
#options        BOOTHOWTO=RB_VERBOSE
#options        KTR
#options        KTR_MASK=KTR_TRAP
##options       KTR_CPUMASK=0xF
#options        KTR_VERBOSE

# HACK!!! to allow sc for 2560x1440 display on Radeon X1950 that vt historically mishandled during booting
device          sc
#device                 kbdmux          # HACK: already listed by vt
options         SC_OFWFB        # OFW frame buffer
options         SC_DFLT_FONT    # compile font in
makeoptions     SC_DFLT_FONT=cp437


# Disable any extra checking for. . .
nooptions       DEADLKRES               # Enable the deadlock resolver
nooptions       INVARIANTS              # Enable calls of extra sanity checking
nooptions       INVARIANT_SUPPORT       # Extra sanity checks of internal structures, required by INVARIANTS
nooptions       WITNESS                 # Enable checks to detect deadlocks and cycles
nooptions       WITNESS_SKIPSPIN        # Don't run witness on spinlocks for speed
nooptions       DIAGNOSTIC
nooptions       MALLOC_DEBUG_MAXZONES   # Separate malloc(9) zones

device          filemon
device          geom_label



# svnlite diff /usr/src/contrib/llvm/lib/Target/PowerPC/PPCFrameLowering.cpp
Index: /usr/src/contrib/llvm/lib/Target/PowerPC/PPCFrameLowering.cpp
===================================================================
--- /usr/src/contrib/llvm/lib/Target/PowerPC/PPCFrameLowering.cpp       (revision 333575)
+++ /usr/src/contrib/llvm/lib/Target/PowerPC/PPCFrameLowering.cpp       (working copy)
@@ -1176,7 +1176,7 @@
       // For SVR4, don't emit a move for the CR spill slot if we haven't
       // spilled CRs.
       if (isSVR4ABI && (PPC::CR2 <= Reg && Reg <= PPC::CR4)
-          && !MustSaveCR)
+          && (!MustSaveCR && isPPC64))
         continue;

       // For 64-bit SVR4 when we have spilled CRs, the spill location



Note: The following file does not intend a powerpc64 functional change
but a powerpc (32-bit) change:

# svnlite diff /usr/src/sys/powerpc/ofw/ofw_machdep.c
Index: /usr/src/sys/powerpc/ofw/ofw_machdep.c
===================================================================
--- /usr/src/sys/powerpc/ofw/ofw_machdep.c      (revision 333575)
+++ /usr/src/sys/powerpc/ofw/ofw_machdep.c      (working copy)
@@ -116,26 +116,27 @@
         * Assume that interrupt are disabled at this point, or
         * SPRG1-3 could be trashed
         */
-#ifdef __powerpc64__
-       __asm __volatile("mtsprg1 %0\n\t"
-                        "mtsprg2 %1\n\t"
-                        "mtsprg3 %2\n\t"
-                        :
-                        : "r"(ofmsr[2]),
-                        "r"(ofmsr[3]),
-                        "r"(ofmsr[4]));
-#else
-       __asm __volatile("mfsprg0 %0\n\t"
-                        "mtsprg0 %1\n\t"
-                        "mtsprg1 %2\n\t"
-                        "mtsprg2 %3\n\t"
-                        "mtsprg3 %4\n\t"
-                        : "=&r"(ofw_sprg0_save)
-                        : "r"(ofmsr[1]),
-                        "r"(ofmsr[2]),
-                        "r"(ofmsr[3]),
-                        "r"(ofmsr[4]));
+#ifndef __powerpc64__
+       if (!(cpu_features & PPC_FEATURE_64))
+               __asm __volatile("mfsprg0 %0\n\t"
+                                "mtsprg0 %1\n\t"
+                                "mtsprg1 %2\n\t"
+                                "mtsprg2 %3\n\t"
+                                "mtsprg3 %4\n\t"
+                                : "=&r"(ofw_sprg0_save)
+                                : "r"(ofmsr[1]),
+                                "r"(ofmsr[2]),
+                                "r"(ofmsr[3]),
+                                "r"(ofmsr[4]));
+       else
 #endif
+               __asm __volatile("mtsprg1 %0\n\t"
+                                "mtsprg2 %1\n\t"
+                                "mtsprg3 %2\n\t"
+                                :
+                                : "r"(ofmsr[2]),
+                                "r"(ofmsr[3]),
+                                "r"(ofmsr[4]));
 }

 static __inline void
@@ -152,7 +153,8 @@
         * PCPU data cannot be used until this routine is called !
         */
 #ifndef __powerpc64__
-       __asm __volatile("mtsprg0 %0" :: "r"(ofw_sprg0_save));
+       if (!(cpu_features & PPC_FEATURE_64))
+               __asm __volatile("mtsprg0 %0" :: "r"(ofw_sprg0_save));
 #endif
 }
 #endif



Note: The following file's change is actually for
!defined(__powerpc64__) added code . . .

# svnlite diff /usr/src/sys/powerpc/aim/mmu_oea64.c
Index: /usr/src/sys/powerpc/aim/mmu_oea64.c
===================================================================
--- /usr/src/sys/powerpc/aim/mmu_oea64.c        (revision 333575)
+++ /usr/src/sys/powerpc/aim/mmu_oea64.c        (working copy)
@@ -1820,6 +1820,18 @@
        PV_PAGE_UNLOCK(m);
 }

+#if defined(AIM) && !defined(__powerpc64__)
+//
+// Part of PowerMac G5 HACK FOR PROBLEM FINDING. . .
+// (G5 used via 32-bit FreeBSD.)
+//
+
+extern char _GOT_START_[]; // beginning of .got/.got.plt
+extern char _GOT_END_[];   // ending    of .got/.got.plt
+
+extern vm_offset_t       __startkernel, __endkernel;
+#endif
+
 /*
  * Map a wired page into kernel virtual address space.
  */
@@ -1830,6 +1842,52 @@
        struct pvo_entry *pvo, *oldpvo;

        pvo = alloc_pvo_entry(0);
+#if defined(AIM) && !defined(__powerpc64__)
+       //
+       // PowerMac G5 HACK FOR PROBLEM FINDING. . .
+       // (G5 used via 32-bit FreeBSD.)
+       //
+       // As a problem-finding-aid try to catch some examples of
+       // jumping to non-code in the kernel before it tries to
+       // execute that that code. Hopefully this will show where
+       // the bad jump into the likes of the .hash section is
+       // happening. (dbb bt and vmcore.*'s have not lead to
+       // that information so far.)
+       //
+       if (cpu_features & PPC_FEATURE_64)
+       {
+               // First deal with pages that should have the original
+               // VM_PROT_EXECUTE status for something on the page
+               // (most pages in the kernel area). So pages with some
+               // byte(s) from .text, .got, or .got.plt, along with
+               // any requested from before where __startkernel
+               // indicates. Also any va requested from a page
+               // containing where __endkernel indicates or later
+               // gets VM_PROT_EXECUTE if such a va is requested.
+               //
+               // So: have just the rest of the kernel area not have
+               // VM_PROT_EXECUTE status in hopes that it will report
+               // where the code is that is making bad jumps to
+               // non-code, such as jumping into the .hash section
+               // instead of reporting on illegal instructions
+               // from the incorrect traget area.
+               //
+               if ( va < ((vm_offset_t)(etext+(PAGE_SIZE-1)) & ~PAGE_MASK) )
+                       pvo->pvo_pte.prot = VM_PROT_READ | VM_PROT_WRITE | VM_PROT_EXECUTE;
+
+               else if (  ((vm_offset_t)_GOT_START_ & ~PAGE_MASK) <= va
+                       && va < ((vm_offset_t)(_GOT_END_+(PAGE_SIZE-1)) & ~PAGE_MASK)
+                       )
+                       pvo->pvo_pte.prot = VM_PROT_READ | VM_PROT_WRITE | VM_PROT_EXECUTE;
+
+               else if ( va < (__endkernel & ~PAGE_MASK) )
+                       pvo->pvo_pte.prot = VM_PROT_READ | VM_PROT_WRITE;
+
+               else // Otherwise do as before the HACK:
+                       pvo->pvo_pte.prot = VM_PROT_READ | VM_PROT_WRITE | VM_PROT_EXECUTE;
+       }
+       else
+#endif
        pvo->pvo_pte.prot = VM_PROT_READ | VM_PROT_WRITE | VM_PROT_EXECUTE;
        pvo->pvo_pte.pa = (pa & ~ADDR_POFF) | moea64_calc_wimg(pa, ma);
        pvo->pvo_vaddr |= PVO_WIRED;



Note: The following should not matter because it is only for
devel/powerpc64-gcc but gcc 4.2.1 and system clang6 got the
same result:

# svnlite diff /usr/ports/devel/powerpc64-gcc/Makefile
Index: /usr/ports/devel/powerpc64-gcc/Makefile
===================================================================
--- /usr/ports/devel/powerpc64-gcc/Makefile     (revision 469767)
+++ /usr/ports/devel/powerpc64-gcc/Makefile     (working copy)
@@ -2,7 +2,7 @@

 PORTNAME=      gcc
 PORTVERSION=   6.3.0
-PORTREVISION=  5
+PORTREVISION=  6
 CATEGORIES=    devel
 MASTER_SITES=  GCC/releases/gcc-${DISTVERSION}
 PKGNAMEPREFIX?=        powerpc64-
@@ -42,6 +42,7 @@
 GNU_CONFIGURE= yes
 CONFIGURE_OUTSOURCE=   yes
 CONFIGURE_ARGS+=--target=${GCC_TARGET} --disable-nls --enable-languages=c,c++ \
+               --enable-gnu-indirect-function \
                --without-headers \
                --with-gmp=${LOCALBASE} \
                --with-pkgversion="FreeBSD Ports Collection for ${PKGNAMEPREFIX:C/-//g}" \
@@ -104,6 +105,6 @@

 # This port and all its slave ports fail on aarch64 -- but not all
 # the same way.  Provide this definition for the master.
-BROKEN_aarch64?=       fails to package
+#BROKEN_aarch64?=      fails to package

 .include <bsd.port.post.mk>


===
Mark Millard
marklmi26-fbsd at yahoo.com
( dsl-only.net went
away in early 2018-Mar)






_______________________________________________
[email protected] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-ppc
To unsubscribe, send any mail to "[email protected]"
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.