Subject: Re: [PATCH v2] powerpc/kexec: Switch to a static PACA on the way out

From: Michael Ellerman <[email-masked]>
Date: Fri, 23 Jul 2010 23:12:03 +1000

On Thu, 2010-07-08 at 17:55 +1000, Matt Evans wrote:
> With dynamic PACAs, the kexecing CPU's PACA won't lie within the kernel
> static data and there is a chance that something may stomp it when preparing
> to kexec.  This patch switches this final CPU to a static PACA just before
> we pull the switch.
> 
> Signed-off-by: Matt Evans <[email-masked]>
> ---
> v2:	Changes from Milton's review:
> 	- Use setup_paca() and move from setup_64.c,
> 	- SLB cache inval. not required,
> 	- Adjust 'paca' (oops..), and
> 	- Poison data_offset/per_cpu_offset
> 
>  arch/powerpc/include/asm/paca.h        |    2 +-
>  arch/powerpc/kernel/machine_kexec_64.c |   20 ++++++++++++++++++++
>  arch/powerpc/kernel/paca.c             |   10 ++++++++++
>  arch/powerpc/kernel/setup_64.c         |   10 ----------
>  4 files changed, 31 insertions(+), 11 deletions(-)
> 
> diff --git a/arch/powerpc/include/asm/paca.h b/arch/powerpc/include/asm/paca.h
> index 8ce7963..1ff6662 100644
> --- a/arch/powerpc/include/asm/paca.h
> +++ b/arch/powerpc/include/asm/paca.h
> @@ -146,7 +146,7 @@ struct paca_struct {
>  extern struct paca_struct *paca;
>  extern __initdata struct paca_struct boot_paca;
>  extern void initialise_paca(struct paca_struct *new_paca, int cpu);
> -
> +extern void setup_paca(struct paca_struct *new_paca);
>  extern void allocate_pacas(void);
>  extern void free_unused_pacas(void);
>  
> diff --git a/arch/powerpc/kernel/machine_kexec_64.c b/arch/powerpc/kernel/machine_kexec_64.c
> index 26f9900..c4d0123 100644
> --- a/arch/powerpc/kernel/machine_kexec_64.c
> +++ b/arch/powerpc/kernel/machine_kexec_64.c
> @@ -273,6 +273,12 @@ static void kexec_prepare_cpus(void)
>  static union thread_union kexec_stack __init_task_data =
>  	{ };
>  
> +/*
> + * For similar reasons to the stack above, the kexecing CPU needs to be on a
> + * static PACA; we switch to kexec_paca.
> + */
> +struct paca_struct kexec_paca;
> +

Hopelessly late probably but .. we could use boot_paca which already
exists and is static.

cheers