[PATCH 9/12] ppc64: Misc fixups for non-zero KERNELBASE

Milton D. Miller II miltonm at realtime.net
Tue Aug 30 16:02:19 EST 2005


Michael Ellerman wrote:

> The code to do startup of secondary cpus assumes it only needs to load the low
> halfword of the __secondary_hold_* symbols. This won't work if we build the
> kernel at 32 MB.
>

No, the cpus are spinning on a copy of the code running below address 100
(or they should be).  The secondary_hold symbols sholuld be the ones in
this copy.

Doing this (and the 0x60 offset)is part of the kexec calling interface.

Using LOAD_ADDR makes the code less common with ppc(32) becasue it 
must do the relocate.

> The interrupt prolog code for pSeries assumes it can get the address of the
> interrupt handler by just loading the top and bottom halfwords of the address.
> This doesn't work if the kernel's linked too far above zero. We'd like to use
> SET_REG_TO_LABEL(), but we're short on space, so we simply augment the
> existing hack.
>

This is a dependent op on back-to-back operations.  We only need this for
PHYSICAL_START > 0x4000 or so.  Lets code that explictly into the macro
with a test for PHYSICAL_START > 0.

You took out the scheduling of putting independent ops between the
clear and the ori of the lower half.

This just cost the main kernel several wasted cycles.  (No, I didn't
sim this to count).


The third segment (moving the dest) is probably ok although does
have 3 unnecessary instructions.

milton

> Signed-off-by: Michael Ellerman <michael at ellerman.id.au>
> ---
>
>  arch/ppc64/kernel/head.S |   14 +++++++-------
>  1 files changed, 7 insertions(+), 7 deletions(-)
>
> Index: work/arch/ppc64/kernel/head.S
> ===================================================================
> --- work.orig/arch/ppc64/kernel/head.S
> +++ work/arch/ppc64/kernel/head.S
> @@ -143,13 +143,12 @@ _GLOBAL(__secondary_hold)
>  	mr	r24,r3
>  
>  	/* Tell the master cpu we're here */
> -	/* Relocation is off & we are located at an address less */
> -	/* than 0x100, so only need to grab low order offset.    */
> -	std	r24,__secondary_hold_acknowledge at l(0)
> +	LOADADDR(r4, __secondary_hold_acknowledge)
> +	std	r24,0(r4)
>  	sync
>  
>  	/* All secondary cpus wait here until told to start. */
> -100:	ld	r4,__secondary_hold_spinloop at l(0)
> +100:	LOADADDR(r4, __secondary_hold_spinloop)
>  	cmpdi	0,r4,1
>  	bne	100b
>  
> @@ -210,9 +209,10 @@ exception_marker:
>  	std	r9,area+EX_R13(r13);					\
>  	mfcr	r9;							\
>  	clrrdi	r12,r13,32;		/* get high part of &label */	\
> +	oris	r12,r12,(label)@h;	/* virt addr of handler ... */	\
> +	ori	r12,r12,(label)@l;	/* .. and the rest */		\
>  	mfmsr	r10;							\
>  	mfspr	r11,SRR0;		/* save SRR0 */			\
> -	ori	r12,r12,(label)@l;	/* virt addr of handler */	\
>  	ori	r10,r10,MSR_IR|MSR_DR|MSR_RI;				\
>  	mtspr	SRR0,r12;						\
>  	mfspr	r12,SRR1;		/* and SRR1 */			\
> @@ -1446,7 +1446,7 @@ _STATIC(__boot_from_prom)
>  _STATIC(__after_prom_start)
>  
>  /*
> - * We need to run with __start at physical address 0.
> + * We need to run with __start at physical address KERNELBASE.
>   * This will leave some code in the first 256B of
>   * real memory, which are reserved for software use.
>   * The remainder of the first page is loaded with the fixed
> @@ -1459,7 +1459,7 @@ _STATIC(__after_prom_start)
>   */
>  	SET_REG_TO_CONST(r27,KERNELBASE)
>  
> -	li	r3,0			/* target addr */
> +	LOADADDR(r3, PHYSICAL_START)	/* target addr */
>  
>  	mr	r4,r30			/* source, current addr of __start */
>  
>



More information about the Linuxppc64-dev mailing list