From: Christophe Leroy <christophe.leroy@c-s.fr>
To: Michael Ellerman <mpe@ellerman.id.au>,
Benjamin Herrenschmidt <benh@kernel.crashing.org>,
Paul Mackerras <paulus@samba.org>
Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org
Subject: Re: [PATCH v5 3/9] powerpc: Prepare for moving thread_info into task_struct
Date: Sun, 7 Oct 2018 05:31:35 +0000 [thread overview]
Message-ID: <459532cd-5ae3-681e-2641-4833d3abb4a3@c-s.fr> (raw)
In-Reply-To: <87tvlzi6yq.fsf@concordia.ellerman.id.au>
On 10/06/2018 12:40 PM, Michael Ellerman wrote:
> Christophe Leroy <christophe.leroy@c-s.fr> writes:
>
>> diff --git a/arch/powerpc/include/asm/livepatch.h b/arch/powerpc/include/asm/livepatch.h
>> index 47a03b9b528b..818451bf629c 100644
>> --- a/arch/powerpc/include/asm/livepatch.h
>> +++ b/arch/powerpc/include/asm/livepatch.h
>> @@ -49,7 +49,7 @@ static inline void klp_init_thread_info(struct thread_info *ti)
>> ti->livepatch_sp = (unsigned long *)(ti + 1) + 1;
>
> We need to do something about this.
Oops I missed that one.
>
> Currently the thread_info sits at the low address of the stack, and we
> use the space immediately above that as a miniature upward growing stack
> for livepatching.
>
> If we keep the livepatch_sp in the thread_info then we need to
> initialise it somewhere when the task starts running on a stack. And I
> don't know how that works if we end up running on the emergency stack
> for example.
>
> So I'm not sure that makes much sense.
>
> Instead we might need to keep the livepatch_sp on the stack page at the
> base, where thread_info currently lives.
>
> That obviously sucks because you can still overflow into it and trash
> it, but it's no worse than what we have now for livepatching.
>
> Need to think about it some more.
>
I think for that serie we can leave with it in the stack, as it won't be
worst than before. Then in a future patch we can change it. I'll open an
issue for that on github.
Then for now, I'll add the following change in this patch.
diff --git a/arch/powerpc/include/asm/livepatch.h
b/arch/powerpc/include/asm/livepatch.h
index 47a03b9b528b..8a81d10ccc82 100644
--- a/arch/powerpc/include/asm/livepatch.h
+++ b/arch/powerpc/include/asm/livepatch.h
@@ -43,13 +43,14 @@ static inline unsigned long
klp_get_ftrace_location(unsigned long faddr)
return ftrace_location_range(faddr, faddr + 16);
}
-static inline void klp_init_thread_info(struct thread_info *ti)
+static inline void klp_init_thread_info(struct task_struct *p)
{
+ struct thread_info *ti = task_thread_info(p);
/* + 1 to account for STACK_END_MAGIC */
- ti->livepatch_sp = (unsigned long *)(ti + 1) + 1;
+ ti->livepatch_sp = end_of_stack(p) + 1;
}
#else
-static void klp_init_thread_info(struct thread_info *ti) { }
+static inline void klp_init_thread_info(struct task_struct *p) { }
#endif /* CONFIG_LIVEPATCH */
#endif /* _ASM_POWERPC_LIVEPATCH_H */
diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
index d9d4eb2ea6c9..a12307ebb7ef 100644
--- a/arch/powerpc/kernel/process.c
+++ b/arch/powerpc/kernel/process.c
@@ -1632,7 +1632,7 @@ int copy_thread(unsigned long clone_flags,
unsigned long usp,
unsigned long sp = (unsigned long)task_stack_page(p) + THREAD_SIZE;
struct thread_info *ti = task_thread_info(p);
- klp_init_thread_info(ti);
+ klp_init_thread_info(p);
/* Copy registers */
sp -= sizeof(struct pt_regs);
diff --git a/arch/powerpc/kernel/setup-common.c
b/arch/powerpc/kernel/setup-common.c
index 9ca9db707bcb..8054a7b9e026 100644
--- a/arch/powerpc/kernel/setup-common.c
+++ b/arch/powerpc/kernel/setup-common.c
@@ -940,7 +940,7 @@ void __init setup_arch(char **cmdline_p)
/* Reserve large chunks of memory for use by CMA for KVM. */
kvm_cma_reserve();
- klp_init_thread_info(&init_thread_info);
+ klp_init_thread_info(&init_task);
init_mm.start_code = (unsigned long)_stext;
init_mm.end_code = (unsigned long) _etext;
Christophe
next prev parent reply other threads:[~2018-10-07 16:37 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-05 7:32 [PATCH v5 0/9] powerpc: Switch to CONFIG_THREAD_INFO_IN_TASK Christophe Leroy
2018-10-05 7:32 ` [PATCH v5 1/9] book3s/64: avoid circular header inclusion in mmu-hash.h Christophe Leroy
2018-10-05 13:45 ` Christophe LEROY
2018-10-06 12:47 ` Michael Ellerman
2018-10-07 16:43 ` Christophe LEROY
2018-10-05 7:32 ` [PATCH v5 2/9] powerpc: Only use task_struct 'cpu' field on SMP Christophe Leroy
2018-10-05 7:32 ` [PATCH v5 3/9] powerpc: Prepare for moving thread_info into task_struct Christophe Leroy
2018-10-06 12:40 ` Michael Ellerman
2018-10-07 5:31 ` Christophe Leroy [this message]
2018-10-05 7:32 ` [PATCH v5 4/9] powerpc: Activate CONFIG_THREAD_INFO_IN_TASK Christophe Leroy
2018-10-05 7:32 ` [PATCH v5 5/9] powerpc: regain entire stack space Christophe Leroy
2018-10-05 7:32 ` [PATCH v5 6/9] powerpc: 'current_set' is now a table of task_struct pointers Christophe Leroy
2018-10-05 7:32 ` [PATCH v5 7/9] powerpc/32: Remove CURRENT_THREAD_INFO and rename TI_CPU Christophe Leroy
2018-10-05 7:32 ` [PATCH v5 8/9] powerpc/64: Remove CURRENT_THREAD_INFO Christophe Leroy
2018-10-05 7:32 ` [PATCH v5 9/9] powerpc: clean stack pointers naming Christophe Leroy
[not found] ` <87pnwk1yw4.fsf@concordia.ellerman.id.au>
2018-10-08 13:30 ` [PATCH v5 0/9] powerpc: Switch to CONFIG_THREAD_INFO_IN_TASK Christophe Leroy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=459532cd-5ae3-681e-2641-4833d3abb4a3@c-s.fr \
--to=christophe.leroy@c-s.fr \
--cc=benh@kernel.crashing.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mpe@ellerman.id.au \
--cc=paulus@samba.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®