linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 2/8] Assume we're on cpu 0 in early boot
@ 2006-06-23  8:20 Michael Ellerman
  2006-06-23 10:03 ` Jimi Xenidis
  0 siblings, 1 reply; 6+ messages in thread
From: Michael Ellerman @ 2006-06-23  8:20 UTC (permalink / raw)
  To: Paul Mackerras; +Cc: linuxppc-dev, Arnd Bergmann

There's a small period early in boot where we don't know which cpu we're
running on. That's ok, except that it means we have no paca, or more
correctly that our paca pointer points somewhere random.

So that we can safely call things like smp_processor_id(), we need a paca,
so just assume we're on cpu 0. No code should _write_ to the paca before
we've set the correct one up.

Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
---

 arch/powerpc/kernel/head_64.S |   10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

Index: to-merge/arch/powerpc/kernel/head_64.S
===================================================================
--- to-merge.orig/arch/powerpc/kernel/head_64.S
+++ to-merge/arch/powerpc/kernel/head_64.S
@@ -1583,9 +1583,6 @@ _GLOBAL(__start_initialization_multiplat
 	/* Setup some critical 970 SPRs before switching MMU off */
 	bl	.__970_cpu_preinit
 
-	/* cpu # */
-	li	r24,0
-
 	/* Switch off MMU if not already */
 	LOAD_REG_IMMEDIATE(r4, .__after_prom_start - KERNELBASE)
 	add	r4,r4,r30
@@ -1908,6 +1905,13 @@ _STATIC(start_here_multiplatform)
 	bl	.__save_cpu_setup
 	sync
 
+	/* Assume we're on cpu for now, we don't actually know yet.
+	 * The early setup code should not write to any paca fields until
+	 * after we've setup the correct paca. See early_setup() */
+	li	r24,0
+	li	r3,0
+	bl	.setup_paca
+
 	/* Do very early kernel initializations, including initial hash table,
 	 * stab and slb setup before we turn on relocation.	*/
 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/8] Assume we're on cpu 0 in early boot
  2006-06-23  8:20 [PATCH 2/8] Assume we're on cpu 0 in early boot Michael Ellerman
@ 2006-06-23 10:03 ` Jimi Xenidis
  2006-06-27  4:00   ` [PATCH] " Michael Ellerman
  0 siblings, 1 reply; 6+ messages in thread
From: Jimi Xenidis @ 2006-06-23 10:03 UTC (permalink / raw)
  To: Michael Ellerman; +Cc: linuxppc-dev, Paul Mackerras, Arnd Bergmann


On Jun 23, 2006, at 4:20 AM, Michael Ellerman wrote:
> +	/* Assume we're on cpu for now, we don't actually know yet.

oops :( "Assume we're on cpu _0_ for now"
-JX

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH] Assume we're on cpu 0 in early boot
  2006-06-23 10:03 ` Jimi Xenidis
@ 2006-06-27  4:00   ` Michael Ellerman
  2006-06-28  1:42     ` Paul Mackerras
  0 siblings, 1 reply; 6+ messages in thread
From: Michael Ellerman @ 2006-06-27  4:00 UTC (permalink / raw)
  To: Paul Mackerras; +Cc: linuxppc-dev, Arnd Bergmann

There's a small period early in boot where we don't know which cpu we're
running on. That's ok, except that it means we have no paca, or more
correctly that our paca pointer points somewhere random.

So that we can safely call things like smp_processor_id(), we need a paca,
so just assume we're on cpu 0. No code should _write_ to the paca before
we've set the correct one up.

Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
---

 arch/powerpc/kernel/head_64.S |   10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

Index: to-merge/arch/powerpc/kernel/head_64.S
===================================================================
--- to-merge.orig/arch/powerpc/kernel/head_64.S
+++ to-merge/arch/powerpc/kernel/head_64.S
@@ -1583,9 +1583,6 @@ _GLOBAL(__start_initialization_multiplat
 	/* Setup some critical 970 SPRs before switching MMU off */
 	bl	.__970_cpu_preinit
 
-	/* cpu # */
-	li	r24,0
-
 	/* Switch off MMU if not already */
 	LOAD_REG_IMMEDIATE(r4, .__after_prom_start - KERNELBASE)
 	add	r4,r4,r30
@@ -1908,6 +1905,13 @@ _STATIC(start_here_multiplatform)
 	bl	.__save_cpu_setup
 	sync
 
+	/* Assume we're on cpu 0 for now, we don't actually know yet.
+	 * The early setup code should not write to any paca fields until
+	 * after we've setup the correct paca. See early_setup() */
+	li	r24,0
+	li	r3,0
+	bl	.setup_paca
+
 	/* Do very early kernel initializations, including initial hash table,
 	 * stab and slb setup before we turn on relocation.	*/
 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] Assume we're on cpu 0 in early boot
  2006-06-27  4:00   ` [PATCH] " Michael Ellerman
@ 2006-06-28  1:42     ` Paul Mackerras
  2006-06-28  2:11       ` Michael Ellerman
  2006-06-28  3:18       ` Michael Ellerman
  0 siblings, 2 replies; 6+ messages in thread
From: Paul Mackerras @ 2006-06-28  1:42 UTC (permalink / raw)
  To: Michael Ellerman; +Cc: linuxppc-dev, Arnd Bergmann

Michael Ellerman writes:

