linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Nicholas Piggin <npiggin@gmail.com>
To: linuxppc-dev@lists.ozlabs.org
Cc: Nicholas Piggin <npiggin@gmail.com>
Subject: [PATCH v2 1/4] powerpc: convert to copy_thread_tls
Date: Tue, 27 Aug 2019 23:55:45 +1000	[thread overview]
Message-ID: <20190827135548.21457-2-npiggin@gmail.com> (raw)
In-Reply-To: <20190827135548.21457-1-npiggin@gmail.com>

Commit 3033f14ab78c3 ("clone: support passing tls argument via C rather
than pt_regs magic") introduced the HAVE_COPY_THREAD_TLS option. Use it
to avoid a subtle assumption about the argument ordering of clone type
syscalls.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
No change since v1.

 arch/powerpc/Kconfig          | 1 +
 arch/powerpc/kernel/process.c | 9 +++++----
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index d8dcd8820369..7477a3263225 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -182,6 +182,7 @@ config PPC
 	select HAVE_STACKPROTECTOR		if PPC64 && $(cc-option,-mstack-protector-guard=tls -mstack-protector-guard-reg=r13)
 	select HAVE_STACKPROTECTOR		if PPC32 && $(cc-option,-mstack-protector-guard=tls -mstack-protector-guard-reg=r2)
 	select HAVE_CONTEXT_TRACKING		if PPC64
+	select HAVE_COPY_THREAD_TLS
 	select HAVE_DEBUG_KMEMLEAK
 	select HAVE_DEBUG_STACKOVERFLOW
 	select HAVE_DYNAMIC_FTRACE
diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
index 8fc4de0d22b4..24621e7e5033 100644
--- a/arch/powerpc/kernel/process.c
+++ b/arch/powerpc/kernel/process.c
@@ -1600,8 +1600,9 @@ static void setup_ksp_vsid(struct task_struct *p, unsigned long sp)
 /*
  * Copy architecture-specific thread state
  */
-int copy_thread(unsigned long clone_flags, unsigned long usp,
-		unsigned long kthread_arg, struct task_struct *p)
+int copy_thread_tls(unsigned long clone_flags, unsigned long usp,
+		unsigned long kthread_arg, struct task_struct *p,
+		unsigned long tls)
 {
 	struct pt_regs *childregs, *kregs;
 	extern void ret_from_fork(void);
@@ -1642,10 +1643,10 @@ int copy_thread(unsigned long clone_flags, unsigned long usp,
 		if (clone_flags & CLONE_SETTLS) {
 #ifdef CONFIG_PPC64
 			if (!is_32bit_task())
-				childregs->gpr[13] = childregs->gpr[6];
+				childregs->gpr[13] = tls;
 			else
 #endif
-				childregs->gpr[2] = childregs->gpr[6];
+				childregs->gpr[2] = tls;
 		}
 
 		f = ret_from_fork;
-- 
2.22.0


  reply	other threads:[~2019-08-27 14:06 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-27 13:55 [PATCH v2 0/4] powerpc/64: syscalls in C Nicholas Piggin
2019-08-27 13:55 ` Nicholas Piggin [this message]
2019-08-27 13:55 ` [PATCH v2 2/4] powerpc/64: remove support for kernel-mode syscalls Nicholas Piggin
2019-08-27 13:55 ` [PATCH v2 3/4] powerpc/64: system call remove non-volatile GPR save optimisation Nicholas Piggin
2019-08-28  9:02   ` Christophe Leroy
2019-08-28  9:32     ` Nicholas Piggin
2019-08-27 13:55 ` [PATCH v2 4/4] powerpc/64: system call implement the bulk of the logic in C Nicholas Piggin
2019-08-28  6:51   ` Christophe Leroy
2019-08-28  9:41     ` Nicholas Piggin
2019-08-28 15:30   ` Michal Suchánek
2019-08-28 22:19     ` Nicholas Piggin
2019-08-30 18:48   ` kbuild test robot
2019-08-30 20:04     ` Michal Suchánek
2019-09-02 10:20       ` Michael Ellerman
2019-08-28  9:06 ` [PATCH v2 0/4] powerpc/64: syscalls " Christophe Leroy
2019-08-28  9:49   ` Nicholas Piggin
2019-08-28  9:55     ` Christophe Leroy
2019-08-29  9:38       ` Nicholas Piggin
2019-08-29 10:45         ` Nicholas Piggin
2019-08-29 11:51         ` Segher Boessenkool
2019-08-29 15:49           ` Nicholas Piggin
2019-08-29 22:56             ` Nicholas Piggin

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=20190827135548.21457-2-npiggin@gmail.com \
    --to=npiggin@gmail.com \
    --cc=linuxppc-dev@lists.ozlabs.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;
as well as URLs for NNTP newsgroup(s).