linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] powerpc: Fix DSCR inheritance over fork()
@ 2015-12-09  9:11 Anton Blanchard
  2015-12-14  9:47 ` Michael Ellerman
  0 siblings, 1 reply; 2+ messages in thread
From: Anton Blanchard @ 2015-12-09  9:11 UTC (permalink / raw)
  To: mpe, benh, paulus, cyrilbur, scottwood, mikey, khandual; +Cc: linuxppc-dev

Two DSCR tests have a hack in them:

	/*
	 * XXX: Force a context switch out so that DSCR
	 * current value is copied into the thread struct
	 * which is required for the child to inherit the
	 * changed value.
	 */
	sleep(1);

We should not be working around this in the testcase, it is a kernel bug.
Fix it by copying the current DSCR to the child, instead of what we
had in the thread struct at last context switch.

Signed-off-by: Anton Blanchard <anton@samba.org>
---
 arch/powerpc/kernel/process.c                                 | 2 +-
 tools/testing/selftests/powerpc/dscr/dscr_inherit_exec_test.c | 8 --------
 tools/testing/selftests/powerpc/dscr/dscr_inherit_test.c      | 8 --------
 3 files changed, 1 insertion(+), 17 deletions(-)

diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
index ec10250..fffc2d2 100644
--- a/arch/powerpc/kernel/process.c
+++ b/arch/powerpc/kernel/process.c
@@ -1282,7 +1282,7 @@ int copy_thread(unsigned long clone_flags, unsigned long usp,
 #ifdef CONFIG_PPC64 
 	if (cpu_has_feature(CPU_FTR_DSCR)) {
 		p->thread.dscr_inherit = current->thread.dscr_inherit;
-		p->thread.dscr = current->thread.dscr;
+		p->thread.dscr = mfspr(SPRN_DSCR);
 	}
 	if (cpu_has_feature(CPU_FTR_HAS_PPR))
 		p->thread.ppr = INIT_PPR;
diff --git a/tools/testing/selftests/powerpc/dscr/dscr_inherit_exec_test.c b/tools/testing/selftests/powerpc/dscr/dscr_inherit_exec_test.c
index 8265504..08a8b95 100644
--- a/tools/testing/selftests/powerpc/dscr/dscr_inherit_exec_test.c
+++ b/tools/testing/selftests/powerpc/dscr/dscr_inherit_exec_test.c
@@ -60,14 +60,6 @@ int dscr_inherit_exec(void)
 		else
 			set_dscr(dscr);
 
-		/*
-		 * XXX: Force a context switch out so that DSCR
-		 * current value is copied into the thread struct
-		 * which is required for the child to inherit the
-		 * changed value.
-		 */
-		sleep(1);
-
 		pid = fork();
 		if (pid == -1) {
 			perror("fork() failed");
diff --git a/tools/testing/selftests/powerpc/dscr/dscr_inherit_test.c b/tools/testing/selftests/powerpc/dscr/dscr_inherit_test.c
index 4e414ca..3e5a6d1 100644
--- a/tools/testing/selftests/powerpc/dscr/dscr_inherit_test.c
+++ b/tools/testing/selftests/powerpc/dscr/dscr_inherit_test.c
@@ -40,14 +40,6 @@ int dscr_inherit(void)
 		else
 			set_dscr(dscr);
 
-		/*
-		 * XXX: Force a context switch out so that DSCR
-		 * current value is copied into the thread struct
-		 * which is required for the child to inherit the
-		 * changed value.
-		 */
-		sleep(1);
-
 		pid = fork();
 		if (pid == -1) {
 			perror("fork() failed");
-- 
2.5.0

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: powerpc: Fix DSCR inheritance over fork()
  2015-12-09  9:11 [PATCH] powerpc: Fix DSCR inheritance over fork() Anton Blanchard
@ 2015-12-14  9:47 ` Michael Ellerman
  0 siblings, 0 replies; 2+ messages in thread
From: Michael Ellerman @ 2015-12-14  9:47 UTC (permalink / raw)
  To: Anton Blanchard, benh, paulus, cyrilbur, scottwood, mikey, khandual
  Cc: linuxppc-dev

On Wed, 2015-09-12 at 09:11:47 UTC, Anton Blanchard wrote:
> Two DSCR tests have a hack in them:
> 
> 	/*
> 	 * XXX: Force a context switch out so that DSCR
> 	 * current value is copied into the thread struct
> 	 * which is required for the child to inherit the
> 	 * changed value.
> 	 */
> 	sleep(1);
> 
> We should not be working around this in the testcase, it is a kernel bug.
> Fix it by copying the current DSCR to the child, instead of what we
> had in the thread struct at last context switch.
> 
> Signed-off-by: Anton Blanchard <anton@samba.org>

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/db1231dcdb4dc6cdcbdef0ba

cheers

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-12-14  9:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-12-09  9:11 [PATCH] powerpc: Fix DSCR inheritance over fork() Anton Blanchard
2015-12-14  9:47 ` Michael Ellerman

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).