> There's a small period early in boot where we don't know which cpu we're
> running on. That's ok, except that it means we have no paca, or more
> correctly that our paca pointer points somewhere random.
> 
> So that we can safely call things like smp_processor_id(), we need a paca,
> so just assume we're on cpu 0. No code should _write_ to the paca before
> we've set the correct one up.

OK, but why not just do a setup_paca(0) at the start of early_setup(),
in C code?  You can also remove the redundant paca setting in
start_here_common() in head_64.S.

Paul.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] Assume we're on cpu 0 in early boot
  2006-06-28  1:42     ` Paul Mackerras
@ 2006-06-28  2:11       ` Michael Ellerman
  2006-06-28  3:18       ` Michael Ellerman
  1 sibling, 0 replies; 6+ messages in thread
From: Michael Ellerman @ 2006-06-28  2:11 UTC (permalink / raw)
  To: Paul Mackerras; +Cc: linuxppc-dev, Arnd Bergmann

[-- Attachment #1: Type: text/plain, Size: 945 bytes --]

On Wed, 2006-06-28 at 11:42 +1000, Paul Mackerras wrote:
> Michael Ellerman writes:
> 
> > There's a small period early in boot where we don't know which cpu we're
> > running on. That's ok, except that it means we have no paca, or more
> > correctly that our paca pointer points somewhere random.
> > 
> > So that we can safely call things like smp_processor_id(), we need a paca,
> > so just assume we're on cpu 0. No code should _write_ to the paca before
> > we've set the correct one up.
> 
> OK, but why not just do a setup_paca(0) at the start of early_setup(),
> in C code?  You can also remove the redundant paca setting in
> start_here_common() in head_64.S.

Yep, duh. New patch RSN.

cheers

-- 
Michael Ellerman
IBM OzLabs

wwweb: http://michael.ellerman.id.au
phone: +61 2 6212 1183 (tie line 70 21183)

We do not inherit the earth from our ancestors,
we borrow it from our children. - S.M.A.R.T Person

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 191 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH] Assume we're on cpu 0 in early boot
  2006-06-28  1:42     ` Paul Mackerras
  2006-06-28  2:11       ` Michael Ellerman
@ 2006-06-28  3:18       ` Michael Ellerman
  1 sibling, 0 replies; 6+ messages in thread
From: Michael Ellerman @ 2006-06-28  3:18 UTC (permalink / raw)
  To: Paul Mackerras; +Cc: linuxppc-dev, Arnd Bergmann

There's a small period early in boot where we don't know which cpu we're
running on. That's ok, except that it means we have no paca, or more
correctly that our paca pointer points somewhere random.

So that we can safely call things like smp_processor_id(), we need a paca,
so just assume we're on cpu 0. No code should _write_ to the paca before
we've set the correct one up.

We setup the proper paca after we've scanned the flat device tree in
early_setup(), so there's no need to do it again in start_here_common.

Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
---

 arch/powerpc/kernel/head_64.S  |   11 -----------
 arch/powerpc/kernel/setup_64.c |    3 +++
 2 files changed, 3 insertions(+), 11 deletions(-)

Index: to-merge/arch/powerpc/kernel/head_64.S
===================================================================
--- to-merge.orig/arch/powerpc/kernel/head_64.S
+++ to-merge/arch/powerpc/kernel/head_64.S
@@ -1602,9 +1602,6 @@ _GLOBAL(__start_initialization_multiplat
 	/* Setup some critical 970 SPRs before switching MMU off */
 	bl	.__970_cpu_preinit
 
-	/* cpu # */
-	li	r24,0
-
 	/* Switch off MMU if not already */
 	LOAD_REG_IMMEDIATE(r4, .__after_prom_start - KERNELBASE)
 	add	r4,r4,r30
@@ -1962,14 +1959,6 @@ _STATIC(start_here_common)
 	li	r3,0
 	bl	.do_cpu_ftr_fixups
 
-	LOAD_REG_IMMEDIATE(r26, boot_cpuid)
-	lwz	r26,0(r26)
-
-	LOAD_REG_IMMEDIATE(r24, paca)	/* Get base vaddr of paca array  */
-	mulli	r13,r26,PACA_SIZE	/* Calculate vaddr of right paca */
-	add	r13,r13,r24		/* for this processor.		 */
-	mtspr	SPRN_SPRG3,r13
-
 	/* ptr to current */
 	LOAD_REG_IMMEDIATE(r4, init_task)
 	std	r4,PACACURRENT(r13)
Index: to-merge/arch/powerpc/kernel/setup_64.c
===================================================================
--- to-merge.orig/arch/powerpc/kernel/setup_64.c
+++ to-merge/arch/powerpc/kernel/setup_64.c
@@ -177,6 +177,9 @@ void __init setup_paca(int cpu)
 
 void __init early_setup(unsigned long dt_ptr)
 {
+	/* Assume we're on cpu 0 for now. Don't write to the paca yet! */
+	setup_paca(0);
+
 	/* Enable early debugging if any specified (see udbg.h) */
 	udbg_early_init();
 

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2006-06-28  3:18 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-06-23  8:20 [PATCH 2/8] Assume we're on cpu 0 in early boot Michael Ellerman
2006-06-23 10:03 ` Jimi Xenidis
2006-06-27  4:00   ` [PATCH] " Michael Ellerman
2006-06-28  1:42     ` Paul Mackerras
2006-06-28  2:11       ` Michael Ellerman
2006-06-28  3:18       ` Michael Ellerman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).