Thread (48 messages) 48 messages, 3 authors, 2021-10-11

Re: [PATCH v6 09/22] powerpc/exec: Set thread.regs early during exec

From: Aneesh Kumar K.V <hidden>
Date: 2020-11-26 07:39:53

Christophe Leroy [off-list ref] writes:
Le 25/11/2020 à 06:16, Aneesh Kumar K.V a écrit :
....
quoted hunk ↗ jump to hunk
+++ b/arch/powerpc/kernel/process.c
quoted
@@ -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.
arch/powerpc/kernel/process.c: In function ‘arch_setup_new_exec’:
arch/powerpc/kernel/process.c:1529:3: error: implicit declaration of function ‘hash__setup_new_exec’; did you mean ‘arch_setup_new_exec’? [-Werror=implicit-function-declaration]
 1529 |   hash__setup_new_exec();
      |   ^~~~~~~~~~~~~~~~~~~~
      |   arch_setup_new_exec


That requires us to have hash__setup_new_exec prototype for all platforms.

-aneesh
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help