From owner-freebsd-ppc@freebsd.org Sun May 13 23:13:07 2018 Return-Path: Delivered-To: freebsd-ppc@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 80A29FD9540 for ; Sun, 13 May 2018 23:13:07 +0000 (UTC) (envelope-from marklmi26-fbsd@yahoo.com) Received: from sonic305-21.consmr.mail.gq1.yahoo.com (sonic305-21.consmr.mail.gq1.yahoo.com [98.137.64.84]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id E949D836A8 for ; Sun, 13 May 2018 23:13:06 +0000 (UTC) (envelope-from marklmi26-fbsd@yahoo.com) X-YMail-OSG: fkgWJ1sVM1m2TR9a.e2phHQFjC9vr1LLAS.3K_rnPQlnUC388i5fsDQF6q5eq7r DGPX9nRoB4OPkt1ZSE8Yg3lYlYCvDlcsMwO7y729GjIaMIxmpuc11gr5e5DDoO1imb3e_VaSU1vv 8txPV0Y3u23G6GpDU4FK.K8LlVfPv63dem9LWIohzIHn56Du_gm5GqzO5BU03h6cKUO6gMfLQZMp v8XUPcxoqpGQPhVfPS6PcTv3JzlZqZyQ3CZIl1dHDsIRmH0wCPcPlbMln.2lx5UeQl0EhDzn2tA4 nfVS1yQbwcRT6P42k85rI19RIyLefzibJT40w0EoUxIiBWEu4arw8KF.HgCgpocvkpuYXly6jvS4 1mcmdN.rbyhWPZG1gdGlMFdkSxG7LRTpL5XWvY1XGUzU0Vlq3C5nZZH_3MaROb6saIu_bmFgk.5_ DQV0TLdHc3Fx7WTsTixWSj82isPruDHToEepspsG9rBo3WgzSbvjj_5lGtvkmMqASQOFKf87xu_8 RC4ZH3xPULww8XGvieTTzXLbbjupCn6L8pCb3_JtVSCntOiHzEe8Rec9euOWxMxnFqAwvZPWR3In 4wcYlwyMnwwxM1dmhgBa_Cf3m68Y98lB6yt4loCGYLFugh3BihA-- Received: from sonic.gate.mail.ne1.yahoo.com by sonic305.consmr.mail.gq1.yahoo.com with HTTP; Sun, 13 May 2018 23:13:00 +0000 Received: from c-76-115-7-162.hsd1.or.comcast.net (EHLO [192.168.1.25]) ([76.115.7.162]) by smtp423.mail.gq1.yahoo.com (Oath Hermes SMTP Server) with ESMTPA ID 8fcb695bce434c34c10f6f97d63dc061 for ; Sun, 13 May 2018 23:12:59 +0000 (UTC) From: Mark Millard Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 11.3 \(3445.6.18\)) Subject: head -r333575's kernel: fails to boot old PowerMac G5 so-called "Quad Core", failing very early Message-Id: <94E173AD-74C0-43ED-9D0D-86D9A56C2A74@yahoo.com> Date: Sun, 13 May 2018 16:12:58 -0700 To: FreeBSD PowerPC ML X-Mailer: Apple Mail (2.3445.6.18) X-BeenThere: freebsd-ppc@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: Porting FreeBSD to the PowerPC List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 13 May 2018 23:13:07 -0000 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=3D=3D6211 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=3D-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=3D1 #options BOOTHOWTO=3DRB_VERBOSE #options KTR #options KTR_MASK=3DKTR_TRAP ##options KTR_CPUMASK=3D0xF #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=3Dcp437 # 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 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- /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 <=3D Reg && Reg <=3D 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 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- /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" - : "=3D&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" + : "=3D&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 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- /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 =3D 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 =3D VM_PROT_READ | = VM_PROT_WRITE | VM_PROT_EXECUTE; + + else if ( ((vm_offset_t)_GOT_START_ & ~PAGE_MASK) <=3D = va + && va < ((vm_offset_t)(_GOT_END_+(PAGE_SIZE-1)) = & ~PAGE_MASK) + ) + pvo->pvo_pte.prot =3D VM_PROT_READ | = VM_PROT_WRITE | VM_PROT_EXECUTE; + + else if ( va < (__endkernel & ~PAGE_MASK) ) + pvo->pvo_pte.prot =3D VM_PROT_READ | = VM_PROT_WRITE; + + else // Otherwise do as before the HACK: + pvo->pvo_pte.prot =3D VM_PROT_READ | = VM_PROT_WRITE | VM_PROT_EXECUTE; + } + else +#endif pvo->pvo_pte.prot =3D VM_PROT_READ | VM_PROT_WRITE | = VM_PROT_EXECUTE; pvo->pvo_pte.pa =3D (pa & ~ADDR_POFF) | moea64_calc_wimg(pa, = ma); pvo->pvo_vaddr |=3D 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 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- /usr/ports/devel/powerpc64-gcc/Makefile (revision 469767) +++ /usr/ports/devel/powerpc64-gcc/Makefile (working copy) @@ -2,7 +2,7 @@ PORTNAME=3D gcc PORTVERSION=3D 6.3.0 -PORTREVISION=3D 5 +PORTREVISION=3D 6 CATEGORIES=3D devel MASTER_SITES=3D GCC/releases/gcc-${DISTVERSION} PKGNAMEPREFIX?=3D powerpc64- @@ -42,6 +42,7 @@ GNU_CONFIGURE=3D yes CONFIGURE_OUTSOURCE=3D yes CONFIGURE_ARGS+=3D--target=3D${GCC_TARGET} --disable-nls = --enable-languages=3Dc,c++ \ + --enable-gnu-indirect-function \ --without-headers \ --with-gmp=3D${LOCALBASE} \ --with-pkgversion=3D"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?=3D fails to package +#BROKEN_aarch64?=3D fails to package .include =3D=3D=3D Mark Millard marklmi26-fbsd at yahoo.com ( dsl-only.net went away in early 2018-Mar)