Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 26 Nov 2017 03:53:20 +0000 (UTC)
From:      Nathan Whitehorn <nwhitehorn@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r326220 - in head: . sys/powerpc/aim sys/powerpc/booke sys/powerpc/powerpc
Message-ID:  <201711260353.vAQ3rKDE006990@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: nwhitehorn
Date: Sun Nov 26 03:53:20 2017
New Revision: 326220
URL: https://svnweb.freebsd.org/changeset/base/326220

Log:
  Use the cookie now set by loader to determine whether the value passed to
  PowerPC kernels in r6 is actually metadata from loader(8) or gibberish
  left in r6, which is not required to be anything under the
  PAPR/ePAPR/CHRP/OF standards, by another boot loader.
  
  Note that, as a result, systems need a new boot loader to boot PPC kernels
  after this revision without ending up at a mountroot prompt. New boot
  loaders are backwards compatible and can boot older kernels.
  
  Reviewed by:	jhibbits
  MFC after:	2 months

Modified:
  head/UPDATING
  head/sys/powerpc/aim/locore32.S
  head/sys/powerpc/aim/locore64.S
  head/sys/powerpc/booke/booke_machdep.c
  head/sys/powerpc/powerpc/machdep.c

Modified: head/UPDATING
==============================================================================
--- head/UPDATING	Sun Nov 26 02:00:33 2017	(r326219)
+++ head/UPDATING	Sun Nov 26 03:53:20 2017	(r326220)
@@ -51,6 +51,14 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 12.x IS SLOW:
 
 ****************************** SPECIAL WARNING: ******************************
 
+20171125:
+	PowerPC users must update loader(8) by rebuilding world before
+	installing a new kernel, as the protocol connecting them has
+	changed. Without the update, loader metadata will not be passed
+	successfully to the kernel and users will have to enter their
+	root partition at the kernel mountroot prompt to continue booting.
+	Newer versions of loader can boot old kernels without issue.
+
 201711xx:
 	The LOADER_FIREWIRE_SUPPORT build variable as been renamed to
 	WITH/OUT_LOADER_FIREWIRE. LOADER_{NO_,}GELI_SUPPORT has been renamed

Modified: head/sys/powerpc/aim/locore32.S
==============================================================================
--- head/sys/powerpc/aim/locore32.S	Sun Nov 26 02:00:33 2017	(r326219)
+++ head/sys/powerpc/aim/locore32.S	Sun Nov 26 03:53:20 2017	(r326220)
@@ -79,13 +79,14 @@ __start:
 	/* Set up temporary stack pointer */
 	lwz	%r1,8(%r30)
 	add	%r1,%r1,%r30
-	addi	%r1,%r1,(8+TMPSTKSZ-32)
+	addi	%r1,%r1,(8+TMPSTKSZ-40)
 
 	/* Relocate self */
 	stw	%r3,16(%r1)
 	stw	%r4,20(%r1)
 	stw	%r5,24(%r1)
 	stw	%r6,28(%r1)
+	stw	%r7,32(%r1)
 
 	lwz	%r3,0(%r30) /* _DYNAMIC in %r3 */
 	add	%r3,%r3,%r30
@@ -99,6 +100,7 @@ __start:
 	lwz	%r4,20(%r1)
 	lwz	%r5,24(%r1)
 	lwz	%r6,28(%r1)
+	lwz	%r7,32(%r1)
 
 	/* MD setup */
 	bl	powerpc_init

Modified: head/sys/powerpc/aim/locore64.S
==============================================================================
--- head/sys/powerpc/aim/locore64.S	Sun Nov 26 02:00:33 2017	(r326219)
+++ head/sys/powerpc/aim/locore64.S	Sun Nov 26 03:53:20 2017	(r326220)
@@ -73,6 +73,7 @@ btext:
  * r4: ignored
  * r5: OF client interface pointer (or zero)
  * r6: Loader metadata pointer (or zero)
+ * r7: Magic cookie (0xfb5d104d) to indicate that r6 has loader metadata
  */
 	.text
 ASENTRY_NOPROF(__start)
@@ -108,6 +109,8 @@ ASENTRY_NOPROF(__start)
 	std	%r4,56(%r1)
 	std	%r5,64(%r1)
 	std	%r6,72(%r1)
+	std	%r7,80(%r1)
+
 	bl	1f
 	.llong _DYNAMIC-.
 1:	mflr	%r3
