[PATCH v6 09/22] powerpc/exec: Set thread.regs early during exec
Christophe Leroy
christophe.leroy at csgroup.eu
Thu Nov 26 00:47:34 AEDT 2020
Le 25/11/2020 à 06:16, Aneesh Kumar K.V a écrit :
> In later patches during exec, we would like to access default regs.amr to
> control access to the user mapping. Having thread.regs set early makes the
> code changes simpler.
>
> Signed-off-by: Aneesh Kumar K.V <aneesh.kumar at linux.ibm.com>
> ---
> arch/powerpc/include/asm/thread_info.h | 2 --
> arch/powerpc/kernel/process.c | 37 +++++++++++++++++---------
> 2 files changed, 25 insertions(+), 14 deletions(-)
>
> diff --git a/arch/powerpc/include/asm/thread_info.h b/arch/powerpc/include/asm/thread_info.h
> index 46a210b03d2b..de4c911d9ced 100644
> --- a/arch/powerpc/include/asm/thread_info.h
> +++ b/arch/powerpc/include/asm/thread_info.h
> @@ -77,10 +77,8 @@ struct thread_info {
> /* how to get the thread information struct from C */
> extern int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src);
>
> -#ifdef CONFIG_PPC_BOOK3S_64
> void arch_setup_new_exec(void);
> #define arch_setup_new_exec arch_setup_new_exec
> -#endif
>
> #endif /* __ASSEMBLY__ */
>
> diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
> index d421a2c7f822..b6b8a845e454 100644
> --- a/arch/powerpc/kernel/process.c
> +++ b/arch/powerpc/kernel/process.c
> @@ -1530,10 +1530,32 @@ void flush_thread(void)
> #ifdef CONFIG_PPC_BOOK3S_64
> void arch_setup_new_exec(void)
> {
> - if (radix_enabled())
> - return;
> - hash__setup_new_exec();
> + if (!radix_enabled())
> + hash__setup_new_exec();
> +
> + /*
> + * If we exec out of a kernel thread then thread.regs will not be
> + * set. Do it now.
> + */
> + if (!current->thread.regs) {
> + struct pt_regs *regs = task_stack_page(current) + THREAD_SIZE;
> + current->thread.regs = regs - 1;
> + }
> +
> +}
> +#else
> +void arch_setup_new_exec(void)
> +{
> + /*
> + * If we exec out of a kernel thread then thread.regs will not be
> + * set. Do it now.
> + */
> + if (!current->thread.regs) {
> + struct pt_regs *regs = task_stack_page(current) + THREAD_SIZE;
> + current->thread.regs = regs - 1;
> + }
> }
> +
> #endif
No need to duplicate arch_setup_new_exec() I think. radix_enabled() is defined at all time so the
first function should be valid at all time.
>
> #ifdef CONFIG_PPC64
> @@ -1765,15 +1787,6 @@ void start_thread(struct pt_regs *regs, unsigned long start, unsigned long sp)
> preload_new_slb_context(start, sp);
> #endif
>
> - /*
> - * If we exec out of a kernel thread then thread.regs will not be
> - * set. Do it now.
> - */
> - if (!current->thread.regs) {
> - struct pt_regs *regs = task_stack_page(current) + THREAD_SIZE;
> - current->thread.regs = regs - 1;
> - }
> -
> #ifdef CONFIG_PPC_TRANSACTIONAL_MEM
> /*
> * Clear any transactional state, we're exec()ing. The cause is
>
More information about the Linuxppc-dev
mailing list