@@ -120,6 +123,7 @@ ASENTRY_NOPROF(__start)
 	ld	%r4,56(%r1)
 	ld	%r5,64(%r1)
 	ld	%r6,72(%r1)
+	ld	%r7,80(%r1)
 
 	/* Begin CPU init */
 	mr	%r4,%r2 /* Replace ignored r4 with tocbase for trap handlers */

Modified: head/sys/powerpc/booke/booke_machdep.c
==============================================================================
--- head/sys/powerpc/booke/booke_machdep.c	Sun Nov 26 02:00:33 2017	(r326219)
+++ head/sys/powerpc/booke/booke_machdep.c	Sun Nov 26 03:53:20 2017	(r326220)
@@ -200,7 +200,8 @@ extern void *int_performance_counter;
 	    ("Handler " #handler " too far from interrupt vector base")); \
 	mtspr(ivor, (uintptr_t)(&handler) & 0xffffUL);
 
-uintptr_t powerpc_init(vm_offset_t fdt, vm_offset_t, vm_offset_t, void *mdp);
+uintptr_t powerpc_init(vm_offset_t fdt, vm_offset_t, vm_offset_t, void *mdp,
+    vm_offset_t mdp_cookie);
 void booke_cpu_init(void);
 
 void
@@ -346,7 +347,11 @@ booke_init(u_long arg1, u_long arg2)
 		break;
 	}
 
-	ret = powerpc_init(dtbp, 0, 0, mdp);
+	/*
+	 * Last element is a magic cookie that indicates that the metadata
+	 * pointer is meaningful.
+	 */
+	ret = powerpc_init(dtbp, 0, 0, mdp, (mdp == NULL) ? 0 : 0xfb5d104d);
 
 	/* Enable caches */
 	booke_enable_l1_cache();

Modified: head/sys/powerpc/powerpc/machdep.c
==============================================================================
--- head/sys/powerpc/powerpc/machdep.c	Sun Nov 26 02:00:33 2017	(r326219)
+++ head/sys/powerpc/powerpc/machdep.c	Sun Nov 26 03:53:20 2017	(r326220)
@@ -154,7 +154,8 @@ SYSINIT(cpu, SI_SUB_CPU, SI_ORDER_FIRST, cpu_startup, 
 SYSCTL_INT(_machdep, CPU_CACHELINE, cacheline_size,
 	   CTLFLAG_RD, &cacheline_size, 0, "");
 
-uintptr_t	powerpc_init(vm_offset_t, vm_offset_t, vm_offset_t, void *);
+uintptr_t	powerpc_init(vm_offset_t, vm_offset_t, vm_offset_t, void *,
+		    vm_offset_t);
 
 long		Maxmem = 0;
 long		realmem = 0;
@@ -232,7 +233,8 @@ void aim_cpu_init(vm_offset_t toc);
 void booke_cpu_init(void);
 
 uintptr_t
-powerpc_init(vm_offset_t fdt, vm_offset_t toc, vm_offset_t ofentry, void *mdp)
+powerpc_init(vm_offset_t fdt, vm_offset_t toc, vm_offset_t ofentry, void *mdp,
+    vm_offset_t mdp_cookie)
 {
 	struct		pcpu *pc;
 	struct cpuref	bsp;
@@ -251,8 +253,11 @@ powerpc_init(vm_offset_t fdt, vm_offset_t toc, vm_offs
 	startkernel = __startkernel;
 	endkernel = __endkernel;
 
-	/* Check for ePAPR loader, which puts a magic value into r6 */
-	if (mdp == (void *)0x65504150)
+	/*
+	 * If the metadata pointer cookie is not set to the magic value,
+	 * the number in mdp should be treated as nonsense.
+	 */
+	if (mdp_cookie != 0xfb5d104d)
 		mdp = NULL;
 
 #ifdef AIM
@@ -352,7 +357,8 @@ powerpc_init(vm_offset_t fdt, vm_offset_t toc, vm_offs
 	platform_probe_and_attach();
 
 	/*
-	 * Set up real per-cpu data.
+	 * Set up per-cpu data for the BSP now that the platform can tell
+	 * us which that is.
 	 */
 	if (platform_smp_get_bsp(&bsp) != 0)
 		bsp.cr_cpuid = 0;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201711260353.vAQ3rKDE006990>